[Spice-commits] 3 commits - doc/reference src/channel-main.c src/channel-main.h src/map-file src/spice-glib-sym-file src/spicy.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Tue May 10 08:56:32 UTC 2016
doc/reference/spice-gtk-sections.txt | 1
src/channel-main.c | 50 ++++++++++++++++++++++++++---------
src/channel-main.h | 2 +
src/map-file | 1
src/spice-glib-sym-file | 1
src/spicy.c | 22 +++++++++++++++
6 files changed, 65 insertions(+), 12 deletions(-)
New commits:
commit 1921897651ee6e3106a5dfc770b65ca4d6520929
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Nov 9 15:02:09 2015 +0100
spicy: add toggle mouse mode menu
This is just for testing, the UI could be different in better clients.
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/src/spicy.c b/src/spicy.c
index 0475530..2865678 100644
--- a/src/spicy.c
+++ b/src/spicy.c
@@ -354,6 +354,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)
{
@@ -693,6 +708,12 @@ static const GtkActionEntry entries[] = {
},{
#endif
+ .name = "MouseMode",
+ .label = "Toggle _mouse mode",
+ .callback = G_CALLBACK(menu_cb_mouse_mode),
+ .accelerator = "<shift>F7",
+
+ },{
/* Help menu */
.name = "About",
.stock_id = "help-about",
@@ -818,6 +839,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"
commit 5a4693db591e97eaa52f9e4cd0adef658aed7f40
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Nov 9 15:02:08 2015 +0100
main: do not always request client mouse mode
Whenever the mouse mode changed on the server, spice-gtk was requesting
client mode. Instead keep the last requested mode and request it
whenever it's possible.
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
Reviewed-by: Victor Toso <victortoso at redhat.com>
diff --git a/src/channel-main.c b/src/channel-main.c
index 1fef6da..f7789dd 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -131,6 +131,7 @@ typedef struct {
struct _SpiceMainChannelPrivate {
enum SpiceMouseMode mouse_mode;
+ enum SpiceMouseMode requested_mouse_mode;
bool agent_connected;
bool agent_caps_received;
@@ -294,6 +295,7 @@ static void spice_main_channel_init(SpiceMainChannel *channel)
c->cancellable_volume_info = g_cancellable_new();
spice_main_channel_reset_capabilties(SPICE_CHANNEL(channel));
+ c->requested_mouse_mode = SPICE_MOUSE_MODE_CLIENT;
}
static gint spice_main_get_max_clipboard(SpiceMainChannel *self)
@@ -1619,13 +1621,17 @@ void spice_main_request_mouse_mode(SpiceMainChannel *channel, int mode)
.mode = mode,
};
SpiceMsgOut *out;
+ SpiceMainChannelPrivate *c;
g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
+ c = channel->priv;
if (spice_channel_get_read_only(SPICE_CHANNEL(channel)))
return;
CHANNEL_DEBUG(channel, "request mouse mode %d", mode);
+ c->requested_mouse_mode = mode;
+
out = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST);
out->marshallers->msgc_main_mouse_mode_request(out->marshaller, &req);
spice_msg_out_send(out);
@@ -1642,18 +1648,9 @@ static void set_mouse_mode(SpiceMainChannel *channel, uint32_t supported, uint32
g_coroutine_object_notify(G_OBJECT(channel), "mouse-mode");
}
- /* switch to client mode if possible */
- if (!spice_channel_get_read_only(SPICE_CHANNEL(channel)) &&
- supported & SPICE_MOUSE_MODE_CLIENT &&
- current != SPICE_MOUSE_MODE_CLIENT) {
- SpiceMsgcMainMouseModeRequest req = {
- .mode = SPICE_MOUSE_MODE_CLIENT,
- };
- SpiceMsgOut *out;
-
- out = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST);
- out->marshallers->msgc_main_mouse_mode_request(out->marshaller, &req);
- spice_msg_out_send_internal(out);
+ if (c->requested_mouse_mode != c->mouse_mode &&
+ c->requested_mouse_mode & supported) {
+ spice_main_request_mouse_mode(SPICE_MAIN_CHANNEL(channel), c->requested_mouse_mode);
}
}
commit 5f89a4df037f6a1f2def94431690bb574d166a0e
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon Nov 9 15:02:07 2015 +0100
gtk: add spice_main_request_mouse_mode()
Send a SpiceMsgcMainMouseModeRequest message to request a mouse mode.
This allows to switch between client/absolute and server/relative mouse
modes.
This is necessary for some applications that require pointer
re-positioning, which we can't provide through a remote protocol easily
with client pointer (no such hardware-level message exists afaik).
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
Reviewed-by: Victor Toso <victortoso at redhat.com>
diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index a6fcfbf..b67dd35 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -70,6 +70,7 @@ spice_main_update_display
spice_main_update_display_enabled
spice_main_send_monitor_config
spice_main_agent_test_capability
+spice_main_request_mouse_mode
spice_main_clipboard_selection_grab
spice_main_clipboard_selection_notify
spice_main_clipboard_selection_release
diff --git a/src/channel-main.c b/src/channel-main.c
index 3966e49..1fef6da 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1602,6 +1602,35 @@ static void agent_stopped(SpiceMainChannel *channel)
set_agent_connected(channel, FALSE);
}
+/**
+ * spice_main_request_mouse_mode:
+ * @channel: a %SpiceMainChannel
+ * @mode: a SPICE_MOUSE_MODE
+ *
+ * Request a mouse mode to the server. The server may not be able to
+ * change the mouse mode, but spice-gtk will try to request it
+ * when possible.
+ *
+ * Since: 0.32
+ **/
+void spice_main_request_mouse_mode(SpiceMainChannel *channel, int mode)
+{
+ SpiceMsgcMainMouseModeRequest req = {
+ .mode = mode,
+ };
+ SpiceMsgOut *out;
+
+ g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
+
+ if (spice_channel_get_read_only(SPICE_CHANNEL(channel)))
+ return;
+
+ CHANNEL_DEBUG(channel, "request mouse mode %d", mode);
+ out = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST);
+ out->marshallers->msgc_main_mouse_mode_request(out->marshaller, &req);
+ spice_msg_out_send(out);
+}
+
/* coroutine context */
static void set_mouse_mode(SpiceMainChannel *channel, uint32_t supported, uint32_t current)
{
diff --git a/src/channel-main.h b/src/channel-main.h
index 6b94c25..3fe8df1 100644
--- a/src/channel-main.h
+++ b/src/channel-main.h
@@ -98,6 +98,8 @@ gboolean spice_main_file_copy_finish(SpiceMainChannel *channel,
GAsyncResult *result,
GError **error);
+void spice_main_request_mouse_mode(SpiceMainChannel *channel, int mode);
+
#ifndef SPICE_DISABLE_DEPRECATED
SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types, int ntypes);
diff --git a/src/map-file b/src/map-file
index 589da21..8618f6e 100644
--- a/src/map-file
+++ b/src/map-file
@@ -74,6 +74,7 @@ spice_main_clipboard_selection_release;
spice_main_clipboard_selection_request;
spice_main_file_copy_async;
spice_main_file_copy_finish;
+spice_main_request_mouse_mode;
spice_main_send_monitor_config;
spice_main_set_display;
spice_main_set_display_enabled;
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
index 0657dcb..7d2af60 100644
--- a/src/spice-glib-sym-file
+++ b/src/spice-glib-sym-file
@@ -53,6 +53,7 @@ spice_main_clipboard_selection_release
spice_main_clipboard_selection_request
spice_main_file_copy_async
spice_main_file_copy_finish
+spice_main_request_mouse_mode
spice_main_send_monitor_config
spice_main_set_display
spice_main_set_display_enabled
More information about the Spice-commits
mailing list