[gtk+] broadway: Send window size to new clients



commit d5812de2e6e08557c0099bedff82607c27b923e6
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Jan 8 17:56:39 2013 +0100

    broadway: Send window size to new clients
    
    Tell all new clients about the current (last sent) window size.

 gdk/broadway/broadway-protocol.h |    4 ++--
 gdk/broadway/broadway-server.c   |   24 +++++++++++++++++++++---
 gdk/broadway/broadway-server.h   |    3 +++
 gdk/broadway/broadwayd.c         |   16 ++++++++++++++--
 4 files changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/gdk/broadway/broadway-protocol.h b/gdk/broadway/broadway-protocol.h
index abc0da7..a343617 100644
--- a/gdk/broadway/broadway-protocol.h
+++ b/gdk/broadway/broadway-protocol.h
@@ -93,8 +93,8 @@ typedef struct {
 
 typedef struct {
   BroadwayInputBaseMsg base;
-  gint32 width;
-  gint32 height;
+  guint32 width;
+  guint32 height;
 } BroadwayInputScreenResizeNotify;
 
 typedef struct {
diff --git a/gdk/broadway/broadway-server.c b/gdk/broadway/broadway-server.c
index 313aba0..3b2c69d 100644
--- a/gdk/broadway/broadway-server.c
+++ b/gdk/broadway/broadway-server.c
@@ -15,7 +15,7 @@
 #include <netinet/tcp.h>
 
 typedef struct BroadwayInput BroadwayInput;
-
+typedef struct BroadwayWindow BroadwayWindow;
 struct _BroadwayServer {
   GObject parent_instance;
 
@@ -31,6 +31,10 @@ struct _BroadwayServer {
 
   GHashTable *id_ht;
   GList *toplevels;
+  BroadwayWindow *root;
+
+  guint32 screen_width;
+  guint32 screen_height;
 
   gint32 mouse_in_toplevel_id;
   int last_x, last_y; /* in root coords */
@@ -73,7 +77,7 @@ struct BroadwayInput {
   gboolean binary;
 };
 
-typedef struct {
+struct BroadwayWindow {
   gint32 id;
   gint32 x;
   gint32 y;
@@ -85,7 +89,7 @@ typedef struct {
   gint32 transient_for;
 
   cairo_surface_t *last_surface;
-} BroadwayWindow;
+};
 
 static void broadway_server_resync_windows (BroadwayServer *server);
 
@@ -109,6 +113,8 @@ broadway_server_init (BroadwayServer *server)
   root->height = 768;
   root->visible = TRUE;
 
+  server->root = root;
+
   g_hash_table_insert (server->id_ht,
 		       GINT_TO_POINTER (root->id),
 		       root);
@@ -210,6 +216,8 @@ update_event_state (BroadwayServer *server,
   case BROADWAY_EVENT_DELETE_NOTIFY:
     break;
   case BROADWAY_EVENT_SCREEN_SIZE_CHANGED:
+    server->root->width = message->screen_resize_notify.width;
+    server->root->height = message->screen_resize_notify.height;
     break;
 
   default:
@@ -705,6 +713,16 @@ broadway_server_get_next_serial (BroadwayServer *server)
 }
 
 void
+broadway_server_get_screen_size (BroadwayServer   *server,
+				 guint32          *width,
+				 guint32          *height)
+{
+  *width = server->root->width;
+  *height = server->root->height;
+}
+
+
+void
 broadway_server_flush (BroadwayServer *server)
 {
   if (server->output &&
diff --git a/gdk/broadway/broadway-server.h b/gdk/broadway/broadway-server.h
index 5860ad8..a548f19 100644
--- a/gdk/broadway/broadway-server.h
+++ b/gdk/broadway/broadway-server.h
@@ -24,6 +24,9 @@ BroadwayServer     *broadway_server_new                      (int
 gboolean            broadway_server_has_client               (BroadwayServer   *server);
 void                broadway_server_flush                    (BroadwayServer   *server);
 void                broadway_server_sync                     (BroadwayServer   *server);
+void                broadway_server_get_screen_size          (BroadwayServer   *server,
+							      guint32          *width,
+							      guint32          *height);
 guint32             broadway_server_get_next_serial          (BroadwayServer   *server);
 guint32             broadway_server_get_last_seen_time       (BroadwayServer   *server);
 gboolean            broadway_server_lookahead_event          (BroadwayServer   *server,
diff --git a/gdk/broadway/broadwayd.c b/gdk/broadway/broadwayd.c
index f756bf3..793393e 100644
--- a/gdk/broadway/broadwayd.c
+++ b/gdk/broadway/broadwayd.c
@@ -454,11 +454,12 @@ incoming_client (GSocketService    *service,
 {
   BroadwayClient *client;
   GInputStream *input;
+  BroadwayInputMsg ev = { {0} };
 
   client = g_new0 (BroadwayClient, 1);
   client->id = client_id_count++;
   client->connection = g_object_ref (connection);
-  
+
   input = g_io_stream_get_input_stream (G_IO_STREAM (client->connection));
   client->in = (GBufferedInputStream *)g_buffered_input_stream_new (input);
 
@@ -469,7 +470,18 @@ incoming_client (GSocketService    *service,
 				      0,
 				      NULL,
 				      client_fill_cb, client);
-  
+
+  /* Send initial resize notify */
+  ev.base.type = BROADWAY_EVENT_SCREEN_SIZE_CHANGED;
+  ev.base.serial = broadway_server_get_next_serial (server) - 1;
+  ev.base.time = broadway_server_get_last_seen_time (server);
+  broadway_server_get_screen_size (server,
+				   &ev.screen_resize_notify.width,
+				   &ev.screen_resize_notify.height);
+
+  broadway_events_got_input (&ev,
+			     client->id);
+
   return TRUE;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]