diff --git a/ChangeLog b/ChangeLog index 949646980..e175b10c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-01-20 Elijah Newren + + 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 * src/async-getprop.c: diff --git a/src/display.c b/src/display.c index fbf6d4b68..aa602f2a5 100644 --- a/src/display.c +++ b/src/display.c @@ -514,6 +514,8 @@ meta_display_open (const char *name) display->grab_resize_timeout_id = 0; display->grab_have_keyboard = FALSE; + display->last_bell_time = 0; + display->grab_op = META_GRAB_OP_NONE; display->grab_wireframe_active = FALSE; display->grab_window = NULL; @@ -2366,7 +2368,12 @@ event_callback (XEvent *event, switch (xkb_ev->xkb_type) { case XkbBellNotify: - meta_bell_notify (display, xkb_ev); + 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); + } break; } } diff --git a/src/display.h b/src/display.h index 0afc5242b..54e5c901e 100644 --- a/src/display.h +++ b/src/display.h @@ -286,6 +286,7 @@ struct _MetaDisplay #ifdef HAVE_XKB int xkb_base_event_type; + Time last_bell_time; #endif #ifdef HAVE_XSYNC /* alarm monitoring client's _NET_WM_SYNC_REQUEST_COUNTER */ @@ -381,13 +382,13 @@ struct _MetaDisplay * the result. */ #define XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) \ - ( (( time1 < time2 ) && ( time2 - time1 < ((guint32)-1)/2 )) || \ - (( time1 > time2 ) && ( time1 - time2 > ((guint32)-1)/2 )) \ + ( (( (time1) < (time2) ) && ( (time2) - (time1) < ((guint32)-1)/2 )) || \ + (( (time1) > (time2) ) && ( (time1) - (time2) > ((guint32)-1)/2 )) \ ) #define XSERVER_TIME_IS_BEFORE(time1, time2) \ - ( time1 == 0 || \ + ( (time1) == 0 || \ (XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) && \ - time2 != 0) \ + (time2) != 0) \ ) gboolean meta_display_open (const char *name);