Commit 121a6f89 authored by Benjamin Berg's avatar Benjamin Berg

media-keys: Move all keyboard bindings into settings

This creates new "X-static" binding entries in the configuration store
which store all the previously hard-coded keys. The effect is that it is
possible for users to override the behaviour, with the caveat that newly
added keybindings will not be picked up for that key.
parent 28684f88
......@@ -145,7 +145,7 @@ typedef struct {
ShellActionMode modes;
MetaKeyBindingFlags grab_flags;
const char *settings_key;
const char *hard_coded;
gboolean static_setting;
char *custom_path;
char *custom_command;
GArray *accel_ids;
......@@ -371,8 +371,6 @@ get_key_string (MediaKey *key)
{
if (key->settings_key != NULL)
return g_strdup_printf ("settings:%s", key->settings_key);
else if (key->hard_coded != NULL)
return g_strdup_printf ("fixed:%s", key->hard_coded);
else if (key->custom_path != NULL)
return g_strdup_printf ("custom:%s", key->custom_path);
else
......@@ -387,11 +385,30 @@ get_bindings (GsdMediaKeysManager *manager,
GPtrArray *array;
gchar *binding;
if (key->settings_key != NULL)
return g_settings_get_strv (priv->settings, key->settings_key);
if (key->settings_key != NULL) {
g_autofree gchar *static_settings_key = NULL;
g_autofree GStrv keys = NULL;
g_autofree GStrv static_keys = NULL;
gchar **item;
if (!key->static_setting)
return g_settings_get_strv (priv->settings, key->settings_key);
static_settings_key = g_strconcat (key->settings_key, "-static", NULL);
keys = g_settings_get_strv (priv->settings, key->settings_key);
static_keys = g_settings_get_strv (priv->settings, static_settings_key);
array = g_ptr_array_new ();
/* Steals all strings from the settings */
for (item = keys; *item; item++)
g_ptr_array_add (array, *item);
for (item = static_keys; *item; item++)
g_ptr_array_add (array, *item);
g_ptr_array_add (array, NULL);
return (GStrv) g_ptr_array_free (array, FALSE);
}
if (key->hard_coded != NULL)
binding = g_strdup (key->hard_coded);
else if (key->custom_path != NULL) {
GSettings *settings;
......@@ -938,7 +955,7 @@ add_key (GsdMediaKeysManager *manager, guint i)
key = media_key_new ();
key->key_type = media_keys[i].key_type;
key->settings_key = media_keys[i].settings_key;
key->hard_coded = media_keys[i].hard_coded;
key->static_setting = media_keys[i].static_setting;
key->modes = media_keys[i].modes;
key->grab_flags = media_keys[i].grab_flags;
......
......@@ -38,82 +38,71 @@
static struct {
MediaKeyType key_type;
const char *settings_key;
const char *hard_coded;
gboolean static_setting;
ShellActionMode modes;
MetaKeyBindingFlags grab_flags;
} media_keys[] = {
{ TOUCHPAD_KEY, NULL,"XF86TouchpadToggle", SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ TOUCHPAD_KEY, NULL,"<Ctrl><Super>XF86TouchpadToggle", SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ TOUCHPAD_ON_KEY, NULL, "XF86TouchpadOn", SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ TOUCHPAD_OFF_KEY, NULL, "XF86TouchpadOff", SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MUTE_KEY, "volume-mute", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ VOLUME_DOWN_KEY, "volume-down", NULL, SHELL_ACTION_MODE_ALL },
{ VOLUME_DOWN_KEY, NULL, "<Ctrl>XF86AudioLowerVolume", SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_KEY, "volume-up", NULL, SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_KEY, NULL, "<Ctrl>XF86AudioRaiseVolume", SHELL_ACTION_MODE_ALL },
{ MIC_MUTE_KEY, "mic-mute", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MUTE_QUIET_KEY, NULL, "<Alt>XF86AudioMute", SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ VOLUME_DOWN_QUIET_KEY, NULL, "<Alt>XF86AudioLowerVolume", SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_QUIET_KEY, NULL, "<Alt>XF86AudioRaiseVolume", SHELL_ACTION_MODE_ALL },
{ VOLUME_DOWN_PRECISE_KEY, NULL, "<Shift>XF86AudioLowerVolume", SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_PRECISE_KEY, NULL, "<Shift>XF86AudioRaiseVolume", SHELL_ACTION_MODE_ALL },
{ LOGOUT_KEY, "logout", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ EJECT_KEY, "eject", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ HOME_KEY, "home", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MEDIA_KEY, "media", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ CALCULATOR_KEY, "calculator", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SEARCH_KEY, "search", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ EMAIL_KEY, "email", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ CONTROL_CENTER_KEY, "control-center", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENSAVER_KEY, "screensaver", NULL, SCREENSAVER_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENSAVER_KEY, NULL, "XF86ScreenSaver", SCREENSAVER_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ HELP_KEY, "help", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ HELP_KEY, NULL, "<Super>F1", GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENSHOT_KEY, "screenshot", NULL, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ WINDOW_SCREENSHOT_KEY, "window-screenshot", NULL, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ AREA_SCREENSHOT_KEY, "area-screenshot", NULL, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENSHOT_CLIP_KEY, "screenshot-clip", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ WINDOW_SCREENSHOT_CLIP_KEY, "window-screenshot-clip", NULL, SHELL_ACTION_MODE_NORMAL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ AREA_SCREENSHOT_CLIP_KEY, "area-screenshot-clip", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENCAST_KEY, "screencast", NULL, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ WWW_KEY, "www", NULL, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ PLAY_KEY, "play", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ PLAY_KEY, NULL, "<Ctrl>XF86AudioPlay", SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ PAUSE_KEY, "pause", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ STOP_KEY, "stop", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ PREVIOUS_KEY, "previous", NULL, SHELL_ACTION_MODE_ALL },
{ PREVIOUS_KEY, NULL, "<Ctrl>XF86AudioPrev", SHELL_ACTION_MODE_ALL },
{ NEXT_KEY, "next", NULL, SHELL_ACTION_MODE_ALL },
{ NEXT_KEY, NULL, "<Ctrl>XF86AudioNext", SHELL_ACTION_MODE_ALL },
{ REWIND_KEY, NULL, "XF86AudioRewind", SHELL_ACTION_MODE_ALL },
{ FORWARD_KEY, NULL, "XF86AudioForward", SHELL_ACTION_MODE_ALL },
{ REPEAT_KEY, NULL, "XF86AudioRepeat", SHELL_ACTION_MODE_ALL },
{ RANDOM_KEY, NULL, "XF86AudioRandomPlay", SHELL_ACTION_MODE_ALL },
{ ROTATE_VIDEO_LOCK_KEY, NULL, "<Super>o", SHELL_ACTION_MODE_ALL },
{ MAGNIFIER_KEY, "magnifier", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENREADER_KEY, "screenreader", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ ON_SCREEN_KEYBOARD_KEY, "on-screen-keyboard", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ INCREASE_TEXT_KEY, "increase-text-size", NULL, SHELL_ACTION_MODE_ALL },
{ DECREASE_TEXT_KEY, "decrease-text-size", NULL, SHELL_ACTION_MODE_ALL },
{ TOGGLE_CONTRAST_KEY, "toggle-contrast", NULL, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MAGNIFIER_ZOOM_IN_KEY, "magnifier-zoom-in", NULL, SHELL_ACTION_MODE_ALL },
{ MAGNIFIER_ZOOM_OUT_KEY, "magnifier-zoom-out", NULL, SHELL_ACTION_MODE_ALL },
{ POWER_KEY, NULL, "XF86PowerOff", POWER_KEYS_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ TOUCHPAD_KEY, "touchpad-toggle", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ TOUCHPAD_ON_KEY, "touchpad-on", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ TOUCHPAD_OFF_KEY, "touchpad-off", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MUTE_KEY, "volume-mute", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ VOLUME_DOWN_KEY, "volume-down", TRUE, SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_KEY, "volume-up", TRUE, SHELL_ACTION_MODE_ALL },
{ MIC_MUTE_KEY, "mic-mute", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MUTE_QUIET_KEY, "volume-mute-quiet", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ VOLUME_DOWN_QUIET_KEY, "volume-down-quiet", TRUE, SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_QUIET_KEY, "volume-up-quiet", TRUE, SHELL_ACTION_MODE_ALL },
{ VOLUME_DOWN_PRECISE_KEY, "volume-down-precise", TRUE, SHELL_ACTION_MODE_ALL },
{ VOLUME_UP_PRECISE_KEY, "volume-up-precise", TRUE, SHELL_ACTION_MODE_ALL },
{ LOGOUT_KEY, "logout", FALSE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ EJECT_KEY, "eject", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ HOME_KEY, "home", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MEDIA_KEY, "media", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ CALCULATOR_KEY, "calculator", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SEARCH_KEY, "search", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ EMAIL_KEY, "email", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ CONTROL_CENTER_KEY, "control-center", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENSAVER_KEY, "screensaver", TRUE, SCREENSAVER_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ HELP_KEY, "help", FALSE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENSHOT_KEY, "screenshot", FALSE, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ WINDOW_SCREENSHOT_KEY, "window-screenshot", FALSE, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ AREA_SCREENSHOT_KEY, "area-screenshot", FALSE, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENSHOT_CLIP_KEY, "screenshot-clip", FALSE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ WINDOW_SCREENSHOT_CLIP_KEY, "window-screenshot-clip", FALSE, SHELL_ACTION_MODE_NORMAL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ AREA_SCREENSHOT_CLIP_KEY, "area-screenshot-clip", FALSE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENCAST_KEY, "screencast", FALSE, NO_LOCK_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ WWW_KEY, "www", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ PLAY_KEY, "play", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ PAUSE_KEY, "pause", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ STOP_KEY, "stop", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ PREVIOUS_KEY, "previous", TRUE, SHELL_ACTION_MODE_ALL },
{ NEXT_KEY, "next", TRUE, SHELL_ACTION_MODE_ALL },
{ REWIND_KEY, "playback-rewind", TRUE, SHELL_ACTION_MODE_ALL },
{ FORWARD_KEY, "playback-forward", TRUE, SHELL_ACTION_MODE_ALL },
{ REPEAT_KEY, "playback-repeat", TRUE, SHELL_ACTION_MODE_ALL },
{ RANDOM_KEY, "playback-random", TRUE, SHELL_ACTION_MODE_ALL },
{ ROTATE_VIDEO_LOCK_KEY, "rotate-video-lock", TRUE, SHELL_ACTION_MODE_ALL },
{ MAGNIFIER_KEY, "magnifier", FALSE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREENREADER_KEY, "screenreader", FALSE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ ON_SCREEN_KEYBOARD_KEY, "on-screen-keyboard", FALSE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ INCREASE_TEXT_KEY, "increase-text-size", FALSE, SHELL_ACTION_MODE_ALL },
{ DECREASE_TEXT_KEY, "decrease-text-size", FALSE, SHELL_ACTION_MODE_ALL },
{ TOGGLE_CONTRAST_KEY, "toggle-contrast", FALSE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ MAGNIFIER_ZOOM_IN_KEY, "magnifier-zoom-in", FALSE, SHELL_ACTION_MODE_ALL },
{ MAGNIFIER_ZOOM_OUT_KEY, "magnifier-zoom-out", FALSE, SHELL_ACTION_MODE_ALL },
{ POWER_KEY, "power", TRUE, POWER_KEYS_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
/* the kernel / Xorg names really are like this... */
{ SLEEP_KEY, NULL, "XF86Suspend", POWER_KEYS_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SUSPEND_KEY, NULL, "XF86Sleep", POWER_KEYS_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ HIBERNATE_KEY, NULL, "XF86Hibernate", POWER_KEYS_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREEN_BRIGHTNESS_UP_KEY, NULL, "XF86MonBrightnessUp", SHELL_ACTION_MODE_ALL },
{ SCREEN_BRIGHTNESS_DOWN_KEY, NULL, "XF86MonBrightnessDown", SHELL_ACTION_MODE_ALL },
{ SCREEN_BRIGHTNESS_CYCLE_KEY, NULL, "XF86MonBrightnessCycle", SHELL_ACTION_MODE_ALL },
{ KEYBOARD_BRIGHTNESS_UP_KEY, NULL, "XF86KbdBrightnessUp", SHELL_ACTION_MODE_ALL },
{ KEYBOARD_BRIGHTNESS_DOWN_KEY, NULL, "XF86KbdBrightnessDown", SHELL_ACTION_MODE_ALL },
{ KEYBOARD_BRIGHTNESS_TOGGLE_KEY, NULL, "XF86KbdLightOnOff", SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ BATTERY_KEY, NULL, "XF86Battery", GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ RFKILL_KEY, NULL, "XF86WLAN", GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ RFKILL_KEY, NULL, "XF86UWB", GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ RFKILL_KEY, NULL, "XF86RFKill", GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ BLUETOOTH_RFKILL_KEY, NULL, "XF86Bluetooth", GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT}
{ SUSPEND_KEY, "suspend", TRUE, POWER_KEYS_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ HIBERNATE_KEY, "hibernate", TRUE, POWER_KEYS_MODE, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ SCREEN_BRIGHTNESS_UP_KEY, "screen-brightness-up", TRUE, SHELL_ACTION_MODE_ALL },
{ SCREEN_BRIGHTNESS_DOWN_KEY, "screen-brightness-down", TRUE, SHELL_ACTION_MODE_ALL },
{ SCREEN_BRIGHTNESS_CYCLE_KEY, "screen-brightness-cycle", TRUE, SHELL_ACTION_MODE_ALL },
{ KEYBOARD_BRIGHTNESS_UP_KEY, "keyboard-brightness-up", TRUE, SHELL_ACTION_MODE_ALL },
{ KEYBOARD_BRIGHTNESS_DOWN_KEY, "keyboard-brightness-down", TRUE, SHELL_ACTION_MODE_ALL },
{ KEYBOARD_BRIGHTNESS_TOGGLE_KEY, "keyboard-brightness-toggle", TRUE, SHELL_ACTION_MODE_ALL, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ BATTERY_KEY, "battery-status", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ RFKILL_KEY, "rfkill", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT },
{ BLUETOOTH_RFKILL_KEY, "rfkill-bluetooth", TRUE, GSD_ACTION_MODE_LAUNCHER, META_KEY_BINDING_IGNORE_AUTOREPEAT}
};
#undef SCREENSAVER_MODE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment