From c613fed9ef688d742bfc85fb569b8174938acce0 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 6 Nov 2002 16:00:56 +0000 Subject: [PATCH] push an error trap around the whole window-key-grab loop 2002-11-06 Havoc Pennington * src/keybindings.c (grab_keys): push an error trap around the whole window-key-grab loop (ungrab_all_keys): avoid requiring return value from the error trap, unless in debugging mode (regrab_window_bindings, regrab_screen_bindings): push traps around the loops, for efficiency * src/display.c (event_callback): fix from Padraig O'Briain to compress extra MappingNotify events to avoid extra work. --- ChangeLog | 12 ++++++++++++ src/display.c | 34 +++++++++++++++++++++++++++++----- src/keybindings.c | 34 ++++++++++++++++++++++++++-------- src/run-metacity.sh | 18 ++++++++++++++++-- 4 files changed, 83 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32b39cf7c..cce726ad5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2002-11-06 Havoc Pennington + + * src/keybindings.c (grab_keys): push an error trap around the + whole window-key-grab loop + (ungrab_all_keys): avoid requiring return value from the error + trap, unless in debugging mode + (regrab_window_bindings, regrab_screen_bindings): push traps + around the loops, for efficiency + + * src/display.c (event_callback): fix from Padraig O'Briain to + compress extra MappingNotify events to avoid extra work. + 2002-11-05 Calum Benson * src/themes/Crux/active-restore-button.png: diff --git a/src/display.c b/src/display.c index dd4a37b08..d9b23f7a0 100644 --- a/src/display.c +++ b/src/display.c @@ -1666,10 +1666,34 @@ event_callback (XEvent *event, } break; case MappingNotify: - /* Let XLib know that there is a new keyboard mapping. - */ - XRefreshKeyboardMapping (&event->xmapping); - meta_display_process_mapping_event (display, event); + { + gboolean ignore_current; + + ignore_current = FALSE; + + /* Check whether the next event is an identical MappingNotify + * event. If it is, ignore the current event, we'll update + * when we get the next one. + */ + if (XPending (display->xdisplay)) + { + XEvent next_event; + + XPeekEvent (display->xdisplay, &next_event); + + if (next_event.type == MappingNotify && + next_event.xmapping.request == event->xmapping.request) + ignore_current = TRUE; + } + + if (!ignore_current) + { + /* Let XLib know that there is a new keyboard mapping. + */ + XRefreshKeyboardMapping (&event->xmapping); + meta_display_process_mapping_event (display, event); + } + } break; default: break; @@ -3311,7 +3335,7 @@ convert_property (MetaDisplay *display, * can send SelectionNotify */ /* FIXME the error trap pop synced anyway, right? */ - meta_topic (META_DEBUG_SYNC, "Syncing on %s\n", __FUNCTION__); + meta_topic (META_DEBUG_SYNC, "Syncing on %s\n", G_GNUC_FUNCTION); XSync (display->xdisplay, False); return TRUE; diff --git a/src/keybindings.c b/src/keybindings.c index 80bb068b9..dd162af78 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -604,6 +604,8 @@ regrab_screen_bindings (MetaDisplay *display) { GSList *tmp; + meta_error_trap_push (display); /* for efficiency push outer trap */ + tmp = display->screens; while (tmp != NULL) { @@ -614,6 +616,8 @@ regrab_screen_bindings (MetaDisplay *display) tmp = tmp->next; } + + meta_error_trap_pop (display, FALSE); } static void @@ -624,6 +628,7 @@ regrab_window_bindings (MetaDisplay *display) windows = meta_display_list_windows (display); + meta_error_trap_push (display); /* for efficiency push outer trap */ tmp = windows; while (tmp != NULL) { @@ -634,6 +639,7 @@ regrab_window_bindings (MetaDisplay *display) tmp = tmp->next; } + meta_error_trap_pop (display, FALSE); g_slist_free (windows); } @@ -882,6 +888,8 @@ grab_keys (MetaKeyBinding *bindings, int i; g_assert (n_bindings == 0 || bindings != NULL); + + meta_error_trap_push (display); i = 0; while (i < n_bindings) @@ -896,24 +904,34 @@ grab_keys (MetaKeyBinding *bindings, ++i; } + + meta_error_trap_pop (display, FALSE); } static void ungrab_all_keys (MetaDisplay *display, Window xwindow) { - int result; - - meta_error_trap_push_with_return (display); + if (meta_is_debugging ()) + meta_error_trap_push_with_return (display); + else + meta_error_trap_push (display); XUngrabKey (display->xdisplay, AnyKey, AnyModifier, xwindow); + + if (meta_is_debugging ()) + { + int result; - result = meta_error_trap_pop_with_return (display, FALSE); - - if (result != Success) - meta_topic (META_DEBUG_KEYBINDINGS, - "Ungrabbing all keys on 0x%lx failed\n", xwindow); + result = meta_error_trap_pop_with_return (display, FALSE); + + if (result != Success) + meta_topic (META_DEBUG_KEYBINDINGS, + "Ungrabbing all keys on 0x%lx failed\n", xwindow); + } + else + meta_error_trap_pop (display, FALSE); } void diff --git a/src/run-metacity.sh b/src/run-metacity.sh index e46dae14b..a131033ac 100755 --- a/src/run-metacity.sh +++ b/src/run-metacity.sh @@ -8,6 +8,10 @@ if test -z "$CLIENT_DISPLAY"; then CLIENT_DISPLAY=:1 fi +if test -z "$METACITY_DISPLAY"; then + export METACITY_DISPLAY=$CLIENT_DISPLAY +fi + if test -z "$SCREENS"; then SCREENS=1 fi @@ -52,7 +56,17 @@ if test -z "$ONLY_WM"; then if test -n "$XMON_DIR"; then echo "Launching xmond" - $XMON_DIR/xmonui | $XMON_DIR/xmond -server $XNEST_DISPLAY & + $XMON_DIR/xmonui | $XMON_DIR/xmond -server localhost:$XNEST_DISPLAY & + sleep 1 + fi + + if test -n "$XSCOPE_DIR"; then + ## xscope doesn't like to die when it should, it backgrounds itself + killall -9 xscope + killall -9 xscope + echo "Launching xscope" + DISPLAY= $XSCOPE_DIR/xscope -o1 -i28 > xscoped-replies.txt & + export METACITY_DISPLAY=localhost:28 sleep 1 fi @@ -89,5 +103,5 @@ if test -z "$ONLY_WM"; then fi if test -z "$ONLY_SETUP"; then - METACITY_VERBOSE=1 METACITY_USE_LOGFILE=1 METACITY_DEBUG_BUTTON_GRABS=1 METACITY_DISPLAY=$CLIENT_DISPLAY exec $DEBUG ./metacity $OPTIONS + METACITY_VERBOSE=1 METACITY_USE_LOGFILE=1 METACITY_DEBUG_BUTTON_GRABS=1 exec $DEBUG ./metacity $OPTIONS fi