From a2c5f5abff3cafc5769588b573bb04cf950a0450 Mon Sep 17 00:00:00 2001 From: Elvis Lee Date: Wed, 21 Aug 2019 20:44:57 +0900 Subject: 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 --- src/quick/items/qquickwindow.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/quick') 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; } -- cgit v1.2.3