Merge pull request #2703 from RyanDwyer/csd-border

Add CSD to border modes
This commit is contained in:
Drew DeVault 2018-10-03 13:03:06 +02:00 committed by GitHub
commit 06c214a800
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 301 additions and 142 deletions

View file

@ -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);
}
} else {
view->using_csd = false;
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 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);
}