[Spice-commits] 2 commits - doc/reference gtk/channel-display.c gtk/channel-display.h gtk/map-file gtk/spice-gtk-sym-file gtk/spice-widget.c gtk/spice-widget.h
Jonathon Jongsma
jjongsma at kemper.freedesktop.org
Mon Nov 4 20:27:07 CET 2013
doc/reference/spice-gtk-sections.txt | 2
gtk/channel-display.c | 2
gtk/channel-display.h | 9 ++++
gtk/map-file | 1
gtk/spice-gtk-sym-file | 1
gtk/spice-widget.c | 78 ++++++++++++++++++++++++++---------
gtk/spice-widget.h | 2
7 files changed, 76 insertions(+), 19 deletions(-)
New commits:
commit ced8b9bddea0f9dcf8d2c4e826010c0470f7a9c8
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Fri Nov 1 17:05:48 2013 -0500
SpiceDisplay: validate 'self' argument for public API
Add defensive g_return[_val]_if_fail(SPICE_IS_DISPLAY()) to all public API
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 8b5fa59..af7252a 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -296,7 +296,7 @@ const SpiceDisplayMonitorConfig* spice_display_get_monitor_config(SpiceDisplay *
g_return_val_if_fail(SPICE_IS_DISPLAY(display), NULL);
- d = SPICE_DISPLAY_GET_PRIVATE(display);
+ d = display->priv;
g_return_val_if_fail(d->monitor_id >= 0, NULL);
g_object_get(d->display, "monitors", &monitors, NULL);
@@ -662,7 +662,11 @@ spice_display_constructor(GType gtype,
**/
void spice_display_set_grab_keys(SpiceDisplay *display, SpiceGrabSequence *seq)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d;
+
+ g_return_if_fail(SPICE_IS_DISPLAY(display));
+
+ d = display->priv;
g_return_if_fail(d != NULL);
if (d->grabseq) {
@@ -721,7 +725,11 @@ static LRESULT CALLBACK keyboard_hook_cb(int code, WPARAM wparam, LPARAM lparam)
**/
SpiceGrabSequence *spice_display_get_grab_keys(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d;
+
+ g_return_val_if_fail(SPICE_IS_DISPLAY(display), NULL);
+
+ d = display->priv;
g_return_val_if_fail(d != NULL, NULL);
return d->grabseq;
@@ -1406,7 +1414,7 @@ void spice_display_send_keys(SpiceDisplay *display, const guint *keyvals,
{
int i;
- g_return_if_fail(SPICE_DISPLAY(display) != NULL);
+ g_return_if_fail(SPICE_IS_DISPLAY(display));
g_return_if_fail(keyvals != NULL);
SPICE_DEBUG("%s", __FUNCTION__);
@@ -2519,6 +2527,8 @@ SpiceDisplay* spice_display_new_with_monitor(SpiceSession *session, gint channel
**/
void spice_display_mouse_ungrab(SpiceDisplay *display)
{
+ g_return_if_fail(SPICE_IS_DISPLAY(display));
+
try_mouse_ungrab(display);
}
@@ -2532,7 +2542,11 @@ void spice_display_mouse_ungrab(SpiceDisplay *display)
**/
void spice_display_copy_to_guest(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d;
+
+ g_return_if_fail(SPICE_IS_DISPLAY(display));
+
+ d = display->priv;
g_return_if_fail(d->gtk_session != NULL);
@@ -2549,7 +2563,11 @@ void spice_display_copy_to_guest(SpiceDisplay *display)
**/
void spice_display_paste_from_guest(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d;
+
+ g_return_if_fail(SPICE_IS_DISPLAY(display));
+
+ d = display->priv;
g_return_if_fail(d->gtk_session != NULL);
@@ -2566,11 +2584,15 @@ void spice_display_paste_from_guest(SpiceDisplay *display)
**/
GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d;
GdkPixbuf *pixbuf;
int x, y;
guchar *src, *data, *dest;
+ g_return_val_if_fail(SPICE_IS_DISPLAY(display), NULL);
+
+ d = display->priv;
+
g_return_val_if_fail(d != NULL, NULL);
/* TODO: ensure d->data has been exposed? */
g_return_val_if_fail(d->data != NULL, NULL);
commit a285e0187d15ad650f6524f3811072fa55b20617
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Thu Oct 31 17:33:30 2013 -0500
Add ability to get SpiceDisplay resolution
Add spice_display_get_monitor_config() to get the current configuration of the
display.
diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index 8d61aa9..9d8551b 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -146,6 +146,7 @@ SpiceAudioPrivate
<TITLE>SpiceDisplayChannel</TITLE>
SpiceDisplayChannel
SpiceDisplayChannelClass
+SpiceDisplayMonitorConfig
<SUBSECTION Standard>
SPICE_DISPLAY_CHANNEL
SPICE_IS_DISPLAY_CHANNEL
@@ -352,6 +353,7 @@ spice_display_set_grab_keys
spice_display_get_grab_keys
spice_display_send_keys
spice_display_get_pixbuf
+spice_display_get_monitor_config
<SUBSECTION>
SpiceGrabSequence
spice_grab_sequence_new
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index a57453f..030679b 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -262,7 +262,7 @@ static void spice_display_channel_class_init(SpiceDisplayChannelClass *klass)
/**
* SpiceDisplayChannel:monitors:
*
- * Current monitors configuration.
+ * Current monitors configuration. An array of #SpiceDisplayMonitorConfig
*
* Since: 0.13
*/
diff --git a/gtk/channel-display.h b/gtk/channel-display.h
index 88e60d9..4a5428e 100644
--- a/gtk/channel-display.h
+++ b/gtk/channel-display.h
@@ -33,6 +33,15 @@ typedef struct _SpiceDisplayChannel SpiceDisplayChannel;
typedef struct _SpiceDisplayChannelClass SpiceDisplayChannelClass;
typedef struct _SpiceDisplayChannelPrivate SpiceDisplayChannelPrivate;
+/**
+ * SpiceDisplayMonitorConfig:
+ * @id: the id of the monitor
+ * @surface_id: the surface id of the monitor
+ * @x: the position of the monitor on the x axis
+ * @y: the position of the monitor on the y axis
+ * @width: the width of the monitor
+ * @height: the height of the monitor
+ */
typedef struct _SpiceDisplayMonitorConfig SpiceDisplayMonitorConfig;
struct _SpiceDisplayMonitorConfig {
guint id;
diff --git a/gtk/map-file b/gtk/map-file
index 368b44f..d093f7c 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -32,6 +32,7 @@ spice_display_new_with_monitor;
spice_display_paste_from_guest;
spice_display_send_keys;
spice_display_set_grab_keys;
+spice_display_get_monitor_config;
spice_error_get_type;
spice_get_option_group;
spice_grab_sequence_as_string;
diff --git a/gtk/spice-gtk-sym-file b/gtk/spice-gtk-sym-file
index 1574e07..8d3c9a0 100644
--- a/gtk/spice-gtk-sym-file
+++ b/gtk/spice-gtk-sym-file
@@ -9,6 +9,7 @@ spice_display_new_with_monitor
spice_display_paste_from_guest
spice_display_send_keys
spice_display_set_grab_keys
+spice_display_get_monitor_config
spice_grab_sequence_as_string
spice_grab_sequence_copy
spice_grab_sequence_free
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index d39ff59..8b5fa59 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -278,25 +278,47 @@ static gint get_display_id(SpiceDisplay *display)
return d->channel_id;
}
-static void update_monitor_area(SpiceDisplay *display)
+/**
+ * spice_display_get_monitor_config:
+ * @display: the display widget
+ *
+ * Gets the monitor configuration for the display, from which you can determine
+ * the current position and resolution of the monitor
+ *
+ * Returns (transfer none): the monitor configuration for the display
+ **/
+const SpiceDisplayMonitorConfig* spice_display_get_monitor_config(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
- SpiceDisplayMonitorConfig *cfg, *c = NULL;
- GArray *monitors = NULL;
int i;
+ GArray *monitors = NULL;
+ SpiceDisplayPrivate *d = NULL;
+ SpiceDisplayMonitorConfig* c = NULL;
- SPICE_DEBUG("update monitor area %d:%d", d->channel_id, d->monitor_id);
- if (d->monitor_id < 0)
- goto whole;
+ g_return_val_if_fail(SPICE_IS_DISPLAY(display), NULL);
+
+ d = SPICE_DISPLAY_GET_PRIVATE(display);
+ g_return_val_if_fail(d->monitor_id >= 0, NULL);
g_object_get(d->display, "monitors", &monitors, NULL);
for (i = 0; monitors != NULL && i < monitors->len; i++) {
- cfg = &g_array_index(monitors, SpiceDisplayMonitorConfig, i);
+ SpiceDisplayMonitorConfig *cfg = &g_array_index(monitors,
+ SpiceDisplayMonitorConfig,
+ i);
if (cfg->id == d->monitor_id) {
- c = cfg;
- break;
+ c = cfg;
+ break;
}
}
+
+ g_clear_pointer(&monitors, g_array_unref);
+ return c;
+}
+
+static void update_monitor_area(SpiceDisplay *display)
+{
+ SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ const SpiceDisplayMonitorConfig *c = spice_display_get_monitor_config(display);
+
if (c == NULL) {
SPICE_DEBUG("update monitor: no monitor %d", d->monitor_id);
set_monitor_ready(display, false);
@@ -318,11 +340,9 @@ static void update_monitor_area(SpiceDisplay *display)
c->x, c->y, c->width, c->height, FALSE);
update_area(display, c->x, c->y, c->width, c->height);
- g_clear_pointer(&monitors, g_array_unref);
return;
whole:
- g_clear_pointer(&monitors, g_array_unref);
/* by display whole surface */
update_area(display, 0, 0, d->width, d->height);
set_monitor_ready(display, true);
diff --git a/gtk/spice-widget.h b/gtk/spice-widget.h
index d239ed2..f7cfbf1 100644
--- a/gtk/spice-widget.h
+++ b/gtk/spice-widget.h
@@ -80,6 +80,8 @@ void spice_display_send_keys(SpiceDisplay *display, const guint *keyvals,
int nkeyvals, SpiceDisplayKeyEvent kind);
GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay *display);
+const SpiceDisplayMonitorConfig* spice_display_get_monitor_config(SpiceDisplay *display);
+
#ifndef SPICE_DISABLE_DEPRECATED
SPICE_DEPRECATED_FOR(spice_gtk_session_copy_to_guest)
void spice_display_copy_to_guest(SpiceDisplay *display);
More information about the Spice-commits
mailing list