mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2026-01-01 13:10:35 +00:00
Unify configured hotkey behaviour
Whether the hotkeys are set through command line, controller or file, we should get the same keybinding result (clear unspecified, and enable global bindings) However, when started from command line arguments, without --hotkey argument, it will have basic non-global default bindings. https://bugzilla.redhat.com/show_bug.cgi?id=1023447
This commit is contained in:
parent
ac2440611a
commit
8565501b1e
@ -1763,6 +1763,17 @@ virt_viewer_app_set_direct(VirtViewerApp *self, gboolean direct)
|
||||
self->priv->direct = direct;
|
||||
}
|
||||
|
||||
void
|
||||
virt_viewer_app_clear_hotkeys(VirtViewerApp *self)
|
||||
{
|
||||
/* Disable default bindings and replace them with our own */
|
||||
gtk_accel_map_change_entry("<virt-viewer>/view/toggle-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);
|
||||
}
|
||||
|
||||
void
|
||||
virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys_str)
|
||||
{
|
||||
@ -1779,12 +1790,8 @@ virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys_str)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Disable default bindings and replace them with our own */
|
||||
gtk_accel_map_change_entry("<virt-viewer>/view/toggle-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);
|
||||
virt_viewer_app_clear_hotkeys(self);
|
||||
g_object_set(self, "enable-accel", TRUE, NULL);
|
||||
|
||||
for (hotkey = hotkeys; *hotkey != NULL; hotkey++) {
|
||||
gchar *key = strstr(*hotkey, "=");
|
||||
@ -1816,7 +1823,6 @@ virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys_str)
|
||||
}
|
||||
g_strfreev(hotkeys);
|
||||
|
||||
g_object_set(self, "enable-accel", TRUE, NULL);
|
||||
virt_viewer_update_smartcard_accels(self);
|
||||
}
|
||||
|
||||
|
||||
@ -99,6 +99,7 @@ VirtViewerSession* virt_viewer_app_get_session(VirtViewerApp *self);
|
||||
gboolean virt_viewer_app_get_fullscreen(VirtViewerApp *app);
|
||||
gboolean virt_viewer_app_get_fullscreen_auto_conf(VirtViewerApp *app);
|
||||
const GOptionEntry* virt_viewer_app_get_options(void);
|
||||
void virt_viewer_app_clear_hotkeys(VirtViewerApp *app);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@ -595,7 +595,7 @@ virt_viewer_file_set_secure_channels(VirtViewerFile* self, const gchar* const* v
|
||||
}
|
||||
|
||||
static void
|
||||
spice_hotkey_set_accel(VirtViewerApp *app, const gchar *accel_path, const gchar *key)
|
||||
spice_hotkey_set_accel(const gchar *accel_path, const gchar *key)
|
||||
{
|
||||
gchar *accel;
|
||||
guint accel_key;
|
||||
@ -606,8 +606,6 @@ spice_hotkey_set_accel(VirtViewerApp *app, const gchar *accel_path, const gchar
|
||||
g_free(accel);
|
||||
|
||||
gtk_accel_map_change_entry(accel_path, accel_key, accel_mods, TRUE);
|
||||
|
||||
g_object_set(G_OBJECT(app), "enable-accel", TRUE, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -636,6 +634,10 @@ virt_viewer_file_fill_app(VirtViewerFile* self, VirtViewerApp *app, GError **err
|
||||
if (virt_viewer_file_is_set(self, "title"))
|
||||
virt_viewer_app_set_title(app, virt_viewer_file_get_title(self));
|
||||
|
||||
|
||||
virt_viewer_app_clear_hotkeys(app);
|
||||
g_object_set(G_OBJECT(app), "enable-accel", TRUE, NULL);
|
||||
|
||||
{
|
||||
gchar *val;
|
||||
static const struct {
|
||||
@ -654,7 +656,7 @@ virt_viewer_file_fill_app(VirtViewerFile* self, VirtViewerApp *app, GError **err
|
||||
if (!virt_viewer_file_is_set(self, accels[i].prop))
|
||||
continue;
|
||||
g_object_get(self, accels[i].prop, &val, NULL);
|
||||
spice_hotkey_set_accel(app, accels[i].accel, val);
|
||||
spice_hotkey_set_accel(accels[i].accel, val);
|
||||
g_free(val);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user