diff options
| author | Drew DeVault <sir@cmpwn.com> | 2017-11-11 10:11:31 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-11 10:11:31 -0500 | 
| commit | a538ef33c1f27d5180117933bee40ecd93fbea7a (patch) | |
| tree | be639c73a782ecfd680dabc31d3a4e4208cba61f /rootston/xwayland.c | |
| parent | 78ed7f3c8983191b0b6399d4c66f5524a23f216a (diff) | |
| parent | 2a9dc60f28616211370fcd48de8c75ef17282d2e (diff) | |
| download | wlroots-a538ef33c1f27d5180117933bee40ecd93fbea7a.tar.xz | |
Merge pull request #384 from acrisci/feature/multiseat
multiseat
Diffstat (limited to 'rootston/xwayland.c')
| -rw-r--r-- | rootston/xwayland.c | 38 | 
1 files changed, 13 insertions, 25 deletions
| diff --git a/rootston/xwayland.c b/rootston/xwayland.c index b608b143..f4e100dc 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -121,26 +121,16 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {  		xwayland_surface, event->x, event->y, event->width, event->height);  } -// XXX Needs deep refactoring to get this better. We need to select the correct -// seat based on seat pointer focus, but interactive moving and resizing is not -// yet seat aware. Even then, we can only guess because X11 events don't give us -// enough wayland info to know for sure. -static struct wlr_cursor *guess_cursor_for_view(struct roots_view *view) { +static struct roots_seat *guess_seat_for_view(struct roots_view *view) { +	// the best we can do is to pick the first seat that has the surface focused +	// for the pointer  	struct roots_input *input = view->desktop->server->input; -	size_t len = sizeof(input->input_events) / sizeof(*input->input_events); -	for (size_t i = 0; i < len; i++) { -		struct wlr_cursor *cursor = input->input_events[i].cursor; -		if (cursor) { -			int width = view->xwayland_surface->surface->current->width; -			int height = view->xwayland_surface->surface->current->height; -			if (cursor->x > view->x && cursor->y > view->y && -					cursor->x < view->x + width && -					cursor->y < view->y + height) { -				return cursor; -			} +	struct roots_seat *seat; +	wl_list_for_each(seat, &input->seats, link) { +		if (seat->seat->pointer_state.focused_surface == view->wlr_surface) { +			return seat;  		}  	} -  	return NULL;  } @@ -148,28 +138,26 @@ static void handle_request_move(struct wl_listener *listener, void *data) {  	struct roots_xwayland_surface *roots_surface =  		wl_container_of(listener, roots_surface, request_move);  	struct roots_view *view = roots_surface->view; -	struct roots_input *input = view->desktop->server->input; -	struct wlr_cursor *cursor = guess_cursor_for_view(view); +	struct roots_seat *seat = guess_seat_for_view(view); -	if (!cursor || input->mode != ROOTS_CURSOR_PASSTHROUGH) { +	if (!seat || seat->cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {  		return;  	} -	view_begin_move(input, cursor, view); +	roots_seat_begin_move(seat, view);  }  static void handle_request_resize(struct wl_listener *listener, void *data) {  	struct roots_xwayland_surface *roots_surface =  		wl_container_of(listener, roots_surface, request_resize);  	struct roots_view *view = roots_surface->view; -	struct roots_input *input = view->desktop->server->input; -	struct wlr_cursor *cursor = guess_cursor_for_view(view); +	struct roots_seat *seat = guess_seat_for_view(view);  	struct wlr_xwayland_resize_event *e = data; -	if (!cursor || input->mode != ROOTS_CURSOR_PASSTHROUGH) { +	if (!seat || seat->cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {  		return;  	} -	view_begin_resize(input, cursor, view, e->edges); +	roots_seat_begin_resize(seat, view, e->edges);  }  static void handle_request_maximize(struct wl_listener *listener, void *data) { | 
