From 463b50e7463417197a0af5dc646365f24cbb08f6 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 10 Jul 2014 14:03:03 -0400 Subject: [PATCH] screen: Fetch the COW window up-front XGetCompositeOverlayWindow is a round trip to the X server. We shouldn't be doing it on every MapWindow. --- src/compositor/compositor.c | 2 +- src/core/screen-private.h | 2 ++ src/core/screen.c | 3 +++ src/x11/window-x11.c | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 7481fa563..b67b5faeb 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -157,7 +157,7 @@ get_output_window (MetaCompositor *compositor) unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 }; XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits }; - output = XCompositeGetOverlayWindow (xdisplay, DefaultRootWindow (xdisplay)); + output = compositor->display->screen->composite_overlay_window; XISetMask (mask.mask, XI_KeyPress); XISetMask (mask.mask, XI_KeyRelease); diff --git a/src/core/screen-private.h b/src/core/screen-private.h index 766af4bd5..44edd93ed 100644 --- a/src/core/screen-private.h +++ b/src/core/screen-private.h @@ -119,6 +119,8 @@ struct _MetaScreen * and restack them below a guard window. When using a compositor * this allows us to provide live previews of unmapped windows */ Window guard_window; + + Window composite_overlay_window; }; struct _MetaScreenClass diff --git a/src/core/screen.c b/src/core/screen.c index fbd3e7d01..dd720c021 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -45,6 +45,7 @@ #include "meta-cursor-tracker-private.h" #include +#include #include #include @@ -700,6 +701,8 @@ meta_screen_new (MetaDisplay *display, screen->starting_corner = META_SCREEN_TOPLEFT; screen->guard_window = None; + screen->composite_overlay_window = XCompositeGetOverlayWindow (xdisplay, xroot); + reload_monitor_infos (screen); meta_screen_set_cursor (screen, META_CURSOR_DEFAULT); diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 29976d29d..45b04d2c1 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -2942,7 +2942,7 @@ is_our_xwindow (MetaDisplay *display, if (xwindow == screen->guard_window) return TRUE; - if (xwindow == XCompositeGetOverlayWindow (display->xdisplay, screen->xroot)) + if (xwindow == screen->composite_overlay_window) return TRUE; /* Any windows created via meta_create_offscreen_window */