summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <RedSoxFan@users.noreply.github.com>2018-07-16 22:21:00 -0400
committerLibravatar GitHub <noreply@github.com>2018-07-16 22:21:00 -0400
commitf516dbfb6d3380de24751de9a3f3156ece869e02 (patch)
treefb23163603e5ac4221d6ee27ff91dffb19e3295f
parentRevert "config: free include path on successful load" (diff)
parentMerge branch 'master' into default-floating-border (diff)
downloadsway-f516dbfb6d3380de24751de9a3f3156ece869e02.tar.gz
sway-f516dbfb6d3380de24751de9a3f3156ece869e02.tar.zst
sway-f516dbfb6d3380de24751de9a3f3156ece869e02.zip
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.h1
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/default_floating_border.c29
-rw-r--r--sway/desktop/render.c32
-rw-r--r--sway/meson.build1
-rw-r--r--sway/tree/container.c11
-rw-r--r--sway/tree/view.c18
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 {
69 bool border_bottom; 69 bool border_bottom;
70 bool border_left; 70 bool border_left;
71 bool border_right; 71 bool border_right;
72 bool using_csd;
72 73
73 struct timespec urgent; 74 struct timespec urgent;
74 bool allow_request_urgent; 75 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[] = {
98 { "client.unfocused", cmd_client_unfocused }, 98 { "client.unfocused", cmd_client_unfocused },
99 { "client.urgent", cmd_client_urgent }, 99 { "client.urgent", cmd_client_urgent },
100 { "default_border", cmd_default_border }, 100 { "default_border", cmd_default_border },
101 { "default_floating_border", cmd_default_floating_border },
101 { "exec", cmd_exec }, 102 { "exec", cmd_exec },
102 { "exec_always", cmd_exec_always }, 103 { "exec_always", cmd_exec_always },
103 { "floating_maximum_size", cmd_floating_maximum_size }, 104 { "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 @@
1#include "log.h"
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "sway/tree/container.h"
5
6struct cmd_results *cmd_default_floating_border(int argc, char **argv) {
7 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "default_floating_border",
9 EXPECTED_AT_LEAST, 1))) {
10 return error;
11 }
12
13 if (strcmp(argv[0], "none") == 0) {
14 config->floating_border = B_NONE;
15 } else if (strcmp(argv[0], "normal") == 0) {
16 config->floating_border = B_NORMAL;
17 } else if (strcmp(argv[0], "pixel") == 0) {
18 config->floating_border = B_PIXEL;
19 } else {
20 return cmd_results_new(CMD_INVALID, "default_floating_border",
21 "Expected 'default_floating_border <none|normal|pixel>' "
22 "or 'default_floating_border <normal|pixel> <px>'");
23 }
24 if (argc == 2) {
25 config->floating_border_thickness = atoi(argv[1]);
26 }
27
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
29}
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,
256 render_view_surfaces(view, output, damage, view->swayc->alpha); 256 render_view_surfaces(view, output, damage, view->swayc->alpha);
257 } 257 }
258 258
259 if (view->using_csd) {
260 return;
261 }
262
259 struct wlr_box box; 263 struct wlr_box box;
260 float output_scale = output->wlr_output->scale; 264 float output_scale = output->wlr_output->scale;
261 float color[4]; 265 float color[4];
@@ -571,12 +575,14 @@ static void render_container_simple(struct sway_output *output,
571 marks_texture = view->marks_unfocused; 575 marks_texture = view->marks_unfocused;
572 } 576 }
573 577
574 if (state->border == B_NORMAL) { 578 if (!view->using_csd) {
575 render_titlebar(output, damage, child, state->swayc_x, 579 if (state->border == B_NORMAL) {
576 state->swayc_y, state->swayc_width, colors, 580 render_titlebar(output, damage, child, state->swayc_x,
577 title_texture, marks_texture); 581 state->swayc_y, state->swayc_width, colors,
578 } else { 582 title_texture, marks_texture);
579 render_top_border(output, damage, child, colors); 583 } else {
584 render_top_border(output, damage, child, colors);
585 }
580 } 586 }
581 render_view(output, damage, child, colors); 587 render_view(output, damage, child, colors);
582 } else { 588 } else {
@@ -761,12 +767,14 @@ static void render_floating_container(struct sway_output *soutput,
761 marks_texture = view->marks_unfocused; 767 marks_texture = view->marks_unfocused;
762 } 768 }
763 769
764 if (con->current.border == B_NORMAL) { 770 if (!view->using_csd) {
765 render_titlebar(soutput, damage, con, con->current.swayc_x, 771 if (con->current.border == B_NORMAL) {
766 con->current.swayc_y, con->current.swayc_width, colors, 772 render_titlebar(soutput, damage, con, con->current.swayc_x,
767 title_texture, marks_texture); 773 con->current.swayc_y, con->current.swayc_width, colors,
768 } else if (con->current.border != B_NONE) { 774 title_texture, marks_texture);
769 render_top_border(soutput, damage, con, colors); 775 } else if (con->current.border != B_NONE) {
776 render_top_border(soutput, damage, con, colors);
777 }
770 } 778 }
771 render_view(soutput, damage, con, colors); 779 render_view(soutput, damage, con, colors);
772 } else { 780 } 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(
35 'commands/border.c', 35 'commands/border.c',
36 'commands/client.c', 36 'commands/client.c',
37 'commands/default_border.c', 37 'commands/default_border.c',
38 'commands/default_floating_border.c',
38 'commands/default_orientation.c', 39 'commands/default_orientation.c',
39 'commands/exit.c', 40 'commands/exit.c',
40 'commands/exec.c', 41 '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) {
967 return; 967 return;
968 } 968 }
969 struct sway_view *view = con->sway_view; 969 struct sway_view *view = con->sway_view;
970 size_t border_width = view->border_thickness * (view->border != B_NONE); 970 size_t border_width = 0;
971 size_t top = 971 size_t top = 0;
972 view->border == B_NORMAL ? container_titlebar_height() : border_width; 972
973 if (!view->using_csd) {
974 border_width = view->border_thickness * (view->border != B_NONE);
975 top = view->border == B_NORMAL ?
976 container_titlebar_height() : border_width;
977 }
973 978
974 con->x = view->x - border_width; 979 con->x = view->x - border_width;
975 con->y = view->y - top; 980 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) {
316} 316}
317 317
318void view_set_tiled(struct sway_view *view, bool tiled) { 318void view_set_tiled(struct sway_view *view, bool tiled) {
319 bool csd = true; 319 if (!tiled) {
320 if (view->impl->has_client_side_decorations) { 320 view->using_csd = true;
321 csd = view->impl->has_client_side_decorations(view); 321 if (view->impl->has_client_side_decorations) {
322 view->using_csd = view->impl->has_client_side_decorations(view);
323 }
324 } else {
325 view->using_csd = false;
322 } 326 }
323 view->border = tiled || !csd ? config->border : B_NONE; 327
324 if (view->impl->set_tiled) { 328 if (view->impl->set_tiled) {
325 view->impl->set_tiled(view, tiled); 329 view->impl->set_tiled(view, tiled);
326 } 330 }
@@ -573,8 +577,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
573 577
574 view->surface = wlr_surface; 578 view->surface = wlr_surface;
575 view->swayc = cont; 579 view->swayc = cont;
576 view->border = config->border;
577 view->border_thickness = config->border_thickness;
578 580
579 view_init_subsurfaces(view, wlr_surface); 581 view_init_subsurfaces(view, wlr_surface);
580 wl_signal_add(&wlr_surface->events.new_subsurface, 582 wl_signal_add(&wlr_surface->events.new_subsurface,
@@ -585,8 +587,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
585 view->container_reparent.notify = view_handle_container_reparent; 587 view->container_reparent.notify = view_handle_container_reparent;
586 588
587 if (view->impl->wants_floating && view->impl->wants_floating(view)) { 589 if (view->impl->wants_floating && view->impl->wants_floating(view)) {
590 view->border = config->floating_border;
591 view->border_thickness = config->floating_border_thickness;
588 container_set_floating(view->swayc, true); 592 container_set_floating(view->swayc, true);
589 } else { 593 } else {
594 view->border = config->border;
595 view->border_thickness = config->border_thickness;
590 view_set_tiled(view, true); 596 view_set_tiled(view, true);
591 } 597 }
592 598