aboutsummaryrefslogtreecommitdiff
path: root/sway/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/render.c108
-rw-r--r--sway/desktop/transaction.c1
-rw-r--r--sway/desktop/xdg_shell.c22
-rw-r--r--sway/desktop/xdg_shell_v6.c22
-rw-r--r--sway/desktop/xwayland.c20
5 files changed, 74 insertions, 99 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index af4e2905..c8b08a58 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -272,7 +272,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
render_view_toplevels(view, output, damage, view->container->alpha);
}
- if (view->container->current.using_csd) {
+ if (con->current.border == B_NONE || con->current.border == B_CSD) {
return;
}
@@ -281,51 +281,49 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
float color[4];
struct sway_container_state *state = &con->current;
- if (state->border != B_NONE) {
- if (state->border_left) {
- memcpy(&color, colors->child_border, sizeof(float) * 4);
- premultiply_alpha(color, con->alpha);
- box.x = state->con_x;
- box.y = state->view_y;
- box.width = state->border_thickness;
- box.height = state->view_height;
- scale_box(&box, output_scale);
- render_rect(output->wlr_output, damage, &box, color);
- }
+ if (state->border_left) {
+ memcpy(&color, colors->child_border, sizeof(float) * 4);
+ premultiply_alpha(color, con->alpha);
+ box.x = state->con_x;
+ box.y = state->view_y;
+ box.width = state->border_thickness;
+ box.height = state->view_height;
+ scale_box(&box, output_scale);
+ render_rect(output->wlr_output, damage, &box, color);
+ }
- list_t *siblings = container_get_current_siblings(con);
- enum sway_container_layout layout =
- container_current_parent_layout(con);
+ list_t *siblings = container_get_current_siblings(con);
+ enum sway_container_layout layout =
+ container_current_parent_layout(con);
- if (state->border_right) {
- if (siblings->length == 1 && layout == L_HORIZ) {
- memcpy(&color, colors->indicator, sizeof(float) * 4);
- } else {
- memcpy(&color, colors->child_border, sizeof(float) * 4);
- }
- premultiply_alpha(color, con->alpha);
- box.x = state->view_x + state->view_width;
- box.y = state->view_y;
- box.width = state->border_thickness;
- box.height = state->view_height;
- scale_box(&box, output_scale);
- render_rect(output->wlr_output, damage, &box, color);
+ if (state->border_right) {
+ if (siblings->length == 1 && layout == L_HORIZ) {
+ memcpy(&color, colors->indicator, sizeof(float) * 4);
+ } else {
+ memcpy(&color, colors->child_border, sizeof(float) * 4);
}
+ premultiply_alpha(color, con->alpha);
+ box.x = state->view_x + state->view_width;
+ box.y = state->view_y;
+ box.width = state->border_thickness;
+ box.height = state->view_height;
+ scale_box(&box, output_scale);
+ render_rect(output->wlr_output, damage, &box, color);
+ }
- if (state->border_bottom) {
- if (siblings->length == 1 && layout == L_VERT) {
- memcpy(&color, colors->indicator, sizeof(float) * 4);
- } else {
- memcpy(&color, colors->child_border, sizeof(float) * 4);
- }
- premultiply_alpha(color, con->alpha);
- box.x = state->con_x;
- box.y = state->view_y + state->view_height;
- box.width = state->con_width;
- box.height = state->border_thickness;
- scale_box(&box, output_scale);
- render_rect(output->wlr_output, damage, &box, color);
+ if (state->border_bottom) {
+ if (siblings->length == 1 && layout == L_VERT) {
+ memcpy(&color, colors->indicator, sizeof(float) * 4);
+ } else {
+ memcpy(&color, colors->child_border, sizeof(float) * 4);
}
+ premultiply_alpha(color, con->alpha);
+ box.x = state->con_x;
+ box.y = state->view_y + state->view_height;
+ box.width = state->con_width;
+ box.height = state->border_thickness;
+ scale_box(&box, output_scale);
+ render_rect(output->wlr_output, damage, &box, color);
}
}
@@ -645,14 +643,12 @@ static void render_containers_linear(struct sway_output *output,
marks_texture = view->marks_unfocused;
}
- if (!view->container->current.using_csd) {
- if (state->border == B_NORMAL) {
- render_titlebar(output, damage, child, state->con_x,
- state->con_y, state->con_width, colors,
- title_texture, marks_texture);
- } else {
- render_top_border(output, damage, child, colors);
- }
+ if (state->border == B_NORMAL) {
+ render_titlebar(output, damage, child, state->con_x,
+ state->con_y, state->con_width, colors,
+ title_texture, marks_texture);
+ } else if (state->border == B_PIXEL) {
+ render_top_border(output, damage, child, colors);
}
render_view(output, damage, child, colors);
} else {
@@ -859,14 +855,12 @@ static void render_floating_container(struct sway_output *soutput,
marks_texture = view->marks_unfocused;
}
- if (!view->container->current.using_csd) {
- if (con->current.border == B_NORMAL) {
- render_titlebar(soutput, damage, con, con->current.con_x,
- con->current.con_y, con->current.con_width, colors,
- title_texture, marks_texture);
- } else if (con->current.border != B_NONE) {
- render_top_border(soutput, damage, con, colors);
- }
+ if (con->current.border == B_NORMAL) {
+ render_titlebar(soutput, damage, con, con->current.con_x,
+ con->current.con_y, con->current.con_width, colors,
+ title_texture, marks_texture);
+ } else if (con->current.border == B_PIXEL) {
+ render_top_border(soutput, damage, con, colors);
}
render_view(soutput, damage, con, colors);
} else {
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 797f6b4c..4624d824 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -167,7 +167,6 @@ static void copy_container_state(struct sway_container *container,
state->border_left = view->border_left;
state->border_right = view->border_right;
state->border_bottom = view->border_bottom;
- state->using_csd = view->using_csd;
} else {
state->children = create_list();
list_cat(state->children, container->children);
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 6d1ccdd7..d563edae 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -175,15 +175,6 @@ static bool wants_floating(struct sway_view *view) {
|| toplevel->parent;
}
-static bool has_client_side_decorations(struct sway_view *view) {
- struct sway_xdg_shell_view *xdg_shell_view =
- xdg_shell_view_from_view(view);
- if (xdg_shell_view == NULL) {
- return true;
- }
- return xdg_shell_view->deco_mode != WLR_SERVER_DECORATION_MANAGER_MODE_SERVER;
-}
-
static void for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (xdg_shell_view_from_view(view) == NULL) {
@@ -240,7 +231,6 @@ static const struct sway_view_impl view_impl = {
.set_tiled = set_tiled,
.set_fullscreen = set_fullscreen,
.wants_floating = wants_floating,
- .has_client_side_decorations = has_client_side_decorations,
.for_each_surface = for_each_surface,
.for_each_popup = for_each_popup,
.close = _close,
@@ -385,15 +375,13 @@ static void handle_map(struct wl_listener *listener, void *data) {
view->natural_height = view->wlr_xdg_surface->surface->current.height;
}
+ view_map(view, view->wlr_xdg_surface->surface);
+
struct sway_server_decoration *deco =
decoration_from_surface(xdg_surface->surface);
- if (deco != NULL) {
- xdg_shell_view->deco_mode = deco->wlr_server_decoration->mode;
- } else {
- xdg_shell_view->deco_mode = WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
- }
-
- view_map(view, view->wlr_xdg_surface->surface);
+ bool csd = !deco || deco->wlr_server_decoration->mode ==
+ WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
+ view_set_csd_from_client(view, csd);
if (xdg_surface->toplevel->client_pending.fullscreen) {
container_set_fullscreen(view->container, true);
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 95ca396c..8c8085f7 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -171,15 +171,6 @@ static bool wants_floating(struct sway_view *view) {
|| toplevel->parent;
}
-static bool has_client_side_decorations(struct sway_view *view) {
- struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
- xdg_shell_v6_view_from_view(view);
- if (xdg_shell_v6_view == NULL) {
- return true;
- }
- return xdg_shell_v6_view->deco_mode != WLR_SERVER_DECORATION_MANAGER_MODE_SERVER;
-}
-
static void for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (xdg_shell_v6_view_from_view(view) == NULL) {
@@ -237,7 +228,6 @@ static const struct sway_view_impl view_impl = {
.set_tiled = set_tiled,
.set_fullscreen = set_fullscreen,
.wants_floating = wants_floating,
- .has_client_side_decorations = has_client_side_decorations,
.for_each_surface = for_each_surface,
.for_each_popup = for_each_popup,
.close = _close,
@@ -382,15 +372,13 @@ static void handle_map(struct wl_listener *listener, void *data) {
view->natural_height = view->wlr_xdg_surface_v6->surface->current.height;
}
+ view_map(view, view->wlr_xdg_surface_v6->surface);
+
struct sway_server_decoration *deco =
decoration_from_surface(xdg_surface->surface);
- if (deco != NULL) {
- xdg_shell_v6_view->deco_mode = deco->wlr_server_decoration->mode;
- } else {
- xdg_shell_v6_view->deco_mode = WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
- }
-
- view_map(view, view->wlr_xdg_surface_v6->surface);
+ bool csd = !deco || deco->wlr_server_decoration->mode ==
+ WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
+ view_set_csd_from_client(view, csd);
if (xdg_surface->toplevel->client_pending.fullscreen) {
container_set_fullscreen(view->container, true);
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index a12ac854..f1205518 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -243,12 +243,14 @@ static bool wants_floating(struct sway_view *view) {
return false;
}
-static bool has_client_side_decorations(struct sway_view *view) {
- if (xwayland_view_from_view(view) == NULL) {
- return false;
- }
- struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
- return surface->decorations != WLR_XWAYLAND_SURFACE_DECORATIONS_ALL;
+static void handle_set_decorations(struct wl_listener *listener, void *data) {
+ struct sway_xwayland_view *xwayland_view =
+ wl_container_of(listener, xwayland_view, set_decorations);
+ struct sway_view *view = &xwayland_view->view;
+ struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
+
+ bool csd = xsurface->decorations != WLR_XWAYLAND_SURFACE_DECORATIONS_ALL;
+ view_set_csd_from_client(view, csd);
}
static void _close(struct sway_view *view) {
@@ -274,7 +276,6 @@ static const struct sway_view_impl view_impl = {
.set_tiled = set_tiled,
.set_fullscreen = set_fullscreen,
.wants_floating = wants_floating,
- .has_client_side_decorations = has_client_side_decorations,
.close = _close,
.destroy = destroy,
};
@@ -343,6 +344,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&xwayland_view->set_role.link);
wl_list_remove(&xwayland_view->set_window_type.link);
wl_list_remove(&xwayland_view->set_hints.link);
+ wl_list_remove(&xwayland_view->set_decorations.link);
wl_list_remove(&xwayland_view->map.link);
wl_list_remove(&xwayland_view->unmap.link);
view_begin_destroy(&xwayland_view->view);
@@ -613,6 +615,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_signal_add(&xsurface->events.set_hints, &xwayland_view->set_hints);
xwayland_view->set_hints.notify = handle_set_hints;
+ wl_signal_add(&xsurface->events.set_decorations,
+ &xwayland_view->set_decorations);
+ xwayland_view->set_decorations.notify = handle_set_decorations;
+
wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap);
xwayland_view->unmap.notify = handle_unmap;