mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
Take control of the panel's global keybindings. The screenshot utility is
2003-02-24 Mark McLoughlin <mark@skynet.ie> Take control of the panel's global keybindings. The screenshot utility is hooked up using a special case run_command and the menu and run dialog bindings are done using the _GNOME_PANEL_ACTION ClientMessage protocol. * src/display.[ch]: (meta_display_open): add some atoms. * src/keybindings.c: (handle_panel_keybinding): impl to handle a keybinding by sending an action message to the panel. * src/metacity.schemas.in: add schemas for the panel and screenshot keybindings and the screenshot commands. * src/prefs.[ch]: (update_command), (meta_prefs_get_gconf_key_for_command): impl special case handling for the screenshot commands. They are stored at the the end of the commands array but have named keys.
This commit is contained in:
parent
947adb6d07
commit
73cce3b174
22
ChangeLog
22
ChangeLog
@ -1,3 +1,25 @@
|
||||
2003-02-24 Mark McLoughlin <mark@skynet.ie>
|
||||
|
||||
Take control of the panel's global keybindings. The
|
||||
screenshot utility is hooked up using a special case
|
||||
run_command and the menu and run dialog bindings are
|
||||
done using the _GNOME_PANEL_ACTION ClientMessage
|
||||
protocol.
|
||||
|
||||
* src/display.[ch]: (meta_display_open): add some atoms.
|
||||
|
||||
* src/keybindings.c:
|
||||
(handle_panel_keybinding): impl to handle a keybinding
|
||||
by sending an action message to the panel.
|
||||
|
||||
* src/metacity.schemas.in: add schemas for the panel and
|
||||
screenshot keybindings and the screenshot commands.
|
||||
|
||||
* src/prefs.[ch]: (update_command),
|
||||
(meta_prefs_get_gconf_key_for_command): impl special case
|
||||
handling for the screenshot commands. They are stored at
|
||||
the the end of the commands array but have named keys.
|
||||
|
||||
2003-02-23 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
Patch from Rob Adams addresses #95014 (placement issues),
|
||||
|
@ -266,7 +266,10 @@ meta_display_open (const char *name)
|
||||
"_NET_STARTUP_ID",
|
||||
"_METACITY_TOGGLE_VERBOSE",
|
||||
"_METACITY_UPDATE_COUNTER",
|
||||
"SYNC_COUNTER"
|
||||
"SYNC_COUNTER",
|
||||
"_GNOME_PANEL_ACTION",
|
||||
"_GNOME_PANEL_ACTION_MAIN_MENU",
|
||||
"_GNOME_PANEL_ACTION_RUN_DIALOG"
|
||||
};
|
||||
Atom atoms[G_N_ELEMENTS(atom_names)];
|
||||
|
||||
@ -406,6 +409,9 @@ meta_display_open (const char *name)
|
||||
display->atom_metacity_toggle_verbose = atoms[78];
|
||||
display->atom_metacity_update_counter = atoms[79];
|
||||
display->atom_sync_counter = atoms[80];
|
||||
display->atom_gnome_panel_action = atoms[81];
|
||||
display->atom_gnome_panel_action_main_menu = atoms[82];
|
||||
display->atom_gnome_panel_action_run_dialog = atoms[83];
|
||||
|
||||
display->prop_hooks = NULL;
|
||||
meta_display_init_window_prop_hooks (display);
|
||||
|
@ -169,6 +169,9 @@ struct _MetaDisplay
|
||||
Atom atom_metacity_toggle_verbose;
|
||||
Atom atom_metacity_update_counter;
|
||||
Atom atom_sync_counter;
|
||||
Atom atom_gnome_panel_action;
|
||||
Atom atom_gnome_panel_action_main_menu;
|
||||
Atom atom_gnome_panel_action_run_dialog;
|
||||
|
||||
/* This is the actual window from focus events,
|
||||
* not the one we last set
|
||||
|
@ -79,6 +79,11 @@ static void handle_toggle_desktop (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
XEvent *event,
|
||||
MetaKeyBinding *binding);
|
||||
static void handle_panel_keybinding (MetaDisplay *display,
|
||||
MetaScreen *screen,
|
||||
MetaWindow *window,
|
||||
XEvent *event,
|
||||
MetaKeyBinding *binding);
|
||||
static void handle_toggle_maximize (MetaDisplay *display,
|
||||
MetaScreen *screen,
|
||||
MetaWindow *window,
|
||||
@ -265,6 +270,10 @@ static const MetaKeyHandler screen_handlers[] = {
|
||||
GINT_TO_POINTER (META_TAB_LIST_DOCKS) },
|
||||
{ META_KEYBINDING_SHOW_DESKTOP, handle_toggle_desktop,
|
||||
NULL },
|
||||
{ META_KEYBINDING_PANEL_MAIN_MENU, handle_panel_keybinding,
|
||||
GINT_TO_POINTER (META_KEYBINDING_ACTION_PANEL_MAIN_MENU) },
|
||||
{ META_KEYBINDING_PANEL_RUN_DIALOG, handle_panel_keybinding,
|
||||
GINT_TO_POINTER (META_KEYBINDING_ACTION_PANEL_RUN_DIALOG) },
|
||||
{ META_KEYBINDING_COMMAND_1, handle_run_command,
|
||||
GINT_TO_POINTER (0) },
|
||||
{ META_KEYBINDING_COMMAND_2, handle_run_command,
|
||||
@ -329,6 +338,10 @@ static const MetaKeyHandler screen_handlers[] = {
|
||||
GINT_TO_POINTER (30) },
|
||||
{ META_KEYBINDING_COMMAND_32, handle_run_command,
|
||||
GINT_TO_POINTER (31) },
|
||||
{ META_KEYBINDING_COMMAND_SCREENSHOT, handle_run_command,
|
||||
GINT_TO_POINTER (32) },
|
||||
{ META_KEYBINDING_COMMAND_WIN_SCREENSHOT, handle_run_command,
|
||||
GINT_TO_POINTER (33) },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
@ -2571,6 +2584,48 @@ handle_toggle_desktop (MetaDisplay *display,
|
||||
meta_screen_show_desktop (screen);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_panel_keybinding (MetaDisplay *display,
|
||||
MetaScreen *screen,
|
||||
MetaWindow *window,
|
||||
XEvent *event,
|
||||
MetaKeyBinding *binding)
|
||||
{
|
||||
MetaKeyBindingAction action;
|
||||
Atom action_atom;
|
||||
XClientMessageEvent ev;
|
||||
|
||||
action = GPOINTER_TO_INT (binding->handler->data);
|
||||
|
||||
action_atom = None;
|
||||
switch (action)
|
||||
{
|
||||
case META_KEYBINDING_ACTION_PANEL_MAIN_MENU:
|
||||
action_atom = display->atom_gnome_panel_action_main_menu;
|
||||
break;
|
||||
case META_KEYBINDING_ACTION_PANEL_RUN_DIALOG:
|
||||
action_atom = display->atom_gnome_panel_action_run_dialog;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
ev.type = ClientMessage;
|
||||
ev.window = screen->xroot;
|
||||
ev.message_type = display->atom_gnome_panel_action;
|
||||
ev.format = 32;
|
||||
ev.data.l[0] = action_atom;
|
||||
ev.data.l[1] = event->xkey.time;
|
||||
|
||||
meta_error_trap_push (display);
|
||||
XSendEvent (display->xdisplay,
|
||||
screen->xroot,
|
||||
False,
|
||||
StructureNotifyMask,
|
||||
(XEvent*) &ev);
|
||||
meta_error_trap_pop (display, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_activate_menu (MetaDisplay *display,
|
||||
MetaScreen *screen,
|
||||
|
@ -1599,6 +1599,100 @@ you set
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/global_keybindings/panel_main_menu</key>
|
||||
<applyto>/apps/metacity/global_keybindings/panel_main_menu</applyto>
|
||||
<owner>metacity</owner>
|
||||
<type>string</type>
|
||||
<default><Alt>F1</default>
|
||||
<locale name="C">
|
||||
<short>Show the panel menu</short>
|
||||
<long>
|
||||
The keybinding which shows the panel's main menu.
|
||||
|
||||
The format looks like "<Control>a" or
|
||||
"<Shift><Alt>F1.
|
||||
|
||||
The parser is fairly liberal and allows lower or upper case,
|
||||
and also abbreviations such as "<Ctl>" and
|
||||
"<Ctrl>". If you set the option to the special string
|
||||
"disabled", then there will be no keybinding for this
|
||||
action.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/global_keybindings/panel_run_dialog</key>
|
||||
<applyto>/apps/metacity/global_keybindings/panel_run_dialog</applyto>
|
||||
<owner>metacity</owner>
|
||||
<type>string</type>
|
||||
<default><Alt>F2</default>
|
||||
<locale name="C">
|
||||
<short>Show the panel run dialog</short>
|
||||
<long>
|
||||
The keybinding which display's the panel's "Run Program" dialog
|
||||
box.
|
||||
|
||||
The format looks like "<Control>a" or
|
||||
"<Shift><Alt>F1.
|
||||
|
||||
The parser is fairly liberal and allows lower or upper case,
|
||||
and also abbreviations such as "<Ctl>" and
|
||||
"<Ctrl>". If you set the option to the special string
|
||||
"disabled", then there will be no keybinding for this
|
||||
action.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/global_keybindings/run_command_screenshot</key>
|
||||
<applyto>/apps/metacity/global_keybindings/run_command_screenshot</applyto>
|
||||
<owner>metacity</owner>
|
||||
<type>string</type>
|
||||
<default>Print</default>
|
||||
<locale name="C">
|
||||
<short>Take a screenshot</short>
|
||||
<long>
|
||||
The keybinding which invokes the panel's screenshot utility.
|
||||
|
||||
The format looks like "<Control>a" or
|
||||
"<Shift><Alt>F1.
|
||||
|
||||
The parser is fairly liberal and allows lower or upper case,
|
||||
and also abbreviations such as "<Ctl>" and
|
||||
"<Ctrl>". If you set the option to the special string
|
||||
"disabled", then there will be no keybinding for this
|
||||
action.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/global_keybindings/run_command_window_screenshot</key>
|
||||
<applyto>/apps/metacity/global_keybindings/run_command_window_screenshot</applyto>
|
||||
<owner>metacity</owner>
|
||||
<type>string</type>
|
||||
<default><Alt>Print</default>
|
||||
<locale name="C">
|
||||
<short>Take a screenshot of a window</short>
|
||||
<long>
|
||||
The keybinding which invokes the panel's screenshot utility
|
||||
to take a screenshot of a window.
|
||||
|
||||
The format looks like "<Control>a" or
|
||||
"<Shift><Alt>F1.
|
||||
|
||||
The parser is fairly liberal and allows lower or upper case,
|
||||
and also abbreviations such as "<Ctl>" and
|
||||
"<Ctrl>". If you set the option to the special string
|
||||
"disabled", then there will be no keybinding for this
|
||||
action.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/global_keybindings/run_command</key>
|
||||
<applyto>/apps/metacity/global_keybindings/run_command_1</applyto>
|
||||
@ -1636,6 +1730,38 @@ you set
|
||||
|
||||
<!-- commands to run with the run_command keybindings -->
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/keybinding_commands/command_screenshot</key>
|
||||
<applyto>/apps/metacity/keybinding_commands/command_screenshot</applyto>
|
||||
<owner>metacity</owner>
|
||||
<type>string</type>
|
||||
<default>gnome-panel-screenshot</default>
|
||||
<locale name="C">
|
||||
<short>The screenshot command</short>
|
||||
<long>
|
||||
The /apps/metacity/global_keybindings/run_command_screenshot
|
||||
key defines a keybinding which causes the command specified
|
||||
by this setting to be invoked.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/keybinding_commands/command_window_screenshot</key>
|
||||
<applyto>/apps/metacity/keybinding_commands/command_window_screenshot</applyto>
|
||||
<owner>metacity</owner>
|
||||
<type>string</type>
|
||||
<default>gnome-panel-screenshot --window</default>
|
||||
<locale name="C">
|
||||
<short>The window screenshot command</short>
|
||||
<long>
|
||||
The /apps/metacity/global_keybindings/run_command_window_screenshot
|
||||
key defines a keybinding which causes the command specified
|
||||
by this setting to be invoked.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/metacity/keybinding_commands/command</key>
|
||||
<applyto>/apps/metacity/keybinding_commands/command_1</applyto>
|
||||
|
56
src/prefs.c
56
src/prefs.c
@ -30,7 +30,11 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX_REASONABLE_WORKSPACES 36
|
||||
#define MAX_COMMANDS 32
|
||||
|
||||
#define MAX_COMMANDS (32 + NUM_EXTRA_COMMANDS)
|
||||
#define NUM_EXTRA_COMMANDS 2
|
||||
#define SCREENSHOT_COMMAND_IDX (MAX_COMMANDS - 2)
|
||||
#define WIN_SCREENSHOT_COMMAND_IDX (MAX_COMMANDS - 1)
|
||||
|
||||
/* If you add a key, it needs updating in init() and in the gconf
|
||||
* notify listener and of course in the .schemas file
|
||||
@ -95,6 +99,7 @@ static MetaButtonLayout button_layout = {
|
||||
}
|
||||
};
|
||||
|
||||
/* The screenshot commands are at the end */
|
||||
static char *commands[MAX_COMMANDS] = { NULL, };
|
||||
|
||||
static char *workspace_names[MAX_REASONABLE_WORKSPACES] = { NULL, };
|
||||
@ -1363,6 +1368,8 @@ static MetaKeyPref screen_bindings[] = {
|
||||
{ META_KEYBINDING_CYCLE_PANELS, 0, 0, TRUE },
|
||||
{ META_KEYBINDING_CYCLE_PANELS_BACKWARD, 0, 0, TRUE },
|
||||
{ META_KEYBINDING_SHOW_DESKTOP, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_PANEL_MAIN_MENU, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_PANEL_RUN_DIALOG, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_COMMAND_1, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_COMMAND_2, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_COMMAND_3, 0, 0, FALSE },
|
||||
@ -1395,6 +1402,8 @@ static MetaKeyPref screen_bindings[] = {
|
||||
{ META_KEYBINDING_COMMAND_30, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_COMMAND_31, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_COMMAND_32, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_COMMAND_SCREENSHOT, 0, 0, FALSE },
|
||||
{ META_KEYBINDING_COMMAND_WIN_SCREENSHOT, 0, 0, FALSE },
|
||||
{ NULL, 0, 0, FALSE}
|
||||
};
|
||||
|
||||
@ -1663,15 +1672,31 @@ update_command (const char *name,
|
||||
|
||||
++p;
|
||||
|
||||
if (!g_ascii_isdigit (*p))
|
||||
if (g_ascii_isdigit (*p))
|
||||
{
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Command %s doesn't end in number?\n", name);
|
||||
return FALSE;
|
||||
i = atoi (p);
|
||||
i -= 1; /* count from 0 not 1 */
|
||||
}
|
||||
else
|
||||
{
|
||||
p = strrchr (name, '/');
|
||||
++p;
|
||||
|
||||
if (strcmp (p, "command_screenshot") == 0)
|
||||
{
|
||||
i = SCREENSHOT_COMMAND_IDX;
|
||||
}
|
||||
else if (strcmp (p, "command_window_screenshot") == 0)
|
||||
{
|
||||
i = WIN_SCREENSHOT_COMMAND_IDX;
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Command %s doesn't end in number?\n", name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
i = atoi (p);
|
||||
i -= 1; /* count from 0 not 1 */
|
||||
|
||||
if (i >= MAX_COMMANDS)
|
||||
{
|
||||
@ -1711,8 +1736,19 @@ char*
|
||||
meta_prefs_get_gconf_key_for_command (int i)
|
||||
{
|
||||
char *key;
|
||||
|
||||
key = g_strdup_printf (KEY_COMMAND_PREFIX"%d", i + 1);
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case SCREENSHOT_COMMAND_IDX:
|
||||
key = g_strdup (KEY_COMMAND_PREFIX "screenshot");
|
||||
break;
|
||||
case WIN_SCREENSHOT_COMMAND_IDX:
|
||||
key = g_strdup (KEY_COMMAND_PREFIX "window_screenshot");
|
||||
break;
|
||||
default:
|
||||
key = g_strdup_printf (KEY_COMMAND_PREFIX"%d", i + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
@ -109,6 +109,8 @@ void meta_prefs_change_workspace_name (int i,
|
||||
#define META_KEYBINDING_CYCLE_PANELS "cycle_panels"
|
||||
#define META_KEYBINDING_CYCLE_PANELS_BACKWARD "cycle_panels_backward"
|
||||
#define META_KEYBINDING_SHOW_DESKTOP "show_desktop"
|
||||
#define META_KEYBINDING_PANEL_MAIN_MENU "panel_main_menu"
|
||||
#define META_KEYBINDING_PANEL_RUN_DIALOG "panel_run_dialog"
|
||||
#define META_KEYBINDING_COMMAND_1 "run_command_1"
|
||||
#define META_KEYBINDING_COMMAND_2 "run_command_2"
|
||||
#define META_KEYBINDING_COMMAND_3 "run_command_3"
|
||||
@ -141,6 +143,8 @@ void meta_prefs_change_workspace_name (int i,
|
||||
#define META_KEYBINDING_COMMAND_30 "run_command_30"
|
||||
#define META_KEYBINDING_COMMAND_31 "run_command_31"
|
||||
#define META_KEYBINDING_COMMAND_32 "run_command_32"
|
||||
#define META_KEYBINDING_COMMAND_SCREENSHOT "run_command_screenshot"
|
||||
#define META_KEYBINDING_COMMAND_WIN_SCREENSHOT "run_command_window_screenshot"
|
||||
|
||||
/* Window bindings */
|
||||
#define META_KEYBINDING_WINDOW_MENU "activate_window_menu"
|
||||
@ -204,6 +208,8 @@ typedef enum _MetaKeyBindingAction
|
||||
META_KEYBINDING_ACTION_CYCLE_PANELS,
|
||||
META_KEYBINDING_ACTION_CYCLE_PANELS_BACKWARD,
|
||||
META_KEYBINDING_ACTION_SHOW_DESKTOP,
|
||||
META_KEYBINDING_ACTION_PANEL_MAIN_MENU,
|
||||
META_KEYBINDING_ACTION_PANEL_RUN_DIALOG,
|
||||
META_KEYBINDING_ACTION_COMMAND_1,
|
||||
META_KEYBINDING_ACTION_COMMAND_2,
|
||||
META_KEYBINDING_ACTION_COMMAND_3,
|
||||
|
Loading…
Reference in New Issue
Block a user