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 f61b140482 .

Pick-to: 6.6 6.5 6.2
Change-Id: Ic93122b92fafcdba973b885e299b282408da7a1c
Reviewed-by: Liang Qi <liang.qi@qt.io>
bb10
Mike Chen 2023-09-15 09:10:41 +08:00 committed by Liang Qi
parent 78272c667f
commit 9161f66a49
1 changed files with 8 additions and 10 deletions

View File

@ -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);