diff options
author | Brian Ashworth <RedSoxFan@users.noreply.github.com> | 2018-07-16 22:21:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-16 22:21:00 -0400 |
commit | f516dbfb6d3380de24751de9a3f3156ece869e02 (patch) | |
tree | fb23163603e5ac4221d6ee27ff91dffb19e3295f | |
parent | db3a36373435a34b8d0a5fc4e90eacaa2b1dae6b (diff) | |
parent | 10fc7a5b494822a944bbada33b2cb25926447d76 (diff) |
Merge pull request #2286 from RyanDwyer/default-floating-border
Implement default_floating_border command and adjust CSD behaviour
-rw-r--r-- | include/sway/tree/view.h | 1 | ||||
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/default_floating_border.c | 29 | ||||
-rw-r--r-- | sway/desktop/render.c | 32 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/tree/container.c | 11 | ||||
-rw-r--r-- | sway/tree/view.c | 18 |
7 files changed, 72 insertions, 21 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 9022f7a6..e270f851 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -69,6 +69,7 @@ struct sway_view { bool border_bottom; bool border_left; bool border_right; + bool using_csd; struct timespec urgent; bool allow_request_urgent; diff --git a/sway/commands.c b/sway/commands.c index 27329602..a3e6a500 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -98,6 +98,7 @@ static struct cmd_handler handlers[] = { { "client.unfocused", cmd_client_unfocused }, { "client.urgent", cmd_client_urgent }, { "default_border", cmd_default_border }, + { "default_floating_border", cmd_default_floating_border }, { "exec", cmd_exec }, { "exec_always", cmd_exec_always }, { "floating_maximum_size", cmd_floating_maximum_size }, diff --git a/sway/commands/default_floating_border.c b/sway/commands/default_floating_border.c new file mode 100644 index 00000000..1bfc24af --- /dev/null +++ b/sway/commands/default_floating_border.c @@ -0,0 +1,29 @@ +#include "log.h" +#include "sway/commands.h" +#include "sway/config.h" +#include "sway/tree/container.h" + +struct cmd_results *cmd_default_floating_border(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "default_floating_border", + EXPECTED_AT_LEAST, 1))) { + return error; + } + + if (strcmp(argv[0], "none") == 0) { + config->floating_border = B_NONE; + } else if (strcmp(argv[0], "normal") == 0) { + config->floating_border = B_NORMAL; + } else if (strcmp(argv[0], "pixel") == 0) { + config->floating_border = B_PIXEL; + } else { + return cmd_results_new(CMD_INVALID, "default_floating_border", + "Expected 'default_floating_border <none|normal|pixel>' " + "or 'default_floating_border <normal|pixel> <px>'"); + } + if (argc == 2) { + config->floating_border_thickness = atoi(argv[1]); + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/desktop/render.c b/sway/desktop/render.c index cb995215..4c85e516 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -256,6 +256,10 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, render_view_surfaces(view, output, damage, view->swayc->alpha); } + if (view->using_csd) { + return; + } + struct wlr_box box; float output_scale = output->wlr_output->scale; float color[4]; @@ -571,12 +575,14 @@ static void render_container_simple(struct sway_output *output, marks_texture = view->marks_unfocused; } - if (state->border == B_NORMAL) { - render_titlebar(output, damage, child, state->swayc_x, - state->swayc_y, state->swayc_width, colors, - title_texture, marks_texture); - } else { - render_top_border(output, damage, child, colors); + if (!view->using_csd) { + if (state->border == B_NORMAL) { + render_titlebar(output, damage, child, state->swayc_x, + state->swayc_y, state->swayc_width, colors, + title_texture, marks_texture); + } else { + render_top_border(output, damage, child, colors); + } } render_view(output, damage, child, colors); } else { @@ -761,12 +767,14 @@ static void render_floating_container(struct sway_output *soutput, marks_texture = view->marks_unfocused; } - if (con->current.border == B_NORMAL) { - render_titlebar(soutput, damage, con, con->current.swayc_x, - con->current.swayc_y, con->current.swayc_width, colors, - title_texture, marks_texture); - } else if (con->current.border != B_NONE) { - render_top_border(soutput, damage, con, colors); + if (!view->using_csd) { + if (con->current.border == B_NORMAL) { + render_titlebar(soutput, damage, con, con->current.swayc_x, + con->current.swayc_y, con->current.swayc_width, colors, + title_texture, marks_texture); + } else if (con->current.border != B_NONE) { + render_top_border(soutput, damage, con, colors); + } } render_view(soutput, damage, con, colors); } else { diff --git a/sway/meson.build b/sway/meson.build index 23e54a62..c58d3470 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -35,6 +35,7 @@ sway_sources = files( 'commands/border.c', 'commands/client.c', 'commands/default_border.c', + 'commands/default_floating_border.c', 'commands/default_orientation.c', 'commands/exit.c', 'commands/exec.c', diff --git a/sway/tree/container.c b/sway/tree/container.c index 6d52c38c..3f9d701a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -967,9 +967,14 @@ void container_set_geometry_from_floating_view(struct sway_container *con) { return; } struct sway_view *view = con->sway_view; - size_t border_width = view->border_thickness * (view->border != B_NONE); - size_t top = - view->border == B_NORMAL ? container_titlebar_height() : border_width; + size_t border_width = 0; + size_t top = 0; + + if (!view->using_csd) { + border_width = view->border_thickness * (view->border != B_NONE); + top = view->border == B_NORMAL ? + container_titlebar_height() : border_width; + } con->x = view->x - border_width; con->y = view->y - top; diff --git a/sway/tree/view.c b/sway/tree/view.c index 8d8d213a..70ab9364 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -316,11 +316,15 @@ void view_set_activated(struct sway_view *view, bool activated) { } void view_set_tiled(struct sway_view *view, bool tiled) { - bool csd = true; - if (view->impl->has_client_side_decorations) { - csd = view->impl->has_client_side_decorations(view); + if (!tiled) { + view->using_csd = true; + if (view->impl->has_client_side_decorations) { + view->using_csd = view->impl->has_client_side_decorations(view); + } + } else { + view->using_csd = false; } - view->border = tiled || !csd ? config->border : B_NONE; + if (view->impl->set_tiled) { view->impl->set_tiled(view, tiled); } @@ -573,8 +577,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { view->surface = wlr_surface; view->swayc = cont; - view->border = config->border; - view->border_thickness = config->border_thickness; view_init_subsurfaces(view, wlr_surface); wl_signal_add(&wlr_surface->events.new_subsurface, @@ -585,8 +587,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { view->container_reparent.notify = view_handle_container_reparent; if (view->impl->wants_floating && view->impl->wants_floating(view)) { + view->border = config->floating_border; + view->border_thickness = config->floating_border_thickness; container_set_floating(view->swayc, true); } else { + view->border = config->border; + view->border_thickness = config->border_thickness; view_set_tiled(view, true); } |