summaryrefslogtreecommitdiff
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 1aa59e68..d7110619 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -8,7 +8,7 @@
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include "config.h"
-#ifdef HAVE_XWAYLAND
+#if HAVE_XWAYLAND
#include <wlr/xwayland.h>
#endif
#include "list.h"
@@ -101,7 +101,7 @@ const char *view_get_instance(struct sway_view *view) {
}
return NULL;
}
-#ifdef HAVE_XWAYLAND
+#if HAVE_XWAYLAND
uint32_t view_get_x11_window_id(struct sway_view *view) {
if (view->impl->get_int_prop) {
return view->impl->get_int_prop(view, VIEW_PROP_X11_WINDOW_ID);
@@ -136,7 +136,7 @@ const char *view_get_shell(struct sway_view *view) {
return "xdg_shell_v6";
case SWAY_VIEW_XDG_SHELL:
return "xdg_shell";
-#ifdef HAVE_XWAYLAND
+#if HAVE_XWAYLAND
case SWAY_VIEW_XWAYLAND:
return "xwayland";
#endif
@@ -185,31 +185,33 @@ bool view_is_only_visible(struct sway_view *view) {
static bool gaps_to_edge(struct sway_view *view) {
struct sway_container *con = view->container;
while (con) {
- if (con->current_gaps > 0) {
+ if (con->current_gaps.top > 0 || con->current_gaps.right > 0 ||
+ con->current_gaps.bottom > 0 || con->current_gaps.left > 0) {
return true;
}
con = con->parent;
}
- return view->container->workspace->current_gaps > 0;
+ struct side_gaps gaps = view->container->workspace->current_gaps;
+ return gaps.top > 0 || gaps.right > 0 || gaps.bottom > 0 || gaps.left > 0;
}
void view_autoconfigure(struct sway_view *view) {
- if (!view->container->workspace) {
+ struct sway_container *con = view->container;
+ if (!con->workspace) {
// Hidden in the scratchpad
return;
}
- struct sway_output *output = view->container->workspace->output;
+ struct sway_output *output = con->workspace->output;
- if (view->container->is_fullscreen) {
- view->x = output->lx;
- view->y = output->ly;
- view->width = output->width;
- view->height = output->height;
+ if (con->is_fullscreen) {
+ con->content_x = output->lx;
+ con->content_y = output->ly;
+ con->content_width = output->width;
+ con->content_height = output->height;
return;
}
struct sway_workspace *ws = view->container->workspace;
- struct sway_container *con = view->container;
bool smart = config->hide_edge_borders == E_SMART ||
config->hide_edge_borders == E_SMART_NO_GAPS;
@@ -222,15 +224,15 @@ void view_autoconfigure(struct sway_view *view) {
if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_VERTICAL
|| (smart && !other_views && no_gaps)) {
- con->border_left = con->x - con->current_gaps != ws->x;
- int right_x = con->x + con->width + con->current_gaps;
+ con->border_left = con->x - con->current_gaps.left != ws->x;
+ int right_x = con->x + con->width + con->current_gaps.right;
con->border_right = right_x != ws->x + ws->width;
}
if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_HORIZONTAL
|| (smart && !other_views && no_gaps)) {
- con->border_top = con->y - con->current_gaps != ws->y;
- int bottom_y = con->y + con->height + con->current_gaps;
+ con->border_top = con->y - con->current_gaps.top != ws->y;
+ int bottom_y = con->y + con->height + con->current_gaps.bottom;
con->border_bottom = bottom_y != ws->y + ws->height;
}
@@ -287,10 +289,10 @@ void view_autoconfigure(struct sway_view *view) {
break;
}
- view->x = x;
- view->y = y;
- view->width = width;
- view->height = height;
+ con->content_x = x;
+ con->content_y = y;
+ con->content_width = width;
+ con->content_height = height;
}
void view_set_activated(struct sway_view *view, bool activated) {
@@ -482,7 +484,7 @@ static struct sway_workspace *select_workspace(struct sway_view *view) {
// Check if there's a PID mapping
pid_t pid;
-#ifdef HAVE_XWAYLAND
+#if HAVE_XWAYLAND
if (view->type == SWAY_VIEW_XWAYLAND) {
struct wlr_xwayland_surface *surf =
wlr_xwayland_surface_from_wlr_surface(view->surface);
@@ -665,11 +667,11 @@ void view_update_size(struct sway_view *view, int width, int height) {
"Expected a floating container")) {
return;
}
- view->width = width;
- view->height = height;
- view->container->current.view_width = width;
- view->container->current.view_height = height;
- container_set_geometry_from_floating_view(view->container);
+ view->container->content_width = width;
+ view->container->content_height = height;
+ view->container->current.content_width = width;
+ view->container->current.content_height = height;
+ container_set_geometry_from_content(view->container);
}
static void subsurface_get_root_coords(struct sway_view_child *child,
@@ -705,7 +707,8 @@ static void view_child_damage(struct sway_view_child *child, bool whole) {
int sx, sy;
child->impl->get_root_coords(child, &sx, &sy);
desktop_damage_surface(child->surface,
- child->view->x + sx, child->view->y + sy, whole);
+ child->view->container->content_x + sx,
+ child->view->container->content_y + sy, whole);
}
static void view_child_handle_surface_commit(struct wl_listener *listener,
@@ -799,7 +802,7 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
wlr_xdg_surface_v6_from_wlr_surface(wlr_surface);
return view_from_wlr_xdg_surface_v6(xdg_surface_v6);
}
-#ifdef HAVE_XWAYLAND
+#if HAVE_XWAYLAND
if (wlr_surface_is_xwayland_surface(wlr_surface)) {
struct wlr_xwayland_surface *xsurface =
wlr_xwayland_surface_from_wlr_surface(wlr_surface);