diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-24 22:30:44 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-01 23:14:58 +1000 |
commit | 1f2e399ade77070a2d0b82856ad9a3eef96b8676 (patch) | |
tree | c469197e140051aea912cb173723c7e55ce1e410 /sway/desktop/xdg_shell_v6.c | |
parent | Send frame done to floating views (diff) | |
download | sway-1f2e399ade77070a2d0b82856ad9a3eef96b8676.tar.gz sway-1f2e399ade77070a2d0b82856ad9a3eef96b8676.tar.zst sway-1f2e399ade77070a2d0b82856ad9a3eef96b8676.zip |
Implement floating
Diffstat (limited to 'sway/desktop/xdg_shell_v6.c')
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index d098c797..47e4162a 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -97,6 +97,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width, | |||
97 | xdg_shell_v6_view->pending_width = width; | 97 | xdg_shell_v6_view->pending_width = width; |
98 | xdg_shell_v6_view->pending_height = height; | 98 | xdg_shell_v6_view->pending_height = height; |
99 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); | 99 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); |
100 | view_update_position(view, ox, oy); | ||
100 | } | 101 | } |
101 | 102 | ||
102 | static void set_activated(struct sway_view *view, bool activated) { | 103 | static void set_activated(struct sway_view *view, bool activated) { |
@@ -109,6 +110,14 @@ static void set_activated(struct sway_view *view, bool activated) { | |||
109 | } | 110 | } |
110 | } | 111 | } |
111 | 112 | ||
113 | static void set_maximized(struct sway_view *view, bool maximized) { | ||
114 | if (xdg_shell_v6_view_from_view(view) == NULL) { | ||
115 | return; | ||
116 | } | ||
117 | struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6; | ||
118 | wlr_xdg_toplevel_v6_set_maximized(surface, maximized); | ||
119 | } | ||
120 | |||
112 | static void set_fullscreen(struct sway_view *view, bool fullscreen) { | 121 | static void set_fullscreen(struct sway_view *view, bool fullscreen) { |
113 | if (xdg_shell_v6_view_from_view(view) == NULL) { | 122 | if (xdg_shell_v6_view_from_view(view) == NULL) { |
114 | return; | 123 | return; |
@@ -117,6 +126,11 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { | |||
117 | wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen); | 126 | wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen); |
118 | } | 127 | } |
119 | 128 | ||
129 | static bool wants_floating(struct sway_view *view) { | ||
130 | // TODO | ||
131 | return false; | ||
132 | } | ||
133 | |||
120 | static void for_each_surface(struct sway_view *view, | 134 | static void for_each_surface(struct sway_view *view, |
121 | wlr_surface_iterator_func_t iterator, void *user_data) { | 135 | wlr_surface_iterator_func_t iterator, void *user_data) { |
122 | if (xdg_shell_v6_view_from_view(view) == NULL) { | 136 | if (xdg_shell_v6_view_from_view(view) == NULL) { |
@@ -153,7 +167,9 @@ static const struct sway_view_impl view_impl = { | |||
153 | .get_string_prop = get_string_prop, | 167 | .get_string_prop = get_string_prop, |
154 | .configure = configure, | 168 | .configure = configure, |
155 | .set_activated = set_activated, | 169 | .set_activated = set_activated, |
170 | .set_maximized = set_maximized, | ||
156 | .set_fullscreen = set_fullscreen, | 171 | .set_fullscreen = set_fullscreen, |
172 | .wants_floating = wants_floating, | ||
157 | .for_each_surface = for_each_surface, | 173 | .for_each_surface = for_each_surface, |
158 | .close = _close, | 174 | .close = _close, |
159 | .destroy = destroy, | 175 | .destroy = destroy, |
@@ -163,11 +179,17 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
163 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 179 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
164 | wl_container_of(listener, xdg_shell_v6_view, commit); | 180 | wl_container_of(listener, xdg_shell_v6_view, commit); |
165 | struct sway_view *view = &xdg_shell_v6_view->view; | 181 | struct sway_view *view = &xdg_shell_v6_view->view; |
166 | // NOTE: We intentionally discard the view's desired width here | 182 | struct wlr_box *geometry = &view->wlr_xdg_surface_v6->geometry; |
167 | // TODO: Store this for restoration when moving to floating plane | 183 | if (!view->natural_width && !view->natural_height) { |
168 | // TODO: Let floating views do whatever | 184 | view->natural_width = geometry->width; |
169 | view_update_size(view, xdg_shell_v6_view->pending_width, | 185 | view->natural_height = geometry->height; |
170 | xdg_shell_v6_view->pending_height); | 186 | } |
187 | if (view->swayc && view->swayc->is_floating) { | ||
188 | view_update_size(view, geometry->width, geometry->height); | ||
189 | } else { | ||
190 | view_update_size(view, xdg_shell_v6_view->pending_width, | ||
191 | xdg_shell_v6_view->pending_height); | ||
192 | } | ||
171 | view_update_title(view, false); | 193 | view_update_title(view, false); |
172 | view_damage_from(view); | 194 | view_damage_from(view); |
173 | } | 195 | } |