Codebase list virt-viewer / f08cb60
Add "USB device reset" accel Adds a "USB device reset" default keyboard shortcut (ctrl+shift+r), as well as the option to override this shortcut with the --hotkeys opt. Updates documentation accordingly. Signed-off-by: Shawn M. Chapla <schapla@codeweavers.com> Shawn M. Chapla authored 3 years ago Shawn M. Chapla committed 3 years ago
4 changed file(s) with 57 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
7272 will be effective even when the guest display widget has input focus. The format
7373 for B<HOTKEYS> is <action1>=<key1>[+<key2>][,<action2>=<key3>[+<key4>]].
7474 Key-names are case-insensitive. Valid actions are: toggle-fullscreen,
75 release-cursor, secure-attention, smartcard-insert and smartcard-remove. The
76 C<secure-attention> action sends a secure attention sequence (Ctrl+Alt+Del) to
77 the guest. Examples:
75 release-cursor, secure-attention, usb-device-reset, smartcard-insert and
76 smartcard-remove. The C<secure-attention> action sends a secure attention
77 sequence (Ctrl+Alt+Del) to the guest. Examples:
7878
7979 --hotkeys=toggle-fullscreen=shift+f11,release-cursor=shift+f12
8080
9292 will be effective even when the guest display widget has input focus. The format
9393 for B<HOTKEYS> is <action1>=<key1>[+<key2>][,<action2>=<key3>[+<key4>]].
9494 Key-names are case-insensitive. Valid actions are: toggle-fullscreen,
95 release-cursor, secure-attention, smartcard-insert and smartcard-remove. The
96 C<secure-attention> action sends a secure attention sequence (Ctrl+Alt+Del) to
97 the guest. Examples:
95 release-cursor, secure-attention, usb-device-reset, smartcard-insert and
96 smartcard-remove. The C<secure-attention> action sends a secure attention
97 sequence (Ctrl+Alt+Del) to the guest. Examples:
9898
9999 --hotkeys=toggle-fullscreen=shift+f11,release-cursor=shift+f12
100100
111111 static void virt_viewer_app_set_fullscreen(VirtViewerApp *self, gboolean fullscreen);
112112 static void virt_viewer_app_update_menu_displays(VirtViewerApp *self);
113113 static void virt_viewer_update_smartcard_accels(VirtViewerApp *self);
114 static void virt_viewer_update_usbredir_accels(VirtViewerApp *self);
114115 static void virt_viewer_app_add_option_entries(VirtViewerApp *self, GOptionContext *context, GOptionGroup *group);
115116 static VirtViewerWindow *virt_viewer_app_get_nth_window(VirtViewerApp *self, gint nth);
116117
164165 GdkModifierType insert_smartcard_accel_mods;
165166 guint remove_smartcard_accel_key;
166167 GdkModifierType remove_smartcard_accel_mods;
168 gboolean usb_device_reset_accel_valid;
169 guint usb_device_reset_accel_key;
170 GdkModifierType usb_device_reset_accel_mods;
167171 gboolean quit_on_disconnect;
168172 gboolean supports_share_clipboard;
169173 VirtViewerKeyMapping *keyMappings;
12701274
12711275 virt_viewer_app_set_usb_options_sensitive(self, has_usbredir);
12721276 virt_viewer_app_set_usb_reset_sensitive(self, has_usbredir);
1277 virt_viewer_update_usbredir_accels(self);
12731278 }
12741279
12751280 static void notify_software_reader_cb(GObject *gobject G_GNUC_UNUSED,
21282133 }
21292134
21302135 static void
2136 virt_viewer_set_usb_device_reset_accel(VirtViewerApp *self,
2137 guint accel_key,
2138 GdkModifierType accel_mods,
2139 gboolean overwrite)
2140 {
2141 VirtViewerAppPrivate *priv = self->priv;
2142
2143 if (overwrite || !priv->usb_device_reset_accel_valid) {
2144 priv->usb_device_reset_accel_valid = TRUE;
2145 priv->usb_device_reset_accel_key = accel_key;
2146 priv->usb_device_reset_accel_mods = accel_mods;
2147 }
2148 }
2149
2150 static void
2151 virt_viewer_update_usbredir_accels(VirtViewerApp *self)
2152 {
2153 gboolean has_usbredir;
2154 VirtViewerAppPrivate *priv = self->priv;
2155
2156 if (self->priv->session != NULL) {
2157 g_object_get(G_OBJECT(self->priv->session),
2158 "has-usbredir", &has_usbredir, NULL);
2159 } else {
2160 has_usbredir = FALSE;
2161 }
2162
2163 if (has_usbredir) {
2164 gtk_accel_map_change_entry("<virt-viewer>/file/usb-device-reset",
2165 priv->usb_device_reset_accel_key,
2166 priv->usb_device_reset_accel_mods,
2167 TRUE);
2168 } else {
2169 gtk_accel_map_change_entry("<virt-viewer>/file/usb-device-reset", 0, 0, TRUE);
2170 }
2171 }
2172
2173 static void
21312174 virt_viewer_app_on_application_startup(GApplication *app)
21322175 {
21332176 VirtViewerApp *self = VIRT_VIEWER_APP(app);
21622205
21632206 virt_viewer_set_insert_smartcard_accel(self, GDK_KEY_F8, GDK_SHIFT_MASK);
21642207 virt_viewer_set_remove_smartcard_accel(self, GDK_KEY_F9, GDK_SHIFT_MASK);
2208 virt_viewer_set_usb_device_reset_accel(self, GDK_KEY_r, GDK_SHIFT_MASK | GDK_CONTROL_MASK, FALSE);
2209
21652210 gtk_accel_map_add_entry("<virt-viewer>/view/toggle-fullscreen", GDK_KEY_F11, 0);
21662211 gtk_accel_map_add_entry("<virt-viewer>/view/release-cursor", GDK_KEY_F12, GDK_SHIFT_MASK);
21672212 gtk_accel_map_add_entry("<virt-viewer>/view/zoom-reset", GDK_KEY_0, GDK_CONTROL_MASK);
24132458 gtk_accel_map_change_entry("<virt-viewer>/send/secure-attention", 0, 0, TRUE);
24142459 virt_viewer_set_insert_smartcard_accel(self, 0, 0);
24152460 virt_viewer_set_remove_smartcard_accel(self, 0, 0);
2461 virt_viewer_set_usb_device_reset_accel(self, 0, 0, TRUE);
24162462 }
24172463
24182464 void
24702516 virt_viewer_set_insert_smartcard_accel(self, accel_key, accel_mods);
24712517 } else if (g_str_equal(*hotkey, "smartcard-remove")) {
24722518 virt_viewer_set_remove_smartcard_accel(self, accel_key, accel_mods);
2519 } else if (g_str_equal(*hotkey, "usb-device-reset")) {
2520 virt_viewer_set_usb_device_reset_accel(self, accel_key, accel_mods, TRUE);
24732521 } else {
24742522 g_warning("Unknown hotkey command %s", *hotkey);
24752523 }
24802528
24812529 virt_viewer_app_set_enable_accel(self, TRUE);
24822530 virt_viewer_update_smartcard_accels(self);
2531 virt_viewer_update_usbredir_accels(self);
24832532 }
24842533
24852534 void
375375 "can-activate-accel", G_CALLBACK(can_activate_cb), self);
376376 g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-zoom-out"),
377377 "can-activate-accel", G_CALLBACK(can_activate_cb), self);
378 g_signal_connect(gtk_builder_get_object(priv->builder, "menu-file-usb-device-reset"),
379 "can-activate-accel", G_CALLBACK(can_activate_cb), self);
378380
379381 vbox = GTK_WIDGET(gtk_builder_get_object(priv->builder, "viewer-box"));
380382 virt_viewer_window_toolbar_setup(self);