summaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 99b44720..b92c7099 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -2,10 +2,12 @@
2#include <wayland-server.h> 2#include <wayland-server.h>
3#include <wlr/types/wlr_output_layout.h> 3#include <wlr/types/wlr_output_layout.h>
4#include "log.h" 4#include "log.h"
5#include "sway/ipc-server.h"
5#include "sway/output.h" 6#include "sway/output.h"
6#include "sway/tree/container.h" 7#include "sway/tree/container.h"
7#include "sway/tree/layout.h" 8#include "sway/tree/layout.h"
8#include "sway/tree/view.h" 9#include "sway/tree/view.h"
10#include "sway/tree/workspace.h"
9 11
10void view_init(struct sway_view *view, enum sway_view_type type, 12void view_init(struct sway_view *view, enum sway_view_type type,
11 const struct sway_view_impl *impl) { 13 const struct sway_view_impl *impl) {
@@ -73,6 +75,50 @@ void view_set_activated(struct sway_view *view, bool activated) {
73 } 75 }
74} 76}
75 77
78void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
79 if (view->is_fullscreen == fullscreen) {
80 return;
81 }
82
83 struct sway_container *workspace = container_parent(view->swayc, C_WORKSPACE);
84 struct sway_container *container = container_parent(workspace, C_OUTPUT);
85 struct sway_output *output = container->sway_output;
86
87 if (view->impl->set_fullscreen) {
88 view->impl->set_fullscreen(view, fullscreen);
89 }
90
91 view->is_fullscreen = fullscreen;
92
93 if (fullscreen) {
94 if (workspace->sway_workspace->fullscreen) {
95 view_set_fullscreen(workspace->sway_workspace->fullscreen, false);
96 }
97 workspace->sway_workspace->fullscreen = view;
98
99 struct sway_seat *seat;
100 struct sway_container *focus, *focus_ws;
101 wl_list_for_each(seat, &input_manager->seats, link) {
102 focus = seat_get_focus(seat);
103 focus_ws = focus;
104 if (focus_ws->type != C_WORKSPACE) {
105 focus_ws = container_parent(focus_ws, C_WORKSPACE);
106 }
107 seat_set_focus(seat, view->swayc);
108 if (focus_ws != workspace) {
109 seat_set_focus(seat, focus);
110 }
111 }
112 } else {
113 workspace->sway_workspace->fullscreen = NULL;
114 }
115
116 arrange_windows(workspace, -1, -1);
117 output_damage_whole(output);
118
119 ipc_event_window(view->swayc, "fullscreen_mode");
120}
121
76void view_close(struct sway_view *view) { 122void view_close(struct sway_view *view) {
77 if (view->impl->close) { 123 if (view->impl->close) {
78 view->impl->close(view); 124 view->impl->close(view);
@@ -197,6 +243,11 @@ void view_unmap(struct sway_view *view) {
197 243
198 wl_signal_emit(&view->events.unmap, view); 244 wl_signal_emit(&view->events.unmap, view);
199 245
246 if (view->is_fullscreen) {
247 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
248 ws->sway_workspace->fullscreen = NULL;
249 }
250
200 view_damage(view, true); 251 view_damage(view, true);
201 252
202 wl_list_remove(&view->surface_new_subsurface.link); 253 wl_list_remove(&view->surface_new_subsurface.link);