From 666e868cb7e7739c0a6590d86f203f3e05976438 Mon Sep 17 00:00:00 2001 From: Arjun Srinivasan Date: Thu, 30 May 2024 17:54:55 +0000 Subject: [PATCH] vm_tools: sommelier: Ignore additional X11 fullscreen state changes. Ignore additional X11 fullscreen state changes when window->fullscreen is already 1. If compositor_fullscreen=0 and fullscreen=1 and the window is iconified while containerized, the window goes back to fullscreen on focus in instead of maintaining earlier state. BUG=b:342633326 TEST=minimize window when compositor_fullscreen=0 and fullscreen=1 Change-Id: Ied1ae5b376623baca3fcb0b595dbe09a12912d00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/5584707 Commit-Queue: Arjun Srinivasan Tested-by: Arjun Srinivasan Reviewed-by: Chloe Pelling --- sommelier.cc | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/sommelier.cc b/sommelier.cc index 8a4370a..afbca33 100644 --- a/sommelier.cc +++ b/sommelier.cc @@ -1862,24 +1862,34 @@ void sl_handle_client_message(struct sl_context* ctx, "action", net_wm_state_to_string(action), "window->name", window->name); if (action == NET_WM_STATE_ADD) { - window->fullscreen = 1; - LOG(VERBOSE) << window << " fullscreen=1"; - if (window->xdg_toplevel && !window->iconified) { - xdg_toplevel_set_fullscreen(window->xdg_toplevel, nullptr); - } else { - window->pending_fullscreen_change = true; + // Ignore additional calls to change to fullscreen + // if X11 state is already fullscreen. Prevents issues when changing + // focus back to game and Exo/X11 state differ. + if (!window->fullscreen) { + window->fullscreen = 1; + LOG(VERBOSE) << window << " fullscreen=1"; + if (window->xdg_toplevel && !window->iconified) { + xdg_toplevel_set_fullscreen(window->xdg_toplevel, nullptr); + } else { + window->pending_fullscreen_change = true; + } } } else if (action == NET_WM_STATE_REMOVE) { - // Preemptively ask Exo to remove fullscreen then check during surface - // commit (ie. after all states aggregated). - window->maybe_promote_to_fullscreen = true; - - window->fullscreen = 0; - LOG(VERBOSE) << window << " fullscreen=0"; - if (window->xdg_toplevel && !window->iconified) { - xdg_toplevel_unset_fullscreen(window->xdg_toplevel); - } else { - window->pending_fullscreen_change = true; + // Ignore additional calls to change to windowed + // if X11 state is already windowed. Prevents issues when changing + // focus back to game and Exo/X11 state differ. + if (window->fullscreen) { + // Preemptively ask Exo to remove fullscreen then check during + // surface commit (ie. after all states aggregated). + window->maybe_promote_to_fullscreen = true; + + window->fullscreen = 0; + LOG(VERBOSE) << window << " fullscreen=0"; + if (window->xdg_toplevel && !window->iconified) { + xdg_toplevel_unset_fullscreen(window->xdg_toplevel); + } else { + window->pending_fullscreen_change = true; + } } } }