mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-11-23 21:13:53 +03:00
bugfix: translating other outputs when we resize an output
This commit is contained in:
parent
daf16b0b02
commit
ea9376b4d7
@ -188,7 +188,7 @@ void MiracleWindowManagementPolicy::advise_output_update(miral::Output const& up
|
||||
{
|
||||
if (pair->output.is_same_output(original))
|
||||
{
|
||||
pair->tree.resize_display(updated.extents().size);
|
||||
pair->tree.set_output_area(updated.extents());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
11
src/node.cpp
11
src/node.cpp
@ -372,5 +372,16 @@ void Node::scale_area(double x_scale, double y_scale)
|
||||
node->scale_area(x_scale, y_scale);
|
||||
}
|
||||
|
||||
redistribute_size();
|
||||
}
|
||||
|
||||
void Node::translate_by(int x, int y)
|
||||
{
|
||||
area.top_left.x = geom::X{area.top_left.x.as_int() + x};
|
||||
area.top_left.y = geom::Y{area.top_left.y.as_int() + y};
|
||||
for (auto node : sub_nodes)
|
||||
{
|
||||
node->translate_by(x, y);
|
||||
}
|
||||
redistribute_size();
|
||||
}
|
@ -91,6 +91,7 @@ public:
|
||||
std::shared_ptr<Node> find_nth_window_child(int i);
|
||||
|
||||
void scale_area(double x_scale, double y_scale);
|
||||
void translate_by(int x, int y);
|
||||
|
||||
private:
|
||||
miral::Window window;
|
||||
|
@ -83,14 +83,19 @@ bool WindowTree::try_select_next(miracle::Direction direction)
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowTree::resize_display(geom::Size new_size)
|
||||
void WindowTree::set_output_area(geom::Rectangle new_area)
|
||||
{
|
||||
double x_scale = static_cast<double>(new_size.width.as_int()) / static_cast<double>(area.size.width.as_int());
|
||||
double y_scale = static_cast<double>(new_size.height.as_int()) / static_cast<double>(area.size.height.as_int());
|
||||
double x_scale = static_cast<double>(new_area.size.width.as_int()) / static_cast<double>(area.size.width.as_int());
|
||||
double y_scale = static_cast<double>(new_area.size.height.as_int()) / static_cast<double>(area.size.height.as_int());
|
||||
root_lane->scale_area(x_scale, y_scale);
|
||||
area.size = geom::Size{
|
||||
geom::Width{ceil(area.size.width.as_int() * x_scale)},
|
||||
geom::Height {ceil(area.size.height.as_int() * y_scale)}};
|
||||
|
||||
int position_diff_x = new_area.top_left.x.as_int() - area.top_left.x.as_int();
|
||||
int position_diff_y = new_area.top_left.y.as_int() - area.top_left.y.as_int();
|
||||
root_lane->translate_by(position_diff_x, position_diff_y);
|
||||
area.top_left = new_area.top_left;
|
||||
}
|
||||
|
||||
bool WindowTree::point_is_in_output(int x, int y)
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
void advise_delete_window(miral::Window&);
|
||||
|
||||
/// Called when the physical display is resized.
|
||||
void resize_display(geom::Size new_size);
|
||||
void set_output_area(geom::Rectangle new_area);
|
||||
|
||||
bool point_is_in_output(int x, int y);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user