Files
Hydra-OS/patches/virt-viewer-hydra-session.patch

148 lines
5.6 KiB
Diff

--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -134,6 +134,7 @@
gboolean authretry;
gboolean started;
gboolean fullscreen;
+ gboolean hide_toolbar;
gboolean attach;
gboolean shared;
gboolean quitting;
@@ -952,6 +953,13 @@
gchar *subtitle = NULL;
const gchar *title = virt_viewer_app_get_title(app);
+ /* Hidden fullscreen windows use the requested title as stable identity. */
+ if (title != NULL && virt_viewer_app_get_hide_toolbar(app) &&
+ virt_viewer_app_get_fullscreen(app)) {
+ g_object_set(window, "subtitle", title, NULL);
+ return;
+ }
+
if (title != NULL) {
VirtViewerDisplay *display = virt_viewer_window_get_display(window);
gchar *d = strstr(title, "%d");
@@ -2134,6 +2142,7 @@
static gboolean opt_verbose = FALSE;
static gboolean opt_debug = FALSE;
static gboolean opt_fullscreen = FALSE;
+static gboolean opt_hide_toolbar = FALSE;
static gboolean opt_kiosk = FALSE;
static gboolean opt_kiosk_quit = FALSE;
static gchar *opt_cursor = NULL;
@@ -2437,6 +2446,7 @@
{ "smartcard-remove", "app.smartcard-remove", {"<Shift>F9", NULL, NULL} },
{ "secure-attention", "win.secure-attention", {"<Ctrl><Alt>End", NULL, NULL} },
{ "usb-device-reset", "win.usb-device-reset", {"<Ctrl><Shift>r", NULL, NULL} },
+ { "usb-device-select", "win.usb-device-select", {NULL, NULL, NULL} },
};
static gchar **hotkey_names;
@@ -2484,6 +2494,7 @@
priv->resource = virt_viewer_get_resource();
virt_viewer_app_set_debug(opt_debug);
+ priv->hide_toolbar = opt_hide_toolbar;
virt_viewer_app_set_fullscreen(self, opt_fullscreen);
virt_viewer_app_set_keymap(self, opt_keymap);
@@ -3098,6 +3109,14 @@
}
gboolean
+virt_viewer_app_get_hide_toolbar(VirtViewerApp *self)
+{
+ VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
+
+ return priv->hide_toolbar;
+}
+
+gboolean
virt_viewer_app_get_fullscreen(VirtViewerApp *self)
{
g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), FALSE);
@@ -3557,6 +3576,8 @@
N_("Zoom level of window, in percentage"), "ZOOM" },
{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &opt_fullscreen,
N_("Open in full screen mode (adjusts guest resolution to fit the client)"), NULL },
+ { "hide-toolbar", '\0', 0, G_OPTION_ARG_NONE, &opt_hide_toolbar,
+ N_("Hide the toolbar in full screen mode"), NULL },
{ "hotkeys", 'H', 0, G_OPTION_ARG_STRING, &opt_hotkeys,
N_("Customise hotkeys"), NULL },
{ "auto-resize", '\0', 0, G_OPTION_ARG_STRING, &opt_resize,
--- a/src/virt-viewer-app.h
+++ b/src/virt-viewer-app.h
@@ -100,6 +100,7 @@
GList* virt_viewer_app_get_windows(VirtViewerApp *self);
VirtViewerSession* virt_viewer_app_get_session(VirtViewerApp *self);
gboolean virt_viewer_app_get_fullscreen(VirtViewerApp *app);
+gboolean virt_viewer_app_get_hide_toolbar(VirtViewerApp *app);
void virt_viewer_app_clear_hotkeys(VirtViewerApp *app);
GList* virt_viewer_app_get_initial_displays(VirtViewerApp* self);
gint virt_viewer_app_get_initial_monitor_for_display(VirtViewerApp* self, gint display);
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -740,9 +740,10 @@
return;
}
- if (!self->kiosk) {
- virt_viewer_timed_revealer_force_reveal(self->revealer, TRUE);
- }
+ gboolean hide_toolbar = virt_viewer_app_get_hide_toolbar(self->app);
+ gtk_widget_set_visible(GTK_WIDGET(self->revealer), !hide_toolbar);
+ virt_viewer_timed_revealer_force_reveal(self->revealer,
+ !self->kiosk && !hide_toolbar);
if (self->display) {
virt_viewer_display_set_monitor(self->display, monitor);
@@ -1354,6 +1355,13 @@
title = g_strdup(g_get_application_name());
}
+ /* Keep exact workspace identity across pointer/keyboard grab changes. */
+ if (self->app && virt_viewer_app_get_hide_toolbar(self->app) &&
+ virt_viewer_app_get_fullscreen(self->app) && self->subtitle) {
+ g_free(title);
+ title = g_strdup(self->subtitle);
+ }
+
gtk_window_set_title(GTK_WINDOW(self->window), title);
if (self->subtitle) {
gtk_header_bar_set_title(GTK_HEADER_BAR(header), self->subtitle);
@@ -1467,6 +1475,34 @@
display = self->display;
event = (GdkEventKey *)ev;
+ /* Keyboard grabs remove GTK's application accelerator group so normal
+ * shortcuts reach the guest. Keep only the explicitly configured manual
+ * USB selector available before forwarding this event to the display. */
+ if (!self->kiosk) {
+ gchar **accels = gtk_application_get_accels_for_action(
+ GTK_APPLICATION(self->app), "win.usb-device-select");
+ gboolean matched = FALSE;
+ for (guint i = 0; accels[i]; i++) {
+ guint key;
+ GdkModifierType mods;
+ gtk_accelerator_parse(accels[i], &key, &mods);
+ if (key && gdk_keyval_to_lower(event->keyval) == key &&
+ (event->state & gtk_accelerator_get_default_mod_mask()) == mods) {
+ matched = TRUE;
+ break;
+ }
+ }
+ g_strfreev(accels);
+ if (matched) {
+ GAction *action = g_action_map_lookup_action(
+ G_ACTION_MAP(self->window), "usb-device-select");
+ if (action && g_action_get_enabled(action)) {
+ g_action_activate(action, NULL);
+ return TRUE;
+ }
+ }
+ }
+
gtk_widget_grab_focus(GTK_WIDGET(display));
// Look through keymaps - if set for mappings and intercept