From 71db8de4be53fc9ec2fab5ed89dd2646468fa15f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 4 May 2018 08:27:53 -0400 Subject: Render floating views --- sway/desktop/output.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 0deb86ca..95479819 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -818,6 +818,7 @@ static void render_output(struct sway_output *output, struct timespec *when, } } else { float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; + wlr_renderer_clear(renderer, clear_color); int nrects; pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects); -- cgit v1.2.3 From 1f2e399ade77070a2d0b82856ad9a3eef96b8676 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 24 May 2018 22:30:44 +1000 Subject: Implement floating --- sway/desktop/output.c | 114 +++++++++++++++++++++++++++++++++++++++----- sway/desktop/xdg_shell.c | 32 +++++++++++-- sway/desktop/xdg_shell_v6.c | 32 +++++++++++-- sway/desktop/xwayland.c | 97 +++++++++++++++++++++++++++++-------- 4 files changed, 233 insertions(+), 42 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 95479819..1d21e80f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -754,9 +754,87 @@ static void render_container(struct sway_output *output, case L_TABBED: render_container_tabbed(output, damage, con, parent_focused); break; - case L_FLOATING: - // TODO - break; + } +} + +static bool floater_intersects_output(struct sway_container *floater, + struct sway_container *output) { + struct wlr_box box = { + .x = floater->x, + .y = floater->y, + .width = floater->width, + .height = floater->height, + }; + return wlr_output_layout_intersects(root_container.sway_root->output_layout, + output->sway_output->wlr_output, &box); +} + +static void container_translate(struct sway_container *con, int x, int y) { + con->x += x; + con->y += y; + if (con->type == C_VIEW) { + con->sway_view->x += x; + con->sway_view->y += y; + } else { + for (int i = 0; i < con->children->length; ++i) { + struct sway_container *child = con->children->items[i]; + container_translate(child, x, y); + } + } +} + +static void render_floating_container(struct sway_output *soutput, + pixman_region32_t *damage, struct sway_container *con) { + // We need to translate the floating container's coordinates from layout + // coordinates into output-local coordinates. This needs to happen for all + // children of the floating container too. + struct sway_container *output = container_parent(con, C_OUTPUT); + container_translate(con, -output->x, -output->y); + + if (con->type == C_VIEW) { + struct sway_view *view = con->sway_view; + struct sway_seat *seat = input_manager_current_seat(input_manager); + struct sway_container *focus = seat_get_focus(seat); + struct border_colors *colors; + struct wlr_texture *title_texture; + struct wlr_texture *marks_texture; + + if (focus == con) { + colors = &config->border_colors.focused; + title_texture = con->title_focused; + marks_texture = view->marks_focused; + } else { + colors = &config->border_colors.unfocused; + title_texture = con->title_unfocused; + marks_texture = view->marks_unfocused; + } + render_titlebar(soutput, damage, con, con->x, con->y, con->width, + colors, title_texture, marks_texture); + render_view(soutput, damage, con, colors); + } else { + render_container(soutput, damage, con, false); + } + // Undo the translation + container_translate(con, output->x, output->y); +} + +static void render_floating(struct sway_output *soutput, + pixman_region32_t *damage) { + for (int i = 0; i < root_container.children->length; ++i) { + struct sway_container *output = root_container.children->items[i]; + for (int j = 0; j < output->children->length; ++j) { + struct sway_container *workspace = output->children->items[j]; + struct sway_workspace *ws = workspace->sway_workspace; + bool ws_is_visible = workspace_is_visible(workspace); + for (int k = 0; k < ws->floating->children->length; ++k) { + struct sway_container *floater = + ws->floating->children->items[k]; + if ((ws_is_visible || floater->is_sticky) + && floater_intersects_output(floater, soutput->swayc)) { + render_floating_container(soutput, damage, floater); + } + } + } } } @@ -794,8 +872,6 @@ static void render_output(struct sway_output *output, struct timespec *when, goto renderer_end; } - //wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1}); - struct sway_container *workspace = output_get_active_workspace(output); if (workspace->sway_workspace->fullscreen) { @@ -818,7 +894,6 @@ static void render_output(struct sway_output *output, struct timespec *when, } } else { float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; - wlr_renderer_clear(renderer, clear_color); int nrects; pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects); @@ -840,6 +915,8 @@ static void render_output(struct sway_output *output, struct timespec *when, &root_container.sway_root->xwayland_unmanaged); render_layer(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); + + render_floating(output, damage); } render_layer(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); @@ -916,6 +993,7 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { struct sway_container *workspace = output_get_active_workspace(output); send_frame_done_container(&data, workspace); + send_frame_done_container(&data, workspace->sway_workspace->floating); send_frame_done_unmanaged(&data, &root_container.sway_root->xwayland_unmanaged); @@ -1037,7 +1115,15 @@ static void output_damage_view(struct sway_output *output, void output_damage_from_view(struct sway_output *output, struct sway_view *view) { - output_damage_view(output, view, false); + if (container_self_or_parent_floating(view->swayc)) { + view->x -= output->swayc->x; + view->y -= output->swayc->y; + output_damage_view(output, view, false); + view->x += output->swayc->x; + view->y += output->swayc->y; + } else { + output_damage_view(output, view, false); + } } static void output_damage_whole_container_iterator(struct sway_container *con, @@ -1053,13 +1139,17 @@ static void output_damage_whole_container_iterator(struct sway_container *con, void output_damage_whole_container(struct sway_output *output, struct sway_container *con) { - float scale = output->wlr_output->scale; struct wlr_box box = { - .x = con->x * scale, - .y = con->y * scale, - .width = con->width * scale, - .height = con->height * scale, + .x = con->x, + .y = con->y, + .width = con->width, + .height = con->height, }; + if (con->is_floating) { + box.x -= output->wlr_output->lx; + box.y -= output->wlr_output->ly; + } + scale_box(&box, output->wlr_output->scale); wlr_output_damage_add_box(output->damage, &box); if (con->type == C_VIEW) { diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index b2b95fa0..e1a73b20 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -98,6 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width, xdg_shell_view->pending_width = width; xdg_shell_view->pending_height = height; wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); + view_update_position(view, ox, oy); } static void set_activated(struct sway_view *view, bool activated) { @@ -110,6 +111,14 @@ static void set_activated(struct sway_view *view, bool activated) { } } +static void set_maximized(struct sway_view *view, bool maximized) { + if (xdg_shell_view_from_view(view) == NULL) { + return; + } + struct wlr_xdg_surface *surface = view->wlr_xdg_surface; + wlr_xdg_toplevel_set_maximized(surface, maximized); +} + static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xdg_shell_view_from_view(view) == NULL) { return; @@ -118,6 +127,11 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { wlr_xdg_toplevel_set_fullscreen(surface, fullscreen); } +static bool wants_floating(struct sway_view *view) { + // TODO + return false; +} + static void for_each_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data) { if (xdg_shell_view_from_view(view) == NULL) { @@ -154,7 +168,9 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, + .set_maximized = set_maximized, .set_fullscreen = set_fullscreen, + .wants_floating = wants_floating, .for_each_surface = for_each_surface, .close = _close, .destroy = destroy, @@ -164,11 +180,17 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, commit); struct sway_view *view = &xdg_shell_view->view; - // NOTE: We intentionally discard the view's desired width here - // TODO: Store this for restoration when moving to floating plane - // TODO: Let floating views do whatever - view_update_size(view, xdg_shell_view->pending_width, - xdg_shell_view->pending_height); + struct wlr_box *geometry = &view->wlr_xdg_surface->geometry; + if (!view->natural_width && !view->natural_height) { + view->natural_width = geometry->width; + view->natural_height = geometry->height; + } + if (view->swayc && view->swayc->is_floating) { + view_update_size(view, geometry->width, geometry->height); + } else { + view_update_size(view, xdg_shell_view->pending_width, + xdg_shell_view->pending_height); + } view_update_title(view, false); view_damage_from(view); } diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index d098c797..47e4162a 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -97,6 +97,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width, xdg_shell_v6_view->pending_width = width; xdg_shell_v6_view->pending_height = height; wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); + view_update_position(view, ox, oy); } static void set_activated(struct sway_view *view, bool activated) { @@ -109,6 +110,14 @@ static void set_activated(struct sway_view *view, bool activated) { } } +static void set_maximized(struct sway_view *view, bool maximized) { + if (xdg_shell_v6_view_from_view(view) == NULL) { + return; + } + struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6; + wlr_xdg_toplevel_v6_set_maximized(surface, maximized); +} + static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xdg_shell_v6_view_from_view(view) == NULL) { return; @@ -117,6 +126,11 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen); } +static bool wants_floating(struct sway_view *view) { + // TODO + return false; +} + static void for_each_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data) { if (xdg_shell_v6_view_from_view(view) == NULL) { @@ -153,7 +167,9 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, + .set_maximized = set_maximized, .set_fullscreen = set_fullscreen, + .wants_floating = wants_floating, .for_each_surface = for_each_surface, .close = _close, .destroy = destroy, @@ -163,11 +179,17 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = wl_container_of(listener, xdg_shell_v6_view, commit); struct sway_view *view = &xdg_shell_v6_view->view; - // NOTE: We intentionally discard the view's desired width here - // TODO: Store this for restoration when moving to floating plane - // TODO: Let floating views do whatever - view_update_size(view, xdg_shell_v6_view->pending_width, - xdg_shell_v6_view->pending_height); + struct wlr_box *geometry = &view->wlr_xdg_surface_v6->geometry; + if (!view->natural_width && !view->natural_height) { + view->natural_width = geometry->width; + view->natural_height = geometry->height; + } + if (view->swayc && view->swayc->is_floating) { + view_update_size(view, geometry->width, geometry->height); + } else { + view_update_size(view, xdg_shell_v6_view->pending_width, + xdg_shell_v6_view->pending_height); + } view_update_title(view, false); view_damage_from(view); } diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 6a99a66a..56cac1bd 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -152,7 +152,9 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) { } } -static void configure(struct sway_view *view, double ox, double oy, int width, +// The x and y arguments are output-local for tiled views, and layout +// coordinates for floating views. +static void configure(struct sway_view *view, double x, double y, int width, int height) { struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); if (xwayland_view == NULL) { @@ -160,25 +162,33 @@ static void configure(struct sway_view *view, double ox, double oy, int width, } struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - struct sway_container *output = container_parent(view->swayc, C_OUTPUT); - if (!sway_assert(output, "view must be within tree to set position")) { - return; - } - struct sway_container *root = container_parent(output, C_ROOT); - if (!sway_assert(root, "output must be within tree to set position")) { - return; - } - struct wlr_output_layout *layout = root->sway_root->output_layout; - struct wlr_output_layout_output *loutput = - wlr_output_layout_get(layout, output->sway_output->wlr_output); - if (!sway_assert(loutput, "output must be within layout to set position")) { - return; + double lx, ly; + if (view->swayc->is_floating) { + lx = x; + ly = y; + } else { + struct sway_container *output = container_parent(view->swayc, C_OUTPUT); + if (!sway_assert(output, "view must be within tree to set position")) { + return; + } + struct sway_container *root = container_parent(output, C_ROOT); + if (!sway_assert(root, "output must be within tree to set position")) { + return; + } + struct wlr_output_layout *layout = root->sway_root->output_layout; + struct wlr_output_layout_output *loutput = + wlr_output_layout_get(layout, output->sway_output->wlr_output); + if (!sway_assert(loutput, + "output must be within layout to set position")) { + return; + } + lx = x + loutput->x; + ly = y + loutput->y; } xwayland_view->pending_width = width; xwayland_view->pending_height = height; - wlr_xwayland_surface_configure(xsurface, ox + loutput->x, oy + loutput->y, - width, height); + wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); } static void set_activated(struct sway_view *view, bool activated) { @@ -189,6 +199,14 @@ static void set_activated(struct sway_view *view, bool activated) { wlr_xwayland_surface_activate(surface, activated); } +static void set_maximized(struct sway_view *view, bool maximized) { + if (xwayland_view_from_view(view) == NULL) { + return; + } + struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; + wlr_xwayland_surface_set_maximized(surface, maximized); +} + static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xwayland_view_from_view(view) == NULL) { return; @@ -197,6 +215,35 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { wlr_xwayland_surface_set_fullscreen(surface, fullscreen); } +static bool wants_floating(struct sway_view *view) { + // TODO: + // We want to return true if the window type contains any of these: + // NET_WM_WINDOW_TYPE_DIALOG + // NET_WM_WINDOW_TYPE_UTILITY + // NET_WM_WINDOW_TYPE_TOOLBAR + // NET_WM_WINDOW_TYPE_SPLASH + // + // We also want to return true if the NET_WM_STATE is MODAL. + // wlroots doesn't appear to provide all this information at the moment. + struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; + uint32_t *atom = xsurface->window_type; + for (size_t i = 0; i < xsurface->window_type_len; ++i) { + wlr_log(L_DEBUG, "xwayland window type %i", *atom); + // TODO: Come up with a better way of doing this + switch (*atom) { + case 36: // NET_WM_WINDOW_TYPE_UTILITY + case 44: // NET_WM_WINDOW_TYPE_SPLASH + case 276: // ? PGP passphrase dialog + case 337: // ? Firefox open file dialog + case 338: // ? Firefox open file dialog + return true; + } + ++atom; + } + + return false; +} + static void _close(struct sway_view *view) { if (xwayland_view_from_view(view) == NULL) { return; @@ -225,7 +272,9 @@ static const struct sway_view_impl view_impl = { .get_int_prop = get_int_prop, .configure = configure, .set_activated = set_activated, + .set_maximized = set_maximized, .set_fullscreen = set_fullscreen, + .wants_floating = wants_floating, .close = _close, .destroy = destroy, }; @@ -234,10 +283,18 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, commit); struct sway_view *view = &xwayland_view->view; - // NOTE: We intentionally discard the view's desired width here - // TODO: Let floating views do whatever - view_update_size(view, xwayland_view->pending_width, - xwayland_view->pending_height); + struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; + if (!view->natural_width && !view->natural_height) { + view->natural_width = xsurface->width; + view->natural_height = xsurface->height; + } + if (view->swayc && view->swayc->is_floating) { + view_update_size(view, xsurface->width, xsurface->height); + view_update_position(view, xsurface->x, xsurface->y); + } else { + view_update_size(view, xwayland_view->pending_width, + xwayland_view->pending_height); + } view_damage_from(view); } -- cgit v1.2.3 From 34f35f0badc767d9b0cbaf2fd429af1d30592d08 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 09:10:35 +1000 Subject: Use L_FLOATING instead of reapable boolean --- sway/desktop/output.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 1d21e80f..e91be4d4 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -754,6 +754,8 @@ static void render_container(struct sway_output *output, case L_TABBED: render_container_tabbed(output, damage, con, parent_focused); break; + case L_FLOATING: + sway_assert(false, "Didn't expect to see floating here"); } } -- cgit v1.2.3 From aaba7642b3e4e9a63aea49412b10221f399b17af Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 09:26:23 +1000 Subject: Replace is_floating boolean with function --- sway/desktop/output.c | 2 +- sway/desktop/xdg_shell.c | 2 +- sway/desktop/xdg_shell_v6.c | 2 +- sway/desktop/xwayland.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index e91be4d4..4e5d106f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -1147,7 +1147,7 @@ void output_damage_whole_container(struct sway_output *output, .width = con->width, .height = con->height, }; - if (con->is_floating) { + if (container_is_floating(con)) { box.x -= output->wlr_output->lx; box.y -= output->wlr_output->ly; } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index e1a73b20..ebb12211 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -185,7 +185,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { view->natural_width = geometry->width; view->natural_height = geometry->height; } - if (view->swayc && view->swayc->is_floating) { + if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, geometry->width, geometry->height); } else { view_update_size(view, xdg_shell_view->pending_width, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 47e4162a..f3df2fe8 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -184,7 +184,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { view->natural_width = geometry->width; view->natural_height = geometry->height; } - if (view->swayc && view->swayc->is_floating) { + if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, geometry->width, geometry->height); } else { view_update_size(view, xdg_shell_v6_view->pending_width, diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 56cac1bd..1373d968 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -163,7 +163,7 @@ static void configure(struct sway_view *view, double x, double y, int width, struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; double lx, ly; - if (view->swayc->is_floating) { + if (container_is_floating(view->swayc)) { lx = x; ly = y; } else { @@ -288,7 +288,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { view->natural_width = xsurface->width; view->natural_height = xsurface->height; } - if (view->swayc && view->swayc->is_floating) { + if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); view_update_position(view, xsurface->x, xsurface->y); } else { -- cgit v1.2.3 From 754cb7944c2f05b35e39dab9605a184ee9f53efd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 09:32:25 +1000 Subject: Respect view's border config for floating containers --- sway/desktop/output.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 4e5d106f..c0e368d0 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -810,8 +810,13 @@ static void render_floating_container(struct sway_output *soutput, title_texture = con->title_unfocused; marks_texture = view->marks_unfocused; } - render_titlebar(soutput, damage, con, con->x, con->y, con->width, - colors, title_texture, marks_texture); + + if (con->sway_view->border == B_NORMAL) { + render_titlebar(soutput, damage, con, con->x, con->y, con->width, + colors, title_texture, marks_texture); + } else { + render_top_border(soutput, damage, con, colors); + } render_view(soutput, damage, con, colors); } else { render_container(soutput, damage, con, false); -- cgit v1.2.3 From dc83b158e12ae33f03165cfd64a50aa7f0a52e26 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 15:39:14 +1000 Subject: Fix issues with sticky containers and workspaces * Attach sticky containers to new workspaces when switching * Fire the close event *before* we start destroying the workspace to prevent a crash Because the sticky container now follows the visible workspace, this simplifies the rendering and container_at logic. --- sway/desktop/output.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index c0e368d0..fb80fd87 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -832,12 +832,13 @@ static void render_floating(struct sway_output *soutput, for (int j = 0; j < output->children->length; ++j) { struct sway_container *workspace = output->children->items[j]; struct sway_workspace *ws = workspace->sway_workspace; - bool ws_is_visible = workspace_is_visible(workspace); + if (!workspace_is_visible(workspace)) { + continue; + } for (int k = 0; k < ws->floating->children->length; ++k) { struct sway_container *floater = ws->floating->children->items[k]; - if ((ws_is_visible || floater->is_sticky) - && floater_intersects_output(floater, soutput->swayc)) { + if (floater_intersects_output(floater, soutput->swayc)) { render_floating_container(soutput, damage, floater); } } -- cgit v1.2.3 From 02de2a6f65c189bf563cca5b4d3fbc11826ea7f7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 09:22:10 +1000 Subject: Rename set_maximized functions to set_tiled --- sway/desktop/xdg_shell.c | 6 +++--- sway/desktop/xdg_shell_v6.c | 6 +++--- sway/desktop/xwayland.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index ebb12211..73d9477f 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -111,12 +111,12 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_maximized(struct sway_view *view, bool maximized) { +static void set_tiled(struct sway_view *view, bool tiled) { if (xdg_shell_view_from_view(view) == NULL) { return; } struct wlr_xdg_surface *surface = view->wlr_xdg_surface; - wlr_xdg_toplevel_set_maximized(surface, maximized); + wlr_xdg_toplevel_set_maximized(surface, tiled); } static void set_fullscreen(struct sway_view *view, bool fullscreen) { @@ -168,7 +168,7 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_maximized = set_maximized, + .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index f3df2fe8..6c98744c 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -110,12 +110,12 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_maximized(struct sway_view *view, bool maximized) { +static void set_tiled(struct sway_view *view, bool tiled) { if (xdg_shell_v6_view_from_view(view) == NULL) { return; } struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6; - wlr_xdg_toplevel_v6_set_maximized(surface, maximized); + wlr_xdg_toplevel_v6_set_maximized(surface, tiled); } static void set_fullscreen(struct sway_view *view, bool fullscreen) { @@ -167,7 +167,7 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_maximized = set_maximized, + .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 1373d968..783868bc 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -199,12 +199,12 @@ static void set_activated(struct sway_view *view, bool activated) { wlr_xwayland_surface_activate(surface, activated); } -static void set_maximized(struct sway_view *view, bool maximized) { +static void set_tiled(struct sway_view *view, bool tiled) { if (xwayland_view_from_view(view) == NULL) { return; } struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; - wlr_xwayland_surface_set_maximized(surface, maximized); + wlr_xwayland_surface_set_maximized(surface, tiled); } static void set_fullscreen(struct sway_view *view, bool fullscreen) { @@ -272,7 +272,7 @@ static const struct sway_view_impl view_impl = { .get_int_prop = get_int_prop, .configure = configure, .set_activated = set_activated, - .set_maximized = set_maximized, + .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .close = _close, -- cgit v1.2.3 From e4e912ea91a5a36d9f17c1730ffbf29707984399 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 16:26:10 +1000 Subject: Store swayc coordinates as layout-local --- sway/desktop/output.c | 83 ++++++++++++++------------------------------- sway/desktop/xdg_shell.c | 4 +-- sway/desktop/xdg_shell_v6.c | 4 +-- sway/desktop/xwayland.c | 28 +-------------- 4 files changed, 30 insertions(+), 89 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index fb80fd87..8600d049 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -65,6 +65,13 @@ struct root_geometry { float rotation; }; +struct render_data { + struct root_geometry root_geo; + struct sway_output *output; + pixman_region32_t *damage; + float alpha; +}; + static bool get_surface_box(struct root_geometry *geo, struct sway_output *output, struct wlr_surface *surface, int sx, int sy, struct wlr_box *surface_box) { @@ -116,8 +123,9 @@ static void surface_for_each_surface(struct wlr_surface *surface, static void output_view_for_each_surface(struct sway_view *view, struct root_geometry *geo, wlr_surface_iterator_func_t iterator, void *user_data) { - geo->x = view->x; - geo->y = view->y; + struct render_data *data = user_data; + geo->x = view->x - data->output->wlr_output->lx; + geo->y = view->y - data->output->wlr_output->ly; geo->width = view->surface->current->width; geo->height = view->surface->current->height; geo->rotation = 0; // TODO @@ -160,13 +168,6 @@ static void scale_box(struct wlr_box *box, float scale) { box->height *= scale; } -struct render_data { - struct root_geometry root_geo; - struct sway_output *output; - pixman_region32_t *damage; - float alpha; -}; - static void scissor_output(struct wlr_output *wlr_output, pixman_box32_t *rect) { struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); @@ -275,7 +276,10 @@ static void render_rect(struct wlr_output *wlr_output, struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); - struct wlr_box box = *_box; + struct wlr_box box; + memcpy(&box, _box, sizeof(struct wlr_box)); + box.x -= wlr_output->lx * wlr_output->scale; + box.y -= wlr_output->ly * wlr_output->scale; pixman_region32_t damage; pixman_region32_init(&damage); @@ -450,8 +454,10 @@ static void render_titlebar(struct sway_output *output, wlr_texture_get_size(marks_texture, &texture_box.width, &texture_box.height); texture_box.x = - (x + width - TITLEBAR_H_PADDING) * output_scale - texture_box.width; - texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; + (x - output->wlr_output->lx + width - TITLEBAR_H_PADDING) + * output_scale - texture_box.width; + texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) + * output_scale; float matrix[9]; wlr_matrix_project_box(matrix, &texture_box, @@ -472,8 +478,10 @@ static void render_titlebar(struct sway_output *output, struct wlr_box texture_box; wlr_texture_get_size(title_texture, &texture_box.width, &texture_box.height); - texture_box.x = (x + TITLEBAR_H_PADDING) * output_scale; - texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; + texture_box.x = (x - output->wlr_output->lx + TITLEBAR_H_PADDING) + * output_scale; + texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) + * output_scale; float matrix[9]; wlr_matrix_project_box(matrix, &texture_box, @@ -771,28 +779,8 @@ static bool floater_intersects_output(struct sway_container *floater, output->sway_output->wlr_output, &box); } -static void container_translate(struct sway_container *con, int x, int y) { - con->x += x; - con->y += y; - if (con->type == C_VIEW) { - con->sway_view->x += x; - con->sway_view->y += y; - } else { - for (int i = 0; i < con->children->length; ++i) { - struct sway_container *child = con->children->items[i]; - container_translate(child, x, y); - } - } -} - static void render_floating_container(struct sway_output *soutput, pixman_region32_t *damage, struct sway_container *con) { - // We need to translate the floating container's coordinates from layout - // coordinates into output-local coordinates. This needs to happen for all - // children of the floating container too. - struct sway_container *output = container_parent(con, C_OUTPUT); - container_translate(con, -output->x, -output->y); - if (con->type == C_VIEW) { struct sway_view *view = con->sway_view; struct sway_seat *seat = input_manager_current_seat(input_manager); @@ -821,8 +809,6 @@ static void render_floating_container(struct sway_output *soutput, } else { render_container(soutput, damage, con, false); } - // Undo the translation - container_translate(con, output->x, output->y); } static void render_floating(struct sway_output *soutput, @@ -1123,15 +1109,7 @@ static void output_damage_view(struct sway_output *output, void output_damage_from_view(struct sway_output *output, struct sway_view *view) { - if (container_self_or_parent_floating(view->swayc)) { - view->x -= output->swayc->x; - view->y -= output->swayc->y; - output_damage_view(output, view, false); - view->x += output->swayc->x; - view->y += output->swayc->y; - } else { - output_damage_view(output, view, false); - } + output_damage_view(output, view, false); } static void output_damage_whole_container_iterator(struct sway_container *con, @@ -1148,24 +1126,13 @@ static void output_damage_whole_container_iterator(struct sway_container *con, void output_damage_whole_container(struct sway_output *output, struct sway_container *con) { struct wlr_box box = { - .x = con->x, - .y = con->y, + .x = con->x - output->wlr_output->lx, + .y = con->y - output->wlr_output->ly, .width = con->width, .height = con->height, }; - if (container_is_floating(con)) { - box.x -= output->wlr_output->lx; - box.y -= output->wlr_output->ly; - } scale_box(&box, output->wlr_output->scale); wlr_output_damage_add_box(output->damage, &box); - - if (con->type == C_VIEW) { - output_damage_whole_container_iterator(con, output); - } else { - container_descendants(con, C_VIEW, - output_damage_whole_container_iterator, output); - } } static void damage_handle_destroy(struct wl_listener *listener, void *data) { diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 73d9477f..412488b3 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -87,7 +87,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p } } -static void configure(struct sway_view *view, double ox, double oy, int width, +static void configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view); @@ -98,7 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width, xdg_shell_view->pending_width = width; xdg_shell_view->pending_height = height; wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); - view_update_position(view, ox, oy); + view_update_position(view, lx, ly); } static void set_activated(struct sway_view *view, bool activated) { diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 6c98744c..b3653913 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -86,7 +86,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p } } -static void configure(struct sway_view *view, double ox, double oy, int width, +static void configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = xdg_shell_v6_view_from_view(view); @@ -97,7 +97,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width, xdg_shell_v6_view->pending_width = width; xdg_shell_v6_view->pending_height = height; wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); - view_update_position(view, ox, oy); + view_update_position(view, lx, ly); } static void set_activated(struct sway_view *view, bool activated) { diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 783868bc..fc488162 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -152,9 +152,7 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) { } } -// The x and y arguments are output-local for tiled views, and layout -// coordinates for floating views. -static void configure(struct sway_view *view, double x, double y, int width, +static void configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); if (xwayland_view == NULL) { @@ -162,30 +160,6 @@ static void configure(struct sway_view *view, double x, double y, int width, } struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - double lx, ly; - if (container_is_floating(view->swayc)) { - lx = x; - ly = y; - } else { - struct sway_container *output = container_parent(view->swayc, C_OUTPUT); - if (!sway_assert(output, "view must be within tree to set position")) { - return; - } - struct sway_container *root = container_parent(output, C_ROOT); - if (!sway_assert(root, "output must be within tree to set position")) { - return; - } - struct wlr_output_layout *layout = root->sway_root->output_layout; - struct wlr_output_layout_output *loutput = - wlr_output_layout_get(layout, output->sway_output->wlr_output); - if (!sway_assert(loutput, - "output must be within layout to set position")) { - return; - } - lx = x + loutput->x; - ly = y + loutput->y; - } - xwayland_view->pending_width = width; xwayland_view->pending_height = height; wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); -- cgit v1.2.3 From 7d2b33a4589df5cd130936fcb2016fda4014123b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 16:26:59 +1000 Subject: Render floating views before top layer and unmanaged --- sway/desktop/output.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 8600d049..3dd10ac2 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -904,13 +904,12 @@ static void render_output(struct sway_output *output, struct timespec *when, struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *focus = seat_get_focus(seat); render_container(output, damage, workspace, focus == workspace); + render_floating(output, damage); render_unmanaged(output, damage, &root_container.sway_root->xwayland_unmanaged); render_layer(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); - - render_floating(output, damage); } render_layer(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); -- cgit v1.2.3 From 3281574fa3199d649401e69e3d41493957b7d690 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 16:30:18 +1000 Subject: Remove check for if floating view intersects output --- sway/desktop/output.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 3dd10ac2..f58c5332 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -767,18 +767,6 @@ static void render_container(struct sway_output *output, } } -static bool floater_intersects_output(struct sway_container *floater, - struct sway_container *output) { - struct wlr_box box = { - .x = floater->x, - .y = floater->y, - .width = floater->width, - .height = floater->height, - }; - return wlr_output_layout_intersects(root_container.sway_root->output_layout, - output->sway_output->wlr_output, &box); -} - static void render_floating_container(struct sway_output *soutput, pixman_region32_t *damage, struct sway_container *con) { if (con->type == C_VIEW) { @@ -824,9 +812,7 @@ static void render_floating(struct sway_output *soutput, for (int k = 0; k < ws->floating->children->length; ++k) { struct sway_container *floater = ws->floating->children->items[k]; - if (floater_intersects_output(floater, soutput->swayc)) { - render_floating_container(soutput, damage, floater); - } + render_floating_container(soutput, damage, floater); } } } -- cgit v1.2.3 From 4371c746e4d46c866ba4cdac2b3fba63a8de762e Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 20:04:59 +1000 Subject: Implement wants_floating for xdg_shell and xdg_shell_v6 --- sway/desktop/xdg_shell.c | 6 ++++-- sway/desktop/xdg_shell_v6.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 412488b3..ae6945c2 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -128,8 +128,10 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { } static bool wants_floating(struct sway_view *view) { - // TODO - return false; + struct wlr_xdg_toplevel_state *state = + &view->wlr_xdg_surface->toplevel->current; + return state->min_width == state->max_width + && state->min_height == state->max_height; } static void for_each_surface(struct sway_view *view, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index b3653913..fc0abf56 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -127,8 +127,10 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { } static bool wants_floating(struct sway_view *view) { - // TODO - return false; + struct wlr_xdg_toplevel_v6_state *state = + &view->wlr_xdg_surface_v6->toplevel->current; + return state->min_width == state->max_width + && state->min_height == state->max_height; } static void for_each_surface(struct sway_view *view, -- cgit v1.2.3 From 3b1db30a5e5758ec099b79250681cbf4be5ae0e9 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 20:37:04 +1000 Subject: Use surface size if xdg shell's geometry isn't set --- sway/desktop/xdg_shell.c | 13 +++++++++---- sway/desktop/xdg_shell_v6.c | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index ae6945c2..30990f67 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -182,13 +182,18 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, commit); struct sway_view *view = &xdg_shell_view->view; - struct wlr_box *geometry = &view->wlr_xdg_surface->geometry; + int width = view->wlr_xdg_surface->geometry.width; + int height = view->wlr_xdg_surface->geometry.height; + if (!width && !height) { + width = view->wlr_xdg_surface->surface->current->width; + height = view->wlr_xdg_surface->surface->current->height; + } if (!view->natural_width && !view->natural_height) { - view->natural_width = geometry->width; - view->natural_height = geometry->height; + view->natural_width = width; + view->natural_height = height; } if (view->swayc && container_is_floating(view->swayc)) { - view_update_size(view, geometry->width, geometry->height); + view_update_size(view, width, height); } else { view_update_size(view, xdg_shell_view->pending_width, xdg_shell_view->pending_height); diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index fc0abf56..7cba6e49 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -181,13 +181,18 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = wl_container_of(listener, xdg_shell_v6_view, commit); struct sway_view *view = &xdg_shell_v6_view->view; - struct wlr_box *geometry = &view->wlr_xdg_surface_v6->geometry; + int width = view->wlr_xdg_surface_v6->geometry.width; + int height = view->wlr_xdg_surface_v6->geometry.height; + if (!width && !height) { + width = view->wlr_xdg_surface_v6->surface->current->width; + height = view->wlr_xdg_surface_v6->surface->current->height; + } if (!view->natural_width && !view->natural_height) { - view->natural_width = geometry->width; - view->natural_height = geometry->height; + view->natural_width = width; + view->natural_height = height; } if (view->swayc && container_is_floating(view->swayc)) { - view_update_size(view, geometry->width, geometry->height); + view_update_size(view, width, height); } else { view_update_size(view, xdg_shell_v6_view->pending_width, xdg_shell_v6_view->pending_height); -- cgit v1.2.3 From 02d385e06f9ca6baccc9fdb35d4ab10532b6c22c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 21:12:10 +1000 Subject: Use swayc rather than wlr_output when rendering --- sway/desktop/output.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index f58c5332..4047fa3f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -124,8 +124,8 @@ static void output_view_for_each_surface(struct sway_view *view, struct root_geometry *geo, wlr_surface_iterator_func_t iterator, void *user_data) { struct render_data *data = user_data; - geo->x = view->x - data->output->wlr_output->lx; - geo->y = view->y - data->output->wlr_output->ly; + geo->x = view->x - data->output->swayc->x; + geo->y = view->y - data->output->swayc->y; geo->width = view->surface->current->width; geo->height = view->surface->current->height; geo->rotation = 0; // TODO @@ -453,10 +453,9 @@ static void render_titlebar(struct sway_output *output, struct wlr_box texture_box; wlr_texture_get_size(marks_texture, &texture_box.width, &texture_box.height); - texture_box.x = - (x - output->wlr_output->lx + width - TITLEBAR_H_PADDING) + texture_box.x = (x - output->swayc->x + width - TITLEBAR_H_PADDING) * output_scale - texture_box.width; - texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) + texture_box.y = (y - output->swayc->y + TITLEBAR_V_PADDING) * output_scale; float matrix[9]; @@ -478,9 +477,9 @@ static void render_titlebar(struct sway_output *output, struct wlr_box texture_box; wlr_texture_get_size(title_texture, &texture_box.width, &texture_box.height); - texture_box.x = (x - output->wlr_output->lx + TITLEBAR_H_PADDING) + texture_box.x = (x - output->swayc->x + TITLEBAR_H_PADDING) * output_scale; - texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) + texture_box.y = (y - output->swayc->y + TITLEBAR_V_PADDING) * output_scale; float matrix[9]; -- cgit v1.2.3 From 5b1601c2e32b43cbb253fcd396ab9096f51b7e6c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 21:33:18 +1000 Subject: Don't let xwayland views set position unless unmanaged --- sway/desktop/xwayland.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index fc488162..f3264ddc 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -160,6 +160,8 @@ static void configure(struct sway_view *view, double lx, double ly, int width, } struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; + xwayland_view->pending_lx = lx; + xwayland_view->pending_ly = ly; xwayland_view->pending_width = width; xwayland_view->pending_height = height; wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); @@ -264,7 +266,8 @@ static void handle_commit(struct wl_listener *listener, void *data) { } if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); - view_update_position(view, xsurface->x, xsurface->y); + view_update_position(view, + xwayland_view->pending_lx, xwayland_view->pending_ly); } else { view_update_size(view, xwayland_view->pending_width, xwayland_view->pending_height); -- cgit v1.2.3 From becceafa7f12f1a1668daca0b27c4102282d9076 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 23:45:27 +1000 Subject: Remove unfinished wants_floating implementation for xwayland --- sway/desktop/xwayland.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index f3264ddc..7dc860aa 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -201,22 +201,6 @@ static bool wants_floating(struct sway_view *view) { // // We also want to return true if the NET_WM_STATE is MODAL. // wlroots doesn't appear to provide all this information at the moment. - struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - uint32_t *atom = xsurface->window_type; - for (size_t i = 0; i < xsurface->window_type_len; ++i) { - wlr_log(L_DEBUG, "xwayland window type %i", *atom); - // TODO: Come up with a better way of doing this - switch (*atom) { - case 36: // NET_WM_WINDOW_TYPE_UTILITY - case 44: // NET_WM_WINDOW_TYPE_SPLASH - case 276: // ? PGP passphrase dialog - case 337: // ? Firefox open file dialog - case 338: // ? Firefox open file dialog - return true; - } - ++atom; - } - return false; } -- cgit v1.2.3 From 97672295ed50d1d6272876c4a3b6b5607cab05c6 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 27 May 2018 23:43:05 +1000 Subject: Don't unmaximize floating views --- sway/desktop/xdg_shell.c | 9 --------- sway/desktop/xdg_shell_v6.c | 9 --------- sway/desktop/xwayland.c | 9 --------- 3 files changed, 27 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 30990f67..7a39a84c 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -111,14 +111,6 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_tiled(struct sway_view *view, bool tiled) { - if (xdg_shell_view_from_view(view) == NULL) { - return; - } - struct wlr_xdg_surface *surface = view->wlr_xdg_surface; - wlr_xdg_toplevel_set_maximized(surface, tiled); -} - static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xdg_shell_view_from_view(view) == NULL) { return; @@ -170,7 +162,6 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 7cba6e49..b1b8091b 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -110,14 +110,6 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_tiled(struct sway_view *view, bool tiled) { - if (xdg_shell_v6_view_from_view(view) == NULL) { - return; - } - struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6; - wlr_xdg_toplevel_v6_set_maximized(surface, tiled); -} - static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xdg_shell_v6_view_from_view(view) == NULL) { return; @@ -169,7 +161,6 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 7dc860aa..d0fbcaeb 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -175,14 +175,6 @@ static void set_activated(struct sway_view *view, bool activated) { wlr_xwayland_surface_activate(surface, activated); } -static void set_tiled(struct sway_view *view, bool tiled) { - if (xwayland_view_from_view(view) == NULL) { - return; - } - struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; - wlr_xwayland_surface_set_maximized(surface, tiled); -} - static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xwayland_view_from_view(view) == NULL) { return; @@ -232,7 +224,6 @@ static const struct sway_view_impl view_impl = { .get_int_prop = get_int_prop, .configure = configure, .set_activated = set_activated, - .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .close = _close, -- cgit v1.2.3 From 9119f876552a47716bd317524bf5d786f909e5e5 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 30 May 2018 10:22:35 +1000 Subject: Fix floating position when view is floated when mapped --- sway/desktop/xdg_shell.c | 22 ++++++++++++---------- sway/desktop/xdg_shell_v6.c | 22 ++++++++++++---------- sway/desktop/xwayland.c | 7 +++---- 3 files changed, 27 insertions(+), 24 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 7a39a84c..32d1e3ca 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -173,17 +173,13 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, commit); struct sway_view *view = &xdg_shell_view->view; - int width = view->wlr_xdg_surface->geometry.width; - int height = view->wlr_xdg_surface->geometry.height; - if (!width && !height) { - width = view->wlr_xdg_surface->surface->current->width; - height = view->wlr_xdg_surface->surface->current->height; - } - if (!view->natural_width && !view->natural_height) { - view->natural_width = width; - view->natural_height = height; - } if (view->swayc && container_is_floating(view->swayc)) { + int width = view->wlr_xdg_surface->geometry.width; + int height = view->wlr_xdg_surface->geometry.height; + if (!width && !height) { + width = view->wlr_xdg_surface->surface->current->width; + height = view->wlr_xdg_surface->surface->current->height; + } view_update_size(view, width, height); } else { view_update_size(view, xdg_shell_view->pending_width, @@ -216,6 +212,12 @@ static void handle_map(struct wl_listener *listener, void *data) { struct sway_view *view = &xdg_shell_view->view; struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; + view->natural_width = view->wlr_xdg_surface->geometry.width; + view->natural_height = view->wlr_xdg_surface->geometry.height; + if (!view->natural_width && !view->natural_height) { + view->natural_width = view->wlr_xdg_surface->surface->current->width; + view->natural_height = view->wlr_xdg_surface->surface->current->height; + } view_map(view, view->wlr_xdg_surface->surface); xdg_shell_view->commit.notify = handle_commit; diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index b1b8091b..6cb489db 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -172,17 +172,13 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = wl_container_of(listener, xdg_shell_v6_view, commit); struct sway_view *view = &xdg_shell_v6_view->view; - int width = view->wlr_xdg_surface_v6->geometry.width; - int height = view->wlr_xdg_surface_v6->geometry.height; - if (!width && !height) { - width = view->wlr_xdg_surface_v6->surface->current->width; - height = view->wlr_xdg_surface_v6->surface->current->height; - } - if (!view->natural_width && !view->natural_height) { - view->natural_width = width; - view->natural_height = height; - } if (view->swayc && container_is_floating(view->swayc)) { + int width = view->wlr_xdg_surface_v6->geometry.width; + int height = view->wlr_xdg_surface_v6->geometry.height; + if (!width && !height) { + width = view->wlr_xdg_surface_v6->surface->current->width; + height = view->wlr_xdg_surface_v6->surface->current->height; + } view_update_size(view, width, height); } else { view_update_size(view, xdg_shell_v6_view->pending_width, @@ -215,6 +211,12 @@ static void handle_map(struct wl_listener *listener, void *data) { struct sway_view *view = &xdg_shell_v6_view->view; struct wlr_xdg_surface_v6 *xdg_surface = view->wlr_xdg_surface_v6; + view->natural_width = view->wlr_xdg_surface_v6->geometry.width; + view->natural_height = view->wlr_xdg_surface_v6->geometry.height; + if (!view->natural_width && !view->natural_height) { + view->natural_width = view->wlr_xdg_surface_v6->surface->current->width; + view->natural_height = view->wlr_xdg_surface_v6->surface->current->height; + } view_map(view, view->wlr_xdg_surface_v6->surface); xdg_shell_v6_view->commit.notify = handle_commit; diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index d0fbcaeb..76265ea9 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -235,10 +235,6 @@ static void handle_commit(struct wl_listener *listener, void *data) { wl_container_of(listener, xwayland_view, commit); struct sway_view *view = &xwayland_view->view; struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - if (!view->natural_width && !view->natural_height) { - view->natural_width = xsurface->width; - view->natural_height = xsurface->height; - } if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); view_update_position(view, @@ -263,6 +259,9 @@ static void handle_map(struct wl_listener *listener, void *data) { struct wlr_xwayland_surface *xsurface = data; struct sway_view *view = &xwayland_view->view; + view->natural_width = xsurface->width; + view->natural_height = xsurface->height; + // Wire up the commit listener here, because xwayland map/unmap can change // the underlying wlr_surface wl_signal_add(&xsurface->surface->events.commit, &xwayland_view->commit); -- cgit v1.2.3 From c9e3a313b440c171ae0bf78eb5b85bf63c3121b9 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 31 May 2018 08:30:07 +1000 Subject: Fix fullscreen position of xwayland views --- sway/desktop/xwayland.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 76265ea9..75bfb7b2 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -237,12 +237,12 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); - view_update_position(view, - xwayland_view->pending_lx, xwayland_view->pending_ly); } else { view_update_size(view, xwayland_view->pending_width, xwayland_view->pending_height); } + view_update_position(view, + xwayland_view->pending_lx, xwayland_view->pending_ly); view_damage_from(view); } -- cgit v1.2.3 From d466b8fa7b5ba8dff4b5ea5520aa523f50815316 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 31 May 2018 21:58:28 +1000 Subject: Don't auto float xdg views if their dimensions are not set --- sway/desktop/xdg_shell.c | 3 ++- sway/desktop/xdg_shell_v6.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sway/desktop') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 32d1e3ca..d2b8822c 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -122,7 +122,8 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { static bool wants_floating(struct sway_view *view) { struct wlr_xdg_toplevel_state *state = &view->wlr_xdg_surface->toplevel->current; - return state->min_width == state->max_width + return state->min_width != 0 && state->min_height != 0 + && state->min_width == state->max_width && state->min_height == state->max_height; } diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 6cb489db..6ffe334a 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -121,7 +121,8 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { static bool wants_floating(struct sway_view *view) { struct wlr_xdg_toplevel_v6_state *state = &view->wlr_xdg_surface_v6->toplevel->current; - return state->min_width == state->max_width + return state->min_width != 0 && state->min_height != 0 + && state->min_width == state->max_width && state->min_height == state->max_height; } -- cgit v1.2.3