From 436e6dca242cedcc53655609248c04fdea2cd89b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Nov 2022 17:06:58 +1100 Subject: Fix window title not redrawing with Wayland/libdecor --- intern/ghost/intern/GHOST_WindowWayland.cpp | 38 ++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index d395888f600..942cb02dd4f 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -363,6 +363,7 @@ static void frame_handle_configure(struct libdecor_frame *frame, int size_next[2]; enum libdecor_window_state window_state; struct libdecor_state *state; + bool do_redraw = false; if (!libdecor_configuration_get_content_size( configuration, frame, &size_next[0], &size_next[1])) { @@ -387,14 +388,34 @@ static void frame_handle_configure(struct libdecor_frame *frame, win->is_maximised = window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED; win->is_fullscreen = window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN; + + GHOST_SystemWayland *system = static_cast(GHOST_ISystem::getSystem()); + const bool is_active_prev_ghost = (win->ghost_window == + system->getWindowManager()->getActiveWindow()); win->is_active = window_state & LIBDECOR_WINDOW_STATE_ACTIVE; + if (is_active_prev_ghost != win->is_active) { + if (win->is_active) { + win->ghost_window->activate(); + } + else { + win->ghost_window->deactivate(); + } + } - win->is_active ? win->ghost_window->activate() : win->ghost_window->deactivate(); + const bool is_active_prev_decor = win->is_active; + if (is_active_prev_decor) { + /* Without this, activating another window doesn't refresh the title-bar as inactive. */ + do_redraw = true; + } state = libdecor_state_new(UNPACK2(size_next)); libdecor_frame_commit(frame, state, configuration); libdecor_state_free(state); + if (do_redraw) { + win->ghost_window->swapBuffers(); + } + win->libdecor->configured = true; } @@ -479,11 +500,16 @@ static void xdg_surface_handle_configure(void *data, win->ghost_window->notify_size(); } - if (win->is_active) { - win->ghost_window->activate(); - } - else { - win->ghost_window->deactivate(); + GHOST_SystemWayland *system = static_cast(GHOST_ISystem::getSystem()); + const bool is_active_prev_ghost = (win->ghost_window == + system->getWindowManager()->getActiveWindow()); + if (is_active_prev_ghost != win->is_active) { + if (win->is_active) { + win->ghost_window->activate(); + } + else { + win->ghost_window->deactivate(); + } } xdg_surface_ack_configure(xdg_surface, serial); -- cgit v1.2.3