From 6e543fbcfd12ec16b4f3a199a2d7e099c84fc142 Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Tue, 3 Feb 2009 13:20:51 +0000 Subject: [PATCH] Store the default keybinding handler alongside the custom one. This allows us to fall back onto it if the custom handler removes itself. --- src/core/keybindings.c | 24 +++++++++++++++++------- src/include/keybindings.h | 1 + 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 230f3a9e3..446b63e54 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -105,10 +105,10 @@ static void regrab_key_bindings (MetaDisplay *display); #define keybind(name, handler, param, flags, stroke, description) \ - { #name, handler, param, flags, NULL, NULL }, + { #name, handler, handler, param, flags, NULL, NULL }, static MetaKeyHandler key_handlers[] = { #include "all-keybindings.h" - { NULL, NULL, 0, 0, NULL, NULL } + { NULL, NULL, NULL, 0, 0, NULL, NULL } }; #undef keybind @@ -1196,11 +1196,21 @@ process_event (MetaKeyBinding *bindings, */ display->allow_terminal_deactivation = TRUE; - (* handler->func) (display, screen, - bindings[i].handler->flags & BINDING_PER_WINDOW? window: NULL, - event, - &bindings[i], - handler->user_data); + if (handler->func) + (* handler->func) (display, screen, + bindings[i].handler->flags & BINDING_PER_WINDOW ? + window: NULL, + event, + &bindings[i], + handler->user_data); + else + (* handler->default_func) (display, screen, + bindings[i].handler->flags & BINDING_PER_WINDOW ? + window: NULL, + event, + &bindings[i], + NULL); + return TRUE; } diff --git a/src/include/keybindings.h b/src/include/keybindings.h index abd2d7eb4..2619cdd83 100644 --- a/src/include/keybindings.h +++ b/src/include/keybindings.h @@ -36,6 +36,7 @@ typedef struct { const char *name; MetaKeyHandlerFunc func; + MetaKeyHandlerFunc default_func; gint data, flags; gpointer user_data; MetaKeyHandlerDataFreeFunc user_data_free_func;