From 68ac8bdea3308997adc35ee7fdd09639356b0573 Mon Sep 17 00:00:00 2001 From: Mike Chen Date: Fri, 15 Sep 2023 09:10:41 +0800 Subject: [PATCH] xcb: unset states and set new ones as need Should not unset all the old state and set the new ones. Only unset the state that needs to be unset. If states changes from maximized to minimized, there is no need to unset the maximized state and set the maximized states again. (minimized and maximized can exist simultaneously :) This amends f61b140482d9578c07410a5979379e44e05352e5 . Pick-to: 6.5 6.2 Change-Id: Ic93122b92fafcdba973b885e299b282408da7a1c Reviewed-by: Liang Qi (cherry picked from commit 9161f66a496c7e6043e0670286f64d6fd95472c8) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/xcb/qxcbwindow.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 19e02560995..3fcc605bfee 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1129,18 +1129,21 @@ void QXcbWindow::setWindowState(Qt::WindowStates state) if (state == m_windowState) return; + Qt::WindowStates unsetState = m_windowState & ~state; + Qt::WindowStates newState = state & ~m_windowState; + // unset old state - if (m_windowState & Qt::WindowMinimized) + if (unsetState & Qt::WindowMinimized) xcb_map_window(xcb_connection(), m_window); - if (m_windowState & Qt::WindowMaximized) + if (unsetState & Qt::WindowMaximized) setNetWmState(false, atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ), atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)); - if (m_windowState & Qt::WindowFullScreen) + if (unsetState & Qt::WindowFullScreen) setNetWmState(false, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN)); // set new state - if (state & Qt::WindowMinimized) { + if (newState & Qt::WindowMinimized) { { xcb_client_message_event_t event; @@ -1161,13 +1164,8 @@ void QXcbWindow::setWindowState(Qt::WindowStates state) } m_minimized = true; } - if (state & Qt::WindowMaximized) - setNetWmState(true, - atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ), - atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)); - if (state & Qt::WindowFullScreen) - setNetWmState(true, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN)); + // set Maximized && FullScreen state if need setNetWmState(state); xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(xcb_connection(), m_window);