aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-09-24 20:54:57 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-09-27 22:51:37 +1000
commit7b138e5ef0f679c9bb0078019d7c9c63fef36273 (patch)
tree2cdbeb394889065e0606a1fcbe38c1e99e25d260 /sway/tree
parent58af0015170204de6d186f0f25cd0b9315d062d7 (diff)
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')
-rw-r--r--sway/tree/container.c2
-rw-r--r--sway/tree/view.c37
2 files changed, 24 insertions, 15 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index baaa82fd..d75e34a5 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -715,7 +715,7 @@ void container_set_geometry_from_floating_view(struct sway_container *con) {
size_t border_width = 0;
size_t top = 0;
- if (!view->using_csd) {
+ if (view->border != B_CSD) {
border_width = view->border_thickness * (view->border != B_NONE);
top = view->border == B_NORMAL ?
container_titlebar_height() : border_width;
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 @@
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_server_decoration.h>
+#include <wlr/types/wlr_xdg_decoration_v1.h>
#include "config.h"
#ifdef HAVE_XWAYLAND
#include <wlr/xwayland.h>
@@ -23,6 +25,7 @@
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#include "sway/config.h"
+#include "sway/xdg_decoration.h"
#include "pango.h"
#include "stringop.h"
@@ -231,12 +234,8 @@ void view_autoconfigure(struct sway_view *view) {
view->border_top = false;
}
- enum sway_container_border border = view->border;
- if (view->using_csd) {
- border = B_NONE;
- }
-
- switch (border) {
+ switch (view->border) {
+ case B_CSD:
case B_NONE:
x = con->x;
y = con->y + y_offset;
@@ -309,16 +308,26 @@ void view_request_activate(struct sway_view *view) {
}
}
-void view_set_tiled(struct sway_view *view, bool tiled) {
- 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;
+void view_set_csd_from_server(struct sway_view *view, bool enabled) {
+ if (view->xdg_decoration) {
+ uint32_t mode = enabled ?
+ WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE :
+ WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
+ wlr_xdg_toplevel_decoration_v1_set_mode(
+ view->xdg_decoration->wlr_xdg_decoration, mode);
}
+}
+void view_set_csd_from_client(struct sway_view *view, bool enabled) {
+ if (enabled && view->border != B_CSD) {
+ view->saved_border = view->border;
+ view->border = B_CSD;
+ } else if (!enabled && view->border == B_CSD) {
+ view->border = view->saved_border;
+ }
+}
+
+void view_set_tiled(struct sway_view *view, bool tiled) {
if (view->impl->set_tiled) {
view->impl->set_tiled(view, tiled);
}