[mutter/wip/xinput2b: 8/22] rm meta_core_select_events()
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/xinput2b: 8/22] rm meta_core_select_events()
- Date: Wed, 21 Nov 2012 02:26:30 +0000 (UTC)
commit 04096689da8ae3acda95498c55210ae96f22fbbb
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Nov 20 20:15:09 2012 -0500
rm meta_core_select_events()
squash me
src/compositor/compositor.c | 62 +++++++++++++++++++---------
src/core/core.c | 95 -------------------------------------------
src/core/core.h | 8 ----
src/core/screen.c | 36 +++++++++++-----
src/core/window.c | 21 +++++++---
5 files changed, 82 insertions(+), 140 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index d0ecc1d..601c3ab 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -156,20 +156,30 @@ 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;
+ unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
+ XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
xroot = meta_screen_get_xroot (screen);
+ output = XCompositeGetOverlayWindow (xdisplay, xroot);
- event_mask = FocusChangeMask |
- ExposureMask |
- EnterWindowMask | LeaveWindowMask |
- PointerMotionMask |
- PropertyChangeMask |
- ButtonPressMask | ButtonReleaseMask |
- KeyPressMask | KeyReleaseMask;
+ XISetMask (mask.mask, XI_KeyPress);
+ XISetMask (mask.mask, XI_KeyRelease);
+ XISetMask (mask.mask, XI_ButtonPress);
+ XISetMask (mask.mask, XI_ButtonRelease);
+ XISetMask (mask.mask, XI_Enter);
+ XISetMask (mask.mask, XI_Leave);
+ XISetMask (mask.mask, XI_FocusIn);
+ XISetMask (mask.mask, XI_FocusOut);
+ XISetMask (mask.mask, XI_Motion);
+ XISelectEvents (xdisplay, output, &mask, 1);
- output = XCompositeGetOverlayWindow (xdisplay, xroot);
- meta_core_select_events (xdisplay, output, event_mask, TRUE);
+ event_mask = ExposureMask | PropertyChangeMask;
+ if (XGetWindowAttributes (xdisplay, output, &attr))
+ event_mask |= attr.your_event_mask;
+
+ XSelectInput (xdisplay, output, event_mask);
return output;
}
@@ -450,7 +460,6 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
Window xroot = meta_screen_get_xroot (screen);
Window xwin;
gint width, height;
- long event_mask;
guint n_retries;
guint max_retries;
@@ -517,16 +526,29 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
XResizeWindow (xdisplay, xwin, width, height);
- event_mask = FocusChangeMask |
- ExposureMask |
- EnterWindowMask | LeaveWindowMask |
- PointerMotionMask |
- PropertyChangeMask |
- ButtonPressMask | ButtonReleaseMask |
- KeyPressMask | KeyReleaseMask |
- StructureNotifyMask;
-
- meta_core_select_events (xdisplay, xwin, event_mask, TRUE);
+ {
+ long event_mask;
+ unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
+ XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
+ XWindowAttributes attr;
+
+ XISetMask (mask.mask, XI_KeyPress);
+ XISetMask (mask.mask, XI_KeyRelease);
+ XISetMask (mask.mask, XI_ButtonPress);
+ XISetMask (mask.mask, XI_ButtonRelease);
+ XISetMask (mask.mask, XI_Enter);
+ XISetMask (mask.mask, XI_Leave);
+ XISetMask (mask.mask, XI_FocusIn);
+ XISetMask (mask.mask, XI_FocusOut);
+ XISetMask (mask.mask, XI_Motion);
+ XISelectEvents (xdisplay, xwin, &mask, 1);
+
+ event_mask = ExposureMask | PropertyChangeMask | StructureNotifyMask;
+ if (XGetWindowAttributes (xdisplay, xwin, &attr))
+ event_mask |= attr.your_event_mask;
+
+ XSelectInput (xdisplay, xwin, event_mask);
+ }
info->window_group = meta_window_group_new (screen);
info->background_actor = meta_background_actor_new_for_screen (screen);
diff --git a/src/core/core.c b/src/core/core.c
index fea3e50..4ede33f 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -774,98 +774,3 @@ meta_invalidate_default_icons (void)
g_slist_free (windows);
}
-
-guchar *
-meta_core_translate_xi2_mask (guint evmask,
- gint *len)
-{
- guchar *mask;
-
- *len = XIMaskLen (XI_LASTEVENT);
- mask = g_new0 (guchar, *len);
-
- if (evmask & KeyPressMask)
- XISetMask (mask, XI_KeyPress);
- if (evmask & KeyReleaseMask)
- XISetMask (mask, XI_KeyRelease);
- if (evmask & ButtonPressMask)
- XISetMask (mask, XI_ButtonPress);
- if (evmask & ButtonReleaseMask)
- XISetMask (mask, XI_ButtonRelease);
- if (evmask & EnterWindowMask)
- XISetMask (mask, XI_Enter);
- if (evmask & LeaveWindowMask)
- XISetMask (mask, XI_Leave);
-
- /* No motion hints in XI2 at the moment... */
- if (evmask & PointerMotionMask ||
- evmask & PointerMotionHintMask)
- XISetMask (mask, XI_Motion);
-
- if (evmask & FocusChangeMask)
- {
- XISetMask (mask, XI_FocusIn);
- XISetMask (mask, XI_FocusOut);
- }
-
- return mask;
-}
-
-/* Selects events on an xwindow, using XInput2 if possible.
- * This function doesn't require the xwindow to have a backing
- * MetaWindow.
- */
-void
-meta_core_select_events (Display *xdisplay,
- Window xwindow,
- gint evmask,
- gboolean preserve_old_mask)
-{
- XIEventMask mask;
-
- mask.deviceid = XIAllMasterDevices;
- mask.mask = meta_core_translate_xi2_mask (evmask, &mask.mask_len);
-
- if (preserve_old_mask)
- {
- XIEventMask *prev;
- gint n_masks, i, j;
-
- prev = XIGetSelectedEvents (xdisplay, xwindow, &n_masks);
-
- for (i = 0; i < n_masks; i++)
- {
- if (prev[i].deviceid != XIAllMasterDevices)
- continue;
-
- for (j = 0; j < MIN (mask.mask_len, prev[i].mask_len); j++)
- mask.mask[j] |= prev[i].mask[j];
- }
-
- XFree (prev);
- }
-
- XISelectEvents (xdisplay, xwindow, &mask, 1);
-
- g_free (mask.mask);
-
- /* Unset any input event so they are only handled via XInput2 */
- evmask &= ~(KeyPressMask | KeyReleaseMask |
- ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | LeaveWindowMask |
- PointerMotionMask | PointerMotionHintMask |
- Button1MotionMask | Button2MotionMask |
- Button3MotionMask | Button4MotionMask |
- Button5MotionMask | ButtonMotionMask |
- FocusChangeMask);
-
- if (preserve_old_mask)
- {
- XWindowAttributes attr;
-
- if (XGetWindowAttributes (xdisplay, xwindow, &attr))
- evmask |= attr.your_event_mask;
- }
-
- XSelectInput (xdisplay, xwindow, evmask);
-}
diff --git a/src/core/core.h b/src/core/core.h
index 000c73f..723b8b3 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -197,14 +197,6 @@ void meta_core_set_screen_cursor (Display *xdisplay,
Window frame_on_screen,
MetaCursor cursor);
-guchar * meta_core_translate_xi2_mask (guint evmask,
- gint *len);
-
-void meta_core_select_events (Display *xdisplay,
- Window xwindow,
- gint evmask,
- gboolean preserve_old_mask);
-
/* Used because we ignore EnterNotify when a window is unmapped that
* really shouldn't cause focus changes, by comparing the event serial
diff --git a/src/core/screen.c b/src/core/screen.c
index 05b55f3..55cd9ca 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -736,14 +736,30 @@ meta_screen_new (MetaDisplay *display,
/* We need to or with the existing event mask since
* gtk+ may be interested in other events.
*/
- meta_core_select_events (xdisplay, xroot,
- (SubstructureRedirectMask | SubstructureNotifyMask |
- ColormapChangeMask | PropertyChangeMask |
- LeaveWindowMask | EnterWindowMask |
- KeyPressMask | KeyReleaseMask |
- FocusChangeMask | StructureNotifyMask |
- ExposureMask),
- TRUE);
+ {
+ long event_mask;
+ unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
+ XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
+ XWindowAttributes attr;
+
+ XISetMask (mask.mask, XI_KeyPress);
+ XISetMask (mask.mask, XI_KeyRelease);
+ XISetMask (mask.mask, XI_ButtonPress);
+ XISetMask (mask.mask, XI_ButtonRelease);
+ XISetMask (mask.mask, XI_Enter);
+ XISetMask (mask.mask, XI_Leave);
+ XISetMask (mask.mask, XI_FocusIn);
+ XISetMask (mask.mask, XI_FocusOut);
+ XISetMask (mask.mask, XI_Motion);
+ XISelectEvents (xdisplay, xroot, &mask, 1);
+
+ event_mask = (SubstructureRedirectMask | SubstructureNotifyMask |
+ StructureNotifyMask | ColormapChangeMask | PropertyChangeMask);
+ if (XGetWindowAttributes (xdisplay, xroot, &attr))
+ event_mask |= attr.your_event_mask;
+
+ XSelectInput (xdisplay, xroot, event_mask);
+ }
if (meta_error_trap_pop_with_return (display) != Success)
{
@@ -930,9 +946,7 @@ meta_screen_free (MetaScreen *screen,
meta_stack_tracker_free (screen->stack_tracker);
meta_error_trap_push_with_return (screen->display);
- meta_core_select_events (screen->display->xdisplay,
- screen->xroot, NoEventMask,
- FALSE);
+ XSelectInput (screen->display->xdisplay, screen->xroot, NoEventMask);
if (meta_error_trap_pop_with_return (screen->display) != Success)
meta_warning (_("Could not release screen %d on display \"%s\"\n"),
diff --git a/src/core/window.c b/src/core/window.c
index c147675..df146d6 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -923,9 +923,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
XAddToSaveSet (display->xdisplay, xwindow);
meta_error_trap_pop_with_return (display);
- event_mask =
- PropertyChangeMask | EnterWindowMask | LeaveWindowMask |
- FocusChangeMask | ColormapChangeMask;
+ event_mask = PropertyChangeMask | ColormapChangeMask;
if (attrs->override_redirect)
event_mask |= StructureNotifyMask;
@@ -933,9 +931,20 @@ 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.
*/
- meta_core_select_events (display->xdisplay, xwindow,
- attrs->your_event_mask | event_mask,
- FALSE);
+ XSelectInput (display->xdisplay, xwindow,
+ attrs->your_event_mask | event_mask);
+
+ {
+ unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
+ XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
+
+ XISetMask (mask.mask, XI_Enter);
+ XISetMask (mask.mask, XI_Leave);
+ XISetMask (mask.mask, XI_FocusIn);
+ XISetMask (mask.mask, XI_FocusOut);
+
+ XISelectEvents (display->xdisplay, xwindow, &mask, 1);
+ }
has_shape = FALSE;
#ifdef HAVE_SHAPE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]