Prevent rapidly repeated visual bells from hanging metacity. Fixes

2006-01-20  Elijah Newren  <newren gmail com>

	Prevent rapidly repeated visual bells from hanging metacity.
	Fixes #322032.

	* src/display.h (struct MetaDisplay): add a last_bell_time field,
	(XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS macro,
	XERVER_TIME_IS_BEFORE macro): add parentheses around usage of
	macro parameter

	* src/display.c (meta_display_open): initialize last_bell_time,
	(event_callback): don't allow more than one bell per second
This commit is contained in:
Elijah Newren 2006-01-20 22:08:52 +00:00 committed by Elijah Newren
parent 32d4bd6b63
commit af14d9d2a1
3 changed files with 26 additions and 5 deletions

View File

@ -1,3 +1,16 @@
2006-01-20 Elijah Newren <newren gmail com>
Prevent rapidly repeated visual bells from hanging metacity.
Fixes #322032.
* src/display.h (struct MetaDisplay): add a last_bell_time field,
(XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS macro,
XERVER_TIME_IS_BEFORE macro): add parentheses around usage of
macro parameter
* src/display.c (meta_display_open): initialize last_bell_time,
(event_callback): don't allow more than one bell per second
2006-01-20 Elijah Newren <newren gmail com> 2006-01-20 Elijah Newren <newren gmail com>
* src/async-getprop.c: * src/async-getprop.c:

View File

@ -514,6 +514,8 @@ meta_display_open (const char *name)
display->grab_resize_timeout_id = 0; display->grab_resize_timeout_id = 0;
display->grab_have_keyboard = FALSE; display->grab_have_keyboard = FALSE;
display->last_bell_time = 0;
display->grab_op = META_GRAB_OP_NONE; display->grab_op = META_GRAB_OP_NONE;
display->grab_wireframe_active = FALSE; display->grab_wireframe_active = FALSE;
display->grab_window = NULL; display->grab_window = NULL;
@ -2366,7 +2368,12 @@ event_callback (XEvent *event,
switch (xkb_ev->xkb_type) switch (xkb_ev->xkb_type)
{ {
case XkbBellNotify: case XkbBellNotify:
if (XSERVER_TIME_IS_BEFORE(display->last_bell_time,
xkb_ev->time - 1000))
{
display->last_bell_time = xkb_ev->time;
meta_bell_notify (display, xkb_ev); meta_bell_notify (display, xkb_ev);
}
break; break;
} }
} }

View File

@ -286,6 +286,7 @@ struct _MetaDisplay
#ifdef HAVE_XKB #ifdef HAVE_XKB
int xkb_base_event_type; int xkb_base_event_type;
Time last_bell_time;
#endif #endif
#ifdef HAVE_XSYNC #ifdef HAVE_XSYNC
/* alarm monitoring client's _NET_WM_SYNC_REQUEST_COUNTER */ /* alarm monitoring client's _NET_WM_SYNC_REQUEST_COUNTER */
@ -381,13 +382,13 @@ struct _MetaDisplay
* the result. * the result.
*/ */
#define XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) \ #define XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) \
( (( time1 < time2 ) && ( time2 - time1 < ((guint32)-1)/2 )) || \ ( (( (time1) < (time2) ) && ( (time2) - (time1) < ((guint32)-1)/2 )) || \
(( time1 > time2 ) && ( time1 - time2 > ((guint32)-1)/2 )) \ (( (time1) > (time2) ) && ( (time1) - (time2) > ((guint32)-1)/2 )) \
) )
#define XSERVER_TIME_IS_BEFORE(time1, time2) \ #define XSERVER_TIME_IS_BEFORE(time1, time2) \
( time1 == 0 || \ ( (time1) == 0 || \
(XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) && \ (XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) && \
time2 != 0) \ (time2) != 0) \
) )
gboolean meta_display_open (const char *name); gboolean meta_display_open (const char *name);