aboutsummaryrefslogtreecommitdiff
path: root/rootston/desktop.c
diff options
context:
space:
mode:
Diffstat (limited to 'rootston/desktop.c')
-rw-r--r--rootston/desktop.c69
1 files changed, 62 insertions, 7 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c
index cf5a8cdc..be74b619 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -89,6 +89,19 @@ void view_move_resize(struct roots_view *view, double x, double y,
view_resize(view, width, height);
}
+static struct wlr_output *view_get_output(struct roots_view *view) {
+ struct wlr_box view_box;
+ view_get_box(view, &view_box);
+
+ double output_x, output_y;
+ wlr_output_layout_closest_point(view->desktop->layout, NULL,
+ view->x + (double)view_box.width/2,
+ view->y + (double)view_box.height/2,
+ &output_x, &output_y);
+ return wlr_output_layout_output_at(view->desktop->layout, output_x,
+ output_y);
+}
+
void view_maximize(struct roots_view *view, bool maximized) {
if (view->maximized == maximized) {
return;
@@ -109,13 +122,7 @@ void view_maximize(struct roots_view *view, bool maximized) {
view->saved.width = view_box.width;
view->saved.height = view_box.height;
- double output_x, output_y;
- wlr_output_layout_closest_point(view->desktop->layout, NULL,
- view->x + (double)view_box.width/2,
- view->y + (double)view_box.height/2,
- &output_x, &output_y);
- struct wlr_output *output = wlr_output_layout_output_at(
- view->desktop->layout, output_x, output_y);
+ struct wlr_output *output = view_get_output(view);
struct wlr_box *output_box =
wlr_output_layout_get_box(view->desktop->layout, output);
@@ -133,6 +140,54 @@ void view_maximize(struct roots_view *view, bool maximized) {
}
}
+void view_set_fullscreen(struct roots_view *view, bool fullscreen,
+ struct wlr_output *output) {
+ bool was_fullscreen = view->fullscreen_output != NULL;
+ if (was_fullscreen == fullscreen) {
+ // TODO: support changing the output?
+ return;
+ }
+
+ // TODO: check if client is focused?
+
+ if (view->set_fullscreen) {
+ view->set_fullscreen(view, fullscreen);
+ }
+
+ if (!was_fullscreen && fullscreen) {
+ if (output == NULL) {
+ output = view_get_output(view);
+ }
+
+ struct wlr_box view_box;
+ view_get_box(view, &view_box);
+
+ view->saved.x = view->x;
+ view->saved.y = view->y;
+ view->saved.rotation = view->rotation;
+ view->saved.width = view_box.width;
+ view->saved.height = view_box.height;
+
+ struct wlr_box *output_box =
+ wlr_output_layout_get_box(view->desktop->layout, output);
+ view_move_resize(view, output_box->x, output_box->y, output_box->width,
+ output_box->height);
+ view->rotation = 0;
+
+ wlr_output_set_fullscreen_surface(output, view->wlr_surface);
+ view->fullscreen_output = output;
+ }
+
+ if (was_fullscreen && !fullscreen) {
+ view_move_resize(view, view->saved.x, view->saved.y, view->saved.width,
+ view->saved.height);
+ view->rotation = view->saved.rotation;
+
+ wlr_output_set_fullscreen_surface(view->fullscreen_output, NULL);
+ view->fullscreen_output = NULL;
+ }
+}
+
void view_close(struct roots_view *view) {
if (view->close) {
view->close(view);