Slight transformation of the x-macros used in keybindings to make them

2008-10-22  Thomas Thurman  <tthurman@gnome.org>

        Slight transformation of the x-macros used in keybindings
        to make them clearer: write handler names out in full
        because the old suffix system was confusing to people
        skim-reading, and switched the order of the last two
        parameters so more would generally fit on a screen.

        * src/core/keybindings.c, src/core/schema-bindings.c
          src/core/prefs.c: sympathy changes
        * src/core/window-bindings.h, src/core/screen-bindings.h:
          transformation as above


svn path=/trunk/; revision=3970
This commit is contained in:
Thomas Thurman 2008-10-22 01:02:45 +00:00 committed by Thomas James Alexander Thurman
parent fd01dbaaea
commit 671b69a251
6 changed files with 293 additions and 368 deletions

View File

@ -1,3 +1,16 @@
2008-10-22 Thomas Thurman <tthurman@gnome.org>
Slight transformation of the x-macros used in keybindings
to make them clearer: write handler names out in full
because the old suffix system was confusing to people
skim-reading, and switched the order of the last two
parameters so more would generally fit on a screen.
* src/core/keybindings.c, src/core/schema-bindings.c
src/core/prefs.c: sympathy changes
* src/core/window-bindings.h, src/core/screen-bindings.h:
transformation as above
2008-10-21 Christian Persch <chpe@gnome.org> 2008-10-21 Christian Persch <chpe@gnome.org>
* src/Makefile.am: fix build when schemas are not installed. * src/Makefile.am: fix build when schemas are not installed.

View File

@ -55,25 +55,16 @@ typedef void (* MetaKeyHandlerFunc) (MetaDisplay *display,
MetaKeyBinding *binding); MetaKeyBinding *binding);
/* Prototypes for handlers */ /* Prototypes for handlers */
#define item(name, suffix, param, flags, description, stroke) \ #define keybind(name, handler, param, flags, stroke, description) \
static void \ static void \
handle_##name (MetaDisplay *display,\ handler (MetaDisplay *display,\
MetaScreen *screen,\ MetaScreen *screen,\
MetaWindow *window,\ MetaWindow *window,\
XEvent *event,\ XEvent *event,\
MetaKeyBinding *binding); MetaKeyBinding *binding);
#include "window-bindings.h" #include "window-bindings.h"
#undef item
#define item(name, suffix, param, flags, description, stroke) \
static void \
handle_##name (MetaDisplay *display,\
MetaScreen *screen,\
MetaWindow *window,\
XEvent *event,\
MetaKeyBinding *binding);
#include "screen-bindings.h" #include "screen-bindings.h"
#undef item #undef keybind
/* These can't be bound to anything, but they are used to handle /* These can't be bound to anything, but they are used to handle
* various other events. TODO: Possibly we should include them as event * various other events. TODO: Possibly we should include them as event
@ -134,11 +125,10 @@ struct _MetaKeyBinding
const MetaKeyHandler *handler; const MetaKeyHandler *handler;
}; };
#define keybind(name, handler, param, flags, stroke, description) \
{ #name, handler, param, flags },
static const MetaKeyHandler screen_handlers[] = { static const MetaKeyHandler screen_handlers[] = {
#define item(name, suffix, param, flags, description, stroke) \
{ #name suffix, handle_##name, param, flags },
#include "screen-bindings.h" #include "screen-bindings.h"
#undef item
{ NULL, NULL, 0, 0 } { NULL, NULL, 0, 0 }
}; };
@ -146,12 +136,10 @@ static const MetaKeyHandler window_handlers[] = {
/* TODO: Are window bindings only ever called on non-null windows? /* TODO: Are window bindings only ever called on non-null windows?
* If so, we can remove the check from all of them. * If so, we can remove the check from all of them.
*/ */
#define item(name, suffix, param, flags, description, stroke) \
{ #name suffix, handle_##name, param, flags },
#include "window-bindings.h" #include "window-bindings.h"
#undef item
{ NULL, NULL, 0, 0 } { NULL, NULL, 0, 0 }
}; };
#undef keybind
static void static void
reload_keymap (MetaDisplay *display) reload_keymap (MetaDisplay *display)

View File

