[Spice-devel] [PATCH spice-gtk 08/25] Add spice_display_get_primary()
Marc-André Lureau
marcandre.lureau at gmail.com
Thu Jul 12 15:29:05 PDT 2012
---
gtk/channel-display.c | 37 +++++++++++++++++++++++++++++++++++++
gtk/channel-display.h | 14 +++++++++++++-
gtk/map-file | 1 +
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 681482b..e7772aa 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -351,6 +351,43 @@ static void spice_display_channel_class_init(SpiceDisplayChannelClass *klass)
rop3_init();
}
+/**
+ * spice_display_get_primary:
+ * @channel:
+ * @surface_id:
+ * @primary:
+ *
+ * Retrieve primary display surface @surface_id.
+ *
+ * Returns: %TRUE if the primary surface was found and its details
+ * collected in @primary.
+ */
+gboolean spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
+ SpiceDisplayPrimary *primary)
+{
+ g_return_val_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel), FALSE);
+ g_return_val_if_fail(primary != NULL, FALSE);
+
+ SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
+ display_surface *surface = find_surface(c, surface_id);
+
+ if (surface == NULL)
+ return FALSE;
+
+ g_return_val_if_fail(surface->primary, FALSE);
+
+ primary->format = surface->format;
+ primary->width = surface->width;
+ primary->height = surface->height;
+ primary->stride = surface->stride;
+ primary->shmid = surface->shmid;
+ primary->data = surface->data;
+ primary->marked = c->mark;
+ SPICE_DEBUG("get primary %p", primary->data);
+
+ return TRUE;
+}
+
/* signal trampoline---------------------------------------------------------- */
struct SPICE_DISPLAY_PRIMARY_CREATE {
diff --git a/gtk/channel-display.h b/gtk/channel-display.h
index a31aa54..88e60d9 100644
--- a/gtk/channel-display.h
+++ b/gtk/channel-display.h
@@ -43,6 +43,17 @@ struct _SpiceDisplayMonitorConfig {
guint height;
};
+typedef struct _SpiceDisplayPrimary SpiceDisplayPrimary;
+struct _SpiceDisplayPrimary {
+ enum SpiceSurfaceFmt format;
+ gint width;
+ gint height;
+ gint stride;
+ gint shmid;
+ guint8 *data;
+ gboolean marked;
+};
+
/**
* SpiceDisplayChannel:
*
@@ -80,10 +91,11 @@ struct _SpiceDisplayChannelClass {
gboolean mark);
/*< private >*/
- /* Do not add fields to this struct */
};
GType spice_display_channel_get_type(void);
+gboolean spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
+ SpiceDisplayPrimary *primary);
G_END_DECLS
diff --git a/gtk/map-file b/gtk/map-file
index 32ead37..c58bab5 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -17,6 +17,7 @@ spice_channel_type_to_string;
spice_client_error_quark;
spice_cursor_channel_get_type;
spice_display_channel_get_type;
+spice_display_get_primary;
spice_display_copy_to_guest;
spice_display_get_grab_keys;
spice_display_get_pixbuf;
--
1.7.10.4
More information about the Spice-devel
mailing list