Merge lp:~alan-griffiths/mir/move-miral-to-mir-cleanup-playground into lp:mir
- move-miral-to-mir-cleanup-playground
- Merge into development-branch
Proposed by
Alan Griffiths
Status: | Superseded |
---|---|
Proposed branch: | lp:~alan-griffiths/mir/move-miral-to-mir-cleanup-playground |
Merge into: | lp:mir |
Prerequisite: | lp:~alan-griffiths/mir/move-miral-to-mir-cleanup |
Diff against target: |
3504 lines (+2/-3095) 43 files modified
examples/miral-shell/CMakeLists.txt (+0/-68) include/miral/miral/command_line_option.h (+0/-112) include/miral/miral/window_management_policy_addendum3.h (+0/-71) include/server/mir/compositor/scene_element.h (+0/-4) include/server/mir/scene/surface.h (+0/-1) include/test/mir/test/doubles/stub_surface.h (+0/-1) playground/CMakeLists.txt (+1/-22) playground/demo-shell/CMakeLists.txt (+0/-19) playground/demo-shell/demo_compositor.cpp (+0/-204) playground/demo-shell/demo_compositor.h (+0/-79) playground/demo-shell/demo_renderer.cpp (+0/-402) playground/demo-shell/demo_renderer.h (+0/-90) playground/demo-shell/demo_shell.cpp (+0/-120) playground/demo-shell/typo/CMakeLists.txt (+0/-23) playground/demo-shell/typo/typo_freetype_renderer.cpp (+0/-125) playground/demo-shell/typo/typo_freetype_renderer.h (+0/-44) playground/demo-shell/typo/typo_glcache.cpp (+0/-99) playground/demo-shell/typo/typo_glcache.h (+0/-56) playground/demo-shell/typo/typo_renderer.cpp (+0/-59) playground/demo-shell/typo/typo_renderer.h (+0/-61) playground/demo-shell/typo/typo_stub_renderer.cpp (+0/-47) playground/demo-shell/typo/typo_stub_renderer.h (+0/-34) playground/demo-shell/window_manager.cpp (+0/-611) playground/demo-shell/window_manager.h (+0/-97) playground/server_configuration.cpp (+0/-86) playground/server_configuration.h (+0/-49) playground/server_example_display_configuration_policy.cpp (+0/-115) playground/server_example_display_configuration_policy.h (+0/-62) src/include/server/mir/compositor/decoration.h (+0/-38) src/miral/CMakeLists.txt (+0/-142) src/miral/miral.pc.in (+0/-12) src/miral/mirclientcpp.pc.in (+0/-10) src/server/scene/basic_surface.cpp (+0/-6) src/server/scene/basic_surface.h (+1/-1) src/server/scene/surface_stack.cpp (+0/-11) tests/include/mir/test/doubles/stub_scene_element.h (+0/-6) tests/include/mir/test/doubles/stub_scene_surface.h (+0/-1) tests/mir_test_framework/stub_surface.cpp (+0/-5) tests/unit-tests/CMakeLists.txt (+0/-2) tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+0/-7) tests/unit-tests/scene/test_basic_surface.cpp (+0/-14) tests/unit-tests/scene/test_surface.cpp (+0/-21) tests/unit-tests/scene/test_surface_stack.cpp (+0/-58) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/move-miral-to-mir-cleanup-playground |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+329939@code.launchpad.net |
Commit message
Incorporate miral project into mir source tree
This is a third pass at removing code obsoleted by MirAL
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'examples/miral-shell/CMakeLists.txt' |
2 | --- examples/miral-shell/CMakeLists.txt 2017-08-30 15:50:37 +0000 |
3 | +++ examples/miral-shell/CMakeLists.txt 2017-08-30 15:50:38 +0000 |
4 | @@ -1,70 +1,3 @@ |
5 | -<<<<<<< TREE |
6 | -include_directories( |
7 | - ${PROJECT_SOURCE_DIR}/include/miral |
8 | - ${PROJECT_SOURCE_DIR}/include/client |
9 | -) |
10 | - |
11 | -add_subdirectory(spinner) |
12 | -add_subdirectory(desktop) |
13 | - |
14 | -add_custom_target(miral-run ALL |
15 | - cp ${CMAKE_CURRENT_SOURCE_DIR}/miral-run.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-run |
16 | -) |
17 | - |
18 | -install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-run |
19 | - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin |
20 | -) |
21 | - |
22 | -add_custom_target(miral-xrun ALL |
23 | - cp ${CMAKE_CURRENT_SOURCE_DIR}/miral-xrun.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-xrun |
24 | -) |
25 | - |
26 | -install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-xrun |
27 | - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin |
28 | -) |
29 | - |
30 | -add_custom_target(miral-screencast ALL |
31 | - cp ${CMAKE_CURRENT_SOURCE_DIR}/miral-screencast.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-screencast |
32 | -) |
33 | - |
34 | -install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-screencast |
35 | - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin |
36 | -) |
37 | - |
38 | -add_custom_target(miral-desktop ALL |
39 | - cp ${CMAKE_CURRENT_SOURCE_DIR}/miral-desktop.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-desktop |
40 | -) |
41 | - |
42 | -install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-desktop |
43 | - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin |
44 | -) |
45 | - |
46 | -add_custom_target(miral-app ALL |
47 | - cp ${CMAKE_CURRENT_SOURCE_DIR}/miral-app.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-app |
48 | -) |
49 | - |
50 | -install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/miral-app |
51 | - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin |
52 | -) |
53 | - |
54 | -mir_add_wrapped_executable(miral-shell |
55 | - shell_main.cpp |
56 | - tiling_window_manager.cpp tiling_window_manager.h |
57 | - floating_window_manager.cpp floating_window_manager.h |
58 | - decoration_provider.cpp decoration_provider.h |
59 | - titlebar_config.cpp titlebar_config.h |
60 | -) |
61 | - |
62 | -pkg_check_modules(FREETYPE freetype2 REQUIRED) |
63 | -target_include_directories(miral-shell PRIVATE ${FREETYPE_INCLUDE_DIRS}) |
64 | -target_compile_definitions(miral-shell PRIVATE -DTYPO_SUPPORTS_FREETYPE) |
65 | -target_link_libraries(miral-shell |
66 | - miral-spinner |
67 | - miral |
68 | - ${FREETYPE_LIBRARIES} |
69 | -) |
70 | - |
71 | -======= |
72 | include_directories( |
73 | ${PROJECT_SOURCE_DIR}/include/miral |
74 | ${PROJECT_SOURCE_DIR}/include/client |
75 | @@ -134,4 +67,3 @@ |
76 | miral |
77 | ) |
78 | |
79 | ->>>>>>> MERGE-SOURCE |
80 | |
81 | === modified file 'include/miral/miral/command_line_option.h' |
82 | --- include/miral/miral/command_line_option.h 2017-08-30 15:50:37 +0000 |
83 | +++ include/miral/miral/command_line_option.h 2017-08-30 15:50:38 +0000 |
84 | @@ -1,114 +1,3 @@ |
85 | -<<<<<<< TREE |
86 | -/* |
87 | - * Copyright © 2016 Canonical Ltd. |
88 | - * |
89 | - * This program is free software: you can redistribute it and/or modify it |
90 | - * under the terms of the GNU General Public License version 2 or 3 as |
91 | - * published by the Free Software Foundation. |
92 | - * |
93 | - * This program is distributed in the hope that it will be useful, |
94 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
95 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
96 | - * GNU General Public License for more details. |
97 | - * |
98 | - * You should have received a copy of the GNU General Public License |
99 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
100 | - * |
101 | - * Authored by: Alan Griffiths <alan@octopull.co.uk> |
102 | - */ |
103 | - |
104 | -#ifndef MIRAL_COMMAND_LINE_OPTION_H |
105 | -#define MIRAL_COMMAND_LINE_OPTION_H |
106 | - |
107 | -#include <mir/optional_value.h> |
108 | - |
109 | -#include <functional> |
110 | -#include <memory> |
111 | -#include <string> |
112 | - |
113 | -namespace mir { class Server; } |
114 | - |
115 | -namespace miral |
116 | -{ |
117 | -/// Add a user configuration option to Mir's option handling. |
118 | -/// By default the callback will be invoked following Mir initialisation but |
119 | -/// prior to the server starting. The value supplied to the callback will come |
120 | -/// from the command line, environment variable, config file or the default. |
121 | -/// |
122 | -/// \note Except for re-ordering implied by "pre_init()" the callbacks will be |
123 | -/// invoked in the order supplied. |
124 | -class CommandLineOption |
125 | -{ |
126 | -public: |
127 | - CommandLineOption( |
128 | - std::function<void(int value)> callback, |
129 | - std::string const& option, |
130 | - std::string const& description, |
131 | - int default_value); |
132 | - |
133 | - CommandLineOption( |
134 | - std::function<void(double value)> callback, |
135 | - std::string const& option, |
136 | - std::string const& description, |
137 | - double default_value); |
138 | - |
139 | - CommandLineOption( |
140 | - std::function<void(std::string const& value)> callback, |
141 | - std::string const& option, |
142 | - std::string const& description, |
143 | - std::string const& default_value); |
144 | - |
145 | - CommandLineOption( |
146 | - std::function<void(std::string const& value)> callback, |
147 | - std::string const& option, |
148 | - std::string const& description, |
149 | - char const* default_value); |
150 | - |
151 | - CommandLineOption( |
152 | - std::function<void(bool value)> callback, |
153 | - std::string const& option, |
154 | - std::string const& description, |
155 | - bool default_value); |
156 | - |
157 | - CommandLineOption( |
158 | - std::function<void(mir::optional_value<int> const& value)> callback, |
159 | - std::string const& option, |
160 | - std::string const& description); |
161 | - |
162 | - CommandLineOption( |
163 | - std::function<void(mir::optional_value<std::string> const& value)> callback, |
164 | - std::string const& option, |
165 | - std::string const& description); |
166 | - |
167 | - CommandLineOption( |
168 | - std::function<void(mir::optional_value<bool> const& value)> callback, |
169 | - std::string const& option, |
170 | - std::string const& description); |
171 | - |
172 | - CommandLineOption( |
173 | - std::function<void(bool is_set)> callback, |
174 | - std::string const& option, |
175 | - std::string const& description); |
176 | - |
177 | - void operator()(mir::Server& server) const; |
178 | - |
179 | - // Call the callback *before* Mir initialization starts |
180 | - friend auto pre_init(CommandLineOption const& clo) -> CommandLineOption; |
181 | - |
182 | - ~CommandLineOption(); |
183 | - CommandLineOption(CommandLineOption const&); |
184 | - auto operator=(CommandLineOption const&) -> CommandLineOption&; |
185 | - |
186 | -private: |
187 | - struct Self; |
188 | - std::shared_ptr<Self> self; |
189 | -}; |
190 | - |
191 | -auto pre_init(CommandLineOption const& clo) -> CommandLineOption; |
192 | -} |
193 | - |
194 | -#endif //MIRAL_COMMAND_LINE_OPTION_H |
195 | -======= |
196 | /* |
197 | * Copyright © 2016 Canonical Ltd. |
198 | * |
199 | @@ -223,4 +112,3 @@ |
200 | } |
201 | |
202 | #endif //MIRAL_COMMAND_LINE_OPTION_H |
203 | ->>>>>>> MERGE-SOURCE |
204 | |
205 | === modified file 'include/miral/miral/window_management_policy_addendum3.h' |
206 | --- include/miral/miral/window_management_policy_addendum3.h 2017-08-30 15:50:37 +0000 |
207 | +++ include/miral/miral/window_management_policy_addendum3.h 2017-08-30 15:50:38 +0000 |
208 | @@ -1,73 +1,3 @@ |
209 | -<<<<<<< TREE |
210 | -/* |
211 | - * Copyright © 2017 Canonical Ltd. |
212 | - * |
213 | - * This program is free software: you can redistribute it and/or modify it |
214 | - * under the terms of the GNU General Public License version 2 or 3 as |
215 | - * published by the Free Software Foundation. |
216 | - * |
217 | - * This program is distributed in the hope that it will be useful, |
218 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
219 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
220 | - * GNU General Public License for more details. |
221 | - * |
222 | - * You should have received a copy of the GNU General Public License |
223 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
224 | - * |
225 | - * Authored by: Alan Griffiths <alan@octopull.co.uk> |
226 | - */ |
227 | - |
228 | -#ifndef MIRAL_WINDOW_MANAGEMENT_POLICY_ADDENDUM3_H |
229 | -#define MIRAL_WINDOW_MANAGEMENT_POLICY_ADDENDUM3_H |
230 | - |
231 | -#include <mir_toolkit/client_types.h> |
232 | - |
233 | -#include <mir/geometry/rectangles.h> |
234 | -#include <mir_toolkit/mir_version_number.h> |
235 | - |
236 | -namespace miral |
237 | -{ |
238 | -using namespace mir::geometry; |
239 | -struct WindowInfo; |
240 | - |
241 | -/** |
242 | - * Handle additional client requests. |
243 | - * |
244 | - * \note This interface is intended to be implemented by a WindowManagementPolicy |
245 | - * implementation, we can't add these functions directly to that interface without |
246 | - * breaking ABI (the vtab could be incompatible). |
247 | - * When initializing the window manager this interface will be detected by |
248 | - * dynamic_cast and registered accordingly. |
249 | - */ |
250 | -class WindowManagementPolicyAddendum3 |
251 | -{ |
252 | -public: |
253 | - /** Confirm (and optionally adjust) the placement of a window on the display. |
254 | - * Called when (re)placing fullscreen, maximized, horizontally maximised and |
255 | - * vertically maximized windows to allow adjustment for decorations. |
256 | - * |
257 | - * @param window_info the window |
258 | - * @param new_placement the suggested placement |
259 | - * |
260 | - * @return the confirmed placement of the window |
261 | - */ |
262 | - virtual auto confirm_placement_on_display( |
263 | - WindowInfo const& window_info, |
264 | - MirWindowState new_state, |
265 | - Rectangle const& new_placement) -> Rectangle = 0; |
266 | - |
267 | - virtual ~WindowManagementPolicyAddendum3() = default; |
268 | - WindowManagementPolicyAddendum3() = default; |
269 | - WindowManagementPolicyAddendum3(WindowManagementPolicyAddendum3 const&) = delete; |
270 | - WindowManagementPolicyAddendum3& operator=(WindowManagementPolicyAddendum3 const&) = delete; |
271 | -}; |
272 | -#if MIRAL_VERSION >= MIR_VERSION_NUMBER(2, 0, 0) |
273 | -#error "We've presumably broken ABI - please roll this interface into WindowManagementPolicy" |
274 | -#endif |
275 | -} |
276 | - |
277 | -#endif //MIRAL_WINDOW_MANAGEMENT_POLICY_ADDENDUM3_H |
278 | -======= |
279 | /* |
280 | * Copyright © 2017 Canonical Ltd. |
281 | * |
282 | @@ -137,4 +67,3 @@ |
283 | } |
284 | |
285 | #endif //MIRAL_WINDOW_MANAGEMENT_POLICY_ADDENDUM3_H |
286 | ->>>>>>> MERGE-SOURCE |
287 | |
288 | === modified file 'include/server/mir/compositor/scene_element.h' |
289 | --- include/server/mir/compositor/scene_element.h 2017-07-28 17:00:43 +0000 |
290 | +++ include/server/mir/compositor/scene_element.h 2017-08-30 15:50:38 +0000 |
291 | @@ -39,10 +39,6 @@ |
292 | virtual void rendered() = 0; |
293 | virtual void occluded() = 0; |
294 | |
295 | - //TODO: Decoration is opaque on purpose. It is only used by an internal example, |
296 | - // and this function should be removed from the public API. |
297 | - virtual std::unique_ptr<Decoration> decoration() const = 0; |
298 | - |
299 | protected: |
300 | SceneElement() = default; |
301 | SceneElement(SceneElement const&) = delete; |
302 | |
303 | === modified file 'include/server/mir/scene/surface.h' |
304 | --- include/server/mir/scene/surface.h 2017-07-28 17:00:43 +0000 |
305 | +++ include/server/mir/scene/surface.h 2017-08-30 15:50:38 +0000 |
306 | @@ -66,7 +66,6 @@ |
307 | virtual graphics::RenderableList generate_renderables(compositor::CompositorID id) const = 0; |
308 | virtual int buffers_ready_for_compositor(void const* compositor_id) const = 0; |
309 | |
310 | - virtual float alpha() const = 0; //only used in examples/ |
311 | virtual MirWindowType type() const = 0; |
312 | virtual MirWindowState state() const = 0; |
313 | virtual void hide() = 0; |
314 | |
315 | === modified file 'include/test/mir/test/doubles/stub_surface.h' |
316 | --- include/test/mir/test/doubles/stub_surface.h 2017-07-28 17:00:43 +0000 |
317 | +++ include/test/mir/test/doubles/stub_surface.h 2017-08-30 15:50:38 +0000 |
318 | @@ -32,7 +32,6 @@ |
319 | { |
320 | std::string name() const override; |
321 | void move_to(geometry::Point const& top_left) override; |
322 | - float alpha() const override; |
323 | geometry::Size size() const override; |
324 | geometry::Size client_size() const override; |
325 | std::shared_ptr<frontend::BufferStream> primary_buffer_stream() const override; |
326 | |
327 | === modified file 'playground/CMakeLists.txt' |
328 | --- playground/CMakeLists.txt 2017-08-30 15:50:37 +0000 |
329 | +++ playground/CMakeLists.txt 2017-08-30 15:50:38 +0000 |
330 | @@ -1,27 +1,6 @@ |
331 | - |
332 | include_directories( |
333 | - ${PROJECT_SOURCE_DIR}/src/include/server |
334 | - ${PROJECT_SOURCE_DIR}/src/include/platform |
335 | - ${PROJECT_SOURCE_DIR}/src/include/common |
336 | - ${PROJECT_SOURCE_DIR}/src/include/gl |
337 | - ${PROJECT_SOURCE_DIR}/src/include/client |
338 | - ${PROJECT_SOURCE_DIR}/src/renderers |
339 | ${PROJECT_SOURCE_DIR}/include/client |
340 | - ${PROJECT_SOURCE_DIR}/include/server |
341 | - ${PROJECT_SOURCE_DIR}/include/platform |
342 | - ${PROJECT_SOURCE_DIR}/include/renderer |
343 | - ${PROJECT_SOURCE_DIR}/include/renderers/gl |
344 | - ${PROJECT_SOURCE_DIR}/examples/ |
345 | -) |
346 | - |
347 | -add_library(playgroundserverconfig STATIC |
348 | - server_configuration.cpp |
349 | - server_example_display_configuration_policy.cpp |
350 | -) |
351 | - |
352 | -add_subdirectory(demo-shell/) |
353 | - |
354 | -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") |
355 | +) |
356 | |
357 | mir_add_wrapped_executable(mir_demo_client_egldiamond_render_surface |
358 | egldiamond_render_surface.c |
359 | |
360 | === removed directory 'playground/demo-shell' |
361 | === removed file 'playground/demo-shell/CMakeLists.txt' |
362 | --- playground/demo-shell/CMakeLists.txt 2017-05-08 03:04:26 +0000 |
363 | +++ playground/demo-shell/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
364 | @@ -1,19 +0,0 @@ |
365 | -add_library(demo-shell STATIC |
366 | - demo_compositor.cpp |
367 | - demo_renderer.cpp |
368 | - window_manager.cpp |
369 | -) |
370 | - |
371 | -add_subdirectory(typo) |
372 | -target_link_libraries(demo-shell typo) |
373 | - |
374 | -mir_add_wrapped_executable(mir_proving_server |
375 | - demo_shell.cpp |
376 | -) |
377 | - |
378 | -target_link_libraries(mir_proving_server |
379 | - demo-shell |
380 | - mirserver |
381 | - playgroundserverconfig |
382 | - exampleserverconfig |
383 | -) |
384 | |
385 | === removed file 'playground/demo-shell/demo_compositor.cpp' |
386 | --- playground/demo-shell/demo_compositor.cpp 2017-07-28 17:00:43 +0000 |
387 | +++ playground/demo-shell/demo_compositor.cpp 1970-01-01 00:00:00 +0000 |
388 | @@ -1,204 +0,0 @@ |
389 | -/* |
390 | - * Copyright © 2014 Canonical Ltd. |
391 | - * |
392 | - * This program is free software: you can redistribute it and/or modify |
393 | - * it under the terms of the GNU General Public License version 2 or 3 as |
394 | - * published by the Free Software Foundation. |
395 | - * |
396 | - * This program is distributed in the hope that it will be useful, |
397 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
398 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
399 | - * GNU General Public License for more details. |
400 | - * |
401 | - * You should have received a copy of the GNU General Public License |
402 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
403 | - * |
404 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
405 | - */ |
406 | - |
407 | -#include "mir/graphics/display_buffer.h" |
408 | -#include "mir/compositor/compositor_report.h" |
409 | -#include "mir/compositor/scene_element.h" |
410 | -#include "demo_compositor.h" |
411 | - |
412 | -namespace me = mir::examples; |
413 | -namespace mg = mir::graphics; |
414 | -namespace mc = mir::compositor; |
415 | -namespace geom = mir::geometry; |
416 | - |
417 | -std::mutex me::DemoCompositor::instances_mutex; |
418 | -std::unordered_set<me::DemoCompositor*> me::DemoCompositor::instances; |
419 | - |
420 | -me::DemoCompositor::DemoCompositor( |
421 | - mg::DisplayBuffer& display_buffer, |
422 | - std::shared_ptr<mc::CompositorReport> const& report) : |
423 | - display_buffer(display_buffer), |
424 | - report(report), |
425 | - viewport(display_buffer.view_area()), |
426 | - zoom_mag{1.0f}, |
427 | - renderer( |
428 | - display_buffer, |
429 | - 30.0f, //titlebar_height |
430 | - 80.0f) //shadow_radius |
431 | -{ |
432 | - std::lock_guard<std::mutex> lock(instances_mutex); |
433 | - instances.insert(this); |
434 | -} |
435 | - |
436 | -me::DemoCompositor::~DemoCompositor() |
437 | -{ |
438 | - std::lock_guard<std::mutex> lock(instances_mutex); |
439 | - instances.erase(this); |
440 | -} |
441 | - |
442 | -void me::DemoCompositor::for_each(std::function<void(DemoCompositor&)> f) |
443 | -{ |
444 | - std::lock_guard<std::mutex> lock(instances_mutex); |
445 | - for (auto& i : instances) |
446 | - f(*i); |
447 | -} |
448 | - |
449 | -void me::DemoCompositor::composite(mc::SceneElementSequence&& elements) |
450 | -{ |
451 | - report->began_frame(this); |
452 | - //a simple filtering out of renderables that shouldn't be drawn |
453 | - //the elements should be notified if they are rendered or not |
454 | - bool nonrenderlist_elements{false}; |
455 | - mg::RenderableList renderable_list; |
456 | - DecorMap decorated; |
457 | - |
458 | - for(auto const& it : elements) |
459 | - { |
460 | - auto const& renderable = it->renderable(); |
461 | - |
462 | - bool embellished = false; |
463 | - if (auto decor = it->decoration()) |
464 | - { |
465 | - embellished = decor->type != mc::Decoration::Type::none; |
466 | - decorated[renderable->id()] = std::move(decor); |
467 | - } |
468 | - |
469 | - if (embellished || viewport.overlaps(renderable->screen_position())) |
470 | - { |
471 | - renderable_list.push_back(renderable); |
472 | - |
473 | - /* |
474 | - * TODO: This logic could be replaced more cleanly in future by |
475 | - * the surface stack logic setting decoration status more |
476 | - * accurately for fullscreen surfaces. |
477 | - */ |
478 | - // Fullscreen and opaque? Definitely no embellishment |
479 | - if (renderable->screen_position() == viewport && |
480 | - renderable->alpha() == 1.0f && |
481 | - !renderable->shaped() && |
482 | - renderable->transformation() == glm::mat4()) |
483 | - { |
484 | - embellished = false; |
485 | - nonrenderlist_elements = false; // Don't care what's underneath |
486 | - } |
487 | - |
488 | - it->rendered(); |
489 | - } |
490 | - else |
491 | - { |
492 | - it->occluded(); |
493 | - } |
494 | - nonrenderlist_elements |= embellished; |
495 | - } |
496 | - |
497 | - /* |
498 | - * Note: Buffer lifetimes are ensured by the two objects holding |
499 | - * references to them; elements and renderable_list. |
500 | - * So no buffer is going to be released back to the client till |
501 | - * both of those containers get destroyed (end of the function). |
502 | - * Actually, there's a third reference held by the texture cache |
503 | - * in GLRenderer, but that gets released earlier in render(). |
504 | - */ |
505 | - elements.clear(); // Release those that didn't make it to renderable_list |
506 | - |
507 | - if (!nonrenderlist_elements && |
508 | - viewport == display_buffer.view_area() && // no bypass while zoomed |
509 | - display_buffer.overlay(renderable_list)) |
510 | - { |
511 | - report->renderables_in_frame(this, renderable_list); |
512 | - renderer.suspend(); |
513 | - } |
514 | - else |
515 | - { |
516 | - renderer.set_output_transform(display_buffer.transformation()); |
517 | - update_viewport(); |
518 | - renderer.set_viewport(viewport); |
519 | - renderer.begin(std::move(decorated)); |
520 | - renderer.render(renderable_list); |
521 | - |
522 | - report->renderables_in_frame(this, renderable_list); |
523 | - report->rendered_frame(this); |
524 | - |
525 | - // Release buffers back to the clients now that the swap has returned. |
526 | - // It's important to do this before starting on the potentially slow |
527 | - // flip() ... |
528 | - // FIXME: This clear() call is blocking a little (LP: #1395421) |
529 | - renderable_list.clear(); |
530 | - } |
531 | - |
532 | - report->finished_frame(this); |
533 | -} |
534 | - |
535 | -void me::DemoCompositor::on_cursor_movement( |
536 | - geometry::Point const& p) |
537 | -{ |
538 | - cursor_pos = p; |
539 | - if (zoom_mag != 1.0f) |
540 | - update_viewport(); |
541 | -} |
542 | - |
543 | -void me::DemoCompositor::zoom(float mag) |
544 | -{ |
545 | - zoom_mag = mag; |
546 | - update_viewport(); |
547 | -} |
548 | - |
549 | -void me::DemoCompositor::set_colour_effect(me::ColourEffect e) |
550 | -{ |
551 | - renderer.set_colour_effect(e); |
552 | -} |
553 | - |
554 | -void me::DemoCompositor::update_viewport() |
555 | -{ |
556 | - auto const& view_area = display_buffer.view_area(); |
557 | - |
558 | - if (zoom_mag == 1.0f) |
559 | - { |
560 | - // The below calculations should yield the same result as this, but |
561 | - // just in case there are any floating point precision errors, |
562 | - // set it precisely: |
563 | - viewport = view_area; |
564 | - } |
565 | - else |
566 | - { |
567 | - int db_width = view_area.size.width.as_int(); |
568 | - int db_height = view_area.size.height.as_int(); |
569 | - int db_x = view_area.top_left.x.as_int(); |
570 | - int db_y = view_area.top_left.y.as_int(); |
571 | - |
572 | - float zoom_width = db_width / zoom_mag; |
573 | - float zoom_height = db_height / zoom_mag; |
574 | - |
575 | - // Note the 0.5f. This is because cursors (and all input in general) |
576 | - // measures coordinates at the centre of a pixel. But GL measures to |
577 | - // the top-left corner of a pixel. |
578 | - float screen_x = cursor_pos.x.as_int() + 0.5f - db_x; |
579 | - float screen_y = cursor_pos.y.as_int() + 0.5f - db_y; |
580 | - |
581 | - float normal_x = screen_x / db_width; |
582 | - float normal_y = screen_y / db_height; |
583 | - |
584 | - // Position the viewport so the cursor location matches up. |
585 | - // This assumes the hardware cursor still traverses the physical |
586 | - // screen and isn't being warped. |
587 | - int zoom_x = db_x + (db_width - zoom_width) * normal_x; |
588 | - int zoom_y = db_y + (db_height - zoom_height) * normal_y; |
589 | - |
590 | - viewport = {{zoom_x, zoom_y}, {zoom_width, zoom_height}}; |
591 | - } |
592 | -} |
593 | |
594 | === removed file 'playground/demo-shell/demo_compositor.h' |
595 | --- playground/demo-shell/demo_compositor.h 2017-07-28 17:00:43 +0000 |
596 | +++ playground/demo-shell/demo_compositor.h 1970-01-01 00:00:00 +0000 |
597 | @@ -1,79 +0,0 @@ |
598 | -/* |
599 | - * Copyright © 2014 Canonical Ltd. |
600 | - * |
601 | - * This program is free software: you can redistribute it and/or modify |
602 | - * it under the terms of the GNU General Public License version 2 or 3 as |
603 | - * published by the Free Software Foundation. |
604 | - * |
605 | - * This program is distributed in the hope that it will be useful, |
606 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
607 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
608 | - * GNU General Public License for more details. |
609 | - * |
610 | - * You should have received a copy of the GNU General Public License |
611 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
612 | - * |
613 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
614 | - */ |
615 | - |
616 | -#ifndef MIR_EXAMPLES_DEMO_COMPOSITOR_H_ |
617 | -#define MIR_EXAMPLES_DEMO_COMPOSITOR_H_ |
618 | - |
619 | -#include "mir/compositor/display_buffer_compositor.h" |
620 | -#include "mir/compositor/scene.h" |
621 | -#include "mir/geometry/rectangle.h" |
622 | -#include "mir/graphics/renderable.h" |
623 | -#include "demo_renderer.h" |
624 | - |
625 | -#include <mutex> |
626 | -#include <set> |
627 | - |
628 | -namespace mir |
629 | -{ |
630 | -namespace compositor |
631 | -{ |
632 | -class Scene; |
633 | -class CompositorReport; |
634 | -} |
635 | -namespace graphics |
636 | -{ |
637 | -class DisplayBuffer; |
638 | -} |
639 | -namespace examples |
640 | -{ |
641 | - |
642 | -class DemoCompositor : public compositor::DisplayBufferCompositor |
643 | -{ |
644 | -public: |
645 | - DemoCompositor( |
646 | - graphics::DisplayBuffer& display_buffer, |
647 | - std::shared_ptr<compositor::CompositorReport> const& report); |
648 | - ~DemoCompositor(); |
649 | - |
650 | - void composite(compositor::SceneElementSequence&& elements) override; |
651 | - |
652 | - void zoom(float mag); |
653 | - void on_cursor_movement(geometry::Point const& p); |
654 | - |
655 | - void set_colour_effect(ColourEffect); |
656 | - |
657 | - static void for_each(std::function<void(DemoCompositor&)> f); |
658 | - |
659 | -private: |
660 | - void update_viewport(); |
661 | - |
662 | - graphics::DisplayBuffer& display_buffer; |
663 | - std::shared_ptr<compositor::CompositorReport> const report; |
664 | - geometry::Rectangle viewport; |
665 | - geometry::Point cursor_pos; |
666 | - float zoom_mag; |
667 | - DemoRenderer renderer; |
668 | - |
669 | - static std::mutex instances_mutex; |
670 | - static std::unordered_set<DemoCompositor*> instances; |
671 | -}; |
672 | - |
673 | -} // namespace examples |
674 | -} // namespace mir |
675 | - |
676 | -#endif // MIR_EXAMPLES_DEMO_COMPOSITOR_H_ |
677 | |
678 | === removed file 'playground/demo-shell/demo_renderer.cpp' |
679 | --- playground/demo-shell/demo_renderer.cpp 2017-07-28 17:00:43 +0000 |
680 | +++ playground/demo-shell/demo_renderer.cpp 1970-01-01 00:00:00 +0000 |
681 | @@ -1,402 +0,0 @@ |
682 | -/* |
683 | - * Copyright © 2014 Canonical Ltd. |
684 | - * |
685 | - * This program is free software: you can redistribute it and/or modify |
686 | - * it under the terms of the GNU General Public License version 2 or 3 as |
687 | - * published by the Free Software Foundation. |
688 | - * |
689 | - * This program is distributed in the hope that it will be useful, |
690 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
691 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
692 | - * GNU General Public License for more details. |
693 | - * |
694 | - * You should have received a copy of the GNU General Public License |
695 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
696 | - * |
697 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
698 | - */ |
699 | - |
700 | -#define MIR_LOG_COMPONENT "DemoRenderer" |
701 | - |
702 | -#include "typo_stub_renderer.h" |
703 | -#ifdef TYPO_SUPPORTS_FREETYPE |
704 | -#include "typo_freetype_renderer.h" |
705 | -#endif |
706 | -#include "demo_renderer.h" |
707 | -#include <mir/graphics/renderable.h> |
708 | -#include <mir/log.h> |
709 | -#include <cmath> |
710 | - |
711 | -using namespace mir; |
712 | -using namespace mir::examples; |
713 | -using namespace mir::geometry; |
714 | -using namespace mir::compositor; |
715 | -using namespace mir::renderer; |
716 | - |
717 | -namespace |
718 | -{ |
719 | - |
720 | -struct Color |
721 | -{ |
722 | - GLubyte r, g, b, a; |
723 | -}; |
724 | - |
725 | -float penumbra_curve(float x) |
726 | -{ |
727 | - return 1.0f - std::sin(x * M_PI / 2.0f); |
728 | -} |
729 | - |
730 | -GLuint generate_shadow_corner_texture(float opacity) |
731 | -{ |
732 | - struct Texel |
733 | - { |
734 | - GLubyte luminance; |
735 | - GLubyte alpha; |
736 | - }; |
737 | - |
738 | - int const width = 256; |
739 | - Texel image[width][width]; |
740 | - |
741 | - int const max = width - 1; |
742 | - for (int y = 0; y < width; ++y) |
743 | - { |
744 | - float curve_y = opacity * 255.0f * |
745 | - penumbra_curve(static_cast<float>(y) / max); |
746 | - for (int x = 0; x < width; ++x) |
747 | - { |
748 | - Texel *t = &image[y][x]; |
749 | - t->luminance = 0; |
750 | - t->alpha = curve_y * penumbra_curve(static_cast<float>(x) / max); |
751 | - } |
752 | - } |
753 | - |
754 | - GLuint corner; |
755 | - glGenTextures(1, &corner); |
756 | - glBindTexture(GL_TEXTURE_2D, corner); |
757 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
758 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
759 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
760 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
761 | - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, |
762 | - width, width, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, |
763 | - image); |
764 | - |
765 | - return corner; |
766 | -} |
767 | - |
768 | -GLuint generate_frame_corner_texture(float corner_radius, |
769 | - Color const& color, |
770 | - GLubyte highlight) |
771 | -{ |
772 | - int const height = 256; |
773 | -/* |
774 | - * GCC 4.9 with optimizations enabled will generate armhf NEON/VFP instructions |
775 | - * here that are not understood/implemented by Valgrind (but are by hardware), |
776 | - * causing Valgrind to crash: |
777 | - * eebe 0acc vcvt.s32.f32 s0, s0, #8 |
778 | - * So this clumsy expression below tricks the compiler into not using those |
779 | - * optimized ARM instructions that Valgrind doesn't support yet: |
780 | - */ |
781 | - int const width = height / (1.0f / corner_radius); |
782 | - Color image[height * height]; // Worst case still much faster than the heap |
783 | - |
784 | - int const cx = width; |
785 | - int const cy = cx; |
786 | - int const radius_sqr = cx * cy; |
787 | - |
788 | - for (int y = 0; y < height; ++y) |
789 | - { |
790 | - for (int x = 0; x < width; ++x) |
791 | - { |
792 | - Color col = color; |
793 | - |
794 | - // Set gradient |
795 | - if (y < cy) |
796 | - { |
797 | - float brighten = (1.0f - (static_cast<float>(y) / cy)) * |
798 | - std::sin(x * M_PI / (2 * (width - 1))); |
799 | - |
800 | - col.r += (highlight - col.r) * brighten; |
801 | - col.g += (highlight - col.g) * brighten; |
802 | - col.b += (highlight - col.b) * brighten; |
803 | - } |
804 | - |
805 | - // Cut out the corner in a circular shape. |
806 | - if (x < cx && y < cy) |
807 | - { |
808 | - int dx = cx - x; |
809 | - int dy = cy - y; |
810 | - if (dx * dx + dy * dy >= radius_sqr) |
811 | - col = {0, 0, 0, 0}; |
812 | - } |
813 | - |
814 | - image[y * width + x] = col; |
815 | - } |
816 | - } |
817 | - |
818 | - GLuint corner; |
819 | - glGenTextures(1, &corner); |
820 | - glBindTexture(GL_TEXTURE_2D, corner); |
821 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
822 | - GL_LINEAR_MIPMAP_LINEAR); |
823 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
824 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
825 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
826 | - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, |
827 | - width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
828 | - image); |
829 | - glGenerateMipmap(GL_TEXTURE_2D); // Antialiasing please |
830 | - |
831 | - return corner; |
832 | -} |
833 | - |
834 | -static const GLchar inverse_fshader[] = |
835 | -{ |
836 | - "#ifdef GL_ES\n" |
837 | - "precision mediump float;\n" |
838 | - "#endif\n" |
839 | - "uniform sampler2D tex;\n" |
840 | - "uniform float alpha;\n" |
841 | - "varying vec2 v_texcoord;\n" |
842 | - "void main() {\n" |
843 | - " vec4 f = texture2D(tex, v_texcoord);\n" |
844 | - " vec3 inverted = (vec3(1.0) - (f.rgb / f.a)) * f.a;\n" |
845 | - " gl_FragColor = alpha*vec4(inverted, f.a);\n" |
846 | - "}\n" |
847 | -}; |
848 | -static const GLchar contrast_fshader[] = |
849 | -{ |
850 | - "#ifdef GL_ES\n" |
851 | - "precision mediump float;\n" |
852 | - "#endif\n" |
853 | - "uniform sampler2D tex;\n" |
854 | - "uniform float alpha;\n" |
855 | - "varying vec2 v_texcoord;\n" |
856 | - "void main() {\n" |
857 | - " vec4 raw = texture2D(tex, v_texcoord);\n" |
858 | - " vec3 bent = (1.0 - cos(raw.rgb * 3.141592654)) / 2.0;\n" |
859 | - " gl_FragColor = alpha * vec4(bent, raw.a);\n" |
860 | - "}\n" |
861 | -}; |
862 | - |
863 | -} // namespace |
864 | - |
865 | -DemoRenderer::DemoRenderer( |
866 | - graphics::DisplayBuffer& display_buffer, |
867 | - float const titlebar_height, |
868 | - float const shadow_radius) : |
869 | - renderer::gl::Renderer(display_buffer), |
870 | - titlebar_height{titlebar_height}, |
871 | - shadow_radius{shadow_radius}, |
872 | - corner_radius{0.5f}, |
873 | - colour_effect{none}, |
874 | - inverse_program(family.add_program(vshader, inverse_fshader)), |
875 | - contrast_program(family.add_program(vshader, contrast_fshader)), |
876 | - title_cache(std::make_shared<typo::StubRenderer>()) |
877 | -{ |
878 | - shadow_corner_tex = generate_shadow_corner_texture(0.4f); |
879 | - titlebar_corner_tex = generate_frame_corner_texture(corner_radius, |
880 | - {128,128,128,255}, |
881 | - 255); |
882 | - |
883 | - clear_color[0] = clear_color[1] = clear_color[2] = 0.2f; |
884 | - clear_color[3] = 1.0f; |
885 | - |
886 | -#ifdef TYPO_SUPPORTS_FREETYPE |
887 | - const char title_font_path[] = "/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf"; |
888 | - auto ftrenderer = std::make_shared<typo::FreetypeRenderer>(); |
889 | - if (ftrenderer->load(title_font_path, 128)) |
890 | - title_cache.change_renderer(ftrenderer); |
891 | - else |
892 | - mir::log_error("Failed to load titlebar font: %s", title_font_path); |
893 | -#endif |
894 | -} |
895 | - |
896 | -DemoRenderer::~DemoRenderer() |
897 | -{ |
898 | - glDeleteTextures(1, &shadow_corner_tex); |
899 | - glDeleteTextures(1, &titlebar_corner_tex); |
900 | -} |
901 | - |
902 | -void DemoRenderer::begin(DecorMap&& d) const |
903 | -{ |
904 | - decor_map = std::move(d); |
905 | - title_cache.drop_unused(); |
906 | - title_cache.mark_all_unused(); |
907 | -} |
908 | - |
909 | -void DemoRenderer::tessellate(std::vector<gl::Primitive>& primitives, |
910 | - graphics::Renderable const& renderable) const |
911 | -{ |
912 | - renderer::gl::Renderer::tessellate(primitives, renderable); |
913 | - auto d = decor_map.find(renderable.id()); |
914 | - if (d != decor_map.end()) |
915 | - { |
916 | - auto& decor = d->second; |
917 | - if (decor->type != Decoration::Type::none) |
918 | - { |
919 | - tessellate_shadow(primitives, renderable, shadow_radius); |
920 | - tessellate_frame(primitives, renderable, titlebar_height, |
921 | - decor->name.c_str()); |
922 | - } |
923 | - } |
924 | -} |
925 | - |
926 | -void DemoRenderer::tessellate_shadow(std::vector<gl::Primitive>& primitives, |
927 | - graphics::Renderable const& renderable, |
928 | - float radius) const |
929 | -{ |
930 | - auto const& rect = renderable.screen_position(); |
931 | - GLfloat left = rect.top_left.x.as_int(); |
932 | - GLfloat right = left + rect.size.width.as_int(); |
933 | - GLfloat top = rect.top_left.y.as_int(); |
934 | - GLfloat bottom = top + rect.size.height.as_int(); |
935 | - |
936 | - auto n = primitives.size(); |
937 | - primitives.resize(n + 8); |
938 | - |
939 | - GLfloat rightr = right + radius; |
940 | - GLfloat leftr = left - radius; |
941 | - GLfloat topr = top - radius; |
942 | - GLfloat bottomr = bottom + radius; |
943 | - |
944 | - auto& right_shadow = primitives[n++]; |
945 | - right_shadow.tex_id = shadow_corner_tex; |
946 | - right_shadow.vertices[0] = {{right, top, 0.0f}, {0.0f, 0.0f}}; |
947 | - right_shadow.vertices[1] = {{rightr, top, 0.0f}, {1.0f, 0.0f}}; |
948 | - right_shadow.vertices[2] = {{rightr, bottom, 0.0f}, {1.0f, 0.0f}}; |
949 | - right_shadow.vertices[3] = {{right, bottom, 0.0f}, {0.0f, 0.0f}}; |
950 | - |
951 | - auto& left_shadow = primitives[n++]; |
952 | - left_shadow.tex_id = shadow_corner_tex; |
953 | - left_shadow.vertices[0] = {{leftr, top, 0.0f}, {1.0f, 0.0f}}; |
954 | - left_shadow.vertices[1] = {{left, top, 0.0f}, {0.0f, 0.0f}}; |
955 | - left_shadow.vertices[2] = {{left, bottom, 0.0f}, {0.0f, 0.0f}}; |
956 | - left_shadow.vertices[3] = {{leftr, bottom, 0.0f}, {1.0f, 0.0f}}; |
957 | - |
958 | - auto& top_shadow = primitives[n++]; |
959 | - top_shadow.tex_id = shadow_corner_tex; |
960 | - top_shadow.vertices[0] = {{left, topr, 0.0f}, {1.0f, 0.0f}}; |
961 | - top_shadow.vertices[1] = {{right, topr, 0.0f}, {1.0f, 0.0f}}; |
962 | - top_shadow.vertices[2] = {{right, top, 0.0f}, {0.0f, 0.0f}}; |
963 | - top_shadow.vertices[3] = {{left, top, 0.0f}, {0.0f, 0.0f}}; |
964 | - |
965 | - auto& bottom_shadow = primitives[n++]; |
966 | - bottom_shadow.tex_id = shadow_corner_tex; |
967 | - bottom_shadow.vertices[0] = {{left, bottom, 0.0f}, {0.0f, 0.0f}}; |
968 | - bottom_shadow.vertices[1] = {{right, bottom, 0.0f}, {0.0f, 0.0f}}; |
969 | - bottom_shadow.vertices[2] = {{right, bottomr, 0.0f}, {1.0f, 0.0f}}; |
970 | - bottom_shadow.vertices[3] = {{left, bottomr, 0.0f}, {1.0f, 0.0f}}; |
971 | - |
972 | - auto& tr_shadow = primitives[n++]; |
973 | - tr_shadow.tex_id = shadow_corner_tex; |
974 | - tr_shadow.vertices[0] = {{right, top, 0.0f}, {0.0f, 0.0f}}; |
975 | - tr_shadow.vertices[1] = {{right, topr, 0.0f}, {1.0f, 0.0f}}; |
976 | - tr_shadow.vertices[2] = {{rightr, topr, 0.0f}, {1.0f, 1.0f}}; |
977 | - tr_shadow.vertices[3] = {{rightr, top, 0.0f}, {0.0f, 1.0f}}; |
978 | - |
979 | - auto& br_shadow = primitives[n++]; |
980 | - br_shadow.tex_id = shadow_corner_tex; |
981 | - br_shadow.vertices[0] = {{right, bottom, 0.0f}, {0.0f, 0.0f}}; |
982 | - br_shadow.vertices[1] = {{rightr, bottom, 0.0f}, {1.0f, 0.0f}}; |
983 | - br_shadow.vertices[2] = {{rightr, bottomr, 0.0f}, {1.0f, 1.0f}}; |
984 | - br_shadow.vertices[3] = {{right, bottomr, 0.0f}, {0.0f, 1.0f}}; |
985 | - |
986 | - auto& bl_shadow = primitives[n++]; |
987 | - bl_shadow.tex_id = shadow_corner_tex; |
988 | - bl_shadow.vertices[0] = {{left, bottom, 0.0f}, {0.0f, 0.0f}}; |
989 | - bl_shadow.vertices[1] = {{left, bottomr, 0.0f}, {1.0f, 0.0f}}; |
990 | - bl_shadow.vertices[2] = {{leftr, bottomr, 0.0f}, {1.0f, 1.0f}}; |
991 | - bl_shadow.vertices[3] = {{leftr, bottom, 0.0f}, {0.0f, 1.0f}}; |
992 | - |
993 | - auto& tl_shadow = primitives[n++]; |
994 | - tl_shadow.tex_id = shadow_corner_tex; |
995 | - tl_shadow.vertices[0] = {{left, top, 0.0f}, {0.0f, 0.0f}}; |
996 | - tl_shadow.vertices[1] = {{leftr, top, 0.0f}, {1.0f, 0.0f}}; |
997 | - tl_shadow.vertices[2] = {{leftr, topr, 0.0f}, {1.0f, 1.0f}}; |
998 | - tl_shadow.vertices[3] = {{left, topr, 0.0f}, {0.0f, 1.0f}}; |
999 | -} |
1000 | - |
1001 | -void DemoRenderer::tessellate_frame(std::vector<gl::Primitive>& primitives, |
1002 | - graphics::Renderable const& renderable, |
1003 | - float titlebar_height, |
1004 | - char const* name) const |
1005 | -{ |
1006 | - auto const& rect = renderable.screen_position(); |
1007 | - GLfloat left = rect.top_left.x.as_int(); |
1008 | - GLfloat right = left + rect.size.width.as_int(); |
1009 | - GLfloat top = rect.top_left.y.as_int(); |
1010 | - |
1011 | - auto n = primitives.size(); |
1012 | - primitives.resize(n + 4); |
1013 | - |
1014 | - GLfloat htop = top - titlebar_height; |
1015 | - GLfloat in = titlebar_height * corner_radius; |
1016 | - GLfloat inleft = left + in; |
1017 | - GLfloat inright = right - in; |
1018 | - |
1019 | - GLfloat mid = (left + right) / 2.0f; |
1020 | - if (inleft > mid) inleft = mid; |
1021 | - if (inright < mid) inright = mid; |
1022 | - |
1023 | - auto& top_left_corner = primitives[n++]; |
1024 | - top_left_corner.tex_id = titlebar_corner_tex; |
1025 | - top_left_corner.vertices[0] = {{left, htop, 0.0f}, {0.0f, 0.0f}}; |
1026 | - top_left_corner.vertices[1] = {{inleft, htop, 0.0f}, {1.0f, 0.0f}}; |
1027 | - top_left_corner.vertices[2] = {{inleft, top, 0.0f}, {1.0f, 1.0f}}; |
1028 | - top_left_corner.vertices[3] = {{left, top, 0.0f}, {0.0f, 1.0f}}; |
1029 | - |
1030 | - auto& top_right_corner = primitives[n++]; |
1031 | - top_right_corner.tex_id = titlebar_corner_tex; |
1032 | - top_right_corner.vertices[0] = {{inright, htop, 0.0f}, {1.0f, 0.0f}}; |
1033 | - top_right_corner.vertices[1] = {{right, htop, 0.0f}, {0.0f, 0.0f}}; |
1034 | - top_right_corner.vertices[2] = {{right, top, 0.0f}, {0.0f, 1.0f}}; |
1035 | - top_right_corner.vertices[3] = {{inright, top, 0.0f}, {1.0f, 1.0f}}; |
1036 | - |
1037 | - auto& titlebar = primitives[n++]; |
1038 | - titlebar.tex_id = titlebar_corner_tex; |
1039 | - titlebar.vertices[0] = {{inleft, htop, 0.0f}, {1.0f, 0.0f}}; |
1040 | - titlebar.vertices[1] = {{inright, htop, 0.0f}, {1.0f, 0.0f}}; |
1041 | - titlebar.vertices[2] = {{inright, top, 0.0f}, {1.0f, 1.0f}}; |
1042 | - titlebar.vertices[3] = {{inleft, top, 0.0f}, {1.0f, 1.0f}}; |
1043 | - |
1044 | - auto str = title_cache.get(name); |
1045 | - GLfloat text_vin = titlebar_height / 5; |
1046 | - GLfloat text_top = htop + text_vin; |
1047 | - GLfloat text_bot = top - text_vin; |
1048 | - GLfloat text_height = text_bot - text_top; |
1049 | - GLfloat text_scale = text_height / str.height; |
1050 | - GLfloat text_left = inleft; |
1051 | - GLfloat text_right = text_left + text_scale * str.width; |
1052 | - GLfloat text_u = 1.0f; |
1053 | - if (text_right > inright) // Title too long for window |
1054 | - { |
1055 | - text_u = (inright - text_left) / (text_right - text_left); |
1056 | - text_right = inright; |
1057 | - } |
1058 | - |
1059 | - auto& text_prim = primitives[n++]; |
1060 | - text_prim.tex_id = str.tex; |
1061 | - text_prim.vertices[0] = {{text_left, text_top, 0.0f}, {0.0f, 0.0f}}; |
1062 | - text_prim.vertices[1] = {{text_right, text_top, 0.0f}, {text_u, 0.0f}}; |
1063 | - text_prim.vertices[2] = {{text_right, text_bot, 0.0f}, {text_u, 1.0f}}; |
1064 | - text_prim.vertices[3] = {{text_left, text_bot, 0.0f}, {0.0f, 1.0f}}; |
1065 | -} |
1066 | - |
1067 | -void DemoRenderer::set_colour_effect(ColourEffect e) |
1068 | -{ |
1069 | - colour_effect = e; |
1070 | -} |
1071 | - |
1072 | -void DemoRenderer::draw(graphics::Renderable const& renderable, |
1073 | - renderer::gl::Renderer::Program const& current_program) const |
1074 | -{ |
1075 | - const renderer::gl::Renderer::Program* const programs[ColourEffect::neffects] = |
1076 | - { |
1077 | - ¤t_program, |
1078 | - &inverse_program, |
1079 | - &contrast_program |
1080 | - }; |
1081 | - |
1082 | - renderer::gl::Renderer::draw(renderable, *programs[colour_effect]); |
1083 | -} |
1084 | |
1085 | === removed file 'playground/demo-shell/demo_renderer.h' |
1086 | --- playground/demo-shell/demo_renderer.h 2017-07-28 17:00:43 +0000 |
1087 | +++ playground/demo-shell/demo_renderer.h 1970-01-01 00:00:00 +0000 |
1088 | @@ -1,90 +0,0 @@ |
1089 | -/* |
1090 | - * Copyright © 2014 Canonical Ltd. |
1091 | - * |
1092 | - * This program is free software: you can redistribute it and/or modify |
1093 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1094 | - * published by the Free Software Foundation. |
1095 | - * |
1096 | - * This program is distributed in the hope that it will be useful, |
1097 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1098 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1099 | - * GNU General Public License for more details. |
1100 | - * |
1101 | - * You should have received a copy of the GNU General Public License |
1102 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1103 | - * |
1104 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1105 | - */ |
1106 | - |
1107 | -#ifndef MIR_EXAMPLES_DEMO_RENDERER_H_ |
1108 | -#define MIR_EXAMPLES_DEMO_RENDERER_H_ |
1109 | - |
1110 | -#include "gl/renderer.h" |
1111 | -#include "mir/compositor/decoration.h" |
1112 | -#include "typo_glcache.h" |
1113 | - |
1114 | -#include <unordered_map> |
1115 | - |
1116 | -namespace mir |
1117 | -{ |
1118 | -namespace examples |
1119 | -{ |
1120 | - |
1121 | -enum ColourEffect |
1122 | -{ |
1123 | - none, |
1124 | - inverse, |
1125 | - contrast, |
1126 | - neffects |
1127 | -}; |
1128 | - |
1129 | -typedef std::unordered_map<graphics::Renderable::ID, |
1130 | - std::unique_ptr<compositor::Decoration>> DecorMap; |
1131 | - |
1132 | -class DemoRenderer : public renderer::gl::Renderer |
1133 | -{ |
1134 | -public: |
1135 | - DemoRenderer( |
1136 | - graphics::DisplayBuffer& display_buffer, |
1137 | - float const titlebar_height, |
1138 | - float const shadow_radius); |
1139 | - ~DemoRenderer(); |
1140 | - |
1141 | - void begin(DecorMap&&) const; |
1142 | - void set_colour_effect(ColourEffect); |
1143 | - |
1144 | -protected: |
1145 | - void tessellate(std::vector<gl::Primitive>& primitives, |
1146 | - graphics::Renderable const& renderable) const override; |
1147 | - |
1148 | - void draw(graphics::Renderable const& renderable, |
1149 | - Renderer::Program const& prog) const override; |
1150 | - |
1151 | -private: |
1152 | - void tessellate_shadow( |
1153 | - std::vector<gl::Primitive>& primitives, |
1154 | - graphics::Renderable const& renderable, |
1155 | - float radius) const; |
1156 | - void tessellate_frame( |
1157 | - std::vector<gl::Primitive>& primitives, |
1158 | - graphics::Renderable const& renderable, |
1159 | - float titlebar_height, |
1160 | - char const* name) const; |
1161 | - |
1162 | - float const titlebar_height; |
1163 | - float const shadow_radius; |
1164 | - float const corner_radius; |
1165 | - GLuint shadow_corner_tex; |
1166 | - GLuint titlebar_corner_tex; |
1167 | - |
1168 | - ColourEffect colour_effect; |
1169 | - Program inverse_program, contrast_program; |
1170 | - |
1171 | - mutable DecorMap decor_map; |
1172 | - mutable typo::GLCache title_cache; |
1173 | -}; |
1174 | - |
1175 | -} // namespace examples |
1176 | -} // namespace mir |
1177 | - |
1178 | -#endif // MIR_EXAMPLES_DEMO_RENDERER_H_ |
1179 | |
1180 | === removed file 'playground/demo-shell/demo_shell.cpp' |
1181 | --- playground/demo-shell/demo_shell.cpp 2017-07-28 17:00:43 +0000 |
1182 | +++ playground/demo-shell/demo_shell.cpp 1970-01-01 00:00:00 +0000 |
1183 | @@ -1,120 +0,0 @@ |
1184 | -/* |
1185 | - * Copyright © 2013-2015 Canonical Ltd. |
1186 | - * |
1187 | - * This program is free software: you can redistribute it and/or modify |
1188 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1189 | - * published by the Free Software Foundation. |
1190 | - * |
1191 | - * This program is distributed in the hope that it will be useful, |
1192 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1193 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1194 | - * GNU General Public License for more details. |
1195 | - * |
1196 | - * You should have received a copy of the GNU General Public License |
1197 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1198 | - * |
1199 | - * Authored by: Robert Carr <robert.carr@canonical.com> |
1200 | - */ |
1201 | - |
1202 | -/// \example demo_shell.cpp A simple mir shell |
1203 | - |
1204 | -#include "demo_compositor.h" |
1205 | -#include "window_manager.h" |
1206 | -#include "../server_configuration.h" |
1207 | - |
1208 | -#include "mir/run_mir.h" |
1209 | -#include "mir/report_exception.h" |
1210 | -#include "mir/graphics/display.h" |
1211 | -#include "mir/input/composite_event_filter.h" |
1212 | -#include "mir/compositor/display_buffer_compositor_factory.h" |
1213 | -#include "mir/renderer/renderer_factory.h" |
1214 | -#include "mir/options/option.h" |
1215 | -#include "server_example_host_lifecycle_event_listener.h" |
1216 | - |
1217 | -#include <iostream> |
1218 | - |
1219 | -namespace me = mir::examples; |
1220 | -namespace ms = mir::scene; |
1221 | -namespace mg = mir::graphics; |
1222 | -namespace mf = mir::frontend; |
1223 | -namespace mi = mir::input; |
1224 | -namespace mc = mir::compositor; |
1225 | -namespace msh = mir::shell; |
1226 | - |
1227 | -namespace mir |
1228 | -{ |
1229 | -namespace examples |
1230 | -{ |
1231 | -class DisplayBufferCompositorFactory : public mc::DisplayBufferCompositorFactory |
1232 | -{ |
1233 | -public: |
1234 | - DisplayBufferCompositorFactory( |
1235 | - std::shared_ptr<mc::CompositorReport> const& report) : |
1236 | - report(report) |
1237 | - { |
1238 | - } |
1239 | - |
1240 | - std::unique_ptr<mc::DisplayBufferCompositor> create_compositor_for( |
1241 | - mg::DisplayBuffer& display_buffer) override |
1242 | - { |
1243 | - return std::unique_ptr<mc::DisplayBufferCompositor>( |
1244 | - new me::DemoCompositor{display_buffer, report}); |
1245 | - } |
1246 | - |
1247 | -private: |
1248 | - std::shared_ptr<mc::CompositorReport> const report; |
1249 | -}; |
1250 | - |
1251 | -class DemoServerConfiguration : public mir::examples::ServerConfiguration |
1252 | -{ |
1253 | -public: |
1254 | - using mir::examples::ServerConfiguration::ServerConfiguration; |
1255 | - |
1256 | - std::shared_ptr<compositor::DisplayBufferCompositorFactory> the_display_buffer_compositor_factory() override |
1257 | - { |
1258 | - return display_buffer_compositor_factory( |
1259 | - [this]() |
1260 | - { |
1261 | - return std::make_shared<me::DisplayBufferCompositorFactory>( |
1262 | - the_compositor_report()); |
1263 | - }); |
1264 | - } |
1265 | - |
1266 | - std::shared_ptr<msh::HostLifecycleEventListener> the_host_lifecycle_event_listener() override |
1267 | - { |
1268 | - return host_lifecycle_event_listener( |
1269 | - [this]() |
1270 | - { |
1271 | - return std::make_shared<HostLifecycleEventListener>(the_logger()); |
1272 | - }); |
1273 | - } |
1274 | -}; |
1275 | - |
1276 | -} |
1277 | -} |
1278 | - |
1279 | -int main(int argc, char const* argv[]) |
1280 | -try |
1281 | -{ |
1282 | - me::DemoServerConfiguration config(argc, argv); |
1283 | - |
1284 | - auto wm = std::make_shared<me::WindowManager>(); |
1285 | - |
1286 | - mir::run_mir(config, [&config, &wm](mir::DisplayServer&) |
1287 | - { |
1288 | - // We use this strange two stage initialization to avoid a circular dependency between the EventFilters |
1289 | - // and the SessionStore |
1290 | - wm->set_focus_controller(config.the_focus_controller()); |
1291 | - wm->set_display(config.the_display()); |
1292 | - wm->set_compositor(config.the_compositor()); |
1293 | - wm->set_input_scene(config.the_input_scene()); |
1294 | - |
1295 | - config.the_composite_event_filter()->prepend(wm); |
1296 | - }); |
1297 | - return 0; |
1298 | -} |
1299 | -catch (...) |
1300 | -{ |
1301 | - mir::report_exception(std::cerr); |
1302 | - return 1; |
1303 | -} |
1304 | |
1305 | === removed directory 'playground/demo-shell/typo' |
1306 | === removed file 'playground/demo-shell/typo/CMakeLists.txt' |
1307 | --- playground/demo-shell/typo/CMakeLists.txt 2017-05-08 03:04:26 +0000 |
1308 | +++ playground/demo-shell/typo/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1309 | @@ -1,23 +0,0 @@ |
1310 | -find_package(PkgConfig) |
1311 | - |
1312 | -pkg_search_module(FREETYPE freetype2) |
1313 | -if (FREETYPE_FOUND) |
1314 | - set(OPTIONAL_SRCS typo_freetype_renderer.cpp) |
1315 | -endif () |
1316 | - |
1317 | -add_library(typo STATIC |
1318 | - typo_renderer.cpp |
1319 | - typo_stub_renderer.cpp |
1320 | - typo_glcache.cpp |
1321 | - ${OPTIONAL_SRCS} |
1322 | -) |
1323 | - |
1324 | -target_link_libraries(typo ${GL_LIBRARIES}) |
1325 | -target_include_directories(typo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) |
1326 | - |
1327 | -if (FREETYPE_FOUND) |
1328 | - target_compile_definitions(typo PUBLIC -DTYPO_SUPPORTS_FREETYPE) |
1329 | - target_link_libraries(typo ${FREETYPE_LIBRARIES}) |
1330 | - target_include_directories(typo PUBLIC ${FREETYPE_INCLUDE_DIRS}) |
1331 | -endif () |
1332 | - |
1333 | |
1334 | === removed file 'playground/demo-shell/typo/typo_freetype_renderer.cpp' |
1335 | --- playground/demo-shell/typo/typo_freetype_renderer.cpp 2017-07-28 17:00:43 +0000 |
1336 | +++ playground/demo-shell/typo/typo_freetype_renderer.cpp 1970-01-01 00:00:00 +0000 |
1337 | @@ -1,125 +0,0 @@ |
1338 | -/* |
1339 | - * Copyright © 2015 Canonical Ltd. |
1340 | - * |
1341 | - * This program is free software: you can redistribute it and/or modify |
1342 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1343 | - * published by the Free Software Foundation. |
1344 | - * |
1345 | - * This program is distributed in the hope that it will be useful, |
1346 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1347 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1348 | - * GNU General Public License for more details. |
1349 | - * |
1350 | - * You should have received a copy of the GNU General Public License |
1351 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1352 | - * |
1353 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1354 | - */ |
1355 | - |
1356 | -#include "typo_freetype_renderer.h" |
1357 | -#include <stdexcept> |
1358 | -#include <cstring> |
1359 | - |
1360 | -using namespace mir::typo; |
1361 | - |
1362 | -FreetypeRenderer::FreetypeRenderer() |
1363 | - : lib(nullptr), face(nullptr), preferred_height(16) |
1364 | -{ |
1365 | - if (FT_Init_FreeType(&lib)) |
1366 | - throw std::runtime_error("FreeType init failed"); |
1367 | -} |
1368 | - |
1369 | -FreetypeRenderer::~FreetypeRenderer() |
1370 | -{ |
1371 | - if (face) FT_Done_Face(face); |
1372 | - if (lib) FT_Done_FreeType(lib); |
1373 | -} |
1374 | - |
1375 | -bool FreetypeRenderer::load(char const* font_path, int pref_height) |
1376 | -{ |
1377 | - preferred_height = pref_height; |
1378 | - |
1379 | - if (face) |
1380 | - { |
1381 | - FT_Done_Face(face); |
1382 | - face = nullptr; |
1383 | - } |
1384 | - if (FT_New_Face(lib, font_path, 0, &face)) |
1385 | - return false; |
1386 | - |
1387 | - FT_Set_Pixel_Sizes(face, 0, preferred_height); |
1388 | - |
1389 | - return true; |
1390 | -} |
1391 | - |
1392 | -void FreetypeRenderer::render(char const* str, Image& img) |
1393 | -{ |
1394 | - int minx = 0, maxx = 0, miny = 0, maxy = 0; |
1395 | - int penx = 0, peny = 0; |
1396 | - FT_GlyphSlot slot = face->glyph; |
1397 | - |
1398 | - char const* s = str; |
1399 | - while (unsigned long u = unicode_from_utf8(&s)) |
1400 | - { |
1401 | - auto glyph = FT_Get_Char_Index(face, u); |
1402 | - FT_Load_Glyph(face, glyph, FT_LOAD_DEFAULT); |
1403 | - FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL); |
1404 | - |
1405 | - int left = penx + slot->bitmap_left; |
1406 | - if (left < minx) minx = left; |
1407 | - |
1408 | - int right = left + slot->bitmap.width; |
1409 | - if (right > maxx) maxx = right; |
1410 | - |
1411 | - int top = peny - slot->bitmap_top; |
1412 | - if (top < miny) miny = top; |
1413 | - |
1414 | - int bottom = top + slot->bitmap.rows; |
1415 | - if (bottom > maxy) maxy = bottom; |
1416 | - |
1417 | - penx += slot->advance.x >> 6; |
1418 | - peny += slot->advance.y >> 6; |
1419 | - } |
1420 | - |
1421 | - int const padding = preferred_height / 8; // Allow mipmapping to smear |
1422 | - int width = maxx - minx + 1 + 2*padding; |
1423 | - int height = maxy - miny + 1; |
1424 | - if (height < preferred_height) // e.g. str has no descenders, but make |
1425 | - height = preferred_height; // room so we get a consistent height |
1426 | - height += 2*padding; |
1427 | - penx = -minx + padding; |
1428 | - peny = -miny + padding; |
1429 | - |
1430 | - img.reserve(width, height, Image::alpha8); |
1431 | - |
1432 | - s = str; |
1433 | - while (unsigned long u = unicode_from_utf8(&s)) |
1434 | - { |
1435 | - auto glyph = FT_Get_Char_Index(face, u); |
1436 | - FT_Load_Glyph(face, glyph, FT_LOAD_DEFAULT); |
1437 | - FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL); |
1438 | - |
1439 | - auto& bitmap = slot->bitmap; |
1440 | - int x = penx + slot->bitmap_left; |
1441 | - int y = peny - slot->bitmap_top; |
1442 | - int right = x + bitmap.width; |
1443 | - int bottom = y + bitmap.rows; |
1444 | - |
1445 | - if (x >= 0 && right <= width && y >= 0 && bottom <= height) |
1446 | - { |
1447 | - unsigned char* src = bitmap.buffer; |
1448 | - unsigned char* dest = img.data() + y*img.stride() + x; |
1449 | - |
1450 | - int ylimit = y + bitmap.rows; |
1451 | - for (; y < ylimit; ++y) |
1452 | - { |
1453 | - memcpy(dest, src, bitmap.width); |
1454 | - src += bitmap.pitch; |
1455 | - dest += img.stride(); |
1456 | - } |
1457 | - } |
1458 | - |
1459 | - penx += slot->advance.x >> 6; |
1460 | - peny += slot->advance.y >> 6; |
1461 | - } |
1462 | -} |
1463 | |
1464 | === removed file 'playground/demo-shell/typo/typo_freetype_renderer.h' |
1465 | --- playground/demo-shell/typo/typo_freetype_renderer.h 2017-07-28 17:00:43 +0000 |
1466 | +++ playground/demo-shell/typo/typo_freetype_renderer.h 1970-01-01 00:00:00 +0000 |
1467 | @@ -1,44 +0,0 @@ |
1468 | -/* |
1469 | - * Copyright © 2015 Canonical Ltd. |
1470 | - * |
1471 | - * This program is free software: you can redistribute it and/or modify |
1472 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1473 | - * published by the Free Software Foundation. |
1474 | - * |
1475 | - * This program is distributed in the hope that it will be useful, |
1476 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1477 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1478 | - * GNU General Public License for more details. |
1479 | - * |
1480 | - * You should have received a copy of the GNU General Public License |
1481 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1482 | - * |
1483 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1484 | - */ |
1485 | - |
1486 | -#ifndef MIR_TYPO_FREETYPE_RENDERER_H_ |
1487 | -#define MIR_TYPO_FREETYPE_RENDERER_H_ |
1488 | - |
1489 | -#include "typo_renderer.h" |
1490 | -#include <ft2build.h> |
1491 | -#include FT_FREETYPE_H |
1492 | - |
1493 | -namespace mir { namespace typo { |
1494 | - |
1495 | -class FreetypeRenderer : public Renderer |
1496 | -{ |
1497 | -public: |
1498 | - FreetypeRenderer(); |
1499 | - ~FreetypeRenderer(); |
1500 | - bool load(char const* font_path, int pref_height); |
1501 | - void render(char const* str, Image& img) override; |
1502 | - |
1503 | -private: |
1504 | - FT_Library lib; |
1505 | - FT_Face face; |
1506 | - int preferred_height; |
1507 | -}; |
1508 | - |
1509 | -} } // namespace mir::typo |
1510 | - |
1511 | -#endif // MIR_TYPO_FREETYPE_RENDERER_H_ |
1512 | |
1513 | === removed file 'playground/demo-shell/typo/typo_glcache.cpp' |
1514 | --- playground/demo-shell/typo/typo_glcache.cpp 2017-07-28 17:00:43 +0000 |
1515 | +++ playground/demo-shell/typo/typo_glcache.cpp 1970-01-01 00:00:00 +0000 |
1516 | @@ -1,99 +0,0 @@ |
1517 | -/* |
1518 | - * Copyright © 2015 Canonical Ltd. |
1519 | - * |
1520 | - * This program is free software: you can redistribute it and/or modify |
1521 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1522 | - * published by the Free Software Foundation. |
1523 | - * |
1524 | - * This program is distributed in the hope that it will be useful, |
1525 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1526 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1527 | - * GNU General Public License for more details. |
1528 | - * |
1529 | - * You should have received a copy of the GNU General Public License |
1530 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1531 | - * |
1532 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1533 | - */ |
1534 | - |
1535 | -#include "typo_glcache.h" |
1536 | -#include MIR_SERVER_GL_H |
1537 | - |
1538 | -using namespace mir::typo; |
1539 | - |
1540 | -GLCache::GLCache(std::shared_ptr<Renderer> const& r) |
1541 | - : renderer(r) |
1542 | -{ |
1543 | -} |
1544 | - |
1545 | -GLCache::~GLCache() |
1546 | -{ |
1547 | - clear(); |
1548 | -} |
1549 | - |
1550 | -void GLCache::change_renderer(std::shared_ptr<Renderer> const& r) |
1551 | -{ |
1552 | - clear(); |
1553 | - renderer = r; |
1554 | -} |
1555 | - |
1556 | -void GLCache::clear() |
1557 | -{ |
1558 | - for (auto& e : map) |
1559 | - glDeleteTextures(1, &e.second.tex); |
1560 | - map.clear(); |
1561 | -} |
1562 | - |
1563 | -void GLCache::mark_all_unused() |
1564 | -{ |
1565 | - for (auto& e : map) |
1566 | - e.second.used = false; |
1567 | -} |
1568 | - |
1569 | -void GLCache::drop_unused() |
1570 | -{ |
1571 | - for (auto e = map.begin(); e != map.end();) |
1572 | - { |
1573 | - if (!e->second.used) |
1574 | - { |
1575 | - glDeleteTextures(1, &e->second.tex); |
1576 | - e = map.erase(e); |
1577 | - } |
1578 | - else |
1579 | - e++; |
1580 | - } |
1581 | -} |
1582 | - |
1583 | -bool GLCache::Entry::valid() const |
1584 | -{ |
1585 | - return width > 0 && height > 0; |
1586 | -} |
1587 | - |
1588 | -GLCache::Entry const& GLCache::get(char const* str) |
1589 | -{ |
1590 | - Entry& entry = map[str]; |
1591 | - if (!entry.valid()) |
1592 | - { |
1593 | - Renderer::Image img; |
1594 | - renderer->render(str, img); |
1595 | - if (img.data()) |
1596 | - { |
1597 | - entry.width = img.width(); |
1598 | - entry.height = img.height(); |
1599 | - glGenTextures(1, &entry.tex); |
1600 | - glBindTexture(GL_TEXTURE_2D, entry.tex); |
1601 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
1602 | - GL_LINEAR_MIPMAP_NEAREST); |
1603 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
1604 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
1605 | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
1606 | - glPixelStorei(GL_UNPACK_ALIGNMENT, img.alignment()); |
1607 | - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, |
1608 | - img.width(), img.height(), 0, GL_ALPHA, |
1609 | - GL_UNSIGNED_BYTE, img.data()); |
1610 | - glGenerateMipmap(GL_TEXTURE_2D); // Antialiasing shrinkage please |
1611 | - } |
1612 | - } |
1613 | - entry.used = true; |
1614 | - return entry; |
1615 | -} |
1616 | |
1617 | === removed file 'playground/demo-shell/typo/typo_glcache.h' |
1618 | --- playground/demo-shell/typo/typo_glcache.h 2017-07-28 17:00:43 +0000 |
1619 | +++ playground/demo-shell/typo/typo_glcache.h 1970-01-01 00:00:00 +0000 |
1620 | @@ -1,56 +0,0 @@ |
1621 | -/* |
1622 | - * Copyright © 2015 Canonical Ltd. |
1623 | - * |
1624 | - * This program is free software: you can redistribute it and/or modify |
1625 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1626 | - * published by the Free Software Foundation. |
1627 | - * |
1628 | - * This program is distributed in the hope that it will be useful, |
1629 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1630 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1631 | - * GNU General Public License for more details. |
1632 | - * |
1633 | - * You should have received a copy of the GNU General Public License |
1634 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1635 | - * |
1636 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1637 | - */ |
1638 | - |
1639 | -#ifndef MIR_TYPO_GLCACHE_H_ |
1640 | -#define MIR_TYPO_GLCACHE_H_ |
1641 | - |
1642 | -#include "typo_renderer.h" |
1643 | -#include <string> |
1644 | -#include <unordered_map> |
1645 | -#include <memory> |
1646 | - |
1647 | -namespace mir { namespace typo { |
1648 | - |
1649 | -class GLCache |
1650 | -{ |
1651 | -public: |
1652 | - struct Entry |
1653 | - { |
1654 | - bool valid() const; |
1655 | - unsigned int tex = 0; |
1656 | - int width = 0, height = 0; |
1657 | - bool used = false; |
1658 | - }; |
1659 | - |
1660 | - explicit GLCache(std::shared_ptr<Renderer> const&); |
1661 | - ~GLCache(); |
1662 | - void change_renderer(std::shared_ptr<Renderer> const&); |
1663 | - Entry const& get(char const* str); |
1664 | - void clear(); |
1665 | - void mark_all_unused(); |
1666 | - void drop_unused(); |
1667 | - |
1668 | -private: |
1669 | - typedef std::unordered_map<std::string, Entry> Map; |
1670 | - Map map; |
1671 | - std::shared_ptr<Renderer> renderer; |
1672 | -}; |
1673 | - |
1674 | -} } // namespace mir::typo |
1675 | - |
1676 | -#endif // MIR_TYPO_GLCACHE_H_ |
1677 | |
1678 | === removed file 'playground/demo-shell/typo/typo_renderer.cpp' |
1679 | --- playground/demo-shell/typo/typo_renderer.cpp 2017-07-28 17:00:43 +0000 |
1680 | +++ playground/demo-shell/typo/typo_renderer.cpp 1970-01-01 00:00:00 +0000 |
1681 | @@ -1,59 +0,0 @@ |
1682 | -/* |
1683 | - * Copyright © 2015 Canonical Ltd. |
1684 | - * |
1685 | - * This program is free software: you can redistribute it and/or modify |
1686 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1687 | - * published by the Free Software Foundation. |
1688 | - * |
1689 | - * This program is distributed in the hope that it will be useful, |
1690 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1691 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1692 | - * GNU General Public License for more details. |
1693 | - * |
1694 | - * You should have received a copy of the GNU General Public License |
1695 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1696 | - * |
1697 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1698 | - */ |
1699 | - |
1700 | -#include "typo_renderer.h" |
1701 | -#include <cstring> |
1702 | - |
1703 | -using namespace mir::typo; |
1704 | - |
1705 | -Renderer::Image::Image() |
1706 | - : buf(nullptr), width_(0), stride_(0), height_(0), align_(4), |
1707 | - format_(alpha8) |
1708 | -{ |
1709 | -} |
1710 | - |
1711 | -Renderer::Image::~Image() |
1712 | -{ |
1713 | - delete[] buf; |
1714 | -} |
1715 | - |
1716 | -void Renderer::Image::reserve(int w, int h, Format f) |
1717 | -{ |
1718 | - width_ = w; |
1719 | - height_ = h; |
1720 | - format_ = f; |
1721 | - int const bpp = 1; // format is always alpha8 |
1722 | - stride_ = (((width_ * bpp) + align_ - 1) / align_) * align_; |
1723 | - delete[] buf; |
1724 | - auto size = stride_ * height_; |
1725 | - buf = new unsigned char[size]; |
1726 | - memset(buf, 0, size); |
1727 | -} |
1728 | - |
1729 | -Renderer::~Renderer() |
1730 | -{ |
1731 | -} |
1732 | - |
1733 | -unsigned long Renderer::unicode_from_utf8(char const** utf8) |
1734 | -{ |
1735 | - int char_len = 1; // TODO: Add support for non-ASCII UTF-8 |
1736 | - unsigned long unicode = **utf8; |
1737 | - if (unicode) |
1738 | - *utf8 += char_len; |
1739 | - return unicode; |
1740 | -} |
1741 | |
1742 | === removed file 'playground/demo-shell/typo/typo_renderer.h' |
1743 | --- playground/demo-shell/typo/typo_renderer.h 2017-07-28 17:00:43 +0000 |
1744 | +++ playground/demo-shell/typo/typo_renderer.h 1970-01-01 00:00:00 +0000 |
1745 | @@ -1,61 +0,0 @@ |
1746 | -/* |
1747 | - * Copyright © 2015 Canonical Ltd. |
1748 | - * |
1749 | - * This program is free software: you can redistribute it and/or modify |
1750 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1751 | - * published by the Free Software Foundation. |
1752 | - * |
1753 | - * This program is distributed in the hope that it will be useful, |
1754 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1755 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1756 | - * GNU General Public License for more details. |
1757 | - * |
1758 | - * You should have received a copy of the GNU General Public License |
1759 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1760 | - * |
1761 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1762 | - */ |
1763 | - |
1764 | -#ifndef MIR_TYPO_RENDERER_H_ |
1765 | -#define MIR_TYPO_RENDERER_H_ |
1766 | - |
1767 | -namespace mir { namespace typo { |
1768 | - |
1769 | -class Renderer |
1770 | -{ |
1771 | -public: |
1772 | - class Image |
1773 | - { |
1774 | - public: |
1775 | - Image(); |
1776 | - Image(Image const&) = delete; |
1777 | - Image(Image const&&) = delete; |
1778 | - Image& operator=(Image const&) = delete; |
1779 | - ~Image(); |
1780 | - |
1781 | - typedef enum {alpha8} Format; |
1782 | - |
1783 | - void reserve(int w, int h, Format f); |
1784 | - unsigned char* data() const { return buf; }; |
1785 | - int width() const { return width_; } |
1786 | - int height() const { return height_; } |
1787 | - int stride() const { return stride_; } |
1788 | - int alignment() const { return align_; } |
1789 | - Format format() const { return format_; } |
1790 | - |
1791 | - private: |
1792 | - unsigned char* buf; |
1793 | - int width_, stride_, height_, align_; |
1794 | - Format format_; |
1795 | - }; |
1796 | - |
1797 | - virtual ~Renderer(); |
1798 | - virtual void render(char const* str, Image& img) = 0; |
1799 | - |
1800 | -protected: |
1801 | - static unsigned long unicode_from_utf8(char const** utf8); |
1802 | -}; |
1803 | - |
1804 | -} } // namespace mir::typo |
1805 | - |
1806 | -#endif // MIR_TYPO_RENDERER_H_ |
1807 | |
1808 | === removed file 'playground/demo-shell/typo/typo_stub_renderer.cpp' |
1809 | --- playground/demo-shell/typo/typo_stub_renderer.cpp 2017-07-28 17:00:43 +0000 |
1810 | +++ playground/demo-shell/typo/typo_stub_renderer.cpp 1970-01-01 00:00:00 +0000 |
1811 | @@ -1,47 +0,0 @@ |
1812 | -/* |
1813 | - * Copyright © 2015 Canonical Ltd. |
1814 | - * |
1815 | - * This program is free software: you can redistribute it and/or modify |
1816 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1817 | - * published by the Free Software Foundation. |
1818 | - * |
1819 | - * This program is distributed in the hope that it will be useful, |
1820 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1821 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1822 | - * GNU General Public License for more details. |
1823 | - * |
1824 | - * You should have received a copy of the GNU General Public License |
1825 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1826 | - * |
1827 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1828 | - */ |
1829 | - |
1830 | -#include "typo_stub_renderer.h" |
1831 | -#include <cstring> |
1832 | - |
1833 | -using namespace mir::typo; |
1834 | - |
1835 | -void StubRenderer::render(char const* str, Image& img) |
1836 | -{ |
1837 | - int const char_width = 8; |
1838 | - int const char_height = 16; |
1839 | - int const char_space = 2; |
1840 | - int const tex_height = 20; |
1841 | - int const len = strlen(str); |
1842 | - int const top = (tex_height - char_height) / 2; |
1843 | - |
1844 | - img.reserve(len*(char_width+char_space) - char_space, tex_height, |
1845 | - Image::alpha8); |
1846 | - |
1847 | - char const* s = str; |
1848 | - for (int n = 0; unicode_from_utf8(&s); ++n) |
1849 | - { |
1850 | - unsigned char* row = img.data() + top*img.stride() + |
1851 | - n*(char_width+char_space); |
1852 | - for (int y = 0; y < char_height; ++y) |
1853 | - { |
1854 | - memset(row, 255, char_width); |
1855 | - row += img.stride(); |
1856 | - } |
1857 | - } |
1858 | -} |
1859 | |
1860 | === removed file 'playground/demo-shell/typo/typo_stub_renderer.h' |
1861 | --- playground/demo-shell/typo/typo_stub_renderer.h 2017-07-28 17:00:43 +0000 |
1862 | +++ playground/demo-shell/typo/typo_stub_renderer.h 1970-01-01 00:00:00 +0000 |
1863 | @@ -1,34 +0,0 @@ |
1864 | -/* |
1865 | - * Copyright © 2015 Canonical Ltd. |
1866 | - * |
1867 | - * This program is free software: you can redistribute it and/or modify |
1868 | - * it under the terms of the GNU General Public License version 2 or 3 as |
1869 | - * published by the Free Software Foundation. |
1870 | - * |
1871 | - * This program is distributed in the hope that it will be useful, |
1872 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1873 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1874 | - * GNU General Public License for more details. |
1875 | - * |
1876 | - * You should have received a copy of the GNU General Public License |
1877 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1878 | - * |
1879 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1880 | - */ |
1881 | - |
1882 | -#ifndef MIR_TYPO_STUB_RENDERER_H_ |
1883 | -#define MIR_TYPO_STUB_RENDERER_H_ |
1884 | - |
1885 | -#include "typo_renderer.h" |
1886 | - |
1887 | -namespace mir { namespace typo { |
1888 | - |
1889 | -class StubRenderer : public Renderer |
1890 | -{ |
1891 | -public: |
1892 | - void render(char const* str, Image& img) override; |
1893 | -}; |
1894 | - |
1895 | -} } // namespace mir::typo |
1896 | - |
1897 | -#endif // MIR_TYPO_STUB_RENDERER_H_ |
1898 | |
1899 | === removed file 'playground/demo-shell/window_manager.cpp' |
1900 | --- playground/demo-shell/window_manager.cpp 2017-07-28 17:00:43 +0000 |
1901 | +++ playground/demo-shell/window_manager.cpp 1970-01-01 00:00:00 +0000 |
1902 | @@ -1,611 +0,0 @@ |
1903 | -/* |
1904 | - * Copyright © 2013 Canonical Ltd. |
1905 | - * |
1906 | - * This program is free software: you can redistribute it and/or modify it |
1907 | - * under the terms of the GNU General Public License version 2 or 3, |
1908 | - * as published by the Free Software Foundation. |
1909 | - * |
1910 | - * This program is distributed in the hope that it will be useful, |
1911 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1912 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1913 | - * GNU General Public License for more details. |
1914 | - * |
1915 | - * You should have received a copy of the GNU General Public License |
1916 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1917 | - * |
1918 | - * Authored by: Robert Carr <robert.carr@canonical.com> |
1919 | - * Daniel van Vugt <daniel.van.vugt@canonical.com> |
1920 | - */ |
1921 | - |
1922 | -#include "window_manager.h" |
1923 | -#include "demo_compositor.h" |
1924 | - |
1925 | -#include "mir/shell/focus_controller.h" |
1926 | -#include "mir/scene/session.h" |
1927 | -#include "mir/scene/surface.h" |
1928 | -#include "mir/graphics/display.h" |
1929 | -#include "mir/graphics/display_configuration.h" |
1930 | -#include "mir/compositor/compositor.h" |
1931 | - |
1932 | -#include <linux/input.h> |
1933 | - |
1934 | -#include <cassert> |
1935 | -#include <cstdlib> |
1936 | -#include <cmath> |
1937 | - |
1938 | -namespace me = mir::examples; |
1939 | -namespace msh = mir::shell; |
1940 | -namespace mg = mir::graphics; |
1941 | -namespace mc = mir::compositor; |
1942 | -namespace mi = mir::input; |
1943 | - |
1944 | -namespace |
1945 | -{ |
1946 | -const int min_swipe_distance = 100; // How long must a swipe be to act on? |
1947 | -} |
1948 | - |
1949 | -me::WindowManager::WindowManager() |
1950 | - : old_pinch_diam(0.0f), max_fingers(0) |
1951 | -{ |
1952 | -} |
1953 | - |
1954 | -void me::WindowManager::set_focus_controller(std::shared_ptr<msh::FocusController> const& controller) |
1955 | -{ |
1956 | - focus_controller = controller; |
1957 | -} |
1958 | - |
1959 | -void me::WindowManager::set_display(std::shared_ptr<mg::Display> const& dpy) |
1960 | -{ |
1961 | - display = dpy; |
1962 | -} |
1963 | - |
1964 | -void me::WindowManager::set_compositor(std::shared_ptr<mc::Compositor> const& cptor) |
1965 | -{ |
1966 | - compositor = cptor; |
1967 | -} |
1968 | - |
1969 | -void me::WindowManager::set_input_scene(std::shared_ptr<mi::Scene> const& s) |
1970 | -{ |
1971 | - input_scene = s; |
1972 | -} |
1973 | - |
1974 | -void me::WindowManager::force_redraw() |
1975 | -{ |
1976 | - // This is clumsy, but the only option our architecture allows us for now |
1977 | - // Same hack as used in TouchspotController... |
1978 | - input_scene->emit_scene_changed(); |
1979 | -} |
1980 | - |
1981 | -namespace |
1982 | -{ |
1983 | - |
1984 | -mir::geometry::Point average_pointer(MirTouchEvent const* tev) |
1985 | -{ |
1986 | - using namespace mir; |
1987 | - using namespace geometry; |
1988 | - |
1989 | - int x = 0, y = 0; |
1990 | - int count = mir_touch_event_point_count(tev); |
1991 | - |
1992 | - for (int i = 0; i < count; i++) |
1993 | - { |
1994 | - x += mir_touch_event_axis_value(tev, i, mir_touch_axis_x); |
1995 | - y += mir_touch_event_axis_value(tev, i, mir_touch_axis_y); |
1996 | - } |
1997 | - |
1998 | - x /= count; |
1999 | - y /= count; |
2000 | - |
2001 | - return Point{x, y}; |
2002 | -} |
2003 | - |
2004 | -float measure_pinch(MirTouchEvent const* tev, |
2005 | - mir::geometry::Displacement& dir) |
2006 | -{ |
2007 | - int count = mir_touch_event_point_count(tev); |
2008 | - int max = 0; |
2009 | - |
2010 | - for (int i = 0; i < count; i++) |
2011 | - { |
2012 | - for (int j = 0; j < i; j++) |
2013 | - { |
2014 | - int dx = mir_touch_event_axis_value(tev, i, mir_touch_axis_x) - |
2015 | - mir_touch_event_axis_value(tev, j, mir_touch_axis_x); |
2016 | - int dy = mir_touch_event_axis_value(tev, i, mir_touch_axis_y) - |
2017 | - mir_touch_event_axis_value(tev, j, mir_touch_axis_y); |
2018 | - |
2019 | - int sqr = dx*dx + dy*dy; |
2020 | - |
2021 | - if (sqr > max) |
2022 | - { |
2023 | - max = sqr; |
2024 | - dir = mir::geometry::Displacement{dx, dy}; |
2025 | - } |
2026 | - } |
2027 | - } |
2028 | - |
2029 | - return sqrtf(max); // return pinch diameter |
2030 | -} |
2031 | - |
2032 | -} // namespace |
2033 | - |
2034 | - |
2035 | -void me::WindowManager::toggle(ColourEffect which) |
2036 | -{ |
2037 | - colour_effect = (colour_effect == which) ? none : which; |
2038 | - me::DemoCompositor::for_each([this](me::DemoCompositor& c) |
2039 | - { |
2040 | - c.set_colour_effect(colour_effect); |
2041 | - }); |
2042 | - force_redraw(); |
2043 | -} |
2044 | - |
2045 | -void me::WindowManager::save_edges(scene::Surface& surf, |
2046 | - geometry::Point const& p) |
2047 | -{ |
2048 | - int width = surf.size().width.as_int(); |
2049 | - int height = surf.size().height.as_int(); |
2050 | - |
2051 | - int left = surf.top_left().x.as_int(); |
2052 | - int right = left + width; |
2053 | - int top = surf.top_left().y.as_int(); |
2054 | - int bottom = top + height; |
2055 | - |
2056 | - int leftish = left + width/3; |
2057 | - int rightish = right - width/3; |
2058 | - int topish = top + height/3; |
2059 | - int bottomish = bottom - height/3; |
2060 | - |
2061 | - int click_x = p.x.as_int(); |
2062 | - xedge = (click_x <= leftish) ? left_edge : |
2063 | - (click_x >= rightish) ? right_edge : |
2064 | - hmiddle; |
2065 | - |
2066 | - int click_y = p.y.as_int(); |
2067 | - yedge = (click_y <= topish) ? top_edge : |
2068 | - (click_y >= bottomish) ? bottom_edge : |
2069 | - vmiddle; |
2070 | -} |
2071 | - |
2072 | -void me::WindowManager::resize(scene::Surface& surf, |
2073 | - geometry::Point const& cursor) const |
2074 | -{ |
2075 | - int width = surf.size().width.as_int(); |
2076 | - int height = surf.size().height.as_int(); |
2077 | - |
2078 | - int left = surf.top_left().x.as_int(); |
2079 | - int right = left + width; |
2080 | - int top = surf.top_left().y.as_int(); |
2081 | - int bottom = top + height; |
2082 | - |
2083 | - geometry::Displacement drag = cursor - old_cursor; |
2084 | - int dx = drag.dx.as_int(); |
2085 | - int dy = drag.dy.as_int(); |
2086 | - |
2087 | - if (xedge == left_edge && dx < width) |
2088 | - left = old_pos.x.as_int() + dx; |
2089 | - else if (xedge == right_edge) |
2090 | - right = old_pos.x.as_int() + old_size.width.as_int() + dx; |
2091 | - |
2092 | - if (yedge == top_edge && dy < height) |
2093 | - top = old_pos.y.as_int() + dy; |
2094 | - else if (yedge == bottom_edge) |
2095 | - bottom = old_pos.y.as_int() + old_size.height.as_int() + dy; |
2096 | - |
2097 | - surf.move_to({left, top}); |
2098 | - surf.resize({right-left, bottom-top}); |
2099 | -} |
2100 | - |
2101 | -bool me::WindowManager::handle_key_event(MirKeyboardEvent const* kev) |
2102 | -{ |
2103 | - static bool display_off = false; |
2104 | - |
2105 | - if (mir_keyboard_event_action(kev) != mir_keyboard_action_down) |
2106 | - return false; |
2107 | - |
2108 | - auto modifiers = mir_keyboard_event_modifiers(kev); |
2109 | - auto scan_code = mir_keyboard_event_scan_code(kev); |
2110 | - |
2111 | - if (modifiers & mir_input_event_modifier_alt && |
2112 | - scan_code == KEY_TAB) // TODO: Use keycode once we support keymapping on the server side |
2113 | - { |
2114 | - focus_controller->focus_next_session(); |
2115 | - if (auto const surface = focus_controller->focused_surface()) |
2116 | - focus_controller->raise({surface}); |
2117 | - return true; |
2118 | - } |
2119 | - else if (modifiers & mir_input_event_modifier_alt && |
2120 | - scan_code == KEY_GRAVE) |
2121 | - { |
2122 | - if (auto const prev = focus_controller->focused_surface()) |
2123 | - { |
2124 | - auto const app = focus_controller->focused_session(); |
2125 | - auto const next = app->surface_after(prev); |
2126 | - focus_controller->set_focus_to(app, next); |
2127 | - focus_controller->raise({next}); |
2128 | - } |
2129 | - return true; |
2130 | - } |
2131 | - else if (modifiers & mir_input_event_modifier_alt && |
2132 | - scan_code == KEY_F4) |
2133 | - { |
2134 | - auto const surf = focus_controller->focused_surface(); |
2135 | - if (surf) |
2136 | - surf->request_client_surface_close(); |
2137 | - return true; |
2138 | - } |
2139 | - else if ((modifiers & mir_input_event_modifier_alt && |
2140 | - scan_code == KEY_P) || |
2141 | - (scan_code == KEY_POWER)) |
2142 | - { |
2143 | - compositor->stop(); |
2144 | - auto conf = display->configuration(); |
2145 | - MirPowerMode new_power_mode = display_off ? |
2146 | - mir_power_mode_on : mir_power_mode_off; |
2147 | - conf->for_each_output( |
2148 | - [&](mg::UserDisplayConfigurationOutput& output) -> void |
2149 | - { |
2150 | - output.power_mode = new_power_mode; |
2151 | - }); |
2152 | - display_off = !display_off; |
2153 | - |
2154 | - display->configure(*conf.get()); |
2155 | - if (!display_off) |
2156 | - compositor->start(); |
2157 | - return true; |
2158 | - } |
2159 | - else if ((modifiers & mir_input_event_modifier_alt) && |
2160 | - (modifiers & mir_input_event_modifier_ctrl) && |
2161 | - (scan_code == KEY_ESC)) |
2162 | - { |
2163 | - std::abort(); |
2164 | - return true; |
2165 | - } |
2166 | - else if ((modifiers & mir_input_event_modifier_alt) && |
2167 | - (modifiers & mir_input_event_modifier_ctrl) && |
2168 | - (scan_code == KEY_L) && |
2169 | - focus_controller) |
2170 | - { |
2171 | - auto const app = focus_controller->focused_session(); |
2172 | - if (app) |
2173 | - { |
2174 | - app->set_lifecycle_state(mir_lifecycle_state_will_suspend); |
2175 | - } |
2176 | - } |
2177 | - else if ((modifiers & mir_input_event_modifier_alt) && |
2178 | - (modifiers & mir_input_event_modifier_ctrl)) |
2179 | - { |
2180 | - MirOrientation orientation = mir_orientation_normal; |
2181 | - bool rotating = true; |
2182 | - int mode_change = 0; |
2183 | - bool preferred_mode = false; |
2184 | - switch (scan_code) |
2185 | - { |
2186 | - case KEY_UP: orientation = mir_orientation_normal; break; |
2187 | - case KEY_DOWN: orientation = mir_orientation_inverted; break; |
2188 | - case KEY_LEFT: orientation = mir_orientation_left; break; |
2189 | - case KEY_RIGHT: orientation = mir_orientation_right; break; |
2190 | - default: rotating = false; break; |
2191 | - } |
2192 | - switch (scan_code) |
2193 | - { |
2194 | - case KEY_MINUS: mode_change = -1; break; |
2195 | - case KEY_EQUAL: mode_change = +1; break; |
2196 | - case KEY_0: preferred_mode = true; break; |
2197 | - default: break; |
2198 | - } |
2199 | - |
2200 | - if (rotating || mode_change || preferred_mode) |
2201 | - { |
2202 | - auto conf = display->configuration(); |
2203 | - conf->for_each_output( |
2204 | - [&](mg::UserDisplayConfigurationOutput& output) -> void |
2205 | - { |
2206 | - // Only apply changes to the monitor the cursor is on |
2207 | - if (!output.extents().contains(old_cursor)) |
2208 | - return; |
2209 | - if (rotating) |
2210 | - output.orientation = orientation; |
2211 | - if (preferred_mode) |
2212 | - { |
2213 | - output.current_mode_index = |
2214 | - output.preferred_mode_index; |
2215 | - } |
2216 | - else if (mode_change) |
2217 | - { |
2218 | - size_t nmodes = output.modes.size(); |
2219 | - if (nmodes) |
2220 | - output.current_mode_index = |
2221 | - (output.current_mode_index + nmodes + |
2222 | - mode_change) % nmodes; |
2223 | - } |
2224 | - }); |
2225 | - |
2226 | - if (!rotating) compositor->stop(); |
2227 | - display->configure(*conf); |
2228 | - if (!rotating) compositor->start(); |
2229 | - force_redraw(); |
2230 | - return true; |
2231 | - } |
2232 | - } |
2233 | - else if ((scan_code == KEY_VOLUMEDOWN || |
2234 | - scan_code == KEY_VOLUMEUP) && |
2235 | - max_fingers == 1) |
2236 | - { |
2237 | - int delta = (scan_code == KEY_VOLUMEDOWN) ? -1 : +1; |
2238 | - static const MirOrientation order[4] = |
2239 | - { |
2240 | - mir_orientation_normal, |
2241 | - mir_orientation_right, |
2242 | - mir_orientation_inverted, |
2243 | - mir_orientation_left |
2244 | - }; |
2245 | - compositor->stop(); |
2246 | - auto conf = display->configuration(); |
2247 | - conf->for_each_output( |
2248 | - [&](mg::UserDisplayConfigurationOutput& output) |
2249 | - { |
2250 | - int i = 0; |
2251 | - for (; i < 4; ++i) |
2252 | - { |
2253 | - if (output.orientation == order[i]) |
2254 | - break; |
2255 | - } |
2256 | - output.orientation = order[(i+4+delta) % 4]; |
2257 | - }); |
2258 | - display->configure(*conf.get()); |
2259 | - compositor->start(); |
2260 | - return true; |
2261 | - } |
2262 | - else if (modifiers & mir_input_event_modifier_meta && |
2263 | - scan_code == KEY_N) |
2264 | - { |
2265 | - toggle(inverse); |
2266 | - return true; |
2267 | - } |
2268 | - else if (modifiers & mir_input_event_modifier_meta && |
2269 | - scan_code == KEY_C) |
2270 | - { |
2271 | - toggle(contrast); |
2272 | - return true; |
2273 | - } |
2274 | - return false; |
2275 | -} |
2276 | - |
2277 | - |
2278 | -bool me::WindowManager::handle_pointer_event(MirPointerEvent const* pev) |
2279 | -{ |
2280 | - bool handled = false; |
2281 | - |
2282 | - geometry::Point cursor{mir_pointer_event_axis_value(pev, mir_pointer_axis_x), |
2283 | - mir_pointer_event_axis_value(pev, mir_pointer_axis_y)}; |
2284 | - auto action = mir_pointer_event_action(pev); |
2285 | - auto modifiers = mir_pointer_event_modifiers(pev); |
2286 | - auto vscroll = mir_pointer_event_axis_value(pev, mir_pointer_axis_vscroll); |
2287 | - auto primary_button_pressed = mir_pointer_event_button_state(pev, mir_pointer_button_primary); |
2288 | - auto tertiary_button_pressed = mir_pointer_event_button_state(pev, mir_pointer_button_tertiary); |
2289 | - |
2290 | - float new_zoom_mag = 0.0f; // zero means unchanged |
2291 | - |
2292 | - if (modifiers & mir_input_event_modifier_meta && |
2293 | - action == mir_pointer_action_motion && |
2294 | - vscroll != 0.0f) |
2295 | - { |
2296 | - zoom_exponent += vscroll; |
2297 | - |
2298 | - // Negative exponents do work too, but disable them until |
2299 | - // there's a clear edge to the desktop. |
2300 | - if (zoom_exponent < 0) |
2301 | - zoom_exponent = 0; |
2302 | - |
2303 | - new_zoom_mag = powf(1.2f, zoom_exponent); |
2304 | - handled = true; |
2305 | - } |
2306 | - |
2307 | - me::DemoCompositor::for_each( |
2308 | - [new_zoom_mag,&cursor](me::DemoCompositor& c) |
2309 | - { |
2310 | - if (new_zoom_mag > 0.0f) |
2311 | - c.zoom(new_zoom_mag); |
2312 | - c.on_cursor_movement(cursor); |
2313 | - }); |
2314 | - |
2315 | - if (zoom_exponent || new_zoom_mag) |
2316 | - force_redraw(); |
2317 | - |
2318 | - auto const surf = focus_controller->focused_surface(); |
2319 | - if (surf && |
2320 | - (modifiers & mir_input_event_modifier_alt) && (primary_button_pressed || tertiary_button_pressed)) |
2321 | - { |
2322 | - // Start of a gesture: When the latest finger/button goes down |
2323 | - if (action == mir_pointer_action_button_down) |
2324 | - { |
2325 | - click = cursor; |
2326 | - save_edges(*surf, click); |
2327 | - handled = true; |
2328 | - } |
2329 | - else if (action == mir_pointer_action_motion) |
2330 | - { |
2331 | - geometry::Displacement drag = cursor - old_cursor; |
2332 | - |
2333 | - if (tertiary_button_pressed) |
2334 | - { // Resize by mouse middle button |
2335 | - resize(*surf, cursor); |
2336 | - } |
2337 | - else |
2338 | - { |
2339 | - surf->move_to(old_pos + drag); |
2340 | - } |
2341 | - |
2342 | - handled = true; |
2343 | - } |
2344 | - |
2345 | - old_pos = surf->top_left(); |
2346 | - old_size = surf->size(); |
2347 | - } |
2348 | - |
2349 | - if (surf && |
2350 | - (modifiers & mir_input_event_modifier_alt) && |
2351 | - action == mir_pointer_action_motion && |
2352 | - vscroll) |
2353 | - { |
2354 | - float alpha = surf->alpha(); |
2355 | - alpha += vscroll > 0.0f ? 0.1f : -0.1f; |
2356 | - if (alpha < 0.0f) |
2357 | - alpha = 0.0f; |
2358 | - else if (alpha > 1.0f) |
2359 | - alpha = 1.0f; |
2360 | - surf->set_alpha(alpha); |
2361 | - handled = true; |
2362 | - } |
2363 | - |
2364 | - old_cursor = cursor; |
2365 | - return handled; |
2366 | -} |
2367 | - |
2368 | -namespace |
2369 | -{ |
2370 | -bool any_touches_went_down(MirTouchEvent const* tev) |
2371 | -{ |
2372 | - auto count = mir_touch_event_point_count(tev); |
2373 | - for (unsigned i = 0; i < count; i++) |
2374 | - { |
2375 | - if (mir_touch_event_action(tev, i) == mir_touch_action_down) |
2376 | - return true; |
2377 | - } |
2378 | - return false; |
2379 | -} |
2380 | -bool last_touch_released(MirTouchEvent const* tev) |
2381 | -{ |
2382 | - auto count = mir_touch_event_point_count(tev); |
2383 | - if (count > 1) |
2384 | - return false; |
2385 | - return mir_touch_event_action(tev, 0) == mir_touch_action_up; |
2386 | -} |
2387 | -} |
2388 | - |
2389 | -bool me::WindowManager::handle_touch_event(MirTouchEvent const* tev) |
2390 | -{ |
2391 | - bool handled = false; |
2392 | - geometry::Point cursor = average_pointer(tev); |
2393 | - |
2394 | - auto const& modifiers = mir_touch_event_modifiers(tev); |
2395 | - |
2396 | - int fingers = mir_touch_event_point_count(tev); |
2397 | - |
2398 | - if (fingers > max_fingers) |
2399 | - max_fingers = fingers; |
2400 | - |
2401 | - auto const surf = focus_controller->focused_surface(); |
2402 | - if (surf && |
2403 | - (modifiers & mir_input_event_modifier_alt || |
2404 | - fingers >= 3)) |
2405 | - { |
2406 | - geometry::Displacement pinch_dir; |
2407 | - auto pinch_diam = |
2408 | - measure_pinch(tev, pinch_dir); |
2409 | - |
2410 | - // Start of a gesture: When the latest finger/button goes down |
2411 | - if (any_touches_went_down(tev)) |
2412 | - { |
2413 | - click = cursor; |
2414 | - save_edges(*surf, click); |
2415 | - handled = true; |
2416 | - } |
2417 | - else if(max_fingers <= 3) // Avoid accidental movement |
2418 | - { |
2419 | - geometry::Displacement drag = cursor - old_cursor; |
2420 | - |
2421 | - surf->move_to(old_pos + drag); |
2422 | - |
2423 | - if (fingers == 3) |
2424 | - { // Resize by pinch/zoom |
2425 | - float diam_delta = pinch_diam - old_pinch_diam; |
2426 | - /* |
2427 | - * Resize vector (dx,dy) has length=diam_delta and |
2428 | - * direction=pinch_dir, so solve for (dx,dy)... |
2429 | - */ |
2430 | - float lenlen = diam_delta * diam_delta; |
2431 | - int x = pinch_dir.dx.as_int(); |
2432 | - int y = pinch_dir.dy.as_int(); |
2433 | - int xx = x * x; |
2434 | - int yy = y * y; |
2435 | - int xxyy = xx + yy; |
2436 | - int dx = sqrtf(lenlen * xx / xxyy); |
2437 | - int dy = sqrtf(lenlen * yy / xxyy); |
2438 | - if (diam_delta < 0.0f) |
2439 | - { |
2440 | - dx = -dx; |
2441 | - dy = -dy; |
2442 | - } |
2443 | - |
2444 | - int width = old_size.width.as_int() + dx; |
2445 | - int height = old_size.height.as_int() + dy; |
2446 | - surf->resize({width, height}); |
2447 | - } |
2448 | - |
2449 | - handled = true; |
2450 | - } |
2451 | - |
2452 | - old_pos = surf->top_left(); |
2453 | - old_size = surf->size(); |
2454 | - old_pinch_diam = pinch_diam; |
2455 | - } |
2456 | - |
2457 | - auto gesture_ended = last_touch_released(tev); |
2458 | - |
2459 | - if (max_fingers == 4 && gesture_ended) |
2460 | - { // Four fingers released |
2461 | - geometry::Displacement dir = cursor - click; |
2462 | - if (abs(dir.dx.as_int()) >= min_swipe_distance) |
2463 | - { |
2464 | - focus_controller->focus_next_session(); |
2465 | - if (auto const surface = focus_controller->focused_surface()) |
2466 | - focus_controller->raise({surface}); |
2467 | - handled = true; |
2468 | - } |
2469 | - } |
2470 | - |
2471 | - if (fingers == 1 && gesture_ended) |
2472 | - max_fingers = 0; |
2473 | - |
2474 | - old_cursor = cursor; |
2475 | - |
2476 | - /* |
2477 | - * For now we reserve all 3 or 4 finger gestures for window manipulation. |
2478 | - * Make sure clients don't receive spurious events in the process... |
2479 | - */ |
2480 | - handled |= (max_fingers == 3 || max_fingers == 4); |
2481 | - |
2482 | - return handled; |
2483 | -} |
2484 | - |
2485 | -bool me::WindowManager::handle(MirEvent const& event) |
2486 | -{ |
2487 | - assert(focus_controller); |
2488 | - assert(display); |
2489 | - assert(compositor); |
2490 | - |
2491 | - if (mir_event_get_type(&event) != mir_event_type_input) |
2492 | - return false; |
2493 | - auto iev = mir_event_get_input_event(&event); |
2494 | - auto input_type = mir_input_event_get_type(iev); |
2495 | - |
2496 | - if (input_type == mir_input_event_type_key) |
2497 | - { |
2498 | - return handle_key_event(mir_input_event_get_keyboard_event(iev)); |
2499 | - } |
2500 | - else if (input_type == mir_input_event_type_pointer && |
2501 | - focus_controller) |
2502 | - { |
2503 | - return handle_pointer_event(mir_input_event_get_pointer_event(iev)); |
2504 | - } |
2505 | - else if (input_type == mir_input_event_type_touch && |
2506 | - focus_controller) |
2507 | - { |
2508 | - return handle_touch_event(mir_input_event_get_touch_event(iev)); |
2509 | - } |
2510 | - |
2511 | - |
2512 | - return false; |
2513 | -} |
2514 | |
2515 | === removed file 'playground/demo-shell/window_manager.h' |
2516 | --- playground/demo-shell/window_manager.h 2017-07-28 17:00:43 +0000 |
2517 | +++ playground/demo-shell/window_manager.h 1970-01-01 00:00:00 +0000 |
2518 | @@ -1,97 +0,0 @@ |
2519 | -/* |
2520 | - * Copyright © 2013 Canonical Ltd. |
2521 | - * |
2522 | - * This program is free software: you can redistribute it and/or modify it |
2523 | - * under the terms of the GNU General Public License version 2 or 3, |
2524 | - * as published by the Free Software Foundation. |
2525 | - * |
2526 | - * This program is distributed in the hope that it will be useful, |
2527 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2528 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2529 | - * GNU General Public License for more details. |
2530 | - * |
2531 | - * You should have received a copy of the GNU General Public License |
2532 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2533 | - * |
2534 | - * Authored by: Robert Carr <robert.carr@canonical.com> |
2535 | - */ |
2536 | - |
2537 | -#ifndef MIR_EXAMPLES_WINDOW_MANAGER_H_ |
2538 | -#define MIR_EXAMPLES_WINDOW_MANAGER_H_ |
2539 | - |
2540 | -#include "mir/input/event_filter.h" |
2541 | -#include "mir/input/scene.h" |
2542 | -#include "mir/geometry/displacement.h" |
2543 | -#include "mir/geometry/size.h" |
2544 | -#include "demo_renderer.h" |
2545 | - |
2546 | -#include <memory> |
2547 | - |
2548 | -namespace mir |
2549 | -{ |
2550 | -namespace shell |
2551 | -{ |
2552 | -class FocusController; |
2553 | -} |
2554 | -namespace graphics |
2555 | -{ |
2556 | -class Display; |
2557 | -} |
2558 | -namespace compositor |
2559 | -{ |
2560 | -class Compositor; |
2561 | -} |
2562 | - |
2563 | -namespace scene { class Surface; } |
2564 | - |
2565 | -namespace examples |
2566 | -{ |
2567 | - |
2568 | -class WindowManager : public input::EventFilter |
2569 | -{ |
2570 | -public: |
2571 | - WindowManager(); |
2572 | - ~WindowManager() = default; |
2573 | - |
2574 | - void set_focus_controller(std::shared_ptr<shell::FocusController> const& focus_controller); |
2575 | - void set_display(std::shared_ptr<graphics::Display> const& display); |
2576 | - void set_compositor(std::shared_ptr<compositor::Compositor> const& compositor); |
2577 | - void set_input_scene(std::shared_ptr<input::Scene> const& scene); |
2578 | - void force_redraw(); |
2579 | - |
2580 | - bool handle(MirEvent const& event) override; |
2581 | - |
2582 | -protected: |
2583 | - WindowManager(const WindowManager&) = delete; |
2584 | - WindowManager& operator=(const WindowManager&) = delete; |
2585 | - |
2586 | -private: |
2587 | - std::shared_ptr<shell::FocusController> focus_controller; |
2588 | - std::shared_ptr<graphics::Display> display; |
2589 | - std::shared_ptr<compositor::Compositor> compositor; |
2590 | - std::shared_ptr<input::Scene> input_scene; |
2591 | - |
2592 | - geometry::Point click; |
2593 | - geometry::Point old_pos; |
2594 | - geometry::Point old_cursor; |
2595 | - geometry::Size old_size; |
2596 | - float old_pinch_diam; |
2597 | - int max_fingers; // Maximum number of fingers touched during gesture |
2598 | - float zoom_exponent = 0.0f; |
2599 | - ColourEffect colour_effect = none; |
2600 | - |
2601 | - void toggle(ColourEffect); |
2602 | - |
2603 | - enum {left_edge, hmiddle, right_edge} xedge = hmiddle; |
2604 | - enum {top_edge, vmiddle, bottom_edge} yedge = vmiddle; |
2605 | - void save_edges(scene::Surface& surf, geometry::Point const& p); |
2606 | - void resize(scene::Surface& surf, geometry::Point const& cursor) const; |
2607 | - bool handle_key_event(MirKeyboardEvent const* event); |
2608 | - bool handle_touch_event(MirTouchEvent const* event); |
2609 | - bool handle_pointer_event(MirPointerEvent const* event); |
2610 | -}; |
2611 | - |
2612 | -} |
2613 | -} // namespace mir |
2614 | - |
2615 | -#endif // MIR_EXAMPLES_WINDOW_MANAGER_H_ |
2616 | |
2617 | === removed file 'playground/server_configuration.cpp' |
2618 | --- playground/server_configuration.cpp 2017-07-28 17:00:43 +0000 |
2619 | +++ playground/server_configuration.cpp 1970-01-01 00:00:00 +0000 |
2620 | @@ -1,86 +0,0 @@ |
2621 | -/* |
2622 | - * Copyright © 2013-2014 Canonical Ltd. |
2623 | - * |
2624 | - * This program is free software: you can redistribute it and/or modify |
2625 | - * it under the terms of the GNU General Public License version 2 or 3 as |
2626 | - * published by the Free Software Foundation. |
2627 | - * |
2628 | - * This program is distributed in the hope that it will be useful, |
2629 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2630 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2631 | - * GNU General Public License for more details. |
2632 | - * |
2633 | - * You should have received a copy of the GNU General Public License |
2634 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2635 | - * |
2636 | - * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
2637 | - */ |
2638 | - |
2639 | -#include "server_configuration.h" |
2640 | -#include "mir/options/default_configuration.h" |
2641 | -#include "mir/input/composite_event_filter.h" |
2642 | -#include "mir/graphics/default_display_configuration_policy.h" |
2643 | -#include "mir/main_loop.h" |
2644 | - |
2645 | -#include "server_example_display_configuration_policy.h" |
2646 | -#include "server_example_input_event_filter.h" |
2647 | - |
2648 | -namespace me = mir::examples; |
2649 | -namespace mg = mir::graphics; |
2650 | - |
2651 | -namespace |
2652 | -{ |
2653 | -std::shared_ptr<mir::options::DefaultConfiguration> const& customize( |
2654 | - std::shared_ptr<mir::options::DefaultConfiguration> const& opt) |
2655 | -{ |
2656 | - opt->add_options()(me::display_config_opt, |
2657 | - boost::program_options::value<std::string>()-> |
2658 | - default_value(me::clone_opt_val), |
2659 | - me::display_config_descr); |
2660 | - |
2661 | - return opt; |
2662 | -} |
2663 | -} |
2664 | - |
2665 | -me::ServerConfiguration::ServerConfiguration(std::shared_ptr<options::DefaultConfiguration> const& configuration_options) : |
2666 | - DefaultServerConfiguration(customize(configuration_options)) |
2667 | -{ |
2668 | -} |
2669 | - |
2670 | -me::ServerConfiguration::ServerConfiguration(int argc, char const** argv) : |
2671 | - ServerConfiguration(std::make_shared<options::DefaultConfiguration>(argc, argv)) |
2672 | -{ |
2673 | -} |
2674 | - |
2675 | -std::shared_ptr<mg::DisplayConfigurationPolicy> |
2676 | -me::ServerConfiguration::the_display_configuration_policy() |
2677 | -{ |
2678 | - return display_configuration_policy( |
2679 | - [this]() -> std::shared_ptr<mg::DisplayConfigurationPolicy> |
2680 | - { |
2681 | - auto display_config = the_options()->get<std::string>(me::display_config_opt); |
2682 | - |
2683 | - if (display_config == me::sidebyside_opt_val) |
2684 | - return std::make_shared<mg::SideBySideDisplayConfigurationPolicy>(); |
2685 | - else if (display_config == me::single_opt_val) |
2686 | - return std::make_shared<mg::SingleDisplayConfigurationPolicy>(); |
2687 | - else |
2688 | - return DefaultServerConfiguration::the_display_configuration_policy(); |
2689 | - }); |
2690 | -} |
2691 | - |
2692 | -std::shared_ptr<mir::input::CompositeEventFilter> |
2693 | -me::ServerConfiguration::the_composite_event_filter() |
2694 | -{ |
2695 | - return composite_event_filter( |
2696 | - [this]() -> std::shared_ptr<mir::input::CompositeEventFilter> |
2697 | - { |
2698 | - if (!quit_filter) |
2699 | - quit_filter = std::make_shared<me::QuitFilter>([this] { the_main_loop()->stop(); }); |
2700 | - |
2701 | - auto composite_filter = DefaultServerConfiguration::the_composite_event_filter(); |
2702 | - composite_filter->append(quit_filter); |
2703 | - |
2704 | - return composite_filter; |
2705 | - }); |
2706 | -} |
2707 | |
2708 | === removed file 'playground/server_configuration.h' |
2709 | --- playground/server_configuration.h 2017-07-28 17:00:43 +0000 |
2710 | +++ playground/server_configuration.h 1970-01-01 00:00:00 +0000 |
2711 | @@ -1,49 +0,0 @@ |
2712 | -/* |
2713 | - * Copyright © 2013-2014 Canonical Ltd. |
2714 | - * |
2715 | - * This program is free software: you can redistribute it and/or modify |
2716 | - * it under the terms of the GNU General Public License version 2 or 3 as |
2717 | - * published by the Free Software Foundation. |
2718 | - * |
2719 | - * This program is distributed in the hope that it will be useful, |
2720 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2721 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2722 | - * GNU General Public License for more details. |
2723 | - * |
2724 | - * You should have received a copy of the GNU General Public License |
2725 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2726 | - * |
2727 | - * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
2728 | - */ |
2729 | - |
2730 | -#ifndef MIR_EXAMPLES_SERVER_CONFIGURATION_H_ |
2731 | -#define MIR_EXAMPLES_SERVER_CONFIGURATION_H_ |
2732 | - |
2733 | -#include "mir/default_server_configuration.h" |
2734 | - |
2735 | -namespace mir |
2736 | -{ |
2737 | -namespace options |
2738 | -{ |
2739 | -class DefaultConfiguration; |
2740 | -} |
2741 | - |
2742 | -namespace examples |
2743 | -{ |
2744 | - |
2745 | -class ServerConfiguration : public DefaultServerConfiguration |
2746 | -{ |
2747 | -public: |
2748 | - ServerConfiguration(int argc, char const** argv); |
2749 | - explicit ServerConfiguration(std::shared_ptr<options::DefaultConfiguration> const& configuration_options); |
2750 | - |
2751 | - std::shared_ptr<graphics::DisplayConfigurationPolicy> the_display_configuration_policy() override; |
2752 | - std::shared_ptr<input::CompositeEventFilter> the_composite_event_filter() override; |
2753 | - |
2754 | -private: |
2755 | - std::shared_ptr<input::EventFilter> quit_filter; |
2756 | -}; |
2757 | -} |
2758 | -} |
2759 | - |
2760 | -#endif /* MIR_EXAMPLES_SERVER_CONFIGURATION_H_ */ |
2761 | |
2762 | === removed file 'playground/server_example_display_configuration_policy.cpp' |
2763 | --- playground/server_example_display_configuration_policy.cpp 2017-07-28 17:00:43 +0000 |
2764 | +++ playground/server_example_display_configuration_policy.cpp 1970-01-01 00:00:00 +0000 |
2765 | @@ -1,115 +0,0 @@ |
2766 | -/* |
2767 | - * Copyright © 2014 Canonical Ltd. |
2768 | - * |
2769 | - * This program is free software: you can redistribute it and/or modify it |
2770 | - * under the terms of the GNU General Public License version 2 or 3, |
2771 | - * as published by the Free Software Foundation. |
2772 | - * |
2773 | - * This program is distributed in the hope that it will be useful, |
2774 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2775 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2776 | - * GNU General Public License for more details. |
2777 | - * |
2778 | - * You should have received a copy of the GNU General Public License |
2779 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2780 | - * |
2781 | - * Authored By: Alan Griffiths <alan@octopull.co.uk> |
2782 | - */ |
2783 | - |
2784 | -#include "server_example_display_configuration_policy.h" |
2785 | -#include "mir/graphics/default_display_configuration_policy.h" |
2786 | - |
2787 | -#include "mir/graphics/display_configuration.h" |
2788 | -#include "mir/server.h" |
2789 | -#include "mir/options/option.h" |
2790 | - |
2791 | -#include <algorithm> |
2792 | -#include <unordered_map> |
2793 | -#include <stdexcept> |
2794 | - |
2795 | -namespace geom = mir::geometry; |
2796 | -namespace me = mir::examples; |
2797 | -namespace mg = mir::graphics; |
2798 | - |
2799 | -///\example server_example_display_configuration_policy.cpp |
2800 | -/// Demonstrate custom display configuration policies for "sidebyside" and "single" |
2801 | - |
2802 | -char const* const me::display_config_opt = "display-config"; |
2803 | -char const* const me::display_config_descr = "Display configuration [{clone,sidebyside,single}]"; |
2804 | - |
2805 | -char const* const me::clone_opt_val = "clone"; |
2806 | -char const* const me::sidebyside_opt_val = "sidebyside"; |
2807 | -char const* const me::single_opt_val = "single"; |
2808 | - |
2809 | -char const* const me::display_alpha_opt = "translucent"; |
2810 | -char const* const me::display_alpha_descr = "Select a display mode with alpha[{on,off}]"; |
2811 | - |
2812 | -char const* const me::display_alpha_off = "off"; |
2813 | -char const* const me::display_alpha_on = "on"; |
2814 | - |
2815 | -namespace |
2816 | -{ |
2817 | -bool contains_alpha(MirPixelFormat format) |
2818 | -{ |
2819 | - return (format == mir_pixel_format_abgr_8888 || |
2820 | - format == mir_pixel_format_argb_8888); |
2821 | -} |
2822 | -} |
2823 | - |
2824 | -me::PixelFormatSelector::PixelFormatSelector(std::shared_ptr<DisplayConfigurationPolicy> const& base_policy, |
2825 | - bool with_alpha) |
2826 | - : base_policy{base_policy}, |
2827 | - with_alpha{with_alpha} |
2828 | -{} |
2829 | - |
2830 | -void me::PixelFormatSelector::apply_to(graphics::DisplayConfiguration & conf) |
2831 | -{ |
2832 | - base_policy->apply_to(conf); |
2833 | - conf.for_each_output( |
2834 | - [&](graphics::UserDisplayConfigurationOutput& conf_output) |
2835 | - { |
2836 | - if (!conf_output.connected || !conf_output.used) return; |
2837 | - |
2838 | - auto const& pos = find_if(conf_output.pixel_formats.begin(), |
2839 | - conf_output.pixel_formats.end(), |
2840 | - [&](MirPixelFormat format) -> bool |
2841 | - { |
2842 | - return contains_alpha(format) == with_alpha; |
2843 | - } |
2844 | - ); |
2845 | - |
2846 | - // keep the default settings if nothing was found |
2847 | - if (pos == conf_output.pixel_formats.end()) |
2848 | - return; |
2849 | - |
2850 | - conf_output.current_format = *pos; |
2851 | - }); |
2852 | -} |
2853 | - |
2854 | -void me::add_display_configuration_options_to(mir::Server& server) |
2855 | -{ |
2856 | - // Add choice of monitor configuration |
2857 | - server.add_configuration_option( |
2858 | - me::display_config_opt, me::display_config_descr, me::clone_opt_val); |
2859 | - server.add_configuration_option( |
2860 | - me::display_alpha_opt, me::display_alpha_descr, me::display_alpha_off); |
2861 | - |
2862 | - server.wrap_display_configuration_policy( |
2863 | - [&](std::shared_ptr<mg::DisplayConfigurationPolicy> const& wrapped) |
2864 | - -> std::shared_ptr<mg::DisplayConfigurationPolicy> |
2865 | - { |
2866 | - auto const options = server.get_options(); |
2867 | - auto display_layout = options->get<std::string>(me::display_config_opt); |
2868 | - auto with_alpha = options->get<std::string>(me::display_alpha_opt) == me::display_alpha_on; |
2869 | - |
2870 | - auto layout_selector = wrapped; |
2871 | - |
2872 | - if (display_layout == me::sidebyside_opt_val) |
2873 | - layout_selector = std::make_shared<mg::SideBySideDisplayConfigurationPolicy>(); |
2874 | - else if (display_layout == me::single_opt_val) |
2875 | - layout_selector = std::make_shared<mg::SingleDisplayConfigurationPolicy>(); |
2876 | - |
2877 | - // Whatever the layout select a pixel format with requested alpha |
2878 | - return std::make_shared<me::PixelFormatSelector>(layout_selector, with_alpha); |
2879 | - }); |
2880 | -} |
2881 | |
2882 | === removed file 'playground/server_example_display_configuration_policy.h' |
2883 | --- playground/server_example_display_configuration_policy.h 2017-07-28 17:00:43 +0000 |
2884 | +++ playground/server_example_display_configuration_policy.h 1970-01-01 00:00:00 +0000 |
2885 | @@ -1,62 +0,0 @@ |
2886 | -/* |
2887 | - * Copyright © 2014 Canonical Ltd. |
2888 | - * |
2889 | - * This program is free software: you can redistribute it and/or modify it |
2890 | - * under the terms of the GNU General Public License version 2 or 3, |
2891 | - * as published by the Free Software Foundation. |
2892 | - * |
2893 | - * This program is distributed in the hope that it will be useful, |
2894 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2895 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2896 | - * GNU General Public License for more details. |
2897 | - * |
2898 | - * You should have received a copy of the GNU General Public License |
2899 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2900 | - * |
2901 | - * Authored By: Alan Griffiths <alan@octopull.co.uk> |
2902 | - */ |
2903 | - |
2904 | -#ifndef MIR_EXAMPLE_DISPLAY_CONFIGURATION_POLICY_H_ |
2905 | -#define MIR_EXAMPLE_DISPLAY_CONFIGURATION_POLICY_H_ |
2906 | - |
2907 | -#include "mir/graphics/display_configuration_policy.h" |
2908 | - |
2909 | -#include <memory> |
2910 | - |
2911 | -namespace mir |
2912 | -{ |
2913 | -class Server; |
2914 | - |
2915 | -namespace examples |
2916 | -{ |
2917 | -extern char const* const display_config_opt; |
2918 | -extern char const* const display_config_descr; |
2919 | -extern char const* const clone_opt_val; |
2920 | -extern char const* const sidebyside_opt_val; |
2921 | -extern char const* const single_opt_val; |
2922 | -extern char const* const display_alpha_opt; |
2923 | -extern char const* const display_alpha_descr; |
2924 | -extern char const* const display_alpha_off; |
2925 | -extern char const* const display_alpha_on; |
2926 | - |
2927 | -/** |
2928 | - * \brief Example of a DisplayConfigurationPolicy that tries to find |
2929 | - * an opaque or transparent pixel format, or falls back to the default |
2930 | - * if not found. |
2931 | - */ |
2932 | -class PixelFormatSelector : public graphics::DisplayConfigurationPolicy |
2933 | -{ |
2934 | -public: |
2935 | - PixelFormatSelector(std::shared_ptr<graphics::DisplayConfigurationPolicy> const& base_policy, |
2936 | - bool with_alpha); |
2937 | - virtual void apply_to(graphics::DisplayConfiguration& conf); |
2938 | -private: |
2939 | - std::shared_ptr<graphics::DisplayConfigurationPolicy> const base_policy; |
2940 | - bool const with_alpha; |
2941 | -}; |
2942 | - |
2943 | -void add_display_configuration_options_to(Server& server); |
2944 | -} |
2945 | -} |
2946 | - |
2947 | -#endif /* MIR_EXAMPLE_DISPLAY_CONFIGURATION_POLICY_H_ */ |
2948 | |
2949 | === removed file 'src/include/server/mir/compositor/decoration.h' |
2950 | --- src/include/server/mir/compositor/decoration.h 2017-07-28 17:00:43 +0000 |
2951 | +++ src/include/server/mir/compositor/decoration.h 1970-01-01 00:00:00 +0000 |
2952 | @@ -1,38 +0,0 @@ |
2953 | -/* |
2954 | - * Copyright © 2015 Canonical Ltd. |
2955 | - * |
2956 | - * This program is free software: you can redistribute it and/or modify it |
2957 | - * under the terms of the GNU General Public License version 2 or 3, |
2958 | - * as published by the Free Software Foundation. |
2959 | - * |
2960 | - * This program is distributed in the hope that it will be useful, |
2961 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2962 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2963 | - * GNU General Public License for more details. |
2964 | - * |
2965 | - * You should have received a copy of the GNU General Public License |
2966 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2967 | - * |
2968 | - * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
2969 | - */ |
2970 | - |
2971 | -#ifndef MIR_COMPOSITOR_DECORATION_H_ |
2972 | -#define MIR_COMPOSITOR_DECORATION_H_ |
2973 | - |
2974 | -#include <string> |
2975 | - |
2976 | -namespace mir { namespace compositor { |
2977 | - |
2978 | -struct Decoration |
2979 | -{ |
2980 | - enum class Type {none, surface} type; |
2981 | - std::string name; |
2982 | - |
2983 | - Decoration() : type{Type::none} {} |
2984 | - Decoration(Type t, std::string const& n) : type{t}, name{n} {} |
2985 | - operator bool() const { return type != Type::none; } |
2986 | -}; |
2987 | - |
2988 | -} } // namespace mir::compositor |
2989 | - |
2990 | -#endif // MIR_COMPOSITOR_DECORATION_H_ |
2991 | |
2992 | === modified file 'src/miral/CMakeLists.txt' |
2993 | --- src/miral/CMakeLists.txt 2017-08-30 15:50:37 +0000 |
2994 | +++ src/miral/CMakeLists.txt 2017-08-30 15:50:38 +0000 |
2995 | @@ -1,4 +1,3 @@ |
2996 | -<<<<<<< TREE |
2997 | set(MIRAL_VERSION_MAJOR 1) |
2998 | set(MIRAL_VERSION_MINOR 5) |
2999 | set(MIRAL_VERSION_PATCH 0) |
3000 | @@ -135,146 +134,6 @@ |
3001 | ${miral_include}/miral/version.h |
3002 | ) |
3003 | |
3004 | -install(TARGETS miral LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}") |
3005 | -install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/miral DESTINATION "${INCLUDEDIR}") |
3006 | -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/miral.pc |
3007 | - ${CMAKE_CURRENT_BINARY_DIR}/mirclientcpp.pc DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") |
3008 | -======= |
3009 | -set(MIRAL_VERSION_MAJOR 1) |
3010 | -set(MIRAL_VERSION_MINOR 5) |
3011 | -set(MIRAL_VERSION_PATCH 0) |
3012 | - |
3013 | -if(${CMAKE_COMPILER_IS_GNUCXX}) |
3014 | - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") |
3015 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") |
3016 | - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto") |
3017 | - set(CMAKE_AR "gcc-ar") |
3018 | - set(CMAKE_NM "gcc-nm") |
3019 | - set(CMAKE_RANLIB "gcc-ranlib") |
3020 | -endif() |
3021 | - |
3022 | -include_directories( |
3023 | - ${PROJECT_SOURCE_DIR}/include/platform |
3024 | - ${PROJECT_SOURCE_DIR}/include/client |
3025 | - ${PROJECT_SOURCE_DIR}/include/server |
3026 | -) |
3027 | - |
3028 | -set(MIRAL_ABI 2) |
3029 | -set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map) |
3030 | -set(miral_include ${PROJECT_SOURCE_DIR}/include/miral) |
3031 | - |
3032 | -add_library(mirclientcpp INTERFACE) |
3033 | - |
3034 | -add_library(miral-internal STATIC |
3035 | - basic_window_manager.cpp basic_window_manager.h window_manager_tools_implementation.h |
3036 | - coordinate_translator.cpp coordinate_translator.h |
3037 | - display_configuration_listeners.cpp display_configuration_listeners.h |
3038 | - mru_window_list.cpp mru_window_list.h |
3039 | - window_management_trace.cpp window_management_trace.h |
3040 | - xcursor_loader.cpp xcursor_loader.h |
3041 | - xcursor.c xcursor.h |
3042 | - both_versions.h |
3043 | - join_client_threads.h |
3044 | -) |
3045 | - |
3046 | -set_source_files_properties(xcursor.c PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE) |
3047 | - |
3048 | -add_library(miral SHARED |
3049 | - active_outputs.cpp ${miral_include}/miral/active_outputs.h |
3050 | - add_init_callback.cpp ${miral_include}/miral/add_init_callback.h |
3051 | - application.cpp ${miral_include}/miral/application.h |
3052 | - application_authorizer.cpp ${miral_include}/miral/application_authorizer.h |
3053 | - application_info.cpp ${miral_include}/miral/application_info.h |
3054 | - canonical_window_manager.cpp ${miral_include}/miral/canonical_window_manager.h |
3055 | - command_line_option.cpp ${miral_include}/miral/command_line_option.h |
3056 | - cursor_theme.cpp ${miral_include}/miral/cursor_theme.h |
3057 | - debug_extension.cpp ${miral_include}/miral/debug_extension.h |
3058 | - keymap.cpp ${miral_include}/miral/keymap.h |
3059 | - runner.cpp ${miral_include}/miral/runner.h |
3060 | - display_configuration_option.cpp ${miral_include}/miral/display_configuration_option.h |
3061 | - output.cpp ${miral_include}/miral/output.h |
3062 | - append_event_filter.cpp ${miral_include}/miral/append_event_filter.h |
3063 | - window.cpp ${miral_include}/miral/window.h |
3064 | - window_info.cpp ${miral_include}/miral/window_info.h |
3065 | - window_management_options.cpp ${miral_include}/miral/window_management_options.h |
3066 | - window_specification.cpp ${miral_include}/miral/window_specification.h |
3067 | - internal_client.cpp ${miral_include}/miral/internal_client.h |
3068 | - set_command_line_handler.cpp ${miral_include}/miral/set_command_line_handler.h |
3069 | - set_terminator.cpp ${miral_include}/miral/set_terminator.h |
3070 | - set_window_management_policy.cpp ${miral_include}/miral/set_window_management_policy.h |
3071 | - workspace_policy.cpp ${miral_include}/miral/workspace_policy.h |
3072 | - window_management_policy.cpp ${miral_include}/miral/window_management_policy.h |
3073 | - window_manager_tools.cpp ${miral_include}/miral/window_manager_tools.h |
3074 | - ${miral_include}/miral/window_management_policy_addendum2.h |
3075 | - ${miral_include}/miral/window_management_policy_addendum3.h |
3076 | - ${miral_include}/mir/client/blob.h |
3077 | - ${miral_include}/mir/client/cookie.h |
3078 | - ${miral_include}/mir/client/window_spec.h |
3079 | - ${miral_include}/mir/client/window_id.h |
3080 | - ${miral_include}/mir/client/connection.h |
3081 | - ${miral_include}/mir/client/display_config.h |
3082 | - ${miral_include}/mir/client/window.h |
3083 | -) |
3084 | - |
3085 | -target_include_directories(mirclientcpp |
3086 | - INTERFACE "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS} |
3087 | -) |
3088 | - |
3089 | -target_include_directories(miral-internal |
3090 | - PRIVATE "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS} |
3091 | - PRIVATE ${MIRSERVER_INCLUDE_DIRS} |
3092 | -) |
3093 | - |
3094 | -target_include_directories(miral |
3095 | - PUBLIC "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS} |
3096 | - PRIVATE ${MIRSERVER_INCLUDE_DIRS} |
3097 | -) |
3098 | - |
3099 | -target_link_libraries(miral |
3100 | - PUBLIC |
3101 | - mirclient |
3102 | - mircommon |
3103 | - PRIVATE |
3104 | - miral-internal |
3105 | - mirserver |
3106 | -) |
3107 | - |
3108 | -set_target_properties(miral |
3109 | - PROPERTIES |
3110 | - SOVERSION ${MIRAL_ABI} |
3111 | - LINK_FLAGS "-Wl,--exclude-libs=ALL -Wl,--version-script,${symbol_map}" |
3112 | - LINK_DEPENDS ${symbol_map} |
3113 | -) |
3114 | - |
3115 | -# clang generates slightly different symbols (but we don't care) |
3116 | -if (CMAKE_COMPILER_IS_GNUCXX) |
3117 | - add_custom_target(check-miral-symbols ALL |
3118 | - DEPENDS miral ${PROJECT_SOURCE_DIR}/debian/libmiral${MIRAL_ABI}.symbols |
3119 | - COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/libmiral${MIRAL_ABI}.symbols |
3120 | - COMMAND dpkg-gensymbols -e${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libmiral.so.${MIRAL_ABI} -plibmiral${MIRAL_ABI} -O${CMAKE_CURRENT_BINARY_DIR}/libmiral${MIRAL_ABI}.symbols |
3121 | - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" |
3122 | - VERBATIM |
3123 | - ) |
3124 | -endif() |
3125 | - |
3126 | -set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") |
3127 | -set(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") |
3128 | - |
3129 | -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/miral.pc.in |
3130 | - ${CMAKE_CURRENT_BINARY_DIR}/miral.pc |
3131 | - @ONLY |
3132 | -) |
3133 | - |
3134 | -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mirclientcpp.pc.in |
3135 | - ${CMAKE_CURRENT_BINARY_DIR}/mirclientcpp.pc |
3136 | - @ONLY |
3137 | -) |
3138 | - |
3139 | -configure_file( |
3140 | - ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in |
3141 | - ${miral_include}/miral/version.h |
3142 | -) |
3143 | - |
3144 | if(TARGET doc) |
3145 | add_custom_target(regenerate-miral-symbols-map |
3146 | ${CMAKE_CURRENT_SOURCE_DIR}/process_doxygen_xml.py ${CMAKE_BINARY_DIR}/doc/xml/*.xml > ${symbol_map} |
3147 | @@ -285,4 +144,3 @@ |
3148 | install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/miral DESTINATION "${INCLUDEDIR}") |
3149 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/miral.pc |
3150 | ${CMAKE_CURRENT_BINARY_DIR}/mirclientcpp.pc DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") |
3151 | ->>>>>>> MERGE-SOURCE |
3152 | |
3153 | === modified file 'src/miral/miral.pc.in' |
3154 | --- src/miral/miral.pc.in 2017-08-30 15:50:37 +0000 |
3155 | +++ src/miral/miral.pc.in 2017-08-29 09:17:03 +0000 |
3156 | @@ -1,4 +1,3 @@ |
3157 | -<<<<<<< TREE |
3158 | libdir=@LIBDIR@ |
3159 | includedir=@INCLUDEDIR@/miral |
3160 | |
3161 | @@ -8,14 +7,3 @@ |
3162 | Requires: mirclientcpp |
3163 | Libs: -L${libdir} -lmiral |
3164 | Cflags: -I${includedir} |
3165 | -======= |
3166 | -libdir=@LIBDIR@ |
3167 | -includedir=@INCLUDEDIR@ |
3168 | - |
3169 | -Name: miral |
3170 | -Description: Mir Abstraction Layer library |
3171 | -Version: @MIRAL_VERSION@ |
3172 | -Requires: mirclientcpp |
3173 | -Libs: -L${libdir} -lmiral |
3174 | -Cflags: -I${includedir} |
3175 | ->>>>>>> MERGE-SOURCE |
3176 | |
3177 | === modified file 'src/miral/mirclientcpp.pc.in' |
3178 | --- src/miral/mirclientcpp.pc.in 2017-08-30 15:50:37 +0000 |
3179 | +++ src/miral/mirclientcpp.pc.in 2017-08-29 09:17:03 +0000 |
3180 | @@ -1,4 +1,3 @@ |
3181 | -<<<<<<< TREE |
3182 | includedir=@INCLUDEDIR@/miral |
3183 | |
3184 | Name: mirclientcpp |
3185 | @@ -6,12 +5,3 @@ |
3186 | Version: @MIRAL_VERSION@ |
3187 | Requires: mirclient |
3188 | Cflags: -I${includedir} |
3189 | -======= |
3190 | -includedir=@INCLUDEDIR@ |
3191 | - |
3192 | -Name: mirclientcpp |
3193 | -Description: Mir Abstraction Layer C++ wrapper for mirclient |
3194 | -Version: @MIRAL_VERSION@ |
3195 | -Requires: mirclient |
3196 | -Cflags: -I${includedir} |
3197 | ->>>>>>> MERGE-SOURCE |
3198 | |
3199 | === modified file 'src/server/scene/basic_surface.cpp' |
3200 | --- src/server/scene/basic_surface.cpp 2017-07-28 17:00:43 +0000 |
3201 | +++ src/server/scene/basic_surface.cpp 2017-08-30 15:50:38 +0000 |
3202 | @@ -289,12 +289,6 @@ |
3203 | observers.moved_to(top_left); |
3204 | } |
3205 | |
3206 | -float ms::BasicSurface::alpha() const |
3207 | -{ |
3208 | - std::unique_lock<std::mutex> lk(guard); |
3209 | - return surface_alpha; |
3210 | -} |
3211 | - |
3212 | void ms::BasicSurface::set_hidden(bool hide) |
3213 | { |
3214 | { |
3215 | |
3216 | === modified file 'src/server/scene/basic_surface.h' |
3217 | --- src/server/scene/basic_surface.h 2017-07-28 17:00:43 +0000 |
3218 | +++ src/server/scene/basic_surface.h 2017-08-30 15:50:38 +0000 |
3219 | @@ -79,7 +79,7 @@ |
3220 | |
3221 | std::string name() const override; |
3222 | void move_to(geometry::Point const& top_left) override; |
3223 | - float alpha() const override; |
3224 | + |
3225 | void set_hidden(bool is_hidden); |
3226 | |
3227 | geometry::Size size() const override; |
3228 | |
3229 | === modified file 'src/server/scene/surface_stack.cpp' |
3230 | --- src/server/scene/surface_stack.cpp 2017-07-28 17:00:43 +0000 |
3231 | +++ src/server/scene/surface_stack.cpp 2017-08-30 15:50:38 +0000 |
3232 | @@ -23,7 +23,6 @@ |
3233 | #include "mir/scene/surface.h" |
3234 | #include "mir/scene/scene_report.h" |
3235 | #include "mir/compositor/scene_element.h" |
3236 | -#include "mir/compositor/decoration.h" |
3237 | #include "mir/graphics/renderable.h" |
3238 | |
3239 | #include <boost/throw_exception.hpp> |
3240 | @@ -73,11 +72,6 @@ |
3241 | tracker->occluded_in(cid); |
3242 | } |
3243 | |
3244 | - std::unique_ptr<mc::Decoration> decoration() const override |
3245 | - { |
3246 | - return std::make_unique<mc::Decoration>(mc::Decoration::Type::surface, surface_name); |
3247 | - } |
3248 | - |
3249 | private: |
3250 | std::shared_ptr<mg::Renderable> const renderable_; |
3251 | std::shared_ptr<ms::RenderingTracker> const tracker; |
3252 | @@ -108,11 +102,6 @@ |
3253 | { |
3254 | } |
3255 | |
3256 | - std::unique_ptr<mc::Decoration> decoration() const override |
3257 | - { |
3258 | - return std::make_unique<mc::Decoration>(); |
3259 | - } |
3260 | - |
3261 | private: |
3262 | std::shared_ptr<mg::Renderable> const renderable_; |
3263 | }; |
3264 | |
3265 | === modified file 'tests/include/mir/test/doubles/stub_scene_element.h' |
3266 | --- tests/include/mir/test/doubles/stub_scene_element.h 2017-07-28 17:00:43 +0000 |
3267 | +++ tests/include/mir/test/doubles/stub_scene_element.h 2017-08-30 15:50:38 +0000 |
3268 | @@ -20,7 +20,6 @@ |
3269 | #define MIR_TEST_DOUBLES_STUB_SCENE_ELEMENT_H_ |
3270 | |
3271 | #include "mir/compositor/scene_element.h" |
3272 | -#include "mir/compositor/decoration.h" |
3273 | #include "stub_renderable.h" |
3274 | |
3275 | namespace mir |
3276 | @@ -56,11 +55,6 @@ |
3277 | { |
3278 | } |
3279 | |
3280 | - std::unique_ptr<compositor::Decoration> decoration() const override |
3281 | - { |
3282 | - return nullptr; |
3283 | - } |
3284 | - |
3285 | private: |
3286 | std::shared_ptr<graphics::Renderable> const renderable_; |
3287 | }; |
3288 | |
3289 | === modified file 'tests/include/mir/test/doubles/stub_scene_surface.h' |
3290 | --- tests/include/mir/test/doubles/stub_scene_surface.h 2017-07-28 17:00:43 +0000 |
3291 | +++ tests/include/mir/test/doubles/stub_scene_surface.h 2017-08-30 15:50:38 +0000 |
3292 | @@ -53,7 +53,6 @@ |
3293 | graphics::RenderableList generate_renderables(compositor::CompositorID) const override { return {}; } |
3294 | int buffers_ready_for_compositor(void const*) const override { return 0; } |
3295 | |
3296 | - float alpha() const override { return 0.0f;} |
3297 | MirWindowType type() const override { return mir_window_type_normal; } |
3298 | MirWindowState state() const override { return mir_window_state_unknown; } |
3299 | |
3300 | |
3301 | === modified file 'tests/mir_test_framework/stub_surface.cpp' |
3302 | --- tests/mir_test_framework/stub_surface.cpp 2017-07-28 17:00:43 +0000 |
3303 | +++ tests/mir_test_framework/stub_surface.cpp 2017-08-30 15:50:38 +0000 |
3304 | @@ -29,11 +29,6 @@ |
3305 | { |
3306 | } |
3307 | |
3308 | -float mtd::StubSurface::alpha() const |
3309 | -{ |
3310 | - return 0; |
3311 | -} |
3312 | - |
3313 | mir::geometry::Size mtd::StubSurface::size() const |
3314 | { |
3315 | return {}; |
3316 | |
3317 | === modified file 'tests/unit-tests/CMakeLists.txt' |
3318 | --- tests/unit-tests/CMakeLists.txt 2017-05-08 03:04:26 +0000 |
3319 | +++ tests/unit-tests/CMakeLists.txt 2017-08-30 15:50:38 +0000 |
3320 | @@ -122,7 +122,6 @@ |
3321 | |
3322 | exampleserverconfig |
3323 | mirdraw |
3324 | - demo-shell |
3325 | mircommon |
3326 | client_platform_common |
3327 | server_platform_common |
3328 | @@ -166,7 +165,6 @@ |
3329 | |
3330 | exampleserverconfig |
3331 | mirdraw |
3332 | - demo-shell |
3333 | mircommon |
3334 | client_platform_common |
3335 | |
3336 | |
3337 | === modified file 'tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp' |
3338 | --- tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2017-07-28 17:00:43 +0000 |
3339 | +++ tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2017-08-30 15:50:38 +0000 |
3340 | @@ -18,7 +18,6 @@ |
3341 | |
3342 | #include "src/server/compositor/default_display_buffer_compositor.h" |
3343 | #include "mir/compositor/display_buffer_compositor.h" |
3344 | -#include "mir/compositor/decoration.h" |
3345 | #include "src/server/report/null_report_factory.h" |
3346 | #include "mir/compositor/scene.h" |
3347 | #include "mir/renderer/renderer.h" |
3348 | @@ -74,11 +73,6 @@ |
3349 | { |
3350 | } |
3351 | |
3352 | - std::unique_ptr<mc::Decoration> decoration() const override |
3353 | - { |
3354 | - return nullptr; |
3355 | - } |
3356 | - |
3357 | private: |
3358 | std::shared_ptr<mg::Renderable> const renderable_; |
3359 | }; |
3360 | @@ -346,7 +340,6 @@ |
3361 | } |
3362 | |
3363 | MOCK_CONST_METHOD0(renderable, std::shared_ptr<mir::graphics::Renderable>()); |
3364 | - MOCK_CONST_METHOD0(decoration, std::unique_ptr<mc::Decoration>()); |
3365 | MOCK_METHOD0(rendered, void()); |
3366 | MOCK_METHOD0(occluded, void()); |
3367 | }; |
3368 | |
3369 | === modified file 'tests/unit-tests/scene/test_basic_surface.cpp' |
3370 | --- tests/unit-tests/scene/test_basic_surface.cpp 2017-07-28 17:00:43 +0000 |
3371 | +++ tests/unit-tests/scene/test_basic_surface.cpp 2017-08-30 15:50:38 +0000 |
3372 | @@ -229,24 +229,10 @@ |
3373 | EXPECT_EQ(trans, got); |
3374 | } |
3375 | |
3376 | -TEST_F(BasicSurfaceTest, test_surface_set_alpha_notifies_changes) |
3377 | -{ |
3378 | - using namespace testing; |
3379 | - EXPECT_CALL(mock_callback, call()) |
3380 | - .Times(1); |
3381 | - |
3382 | - surface.add_observer(observer); |
3383 | - |
3384 | - float alpha = 0.5f; |
3385 | - surface.set_alpha(0.5f); |
3386 | - EXPECT_THAT(alpha, FloatEq(surface.alpha())); |
3387 | -} |
3388 | - |
3389 | TEST_F(BasicSurfaceTest, test_surface_is_opaque_by_default) |
3390 | { |
3391 | using namespace testing; |
3392 | |
3393 | - EXPECT_THAT(1.0f, FloatEq(surface.alpha())); |
3394 | auto renderables = surface.generate_renderables(compositor_id); |
3395 | ASSERT_THAT(renderables.size(), testing::Eq(1)); |
3396 | EXPECT_FALSE(renderables[0]->shaped()); |
3397 | |
3398 | === modified file 'tests/unit-tests/scene/test_surface.cpp' |
3399 | --- tests/unit-tests/scene/test_surface.cpp 2017-07-28 17:00:43 +0000 |
3400 | +++ tests/unit-tests/scene/test_surface.cpp 2017-08-30 15:50:38 +0000 |
3401 | @@ -331,27 +331,6 @@ |
3402 | } |
3403 | } |
3404 | |
3405 | -TEST_F(SurfaceCreation, test_surface_set_alpha) |
3406 | -{ |
3407 | - using namespace testing; |
3408 | - |
3409 | - float alpha = 0.5f; |
3410 | - |
3411 | - surface.set_alpha(alpha); |
3412 | - EXPECT_FLOAT_EQ(alpha, surface.alpha()); |
3413 | - auto renderables = surface.generate_renderables(nullptr); |
3414 | - ASSERT_THAT(renderables.size(), Ge(1)); |
3415 | - EXPECT_FLOAT_EQ(alpha, renderables[0]->alpha()); |
3416 | - |
3417 | - alpha = 0.1; |
3418 | - |
3419 | - surface.set_alpha(alpha); |
3420 | - EXPECT_FLOAT_EQ(alpha, surface.alpha()); |
3421 | - renderables = surface.generate_renderables(nullptr); |
3422 | - ASSERT_THAT(renderables.size(), Ge(1)); |
3423 | - EXPECT_FLOAT_EQ(alpha, renderables[0]->alpha()); |
3424 | -} |
3425 | - |
3426 | TEST_F(SurfaceCreation, consume_calls_send_event) |
3427 | { |
3428 | using namespace testing; |
3429 | |
3430 | === modified file 'tests/unit-tests/scene/test_surface_stack.cpp' |
3431 | --- tests/unit-tests/scene/test_surface_stack.cpp 2017-07-28 17:00:43 +0000 |
3432 | +++ tests/unit-tests/scene/test_surface_stack.cpp 2017-08-30 15:50:38 +0000 |
3433 | @@ -22,7 +22,6 @@ |
3434 | #include "mir/scene/observer.h" |
3435 | #include "mir/scene/surface_creation_parameters.h" |
3436 | #include "mir/compositor/scene_element.h" |
3437 | -#include "mir/compositor/decoration.h" |
3438 | #include "src/server/report/null_report_factory.h" |
3439 | #include "src/server/scene/basic_surface.h" |
3440 | #include "src/server/compositor/stream.h" |
3441 | @@ -226,63 +225,6 @@ |
3442 | SceneElementForStream(stub_buffer_stream2))); |
3443 | } |
3444 | |
3445 | -TEST_F(SurfaceStack, decor_name_is_surface_name) |
3446 | -{ |
3447 | - using namespace testing; |
3448 | - |
3449 | - ms::SurfaceStack stack{report}; |
3450 | - auto surface = std::make_shared<ms::BasicSurface>( |
3451 | - std::string("Mary had a little lamb"), |
3452 | - geom::Rectangle{{},{}}, |
3453 | - mir_pointer_unconfined, |
3454 | - std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } }, |
3455 | - std::shared_ptr<mg::CursorImage>(), |
3456 | - report); |
3457 | - stack.add_surface(surface, default_params.input_mode); |
3458 | - surface->configure(mir_window_attrib_visibility, |
3459 | - mir_window_visibility_exposed); |
3460 | - |
3461 | - auto elements = stack.scene_elements_for(compositor_id); |
3462 | - ASSERT_EQ(1, elements.size()); |
3463 | - |
3464 | - auto& element = elements.front(); |
3465 | - |
3466 | - auto decor = element->decoration(); |
3467 | - ASSERT_THAT(decor, Ne(nullptr)); |
3468 | - EXPECT_EQ(mc::Decoration::Type::surface, decor->type); |
3469 | - EXPECT_EQ("Mary had a little lamb", decor->name); |
3470 | -} |
3471 | - |
3472 | -TEST_F(SurfaceStack, gets_surface_renames) |
3473 | -{ |
3474 | - using namespace testing; |
3475 | - |
3476 | - ms::SurfaceStack stack{report}; |
3477 | - auto surface = std::make_shared<ms::BasicSurface>( |
3478 | - std::string("username@hostname: /"), |
3479 | - geom::Rectangle{{},{}}, |
3480 | - mir_pointer_unconfined, |
3481 | - std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } }, |
3482 | - std::shared_ptr<mg::CursorImage>(), |
3483 | - report); |
3484 | - stack.add_surface(surface, default_params.input_mode); |
3485 | - surface->configure(mir_window_attrib_visibility, |
3486 | - mir_window_visibility_exposed); |
3487 | - |
3488 | - // (change directory in shell app) |
3489 | - surface->rename("username@hostname: ~/Documents"); |
3490 | - |
3491 | - auto elements = stack.scene_elements_for(compositor_id); |
3492 | - ASSERT_EQ(1, elements.size()); |
3493 | - |
3494 | - auto& element = elements.front(); |
3495 | - |
3496 | - auto decor = element->decoration(); |
3497 | - ASSERT_THAT(decor, Ne(nullptr)); |
3498 | - EXPECT_EQ(mc::Decoration::Type::surface, decor->type); |
3499 | - EXPECT_EQ("username@hostname: ~/Documents", decor->name); |
3500 | -} |
3501 | - |
3502 | TEST_F(SurfaceStack, scene_counts_pending_accurately) |
3503 | { |
3504 | using namespace testing; |