Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/example-server-lib/floating_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ bool FloatingWindowManagerPolicy::handle_pointer_event(MirPointerEvent const* ev

if (action == mir_pointer_action_button_down)
{
if (auto const window = tools.window_at(cursor))
tools.select_active_window(window);

if (auto const window = tools.active_window())
if (mir_pointer_event_button_state(event, mir_pointer_button_tertiary))
{
if (mir_pointer_event_button_state(event, mir_pointer_button_tertiary))
if (modifiers == mir_input_event_modifier_alt)
{
if (modifiers == mir_input_event_modifier_alt)
if (auto const window = tools.window_at(cursor))
tools.select_active_window(window);

if (auto const window = tools.active_window())
Comment on lines 91 to +100
{
Rectangle const old_pos{window.top_left(), window.size()};

Expand Down
37 changes: 25 additions & 12 deletions src/miral/floating_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,26 +386,39 @@ bool miral::FloatingWindowManager::Impl::handle_pointer_event(MirPointerEvent co
break;
}

if (!consumes_event && action == mir_pointer_action_button_down)
if (!consumes_event)
{
if (auto const window = tools.window_at(new_cursor))
{
tools.select_active_window(window);
}

if (auto const window = tools.active_window())
switch (action)
{
case mir_pointer_action_button_down:
if (mir_pointer_event_button_state(event, mir_pointer_button_primary))
{
if (shift_keys == pointer_drag_modifier)
{
begin_pointer_gesture(
tools.info_for(window),
mir_pointer_event_input_event(event),
Gesture::pointer_moving, mir_resize_edge_none);
consumes_event = true;
if (auto const hint = tools.window_at(new_cursor))
{
tools.select_active_window(hint);

if (auto const window = tools.active_window())
{
begin_pointer_gesture(
tools.info_for(window),
mir_pointer_event_input_event(event),
Gesture::pointer_moving, mir_resize_edge_none);
consumes_event = true;
}
Comment on lines +401 to +409
}
}
}
break;
case mir_pointer_action_button_up:
if (auto const window = tools.window_at(new_cursor))
{
tools.select_active_window(window);
Comment on lines +415 to +417
}
break;
default:
break;
}
}

Expand Down
19 changes: 17 additions & 2 deletions tests/window_management_tests/test_floating_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ TEST_F(FloatingWindowManagerTest, can_select_window_with_pointer)

EXPECT_TRUE(focused(window2));

auto const select_event = mir::events::make_pointer_event(
auto const select_event1 = mir::events::make_pointer_event(
0,
std::chrono::system_clock::now().time_since_epoch(),
mir_input_event_modifier_none,
Expand All @@ -222,7 +222,22 @@ TEST_F(FloatingWindowManagerTest, can_select_window_with_pointer)
mir_pointer_axis_source_none,
{},
{});
publish_event(*select_event);
auto const select_event2 = mir::events::make_pointer_event(
0,
std::chrono::system_clock::now().time_since_epoch(),
mir_input_event_modifier_none,
mir_pointer_action_button_up,
mir_pointer_button_primary,
geom::PointF{
window1.top_left().x.as_int() + window1.size().width.as_int() - 1,
window1.top_left().y.as_int() + window1.size().height.as_int() - 1},
{},
mir_pointer_axis_source_none,
{},
{});

publish_event(*select_event1);
publish_event(*select_event2);

EXPECT_TRUE(focused(window1));
}
Expand Down
Loading