summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2003-01-11 19:32:12 +0000
committerHavoc Pennington <hp@src.gnome.org>2003-01-11 19:32:12 +0000
commit8f7eda43a8258e55fe64d7a495bde5db72db16b3 (patch)
tree4716b17ee597a3224f0527893ebacbb1aec1c55e
parent339a86150b1d777ef3ba61e642ba0a603fe22218 (diff)
downloadmetacity-8f7eda43a8258e55fe64d7a495bde5db72db16b3.tar.gz
metacity-8f7eda43a8258e55fe64d7a495bde5db72db16b3.tar.bz2
implement compression of motion events (drop all but the most recently
2003-01-11 Havoc Pennington <hp@pobox.com> * src/window.c (meta_window_handle_mouse_grab_op_event): implement compression of motion events (drop all but the most recently received), guessing at fixes for #103009
-rw-r--r--ChangeLog6
-rw-r--r--src/window.c80
2 files changed, 79 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ad6fb56..748754d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2003-01-11 Havoc Pennington <hp@pobox.com>
+ * src/window.c (meta_window_handle_mouse_grab_op_event): implement
+ compression of motion events (drop all but the most recently
+ received), guessing at fixes for #103009
+
+2003-01-11 Havoc Pennington <hp@pobox.com>
+
* configure.in: add ability to --disable-shape
2003-01-11 Akira TAGOH <tagoh@gnome.gr.jp>
diff --git a/src/window.c b/src/window.c
index 038e411..779cf4f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6309,6 +6309,66 @@ update_resize (MetaWindow *window,
clear_moveresize_time (window);
}
+typedef struct
+{
+ XEvent prev_event;
+ gboolean done;
+ int count;
+} CompressEventData;
+
+static Bool
+compress_event_predicate (Display *display,
+ XEvent *xevent,
+ XPointer arg)
+{
+ CompressEventData *ced = (void*) arg;
+
+ if (ced->done)
+ return False;
+ else if (ced->prev_event.type == xevent->type &&
+ ced->prev_event.xany.window == xevent->xany.window)
+ {
+ ced->count += 1;
+ return True;
+ }
+ else if (xevent->type != Expose &&
+ xevent->type != ConfigureNotify &&
+ xevent->type != PropertyNotify)
+ {
+ /* Don't compress across most unrelated events, just to be safe */
+ ced->done = TRUE;
+ return False;
+ }
+ else
+ return False;
+}
+
+static void
+maybe_replace_with_newer_event (MetaWindow *window,
+ XEvent *event)
+{
+ XEvent new_event;
+ CompressEventData ced;
+
+ /* Chew up all events of the same type on the same window */
+
+ ced.count = 0;
+ ced.done = FALSE;
+ ced.prev_event = *event;
+ while (XCheckIfEvent (window->display->xdisplay,
+ &new_event,
+ compress_event_predicate,
+ (void*) &ced.prev_event))
+ ced.prev_event = new_event;
+
+ if (ced.count > 0)
+ {
+ meta_topic (META_DEBUG_RESIZING,
+ "Compressed %d motion events\n", ced.count);
+ *event = ced.prev_event;
+ }
+}
+
void
meta_window_handle_mouse_grab_op_event (MetaWindow *window,
XEvent *event)
@@ -6378,17 +6438,23 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
if (meta_grab_op_is_moving (window->display->grab_op))
{
if (event->xmotion.root == window->screen->xroot)
- update_move (window,
- event->xmotion.state,
- event->xmotion.x_root,
- event->xmotion.y_root);
+ {
+ maybe_replace_with_newer_event (window, event);
+ update_move (window,
+ event->xmotion.state,
+ event->xmotion.x_root,
+ event->xmotion.y_root);
+ }
}
else if (meta_grab_op_is_resizing (window->display->grab_op))
{
if (event->xmotion.root == window->screen->xroot)
- update_resize (window,
- event->xmotion.x_root,
- event->xmotion.y_root);
+ {
+ maybe_replace_with_newer_event (window, event);
+ update_resize (window,
+ event->xmotion.x_root,
+ event->xmotion.y_root);
+ }
}
break;