diff options
| author | Drew DeVault <sir@cmpwn.com> | 2017-11-10 08:21:50 -0500 | 
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2017-11-10 08:21:50 -0500 | 
| commit | 425713b83730a7b707ac5b0a325b8e37464a982c (patch) | |
| tree | ef504e85918a36d1abc4e9b659abf000d453a164 /rootston/desktop.c | |
| parent | ca3c373c18fa2c4edb2e3f46c74d50f1f571e72c (diff) | |
| parent | aafb00a15fd84b6d40f2efa52333eea5633b14e5 (diff) | |
| download | wlroots-425713b83730a7b707ac5b0a325b8e37464a982c.tar.xz | |
Merge branch 'hidpi'
Diffstat (limited to 'rootston/desktop.c')
| -rw-r--r-- | rootston/desktop.c | 65 | 
1 files changed, 47 insertions, 18 deletions
| diff --git a/rootston/desktop.c b/rootston/desktop.c index b36a6932..78bd271a 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -35,36 +35,64 @@ void view_destroy(struct roots_view *view) {  	free(view);  } -void view_get_size(struct roots_view *view, struct wlr_box *box) { +void view_get_size(const struct roots_view *view, struct wlr_box *box) {  	if (view->get_size) {  		view->get_size(view, box); -		return; +	} else { +		box->width = view->wlr_surface->current->width; +		box->height = view->wlr_surface->current->height;  	} -	box->x = box->y = 0; -	box->width = view->wlr_surface->current->width; -	box->height = view->wlr_surface->current->height; +	box->x = view->x; +	box->y = view->y;  } -void view_activate(struct roots_view *view, bool activate) { -	if (view->activate) { -		view->activate(view, activate); +static void view_update_output(const struct roots_view *view, +		const struct wlr_box *before) { +	struct roots_desktop *desktop = view->desktop; +	struct roots_output *output; +	struct wlr_box box; +	view_get_size(view, &box); +	wl_list_for_each(output, &desktop->outputs, link) { +		bool intersected = before->x != -1 && wlr_output_layout_intersects( +				desktop->layout, output->wlr_output, +				before->x, before->y, before->x + before->width, +				before->y + before->height); +		bool intersects = wlr_output_layout_intersects( +				desktop->layout, output->wlr_output, +				view->x, view->y, view->x + box.width, view->y + box.height); +		if (intersected && !intersects) { +			wlr_surface_send_leave(view->wlr_surface, output->wlr_output); +		} +		if (!intersected && intersects) { +			wlr_surface_send_enter(view->wlr_surface, output->wlr_output); +		}  	}  }  void view_move(struct roots_view *view, double x, double y) { +	struct wlr_box before; +	view_get_size(view, &before);  	if (view->move) {  		view->move(view, x, y); -		return; +	} else { +		view->x = x; +		view->y = y;  	} +} -	view->x = x; -	view->y = y; +void view_activate(struct roots_view *view, bool activate) { +	if (view->activate) { +		view->activate(view, activate); +	}  }  void view_resize(struct roots_view *view, uint32_t width, uint32_t height) { +	struct wlr_box before; +	view_get_size(view, &before);  	if (view->resize) {  		view->resize(view, width, height);  	} +	view_update_output(view, &before);  }  void view_move_resize(struct roots_view *view, double x, double y, @@ -85,8 +113,8 @@ void view_close(struct roots_view *view) {  }  bool view_center(struct roots_view *view) { -	struct wlr_box size; -	view_get_size(view, &size); +	struct wlr_box box; +	view_get_size(view, &box);  	struct roots_desktop *desktop = view->desktop;  	struct wlr_cursor *cursor = desktop->server->input->cursor; @@ -109,19 +137,20 @@ bool view_center(struct roots_view *view) {  	int width, height;  	wlr_output_effective_resolution(output, &width, &height); -	double view_x = (double)(width - size.width) / 2 + l_output->x; -	double view_y = (double)(height - size.height) / 2 + l_output->y; - +	double view_x = (double)(width - box.width) / 2 + l_output->x; +	double view_y = (double)(height - box.height) / 2 + l_output->y;  	view_move(view, view_x, view_y);  	return true;  }  void view_setup(struct roots_view *view) { -	view_center(view); -  	struct roots_input *input = view->desktop->server->input; +	view_center(view);  	set_view_focus(input, view->desktop, view); +	struct wlr_box before; +	view_get_size(view, &before); +	view_update_output(view, &before);  }  void view_teardown(struct roots_view *view) { | 
