Skip to content

Commit

Permalink
Fix initial centering XDG windows on multiple monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Oct 29, 2023
1 parent a336c85 commit c8a0e7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ wlr_box Output::usable_area_in_layout_coords() const {
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;
box.x += layout_x;
box.y += layout_y;
return box;
}
2 changes: 1 addition & 1 deletion src/surface/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class XdgView : public View {

private:
Listeners listeners;
bool never_mapped;
bool pending_map = true;

public:
Server& server;
Expand Down
6 changes: 2 additions & 4 deletions src/surface/xdg_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ XdgView::XdgView(Server& server, wlr_xdg_toplevel& toplevel) noexcept
scene_node = &scene_tree->node;
surface = toplevel.base->surface;

never_mapped = true;

wlr_xdg_toplevel_set_wm_capabilities(
&toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE | WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE);

Expand Down Expand Up @@ -197,7 +195,7 @@ const wlr_box XdgView::get_geometry() const {
}

void XdgView::map() {
if (never_mapped) {
if (pending_map) {
previous = {0, 0, 0, 0};
wlr_xdg_surface_get_geometry(xdg_toplevel.base, &current);

Expand All @@ -209,7 +207,7 @@ void XdgView::map() {
set_position(center_x - (current.width / 2), center_y - (current.height / 2));
}

never_mapped = false;
pending_map = false;
}

wlr_scene_node_set_enabled(scene_node, true);
Expand Down

0 comments on commit c8a0e7f

Please sign in to comment.