summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2022-10-04 19:33:17 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2022-10-05 14:27:01 +0300
commit2e7e3ed4ec88e756eed3a55df3179569086d63cb (patch)
tree4ef489d2dde1959ab73aefde09ce3d19b3252596
parent3db07fafa1c7ff9749b6a82ccb36d8b62f2304d9 (diff)
downloadmetacity-2e7e3ed4ec88e756eed3a55df3179569086d63cb.tar.gz
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.
-rw-r--r--src/core/display.c40
1 files changed, 39 insertions, 1 deletions
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)