diff options
author | Thomas Thurman <tthurman@gnome.org> | 2008-11-22 19:02:54 +0000 |
---|---|---|
committer | Thomas James Alexander Thurman <tthurman@src.gnome.org> | 2008-11-22 19:02:54 +0000 |
commit | ac365b4ead0789ac95a23f33ec831eaa99dd210c (patch) | |
tree | 5c3935140657264ed2de02c17bd9c3aa17362e8c /src/core/keybindings.c | |
parent | a06d96316e046e5298a54b8eff13081560ca0cda (diff) | |
download | metacity-ac365b4ead0789ac95a23f33ec831eaa99dd210c.tar.gz |
(Apologies for huge commit; these were done on a transatlantic flight. This is why we need bzr.)
2008-11-22 Thomas Thurman <tthurman@gnome.org>
* src/core/all-keybindings.h: "backward", not "backwards" throughout.
2008-11-20 Thomas Thurman <tthurman@gnome.org>
* configure.in: turned on -Wall and -Werror in order to
trap as many problems as possible.
* src/ui/resizepopup.c: added correct #include.
* src/ui/theme-viewer.c: initialised variable.
* src/core/xprops.c: corrected cast.
* src/core/main.c: added warning if chdir() fails.
* src/core/schema-bindings.c: checking the return
result of fgets().
2008-11-20 Thomas Thurman <tthurman@gnome.org>
Merged screen and window keybinding tables so that
we can use just one file for the both. Also incidentally
closes #528337. Further efficiencies of scale to come.
* src/include/prefs.h: replace META_PREF_*_KEYBINDINGS
with META_PREF_KEYBINDINGS
* src/core/keybindings.c: replace *_bindings with key_bindings
and similar throughout; all window-based functions are now
guaranteed to receive a window so don't need to check for
themselves
(find_handler): moved so it can also be called from
rebuild_binding_table
* src/core/display-private.h: replace *_bindings with key_bindings
* src/core/prefs.c: update_*_binding becomes update_key_binding;
(change_notify): tidy up references to "enormous if statement"
since it's almost entirely gone now
* src/core/all-keybindings.h: new merged version of
screen-bindings.h and window-bindings.h.
svn path=/trunk/; revision=4022
Diffstat (limited to 'src/core/keybindings.c')
-rw-r--r-- | src/core/keybindings.c | 540 |
1 files changed, 202 insertions, 338 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 6b733d7c..66b8294f 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -63,8 +63,7 @@ handler (MetaDisplay *display,\ MetaWindow *window,\ XEvent *event,\ MetaKeyBinding *binding); -#include "window-bindings.h" -#include "screen-bindings.h" +#include "all-keybindings.h" #undef keybind /* These can't be bound to anything, but they are used to handle @@ -106,8 +105,7 @@ static gboolean process_workspace_switch_grab (MetaDisplay *display, XEvent *event, KeySym keysym); -static void regrab_screen_bindings (MetaDisplay *display); -static void regrab_window_bindings (MetaDisplay *display); +static void regrab_key_bindings (MetaDisplay *display); typedef struct { @@ -128,16 +126,8 @@ struct _MetaKeyBinding #define keybind(name, handler, param, flags, stroke, description) \ { #name, handler, param, flags }, -static const MetaKeyHandler screen_handlers[] = { -#include "screen-bindings.h" - { NULL, NULL, 0, 0 } -}; - -static const MetaKeyHandler window_handlers[] = { -/* TODO: Are window bindings only ever called on non-null windows? - * If so, we can remove the check from all of them. - */ -#include "window-bindings.h" +static const MetaKeyHandler key_handlers[] = { +#include "all-keybindings.h" { NULL, NULL, 0, 0 } }; #undef keybind @@ -264,32 +254,17 @@ reload_keycodes (MetaDisplay *display) { meta_topic (META_DEBUG_KEYBINDINGS, "Reloading keycodes for binding tables\n"); - - if (display->screen_bindings) - { - int i; - - i = 0; - while (i < display->n_screen_bindings) - { - if (display->screen_bindings[i].keycode == 0) - display->screen_bindings[i].keycode = XKeysymToKeycode ( - display->xdisplay, display->screen_bindings[i].keysym); - - ++i; - } - } - if (display->window_bindings) + if (display->key_bindings) { int i; i = 0; - while (i < display->n_window_bindings) + while (i < display->n_key_bindings) { - if (display->window_bindings[i].keycode == 0) - display->window_bindings[i].keycode = XKeysymToKeycode ( - display->xdisplay, display->window_bindings[i].keysym); + if (display->key_bindings[i].keycode == 0) + display->key_bindings[i].keycode = XKeysymToKeycode ( + display->xdisplay, display->key_bindings[i].keysym); ++i; } @@ -302,49 +277,29 @@ reload_modifiers (MetaDisplay *display) meta_topic (META_DEBUG_KEYBINDINGS, "Reloading keycodes for binding tables\n"); - if (display->screen_bindings) - { - int i; - - i = 0; - while (i < display->n_screen_bindings) - { - meta_display_devirtualize_modifiers (display, - display->screen_bindings[i].modifiers, - &display->screen_bindings[i].mask); - - meta_topic (META_DEBUG_KEYBINDINGS, - " Devirtualized mods 0x%x -> 0x%x (%s)\n", - display->screen_bindings[i].modifiers, - display->screen_bindings[i].mask, - display->screen_bindings[i].name); - - ++i; - } - } - - if (display->window_bindings) + if (display->key_bindings) { int i; i = 0; - while (i < display->n_window_bindings) + while (i < display->n_key_bindings) { meta_display_devirtualize_modifiers (display, - display->window_bindings[i].modifiers, - &display->window_bindings[i].mask); + display->key_bindings[i].modifiers, + &display->key_bindings[i].mask); meta_topic (META_DEBUG_KEYBINDINGS, " Devirtualized mods 0x%x -> 0x%x (%s)\n", - display->window_bindings[i].modifiers, - display->window_bindings[i].mask, - display->window_bindings[i].name); + display->key_bindings[i].modifiers, + display->key_bindings[i].mask, + display->key_bindings[i].name); ++i; } } } + static int count_bindings (const MetaKeyPref *prefs, int n_prefs) @@ -380,6 +335,25 @@ count_bindings (const MetaKeyPref *prefs, return count; } +/* FIXME: replace this with a temporary hash */ +static const MetaKeyHandler* +find_handler (const MetaKeyHandler *handlers, + const char *name) +{ + const MetaKeyHandler *iter; + + iter = handlers; + while (iter->name) + { + if (strcmp (iter->name, name) == 0) + return iter; + + ++iter; + } + + return NULL; +} + static void rebuild_binding_table (MetaDisplay *display, MetaKeyBinding **bindings_p, @@ -406,7 +380,10 @@ rebuild_binding_table (MetaDisplay *display, if (combo && (combo->keysym != None || combo->keycode != 0)) { + const MetaKeyHandler *handler = find_handler (key_handlers, prefs[src].name); + (*bindings_p)[dest].name = prefs[src].name; + (*bindings_p)[dest].handler = handler; (*bindings_p)[dest].keysym = combo->keysym; (*bindings_p)[dest].keycode = combo->keycode; (*bindings_p)[dest].modifiers = combo->modifiers; @@ -422,6 +399,7 @@ rebuild_binding_table (MetaDisplay *display, prefs[src].name); (*bindings_p)[dest].name = prefs[src].name; + (*bindings_p)[dest].handler = handler; (*bindings_p)[dest].keysym = combo->keysym; (*bindings_p)[dest].keycode = combo->keycode; (*bindings_p)[dest].modifiers = combo->modifiers | @@ -448,41 +426,26 @@ rebuild_binding_table (MetaDisplay *display, } static void -rebuild_screen_binding_table (MetaDisplay *display) +rebuild_key_binding_table (MetaDisplay *display) { const MetaKeyPref *prefs; int n_prefs; meta_topic (META_DEBUG_KEYBINDINGS, - "Rebuilding screen binding table from preferences\n"); + "Rebuilding key binding table from preferences\n"); - meta_prefs_get_screen_bindings (&prefs, &n_prefs); + meta_prefs_get_key_bindings (&prefs, &n_prefs); rebuild_binding_table (display, - &display->screen_bindings, - &display->n_screen_bindings, + &display->key_bindings, + &display->n_key_bindings, prefs, n_prefs); } static void -rebuild_window_binding_table (MetaDisplay *display) -{ - const MetaKeyPref *prefs; - int n_prefs; - - meta_topic (META_DEBUG_KEYBINDINGS, - "Rebuilding window binding table from preferences\n"); - - meta_prefs_get_window_bindings (&prefs, &n_prefs); - rebuild_binding_table (display, - &display->window_bindings, - &display->n_window_bindings, - prefs, n_prefs); -} - -static void -regrab_screen_bindings (MetaDisplay *display) +regrab_key_bindings (MetaDisplay *display) { GSList *tmp; + GSList *windows; meta_error_trap_push (display); /* for efficiency push outer trap */ @@ -497,18 +460,7 @@ regrab_screen_bindings (MetaDisplay *display) tmp = tmp->next; } - meta_error_trap_pop (display, FALSE); -} - -static void -regrab_window_bindings (MetaDisplay *display) -{ - GSList *windows; - GSList *tmp; - windows = meta_display_list_windows (display); - - meta_error_trap_push (display); /* for efficiency push outer trap */ tmp = windows; while (tmp != NULL) { @@ -532,14 +484,14 @@ display_get_keybinding_action (MetaDisplay *display, { int i; - i = display->n_screen_bindings - 1; + i = display->n_key_bindings - 1; while (i >= 0) { - if (display->screen_bindings[i].keysym == keysym && - display->screen_bindings[i].keycode == keycode && - display->screen_bindings[i].mask == mask) + if (display->key_bindings[i].keysym == keysym && + display->key_bindings[i].keycode == keycode && + display->key_bindings[i].mask == mask) { - return meta_prefs_get_keybinding_action (display->screen_bindings[i].name); + return meta_prefs_get_keybinding_action (display->key_bindings[i].name); } --i; @@ -561,8 +513,7 @@ meta_display_process_mapping_event (MetaDisplay *display, reload_modifiers (display); - regrab_screen_bindings (display); - regrab_window_bindings (display); + regrab_key_bindings (display); } else if (event->xmapping.request == MappingKeyboard) { @@ -574,8 +525,7 @@ meta_display_process_mapping_event (MetaDisplay *display, reload_keycodes (display); - regrab_screen_bindings (display); - regrab_window_bindings (display); + regrab_key_bindings (display); } } @@ -589,17 +539,11 @@ bindings_changed_callback (MetaPreference pref, switch (pref) { - case META_PREF_SCREEN_KEYBINDINGS: - rebuild_screen_binding_table (display); + case META_PREF_KEYBINDINGS: + rebuild_key_binding_table (display); reload_keycodes (display); reload_modifiers (display); - regrab_screen_bindings (display); - break; - case META_PREF_WINDOW_KEYBINDINGS: - rebuild_window_binding_table (display); - reload_keycodes (display); - reload_modifiers (display); - regrab_window_bindings (display); + regrab_key_bindings (display); break; default: break; @@ -622,10 +566,8 @@ meta_display_init_keys (MetaDisplay *display) display->hyper_mask = 0; display->super_mask = 0; display->meta_mask = 0; - display->screen_bindings = NULL; - display->n_screen_bindings = 0; - display->window_bindings = NULL; - display->n_window_bindings = 0; + display->key_bindings = NULL; + display->n_key_bindings = 0; XDisplayKeycodes (display->xdisplay, &display->min_keycode, @@ -639,8 +581,7 @@ meta_display_init_keys (MetaDisplay *display) reload_keymap (display); reload_modmap (display); - rebuild_window_binding_table (display); - rebuild_screen_binding_table (display); + rebuild_key_binding_table (display); reload_keycodes (display); reload_modifiers (display); @@ -662,8 +603,7 @@ meta_display_shutdown_keys (MetaDisplay *display) if (display->modmap) XFreeModifiermap (display->modmap); - g_free (display->screen_bindings); - g_free (display->window_bindings); + g_free (display->key_bindings); } static const char* @@ -765,7 +705,8 @@ static void grab_keys (MetaKeyBinding *bindings, int n_bindings, MetaDisplay *display, - Window xwindow) + Window xwindow, + gboolean binding_per_window) { int i; @@ -776,7 +717,9 @@ grab_keys (MetaKeyBinding *bindings, i = 0; while (i < n_bindings) { - if (bindings[i].keycode != 0) + if (!!binding_per_window == + !!(bindings[i].handler->flags & BINDING_PER_WINDOW) && + bindings[i].keycode != 0) { meta_grab_key (display, xwindow, bindings[i].keysym, @@ -825,9 +768,10 @@ meta_screen_grab_keys (MetaScreen *screen) if (screen->keys_grabbed) return; - grab_keys (screen->display->screen_bindings, - screen->display->n_screen_bindings, - screen->display, screen->xroot); + grab_keys (screen->display->key_bindings, + screen->display->n_key_bindings, + screen->display, screen->xroot, + FALSE); screen->keys_grabbed = TRUE; } @@ -867,10 +811,11 @@ meta_window_grab_keys (MetaWindow *window) return; /* already all good */ } - grab_keys (window->display->window_bindings, - window->display->n_window_bindings, + grab_keys (window->display->key_bindings, + window->display->n_key_bindings, window->display, - window->frame ? window->frame->xwindow : window->xwindow); + window->frame ? window->frame->xwindow : window->xwindow, + TRUE); window->keys_grabbed = TRUE; window->grab_on_frame = window->frame != NULL; @@ -1214,83 +1159,67 @@ primary_modifier_still_pressed (MetaDisplay *display, return TRUE; } -static const MetaKeyHandler* -find_handler (const MetaKeyHandler *handlers, - const char *name) -{ - const MetaKeyHandler *iter; - - iter = handlers; - while (iter->name) - { - if (strcmp (iter->name, - name) == 0) - return iter; - - ++iter; - } - - return NULL; -} - +/* now called from only one place, may be worth merging */ static gboolean process_event (MetaKeyBinding *bindings, int n_bindings, - const MetaKeyHandler *handlers, MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, - KeySym keysym) + KeySym keysym, + gboolean on_window) { int i; /* we used to have release-based bindings but no longer. */ if (event->type == KeyRelease) return FALSE; - - i = 0; - while (i < n_bindings) + + /* + * TODO: This would be better done with a hash table; + * it doesn't suit to use O(n) for such a common operation. + */ + for (i=0; i<n_bindings; i++) { - if (bindings[i].keycode == event->xkey.keycode && - ((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) == - bindings[i].mask) && - event->type == KeyPress) - { - const MetaKeyHandler *handler; + const MetaKeyHandler *handler = bindings[i].handler; - meta_topic (META_DEBUG_KEYBINDINGS, - "Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n", - bindings[i].keycode, bindings[i].mask, - event->xkey.keycode, event->xkey.state); - - if (bindings[i].handler) - handler = bindings[i].handler; - else - { - handler = find_handler (handlers, bindings[i].name); - bindings[i].handler = handler; /* cache */ - } + if ((!on_window && handler->flags & BINDING_PER_WINDOW) || + event->type != KeyPress || + bindings[i].keycode != event->xkey.keycode || + ((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) != + bindings[i].mask)) + continue; + + /* + * window must be non-NULL for on_window to be true, + * and so also window must be non-NULL if we get here and + * this is a BINDING_PER_WINDOW binding. + */ - if (handler == NULL) - meta_bug ("Binding %s has no handler\n", bindings[i].name); - else - meta_topic (META_DEBUG_KEYBINDINGS, - "Running handler for %s\n", - bindings[i].name); + meta_topic (META_DEBUG_KEYBINDINGS, + "Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n", + bindings[i].keycode, bindings[i].mask, + event->xkey.keycode, event->xkey.state); + + if (handler == NULL) + meta_bug ("Binding %s has no handler\n", bindings[i].name); + else + meta_topic (META_DEBUG_KEYBINDINGS, + "Running handler for %s\n", + bindings[i].name); - /* Global keybindings count as a let-the-terminal-lose-focus - * due to new window mapping until the user starts - * interacting with the terminal again. - */ - display->allow_terminal_deactivation = TRUE; + /* Global keybindings count as a let-the-terminal-lose-focus + * due to new window mapping until the user starts + * interacting with the terminal again. + */ + display->allow_terminal_deactivation = TRUE; - (* handler->func) (display, screen, window, event, - &bindings[i]); - return TRUE; - } - - ++i; + (* handler->func) (display, screen, + bindings[i].handler->flags & BINDING_PER_WINDOW? window: NULL, + event, + &bindings[i]); + return TRUE; } meta_topic (META_DEBUG_KEYBINDINGS, @@ -1315,12 +1244,11 @@ meta_display_process_key_event (MetaDisplay *display, XEvent *event) { KeySym keysym; - gboolean handled; gboolean keep_grab; gboolean all_keys_grabbed; const char *str; MetaScreen *screen; - + XAllowEvents (display->xdisplay, all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard, event->xkey.time); @@ -1349,6 +1277,7 @@ meta_display_process_key_event (MetaDisplay *display, str = XKeysymToString (keysym); + /* was topic */ meta_topic (META_DEBUG_KEYBINDINGS, "Processing key %s event, keysym: %s state: 0x%x window: %s\n", event->type == KeyPress ? "press" : "release", @@ -1441,16 +1370,10 @@ meta_display_process_key_event (MetaDisplay *display, } } /* Do the normal keybindings */ - handled = process_event (display->screen_bindings, - display->n_screen_bindings, - screen_handlers, - display, screen, NULL, event, keysym); - - if (!all_keys_grabbed && !handled && window) - handled = process_event (display->window_bindings, - display->n_window_bindings, - window_handlers, - display, screen, window, event, keysym); + process_event (display->key_bindings, + display->n_key_bindings, + display, screen, window, event, keysym, + !all_keys_grabbed && window); } static gboolean @@ -2480,7 +2403,7 @@ handle_maximize_vertically (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window && window->has_resize_func) + if (window->has_resize_func) { if (window->maximized_vertically) meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL); @@ -2496,7 +2419,7 @@ handle_maximize_horizontally (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window && window->has_resize_func) + if (window->has_resize_func) { if (window->maximized_horizontally) meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL); @@ -2564,10 +2487,7 @@ handle_move_to_corner_nw (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, FALSE); - } + handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, FALSE); } static void @@ -2577,10 +2497,7 @@ handle_move_to_corner_ne (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, FALSE); - } + handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, FALSE); } static void @@ -2590,10 +2507,7 @@ handle_move_to_corner_sw (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, TRUE); - } + handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, TRUE); } static void @@ -2603,10 +2517,7 @@ handle_move_to_corner_se (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, TRUE); - } + handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, TRUE); } static void @@ -2616,10 +2527,7 @@ handle_move_to_side_n (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, FALSE); - } + handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, FALSE); } static void @@ -2629,10 +2537,7 @@ handle_move_to_side_s (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, TRUE); - } + handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, TRUE); } static void @@ -2642,10 +2547,7 @@ handle_move_to_side_e (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, TRUE, FALSE); - } + handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, TRUE, FALSE); } static void @@ -2655,10 +2557,7 @@ handle_move_to_side_w (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, FALSE, FALSE); - } + handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, FALSE, FALSE); } static void @@ -2673,9 +2572,6 @@ handle_move_to_center (MetaDisplay *display, int orig_x, orig_y; int frame_width, frame_height; - if (!window) - return; - meta_window_get_work_area_all_xineramas (window, &work_area); meta_window_get_outer_rect (window, &outer); meta_window_get_position (window, &orig_x, &orig_y); @@ -3074,13 +2970,10 @@ handle_toggle_fullscreen (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - if (window->fullscreen) - meta_window_unmake_fullscreen (window); - else if (window->has_fullscreen_func) - meta_window_make_fullscreen (window); - } + if (window->fullscreen) + meta_window_unmake_fullscreen (window); + else if (window->has_fullscreen_func) + meta_window_make_fullscreen (window); } static void @@ -3090,13 +2983,10 @@ handle_toggle_above (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - if (window->wm_state_above) - meta_window_unmake_above (window); - else - meta_window_make_above (window); - } + if (window->wm_state_above) + meta_window_unmake_above (window); + else + meta_window_make_above (window); } static void @@ -3106,17 +2996,14 @@ handle_toggle_maximized (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - if (META_WINDOW_MAXIMIZED (window)) - meta_window_unmaximize (window, - META_MAXIMIZE_HORIZONTAL | - META_MAXIMIZE_VERTICAL); - else if (window->has_maximize_func) - meta_window_maximize (window, - META_MAXIMIZE_HORIZONTAL | - META_MAXIMIZE_VERTICAL); - } + if (META_WINDOW_MAXIMIZED (window)) + meta_window_unmaximize (window, + META_MAXIMIZE_HORIZONTAL | + META_MAXIMIZE_VERTICAL); + else if (window->has_maximize_func) + meta_window_maximize (window, + META_MAXIMIZE_HORIZONTAL | + META_MAXIMIZE_VERTICAL); } static void @@ -3126,13 +3013,10 @@ handle_maximize (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - if (window->has_maximize_func) - meta_window_maximize (window, - META_MAXIMIZE_HORIZONTAL | - META_MAXIMIZE_VERTICAL); - } + if (window->has_maximize_func) + meta_window_maximize (window, + META_MAXIMIZE_HORIZONTAL | + META_MAXIMIZE_VERTICAL); } static void @@ -3142,13 +3026,10 @@ handle_unmaximize (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - if (window->maximized_vertically || window->maximized_horizontally) - meta_window_unmaximize (window, - META_MAXIMIZE_HORIZONTAL | - META_MAXIMIZE_VERTICAL); - } + if (window->maximized_vertically || window->maximized_horizontally) + meta_window_unmaximize (window, + META_MAXIMIZE_HORIZONTAL | + META_MAXIMIZE_VERTICAL); } static void @@ -3158,13 +3039,10 @@ handle_toggle_shaded (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - if (window->shaded) - meta_window_unshade (window, event->xkey.time); - else if (window->has_shade_func) - meta_window_shade (window, event->xkey.time); - } + if (window->shaded) + meta_window_unshade (window, event->xkey.time); + else if (window->has_shade_func) + meta_window_shade (window, event->xkey.time); } static void @@ -3174,9 +3052,8 @@ handle_close (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - if (window->has_close_func) - meta_window_delete (window, event->xkey.time); + if (window->has_close_func) + meta_window_delete (window, event->xkey.time); } static void @@ -3186,9 +3063,8 @@ handle_minimize (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - if (window->has_minimize_func) - meta_window_minimize (window); + if (window->has_minimize_func) + meta_window_minimize (window); } static void @@ -3198,7 +3074,7 @@ handle_begin_move (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window && window->has_move_func) + if (window->has_move_func) { meta_window_begin_grab_op (window, META_GRAB_OP_KEYBOARD_MOVING, @@ -3214,7 +3090,7 @@ handle_begin_resize (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window && window->has_resize_func) + if (window->has_resize_func) { meta_window_begin_grab_op (window, META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN, @@ -3230,13 +3106,10 @@ handle_toggle_on_all_workspaces (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - if (window->on_all_workspaces) - meta_window_unstick (window); - else - meta_window_stick (window); - } + if (window->on_all_workspaces) + meta_window_unstick (window); + else + meta_window_stick (window); } static void @@ -3258,7 +3131,7 @@ handle_move_to_workspace (MetaDisplay *display, * all of whose members are negative. Such a change is called a flip. */ - if (window == NULL || window->always_sticky) + if (window->always_sticky) return; workspace = NULL; @@ -3302,44 +3175,41 @@ handle_raise_or_lower (MetaDisplay *display, { /* Get window at pointer */ - if (window) - { - MetaWindow *above = NULL; - - /* Check if top */ - if (meta_stack_get_top (window->screen->stack) == window) - { - meta_window_lower (window); - return; - } + MetaWindow *above = NULL; - /* else check if windows in same layer are intersecting it */ + /* Check if top */ + if (meta_stack_get_top (window->screen->stack) == window) + { + meta_window_lower (window); + return; + } - above = meta_stack_get_above (window->screen->stack, window, TRUE); - - while (above) - { - MetaRectangle tmp, win_rect, above_rect; + /* else check if windows in same layer are intersecting it */ + + above = meta_stack_get_above (window->screen->stack, window, TRUE); - if (above->mapped) + while (above) + { + MetaRectangle tmp, win_rect, above_rect; + + if (above->mapped) + { + meta_window_get_outer_rect (window, &win_rect); + meta_window_get_outer_rect (above, &above_rect); + + /* Check if obscured */ + if (meta_rectangle_intersect (&win_rect, &above_rect, &tmp)) { - meta_window_get_outer_rect (window, &win_rect); - meta_window_get_outer_rect (above, &above_rect); - - /* Check if obscured */ - if (meta_rectangle_intersect (&win_rect, &above_rect, &tmp)) - { - meta_window_raise (window); - return; - } + meta_window_raise (window); + return; } + } - above = meta_stack_get_above (window->screen->stack, above, TRUE); - } - - /* window is not obscured */ - meta_window_lower (window); + above = meta_stack_get_above (window->screen->stack, above, TRUE); } + + /* window is not obscured */ + meta_window_lower (window); } static void @@ -3349,10 +3219,7 @@ handle_raise (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - meta_window_raise (window); - } + meta_window_raise (window); } static void @@ -3362,10 +3229,7 @@ handle_lower (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding) { - if (window) - { - meta_window_lower (window); - } + meta_window_lower (window); } static void |