Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api add min max size #2306

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugins/single_plugins/ipc-rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions plugins/tile/tile-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/wayfire/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/api/wayfire/toplevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions src/view/xdg-shell/xdg-toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
3 changes: 3 additions & 0 deletions src/view/xdg-shell/xdg-toplevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class xdg_toplevel_t : public toplevel_t, public std::enable_shared_from_this<xd
wf::geometry_t calculate_base_geometry();
void request_native_size();

wf::dimensions_t get_min_size() override;
wf::dimensions_t get_max_size() override;

private:
std::shared_ptr<wf::scene::wlr_surface_node_t> main_surface;
scene::surface_state_t pending_state;
Expand Down
26 changes: 26 additions & 0 deletions src/view/xwayland/xwayland-toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/view/xwayland/xwayland-toplevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wf::scene::wlr_surface_node_t> main_surface);
void set_output_offset(wf::point_t output_offset);

Expand Down
Loading