aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-05-25 11:15:43 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commit13a4b0512e25b8da6e16ca1286f8b62fcc24c5cc (patch)
tree5e03717e41e4af7282995b15b0938a6f07c4c74d /sway/tree
parent754cb7944c2f05b35e39dab9605a184ee9f53efd (diff)
Fix unfullscreening a floating view
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c19
-rw-r--r--sway/tree/view.c29
2 files changed, 30 insertions, 18 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index c16f1748..fd7ee2c3 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -906,23 +906,6 @@ size_t container_titlebar_height() {
return config->font_height + TITLEBAR_V_PADDING * 2;
}
-static void configure_floating_view(struct sway_view *view) {
- struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
- int max_width = ws->width * 0.6666;
- int max_height = ws->height * 0.6666;
- int width =
- view->natural_width > max_width ? max_width : view->natural_width;
- int height =
- view->natural_height > max_height ? max_height : view->natural_height;
- struct sway_container *output = ws->parent;
- int lx = output->x + (ws->width - width) / 2;
- int ly = output->y + (ws->height - height) / 2;
-
- view->border_left = view->border_right = view->border_bottom = true;
- view_set_maximized(view, false);
- view_configure(view, lx, ly, width, height);
-}
-
void container_set_floating(struct sway_container *container, bool enable) {
if (container_is_floating(container) == enable) {
return;
@@ -936,7 +919,7 @@ void container_set_floating(struct sway_container *container, bool enable) {
container_remove_child(container);
container_add_child(workspace->sway_workspace->floating, container);
if (container->type == C_VIEW) {
- configure_floating_view(container->sway_view);
+ view_autoconfigure(container->sway_view);
}
seat_set_focus(seat, seat_get_focus_inactive(seat, container));
container_reap_empty_recursive(workspace);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 8548d9b8..65961dd9 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -126,6 +126,23 @@ void view_configure(struct sway_view *view, double ox, double oy, int width,
}
}
+static void view_autoconfigure_floating(struct sway_view *view) {
+ struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
+ int max_width = ws->width * 0.6666;
+ int max_height = ws->height * 0.6666;
+ int width =
+ view->natural_width > max_width ? max_width : view->natural_width;
+ int height =
+ view->natural_height > max_height ? max_height : view->natural_height;
+ struct sway_container *output = ws->parent;
+ int lx = output->x + (ws->width - width) / 2;
+ int ly = output->y + (ws->height - height) / 2;
+
+ view->border_left = view->border_right = view->border_bottom = true;
+ view_set_maximized(view, false);
+ view_configure(view, lx, ly, width, height);
+}
+
void view_autoconfigure(struct sway_view *view) {
if (!sway_assert(view->swayc,
"Called view_autoconfigure() on a view without a swayc")) {
@@ -140,6 +157,11 @@ void view_autoconfigure(struct sway_view *view) {
return;
}
+ if (container_is_floating(view->swayc)) {
+ view_autoconfigure_floating(view);
+ return;
+ }
+
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
int other_views = 0;
@@ -261,6 +283,8 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
view_set_fullscreen(workspace->sway_workspace->fullscreen, false);
}
workspace->sway_workspace->fullscreen = view;
+ view->swayc->saved_x = view->swayc->x;
+ view->swayc->saved_y = view->swayc->y;
view->swayc->saved_width = view->swayc->width;
view->swayc->saved_height = view->swayc->height;
@@ -283,6 +307,11 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
workspace->sway_workspace->fullscreen = NULL;
view->swayc->width = view->swayc->saved_width;
view->swayc->height = view->swayc->saved_height;
+ if (container_is_floating(view->swayc)) {
+ view->swayc->x = view->swayc->saved_x;
+ view->swayc->y = view->swayc->saved_y;
+ view_autoconfigure(view);
+ }
}
}