Skip to content

Commit

Permalink
Use useable output area for maximize
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Oct 13, 2023
1 parent 7a354d7 commit 50cb351
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,13 @@ void Output::update_layout() {
wlr_scene_layer_surface_v1_configure(layer->scene_layer_surface, &full_area, &usable_area);
}
}

wlr_box Output::usable_area_in_layout_coords() const {
double layout_x = 0, layout_y = 0;
wlr_output_layout_output_coords(server.output_layout, output, &layout_x, &layout_y);

wlr_box box = usable_area;
box.x -= layout_x;
box.y -= layout_y;
return box;
}
1 change: 1 addition & 0 deletions src/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Output {
~Output() noexcept;

void update_layout();
wlr_box usable_area_in_layout_coords() const;
};

#endif
7 changes: 3 additions & 4 deletions src/surface/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@ void View::set_maximized(const bool maximized) {
previous.x = current.x;
previous.y = current.y;

wlr_box output_box = current;

auto best_output = find_output_for_maximize();
if (best_output.has_value()) {
wlr_output_layout_get_box(server.output_layout, best_output.value()->output, &output_box);
if (!best_output.has_value()) {
return;
}

wlr_box output_box = best_output.value()->usable_area_in_layout_coords();
set_size(output_box.width, output_box.height);
impl_set_maximized(true);
current.x = output_box.x;
Expand Down

0 comments on commit 50cb351

Please sign in to comment.