summaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 6da5ac3c..4507655e 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1163,19 +1163,16 @@ void container_floating_translate(struct sway_container *con,
1163 double x_amount, double y_amount) { 1163 double x_amount, double y_amount) {
1164 con->x += x_amount; 1164 con->x += x_amount;
1165 con->y += y_amount; 1165 con->y += y_amount;
1166 con->current.swayc_x += x_amount;
1167 con->current.swayc_y += y_amount;
1168 if (con->type == C_VIEW) { 1166 if (con->type == C_VIEW) {
1169 con->sway_view->x += x_amount; 1167 con->sway_view->x += x_amount;
1170 con->sway_view->y += y_amount; 1168 con->sway_view->y += y_amount;
1171 con->current.view_x += x_amount;
1172 con->current.view_y += y_amount;
1173 } else { 1169 } else {
1174 for (int i = 0; i < con->children->length; ++i) { 1170 for (int i = 0; i < con->children->length; ++i) {
1175 struct sway_container *child = con->children->items[i]; 1171 struct sway_container *child = con->children->items[i];
1176 container_floating_translate(child, x_amount, y_amount); 1172 container_floating_translate(child, x_amount, y_amount);
1177 } 1173 }
1178 } 1174 }
1175 container_set_dirty(con);
1179} 1176}
1180 1177
1181/** 1178/**
@@ -1185,7 +1182,7 @@ void container_floating_translate(struct sway_container *con,
1185 * one, otherwise we'll choose whichever output is closest to the container's 1182 * one, otherwise we'll choose whichever output is closest to the container's
1186 * center. 1183 * center.
1187 */ 1184 */
1188static struct sway_container *container_floating_find_output( 1185struct sway_container *container_floating_find_output(
1189 struct sway_container *con) { 1186 struct sway_container *con) {
1190 double center_x = con->x + con->width / 2; 1187 double center_x = con->x + con->width / 2;
1191 double center_y = con->y + con->height / 2; 1188 double center_y = con->y + con->height / 2;
@@ -1219,9 +1216,7 @@ void container_floating_move_to(struct sway_container *con,
1219 "Expected a floating container")) { 1216 "Expected a floating container")) {
1220 return; 1217 return;
1221 } 1218 }
1222 desktop_damage_whole_container(con);
1223 container_floating_translate(con, lx - con->x, ly - con->y); 1219 container_floating_translate(con, lx - con->x, ly - con->y);
1224 desktop_damage_whole_container(con);
1225 struct sway_container *old_workspace = container_parent(con, C_WORKSPACE); 1220 struct sway_container *old_workspace = container_parent(con, C_WORKSPACE);
1226 struct sway_container *new_output = container_floating_find_output(con); 1221 struct sway_container *new_output = container_floating_find_output(con);
1227 if (!sway_assert(new_output, "Unable to find any output")) { 1222 if (!sway_assert(new_output, "Unable to find any output")) {
@@ -1239,6 +1234,17 @@ void container_floating_move_to(struct sway_container *con,
1239 } 1234 }
1240} 1235}
1241 1236
1237void container_floating_move_to_center(struct sway_container *con) {
1238 if (!sway_assert(container_is_floating(con),
1239 "Expected a floating container")) {
1240 return;
1241 }
1242 struct sway_container *ws = container_parent(con, C_WORKSPACE);
1243 double new_lx = ws->x + (ws->width - con->width) / 2;
1244 double new_ly = ws->y + (ws->height - con->height) / 2;
1245 container_floating_translate(con, new_lx - con->x, new_ly - con->y);
1246}
1247
1242void container_set_dirty(struct sway_container *container) { 1248void container_set_dirty(struct sway_container *container) {
1243 if (container->dirty) { 1249 if (container->dirty) {
1244 return; 1250 return;
@@ -1318,6 +1324,11 @@ void container_set_fullscreen(struct sway_container *container, bool enable) {
1318 container->y = container->saved_y; 1324 container->y = container->saved_y;
1319 container->width = container->saved_width; 1325 container->width = container->saved_width;
1320 container->height = container->saved_height; 1326 container->height = container->saved_height;
1327 struct sway_container *output =
1328 container_floating_find_output(container);
1329 if (!container_has_ancestor(container, output)) {
1330 container_floating_move_to_center(container);
1331 }
1321 } else { 1332 } else {
1322 container->width = container->saved_width; 1333 container->width = container->saved_width;
1323 container->height = container->saved_height; 1334 container->height = container->saved_height;