summaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-24 20:54:57 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-27 22:51:37 +1000
commit7b138e5ef0f679c9bb0078019d7c9c63fef36273 (patch)
tree2cdbeb394889065e0606a1fcbe38c1e99e25d260 /sway/tree/view.c
parentMerge pull request #2717 from ianyfan/tablet-config (diff)
downloadsway-7b138e5ef0f679c9bb0078019d7c9c63fef36273.tar.gz
sway-7b138e5ef0f679c9bb0078019d7c9c63fef36273.tar.zst
sway-7b138e5ef0f679c9bb0078019d7c9c63fef36273.zip
Add CSD to border modes
This replaces view.using_csd with a new border mode: B_CSD. This also removes sway_xdg_shell{_v6}_view.deco_mode and view->has_client_side_decorations as we can now get these from the border. You can use `border toggle` to cycle through the modes including CSD, or use `border csd` to set it directly. The client must support the xdg-decoration protocol, and the only client I know of that does is the example in wlroots. If the client switches from SSD to CSD without us expecting it (via the server-decoration protocol), we stash the previous border type into view.saved_border so we can restore it if the client returns to SSD. I haven't found a way to test this though.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e370443c..c370de2d 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
@@ -231,12 +234,8 @@ void view_autoconfigure(struct sway_view *view) {
231 view->border_top = false; 234 view->border_top = false;
232 } 235 }
233 236
234 enum sway_container_border border = view->border; 237 switch (view->border) {
235 if (view->using_csd) { 238 case B_CSD:
236 border = B_NONE;
237 }
238
239 switch (border) {
240 case B_NONE: 239 case B_NONE:
241 x = con->x; 240 x = con->x;
242 y = con->y + y_offset; 241 y = con->y + y_offset;
@@ -309,16 +308,26 @@ void view_request_activate(struct sway_view *view) {
309 } 308 }
310} 309}
311 310
312void view_set_tiled(struct sway_view *view, bool tiled) { 311void view_set_csd_from_server(struct sway_view *view, bool enabled) {
313 if (!tiled) { 312 if (view->xdg_decoration) {
314 view->using_csd = true; 313 uint32_t mode = enabled ?
315 if (view->impl->has_client_side_decorations) { 314 WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE :
316 view->using_csd = view->impl->has_client_side_decorations(view); 315 WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
317 } 316 wlr_xdg_toplevel_decoration_v1_set_mode(
318 } else { 317 view->xdg_decoration->wlr_xdg_decoration, mode);
319 view->using_csd = false;
320 } 318 }
319}
321 320
321void view_set_csd_from_client(struct sway_view *view, bool enabled) {
322 if (enabled && view->border != B_CSD) {
323 view->saved_border = view->border;
324 view->border = B_CSD;
325 } else if (!enabled && view->border == B_CSD) {
326 view->border = view->saved_border;
327 }
328}
329
330void view_set_tiled(struct sway_view *view, bool tiled) {
322 if (view->impl->set_tiled) { 331 if (view->impl->set_tiled) {
323 view->impl->set_tiled(view, tiled); 332 view->impl->set_tiled(view, tiled);
324 } 333 }