Skip to content

Commit d8eabb8

Browse files
zhangxianwei8raveit65
authored andcommitted
media-keys: Add support for display switch OSD
Some laptops have a display switch mode hotkey. This is bound by default to XF86Display. Add OSD to give people a visual feed back. Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
1 parent 62299ac commit d8eabb8

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

plugins/media-keys/acme.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ enum {
5858
LOGOUT_KEY,
5959
RFKILL_KEY,
6060
BLUETOOTH_RFKILL_KEY,
61+
DISPLAY_KEY,
6162
HANDLED_KEYS,
6263
};
6364

@@ -99,7 +100,8 @@ static struct {
99100
{ ON_SCREEN_KEYBOARD_KEY, "on-screen-keyboard", NULL, NULL },
100101
{ LOGOUT_KEY, "logout", NULL, NULL },
101102
{ RFKILL_KEY, NULL, "XF86WLAN", NULL },
102-
{ BLUETOOTH_RFKILL_KEY, NULL, "XF86Bluetooth", NULL }
103+
{ BLUETOOTH_RFKILL_KEY, NULL, "XF86Bluetooth", NULL },
104+
{ DISPLAY_KEY, NULL, "XF86Display", NULL }
103105
};
104106

105107
#endif /* __ACME_H__ */

plugins/media-keys/msd-media-keys-manager.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,27 @@ do_rfkill_action (MsdMediaKeysManager *manager,
918918
data->property, new_state ? "true" : "false");
919919
}
920920

921+
static void
922+
do_display_osd_action (MsdMediaKeysManager *manager)
923+
{
924+
GdkDisplay *display;
925+
int n_monitors;
926+
927+
display = gdk_display_get_default ();
928+
n_monitors = gdk_display_get_n_monitors (display);
929+
930+
dialog_init (manager);
931+
if (n_monitors > 1)
932+
msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
933+
"video-joined-displays-symbolic",
934+
_("Changing Screen Layout"));
935+
else
936+
msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog),
937+
"video-single-display-symbolic",
938+
_("No External Display"));
939+
dialog_show (manager);
940+
}
941+
921942
static gint
922943
find_by_application (gconstpointer a,
923944
gconstpointer b)
@@ -1179,6 +1200,9 @@ do_action (MsdMediaKeysManager *manager,
11791200
case BLUETOOTH_RFKILL_KEY:
11801201
do_rfkill_action (manager, TRUE);
11811202
break;
1203+
case DISPLAY_KEY:
1204+
do_display_osd_action (manager);
1205+
break;
11821206
default:
11831207
g_assert_not_reached ();
11841208
}

0 commit comments

Comments
 (0)