diff options
Diffstat (limited to 'sway/tree/container.c')
| -rw-r--r-- | sway/tree/container.c | 80 | 
1 files changed, 46 insertions, 34 deletions
| diff --git a/sway/tree/container.c b/sway/tree/container.c index 458ed7ff..cf6f5b54 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -165,13 +165,13 @@ static struct sway_container *surface_at_view(struct sway_container *con, double  		return NULL;  	}  	struct sway_view *view = con->view; -	double view_sx = lx - view->x + view->geometry.x; -	double view_sy = ly - view->y + view->geometry.y; +	double view_sx = lx - con->content_x + view->geometry.x; +	double view_sy = ly - con->content_y + view->geometry.y;  	double _sx, _sy;  	struct wlr_surface *_surface = NULL;  	switch (view->type) { -#ifdef HAVE_XWAYLAND +#if HAVE_XWAYLAND  	case SWAY_VIEW_XWAYLAND:  		_surface = wlr_surface_surface_at(view->surface,  				view_sx, view_sy, &_sx, &_sy); @@ -641,16 +641,18 @@ void container_init_floating(struct sway_container *con) {  		con->y = ws->y + (ws->height - con->height) / 2;  	} else {  		struct sway_view *view = con->view; -		view->width = fmax(min_width, fmin(view->natural_width, max_width)); -		view->height = fmax(min_height, fmin(view->natural_height, max_height)); -		view->x = ws->x + (ws->width - view->width) / 2; -		view->y = ws->y + (ws->height - view->height) / 2; +		con->content_width = +			fmax(min_width, fmin(view->natural_width, max_width)); +		con->content_height = +			fmax(min_height, fmin(view->natural_height, max_height)); +		con->content_x = ws->x + (ws->width - con->content_width) / 2; +		con->content_y = ws->y + (ws->height - con->content_height) / 2;  		// If the view's border is B_NONE then these properties are ignored.  		con->border_top = con->border_bottom = true;  		con->border_left = con->border_right = true; -		container_set_geometry_from_floating_view(con); +		container_set_geometry_from_content(con);  	}  } @@ -707,14 +709,13 @@ void container_set_floating(struct sway_container *container, bool enable) {  	ipc_event_window(container, "floating");  } -void container_set_geometry_from_floating_view(struct sway_container *con) { +void container_set_geometry_from_content(struct sway_container *con) {  	if (!sway_assert(con->view, "Expected a view")) {  		return;  	}  	if (!sway_assert(container_is_floating(con), "Expected a floating view")) {  		return;  	} -	struct sway_view *view = con->view;  	size_t border_width = 0;  	size_t top = 0; @@ -724,10 +725,10 @@ void container_set_geometry_from_floating_view(struct sway_container *con) {  			container_titlebar_height() : border_width;  	} -	con->x = view->x - border_width; -	con->y = view->y - top; -	con->width = view->width + border_width * 2; -	con->height = top + view->height + border_width; +	con->x = con->content_x - border_width; +	con->y = con->content_y - top; +	con->width = con->content_width + border_width * 2; +	con->height = top + con->content_height + border_width;  	node_set_dirty(&con->node);  } @@ -756,15 +757,16 @@ void container_floating_translate(struct sway_container *con,  		double x_amount, double y_amount) {  	con->x += x_amount;  	con->y += y_amount; -	if (con->view) { -		con->view->x += x_amount; -		con->view->y += y_amount; -	} else { +	con->content_x += x_amount; +	con->content_y += y_amount; + +	if (con->children) {  		for (int i = 0; i < con->children->length; ++i) {  			struct sway_container *child = con->children->items[i];  			container_floating_translate(child, x_amount, y_amount);  		}  	} +  	node_set_dirty(&con->node);  } @@ -964,10 +966,10 @@ static void surface_send_leave_iterator(struct wlr_surface *surface,  void container_discover_outputs(struct sway_container *con) {  	struct wlr_box con_box = { -		.x = con->current.con_x, -		.y = con->current.con_y, -		.width = con->current.con_width, -		.height = con->current.con_height, +		.x = con->current.x, +		.y = con->current.y, +		.width = con->current.width, +		.height = con->current.height,  	};  	struct sway_output *old_output = container_get_effective_output(con); @@ -1009,19 +1011,25 @@ void container_discover_outputs(struct sway_container *con) {  }  void container_remove_gaps(struct sway_container *c) { -	if (c->current_gaps == 0) { +	if (c->current_gaps.top == 0 && c->current_gaps.right == 0 && +			c->current_gaps.bottom == 0 && c->current_gaps.left == 0) {  		return;  	} -	c->width += c->current_gaps * 2; -	c->height += c->current_gaps * 2; -	c->x -= c->current_gaps; -	c->y -= c->current_gaps; -	c->current_gaps = 0; +	c->width += c->current_gaps.left + c->current_gaps.right; +	c->height += c->current_gaps.top + c->current_gaps.bottom; +	c->x -= c->current_gaps.left; +	c->y -= c->current_gaps.top; + +	c->current_gaps.top = 0; +	c->current_gaps.right = 0; +	c->current_gaps.bottom = 0; +	c->current_gaps.left = 0;  }  void container_add_gaps(struct sway_container *c) { -	if (c->current_gaps > 0) { +	if (c->current_gaps.top > 0 || c->current_gaps.right > 0 || +			c->current_gaps.bottom > 0 || c->current_gaps.left > 0) {  		return;  	}  	// Linear containers don't have gaps because it'd create double gaps @@ -1054,11 +1062,15 @@ void container_add_gaps(struct sway_container *c) {  	struct sway_workspace *ws = c->workspace; -	c->current_gaps = ws->gaps_inner; -	c->x += c->current_gaps; -	c->y += c->current_gaps; -	c->width -= 2 * c->current_gaps; -	c->height -= 2 * c->current_gaps; +	c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0; +	c->current_gaps.right = ws->gaps_inner; +	c->current_gaps.bottom = ws->gaps_inner; +	c->current_gaps.left = c->x == ws->x ? ws->gaps_inner : 0; + +	c->x += c->current_gaps.left; +	c->y += c->current_gaps.top; +	c->width -= c->current_gaps.left + c->current_gaps.right; +	c->height -= c->current_gaps.top + c->current_gaps.bottom;  }  enum sway_container_layout container_parent_layout(struct sway_container *con) { | 
