146 lines
5.0 KiB
Diff
146 lines
5.0 KiB
Diff
From 1b797d6e15ece7f87af2d86be4ad19f885619285 Mon Sep 17 00:00:00 2001
|
|
From: root <root@localhost.localdomain>
|
|
Date: Wed, 26 Oct 2022 13:43:00 +0800
|
|
Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A1=8C=E9=9D=A2=E6=96=87=E4=BB=B6?=
|
|
=?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E7=84=A6=E7=82=B9=E4=B8=A2=E5=A4=B1?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
bugfix for BUG165587 BUG165577 BUG165563
|
|
---
|
|
xcb/windoweventhook.cpp | 88 +----------------------------------------
|
|
xcb/windoweventhook.h | 3 --
|
|
2 files changed, 2 insertions(+), 89 deletions(-)
|
|
|
|
diff --git a/xcb/windoweventhook.cpp b/xcb/windoweventhook.cpp
|
|
index 4c4bd78..8543a1f 100644
|
|
--- a/xcb/windoweventhook.cpp
|
|
+++ b/xcb/windoweventhook.cpp
|
|
@@ -326,21 +326,6 @@ void WindowEventHook::handleClientMessageEvent(QXcbWindow *window, const xcb_cli
|
|
}
|
|
}
|
|
|
|
-bool WindowEventHook::relayFocusToModalWindow(QWindow *w, QXcbConnection *connection)
|
|
-{
|
|
- QWindow *modal_window = 0;
|
|
- if (QGuiApplicationPrivate::instance()->isWindowBlocked(w,&modal_window) && modal_window != w) {
|
|
- if (!modal_window->isExposed())
|
|
- return false;
|
|
-
|
|
- modal_window->requestActivate();
|
|
- connection->flush();
|
|
- return true;
|
|
- }
|
|
-
|
|
- return false;
|
|
-}
|
|
-
|
|
void WindowEventHook::handleFocusInEvent(QXcbWindow *window, const xcb_focus_in_event_t *event)
|
|
{
|
|
// Ignore focus events that are being sent only because the pointer is over
|
|
@@ -357,63 +342,7 @@ void WindowEventHook::handleFocusInEvent(QXcbWindow *window, const xcb_focus_in_
|
|
return;
|
|
}
|
|
|
|
- if (relayFocusToModalWindow(w, window->connection()))
|
|
- return;
|
|
-
|
|
-#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
|
- window->connection()->focusInTimer().stop();
|
|
-#endif
|
|
-
|
|
-#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
|
|
- window->connection()->setFocusWindow(w);
|
|
-#else
|
|
- window->connection()->setFocusWindow(static_cast<QXcbWindow *>(w->handle()));
|
|
-#endif
|
|
-
|
|
- QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
|
-}
|
|
-
|
|
-enum QX11EmbedMessageType {
|
|
- XEMBED_EMBEDDED_NOTIFY = 0,
|
|
- XEMBED_WINDOW_ACTIVATE = 1,
|
|
- XEMBED_WINDOW_DEACTIVATE = 2,
|
|
- XEMBED_REQUEST_FOCUS = 3,
|
|
- XEMBED_FOCUS_IN = 4,
|
|
- XEMBED_FOCUS_OUT = 5,
|
|
- XEMBED_FOCUS_NEXT = 6,
|
|
- XEMBED_FOCUS_PREV = 7,
|
|
- XEMBED_MODALITY_ON = 10,
|
|
- XEMBED_MODALITY_OFF = 11,
|
|
- XEMBED_REGISTER_ACCELERATOR = 12,
|
|
- XEMBED_UNREGISTER_ACCELERATOR = 13,
|
|
- XEMBED_ACTIVATE_ACCELERATOR = 14
|
|
-};
|
|
-
|
|
-static bool focusInPeeker(QXcbConnection *connection, xcb_generic_event_t *event)
|
|
-{
|
|
- if (!event) {
|
|
- // FocusIn event is not in the queue, proceed with FocusOut normally.
|
|
- QWindowSystemInterface::handleWindowActivated(0, Qt::ActiveWindowFocusReason);
|
|
- return true;
|
|
- }
|
|
- uint response_type = event->response_type & ~0x80;
|
|
- if (response_type == XCB_FOCUS_IN) {
|
|
- // Ignore focus events that are being sent only because the pointer is over
|
|
- // our window, even if the input focus is in a different window.
|
|
- xcb_focus_in_event_t *e = (xcb_focus_in_event_t *) event;
|
|
- if (e->detail != XCB_NOTIFY_DETAIL_POINTER)
|
|
- return true;
|
|
- }
|
|
-
|
|
- /* We are also interested in XEMBED_FOCUS_IN events */
|
|
- if (response_type == XCB_CLIENT_MESSAGE) {
|
|
- xcb_client_message_event_t *cme = (xcb_client_message_event_t *)event;
|
|
- if (cme->type == connection->atom(QXcbAtom::_XEMBED)
|
|
- && cme->data.data32[1] == XEMBED_FOCUS_IN)
|
|
- return true;
|
|
- }
|
|
-
|
|
- return false;
|
|
+ VtableHook::callOriginalFun(window, &QXcbWindow::handleFocusInEvent, event);
|
|
}
|
|
|
|
void WindowEventHook::handleFocusOutEvent(QXcbWindow *window, const xcb_focus_out_event_t *event)
|
|
@@ -428,20 +357,7 @@ void WindowEventHook::handleFocusOutEvent(QXcbWindow *window, const xcb_focus_ou
|
|
if (event->detail == XCB_NOTIFY_DETAIL_POINTER)
|
|
return;
|
|
|
|
- QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window->window()))->eventReceiver();
|
|
-
|
|
- if (relayFocusToModalWindow(w, window->connection()))
|
|
- return;
|
|
-
|
|
- window->connection()->setFocusWindow(0);
|
|
- // Do not set the active window to 0 if there is a FocusIn coming.
|
|
- // There is however no equivalent for XPutBackEvent so register a
|
|
- // callback for QXcbConnection instead.
|
|
-#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
|
- window->connection()->focusInTimer().start(100);
|
|
-#else
|
|
- window->connection()->addPeekFunc(focusInPeeker);
|
|
-#endif
|
|
+ VtableHook::callOriginalFun(window, &QXcbWindow::handleFocusOutEvent, event);
|
|
}
|
|
|
|
void WindowEventHook::handlePropertyNotifyEvent(QXcbWindowEventListener *el, const xcb_property_notify_event_t *event)
|
|
diff --git a/xcb/windoweventhook.h b/xcb/windoweventhook.h
|
|
index 308d30a..83a3939 100644
|
|
--- a/xcb/windoweventhook.h
|
|
+++ b/xcb/windoweventhook.h
|
|
@@ -44,9 +44,6 @@ public:
|
|
#else
|
|
static bool windowEvent(QXcbWindow *window, QEvent *event);
|
|
#endif
|
|
-
|
|
-private:
|
|
- static bool relayFocusToModalWindow(QWindow *w, QXcbConnection *connection);
|
|
};
|
|
|
|
DPP_END_NAMESPACE
|
|
--
|
|
2.27.0
|
|
|