From 2e7e3ed4ec88e756eed3a55df3179569086d63cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= Date: Tue, 4 Oct 2022 19:33:17 +0300 Subject: display: avoid unnecessary stack changes Currently docks are raised when a mouse enters the window and are lowered when mouse leaves it. Typically this will make unnecessary stack changes and unneeded screen redraw. Functions meta_window_raise and meta_window_lower raises or lowers windows within the window layer. For dock windows that means that raising/lowering happens between windows in META_LAYER_BOTTOM layer or META_LAYER_DOCK/META_LAYER_TOP layers. In typical configuration with top and bottom panels this means that rasing/lowering happens between both panels for no reason. Stop doing that if dock does not overlap with other windows in same layer. Dock raising was added in commit 7be4c63ee459 when panel was put in the nromal layer. --- src/core/display.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/core/display.c b/src/core/display.c index 9e0d8d60..ce903273 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1717,6 +1717,42 @@ handle_window_focus_event (MetaDisplay *display, } } +static gboolean +dock_has_overlaps (MetaWindow *dock, + GList *windows) +{ + MetaRectangle dock_rect; + GList *tmp; + + if (dock->type != META_WINDOW_DOCK) + return FALSE; + + meta_window_get_input_rect (dock, &dock_rect); + + tmp = windows; + while (tmp != NULL) + { + MetaWindow *other; + MetaRectangle other_rect; + + other = tmp->data; + tmp = tmp->next; + + if (dock == other) + continue; + + if (dock->layer != other->layer) + continue; + + meta_window_get_input_rect (other, &other_rect); + + if (meta_rectangle_overlap (&dock_rect, &other_rect)) + return TRUE; + } + + return FALSE; +} + static Bool unmap_predicate (Display *display, XEvent *event, @@ -2205,7 +2241,8 @@ event_callback (XEvent *event, break; } - if (window->type == META_WINDOW_DOCK) + if (window->type == META_WINDOW_DOCK && + dock_has_overlaps (window, screen->stack->sorted)) meta_window_raise (window); } break; @@ -2216,6 +2253,7 @@ event_callback (XEvent *event, else if (window != NULL) { if (window->type == META_WINDOW_DOCK && + dock_has_overlaps (window, screen->stack->sorted) && event->xcrossing.mode != NotifyGrab && event->xcrossing.mode != NotifyUngrab && !window->has_focus) -- cgit v1.2.1