xwm: Use a simple heuristic for mapping X input events to a weston seat
diff --git a/src/xwayland/selection.c b/src/xwayland/selection.c
index 0ec571a..cd49289 100644
--- a/src/xwayland/selection.c
+++ b/src/xwayland/selection.c
@@ -149,6 +149,7 @@
{
struct x11_data_source *source;
struct weston_compositor *compositor;
+ struct weston_seat *seat = weston_wm_pick_seat(wm);
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
xcb_atom_t *value;
@@ -194,7 +195,7 @@
}
compositor = wm->server->compositor;
- wl_seat_set_selection(&compositor->seat->seat, &source->base,
+ wl_seat_set_selection(&seat->seat, &source->base,
wl_display_next_serial(compositor->wl_display));
free(reply);
@@ -422,7 +423,7 @@
weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_type)
{
struct wl_data_source *source;
- struct wl_seat *seat = &wm->server->compositor->seat->seat;
+ struct weston_seat *seat = weston_wm_pick_seat(wm);
int p[2];
if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1) {
@@ -440,7 +441,7 @@
weston_wm_read_data_source,
wm);
- source = seat->selection_data_source;
+ source = seat->seat.selection_data_source;
source->send(source, mime_type, p[1]);
}
@@ -550,6 +551,7 @@
xcb_xfixes_selection_notify_event_t *xfixes_selection_notify =
(xcb_xfixes_selection_notify_event_t *) event;
struct weston_compositor *compositor;
+ struct weston_seat *seat = weston_wm_pick_seat(wm);
uint32_t serial;
weston_log("xfixes selection notify event: owner %d\n",
@@ -561,7 +563,7 @@
* proxy selection. Clear the wayland selection. */
compositor = wm->server->compositor;
serial = wl_display_next_serial(compositor->wl_display);
- wl_seat_set_selection(&compositor->seat->seat, NULL, serial);
+ wl_seat_set_selection(&seat->seat, NULL, serial);
}
wm->selection_owner = XCB_WINDOW_NONE;
@@ -663,7 +665,7 @@
void
weston_wm_selection_init(struct weston_wm *wm)
{
- struct wl_seat *seat;
+ struct weston_seat *seat;
uint32_t values[1], mask;
wm->selection_request.requestor = XCB_NONE;
@@ -693,9 +695,9 @@
xcb_xfixes_select_selection_input(wm->conn, wm->selection_window,
wm->atom.clipboard, mask);
- seat = &wm->server->compositor->seat->seat;
+ seat = weston_wm_pick_seat(wm);
wm->selection_listener.notify = weston_wm_set_selection;
- wl_signal_add(&seat->selection_signal, &wm->selection_listener);
+ wl_signal_add(&seat->seat.selection_signal, &wm->selection_listener);
weston_wm_set_selection(&wm->selection_listener, seat);
}
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index d724d47..e705fec 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -879,6 +879,13 @@
}
}
+struct weston_seat *
+weston_wm_pick_seat(struct weston_wm *wm)
+{
+ return container_of(wm->server->compositor->seat_list.next,
+ struct weston_seat, link);
+}
+
static void
weston_wm_window_handle_moveresize(struct weston_wm_window *window,
xcb_client_message_event_t *client_message)
@@ -895,7 +902,7 @@
};
struct weston_wm *wm = window->wm;
- struct weston_seat *seat = wm->server->compositor->seat;
+ struct weston_seat *seat = weston_wm_pick_seat(wm);
int detail;
struct weston_shell_interface *shell_interface =
&wm->server->compositor->shell_interface;
@@ -1047,6 +1054,7 @@
xcb_button_press_event_t *button = (xcb_button_press_event_t *) event;
struct weston_shell_interface *shell_interface =
&wm->server->compositor->shell_interface;
+ struct weston_seat *seat = weston_wm_pick_seat(wm);
struct weston_wm_window *window;
enum theme_location location;
struct theme *t = wm->theme;
@@ -1068,8 +1076,7 @@
switch (location) {
case THEME_LOCATION_TITLEBAR:
- shell_interface->move(window->shsurf,
- wm->server->compositor->seat);
+ shell_interface->move(window->shsurf, seat);
break;
case THEME_LOCATION_RESIZING_TOP:
case THEME_LOCATION_RESIZING_BOTTOM:
@@ -1080,8 +1087,7 @@
case THEME_LOCATION_RESIZING_BOTTOM_LEFT:
case THEME_LOCATION_RESIZING_BOTTOM_RIGHT:
shell_interface->resize(window->shsurf,
- wm->server->compositor->seat,
- location);
+ seat, location);
break;
default:
break;
diff --git a/src/xwayland/xwayland.h b/src/xwayland/xwayland.h
index 23c6a77..bd127b7 100644
--- a/src/xwayland/xwayland.h
+++ b/src/xwayland/xwayland.h
@@ -152,3 +152,5 @@
void
weston_wm_destroy(struct weston_wm *wm);
+struct weston_seat *
+weston_wm_pick_seat(struct weston_wm *wm);