[Spice-devel] [PATCH spice-gtk 3/3] spicy: add toggle mouse mode menu

Marc-André Lureau marcandre.lureau at redhat.com
Fri Mar 27 08:28:59 PDT 2015


This is just for testing, the UI could be different in better clients.
---
 gtk/spicy.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gtk/spicy.c b/gtk/spicy.c
index 4bc6ddb..58a471f 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -472,6 +472,21 @@ static void menu_cb_remove_smartcard(GtkAction *action, void *data)
 }
 #endif
 
+static void menu_cb_mouse_mode(GtkAction *action, void *data)
+{
+    SpiceWindow *win = data;
+    SpiceMainChannel *cmain = win->conn->main;
+    int mode;
+
+    g_object_get(cmain, "mouse-mode", &mode, NULL);
+    if (mode == SPICE_MOUSE_MODE_CLIENT)
+        mode = SPICE_MOUSE_MODE_SERVER;
+    else
+        mode = SPICE_MOUSE_MODE_CLIENT;
+
+    spice_main_request_mouse_mode(cmain, mode);
+}
+
 #ifdef USE_USBREDIR
 static void remove_cb(GtkContainer *container, GtkWidget *widget, void *data)
 {
@@ -808,6 +823,12 @@ static const GtkActionEntry entries[] = {
     },{
 #endif
 
+        .name        = "MouseMode",
+        .label       = N_("Toggle _mouse mode"),
+        .callback    = G_CALLBACK(menu_cb_mouse_mode),
+        .accelerator = "<shift>F7",
+
+    },{
         /* Help menu */
         .name        = "About",
         .stock_id    = GTK_STOCK_ABOUT,
@@ -899,6 +920,7 @@ static char ui_xml[] =
 "    <menu action='OptionMenu'>\n"
 "      <menuitem action='grab-keyboard'/>\n"
 "      <menuitem action='grab-mouse'/>\n"
+"      <menuitem action='MouseMode'/>\n"
 "      <menuitem action='resize-guest'/>\n"
 "      <menuitem action='scaling'/>\n"
 "      <menuitem action='disable-inputs'/>\n"
-- 
2.1.0



More information about the Spice-devel mailing list