aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-10-03 13:03:06 +0200
committerLibravatar GitHub <noreply@github.com>2018-10-03 13:03:06 +0200
commit06c214a800cab9119ae4b04371e3f6bbca8a0550 (patch)
treeeed325e37d02fa71858a33e71ef33961395dd16f /sway/tree/view.c
parentMerge pull request #2755 from RyanDwyer/fix-tiling-criteria (diff)
parentRemove server-decoration assumption if view supports xdg-decoration (diff)
downloadsway-06c214a800cab9119ae4b04371e3f6bbca8a0550.tar.gz
sway-06c214a800cab9119ae4b04371e3f6bbca8a0550.tar.zst
sway-06c214a800cab9119ae4b04371e3f6bbca8a0550.zip
Merge pull request #2703 from RyanDwyer/csd-border
Add CSD to border modes
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index ca5e6ab0..9c7c44e9 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -5,6 +5,8 @@
5#include <wlr/render/wlr_renderer.h> 5#include <wlr/render/wlr_renderer.h>
6#include <wlr/types/wlr_buffer.h> 6#include <wlr/types/wlr_buffer.h>
7#include <wlr/types/wlr_output_layout.h> 7#include <wlr/types/wlr_output_layout.h>
8#include <wlr/types/wlr_server_decoration.h>
9#include <wlr/types/wlr_xdg_decoration_v1.h>
8#include "config.h" 10#include "config.h"
9#ifdef HAVE_XWAYLAND 11#ifdef HAVE_XWAYLAND
10#include <wlr/xwayland.h> 12#include <wlr/xwayland.h>
@@ -23,6 +25,7 @@
23#include "sway/tree/view.h" 25#include "sway/tree/view.h"
24#include "sway/tree/workspace.h" 26#include "sway/tree/workspace.h"
25#include "sway/config.h" 27#include "sway/config.h"
28#include "sway/xdg_decoration.h"
26#include "pango.h" 29#include "pango.h"
27#include "stringop.h" 30#include "stringop.h"
28 31
@@ -248,12 +251,8 @@ void view_autoconfigure(struct sway_view *view) {
248 view->border_top = false; 251 view->border_top = false;
249 } 252 }
250 253
251 enum sway_container_border border = view->border; 254 switch (view->border) {
252 if (view->using_csd) { 255 case B_CSD:
253 border = B_NONE;
254 }
255
256 switch (border) {
257 case B_NONE: 256 case B_NONE:
258 x = con->x; 257 x = con->x;
259 y = con->y + y_offset; 258 y = con->y + y_offset;
@@ -326,16 +325,32 @@ void view_request_activate(struct sway_view *view) {
326 } 325 }
327} 326}
328 327
329void view_set_tiled(struct sway_view *view, bool tiled) { 328void view_set_csd_from_server(struct sway_view *view, bool enabled) {
330 if (!tiled) { 329 wlr_log(WLR_DEBUG, "Telling view %p to set CSD to %i", view, enabled);
331 view->using_csd = true; 330 if (view->xdg_decoration) {
332 if (view->impl->has_client_side_decorations) { 331 uint32_t mode = enabled ?
333 view->using_csd = view->impl->has_client_side_decorations(view); 332 WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE :
333 WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
334 wlr_xdg_toplevel_decoration_v1_set_mode(
335 view->xdg_decoration->wlr_xdg_decoration, mode);
336 }
337 view->using_csd = enabled;
338}
339
340void view_update_csd_from_client(struct sway_view *view, bool enabled) {
341 wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled);
342 if (enabled && view->border != B_CSD) {
343 view->saved_border = view->border;
344 if (container_is_floating(view->container)) {
345 view->border = B_CSD;
334 } 346 }
335 } else { 347 } else if (!enabled && view->border == B_CSD) {
336 view->using_csd = false; 348 view->border = view->saved_border;
337 } 349 }
350 view->using_csd = enabled;
351}
338 352
353void view_set_tiled(struct sway_view *view, bool tiled) {
339 if (view->impl->set_tiled) { 354 if (view->impl->set_tiled) {
340 view->impl->set_tiled(view, tiled); 355 view->impl->set_tiled(view, tiled);
341 } 356 }