Merge lp:~alan-griffiths/miral/miral-shell-intro-text into lp:miral
- miral-shell-intro-text
- Merge into trunk
Proposed by
Alan Griffiths
Status: | Superseded |
---|---|
Proposed branch: | lp:~alan-griffiths/miral/miral-shell-intro-text |
Merge into: | lp:miral |
Prerequisite: | lp:~alan-griffiths/miral/workspaces-example |
Diff against target: |
761 lines (+293/-73) 7 files modified
include/mir/client/display_config.h (+75/-0) miral-shell/CMakeLists.txt (+1/-1) miral-shell/decoration_provider.cpp (+176/-35) miral-shell/decoration_provider.h (+14/-8) miral-shell/titlebar_window_manager.cpp (+23/-26) miral-shell/titlebar_window_manager.h (+3/-3) miral/CMakeLists.txt (+1/-0) |
To merge this branch: | bzr merge lp:~alan-griffiths/miral/miral-shell-intro-text |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+317120@code.launchpad.net |
This proposal has been superseded by a proposal from 2017-02-17.
Commit message
[miral-shell] Use background on 1st monitor to show keyboard shortcuts
Description of the change
To post a comment you must log in.
- 511. By Alan Griffiths
-
Better naming
- 512. By Alan Griffiths
- 513. By Alan Griffiths
- 514. By Alan Griffiths
- 515. By Alan Griffiths
- 516. By Alan Griffiths
-
Display helptext on all outputs
- 517. By Alan Griffiths
- 518. By Alan Griffiths
-
Remove intro text if display config changes
Unmerged revisions
- 518. By Alan Griffiths
-
Remove intro text if display config changes
- 517. By Alan Griffiths
- 516. By Alan Griffiths
-
Display helptext on all outputs
- 515. By Alan Griffiths
- 514. By Alan Griffiths
- 513. By Alan Griffiths
- 512. By Alan Griffiths
- 511. By Alan Griffiths
-
Better naming
- 510. By Alan Griffiths
-
Fix whitespace
- 509. By Alan Griffiths
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'include/mir/client/display_config.h' |
2 | --- include/mir/client/display_config.h 1970-01-01 00:00:00 +0000 |
3 | +++ include/mir/client/display_config.h 2017-02-16 17:33:30 +0000 |
4 | @@ -0,0 +1,75 @@ |
5 | +/* |
6 | + * Copyright © 2017 Canonical Ltd. |
7 | + * |
8 | + * This program is free software: you can redistribute it and/or modify it |
9 | + * under the terms of the GNU General Public License version 3, |
10 | + * as published by the Free Software Foundation. |
11 | + * |
12 | + * This program is distributed in the hope that it will be useful, |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | + * GNU General Public License for more details. |
16 | + * |
17 | + * You should have received a copy of the GNU General Public License |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | + * |
20 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
21 | + */ |
22 | + |
23 | +#ifndef MIR_CLIENT_DISPLAY_CONFIG_H |
24 | +#define MIR_CLIENT_DISPLAY_CONFIG_H |
25 | + |
26 | +#include <mir_toolkit/mir_connection.h> |
27 | +#include <mir_toolkit/mir_display_configuration.h> |
28 | + |
29 | +#include <functional> |
30 | +#include <memory> |
31 | + |
32 | +namespace mir |
33 | +{ |
34 | +/// Convenient C++ wrappers around the Mir toolkit API. |
35 | +/// |
36 | +/// These wrappers are intentionally inline adapters: the compiled code depend directly on the Mir toolkit API. |
37 | +namespace client |
38 | +{ |
39 | +class DisplayConfig |
40 | +{ |
41 | +public: |
42 | + DisplayConfig() = default; |
43 | + |
44 | + explicit DisplayConfig(MirDisplayConfig* config) : self{config, deleter} {} |
45 | + |
46 | + explicit DisplayConfig(MirConnection* connection) : |
47 | + self{mir_connection_create_display_configuration(connection), deleter} {} |
48 | + |
49 | + operator MirDisplayConfig*() { return self.get(); } |
50 | + |
51 | + operator MirDisplayConfig const*() const { return self.get(); } |
52 | + |
53 | + void reset() { self.reset(); } |
54 | + |
55 | + void for_each_output(std::function<void(MirOutput const*)> const& enumerator) const |
56 | + { |
57 | + auto const count = mir_display_config_get_num_outputs(*this); |
58 | + |
59 | + for (int i = 0; i != count; ++i) |
60 | + enumerator(mir_display_config_get_output(*this, i)); |
61 | + } |
62 | + |
63 | + void for_each_output(std::function<void(MirOutput*)> const& enumerator) |
64 | + { |
65 | + auto const count = mir_display_config_get_num_outputs(*this); |
66 | + |
67 | + for (int i = 0; i != count; ++i) |
68 | + enumerator(mir_display_config_get_mutable_output(*this, i)); |
69 | + } |
70 | + |
71 | +private: |
72 | + static void deleter(MirDisplayConfig* config) { mir_display_config_release(config); } |
73 | + |
74 | + std::shared_ptr <MirDisplayConfig> self; |
75 | +}; |
76 | +} |
77 | +} |
78 | + |
79 | +#endif //MIR_CLIENT_DISPLAY_CONFIG_H |
80 | |
81 | === modified file 'miral-shell/CMakeLists.txt' |
82 | --- miral-shell/CMakeLists.txt 2016-12-14 11:22:57 +0000 |
83 | +++ miral-shell/CMakeLists.txt 2017-02-16 17:33:30 +0000 |
84 | @@ -45,7 +45,7 @@ |
85 | shell_main.cpp |
86 | tiling_window_manager.cpp tiling_window_manager.h |
87 | titlebar_window_manager.cpp titlebar_window_manager.h |
88 | - titlebar_provider.cpp titlebar_provider.h |
89 | + decoration_provider.cpp decoration_provider.h |
90 | titlebar_config.cpp titlebar_config.h |
91 | ) |
92 | |
93 | |
94 | === renamed file 'miral-shell/titlebar_provider.cpp' => 'miral-shell/decoration_provider.cpp' |
95 | --- miral-shell/titlebar_provider.cpp 2017-02-16 17:33:30 +0000 |
96 | +++ miral-shell/decoration_provider.cpp 2017-02-16 17:33:30 +0000 |
97 | @@ -1,5 +1,5 @@ |
98 | /* |
99 | - * Copyright © 2016 Canonical Ltd. |
100 | + * Copyright © 2016-2017 Canonical Ltd. |
101 | * |
102 | * This program is free software: you can redistribute it and/or modify it |
103 | * under the terms of the GNU General Public License version 3, |
104 | @@ -16,9 +16,10 @@ |
105 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
106 | */ |
107 | |
108 | -#include "titlebar_provider.h" |
109 | +#include "decoration_provider.h" |
110 | #include "titlebar_config.h" |
111 | |
112 | +#include <mir/client/display_config.h> |
113 | #include <mir/client/window_spec.h> |
114 | |
115 | #include <mir_toolkit/mir_buffer_stream.h> |
116 | @@ -37,8 +38,9 @@ |
117 | namespace |
118 | { |
119 | int const title_bar_height = 12; |
120 | +char const* const wallpaper_name = "wallpaper"; |
121 | |
122 | -void null_surface_callback(MirWindow*, void*) {} |
123 | +void null_window_callback(MirWindow*, void*) {} |
124 | |
125 | struct Printer |
126 | { |
127 | @@ -48,6 +50,7 @@ |
128 | Printer& operator=(Printer const&) = delete; |
129 | |
130 | void print(MirGraphicsRegion const& region, std::string const& title, int const intensity); |
131 | + void printhelp(MirGraphicsRegion const& region); |
132 | |
133 | private: |
134 | std::wstring_convert<std::codecvt_utf16<wchar_t>> converter; |
135 | @@ -59,11 +62,7 @@ |
136 | |
137 | void paint_surface(MirWindow* surface, std::string const& title, int const intensity) |
138 | { |
139 | -#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0) |
140 | - MirBufferStream* buffer_stream = mir_surface_get_buffer_stream(surface); |
141 | -#else |
142 | MirBufferStream* buffer_stream = mir_window_get_buffer_stream(surface); |
143 | -#endif |
144 | |
145 | // TODO sometimes buffer_stream is nullptr - find out why (and fix). |
146 | // (Only observed when creating a lot of clients at once) |
147 | @@ -152,22 +151,114 @@ |
148 | base_y += glyph->advance.y >> 6; |
149 | } |
150 | } |
151 | + |
152 | +void Printer::printhelp(MirGraphicsRegion const& region) |
153 | +{ |
154 | + static char const* const helptext[] = |
155 | + { |
156 | + "Welcome to miral-shell", |
157 | + "", |
158 | + "Keyboard shortcuts:", |
159 | + "", |
160 | + " o Switch apps: Alt-Tab, tap or click on the corresponding window", |
161 | + " o Switch window: Alt-`, tap or click on the corresponding window", |
162 | + "", |
163 | + " o Move window: Alt-leftmousebutton drag (three finger drag)", |
164 | + " o Resize window: Alt-middle_button drag (three finger pinch)", |
165 | + "", |
166 | + " o Maximize/restore current window (to display size). : Alt-F11", |
167 | + " o Maximize/restore current window (to display height): Shift-F11", |
168 | + " o Maximize/restore current window (to display width) : Ctrl-F11", |
169 | + "", |
170 | + " o Switch workspace: Meta-Alt-[F1|F2|F3|F4]", |
171 | + " o Switch workspace taking active window: Meta-Ctrl-[F1|F2|F3|F4]", |
172 | + "", |
173 | + " o To exit: Ctrl-Alt-BkSp", |
174 | + }; |
175 | + |
176 | + int help_width = 0; |
177 | + unsigned int help_height = 0; |
178 | + unsigned int line_height = 0; |
179 | + |
180 | + for (auto const* rawline : helptext) |
181 | + { |
182 | + int line_width = 0; |
183 | + |
184 | + auto const line = converter.from_bytes(rawline); |
185 | + |
186 | + auto const fwidth = std::min(region.width / 60, 20); |
187 | + |
188 | + FT_Set_Pixel_Sizes(face, fwidth, 0); |
189 | + |
190 | + for (auto const& ch : line) |
191 | + { |
192 | + FT_Load_Glyph(face, FT_Get_Char_Index(face, ch), FT_LOAD_DEFAULT); |
193 | + auto const glyph = face->glyph; |
194 | + FT_Render_Glyph(glyph, FT_RENDER_MODE_NORMAL); |
195 | + |
196 | + line_width += glyph->advance.x >> 6; |
197 | + line_height = std::max(line_height, glyph->bitmap.rows + glyph->bitmap.rows/2); |
198 | + } |
199 | + |
200 | + if (help_width < line_width) help_width = line_width; |
201 | + help_height += line_height; |
202 | + } |
203 | + |
204 | + int base_y = (region.height - help_height)/2; |
205 | + |
206 | + for (auto const* rawline : helptext) |
207 | + { |
208 | + int base_x = (region.width - help_width)/2; |
209 | + |
210 | + auto const line = converter.from_bytes(rawline); |
211 | + |
212 | + for (auto const& ch : line) |
213 | + { |
214 | + FT_Load_Glyph(face, FT_Get_Char_Index(face, ch), FT_LOAD_DEFAULT); |
215 | + auto const glyph = face->glyph; |
216 | + FT_Render_Glyph(glyph, FT_RENDER_MODE_NORMAL); |
217 | + |
218 | + auto const& bitmap = glyph->bitmap; |
219 | + auto const x = base_x + glyph->bitmap_left; |
220 | + |
221 | + if (static_cast<int>(x + bitmap.width) <= region.width) |
222 | + { |
223 | + unsigned char* src = bitmap.buffer; |
224 | + |
225 | + auto const y = base_y - glyph->bitmap_top; |
226 | + char* dest = region.vaddr + y * region.stride + 4 * x; |
227 | + |
228 | + for (auto row = 0u; row != bitmap.rows; ++row) |
229 | + { |
230 | + for (auto col = 0u; col != 4 * bitmap.width; ++col) |
231 | + dest[col] |= src[col / 4]/2; |
232 | + |
233 | + src += bitmap.pitch; |
234 | + dest += region.stride; |
235 | + } |
236 | + } |
237 | + |
238 | + base_x += glyph->advance.x >> 6; |
239 | + } |
240 | + base_y += line_height; |
241 | + } |
242 | +} |
243 | } |
244 | |
245 | using namespace mir::client; |
246 | using namespace mir::geometry; |
247 | |
248 | -TitlebarProvider::TitlebarProvider(miral::WindowManagerTools const& tools) : tools{tools} |
249 | +DecorationProvider::DecorationProvider(miral::WindowManagerTools const& tools) : tools{tools} |
250 | { |
251 | |
252 | } |
253 | |
254 | -TitlebarProvider::~TitlebarProvider() |
255 | +DecorationProvider::~DecorationProvider() |
256 | { |
257 | stop(); |
258 | } |
259 | |
260 | -void TitlebarProvider::stop() |
261 | +void DecorationProvider::stop() |
262 | { |
263 | enqueue_work([this] |
264 | { |
265 | @@ -177,30 +268,75 @@ |
266 | |
267 | enqueue_work([this] |
268 | { |
269 | + wallpaper.erase(begin(wallpaper), end(wallpaper)); |
270 | connection.reset(); |
271 | stop_work(); |
272 | }); |
273 | } |
274 | |
275 | -void TitlebarProvider::operator()(mir::client::Connection connection) |
276 | +namespace |
277 | +{ |
278 | +void render_pattern(MirGraphicsRegion* region, uint8_t const pattern[]) |
279 | +{ |
280 | + char* row = region->vaddr; |
281 | + |
282 | + for (int j = 0; j < region->height; j++) |
283 | + { |
284 | + uint32_t* pixel = (uint32_t*)row; |
285 | + |
286 | + for (int i = 0; i < region->width; i++) |
287 | + memcpy(pixel + i, pattern, sizeof pixel[i]); |
288 | + |
289 | + row += region->stride; |
290 | + } |
291 | + |
292 | + static Printer printer; |
293 | + printer.printhelp(*region); |
294 | +} |
295 | +} |
296 | + |
297 | +void DecorationProvider::operator()(Connection connection) |
298 | { |
299 | this->connection = connection; |
300 | + |
301 | + DisplayConfig const display_conf{this->connection}; |
302 | + |
303 | + display_conf.for_each_output([this](MirOutput const* output) |
304 | + { |
305 | + wallpaper.push_back( |
306 | + WindowSpec::for_gloss(this->connection, 100, 100) |
307 | + .set_pixel_format(mir_pixel_format_xrgb_8888) |
308 | + .set_buffer_usage(mir_buffer_usage_software) |
309 | + .set_fullscreen_on_output(mir_output_get_id(output)) |
310 | + .set_name(wallpaper_name).create_window()); |
311 | + |
312 | + MirGraphicsRegion graphics_region; |
313 | + MirBufferStream* buffer_stream = mir_window_get_buffer_stream(wallpaper.back()); |
314 | + |
315 | + mir_buffer_stream_get_graphics_region(buffer_stream, &graphics_region); |
316 | + |
317 | + static uint8_t const pattern[4] = { 0x00, 0x00, 0x00, 0x00 }; |
318 | + |
319 | + render_pattern(&graphics_region, pattern); |
320 | + mir_buffer_stream_swap_buffers_sync(buffer_stream); |
321 | + }); |
322 | + |
323 | start_work(); |
324 | } |
325 | |
326 | -void TitlebarProvider::operator()(std::weak_ptr<mir::scene::Session> const& session) |
327 | +void DecorationProvider::operator()(std::weak_ptr<mir::scene::Session> const& session) |
328 | { |
329 | std::lock_guard<decltype(mutex)> lock{mutex}; |
330 | this->weak_session = session; |
331 | } |
332 | |
333 | -auto TitlebarProvider::session() const -> std::shared_ptr<mir::scene::Session> |
334 | +auto DecorationProvider::session() const -> std::shared_ptr<mir::scene::Session> |
335 | { |
336 | std::lock_guard<decltype(mutex)> lock{mutex}; |
337 | return weak_session.lock(); |
338 | } |
339 | |
340 | -void TitlebarProvider::create_titlebar_for(miral::Window const& window) |
341 | +void DecorationProvider::create_titlebar_for(miral::Window const& window) |
342 | { |
343 | enqueue_work([this, window] |
344 | { |
345 | @@ -220,7 +356,7 @@ |
346 | }); |
347 | } |
348 | |
349 | -void TitlebarProvider::paint_titlebar_for(miral::WindowInfo const& info, int intensity) |
350 | +void DecorationProvider::paint_titlebar_for(miral::WindowInfo const& info, int intensity) |
351 | { |
352 | if (auto data = find_titlebar_data(info.window())) |
353 | { |
354 | @@ -240,7 +376,7 @@ |
355 | } |
356 | } |
357 | |
358 | -void TitlebarProvider::destroy_titlebar_for(miral::Window const& window) |
359 | +void DecorationProvider::destroy_titlebar_for(miral::Window const& window) |
360 | { |
361 | if (auto data = find_titlebar_data(window)) |
362 | { |
363 | @@ -248,11 +384,7 @@ |
364 | { |
365 | enqueue_work([surface] |
366 | { |
367 | -#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0) |
368 | - mir_surface_release(surface, &null_surface_callback, nullptr); |
369 | -#else |
370 | - mir_window_release(surface, &null_surface_callback, nullptr); |
371 | -#endif |
372 | + mir_window_release(surface, &null_window_callback, nullptr); |
373 | }); |
374 | } |
375 | |
376 | @@ -264,7 +396,7 @@ |
377 | } |
378 | } |
379 | |
380 | -void TitlebarProvider::resize_titlebar_for(miral::WindowInfo const& window_info, Size const& size) |
381 | +void DecorationProvider::resize_titlebar_for(miral::WindowInfo const& window_info, Size const& size) |
382 | { |
383 | auto const window = window_info.window(); |
384 | |
385 | @@ -279,9 +411,10 @@ |
386 | } |
387 | } |
388 | |
389 | -void TitlebarProvider::place_new_titlebar(miral::WindowSpecification& window_spec) |
390 | +void DecorationProvider::place_new_decoration(miral::WindowSpecification& window_spec) |
391 | { |
392 | auto const name = window_spec.name().value(); |
393 | + if (name == "wallpaper") return; |
394 | |
395 | std::lock_guard<decltype(mutex)> lock{mutex}; |
396 | |
397 | @@ -296,8 +429,10 @@ |
398 | window_spec.top_left() = parent_window.top_left() - Displacement{0, title_bar_height}; |
399 | } |
400 | |
401 | -void TitlebarProvider::advise_new_titlebar(miral::WindowInfo const& window_info) |
402 | +void DecorationProvider::advise_new_titlebar(miral::WindowInfo const& window_info) |
403 | { |
404 | + if (window_info.name() == wallpaper_name) return; |
405 | + |
406 | { |
407 | std::lock_guard<decltype(mutex)> lock{mutex}; |
408 | |
409 | @@ -307,7 +442,7 @@ |
410 | tools.raise_tree(window_info.parent()); |
411 | } |
412 | |
413 | -void TitlebarProvider::advise_state_change(miral::WindowInfo const& window_info, MirWindowState state) |
414 | +void DecorationProvider::advise_state_change(miral::WindowInfo const& window_info, MirWindowState state) |
415 | { |
416 | if (auto titlebar = find_titlebar_window(window_info.window())) |
417 | { |
418 | @@ -332,7 +467,7 @@ |
419 | } |
420 | } |
421 | |
422 | -void TitlebarProvider::repaint_titlebar_for(miral::WindowInfo const& window_info) |
423 | +void DecorationProvider::repaint_titlebar_for(miral::WindowInfo const& window_info) |
424 | { |
425 | if (auto data = find_titlebar_data(window_info.window())) |
426 | { |
427 | @@ -346,23 +481,19 @@ |
428 | } |
429 | } |
430 | |
431 | -TitlebarProvider::Data::~Data() |
432 | +DecorationProvider::Data::~Data() |
433 | { |
434 | if (auto surface = titlebar.exchange(nullptr)) |
435 | -#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0) |
436 | - mir_surface_release(surface, &null_surface_callback, nullptr); |
437 | -#else |
438 | - mir_window_release(surface, &null_surface_callback, nullptr); |
439 | -#endif |
440 | + mir_window_release(surface, &null_window_callback, nullptr); |
441 | } |
442 | |
443 | -void TitlebarProvider::insert(MirWindow* surface, Data* data) |
444 | +void DecorationProvider::insert(MirWindow* surface, Data* data) |
445 | { |
446 | data->on_create(surface); |
447 | data->titlebar = surface; |
448 | } |
449 | |
450 | -TitlebarProvider::Data* TitlebarProvider::find_titlebar_data(miral::Window const& window) |
451 | +DecorationProvider::Data* DecorationProvider::find_titlebar_data(miral::Window const& window) |
452 | { |
453 | std::lock_guard<decltype(mutex)> lock{mutex}; |
454 | |
455 | @@ -371,7 +502,7 @@ |
456 | return (find != window_to_titlebar.end()) ? &find->second : nullptr; |
457 | } |
458 | |
459 | -miral::Window TitlebarProvider::find_titlebar_window(miral::Window const& window) const |
460 | +miral::Window DecorationProvider::find_titlebar_window(miral::Window const& window) const |
461 | { |
462 | std::lock_guard<decltype(mutex)> lock{mutex}; |
463 | |
464 | @@ -380,6 +511,16 @@ |
465 | return (find != window_to_titlebar.end()) ? find->second.window : miral::Window{}; |
466 | } |
467 | |
468 | +bool DecorationProvider::is_decoration(miral::Window const& window) const |
469 | +{ |
470 | + return window.application() == session(); |
471 | +} |
472 | + |
473 | +bool DecorationProvider::is_titlebar(miral::WindowInfo const& window_info) const |
474 | +{ |
475 | + return window_info.window().application() == session() && window_info.name() != wallpaper_name; |
476 | +} |
477 | + |
478 | Worker::~Worker() |
479 | { |
480 | if (worker.joinable()) worker.join(); |
481 | |
482 | === renamed file 'miral-shell/titlebar_provider.h' => 'miral-shell/decoration_provider.h' |
483 | --- miral-shell/titlebar_provider.h 2017-02-16 17:33:30 +0000 |
484 | +++ miral-shell/decoration_provider.h 2017-02-16 17:33:30 +0000 |
485 | @@ -1,5 +1,5 @@ |
486 | /* |
487 | - * Copyright © 2016 Canonical Ltd. |
488 | + * Copyright © 2016-2017 Canonical Ltd. |
489 | * |
490 | * This program is free software: you can redistribute it and/or modify it |
491 | * under the terms of the GNU General Public License version 3, |
492 | @@ -16,8 +16,8 @@ |
493 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
494 | */ |
495 | |
496 | -#ifndef MIRAL_SHELL_TITLEBAR_PROVIDER_H |
497 | -#define MIRAL_SHELL_TITLEBAR_PROVIDER_H |
498 | +#ifndef MIRAL_SHELL_DECORATION_PROVIDER_H |
499 | +#define MIRAL_SHELL_DECORATION_PROVIDER_H |
500 | |
501 | |
502 | #include <miral/window_manager_tools.h> |
503 | @@ -29,6 +29,8 @@ |
504 | #include <map> |
505 | #include <mutex> |
506 | #include <mir/client/connection.h> |
507 | +#include <mir/client/window.h> |
508 | + |
509 | #include <thread> |
510 | #include <condition_variable> |
511 | #include <queue> |
512 | @@ -54,11 +56,11 @@ |
513 | void do_work(); |
514 | }; |
515 | |
516 | -class TitlebarProvider : Worker |
517 | +class DecorationProvider : Worker |
518 | { |
519 | public: |
520 | - TitlebarProvider(miral::WindowManagerTools const& tools); |
521 | - ~TitlebarProvider(); |
522 | + DecorationProvider(miral::WindowManagerTools const& tools); |
523 | + ~DecorationProvider(); |
524 | |
525 | void operator()(mir::client::Connection connection); |
526 | void operator()(std::weak_ptr<mir::scene::Session> const& session); |
527 | @@ -66,7 +68,7 @@ |
528 | auto session() const -> std::shared_ptr<mir::scene::Session>; |
529 | |
530 | void create_titlebar_for(miral::Window const& window); |
531 | - void place_new_titlebar(miral::WindowSpecification& window_spec); |
532 | + void place_new_decoration(miral::WindowSpecification& window_spec); |
533 | void paint_titlebar_for(miral::WindowInfo const& window, int intensity); |
534 | void destroy_titlebar_for(miral::Window const& window); |
535 | void resize_titlebar_for(miral::WindowInfo const& window_info, mir::geometry::Size const& size); |
536 | @@ -75,6 +77,9 @@ |
537 | |
538 | void stop(); |
539 | |
540 | + bool is_decoration(miral::Window const& window) const; |
541 | + bool is_titlebar(miral::WindowInfo const& window_info) const; |
542 | + |
543 | private: |
544 | struct Data |
545 | { |
546 | @@ -92,6 +97,7 @@ |
547 | miral::WindowManagerTools tools; |
548 | std::mutex mutable mutex; |
549 | mir::client::Connection connection; |
550 | + std::vector<mir::client::Window> wallpaper; |
551 | std::weak_ptr<mir::scene::Session> weak_session; |
552 | |
553 | SurfaceMap window_to_titlebar; |
554 | @@ -104,4 +110,4 @@ |
555 | }; |
556 | |
557 | |
558 | -#endif //MIRAL_SHELL_TITLEBAR_PROVIDER_H |
559 | +#endif //MIRAL_SHELL_DECORATION_PROVIDER_H |
560 | |
561 | === modified file 'miral-shell/titlebar_window_manager.cpp' |
562 | --- miral-shell/titlebar_window_manager.cpp 2017-02-16 17:33:30 +0000 |
563 | +++ miral-shell/titlebar_window_manager.cpp 2017-02-16 17:33:30 +0000 |
564 | @@ -1,5 +1,5 @@ |
565 | /* |
566 | - * Copyright © 2016 Canonical Ltd. |
567 | + * Copyright © 2016-2017 Canonical Ltd. |
568 | * |
569 | * This program is free software: you can redistribute it and/or modify it |
570 | * under the terms of the GNU General Public License version 3, |
571 | @@ -17,7 +17,7 @@ |
572 | */ |
573 | |
574 | #include "titlebar_window_manager.h" |
575 | -#include "titlebar_provider.h" |
576 | +#include "decoration_provider.h" |
577 | |
578 | #include <miral/application_info.h> |
579 | #include <miral/internal_client.h> |
580 | @@ -78,9 +78,9 @@ |
581 | miral::InternalClientLauncher const& launcher) : |
582 | CanonicalWindowManagerPolicy(tools), |
583 | spinner{spinner}, |
584 | - titlebar_provider{std::make_unique<TitlebarProvider>(tools)} |
585 | + decoration_provider{std::make_unique<DecorationProvider>(tools)} |
586 | { |
587 | - launcher.launch("decorations", *titlebar_provider); |
588 | + launcher.launch("decorations", *decoration_provider); |
589 | |
590 | for (auto key : {KEY_F1, KEY_F2, KEY_F3, KEY_F4}) |
591 | key_to_workspace[key] = this->tools.create_workspace(); |
592 | @@ -142,9 +142,9 @@ |
593 | { |
594 | if (auto const possible_titlebar = tools.window_at(old_cursor)) |
595 | { |
596 | - if (possible_titlebar.application() == titlebar_provider->session()) |
597 | + auto const& info = tools.info_for(possible_titlebar); |
598 | + if (decoration_provider->is_titlebar(info)) |
599 | { |
600 | - auto const& info = tools.info_for(possible_titlebar); |
601 | if (tools.select_active_window(info.parent()) == info.parent()) |
602 | tools.drag_active_window(cursor - old_cursor); |
603 | consumes_event = true; |
604 | @@ -309,19 +309,16 @@ |
605 | { |
606 | CanonicalWindowManagerPolicy::advise_new_window(window_info); |
607 | |
608 | - auto const application = window_info.window().application(); |
609 | auto const parent = window_info.parent(); |
610 | |
611 | - auto const is_titlebar = application == titlebar_provider->session(); |
612 | - |
613 | - if (is_titlebar) |
614 | + if (decoration_provider->is_titlebar(window_info)) |
615 | { |
616 | - titlebar_provider->advise_new_titlebar(window_info); |
617 | + decoration_provider->advise_new_titlebar(window_info); |
618 | |
619 | if (tools.active_window() == parent) |
620 | - titlebar_provider->paint_titlebar_for(tools.info_for(parent), 0xFF); |
621 | + decoration_provider->paint_titlebar_for(tools.info_for(parent), 0xFF); |
622 | else |
623 | - titlebar_provider->paint_titlebar_for(tools.info_for(parent), 0x3F); |
624 | + decoration_provider->paint_titlebar_for(tools.info_for(parent), 0x3F); |
625 | } |
626 | |
627 | if (!parent) |
628 | @@ -340,7 +337,7 @@ |
629 | void TitlebarWindowManagerPolicy::handle_window_ready(WindowInfo& window_info) |
630 | { |
631 | if (window_info.window().application() != spinner.session() && window_info.needs_titlebar(window_info.type())) |
632 | - titlebar_provider->create_titlebar_for(window_info.window()); |
633 | + decoration_provider->create_titlebar_for(window_info.window()); |
634 | |
635 | CanonicalWindowManagerPolicy::handle_window_ready(window_info); |
636 | } |
637 | @@ -349,14 +346,14 @@ |
638 | { |
639 | CanonicalWindowManagerPolicy::advise_focus_lost(info); |
640 | |
641 | - titlebar_provider->paint_titlebar_for(info, 0x3F); |
642 | + decoration_provider->paint_titlebar_for(info, 0x3F); |
643 | } |
644 | |
645 | void TitlebarWindowManagerPolicy::advise_focus_gained(WindowInfo const& info) |
646 | { |
647 | CanonicalWindowManagerPolicy::advise_focus_gained(info); |
648 | |
649 | - titlebar_provider->paint_titlebar_for(info, 0xFF); |
650 | + decoration_provider->paint_titlebar_for(info, 0xFF); |
651 | |
652 | // Frig to force the spinner to the top |
653 | if (auto const spinner_session = spinner.session()) |
654 | @@ -372,21 +369,21 @@ |
655 | { |
656 | CanonicalWindowManagerPolicy::advise_state_change(window_info, state); |
657 | |
658 | - titlebar_provider->advise_state_change(window_info, state); |
659 | + decoration_provider->advise_state_change(window_info, state); |
660 | } |
661 | |
662 | void TitlebarWindowManagerPolicy::advise_resize(WindowInfo const& window_info, Size const& new_size) |
663 | { |
664 | CanonicalWindowManagerPolicy::advise_resize(window_info, new_size); |
665 | |
666 | - titlebar_provider->resize_titlebar_for(window_info, new_size); |
667 | + decoration_provider->resize_titlebar_for(window_info, new_size); |
668 | } |
669 | |
670 | void TitlebarWindowManagerPolicy::advise_delete_window(WindowInfo const& window_info) |
671 | { |
672 | CanonicalWindowManagerPolicy::advise_delete_window(window_info); |
673 | |
674 | - titlebar_provider->destroy_titlebar_for(window_info.window()); |
675 | + decoration_provider->destroy_titlebar_for(window_info.window()); |
676 | } |
677 | |
678 | bool TitlebarWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event) |
679 | @@ -535,7 +532,7 @@ |
680 | if (action == mir_keyboard_action_down && scan_code == KEY_BACKSPACE && |
681 | (modifiers == (mir_input_event_modifier_alt | mir_input_event_modifier_ctrl))) |
682 | { |
683 | - titlebar_provider->stop(); |
684 | + decoration_provider->stop(); |
685 | } |
686 | |
687 | return false; |
688 | @@ -654,8 +651,8 @@ |
689 | if (parameters.state().value() != mir_window_state_fullscreen && needs_titlebar) |
690 | parameters.top_left() = Point{parameters.top_left().value().x, parameters.top_left().value().y + DeltaY{title_bar_height}}; |
691 | |
692 | - if (app_info.application() == titlebar_provider->session()) |
693 | - titlebar_provider->place_new_titlebar(parameters); |
694 | + if (app_info.application() == decoration_provider->session()) |
695 | + decoration_provider->place_new_decoration(parameters); |
696 | |
697 | parameters.userdata() = std::make_shared<PolicyData>(); |
698 | return parameters; |
699 | @@ -697,8 +694,8 @@ |
700 | |
701 | tools.for_each_window_in_workspace(active_workspace, [&](Window const& window) |
702 | { |
703 | - if (window.application() == titlebar_provider->session()) |
704 | - return; // titlebars are taken care of automatically |
705 | + if (decoration_provider->is_decoration(window)) |
706 | + return; // decorations are taken care of automatically |
707 | |
708 | auto const& window_info = tools.info_for(window); |
709 | auto& pdata = policy_data_for(window_info); |
710 | @@ -709,8 +706,8 @@ |
711 | |
712 | tools.for_each_window_in_workspace(old_active, [&](Window const& window) |
713 | { |
714 | - if (window.application() == titlebar_provider->session()) |
715 | - return; // titlebars are taken care of automatically |
716 | + if (decoration_provider->is_decoration(window)) |
717 | + return; // decorations are taken care of automatically |
718 | |
719 | auto const& window_info = tools.info_for(window); |
720 | auto& pdata = policy_data_for(window_info); |
721 | |
722 | === modified file 'miral-shell/titlebar_window_manager.h' |
723 | --- miral-shell/titlebar_window_manager.h 2017-02-16 17:33:30 +0000 |
724 | +++ miral-shell/titlebar_window_manager.h 2017-02-16 17:33:30 +0000 |
725 | @@ -1,5 +1,5 @@ |
726 | /* |
727 | - * Copyright © 2016 Canonical Ltd. |
728 | + * Copyright © 2016-2017 Canonical Ltd. |
729 | * |
730 | * This program is free software: you can redistribute it and/or modify it |
731 | * under the terms of the GNU General Public License version 3, |
732 | @@ -31,7 +31,7 @@ |
733 | |
734 | using namespace mir::geometry; |
735 | |
736 | -class TitlebarProvider; |
737 | +class DecorationProvider; |
738 | |
739 | class TitlebarWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy, miral::WorkspacePolicy |
740 | { |
741 | @@ -98,7 +98,7 @@ |
742 | |
743 | SpinnerSplash const spinner; |
744 | |
745 | - std::unique_ptr<TitlebarProvider> const titlebar_provider; |
746 | + std::unique_ptr<DecorationProvider> const decoration_provider; |
747 | |
748 | void end_resize(); |
749 | |
750 | |
751 | === modified file 'miral/CMakeLists.txt' |
752 | --- miral/CMakeLists.txt 2017-02-16 17:33:30 +0000 |
753 | +++ miral/CMakeLists.txt 2017-02-16 17:33:30 +0000 |
754 | @@ -55,6 +55,7 @@ |
755 | ${CMAKE_SOURCE_DIR}/include/mir/client/window_spec.h |
756 | ${CMAKE_SOURCE_DIR}/include/mir/client/window_id.h |
757 | ${CMAKE_SOURCE_DIR}/include/mir/client/connection.h |
758 | + ${CMAKE_SOURCE_DIR}/include/mir/client/display_config.h |
759 | ${CMAKE_SOURCE_DIR}/include/mir/client/window.h |
760 | ${CMAKE_SOURCE_DIR}/include/mir/client/detail/mir_forward_compatibility.h |
761 | ) |