aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xdg_shell.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-24 22:30:44 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commit1f2e399ade77070a2d0b82856ad9a3eef96b8676 (patch)
treec469197e140051aea912cb173723c7e55ce1e410 /sway/desktop/xdg_shell.c
parentSend frame done to floating views (diff)
downloadsway-1f2e399ade77070a2d0b82856ad9a3eef96b8676.tar.gz
sway-1f2e399ade77070a2d0b82856ad9a3eef96b8676.tar.zst
sway-1f2e399ade77070a2d0b82856ad9a3eef96b8676.zip
Implement floating
Diffstat (limited to 'sway/desktop/xdg_shell.c')
-rw-r--r--sway/desktop/xdg_shell.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index b2b95fa0..e1a73b20 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -98,6 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
98 xdg_shell_view->pending_width = width; 98 xdg_shell_view->pending_width = width;
99 xdg_shell_view->pending_height = height; 99 xdg_shell_view->pending_height = height;
100 wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); 100 wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
101 view_update_position(view, ox, oy);
101} 102}
102 103
103static void set_activated(struct sway_view *view, bool activated) { 104static void set_activated(struct sway_view *view, bool activated) {
@@ -110,6 +111,14 @@ static void set_activated(struct sway_view *view, bool activated) {
110 } 111 }
111} 112}
112 113
114static void set_maximized(struct sway_view *view, bool maximized) {
115 if (xdg_shell_view_from_view(view) == NULL) {
116 return;
117 }
118 struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
119 wlr_xdg_toplevel_set_maximized(surface, maximized);
120}
121
113static void set_fullscreen(struct sway_view *view, bool fullscreen) { 122static void set_fullscreen(struct sway_view *view, bool fullscreen) {
114 if (xdg_shell_view_from_view(view) == NULL) { 123 if (xdg_shell_view_from_view(view) == NULL) {
115 return; 124 return;
@@ -118,6 +127,11 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
118 wlr_xdg_toplevel_set_fullscreen(surface, fullscreen); 127 wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
119} 128}
120 129
130static bool wants_floating(struct sway_view *view) {
131 // TODO
132 return false;
133}
134
121static void for_each_surface(struct sway_view *view, 135static void for_each_surface(struct sway_view *view,
122 wlr_surface_iterator_func_t iterator, void *user_data) { 136 wlr_surface_iterator_func_t iterator, void *user_data) {
123 if (xdg_shell_view_from_view(view) == NULL) { 137 if (xdg_shell_view_from_view(view) == NULL) {
@@ -154,7 +168,9 @@ static const struct sway_view_impl view_impl = {
154 .get_string_prop = get_string_prop, 168 .get_string_prop = get_string_prop,
155 .configure = configure, 169 .configure = configure,
156 .set_activated = set_activated, 170 .set_activated = set_activated,
171 .set_maximized = set_maximized,
157 .set_fullscreen = set_fullscreen, 172 .set_fullscreen = set_fullscreen,
173 .wants_floating = wants_floating,
158 .for_each_surface = for_each_surface, 174 .for_each_surface = for_each_surface,
159 .close = _close, 175 .close = _close,
160 .destroy = destroy, 176 .destroy = destroy,
@@ -164,11 +180,17 @@ static void handle_commit(struct wl_listener *listener, void *data) {
164 struct sway_xdg_shell_view *xdg_shell_view = 180 struct sway_xdg_shell_view *xdg_shell_view =
165 wl_container_of(listener, xdg_shell_view, commit); 181 wl_container_of(listener, xdg_shell_view, commit);
166 struct sway_view *view = &xdg_shell_view->view; 182 struct sway_view *view = &xdg_shell_view->view;
167 // NOTE: We intentionally discard the view's desired width here 183 struct wlr_box *geometry = &view->wlr_xdg_surface->geometry;
168 // TODO: Store this for restoration when moving to floating plane 184 if (!view->natural_width && !view->natural_height) {
169 // TODO: Let floating views do whatever 185 view->natural_width = geometry->width;
170 view_update_size(view, xdg_shell_view->pending_width, 186 view->natural_height = geometry->height;
171 xdg_shell_view->pending_height); 187 }
188 if (view->swayc && view->swayc->is_floating) {
189 view_update_size(view, geometry->width, geometry->height);
190 } else {
191 view_update_size(view, xdg_shell_view->pending_width,
192 xdg_shell_view->pending_height);
193 }
172 view_update_title(view, false); 194 view_update_title(view, false);
173 view_damage_from(view); 195 view_damage_from(view);
174} 196}