bugfix: XWayland windows some times become unclickable (#167)

This commit is contained in:
Matthew Kosarek 2024-06-18 11:49:39 -04:00 committed by GitHub
parent 9e0c553c63
commit 79a912698c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 39 additions and 29 deletions

View File

@ -54,12 +54,12 @@ OutputContent::OutputContent(
{
}
std::shared_ptr<TilingWindowTree> OutputContent::get_active_tree() const
std::shared_ptr<TilingWindowTree> const& OutputContent::get_active_tree() const
{
return get_active_workspace()->get_tree();
}
std::shared_ptr<WorkspaceContent> OutputContent::get_active_workspace() const
std::shared_ptr<WorkspaceContent> const& OutputContent::get_active_workspace() const
{
for (auto& info : workspaces)
{
@ -68,14 +68,28 @@ std::shared_ptr<WorkspaceContent> OutputContent::get_active_workspace() const
}
throw std::runtime_error("get_active_workspace: unable to find the active workspace. We shouldn't be here!");
return nullptr;
}
bool OutputContent::handle_pointer_event(const MirPointerEvent* event)
{
if (floating_window_manager.handle_pointer_event(event))
auto x = miral::toolkit::mir_pointer_event_axis_value(event, MirPointerAxis::mir_pointer_axis_x);
auto y = miral::toolkit::mir_pointer_event_axis_value(event, MirPointerAxis::mir_pointer_axis_y);
if (get_active_workspace_num() < 0)
return false;
if (select_window_from_point(static_cast<int>(x), static_cast<int>(y)))
return true;
auto const action = mir_pointer_event_action(event);
if (has_clicked_floating_window || get_active_workspace()->has_floating_window(active_window))
{
if (action == mir_pointer_action_button_down)
has_clicked_floating_window = true;
else if (action == mir_pointer_action_button_up)
has_clicked_floating_window = false;
return floating_window_manager.handle_pointer_event(event);
}
return false;
}
@ -362,11 +376,11 @@ OutputContent::confirm_placement_on_display(
return new_placement;
}
void OutputContent::select_window_from_point(int x, int y)
bool OutputContent::select_window_from_point(int x, int y)
{
auto workspace = get_active_workspace();
auto const& workspace = get_active_workspace();
if (workspace->get_tree()->has_fullscreen_window())
return;
return false;
auto const& floating = workspace->get_floating_windows();
int floating_index = -1;
@ -374,24 +388,25 @@ void OutputContent::select_window_from_point(int x, int y)
{
geom::Rectangle window_area(floating[i].top_left(), floating[i].size());
if (floating[i] == active_window && window_area.contains(geom::Point(x, y)))
return;
return false;
else if (window_area.contains(geom::Point(x, y)))
{
floating_index = i;
}
}
if (floating_index >= 0)
{
node_interface.select_active_window(floating[floating_index]);
return;
return true;
}
auto node = workspace->get_tree()->select_window_from_point(x, y);
if (node && node->get_window() != active_window)
{
node_interface.select_active_window(node->get_window());
return true;
}
return false;
}
void OutputContent::select_window(miral::Window const& window)
@ -791,9 +806,8 @@ void OutputContent::request_toggle_active_float()
}
case WindowType::floating:
{
advise_delete_window(window_helpers::get_metadata(active_window, tools));
add_immediately(active_window);
node_interface.select_active_window(active_window);
get_active_workspace()->remove_floating_window(active_window);
break;
}
default:
@ -843,4 +857,4 @@ void OutputContent::set_position(glm::vec2 const& v)
glm::vec2 const& OutputContent::get_position() const
{
return position_offset;
}
}

View File

@ -49,9 +49,9 @@ public:
Animator&);
~OutputContent() = default;
[[nodiscard]] std::shared_ptr<TilingWindowTree> get_active_tree() const;
[[nodiscard]] std::shared_ptr<TilingWindowTree> const& get_active_tree() const;
[[nodiscard]] int get_active_workspace_num() const { return active_workspace; }
[[nodiscard]] std::shared_ptr<WorkspaceContent> get_active_workspace() const;
[[nodiscard]] std::shared_ptr<WorkspaceContent> const& get_active_workspace() const;
bool handle_pointer_event(MirPointerEvent const* event);
WindowType allocate_position(miral::WindowSpecification& requested_specification);
std::shared_ptr<WindowMetadata> advise_new_window(miral::WindowInfo const& window_info, WindowType type);
@ -72,7 +72,7 @@ public:
std::shared_ptr<miracle::WindowMetadata> const& metadata,
MirWindowState new_state,
const mir::geometry::Rectangle& new_placement);
void select_window_from_point(int x, int y);
bool select_window_from_point(int x, int y);
void select_window(miral::Window const&);
void advise_new_workspace(int workspace);
void advise_workspace_deleted(int workspace);
@ -135,6 +135,7 @@ private:
bool is_active_ = false;
miral::Window active_window;
AnimationHandle handle;
bool has_clicked_floating_window = false;
/// The position of the output for scrolling across workspaces
glm::vec2 position_offset = glm::vec2(0.f);

View File

@ -200,6 +200,7 @@ bool Policy::handle_pointer_event(MirPointerEvent const* event)
auto y = miral::toolkit::mir_pointer_event_axis_value(event, MirPointerAxis::mir_pointer_axis_y);
state.cursor_position = { x, y };
// Select the output first
for (auto const& output : output_list)
{
if (output->point_is_in_output(static_cast<int>(x), static_cast<int>(y)))
@ -212,16 +213,11 @@ bool Policy::handle_pointer_event(MirPointerEvent const* event)
active_output->set_is_active(true);
workspace_manager.request_focus(output->get_active_workspace_num());
}
if (output->get_active_workspace_num() >= 0 && state.mode != WindowManagerMode::resizing)
{
active_output->select_window_from_point(static_cast<int>(x), static_cast<int>(y));
}
break;
}
}
if (active_output)
if (active_output && state.mode != WindowManagerMode::resizing)
return active_output->handle_pointer_event(event);
return false;
@ -275,7 +271,9 @@ void Policy::advise_new_window(miral::WindowInfo const& window_info)
// Associate to an animation handle
metadata->set_animation_handle(animator.register_animateable());
node_interface.open(window_info.window());
if (metadata->get_type() != WindowType::other)
node_interface.open(window_info.window());
pending_type = WindowType::none;
pending_output.reset();

View File

@ -164,10 +164,7 @@ void TilingWindowTree::set_output_area(geom::Rectangle const& new_area)
std::shared_ptr<LeafNode> TilingWindowTree::select_window_from_point(int x, int y)
{
if (is_active_window_fullscreen)
{
tiling_interface.select_active_window(active_window->get_window());
return active_window;
}
auto node = root_lane->find_where([&](std::shared_ptr<Node> const& node)
{

View File

@ -45,7 +45,7 @@ int WorkspaceContent::get_workspace() const
return workspace;
}
std::shared_ptr<TilingWindowTree> WorkspaceContent::get_tree() const
std::shared_ptr<TilingWindowTree> const& WorkspaceContent::get_tree() const
{
return tree;
}

View File

@ -43,7 +43,7 @@ public:
TilingInterface& node_interface);
[[nodiscard]] int get_workspace() const;
[[nodiscard]] std::shared_ptr<TilingWindowTree> get_tree() const;
[[nodiscard]] std::shared_ptr<TilingWindowTree> const& get_tree() const;
void show();
void hide();
void transfer_pinned_windows_to(std::shared_ptr<WorkspaceContent> const& other);