[Spice-commits] 3 commits - gtk/glib-compat.c gtk/glib-compat.h gtk/spice-session.c gtk/spice-widget.c gtk/vncdisplaykeymap.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Tue May 14 05:40:16 PDT 2013
gtk/glib-compat.c | 11 +++++++++++
gtk/glib-compat.h | 4 ++++
gtk/spice-session.c | 48 +++++++++++++++++++++++++++++++++++-------------
gtk/spice-widget.c | 9 ++++-----
gtk/vncdisplaykeymap.c | 5 +++++
5 files changed, 59 insertions(+), 18 deletions(-)
New commits:
commit ece9df86a81e425821f513df258c0f40c6faf214
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Tue May 14 14:23:37 2013 +0200
Build fixes for gtk+2
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 3694da3..7eb9e64 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -46,17 +46,16 @@
/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */
#if GTK_CHECK_VERSION (2, 91, 0)
-
static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
{
*ww = gdk_window_get_width(w);
*wh = gdk_window_get_height(w);
}
+#endif
-#define GtkObject GtkWidget
-#define GtkObjectClass GtkWidgetClass
-#define GTK_OBJECT_CLASS(c) GTK_WIDGET_CLASS(c)
-
+#if !GTK_CHECK_VERSION (2, 91, 0)
+#define GDK_IS_X11_DISPLAY(D) TRUE
+#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))
#endif
#if !GTK_CHECK_VERSION(2, 20, 0)
diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c
index d901811..543761d 100644
--- a/gtk/vncdisplaykeymap.c
+++ b/gtk/vncdisplaykeymap.c
@@ -48,6 +48,11 @@
#define GDK_Tab GDK_KEY_Tab
#endif
+#if !GLIB_CHECK_VERSION(3,0,0)
+#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))
+#endif
+
+
/* keycode translation for sending ISO_Left_Send
* to vncserver
*/
commit 90d3f3aac8080077064de54f571dce2f859d9788
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Tue May 14 14:16:46 2013 +0200
Fix glib2 2.22 build after edf1daf5
channel-display.c: In function 'display_update_stream_report':
channel-display.c:1273: warning: implicit declaration of function
'g_get_monotonic_time'
diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 0c108ef..21be1f6 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -101,3 +101,14 @@ g_slist_free_full(GSList *list,
G_DEFINE_BOXED_TYPE (GMainContext, spice_main_context, g_main_context_ref, g_main_context_unref)
#endif
+#if !GLIB_CHECK_VERSION(2,27,2)
+guint64 g_get_monotonic_time(void)
+{
+ GTimeVal tv;
+
+ /* TODO: support real monotonic clock? */
+ g_get_current_time(&tv);
+
+ return (((gint64) tv.tv_sec) * 1000000) + tv.tv_usec;
+}
+#endif
diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
index cc5232a..c30a735 100644
--- a/gtk/glib-compat.h
+++ b/gtk/glib-compat.h
@@ -129,4 +129,8 @@ GType spice_main_context_get_type (void) G_GNUC_CONST;
} G_STMT_END
#endif
+#if !GLIB_CHECK_VERSION(2,27,2)
+guint64 g_get_monotonic_time(void);
+#endif
+
#endif /* GLIB_COMPAT_H */
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 8a612cf..8cb2d39 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1969,18 +1969,6 @@ int spice_session_get_connection_id(SpiceSession *session)
return s->connection_id;
}
-#if !GLIB_CHECK_VERSION(2,27,2)
-static guint64 g_get_monotonic_time(void)
-{
- GTimeVal tv;
-
- /* TODO: support real monotonic clock? */
- g_get_current_time(&tv);
-
- return (((gint64) tv.tv_sec) * 1000000) + tv.tv_usec;
-}
-#endif
-
G_GNUC_INTERNAL
guint32 spice_session_get_mm_time(SpiceSession *session)
{
commit 1d9a42427b39ed454f3e94553d790140cc8bc0ba
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon May 13 18:37:02 2013 +0200
session: timeout after 10s of socket connect() attempt
https://bugzilla.redhat.com/show_bug.cgi?id=885101
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 8f4e1bd..8a612cf 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1693,6 +1693,9 @@ struct spice_open_host {
GError *error;
GSocketConnection *connection;
GSocketClient *client;
+#if !GLIB_CHECK_VERSION(2,26,0)
+ guint timeout_id;
+#endif
};
static void socket_client_connect_ready(GObject *source_object, GAsyncResult *result,
@@ -1795,6 +1798,20 @@ static gboolean open_host_idle_cb(gpointer data)
return FALSE;
}
+#define SOCKET_TIMEOUT 10
+
+#if !GLIB_CHECK_VERSION(2,26,0)
+static gboolean connect_timeout(gpointer data)
+{
+ spice_open_host *open_host = data;
+
+ open_host->timeout_id = 0;
+ coroutine_yieldto(open_host->from, NULL);
+
+ return FALSE;
+}
+#endif
+
/* coroutine context */
G_GNUC_INTERNAL
GSocketConnection* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *channel,
@@ -1827,11 +1844,25 @@ GSocketConnection* spice_session_channel_open_host(SpiceSession *session, SpiceC
}
open_host.client = g_socket_client_new();
+#if GLIB_CHECK_VERSION(2,26,0)
+ g_socket_client_set_timeout(open_host.client, SOCKET_TIMEOUT);
+#else
+ open_host.timeout_id =
+ g_timeout_add_seconds(SOCKET_TIMEOUT, connect_timeout, &open_host);
+#endif
guint id = g_idle_add(open_host_idle_cb, &open_host);
/* switch to main loop and wait for connection */
coroutine_yield(NULL);
- g_source_remove (id);
+ g_source_remove(id);
+
+#if !GLIB_CHECK_VERSION(2,26,0)
+ if (open_host.timeout_id == 0)
+ open_host.error = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+ "connect timed out");
+ else
+ g_source_remove(open_host.timeout_id);
+#endif
if (open_host.error != NULL) {
g_warning("%s", open_host.error->message);
@@ -1839,6 +1870,9 @@ GSocketConnection* spice_session_channel_open_host(SpiceSession *session, SpiceC
} else if (open_host.connection != NULL) {
GSocket *socket;
socket = g_socket_connection_get_socket(open_host.connection);
+#if GLIB_CHECK_VERSION(2,26,0)
+ g_socket_set_timeout(socket, 0);
+#endif
g_socket_set_blocking(socket, FALSE);
g_socket_set_keepalive(socket, TRUE);
}
More information about the Spice-commits
mailing list