From 659871de1eacc7d6ad1a153cae160c818ef1739a Mon Sep 17 00:00:00 2001 From: Armin Preiml Date: Sat, 30 Jun 2018 10:29:32 +0200 Subject: [PATCH 1/6] fix swaymsg: errors are displayed again Command errors didn't get displayed, because the success function didn't accept objects --- swaymsg/main.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/swaymsg/main.c b/swaymsg/main.c index 29f2a907c..398822939 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -19,30 +19,44 @@ void sway_terminate(int exit_code) { exit(exit_code); } +static bool success_object(json_object *result) { + json_object *success; + + if (!json_object_object_get_ex(result, "success", &success)) { + return false; + } + + if (!json_object_get_boolean(success)) { + return false; + } + + return true; +} + // Iterate results array and return false if any of them failed static bool success(json_object *r, bool fallback) { if (!json_object_is_type(r, json_type_array)) { return fallback; } + size_t results_len = json_object_array_length(r); if (!results_len) { return fallback; } + for (size_t i = 0; i < results_len; ++i) { json_object *result = json_object_array_get_idx(r, i); - json_object *success; - if (!json_object_object_get_ex(result, "success", &success)) { - return false; - } - if (!json_object_get_boolean(success)) { + + if (!success_object(result)) { return false; } } + return true; } static void pretty_print_cmd(json_object *r) { - if (!success(r, true)) { + if (!success_object(r)) { json_object *error; if (!json_object_object_get_ex(r, "error", &error)) { printf("An unknkown error occurred"); @@ -402,6 +416,7 @@ int main(int argc, char **argv) { } else { sway_abort("Unknown message type %s", cmdtype); } + free(cmdtype); char *command = NULL; From 354648cc073a4cb0c35862e68175b918c31c3104 Mon Sep 17 00:00:00 2001 From: Armin Preiml Date: Sat, 30 Jun 2018 10:38:16 +0200 Subject: [PATCH 2/6] refactor success_object --- swaymsg/main.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/swaymsg/main.c b/swaymsg/main.c index 398822939..4283bf00c 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -26,11 +26,7 @@ static bool success_object(json_object *result) { return false; } - if (!json_object_get_boolean(success)) { - return false; - } - - return true; + return json_object_get_boolean(success); } // Iterate results array and return false if any of them failed From 4de28bba68d01bafc40ebb270227d5d8fe0ddd87 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 29 Jun 2018 23:07:59 +0100 Subject: [PATCH 3/6] Fix floating views not receiving frame events That happened when they were in tabbed or stacked containers. Fixes #2161 --- sway/tree/view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/tree/view.c b/sway/tree/view.c index c9c824053..de4ce2e64 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -948,7 +948,7 @@ bool view_is_visible(struct sway_view *view) { // Check view isn't in a tabbed or stacked container on an inactive tab struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *container = view->swayc; - while (container->type != C_WORKSPACE) { + while (container->type != C_WORKSPACE && container->layout != L_FLOATING) { if (container->parent->layout == L_TABBED || container->parent->layout == L_STACKED) { if (seat_get_active_child(seat, container->parent) != container) { From e0d0e8f840271ab12533cb16c9a7ccba237adcb3 Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Wed, 27 Jun 2018 17:53:13 +0100 Subject: [PATCH 4/6] Revert "Don't unmaximize floating views" This reverts commit 97672295ed50d1d6272876c4a3b6b5607cab05c6. --- include/sway/tree/view.h | 3 +++ sway/desktop/output.c | 4 ++-- sway/desktop/xdg_shell.c | 16 ++++++++++++++-- sway/desktop/xdg_shell_v6.c | 10 +++++++++- sway/desktop/xwayland.c | 10 +++++++++- sway/tree/container.c | 3 +++ sway/tree/view.c | 11 +++++++++++ 7 files changed, 51 insertions(+), 6 deletions(-) diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 3df38e2d8..918652324 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -32,6 +32,7 @@ struct sway_view_impl { void (*configure)(struct sway_view *view, double lx, double ly, int width, int height); void (*set_activated)(struct sway_view *view, bool activated); + void (*set_tiled)(struct sway_view *view, bool tiled); void (*set_fullscreen)(struct sway_view *view, bool fullscreen); bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, @@ -223,6 +224,8 @@ void view_autoconfigure(struct sway_view *view); void view_set_activated(struct sway_view *view, bool activated); +void view_set_tiled(struct sway_view *view, bool tiled); + void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); void view_set_fullscreen(struct sway_view *view, bool fullscreen); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index f0f1603a9..e1c44a28c 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -645,7 +645,7 @@ static void render_container_simple(struct sway_output *output, if (child->sway_view->border == B_NORMAL) { render_titlebar(output, damage, child, child->x, child->y, child->width, colors, title_texture, marks_texture); - } else { + } else if (con->sway_view->border != B_NONE) { render_top_border(output, damage, child, colors); } render_view(output, damage, child, colors); @@ -815,7 +815,7 @@ static void render_floating_container(struct sway_output *soutput, if (con->sway_view->border == B_NORMAL) { render_titlebar(soutput, damage, con, con->x, con->y, con->width, colors, title_texture, marks_texture); - } else { + } else if (con->sway_view->border != B_NONE) { render_top_border(soutput, damage, con, colors); } render_view(soutput, damage, con, colors); diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 8457c06bc..6ac0f9c7f 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -111,6 +111,19 @@ 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; + enum wlr_edges edges = WLR_EDGE_NONE; + if (tiled) { + edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | + WLR_EDGE_BOTTOM; + } + wlr_xdg_toplevel_set_tiled(surface, edges); +} + static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xdg_shell_view_from_view(view) == NULL) { return; @@ -164,6 +177,7 @@ 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, @@ -273,8 +287,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'", xdg_surface->toplevel->title, xdg_surface->toplevel->app_id); wlr_xdg_surface_ping(xdg_surface); - wlr_xdg_toplevel_set_tiled(xdg_surface, WLR_EDGE_LEFT | WLR_EDGE_RIGHT | - WLR_EDGE_TOP | WLR_EDGE_BOTTOM); struct sway_xdg_shell_view *xdg_shell_view = calloc(1, sizeof(struct sway_xdg_shell_view)); diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index eb1cef265..a37a4caff 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -110,6 +110,14 @@ 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; @@ -164,6 +172,7 @@ 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, @@ -273,7 +282,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { wlr_log(L_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'", xdg_surface->toplevel->title, xdg_surface->toplevel->app_id); wlr_xdg_surface_v6_ping(xdg_surface); - wlr_xdg_toplevel_v6_set_maximized(xdg_surface, true); struct sway_xdg_shell_v6_view *xdg_shell_v6_view = calloc(1, sizeof(struct sway_xdg_shell_v6_view)); diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index df5f66982..fcc8164f0 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -199,6 +199,14 @@ 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; @@ -265,6 +273,7 @@ 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, @@ -309,7 +318,6 @@ static void handle_map(struct wl_listener *listener, void *data) { xwayland_view->commit.notify = handle_commit; // Put it back into the tree - wlr_xwayland_surface_set_maximized(xsurface, true); view_map(view, xsurface->surface); if (xsurface->fullscreen) { diff --git a/sway/tree/container.c b/sway/tree/container.c index af55a54e7..d8d5c34a4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -943,6 +943,9 @@ void container_set_floating(struct sway_container *container, bool enable) { container_add_child(workspace, container); container->width = container->parent->width; container->height = container->parent->height; + if (container->type == C_VIEW) { + view_set_tiled(container->sway_view, true); + } container->is_sticky = false; container_reap_empty_recursive(workspace->sway_workspace->floating); } diff --git a/sway/tree/view.c b/sway/tree/view.c index de4ce2e64..98637c33b 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -141,6 +141,9 @@ static void view_autoconfigure_floating(struct sway_view *view) { view->border_top = view->border_bottom = true; view->border_left = view->border_right = true; + // Don't maximize floating windows + view_set_tiled(view, false); + view_configure(view, lx, ly, width, height); } @@ -248,6 +251,7 @@ void view_autoconfigure(struct sway_view *view) { view->x = x; view->y = y; + view_set_tiled(view, true); view_configure(view, x, y, width, height); } @@ -257,6 +261,13 @@ void view_set_activated(struct sway_view *view, bool activated) { } } +void view_set_tiled(struct sway_view *view, bool tiled) { + view->border = tiled ? config->border : B_NONE; + if (view->impl->set_tiled) { + view->impl->set_tiled(view, tiled); + } +} + // Set fullscreen, but without IPC events or arranging windows. void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { if (view->is_fullscreen == fullscreen) { From f42bf0ad4abe185200b68ebce4848b80366cc474 Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Sat, 30 Jun 2018 11:11:06 +0100 Subject: [PATCH 5/6] container_at_view: don't offset the view by the window geometry Fixes floating window input offsets. As discussed on IRC with emersion, this shouldn't have been done in the first place. --- sway/tree/container.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index d8d5c34a4..2de0c7a8b 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -507,21 +507,11 @@ static struct sway_container *container_at_view(struct sway_container *swayc, view_sx, view_sy, &_sx, &_sy); break; case SWAY_VIEW_XDG_SHELL_V6: - // the top left corner of the sway container is the - // coordinate of the top left corner of the window geometry - view_sx += sview->wlr_xdg_surface_v6->geometry.x; - view_sy += sview->wlr_xdg_surface_v6->geometry.y; - _surface = wlr_xdg_surface_v6_surface_at( sview->wlr_xdg_surface_v6, view_sx, view_sy, &_sx, &_sy); break; case SWAY_VIEW_XDG_SHELL: - // the top left corner of the sway container is the - // coordinate of the top left corner of the window geometry - view_sx += sview->wlr_xdg_surface->geometry.x; - view_sy += sview->wlr_xdg_surface->geometry.y; - _surface = wlr_xdg_surface_surface_at( sview->wlr_xdg_surface, view_sx, view_sy, &_sx, &_sy); From 0cc24dd9c8b7329c91ae5ebd6ebd13b874eaab17 Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Sat, 30 Jun 2018 12:45:49 +0100 Subject: [PATCH 6/6] Fix crash with stacking layout after f42bf0ad4 The "simple" rendering function only applies to tiled views. --- sway/desktop/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index e1c44a28c..6244ca4a3 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -645,7 +645,7 @@ static void render_container_simple(struct sway_output *output, if (child->sway_view->border == B_NORMAL) { render_titlebar(output, damage, child, child->x, child->y, child->width, colors, title_texture, marks_texture); - } else if (con->sway_view->border != B_NONE) { + } else { render_top_border(output, damage, child, colors); } render_view(output, damage, child, colors);