[mutter/wip/xinput2r: 15/68] window: use input event helper functions in grab operations.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/xinput2r: 15/68] window: use input event helper functions in grab operations.
- Date: Wed, 24 Oct 2012 16:10:35 +0000 (UTC)
commit cdefae5708f0e280d07e1d6c9dc953d757ac9cd0
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jun 9 17:46:17 2011 +0200
window: use input event helper functions in grab operations.
src/core/window.c | 109 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 77 insertions(+), 32 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 06dba27..391bec1 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -43,6 +43,7 @@
#include <meta/group.h>
#include "window-props.h"
#include "constraints.h"
+#include "input-events.h"
#include "mutter-enum-types.h"
#include <X11/Xatom.h>
@@ -50,6 +51,10 @@
#include <string.h>
#include <math.h>
+#ifdef HAVE_XINPUT2
+#include <X11/extensions/XInput2.h>
+#endif
+
#ifdef HAVE_SHAPE
#include <X11/extensions/shape.h>
#endif
@@ -9130,7 +9135,10 @@ update_resize (MetaWindow *window,
typedef struct
{
- const XEvent *current_event;
+ guint current_event_type;
+ Window current_event_window;
+ MetaDisplay *display;
+ MetaDevice *device;
int count;
guint32 last_time;
} EventScannerData;
@@ -9141,13 +9149,33 @@ find_last_time_predicate (Display *display,
XPointer arg)
{
EventScannerData *esd = (void*) arg;
+ Window xwindow;
- if (esd->current_event->type == xevent->type &&
- esd->current_event->xany.window == xevent->xany.window)
- {
- esd->count += 1;
- esd->last_time = xevent->xmotion.time;
- }
+#ifdef HAVE_XINPUT2
+ /* We are peeking into events not yet handled by GDK,
+ * Allocate cookie events here so we can handle XI2.
+ *
+ * GDK will handle later these events, and eventually
+ * free the cookie data itself.
+ */
+ XGetEventData (display, &xevent->xcookie);
+#endif
+
+ if (!meta_input_event_is_type (esd->display, xevent,
+ esd->current_event_type))
+ return False;
+
+ xwindow = meta_input_event_get_window (esd->display, xevent);
+
+ if (xwindow == None ||
+ xwindow != esd->current_event_window)
+ return False;
+
+ if (esd->device != meta_input_event_get_device (esd->display, xevent))
+ return False;
+
+ esd->count += 1;
+ esd->last_time = meta_input_event_get_time (esd->display, xevent);
return False;
}
@@ -9163,13 +9191,16 @@ check_use_this_motion_notify (MetaWindow *window,
if (window->display->grab_motion_notify_time != 0)
{
+ Time evtime;
+
+ evtime = meta_input_event_get_time (window->display, event);
+
/* == is really the right test, but I'm all for paranoia */
- if (window->display->grab_motion_notify_time <=
- event->xmotion.time)
+ if (window->display->grab_motion_notify_time <= evtime)
{
meta_topic (META_DEBUG_RESIZING,
"Arrived at event with time %u (waiting for %u), using it\n",
- (unsigned int)event->xmotion.time,
+ (unsigned int) evtime,
window->display->grab_motion_notify_time);
window->display->grab_motion_notify_time = 0;
return TRUE;
@@ -9178,7 +9209,11 @@ check_use_this_motion_notify (MetaWindow *window,
return FALSE; /* haven't reached the saved timestamp yet */
}
- esd.current_event = event;
+ esd.current_event_window = meta_input_event_get_window (window->display,
+ event);
+ esd.device = device;
+ esd.current_event_type = MotionNotify;
+ esd.display = window->display;
esd.count = 0;
esd.last_time = 0;
@@ -9226,6 +9261,10 @@ void
meta_window_handle_mouse_grab_op_event (MetaWindow *window,
XEvent *event)
{
+ gdouble x_root, y_root;
+ guint evtype, state;
+ Window xroot;
+
#ifdef HAVE_XSYNC
if (event->type == (window->display->xsync_event_base + XSyncAlarmNotify))
{
@@ -9275,12 +9314,19 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
}
#endif /* HAVE_XSYNC */
- switch (event->type)
+ if (!meta_input_event_get_type (window->display, event, &evtype) ||
+ !meta_input_event_get_state (window->display, event, &state) ||
+ !meta_input_event_get_coordinates (window->display, event,
+ NULL, NULL, &x_root, &y_root))
+ return;
+
+ xroot = meta_input_event_get_root_window (window->display, event);
+
+ switch (evtype)
{
case ButtonRelease:
meta_display_check_threshold_reached (window->display,
- event->xbutton.x_root,
- event->xbutton.y_root);
+ x_root, y_root);
/* If the user was snap moving then ignore the button release
* because they may have let go of shift before releasing the
* mouse button and they almost certainly do not want a
@@ -9292,17 +9338,17 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
{
if (window->tile_mode != META_TILE_NONE)
meta_window_tile (window);
- else if (event->xbutton.root == window->screen->xroot)
- update_move (window, event->xbutton.state & ShiftMask,
- event->xbutton.x_root, event->xbutton.y_root);
+ else if (xroot == window->screen->xroot)
+ update_move (window,
+ state & ShiftMask,
+ x_root, y_root);
}
else if (meta_grab_op_is_resizing (window->display->grab_op))
{
- if (event->xbutton.root == window->screen->xroot)
+ if (xroot == window->screen->xroot)
update_resize (window,
- event->xbutton.state & ShiftMask,
- event->xbutton.x_root,
- event->xbutton.y_root,
+ state & ShiftMask,
+ x_root, y_root,
TRUE);
if (window->display->compositor)
meta_compositor_set_updates (window->display->compositor, window, TRUE);
@@ -9318,35 +9364,34 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
}
}
- meta_display_end_grab_op (window->display, event->xbutton.time);
+ meta_display_end_grab_op (window->display,
+ meta_input_event_get_time (window->display,
+ event));
break;
case MotionNotify:
meta_display_check_threshold_reached (window->display,
- event->xmotion.x_root,
- event->xmotion.y_root);
+ x_root, y_root);
if (meta_grab_op_is_moving (window->display->grab_op))
{
- if (event->xmotion.root == window->screen->xroot)
+ if (xroot == window->screen->xroot)
{
if (check_use_this_motion_notify (window,
event))
update_move (window,
- event->xmotion.state & ShiftMask,
- event->xmotion.x_root,
- event->xmotion.y_root);
+ state & ShiftMask,
+ x_root, y_root);
}
}
else if (meta_grab_op_is_resizing (window->display->grab_op))
{
- if (event->xmotion.root == window->screen->xroot)
+ if (xroot == window->screen->xroot)
{
if (check_use_this_motion_notify (window,
event))
update_resize (window,
- event->xmotion.state & ShiftMask,
- event->xmotion.x_root,
- event->xmotion.y_root,
+ state & ShiftMask,
+ x_root, y_root,
FALSE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]