mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-12-02 08:48:07 +03:00
feature: resizing the display resizes the windows in it
This commit is contained in:
parent
a1eb6f7347
commit
e3add8c55e
@ -159,7 +159,7 @@ void MiracleWindowManagementPolicy::advise_output_create(miral::Output const& ou
|
||||
|
||||
void MiracleWindowManagementPolicy::advise_output_update(miral::Output const& updated, miral::Output const& original)
|
||||
{
|
||||
for (auto pair : tree_list)
|
||||
for (auto& pair : tree_list)
|
||||
{
|
||||
if (pair.output.is_same_output(original))
|
||||
{
|
||||
|
13
src/node.cpp
13
src/node.cpp
@ -361,3 +361,16 @@ std::shared_ptr<Node> Node::find_nth_window_child(int i)
|
||||
// The lane is correct, so let's get the first window in that lane.
|
||||
return sub_nodes[i]->find_nth_window_child(0);
|
||||
}
|
||||
|
||||
void Node::scale_area(double x_scale, double y_scale)
|
||||
{
|
||||
area.size.width = geom::Width{ceil(x_scale * area.size.width.as_int())};
|
||||
area.size.height = geom::Height {ceil(y_scale * area.size.height.as_int())};
|
||||
|
||||
for (auto node : sub_nodes)
|
||||
{
|
||||
node->scale_area(x_scale, y_scale);
|
||||
}
|
||||
|
||||
redistribute_size();
|
||||
}
|
@ -90,6 +90,8 @@ public:
|
||||
std::shared_ptr<Node> to_lane();
|
||||
std::shared_ptr<Node> find_nth_window_child(int i);
|
||||
|
||||
void scale_area(double x_scale, double y_scale);
|
||||
|
||||
private:
|
||||
miral::Window window;
|
||||
std::vector<std::shared_ptr<Node>> sub_nodes;
|
||||
|
@ -85,9 +85,12 @@ bool WindowTree::try_select_next(miracle::Direction direction)
|
||||
|
||||
void WindowTree::resize_display(geom::Size new_size)
|
||||
{
|
||||
size = new_size;
|
||||
root_lane->redistribute_size();
|
||||
// TODO: Resize all windows
|
||||
double x_scale = static_cast<double>(new_size.width.as_int()) / static_cast<double>(size.width.as_int());
|
||||
double y_scale = static_cast<double>(new_size.height.as_int()) / static_cast<double>(size.height.as_int());
|
||||
root_lane->scale_area(x_scale, y_scale);
|
||||
size = geom::Size{
|
||||
geom::Width{ceil(size.width.as_int() * x_scale)},
|
||||
geom::Height {ceil(size.height.as_int() * y_scale)}};
|
||||
}
|
||||
|
||||
bool WindowTree::try_move_active_window(miracle::Direction direction)
|
||||
|
Loading…
Reference in New Issue
Block a user