diff options
author | Elvis Lee <kwangwoong.lee@lge.com> | 2019-08-21 20:44:57 +0900 |
---|---|---|
committer | Risto Avila <risto.avila@qt.io> | 2020-09-14 09:15:04 +0300 |
commit | a2c5f5abff3cafc5769588b573bb04cf950a0450 (patch) | |
tree | 04782cd5ba3395b0de6008e71075d2d91d699730 /src/quick/items/qquickwindow.cpp | |
parent | a99fc26faa21eca7921016ef7b399a2877a0652c (diff) |
webOS: Allow to have activeFocus for each window
This makes multiple windows focused if there is a single window per
screen assuming that windows across screens don't compete the keyboard
focus.
Pick-to: 5.15
Task-number: QTBUG-83361
Change-Id: Id6f6fd0c95747b03d56c5e535f1313c27d67ab24
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index d6e0ca15cd..f976095ee1 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1149,6 +1149,23 @@ static inline bool windowHasFocus(QQuickWindow *win) return win == focusWindow || QQuickRenderControl::renderWindowFor(win) == focusWindow; } +#ifdef Q_OS_WEBOS +// Temporary fix for webOS until multi-seat is implemented see QTBUG-85272 +static inline bool singleWindowOnScreen(QQuickWindow *win) +{ + const QWindowList windowList = QGuiApplication::allWindows(); + for (int i = 0; i < windowList.count(); i++) { + QWindow *ii = windowList.at(i); + if (ii == win) + continue; + if (ii->screen() == win->screen()) + return false; + } + + return true; +} +#endif + /*! Set the focus inside \a scope to be \a item. If the scope contains the active focus item, it will be changed to \a item. @@ -1223,7 +1240,14 @@ void QQuickWindowPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, Q } if (!(options & DontChangeFocusProperty)) { - if (item != contentItem || windowHasFocus(q)) { + if (item != contentItem + || windowHasFocus(q) +#ifdef Q_OS_WEBOS + // Allow focused if there is only one window in the screen where it belongs. + // Temporary fix for webOS until multi-seat is implemented see QTBUG-85272 + || singleWindowOnScreen(q) +#endif + ) { itemPrivate->focus = true; changed << item; } |