Merge lp:~alan-griffiths/miral/fix-1671072 into lp:miral

Proposed by Alan Griffiths
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 543
Merged at revision: 538
Proposed branch: lp:~alan-griffiths/miral/fix-1671072
Merge into: lp:miral
Diff against target: 135 lines (+63/-21)
3 files modified
debian/changelog (+2/-0)
miral/basic_window_manager.cpp (+25/-21)
test/active_window.cpp (+36/-0)
To merge this branch: bzr merge lp:~alan-griffiths/miral/fix-1671072
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Kevin DuBois (community) Approve
Gerry Boland (community) Needs Information
Review via email: mp+320081@code.launchpad.net

Commit message

[libmiral] When a dialog is being hidden don't consider it a candidate active window

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

Why is this dialog specific? Is it the modality that is the cause?

review: Needs Information
lp:~alan-griffiths/miral/fix-1671072 updated
540. By Alan Griffiths

Update changelog

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Why is this dialog specific? Is it the modality that is the cause?

Yes. When a window has a child dialog then we consider the dialog for focus first. And the logic there didn't adequately handle the scenario where the child is being hidden.

lp:~alan-griffiths/miral/fix-1671072 updated
541. By Alan Griffiths

Reduce diff

542. By Alan Griffiths

ActiveWindow.when_another_window_is_about_hiding_active_dialog_makes_parent_active

543. By Alan Griffiths

Test passing

Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

lgtm

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Confirmed fixes the bug

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2017-03-15 17:44:36 +0000
+++ debian/changelog 2017-03-16 17:00:52 +0000
@@ -11,6 +11,8 @@
11 miral-shell can crash, or hang on exit (LP: #1673038)11 miral-shell can crash, or hang on exit (LP: #1673038)
12 . [miral-shell] if the specified font doesn't exist the server crashes12 . [miral-shell] if the specified font doesn't exist the server crashes
13 (LP: #1671028)13 (LP: #1671028)
14 . [libmiral] When a dialog is hidden ensure that the active window focus
15 goes to the parent. (LP: #1671072)
1416
15 -- Alan Griffiths <alan.griffiths@canonical.com> Mon, 06 Mar 2017 10:00:20 +000017 -- Alan Griffiths <alan.griffiths@canonical.com> Mon, 06 Mar 2017 10:00:20 +0000
1618
1719
=== modified file 'miral/basic_window_manager.cpp'
--- miral/basic_window_manager.cpp 2017-03-06 09:11:47 +0000
+++ miral/basic_window_manager.cpp 2017-03-16 17:00:52 +0000
@@ -1090,29 +1090,35 @@
1090 {1090 {
1091 case mir_window_state_hidden:1091 case mir_window_state_hidden:
1092 case mir_window_state_minimized:1092 case mir_window_state_minimized:
1093 window_info.state(value);
1093 if (window == active_window())1094 if (window == active_window())
1094 {1095 {
1095 auto const workspaces_containing_window = workspaces_containing(window);1096 select_active_window(window);
10961097
1097 // Try to activate to recently active window of any application1098 if (window == active_window() || !active_window())
1098 mru_active_windows.enumerate([&](Window& candidate)1099 {
1099 {1100 auto const workspaces_containing_window = workspaces_containing(window);
1100 if (candidate == window)1101
1101 return true;1102 // Try to activate to recently active window of any application
1102 auto const w = candidate;1103 mru_active_windows.enumerate([&](Window& candidate)
1103 for (auto const& workspace : workspaces_containing(w))
1104 {1104 {
1105 for (auto const& ww : workspaces_containing_window)1105 if (candidate == window)
1106 return true;
1107 auto const w = candidate;
1108 for (auto const& workspace : workspaces_containing(w))
1106 {1109 {
1107 if (ww == workspace)1110 for (auto const& ww : workspaces_containing_window)
1108 {1111 {
1109 return !(select_active_window(w));1112 if (ww == workspace)
1113 {
1114 return !(select_active_window(w));
1115 }
1110 }1116 }
1111 }1117 }
1112 }
11131118
1114 return true;1119 return true;
1115 });1120 });
1121 }
11161122
1117 // Try to activate to recently active window of any application1123 // Try to activate to recently active window of any application
1118 if (window == active_window() || !active_window())1124 if (window == active_window() || !active_window())
@@ -1128,7 +1134,6 @@
1128 select_active_window({});1134 select_active_window({});
1129 }1135 }
11301136
1131 window_info.state(value);
1132 mir_surface->configure(mir_window_attrib_state, value);1137 mir_surface->configure(mir_window_attrib_state, value);
1133 mir_surface->hide();1138 mir_surface->hide();
11341139
@@ -1205,11 +1210,10 @@
12051210
1206 for (auto const& child : info_for_hint.children())1211 for (auto const& child : info_for_hint.children())
1207 {1212 {
1208 if (std::shared_ptr<mir::scene::Surface> surface = child)1213 auto const& info_for_child = info_for(child);
1209 {1214
1210 if (surface->type() == mir_window_type_dialog && surface->visible())1215 if (info_for_child.type() == mir_window_type_dialog && info_for_child.is_visible())
1211 return select_active_window(child);1216 return select_active_window(child);
1212 }
1213 }1217 }
12141218
1215 if (info_for_hint.can_be_active() && info_for_hint.is_visible())1219 if (info_for_hint.can_be_active() && info_for_hint.is_visible())
12161220
=== modified file 'test/active_window.cpp'
--- test/active_window.cpp 2017-03-03 16:17:37 +0000
+++ test/active_window.cpp 2017-03-16 17:00:52 +0000
@@ -360,3 +360,39 @@
360360
361 assert_active_window_is(test_name);361 assert_active_window_is(test_name);
362}362}
363
364// lp:1671072
365TEST_F(ActiveWindow, hiding_active_dialog_makes_parent_active)
366{
367 char const* const parent_name = __PRETTY_FUNCTION__;
368 auto const dialog_name = "dialog";
369 auto const connection = connect_client(parent_name);
370
371 auto const parent = create_surface(connection, parent_name, sync1);
372 auto const dialog = create_dialog(connection, dialog_name, parent, sync2);
373
374 sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });
375
376 EXPECT_TRUE(sync1.signal_raised());
377
378 assert_active_window_is(parent_name);
379}
380
381TEST_F(ActiveWindow, when_another_window_is_about_hiding_active_dialog_makes_parent_active)
382{
383 FocusChangeSync sync3;
384 char const* const parent_name = __PRETTY_FUNCTION__;
385 auto const dialog_name = "dialog";
386 auto const another_window_name = "another window";
387 auto const connection = connect_client(parent_name);
388
389 auto const parent = create_surface(connection, parent_name, sync1);
390 auto const another_window = create_surface(connection, another_window_name, sync2);
391 auto const dialog = create_dialog(connection, dialog_name, parent, sync3);
392
393 sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });
394
395 EXPECT_TRUE(sync1.signal_raised());
396
397 assert_active_window_is(parent_name);
398}

Subscribers

People subscribed via source and target branches