aboutsummaryrefslogtreecommitdiff
path: root/sway/desktop/xdg_shell.c
diff options
context:
space:
mode:
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,
xdg_shell_view->pending_width = width;
xdg_shell_view->pending_height = height;
wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
+ view_update_position(view, ox, oy);
}
static void set_activated(struct sway_view *view, bool activated) {
@@ -110,6 +111,14 @@ static void set_activated(struct sway_view *view, bool activated) {
}
}
+static void set_maximized(struct sway_view *view, bool maximized) {
+ if (xdg_shell_view_from_view(view) == NULL) {
+ return;
+ }
+ struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
+ wlr_xdg_toplevel_set_maximized(surface, maximized);
+}
+
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
@@ -118,6 +127,11 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
}
+static bool wants_floating(struct sway_view *view) {
+ // TODO
+ return false;
+}
+
static void for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data) {
if (xdg_shell_view_from_view(view) == NULL) {
@@ -154,7 +168,9 @@ static const struct sway_view_impl view_impl = {
.get_string_prop = get_string_prop,
.configure = configure,
.set_activated = set_activated,
+ .set_maximized = set_maximized,
.set_fullscreen = set_fullscreen,
+ .wants_floating = wants_floating,
.for_each_surface = for_each_surface,
.close = _close,
.destroy = destroy,
@@ -164,11 +180,17 @@ static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_xdg_shell_view *xdg_shell_view =
wl_container_of(listener, xdg_shell_view, commit);
struct sway_view *view = &xdg_shell_view->view;
- // NOTE: We intentionally discard the view's desired width here
- // TODO: Store this for restoration when moving to floating plane
- // TODO: Let floating views do whatever
- view_update_size(view, xdg_shell_view->pending_width,
- xdg_shell_view->pending_height);
+ struct wlr_box *geometry = &view->wlr_xdg_surface->geometry;
+ if (!view->natural_width && !view->natural_height) {
+ view->natural_width = geometry->width;
+ view->natural_height = geometry->height;
+ }
+ if (view->swayc && view->swayc->is_floating) {
+ view_update_size(view, geometry->width, geometry->height);
+ } else {
+ view_update_size(view, xdg_shell_view->pending_width,
+ xdg_shell_view->pending_height);
+ }
view_update_title(view, false);
view_damage_from(view);
}