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 <liang.qi@qt.io>
(cherry picked from commit 9161f66a496c7e6043e0670286f64d6fd95472c8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mike Chen 2023-09-15 09:10:41 +08:00 committed by Qt Cherry-pick Bot
parent 2eb1a72f73
commit 68ac8bdea3

View File

@ -1129,18 +1129,21 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
if (state == m_windowState) if (state == m_windowState)
return; return;
Qt::WindowStates unsetState = m_windowState & ~state;
Qt::WindowStates newState = state & ~m_windowState;
// unset old state // unset old state
if (m_windowState & Qt::WindowMinimized) if (unsetState & Qt::WindowMinimized)
xcb_map_window(xcb_connection(), m_window); xcb_map_window(xcb_connection(), m_window);
if (m_windowState & Qt::WindowMaximized) if (unsetState & Qt::WindowMaximized)
setNetWmState(false, setNetWmState(false,
atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ), atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ),
atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)); 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)); setNetWmState(false, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN));
// set new state // set new state
if (state & Qt::WindowMinimized) { if (newState & Qt::WindowMinimized) {
{ {
xcb_client_message_event_t event; xcb_client_message_event_t event;
@ -1161,13 +1164,8 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
} }
m_minimized = true; 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); setNetWmState(state);
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(xcb_connection(), m_window); xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(xcb_connection(), m_window);