From cf484079722ea216de2ff84b14c7a998d3f65bd0 Mon Sep 17 00:00:00 2001 From: Thomas Thurman Date: Sat, 6 Sep 2008 22:01:56 +0000 Subject: [PATCH] An attempt to keep all information about window bindings in the same 2008-09-06 Thomas Thurman An attempt to keep all information about window bindings in the same place. Screen bindings to come. * src/core/window-bindings.h: new file, list of all window bindings * src/include/prefs.h: drop all the existing window-binding macros * src/core/schema-bindings.c (): output all the schema blocks that would appear in metacity.schema for these window bindings. This ought to become part of the build process, and hopefully will soon. When this works it will also close #469361. * src/core/keybindings.c: generate handle_* prototypes using x-macros; populate window_handlers using x-macros; rename several functions to have consistent names; do_handle_move_to_workspace(), handle_move_to_workspace_flip(), and handle_move_to_workspace() all merged into handle_move_to_workspace. * src/core/prefs.c: generate window_bindings and window_string_bindings using x-macros; (meta_prefs_set_compositing_manager) fix unrelated problem with use of GConf functions when GConf was disabled. * src/core/core.c (meta_core_get_menu_accelerator): binding names given as literals since this is the only place in the code they now appear svn path=/trunk/; revision=3860 --- ChangeLog | 84 +++++++++++ src/core/core.c | 50 +++---- src/core/keybindings.c | 279 ++++++----------------------------- src/core/prefs.c | 71 ++------- src/core/schema-bindings.c | 88 +++++++++++ src/core/window-bindings.h | 293 +++++++++++++++++++++++++++++++++++++ src/include/prefs.h | 44 ------ 7 files changed, 548 insertions(+), 361 deletions(-) create mode 100644 src/core/schema-bindings.c create mode 100644 src/core/window-bindings.h diff --git a/ChangeLog b/ChangeLog index 769760283..9241d671a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,87 @@ +2008-09-06 Thomas Thurman + + An attempt to keep all information about window bindings + in the same place. Screen bindings to come. + + * src/core/window-bindings.h: new file, list of all window bindings + * src/include/prefs.h: drop all the existing window-binding macros + + * src/core/schema-bindings.c (): output all the schema blocks that + would appear in metacity.schema for these window bindings. This + ought to become part of the build process, and hopefully will soon. + When this works it will also close #469361. + + * src/core/keybindings.c: generate handle_* prototypes using + x-macros; populate window_handlers using x-macros; rename several + functions to have consistent names; do_handle_move_to_workspace(), + handle_move_to_workspace_flip(), and handle_move_to_workspace() all + merged into handle_move_to_workspace. + + * src/core/prefs.c: generate window_bindings and window_string_bindings + using x-macros; (meta_prefs_set_compositing_manager) fix unrelated + problem with use of GConf functions when GConf was disabled. + + * src/core/core.c (meta_core_get_menu_accelerator): binding names + given as literals since this is the only place in the code they + now appear + + +2008-09-06 Thomas Thurman + + An attempt to keep all information about window bindings + in the same place. Screen bindings to come. + + * src/core/window-bindings.h: new file, list of all window bindings + * src/include/prefs.h: drop all the existing window-binding macros + + * src/core/schema-bindings.c (): output all the schema blocks that + would appear in metacity.schema for these window bindings. This + ought to become part of the build process, and hopefully will soon. + When this works it will also close #469361. + + * src/core/keybindings.c: generate handle_* prototypes using + x-macros; populate window_handlers using x-macros; rename several + functions to have consistent names; do_handle_move_to_workspace(), + handle_move_to_workspace_flip(), and handle_move_to_workspace() all + merged into handle_move_to_workspace. + + * src/core/prefs.c: generate window_bindings and window_string_bindings + using x-macros; (meta_prefs_set_compositing_manager) fix unrelated + problem with use of GConf functions when GConf was disabled. + + * src/core/core.c (meta_core_get_menu_accelerator): binding names + given as literals since this is the only place in the code they + now appear + + +2008-09-06 Thomas Thurman + + An attempt to keep all information about window bindings + in the same place. Screen bindings to come. + + * src/core/window-bindings.h: new file, list of all window bindings + * src/include/prefs.h: drop all the existing window-binding macros + + * src/core/schema-bindings.c (): output all the schema blocks that + would appear in metacity.schema for these window bindings. This + ought to become part of the build process, and hopefully will soon. + When this works it will also close #469361. + + * src/core/keybindings.c: generate handle_* prototypes using + x-macros; populate window_handlers using x-macros; rename several + functions to have consistent names; do_handle_move_to_workspace(), + handle_move_to_workspace_flip(), and handle_move_to_workspace() all + merged into handle_move_to_workspace. + + * src/core/prefs.c: generate window_bindings and window_string_bindings + using x-macros; (meta_prefs_set_compositing_manager) fix unrelated + problem with use of GConf functions when GConf was disabled. + + * src/core/core.c (meta_core_get_menu_accelerator): binding names + given as literals since this is the only place in the code they + now appear + + 2008-09-03 Thomas Thurman * src/metacity.desktop.in: removed invalid "Window Manager" group diff --git a/src/core/core.c b/src/core/core.c index 4207d8a56..a63531fea 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -520,87 +520,87 @@ meta_core_get_menu_accelerator (MetaMenuOp menu_op, switch (menu_op) { case META_MENU_OP_DELETE: - name = META_KEYBINDING_CLOSE; + name = "close"; break; case META_MENU_OP_MINIMIZE: - name = META_KEYBINDING_MINIMIZE; + name = "minimize"; break; case META_MENU_OP_UNMAXIMIZE: - name = META_KEYBINDING_UNMAXIMIZE; + name = "unmaximize"; break; case META_MENU_OP_MAXIMIZE: - name = META_KEYBINDING_MAXIMIZE; + name = "maximize"; break; case META_MENU_OP_UNSHADE: case META_MENU_OP_SHADE: - name = META_KEYBINDING_TOGGLE_SHADE; + name = "toggle_shaded"; break; case META_MENU_OP_UNSTICK: case META_MENU_OP_STICK: - name = META_KEYBINDING_TOGGLE_STICKY; + name = "toggle_on_all_workspaces"; break; case META_MENU_OP_ABOVE: case META_MENU_OP_UNABOVE: - name = META_KEYBINDING_TOGGLE_ABOVE; + name = "toggle_above"; break; case META_MENU_OP_WORKSPACES: switch (workspace) { case 1: - name = META_KEYBINDING_MOVE_WORKSPACE_1; + name = "move_to_workspace_1"; break; case 2: - name = META_KEYBINDING_MOVE_WORKSPACE_2; + name = "move_to_workspace_2"; break; case 3: - name = META_KEYBINDING_MOVE_WORKSPACE_3; + name = "move_to_workspace_3"; break; case 4: - name = META_KEYBINDING_MOVE_WORKSPACE_4; + name = "move_to_workspace_4"; break; case 5: - name = META_KEYBINDING_MOVE_WORKSPACE_5; + name = "move_to_workspace_5"; break; case 6: - name = META_KEYBINDING_MOVE_WORKSPACE_6; + name = "move_to_workspace_6"; break; case 7: - name = META_KEYBINDING_MOVE_WORKSPACE_7; + name = "move_to_workspace_7"; break; case 8: - name = META_KEYBINDING_MOVE_WORKSPACE_8; + name = "move_to_workspace_8"; break; case 9: - name = META_KEYBINDING_MOVE_WORKSPACE_9; + name = "move_to_workspace_9"; break; case 10: - name = META_KEYBINDING_MOVE_WORKSPACE_10; + name = "move_to_workspace_10"; break; case 11: - name = META_KEYBINDING_MOVE_WORKSPACE_11; + name = "move_to_workspace_11"; break; case 12: - name = META_KEYBINDING_MOVE_WORKSPACE_12; + name = "move_to_workspace_12"; break; } break; case META_MENU_OP_MOVE: - name = META_KEYBINDING_BEGIN_MOVE; + name = "begin_move"; break; case META_MENU_OP_RESIZE: - name = META_KEYBINDING_BEGIN_RESIZE; + name = "begin_resize"; break; case META_MENU_OP_MOVE_LEFT: - name = META_KEYBINDING_MOVE_WORKSPACE_LEFT; + name = "move_to_workspace_left"; break; case META_MENU_OP_MOVE_RIGHT: - name = META_KEYBINDING_MOVE_WORKSPACE_RIGHT; + name = "move_to_workspace_right"; break; case META_MENU_OP_MOVE_UP: - name = META_KEYBINDING_MOVE_WORKSPACE_UP; + name = "move_to_workspace_up"; break; case META_MENU_OP_MOVE_DOWN: - name = META_KEYBINDING_MOVE_WORKSPACE_DOWN; + name = "move_to_workspace_down"; break; case META_MENU_OP_RECOVER: /* No keybinding for this one */ diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 33fd4bf04..c6e29faa9 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -54,16 +54,22 @@ typedef void (* MetaKeyHandlerFunc) (MetaDisplay *display, XEvent *event, MetaKeyBinding *binding); +/* Prototypes for handlers */ +#define item(name, suffix, param, short, long, stroke) \ +static void \ +handle_##name (MetaDisplay *display,\ + MetaScreen *screen,\ + MetaWindow *window,\ + XEvent *event,\ + MetaKeyBinding *binding); +#include "window-bindings.h" +#undef item + static void handle_activate_workspace (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, MetaKeyBinding *binding); -static void handle_activate_menu (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); static void handle_tab_forward (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, @@ -99,146 +105,16 @@ static void handle_panel_keybinding (MetaDisplay *display, MetaWindow *window, XEvent *event, MetaKeyBinding *binding); -static void handle_toggle_above (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_toggle_maximize (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_maximize (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_unmaximize (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_toggle_shade (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_close_window (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_minimize_window (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_begin_move (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_begin_resize (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_toggle_sticky (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_workspace (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_workspace_flip (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); static void handle_workspace_switch (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, MetaKeyBinding *binding); -static void handle_raise_or_lower (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_raise (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_lower (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); static void handle_run_command (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, MetaKeyBinding *binding); -static void handle_maximize_vert (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_maximize_horiz (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_side_n (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_side_w (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_side_s (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_side_e (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_corner_nw (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_corner_ne (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_corner_sw (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_corner_se (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); -static void handle_move_to_center (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding); static void handle_spew_mark (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, @@ -437,65 +313,17 @@ static const MetaKeyHandler screen_handlers[] = { }; static const MetaKeyHandler window_handlers[] = { - { META_KEYBINDING_WINDOW_MENU, handle_activate_menu, NULL }, - { META_KEYBINDING_TOGGLE_FULLSCREEN, handle_toggle_fullscreen, NULL }, - { META_KEYBINDING_TOGGLE_ABOVE, handle_toggle_above, NULL }, - { META_KEYBINDING_TOGGLE_MAXIMIZE, handle_toggle_maximize, NULL }, - { META_KEYBINDING_MAXIMIZE, handle_maximize, NULL }, - { META_KEYBINDING_UNMAXIMIZE, handle_unmaximize, NULL }, - { META_KEYBINDING_TOGGLE_SHADE, handle_toggle_shade, NULL }, - { META_KEYBINDING_CLOSE, handle_close_window, NULL }, - { META_KEYBINDING_MINIMIZE, handle_minimize_window, NULL }, - { META_KEYBINDING_BEGIN_MOVE, handle_begin_move, }, - { META_KEYBINDING_BEGIN_RESIZE, handle_begin_resize, }, - { META_KEYBINDING_TOGGLE_STICKY, handle_toggle_sticky, }, - { META_KEYBINDING_MOVE_WORKSPACE_1, handle_move_to_workspace, - GINT_TO_POINTER (0) }, - { META_KEYBINDING_MOVE_WORKSPACE_2, handle_move_to_workspace, - GINT_TO_POINTER (1) }, - { META_KEYBINDING_MOVE_WORKSPACE_3, handle_move_to_workspace, - GINT_TO_POINTER (2) }, - { META_KEYBINDING_MOVE_WORKSPACE_4, handle_move_to_workspace, - GINT_TO_POINTER (3) }, - { META_KEYBINDING_MOVE_WORKSPACE_5, handle_move_to_workspace, - GINT_TO_POINTER (4) }, - { META_KEYBINDING_MOVE_WORKSPACE_6, handle_move_to_workspace, - GINT_TO_POINTER (5) }, - { META_KEYBINDING_MOVE_WORKSPACE_7, handle_move_to_workspace, - GINT_TO_POINTER (6) }, - { META_KEYBINDING_MOVE_WORKSPACE_8, handle_move_to_workspace, - GINT_TO_POINTER (7) }, - { META_KEYBINDING_MOVE_WORKSPACE_9, handle_move_to_workspace, - GINT_TO_POINTER (8) }, - { META_KEYBINDING_MOVE_WORKSPACE_10, handle_move_to_workspace, - GINT_TO_POINTER (9) }, - { META_KEYBINDING_MOVE_WORKSPACE_11, handle_move_to_workspace, - GINT_TO_POINTER (10) }, - { META_KEYBINDING_MOVE_WORKSPACE_12, handle_move_to_workspace, - GINT_TO_POINTER (11) }, - { META_KEYBINDING_MOVE_WORKSPACE_LEFT, handle_move_to_workspace_flip, - GINT_TO_POINTER (META_MOTION_LEFT) }, - { META_KEYBINDING_MOVE_WORKSPACE_RIGHT, handle_move_to_workspace_flip, - GINT_TO_POINTER (META_MOTION_RIGHT) }, - { META_KEYBINDING_MOVE_WORKSPACE_UP, handle_move_to_workspace_flip, - GINT_TO_POINTER (META_MOTION_UP) }, - { META_KEYBINDING_MOVE_WORKSPACE_DOWN, handle_move_to_workspace_flip, - GINT_TO_POINTER (META_MOTION_DOWN) }, - { META_KEYBINDING_RAISE_OR_LOWER, handle_raise_or_lower, NULL}, - { META_KEYBINDING_RAISE, handle_raise, NULL}, - { META_KEYBINDING_LOWER, handle_lower, NULL}, - { META_KEYBINDING_MAXIMIZE_VERTICALLY, handle_maximize_vert, NULL }, - { META_KEYBINDING_MAXIMIZE_HORIZONTALLY, handle_maximize_horiz, NULL }, - { META_KEYBINDING_MOVE_TO_SIDE_N, handle_move_to_side_n, NULL }, - { META_KEYBINDING_MOVE_TO_SIDE_S, handle_move_to_side_s, NULL }, - { META_KEYBINDING_MOVE_TO_SIDE_E, handle_move_to_side_e, NULL }, - { META_KEYBINDING_MOVE_TO_SIDE_W, handle_move_to_side_w, NULL }, - { META_KEYBINDING_MOVE_TO_CORNER_NW, handle_move_to_corner_nw, NULL }, - { META_KEYBINDING_MOVE_TO_CORNER_NE, handle_move_to_corner_ne, NULL }, - { META_KEYBINDING_MOVE_TO_CORNER_SW, handle_move_to_corner_sw, NULL }, - { META_KEYBINDING_MOVE_TO_CORNER_SE, handle_move_to_corner_se, NULL }, - { META_KEYBINDING_MOVE_TO_CENTER, handle_move_to_center, NULL }, - { NULL, NULL, NULL } +/* TODO: Eventually, we should stop using GINT_TO_POINTER here, because + * they're always integers. + * + * TODO: Are window bindings only ever called on non-null windows? + * If so, we can remove the check from all of them. + */ +#define item(name, suffix, param, a, b, c) { #name, handle_##name, \ + GINT_TO_POINTER (param) }, +#include "window-bindings.h" +#undef item + { NULL, NULL, NULL } }; static void @@ -2856,7 +2684,7 @@ handle_run_command (MetaDisplay *display, static void -handle_maximize_vert (MetaDisplay *display, +handle_maximize_vertically (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, @@ -2872,7 +2700,7 @@ handle_maximize_vert (MetaDisplay *display, } static void -handle_maximize_horiz (MetaDisplay *display, +handle_maximize_horizontally (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, @@ -3265,7 +3093,7 @@ handle_panel_keybinding (MetaDisplay *display, } static void -handle_activate_menu (MetaDisplay *display, +handle_activate_window_menu (MetaDisplay *display, MetaScreen *screen, MetaWindow *event_window, XEvent *event, @@ -3502,7 +3330,7 @@ handle_toggle_above (MetaDisplay *display, } static void -handle_toggle_maximize (MetaDisplay *display, +handle_toggle_maximized (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, @@ -3554,7 +3382,7 @@ handle_unmaximize (MetaDisplay *display, } static void -handle_toggle_shade (MetaDisplay *display, +handle_toggle_shaded (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, @@ -3570,7 +3398,7 @@ handle_toggle_shade (MetaDisplay *display, } static void -handle_close_window (MetaDisplay *display, +handle_close (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, @@ -3582,7 +3410,7 @@ handle_close_window (MetaDisplay *display, } static void -handle_minimize_window (MetaDisplay *display, +handle_minimize (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, @@ -3626,7 +3454,7 @@ handle_begin_resize (MetaDisplay *display, } static void -handle_toggle_sticky (MetaDisplay *display, +handle_toggle_on_all_workspaces (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, @@ -3642,23 +3470,31 @@ handle_toggle_sticky (MetaDisplay *display, } static void -do_handle_move_to_workspace (MetaDisplay *display, +handle_move_to_workspace (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, XEvent *event, - MetaKeyBinding *binding, - gboolean flip) + MetaKeyBinding *binding) { int which; + gboolean flip; MetaWorkspace *workspace; which = GPOINTER_TO_INT (binding->handler->data); + /* If which is zero or positive, it's a workspace number, and the window + * should move to the workspace with that number. + * + * However, if it's negative, it's a direction with respect to the current + * position; it's expressed as a member of the MetaMotionDirection enum, + * all of whose members are negative. Such a change is called a flip. + */ + flip = (which < 0); if (window == NULL || window->always_sticky) return; workspace = NULL; - if (which < 0) + if (flip) { workspace = meta_workspace_get_neighbor (screen->active_workspace, which); @@ -3676,7 +3512,7 @@ do_handle_move_to_workspace (MetaDisplay *display, { meta_topic (META_DEBUG_FOCUS, "Resetting mouse_mode to FALSE due to " - "do_handle_move_to_workspace() call with flip set.\n"); + "handle_move_to_workspace() call with flip set.\n"); workspace->screen->display->mouse_mode = FALSE; meta_workspace_activate_with_focus (workspace, window, @@ -3689,35 +3525,6 @@ do_handle_move_to_workspace (MetaDisplay *display, } } -static void -handle_move_to_workspace (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding) -{ - do_handle_move_to_workspace (display, - screen, - window, - event, - binding, - FALSE); -} -static void -handle_move_to_workspace_flip (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, - MetaKeyBinding *binding) -{ - do_handle_move_to_workspace (display, - screen, - window, - event, - binding, - TRUE); -} - static void handle_raise_or_lower (MetaDisplay *display, MetaScreen *screen, diff --git a/src/core/prefs.c b/src/core/prefs.c index f8cc3d5ca..dffe71cf2 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -1888,48 +1888,10 @@ static MetaKeyPref screen_bindings[] = { }; static MetaKeyPref window_bindings[] = { - { META_KEYBINDING_WINDOW_MENU, NULL, FALSE }, - { META_KEYBINDING_TOGGLE_FULLSCREEN, NULL, FALSE }, - { META_KEYBINDING_TOGGLE_MAXIMIZE, NULL, FALSE }, - { META_KEYBINDING_TOGGLE_ABOVE, NULL, FALSE }, - { META_KEYBINDING_MAXIMIZE, NULL, FALSE }, - { META_KEYBINDING_UNMAXIMIZE, NULL, FALSE }, - { META_KEYBINDING_TOGGLE_SHADE, NULL, FALSE }, - { META_KEYBINDING_MINIMIZE, NULL, FALSE }, - { META_KEYBINDING_CLOSE, NULL, FALSE }, - { META_KEYBINDING_BEGIN_MOVE, NULL, FALSE }, - { META_KEYBINDING_BEGIN_RESIZE, NULL, FALSE }, - { META_KEYBINDING_TOGGLE_STICKY, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_1, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_2, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_3, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_4, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_5, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_6, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_7, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_8, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_9, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_10, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_11, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_12, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_LEFT, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_RIGHT, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_UP, NULL, FALSE }, - { META_KEYBINDING_MOVE_WORKSPACE_DOWN, NULL, FALSE }, - { META_KEYBINDING_RAISE_OR_LOWER, NULL, FALSE }, - { META_KEYBINDING_RAISE, NULL, FALSE }, - { META_KEYBINDING_LOWER, NULL, FALSE }, - { META_KEYBINDING_MAXIMIZE_VERTICALLY, NULL, FALSE }, - { META_KEYBINDING_MAXIMIZE_HORIZONTALLY, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_CORNER_NW, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_CORNER_NE, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_CORNER_SW, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_CORNER_SE, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_SIDE_N, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_SIDE_S, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_SIDE_E, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_SIDE_W, NULL, FALSE }, - { META_KEYBINDING_MOVE_TO_CENTER, NULL, FALSE }, +#define item(name, suffix, param, a, b, c) \ + { #name suffix, NULL, FALSE }, +#include "window-bindings.h" +#undef item { NULL, NULL, FALSE } }; @@ -1961,23 +1923,16 @@ static MetaSimpleKeyMapping screen_string_bindings[] = { { NULL, NULL } }; -/* Name field must occur in the same order as window_bindings, though entries - * can be skipped - */ static MetaSimpleKeyMapping window_string_bindings[] = { - { META_KEYBINDING_WINDOW_MENU, "Print" }, - { META_KEYBINDING_MAXIMIZE, "F10" }, - { META_KEYBINDING_UNMAXIMIZE, "F5" }, - { META_KEYBINDING_MINIMIZE, "F9" }, - { META_KEYBINDING_CLOSE, "F4" }, - { META_KEYBINDING_BEGIN_MOVE, "F7" }, - { META_KEYBINDING_BEGIN_RESIZE, "F8" }, - { META_KEYBINDING_MOVE_WORKSPACE_LEFT, "Left" }, - { META_KEYBINDING_MOVE_WORKSPACE_RIGHT, "Right" }, - { META_KEYBINDING_MOVE_WORKSPACE_UP, "Up" }, - { META_KEYBINDING_MOVE_WORKSPACE_DOWN, "Down" }, +#define ONLY_BOUND_BY_DEFAULT +#define item(name, suffix, param, short, long, keystroke) \ + { #name suffix, keystroke }, +#include "window-bindings.h" +#undef item +#undef ONLY_BOUND_BY_DEFAULT { NULL, NULL } }; + #endif /* NOT HAVE_GCONF */ static void @@ -2949,6 +2904,7 @@ meta_prefs_get_compositing_manager (void) void meta_prefs_set_compositing_manager (gboolean whether) { +#ifdef HAVE_GCONF GError *err = NULL; gconf_client_set_bool (default_client, @@ -2962,6 +2918,9 @@ meta_prefs_set_compositing_manager (gboolean whether) err->message); g_error_free (err); } +#else + compositing_manager = whether; +#endif } #ifndef HAVE_GCONF diff --git a/src/core/schema-bindings.c b/src/core/schema-bindings.c new file mode 100644 index 000000000..49b8c4bbb --- /dev/null +++ b/src/core/schema-bindings.c @@ -0,0 +1,88 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Thomas Thurman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +/** \file Schema bindings generator. + * + * This program simply takes the items given in the binding lists in + * window-bindings.h and turns them into a portion of + * the GConf .schemas file. + */ + +#include +#include + +#define _(x) x + +char *liberal; + +const char* window_string = \ + " \n" \ + " /schemas/apps/metacity/%s_keybindings/%s%s\n" \ + " /apps/metacity/%s_keybindings/%s%s\n" \ + " metacity\n" \ + " string\n" \ + " %s\n" \ + " \n" \ + " %s\n" \ + " \n" \ + " %s %s\n" \ + " \n" \ + " \n" \ + " \n\n\n"; + +void +produce_window_bindings () +{ + /* Escaped versions of each of these fields (i.e. > => >, etc) */ + gchar *esc_short, *esc_long, *esc_key; + +#define item(name, suffix, param, short, long, keystroke) \ + esc_short = g_markup_escape_text (short, -1);\ + esc_long = g_markup_escape_text (long, -1);\ + if (keystroke) esc_key = g_markup_escape_text (keystroke, -1);\ + printf(\ + window_string, \ + "window", #name, suffix? suffix:"", \ + "window", #name, suffix? suffix:"",\ + keystroke? esc_key: "disabled", \ + esc_short, esc_long, liberal);\ + g_free (esc_short);\ + g_free (esc_long);\ + if (keystroke) g_free (esc_key); +#include "../src/core/window-bindings.h" +#undef item +} + +int +main () +{ + liberal = g_markup_escape_text(_("The parser is fairly liberal and allows "\ + "lower or upper case, and also abbreviations such as \"\" and " \ + "\"\". If you set the option to the special string " \ + "\"disabled\", then there will be no keybinding for this action."), -1); + + produce_window_bindings (); + + g_free (liberal); +} + +/* eof schema-bindings.c */ + diff --git a/src/core/window-bindings.h b/src/core/window-bindings.h new file mode 100644 index 000000000..8616cd9be --- /dev/null +++ b/src/core/window-bindings.h @@ -0,0 +1,293 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Thomas Thurman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +/** + * \file A list of window binding information. + * + * Each action which can have a keystroke bound to it is listed below. + * To use this file, define "item" to be a six-argument macro (you can + * throw any of the arguments you please away), include this file, + * and then undefine the macro again. + * + * (If you aren't familiar with this technique, sometimes called "x-macros", + * see DDJ of May 2001: .) + * + * This makes it possible to keep all information about all the keybindings + * in the same place. The only exception is the code to run when an action + * is actually invoked; while we *could* have put that in this file, it would + * have made debugging ridiculously difficult. Instead, each action should + * have a corresponding static function named handle_() in + * keybindings.c. + * + * Currently, the GConf schemas in src/metacity.schemas also need to be + * updated separately. There is a program called schema-bindings.c in this + * directory which will fix that, but it needs integrating into the build + * process. + * + * The arguments to item() are: + * 1) name: the name of the binding; a bareword identifier + * 2) suffix: a string to add to the binding name to make the handler name + * (usually the empty string) + * 3) param: an integer parameter to pass to the handler + * 4) short: a short description. Mostly, you won't use this. + * It must be marked translatable (i.e. inside "_(...)"). + * 5) long: like short, except long. Don't include all the stuff about + * the parser being fairly liberal. + * 6) keystroke: a string representing the default binding. + * If this is NULL, the action is unbound by default. + * + * Don't try to do XML entity escaping anywhere in the strings. + * + * Some code out there wants only the entries which have a default + * binding (i.e. whose sixth parameter is not NULL). You can get only these + * by defining ONLY_BOUND_BY_DEFAULT before you include this file. + */ + +#ifndef item +#error "item () must be defined when you include window-bindings.h" +#endif + +item (activate_window_menu, "", 0, + _("Activate window menu"), + _("The keybinding used to activate the window menu."), + "Print") + +#ifndef ONLY_BOUND_BY_DEFAULT + +item (toggle_fullscreen, "", 0, + _("Toggle fullscreen mode"), + _("The keybinding used to toggle fullscreen mode."), + NULL) +item (toggle_maximized, "", 0, + _("Toggle maximization state"), + _("The keybinding used to toggle maximization."), + NULL) +item (toggle_above, "", 0, + _("Toggle always on top state"), + _("The keybinding used to toggle always on top. A window that is " + "always on top will always be visible over other overlapping " + "windows."), + NULL) +#endif /* ONLY_BOUND_BY_DEFAULT */ + +item (maximize, "", 0, + _("Maximize window"), + _("The keybinding used to maximize a window."), + "F10") +item (unmaximize, "", 0, + _("Unmaximize window"), + _("The keybinding used to unmaximize a window."), + "F5") + +#ifndef ONLY_BOUND_BY_DEFAULT + +item (toggle_shaded, "", 0, + _("Toggle shaded state"), + _("The keybinding used to toggle shaded/unshaded state."), + NULL) + +#endif /* ONLY_BOUND_BY_DEFAULT */ + +item (minimize, "", 0, + _("Minimize window"), + _("The keybinding used to minimize a window."), + "F9") +item (close, "", 0, + _("Close window"), + _("The keybinding used to close a window."), + "F4") +item (begin_move, "", 0, + _("Move window"), + _("The keybinding used to enter \"move mode\" " + "and begin moving a window using the keyboard."), + "F7") +item (begin_resize, "", 0, + _("Resize window"), + ("The keybinding used to enter \"resize mode\" " + "and begin resizing a window using the keyboard."), + "F8") + +#ifndef ONLY_BOUND_BY_DEFAULT + +item (toggle_on_all_workspaces, "", 0, + _("Toggle window on all workspaces"), + _("The keybinding used to toggle whether the window is on all " + "workspaces or just one."), + NULL) + + +item (move_to_workspace, "_1", 1, + _("Move window to workspace 1"), + _("The keybinding used to move a window to workspace 1."), + NULL) +item (move_to_workspace, "_2", 2, + _("Move window to workspace 2"), + _("The keybinding used to move a window to workspace 2."), + NULL) +item (move_to_workspace, "_3", 3, + _("Move window to workspace 3"), + _("The keybinding used to move a window to workspace 3."), + NULL) +item (move_to_workspace, "_4", 4, + _("Move window to workspace 4"), + _("The keybinding used to move a window to workspace 4."), + NULL) +item (move_to_workspace, "_5", 5, + _("Move window to workspace 5"), + _("The keybinding used to move a window to workspace 5."), + NULL) +item (move_to_workspace, "_6", 6, + _("Move window to workspace 6"), + _("The keybinding used to move a window to workspace 6."), + NULL) +item (move_to_workspace, "_7", 7, + _("Move window to workspace 7"), + _("The keybinding used to move a window to workspace 7."), + NULL) +item (move_to_workspace, "_8", 8, + _("Move window to workspace 8"), + _("The keybinding used to move a window to workspace 8."), + NULL) +item (move_to_workspace, "_9", 9, + _("Move window to workspace 9"), + _("The keybinding used to move a window to workspace 9."), + NULL) +item (move_to_workspace, "_10", 10, + _("Move window to workspace 10"), + _("The keybinding used to move a window to workspace 10."), + NULL) +item (move_to_workspace, "_11", 11, + _("Move window to workspace 11"), + _("The keybinding used to move a window to workspace 11."), + NULL) +item (move_to_workspace, "_12", 12, + _("Move window to workspace 12"), + _("The keybinding used to move a window to workspace 12."), + NULL) + +#endif /* ONLY_BOUND_BY_DEFAULT */ + +/* META_MOTION_* are negative, and so distinct from workspace numbers, + * which are always zero or positive. + * If you make use of these constants, you will need to include workspace.h + * (which you're probably using already for other reasons anyway). + * If your definition of item() throws them away, you don't need to include + * workspace.h, of course. + */ + +item (move_to_workspace, "_left", META_MOTION_LEFT, + _("Move window one workspace to the left"), + _("The keybinding used to move a window one workspace to the left."), + "Left") +item (move_to_workspace, "_right", META_MOTION_RIGHT, + _("Move window one workspace to the right"), + _("The keybinding used to move a window one workspace to the right."), + "Right") +item (move_to_workspace, "_up", META_MOTION_UP, + _("Move window one workspace up"), + _("The keybinding used to move a window one workspace up."), + "Up") +item (move_to_workspace, "_down", META_MOTION_DOWN, + _("Move window one workspace down"), + _("The keybinding used to move a window one workspace down."), + "Down") + +#ifndef ONLY_BOUND_BY_DEFAULT + +item (raise_or_lower, "", 0, + _("Raise obscured window, otherwise lower"), + _("This keybinding changes whether a window is above or below " + "other windows. If the window is covered by another one, it " + "raises the window above all others, and if the window is " + "already fully visible, it lowers it below all others."), + NULL) +item (raise, "", 0, + _("Raise window above other windows"), + _("This keybinding raises the window above other windows."), + NULL) +item (lower, "", 0, + _("Lower window below other windows"), + _("This keybinding lowers a window below other windows."), + NULL) + +item (maximize_vertically, "", 0, + _("Maximize window vertically"), + _("This keybinding resizes a window to fill available " + "vertical space."), + NULL) +item (maximize_horizontally, "", 0, + _("Maximize window horizontally"), + _("This keybinding resizes a window to fill available " + "horizontal space."), + NULL) + +item (move_to_corner_nw, "", 0, + _("Move window to north-west corner"), + _("This keybinding moves a window into the north-west (top left) " + "corner of the screen."), + NULL) +item (move_to_corner_ne, "", 0, + _("Move window to north-east corner"), + _("This keybinding moves a window into the north-east (top right) " + "corner of the screen."), + NULL) +item (move_to_corner_sw, "", 0, + _("Move window to south-west corner"), + _("This keybinding moves a window into the north-east (bottom left) " + "corner of the screen."), + NULL) +item (move_to_corner_se, "", 0, + _("Move window to south-east corner"), + _("This keybinding moves a window into the north-east (bottom right) " + "corner of the screen."), + NULL) + +item (move_to_side_n, "", 0, + _("Move window to north side of screen"), + _("This keybinding moves a window against the north (top) " + "side of the screen."), + NULL) +item (move_to_side_s, "", 0, + _("Move window to south side of screen"), + _("This keybinding moves a window against the south (bottom) " + "side of the screen."), + NULL) +item (move_to_side_e, "", 0, + _("Move window to east side of screen"), + _("This keybinding moves a window against the east (right) " + "side of the screen."), + NULL) +item (move_to_side_w, "", 0, + _("Move window to west side of screen"), + _("This keybinding moves a window against the west (left) " + "side of the screen."), + NULL) + +item (move_to_center, "", 0, + _("Move window to center of screen"), + _("This keybinding moves a window into the center " + "of the screen."), + NULL) + +#endif /* ONLY_BOUND_BY_DEFAULT */ + +/* eof window-bindings.h */ + diff --git a/src/include/prefs.h b/src/include/prefs.h index 4a76f4093..9a4d12855 100644 --- a/src/include/prefs.h +++ b/src/include/prefs.h @@ -189,50 +189,6 @@ void meta_prefs_set_compositing_manager (gboolean whether); #define META_KEYBINDING_RUN_COMMAND_TERMINAL "run_command_terminal" #define META_KEYBINDING_SET_SPEW_MARK "set_spew_mark" -/* Window bindings */ -#define META_KEYBINDING_WINDOW_MENU "activate_window_menu" -#define META_KEYBINDING_TOGGLE_FULLSCREEN "toggle_fullscreen" -#define META_KEYBINDING_TOGGLE_MAXIMIZE "toggle_maximized" -#define META_KEYBINDING_TOGGLE_ABOVE "toggle_above" -#define META_KEYBINDING_MAXIMIZE "maximize" -#define META_KEYBINDING_UNMAXIMIZE "unmaximize" -#define META_KEYBINDING_TOGGLE_SHADE "toggle_shaded" -#define META_KEYBINDING_MINIMIZE "minimize" -#define META_KEYBINDING_CLOSE "close" -#define META_KEYBINDING_BEGIN_MOVE "begin_move" -#define META_KEYBINDING_BEGIN_RESIZE "begin_resize" -#define META_KEYBINDING_TOGGLE_STICKY "toggle_on_all_workspaces" -#define META_KEYBINDING_MOVE_WORKSPACE_1 "move_to_workspace_1" -#define META_KEYBINDING_MOVE_WORKSPACE_2 "move_to_workspace_2" -#define META_KEYBINDING_MOVE_WORKSPACE_3 "move_to_workspace_3" -#define META_KEYBINDING_MOVE_WORKSPACE_4 "move_to_workspace_4" -#define META_KEYBINDING_MOVE_WORKSPACE_5 "move_to_workspace_5" -#define META_KEYBINDING_MOVE_WORKSPACE_6 "move_to_workspace_6" -#define META_KEYBINDING_MOVE_WORKSPACE_7 "move_to_workspace_7" -#define META_KEYBINDING_MOVE_WORKSPACE_8 "move_to_workspace_8" -#define META_KEYBINDING_MOVE_WORKSPACE_9 "move_to_workspace_9" -#define META_KEYBINDING_MOVE_WORKSPACE_10 "move_to_workspace_10" -#define META_KEYBINDING_MOVE_WORKSPACE_11 "move_to_workspace_11" -#define META_KEYBINDING_MOVE_WORKSPACE_12 "move_to_workspace_12" -#define META_KEYBINDING_MOVE_WORKSPACE_LEFT "move_to_workspace_left" -#define META_KEYBINDING_MOVE_WORKSPACE_RIGHT "move_to_workspace_right" -#define META_KEYBINDING_MOVE_WORKSPACE_UP "move_to_workspace_up" -#define META_KEYBINDING_MOVE_WORKSPACE_DOWN "move_to_workspace_down" -#define META_KEYBINDING_RAISE_OR_LOWER "raise_or_lower" -#define META_KEYBINDING_RAISE "raise" -#define META_KEYBINDING_LOWER "lower" -#define META_KEYBINDING_MAXIMIZE_VERTICALLY "maximize_vertically" -#define META_KEYBINDING_MAXIMIZE_HORIZONTALLY "maximize_horizontally" -#define META_KEYBINDING_MOVE_TO_CORNER_NW "move_to_corner_nw" -#define META_KEYBINDING_MOVE_TO_CORNER_NE "move_to_corner_ne" -#define META_KEYBINDING_MOVE_TO_CORNER_SW "move_to_corner_sw" -#define META_KEYBINDING_MOVE_TO_CORNER_SE "move_to_corner_se" -#define META_KEYBINDING_MOVE_TO_SIDE_N "move_to_side_n" -#define META_KEYBINDING_MOVE_TO_SIDE_S "move_to_side_s" -#define META_KEYBINDING_MOVE_TO_SIDE_E "move_to_side_e" -#define META_KEYBINDING_MOVE_TO_SIDE_W "move_to_side_w" -#define META_KEYBINDING_MOVE_TO_CENTER "move_to_center" - typedef enum _MetaKeyBindingAction { META_KEYBINDING_ACTION_NONE = -1,