Commit 967777b9 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

add myself here, bug #100789

2002-12-09  Havoc Pennington  <hp@pobox.com>

	* AUTHORS: add myself here, bug #100789

	* src/display.c (meta_display_set_grab_op_cursor): drop
	PointerMotionHintMask

	* src/window.c (meta_window_handle_mouse_grab_op_event): don't use
	XQueryPointer, as we aren't using PointerMotionHint now

	* src/display.c (event_callback): rearrange a bit of code
	for slight speedup and clarity

	* src/window.c (update_resize)
	(meta_window_handle_mouse_grab_op_event): implement
	usage of the _METACITY_UPDATE_COUNTER
	(meta_window_handle_mouse_grab_op_event): fix code that
	used event->xbutton with a motion event

	* src/display.c (meta_display_open): add new atoms, and
	initialize Xsync if we have it
	(grab_op_is_resizing): new function
	(meta_display_begin_grab_op): create an alarm monitoring
	window's _METACITY_UPDATE_COUNTER
	(meta_spew_event): conditionalize this on WITH_VERBOSE_MODE
	and print alarm events.

	* src/window.c (meta_window_new): fetch _METACITY_UPDATE_COUNTER

	* configure.in (HAVE_XSYNC): check for Xsync extension
parent ba18c630
Havoc Pennington <hp@redhat.com>
2002-12-09 Havoc Pennington <hp@pobox.com>
* AUTHORS: add myself here, bug #100789
* src/display.c (meta_display_set_grab_op_cursor): drop
PointerMotionHintMask
* src/window.c (meta_window_handle_mouse_grab_op_event): don't use
XQueryPointer, as we aren't using PointerMotionHint now
* src/display.c (event_callback): rearrange a bit of code
for slight speedup and clarity
* src/window.c (update_resize)
(meta_window_handle_mouse_grab_op_event): implement
usage of the _METACITY_UPDATE_COUNTER
(meta_window_handle_mouse_grab_op_event): fix code that
used event->xbutton with a motion event
* src/display.c (meta_display_open): add new atoms, and
initialize Xsync if we have it
(grab_op_is_resizing): new function
(meta_display_begin_grab_op): create an alarm monitoring
window's _METACITY_UPDATE_COUNTER
(meta_spew_event): conditionalize this on WITH_VERBOSE_MODE
and print alarm events.
* src/window.c (meta_window_new): fetch _METACITY_UPDATE_COUNTER
* configure.in (HAVE_XSYNC): check for Xsync extension
Mon Dec 9 22:09:56 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* src/display.c, src/window.c: Handle crossing events during
......
......@@ -108,6 +108,8 @@ AC_ARG_ENABLE(sm, [ --disable-sm disable metacity's session m
AC_ARG_ENABLE(startup-notification, [ --disable-startup-notification disable metacity's startup notification support, for embedded/size-sensitive custom non-GNOME builds],enable_startup_notification=no,enable_startup_notification=auto)
AC_ARG_ENABLE(xsync, [ --disable-xsync disable metacity's use of the XSync extension],enable_xsync=no,enable_xsync=auto)
## try definining HAVE_BACKTRACE
AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
......@@ -231,7 +233,31 @@ if test "x$found_randr" = "xyes"; then
AC_DEFINE(HAVE_RANDR, , [Have the Xrandr extension library])
fi
METACITY_LIBS="$RANDR_LIBS $SHAPE_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_LIBS"
XSYNC_LIBS=
found_xsync=no
AC_CHECK_LIB(Xext, XSyncQueryExtension,
[AC_CHECK_HEADER(X11/extensions/sync.h,
found_xsync=yes,,
[#include <X11/Xlib.h>])],
, $ALL_X_LIBS)
if test x$enable_xsync = xno; then
found_xsync=no
fi
if test x$enable_xsync = xyes; then
if test "$found_xsync" = "no"; then
AC_MSG_ERROR([--enable-xsync forced and XSync not found])
exit 1
fi
fi
if test "x$found_xsync" = "xyes"; then
XSYNC_LIBS=-lXext
AC_DEFINE(HAVE_XSYNC, , [Have the Xsync extension library])
fi
METACITY_LIBS="$XSYNC_LIBS $RANDR_LIBS $SHAPE_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_LIBS"
METACITY_MESSAGE_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_MESSAGE_LIBS"
METACITY_WINDOW_DEMO_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_WINDOW_DEMO_LIBS"
METACITY_PROPS_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $METACITY_PROPS_LIBS"
......@@ -338,5 +364,6 @@ metacity-$VERSION:
Session management: ${found_sm}
Shape extension: ${found_shape}
Resize-and-rotate: ${found_randr}
Xsync: ${found_xsync}
Deprecated config dialog: ${enable_config_dialog}
"
......@@ -2,6 +2,7 @@
/*
* Copyright (C) 2001 Havoc Pennington
* Copyright (C) 2002 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -253,7 +254,9 @@ meta_display_open (const char *name)
"_NET_WM_STATE_ABOVE",
"_NET_WM_STATE_BELOW",
"_NET_STARTUP_ID",
"_METACITY_TOGGLE_VERBOSE"
"_METACITY_TOGGLE_VERBOSE",
"_METACITY_UPDATE_COUNTER",
"SYNC_COUNTER"
};
Atom atoms[G_N_ELEMENTS(atom_names)];
......@@ -389,6 +392,8 @@ meta_display_open (const char *name)
display->atom_net_wm_state_below = atoms[76];
display->atom_net_startup_id = atoms[77];
display->atom_metacity_toggle_verbose = atoms[78];
display->atom_metacity_update_counter = atoms[79];
display->atom_sync_counter = atoms[80];
display->prop_hooks = NULL;
meta_display_init_window_prop_hooks (display);
......@@ -453,6 +458,35 @@ meta_display_open (const char *name)
display->grab_screen = NULL;
display->grab_resize_popup = NULL;
#ifdef HAVE_XSYNC
{
int major, minor;
display->xsync_error_base = 0;
display->xsync_event_base = 0;
/* I don't think we really have to fill these in */
major = SYNC_MAJOR_VERSION;
minor = SYNC_MINOR_VERSION;
if (!XSyncQueryExtension (display->xdisplay,
&display->xsync_event_base,
&display->xsync_error_base) ||
!XSyncInitialize (display->xdisplay,
&major, &minor))
{
display->xsync_error_base = 0;
display->xsync_event_base = 0;
}
meta_verbose ("Attempted to init Xsync, found version %d.%d error base %d event base %d\n",
major, minor,
display->xsync_error_base,
display->xsync_event_base);
}
#else /* HAVE_XSYNC */
meta_verbose ("Not compiled with Xsync support\n");
#endif /* !HAVE_XSYNC */
screens = NULL;
#ifdef HAVE_GTK_MULTIHEAD
......@@ -896,6 +930,51 @@ grab_op_is_keyboard (MetaGrabOp op)
}
}
gboolean
meta_grab_op_is_resizing (MetaGrabOp op)
{
switch (op)
{
case META_GRAB_OP_RESIZING_SE:
case META_GRAB_OP_RESIZING_S:
case META_GRAB_OP_RESIZING_SW:
case META_GRAB_OP_RESIZING_N:
case META_GRAB_OP_RESIZING_NE:
case META_GRAB_OP_RESIZING_NW:
case META_GRAB_OP_RESIZING_W:
case META_GRAB_OP_RESIZING_E:
case META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN:
case META_GRAB_OP_KEYBOARD_RESIZING_S:
case META_GRAB_OP_KEYBOARD_RESIZING_N:
case META_GRAB_OP_KEYBOARD_RESIZING_W:
case META_GRAB_OP_KEYBOARD_RESIZING_E:
case META_GRAB_OP_KEYBOARD_RESIZING_SE:
case META_GRAB_OP_KEYBOARD_RESIZING_NE:
case META_GRAB_OP_KEYBOARD_RESIZING_SW:
case META_GRAB_OP_KEYBOARD_RESIZING_NW:
return TRUE;
break;
default:
return FALSE;
}
}
gboolean
meta_grab_op_is_moving (MetaGrabOp op)
{
switch (op)
{
case META_GRAB_OP_MOVING:
case META_GRAB_OP_KEYBOARD_MOVING:
return TRUE;
break;
default:
return FALSE;
}
}
/* Get time of current event, or CurrentTime if none. */
guint32
meta_display_get_current_time (MetaDisplay *display)
......@@ -1093,6 +1172,20 @@ event_callback (XEvent *event,
frame_was_receiver = TRUE;
meta_topic (META_DEBUG_EVENTS, "Frame was receiver of event\n");
}
#ifdef HAVE_XSYNC
if (META_DISPLAY_HAS_XSYNC (display) &&
event->type == (display->xsync_event_base + XSyncAlarmNotify) &&
((XSyncAlarmNotifyEvent*)event)->alarm == display->grab_update_alarm)
{
filter_out_event = TRUE; /* GTK doesn't want to see this really */
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);
}
#endif /* HAVE_XSYNC */
switch (event->type)
{
......@@ -1242,25 +1335,22 @@ event_callback (XEvent *event,
}
break;
case ButtonRelease:
if (grab_op_is_mouse (display->grab_op) &&
display->grab_window == window)
if (display->grab_window == window &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
break;
case MotionNotify:
if (grab_op_is_mouse (display->grab_op) &&
display->grab_window == window)
if (display->grab_window == window &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
break;
case EnterNotify:
if (grab_op_is_mouse (display->grab_op) &&
display->grab_window == window)
{
meta_window_handle_mouse_grab_op_event (window, event);
break;
}
if (display->grab_window == window &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
/* do this even if window->has_focus to avoid races */
if (window && !serial_is_ignored (display, event->xany.serial) &&
event->xcrossing.detail != NotifyInferior)
else if (window && !serial_is_ignored (display, event->xany.serial) &&
event->xcrossing.detail != NotifyInferior)
{
switch (meta_prefs_get_focus_mode ())
{
......@@ -1317,13 +1407,10 @@ event_callback (XEvent *event,
}
break;
case LeaveNotify:
if (grab_op_is_mouse (display->grab_op) &&
display->grab_window == window)
{
meta_window_handle_mouse_grab_op_event (window, event);
break;
}
if (window)
if (display->grab_window == window &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
else if (window != NULL)
{
switch (meta_prefs_get_focus_mode ())
{
......@@ -1872,6 +1959,7 @@ event_get_time (MetaDisplay *display,
}
}
#ifdef WITH_VERBOSE_MODE
const char*
meta_event_detail_to_string (int d)
{
......@@ -1908,7 +1996,9 @@ meta_event_detail_to_string (int d)
return detail;
}
#endif /* WITH_VERBOSE_MODE */
#ifdef WITH_VERBOSE_MODE
const char*
meta_event_mode_to_string (int m)
{
......@@ -1936,7 +2026,9 @@ meta_event_mode_to_string (int m)
return mode;
}
#endif /* WITH_VERBOSE_MODE */
#ifdef WITH_VERBOSE_MODE
static const char*
stack_mode_to_string (int mode)
{
......@@ -1956,7 +2048,9 @@ stack_mode_to_string (int mode)
return "Unknown";
}
#endif /* WITH_VERBOSE_MODE */
#ifdef WITH_VERBOSE_MODE
static char*
key_event_description (Display *xdisplay,
XEvent *event)
......@@ -1971,7 +2065,43 @@ key_event_description (Display *xdisplay,
return g_strdup_printf ("Key '%s' state 0x%x",
str ? str : "(null)", event->xkey.state);
}
#endif /* WITH_VERBOSE_MODE */
#ifdef HAVE_XSYNC
#ifdef WITH_VERBOSE_MODE
static gint64
sync_value_to_64 (const XSyncValue *value)
{
gint64 v;
v = XSyncValueLow32 (*value);
v |= (((gint64)XSyncValueHigh32 (*value)) << 32);
return v;
}
#endif /* WITH_VERBOSE_MODE */
#ifdef WITH_VERBOSE_MODE
static const char*
alarm_state_to_string (XSyncAlarmState state)
{
switch (state)
{
case XSyncAlarmActive:
return "Active";
case XSyncAlarmInactive:
return "Inactive";
case XSyncAlarmDestroyed:
return "Destroyed";
default:
return "(unknown)";
}
}
#endif /* WITH_VERBOSE_MODE */
#endif /* HAVE_XSYNC */
#ifdef WITH_VERBOSE_MODE
static void
meta_spew_event (MetaDisplay *display,
XEvent *event)
......@@ -2207,8 +2337,30 @@ meta_spew_event (MetaDisplay *display,
name = "MappingNotify";
break;
default:
name = "(Unknown event)";
extra = g_strdup_printf ("type: %d", event->xany.type);
#ifdef HAVE_XSYNC
if (META_DISPLAY_HAS_XSYNC (display) &&
event->type == (display->xsync_event_base + XSyncAlarmNotify))
{
XSyncAlarmNotifyEvent *aevent = (XSyncAlarmNotifyEvent*) event;
name = "XSyncAlarmNotify";
extra =
g_strdup_printf ("alarm: 0x%lx"
" counter_value: %" G_GINT64_FORMAT
" alarm_value: %" G_GINT64_FORMAT
" time: %u alarm state: %s",
aevent->alarm,
(gint64) sync_value_to_64 (&aevent->counter_value),
(gint64) sync_value_to_64 (&aevent->alarm_value),
(unsigned int) aevent->time,
alarm_state_to_string (aevent->state));
}
else
#endif /* HAVE_XSYNC */
{
name = "(Unknown event)";
extra = g_strdup_printf ("type: %d", event->xany.type);
}
break;
}
......@@ -2230,6 +2382,7 @@ meta_spew_event (MetaDisplay *display,
if (extra)
g_free (extra);
}
#endif /* WITH_VERBOSE_MODE */
MetaWindow*
meta_display_lookup_x_window (MetaDisplay *display,
......@@ -2385,8 +2538,8 @@ meta_display_set_grab_op_cursor (MetaDisplay *display,
cursor = xcursor_for_op (display, op);
#define GRAB_MASK (PointerMotionMask | PointerMotionHintMask | \
ButtonPressMask | ButtonReleaseMask | \
#define GRAB_MASK (PointerMotionMask | \
ButtonPressMask | ButtonReleaseMask | \
EnterWindowMask | LeaveWindowMask)
if (change_pointer)
......@@ -2515,9 +2668,14 @@ 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_latest_motion_x = root_x;
display->grab_latest_motion_y = root_y;
display->grab_last_moveresize_time.tv_sec = 0;
display->grab_last_moveresize_time.tv_usec = 0;
#ifdef HAVE_XSYNC
display->grab_update_alarm = None;
#endif
if (display->grab_window)
{
display->grab_initial_window_pos = display->grab_window->rect;
......@@ -2525,6 +2683,46 @@ meta_display_begin_grab_op (MetaDisplay *display,
&display->grab_initial_window_pos.x,
&display->grab_initial_window_pos.y);
display->grab_current_window_pos = display->grab_initial_window_pos;
#ifdef HAVE_XSYNC
if (meta_grab_op_is_resizing (display->grab_op) &&
display->grab_window->update_counter != None)
{
XSyncAlarmAttributes values;
/* trigger when we make a positive transition to a value
* one higher than the current value.
*/
values.trigger.counter = display->grab_window->update_counter;
values.trigger.value_type = XSyncRelative;
values.trigger.test_type = XSyncPositiveTransition;
XSyncIntToValue (&values.trigger.wait_value, 1);
/* After triggering, increment test_value by this.
* (NOT wait_value above)
*/
XSyncIntToValue (&values.delta, 1);
/* we want events (on by default anyway) */
values.events = True;
meta_error_trap_push_with_return (display);
display->grab_update_alarm = XSyncCreateAlarm (display->xdisplay,
XSyncCACounter |
XSyncCAValueType |
XSyncCAValue |
XSyncCATestType |
XSyncCADelta |
XSyncCAEvents,
&values);
if (meta_error_trap_pop_with_return (display, FALSE) != Success)
display->grab_update_alarm = None;
meta_topic (META_DEBUG_RESIZING,
"Created update alarm 0x%lx\n",
display->grab_update_alarm);
}
#endif
}
meta_topic (META_DEBUG_WINDOW_OPS,
......@@ -2604,6 +2802,14 @@ meta_display_end_grab_op (MetaDisplay *display,
else
meta_screen_ungrab_all_keys (display->grab_screen);
}
#ifdef HAVE_XSYNC
if (display->grab_update_alarm != None)
{
XSyncDestroyAlarm (display->xdisplay,
display->grab_update_alarm);
}
#endif /* HAVE_XSYNC */
display->grab_window = NULL;
display->grab_screen = NULL;
......
......@@ -2,6 +2,7 @@
/*
* Copyright (C) 2001 Havoc Pennington
* Copyright (C) 2002 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -35,6 +36,10 @@
#include <libsn/sn.h>
#endif
#ifdef HAVE_XSYNC
#include <X11/extensions/sync.h>
#endif
#define meta_XFree(p) do { if ((p)) XFree ((p)); } while (0)
/* this doesn't really belong here, oh well. */
......@@ -162,6 +167,8 @@ struct _MetaDisplay
Atom atom_net_wm_state_below;
Atom atom_net_startup_id;
Atom atom_metacity_toggle_verbose;
Atom atom_metacity_update_counter;
Atom atom_sync_counter;
/* This is the actual window from focus events,
* not the one we last set
......@@ -229,6 +236,8 @@ struct _MetaDisplay
int grab_initial_root_y;
int grab_current_root_x;
int grab_current_root_y;
int grab_latest_motion_x;
int grab_latest_motion_y;
gulong grab_mask;
guint grab_have_pointer : 1;
guint grab_have_keyboard : 1;
......@@ -236,7 +245,10 @@ struct _MetaDisplay
MetaRectangle grab_current_window_pos;
MetaResizePopup *grab_resize_popup;
GTimeVal grab_last_moveresize_time;
#ifdef HAVE_XSYNC
/* alarm monitoring client's _METACITY_UPDATE_COUNTER */
XSyncAlarm grab_update_alarm;
#endif
/* Keybindings stuff */
MetaKeyBinding *screen_bindings;
......@@ -275,11 +287,15 @@ struct _MetaDisplay
MetaGroupPropHooks *group_prop_hooks;
#ifdef HAVE_STARTUP_NOTIFICATION
/* This is at the end in case someone doesn't include config.h before this file
* the results won't be catastrophic
*/
SnDisplay *sn_display;
#endif
#ifdef HAVE_XSYNC
int xsync_event_base;
int xsync_error_base;
#define META_DISPLAY_HAS_XSYNC(display) ((display)->xsync_event_base != 0)
#else
#define META_DISPLAY_HAS_XSYNC(display) FALSE
#endif
};
gboolean meta_display_open (const char *name);
......@@ -399,6 +415,9 @@ MetaWindow* meta_display_get_tab_current (MetaDisplay *display,
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_rectangle_intersect (MetaRectangle *src1,
MetaRectangle *src2,
MetaRectangle *dest);
......
......@@ -280,6 +280,8 @@ topic_name (MetaDebugTopic topic)
return "PREFS";
case META_DEBUG_GROUPS:
return "GROUPS";
case META_DEBUG_RESIZING:
return "RESIZING";
}
return "Window manager";
......
......@@ -64,7 +64,8 @@ typedef enum
META_DEBUG_ERRORS = 1 << 14,
META_DEBUG_STARTUP = 1 << 15,
META_DEBUG_PREFS = 1 << 16,
META_DEBUG_GROUPS = 1 << 17
META_DEBUG_GROUPS = 1 << 17,
META_DEBUG_RESIZING = 1 << 18
} MetaDebugTopic;
......
......@@ -412,7 +412,32 @@ reload_net_startup_id (MetaWindow *window,
window->desc);
}
#define N_HOOKS 23
static void
init_update_counter (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_SYNC_COUNTER;
value->atom = display->atom_metacity_update_counter;
}
static void
reload_update_counter (MetaWindow *window,
MetaPropValue *value)
{
if (value->type != META_PROP_VALUE_INVALID)
{
#ifdef HAVE_XSYNC
XSyncCounter counter = value->v.xcounter;
window->update_counter = counter;
meta_verbose ("Window has _METACITY_UPDATE_COUNTER 0x%lx\n",
window->update_counter);
#endif
}
}
#define N_HOOKS 24
void
meta_display_init_window_prop_hooks (MetaDisplay *display)
......@@ -541,6 +566,11 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
hooks[i].init_func = init_net_startup_id;
hooks[i].reload_func = reload_net_startup_id;
++i;
hooks[i].property = display->atom_metacity_update_counter;
hooks[i].init_func = init_update_counter;
hooks[i].reload_func = reload_update_counter;
++i;
if (i != N_HOOKS)
g_error ("Initialized %d hooks should have been %d\n", i, N_HOOKS);
......
......@@ -159,7 +159,7 @@ meta_window_new (MetaDisplay *display,
GSList *tmp;
MetaWorkspace *space;
gulong existing_wm_state;
#define N_INITIAL_PROPS 9
#define N_INITIAL_PROPS 10
Atom initial_props[N_INITIAL_PROPS];
int i;
......@@ -280,12 +280,16 @@ meta_window_new (MetaDisplay *display,
window->dialog_pipe = -1;
window->xwindow = xwindow;
/* this is in window->screen->display, but that's too annoying to
* type
*/
window->display = display;
window->workspaces = NULL;
#ifdef HAVE_XSYNC
window->update_counter = None;
#endif
window->screen = NULL;
tmp = display->screens;
......@@ -443,6 +447,7 @@ meta_window_new (MetaDisplay *display,
initial_props[i++] = display->atom_net_wm_desktop;
initial_props[i++] = display->atom_win_workspace;
initial_props[i++] = display->atom_net_startup_id;
initial_props[i++] = display->atom_metacity_update_counter;
g_assert (N_INITIAL_PROPS == i);
meta_window_reload_properties (window, initial_props, N_INITIAL_PROPS);
......@@ -4138,6 +4143,13 @@ process_property_notify (MetaWindow *window,
meta_window_reload_property (window,
window->display->atom_net_startup_id);
}
else if (event->atom == window->display->atom_metacity_update_counter)
{
meta_verbose ("Property notify on %s for _METACITY_UPDATE_COUNTER\n", window->desc);
meta_window_reload_property (window,
window->display->atom_metacity_update_counter);
}
return TRUE;
}
......@@ -6064,37 +6076,6 @@ meta_window_show_menu (MetaWindow *window,
meta_ui_window_menu_popup (menu, root_x, root_y, button, timestamp);
}
static gboolean
window_query_root_pointer (MetaWindow *window,
int *x, int *y)
{
Window root_return, child_return;
int root_x_return, root_y_return;
int win_x_return, win_y_return;
unsigned int mask_return;
meta_error_trap_push (window->display);
XQueryPointer (window->display->xdisplay,
window->xwindow,
&root_return,
&child_return,
&root_x_return,
&root_y_return,
&win_x_return,
&win_y_return,
&mask_return);
meta_error_trap_pop (window->display, TRUE);
if (x)
*x = root_x_return;
if (y)
*y = root_y_return;
return root_return == window->screen->xroot;
}
static void
clear_moveresize_time (MetaWindow *window)
{
......@@ -6108,6 +6089,7 @@ check_moveresize_frequency (MetaWindow *window)
{
GTimeVal current_time;
double elapsed;
double max_resizes_per_second;
g_get_current_time (&current_time);
......@@ -6116,12 +6098,24 @@ check_moveresize_frequency (MetaWindow *window)
((((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 EPSILON (1e-6)
#define MAX_RESIZES_PER_SECOND 20.0
if (elapsed >= 0.0 && elapsed < (1000.0 / MAX_RESIZES_PER_SECOND))
#ifdef HAVE_XSYNC
if (window->display->grab_update_alarm != None)
max_resizes_per_second = 1.0; /* this is max resizes without
* getting any alarms; we resize
* immediately if we get one.
* i.e. this is a timeout for the
* client getting stuck.
*/
else
#endif /* HAVE_XSYNC */
max_resizes_per_second = 20.0;
#define EPSILON (1e-6)
if (elapsed >= 0.0 && elapsed < (1000.0 / max_resizes_per_second))
{
meta_verbose ("Delaying move/resize as only %g of %g seconds elapsed\n",
elapsed / 1000.0, 1.0 / MAX_RESIZES_PER_SECOND);
meta_topic (META_DEBUG_RESIZING,
"Delaying move/resize as only %g of %g seconds elapsed\n",
elapsed / 1000.0, 1.0 / max_resizes_per_second);
return FALSE;
}
else if (elapsed < (0.0 - EPSILON)) /* handle clock getting set backward */
......@@ -6129,9 +6123,10 @@ check_moveresize_frequency (MetaWindow *window)
/* store latest time */
window->display->grab_last_moveresize_time = current_time;
meta_verbose ("Doing move/resize as %g of %g seconds elapsed\n",
elapsed / 1000.0, 1.0 / MAX_RESIZES_PER_SECOND);
meta_topic (META_DEBUG_RESIZING,
" Doing move/resize now (%g of %g seconds elapsed)\n",
elapsed / 1000.0, 1.0 / max_resizes_per_second);
return TRUE;
}
......@@ -6144,6 +6139,10 @@ update_move (MetaWindow *window,
{
int dx, dy;
int new_x, new_y;
int move_threshold;
window->display->grab_latest_motion_x = x;
window->display->grab_latest_motion_y = y;