@ -1815,8 +1815,8 @@ meta_prefs_set_num_workspaces (int n_workspaces)
#endif /* HAVE_GCONF */ #endif /* HAVE_GCONF */
} }
#define item(name, suffix, param, flags, description, stroke) \ #define keybind(name, handler, param, flags, stroke, description) \
{ #name suffix, NULL, flags & BINDING_REVERSES }, { #name, NULL, flags & BINDING_REVERSES },
static MetaKeyPref screen_bindings[] = { static MetaKeyPref screen_bindings[] = {
#include "screen-bindings.h" #include "screen-bindings.h"
{ NULL, NULL, FALSE} { NULL, NULL, FALSE}
@ -1826,7 +1826,7 @@ static MetaKeyPref window_bindings[] = {
#include "window-bindings.h" #include "window-bindings.h"
{ NULL, NULL, FALSE } { NULL, NULL, FALSE }
}; };
#undef item #undef keybind
#ifndef HAVE_GCONF #ifndef HAVE_GCONF
typedef struct typedef struct
@ -1842,21 +1842,20 @@ typedef struct
* data and move it into code. Then the compiler would optimise away * data and move it into code. Then the compiler would optimise away
* the problem lines. * the problem lines.
*/ */
#define keybind(name, handler, param, flags, stroke, description) \
{ #name, keystroke },
static MetaSimpleKeyMapping screen_string_bindings[] = { static MetaSimpleKeyMapping screen_string_bindings[] = {
#define item(name, suffix, param, flags, description, keystroke) \
{ #name suffix, keystroke },
#include "screen-bindings.h" #include "screen-bindings.h"
#undef item
{ NULL, NULL } { NULL, NULL }
}; };
static MetaSimpleKeyMapping window_string_bindings[] = { static MetaSimpleKeyMapping window_string_bindings[] = {
#define item(name, suffix, param, flags, description, keystroke) \
{ #name suffix, keystroke },
#include "window-bindings.h" #include "window-bindings.h"
#undef item
{ NULL, NULL } { NULL, NULL }
}; };
#undef keybind
#endif /* NOT HAVE_GCONF */ #endif /* NOT HAVE_GCONF */

View File

@ -26,10 +26,6 @@
* the GConf .schemas file. * the GConf .schemas file.
* *
* FIXME: also need to make 50-metacity-desktop-key.xml * FIXME: also need to make 50-metacity-desktop-key.xml
*
* FIXME: this actually breaks i18n because the schemas.in->schemas process
* doesn't recognise the concatenated strings, and so we will have to do
* them ourselves; this will need to be fixed before the next release.
*/ */
#include <stdio.h> #include <stdio.h>
@ -132,16 +128,16 @@ produce_bindings ()
if (!feof (metacity_schemas_in_in)) if (!feof (metacity_schemas_in_in))
{ {
#define item(name, suffix, param, flags, description, keystroke) \ #define keybind(name, handler, param, flags, stroke, description) \
single_stanza ( \ single_stanza ( \
flags & BINDING_PER_WINDOW, \ flags & BINDING_PER_WINDOW, \
#name suffix, \ #name, \
keystroke, \ stroke, \
flags & BINDING_REVERSES, \ flags & BINDING_REVERSES, \
description); description);
#include "window-bindings.h" #include "window-bindings.h"
#include "screen-bindings.h" #include "screen-bindings.h"
#undef item #undef keybind
} }
while (!feof (metacity_schemas_in_in)) while (!feof (metacity_schemas_in_in))

View File

@ -23,7 +23,7 @@
* A list of screen keybinding information. * A list of screen keybinding information.
* *
* Each action which can have a keystroke bound to it is listed below. * Each action which can have a keystroke bound to it is listed below.
* To use this file, define "item" to be a seven-argument macro (you can * To use this file, define keybind() to be a seven-argument macro (you can
* throw any of the arguments you please away), include this file, * throw any of the arguments you please away), include this file,
* and then undefine the macro again. * and then undefine the macro again.
* *
@ -46,30 +46,34 @@
* directory which will fix that, but it needs integrating into the build * directory which will fix that, but it needs integrating into the build
* process. * process.
* *
* The arguments to item() are: * The arguments to keybind() are:
* 1) the name of the binding; a bareword identifier * 1) the name of the binding; a bareword identifier
* (it's fine if it happens to clash with a C reserved word) * (it's fine if it happens to clash with a C reserved word)
* 2) a string to add to the binding name to make the handler name * 2) the name of the function which implements it.
* (usually the empty string) * Clearly we could have guessed this from the binding very often,
* but we choose to write it in full for the benefit of grep.
* 3) an integer parameter to pass to the handler * 3) an integer parameter to pass to the handler
* 4) a set of boolean flags, ORed together: * 4) a set of boolean flags, ORed together:
* BINDING_PER_WINDOW - this is a window-based binding * BINDING_PER_WINDOW - this is a window-based binding
* (not used in this file) * (all in window-bindings.h use this,
* and none in screen-bindings.h)
* BINDING_REVERSES - the binding can reverse if you hold down Shift * BINDING_REVERSES - the binding can reverse if you hold down Shift
* BINDING_IS_REVERSED - the same, but the senses are reversed from the * BINDING_IS_REVERSED - the same, but the senses are reversed from the
* handler's point of view (let me know if I should * handler's point of view (let me know if I should
* explain this better) * explain this better)
* or 0 if no flag applies.
* *
* 5) a short description. Mostly, you won't use this. * 5) a string representing the default binding.
* It must be marked translatable (i.e. inside "_(...)").
* 6) a string representing the default binding.
* If this is NULL, the action is unbound by default. * If this is NULL, the action is unbound by default.
* Please use NULL and not "disabled".
* 6) a short description.
* It must be marked translatable (i.e. inside "_(...)").
* *
* Don't try to do XML entity escaping anywhere in the strings. * Don't try to do XML entity escaping anywhere in the strings.
*/ */
#ifndef item #ifndef keybind
#error "item () must be defined when you include screen-bindings.h" #error "keybind () must be defined when you include screen-bindings.h"
#endif #endif
/***********************************/ /***********************************/
@ -81,10 +85,6 @@
#define BINDING_REVERSES 0x02 #define BINDING_REVERSES 0x02
#define BINDING_IS_REVERSED 0x04 #define BINDING_IS_REVERSED 0x04
/* FIXME: There is somewhere better for these; remove them */
#define PANEL_MAIN_MENU -1
#define PANEL_RUN_DIALOG -2
#endif /* _BINDINGS_DEFINED_CONSTANTS */ #endif /* _BINDINGS_DEFINED_CONSTANTS */
/***********************************/ /***********************************/
@ -92,66 +92,54 @@
/* convenience, since in this file they must always be set together */ /* convenience, since in this file they must always be set together */
#define REVERSES_AND_REVERSED (BINDING_REVERSES | BINDING_IS_REVERSED) #define REVERSES_AND_REVERSED (BINDING_REVERSES | BINDING_IS_REVERSED)
item (switch_to_workspace, "_1", 0, 0, keybind (switch_to_workspace_1, handle_switch_to_workspace, 0, 0, NULL,
_("Switch to workspace 1"), _("Switch to workspace 1"))
NULL) keybind (switch_to_workspace_2, handle_switch_to_workspace, 1, 0, NULL,
item (switch_to_workspace, "_2", 1, 0, _("Switch to workspace 2"))
_("Switch to workspace 2"), keybind (switch_to_workspace_3, handle_switch_to_workspace, 2, 0, NULL,
NULL) _("Switch to workspace 3"))
item (switch_to_workspace, "_3", 2, 0, keybind (switch_to_workspace_4, handle_switch_to_workspace, 3, 0, NULL,
_("Switch to workspace 3"), _("Switch to workspace 4"))
NULL) keybind (switch_to_workspace_5, handle_switch_to_workspace, 4, 0, NULL,
item (switch_to_workspace, "_4", 3, 0, _("Switch to workspace 5"))
_("Switch to workspace 4"), keybind (switch_to_workspace_6, handle_switch_to_workspace, 5, 0, NULL,
NULL) _("Switch to workspace 6"))
item (switch_to_workspace, "_5", 4, 0, keybind (switch_to_workspace_7, handle_switch_to_workspace, 6, 0, NULL,
_("Switch to workspace 5"), _("Switch to workspace 7"))
NULL) keybind (switch_to_workspace_8, handle_switch_to_workspace, 7, 0, NULL,
item (switch_to_workspace, "_6", 5, 0, _("Switch to workspace 8"))
_("Switch to workspace 6"), keybind (switch_to_workspace_9, handle_switch_to_workspace, 8, 0, NULL,
NULL) _("Switch to workspace 9"))
item (switch_to_workspace, "_7", 6, 0, keybind (switch_to_workspace_10, handle_switch_to_workspace, 9, 0, NULL,
_("Switch to workspace 7"), _("Switch to workspace 10"))
NULL) keybind (switch_to_workspace_11, handle_switch_to_workspace, 10, 0, NULL,
item (switch_to_workspace, "_8", 7, 0, _("Switch to workspace 11"))
_("Switch to workspace 8"), keybind (switch_to_workspace_12, handle_switch_to_workspace, 11, 0, NULL,
NULL) _("Switch to workspace 12"))
item (switch_to_workspace, "_9", 8, 0,
_("Switch to workspace 9"),
NULL)
item (switch_to_workspace, "_10", 9, 0,
_("Switch to workspace 10"),
NULL)
item (switch_to_workspace, "_11", 10, 0,
_("Switch to workspace 11"),
NULL)
item (switch_to_workspace, "_12", 11, 0,
_("Switch to workspace 12"),
NULL)
/* META_MOTION_* are negative, and so distinct from workspace numbers, /* META_MOTION_* are negative, and so distinct from workspace numbers,
* which are always zero or positive. * which are always zero or positive.
* If you make use of these constants, you will need to include workspace.h * If you make use of these constants, you will need to include workspace.h
* (which you're probably using already for other reasons anyway). * (which you're probably using already for other reasons anyway).
* If your definition of item() throws them away, you don't need to include * If your definition of keybind() throws them away, you don't need to include
* workspace.h, of course. * workspace.h, of course.
*/ */
item (switch_to_workspace, "_left", META_MOTION_LEFT, 0, keybind (switch_to_workspace_left, handle_switch_to_workspace,
_("Switch to workspace on the left of the current workspace"), META_MOTION_LEFT, 0, "<Control><Alt>Left",
"<Control><Alt>Left") _("Switch to workspace on the left of the current workspace"))
item (switch_to_workspace, "_right", META_MOTION_RIGHT, 0, keybind (switch_to_workspace_right, handle_switch_to_workspace,
_("Switch to workspace on the right of the current workspace"), META_MOTION_RIGHT, 0, "<Control><Alt>Right",
"<Control><Alt>Right") _("Switch to workspace on the right of the current workspace"))
item (switch_to_workspace, "_up", META_MOTION_UP, 0, keybind (switch_to_workspace_up, handle_switch_to_workspace,
_("Switch to workspace above the current workspace"), META_MOTION_UP, 0, "<Control><Alt>Up",
"<Control><Alt>Up") _("Switch to workspace above the current workspace"))
item (switch_to_workspace, "_down", META_MOTION_DOWN, 0, keybind (switch_to_workspace_down, handle_switch_to_workspace,
_("Switch to workspace below the current workspace"), META_MOTION_DOWN, 0, "<Control><Alt>Down",
"<Control><Alt>Down") _("Switch to workspace below the current workspace"))
/***********************************/ /***********************************/
@ -160,110 +148,109 @@ item (switch_to_workspace, "_down", META_MOTION_DOWN, 0,
* *
* TODO: "NORMAL" and "DOCKS" should be renamed to the same name as their * TODO: "NORMAL" and "DOCKS" should be renamed to the same name as their
* action, for obviousness. * action, for obviousness.
*
* TODO: handle_switch and handle_cycle should probably really be the
* same function checking a bit in the parameter for difference.
*/ */
item (switch, "_group", META_TAB_LIST_GROUP, BINDING_REVERSES, keybind (switch_group, handle_switch, META_TAB_LIST_GROUP,
_("Move between windows of an application, using a popup window"), BINDING_REVERSES, NULL,
NULL) _("Move between windows of an application, using a popup window"))
item (switch, "_group_backwards", META_TAB_LIST_GROUP, REVERSES_AND_REVERSED, keybind (switch_group_backwards, handle_switch, META_TAB_LIST_GROUP,
REVERSES_AND_REVERSED, NULL,
_("Move backwards between windows of an application, " _("Move backwards between windows of an application, "
"using a popup window"), "using a popup window"))
NULL) keybind (switch_windows, handle_switch, META_TAB_LIST_NORMAL,
item (switch, "_windows", META_TAB_LIST_NORMAL, BINDING_REVERSES, BINDING_REVERSES, "<Alt>Tab",
_("Move between windows, using a popup window"), _("Move between windows, using a popup window"))
"<Alt>Tab") keybind (switch_windows_backwards, handle_switch, META_TAB_LIST_NORMAL,
item (switch, "_windows_backwards",META_TAB_LIST_NORMAL, REVERSES_AND_REVERSED, REVERSES_AND_REVERSED, NULL,
_("Move backwards between windows, using a popup window"), _("Move backwards between windows, using a popup window"))
NULL) keybind (switch_panels, handle_switch, META_TAB_LIST_DOCKS,
item (switch, "_panels", META_TAB_LIST_DOCKS, BINDING_REVERSES, BINDING_REVERSES, "<Control><Alt>Tab",
_("Move between panels and the desktop, using a popup window"), _("Move between panels and the desktop, using a popup window"))
"<Control><Alt>Tab") keybind (switch_panels_backwards, handle_switch, META_TAB_LIST_DOCKS,
item (switch, "_panels_backwards", META_TAB_LIST_DOCKS, REVERSES_AND_REVERSED, REVERSES_AND_REVERSED, NULL,
_("Move backwards between panels and the desktop, " _("Move backwards between panels and the desktop, "
"using a popup window"), "using a popup window"))
NULL)
item (cycle, "_group", META_TAB_LIST_GROUP, BINDING_REVERSES, keybind (cycle_group, handle_cycle, META_TAB_LIST_GROUP,
_("Move between windows of an application immediately"), BINDING_REVERSES, "<Alt>F6",
"<Alt>F6") _("Move between windows of an application immediately"))
item (cycle, "_group_backwards", META_TAB_LIST_GROUP, REVERSES_AND_REVERSED, keybind (cycle_group_backwards, handle_cycle, META_TAB_LIST_GROUP,
_("Move backwards between windows of an application immediately"), REVERSES_AND_REVERSED, NULL,
NULL) _("Move backwards between windows of an application immediately"))
item (cycle, "_windows", META_TAB_LIST_NORMAL, BINDING_REVERSES, keybind (cycle_windows, handle_cycle, META_TAB_LIST_NORMAL,
_("Move between windows immediately"), BINDING_REVERSES, "<Alt>Escape",
"<Alt>Escape") _("Move between windows immediately"))
item (cycle, "_windows_backwards",META_TAB_LIST_NORMAL, REVERSES_AND_REVERSED, keybind (cycle_windows_backwards, handle_cycle, META_TAB_LIST_NORMAL,
_("Move backwards between windows immediately"), REVERSES_AND_REVERSED, NULL,
NULL) _("Move backwards between windows immediately"))
item (cycle, "_panels", META_TAB_LIST_DOCKS, BINDING_REVERSES, keybind (cycle_panels, handle_cycle, META_TAB_LIST_DOCKS,
_("Move between panels and the desktop immediately"), BINDING_REVERSES, "<Control><Alt>Escape",
"<Control><Alt>Escape") _("Move between panels and the desktop immediately"))
item (cycle, "_panels_backwards", META_TAB_LIST_DOCKS, REVERSES_AND_REVERSED, keybind (cycle_panels_backwards, handle_cycle, META_TAB_LIST_DOCKS,
_("Move backwards between panels and the desktop immediately"), REVERSES_AND_REVERSED, NULL,
NULL) _("Move backwards between panels and the desktop immediately"))
/***********************************/ /***********************************/
item (show_desktop, "", 0, 0, keybind (show_desktop, handle_show_desktop, 0, 0, "<Control><Alt>d",
_("Hide all normal windows and set focus to the desktop background"), _("Hide all normal windows and set focus to the desktop background"))
"<Control><Alt>d") keybind (panel_main_menu, handle_panel,
item (panel, "_main_menu", META_KEYBINDING_ACTION_PANEL_MAIN_MENU, 0, META_KEYBINDING_ACTION_PANEL_MAIN_MENU, 0, "<Alt>F1",
_("Show the panel's main menu"), _("Show the panel's main menu"))
"<Alt>F1") keybind (panel_run_dialog, handle_panel,
item (panel, "_run_dialog", META_KEYBINDING_ACTION_PANEL_RUN_DIALOG, 0, META_KEYBINDING_ACTION_PANEL_RUN_DIALOG, 0, "<Alt>F2",
_("Show the panel's \"Run Application\" dialog box"), _("Show the panel's \"Run Application\" dialog box"))
"<Alt>F2")
/* Yes, the param is offset by one. Historical reasons. (Maybe worth fixing /* Yes, the param is offset by one. Historical reasons. (Maybe worth fixing
* at some point.) The description is NULL here because the stanza is * at some point.) The description is NULL here because the stanza is
* irregularly shaped in metacity.schemas.in. This will probably be fixed * irregularly shaped in metacity.schemas.in. This will probably be fixed
* as well. * as well.
*/ */
item (run_command, "_1", 0, 0, NULL, NULL) keybind (run_command_1, handle_run_command, 0, 0, NULL, NULL)
item (run_command, "_2", 1, 0, NULL, NULL) keybind (run_command_2, handle_run_command, 1, 0, NULL, NULL)
item (run_command, "_3", 2, 0, NULL, NULL) keybind (run_command_3, handle_run_command, 2, 0, NULL, NULL)
item (run_command, "_4", 3, 0, NULL, NULL) keybind (run_command_4, handle_run_command, 3, 0, NULL, NULL)
item (run_command, "_5", 4, 0, NULL, NULL) keybind (run_command_5, handle_run_command, 4, 0, NULL, NULL)
item (run_command, "_6", 5, 0, NULL, NULL) keybind (run_command_6, handle_run_command, 5, 0, NULL, NULL)
item (run_command, "_7", 6, 0, NULL, NULL) keybind (run_command_7, handle_run_command, 6, 0, NULL, NULL)
item (run_command, "_8", 7, 0, NULL, NULL) keybind (run_command_8, handle_run_command, 7, 0, NULL, NULL)
item (run_command, "_9", 8, 0, NULL, NULL) keybind (run_command_9, handle_run_command, 8, 0, NULL, NULL)
item (run_command, "_10", 9, 0, NULL, NULL) keybind (run_command_10, handle_run_command, 9, 0, NULL, NULL)
item (run_command, "_11", 10, 0, NULL, NULL) keybind (run_command_11, handle_run_command, 10, 0, NULL, NULL)
item (run_command, "_12", 11, 0, NULL, NULL) keybind (run_command_12, handle_run_command, 11, 0, NULL, NULL)
item (run_command, "_13", 12, 0, NULL, NULL) keybind (run_command_13, handle_run_command, 12, 0, NULL, NULL)
item (run_command, "_14", 13, 0, NULL, NULL) keybind (run_command_14, handle_run_command, 13, 0, NULL, NULL)
item (run_command, "_15", 14, 0, NULL, NULL) keybind (run_command_15, handle_run_command, 14, 0, NULL, NULL)
item (run_command, "_16", 15, 0, NULL, NULL) keybind (run_command_16, handle_run_command, 15, 0, NULL, NULL)
item (run_command, "_17", 16, 0, NULL, NULL) keybind (run_command_17, handle_run_command, 16, 0, NULL, NULL)
item (run_command, "_18", 17, 0, NULL, NULL) keybind (run_command_18, handle_run_command, 17, 0, NULL, NULL)
item (run_command, "_19", 18, 0, NULL, NULL) keybind (run_command_19, handle_run_command, 18, 0, NULL, NULL)
item (run_command, "_20", 19, 0, NULL, NULL) keybind (run_command_20, handle_run_command, 19, 0, NULL, NULL)
item (run_command, "_21", 20, 0, NULL, NULL) keybind (run_command_21, handle_run_command, 20, 0, NULL, NULL)
item (run_command, "_22", 21, 0, NULL, NULL) keybind (run_command_22, handle_run_command, 21, 0, NULL, NULL)
item (run_command, "_23", 22, 0, NULL, NULL) keybind (run_command_23, handle_run_command, 22, 0, NULL, NULL)
item (run_command, "_24", 23, 0, NULL, NULL) keybind (run_command_24, handle_run_command, 23, 0, NULL, NULL)
item (run_command, "_25", 24, 0, NULL, NULL) keybind (run_command_25, handle_run_command, 24, 0, NULL, NULL)
item (run_command, "_26", 25, 0, NULL, NULL) keybind (run_command_26, handle_run_command, 25, 0, NULL, NULL)
item (run_command, "_27", 26, 0, NULL, NULL) keybind (run_command_27, handle_run_command, 26, 0, NULL, NULL)
item (run_command, "_28", 27, 0, NULL, NULL) keybind (run_command_28, handle_run_command, 27, 0, NULL, NULL)
item (run_command, "_29", 28, 0, NULL, NULL) keybind (run_command_29, handle_run_command, 28, 0, NULL, NULL)
item (run_command, "_30", 29, 0, NULL, NULL) keybind (run_command_30, handle_run_command, 29, 0, NULL, NULL)
item (run_command, "_31", 30, 0, NULL, NULL) keybind (run_command_31, handle_run_command, 30, 0, NULL, NULL)
item (run_command, "_32", 31, 0, NULL, NULL) keybind (run_command_32, handle_run_command, 31, 0, NULL, NULL)
item (run_command, "_screenshot", 32, 0, keybind (run_command_screenshot, handle_run_command, 32, 0, "Print",
_("Take a screenshot"), _("Take a screenshot"))
"Print") keybind (run_command_window_screenshot, handle_run_command, 33, 0,"<Alt>Print",
item (run_command, "_window_screenshot", 33, 0, _("Take a screenshot of a window"))
_("Take a screenshot of a window"),
"<Alt>Print")
item (run_terminal, "", 0, 0, keybind (run_terminal, handle_run_terminal, 0, 0, NULL, _("Run a terminal"))
_("Run a terminal"),
NULL)
/* No description because this is undocumented */ /* No description because this is undocumented */
item (set_spew_mark, "", 0, 0, NULL, NULL) keybind (set_spew_mark, handle_set_spew_mark, 0, 0, NULL, NULL)
#undef REVERSES_AND_REVERSED #undef REVERSES_AND_REVERSED

View File

@ -20,51 +20,13 @@
*/ */
/** /**
* \file A list of window keybinding information. * A list of window keybinding information.
* *
* Each action which can have a keystroke bound to it is listed below. * Information about how this file works is in screen-bindings.h.
* 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: <http://www.ddj.com/cpp/184401387>.)
*
* 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_<name>() 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) the name of the binding; a bareword identifier
* 2) a suffix to add to the binding name to make the handler name
* (usually the empty string)
* 3) an integer parameter to pass to the handler
* 4) a set of boolean flags, ORed together.
* This is used in *this* file for completeness, but at present
* is not checked anywhere. We use the flag BINDING_PER_WINDOW
* on all window-based bindings (i.e. every binding in this file).
* 5) a short description. Mostly, you won't use this.
* It must be marked translatable (i.e. inside "_(...)").
* 6) 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.
*
* Possible future work:
* - merge with screen-bindings.h somehow
* - "suffix" is confusing; write it out in full
*/ */
#ifndef item #ifndef keybind
#error "item () must be defined when you include window-bindings.h" #error "keybind () must be defined when you include window-bindings.h"
#endif #endif
/***********************************/ /***********************************/
@ -78,158 +40,138 @@
#define BINDING_REVERSES 0x02 #define BINDING_REVERSES 0x02
#define BINDING_IS_REVERSED 0x04 #define BINDING_IS_REVERSED 0x04
/* FIXME: There is somewhere better for these; remove them */
#define PANEL_MAIN_MENU -1
#define PANEL_RUN_DIALOG -2
#endif /* _BINDINGS_DEFINED_CONSTANTS */ #endif /* _BINDINGS_DEFINED_CONSTANTS */
item (activate_window_menu, "", 0, BINDING_PER_WINDOW, keybind (activate_window_menu, handle_activate_window_menu, 0,
_("Activate the window menu"), BINDING_PER_WINDOW, "<Alt>Space",
"<Alt>Space") _("Activate the window menu"))
keybind (toggle_fullscreen, handle_toggle_fullscreen, 0, BINDING_PER_WINDOW,
NULL,
_("Toggle fullscreen mode"))
keybind (toggle_maximized, handle_toggle_maximized, 0, BINDING_PER_WINDOW, NULL,
_("Toggle maximization state"))
keybind (toggle_above, handle_toggle_above, 0, BINDING_PER_WINDOW, NULL,
_("Toggle whether a window will always be visible over other windows"))
keybind (maximize, handle_maximize, 0, BINDING_PER_WINDOW, "<Alt>F10",
_("Maximize window"))
keybind (unmaximize, handle_unmaximize, 0, BINDING_PER_WINDOW, "<Alt>F5",
_("Unmaximize window"))
keybind (toggle_shaded, handle_toggle_shaded, 0, BINDING_PER_WINDOW, NULL,
_("Toggle shaded state"))
keybind (minimize, handle_minimize, 0, BINDING_PER_WINDOW, "<Alt>F9",
_("Minimize window"))
keybind (close, handle_close, 0, BINDING_PER_WINDOW, "<Alt>F4",
_("Close window"))
keybind (begin_move, handle_begin_move, 0, BINDING_PER_WINDOW, "<Alt>F7",
_("Move window"))
keybind (begin_resize, handle_begin_resize, 0, BINDING_PER_WINDOW, "<Alt>F8",
_("Resize window"))
keybind (toggle_on_all_workspaces, handle_toggle_on_all_workspaces, 0,
BINDING_PER_WINDOW, NULL,
_("Toggle whether window is on all workspaces or just one"))
item (toggle_fullscreen, "", 0, BINDING_PER_WINDOW, keybind (move_to_workspace_1, handle_move_to_workspace, 0, BINDING_PER_WINDOW,
_("Toggle fullscreen mode"), NULL,
NULL) _("Move window to workspace 1"))
item (toggle_maximized, "", 0, BINDING_PER_WINDOW, keybind (move_to_workspace_2, handle_move_to_workspace, 1, BINDING_PER_WINDOW,
_("Toggle maximization state"), NULL,
NULL) _("Move window to workspace 2"))
item (toggle_above, "", 0, BINDING_PER_WINDOW, keybind (move_to_workspace_3, handle_move_to_workspace, 2, BINDING_PER_WINDOW,
_("Toggle whether a window will always be visible over other windows"), NULL,
NULL) _("Move window to workspace 3"))
keybind (move_to_workspace_4, handle_move_to_workspace, 3, BINDING_PER_WINDOW,
item (maximize, "", 0, BINDING_PER_WINDOW, NULL,
_("Maximize window"), _("Move window to workspace 4"))
"<Alt>F10") keybind (move_to_workspace_5, handle_move_to_workspace, 4, BINDING_PER_WINDOW,
item (unmaximize, "", 0, BINDING_PER_WINDOW, NULL,
_("Unmaximize window"), _("Move window to workspace 5"))
"<Alt>F5") keybind (move_to_workspace_6, handle_move_to_workspace, 5, BINDING_PER_WINDOW,
NULL,
item (toggle_shaded, "", 0, BINDING_PER_WINDOW, _("Move window to workspace 6"))
_("Toggle shaded state"), keybind (move_to_workspace_7, handle_move_to_workspace, 6, BINDING_PER_WINDOW,
NULL) NULL,
_("Move window to workspace 7"))
item (minimize, "", 0, BINDING_PER_WINDOW, keybind (move_to_workspace_8, handle_move_to_workspace, 7, BINDING_PER_WINDOW,
_("Minimize window"), NULL,
"<Alt>F9") _("Move window to workspace 8"))
item (close, "", 0, BINDING_PER_WINDOW, keybind (move_to_workspace_9, handle_move_to_workspace, 8, BINDING_PER_WINDOW,
_("Close window"), NULL,
"<Alt>F4") _("Move window to workspace 9"))
item (begin_move, "", 0, BINDING_PER_WINDOW, keybind (move_to_workspace_10, handle_move_to_workspace, 9, BINDING_PER_WINDOW,
_("Move window"), NULL,
"<Alt>F7") _("Move window to workspace 10"))
item (begin_resize, "", 0, BINDING_PER_WINDOW, keybind (move_to_workspace_11, handle_move_to_workspace, 10, BINDING_PER_WINDOW,
_("Resize window"), NULL,
"<Alt>F8") _("Move window to workspace 11"))
keybind (move_to_workspace_12, handle_move_to_workspace, 11, BINDING_PER_WINDOW,
item (toggle_on_all_workspaces, "", 0, BINDING_PER_WINDOW, NULL,
_("Toggle whether window is on all workspaces or just one"), _("Move window to workspace 12"))
NULL)
item (move_to_workspace, "_1", 0, BINDING_PER_WINDOW,
_("Move window to workspace 1"),
NULL)
item (move_to_workspace, "_2", 1, BINDING_PER_WINDOW,
_("Move window to workspace 2"),
NULL)
item (move_to_workspace, "_3", 2, BINDING_PER_WINDOW,
_("Move window to workspace 3"),
NULL)
item (move_to_workspace, "_4", 3, BINDING_PER_WINDOW,
_("Move window to workspace 4"),
NULL)
item (move_to_workspace, "_5", 4, BINDING_PER_WINDOW,
_("Move window to workspace 5"),
NULL)
item (move_to_workspace, "_6", 5, BINDING_PER_WINDOW,
_("Move window to workspace 6"),
NULL)
item (move_to_workspace, "_7", 6, BINDING_PER_WINDOW,
_("Move window to workspace 7"),
NULL)
item (move_to_workspace, "_8", 7, BINDING_PER_WINDOW,
_("Move window to workspace 8"),
NULL)
item (move_to_workspace, "_9", 8, BINDING_PER_WINDOW,
_("Move window to workspace 9"),
NULL)
item (move_to_workspace, "_10", 9, BINDING_PER_WINDOW,
_("Move window to workspace 10"),
NULL)
item (move_to_workspace, "_11", 10, BINDING_PER_WINDOW,
_("Move window to workspace 11"),
NULL)
item (move_to_workspace, "_12", 11, BINDING_PER_WINDOW,
_("Move window to workspace 12"),
NULL)
/* META_MOTION_* are negative, and so distinct from workspace numbers, /* META_MOTION_* are negative, and so distinct from workspace numbers,
* which are always zero or positive. * which are always zero or positive.
* If you make use of these constants, you will need to include workspace.h * If you make use of these constants, you will need to include workspace.h
* (which you're probably using already for other reasons anyway). * (which you're probably using already for other reasons anyway).
* If your definition of item() throws them away, you don't need to include * If your definition of keybind() throws them away, you don't need to include
* workspace.h, of course. * workspace.h, of course.
*/ */
item (move_to_workspace, "_left", META_MOTION_LEFT, BINDING_PER_WINDOW, keybind (move_to_workspace_left, handle_move_to_workspace,
_("Move window one workspace to the left"), META_MOTION_LEFT, BINDING_PER_WINDOW, "<Control><Shift><Alt>Left",
"<Control><Shift><Alt>Left") _("Move window one workspace to the left"))
item (move_to_workspace, "_right", META_MOTION_RIGHT, BINDING_PER_WINDOW, keybind (move_to_workspace_right, handle_move_to_workspace,
_("Move window one workspace to the right"), META_MOTION_RIGHT, BINDING_PER_WINDOW, "<Control><Shift><Alt>Right",
"<Control><Shift><Alt>Right") _("Move window one workspace to the right"))
item (move_to_workspace, "_up", META_MOTION_UP, BINDING_PER_WINDOW, keybind (move_to_workspace_up, handle_move_to_workspace,
_("Move window one workspace up"), META_MOTION_UP, BINDING_PER_WINDOW, "<Control><Shift><Alt>Up",
"<Control><Shift><Alt>Up") _("Move window one workspace up"))
item (move_to_workspace, "_down", META_MOTION_DOWN, BINDING_PER_WINDOW, keybind (move_to_workspace_down, handle_move_to_workspace,
_("Move window one workspace down"), META_MOTION_DOWN, BINDING_PER_WINDOW, "<Control><Shift><Alt>Down",
"<Control><Shift><Alt>Down") _("Move window one workspace down"))
item (raise_or_lower, "", 0, BINDING_PER_WINDOW, keybind (raise_or_lower, handle_raise_or_lower, 0, BINDING_PER_WINDOW, NULL,
_("Raise window if it's covered by another window, otherwise lower it"), _("Raise window if it's covered by another window, otherwise lower it"))
NULL) keybind (raise, handle_raise, 0, BINDING_PER_WINDOW, NULL,
item (raise, "", 0, BINDING_PER_WINDOW, _("Raise window above other windows"))
_("Raise window above other windows"), keybind (lower, handle_lower, 0, BINDING_PER_WINDOW, NULL,
NULL) _("Lower window below other windows"))
item (lower, "", 0, BINDING_PER_WINDOW,
_("Lower window below other windows"),
NULL)
item (maximize_vertically, "", 0, BINDING_PER_WINDOW, keybind (maximize_vertically, handle_maximize_vertically, 0,
_("Maximize window vertically"), BINDING_PER_WINDOW, NULL,
NULL) _("Maximize window vertically"))
item (maximize_horizontally, "", 0, BINDING_PER_WINDOW,
_("Maximize window horizontally"),
NULL)
item (move_to_corner_nw, "", 0, BINDING_PER_WINDOW, keybind (maximize_horizontally, handle_maximize_horizontally, 0,
_("Move window to north-west (top left) corner"), BINDING_PER_WINDOW, NULL,
NULL) _("Maximize window horizontally"))
item (move_to_corner_ne, "", 0, BINDING_PER_WINDOW,
_("Move window to north-east (top right) corner"),
NULL)
item (move_to_corner_sw, "", 0, BINDING_PER_WINDOW,
_("Move window to south-west (bottom left) corner"),
NULL)
item (move_to_corner_se, "", 0, BINDING_PER_WINDOW,
_("Move window to south-east (bottom right) corner"),
NULL)
item (move_to_side_n, "", 0, BINDING_PER_WINDOW, keybind (move_to_corner_nw, handle_move_to_corner_nw, 0,
_("Move window to north (top) side of screen"), BINDING_PER_WINDOW, NULL,
NULL) _("Move window to north-west (top left) corner"))
item (move_to_side_s, "", 0, BINDING_PER_WINDOW, keybind (move_to_corner_ne, handle_move_to_corner_ne, 0,
_("Move window to south (bottom) side of screen"), BINDING_PER_WINDOW, NULL,
NULL) _("Move window to north-east (top right) corner"))
item (move_to_side_e, "", 0, BINDING_PER_WINDOW, keybind (move_to_corner_sw, handle_move_to_corner_sw, 0,
_("Move window to east (right) side of screen"), BINDING_PER_WINDOW, NULL,
NULL) _("Move window to south-west (bottom left) corner"))
item (move_to_side_w, "", 0, BINDING_PER_WINDOW, keybind (move_to_corner_nw, handle_move_to_corner_se, 0,
_("Move window to west (left) side of screen"), BINDING_PER_WINDOW, NULL,
NULL) _("Move window to south-east (bottom right) corner"))
item (move_to_center, "", 0, BINDING_PER_WINDOW,
_("Move window to center of screen"), keybind (move_to_side_n, handle_move_to_side_n, 0,
NULL) BINDING_PER_WINDOW, NULL,
_("Move window to north (top) side of screen"))
keybind (move_to_side_s, handle_move_to_side_s, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to south (bottom) side of screen"))
keybind (move_to_side_e, handle_move_to_side_e, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to east (right) side of screen"))
keybind (move_to_side_w, handle_move_to_side_w, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to west (left) side of screen"))
keybind (move_to_center, handle_move_to_center, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to center of screen"))
/* eof window-bindings.h */ /* eof window-bindings.h */