[virt-tools-list] [PATCH 1/2] Add ability to send Secure attention sequence via keyboard
Jonathon Jongsma
jjongsma at redhat.com
Fri Aug 30 21:21:28 UTC 2013
On Windows, the OS doesn't allow applications to handle Ctrl+Alt+Del, because
it's handled by the OS at a much lower level. Although we have a menu item to
send this sequence to the guest, it's not possible to send via the keyboard (in
the windows client). So add an alternative key sequence (defaulting to
Ctrl+Alt+End) to send this sequence to the guest.
---
src/virt-gtk-compat.h | 1 +
src/virt-viewer-app.c | 4 ++++
src/virt-viewer-window.c | 44 ++++++++++++++++++++++++--------------------
3 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/src/virt-gtk-compat.h b/src/virt-gtk-compat.h
index 81d2fbd..67ac768 100644
--- a/src/virt-gtk-compat.h
+++ b/src/virt-gtk-compat.h
@@ -39,6 +39,7 @@ G_BEGIN_DECLS
#define GDK_Control_L GDK_KEY_Control_L
#define GDK_Alt_L GDK_KEY_Alt_L
#define GDK_Delete GDK_KEY_Delete
+#define GDK_End GDK_KEY_End
#define GDK_BackSpace GDK_KEY_BackSpace
#define GDK_Print GDK_KEY_Print
#define GDK_F1 GDK_KEY_F1
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 5f65ec3..445fe26 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1582,6 +1582,7 @@ virt_viewer_app_constructor (GType gtype,
gtk_accel_map_add_entry("<virt-viewer>/view/fullscreen", GDK_F11, 0);
gtk_accel_map_add_entry("<virt-viewer>/view/release-cursor", GDK_F12, GDK_SHIFT_MASK);
gtk_accel_map_add_entry("<virt-viewer>/view/zoom-reset", GDK_0, GDK_CONTROL_MASK);
+ gtk_accel_map_add_entry("<virt-viewer>/send/secure-attention", GDK_End, GDK_CONTROL_MASK | GDK_MOD1_MASK);
virt_viewer_window_set_zoom_level(priv->main_window, opt_zoom);
virt_viewer_app_set_fullscreen(self, opt_fullscreen);
@@ -1779,6 +1780,7 @@ virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys_str)
/* Disable default bindings and replace them with our own */
gtk_accel_map_change_entry("<virt-viewer>/view/fullscreen", 0, 0, TRUE);
gtk_accel_map_change_entry("<virt-viewer>/view/release-cursor", 0, 0, TRUE);
+ gtk_accel_map_change_entry("<virt-viewer>/send/secure-attention", 0, 0, TRUE);
virt_viewer_set_insert_smartcard_accel(self, 0, 0);
virt_viewer_set_remove_smartcard_accel(self, 0, 0);
@@ -1800,6 +1802,8 @@ virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys_str)
gtk_accel_map_change_entry("<virt-viewer>/view/fullscreen", accel_key, accel_mods, TRUE);
} else if (g_str_equal(*hotkey, "release-cursor")) {
gtk_accel_map_change_entry("<virt-viewer>/view/release-cursor", accel_key, accel_mods, TRUE);
+ } else if (g_str_equal(*hotkey, "secure-attention")) {
+ gtk_accel_map_change_entry("<virt-viewer>/send/secure-attention", accel_key, accel_mods, TRUE);
} else if (g_str_equal(*hotkey, "smartcard-insert")) {
virt_viewer_set_insert_smartcard_accel(self, accel_key, accel_mods);
} else if (g_str_equal(*hotkey, "smartcard-remove")) {
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 0fcd53e..7593e3c 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -558,26 +558,27 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor)
struct keyComboDef {
guint keys[MAX_KEY_COMBO];
const char *label;
+ const gchar* accel_path;
};
static const struct keyComboDef keyCombos[] = {
- { { GDK_Control_L, GDK_Alt_L, GDK_Delete, GDK_VoidSymbol }, N_("Ctrl+Alt+_Del")},
- { { GDK_Control_L, GDK_Alt_L, GDK_BackSpace, GDK_VoidSymbol }, N_("Ctrl+Alt+_Backspace")},
- { { GDK_VoidSymbol }, "" },
- { { GDK_Control_L, GDK_Alt_L, GDK_F1, GDK_VoidSymbol }, N_("Ctrl+Alt+F_1")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F2, GDK_VoidSymbol }, N_("Ctrl+Alt+F_2")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F3, GDK_VoidSymbol }, N_("Ctrl+Alt+F_3")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F4, GDK_VoidSymbol }, N_("Ctrl+Alt+F_4")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F5, GDK_VoidSymbol }, N_("Ctrl+Alt+F_5")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F6, GDK_VoidSymbol }, N_("Ctrl+Alt+F_6")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F7, GDK_VoidSymbol }, N_("Ctrl+Alt+F_7")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F8, GDK_VoidSymbol }, N_("Ctrl+Alt+F_8")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F9, GDK_VoidSymbol }, N_("Ctrl+Alt+F_9")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F10, GDK_VoidSymbol }, N_("Ctrl+Alt+F1_0")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F11, GDK_VoidSymbol }, N_("Ctrl+Alt+F11")},
- { { GDK_Control_L, GDK_Alt_L, GDK_F12, GDK_VoidSymbol }, N_("Ctrl+Alt+F12")},
- { { GDK_VoidSymbol }, "" },
- { { GDK_Print, GDK_VoidSymbol }, "_PrintScreen"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_Delete, GDK_VoidSymbol }, N_("Ctrl+Alt+_Del"), "<virt-viewer>/send/secure-attention"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_BackSpace, GDK_VoidSymbol }, N_("Ctrl+Alt+_Backspace"), NULL},
+ { { GDK_VoidSymbol }, "" , NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F1, GDK_VoidSymbol }, N_("Ctrl+Alt+F_1"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F2, GDK_VoidSymbol }, N_("Ctrl+Alt+F_2"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F3, GDK_VoidSymbol }, N_("Ctrl+Alt+F_3"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F4, GDK_VoidSymbol }, N_("Ctrl+Alt+F_4"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F5, GDK_VoidSymbol }, N_("Ctrl+Alt+F_5"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F6, GDK_VoidSymbol }, N_("Ctrl+Alt+F_6"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F7, GDK_VoidSymbol }, N_("Ctrl+Alt+F_7"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F8, GDK_VoidSymbol }, N_("Ctrl+Alt+F_8"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F9, GDK_VoidSymbol }, N_("Ctrl+Alt+F_9"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F10, GDK_VoidSymbol }, N_("Ctrl+Alt+F1_0"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F11, GDK_VoidSymbol }, N_("Ctrl+Alt+F11"), NULL},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F12, GDK_VoidSymbol }, N_("Ctrl+Alt+F12"), NULL},
+ { { GDK_VoidSymbol }, "" , NULL},
+ { { GDK_Print, GDK_VoidSymbol }, "_PrintScreen", NULL},
};
static guint
@@ -607,7 +608,7 @@ virt_viewer_window_menu_send(GtkWidget *menu,
static void
virt_viewer_menu_add_combo(VirtViewerWindow *self, GtkMenu *menu,
- const guint *keys, const gchar *label)
+ const guint *keys, const gchar *label, const gchar* accel_path)
{
GtkWidget *item;
@@ -615,6 +616,8 @@ virt_viewer_menu_add_combo(VirtViewerWindow *self, GtkMenu *menu,
item = gtk_separator_menu_item_new();
} else {
item = gtk_menu_item_new_with_mnemonic(label);
+ if (accel_path)
+ gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
guint *ckeys = g_memdup(keys, (get_nkeys(keys) + 1) * sizeof(guint));
g_object_set_data_full(G_OBJECT(item), "vv-keys", ckeys, g_free);
g_signal_connect(item, "activate", G_CALLBACK(virt_viewer_window_menu_send), self);
@@ -682,7 +685,7 @@ accel_map_item_cb(gpointer data,
guint *keys = accel_key_to_keys(&key);
gchar *label = gtk_accelerator_get_label(accel_key, accel_mods);
- virt_viewer_menu_add_combo(d->self, d->menu, keys, label);
+ virt_viewer_menu_add_combo(d->self, d->menu, keys, label, NULL);
g_free(label);
g_free(keys);
}
@@ -693,9 +696,10 @@ virt_viewer_window_get_keycombo_menu(VirtViewerWindow *self)
gint i;
VirtViewerWindowPrivate *priv = self->priv;
GtkMenu *menu = GTK_MENU(gtk_menu_new());
+ gtk_menu_set_accel_group(menu, priv->accel_group);
for (i = 0 ; i < G_N_ELEMENTS(keyCombos); i++) {
- virt_viewer_menu_add_combo(self, menu, keyCombos[i].keys, keyCombos[i].label);
+ virt_viewer_menu_add_combo(self, menu, keyCombos[i].keys, keyCombos[i].label, keyCombos[i].accel_path);
}
if (virt_viewer_app_get_enable_accel(priv->app)) {
--
1.8.3.1
More information about the virt-tools-list
mailing list