[gtk-vnc] src: add API for requesting a desktop resize
- From: Daniel P. Berrange <dberrange src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-vnc] src: add API for requesting a desktop resize
- Date: Fri, 8 Jan 2021 15:26:19 +0000 (UTC)
commit b884d72881db9a36ea380ecfdb989722edb72c67
Author: Daniel P. Berrangé <dan berrange com>
Date: Wed Dec 9 12:59:30 2020 +0000
src: add API for requesting a desktop resize
Signed-off-by: Daniel P. Berrangé <berrange redhat com>
src/libgvnc_sym.version | 2 ++
src/vncconnection.c | 43 ++++++++++++++++++++++++++++++++++++-------
src/vncconnection.h | 11 +++++++++++
3 files changed, 49 insertions(+), 7 deletions(-)
---
diff --git a/src/libgvnc_sym.version b/src/libgvnc_sym.version
index 83bc44f..fbf981a 100644
--- a/src/libgvnc_sym.version
+++ b/src/libgvnc_sym.version
@@ -83,6 +83,7 @@
vnc_connection_auth_vencrypt_get_type;
vnc_connection_credential_get_type;
vnc_connection_power_action_get_type;
+ vnc_connection_resize_status_get_type;
vnc_connection_audio_enable;
vnc_connection_audio_disable;
vnc_connection_set_audio_format;
@@ -91,6 +92,7 @@
vnc_connection_get_ledstate;
vnc_connection_get_power_control;
vnc_connection_power_control;
+ vnc_connection_set_size;
vnc_util_set_debug;
vnc_util_get_debug;
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 3ee2b05..217a0ae 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -93,6 +93,7 @@ typedef enum {
VNC_CONNECTION_CLIENT_MESSAGE_POINTER = 5,
VNC_CONNECTION_CLIENT_MESSAGE_CUT_TEXT = 6,
VNC_CONNECTION_CLIENT_MESSAGE_XVP = 250,
+ VNC_CONNECTION_CLIENT_MESSAGE_SET_DESKTOP_SIZE = 251,
VNC_CONNECTION_CLIENT_MESSAGE_QEMU = 255,
} VncConnectionClientMessage;
@@ -118,13 +119,6 @@ typedef enum {
VNC_CONNECTION_RESIZE_TRIGGER_OTHER_CLIENT = 2,
} VncConnectionResizeTrigger;
-typedef enum {
- VNC_CONNECTION_RESIZE_STATUS_OK = 0,
- VNC_CONNECTION_RESIZE_STATUS_ADMIN_PROHIBITED = 1,
- VNC_CONNECTION_RESIZE_STATUS_OUT_OF_RESOURCES = 2,
- VNC_CONNECTION_RESIZE_STATUS_INVALID_LAOUT = 3,
- VNC_CONNECTION_RESIZE_STATUS_FORWARDED = 4,
-} VncConnectionResizeStatus;
typedef void vnc_connection_rich_cursor_blt_func(VncConnection *conn, guint8 *, guint8 *,
guint8 *, int, guint16, guint16);
@@ -252,6 +246,8 @@ struct _VncConnectionPrivate
} lastUpdateRequest;
gboolean skip_non_incremental;
+ gboolean has_resize;
+
gboolean has_audio;
gboolean audio_format_pending;
gboolean audio_enable_pending;
@@ -2952,6 +2948,8 @@ static void vnc_connection_extended_resize(VncConnection *conn, int width, int h
VNC_DEBUG("Desktop extended resize w=%d h=%d trigger=%d status=%d", width, height, trigger, status);
+ priv->has_resize = TRUE;
+
if (vnc_connection_has_error(conn))
return;
@@ -6545,6 +6543,37 @@ gboolean vnc_connection_power_control(VncConnection *conn,
}
+VncConnectionResizeStatus vnc_connection_set_size(VncConnection *conn,
+ guint width, guint height)
+{
+ VncConnectionPrivate *priv = conn->priv;
+
+ VNC_DEBUG("Requesting resize %dx%d", width, height);
+
+ if (!priv->has_resize)
+ return VNC_CONNECTION_RESIZE_STATUS_UNSUPPORTED;
+
+ vnc_connection_buffered_write_u8(conn, VNC_CONNECTION_CLIENT_MESSAGE_SET_DESKTOP_SIZE);
+ vnc_connection_buffered_write_u8(conn, 0); /* pad */
+ vnc_connection_buffered_write_u16(conn, width);
+ vnc_connection_buffered_write_u16(conn, height);
+
+ vnc_connection_buffered_write_u8(conn, 1); /* nscreens */
+ vnc_connection_buffered_write_u8(conn, 0); /* pad */
+
+ /* 1st screen */
+ vnc_connection_buffered_write_u32(conn, 0); /* ID */
+ vnc_connection_buffered_write_u16(conn, 0); /* x-pos */
+ vnc_connection_buffered_write_u16(conn, 0); /* y-pos */
+ vnc_connection_buffered_write_u16(conn, width);
+ vnc_connection_buffered_write_u16(conn, height);
+ vnc_connection_buffered_write_u32(conn, 0); /* flags */
+
+ vnc_connection_buffered_flush(conn);
+
+ return !vnc_connection_has_error(conn);
+
+}
/*
* Local variables:
diff --git a/src/vncconnection.h b/src/vncconnection.h
index 02c121e..fde1284 100644
--- a/src/vncconnection.h
+++ b/src/vncconnection.h
@@ -173,6 +173,15 @@ typedef enum {
VNC_CONNECTION_POWER_ACTION_RESET = 4,
} VncConnectionPowerAction;
+typedef enum {
+ VNC_CONNECTION_RESIZE_STATUS_UNSUPPORTED = -1,
+ VNC_CONNECTION_RESIZE_STATUS_OK = 0,
+ VNC_CONNECTION_RESIZE_STATUS_ADMIN_PROHIBITED = 1,
+ VNC_CONNECTION_RESIZE_STATUS_OUT_OF_RESOURCES = 2,
+ VNC_CONNECTION_RESIZE_STATUS_INVALID_LAOUT = 3,
+ VNC_CONNECTION_RESIZE_STATUS_FORWARDED = 4,
+} VncConnectionResizeStatus;
+
GType vnc_connection_get_type(void) G_GNUC_CONST;
VncConnection *vnc_connection_new(void);
@@ -243,6 +252,8 @@ gboolean vnc_connection_audio_disable(VncConnection *conn);
gboolean vnc_connection_power_control(VncConnection *conn,
VncConnectionPowerAction action);
+VncConnectionResizeStatus vnc_connection_set_size(VncConnection *conn,
+ guint width, guint height);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]