broadway: Fix handling of input with multiple in-process GdkDisplays

We need each instance to only forward input to the right display.
This make the inspector work better.
This commit is contained in:
Alexander Larsson 2019-03-29 11:03:38 +01:00
parent 43778bef4d
commit ab801fe782
5 changed files with 18 additions and 28 deletions

View File

@ -38,6 +38,7 @@ typedef struct BroadwayInput BroadwayInput;
struct _GdkBroadwayServer {
GObject parent_instance;
GdkDisplay *display;
guint32 next_serial;
guint32 next_texture_id;
@ -96,7 +97,9 @@ _gdk_broadway_server_get_next_serial (GdkBroadwayServer *server)
}
GdkBroadwayServer *
_gdk_broadway_server_new (const char *display, GError **error)
_gdk_broadway_server_new (GdkDisplay *display,
const char *display_name,
GError **error)
{
GdkBroadwayServer *server;
GSocketClient *client;
@ -108,14 +111,14 @@ _gdk_broadway_server_new (const char *display, GError **error)
char *local_socket_type = NULL;
int port;
if (display == NULL)
display = ":0";
if (display_name == NULL)
display_name = ":0";
if (display[0] == ':' && g_ascii_isdigit(display[1]))
if (display_name[0] == ':' && g_ascii_isdigit(display_name[1]))
{
char *path, *basename;
port = strtol (display + strlen (":"), NULL, 10);
port = strtol (display_name + strlen (":"), NULL, 10);
basename = g_strdup_printf ("broadway%d.socket", port + 1);
path = g_build_filename (g_get_user_runtime_dir (), basename, NULL);
g_free (basename);
@ -127,7 +130,7 @@ _gdk_broadway_server_new (const char *display, GError **error)
else
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("Broadway display type not supported: %s"), display);
_("Broadway display type not supported: %s"), display_name);
return NULL;
}
@ -145,6 +148,7 @@ _gdk_broadway_server_new (const char *display, GError **error)
server = g_object_new (GDK_TYPE_BROADWAY_SERVER, NULL);
server->connection = connection;
server->display = display;
in = g_io_stream_get_input_stream (G_IO_STREAM (server->connection));
pollable = G_POLLABLE_INPUT_STREAM (in);
@ -346,7 +350,7 @@ process_input_messages (GdkBroadwayServer *server)
server->incomming);
if (reply->base.type == BROADWAY_REPLY_EVENT)
_gdk_broadway_events_got_input (&reply->event.msg);
_gdk_broadway_events_got_input (server->display, &reply->event.msg);
else
g_warning ("Unhandled reply type %d", reply->base.type);
g_free (reply);

View File

@ -14,7 +14,8 @@ typedef struct _GdkBroadwayServerClass GdkBroadwayServerClass;
#define GDK_IS_BROADWAY_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_SERVER))
#define GDK_BROADWAY_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_SERVER, GdkBroadwayServerClass))
GdkBroadwayServer *_gdk_broadway_server_new (const char *display,
GdkBroadwayServer *_gdk_broadway_server_new (GdkDisplay *display,
const char *display_name,
GError **error);
void _gdk_broadway_server_flush (GdkBroadwayServer *server);
void _gdk_broadway_server_sync (GdkBroadwayServer *server);

View File

@ -174,7 +174,7 @@ _gdk_broadway_display_open (const gchar *display_name)
if (display_name == NULL)
display_name = g_getenv ("BROADWAY_DISPLAY");
broadway_display->server = _gdk_broadway_server_new (display_name, &error);
broadway_display->server = _gdk_broadway_server_new (display, display_name, &error);
if (broadway_display->server == NULL)
{
g_printerr ("Unable to init Broadway server: %s\n", error->message);

View File

@ -83,30 +83,14 @@ gdk_event_source_check (GSource *source)
}
void
_gdk_broadway_events_got_input (BroadwayInputMsg *message)
_gdk_broadway_events_got_input (GdkDisplay *display,
BroadwayInputMsg *message)
{
GdkDisplay *display;
GdkBroadwayDisplay *display_broadway;
GdkSeat *seat;
GdkSurface *surface;
GdkEvent *event = NULL;
GList *node;
GSList *list, *d;
display = NULL;
list = gdk_display_manager_list_displays (gdk_display_manager_get ());
for (d = list; d; d = d->next)
{
if (GDK_IS_BROADWAY_DISPLAY (d->data))
{
display = d->data;
break;
}
}
g_slist_free (list);
g_assert (display != NULL);
display_broadway = GDK_BROADWAY_DISPLAY (display);
seat = gdk_display_get_default_seat (display);

View File

@ -78,7 +78,8 @@ gboolean _gdk_keymap_key_is_modifier (GdkKeymap *keymap,
void _gdk_broadway_display_size_changed (GdkDisplay *display,
BroadwayInputScreenResizeNotify *msg);
void _gdk_broadway_events_got_input (BroadwayInputMsg *message);
void _gdk_broadway_events_got_input (GdkDisplay *display,
BroadwayInputMsg *message);
void _gdk_broadway_display_init_root_window (GdkDisplay *display);
void _gdk_broadway_display_init_dnd (GdkDisplay *display);