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
64 | 64 | =item -s, --shared |
65 | 65 | |
66 | 66 | 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. | |
67 | 78 | |
68 | 79 | =item --debug |
69 | 80 |
84 | 84 | =item -s, --shared |
85 | 85 | |
86 | 86 | 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. | |
87 | 98 | |
88 | 99 | =item --debug |
89 | 100 |
0 | 0 | src_include_dir = [include_directories('.')] |
1 | 1 | |
2 | 2 | enum_sources = [ |
3 | 'virt-viewer-app.h', | |
3 | 4 | 'virt-viewer-display.h', |
4 | 5 | ] |
5 | 6 |
158 | 158 | gboolean grabbed; |
159 | 159 | char *title; |
160 | 160 | char *uuid; |
161 | VirtViewerCursor cursor; | |
161 | 162 | |
162 | 163 | GKeyFile *config; |
163 | 164 | gchar *config_file; |
2117 | 2118 | static gboolean opt_fullscreen = FALSE; |
2118 | 2119 | static gboolean opt_kiosk = FALSE; |
2119 | 2120 | static gboolean opt_kiosk_quit = FALSE; |
2121 | static gchar *opt_cursor = NULL; | |
2120 | 2122 | |
2121 | 2123 | #ifndef G_OS_WIN32 |
2122 | 2124 | static gboolean |
2536 | 2538 | #endif |
2537 | 2539 | g_print("\n"); |
2538 | 2540 | 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); | |
2539 | 2553 | } |
2540 | 2554 | |
2541 | 2555 | end: |
2841 | 2855 | return priv->shared; |
2842 | 2856 | } |
2843 | 2857 | |
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 | ||
2844 | 2874 | gboolean |
2845 | 2875 | virt_viewer_app_is_active(VirtViewerApp *self) |
2846 | 2876 | { |
3371 | 3401 | N_("Customise hotkeys"), NULL }, |
3372 | 3402 | { "keymap", 'K', 0, G_OPTION_ARG_STRING, &opt_keymap, |
3373 | 3403 | 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" }, | |
3374 | 3406 | { "kiosk", 'k', 0, G_OPTION_ARG_NONE, &opt_kiosk, |
3375 | 3407 | N_("Enable kiosk mode"), NULL }, |
3376 | 3408 | { "kiosk-quit", '\0', 0, G_OPTION_ARG_CALLBACK, option_kiosk_quit, |
39 | 39 | gboolean isLast; |
40 | 40 | } VirtViewerKeyMapping; |
41 | 41 | |
42 | typedef enum { | |
43 | VIRT_VIEWER_CURSOR_AUTO, | |
44 | VIRT_VIEWER_CURSOR_LOCAL, | |
45 | } VirtViewerCursor; | |
46 | ||
42 | 47 | struct _VirtViewerAppClass { |
43 | 48 | GtkApplicationClass parent_class; |
44 | 49 | |
71 | 76 | gboolean virt_viewer_app_get_attach(VirtViewerApp *self); |
72 | 77 | void virt_viewer_app_set_shared(VirtViewerApp *self, gboolean shared); |
73 | 78 | 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); | |
74 | 81 | gboolean virt_viewer_app_has_session(VirtViewerApp *self); |
75 | 82 | void virt_viewer_app_set_connect_info(VirtViewerApp *self, |
76 | 83 | const gchar *host, |
499 | 499 | |
500 | 500 | vnc_display_set_shared_flag(self->vnc, |
501 | 501 | 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); | |
502 | 504 | |
503 | 505 | g_signal_connect_object(self->vnc, "vnc-connected", |
504 | 506 | G_CALLBACK(virt_viewer_session_vnc_connected), self, 0); |
731 | 731 | g_hash_table_unref(displaymap); |
732 | 732 | return NULL; |
733 | 733 | } |
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 | } |