broadway: Send window size to new clients

Tell all new clients about the current (last sent) window size.
This commit is contained in:
Alexander Larsson 2013-01-08 17:56:39 +01:00
parent 35c295da89
commit d5812de2e6
4 changed files with 40 additions and 7 deletions

View File

@ -93,8 +93,8 @@ typedef struct {
typedef struct {
BroadwayInputBaseMsg base;
gint32 width;
gint32 height;
guint32 width;
guint32 height;
} BroadwayInputScreenResizeNotify;
typedef struct {

View File

@ -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:
@ -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)
{

View File

@ -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,

View File

@ -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;
}