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
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-03-15 17:44:36 +0000
3+++ debian/changelog 2017-03-16 17:00:52 +0000
4@@ -11,6 +11,8 @@
5 miral-shell can crash, or hang on exit (LP: #1673038)
6 . [miral-shell] if the specified font doesn't exist the server crashes
7 (LP: #1671028)
8+ . [libmiral] When a dialog is hidden ensure that the active window focus
9+ goes to the parent. (LP: #1671072)
10
11 -- Alan Griffiths <alan.griffiths@canonical.com> Mon, 06 Mar 2017 10:00:20 +0000
12
13
14=== modified file 'miral/basic_window_manager.cpp'
15--- miral/basic_window_manager.cpp 2017-03-06 09:11:47 +0000
16+++ miral/basic_window_manager.cpp 2017-03-16 17:00:52 +0000
17@@ -1090,29 +1090,35 @@
18 {
19 case mir_window_state_hidden:
20 case mir_window_state_minimized:
21+ window_info.state(value);
22 if (window == active_window())
23 {
24- auto const workspaces_containing_window = workspaces_containing(window);
25-
26- // Try to activate to recently active window of any application
27- mru_active_windows.enumerate([&](Window& candidate)
28- {
29- if (candidate == window)
30- return true;
31- auto const w = candidate;
32- for (auto const& workspace : workspaces_containing(w))
33+ select_active_window(window);
34+
35+ if (window == active_window() || !active_window())
36+ {
37+ auto const workspaces_containing_window = workspaces_containing(window);
38+
39+ // Try to activate to recently active window of any application
40+ mru_active_windows.enumerate([&](Window& candidate)
41 {
42- for (auto const& ww : workspaces_containing_window)
43+ if (candidate == window)
44+ return true;
45+ auto const w = candidate;
46+ for (auto const& workspace : workspaces_containing(w))
47 {
48- if (ww == workspace)
49+ for (auto const& ww : workspaces_containing_window)
50 {
51- return !(select_active_window(w));
52+ if (ww == workspace)
53+ {
54+ return !(select_active_window(w));
55+ }
56 }
57 }
58- }
59
60- return true;
61- });
62+ return true;
63+ });
64+ }
65
66 // Try to activate to recently active window of any application
67 if (window == active_window() || !active_window())
68@@ -1128,7 +1134,6 @@
69 select_active_window({});
70 }
71
72- window_info.state(value);
73 mir_surface->configure(mir_window_attrib_state, value);
74 mir_surface->hide();
75
76@@ -1205,11 +1210,10 @@
77
78 for (auto const& child : info_for_hint.children())
79 {
80- if (std::shared_ptr<mir::scene::Surface> surface = child)
81- {
82- if (surface->type() == mir_window_type_dialog && surface->visible())
83- return select_active_window(child);
84- }
85+ auto const& info_for_child = info_for(child);
86+
87+ if (info_for_child.type() == mir_window_type_dialog && info_for_child.is_visible())
88+ return select_active_window(child);
89 }
90
91 if (info_for_hint.can_be_active() && info_for_hint.is_visible())
92
93=== modified file 'test/active_window.cpp'
94--- test/active_window.cpp 2017-03-03 16:17:37 +0000
95+++ test/active_window.cpp 2017-03-16 17:00:52 +0000
96@@ -360,3 +360,39 @@
97
98 assert_active_window_is(test_name);
99 }
100+
101+// lp:1671072
102+TEST_F(ActiveWindow, hiding_active_dialog_makes_parent_active)
103+{
104+ char const* const parent_name = __PRETTY_FUNCTION__;
105+ auto const dialog_name = "dialog";
106+ auto const connection = connect_client(parent_name);
107+
108+ auto const parent = create_surface(connection, parent_name, sync1);
109+ auto const dialog = create_dialog(connection, dialog_name, parent, sync2);
110+
111+ sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });
112+
113+ EXPECT_TRUE(sync1.signal_raised());
114+
115+ assert_active_window_is(parent_name);
116+}
117+
118+TEST_F(ActiveWindow, when_another_window_is_about_hiding_active_dialog_makes_parent_active)
119+{
120+ FocusChangeSync sync3;
121+ char const* const parent_name = __PRETTY_FUNCTION__;
122+ auto const dialog_name = "dialog";
123+ auto const another_window_name = "another window";
124+ auto const connection = connect_client(parent_name);
125+
126+ auto const parent = create_surface(connection, parent_name, sync1);
127+ auto const another_window = create_surface(connection, another_window_name, sync2);
128+ auto const dialog = create_dialog(connection, dialog_name, parent, sync3);
129+
130+ sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });
131+
132+ EXPECT_TRUE(sync1.signal_raised());
133+
134+ assert_active_window_is(parent_name);
135+}

Subscribers

People subscribed via source and target branches