[virt-tools-list] [PATCH virt-viewer 1/3] session: Add virt_viewer_session_can_resize_guest()
Pavel Grunt
pgrunt at redhat.com
Fri May 22 08:53:05 UTC 2015
The function checks for capability of resizing the guest desktop.
Spice session can resize the guest only when spice-agent is connected.
Related: https://bugs.freedesktop.org/show_bug.cgi?id=90582
---
src/virt-viewer-session-spice.c | 15 +++++++++++++++
src/virt-viewer-session.c | 11 +++++++++++
src/virt-viewer-session.h | 2 ++
3 files changed, 28 insertions(+)
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index b69faa6..4256d4c 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -165,6 +165,20 @@ virt_viewer_session_spice_can_share_folder(VirtViewerSession *session)
return spice_session_has_channel_type(self->priv->session, SPICE_CHANNEL_WEBDAV);
}
+static gboolean
+virt_viewer_session_spice_can_resize_guest(VirtViewerSession *session)
+{
+ gboolean agent_connected;
+
+ g_return_val_if_fail(VIRT_VIEWER_IS_SESSION_SPICE(session), FALSE);
+
+ g_object_get(virt_viewer_session_spice_get_main_channel(VIRT_VIEWER_SESSION_SPICE(session)),
+ "agent-connected", &agent_connected,
+ NULL);
+
+ return agent_connected;
+}
+
static void
virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
{
@@ -186,6 +200,7 @@ virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
dclass->mime_type = virt_viewer_session_spice_mime_type;
dclass->apply_monitor_geometry = virt_viewer_session_spice_apply_monitor_geometry;
dclass->can_share_folder = virt_viewer_session_spice_can_share_folder;
+ dclass->can_resize_guest = virt_viewer_session_spice_can_resize_guest;
g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index 131a500..fccaa19 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -678,6 +678,17 @@ gboolean virt_viewer_session_can_share_folder(VirtViewerSession *self)
return klass->can_share_folder ? klass->can_share_folder(self) : FALSE;
}
+gboolean virt_viewer_session_can_resize_guest(VirtViewerSession *self)
+{
+ VirtViewerSessionClass *klass;
+
+ g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
+
+ klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
+
+ return klass->can_resize_guest ? klass->can_resize_guest(self) : FALSE;
+}
+
/*
* Local variables:
* c-indent-level: 4
diff --git a/src/virt-viewer-session.h b/src/virt-viewer-session.h
index 533d79a..4afc176 100644
--- a/src/virt-viewer-session.h
+++ b/src/virt-viewer-session.h
@@ -74,6 +74,7 @@ struct _VirtViewerSessionClass {
void (* smartcard_insert) (VirtViewerSession* session);
void (* smartcard_remove) (VirtViewerSession* session);
const gchar* (* mime_type) (VirtViewerSession* session);
+ gboolean (*can_resize_guest)(VirtViewerSession *session);
/* signals */
void (*session_connected)(VirtViewerSession *session);
@@ -132,6 +133,7 @@ gchar* virt_viewer_session_get_uri(VirtViewerSession *self);
void virt_viewer_session_set_file(VirtViewerSession *self, VirtViewerFile *file);
VirtViewerFile* virt_viewer_session_get_file(VirtViewerSession *self);
gboolean virt_viewer_session_can_share_folder(VirtViewerSession *self);
+gboolean virt_viewer_session_can_resize_guest(VirtViewerSession *self);
G_END_DECLS
--
2.4.1
More information about the virt-tools-list
mailing list