[metacity/wip/muktupavels/docks: 2/2] display: avoid unnecessary stack changes
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity/wip/muktupavels/docks: 2/2] display: avoid unnecessary stack changes
- Date: Wed, 5 Oct 2022 11:27:16 +0000 (UTC)
commit 2e7e3ed4ec88e756eed3a55df3179569086d63cb
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Oct 4 19:33:17 2022 +0300
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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]