[mutter/wip/xinput2r: 27/68] Use meta_core_select_events() for input events



commit d491904702e38f1ecbf3db5b75b84d133922bc90
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 12 21:35:22 2011 +0200

    Use meta_core_select_events() for input events

 src/compositor/compositor.c |   18 +++---------------
 src/core/screen.c           |   25 ++++++++++++++-----------
 src/core/window.c           |    5 ++++-
 3 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index f96c77d..19147e3 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -18,6 +18,7 @@
 #include "meta-background-actor-private.h"
 #include "window-private.h" /* to check window->hidden */
 #include "display-private.h" /* for meta_display_lookup_x_window() */
+#include "core.h" /* for meta_core_select_events() */
 #include "input-events.h"
 #include <X11/extensions/shape.h>
 #include <X11/extensions/Xcomposite.h>
@@ -156,7 +157,6 @@ get_output_window (MetaScreen *screen)
   MetaDisplay *display = meta_screen_get_display (screen);
   Display     *xdisplay = meta_display_get_xdisplay (display);
   Window       output, xroot;
-  XWindowAttributes attr;
   long         event_mask;
 
   xroot = meta_screen_get_xroot (screen);
@@ -170,13 +170,7 @@ get_output_window (MetaScreen *screen)
                KeyPressMask | KeyReleaseMask;
 
   output = XCompositeGetOverlayWindow (xdisplay, xroot);
-
-  if (XGetWindowAttributes (xdisplay, output, &attr))
-      {
-        event_mask |= attr.your_event_mask;
-      }
-
-  XSelectInput (xdisplay, output, event_mask);
+  meta_core_select_events (xdisplay, output, event_mask, TRUE);
 
   return output;
 }
@@ -457,7 +451,6 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
   Window          xroot         = meta_screen_get_xroot (screen);
   Window          xwin;
   gint            width, height;
-  XWindowAttributes attr;
   long            event_mask;
   guint           n_retries;
   guint           max_retries;
@@ -534,12 +527,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
                KeyPressMask | KeyReleaseMask |
                StructureNotifyMask;
 
-  if (XGetWindowAttributes (xdisplay, xwin, &attr))
-      {
-        event_mask |= attr.your_event_mask;
-      }
-
-  XSelectInput (xdisplay, xwin, event_mask);
+  meta_core_select_events (xdisplay, xwin, event_mask, TRUE);
 
   info->window_group = meta_window_group_new (screen);
   info->background_actor = meta_background_actor_new_for_screen (screen);
diff --git a/src/core/screen.c b/src/core/screen.c
index 03adfef..05b55f3 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -37,6 +37,7 @@
 #include "workspace-private.h"
 #include "keybindings-private.h"
 #include "stack.h"
+#include "core.h"
 #include "xprops.h"
 #include <meta/compositor.h>
 #include "mutter-enum-types.h"
@@ -621,7 +622,6 @@ meta_screen_new (MetaDisplay *display,
   MetaScreen *screen;
   Window xroot;
   Display *xdisplay;
-  XWindowAttributes attr;
   Window new_wm_sn_owner;
   Window current_wm_sn_owner;
   gboolean replace_current_wm;
@@ -736,15 +736,15 @@ meta_screen_new (MetaDisplay *display,
   /* We need to or with the existing event mask since
    * gtk+ may be interested in other events.
    */
-  XGetWindowAttributes (xdisplay, xroot, &attr);
-  XSelectInput (xdisplay,
-                xroot,
-                SubstructureRedirectMask | SubstructureNotifyMask |
-                ColormapChangeMask | PropertyChangeMask |
-                LeaveWindowMask | EnterWindowMask |
-                KeyPressMask | KeyReleaseMask |
-                FocusChangeMask | StructureNotifyMask |
-                ExposureMask | attr.your_event_mask);
+  meta_core_select_events (xdisplay, xroot,
+                           (SubstructureRedirectMask | SubstructureNotifyMask |
+                            ColormapChangeMask | PropertyChangeMask |
+                            LeaveWindowMask | EnterWindowMask |
+                            KeyPressMask | KeyReleaseMask |
+                            FocusChangeMask | StructureNotifyMask |
+                            ExposureMask),
+                           TRUE);
+
   if (meta_error_trap_pop_with_return (display) != Success)
     {
       meta_warning (_("Screen %d on display \"%s\" already has a window manager\n"),
@@ -930,7 +930,10 @@ meta_screen_free (MetaScreen *screen,
   meta_stack_tracker_free (screen->stack_tracker);
 
   meta_error_trap_push_with_return (screen->display);
-  XSelectInput (screen->display->xdisplay, screen->xroot, 0);
+  meta_core_select_events (screen->display->xdisplay,
+                           screen->xroot, NoEventMask,
+                           FALSE);
+
   if (meta_error_trap_pop_with_return (screen->display) != Success)
     meta_warning (_("Could not release screen %d on display \"%s\"\n"),
                   screen->number, screen->display->name);
diff --git a/src/core/window.c b/src/core/window.c
index 3cb92e9..be31bdf 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -45,6 +45,7 @@
 #include "constraints.h"
 #include "input-events.h"
 #include "mutter-enum-types.h"
+#include "core.h"
 
 #include <X11/Xatom.h>
 #include <X11/Xlibint.h> /* For display->resource_mask */
@@ -937,7 +938,9 @@ meta_window_new_with_attrs (MetaDisplay       *display,
    * the event mask, not replace it. For windows from other clients,
    * attrs->your_event_mask will be empty at this point.
    */
-  XSelectInput (display->xdisplay, xwindow, attrs->your_event_mask | event_mask);
+  meta_core_select_events (display->xdisplay, xwindow,
+                           attrs->your_event_mask | event_mask,
+                           TRUE);
 
   has_shape = FALSE;
 #ifdef HAVE_SHAPE



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]