aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-10-03 13:03:06 +0200
committerGitHub <noreply@github.com>2018-10-03 13:03:06 +0200
commit06c214a800cab9119ae4b04371e3f6bbca8a0550 (patch)
treeeed325e37d02fa71858a33e71ef33961395dd16f /sway/tree
parentf74829d390bab2eccd68923c4b8b82a873322168 (diff)
parentf16529e2588f5e71d6777f4c06dfb58b29308cd0 (diff)
Merge pull request #2703 from RyanDwyer/csd-border
Add CSD to border modes
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c8
-rw-r--r--sway/tree/view.c41
2 files changed, 35 insertions, 14 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index e1e616f9..a069b177 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -669,6 +669,9 @@ void container_set_floating(struct sway_container *container, bool enable) {
container_init_floating(container);
if (container->view) {
view_set_tiled(container->view, false);
+ if (container->view->using_csd) {
+ container->view->border = B_CSD;
+ }
}
if (old_parent) {
container_reap_empty(old_parent);
@@ -695,6 +698,9 @@ void container_set_floating(struct sway_container *container, bool enable) {
}
if (container->view) {
view_set_tiled(container->view, true);
+ if (container->view->using_csd) {
+ container->view->border = container->view->saved_border;
+ }
}
container->is_sticky = false;
}
@@ -715,7 +721,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 ca5e6ab0..9c7c44e9 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"
@@ -248,12 +251,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;
@@ -326,16 +325,32 @@ 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);
+void view_set_csd_from_server(struct sway_view *view, bool enabled) {
+ wlr_log(WLR_DEBUG, "Telling view %p to set CSD to %i", view, 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);
+ }
+ view->using_csd = enabled;
+}
+
+void view_update_csd_from_client(struct sway_view *view, bool enabled) {
+ wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled);
+ if (enabled && view->border != B_CSD) {
+ view->saved_border = view->border;
+ if (container_is_floating(view->container)) {
+ view->border = B_CSD;
}
- } else {
- view->using_csd = false;
+ } else if (!enabled && view->border == B_CSD) {
+ view->border = view->saved_border;
}
+ view->using_csd = enabled;
+}
+void view_set_tiled(struct sway_view *view, bool tiled) {
if (view->impl->set_tiled) {
view->impl->set_tiled(view, tiled);
}