Client: Fix keyboard focus logic and crash
The previous solution did not check for nullptr before dereferencing, which caused a crash. Furthermore, it checked the new ShellSurface's shellManagesActiveState before deciding whether to unfocus the old one. Task-number: QTBUG-55526 Change-Id: I410b6200a5b7b86806f70970730045a4a25f21db Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
895b46e394
commit
01234b85f8
@ -399,13 +399,16 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
|
|||||||
{
|
{
|
||||||
QWaylandWindow *keyboardFocus = inputDevice->keyboardFocus();
|
QWaylandWindow *keyboardFocus = inputDevice->keyboardFocus();
|
||||||
|
|
||||||
if (!keyboardFocus->shellSurface()->shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) {
|
if (mLastKeyboardFocus == keyboardFocus)
|
||||||
if (keyboardFocus)
|
return;
|
||||||
handleWindowActivated(keyboardFocus);
|
|
||||||
if (mLastKeyboardFocus)
|
if (keyboardFocus && !keyboardFocus->shellManagesActiveState())
|
||||||
handleWindowDeactivated(mLastKeyboardFocus);
|
handleWindowActivated(keyboardFocus);
|
||||||
}
|
|
||||||
mLastKeyboardFocus = inputDevice->keyboardFocus();
|
if (mLastKeyboardFocus && !mLastKeyboardFocus->shellManagesActiveState())
|
||||||
|
handleWindowDeactivated(mLastKeyboardFocus);
|
||||||
|
|
||||||
|
mLastKeyboardFocus = keyboardFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandDisplay::handleWaylandSync()
|
void QWaylandDisplay::handleWaylandSync()
|
||||||
|
@ -500,6 +500,11 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const
|
|||||||
return mSubSurfaceWindow;
|
return mSubSurfaceWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWaylandWindow::shellManagesActiveState() const
|
||||||
|
{
|
||||||
|
return mShellSurface && mShellSurface->shellManagesActiveState();
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
|
void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
|
||||||
{
|
{
|
||||||
if (mDisplay->compositorVersion() < 2)
|
if (mDisplay->compositorVersion() < 2)
|
||||||
|
@ -136,6 +136,8 @@ public:
|
|||||||
QWaylandSubSurface *subSurfaceWindow() const;
|
QWaylandSubSurface *subSurfaceWindow() const;
|
||||||
QWaylandScreen *screen() const { return mScreen; }
|
QWaylandScreen *screen() const { return mScreen; }
|
||||||
|
|
||||||
|
bool shellManagesActiveState() const;
|
||||||
|
|
||||||
void handleContentOrientationChange(Qt::ScreenOrientation orientation) Q_DECL_OVERRIDE;
|
void handleContentOrientationChange(Qt::ScreenOrientation orientation) Q_DECL_OVERRIDE;
|
||||||
void setOrientationMask(Qt::ScreenOrientations mask);
|
void setOrientationMask(Qt::ScreenOrientations mask);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user