From 895f0cfac944a494fd9698948831cfe832a59e6f Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Tue, 2 Apr 2024 17:31:20 +0200 Subject: [PATCH 1/3] toplevel-interface: add min/max size APIs --- src/api/wayfire/plugin.hpp | 2 +- src/api/wayfire/toplevel.hpp | 18 +++++++++++++++++ src/view/xdg-shell/xdg-toplevel.cpp | 20 +++++++++++++++++++ src/view/xdg-shell/xdg-toplevel.hpp | 3 +++ src/view/xwayland/xwayland-toplevel.cpp | 26 +++++++++++++++++++++++++ src/view/xwayland/xwayland-toplevel.hpp | 3 +++ 6 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/api/wayfire/plugin.hpp b/src/api/wayfire/plugin.hpp index 6deca39aa..e04d58757 100644 --- a/src/api/wayfire/plugin.hpp +++ b/src/api/wayfire/plugin.hpp @@ -105,7 +105,7 @@ class plugin_interface_t using wayfire_plugin_load_func = wf::plugin_interface_t * (*)(); /** The version of Wayfire's API/ABI */ -constexpr uint32_t WAYFIRE_API_ABI_VERSION = 2024'04'01; +constexpr uint32_t WAYFIRE_API_ABI_VERSION = 2024'04'02; /** * Each plugin must also provide a function which returns the Wayfire API/ABI diff --git a/src/api/wayfire/toplevel.hpp b/src/api/wayfire/toplevel.hpp index cefa95fbb..cf2aa303a 100644 --- a/src/api/wayfire/toplevel.hpp +++ b/src/api/wayfire/toplevel.hpp @@ -103,6 +103,24 @@ class toplevel_t : public wf::txn::transaction_object_t, public wf::object_base_ return _pending; } + /** + * The minimum desirable size of the toplevel if set by the client. + * If the client has not indicated a minimum size in either dimension, that dimension will be set to 0. + */ + virtual wf::dimensions_t get_min_size() + { + return {0, 0}; + } + + /** + * The maximum desirable size of the toplevel if set by the client. + * If the client has not indicated a maximum size in either dimension, that dimension will be set to 0. + */ + virtual wf::dimensions_t get_max_size() + { + return {0, 0}; + } + protected: toplevel_state_t _current; toplevel_state_t _pending; diff --git a/src/view/xdg-shell/xdg-toplevel.cpp b/src/view/xdg-shell/xdg-toplevel.cpp index 221daf607..2802b86a8 100644 --- a/src/view/xdg-shell/xdg-toplevel.cpp +++ b/src/view/xdg-shell/xdg-toplevel.cpp @@ -246,3 +246,23 @@ wf::dimensions_t wf::xdg_toplevel_t::get_current_wlr_toplevel_size() wlr_xdg_surface_get_geometry(toplevel->base, &wm_box); return wf::dimensions(wm_box); } + +wf::dimensions_t wf::xdg_toplevel_t::get_min_size() +{ + if (toplevel) + { + return wf::dimensions_t{toplevel->current.min_width, toplevel->current.min_height}; + } + + return {0, 0}; +} + +wf::dimensions_t wf::xdg_toplevel_t::get_max_size() +{ + if (toplevel) + { + return wf::dimensions_t{toplevel->current.max_width, toplevel->current.max_height}; + } + + return {0, 0}; +} diff --git a/src/view/xdg-shell/xdg-toplevel.hpp b/src/view/xdg-shell/xdg-toplevel.hpp index 83ea9d5b5..dfdee5d1d 100644 --- a/src/view/xdg-shell/xdg-toplevel.hpp +++ b/src/view/xdg-shell/xdg-toplevel.hpp @@ -27,6 +27,9 @@ class xdg_toplevel_t : public toplevel_t, public std::enable_shared_from_this main_surface; scene::surface_state_t pending_state; diff --git a/src/view/xwayland/xwayland-toplevel.cpp b/src/view/xwayland/xwayland-toplevel.cpp index 0ccdf7268..08e3d12c2 100644 --- a/src/view/xwayland/xwayland-toplevel.cpp +++ b/src/view/xwayland/xwayland-toplevel.cpp @@ -287,4 +287,30 @@ wf::dimensions_t wf::xw::xwayland_toplevel_t::get_current_xw_size() return size; } +wf::dimensions_t wf::xw::xwayland_toplevel_t::get_min_size() +{ + if (xw && xw->size_hints) + { + return wf::dimensions_t{ + std::max(0, xw->size_hints->min_width), + std::max(0, xw->size_hints->min_height) + }; + } + + return {0, 0}; +} + +wf::dimensions_t wf::xw::xwayland_toplevel_t::get_max_size() +{ + if (xw && xw->size_hints) + { + return wf::dimensions_t{ + std::max(0, xw->size_hints->max_width), + std::max(0, xw->size_hints->max_height) + }; + } + + return {0, 0}; +} + #endif diff --git a/src/view/xwayland/xwayland-toplevel.hpp b/src/view/xwayland/xwayland-toplevel.hpp index 9e0bbf895..505dae87d 100644 --- a/src/view/xwayland/xwayland-toplevel.hpp +++ b/src/view/xwayland/xwayland-toplevel.hpp @@ -29,6 +29,9 @@ class xwayland_toplevel_t : public wf::toplevel_t, public std::enable_shared_fro void commit() override; void apply() override; + wf::dimensions_t get_min_size() override; + wf::dimensions_t get_max_size() override; + void set_main_surface(std::shared_ptr main_surface); void set_output_offset(wf::point_t output_offset); From 187768c19f276dc2d529028309a229b67304052e Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Tue, 2 Apr 2024 17:34:41 +0200 Subject: [PATCH 2/3] simple-tile: do not tile views with min==max size Fixes #2243 --- plugins/tile/tile-plugin.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/tile/tile-plugin.cpp b/plugins/tile/tile-plugin.cpp index 4f06ec3a0..9480c6a95 100644 --- a/plugins/tile/tile-plugin.cpp +++ b/plugins/tile/tile-plugin.cpp @@ -35,6 +35,12 @@ static bool can_tile_view(wayfire_toplevel_view view) return false; } + if ((view->toplevel()->get_min_size() == view->toplevel()->get_max_size()) && + (view->toplevel()->get_min_size().width > 0) && (view->toplevel()->get_min_size().height > 0)) + { + return false; + } + return true; } From c2f5cb618e74c955c1e5e6fbc283f1d285f17e43 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Tue, 2 Apr 2024 17:35:10 +0200 Subject: [PATCH 3/3] ipc-rules: report min/max size for toplevels --- plugins/single_plugins/ipc-rules.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/single_plugins/ipc-rules.cpp b/plugins/single_plugins/ipc-rules.cpp index b622e0583..1ba366596 100644 --- a/plugins/single_plugins/ipc-rules.cpp +++ b/plugins/single_plugins/ipc-rules.cpp @@ -799,7 +799,11 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker description["activated"] = toplevel ? toplevel->activated : false; description["sticky"] = toplevel ? toplevel->sticky : false; description["wset-index"] = toplevel && toplevel->get_wset() ? toplevel->get_wset()->get_index() : -1; - description["focusable"] = view->is_focusable(); + description["min-size"] = wf::ipc::dimensions_to_json( + toplevel ? toplevel->toplevel()->get_min_size() : wf::dimensions_t{0, 0}); + description["max-size"] = wf::ipc::dimensions_to_json( + toplevel ? toplevel->toplevel()->get_max_size() : wf::dimensions_t{0, 0}); + description["focusable"] = view->is_focusable(); description["type"] = get_view_type(view); return description;