Skip to content

Commit

Permalink
Merge pull request #3187 from MirServer/new_window_placement
Browse files Browse the repository at this point in the history
Change placement of new floating windows
  • Loading branch information
hbatagelo authored Jan 16, 2024
2 parents a632621 + f4b238a commit d685c47
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/miral/basic_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,42 @@ auto miral::BasicWindowManager::place_new_surface(WindowSpecification parameters

if (parameters.top_left().value().y < display_area.top_left.y)
parameters.top_left() = Point{parameters.top_left().value().x, display_area.top_left.y};

if (parameters.state() == mir_window_state_restored)
{
auto const offset{48};
std::array const positions {
parameters.top_left().value(),
parameters.top_left().value() + Displacement( offset, offset),
parameters.top_left().value() + Displacement(-offset, offset),
parameters.top_left().value() + Displacement( offset, -offset),
parameters.top_left().value() + Displacement(-offset, -offset)};

for (auto const& position : positions)
{
auto const window{window_at(position)};

static auto const ignored_state_or_type = [](WindowInfo const& info)
{
switch (info.type())
{
case mir_window_type_normal:
case mir_window_type_decoration:
case mir_window_type_freestyle:
return info.state() != mir_window_state_restored;

default:
return true;
}
};

if (!window || ignored_state_or_type(info_for(window)) || window.top_left() != position)
{
parameters.top_left().value() = position;
break;
}
}
}
}

return parameters;
Expand Down

0 comments on commit d685c47

Please sign in to comment.