Codebase list virt-viewer / 15fbaa3
src: introduce "--cursor auto|local" command line Normally we will honour the server requested behaviour for cursor, either letting the server render it directly, or locally rendering a cursor that the server provided us. There are times, however, where the server does the wrong thing. For example it might tell us to render an empty cursor, leaving the user with no visible cursor at all. In this case it can be helpful to ignore what the server requests, and always display the default local cursor. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Daniel P. Berrangé authored 3 years ago Daniel P. Berrangé committed 3 years ago
8 changed file(s) with 84 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6464 =item -s, --shared
6565
6666 Permitted a shared session with multiple clients
67
68 =item --cursor auto|local
69
70 Control how the mouse cursor is rendered. C<auto> is the default behaviour,
71 which will honour the behaviour requested by the remote server. This may
72 involve the server remote rendering the cursor into the framebuffer, or
73 sending the cursor details to the client to render. C<local> overrides
74 this default to request that the local desktop cursor is always rendered
75 regardless of what the server requests. The latter is rarely needed, but
76 can be used if the server has a bad configuration that results in its
77 own cursor being hidden.
6778
6879 =item --debug
6980
8484 =item -s, --shared
8585
8686 Permitted a shared session with multiple clients
87
88 =item --cursor auto|local
89
90 Control how the mouse cursor is rendered. C<auto> is the default behaviour,
91 which will honour the behaviour requested by the remote server. This may
92 involve the server remote rendering the cursor into the framebuffer, or
93 sending the cursor details to the client to render. C<local> overrides
94 this default to request that the local desktop cursor is always rendered
95 regardless of what the server requests. The latter is rarely needed, but
96 can be used if the server has a bad configuration that results in its
97 own cursor being hidden.
8798
8899 =item --debug
89100
00 src_include_dir = [include_directories('.')]
11
22 enum_sources = [
3 'virt-viewer-app.h',
34 'virt-viewer-display.h',
45 ]
56
158158 gboolean grabbed;
159159 char *title;
160160 char *uuid;
161 VirtViewerCursor cursor;
161162
162163 GKeyFile *config;
163164 gchar *config_file;
21172118 static gboolean opt_fullscreen = FALSE;
21182119 static gboolean opt_kiosk = FALSE;
21192120 static gboolean opt_kiosk_quit = FALSE;
2121 static gchar *opt_cursor = NULL;
21202122
21212123 #ifndef G_OS_WIN32
21222124 static gboolean
25362538 #endif
25372539 g_print("\n");
25382540 ret = TRUE;
2541 }
2542
2543 if (opt_cursor) {
2544 int cursor = virt_viewer_enum_from_string(VIRT_VIEWER_TYPE_CURSOR,
2545 opt_cursor);
2546 if (cursor < 0) {
2547 g_printerr("unknown value '%s' for --cursor\n", opt_cursor);
2548 *status = 1;
2549 ret = TRUE;
2550 goto end;
2551 }
2552 virt_viewer_app_set_cursor(self, cursor);
25392553 }
25402554
25412555 end:
28412855 return priv->shared;
28422856 }
28432857
2858 void virt_viewer_app_set_cursor(VirtViewerApp *self, VirtViewerCursor cursor)
2859 {
2860 g_return_if_fail(VIRT_VIEWER_IS_APP(self));
2861
2862 VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
2863 priv->cursor = cursor;
2864 }
2865
2866 VirtViewerCursor virt_viewer_app_get_cursor(VirtViewerApp *self)
2867 {
2868 g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), FALSE);
2869
2870 VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self);
2871 return priv->cursor;
2872 }
2873
28442874 gboolean
28452875 virt_viewer_app_is_active(VirtViewerApp *self)
28462876 {
33713401 N_("Customise hotkeys"), NULL },
33723402 { "keymap", 'K', 0, G_OPTION_ARG_STRING, &opt_keymap,
33733403 N_("Remap keys format key=keymod+key e.g. F1=SHIFT+CTRL+F1,1=SHIFT+F1,ALT_L=Void"), NULL },
3404 { "cursor", '\0', 0, G_OPTION_ARG_STRING, &opt_cursor,
3405 N_("Cursor display mode: 'local' or 'auto'"), "MODE" },
33743406 { "kiosk", 'k', 0, G_OPTION_ARG_NONE, &opt_kiosk,
33753407 N_("Enable kiosk mode"), NULL },
33763408 { "kiosk-quit", '\0', 0, G_OPTION_ARG_CALLBACK, option_kiosk_quit,
3939 gboolean isLast;
4040 } VirtViewerKeyMapping;
4141
42 typedef enum {
43 VIRT_VIEWER_CURSOR_AUTO,
44 VIRT_VIEWER_CURSOR_LOCAL,
45 } VirtViewerCursor;
46
4247 struct _VirtViewerAppClass {
4348 GtkApplicationClass parent_class;
4449
7176 gboolean virt_viewer_app_get_attach(VirtViewerApp *self);
7277 void virt_viewer_app_set_shared(VirtViewerApp *self, gboolean shared);
7378 gboolean virt_viewer_app_get_shared(VirtViewerApp *self);
79 void virt_viewer_app_set_cursor(VirtViewerApp *self, VirtViewerCursor cursor);
80 VirtViewerCursor virt_viewer_app_get_cursor(VirtViewerApp *self);
7481 gboolean virt_viewer_app_has_session(VirtViewerApp *self);
7582 void virt_viewer_app_set_connect_info(VirtViewerApp *self,
7683 const gchar *host,
499499
500500 vnc_display_set_shared_flag(self->vnc,
501501 virt_viewer_app_get_shared(app));
502 vnc_display_set_pointer_local(self->vnc,
503 virt_viewer_app_get_cursor(app) == VIRT_VIEWER_CURSOR_LOCAL);
502504
503505 g_signal_connect_object(self->vnc, "vnc-connected",
504506 G_CALLBACK(virt_viewer_session_vnc_connected), self, 0);
731731 g_hash_table_unref(displaymap);
732732 return NULL;
733733 }
734
735 int
736 virt_viewer_enum_from_string(GType enum_type, gchar *name)
737 {
738 GEnumClass *enum_class;
739 GEnumValue *enum_value;
740
741 g_return_val_if_fail(G_TYPE_IS_ENUM(enum_type), -1);
742
743 enum_class = g_type_class_ref(enum_type);
744 enum_value = g_enum_get_value_by_nick(enum_class, name);
745 g_type_class_unref(enum_class);
746
747 if (enum_value == NULL)
748 return -1;
749
750 return enum_value->value;
751 }
6363 GHashTable* virt_viewer_parse_monitor_mappings(gchar **mappings,
6464 const gsize nmappings,
6565 const gint nmonitors);
66
67 int virt_viewer_enum_from_string(GType enum_type, gchar *name);