push an error trap around the whole window-key-grab loop

2002-11-06  Havoc Pennington  <hp@pobox.com>

	* 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.
This commit is contained in:
Havoc Pennington 2002-11-06 16:00:56 +00:00 committed by Havoc Pennington
parent 6c18374142
commit c613fed9ef
4 changed files with 83 additions and 15 deletions

View File

@ -1,3 +1,15 @@
2002-11-06 Havoc Pennington <hp@pobox.com>
* 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 <calum.benson@sun.com> 2002-11-05 Calum Benson <calum.benson@sun.com>
* src/themes/Crux/active-restore-button.png: * src/themes/Crux/active-restore-button.png:

View File

@ -1666,10 +1666,34 @@ event_callback (XEvent *event,
} }
break; break;
case MappingNotify: case MappingNotify:
{
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. /* Let XLib know that there is a new keyboard mapping.
*/ */
XRefreshKeyboardMapping (&event->xmapping); XRefreshKeyboardMapping (&event->xmapping);
meta_display_process_mapping_event (display, event); meta_display_process_mapping_event (display, event);
}
}
break; break;
default: default:
break; break;
@ -3311,7 +3335,7 @@ convert_property (MetaDisplay *display,
* can send SelectionNotify * can send SelectionNotify
*/ */
/* FIXME the error trap pop synced anyway, right? */ /* 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); XSync (display->xdisplay, False);
return TRUE; return TRUE;

View File

@ -604,6 +604,8 @@ regrab_screen_bindings (MetaDisplay *display)
{ {
GSList *tmp; GSList *tmp;
meta_error_trap_push (display); /* for efficiency push outer trap */
tmp = display->screens; tmp = display->screens;
while (tmp != NULL) while (tmp != NULL)
{ {
@ -614,6 +616,8 @@ regrab_screen_bindings (MetaDisplay *display)
tmp = tmp->next; tmp = tmp->next;
} }
meta_error_trap_pop (display, FALSE);
} }
static void static void
@ -624,6 +628,7 @@ regrab_window_bindings (MetaDisplay *display)
windows = meta_display_list_windows (display); windows = meta_display_list_windows (display);
meta_error_trap_push (display); /* for efficiency push outer trap */
tmp = windows; tmp = windows;
while (tmp != NULL) while (tmp != NULL)
{ {
@ -634,6 +639,7 @@ regrab_window_bindings (MetaDisplay *display)
tmp = tmp->next; tmp = tmp->next;
} }
meta_error_trap_pop (display, FALSE);
g_slist_free (windows); g_slist_free (windows);
} }
@ -883,6 +889,8 @@ grab_keys (MetaKeyBinding *bindings,
g_assert (n_bindings == 0 || bindings != NULL); g_assert (n_bindings == 0 || bindings != NULL);
meta_error_trap_push (display);
i = 0; i = 0;
while (i < n_bindings) while (i < n_bindings)
{ {
@ -896,24 +904,34 @@ grab_keys (MetaKeyBinding *bindings,
++i; ++i;
} }
meta_error_trap_pop (display, FALSE);
} }
static void static void
ungrab_all_keys (MetaDisplay *display, ungrab_all_keys (MetaDisplay *display,
Window xwindow) Window xwindow)
{ {
int result; if (meta_is_debugging ())
meta_error_trap_push_with_return (display); meta_error_trap_push_with_return (display);
else
meta_error_trap_push (display);
XUngrabKey (display->xdisplay, AnyKey, AnyModifier, XUngrabKey (display->xdisplay, AnyKey, AnyModifier,
xwindow); xwindow);
if (meta_is_debugging ())
{
int result;
result = meta_error_trap_pop_with_return (display, FALSE); result = meta_error_trap_pop_with_return (display, FALSE);
if (result != Success) if (result != Success)
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ungrabbing all keys on 0x%lx failed\n", xwindow); "Ungrabbing all keys on 0x%lx failed\n", xwindow);
}
else
meta_error_trap_pop (display, FALSE);
} }
void void

View File

@ -8,6 +8,10 @@ if test -z "$CLIENT_DISPLAY"; then
CLIENT_DISPLAY=:1 CLIENT_DISPLAY=:1
fi fi
if test -z "$METACITY_DISPLAY"; then
export METACITY_DISPLAY=$CLIENT_DISPLAY
fi
if test -z "$SCREENS"; then if test -z "$SCREENS"; then
SCREENS=1 SCREENS=1
fi fi
@ -52,7 +56,17 @@ if test -z "$ONLY_WM"; then
if test -n "$XMON_DIR"; then if test -n "$XMON_DIR"; then
echo "Launching xmond" 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 sleep 1
fi fi
@ -89,5 +103,5 @@ if test -z "$ONLY_WM"; then
fi fi
if test -z "$ONLY_SETUP"; then 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 fi