]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: treat X11 panel views as if fixedPosition rule is set
authorJohn Lindgren <john@jlindgren.net>
Mon, 27 Nov 2023 22:11:29 +0000 (17:11 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 29 Nov 2023 06:48:31 +0000 (06:48 +0000)
include/view.h
src/interactive.c
src/view.c
src/xwayland.c

index 04460f3b7daf60bbd501e4b064ba5a310c1ea658..a3dd9cb069cea6b23b310d48c4d8ec54820d7adf 100644 (file)
@@ -112,6 +112,8 @@ struct view_impl {
        struct view_size_hints (*get_size_hints)(struct view *self);
        /* if not implemented, VIEW_WANTS_FOCUS_ALWAYS is assumed */
        enum view_wants_focus (*wants_focus)(struct view *self);
+       /* returns true if view reserves space at screen edge */
+       bool (*has_strut_partial)(struct view *self);
 };
 
 struct view {
@@ -431,6 +433,14 @@ void view_append_children(struct view *view, struct wl_array *children);
  */
 bool view_is_related(struct view *view, struct wlr_surface *surface);
 
+/**
+ * view_has_strut_partial() - returns true for views that reserve space
+ * at a screen edge (e.g. panels). These views are treated as if they
+ * have the fixedPosition window rule: i.e. they are not restricted to
+ * the usable area and cannot be moved/resized interactively.
+ */
+bool view_has_strut_partial(struct view *view);
+
 const char *view_get_string_prop(struct view *view, const char *prop);
 void view_update_title(struct view *view);
 void view_update_app_id(struct view *view);
index 31c3c076e45def44452078241aa188339b980d5b..95eb4b78cc36f6554ae6c8a3d8082cd6b9796e6e 100644 (file)
@@ -35,7 +35,9 @@ interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
                return;
        }
 
-       if (window_rules_get_property(view, "fixedPosition") == LAB_PROP_TRUE) {
+       /* Prevent moving/resizing fixed-position and panel-like views */
+       if (window_rules_get_property(view, "fixedPosition") == LAB_PROP_TRUE
+                       || view_has_strut_partial(view)) {
                return;
        }
 
index f26ca4ac4f9c6d294af5e800acdbdc3c0f98dfe4..7dc812056c7fd19c30825e82e027d66ea2d5673b 100644 (file)
@@ -593,7 +593,9 @@ view_adjust_floating_geometry(struct view *view, struct wlr_box *geometry)
                return false;
        }
 
-       if (window_rules_get_property(view, "fixedPosition") == LAB_PROP_TRUE) {
+       /* Avoid moving panels out of their own reserved area ("strut") */
+       if (window_rules_get_property(view, "fixedPosition") == LAB_PROP_TRUE
+                       || view_has_strut_partial(view)) {
                return false;
        }
 
@@ -1550,6 +1552,14 @@ view_is_related(struct view *view, struct wlr_surface *surface)
        return false;
 }
 
+bool
+view_has_strut_partial(struct view *view)
+{
+       assert(view);
+       return view->impl->has_strut_partial &&
+               view->impl->has_strut_partial(view);
+}
+
 const char *
 view_get_string_prop(struct view *view, const char *prop)
 {
index ac2c715871b7424f043b328e684607c0fb89936d..30277c0608d948c3bf4f32f8d33dae2cb642c4fd 100644 (file)
@@ -103,6 +103,14 @@ xwayland_view_wants_focus(struct view *view)
        return VIEW_WANTS_FOCUS_NEVER;
 }
 
+static bool
+xwayland_view_has_strut_partial(struct view *view)
+{
+       struct wlr_xwayland_surface *xsurface =
+               xwayland_surface_from_view(view);
+       return (bool)xsurface->strut_partial;
+}
+
 static struct wlr_xwayland_surface *
 top_parent_of(struct view *view)
 {
@@ -786,6 +794,7 @@ static const struct view_impl xwayland_view_impl = {
        .is_related = xwayland_view_is_related,
        .get_size_hints = xwayland_view_get_size_hints,
        .wants_focus = xwayland_view_wants_focus,
+       .has_strut_partial = xwayland_view_has_strut_partial,
 };
 
 void