From 21a89dd6e1aed60a3dc8cc20009174ea0a6a6f1e Mon Sep 17 00:00:00 2001 From: Konrad Materka Date: Thu, 19 Dec 2019 13:45:29 +0100 Subject: [PATCH] [XembedSNIProxy] Regression - really resize instead of notifying only. Summary: Regression introduced in previous commit, review D25777. Tray icons should have an ability to resize. If not, icons smaller than 32x32 will render incorectly. In addition, do not notify using xcb_configure_notify_event_t, in some cases (Wine) it messes up the event handling. BUG: 414667 FIXED-IN: 5.18.0 Test Plan: Tested with keepass2, keepassx, pidgin, xchat, hexchat, tuxguitar, liferea, wine tflash.exe, workrave, stardict Reviewers: #plasma_workspaces, #plasma, davidedmundson Reviewed By: #plasma_workspaces, #plasma, davidedmundson Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D26088 --- xembed-sni-proxy/fdoselectionmanager.cpp | 6 +++-- xembed-sni-proxy/sniproxy.cpp | 31 ++++++++++-------------- xembed-sni-proxy/sniproxy.h | 2 +- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/xembed-sni-proxy/fdoselectionmanager.cpp b/xembed-sni-proxy/fdoselectionmanager.cpp index faf2ef2da..4b71d7ea7 100644 --- a/xembed-sni-proxy/fdoselectionmanager.cpp +++ b/xembed-sni-proxy/fdoselectionmanager.cpp @@ -158,8 +158,10 @@ bool FdoSelectionManager::nativeEventFilter(const QByteArray &eventType, void *m const auto event = reinterpret_cast(ev); const auto sniProxy = m_proxies.value(event->window); if (sniProxy) { - // The embedded window tries to move or resize. Ignore this request and send the current configuration. - sniProxy->sendConfigureNotification(); + // The embedded window tries to move or resize. Ignore move, handle resize only. + if ((event->value_mask & XCB_CONFIG_WINDOW_WIDTH) || (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT)) { + sniProxy->resizeWindow(event->width, event->height); + } } } diff --git a/xembed-sni-proxy/sniproxy.cpp b/xembed-sni-proxy/sniproxy.cpp index 96c480d18..da9122c57 100644 --- a/xembed-sni-proxy/sniproxy.cpp +++ b/xembed-sni-proxy/sniproxy.cpp @@ -20,6 +20,7 @@ #include "sniproxy.h" +#include #include #include #include @@ -223,20 +224,19 @@ void SNIProxy::stackContainerWindow(const uint32_t stackMode) const xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_STACK_MODE, stackData); } -void SNIProxy::sendConfigureNotification() const +void SNIProxy::resizeWindow(const uint16_t width, const uint16_t height) const { - xcb_configure_notify_event_t event; - memset(&event, 0x00, sizeof(xcb_configure_notify_event_t)); - event.response_type = XCB_CONFIGURE_NOTIFY; - event.event = m_windowId; - event.window = m_windowId; - event.x = 0; - event.y = 0; - event.width = s_embedSize; - event.height = s_embedSize; - auto connection = QX11Info::connection(); - xcb_send_event(connection, false, m_windowId, XCB_EVENT_MASK_STRUCTURE_NOTIFY, reinterpret_cast(&event)); + + uint16_t widthNormalized = std::min(width, s_embedSize); + uint16_t heighNormalized = std::min(height, s_embedSize); + + const uint32_t windowSizeConfigVals[2] = { widthNormalized, heighNormalized }; + xcb_configure_window(connection, m_windowId, + XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, + windowSizeConfigVals); + + xcb_flush(connection); } QSize SNIProxy::calculateClientWindowSize() const @@ -258,12 +258,7 @@ QSize SNIProxy::calculateClientWindowSize() const if (clientWindowSize.isEmpty() || clientWindowSize.width() > s_embedSize || clientWindowSize.height() > s_embedSize) { qCDebug(SNIPROXY) << "Resizing window" << m_windowId << Title() << "from w*h" << clientWindowSize; - sendConfigureNotification(); - - const uint32_t windowSizeConfigVals[2] = { s_embedSize, s_embedSize }; - xcb_configure_window(c, m_windowId, - XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, - windowSizeConfigVals); + resizeWindow(s_embedSize, s_embedSize); clientWindowSize = QSize(s_embedSize, s_embedSize); } diff --git a/xembed-sni-proxy/sniproxy.h b/xembed-sni-proxy/sniproxy.h index 408c2f3c0..d4550404c 100644 --- a/xembed-sni-proxy/sniproxy.h +++ b/xembed-sni-proxy/sniproxy.h @@ -50,7 +50,7 @@ public: void update(); void stackContainerWindow(const uint32_t stackMode) const; - void sendConfigureNotification() const; + void resizeWindow(const uint16_t width, const uint16_t height) const; /** * @return the category of the application associated to this item