diff options
author | emersion <contact@emersion.fr> | 2017-11-12 22:12:50 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-11-12 22:12:50 +0100 |
commit | f8b43940b1a14e78c5365c9c1d17bfc79f523530 (patch) | |
tree | ad2aa347b862cc7446a1cc80f5932847e1491fbe /rootston/desktop.c | |
parent | 2e312a7e27fac0ef299abbdf5f66cf164992f02f (diff) | |
parent | a317ecdab8ef8deb184b72db208794daa4c4a3a0 (diff) |
Merge branch 'master' into cursor-scale
Diffstat (limited to 'rootston/desktop.c')
-rw-r--r-- | rootston/desktop.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c index 51bb0e2a..1695d007 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -167,9 +167,22 @@ bool view_center(struct roots_view *view) { view_get_box(view, &box); struct roots_desktop *desktop = view->desktop; + struct roots_input *input = desktop->server->input; + struct roots_seat *seat = NULL, *_seat; + wl_list_for_each(_seat, &input->seats, link) { + if (!seat || (seat->seat->last_event.tv_sec > _seat->seat->last_event.tv_sec && + seat->seat->last_event.tv_nsec > _seat->seat->last_event.tv_nsec)) { + seat = _seat; + } + } + if (!seat) { + return false; + } struct wlr_output *output = - wlr_output_layout_get_center_output(desktop->layout); + wlr_output_layout_output_at(desktop->layout, + seat->cursor->cursor->x, + seat->cursor->cursor->y); if (!output) { // empty layout return false; @@ -218,7 +231,7 @@ void view_teardown(struct roots_view *view) { struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { - for (int i = desktop->views->length - 1; i >= 0; --i) { + for (ssize_t i = desktop->views->length - 1; i >= 0; --i) { struct roots_view *view = desktop->views->items[i]; if (view->type == ROOTS_WL_SHELL_VIEW && @@ -230,11 +243,12 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, double view_sx = lx - view->x; double view_sy = ly - view->y; + struct wlr_surface_state *state = view->wlr_surface->current; struct wlr_box box = { .x = 0, .y = 0, - .width = view->wlr_surface->current->buffer_width, - .height = view->wlr_surface->current->buffer_height, + .width = state->buffer_width / state->scale, + .height = state->buffer_height / state->scale, }; if (view->rotation != 0.0) { // Coordinates relative to the center of the view @@ -248,7 +262,6 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, } if (view->type == ROOTS_XDG_SHELL_V6_VIEW) { - // TODO: test if this works with rotated views double popup_sx, popup_sy; struct wlr_xdg_surface_v6 *popup = wlr_xdg_surface_v6_popup_at(view->xdg_surface_v6, @@ -263,7 +276,6 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, } if (view->type == ROOTS_WL_SHELL_VIEW) { - // TODO: test if this works with rotated views double popup_sx, popup_sy; struct wlr_wl_shell_surface *popup = wlr_wl_shell_surface_popup_at(view->wl_shell_surface, |