Merge lp:~alan-griffiths/miral/connect-gdk_window_move_to_rect-inspired-placement-logic-to-Mir-0.25-API into lp:miral

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: 329
Merged at revision: 314
Proposed branch: lp:~alan-griffiths/miral/connect-gdk_window_move_to_rect-inspired-placement-logic-to-Mir-0.25-API
Merge into: lp:miral
Prerequisite: lp:~alan-griffiths/miral/gdk_window_move_to_rect-inspired-placement-logic
Diff against target: 265 lines (+109/-42)
4 files modified
include/miral/window_specification.h (+68/-34)
miral/basic_window_manager.cpp (+4/-4)
miral/window_specification.cpp (+35/-2)
test/window_placement.cpp (+2/-2)
To merge this branch: bzr merge lp:~alan-griffiths/miral/connect-gdk_window_move_to_rect-inspired-placement-logic-to-Mir-0.25-API
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Review via email: mp+304481@code.launchpad.net

Commit message

Connect the placement logic to Mir-0.25 placement requests

Description of the change

Connect the placement logic to Mir-0.25 placement requests

This assumes that we land for 0.25 lp:~alan-griffiths/miral/connect-gdk_window_move_to_rect-inspired-placement-logic-to-Mir-0.25-API

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) :
review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Need to wait on the corresponding Mir MP

328. By Alan Griffiths

Update enums to match latest version of Mir MP

329. By Alan Griffiths

merge :parent

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

