diff --git a/gdk/broadway/broadway-protocol.h b/gdk/broadway/broadway-protocol.h index abc0da711d..a343617d85 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 313aba06cd..3b2c69dab7 100644 --- a/gdk/broadway/broadway-server.c +++ b/gdk/broadway/broadway-server.c @@ -15,7 +15,7 @@ #include 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: @@ -704,6 +712,16 @@ broadway_server_get_next_serial (BroadwayServer *server) return server->saved_serial; } +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) { diff --git a/gdk/broadway/broadway-server.h b/gdk/broadway/broadway-server.h index 5860ad8386..a548f19aab 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 f756bf36c5..793393ec24 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; }