[gtk+/broadway: 219/246] broadway: Add _gdk_broadway_display_block_for_input
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/broadway: 219/246] broadway: Add _gdk_broadway_display_block_for_input
- Date: Tue, 15 Mar 2011 11:59:27 +0000 (UTC)
commit 614eb3b3d768cbdd4981f77f309528c366cb26f9
Author: Alexander Larsson <alexl redhat com>
Date: Fri Mar 11 14:45:13 2011 +0100
broadway: Add _gdk_broadway_display_block_for_input
gdk/broadway/gdkdisplay-broadway.c | 71 ++++++++++++++++++++++++++++++++++++
gdk/broadway/gdkprivate-broadway.h | 3 ++
2 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 5f0898d..9f90cc9 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -252,6 +252,77 @@ input_data_cb (GObject *stream,
return TRUE;
}
+static gboolean
+process_input_idle_cb (GdkBroadwayDisplay *display)
+{
+ process_input_messages (display);
+ return FALSE;
+}
+
+/* Note: This may be called while handling a message (i.e. sorta recursively) */
+char *
+_gdk_broadway_display_block_for_input (GdkDisplay *display, char op, guint32 serial)
+{
+ GdkBroadwayDisplay *broadway_display;
+ char *message;
+ guint32 msg_serial;
+ gboolean queued_idle;
+ gssize res;
+ guint8 buffer[1024];
+ BroadwayInput *input;
+ GInputStream *in;
+ GList *l;
+
+ queued_idle = FALSE;
+
+ gdk_display_flush (display);
+
+ broadway_display = GDK_BROADWAY_DISPLAY (display);
+ if (broadway_display->input == NULL)
+ return NULL;
+
+ input = broadway_display->input;
+
+ while (TRUE) {
+ /* Check for existing reply in queue */
+
+ for (l = broadway_display->input_messages; l != NULL; l = l->next)
+ {
+ message = l->data;
+
+ if (message[0] == op)
+ {
+ msg_serial = (guint32)strtol(message+1, NULL, 10);
+ if (msg_serial == serial)
+ {
+ broadway_display->input_messages =
+ g_list_delete_link (broadway_display->input_messages, l);
+ return message;
+ }
+ }
+ }
+
+ /* Not found, read more, blocking */
+
+ in = g_io_stream_get_input_stream (G_IO_STREAM (input->connection));
+ res = g_input_stream_read (in, buffer, sizeof (buffer), NULL, NULL);
+ if (res <= 0)
+ return NULL;
+ g_byte_array_append (input->buffer, buffer, res);
+
+ parse_input (input);
+
+ /* Since we're parsing input but not processing the resulting messages
+ we might not get a readable callback on the stream, so queue an idle to
+ process the messages */
+ if (!queued_idle)
+ {
+ queued_idle = TRUE;
+ g_idle_add_full (G_PRIORITY_DEFAULT, (GSourceFunc)process_input_idle_cb, display, NULL);
+ }
+ }
+}
+
#include <unistd.h>
#include <fcntl.h>
static void
diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h
index 2ddba08..5e60e89 100644
--- a/gdk/broadway/gdkprivate-broadway.h
+++ b/gdk/broadway/gdkprivate-broadway.h
@@ -187,6 +187,9 @@ gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
gchar *_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display,
const gchar *str);
GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display);
+char * _gdk_broadway_display_block_for_input (GdkDisplay *display,
+ char op,
+ guint32 serial);
/* Window methods - testing */
void _gdk_broadway_window_sync_rendering (GdkWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]