API has landed in Mir

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/miral/window_specification.h'
2--- include/miral/window_specification.h 2016-09-01 11:34:45 +0000
3+++ include/miral/window_specification.h 2016-09-05 15:52:44 +0000
4@@ -33,17 +33,38 @@
5 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 4, 0)
6
7 // Inspired by GdkGravity
8+/**
9+ * Reference point for aligning a surface relative to a rectangle.
10+ * Each element (surface and rectangle) has a MirPlacementGravity assigned.
11+ */
12 typedef enum MirPlacementGravity
13 {
14- mir_placement_gravity_northwest = 1, // the reference point is at the top left corner.
15- mir_placement_gravity_north, // the reference point is in the middle of the top edge.
16- mir_placement_gravity_northeast, // the reference point is at the top right corner.
17- mir_placement_gravity_west, // the reference point is at the middle of the left edge.
18- mir_placement_gravity_centre, // the reference point is at the center of the window.
19- mir_placement_gravity_east, // the reference point is at the middle of the right edge.
20- mir_placement_gravity_southwest, // the reference point is at the lower left corner.
21- mir_placement_gravity_south, // the reference point is at the middle of the lower edge.
22- mir_placement_gravity_southeast, // the reference point is at the lower right corner.
23+ /// the reference point is at the center.
24+ mir_placement_gravity_center = 0,
25+
26+ /// the reference point is at the middle of the left edge.
27+ mir_placement_gravity_west = 1 << 0,
28+
29+ /// the reference point is at the middle of the right edge.
30+ mir_placement_gravity_east = 1 << 1,
31+
32+ /// the reference point is in the middle of the top edge.
33+ mir_placement_gravity_north = 1 << 2,
34+
35+ /// the reference point is at the middle of the lower edge.
36+ mir_placement_gravity_south = 1 << 3,
37+
38+ /// the reference point is at the top left corner.
39+ mir_placement_gravity_northwest = mir_placement_gravity_north | mir_placement_gravity_west,
40+
41+ /// the reference point is at the top right corner.
42+ mir_placement_gravity_northeast = mir_placement_gravity_north | mir_placement_gravity_east,
43+
44+ /// the reference point is at the lower left corner.
45+ mir_placement_gravity_southwest = mir_placement_gravity_south | mir_placement_gravity_west,
46+
47+ /// the reference point is at the lower right corner.
48+ mir_placement_gravity_southeast = mir_placement_gravity_south | mir_placement_gravity_east
49 } MirPlacementGravity;
50
51 // Inspired by GdkAnchorHints
52@@ -51,44 +72,57 @@
53 * Positioning hints for aligning a window relative to a rectangle.
54 *
55 * These hints determine how the window should be positioned in the case that
56- * the window would fall off-screen if placed in its ideal position.
57+ * the surface would fall off-screen if placed in its ideal position.
58 *
59- * For example, mir_placement_hints_flip_x will invert the x component of
60- * aux_rect_placement_offset and replace mir_placement_gravity_northwest with
61- * mir_placement_gravity_northeast and vice versa if the window extends
62+ * For example, \p mir_placement_hints_flip_x will invert the x component of
63+ * \p aux_rect_placement_offset and replace \p mir_placement_gravity_northwest
64+ * with \p mir_placement_gravity_northeast and vice versa if the window extends
65 * beyond the left or right edges of the monitor.
66 *
67- * If mir_placement_hints_slide_x is set, the window can be shifted
68+ * If \p mir_placement_hints_slide_x is set, the window can be shifted
69 * horizontally to fit on-screen.
70 *
71- * If mir_placement_hints_resize_x is set, the window can be shrunken
72+ * If \p mir_placement_hints_resize_x is set, the window can be shrunken
73 * horizontally to fit.
74 *
75- * If mir_placement_hints_antipodes is set then the rect gravity may be
76- * substituted with the opposite corner (e.g. mir_placement_gravity_northeast
77- * to mir_placement_gravity_southwest) in combination with other options.
78+ * If \p mir_placement_hints_antipodes is set then the rect gravity may be
79+ * substituted with the opposite corner (e.g. \p mir_placement_gravity_northeast
80+ * to \p mir_placement_gravity_southwest) in combination with other options.
81 *
82 * When multiple flags are set, flipping should take precedence over sliding,
83 * which should take precedence over resizing.
84 */
85 typedef enum MirPlacementHints
86 {
87- mir_placement_hints_flip_x = 1 << 0, // allow flipping anchors horizontally
88- mir_placement_hints_flip_y = 1 << 1, // allow flipping anchors vertically
89- mir_placement_hints_slide_x = 1 << 2, // allow sliding window horizontally
90- mir_placement_hints_slide_y = 1 << 3, // allow sliding window vertically
91- mir_placement_hints_resize_x = 1 << 4, // allow resizing window horizontally
92- mir_placement_hints_resize_y = 1 << 5, // allow resizing window vertically
93- mir_placement_hints_antipodes= 1 << 6, // allow flipping aux_anchor to opposite corner
94-
95- // allow flipping anchors on both axes
96- mir_placement_hints_flip_any = mir_placement_hints_flip_x|mir_placement_hints_flip_y,
97-
98- // allow sliding window on both axes
99- mir_placement_hints_slide_any = mir_placement_hints_slide_x|mir_placement_hints_slide_y,
100-
101- // allow resizing window on both axes
102- mir_placement_hints_resize_any = mir_placement_hints_resize_x|mir_placement_hints_resize_y,
103+ /// allow flipping anchors horizontally
104+ mir_placement_hints_flip_x = 1 << 0,
105+
106+ /// allow flipping anchors vertically
107+ mir_placement_hints_flip_y = 1 << 1,
108+
109+ /// allow sliding window horizontally
110+ mir_placement_hints_slide_x = 1 << 2,
111+
112+ /// allow sliding window vertically
113+ mir_placement_hints_slide_y = 1 << 3,
114+
115+ /// allow resizing window horizontally
116+ mir_placement_hints_resize_x = 1 << 4,
117+
118+ /// allow resizing window vertically
119+ mir_placement_hints_resize_y = 1 << 5,
120+
121+ /// allow flipping aux_anchor to opposite corner
122+ mir_placement_hints_antipodes= 1 << 6,
123+
124+ /// allow flipping anchors on both axes
125+ mir_placement_hints_flip_any = mir_placement_hints_flip_x|mir_placement_hints_flip_y,
126+
127+ /// allow sliding window on both axes
128+ mir_placement_hints_slide_any = mir_placement_hints_slide_x|mir_placement_hints_slide_y,
129+
130+ /// allow resizing window on both axes
131+ mir_placement_hints_resize_any = mir_placement_hints_resize_x|mir_placement_hints_resize_y,
132 } MirPlacementHints;
133 #endif
134
135
136=== modified file 'miral/basic_window_manager.cpp'
137--- miral/basic_window_manager.cpp 2016-09-01 11:34:45 +0000
138+++ miral/basic_window_manager.cpp 2016-09-05 15:52:44 +0000
139@@ -1154,7 +1154,7 @@
140 case mir_placement_gravity_west:
141 return aux_rect.top_left + 0.5*as_displacement(aux_rect.size).dy;
142
143- case mir_placement_gravity_centre:
144+ case mir_placement_gravity_center:
145 return aux_rect.top_left + 0.5*as_displacement(aux_rect.size);
146
147 case mir_placement_gravity_east:
148@@ -1192,7 +1192,7 @@
149 case mir_placement_gravity_west:
150 return {0, -0.5 * displacement.dy};
151
152- case mir_placement_gravity_centre:
153+ case mir_placement_gravity_center:
154 return {-0.5 * displacement.dx, -0.5 * displacement.dy};
155
156 case mir_placement_gravity_east:
157@@ -1231,8 +1231,8 @@
158
159 std::vector<MirPlacementGravity> rect_gravities{parameters.aux_rect_placement_gravity().value()};
160
161- if (hints & mir_placement_hints_antipodes)
162- rect_gravities.push_back(antipodes(parameters.aux_rect_placement_gravity().value()));
163+ if (hints & mir_placement_hints_antipodes)
164+ rect_gravities.push_back(antipodes(parameters.aux_rect_placement_gravity().value()));
165
166 mir::optional_value<Rectangle> default_result;
167
168
169=== modified file 'miral/window_specification.cpp'
170--- miral/window_specification.cpp 2016-09-01 11:34:45 +0000
171+++ miral/window_specification.cpp 2016-09-05 15:52:44 +0000
172@@ -72,6 +72,11 @@
173 state(spec.state),
174 preferred_orientation(spec.preferred_orientation),
175 aux_rect(spec.aux_rect),
176+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
177+ placement_hints(spec.placement_hints),
178+ window_placement_gravity(spec.surface_placement_gravity),
179+ aux_rect_placement_gravity(spec.aux_rect_placement_gravity),
180+#endif
181 min_width(spec.min_width),
182 min_height(spec.min_height),
183 max_width(spec.max_width),
184@@ -86,7 +91,12 @@
185 input_mode(),
186 shell_chrome(spec.shell_chrome)
187 {
188- if (spec.edge_attachment.is_set())
189+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
190+ if (spec.aux_rect_placement_offset_x.is_set() && spec.aux_rect_placement_offset_y.is_set())
191+ aux_rect_placement_offset = Displacement{spec.aux_rect_placement_offset_x.value(), spec.aux_rect_placement_offset_y.value()};
192+#endif
193+
194+ if (spec.edge_attachment.is_set() && !placement_hints.is_set())
195 {
196 switch (spec.edge_attachment.value())
197 {
198@@ -204,6 +214,11 @@
199 state(params.state),
200 preferred_orientation(params.preferred_orientation),
201 aux_rect(params.aux_rect),
202+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
203+ placement_hints(params.placement_hints),
204+ window_placement_gravity(params.surface_placement_gravity),
205+ aux_rect_placement_gravity(params.aux_rect_placement_gravity),
206+#endif
207 min_width(params.min_width),
208 min_height(params.min_height),
209 max_width(params.max_width),
210@@ -222,7 +237,12 @@
211 input_mode(static_cast<InputReceptionMode>(params.input_mode)),
212 shell_chrome(params.shell_chrome)
213 {
214- if (params.edge_attachment.is_set())
215+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
216+ if (params.aux_rect_placement_offset_x.is_set() && params.aux_rect_placement_offset_y.is_set())
217+ aux_rect_placement_offset = Displacement{params.aux_rect_placement_offset_x.value(), params.aux_rect_placement_offset_y.value()};
218+#endif
219+
220+ if (params.edge_attachment.is_set() && !placement_hints.is_set())
221 {
222 switch (params.edge_attachment.value())
223 {
224@@ -284,6 +304,19 @@
225 copy_if_set(params.input_shape, input_shape);
226 copy_if_set(params.input_mode, input_mode);
227 copy_if_set(params.shell_chrome, shell_chrome);
228+
229+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
230+ copy_if_set(params.placement_hints, placement_hints);
231+ copy_if_set(params.surface_placement_gravity, window_placement_gravity);
232+ copy_if_set(params.aux_rect_placement_gravity, aux_rect_placement_gravity);
233+
234+ if (aux_rect_placement_offset.is_set())
235+ {
236+ auto const offset = aux_rect_placement_offset.value();
237+ params.aux_rect_placement_offset_x = offset.dx.as_int();
238+ params.aux_rect_placement_offset_y = offset.dy.as_int();
239+ }
240+#endif
241 }
242
243 miral::WindowSpecification::WindowSpecification() :
244
245=== modified file 'test/window_placement.cpp'
246--- test/window_placement.cpp 2016-08-29 16:03:55 +0000
247+++ test/window_placement.cpp 2016-09-05 15:52:44 +0000
248@@ -362,7 +362,7 @@
249 mir_placement_gravity_north,
250 mir_placement_gravity_northeast,
251 mir_placement_gravity_west,
252- mir_placement_gravity_centre,
253+ mir_placement_gravity_center,
254 mir_placement_gravity_east,
255 mir_placement_gravity_southwest,
256 mir_placement_gravity_south,
257@@ -387,7 +387,7 @@
258 case mir_placement_gravity_west:
259 return rectangle.top_left + Displacement{0, 0.5 * displacement.dy};
260
261- case mir_placement_gravity_centre:
262+ case mir_placement_gravity_center:
263 return rectangle.top_left + 0.5 * displacement;
264
265 case mir_placement_gravity_east:

Subscribers

People subscribed via source and target branches