From 3e3209cba22c9a5a562acc5e543946408a36e2f4 Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 5 Nov 2017 10:22:42 +0100 Subject: Fix laggy move-resize in xdg-shell --- include/rootston/view.h | 6 ++++ rootston/xdg_shell_v6.c | 76 +++++++++++++++++++++++++++++-------------------- rootston/xwayland.c | 22 +++++++------- 3 files changed, 62 insertions(+), 42 deletions(-) diff --git a/include/rootston/view.h b/include/rootston/view.h index 0913b42e..adfbe6e0 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -26,6 +26,12 @@ struct roots_xdg_surface_v6 { struct wl_listener destroy; struct wl_listener request_move; struct wl_listener request_resize; + + struct { + bool needs_move; + double x, y; + uint32_t width, height; + } move_resize; }; struct roots_xwayland_surface { diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index ca33c582..38341922 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -12,27 +12,26 @@ static void get_size(struct roots_view *view, struct wlr_box *box) { assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); - struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; - // TODO: surf->geometry can be NULL - memcpy(box, surf->geometry, sizeof(struct wlr_box)); + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + // TODO: surface->geometry can be NULL + memcpy(box, surface->geometry, sizeof(struct wlr_box)); } static void activate(struct roots_view *view, bool active) { assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); - struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; - if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { - wlr_xdg_toplevel_v6_set_activated(surf, active); + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { + wlr_xdg_toplevel_v6_set_activated(surface, active); } } -static void apply_size_constraints(struct wlr_xdg_surface_v6 *surf, +static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface, uint32_t width, uint32_t height, uint32_t *dest_width, uint32_t *dest_height) { *dest_width = width; *dest_height = height; - struct wlr_xdg_toplevel_v6_state *state = - &surf->toplevel_state->current; + struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel_state->current; if (width < state->min_width) { *dest_width = state->min_width; } else if (state->max_width > 0 && @@ -49,46 +48,50 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surf, static void resize(struct roots_view *view, uint32_t width, uint32_t height) { assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); - struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; - if (surf->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { return; } - uint32_t contrained_width, contrained_height; - apply_size_constraints(surf, width, height, &contrained_width, - &contrained_height); + uint32_t constrained_width, constrained_height; + apply_size_constraints(surface, width, height, &constrained_width, + &constrained_height); - wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height); + wlr_xdg_toplevel_v6_set_size(surface, constrained_width, + constrained_height); } static void move_resize(struct roots_view *view, double x, double y, uint32_t width, uint32_t height) { assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); - struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; - if (surf->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { + struct roots_xdg_surface_v6 *roots_surface = view->roots_xdg_surface_v6; + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { return; } - uint32_t contrained_width, contrained_height; - apply_size_constraints(surf, width, height, &contrained_width, - &contrained_height); + uint32_t constrained_width, constrained_height; + apply_size_constraints(surface, width, height, &constrained_width, + &constrained_height); - x = x + width - contrained_width; - y = y + height - contrained_height; + x = x + width - constrained_width; + y = y + height - constrained_height; - // TODO: we should wait for an ack_configure event before updating the - // position - view->x = x; - view->y = y; + roots_surface->move_resize.needs_move = true; + roots_surface->move_resize.x = x; + roots_surface->move_resize.y = y; + roots_surface->move_resize.width = constrained_width; + roots_surface->move_resize.height = constrained_height; - wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height); + wlr_xdg_toplevel_v6_set_size(surface, constrained_width, + constrained_height); } static void close(struct roots_view *view) { assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); - struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; - if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { - wlr_xdg_toplevel_v6_send_close(surf); + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { + wlr_xdg_toplevel_v6_send_close(surface); } } @@ -119,7 +122,18 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { } static void handle_commit(struct wl_listener *listener, void *data) { - // TODO is there anything we need to do here? + struct roots_xdg_surface_v6 *roots_surface = + wl_container_of(listener, roots_surface, commit); + struct roots_view *view = roots_surface->view; + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + + if (roots_surface->move_resize.needs_move) { + view->x = roots_surface->move_resize.x + + roots_surface->move_resize.width - surface->geometry->width; + view->y = roots_surface->move_resize.y + + roots_surface->move_resize.height - surface->geometry->height; + roots_surface->move_resize.needs_move = false; + } } static void handle_destroy(struct wl_listener *listener, void *data) { diff --git a/rootston/xwayland.c b/rootston/xwayland.c index e3fc1c84..76cdf05a 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -52,13 +52,13 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) { assert(view->type == ROOTS_XWAYLAND_VIEW); struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; - uint32_t contrained_width, contrained_height; - apply_size_constraints(xwayland_surface, width, height, &contrained_width, - &contrained_height); + uint32_t constrained_width, constrained_height; + apply_size_constraints(xwayland_surface, width, height, &constrained_width, + &constrained_height); wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - xwayland_surface->x, xwayland_surface->y, contrained_width, - contrained_height); + xwayland_surface->x, xwayland_surface->y, constrained_width, + constrained_height); } static void move_resize(struct roots_view *view, double x, double y, @@ -66,18 +66,18 @@ static void move_resize(struct roots_view *view, double x, double y, assert(view->type == ROOTS_XWAYLAND_VIEW); struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; - uint32_t contrained_width, contrained_height; - apply_size_constraints(xwayland_surface, width, height, &contrained_width, - &contrained_height); + uint32_t constrained_width, constrained_height; + apply_size_constraints(xwayland_surface, width, height, &constrained_width, + &constrained_height); - x = x + width - contrained_width; - y = y + height - contrained_height; + x = x + width - constrained_width; + y = y + height - constrained_height; view->x = x; view->y = y; wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - x, y, contrained_width, contrained_height); + x, y, constrained_width, constrained_height); } static void close(struct roots_view *view) { -- cgit v1.2.3 From e2843d87c868341869cf905f6c77531e78d997ad Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 17 Nov 2017 23:52:42 +0100 Subject: Ensure to move the view when configured --- include/rootston/view.h | 2 +- include/wlr/types/wlr_xdg_shell_v6.h | 24 +++++++++++++--------- rootston/xdg_shell_v6.c | 10 ++++----- types/wlr_xdg_shell_v6.c | 40 ++++++++++++++++++------------------ 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/include/rootston/view.h b/include/rootston/view.h index 9df2ee08..66616207 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -30,7 +30,7 @@ struct roots_xdg_surface_v6 { struct wl_listener request_maximize; struct { - bool needs_move; + uint32_t configure_serial; double x, y; uint32_t width, height; } move_resize; diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index e3982003..d0e7957b 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -107,7 +107,9 @@ struct wlr_xdg_surface_v6 { bool configured; bool added; + uint32_t configure_serial; struct wl_event_source *configure_idle; + uint32_t configure_next_serial; struct wl_list configure_list; char *title; @@ -171,37 +173,38 @@ void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell); void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface); /** - * Request that this toplevel surface be the given size. + * Request that this toplevel surface be the given size. Returns the associated + * configure serial. */ -void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t width, uint32_t height); /** * Request that this toplevel surface show itself in an activated or deactivated - * state. + * state. Returns the associated configure serial. */ -void wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, bool activated); /** * Request that this toplevel surface consider itself maximized or not - * maximized. + * maximized. Returns the associated configure serial. */ -void wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, bool maximized); /** * Request that this toplevel surface consider itself fullscreen or not - * fullscreen. + * fullscreen. Returns the associated configure serial. */ -void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, bool fullscreen); /** * Request that this toplevel surface consider itself to be resizing or not - * resizing. + * resizing. Returns the associated configure serial. */ -void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, bool resizing); /** @@ -223,4 +226,5 @@ void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface, struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at( struct wlr_xdg_surface_v6 *surface, double sx, double sy, double *popup_sx, double *popup_sy); + #endif diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index f9c905dd..d91fc2d9 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -83,14 +83,13 @@ static void move_resize(struct roots_view *view, double x, double y, x = x + width - constrained_width; y = y + height - constrained_height; - roots_surface->move_resize.needs_move = true; roots_surface->move_resize.x = x; roots_surface->move_resize.y = y; roots_surface->move_resize.width = constrained_width; roots_surface->move_resize.height = constrained_height; - wlr_xdg_toplevel_v6_set_size(surface, constrained_width, - constrained_height); + roots_surface->move_resize.configure_serial = wlr_xdg_toplevel_v6_set_size( + surface, constrained_width, constrained_height); } static void maximize(struct roots_view *view, bool maximized) { @@ -159,12 +158,13 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct roots_view *view = roots_surface->view; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; - if (roots_surface->move_resize.needs_move) { + if (roots_surface->move_resize.configure_serial == + surface->configure_serial) { view->x = roots_surface->move_resize.x + roots_surface->move_resize.width - surface->geometry->width; view->y = roots_surface->move_resize.y + roots_surface->move_resize.height - surface->geometry->height; - roots_surface->move_resize.needs_move = false; + roots_surface->move_resize.configure_serial = 0; } } diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 429baa70..dfe5ddc5 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -812,6 +812,7 @@ static void xdg_surface_ack_configure(struct wl_client *client, } surface->configured = true; + surface->configure_serial = serial; wl_signal_emit(&surface->events.ack_configure, surface); @@ -941,7 +942,6 @@ static void wlr_xdg_toplevel_v6_send_configure( static void wlr_xdg_surface_send_configure(void *user_data) { struct wlr_xdg_surface_v6 *surface = user_data; - struct wl_display *display = wl_client_get_display(surface->client->client); surface->configure_idle = NULL; @@ -953,7 +953,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) { } wl_list_insert(surface->configure_list.prev, &configure->link); - configure->serial = wl_display_next_serial(display); + configure->serial = surface->configure_next_serial; switch (surface->role) { case WLR_XDG_SURFACE_V6_ROLE_NONE: @@ -974,7 +974,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) { zxdg_surface_v6_send_configure(surface->resource, configure->serial); } -static void wlr_xdg_surface_v6_schedule_configure( +static uint32_t wlr_xdg_surface_v6_schedule_configure( struct wlr_xdg_surface_v6 *surface) { struct wl_display *display = wl_client_get_display(surface->client->client); struct wl_event_loop *loop = wl_display_get_event_loop(display); @@ -995,23 +995,23 @@ static void wlr_xdg_surface_v6_schedule_configure( if (surface->configure_idle != NULL) { if (!pending_same) { // configure request already scheduled - return; + return surface->configure_next_serial; } // configure request not necessary anymore wl_event_source_remove(surface->configure_idle); surface->configure_idle = NULL; + return 0; } else { if (pending_same) { // configure request not necessary - return; + return 0; } - surface->configure_idle = - wl_event_loop_add_idle( - loop, - wlr_xdg_surface_send_configure, - surface); + surface->configure_next_serial = wl_display_next_serial(display); + surface->configure_idle = wl_event_loop_add_idle(loop, + wlr_xdg_surface_send_configure, surface); + return surface->configure_next_serial; } } @@ -1304,45 +1304,45 @@ void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) { surface->client->ping_serial); } -void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t width, uint32_t height) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); surface->toplevel_state->pending.width = width; surface->toplevel_state->pending.height = height; - wlr_xdg_surface_v6_schedule_configure(surface); + return wlr_xdg_surface_v6_schedule_configure(surface); } -void wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, bool activated) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); surface->toplevel_state->pending.activated = activated; - wlr_xdg_surface_v6_schedule_configure(surface); + return wlr_xdg_surface_v6_schedule_configure(surface); } -void wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, bool maximized) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); surface->toplevel_state->pending.maximized = maximized; - wlr_xdg_surface_v6_schedule_configure(surface); + return wlr_xdg_surface_v6_schedule_configure(surface); } -void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, bool fullscreen) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); surface->toplevel_state->pending.fullscreen = fullscreen; - wlr_xdg_surface_v6_schedule_configure(surface); + return wlr_xdg_surface_v6_schedule_configure(surface); } -void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, +uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, bool resizing) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); surface->toplevel_state->pending.resizing = resizing; - wlr_xdg_surface_v6_schedule_configure(surface); + return wlr_xdg_surface_v6_schedule_configure(surface); } void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) { -- cgit v1.2.3 From a3a8b7bfd8d1616cdf9f7ba911616ca0baeedc67 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 18 Nov 2017 09:09:23 +0100 Subject: Fixed a bug with move-resize, removed xdg-shell ack_configure event Fixed move-resizing a view when only one coordinate changes. --- include/rootston/view.h | 1 + include/wlr/types/wlr_xdg_shell_v6.h | 1 - rootston/cursor.c | 8 +------- rootston/desktop.c | 5 +++++ rootston/xdg_shell_v6.c | 31 ++++++++++++++++++++++++------- types/wlr_xdg_shell_v6.c | 3 --- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/rootston/view.h b/include/rootston/view.h index 66616207..058dc73e 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -32,6 +32,7 @@ struct roots_xdg_surface_v6 { struct { uint32_t configure_serial; double x, y; + bool update_x, update_y; uint32_t width, height; } move_resize; }; diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index d0e7957b..6ac84cef 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -125,7 +125,6 @@ struct wlr_xdg_surface_v6 { struct { struct wl_signal commit; struct wl_signal destroy; - struct wl_signal ack_configure; struct wl_signal ping_timeout; struct wl_signal request_maximize; diff --git a/rootston/cursor.c b/rootston/cursor.c index 5949a364..d4c4510a 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -98,13 +98,7 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, uint32_t t height = 0; } - if (active_x != seat->focus->x || - active_y != seat->focus->y) { - view_move_resize(seat->focus, active_x, active_y, - width, height); - } else { - view_resize(seat->focus, width, height); - } + view_move_resize(seat->focus, active_x, active_y, width, height); } break; case ROOTS_CURSOR_ROTATE: diff --git a/rootston/desktop.c b/rootston/desktop.c index 1695d007..be63d7f5 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -103,6 +103,11 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) { void view_move_resize(struct roots_view *view, double x, double y, uint32_t width, uint32_t height) { + if (x == view->x == x && y == view->y) { + view_resize(view, width, height); + return; + } + if (view->move_resize) { view->move_resize(view, x, y, width, height); return; diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index d91fc2d9..5a55b8c4 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -76,15 +76,24 @@ static void move_resize(struct roots_view *view, double x, double y, return; } + bool update_x = x != view->x; + bool update_y = y != view->y; + uint32_t constrained_width, constrained_height; apply_size_constraints(surface, width, height, &constrained_width, &constrained_height); - x = x + width - constrained_width; - y = y + height - constrained_height; + if (update_x) { + x = x + width - constrained_width; + } + if (update_y) { + y = y + height - constrained_height; + } roots_surface->move_resize.x = x; roots_surface->move_resize.y = y; + roots_surface->move_resize.update_x = update_x; + roots_surface->move_resize.update_y = update_y; roots_surface->move_resize.width = constrained_width; roots_surface->move_resize.height = constrained_height; @@ -158,12 +167,20 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct roots_view *view = roots_surface->view; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; - if (roots_surface->move_resize.configure_serial == + if (roots_surface->move_resize.configure_serial > 0 && + roots_surface->move_resize.configure_serial == surface->configure_serial) { - view->x = roots_surface->move_resize.x + - roots_surface->move_resize.width - surface->geometry->width; - view->y = roots_surface->move_resize.y + - roots_surface->move_resize.height - surface->geometry->height; + struct wlr_box size; + get_size(view, &size); + + if (roots_surface->move_resize.update_x) { + view->x = roots_surface->move_resize.x + + roots_surface->move_resize.width - size.width; + } + if (roots_surface->move_resize.update_y) { + view->y = roots_surface->move_resize.y + + roots_surface->move_resize.height - size.height; + } roots_surface->move_resize.configure_serial = 0; } } diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index dfe5ddc5..8bb48a24 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -814,8 +814,6 @@ static void xdg_surface_ack_configure(struct wl_client *client, surface->configured = true; surface->configure_serial = serial; - wl_signal_emit(&surface->events.ack_configure, surface); - free(configure); } @@ -1155,7 +1153,6 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, wl_signal_init(&surface->events.request_show_window_menu); wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.destroy); - wl_signal_init(&surface->events.ack_configure); wl_signal_init(&surface->events.ping_timeout); wl_signal_add(&surface->surface->events.destroy, -- cgit v1.2.3 From 8693bbd6b11b2519747fe3efcd6376a9736aef6f Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 18 Nov 2017 09:13:31 +0100 Subject: Update view coords when no configure is required --- rootston/xdg_shell_v6.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 5a55b8c4..8819ebdd 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -97,8 +97,14 @@ static void move_resize(struct roots_view *view, double x, double y, roots_surface->move_resize.width = constrained_width; roots_surface->move_resize.height = constrained_height; - roots_surface->move_resize.configure_serial = wlr_xdg_toplevel_v6_set_size( - surface, constrained_width, constrained_height); + uint32_t serial = wlr_xdg_toplevel_v6_set_size(surface, constrained_width, + constrained_height); + if (serial > 0) { + roots_surface->move_resize.configure_serial = serial; + } else { + view->x = x; + view->y = y; + } } static void maximize(struct roots_view *view, bool maximized) { -- cgit v1.2.3 From 7375931686e6a58c08a7727ce2f5d88e0be9adfa Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 18 Nov 2017 09:15:48 +0100 Subject: Fix typo making GCC build fail --- rootston/desktop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootston/desktop.c b/rootston/desktop.c index be63d7f5..fca801bb 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -103,7 +103,7 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) { void view_move_resize(struct roots_view *view, double x, double y, uint32_t width, uint32_t height) { - if (x == view->x == x && y == view->y) { + if (x == view->x && y == view->y) { view_resize(view, width, height); return; } -- cgit v1.2.3 From c0e2dc6f7875a3dc5ad7ca49444e068f15c001ed Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 19 Nov 2017 22:55:44 +0100 Subject: Update view position for previous configure_ack too --- rootston/xdg_shell_v6.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 8819ebdd..ca011d49 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -174,7 +174,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; if (roots_surface->move_resize.configure_serial > 0 && - roots_surface->move_resize.configure_serial == + roots_surface->move_resize.configure_serial >= surface->configure_serial) { struct wlr_box size; get_size(view, &size); @@ -187,7 +187,11 @@ static void handle_commit(struct wl_listener *listener, void *data) { view->y = roots_surface->move_resize.y + roots_surface->move_resize.height - size.height; } - roots_surface->move_resize.configure_serial = 0; + + if (roots_surface->move_resize.configure_serial == + surface->configure_serial) { + roots_surface->move_resize.configure_serial = 0; + } } } -- cgit v1.2.3 From ac6385689f8a4895888f069afeae037edc7c7e19 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 11:10:43 +0100 Subject: Set min view size to 1x1 --- rootston/cursor.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rootston/cursor.c b/rootston/cursor.c index db2a414c..93ee03d4 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -69,37 +69,37 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, if (seat->focus) { double dx = cursor->cursor->x - cursor->offs_x; double dy = cursor->cursor->y - cursor->offs_y; - double active_x = seat->focus->x; - double active_y = seat->focus->y; + double x = seat->focus->x; + double y = seat->focus->y; int width = cursor->view_width; int height = cursor->view_height; if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { - active_y = cursor->view_y + dy; + y = cursor->view_y + dy; height -= dy; - if (height < 0) { - active_y += height; + if (height < 1) { + y += height; } } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { height += dy; } if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - active_x = cursor->view_x + dx; + x = cursor->view_x + dx; width -= dx; - if (width < 0) { - active_x += width; + if (width < 1) { + x += width; } } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { width += dx; } - if (width < 0) { - width = 0; + if (width < 1) { + width = 1; } - if (height < 0) { - height = 0; + if (height < 1) { + height = 1; } - view_move_resize(seat->focus, active_x, active_y, width, height); + view_move_resize(seat->focus, x, y, width, height); } break; case ROOTS_CURSOR_ROTATE: -- cgit v1.2.3 From 0153a0ed8fb934333505ee7793b1c493d8d0cd35 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 12:05:21 +0100 Subject: Fix laggy move-resize for xwayland views --- include/rootston/view.h | 15 +++++++++------ rootston/xdg_shell_v6.c | 37 ++++++++++++++++++------------------ rootston/xwayland.c | 50 +++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/include/rootston/view.h b/include/rootston/view.h index 058dc73e..66fc88bc 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -29,12 +29,7 @@ struct roots_xdg_surface_v6 { struct wl_listener request_resize; struct wl_listener request_maximize; - struct { - uint32_t configure_serial; - double x, y; - bool update_x, update_y; - uint32_t width, height; - } move_resize; + uint32_t pending_move_resize_configure_serial; }; struct roots_xwayland_surface { @@ -48,6 +43,8 @@ struct roots_xwayland_surface { struct wl_listener request_maximize; struct wl_listener map_notify; struct wl_listener unmap_notify; + + struct wl_listener surface_commit; }; enum roots_view_type { @@ -69,6 +66,12 @@ struct roots_view { float rotation; } saved; + struct { + bool update_x, update_y; + double x, y; + uint32_t width, height; + } pending_move_resize; + // TODO: Something for roots-enforced width/height enum roots_view_type type; union { diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index ca011d49..95df36a2 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -90,17 +90,17 @@ static void move_resize(struct roots_view *view, double x, double y, y = y + height - constrained_height; } - roots_surface->move_resize.x = x; - roots_surface->move_resize.y = y; - roots_surface->move_resize.update_x = update_x; - roots_surface->move_resize.update_y = update_y; - roots_surface->move_resize.width = constrained_width; - roots_surface->move_resize.height = constrained_height; + view->pending_move_resize.update_x = update_x; + view->pending_move_resize.update_y = update_y; + view->pending_move_resize.x = x; + view->pending_move_resize.y = y; + view->pending_move_resize.width = constrained_width; + view->pending_move_resize.height = constrained_height; uint32_t serial = wlr_xdg_toplevel_v6_set_size(surface, constrained_width, constrained_height); if (serial > 0) { - roots_surface->move_resize.configure_serial = serial; + roots_surface->pending_move_resize_configure_serial = serial; } else { view->x = x; view->y = y; @@ -173,24 +173,23 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct roots_view *view = roots_surface->view; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; - if (roots_surface->move_resize.configure_serial > 0 && - roots_surface->move_resize.configure_serial >= - surface->configure_serial) { + uint32_t pending_serial = + roots_surface->pending_move_resize_configure_serial; + if (pending_serial > 0 && pending_serial >= surface->configure_serial) { struct wlr_box size; get_size(view, &size); - if (roots_surface->move_resize.update_x) { - view->x = roots_surface->move_resize.x + - roots_surface->move_resize.width - size.width; + if (view->pending_move_resize.update_x) { + view->x = view->pending_move_resize.x + + view->pending_move_resize.width - size.width; } - if (roots_surface->move_resize.update_y) { - view->y = roots_surface->move_resize.y + - roots_surface->move_resize.height - size.height; + if (view->pending_move_resize.update_y) { + view->y = view->pending_move_resize.y + + view->pending_move_resize.height - size.height; } - if (roots_surface->move_resize.configure_serial == - surface->configure_serial) { - roots_surface->move_resize.configure_serial = 0; + if (pending_serial == surface->configure_serial) { + roots_surface->pending_move_resize_configure_serial = 0; } } } diff --git a/rootston/xwayland.c b/rootston/xwayland.c index f1093552..372fd951 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -66,15 +66,26 @@ static void move_resize(struct roots_view *view, double x, double y, assert(view->type == ROOTS_XWAYLAND_VIEW); struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; + bool update_x = x != view->x; + bool update_y = y != view->y; + uint32_t constrained_width, constrained_height; apply_size_constraints(xwayland_surface, width, height, &constrained_width, &constrained_height); - x = x + width - constrained_width; - y = y + height - constrained_height; + if (update_x) { + x = x + width - constrained_width; + } + if (update_y) { + y = y + height - constrained_height; + } - view->x = x; - view->y = y; + view->pending_move_resize.update_x = update_x; + view->pending_move_resize.update_y = update_y; + view->pending_move_resize.x = x; + view->pending_move_resize.y = y; + view->pending_move_resize.width = constrained_width; + view->pending_move_resize.height = constrained_height; wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, x, y, constrained_width, constrained_height); @@ -171,6 +182,27 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { view_maximize(view, maximized); } +static void handle_surface_commit(struct wl_listener *listener, void *data) { + struct roots_xwayland_surface *roots_surface = + wl_container_of(listener, roots_surface, surface_commit); + struct roots_view *view = roots_surface->view; + struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; + + int width = xwayland_surface->surface->current->width; + int height = xwayland_surface->surface->current->height; + + if (view->pending_move_resize.update_x) { + view->x = view->pending_move_resize.x + + view->pending_move_resize.width - width; + view->pending_move_resize.update_x = false; + } + if (view->pending_move_resize.update_y) { + view->y = view->pending_move_resize.y + + view->pending_move_resize.height - height; + view->pending_move_resize.update_y = false; + } +} + static void handle_map_notify(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, map_notify); @@ -182,6 +214,10 @@ static void handle_map_notify(struct wl_listener *listener, void *data) { view->x = (double)xsurface->x; view->y = (double)xsurface->y; + roots_surface->surface_commit.notify = handle_surface_commit; + wl_signal_add(&xsurface->surface->events.commit, + &roots_surface->surface_commit); + wlr_list_push(desktop->views, roots_surface->view); } @@ -191,6 +227,8 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = roots_surface->view->desktop; roots_surface->view->wlr_surface = NULL; + wl_list_remove(&roots_surface->surface_commit.link); + for (size_t i = 0; i < desktop->views->length; i++) { if (desktop->views->items[i] == roots_surface->view) { wlr_list_del(desktop->views, i); @@ -231,6 +269,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { wl_signal_add(&surface->events.request_maximize, &roots_surface->request_maximize); + roots_surface->surface_commit.notify = handle_surface_commit; + wl_signal_add(&surface->surface->events.commit, + &roots_surface->surface_commit); + struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (view == NULL) { free(roots_surface); -- cgit v1.2.3 From 272e0858e49bf341b363fdbe59a5f669ba678ce2 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 12:16:10 +0100 Subject: Fix laggy move-resize for wl-shell views --- rootston/desktop.c | 12 ++++++++++-- rootston/wl_shell.c | 19 ++++++++++++++++++- rootston/xwayland.c | 6 +++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/rootston/desktop.c b/rootston/desktop.c index b3287ed0..c6a1957c 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -103,7 +103,9 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) { void view_move_resize(struct roots_view *view, double x, double y, uint32_t width, uint32_t height) { - if (x == view->x && y == view->y) { + bool update_x = x != view->x; + bool update_y = y != view->y; + if (!update_x && !update_y) { view_resize(view, width, height); return; } @@ -113,7 +115,13 @@ void view_move_resize(struct roots_view *view, double x, double y, return; } - view_move(view, x, y); + view->pending_move_resize.update_x = update_x; + view->pending_move_resize.update_y = update_y; + view->pending_move_resize.x = x; + view->pending_move_resize.y = y; + view->pending_move_resize.width = width; + view->pending_move_resize.height = height; + view_resize(view, width, height); } diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 96f461fe..0043219f 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -71,7 +71,24 @@ static void handle_set_state(struct wl_listener *listener, void *data) { } static void handle_surface_commit(struct wl_listener *listener, void *data) { - // TODO do we need to do anything here? + struct roots_wl_shell_surface *roots_surface = + wl_container_of(listener, roots_surface, surface_commit); + struct roots_view *view = roots_surface->view; + struct wlr_surface *wlr_surface = view->wlr_surface; + + int width = wlr_surface->current->width; + int height = wlr_surface->current->height; + + if (view->pending_move_resize.update_x) { + view->x = view->pending_move_resize.x + + view->pending_move_resize.width - width; + view->pending_move_resize.update_x = false; + } + if (view->pending_move_resize.update_y) { + view->y = view->pending_move_resize.y + + view->pending_move_resize.height - height; + view->pending_move_resize.update_y = false; + } } static void handle_destroy(struct wl_listener *listener, void *data) { diff --git a/rootston/xwayland.c b/rootston/xwayland.c index 372fd951..b2f64879 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -186,10 +186,10 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, surface_commit); struct roots_view *view = roots_surface->view; - struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; + struct wlr_surface *wlr_surface = view->wlr_surface; - int width = xwayland_surface->surface->current->width; - int height = xwayland_surface->surface->current->height; + int width = wlr_surface->current->width; + int height = wlr_surface->current->height; if (view->pending_move_resize.update_x) { view->x = view->pending_move_resize.x + -- cgit v1.2.3 From b04a9a248d4cf3d0e93e1b39ee9eedc9da359173 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 17:27:36 +0100 Subject: Initial fullscreen support --- include/rootston/view.h | 6 +++ include/wlr/types/wlr_output.h | 6 +++ include/wlr/types/wlr_xdg_shell_v6.h | 7 ++++ rootston/desktop.c | 69 +++++++++++++++++++++++++++++++---- rootston/output.c | 7 ++++ rootston/wl_shell.c | 20 ++++++++++ rootston/xdg_shell_v6.c | 29 +++++++++++++++ types/wlr_output.c | 67 ++++++++++++++++++++++++++++++++++ types/wlr_xdg_shell_v6.c | 71 ++++++++++++++++++++---------------- 9 files changed, 244 insertions(+), 38 deletions(-) diff --git a/include/rootston/view.h b/include/rootston/view.h index 69034d60..e1397b89 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -13,6 +13,7 @@ struct roots_wl_shell_surface { struct wl_listener request_move; struct wl_listener request_resize; struct wl_listener request_set_maximized; + struct wl_listener request_set_fullscreen; struct wl_listener set_state; struct wl_listener surface_commit; @@ -26,6 +27,7 @@ struct roots_xdg_surface_v6 { struct wl_listener request_move; struct wl_listener request_resize; struct wl_listener request_maximize; + struct wl_listener request_fullscreen; }; struct roots_xwayland_surface { @@ -54,6 +56,7 @@ struct roots_view { float rotation; bool maximized; + struct wlr_output *fullscreen_output; struct { double x, y; uint32_t width, height; @@ -93,6 +96,7 @@ struct roots_view { void (*move_resize)(struct roots_view *view, double x, double y, uint32_t width, uint32_t height); void (*maximize)(struct roots_view *view, bool maximized); + void (*set_fullscreen)(struct roots_view *view, bool fullscreen); void (*close)(struct roots_view *view); }; @@ -103,6 +107,8 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height); void view_move_resize(struct roots_view *view, double x, double y, uint32_t width, uint32_t height); void view_maximize(struct roots_view *view, bool maximized); +void view_set_fullscreen(struct roots_view *view, bool fullscreen, + struct wlr_output *output); void view_close(struct roots_view *view); bool view_center(struct roots_view *view); void view_setup(struct roots_view *view); diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index cf000019..d382b593 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -64,6 +64,10 @@ struct wlr_output { struct wl_signal destroy; } events; + struct wlr_surface *fullscreen_surface; + struct wl_listener fullscreen_surface_commit; + struct wl_listener fullscreen_surface_destroy; + struct wl_list cursors; // wlr_output_cursor::link struct wlr_output_cursor *hardware_cursor; @@ -89,6 +93,8 @@ void wlr_output_swap_buffers(struct wlr_output *output); void wlr_output_set_gamma(struct wlr_output *output, uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b); uint32_t wlr_output_get_gamma_size(struct wlr_output *output); +void wlr_output_set_fullscreen_surface(struct wlr_output *output, + struct wlr_surface *surface); struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output); bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index e3982003..7940deef 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -152,6 +152,13 @@ struct wlr_xdg_toplevel_v6_resize_event { uint32_t edges; }; +struct wlr_xdg_toplevel_v6_set_fullscreen_event { + struct wl_client *client; + struct wlr_xdg_surface_v6 *surface; + bool fullscreen; + struct wlr_output *output; +}; + struct wlr_xdg_toplevel_v6_show_window_menu_event { struct wl_client *client; struct wlr_xdg_surface_v6 *surface; diff --git a/rootston/desktop.c b/rootston/desktop.c index cf5a8cdc..be74b619 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -89,6 +89,19 @@ void view_move_resize(struct roots_view *view, double x, double y, view_resize(view, width, height); } +static struct wlr_output *view_get_output(struct roots_view *view) { + struct wlr_box view_box; + view_get_box(view, &view_box); + + double output_x, output_y; + wlr_output_layout_closest_point(view->desktop->layout, NULL, + view->x + (double)view_box.width/2, + view->y + (double)view_box.height/2, + &output_x, &output_y); + return wlr_output_layout_output_at(view->desktop->layout, output_x, + output_y); +} + void view_maximize(struct roots_view *view, bool maximized) { if (view->maximized == maximized) { return; @@ -109,13 +122,7 @@ void view_maximize(struct roots_view *view, bool maximized) { view->saved.width = view_box.width; view->saved.height = view_box.height; - double output_x, output_y; - wlr_output_layout_closest_point(view->desktop->layout, NULL, - view->x + (double)view_box.width/2, - view->y + (double)view_box.height/2, - &output_x, &output_y); - struct wlr_output *output = wlr_output_layout_output_at( - view->desktop->layout, output_x, output_y); + struct wlr_output *output = view_get_output(view); struct wlr_box *output_box = wlr_output_layout_get_box(view->desktop->layout, output); @@ -133,6 +140,54 @@ void view_maximize(struct roots_view *view, bool maximized) { } } +void view_set_fullscreen(struct roots_view *view, bool fullscreen, + struct wlr_output *output) { + bool was_fullscreen = view->fullscreen_output != NULL; + if (was_fullscreen == fullscreen) { + // TODO: support changing the output? + return; + } + + // TODO: check if client is focused? + + if (view->set_fullscreen) { + view->set_fullscreen(view, fullscreen); + } + + if (!was_fullscreen && fullscreen) { + if (output == NULL) { + output = view_get_output(view); + } + + struct wlr_box view_box; + view_get_box(view, &view_box); + + view->saved.x = view->x; + view->saved.y = view->y; + view->saved.rotation = view->rotation; + view->saved.width = view_box.width; + view->saved.height = view_box.height; + + struct wlr_box *output_box = + wlr_output_layout_get_box(view->desktop->layout, output); + view_move_resize(view, output_box->x, output_box->y, output_box->width, + output_box->height); + view->rotation = 0; + + wlr_output_set_fullscreen_surface(output, view->wlr_surface); + view->fullscreen_output = output; + } + + if (was_fullscreen && !fullscreen) { + view_move_resize(view, view->saved.x, view->saved.y, view->saved.width, + view->saved.height); + view->rotation = view->saved.rotation; + + wlr_output_set_fullscreen_surface(view->fullscreen_output, NULL); + view->fullscreen_output = NULL; + } +} + void view_close(struct roots_view *view) { if (view->close) { view->close(view); diff --git a/rootston/output.c b/rootston/output.c index 83ff37fd..35a5dac3 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -186,6 +186,13 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_output_make_current(wlr_output); wlr_renderer_begin(server->renderer, wlr_output); + if (wlr_output->fullscreen_surface != NULL) { + wlr_renderer_end(server->renderer); + wlr_output_swap_buffers(wlr_output); + output->last_frame = desktop->last_frame = now; + return; + } + struct roots_view *view; wl_list_for_each_reverse(view, &desktop->views, link) { render_view(view, desktop, wlr_output, &now); diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 7359c878..f285d7f6 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -59,6 +59,17 @@ static void handle_request_set_maximized(struct wl_listener *listener, view_maximize(view, true); } +static void handle_request_set_fullscreen(struct wl_listener *listener, + void *data) { + struct roots_wl_shell_surface *roots_surface = + wl_container_of(listener, roots_surface, request_set_fullscreen); + struct roots_view *view = roots_surface->view; + struct wlr_wl_shell_surface_set_fullscreen_event *e = data; + + // TODO: support e->method, e->framerate + view_set_fullscreen(view, true, e->output); +} + static void handle_set_state(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = wl_container_of(listener, roots_surface, set_state); @@ -68,6 +79,10 @@ static void handle_set_state(struct wl_listener *listener, void *data) { surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) { view_maximize(view, false); } + if (view->fullscreen_output != NULL && + surface->state != WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN) { + view_set_fullscreen(view, false, NULL); + } } static void handle_surface_commit(struct wl_listener *listener, void *data) { @@ -81,6 +96,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&roots_surface->request_move.link); wl_list_remove(&roots_surface->request_resize.link); wl_list_remove(&roots_surface->request_set_maximized.link); + wl_list_remove(&roots_surface->request_set_fullscreen.link); wl_list_remove(&roots_surface->set_state.link); wl_list_remove(&roots_surface->surface_commit.link); view_destroy(roots_surface->view); @@ -111,6 +127,10 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { roots_surface->request_set_maximized.notify = handle_request_set_maximized; wl_signal_add(&surface->events.request_set_maximized, &roots_surface->request_set_maximized); + roots_surface->request_set_fullscreen.notify = + handle_request_set_fullscreen; + wl_signal_add(&surface->events.request_set_fullscreen, + &roots_surface->request_set_fullscreen); roots_surface->set_state.notify = handle_set_state; wl_signal_add(&surface->events.set_state, &roots_surface->set_state); roots_surface->surface_commit.notify = handle_surface_commit; diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 656231c7..9017f7bd 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -100,6 +100,16 @@ static void maximize(struct roots_view *view, bool maximized) { wlr_xdg_toplevel_v6_set_maximized(surface, maximized); } +static void set_fullscreen(struct roots_view *view, bool fullscreen) { + assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { + return; + } + + wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen); +} + static void close(struct roots_view *view) { assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; @@ -150,6 +160,21 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { view_maximize(view, surface->toplevel_state->next.maximized); } +static void handle_request_fullscreen(struct wl_listener *listener, + void *data) { + struct roots_xdg_surface_v6 *roots_xdg_surface = + wl_container_of(listener, roots_xdg_surface, request_fullscreen); + struct roots_view *view = roots_xdg_surface->view; + struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data; + + if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { + return; + } + + view_set_fullscreen(view, e->fullscreen, e->output); +} + static void handle_commit(struct wl_listener *listener, void *data) { //struct roots_xdg_surface_v6 *roots_xdg_surface = // wl_container_of(listener, roots_xdg_surface, commit); @@ -202,6 +227,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { roots_surface->request_maximize.notify = handle_request_maximize; wl_signal_add(&surface->events.request_maximize, &roots_surface->request_maximize); + roots_surface->request_fullscreen.notify = handle_request_fullscreen; + wl_signal_add(&surface->events.request_fullscreen, + &roots_surface->request_fullscreen); struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (!view) { @@ -217,6 +245,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->resize = resize; view->move_resize = move_resize; view->maximize = maximize; + view->set_fullscreen = set_fullscreen; view->close = close; roots_surface->view = view; view_init(view, desktop); diff --git a/types/wlr_output.c b/types/wlr_output.c index 411dd404..5a8baa3d 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -252,6 +252,24 @@ void wlr_output_make_current(struct wlr_output *output) { output->impl->make_current(output); } +static void output_fullscreen_surface_render(struct wlr_output *output, + struct wlr_surface *surface) { + int x = (output->width - surface->current->width) / 2; + int y = (output->height - surface->current->height) / 2; + + glViewport(0, 0, output->width, output->height); + glClearColor(0, 0, 0, 0); + + if (!wlr_surface_has_buffer(surface)) { + return; + } + + float matrix[16]; + wlr_texture_get_matrix(surface->texture, &matrix, &output->transform_matrix, + x, y); + wlr_render_with_matrix(surface->renderer, surface->texture, &matrix); +} + static void output_cursor_get_box(struct wlr_output_cursor *cursor, struct wlr_box *box) { box->x = cursor->x - cursor->hotspot_x; @@ -308,6 +326,10 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) { void wlr_output_swap_buffers(struct wlr_output *output) { wl_signal_emit(&output->events.swap_buffers, &output); + if (output->fullscreen_surface != NULL) { + output_fullscreen_surface_render(output, output->fullscreen_surface); + } + struct wlr_output_cursor *cursor; wl_list_for_each(cursor, &output->cursors, link) { if (!cursor->enabled || output->hardware_cursor == cursor) { @@ -334,6 +356,51 @@ uint32_t wlr_output_get_gamma_size(struct wlr_output *output) { return output->impl->get_gamma_size(output); } +static void output_fullscreen_surface_reset(struct wlr_output *output) { + if (output->fullscreen_surface != NULL) { + wl_list_remove(&output->fullscreen_surface_commit.link); + wl_list_remove(&output->fullscreen_surface_destroy.link); + output->fullscreen_surface = NULL; + output->needs_swap = true; + } +} + +static void output_fullscreen_surface_handle_commit( + struct wl_listener *listener, void *data) { + struct wlr_output *output = wl_container_of(listener, output, + fullscreen_surface_destroy); + output->needs_swap = true; +} + +static void output_fullscreen_surface_handle_destroy( + struct wl_listener *listener, void *data) { + struct wlr_output *output = wl_container_of(listener, output, + fullscreen_surface_destroy); + output_fullscreen_surface_reset(output); +} + +void wlr_output_set_fullscreen_surface(struct wlr_output *output, + struct wlr_surface *surface) { + // TODO: hardware fullscreen + output_fullscreen_surface_reset(output); + + output->fullscreen_surface = surface; + output->needs_swap = true; + + if (surface == NULL) { + return; + } + + output->fullscreen_surface_commit.notify = + output_fullscreen_surface_handle_commit; + wl_signal_add(&surface->events.commit, &output->fullscreen_surface_commit); + output->fullscreen_surface_destroy.notify = + output_fullscreen_surface_handle_destroy; + wl_signal_add(&surface->events.destroy, + &output->fullscreen_surface_destroy); +} + + static void output_cursor_reset(struct wlr_output_cursor *cursor) { if (cursor->output->hardware_cursor != cursor) { cursor->output->needs_swap = true; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 429baa70..896a5f33 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -597,21 +597,14 @@ static void xdg_toplevel_protocol_move(struct wl_client *client, return; } - struct wlr_xdg_toplevel_v6_move_event *event = - calloc(1, sizeof(struct wlr_xdg_toplevel_v6_move_event)); - if (event == NULL) { - wl_client_post_no_memory(client); - return; - } - - event->client = client; - event->surface = surface; - event->seat = seat; - event->serial = serial; - - wl_signal_emit(&surface->events.request_move, event); + struct wlr_xdg_toplevel_v6_move_event event = { + .client = client, + .surface = surface, + .seat = seat, + .serial = serial, + }; - free(event); + wl_signal_emit(&surface->events.request_move, &event); } static void xdg_toplevel_protocol_resize(struct wl_client *client, @@ -628,22 +621,15 @@ static void xdg_toplevel_protocol_resize(struct wl_client *client, return; } - struct wlr_xdg_toplevel_v6_resize_event *event = - calloc(1, sizeof(struct wlr_xdg_toplevel_v6_resize_event)); - if (event == NULL) { - wl_client_post_no_memory(client); - return; - } - - event->client = client; - event->surface = surface; - event->seat = seat; - event->serial = serial; - event->edges = edges; - - wl_signal_emit(&surface->events.request_resize, event); + struct wlr_xdg_toplevel_v6_resize_event event = { + .client = client, + .surface = surface, + .seat = seat, + .serial = serial, + .edges = edges, + }; - free(event); + wl_signal_emit(&surface->events.request_resize, &event); } static void xdg_toplevel_protocol_set_max_size(struct wl_client *client, @@ -677,15 +663,38 @@ static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client, static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource) { struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); + + struct wlr_output *output = NULL; + if (output_resource != NULL) { + output = wl_resource_get_user_data(output_resource); + } + surface->toplevel_state->next.fullscreen = true; - wl_signal_emit(&surface->events.request_fullscreen, surface); + + struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { + .client = client, + .surface = surface, + .fullscreen = true, + .output = output, + }; + + wl_signal_emit(&surface->events.request_fullscreen, &event); } static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client, struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); + surface->toplevel_state->next.fullscreen = false; - wl_signal_emit(&surface->events.request_fullscreen, surface); + + struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { + .client = client, + .surface = surface, + .fullscreen = false, + .output = NULL, + }; + + wl_signal_emit(&surface->events.request_fullscreen, &event); } static void xdg_toplevel_protocol_set_minimized(struct wl_client *client, -- cgit v1.2.3 From 80998cdf57756fe46d55921c98a745aff4848215 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 17:58:26 +0100 Subject: Add support for fullscreen xwayland views --- include/rootston/view.h | 1 + rootston/xwayland.c | 21 +++++++++++++++++++++ types/wlr_output.c | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/include/rootston/view.h b/include/rootston/view.h index e1397b89..77bbfbec 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -38,6 +38,7 @@ struct roots_xwayland_surface { struct wl_listener request_move; struct wl_listener request_resize; struct wl_listener request_maximize; + struct wl_listener request_fullscreen; struct wl_listener map_notify; struct wl_listener unmap_notify; }; diff --git a/rootston/xwayland.c b/rootston/xwayland.c index c92c424b..5e27afed 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -92,6 +92,13 @@ static void maximize(struct roots_view *view, bool maximized) { view->xwayland_surface, maximized); } +static void set_fullscreen(struct roots_view *view, bool fullscreen) { + assert(view->type == ROOTS_XWAYLAND_VIEW); + + wlr_xwayland_surface_set_fullscreen(view->desktop->xwayland, + view->xwayland_surface, fullscreen); +} + static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, destroy); @@ -170,6 +177,16 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { view_maximize(view, maximized); } +static void handle_request_fullscreen(struct wl_listener *listener, + void *data) { + struct roots_xwayland_surface *roots_surface = + wl_container_of(listener, roots_surface, request_fullscreen); + struct roots_view *view = roots_surface->view; + struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; + + view_set_fullscreen(view, xwayland_surface->fullscreen, NULL); +} + static void handle_map_notify(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, map_notify); @@ -223,6 +240,9 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { roots_surface->request_maximize.notify = handle_request_maximize; wl_signal_add(&surface->events.request_maximize, &roots_surface->request_maximize); + roots_surface->request_fullscreen.notify = handle_request_fullscreen; + wl_signal_add(&surface->events.request_fullscreen, + &roots_surface->request_fullscreen); struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (view == NULL) { @@ -240,6 +260,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { view->move = move; view->move_resize = move_resize; view->maximize = maximize; + view->set_fullscreen = set_fullscreen; view->close = close; roots_surface->view = view; view_init(view, desktop); diff --git a/types/wlr_output.c b/types/wlr_output.c index 5a8baa3d..3ef91179 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -382,6 +382,10 @@ static void output_fullscreen_surface_handle_destroy( void wlr_output_set_fullscreen_surface(struct wlr_output *output, struct wlr_surface *surface) { // TODO: hardware fullscreen + if (output->fullscreen_surface == surface) { + return; + } + output_fullscreen_surface_reset(output); output->fullscreen_surface = surface; -- cgit v1.2.3 From abab2902f5051bcde93b34b5a57bf9bae93b3bab Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 19:45:10 +0100 Subject: Check for subsurfaces and popups before using wlr_output_set_fullscreen_surface --- include/rootston/desktop.h | 5 +++-- include/rootston/view.h | 2 +- rootston/desktop.c | 16 +++++++++++++--- rootston/output.c | 27 ++++++++++++++++++++++++++- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index c245eb09..8bf1f6eb 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -19,13 +19,14 @@ struct roots_output { struct wlr_output *wlr_output; struct wl_listener frame; struct timespec last_frame; - struct wl_list link; + struct wl_list link; // roots_desktop:outputs + struct roots_view *fullscreen_view; }; struct roots_desktop { struct wl_list views; // roots_view::link - struct wl_list outputs; + struct wl_list outputs; // roots_output::link struct timespec last_frame; struct roots_server *server; diff --git a/include/rootston/view.h b/include/rootston/view.h index 77bbfbec..44a98115 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -57,7 +57,7 @@ struct roots_view { float rotation; bool maximized; - struct wlr_output *fullscreen_output; + struct roots_output *fullscreen_output; struct { double x, y; uint32_t width, height; diff --git a/rootston/desktop.c b/rootston/desktop.c index be74b619..b48da44b 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -174,8 +174,14 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen, output_box->height); view->rotation = 0; - wlr_output_set_fullscreen_surface(output, view->wlr_surface); - view->fullscreen_output = output; + struct roots_output *roots_output; + wl_list_for_each(roots_output, &view->desktop->outputs, link) { + if (roots_output->wlr_output == output) { + roots_output->fullscreen_view = view; + view->fullscreen_output = roots_output; + break; + } + } } if (was_fullscreen && !fullscreen) { @@ -183,7 +189,7 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen, view->saved.height); view->rotation = view->saved.rotation; - wlr_output_set_fullscreen_surface(view->fullscreen_output, NULL); + view->fullscreen_output->fullscreen_view = NULL; view->fullscreen_output = NULL; } } @@ -236,6 +242,10 @@ bool view_center(struct roots_view *view) { void view_destroy(struct roots_view *view) { wl_signal_emit(&view->events.destroy, view); + if (view->fullscreen_output) { + view->fullscreen_output->fullscreen_view = NULL; + } + wl_list_remove(&view->link); free(view); } diff --git a/rootston/output.c b/rootston/output.c index 35a5dac3..82618b06 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -174,6 +174,22 @@ static void render_view(struct roots_view *view, struct roots_desktop *desktop, } } +static bool has_standalone_surface(struct roots_view *view) { + if (!wl_list_empty(&view->wlr_surface->subsurface_list)) { + wlr_log(L_DEBUG, "has subsurfaces"); + return false; + } + + switch (view->type) { + case ROOTS_XDG_SHELL_V6_VIEW: + return wl_list_empty(&view->xdg_surface_v6->popups); + case ROOTS_WL_SHELL_VIEW: + return wl_list_empty(&view->wl_shell_surface->popups); + case ROOTS_XWAYLAND_VIEW: + return true; + } +} + static void output_frame_notify(struct wl_listener *listener, void *data) { struct wlr_output *wlr_output = data; struct roots_output *output = wl_container_of(listener, output, frame); @@ -186,11 +202,20 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_output_make_current(wlr_output); wlr_renderer_begin(server->renderer, wlr_output); - if (wlr_output->fullscreen_surface != NULL) { + if (output->fullscreen_view != NULL) { + if (has_standalone_surface(output->fullscreen_view)) { + wlr_output_set_fullscreen_surface(wlr_output, + output->fullscreen_view->wlr_surface); + } else { + wlr_output_set_fullscreen_surface(wlr_output, NULL); + render_view(output->fullscreen_view, desktop, wlr_output, &now); + } wlr_renderer_end(server->renderer); wlr_output_swap_buffers(wlr_output); output->last_frame = desktop->last_frame = now; return; + } else { + wlr_output_set_fullscreen_surface(wlr_output, NULL); } struct roots_view *view; -- cgit v1.2.3 From bc68f269605ddd681b3ab968bdf80a72f3618982 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 19:52:47 +0100 Subject: Fix evince fullscreen under xwayland --- xwayland/xwm.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 36722591..cd0a98f5 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1345,18 +1345,16 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { } void wlr_xwayland_surface_set_maximized(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool maximized) { - if (xsurface_is_maximized(surface) != maximized) { - surface->maximized_horz = maximized; - surface->maximized_vert = maximized; - xsurface_set_net_wm_state(surface); - } + struct wlr_xwayland_surface *surface, bool maximized) { + surface->maximized_horz = maximized; + surface->maximized_vert = maximized; + xsurface_set_net_wm_state(surface); + xcb_flush(surface->xwm->xcb_conn); } void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool fullscreen) { - if (surface->fullscreen != fullscreen) { - surface->fullscreen = fullscreen; - xsurface_set_net_wm_state(surface); - } + struct wlr_xwayland_surface *surface, bool fullscreen) { + surface->fullscreen = fullscreen; + xsurface_set_net_wm_state(surface); + xcb_flush(surface->xwm->xcb_conn); } -- cgit v1.2.3 From 54f1135c057e76b1c05058592a6878a07a524b99 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 20:53:13 +0100 Subject: Fix fullscreen in xdg-shell --- include/wlr/types/wlr_surface.h | 8 ++++++-- rootston/output.c | 12 +----------- types/wlr_output.c | 39 +++++++++++++++++++-------------------- types/wlr_surface.c | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index cea53109..c8e3761a 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -1,9 +1,10 @@ #ifndef WLR_TYPES_WLR_SURFACE_H #define WLR_TYPES_WLR_SURFACE_H -#include -#include #include #include +#include +#include +#include #include struct wlr_frame_callback { @@ -142,4 +143,7 @@ void wlr_surface_send_enter(struct wlr_surface *surface, void wlr_surface_send_leave(struct wlr_surface *surface, struct wlr_output *output); +void wlr_surface_send_frame_done(struct wlr_surface *surface, + const struct timespec *when); + #endif diff --git a/rootston/output.c b/rootston/output.c index 82618b06..52db62f1 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -13,10 +13,6 @@ #include "rootston/desktop.h" #include "rootston/config.h" -static inline int64_t timespec_to_msec(const struct timespec *a) { - return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; -} - /** * Rotate a child's position relative to a parent. The parent size is (pw, ph), * the child position is (*sx, *sy) and its size is (sw, sh). @@ -75,12 +71,7 @@ static void render_surface(struct wlr_surface *surface, wlr_render_with_matrix(desktop->server->renderer, surface->texture, &matrix); - struct wlr_frame_callback *cb, *cnext; - wl_list_for_each_safe(cb, cnext, - &surface->current->frame_callback_list, link) { - wl_callback_send_done(cb->resource, timespec_to_msec(when)); - wl_resource_destroy(cb->resource); - } + wlr_surface_send_frame_done(surface, when); } struct wlr_subsurface *subsurface; @@ -176,7 +167,6 @@ static void render_view(struct roots_view *view, struct roots_desktop *desktop, static bool has_standalone_surface(struct roots_view *view) { if (!wl_list_empty(&view->wlr_surface->subsurface_list)) { - wlr_log(L_DEBUG, "has subsurfaces"); return false; } diff --git a/types/wlr_output.c b/types/wlr_output.c index 3ef91179..8accf7a5 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -253,7 +253,7 @@ void wlr_output_make_current(struct wlr_output *output) { } static void output_fullscreen_surface_render(struct wlr_output *output, - struct wlr_surface *surface) { + struct wlr_surface *surface, const struct timespec *when) { int x = (output->width - surface->current->width) / 2; int y = (output->height - surface->current->height) / 2; @@ -268,6 +268,8 @@ static void output_fullscreen_surface_render(struct wlr_output *output, wlr_texture_get_matrix(surface->texture, &matrix, &output->transform_matrix, x, y); wlr_render_with_matrix(surface->renderer, surface->texture, &matrix); + + wlr_surface_send_frame_done(surface, when); } static void output_cursor_get_box(struct wlr_output_cursor *cursor, @@ -278,7 +280,8 @@ static void output_cursor_get_box(struct wlr_output_cursor *cursor, box->height = cursor->height; } -static void output_cursor_render(struct wlr_output_cursor *cursor) { +static void output_cursor_render(struct wlr_output_cursor *cursor, + const struct timespec *when) { struct wlr_texture *texture = cursor->texture; struct wlr_renderer *renderer = cursor->renderer; if (cursor->surface != NULL) { @@ -321,13 +324,21 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) { wlr_texture_get_matrix(texture, &matrix, &cursor->output->transform_matrix, x, y); wlr_render_with_matrix(renderer, texture, &matrix); + + if (cursor->surface != NULL) { + wlr_surface_send_frame_done(cursor->surface, when); + } } void wlr_output_swap_buffers(struct wlr_output *output) { wl_signal_emit(&output->events.swap_buffers, &output); + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + if (output->fullscreen_surface != NULL) { - output_fullscreen_surface_render(output, output->fullscreen_surface); + output_fullscreen_surface_render(output, output->fullscreen_surface, + &now); } struct wlr_output_cursor *cursor; @@ -335,7 +346,7 @@ void wlr_output_swap_buffers(struct wlr_output *output) { if (!cursor->enabled || output->hardware_cursor == cursor) { continue; } - output_cursor_render(cursor); + output_cursor_render(cursor, &now); } output->impl->swap_buffers(output); @@ -472,30 +483,18 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor) { cursor->output->needs_swap = true; } else { // TODO: upload pixels - } -} -static inline int64_t timespec_to_msec(const struct timespec *a) { - return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + wlr_surface_send_frame_done(cursor->surface, &now); + } } static void output_cursor_handle_commit(struct wl_listener *listener, void *data) { struct wlr_output_cursor *cursor = wl_container_of(listener, cursor, surface_commit); - struct wlr_surface *surface = data; - output_cursor_commit(cursor); - - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - - struct wlr_frame_callback *cb, *cnext; - wl_list_for_each_safe(cb, cnext, &surface->current->frame_callback_list, - link) { - wl_callback_send_done(cb->resource, timespec_to_msec(&now)); - wl_resource_destroy(cb->resource); - } } static void output_cursor_handle_destroy(struct wl_listener *listener, diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 8cc2aa33..ad0c6f68 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -929,3 +929,17 @@ void wlr_surface_send_leave(struct wlr_surface *surface, } } } + +static inline int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} + +void wlr_surface_send_frame_done(struct wlr_surface *surface, + const struct timespec *when) { + struct wlr_frame_callback *cb, *cnext; + wl_list_for_each_safe(cb, cnext, &surface->current->frame_callback_list, + link) { + wl_callback_send_done(cb->resource, timespec_to_msec(when)); + wl_resource_destroy(cb->resource); + } +} -- cgit v1.2.3 From 5a8bbc62032ff1623cbee487bb15c3bb136094fc Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 20:54:54 +0100 Subject: Fix GCC build --- rootston/output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/rootston/output.c b/rootston/output.c index 52db62f1..d62c0b0d 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -178,6 +178,7 @@ static bool has_standalone_surface(struct roots_view *view) { case ROOTS_XWAYLAND_VIEW: return true; } + return true; } static void output_frame_notify(struct wl_listener *listener, void *data) { -- cgit v1.2.3 From a268f57ed5329e5b410267eb715e9ebeffa80e3f Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 21:05:05 +0100 Subject: Forgot a call to glClear --- types/wlr_output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/types/wlr_output.c b/types/wlr_output.c index 8accf7a5..41a3f794 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -259,6 +259,7 @@ static void output_fullscreen_surface_render(struct wlr_output *output, glViewport(0, 0, output->width, output->height); glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); if (!wlr_surface_has_buffer(surface)) { return; -- cgit v1.2.3 From 17d9e2ce3508d21ccdc9907b02d127b47a4a21bb Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 21 Nov 2017 09:50:00 +0100 Subject: Unify view events naming, remove client from event structs --- include/rootston/view.h | 4 +- include/wlr/types/wlr_wl_shell.h | 10 ++--- include/wlr/types/wlr_xdg_shell_v6.h | 7 +-- rootston/wl_shell.c | 30 ++++++------- types/wlr_wl_shell.c | 87 +++++++++++------------------------- types/wlr_xdg_shell_v6.c | 28 ++++-------- 6 files changed, 55 insertions(+), 111 deletions(-) diff --git a/include/rootston/view.h b/include/rootston/view.h index 44a98115..5901f0a5 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -12,8 +12,8 @@ struct roots_wl_shell_surface { struct wl_listener destroy; struct wl_listener request_move; struct wl_listener request_resize; - struct wl_listener request_set_maximized; - struct wl_listener request_set_fullscreen; + struct wl_listener request_maximize; + struct wl_listener request_fullscreen; struct wl_listener set_state; struct wl_listener surface_commit; diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 24936a34..ec087693 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -81,8 +81,8 @@ struct wlr_wl_shell_surface { struct wl_signal request_move; struct wl_signal request_resize; - struct wl_signal request_set_fullscreen; - struct wl_signal request_set_maximized; + struct wl_signal request_fullscreen; + struct wl_signal request_maximize; struct wl_signal set_state; struct wl_signal set_title; @@ -93,14 +93,12 @@ struct wlr_wl_shell_surface { }; struct wlr_wl_shell_surface_move_event { - struct wl_client *client; struct wlr_wl_shell_surface *surface; struct wlr_seat_client *seat; uint32_t serial; }; struct wlr_wl_shell_surface_resize_event { - struct wl_client *client; struct wlr_wl_shell_surface *surface; struct wlr_seat_client *seat; uint32_t serial; @@ -108,15 +106,13 @@ struct wlr_wl_shell_surface_resize_event { }; struct wlr_wl_shell_surface_set_fullscreen_event { - struct wl_client *client; struct wlr_wl_shell_surface *surface; enum wl_shell_surface_fullscreen_method method; uint32_t framerate; struct wlr_output *output; }; -struct wlr_wl_shell_surface_set_maximized_event { - struct wl_client *client; +struct wlr_wl_shell_surface_maximize_event { struct wlr_wl_shell_surface *surface; struct wlr_output *output; }; diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 7940deef..7e89ec74 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -138,14 +138,12 @@ struct wlr_xdg_surface_v6 { }; struct wlr_xdg_toplevel_v6_move_event { - struct wl_client *client; struct wlr_xdg_surface_v6 *surface; struct wlr_seat_client *seat; uint32_t serial; }; struct wlr_xdg_toplevel_v6_resize_event { - struct wl_client *client; struct wlr_xdg_surface_v6 *surface; struct wlr_seat_client *seat; uint32_t serial; @@ -153,19 +151,16 @@ struct wlr_xdg_toplevel_v6_resize_event { }; struct wlr_xdg_toplevel_v6_set_fullscreen_event { - struct wl_client *client; struct wlr_xdg_surface_v6 *surface; bool fullscreen; struct wlr_output *output; }; struct wlr_xdg_toplevel_v6_show_window_menu_event { - struct wl_client *client; struct wlr_xdg_surface_v6 *surface; struct wlr_seat_client *seat; uint32_t serial; - uint32_t x; - uint32_t y; + uint32_t x, y; }; struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display); diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index e69f2dd9..ce568355 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -50,23 +50,21 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { roots_seat_begin_resize(seat, view, e->edges); } -static void handle_request_set_maximized(struct wl_listener *listener, +static void handle_request_maximize(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = - wl_container_of(listener, roots_surface, request_set_maximized); + wl_container_of(listener, roots_surface, request_maximize); struct roots_view *view = roots_surface->view; - //struct wlr_wl_shell_surface_set_maximized_event *e = data; + //struct wlr_wl_shell_surface_maximize_event *e = data; view_maximize(view, true); } -static void handle_request_set_fullscreen(struct wl_listener *listener, +static void handle_request_fullscreen(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = - wl_container_of(listener, roots_surface, request_set_fullscreen); + wl_container_of(listener, roots_surface, request_fullscreen); struct roots_view *view = roots_surface->view; struct wlr_wl_shell_surface_set_fullscreen_event *e = data; - - // TODO: support e->method, e->framerate view_set_fullscreen(view, true, e->output); } @@ -95,8 +93,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&roots_surface->destroy.link); wl_list_remove(&roots_surface->request_move.link); wl_list_remove(&roots_surface->request_resize.link); - wl_list_remove(&roots_surface->request_set_maximized.link); - wl_list_remove(&roots_surface->request_set_fullscreen.link); + wl_list_remove(&roots_surface->request_maximize.link); + wl_list_remove(&roots_surface->request_fullscreen.link); wl_list_remove(&roots_surface->set_state.link); wl_list_remove(&roots_surface->surface_commit.link); wl_list_remove(&roots_surface->view->link); @@ -125,13 +123,13 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { roots_surface->request_resize.notify = handle_request_resize; wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize); - roots_surface->request_set_maximized.notify = handle_request_set_maximized; - wl_signal_add(&surface->events.request_set_maximized, - &roots_surface->request_set_maximized); - roots_surface->request_set_fullscreen.notify = - handle_request_set_fullscreen; - wl_signal_add(&surface->events.request_set_fullscreen, - &roots_surface->request_set_fullscreen); + roots_surface->request_maximize.notify = handle_request_maximize; + wl_signal_add(&surface->events.request_maximize, + &roots_surface->request_maximize); + roots_surface->request_fullscreen.notify = + handle_request_fullscreen; + wl_signal_add(&surface->events.request_fullscreen, + &roots_surface->request_fullscreen); roots_surface->set_state.notify = handle_set_state; wl_signal_add(&surface->events.set_state, &roots_surface->set_state); roots_surface->surface_commit.notify = handle_surface_commit; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index abe967d7..6174c872 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -108,25 +108,17 @@ static void shell_surface_protocol_pong(struct wl_client *client, static void shell_surface_protocol_move(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial) { - wlr_log(L_DEBUG, "got shell surface move"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_seat_client *seat = wl_resource_get_user_data(seat_resource); - struct wlr_wl_shell_surface_move_event *event = - calloc(1, sizeof(struct wlr_wl_shell_surface_move_event)); - if (event == NULL) { - wl_client_post_no_memory(client); - return; - } - event->client = client; - event->surface = surface; - event->seat = seat; - event->serial = serial; + struct wlr_wl_shell_surface_move_event event = { + .surface = surface, + .seat = seat, + .serial = serial, + }; - wl_signal_emit(&surface->events.request_move, event); - - free(event); + wl_signal_emit(&surface->events.request_move, &event); } static struct wlr_wl_shell_popup_grab *shell_popup_grab_from_seat( @@ -174,26 +166,18 @@ static void shell_surface_destroy_popup_state( static void shell_surface_protocol_resize(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial, enum wl_shell_surface_resize edges) { - wlr_log(L_DEBUG, "got shell surface resize"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_seat_client *seat = wl_resource_get_user_data(seat_resource); - struct wlr_wl_shell_surface_resize_event *event = - calloc(1, sizeof(struct wlr_wl_shell_surface_resize_event)); - if (event == NULL) { - wl_client_post_no_memory(client); - return; - } - event->client = client; - event->surface = surface; - event->seat = seat; - event->serial = serial; - event->edges = edges; + struct wlr_wl_shell_surface_resize_event event = { + .surface = surface, + .seat = seat, + .serial = serial, + .edges = edges, + }; - wl_signal_emit(&surface->events.request_resize, event); - - free(event); + wl_signal_emit(&surface->events.request_resize, &event); } static void shell_surface_set_state(struct wlr_wl_shell_surface *surface, @@ -279,7 +263,6 @@ static void shell_surface_protocol_set_fullscreen(struct wl_client *client, struct wl_resource *resource, enum wl_shell_surface_fullscreen_method method, uint32_t framerate, struct wl_resource *output_resource) { - wlr_log(L_DEBUG, "got shell surface fullscreen"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_output *output = NULL; if (output_resource != NULL) { @@ -289,24 +272,16 @@ static void shell_surface_protocol_set_fullscreen(struct wl_client *client, shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN, NULL, NULL); - struct wlr_wl_shell_surface_set_fullscreen_event *event = - calloc(1, sizeof(struct wlr_wl_shell_surface_set_fullscreen_event)); - if (event == NULL) { - wl_client_post_no_memory(client); - return; - } - event->client = client; - event->surface = surface; - event->method = method; - event->framerate = framerate; - event->output = output; + struct wlr_wl_shell_surface_set_fullscreen_event event = { + .surface = surface, + .method = method, + .framerate = framerate, + .output = output, + }; - wl_signal_emit(&surface->events.request_set_fullscreen, event); - - free(event); + wl_signal_emit(&surface->events.request_fullscreen, &event); } - static void shell_surface_protocol_set_popup(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial, struct wl_resource *parent_resource, int32_t x, @@ -368,7 +343,6 @@ static void shell_surface_protocol_set_popup(struct wl_client *client, static void shell_surface_protocol_set_maximized(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource) { - wlr_log(L_DEBUG, "got shell surface maximized"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_output *output = NULL; if (output_resource != NULL) { @@ -378,19 +352,12 @@ static void shell_surface_protocol_set_maximized(struct wl_client *client, shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED, NULL, NULL); - struct wlr_wl_shell_surface_set_maximized_event *event = - calloc(1, sizeof(struct wlr_wl_shell_surface_set_maximized_event)); - if (event == NULL) { - wl_client_post_no_memory(client); - return; - } - event->client = client; - event->surface = surface; - event->output = output; - - wl_signal_emit(&surface->events.request_set_maximized, event); + struct wlr_wl_shell_surface_maximize_event event = { + .surface = surface, + .output = output, + }; - free(event); + wl_signal_emit(&surface->events.request_maximize, &event); } static void shell_surface_protocol_set_title(struct wl_client *client, @@ -545,8 +512,8 @@ static void shell_protocol_get_shell_surface(struct wl_client *client, wl_signal_init(&wl_surface->events.ping_timeout); wl_signal_init(&wl_surface->events.request_move); wl_signal_init(&wl_surface->events.request_resize); - wl_signal_init(&wl_surface->events.request_set_fullscreen); - wl_signal_init(&wl_surface->events.request_set_maximized); + wl_signal_init(&wl_surface->events.request_fullscreen); + wl_signal_init(&wl_surface->events.request_maximize); wl_signal_init(&wl_surface->events.set_state); wl_signal_init(&wl_surface->events.set_title); wl_signal_init(&wl_surface->events.set_class); diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 896a5f33..b69f713e 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -564,23 +564,15 @@ static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client, return; } - struct wlr_xdg_toplevel_v6_show_window_menu_event *event = - calloc(1, sizeof(struct wlr_xdg_toplevel_v6_show_window_menu_event)); - if (event == NULL) { - wl_client_post_no_memory(client); - return; - } - - event->client = client; - event->surface = surface; - event->seat = seat; - event->serial = serial; - event->x = x; - event->y = y; - - wl_signal_emit(&surface->events.request_show_window_menu, event); + struct wlr_xdg_toplevel_v6_show_window_menu_event event = { + .surface = surface, + .seat = seat, + .serial = serial, + .x = x, + .y = y, + }; - free(event); + wl_signal_emit(&surface->events.request_show_window_menu, &event); } static void xdg_toplevel_protocol_move(struct wl_client *client, @@ -598,7 +590,6 @@ static void xdg_toplevel_protocol_move(struct wl_client *client, } struct wlr_xdg_toplevel_v6_move_event event = { - .client = client, .surface = surface, .seat = seat, .serial = serial, @@ -622,7 +613,6 @@ static void xdg_toplevel_protocol_resize(struct wl_client *client, } struct wlr_xdg_toplevel_v6_resize_event event = { - .client = client, .surface = surface, .seat = seat, .serial = serial, @@ -672,7 +662,6 @@ static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client, surface->toplevel_state->next.fullscreen = true; struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { - .client = client, .surface = surface, .fullscreen = true, .output = output, @@ -688,7 +677,6 @@ static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client, surface->toplevel_state->next.fullscreen = false; struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { - .client = client, .surface = surface, .fullscreen = false, .output = NULL, -- cgit v1.2.3 From 9e29621ec32f6142f482780c764e6e93af31b806 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 21 Nov 2017 10:14:50 +0100 Subject: Always center fullscreen view on screen --- rootston/desktop.c | 5 +++++ rootston/output.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/rootston/desktop.c b/rootston/desktop.c index 7a780cb9..0eb63dc4 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -53,6 +53,10 @@ static void view_update_output(const struct roots_view *view, } void view_move(struct roots_view *view, double x, double y) { + if (view->x == x && view->y == y) { + return; + } + struct wlr_box before; view_get_box(view, &before); if (view->move) { @@ -61,6 +65,7 @@ void view_move(struct roots_view *view, double x, double y) { view->x = x; view->y = y; } + view_update_output(view, &before); } void view_activate(struct roots_view *view, bool activate) { diff --git a/rootston/output.c b/rootston/output.c index d62c0b0d..bf684f2f 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -194,11 +195,26 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_renderer_begin(server->renderer, wlr_output); if (output->fullscreen_view != NULL) { + // Make sure the view is centered on screen + const struct wlr_box *output_box = + wlr_output_layout_get_box(desktop->layout, wlr_output); + struct wlr_box view_box; + view_get_box(output->fullscreen_view, &view_box); + double view_x = (double)(output_box->width - view_box.width) / 2 + + output_box->x; + double view_y = (double)(output_box->height - view_box.height) / 2 + + output_box->y; + view_move(output->fullscreen_view, view_x, view_y); + if (has_standalone_surface(output->fullscreen_view)) { wlr_output_set_fullscreen_surface(wlr_output, output->fullscreen_view->wlr_surface); } else { wlr_output_set_fullscreen_surface(wlr_output, NULL); + + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + render_view(output->fullscreen_view, desktop, wlr_output, &now); } wlr_renderer_end(server->renderer); -- cgit v1.2.3 From 9a6f799d8f72c1dcd24e22749d43eb2ed54681c6 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 21 Nov 2017 10:37:53 +0100 Subject: Add fullscreen command, fix view_at with fullscreen views --- include/rootston/desktop.h | 6 +- rootston/cursor.c | 9 ++- rootston/desktop.c | 183 ++++++++++++++++++++++++++------------------- rootston/keyboard.c | 6 ++ 4 files changed, 122 insertions(+), 82 deletions(-) diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 8bf1f6eb..e5c5f806 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -60,11 +60,13 @@ struct roots_server; struct roots_desktop *desktop_create(struct roots_server *server, struct roots_config *config); void desktop_destroy(struct roots_desktop *desktop); +struct roots_output *desktop_output_from_wlr_output( + struct roots_desktop *desktop, struct wlr_output *output); +struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx, + double ly, struct wlr_surface **surface, double *sx, double *sy); void view_init(struct roots_view *view, struct roots_desktop *desktop); void view_destroy(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); void view_activate(struct roots_view *view, bool activate); void output_add_notify(struct wl_listener *listener, void *data); diff --git a/rootston/cursor.c b/rootston/cursor.c index 71075aa9..b3c87b30 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -37,7 +37,7 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, double sx, sy; switch (cursor->mode) { case ROOTS_CURSOR_PASSTHROUGH: - view = view_at(desktop, cursor->cursor->x, cursor->cursor->y, + view = desktop_view_at(desktop, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); bool set_compositor_cursor = !view && cursor->cursor_client; if (view) { @@ -137,7 +137,8 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, struct wlr_surface *surface; double sx, sy; - struct roots_view *view = view_at(desktop, lx, ly, &surface, &sx, &sy); + struct roots_view *view = + desktop_view_at(desktop, lx, ly, &surface, &sx, &sy); if (state == WLR_BUTTON_PRESSED && view && @@ -237,7 +238,7 @@ void roots_cursor_handle_touch_down(struct roots_cursor *cursor, return; } double sx, sy; - view_at(desktop, lx, ly, &surface, &sx, &sy); + desktop_view_at(desktop, lx, ly, &surface, &sx, &sy); uint32_t serial = 0; if (surface) { @@ -291,7 +292,7 @@ void roots_cursor_handle_touch_motion(struct roots_cursor *cursor, } double sx, sy; - view_at(desktop, lx, ly, &surface, &sx, &sy); + desktop_view_at(desktop, lx, ly, &surface, &sx, &sy); if (surface) { wlr_seat_touch_point_focus(cursor->seat->seat, surface, diff --git a/rootston/desktop.c b/rootston/desktop.c index 0eb63dc4..1a21a7c2 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -163,6 +163,11 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen, if (output == NULL) { output = view_get_output(view); } + struct roots_output *roots_output = + desktop_output_from_wlr_output(view->desktop, output); + if (roots_output == NULL) { + return; + } struct wlr_box view_box; view_get_box(view, &view_box); @@ -179,14 +184,8 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen, output_box->height); view->rotation = 0; - struct roots_output *roots_output; - wl_list_for_each(roots_output, &view->desktop->outputs, link) { - if (roots_output->wlr_output == output) { - roots_output->fullscreen_view = view; - view->fullscreen_output = roots_output; - break; - } - } + roots_output->fullscreen_view = view; + view->fullscreen_output = roots_output; } if (was_fullscreen && !fullscreen) { @@ -273,83 +272,104 @@ void view_setup(struct roots_view *view) { view_update_output(view, &before); } -struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, +static bool view_at(struct roots_view *view, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { - struct roots_view *view; - wl_list_for_each(view, &desktop->views, link) { - if (view->type == ROOTS_WL_SHELL_VIEW && - view->wl_shell_surface->state == - WLR_WL_SHELL_SURFACE_STATE_POPUP) { - continue; - } + if (view->type == ROOTS_WL_SHELL_VIEW && + view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) { + return false; + } - 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 = state->buffer_width / state->scale, - .height = state->buffer_height / state->scale, - }; - if (view->rotation != 0.0) { - // Coordinates relative to the center of the view - double ox = view_sx - (double)box.width/2, - oy = view_sy - (double)box.height/2; - // Rotated coordinates - double rx = cos(view->rotation)*ox - sin(view->rotation)*oy, - ry = cos(view->rotation)*oy + sin(view->rotation)*ox; - view_sx = rx + (double)box.width/2; - view_sy = ry + (double)box.height/2; - } + 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 = state->buffer_width / state->scale, + .height = state->buffer_height / state->scale, + }; + if (view->rotation != 0.0) { + // Coordinates relative to the center of the view + double ox = view_sx - (double)box.width/2, + oy = view_sy - (double)box.height/2; + // Rotated coordinates + double rx = cos(view->rotation)*ox - sin(view->rotation)*oy, + ry = cos(view->rotation)*oy + sin(view->rotation)*ox; + view_sx = rx + (double)box.width/2; + view_sy = ry + (double)box.height/2; + } - if (view->type == ROOTS_XDG_SHELL_V6_VIEW) { - double popup_sx, popup_sy; - struct wlr_xdg_surface_v6 *popup = - wlr_xdg_surface_v6_popup_at(view->xdg_surface_v6, - view_sx, view_sy, &popup_sx, &popup_sy); - - if (popup) { - *sx = view_sx - popup_sx; - *sy = view_sy - popup_sy; - *surface = popup->surface; - return view; - } + if (view->type == ROOTS_XDG_SHELL_V6_VIEW) { + double popup_sx, popup_sy; + struct wlr_xdg_surface_v6 *popup = + wlr_xdg_surface_v6_popup_at(view->xdg_surface_v6, + view_sx, view_sy, &popup_sx, &popup_sy); + + if (popup) { + *sx = view_sx - popup_sx; + *sy = view_sy - popup_sy; + *surface = popup->surface; + return true; } + } - if (view->type == ROOTS_WL_SHELL_VIEW) { - double popup_sx, popup_sy; - struct wlr_wl_shell_surface *popup = - wlr_wl_shell_surface_popup_at(view->wl_shell_surface, - view_sx, view_sy, &popup_sx, &popup_sy); - - if (popup) { - *sx = view_sx - popup_sx; - *sy = view_sy - popup_sy; - *surface = popup->surface; - return view; - } + if (view->type == ROOTS_WL_SHELL_VIEW) { + double popup_sx, popup_sy; + struct wlr_wl_shell_surface *popup = + wlr_wl_shell_surface_popup_at(view->wl_shell_surface, + view_sx, view_sy, &popup_sx, &popup_sy); + + if (popup) { + *sx = view_sx - popup_sx; + *sy = view_sy - popup_sy; + *surface = popup->surface; + return true; } + } - double sub_x, sub_y; - struct wlr_subsurface *subsurface = - wlr_surface_subsurface_at(view->wlr_surface, - view_sx, view_sy, &sub_x, &sub_y); - if (subsurface) { - *sx = view_sx - sub_x; - *sy = view_sy - sub_y; - *surface = subsurface->surface; - return view; + double sub_x, sub_y; + struct wlr_subsurface *subsurface = + wlr_surface_subsurface_at(view->wlr_surface, + view_sx, view_sy, &sub_x, &sub_y); + if (subsurface) { + *sx = view_sx - sub_x; + *sy = view_sy - sub_y; + *surface = subsurface->surface; + return true; + } + + if (wlr_box_contains_point(&box, view_sx, view_sy) && + pixman_region32_contains_point(&view->wlr_surface->current->input, + view_sx, view_sy, NULL)) { + *sx = view_sx; + *sy = view_sy; + *surface = view->wlr_surface; + return true; + } + + return false; +} + +struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx, + double ly, struct wlr_surface **surface, double *sx, double *sy) { + struct wlr_output *wlr_output = + wlr_output_layout_output_at(desktop->layout, lx, ly); + if (wlr_output != NULL) { + struct roots_output *output = + desktop_output_from_wlr_output(desktop, wlr_output); + if (output != NULL && output->fullscreen_view != NULL) { + if (view_at(output->fullscreen_view, lx, ly, surface, sx, sy)) { + return output->fullscreen_view; + } else { + return NULL; + } } + } - if (wlr_box_contains_point(&box, view_sx, view_sy) && - pixman_region32_contains_point( - &view->wlr_surface->current->input, - view_sx, view_sy, NULL)) { - *sx = view_sx; - *sy = view_sy; - *surface = view->wlr_surface; + struct roots_view *view; + wl_list_for_each(view, &desktop->views, link) { + if (view_at(view, lx, ly, surface, sx, sy)) { return view; } } @@ -445,3 +465,14 @@ struct roots_desktop *desktop_create(struct roots_server *server, void desktop_destroy(struct roots_desktop *desktop) { // TODO } + +struct roots_output *desktop_output_from_wlr_output( + struct roots_desktop *desktop, struct wlr_output *output) { + struct roots_output *roots_output; + wl_list_for_each(roots_output, &desktop->outputs, link) { + if (roots_output->wlr_output == output) { + return roots_output; + } + } + return NULL; +} diff --git a/rootston/keyboard.c b/rootston/keyboard.c index f3fc9a85..6ad99077 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -95,6 +95,12 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard, if (focus != NULL) { view_close(focus); } + } else if (strcmp(command, "fullscreen") == 0) { + struct roots_view *focus = roots_seat_get_focus(seat); + if (focus != NULL) { + bool is_fullscreen = focus->fullscreen_output != NULL; + view_set_fullscreen(focus, !is_fullscreen, NULL); + } } else if (strcmp(command, "next_window") == 0) { roots_seat_cycle_focus(seat); } else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) { -- cgit v1.2.3 From 5a664e1e46df78c10977a4a9ee0bc53e5acf3772 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 21 Nov 2017 18:43:22 +0100 Subject: Fix messed up outputs after fullscreen --- types/wlr_output.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/wlr_output.c b/types/wlr_output.c index bc89c97a..2ee95162 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -379,7 +379,7 @@ static void output_fullscreen_surface_reset(struct wlr_output *output) { static void output_fullscreen_surface_handle_commit( struct wl_listener *listener, void *data) { struct wlr_output *output = wl_container_of(listener, output, - fullscreen_surface_destroy); + fullscreen_surface_commit); output->needs_swap = true; } @@ -393,6 +393,7 @@ static void output_fullscreen_surface_handle_destroy( void wlr_output_set_fullscreen_surface(struct wlr_output *output, struct wlr_surface *surface) { // TODO: hardware fullscreen + if (output->fullscreen_surface == surface) { return; } -- cgit v1.2.3 From 3262661e1e77db11d7e4939aa377804046df43f5 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 21 Nov 2017 20:58:15 +0100 Subject: Fix HiDPI support --- rootston/desktop.c | 6 ++---- types/wlr_output.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/rootston/desktop.c b/rootston/desktop.c index eb18e716..bb3af258 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -36,7 +36,7 @@ static void view_update_output(const struct roots_view *view, struct wlr_box box; view_get_box(view, &box); wl_list_for_each(output, &desktop->outputs, link) { - bool intersected = before->x != -1 && wlr_output_layout_intersects( + bool intersected = before != NULL && wlr_output_layout_intersects( desktop->layout, output->wlr_output, before->x, before->y, before->x + before->width, before->y + before->height); @@ -280,9 +280,7 @@ void view_setup(struct roots_view *view) { } view_center(view); - struct wlr_box before; - view_get_box(view, &before); - view_update_output(view, &before); + view_update_output(view, NULL); } static bool view_at(struct roots_view *view, double lx, double ly, diff --git a/types/wlr_output.c b/types/wlr_output.c index 2ee95162..3f0e1c21 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -253,8 +253,8 @@ void wlr_output_make_current(struct wlr_output *output) { static void output_fullscreen_surface_render(struct wlr_output *output, struct wlr_surface *surface, const struct timespec *when) { - int x = (output->width - surface->current->width) / 2; - int y = (output->height - surface->current->height) / 2; + int x = (output->width - surface->current->buffer_width) / 2; + int y = (output->height - surface->current->buffer_height) / 2; glViewport(0, 0, output->width, output->height); glClearColor(0, 0, 0, 0); -- cgit v1.2.3 From cc2468923b134cdf6d980b2930cd80f0d15e96e3 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 21 Nov 2017 21:12:12 +0100 Subject: Fix non-HiDPI-aware fullscreen surface rendering in wlr_output --- types/wlr_output.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/types/wlr_output.c b/types/wlr_output.c index 3f0e1c21..1d98d376 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -253,8 +253,16 @@ void wlr_output_make_current(struct wlr_output *output) { static void output_fullscreen_surface_render(struct wlr_output *output, struct wlr_surface *surface, const struct timespec *when) { - int x = (output->width - surface->current->buffer_width) / 2; - int y = (output->height - surface->current->buffer_height) / 2; + int width, height; + wlr_output_effective_resolution(output, &width, &height); + + int x = (width - surface->current->width) / 2; + int y = (height - surface->current->height) / 2; + + int render_x = x * output->scale; + int render_y = y * output->scale; + int render_width = surface->current->width * output->scale; + int render_height = surface->current->height * output->scale; glViewport(0, 0, output->width, output->height); glClearColor(0, 0, 0, 0); @@ -264,9 +272,16 @@ static void output_fullscreen_surface_render(struct wlr_output *output, return; } + float translate[16]; + wlr_matrix_translate(&translate, render_x, render_y, 0); + + float scale[16]; + wlr_matrix_scale(&scale, render_width, render_height, 1); + float matrix[16]; - wlr_texture_get_matrix(surface->texture, &matrix, &output->transform_matrix, - x, y); + wlr_matrix_mul(&translate, &scale, &matrix); + wlr_matrix_mul(&output->transform_matrix, &matrix, &matrix); + wlr_render_with_matrix(surface->renderer, surface->texture, &matrix); wlr_surface_send_frame_done(surface, when); -- cgit v1.2.3 From 87258c718cfe82187e62f38951d28fc955f5e3a9 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Nov 2017 12:05:44 +1300 Subject: Add minimum meson version --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 8ace085c..addea930 100644 --- a/meson.build +++ b/meson.build @@ -2,6 +2,7 @@ project( 'wlroots', 'c', license: 'MIT', + meson_version: '>=0.43.0', default_options: [ 'c_std=c11', 'warning_level=2', -- cgit v1.2.3 From 02374b945d26b094ba7cd771841f967c7b83c956 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Nov 2017 14:04:29 +1300 Subject: Change glapi.sh to generate both files --- glgen.sh | 72 ++++++++++++++++++++++++------------------------------ render/meson.build | 17 +++++-------- 2 files changed, 38 insertions(+), 51 deletions(-) diff --git a/glgen.sh b/glgen.sh index 75d93c3b..5cb23225 100755 --- a/glgen.sh +++ b/glgen.sh @@ -7,15 +7,16 @@ # to fail if it can't load the function. You'll need to check if that function # is NULL before using it. -if [ $# -ne 2 ]; then +if [ $# -ne 3 ]; then exit 1 fi SPEC=$1 -OUT=$2 +OUT_C=$2 +OUT_H=$3 BASE=$(basename "$SPEC" .txt) -INCLUDE_GUARD=$(printf %s "$SPEC" | tr -c [:alnum:] _ | tr [:lower:] [:upper:]) +INCLUDE_GUARD=$(printf %s "$OUT_H" | tr -c [:alnum:] _ | tr [:lower:] [:upper:]) DECL="" DEFN="" @@ -57,46 +58,37 @@ while read -r COMMAND; do fi done < $SPEC +cat > $OUT_H << EOF +#ifndef $INCLUDE_GUARD +#define $INCLUDE_GUARD -case $OUT in -*.h) - cat > $OUT << EOF - #ifndef $INCLUDE_GUARD - #define $INCLUDE_GUARD +#include - #include +#include +#include +#include +#include +#include - #include - #include - #include - #include - #include +bool load_$BASE(void); +$DECL - bool load_$BASE(void); - $DECL - - #endif +#endif EOF - ;; -*.c) - cat > $OUT << EOF - #include - #include "$BASE.h" - $DEFN - - bool load_$BASE(void) { - static bool done = false; - if (done) { - return true; - } - $LOADER - - done = true; - return true; - } + +cat > $OUT_C << EOF +#include +#include "$OUT_H" +$DEFN + +bool load_$BASE(void) { + static bool done = false; + if (done) { + return true; + } +$LOADER + + done = true; + return true; +} EOF - ;; -*) - exit 1 - ;; -esac diff --git a/render/meson.build b/render/meson.build index 749d1393..1eea9a83 100644 --- a/render/meson.build +++ b/render/meson.build @@ -1,14 +1,9 @@ glgen = find_program('../glgen.sh') -glapi_c = custom_target('glapi.c', +glapi = custom_target('glapi', input: 'glapi.txt', - output: '@BASENAME@.c', - command: [glgen, '@INPUT@', '@OUTPUT@'], -) -glapi_h = custom_target('glapi.h', - input: 'glapi.txt', - output: '@BASENAME@.h', - command: [glgen, '@INPUT@', '@OUTPUT@'], + output: ['@BASENAME@.c', '@BASENAME@.h'], + command: [glgen, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@'], ) lib_wlr_render = static_library( @@ -24,13 +19,13 @@ lib_wlr_render = static_library( 'wlr_renderer.c', 'wlr_texture.c', ), - glapi_c, - glapi_h, + glapi[0], + glapi[1], include_directories: wlr_inc, dependencies: [glesv2, egl], ) wlr_render = declare_dependency( link_with: lib_wlr_render, - sources: glapi_h, + sources: glapi[1], ) -- cgit v1.2.3 From 71aa634ac501389b5c0c02fa0fed2ea08ca9f350 Mon Sep 17 00:00:00 2001 From: Greg V Date: Wed, 22 Nov 2017 15:17:10 +0300 Subject: Fix Xwayland second socket path on non-Linux systems It was creating two sockets with the same path --- xwayland/sockets.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xwayland/sockets.c b/xwayland/sockets.c index dd732dd7..1bddd20f 100644 --- a/xwayland/sockets.c +++ b/xwayland/sockets.c @@ -21,6 +21,7 @@ static const char *lock_fmt = "/tmp/.X%d-lock"; static const char *socket_dir = "/tmp/.X11-unix"; static const char *socket_fmt = "/tmp/.X11-unix/X%d"; +static const char *socket_fmt2 = "/tmp/.X11-unix/X%d_"; static int open_socket(struct sockaddr_un *addr, size_t path_size) { int fd, rc; @@ -73,7 +74,7 @@ static bool open_sockets(int socks[2], int display) { addr.sun_path[0] = 0; path_size = snprintf(addr.sun_path + 1, sizeof(addr.sun_path) - 1, socket_fmt, display); #else - path_size = snprintf(addr.sun_path, sizeof(addr.sun_path), socket_fmt, display); + path_size = snprintf(addr.sun_path, sizeof(addr.sun_path), socket_fmt2, display); #endif socks[0] = open_socket(&addr, path_size); if (socks[0] < 0) { @@ -97,6 +98,11 @@ void unlink_display_sockets(int display) { snprintf(sun_path, sizeof(sun_path), socket_fmt, display); unlink(sun_path); +#ifndef __linux__ + snprintf(sun_path, sizeof(sun_path), socket_fmt2, display); + unlink(sun_path); +#endif + snprintf(sun_path, sizeof(sun_path), lock_fmt, display); unlink(sun_path); } -- cgit v1.2.3 From 1ae944c07189b54d5d7458a2d0efaa39fbbac457 Mon Sep 17 00:00:00 2001 From: Greg V Date: Wed, 22 Nov 2017 15:57:05 +0300 Subject: Use SIGUSR2 for vt switching instead of SIGUSR1 Xwayland uses SIGUSR1 to signal readiness. With direct(-freebsd) session and Xwayland, wlroots was confusing the Xwayland readiness signal with a vt switch signal, freezing the desktop. Same problem was found in Weston in 2014: https://phabricator.freedesktop.org/T7080 --- backend/session/direct-freebsd.c | 6 +++--- backend/session/direct.c | 6 +++--- xwayland/sockets.c | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/session/direct-freebsd.c b/backend/session/direct-freebsd.c index fc4bab04..c0621416 100644 --- a/backend/session/direct-freebsd.c +++ b/backend/session/direct-freebsd.c @@ -148,8 +148,8 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display struct vt_mode mode = { .mode = VT_PROCESS, - .relsig = SIGUSR1, - .acqsig = SIGUSR1, + .relsig = SIGUSR2, + .acqsig = SIGUSR2, .frsig = SIGIO, // has to be set }; @@ -159,7 +159,7 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display } struct wl_event_loop *loop = wl_display_get_event_loop(display); - session->vt_source = wl_event_loop_add_signal(loop, SIGUSR1, + session->vt_source = wl_event_loop_add_signal(loop, SIGUSR2, vt_handler, session); if (!session->vt_source) { goto error; diff --git a/backend/session/direct.c b/backend/session/direct.c index 942dc552..9d6cd36d 100644 --- a/backend/session/direct.c +++ b/backend/session/direct.c @@ -184,8 +184,8 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display struct vt_mode mode = { .mode = VT_PROCESS, - .relsig = SIGUSR1, - .acqsig = SIGUSR1, + .relsig = SIGUSR2, + .acqsig = SIGUSR2, }; if (ioctl(fd, VT_SETMODE, &mode) < 0) { @@ -194,7 +194,7 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display } struct wl_event_loop *loop = wl_display_get_event_loop(display); - session->vt_source = wl_event_loop_add_signal(loop, SIGUSR1, + session->vt_source = wl_event_loop_add_signal(loop, SIGUSR2, vt_handler, session); if (!session->vt_source) { goto error; diff --git a/xwayland/sockets.c b/xwayland/sockets.c index 1bddd20f..2119056d 100644 --- a/xwayland/sockets.c +++ b/xwayland/sockets.c @@ -21,7 +21,9 @@ static const char *lock_fmt = "/tmp/.X%d-lock"; static const char *socket_dir = "/tmp/.X11-unix"; static const char *socket_fmt = "/tmp/.X11-unix/X%d"; +#ifndef __linux__ static const char *socket_fmt2 = "/tmp/.X11-unix/X%d_"; +#endif static int open_socket(struct sockaddr_un *addr, size_t path_size) { int fd, rc; -- cgit v1.2.3 From 903ba1c9b327e245b58c6e8d0277685e2fdcc745 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 22 Nov 2017 15:33:17 -0500 Subject: rootston: maximize command --- rootston/keyboard.c | 5 +++++ rootston/rootston.ini.example | 1 + 2 files changed, 6 insertions(+) diff --git a/rootston/keyboard.c b/rootston/keyboard.c index f3fc9a85..0b7afcb3 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -106,6 +106,11 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard, } else if (pid == 0) { execl("/bin/sh", "/bin/sh", "-c", shell_cmd, (void *)NULL); } + } else if (strcmp(command, "maximize") == 0) { + struct roots_view *focus = roots_seat_get_focus(seat); + if (focus != NULL) { + view_maximize(focus, !focus->maximized); + } } else { wlr_log(L_ERROR, "unknown binding command: %s", command); } diff --git a/rootston/rootston.ini.example b/rootston/rootston.ini.example index 17467100..a2fabb6b 100644 --- a/rootston/rootston.ini.example +++ b/rootston/rootston.ini.example @@ -44,4 +44,5 @@ meta-key = Logo [bindings] Logo+Shift+e = exit Logo+q = close +Logo+m = maximize Alt+Tab = next_window -- cgit v1.2.3 From f2b225ad0b6c0d118fa98b9c9691ab7729e37326 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 25 Nov 2017 15:27:41 -0500 Subject: Add xdg_shell ack_configure event --- include/wlr/types/wlr_xdg_shell_v6.h | 1 + types/wlr_xdg_shell_v6.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 6ac84cef..1d881791 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -126,6 +126,7 @@ struct wlr_xdg_surface_v6 { struct wl_signal commit; struct wl_signal destroy; struct wl_signal ping_timeout; + struct wl_signal ack_configure; struct wl_signal request_maximize; struct wl_signal request_fullscreen; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 8bb48a24..20cb0bc6 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -813,8 +813,9 @@ static void xdg_surface_ack_configure(struct wl_client *client, surface->configured = true; surface->configure_serial = serial; - free(configure); + + wl_signal_emit(&surface->events.ack_configure, surface); } static void xdg_surface_set_window_geometry(struct wl_client *client, @@ -1154,6 +1155,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.ping_timeout); + wl_signal_init(&surface->events.ack_configure); wl_signal_add(&surface->surface->events.destroy, &surface->surface_destroy_listener); -- cgit v1.2.3 From d361cda3b637360951146624fd06fc7d43df3da3 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 25 Nov 2017 17:13:24 -0500 Subject: Revert "Add xdg_shell ack_configure event" This reverts commit f2b225ad0b6c0d118fa98b9c9691ab7729e37326. --- include/wlr/types/wlr_xdg_shell_v6.h | 1 - types/wlr_xdg_shell_v6.c | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 1d881791..6ac84cef 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -126,7 +126,6 @@ struct wlr_xdg_surface_v6 { struct wl_signal commit; struct wl_signal destroy; struct wl_signal ping_timeout; - struct wl_signal ack_configure; struct wl_signal request_maximize; struct wl_signal request_fullscreen; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 20cb0bc6..8bb48a24 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -813,9 +813,8 @@ static void xdg_surface_ack_configure(struct wl_client *client, surface->configured = true; surface->configure_serial = serial; - free(configure); - wl_signal_emit(&surface->events.ack_configure, surface); + free(configure); } static void xdg_surface_set_window_geometry(struct wl_client *client, @@ -1155,7 +1154,6 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.ping_timeout); - wl_signal_init(&surface->events.ack_configure); wl_signal_add(&surface->surface->events.destroy, &surface->surface_destroy_listener); -- cgit v1.2.3 From 87ea76e0374ddf23975ed5e57f01ad0ef69d0ab2 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 27 Nov 2017 12:15:38 +1300 Subject: Remove unneeded linux include --- backend/wayland/os-compatibility.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/wayland/os-compatibility.c b/backend/wayland/os-compatibility.c index 14125793..cbd7988d 100644 --- a/backend/wayland/os-compatibility.c +++ b/backend/wayland/os-compatibility.c @@ -29,9 +29,6 @@ #include #include #include -#ifdef __linux__ -#include -#endif #include #include -- cgit v1.2.3 From 0781f6e483c0dd40996d8fcb541b04991b144e48 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 29 Nov 2017 00:26:55 +0100 Subject: Fix initial hardware cursor position --- types/wlr_output.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/wlr_output.c b/types/wlr_output.c index 94fe4c3b..56a2a7df 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -356,6 +356,10 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, if (cursor->output->hardware_cursor == NULL && cursor->output->impl->set_cursor) { + if (cursor->output->impl->move_cursor) { + cursor->output->impl->move_cursor(cursor->output, + (int)cursor->x, (int)cursor->y); + } int ok = cursor->output->impl->set_cursor(cursor->output, pixels, stride, width, height, hotspot_x, hotspot_y, true); if (ok) { -- cgit v1.2.3 From bc113c16aab5fed2a937ddb8b2b560eaef28620d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 30 Nov 2017 10:32:55 +1300 Subject: Use correct include path for glapi.h --- backend/drm/renderer.c | 2 +- render/egl.c | 2 +- render/gles2/renderer.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index d53acaa8..87064914 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -14,7 +14,7 @@ #include #include #include "backend/drm/drm.h" -#include "render/glapi.h" +#include "glapi.h" bool wlr_drm_renderer_init(struct wlr_drm_backend *drm, struct wlr_drm_renderer *renderer) { diff --git a/render/egl.c b/render/egl.c index 08612125..22d58df2 100644 --- a/render/egl.c +++ b/render/egl.c @@ -4,7 +4,7 @@ #include #include #include -#include "render/glapi.h" +#include "glapi.h" // Extension documentation // https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_image_base.txt. diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 646d69ec..89cc4ffb 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -12,7 +12,7 @@ #include #include #include "render/gles2.h" -#include "render/glapi.h" +#include "glapi.h" struct shaders shaders; -- cgit v1.2.3 From cef6d7549131cfee7cd60ada0388a2766335c70a Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 30 Nov 2017 15:00:36 +0100 Subject: Moved os-compatibility and added header * Moved os-compatibility.c to util * Added header under util * Removed static since it isn't needed (i think so) * Adjusted meson.build to include lib_wlr Improved some codestyle * Added guard to os-compatibility.h * Fixed typo in include statment Adjusted Guard * Changed guard to _WLR_UTIL_OS_COMPATIBILITY --- backend/meson.build | 1 - backend/wayland/os-compatibility.c | 153 ------------------------------------- examples/meson.build | 3 +- examples/screenshot.c | 2 +- include/util/os-compatibility.h | 12 +++ util/meson.build | 1 + util/os-compatibility.c | 147 +++++++++++++++++++++++++++++++++++ 7 files changed, 163 insertions(+), 156 deletions(-) delete mode 100644 backend/wayland/os-compatibility.c create mode 100644 include/util/os-compatibility.h create mode 100644 util/os-compatibility.c diff --git a/backend/meson.build b/backend/meson.build index 5ed7b227..c9d47317 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -21,7 +21,6 @@ backend_files = files( 'wayland/output.c', 'wayland/registry.c', 'wayland/wl_seat.c', - 'wayland/os-compatibility.c', 'x11/backend.c', ) diff --git a/backend/wayland/os-compatibility.c b/backend/wayland/os-compatibility.c deleted file mode 100644 index cbd7988d..00000000 --- a/backend/wayland/os-compatibility.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright © 2012 Collabora, Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define _XOPEN_SOURCE 700 -#include -#include -#include -#include -#include -#include -#include - -int -os_fd_set_cloexec(int fd) -{ - long flags; - - if (fd == -1) - return -1; - - flags = fcntl(fd, F_GETFD); - if (flags == -1) - return -1; - - if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) - return -1; - - return 0; -} - -static int -set_cloexec_or_close(int fd) -{ - if (os_fd_set_cloexec(fd) != 0) { - close(fd); - return -1; - } - return fd; -} - -static int -create_tmpfile_cloexec(char *tmpname) -{ - int fd; - -#ifdef HAVE_MKOSTEMP - fd = mkostemp(tmpname, O_CLOEXEC); - if (fd >= 0) - unlink(tmpname); -#else - fd = mkstemp(tmpname); - if (fd >= 0) { - fd = set_cloexec_or_close(fd); - unlink(tmpname); - } -#endif - - return fd; -} - -/* - * Create a new, unique, anonymous file of the given size, and - * return the file descriptor for it. The file descriptor is set - * CLOEXEC. The file is immediately suitable for mmap()'ing - * the given size at offset zero. - * - * The file should not have a permanent backing store like a disk, - * but may have if XDG_RUNTIME_DIR is not properly implemented in OS. - * - * The file name is deleted from the file system. - * - * The file is suitable for buffer sharing between processes by - * transmitting the file descriptor over Unix sockets using the - * SCM_RIGHTS methods. - * - * If the C library implements posix_fallocate(), it is used to - * guarantee that disk space is available for the file at the - * given size. If disk space is insufficient, errno is set to ENOSPC. - * If posix_fallocate() is not supported, program may receive - * SIGBUS on accessing mmap()'ed file contents instead. - */ -int -os_create_anonymous_file(off_t size) -{ - static const char template[] = "/wlroots-shared-XXXXXX"; - const char *path; - char *name; - int fd; - int ret; - - path = getenv("XDG_RUNTIME_DIR"); - if (!path) { - errno = ENOENT; - return -1; - } - - name = malloc(strlen(path) + sizeof(template)); - if (!name) - return -1; - - strcpy(name, path); - strcat(name, template); - - fd = create_tmpfile_cloexec(name); - - free(name); - - if (fd < 0) - return -1; - -#ifdef HAVE_POSIX_FALLOCATE - do { - ret = posix_fallocate(fd, 0, size); - } while (ret == EINTR); - if (ret != 0) { - close(fd); - errno = ret; - return -1; - } -#else - do { - ret = ftruncate(fd, size); - } while (ret < 0 && errno == EINTR); - if (ret < 0) { - close(fd); - return -1; - } -#endif - - return fd; -} diff --git a/examples/meson.build b/examples/meson.build index 89fc6211..af0f5a18 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -29,5 +29,6 @@ executable( executable( 'screenshot', 'screenshot.c', - dependencies: [wayland_client, wlr_protos], + dependencies: [wayland_client, wlr_protos, wlroots], + link_with: lib_shared, ) diff --git a/examples/screenshot.c b/examples/screenshot.c index fc7f3cb3..a887d1d7 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -35,7 +35,7 @@ #include #include #include -#include "../backend/wayland/os-compatibility.c" +#include "util/os-compatibility.h" static struct wl_shm *shm = NULL; static struct orbital_screenshooter *screenshooter = NULL; diff --git a/include/util/os-compatibility.h b/include/util/os-compatibility.h new file mode 100644 index 00000000..b2ec2db9 --- /dev/null +++ b/include/util/os-compatibility.h @@ -0,0 +1,12 @@ +#ifndef _WLR_UTIL_OS_COMPATIBILITY_H +#define _WLR_UTIL_OS_COMPATIBILITY_H + +int os_fd_set_cloexec(int fd); + +int set_cloexec_or_close(int fd); + +int create_tmpfile_cloexec(char *tmpname); + +int os_create_anonymous_file(off_t size); + +#endif diff --git a/util/meson.build b/util/meson.build index dd620818..21930693 100644 --- a/util/meson.build +++ b/util/meson.build @@ -2,6 +2,7 @@ lib_wlr_util = static_library( 'wlr_util', files( 'log.c', + 'os-compatibility.c', ), include_directories: wlr_inc, ) diff --git a/util/os-compatibility.c b/util/os-compatibility.c new file mode 100644 index 00000000..98aeab3d --- /dev/null +++ b/util/os-compatibility.c @@ -0,0 +1,147 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define _XOPEN_SOURCE 700 +#include +#include +#include +#include +#include +#include +#include +#include "util/os-compatibility.h" + +int os_fd_set_cloexec(int fd) { + long flags; + + if (fd == -1) + return -1; + + flags = fcntl(fd, F_GETFD); + if (flags == -1) + return -1; + + if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) + return -1; + + return 0; +} + +int set_cloexec_or_close(int fd) { + if (os_fd_set_cloexec(fd) != 0) { + close(fd); + return -1; + } + return fd; +} + +int create_tmpfile_cloexec(char *tmpname) +{ + int fd; + +#ifdef HAVE_MKOSTEMP + fd = mkostemp(tmpname, O_CLOEXEC); + if (fd >= 0) + unlink(tmpname); +#else + fd = mkstemp(tmpname); + if (fd >= 0) { + fd = set_cloexec_or_close(fd); + unlink(tmpname); + } +#endif + + return fd; +} + +/* + * Create a new, unique, anonymous file of the given size, and + * return the file descriptor for it. The file descriptor is set + * CLOEXEC. The file is immediately suitable for mmap()'ing + * the given size at offset zero. + * + * The file should not have a permanent backing store like a disk, + * but may have if XDG_RUNTIME_DIR is not properly implemented in OS. + * + * The file name is deleted from the file system. + * + * The file is suitable for buffer sharing between processes by + * transmitting the file descriptor over Unix sockets using the + * SCM_RIGHTS methods. + * + * If the C library implements posix_fallocate(), it is used to + * guarantee that disk space is available for the file at the + * given size. If disk space is insufficient, errno is set to ENOSPC. + * If posix_fallocate() is not supported, program may receive + * SIGBUS on accessing mmap()'ed file contents instead. + */ +int os_create_anonymous_file(off_t size) { + static const char template[] = "/wlroots-shared-XXXXXX"; + const char *path; + char *name; + int fd; + int ret; + + path = getenv("XDG_RUNTIME_DIR"); + if (!path) { + errno = ENOENT; + return -1; + } + + name = malloc(strlen(path) + sizeof(template)); + if (!name) + return -1; + + strcpy(name, path); + strcat(name, template); + + fd = create_tmpfile_cloexec(name); + + free(name); + + if (fd < 0) + return -1; + +#ifdef HAVE_POSIX_FALLOCATE + do { + ret = posix_fallocate(fd, 0, size); + } while (ret == EINTR); + if (ret != 0) { + close(fd); + errno = ret; + return -1; + } +#else + do { + ret = ftruncate(fd, size); + } while (ret < 0 && errno == EINTR); + if (ret < 0) { + close(fd); + return -1; + } +#endif + + return fd; +} -- cgit v1.2.3 From a8d8a63fe0b437a6a4d37fd03a0e8b4e178e22c7 Mon Sep 17 00:00:00 2001 From: n3rdopolis Date: Sat, 2 Dec 2017 10:50:00 -0500 Subject: Attempt to fix #454 With logind, only seat0 can use TTYs --- backend/session/logind.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/session/logind.c b/backend/session/logind.c index daff75b6..e42b85f8 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -347,19 +347,22 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) { goto error; } - ret = sd_session_get_vt(session->id, &session->base.vtnr); - if (ret < 0) { - wlr_log(L_ERROR, "Session not running in virtual terminal"); - goto error; - } - char *seat; ret = sd_session_get_seat(session->id, &seat); if (ret < 0) { wlr_log(L_ERROR, "Failed to get seat id: %s", strerror(-ret)); goto error; } + snprintf(session->base.seat, sizeof(session->base.seat), "%s", seat); + if (seat == "seat0") + { + ret = sd_session_get_vt(session->id, &session->base.vtnr); + if (ret < 0) { + wlr_log(L_ERROR, "Session not running in virtual terminal"); + goto error; + } + } free(seat); ret = sd_bus_default_system(&session->bus); -- cgit v1.2.3 From 8a2d54c24ab157c8acc669f6aa5af365abc71a70 Mon Sep 17 00:00:00 2001 From: n3rdopolis Date: Sat, 2 Dec 2017 12:37:28 -0500 Subject: Fix style and string comparison --- backend/session/logind.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/session/logind.c b/backend/session/logind.c index e42b85f8..e9d4c8f3 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -353,10 +353,9 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) { wlr_log(L_ERROR, "Failed to get seat id: %s", strerror(-ret)); goto error; } - snprintf(session->base.seat, sizeof(session->base.seat), "%s", seat); - if (seat == "seat0") - { + + if (strcmp(seat, "seat0") == 0) { ret = sd_session_get_vt(session->id, &session->base.vtnr); if (ret < 0) { wlr_log(L_ERROR, "Session not running in virtual terminal"); -- cgit v1.2.3 From 41d7bad4703d872ffcfb2c20f300d4b3e1c84246 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 3 Dec 2017 12:37:23 -0500 Subject: wl-shell: add commit event --- include/wlr/types/wlr_wl_shell.h | 1 + types/wlr_wl_shell.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index ec087693..986f92e8 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -77,6 +77,7 @@ struct wlr_wl_shell_surface { struct { struct wl_signal destroy; + struct wl_signal commit; struct wl_signal ping_timeout; struct wl_signal request_move; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 6174c872..ee72856c 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -459,6 +459,8 @@ static void handle_wlr_surface_committed(struct wl_listener *listener, surface->popup_state->seat); shell_pointer_grab_maybe_end(&grab->pointer_grab); } + + wl_signal_emit(&surface->events.commit, surface); } static int shell_surface_ping_timeout(void *user_data) { @@ -509,6 +511,7 @@ static void shell_protocol_get_shell_surface(struct wl_client *client, wl_surface->resource); wl_signal_init(&wl_surface->events.destroy); + wl_signal_init(&wl_surface->events.commit); wl_signal_init(&wl_surface->events.ping_timeout); wl_signal_init(&wl_surface->events.request_move); wl_signal_init(&wl_surface->events.request_resize); -- cgit v1.2.3 From 20545b09faf52bfde4513e6fbe519d4df686e404 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 3 Dec 2017 13:02:02 -0500 Subject: rootston: use wl-shell surface commit --- rootston/wl_shell.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 5fd6352d..d0aad407 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -150,8 +150,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { roots_surface->set_state.notify = handle_set_state; wl_signal_add(&surface->events.set_state, &roots_surface->set_state); roots_surface->surface_commit.notify = handle_surface_commit; - wl_signal_add(&surface->surface->events.commit, - &roots_surface->surface_commit); + wl_signal_add(&surface->events.commit, &roots_surface->surface_commit); struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (!view) { -- cgit v1.2.3 From 344ca222db6b1811f983cabb80c3ba70e04fd31e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 3 Dec 2017 13:16:41 -0500 Subject: wrap server decoration modes --- include/wlr/types/wlr_server_decoration.h | 27 +++++++++++++++++++++++++-- rootston/desktop.c | 3 +-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/wlr/types/wlr_server_decoration.h b/include/wlr/types/wlr_server_decoration.h index b4cac5b7..474a9386 100644 --- a/include/wlr/types/wlr_server_decoration.h +++ b/include/wlr/types/wlr_server_decoration.h @@ -3,12 +3,35 @@ #include +/** + * Possible values to use in request_mode and the event mode. Same as + * org_kde_kwin_server_decoration_manager_mode. + */ +enum wlr_server_decoration_manager_mode { + /** + * Undecorated: The surface is not decorated at all, neither server nor + * client-side. An example is a popup surface which should not be + * decorated. + */ + WLR_SERVER_DECORATION_MANAGER_MODE_NONE = 0, + /** + * Client-side decoration: The decoration is part of the surface and the + * client. + */ + WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT = 1, + /** + * Server-side decoration: The server embeds the surface into a decoration + * frame. + */ + WLR_SERVER_DECORATION_MANAGER_MODE_SERVER = 2, +}; + struct wlr_server_decoration_manager { struct wl_global *wl_global; struct wl_list wl_resources; struct wl_list decorations; // wlr_server_decoration::link - uint32_t default_mode; // enum org_kde_kwin_server_decoration_manager_mode + uint32_t default_mode; // enum wlr_server_decoration_manager_mode struct { struct wl_signal new_decoration; @@ -22,7 +45,7 @@ struct wlr_server_decoration { struct wlr_surface *surface; struct wl_list link; - uint32_t mode; // enum org_kde_kwin_server_decoration_manager_mode + uint32_t mode; // enum wlr_server_decoration_manager_mode struct { struct wl_signal destroy; diff --git a/rootston/desktop.c b/rootston/desktop.c index bb3af258..244f7c94 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "rootston/server.h" #include "rootston/seat.h" #include "rootston/xcursor.h" @@ -468,7 +467,7 @@ struct roots_desktop *desktop_create(struct roots_server *server, wlr_server_decoration_manager_create(server->wl_display); wlr_server_decoration_manager_set_default_mode( desktop->server_decoration_manager, - ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT); + WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT); return desktop; } -- cgit v1.2.3 From 86df909256ede7ed5f415073bdf9f952ebcf473d Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 3 Dec 2017 17:30:57 -0500 Subject: xwayland: remove xwayland param from xsurface methods --- include/wlr/xwayland.h | 20 +++++++++----------- rootston/xwayland.c | 28 ++++++++++++---------------- xwayland/xwm.c | 32 +++++++++++++++----------------- 3 files changed, 36 insertions(+), 44 deletions(-) diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 9b493d88..792d2b88 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -153,20 +153,18 @@ void wlr_xwayland_set_cursor(struct wlr_xwayland *wlr_xwayland, uint8_t *pixels, uint32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x, int32_t hotspot_y); -void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool activated); +void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *surface, + bool activated); -void wlr_xwayland_surface_configure(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, int16_t x, int16_t y, - uint16_t width, uint16_t height); +void wlr_xwayland_surface_configure(struct wlr_xwayland_surface *surface, + int16_t x, int16_t y, uint16_t width, uint16_t height); -void wlr_xwayland_surface_close(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface); +void wlr_xwayland_surface_close(struct wlr_xwayland_surface *surface); -void wlr_xwayland_surface_set_maximized(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool maximized); +void wlr_xwayland_surface_set_maximized(struct wlr_xwayland_surface *surface, + bool maximized); -void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool fullscreen); +void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface, + bool fullscreen); #endif diff --git a/rootston/xwayland.c b/rootston/xwayland.c index 2b17ee3f..5f677116 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -11,8 +11,7 @@ static void activate(struct roots_view *view, bool active) { assert(view->type == ROOTS_XWAYLAND_VIEW); - struct wlr_xwayland *xwayland = view->desktop->xwayland; - wlr_xwayland_surface_activate(xwayland, view->xwayland_surface, active); + wlr_xwayland_surface_activate(view->xwayland_surface, active); } static void move(struct roots_view *view, double x, double y) { @@ -20,8 +19,8 @@ static void move(struct roots_view *view, double x, double y) { struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; view->x = x; view->y = y; - wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - x, y, xwayland_surface->width, xwayland_surface->height); + wlr_xwayland_surface_configure(xwayland_surface, x, y, + xwayland_surface->width, xwayland_surface->height); } static void apply_size_constraints( @@ -56,9 +55,8 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) { apply_size_constraints(xwayland_surface, width, height, &constrained_width, &constrained_height); - wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - xwayland_surface->x, xwayland_surface->y, constrained_width, - constrained_height); + wlr_xwayland_surface_configure(xwayland_surface, xwayland_surface->x, + xwayland_surface->y, constrained_width, constrained_height); } static void move_resize(struct roots_view *view, double x, double y, @@ -87,27 +85,25 @@ static void move_resize(struct roots_view *view, double x, double y, view->pending_move_resize.width = constrained_width; view->pending_move_resize.height = constrained_height; - wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - x, y, constrained_width, constrained_height); + wlr_xwayland_surface_configure(xwayland_surface, x, y, constrained_width, + constrained_height); } static void close(struct roots_view *view) { assert(view->type == ROOTS_XWAYLAND_VIEW); - wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface); + wlr_xwayland_surface_close(view->xwayland_surface); } static void maximize(struct roots_view *view, bool maximized) { assert(view->type == ROOTS_XWAYLAND_VIEW); - wlr_xwayland_surface_set_maximized(view->desktop->xwayland, - view->xwayland_surface, maximized); + wlr_xwayland_surface_set_maximized(view->xwayland_surface, maximized); } static void set_fullscreen(struct roots_view *view, bool fullscreen) { assert(view->type == ROOTS_XWAYLAND_VIEW); - wlr_xwayland_surface_set_fullscreen(view->desktop->xwayland, - view->xwayland_surface, fullscreen); + wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen); } static void handle_destroy(struct wl_listener *listener, void *data) { @@ -139,8 +135,8 @@ static void handle_request_configure(struct wl_listener *listener, void *data) { roots_surface->view->x = (double)event->x; roots_surface->view->y = (double)event->y; - wlr_xwayland_surface_configure(roots_surface->view->desktop->xwayland, - xwayland_surface, event->x, event->y, event->width, event->height); + wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y, + event->width, event->height); } static struct roots_seat *guess_seat_for_view(struct roots_view *view) { diff --git a/xwayland/xwm.c b/xwayland/xwm.c index d36822b5..562f2052 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -590,7 +590,7 @@ static void xwm_handle_configure_request(struct wlr_xwm *xwm, if (xsurface->surface == NULL) { // Surface has not been mapped yet - wlr_xwayland_surface_configure(xwm->xwayland, xsurface, ev->x, ev->y, + wlr_xwayland_surface_configure(xsurface, ev->x, ev->y, ev->width, ev->height); } else { struct wlr_xwayland_surface_configure_event *wlr_event = @@ -981,25 +981,24 @@ static void handle_compositor_surface_create(struct wl_listener *listener, } } -void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *xsurface, bool activated) { - struct wlr_xwayland_surface *focused = wlr_xwayland->xwm->focus_surface; +void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *xsurface, + bool activated) { + struct wlr_xwayland_surface *focused = xsurface->xwm->focus_surface; if (activated) { - xwm_surface_activate(wlr_xwayland->xwm, xsurface); + xwm_surface_activate(xsurface->xwm, xsurface); } else if (focused == xsurface) { - xwm_surface_activate(wlr_xwayland->xwm, NULL); + xwm_surface_activate(xsurface->xwm, NULL); } } -void wlr_xwayland_surface_configure(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *xsurface, int16_t x, int16_t y, - uint16_t width, uint16_t height) { +void wlr_xwayland_surface_configure(struct wlr_xwayland_surface *xsurface, + int16_t x, int16_t y, uint16_t width, uint16_t height) { xsurface->x = x; xsurface->y = y; xsurface->width = width; xsurface->height = height; - struct wlr_xwm *xwm = wlr_xwayland->xwm; + struct wlr_xwm *xwm = xsurface->xwm; uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH; @@ -1008,9 +1007,8 @@ void wlr_xwayland_surface_configure(struct wlr_xwayland *wlr_xwayland, xcb_flush(xwm->xcb_conn); } -void wlr_xwayland_surface_close(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *xsurface) { - struct wlr_xwm *xwm = wlr_xwayland->xwm; +void wlr_xwayland_surface_close(struct wlr_xwayland_surface *xsurface) { + struct wlr_xwm *xwm = xsurface->xwm; bool supports_delete = false; for (size_t i = 0; i < xsurface->protocols_len; i++) { @@ -1343,16 +1341,16 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { return xwm; } -void wlr_xwayland_surface_set_maximized(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool maximized) { +void wlr_xwayland_surface_set_maximized(struct wlr_xwayland_surface *surface, + bool maximized) { surface->maximized_horz = maximized; surface->maximized_vert = maximized; xsurface_set_net_wm_state(surface); xcb_flush(surface->xwm->xcb_conn); } -void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool fullscreen) { +void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface, + bool fullscreen) { surface->fullscreen = fullscreen; xsurface_set_net_wm_state(surface); xcb_flush(surface->xwm->xcb_conn); -- cgit v1.2.3 From 8af779fae610a86c6757eb4614cace39f687c292 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 5 Dec 2017 22:23:01 +0100 Subject: Fix segfault when moving hardware cursor --- backend/drm/drm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index dd247998..9fcf2ad7 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -634,8 +634,10 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output, struct wlr_box transformed_box; wlr_output_transform_apply_to_box(transform, &box, &transformed_box); - transformed_box.x -= plane->cursor_hotspot_x; - transformed_box.y -= plane->cursor_hotspot_y; + if (plane != NULL) { + transformed_box.x -= plane->cursor_hotspot_x; + transformed_box.y -= plane->cursor_hotspot_y; + } return drm->iface->crtc_move_cursor(drm, conn->crtc, transformed_box.x, transformed_box.y); -- cgit v1.2.3 From bf2b58eb6db5a59f08a3b0a3ab5e43e93711bf51 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 6 Dec 2017 16:36:46 +0100 Subject: Add wlr_output_set_scale Fixes #465 --- include/wlr/types/wlr_output.h | 1 + rootston/output.c | 6 +++--- types/wlr_output.c | 29 +++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index d382b593..42c46233 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -85,6 +85,7 @@ bool wlr_output_set_mode(struct wlr_output *output, void wlr_output_transform(struct wlr_output *output, enum wl_output_transform transform); void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly); +void wlr_output_set_scale(struct wlr_output *output, uint32_t scale); void wlr_output_destroy(struct wlr_output *output); void wlr_output_effective_resolution(struct wlr_output *output, int *width, int *height); diff --git a/rootston/output.c b/rootston/output.c index bf684f2f..d0f4a378 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -314,10 +314,10 @@ void output_add_notify(struct wl_listener *listener, void *data) { if (output_config->mode.width) { set_mode(wlr_output, output_config); } - wlr_output->scale = output_config->scale; + wlr_output_set_scale(wlr_output, output_config->scale); wlr_output_transform(wlr_output, output_config->transform); - wlr_output_layout_add(desktop->layout, - wlr_output, output_config->x, output_config->y); + wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, + output_config->y); } else { wlr_output_layout_add_auto(desktop->layout, wlr_output); } diff --git a/types/wlr_output.c b/types/wlr_output.c index 21d94cfb..163f2d8c 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -52,6 +52,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) { static void wlr_output_send_current_mode_to_resource( struct wl_resource *resource) { + assert(resource); struct wlr_output *output = wl_resource_get_user_data(resource); assert(output); const uint32_t version = wl_resource_get_version(resource); @@ -119,7 +120,6 @@ struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output, struct wl_global *wl_global = wl_global_create(display, &wl_output_interface, 3, wlr_output, wl_output_bind); wlr_output->wl_global = wl_global; - wl_list_init(&wlr_output->wl_resources); return wl_global; } @@ -155,6 +155,7 @@ bool wlr_output_set_mode(struct wlr_output *output, bool result = output->impl->set_mode(output, mode); if (result) { wlr_output_update_matrix(output); + struct wl_resource *resource; wl_resource_for_each(resource, &output->wl_resources) { wlr_output_send_current_mode_to_resource(resource); @@ -168,14 +169,14 @@ void wlr_output_update_size(struct wlr_output *output, int32_t width, if (output->width == width && output->height == height) { return; } + output->width = width; output->height = height; wlr_output_update_matrix(output); - if (output->wl_global != NULL) { - struct wl_resource *resource; - wl_resource_for_each(resource, &output->wl_resources) { - wlr_output_send_current_mode_to_resource(resource); - } + + struct wl_resource *resource; + wl_resource_for_each(resource, &output->wl_resources) { + wlr_output_send_current_mode_to_resource(resource); } } @@ -194,6 +195,21 @@ void wlr_output_set_position(struct wlr_output *output, int32_t lx, output->lx = lx; output->ly = ly; + // TODO: only send geometry and done + struct wl_resource *resource; + wl_resource_for_each(resource, &output->wl_resources) { + wl_output_send_to_resource(resource); + } +} + +void wlr_output_set_scale(struct wlr_output *output, uint32_t scale) { + if (output->scale == scale) { + return; + } + + output->scale = scale; + + // TODO: only send mode and done struct wl_resource *resource; wl_resource_for_each(resource, &output->wl_resources) { wl_output_send_to_resource(resource); @@ -209,6 +225,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, output->transform = WL_OUTPUT_TRANSFORM_NORMAL; output->scale = 1; wl_list_init(&output->cursors); + wl_list_init(&output->wl_resources); wl_signal_init(&output->events.frame); wl_signal_init(&output->events.swap_buffers); wl_signal_init(&output->events.resolution); -- cgit v1.2.3 From dac0233804c7a8a1ffe76c4c3f0644873a0267d0 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 6 Dec 2017 16:54:08 +0100 Subject: Send new output to clients when changing transform --- types/wlr_output.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/wlr_output.c b/types/wlr_output.c index 163f2d8c..ed74004d 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -184,6 +184,12 @@ void wlr_output_transform(struct wlr_output *output, enum wl_output_transform transform) { output->impl->transform(output, transform); wlr_output_update_matrix(output); + + // TODO: only send geometry and done + struct wl_resource *resource; + wl_resource_for_each(resource, &output->wl_resources) { + wl_output_send_to_resource(resource); + } } void wlr_output_set_position(struct wlr_output *output, int32_t lx, -- cgit v1.2.3 From 91d72040e588c500e8017c6ad824a96ed4180996 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 7 Dec 2017 13:59:19 +0100 Subject: Configure outputs with make, model, serial in rootston Added fallbacks in DRM backend in case EDID extension data for model and serial is missing. Updates #403 --- backend/drm/util.c | 6 ++++++ rootston/config.c | 15 ++++++++++----- rootston/output.c | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/drm/util.c b/backend/drm/util.c index c27d7b67..25256343 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -93,6 +93,12 @@ void parse_edid(struct wlr_output *restrict output, size_t len, const uint8_t *d uint16_t id = (data[8] << 8) | data[9]; snprintf(output->make, sizeof(output->make), "%s", get_manufacturer(id)); + uint16_t model = data[10] | (data[11] << 8); + snprintf(output->model, sizeof(output->model), "0x%04X", model); + + uint32_t serial = data[12] | (data[13] << 8) | (data[14] << 8) | (data[15] << 8); + snprintf(output->serial, sizeof(output->serial), "0x%08X", serial); + output->phys_width = ((data[68] & 0xf0) << 4) | data[66]; output->phys_height = ((data[68] & 0x0f) << 8) | data[67]; diff --git a/rootston/config.c b/rootston/config.c index 466ad16a..59adf13c 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -120,7 +120,7 @@ void add_binding_config(struct wl_list *bindings, const char* combination, xkb_keysym_t keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP]; char *symnames = strdup(combination); - char* symname = strtok(symnames, "+"); + char *symname = strtok(symnames, "+"); while (symname) { uint32_t modifier = parse_modifier(symname); if (modifier != 0) { @@ -466,10 +466,15 @@ void roots_config_destroy(struct roots_config *config) { struct roots_output_config *roots_config_get_output(struct roots_config *config, struct wlr_output *output) { - struct roots_output_config *o_config; - wl_list_for_each(o_config, &config->outputs, link) { - if (strcmp(o_config->name, output->name) == 0) { - return o_config; + char name[83]; + snprintf(name, sizeof(name), "%s %s %s", output->make, output->model, + output->serial); + + struct roots_output_config *oc; + wl_list_for_each(oc, &config->outputs, link) { + if (strcmp(oc->name, output->name) == 0 || + strcmp(oc->name, name) == 0) { + return oc; } } diff --git a/rootston/output.c b/rootston/output.c index d0f4a378..aace1991 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -291,7 +291,7 @@ void output_add_notify(struct wl_listener *listener, void *data) { struct roots_config *config = desktop->config; wlr_log(L_DEBUG, "Output '%s' added", wlr_output->name); - wlr_log(L_DEBUG, "%s %s %s %"PRId32"mm x %"PRId32"mm", wlr_output->make, + wlr_log(L_DEBUG, "'%s %s %s' %"PRId32"mm x %"PRId32"mm", wlr_output->make, wlr_output->model, wlr_output->serial, wlr_output->phys_width, wlr_output->phys_height); if (wl_list_length(&wlr_output->modes) > 0) { -- cgit v1.2.3 From d74ac69f7b932a8833527a41351e3310ad391d7c Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 7 Dec 2017 11:19:43 -0500 Subject: bring edges into wlr --- include/rootston/cursor.h | 7 ------- include/rootston/xcursor.h | 2 -- include/wlr/types/wlr_xcursor_manager.h | 7 +++++++ include/wlr/util/edges.h | 12 ++++++++++++ rootston/cursor.c | 17 +++++++++-------- rootston/meson.build | 1 - rootston/seat.c | 3 ++- rootston/xcursor.c | 28 ---------------------------- types/wlr_xcursor_manager.c | 23 +++++++++++++++++++++++ 9 files changed, 53 insertions(+), 47 deletions(-) create mode 100644 include/wlr/util/edges.h delete mode 100644 rootston/xcursor.c diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h index e2a371bf..2d9a9215 100644 --- a/include/rootston/cursor.h +++ b/include/rootston/cursor.h @@ -10,13 +10,6 @@ enum roots_cursor_mode { ROOTS_CURSOR_ROTATE = 3, }; -enum roots_cursor_resize_edge { - ROOTS_CURSOR_RESIZE_EDGE_TOP = 1, - ROOTS_CURSOR_RESIZE_EDGE_BOTTOM = 2, - ROOTS_CURSOR_RESIZE_EDGE_LEFT = 4, - ROOTS_CURSOR_RESIZE_EDGE_RIGHT = 8, -}; - struct roots_input_event { uint32_t serial; struct wlr_cursor *cursor; diff --git a/include/rootston/xcursor.h b/include/rootston/xcursor.h index bc00f79c..285db78d 100644 --- a/include/rootston/xcursor.h +++ b/include/rootston/xcursor.h @@ -9,6 +9,4 @@ #define ROOTS_XCURSOR_MOVE "grabbing" #define ROOTS_XCURSOR_ROTATE "grabbing" -const char *roots_xcursor_get_resize_name(uint32_t edges); - #endif diff --git a/include/wlr/types/wlr_xcursor_manager.h b/include/wlr/types/wlr_xcursor_manager.h index c78a6e8d..63eb5386 100644 --- a/include/wlr/types/wlr_xcursor_manager.h +++ b/include/wlr/types/wlr_xcursor_manager.h @@ -4,6 +4,7 @@ #include #include #include +#include /** * A scaled XCursor theme. @@ -50,4 +51,10 @@ struct wlr_xcursor *wlr_xcursor_manager_get_xcursor( void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, const char *name, struct wlr_cursor *cursor); +/** + * Get the name of the cursor image for the given edges. + */ +const char *wlr_xcursor_manager_get_resize_name(enum wlr_edges edges); + + #endif diff --git a/include/wlr/util/edges.h b/include/wlr/util/edges.h new file mode 100644 index 00000000..53268323 --- /dev/null +++ b/include/wlr/util/edges.h @@ -0,0 +1,12 @@ +#ifndef WLR_UTIL_EDGES_H +#define WLR_UTIL_EDGES_H + +enum wlr_edges { + WLR_EDGE_NONE = 0, + WLR_EDGE_TOP = 1, + WLR_EDGE_BOTTOM = 2, + WLR_EDGE_LEFT = 4, + WLR_EDGE_RIGHT = 8, +}; + +#endif diff --git a/rootston/cursor.c b/rootston/cursor.c index f0e3d70d..d38e40a1 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -8,6 +8,7 @@ #endif #include #include +#include #include "rootston/xcursor.h" #include "rootston/cursor.h" @@ -75,22 +76,22 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, double y = view->y; int width = cursor->view_width; int height = cursor->view_height; - if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { + if (cursor->resize_edges & WLR_EDGE_TOP) { y = cursor->view_y + dy; height -= dy; if (height < 1) { y += height; } - } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { + } else if (cursor->resize_edges & WLR_EDGE_BOTTOM) { height += dy; } - if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { + if (cursor->resize_edges & WLR_EDGE_LEFT) { x = cursor->view_x + dx; width -= dx; if (width < 1) { x += width; } - } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { + } else if (cursor->resize_edges & WLR_EDGE_RIGHT) { width += dx; } @@ -147,14 +148,14 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, case BTN_RIGHT: edges = 0; if (sx < view->wlr_surface->current->width/2) { - edges |= ROOTS_CURSOR_RESIZE_EDGE_LEFT; + edges |= WLR_EDGE_LEFT; } else { - edges |= ROOTS_CURSOR_RESIZE_EDGE_RIGHT; + edges |= WLR_EDGE_RIGHT; } if (sy < view->wlr_surface->current->height/2) { - edges |= ROOTS_CURSOR_RESIZE_EDGE_TOP; + edges |= WLR_EDGE_TOP; } else { - edges |= ROOTS_CURSOR_RESIZE_EDGE_BOTTOM; + edges |= WLR_EDGE_BOTTOM; } roots_seat_begin_resize(seat, view, edges); break; diff --git a/rootston/meson.build b/rootston/meson.build index 9c543c4f..36b6241a 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -8,7 +8,6 @@ sources = [ 'main.c', 'output.c', 'seat.c', - 'xcursor.c', 'xdg_shell_v6.c', 'wl_shell.c', ] diff --git a/rootston/seat.c b/rootston/seat.c index 737bbd67..f6473581 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -661,8 +661,9 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, view_maximize(view, false); wlr_seat_pointer_clear_focus(seat->seat); + const char *resize_name = wlr_xcursor_manager_get_resize_name(edges); wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, - roots_xcursor_get_resize_name(edges), seat->cursor->cursor); + resize_name, seat->cursor->cursor); } void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) { diff --git a/rootston/xcursor.c b/rootston/xcursor.c deleted file mode 100644 index 74e732c9..00000000 --- a/rootston/xcursor.c +++ /dev/null @@ -1,28 +0,0 @@ -#define _POSIX_C_SOURCE 200809L -#include -#include -#include "rootston/xcursor.h" -#include "rootston/input.h" - -const char *roots_xcursor_get_resize_name(uint32_t edges) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "ne-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "nw-resize"; - } - return "n-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "se-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "sw-resize"; - } - return "s-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "e-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "w-resize"; - } - return "se-resize"; // fallback -} diff --git a/types/wlr_xcursor_manager.c b/types/wlr_xcursor_manager.c index f32a96bc..9350d721 100644 --- a/types/wlr_xcursor_manager.c +++ b/types/wlr_xcursor_manager.c @@ -82,3 +82,26 @@ void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, theme->scale); } } + +const char *wlr_xcursor_manager_get_resize_name(enum wlr_edges edges) { + if (edges & WLR_EDGE_TOP) { + if (edges & WLR_EDGE_RIGHT) { + return "ne-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "nw-resize"; + } + return "n-resize"; + } else if (edges & WLR_EDGE_BOTTOM) { + if (edges & WLR_EDGE_RIGHT) { + return "se-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "sw-resize"; + } + return "s-resize"; + } else if (edges & WLR_EDGE_RIGHT) { + return "e-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "w-resize"; + } + return "se-resize"; // fallback +} -- cgit v1.2.3 From 31bafc24614cb5a66348ca965f1b4fae9209e35c Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 7 Dec 2017 12:04:02 -0500 Subject: xwm: use edges enum --- xwayland/xwm.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 562f2052..a86fbd0e 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -8,6 +8,7 @@ #include #include #include "wlr/util/log.h" +#include "wlr/util/edges.h" #include "wlr/types/wlr_surface.h" #include "wlr/xwayland.h" #include "wlr/xcursor.h" @@ -742,14 +743,43 @@ static void xwm_handle_surface_id_message(struct wlr_xwm *xwm, #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 // move via keyboard #define _NET_WM_MOVERESIZE_CANCEL 11 // cancel operation +static enum wlr_edges net_wm_edges_to_wlr(uint32_t net_wm_edges) { + enum wlr_edges edges = WLR_EDGE_NONE; + + switch(net_wm_edges) { + case _NET_WM_MOVERESIZE_SIZE_TOPLEFT: + edges = WLR_EDGE_TOP | WLR_EDGE_LEFT; + break; + case _NET_WM_MOVERESIZE_SIZE_TOP: + edges = WLR_EDGE_TOP; + break; + case _NET_WM_MOVERESIZE_SIZE_TOPRIGHT: + edges = WLR_EDGE_TOP | WLR_EDGE_RIGHT; + break; + case _NET_WM_MOVERESIZE_SIZE_RIGHT: + edges = WLR_EDGE_RIGHT; + break; + case _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT: + edges = WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT; + break; + case _NET_WM_MOVERESIZE_SIZE_BOTTOM: + edges = WLR_EDGE_BOTTOM; + break; + case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT: + edges = WLR_EDGE_BOTTOM | WLR_EDGE_LEFT; + break; + case _NET_WM_MOVERESIZE_SIZE_LEFT: + edges = WLR_EDGE_LEFT; + break; + default: + break; + } + + return edges; +} + static void xwm_handle_net_wm_moveresize_message(struct wlr_xwm *xwm, xcb_client_message_event_t *ev) { - // same as xdg-toplevel-v6 - // TODO need a common enum for this - static const int map[] = { - 5, 1, 9, 8, 10, 2, 6, 4 - }; - struct wlr_xwayland_surface *xsurface = lookup_surface(xwm, ev->window); if (!xsurface) { return; @@ -775,7 +805,7 @@ static void xwm_handle_net_wm_moveresize_message(struct wlr_xwm *xwm, case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT: case _NET_WM_MOVERESIZE_SIZE_LEFT: resize_event.surface = xsurface; - resize_event.edges = map[detail]; + resize_event.edges = net_wm_edges_to_wlr(detail); wl_signal_emit(&xsurface->events.request_resize, &resize_event); break; case _NET_WM_MOVERESIZE_CANCEL: -- cgit v1.2.3 From 4c60072be584a7ed5b97de325994217a9e96bbd4 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Fri, 8 Dec 2017 06:08:06 -0500 Subject: move get_resize_name to xcursor --- include/wlr/types/wlr_xcursor_manager.h | 7 ------- include/wlr/xcursor.h | 6 ++++++ rootston/seat.c | 2 +- types/wlr_xcursor_manager.c | 23 ----------------------- xcursor/wlr_xcursor.c | 23 +++++++++++++++++++++++ 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/include/wlr/types/wlr_xcursor_manager.h b/include/wlr/types/wlr_xcursor_manager.h index 63eb5386..c78a6e8d 100644 --- a/include/wlr/types/wlr_xcursor_manager.h +++ b/include/wlr/types/wlr_xcursor_manager.h @@ -4,7 +4,6 @@ #include #include #include -#include /** * A scaled XCursor theme. @@ -51,10 +50,4 @@ struct wlr_xcursor *wlr_xcursor_manager_get_xcursor( void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, const char *name, struct wlr_cursor *cursor); -/** - * Get the name of the cursor image for the given edges. - */ -const char *wlr_xcursor_manager_get_resize_name(enum wlr_edges edges); - - #endif diff --git a/include/wlr/xcursor.h b/include/wlr/xcursor.h index b6362b06..42fcedb9 100644 --- a/include/wlr/xcursor.h +++ b/include/wlr/xcursor.h @@ -32,6 +32,7 @@ #define WLR_XCURSOR_H #include +#include struct wlr_xcursor_image { uint32_t width; /* actual width */ @@ -65,4 +66,9 @@ struct wlr_xcursor *wlr_xcursor_theme_get_cursor( int wlr_xcursor_frame(struct wlr_xcursor *cursor, uint32_t time); +/** + * Get the name of the resize cursor image for the given edges. + */ +const char *wlr_xcursor_get_resize_name(enum wlr_edges edges); + #endif diff --git a/rootston/seat.c b/rootston/seat.c index f6473581..1fa09ad6 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -661,7 +661,7 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, view_maximize(view, false); wlr_seat_pointer_clear_focus(seat->seat); - const char *resize_name = wlr_xcursor_manager_get_resize_name(edges); + const char *resize_name = wlr_xcursor_get_resize_name(edges); wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, resize_name, seat->cursor->cursor); } diff --git a/types/wlr_xcursor_manager.c b/types/wlr_xcursor_manager.c index 9350d721..f32a96bc 100644 --- a/types/wlr_xcursor_manager.c +++ b/types/wlr_xcursor_manager.c @@ -82,26 +82,3 @@ void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, theme->scale); } } - -const char *wlr_xcursor_manager_get_resize_name(enum wlr_edges edges) { - if (edges & WLR_EDGE_TOP) { - if (edges & WLR_EDGE_RIGHT) { - return "ne-resize"; - } else if (edges & WLR_EDGE_LEFT) { - return "nw-resize"; - } - return "n-resize"; - } else if (edges & WLR_EDGE_BOTTOM) { - if (edges & WLR_EDGE_RIGHT) { - return "se-resize"; - } else if (edges & WLR_EDGE_LEFT) { - return "sw-resize"; - } - return "s-resize"; - } else if (edges & WLR_EDGE_RIGHT) { - return "e-resize"; - } else if (edges & WLR_EDGE_LEFT) { - return "w-resize"; - } - return "se-resize"; // fallback -} diff --git a/xcursor/wlr_xcursor.c b/xcursor/wlr_xcursor.c index fdebe1af..b1678223 100644 --- a/xcursor/wlr_xcursor.c +++ b/xcursor/wlr_xcursor.c @@ -326,3 +326,26 @@ static int wlr_xcursor_frame_and_duration(struct wlr_xcursor *cursor, int wlr_xcursor_frame(struct wlr_xcursor *_cursor, uint32_t time) { return wlr_xcursor_frame_and_duration(_cursor, time, NULL); } + +const char *wlr_xcursor_get_resize_name(enum wlr_edges edges) { + if (edges & WLR_EDGE_TOP) { + if (edges & WLR_EDGE_RIGHT) { + return "ne-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "nw-resize"; + } + return "n-resize"; + } else if (edges & WLR_EDGE_BOTTOM) { + if (edges & WLR_EDGE_RIGHT) { + return "se-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "sw-resize"; + } + return "s-resize"; + } else if (edges & WLR_EDGE_RIGHT) { + return "e-resize"; + } else if (edges & WLR_EDGE_LEFT) { + return "w-resize"; + } + return "se-resize"; // fallback +} -- cgit v1.2.3 From c5fa415a0373e0fbd974d4a8aee94014050b93f2 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 8 Dec 2017 14:23:33 +0100 Subject: Send wl_surface.{enter,leave} to cursor surfaces --- include/rootston/xcursor.h | 2 +- include/wlr/types/wlr_output.h | 4 +++ types/wlr_output.c | 75 +++++++++++++++++++++++++++++------------- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/include/rootston/xcursor.h b/include/rootston/xcursor.h index 285db78d..a7d2b960 100644 --- a/include/rootston/xcursor.h +++ b/include/rootston/xcursor.h @@ -3,7 +3,7 @@ #include -#define ROOTS_XCURSOR_SIZE 16 +#define ROOTS_XCURSOR_SIZE 24 #define ROOTS_XCURSOR_DEFAULT "left_ptr" #define ROOTS_XCURSOR_MOVE "grabbing" diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 42c46233..895536e1 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -16,6 +16,7 @@ struct wlr_output_cursor { struct wlr_output *output; double x, y; bool enabled; + bool visible; uint32_t width, height; int32_t hotspot_x, hotspot_y; struct wl_list link; @@ -98,6 +99,9 @@ void wlr_output_set_fullscreen_surface(struct wlr_output *output, struct wlr_surface *surface); struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output); +/** + * Sets the cursor image. The image must be already scaled for the output. + */ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x, int32_t hotspot_y); diff --git a/types/wlr_output.c b/types/wlr_output.c index ed74004d..3141e9ef 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -316,6 +316,11 @@ static void output_cursor_get_box(struct wlr_output_cursor *cursor, box->y = cursor->y - cursor->hotspot_y; box->width = cursor->width; box->height = cursor->height; + + if (cursor->surface != NULL) { + box->x += cursor->surface->current->sx; + box->y += cursor->surface->current->sy; + } } static void output_cursor_render(struct wlr_output_cursor *cursor, @@ -331,36 +336,29 @@ static void output_cursor_render(struct wlr_output_cursor *cursor, return; } - struct wlr_box output_box; - output_box.x = output_box.y = 0; - wlr_output_effective_resolution(cursor->output, &output_box.width, - &output_box.height); - output_box.width *= cursor->output->scale; - output_box.height *= cursor->output->scale; + glViewport(0, 0, cursor->output->width, cursor->output->height); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); struct wlr_box cursor_box; output_cursor_get_box(cursor, &cursor_box); - struct wlr_box intersection; - struct wlr_box *intersection_ptr = &intersection; - if (!wlr_box_intersection(&output_box, &cursor_box, &intersection_ptr)) { - return; - } - - glViewport(0, 0, cursor->output->width, cursor->output->height); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + float translate[16]; + wlr_matrix_translate(&translate, cursor_box.x, cursor_box.y, 0); - int x = cursor->x - cursor->hotspot_x; - int y = cursor->y - cursor->hotspot_y; + // Assume cursors without a surface are already scaled for the output if (cursor->surface != NULL) { - x += cursor->surface->current->sx; - y += cursor->surface->current->sy; + cursor_box.width *= cursor->output->scale; + cursor_box.height *= cursor->output->scale; } + float scale[16]; + wlr_matrix_scale(&scale, cursor_box.width, cursor_box.height, 1); + float matrix[16]; - wlr_texture_get_matrix(texture, &matrix, &cursor->output->transform_matrix, - x, y); + wlr_matrix_mul(&translate, &scale, &matrix); + wlr_matrix_mul(&cursor->output->transform_matrix, &matrix, &matrix); + wlr_render_with_matrix(renderer, texture, &matrix); if (cursor->surface != NULL) { @@ -381,7 +379,8 @@ void wlr_output_swap_buffers(struct wlr_output *output) { struct wlr_output_cursor *cursor; wl_list_for_each(cursor, &output->cursors, link) { - if (!cursor->enabled || output->hardware_cursor == cursor) { + if (!cursor->enabled || !cursor->visible || + output->hardware_cursor == cursor) { continue; } output_cursor_render(cursor, &now); @@ -516,6 +515,34 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, stride, width, height, pixels); } +static void output_cursor_update_visible(struct wlr_output_cursor *cursor) { + struct wlr_box output_box; + output_box.x = output_box.y = 0; + wlr_output_effective_resolution(cursor->output, &output_box.width, + &output_box.height); + output_box.width *= cursor->output->scale; + output_box.height *= cursor->output->scale; + + struct wlr_box cursor_box; + output_cursor_get_box(cursor, &cursor_box); + + struct wlr_box intersection; + struct wlr_box *intersection_ptr = &intersection; + bool visible = + wlr_box_intersection(&output_box, &cursor_box, &intersection_ptr); + + if (cursor->surface != NULL) { + if (cursor->visible && !visible) { + wlr_surface_send_leave(cursor->surface, cursor->output); + } + if (!cursor->visible && visible) { + wlr_surface_send_enter(cursor->surface, cursor->output); + } + } + + cursor->visible = visible; +} + static void output_cursor_commit(struct wlr_output_cursor *cursor) { // Some clients commit a cursor surface with a NULL buffer to hide it. cursor->enabled = wlr_surface_has_buffer(cursor->surface); @@ -584,6 +611,9 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor, wl_signal_add(&surface->events.commit, &cursor->surface_commit); wl_signal_add(&surface->events.destroy, &cursor->surface_destroy); output_cursor_commit(cursor); + + cursor->visible = false; + output_cursor_update_visible(cursor); } else { cursor->enabled = false; cursor->width = 0; @@ -599,6 +629,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, y *= cursor->output->scale; cursor->x = x; cursor->y = y; + output_cursor_update_visible(cursor); if (cursor->output->hardware_cursor != cursor) { cursor->output->needs_swap = true; -- cgit v1.2.3 From 5dc303fc26a765c3cff26fe1ee8e5b492d64f2d7 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 8 Dec 2017 14:33:02 +0100 Subject: Fix client cursors hotspot on scaled outputs --- types/wlr_output.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/types/wlr_output.c b/types/wlr_output.c index 3141e9ef..b4ee4176 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -346,12 +346,6 @@ static void output_cursor_render(struct wlr_output_cursor *cursor, float translate[16]; wlr_matrix_translate(&translate, cursor_box.x, cursor_box.y, 0); - // Assume cursors without a surface are already scaled for the output - if (cursor->surface != NULL) { - cursor_box.width *= cursor->output->scale; - cursor_box.height *= cursor->output->scale; - } - float scale[16]; wlr_matrix_scale(&scale, cursor_box.width, cursor_box.height, 1); @@ -546,8 +540,8 @@ static void output_cursor_update_visible(struct wlr_output_cursor *cursor) { static void output_cursor_commit(struct wlr_output_cursor *cursor) { // Some clients commit a cursor surface with a NULL buffer to hide it. cursor->enabled = wlr_surface_has_buffer(cursor->surface); - cursor->width = cursor->surface->current->width; - cursor->height = cursor->surface->current->height; + cursor->width = cursor->surface->current->width * cursor->output->scale; + cursor->height = cursor->surface->current->height * cursor->output->scale; if (cursor->output->hardware_cursor != cursor) { cursor->output->needs_swap = true; @@ -580,8 +574,8 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor, return; } - cursor->hotspot_x = hotspot_x; - cursor->hotspot_y = hotspot_y; + cursor->hotspot_x = hotspot_x * cursor->output->scale; + cursor->hotspot_y = hotspot_y * cursor->output->scale; if (surface && surface == cursor->surface) { if (cursor->output->hardware_cursor == cursor && -- cgit v1.2.3 From 15bb9a53b438eb37ed5ae7c0836b7ec8a3b6b35e Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 8 Dec 2017 14:40:57 +0100 Subject: Fix unscaled cursor sx, sy --- types/wlr_output.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/wlr_output.c b/types/wlr_output.c index b4ee4176..f4ae7aaa 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -310,6 +310,9 @@ static void output_fullscreen_surface_render(struct wlr_output *output, wlr_surface_send_frame_done(surface, when); } +/** + * Returns the cursor box, scaled for its output. + */ static void output_cursor_get_box(struct wlr_output_cursor *cursor, struct wlr_box *box) { box->x = cursor->x - cursor->hotspot_x; @@ -318,8 +321,8 @@ static void output_cursor_get_box(struct wlr_output_cursor *cursor, box->height = cursor->height; if (cursor->surface != NULL) { - box->x += cursor->surface->current->sx; - box->y += cursor->surface->current->sy; + box->x += cursor->surface->current->sx * cursor->output->scale; + box->y += cursor->surface->current->sy * cursor->output->scale; } } -- cgit v1.2.3