summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2002-08-10 05:27:17 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-08-10 05:27:17 +0000
commitf36d236a55a5ef2b8334be521d144e151e453c99 (patch)
treec862f15631da1f4c1c8d9844bb77af27497d3e2c /src
parent9a72bf18586c3d8074be3e357fbee8735af15e02 (diff)
downloadmetacity-f36d236a55a5ef2b8334be521d144e151e453c99.tar.gz
metacity-f36d236a55a5ef2b8334be521d144e151e453c99.tar.bz2
track time to avoid sending a deluge of move/resize requests, suggestion
2002-08-10 Havoc Pennington <hp@pobox.com> * src/window.c (update_resize): track time to avoid sending a deluge of move/resize requests, suggestion from xavier.bestel@free.fr bug #86830. Not really sure if this will make a difference or not. We'll see I guess. (update_move): do same on move though it seems less important here. * src/display.h (struct _MetaDisplay): store the last time we sent a move/resize event.
Diffstat (limited to 'src')
-rw-r--r--src/display.c3
-rw-r--r--src/display.h3
-rw-r--r--src/window.c49
3 files changed, 54 insertions, 1 deletions
diff --git a/src/display.c b/src/display.c
index a47b2a4..7539fe7 100644
--- a/src/display.c
+++ b/src/display.c
@@ -2396,6 +2396,9 @@ meta_display_begin_grab_op (MetaDisplay *display,
display->grab_initial_root_y = root_y;
display->grab_current_root_x = root_x;
display->grab_current_root_y = root_y;
+ display->grab_last_moveresize_time.tv_sec = 0;
+ display->grab_last_moveresize_time.tv_usec = 0;
+
if (display->grab_window)
{
display->grab_initial_window_pos = display->grab_window->rect;
diff --git a/src/display.h b/src/display.h
index 552a947..754110b 100644
--- a/src/display.h
+++ b/src/display.h
@@ -219,7 +219,8 @@ struct _MetaDisplay
MetaRectangle grab_initial_window_pos;
MetaRectangle grab_current_window_pos;
MetaResizePopup *grab_resize_popup;
-
+ GTimeVal grab_last_moveresize_time;
+
/* Keybindings stuff */
MetaKeyBinding *screen_bindings;
diff --git a/src/window.c b/src/window.c
index 3940260..72aeb34 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5817,6 +5817,37 @@ window_query_root_pointer (MetaWindow *window,
*y = root_y_return;
}
+static gboolean
+check_moveresize_frequency (MetaWindow *window)
+{
+ GTimeVal current_time;
+ double elapsed;
+
+ g_get_current_time (&current_time);
+
+ /* use milliseconds, 1000 milliseconds/second */
+ elapsed =
+ ((((double)current_time.tv_sec - window->display->grab_last_moveresize_time.tv_sec) * G_USEC_PER_SEC +
+ (current_time.tv_usec - window->display->grab_last_moveresize_time.tv_usec))) / 1000.0;
+
+#define MAX_RESIZES_PER_SECOND 30.0
+ if (elapsed < (1000.0 / MAX_RESIZES_PER_SECOND))
+ return FALSE;
+
+ /* store latest time */
+ window->display->grab_last_moveresize_time = current_time;
+
+ return TRUE;
+}
+
+static void
+clear_moveresize_time (MetaWindow *window)
+{
+ /* Forces the next update to actually do something */
+ window->display->grab_last_moveresize_time.tv_sec = 0;
+ window->display->grab_last_moveresize_time.tv_usec = 0;
+}
+
static void
update_move (MetaWindow *window,
unsigned int mask,
@@ -5838,6 +5869,14 @@ update_move (MetaWindow *window,
new_x = meta_window_find_nearest_vertical_edge (window, new_x);
new_y = meta_window_find_nearest_horizontal_edge (window, new_y);
}
+
+ /* Force a move regardless of time if a certain delta is exceeded,
+ * so we don't get too out of sync with reality when dropping frames
+ */
+#define MOVE_THRESHOLD 15
+ if (!check_moveresize_frequency (window) &&
+ ABS (dx) < MOVE_THRESHOLD && ABS (dy) < MOVE_THRESHOLD)
+ return;
meta_window_move (window, TRUE, new_x, new_y);
}
@@ -5903,6 +5942,14 @@ update_resize (MetaWindow *window,
break;
}
+ /* Force a move regardless of time if a certain delta
+ * is exceeded
+ */
+#define RESIZE_THRESHOLD 15
+ if (!check_moveresize_frequency (window) &&
+ ABS (dx) < RESIZE_THRESHOLD && ABS (dy) < RESIZE_THRESHOLD)
+ return;
+
/* compute gravity of client during operation */
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
g_assert (gravity >= 0);
@@ -5921,6 +5968,7 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
{
case META_GRAB_OP_MOVING:
case META_GRAB_OP_KEYBOARD_MOVING:
+ clear_moveresize_time (window);
update_move (window, event->xbutton.state,
event->xbutton.x_root, event->xbutton.y_root);
break;
@@ -5941,6 +5989,7 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
case META_GRAB_OP_KEYBOARD_RESIZING_NE:
case META_GRAB_OP_KEYBOARD_RESIZING_SW:
case META_GRAB_OP_KEYBOARD_RESIZING_NW:
+ clear_moveresize_time (window);
update_resize (window, event->xbutton.x_root, event->xbutton.y_root);
break;