[metacity] window: Move grab op sync handling code out
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] window: Move grab op sync handling code out
- Date: Sun, 5 Mar 2017 01:02:45 +0000 (UTC)
commit 588d7cbb988dda453c62d47f887f3fc562cd5c61
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Nov 15 17:18:06 2012 -0500
window: Move grab op sync handling code out
This removes some duplicate event type checks, and will make
the code cleaner in the future when we want to make the grab_op_event
handler take an XIDeviceEvent directly.
Based on a patch by Owen Taylor <otaylor fishsoup net>
https://bugzilla.gnome.org/show_bug.cgi?id=688779
src/core/display-private.h | 1 +
src/core/display.c | 31 +++++++++++++++++--------------
src/core/window-private.h | 3 +++
src/core/window.c | 13 ++++++++++---
4 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index a83e0d8..50b9dd1 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -438,6 +438,7 @@ int meta_resize_gravity_from_grab_op (MetaGrabOp op);
gboolean meta_grab_op_is_moving (MetaGrabOp op);
gboolean meta_grab_op_is_resizing (MetaGrabOp op);
+gboolean meta_grab_op_is_mouse (MetaGrabOp op);
gboolean meta_display_devirtualize_modifiers (MetaDisplay *display,
MetaVirtualModifier modifiers,
diff --git a/src/core/display.c b/src/core/display.c
index 0cd062c..8ca09fa 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1028,8 +1028,8 @@ grab_op_is_mouse_only (MetaGrabOp op)
}
}
-static gboolean
-grab_op_is_mouse (MetaGrabOp op)
+gboolean
+meta_grab_op_is_mouse (MetaGrabOp op)
{
switch (op)
{
@@ -1790,12 +1790,15 @@ event_callback (XEvent *event,
event->type == (display->xsync_event_base + XSyncAlarmNotify) &&
((XSyncAlarmNotifyEvent*)event)->alarm == display->grab_sync_request_alarm)
{
- filter_out_event = TRUE; /* GTK doesn't want to see this really */
+ XSyncValue value;
+ guint64 new_counter_value;
- if (display->grab_op != META_GRAB_OP_NONE &&
- display->grab_window != NULL &&
- grab_op_is_mouse (display->grab_op))
- meta_window_handle_mouse_grab_op_event (display->grab_window, event);
+ value = ((XSyncAlarmNotifyEvent *) event)->counter_value;
+ new_counter_value = XSyncValueLow32 (value) + ((gint64) XSyncValueHigh32 (value) << 32);
+
+ meta_window_update_sync_request_counter (display->grab_window, new_counter_value);
+
+ filter_out_event = TRUE; /* GTK doesn't want to see this really */
}
if (META_DISPLAY_HAS_SHAPE (display) &&
@@ -1875,7 +1878,7 @@ event_callback (XEvent *event,
break;
case ButtonPress:
if ((window &&
- grab_op_is_mouse (display->grab_op) &&
+ meta_grab_op_is_mouse (display->grab_op) &&
display->grab_button != (int) event->xbutton.button &&
display->grab_window == window) ||
grab_op_is_keyboard (display->grab_op))
@@ -2052,17 +2055,17 @@ event_callback (XEvent *event,
break;
case ButtonRelease:
if (display->grab_window == window &&
- grab_op_is_mouse (display->grab_op))
+ meta_grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
break;
case MotionNotify:
if (display->grab_window == window &&
- grab_op_is_mouse (display->grab_op))
+ meta_grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
break;
case EnterNotify:
if (display->grab_window == window &&
- grab_op_is_mouse (display->grab_op))
+ meta_grab_op_is_mouse (display->grab_op))
{
meta_window_handle_mouse_grab_op_event (window, event);
break;
@@ -2142,7 +2145,7 @@ event_callback (XEvent *event,
break;
case LeaveNotify:
if (display->grab_window == window &&
- grab_op_is_mouse (display->grab_op))
+ meta_grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
else if (window != NULL)
{
@@ -3516,7 +3519,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
MetaWindow *grab_window = NULL;
Window grab_xwindow;
- if (grab_op_is_mouse (op) && meta_grab_op_is_moving (op))
+ if (meta_grab_op_is_mouse (op) && meta_grab_op_is_moving (op))
{
meta_compositor_begin_move (display->compositor,
window, &window->rect,
@@ -3910,7 +3913,7 @@ meta_display_end_grab_op (MetaDisplay *display,
}
if (display->grab_window &&
- grab_op_is_mouse (display->grab_op) &&
+ meta_grab_op_is_mouse (display->grab_op) &&
meta_grab_op_is_moving (display->grab_op))
{
meta_compositor_end_move (display->compositor, display->grab_window);
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 1dd6600..fbd0bc1 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -607,6 +607,9 @@ void meta_window_shove_titlebar_onscreen (MetaWindow *window);
void meta_window_set_gravity (MetaWindow *window,
int gravity);
+void meta_window_update_sync_request_counter (MetaWindow *window,
+ guint64 new_counter_value);
+
void meta_window_handle_mouse_grab_op_event (MetaWindow *window,
XEvent *event);
diff --git a/src/core/window.c b/src/core/window.c
index 440aa86..f1c7247 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -7894,10 +7894,12 @@ update_tile_mode (MetaWindow *window)
}
void
-meta_window_handle_mouse_grab_op_event (MetaWindow *window,
- XEvent *event)
+meta_window_update_sync_request_counter (MetaWindow *window,
+ guint64 new_counter_value)
{
- if (event->type == (window->display->xsync_event_base + XSyncAlarmNotify))
+ if (window->display->grab_op != META_GRAB_OP_NONE &&
+ window == window->display->grab_window &&
+ meta_grab_op_is_mouse (window->display->grab_op))
{
meta_topic (META_DEBUG_RESIZING,
"Alarm event received last motion x = %d y = %d\n",
@@ -7968,7 +7970,12 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
break;
}
}
+}
+void
+meta_window_handle_mouse_grab_op_event (MetaWindow *window,
+ XEvent *event)
+{
switch (event->type)
{
case ButtonRelease:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]