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

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: 229
Merged at revision: 226
Proposed branch: lp:~alan-griffiths/miral/fix-1603086
Merge into: lp:miral
Diff against target: 181 lines (+79/-44)
3 files modified
miral-shell/titlebar_provider.cpp (+16/-5)
miral/basic_window_manager.cpp (+60/-37)
miral/basic_window_manager.h (+3/-2)
To merge this branch: bzr merge lp:~alan-griffiths/miral/fix-1603086
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) Approve
Review via email: mp+300220@code.launchpad.net

Commit message

Add support for modifying surface attachment

To post a comment you must log in.
lp:~alan-griffiths/miral/fix-1603086 updated
229. By Alan Griffiths

Revert unnecessary logic

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I have been using that revision for testing gtk changes.. No new problems were found, and it fixes the tooltip placement.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'miral-shell/titlebar_provider.cpp'
2--- miral-shell/titlebar_provider.cpp 2016-07-11 15:11:07 +0000
3+++ miral-shell/titlebar_provider.cpp 2016-07-15 17:02:36 +0000
4@@ -134,11 +134,22 @@
5
6 void TitlebarProvider::destroy_titlebar_for(miral::Window const& window)
7 {
8- enqueue_work([this, window]
9+ if (auto data = find_titlebar_data(window))
10+ {
11+ if (auto surface = data->titlebar.exchange(nullptr))
12 {
13- std::lock_guard<decltype(mutex)> lock{mutex};
14- window_to_titlebar.erase(window);
15- });
16+ enqueue_work([surface]
17+ {
18+ mir_surface_release(surface, &null_surface_callback, nullptr);
19+ });
20+ }
21+
22+ enqueue_work([this, window]
23+ {
24+ std::lock_guard<decltype(mutex)> lock{mutex};
25+ window_to_titlebar.erase(window);
26+ });
27+ }
28 }
29
30 void TitlebarProvider::resize_titlebar_for(miral::Window const& window, Size const& size)
31@@ -200,7 +211,7 @@
32
33 TitlebarProvider::Data::~Data()
34 {
35- if (auto const surface = titlebar.load())
36+ if (auto surface = titlebar.exchange(nullptr))
37 mir_surface_release(surface, &null_surface_callback, nullptr);
38 }
39
40
41=== modified file 'miral/basic_window_manager.cpp'
42--- miral/basic_window_manager.cpp 2016-07-13 10:28:40 +0000
43+++ miral/basic_window_manager.cpp 2016-07-15 17:02:36 +0000
44@@ -638,6 +638,19 @@
45 place_and_size(window_info, new_pos, new_size);
46 }
47
48+ if (window_info.parent() && modifications.aux_rect().is_set() && modifications.edge_attachment().is_set())
49+ {
50+ auto parent = window_info.parent();
51+
52+ if (parent)
53+ {
54+ auto new_pos = place_relative(parent.top_left(), modifications);
55+
56+ if (new_pos.is_set())
57+ move_tree(window_info, new_pos.value() - window.top_left());
58+ }
59+ }
60+
61 if (modifications.state().is_set())
62 {
63 set_state(window_info, modifications.state().value());
64@@ -937,8 +950,6 @@
65 parameters.state() = mir_surface_state_restored;
66
67 auto const active_display_area = active_display();
68-
69- auto const width = parameters.size().value().width.as_int();
70 auto const height = parameters.size().value().height.as_int();
71
72 bool positioned = false;
73@@ -976,41 +987,12 @@
74
75 if (has_parent && parameters.aux_rect().is_set() && parameters.edge_attachment().is_set())
76 {
77- auto parent = info_for(parameters.parent().value()).window();
78-
79- auto const edge_attachment = parameters.edge_attachment().value();
80- auto const aux_rect = parameters.aux_rect().value();
81- auto const parent_top_left = parent.top_left();
82- auto const top_left = aux_rect.top_left -Point{} + parent_top_left;
83- auto const top_right= aux_rect.top_right() -Point{} + parent_top_left;
84- auto const bot_left = aux_rect.bottom_left()-Point{} + parent_top_left;
85-
86- if (edge_attachment & mir_edge_attachment_vertical)
87- {
88- if (active_display_area.contains(top_right + Displacement{width, height}))
89- {
90- parameters.top_left() = top_right;
91- positioned = true;
92- }
93- else if (active_display_area.contains(top_left + Displacement{-width, height}))
94- {
95- parameters.top_left() = top_left + Displacement{-width, 0};
96- positioned = true;
97- }
98- }
99-
100- if (edge_attachment & mir_edge_attachment_horizontal)
101- {
102- if (active_display_area.contains(bot_left + Displacement{width, height}))
103- {
104- parameters.top_left() = bot_left;
105- positioned = true;
106- }
107- else if (active_display_area.contains(top_left + Displacement{width, -height}))
108- {
109- parameters.top_left() = top_left + Displacement{0, -height};
110- positioned = true;
111- }
112+ auto const position = place_relative(info_for(parameters.parent().value()).window().top_left(), parameters);
113+
114+ if (position.is_set())
115+ {
116+ parameters.top_left() = position.value();
117+ positioned = true;
118 }
119 }
120 else if (has_parent)
121@@ -1076,3 +1058,44 @@
122
123 return parameters;
124 }
125+
126+auto miral::BasicWindowManager::place_relative(Point const& parent_top_left, WindowSpecification const& parameters)
127+-> mir::optional_value<Point>
128+{
129+ mir::optional_value<Point> result;
130+ auto const active_display_area = active_display();
131+ auto const width = parameters.size().value().width.as_int();
132+ auto const height = parameters.size().value().height.as_int();
133+
134+ auto const edge_attachment = parameters.edge_attachment().value();
135+ auto const aux_rect = parameters.aux_rect().value();
136+ auto const top_left = aux_rect.top_left -Point{} + parent_top_left;
137+ auto const top_right= aux_rect.top_right() -Point{} + parent_top_left;
138+ auto const bot_left = aux_rect.bottom_left()-Point{} + parent_top_left;
139+
140+ if (edge_attachment & mir_edge_attachment_vertical)
141+ {
142+ if (active_display_area.contains(top_right + Displacement{width, height}))
143+ {
144+ result = top_right;
145+ }
146+ else if (active_display_area.contains(top_left + Displacement{-width, height}))
147+ {
148+ result = top_left + Displacement{-width, 0};
149+ }
150+ }
151+
152+ if (edge_attachment & mir_edge_attachment_horizontal)
153+ {
154+ if (active_display_area.contains(bot_left + Displacement{width, height}))
155+ {
156+ result = bot_left;
157+ }
158+ else if (active_display_area.contains(top_left + Displacement{width, -height}))
159+ {
160+ result = top_left + Displacement{0, -height};
161+ }
162+ }
163+
164+ return result;
165+}
166
167=== modified file 'miral/basic_window_manager.h'
168--- miral/basic_window_manager.h 2016-06-29 13:17:33 +0000
169+++ miral/basic_window_manager.h 2016-07-15 17:02:36 +0000
170@@ -161,8 +161,9 @@
171
172 auto can_activate_window_for_session(miral::Application const& session) -> bool;
173
174- auto place_new_surface(ApplicationInfo const& app_info, WindowSpecification parameters)
175- -> WindowSpecification;
176+ auto place_new_surface(ApplicationInfo const& app_info, WindowSpecification parameters) -> WindowSpecification;
177+ auto place_relative(Point const& parent_top_left, miral::WindowSpecification const& parameters) -> mir::optional_value<Point>;
178+
179 auto build_window(Application const& application, WindowSpecification const& spec)
180 -> WindowInfo&;
181 void move_tree(miral::WindowInfo& root, mir::geometry::Displacement movement);

Subscribers

People subscribed via source and target branches