mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-11-23 12:15:59 +03:00
bugfix: somewhat handling attached windows
This commit is contained in:
parent
d6abbe57e1
commit
aebb8465ea
@ -58,17 +58,6 @@ const std::string POSSIBLE_TERMINALS[] = {
|
||||
"wezterm",
|
||||
"rio"
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool is_tileable(T& requested_specification)
|
||||
{
|
||||
auto t = requested_specification.type();
|
||||
auto state = requested_specification.state();
|
||||
auto has_exclusive_rect = requested_specification.exclusive_rect().is_set();
|
||||
return (t == mir_window_type_normal || t == mir_window_type_freestyle)
|
||||
&& (state == mir_window_state_restored || state == mir_window_state_maximized)
|
||||
&& !has_exclusive_rect;
|
||||
}
|
||||
}
|
||||
|
||||
MiracleWindowManagementPolicy::MiracleWindowManagementPolicy(
|
||||
@ -258,30 +247,17 @@ auto MiracleWindowManagementPolicy::place_new_window(
|
||||
const miral::ApplicationInfo &app_info,
|
||||
const miral::WindowSpecification &requested_specification) -> miral::WindowSpecification
|
||||
{
|
||||
if (is_tileable(requested_specification))
|
||||
{
|
||||
// In this step, we'll ask the WindowTree where we should place the window on the display
|
||||
// We will also resize the adjacent windows accordingly in this step.
|
||||
return active_output->screen->get_active_tree().allocate_position(requested_specification);
|
||||
}
|
||||
|
||||
return requested_specification;
|
||||
return active_output->screen->get_active_tree().allocate_position(requested_specification);
|
||||
}
|
||||
|
||||
void MiracleWindowManagementPolicy::advise_new_window(miral::WindowInfo const& window_info)
|
||||
{
|
||||
miral::WindowManagementPolicy::advise_new_window(window_info);
|
||||
if (is_tileable(window_info))
|
||||
active_output->screen->get_active_tree().advise_new_window(window_info);
|
||||
active_output->screen->get_active_tree().advise_new_window(window_info);
|
||||
}
|
||||
|
||||
void MiracleWindowManagementPolicy::handle_window_ready(miral::WindowInfo &window_info)
|
||||
{
|
||||
if (!is_tileable(window_info))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto const& output : output_list)
|
||||
{
|
||||
if (output->screen->get_active_tree().handle_window_ready(window_info))
|
||||
|
@ -8,6 +8,17 @@ namespace miracle
|
||||
namespace window_helpers
|
||||
{
|
||||
bool is_window_fullscreen(MirWindowState state);
|
||||
|
||||
template <typename T>
|
||||
bool is_tileable(T const& requested_specification)
|
||||
{
|
||||
auto t = requested_specification.type();
|
||||
auto state = requested_specification.state();
|
||||
auto has_exclusive_rect = requested_specification.exclusive_rect().is_set();
|
||||
return (t == mir_window_type_normal || t == mir_window_type_freestyle)
|
||||
&& (state == mir_window_state_restored || state == mir_window_state_maximized)
|
||||
&& !has_exclusive_rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "window_tree.h"
|
||||
#include "window_helpers.h"
|
||||
#include "screen.h"
|
||||
#include "window_helpers.h"
|
||||
|
||||
#include <memory>
|
||||
#include <mir/log.h>
|
||||
#include <iostream>
|
||||
@ -28,6 +30,9 @@ WindowTree::WindowTree(
|
||||
miral::WindowSpecification WindowTree::allocate_position(const miral::WindowSpecification &requested_specification)
|
||||
{
|
||||
miral::WindowSpecification new_spec = requested_specification;
|
||||
if (!window_helpers::is_tileable(requested_specification))
|
||||
return new_spec;
|
||||
|
||||
new_spec.min_width() = geom::Width{0};
|
||||
new_spec.max_width() = geom::Width{std::numeric_limits<int>::max()};
|
||||
new_spec.min_height() = geom::Height{0};
|
||||
@ -46,6 +51,13 @@ miral::WindowSpecification WindowTree::allocate_position(const miral::WindowSpec
|
||||
|
||||
void WindowTree::advise_new_window(miral::WindowInfo const& window_info)
|
||||
{
|
||||
if (!window_helpers::is_tileable(window_info) && window_info.state() == MirWindowState::mir_window_state_attached)
|
||||
{
|
||||
tools.select_active_window(window_info.window());
|
||||
non_tiling_window_list.push_back(window_info.window());
|
||||
return;
|
||||
}
|
||||
|
||||
_get_active_lane()->add_window(window_info.window());
|
||||
if (window_helpers::is_window_fullscreen(window_info.state()))
|
||||
{
|
||||
@ -170,6 +182,18 @@ bool WindowTree::select_window_from_point(int x, int y)
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto const& window : non_tiling_window_list)
|
||||
{
|
||||
auto rectangle = geom::Rectangle{window.top_left(), window.size()};
|
||||
if (rectangle.contains(geom::Point(x, y)))
|
||||
{
|
||||
tools.select_active_window(window);
|
||||
active_window = nullptr;
|
||||
is_active_window_fullscreen = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
auto node = root_lane->find_where([&](std::shared_ptr<Node> const& node)
|
||||
{
|
||||
return node->is_window() && node->get_logical_area().contains(geom::Point(x, y));
|
||||
@ -319,6 +343,13 @@ void WindowTree::advise_focus_lost(miral::Window& window)
|
||||
|
||||
void WindowTree::advise_delete_window(miral::Window& window)
|
||||
{
|
||||
auto non_tiling_it = std::find(non_tiling_window_list.begin(), non_tiling_window_list.end(), window);
|
||||
if (non_tiling_it != non_tiling_window_list.end())
|
||||
{
|
||||
non_tiling_window_list.erase(non_tiling_it);
|
||||
return;
|
||||
}
|
||||
|
||||
auto window_node = root_lane->find_node_for_window(window);
|
||||
if (!window_node)
|
||||
{
|
||||
|
@ -135,6 +135,7 @@ private:
|
||||
bool is_hidden = false;
|
||||
std::vector<NodeResurrection> nodes_to_resurrect;
|
||||
|
||||
std::vector<miral::Window> non_tiling_window_list;
|
||||
std::shared_ptr<Node> _get_active_lane();
|
||||
void _handle_direction_request(NodeLayoutDirection direction);
|
||||
void _handle_resize_request(std::shared_ptr<Node> const& node, Direction direction, int amount);
|
||||
|
Loading…
Reference in New Issue
Block a user