Merge lp:~alan-griffiths/miral/1.4 into lp:miral/zesty
- 1.4
- Merge into zesty
Proposed by
Alan Griffiths
Status: | Rejected |
---|---|
Rejected by: | Alan Griffiths |
Proposed branch: | lp:~alan-griffiths/miral/1.4 |
Merge into: | lp:miral/zesty |
Diff against target: |
4800 lines (+1757/-1089) 63 files modified
CMakeLists.txt (+18/-23) debian/changelog (+17/-2) debian/control (+4/-9) debian/libmiral2.symbols (+4/-0) doc/introducing_the_miral_api.md (+2/-2) include/mir/client/detail/mir_forward_compatibility.h (+0/-172) include/mir/client/display_config.h (+0/-5) include/mir/client/surface.h (+50/-0) include/mir/client/window.h (+0/-12) include/mir/client/window_id.h (+0/-17) include/mir/client/window_spec.h (+36/-121) include/miral/cursor_theme.h (+2/-2) include/miral/window_management_policy.h (+0/-2) include/miral/window_management_policy_addendum2.h (+70/-0) include/miral/window_manager_tools.h (+12/-0) include/miral/window_specification.h (+0/-2) miral-kiosk/sw_splash.cpp (+29/-7) miral-shell/CMakeLists.txt (+4/-5) miral-shell/decoration_provider.cpp (+72/-47) miral-shell/decoration_provider.h (+7/-1) miral-shell/floating_window_manager.cpp (+23/-23) miral-shell/floating_window_manager.h (+7/-7) miral-shell/miral-app.sh (+1/-1) miral-shell/miral-desktop.sh (+1/-1) miral-shell/miral-run.sh (+1/-1) miral-shell/miral-screencast.sh (+1/-1) miral-shell/miral-xrun.sh (+1/-0) miral-shell/shell_main.cpp (+3/-3) miral-shell/spinner/CMakeLists.txt (+1/-0) miral-shell/spinner/eglapp.cpp (+19/-100) miral-shell/spinner/eglspinner.cpp (+2/-0) miral-shell/spinner/miregl.cpp (+30/-39) miral-shell/spinner/miregl.h (+7/-7) miral/CMakeLists.txt (+53/-55) miral/active_outputs.cpp (+1/-76) miral/basic_window_manager.cpp (+76/-27) miral/basic_window_manager.h (+14/-0) miral/both_versions.h (+2/-7) miral/cursor_theme.cpp (+7/-0) miral/keymap.cpp (+0/-16) miral/mir_features.h.in (+0/-29) miral/mru_window_list.cpp (+0/-1) miral/runner.cpp (+0/-15) miral/set_window_management_policy.cpp (+0/-4) miral/symbols.map (+21/-0) miral/window_management_options.cpp (+1/-5) miral/window_management_trace.cpp (+18/-0) miral/window_management_trace.h (+2/-0) miral/window_manager_tools.cpp (+6/-0) miral/window_manager_tools_implementation.h (+3/-0) miral/window_specification.cpp (+0/-57) scripts/process_doxygen_xml.py (+12/-1) test/CMakeLists.txt (+13/-1) test/active_window.cpp (+76/-62) test/client_mediated_gestures.cpp (+295/-0) test/drag_and_drop.cpp (+653/-0) test/select_active_window.cpp (+0/-2) test/test_server.cpp (+0/-13) test/test_server.h (+0/-1) test/window_id.cpp (+3/-45) test/window_placement_client_api.cpp (+2/-20) test/window_properties.cpp (+23/-12) test/workspaces.cpp (+52/-28) |
To merge this branch: | bzr merge lp:~alan-griffiths/miral/1.4 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+325737@code.launchpad.net |
Commit message
Description of the change
Merge MirAL 1.4 into zesty
To post a comment you must log in.
lp:~alan-griffiths/miral/1.4
updated
- 361. By Alan Griffiths
-
Merge lp:miral for 1.4
Unmerged revisions
- 361. By Alan Griffiths
-
Merge lp:miral for 1.4
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2017-03-24 17:44:48 +0000 | |||
3 | +++ CMakeLists.txt 2017-06-20 16:14:05 +0000 | |||
4 | @@ -1,16 +1,12 @@ | |||
6 | 1 | cmake_minimum_required(VERSION 3.1) | 1 | cmake_minimum_required(VERSION 3.5) |
7 | 2 | cmake_policy(SET CMP0015 NEW) | ||
8 | 3 | cmake_policy(SET CMP0022 NEW) | ||
9 | 4 | |||
10 | 2 | project(miral) | 5 | project(miral) |
11 | 3 | 6 | ||
12 | 4 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
13 | 5 | set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "/usr install prefix" FORCE) | ||
14 | 6 | endif() | ||
15 | 7 | |||
16 | 8 | include (GNUInstallDirs) | 7 | include (GNUInstallDirs) |
17 | 9 | include(CheckCXXCompilerFlag) | 8 | include(CheckCXXCompilerFlag) |
18 | 10 | 9 | ||
19 | 11 | cmake_policy(SET CMP0015 NEW) | ||
20 | 12 | cmake_policy(SET CMP0022 NEW) | ||
21 | 13 | |||
22 | 14 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | 10 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
23 | 15 | 11 | ||
24 | 16 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | 12 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
25 | @@ -36,16 +32,21 @@ | |||
26 | 36 | 32 | ||
27 | 37 | include(FindPkgConfig) | 33 | include(FindPkgConfig) |
28 | 38 | 34 | ||
30 | 39 | pkg_check_modules(MIRCLIENT mirclient>=0.20 REQUIRED) | 35 | pkg_check_modules(MIRCLIENT mirclient>=0.26 REQUIRED) |
31 | 40 | 36 | ||
32 | 41 | include_directories(include SYSTEM ${MIRCLIENT_INCLUDE_DIRS}) | 37 | include_directories(include SYSTEM ${MIRCLIENT_INCLUDE_DIRS}) |
33 | 42 | 38 | ||
34 | 43 | set(MIRAL_VERSION_MAJOR 1) | 39 | set(MIRAL_VERSION_MAJOR 1) |
37 | 44 | set(MIRAL_VERSION_MINOR 3) | 40 | set(MIRAL_VERSION_MINOR 4) |
38 | 45 | set(MIRAL_VERSION_PATCH 2) | 41 | set(MIRAL_VERSION_PATCH 0) |
39 | 46 | 42 | ||
40 | 47 | set(MIRAL_VERSION ${MIRAL_VERSION_MAJOR}.${MIRAL_VERSION_MINOR}.${MIRAL_VERSION_PATCH}) | 43 | set(MIRAL_VERSION ${MIRAL_VERSION_MAJOR}.${MIRAL_VERSION_MINOR}.${MIRAL_VERSION_PATCH}) |
41 | 48 | 44 | ||
42 | 45 | if (MIRCLIENT_VERSION VERSION_LESS 0.26.3) | ||
43 | 46 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") | ||
44 | 47 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") | ||
45 | 48 | endif() | ||
46 | 49 | |||
47 | 49 | add_subdirectory(miral) | 50 | add_subdirectory(miral) |
48 | 50 | add_subdirectory(miral-shell) | 51 | add_subdirectory(miral-shell) |
49 | 51 | add_subdirectory(miral-kiosk) | 52 | add_subdirectory(miral-kiosk) |
50 | @@ -54,19 +55,13 @@ | |||
51 | 54 | if(NOT MIRTEST_FOUND) | 55 | if(NOT MIRTEST_FOUND) |
52 | 55 | message(WARNING "mirtest-dev package not installed - tests cannot be built") | 56 | message(WARNING "mirtest-dev package not installed - tests cannot be built") |
53 | 56 | else() | 57 | else() |
60 | 57 | if (MIRTEST_VERSION VERSION_LESS 0.24) | 58 | option(MIRAL_ENABLE_TESTS "Build tests" on) |
61 | 58 | # building the tests is disabled by default because the mirtest-dev package is broken on xenial | 59 | |
62 | 59 | # (lp:1583536 and lp:1603080) | 60 | if (MIRAL_ENABLE_TESTS) |
63 | 60 | option(MIRAL_ENABLE_TESTS "Build tests" off) | 61 | enable_testing() |
64 | 61 | else() | 62 | find_package(GMock REQUIRED) |
65 | 62 | option(MIRAL_ENABLE_TESTS "Build tests" on) | 63 | add_subdirectory(test) |
66 | 63 | endif() | 64 | endif() |
67 | 64 | |||
68 | 65 | if (MIRAL_ENABLE_TESTS) | ||
69 | 66 | enable_testing() | ||
70 | 67 | find_package(GMock REQUIRED) | ||
71 | 68 | add_subdirectory(test) | ||
72 | 69 | endif() | ||
73 | 70 | endif() | 65 | endif() |
74 | 71 | 66 | ||
75 | 72 | include (cmake/Doxygen.cmake) | 67 | include (cmake/Doxygen.cmake) |
76 | 73 | 68 | ||
77 | === modified file 'debian/changelog' | |||
78 | --- debian/changelog 2017-03-30 14:18:38 +0000 | |||
79 | +++ debian/changelog 2017-06-20 16:14:05 +0000 | |||
80 | @@ -1,3 +1,18 @@ | |||
81 | 1 | miral (1.4.0) UNRELEASED; urgency=medium | ||
82 | 2 | |||
83 | 3 | * New upstream release 1.4.0 (https://launchpad.net/miral/+milestone/1.4.0) | ||
84 | 4 | - ABI summary: | ||
85 | 5 | . miral ABI unchanged at 2 | ||
86 | 6 | - Enhancements: | ||
87 | 7 | . Support for passing messages to enable Drag & Drop | ||
88 | 8 | . Support for client requested move | ||
89 | 9 | . Port to the undeprecated Mir APIs | ||
90 | 10 | . Added "--cursor-theme" option when configuring a cursor theme | ||
91 | 11 | . Drop support for Mir versions before 0.26 | ||
92 | 12 | - Bugs fixed: | ||
93 | 13 | |||
94 | 14 | -- Alan Griffiths <alan.griffiths@canonical.com> Tue, 21 Mar 2017 17:57:20 +0000 | ||
95 | 15 | |||
96 | 1 | miral (1.3.2+17.04.20170330.5-0ubuntu1) zesty; urgency=medium | 16 | miral (1.3.2+17.04.20170330.5-0ubuntu1) zesty; urgency=medium |
97 | 2 | 17 | ||
98 | 3 | * New upstream release 1.3.2 (https://launchpad.net/miral/+milestone/1.3.2) | 18 | * New upstream release 1.3.2 (https://launchpad.net/miral/+milestone/1.3.2) |
99 | @@ -74,11 +89,11 @@ | |||
100 | 74 | . Chrome-less shell hint does not work any more (LP: #1658117) | 89 | . Chrome-less shell hint does not work any more (LP: #1658117) |
101 | 75 | . WindowSpec::set_state() wrapper for mir_window_spec_set_state() | 90 | . WindowSpec::set_state() wrapper for mir_window_spec_set_state() |
102 | 76 | (LP: #1661256) | 91 | (LP: #1661256) |
104 | 77 | . "$ miral-app -kiosk" fails with "Unknown command line options: | 92 | . "$ miral-app -kiosk" fails with "Unknown command line options: |
105 | 78 | --desktop_file_hint=miral-shell.desktop" (LP: #1660933) | 93 | --desktop_file_hint=miral-shell.desktop" (LP: #1660933) |
106 | 79 | . libmiral] Fix focus and movement rules for Input Method and Satellite | 94 | . libmiral] Fix focus and movement rules for Input Method and Satellite |
107 | 80 | windows. (LP: #1660691) | 95 | windows. (LP: #1660691) |
109 | 81 | 96 | ||
110 | 82 | 97 | ||
111 | 83 | -- Alan Griffiths <alan.griffiths@canonical.com> Wed, 15 Feb 2017 14:05:46 +0000 | 98 | -- Alan Griffiths <alan.griffiths@canonical.com> Wed, 15 Feb 2017 14:05:46 +0000 |
112 | 84 | 99 | ||
113 | 85 | 100 | ||
114 | === modified file 'debian/control' | |||
115 | --- debian/control 2017-02-16 11:13:26 +0000 | |||
116 | +++ debian/control 2017-06-20 16:14:05 +0000 | |||
117 | @@ -14,18 +14,13 @@ | |||
118 | 14 | python-pil, | 14 | python-pil, |
119 | 15 | google-mock (>= 1.6.0+svn437), | 15 | google-mock (>= 1.6.0+svn437), |
120 | 16 | python3:any, | 16 | python3:any, |
124 | 17 | libmirserver-dev, | 17 | libmirserver-dev (>= 0.26), |
125 | 18 | libmirclient-dev, | 18 | libmirclient-dev (>= 0.26), |
126 | 19 | mirtest-dev, | 19 | mirtest-dev (>= 0.26), |
127 | 20 | mir-test-tools (>= 0.26), | ||
128 | 20 | libglib2.0-dev, | 21 | libglib2.0-dev, |
129 | 21 | libgles2-mesa-dev, | 22 | libgles2-mesa-dev, |
130 | 22 | libfreetype6-dev, | 23 | libfreetype6-dev, |
131 | 23 | # The following workaround missing dependencies in Mir packages | ||
132 | 24 | uuid-dev, | ||
133 | 25 | libboost-system-dev, | ||
134 | 26 | libboost-filesystem-dev, | ||
135 | 27 | mir-test-tools, | ||
136 | 28 | mir-renderer-gl-dev, | ||
137 | 29 | Standards-Version: 3.9.8 | 24 | Standards-Version: 3.9.8 |
138 | 30 | Homepage: https://launchpad.net/miral | 25 | Homepage: https://launchpad.net/miral |
139 | 31 | # If you aren't a member of ~mir-team but need to upload packaging changes, | 26 | # If you aren't a member of ~mir-team but need to upload packaging changes, |
140 | 32 | 27 | ||
141 | === modified file 'debian/libmiral2.symbols' | |||
142 | --- debian/libmiral2.symbols 2017-03-15 17:44:36 +0000 | |||
143 | +++ debian/libmiral2.symbols 2017-06-20 16:14:05 +0000 | |||
144 | @@ -389,3 +389,7 @@ | |||
145 | 389 | (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1 | 389 | (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1 |
146 | 390 | (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1 | 390 | (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1 |
147 | 391 | (c++)"miral::SetWindowManagementPolicy::operator()(mir::Server&) const@MIRAL_1.3.1" 1.3.1 | 391 | (c++)"miral::SetWindowManagementPolicy::operator()(mir::Server&) const@MIRAL_1.3.1" 1.3.1 |
148 | 392 | MIRAL_1.4.0@MIRAL_1.4.0 1.4.0 | ||
149 | 393 | (c++)"miral::WindowManagerTools::end_drag_and_drop()@MIRAL_1.4.0" 1.4.0 | ||
150 | 394 | (c++)"miral::WindowManagerTools::start_drag_and_drop(miral::WindowInfo&, std::vector<unsigned char, std::allocator<unsigned char> > const&)@MIRAL_1.4.0" 1.4.0 | ||
151 | 395 | (c++)"typeinfo for miral::WindowManagementPolicyAddendum2@MIRAL_1.4.0" 1.4.0 | ||
152 | 392 | 396 | ||
153 | === removed directory 'debian/tmp' | |||
154 | === modified file 'doc/introducing_the_miral_api.md' | |||
155 | --- doc/introducing_the_miral_api.md 2016-08-02 13:25:18 +0000 | |||
156 | +++ doc/introducing_the_miral_api.md 2017-06-20 16:14:05 +0000 | |||
157 | @@ -8,14 +8,14 @@ | |||
158 | 8 | 8 | ||
159 | 9 | \include shell_main.cpp | 9 | \include shell_main.cpp |
160 | 10 | 10 | ||
162 | 11 | This shell is providing TitlebarWindowManagerPolicy, TilingWindowManagerPolicy | 11 | This shell is providing FloatingWindowManagerPolicy, TilingWindowManagerPolicy |
163 | 12 | and SpinnerSplash. The rest is from MirAL. | 12 | and SpinnerSplash. The rest is from MirAL. |
164 | 13 | 13 | ||
165 | 14 | If you look for the corresponding code in lp:qtmir and lp:mir you’ll find it | 14 | If you look for the corresponding code in lp:qtmir and lp:mir you’ll find it |
166 | 15 | less clear, more verbose and scattered over multiple files. | 15 | less clear, more verbose and scattered over multiple files. |
167 | 16 | 16 | ||
168 | 17 | A shell has to provide a window management policy (miral-shell provides two: | 17 | A shell has to provide a window management policy (miral-shell provides two: |
170 | 18 | TitlebarWindowManagerPolicy and TilingWindowManagerPolicy). A window management | 18 | FloatingWindowManagerPolicy and TilingWindowManagerPolicy). A window management |
171 | 19 | policy needs to implement the \ref miral::WindowManagementPolicy interface for | 19 | policy needs to implement the \ref miral::WindowManagementPolicy interface for |
172 | 20 | handling a set of window management events. | 20 | handling a set of window management events. |
173 | 21 | 21 | ||
174 | 22 | 22 | ||
175 | === removed file 'include/mir/client/detail/mir_forward_compatibility.h' | |||
176 | --- include/mir/client/detail/mir_forward_compatibility.h 2017-02-14 13:50:07 +0000 | |||
177 | +++ include/mir/client/detail/mir_forward_compatibility.h 1970-01-01 00:00:00 +0000 | |||
178 | @@ -1,172 +0,0 @@ | |||
179 | 1 | /* | ||
180 | 2 | * Copyright © 2016 Canonical Ltd. | ||
181 | 3 | * | ||
182 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
183 | 5 | * under the terms of the GNU General Public License version 3, | ||
184 | 6 | * as published by the Free Software Foundation. | ||
185 | 7 | * | ||
186 | 8 | * This program is distributed in the hope that it will be useful, | ||
187 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
188 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
189 | 11 | * GNU General Public License for more details. | ||
190 | 12 | * | ||
191 | 13 | * You should have received a copy of the GNU General Public License | ||
192 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
193 | 15 | * | ||
194 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
195 | 17 | */ | ||
196 | 18 | |||
197 | 19 | #ifndef MIRAL_MIR_FORWARD_COMPATIBILITY_H | ||
198 | 20 | #define MIRAL_MIR_FORWARD_COMPATIBILITY_H | ||
199 | 21 | |||
200 | 22 | #include <mir_toolkit/version.h> | ||
201 | 23 | #include <mir_toolkit/common.h> | ||
202 | 24 | #include <mir/client/detail/mir_features.h> | ||
203 | 25 | |||
204 | 26 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
205 | 27 | using MirWindowAttrib = MirSurfaceAttrib; | ||
206 | 28 | auto const mir_window_attrib_type = mir_surface_attrib_type; | ||
207 | 29 | auto const mir_window_attrib_state = mir_surface_attrib_state; | ||
208 | 30 | auto const mir_window_attrib_swapinterval = mir_surface_attrib_swapinterval; | ||
209 | 31 | auto const mir_window_attrib_focus = mir_surface_attrib_focus; | ||
210 | 32 | auto const mir_window_attrib_dpi = mir_surface_attrib_dpi; | ||
211 | 33 | auto const mir_window_attrib_visibility = mir_surface_attrib_visibility; | ||
212 | 34 | auto const mir_window_attrib_preferred_orientation = mir_surface_attrib_preferred_orientation; | ||
213 | 35 | auto const mir_window_attribs = mir_surface_attribs; | ||
214 | 36 | |||
215 | 37 | using MirWindowType = MirSurfaceType; | ||
216 | 38 | auto const mir_window_type_normal = mir_surface_type_normal; | ||
217 | 39 | auto const mir_window_type_utility = mir_surface_type_utility; | ||
218 | 40 | auto const mir_window_type_dialog = mir_surface_type_dialog; | ||
219 | 41 | auto const mir_window_type_gloss = mir_surface_type_gloss; | ||
220 | 42 | auto const mir_window_type_freestyle = mir_surface_type_freestyle; | ||
221 | 43 | auto const mir_window_type_menu = mir_surface_type_menu; | ||
222 | 44 | auto const mir_window_type_inputmethod = mir_surface_type_inputmethod; | ||
223 | 45 | auto const mir_window_type_satellite = mir_surface_type_satellite; | ||
224 | 46 | auto const mir_window_type_tip = mir_surface_type_tip; | ||
225 | 47 | auto const mir_window_types = mir_surface_types; | ||
226 | 48 | |||
227 | 49 | using MirWindowState = MirSurfaceState; | ||
228 | 50 | auto const mir_window_state_unknown = mir_surface_state_unknown; | ||
229 | 51 | auto const mir_window_state_restored = mir_surface_state_restored; | ||
230 | 52 | auto const mir_window_state_minimized = mir_surface_state_minimized; | ||
231 | 53 | auto const mir_window_state_maximized = mir_surface_state_maximized; | ||
232 | 54 | auto const mir_window_state_vertmaximized = mir_surface_state_vertmaximized; | ||
233 | 55 | auto const mir_window_state_fullscreen = mir_surface_state_fullscreen; | ||
234 | 56 | auto const mir_window_state_horizmaximized = mir_surface_state_horizmaximized; | ||
235 | 57 | auto const mir_window_state_hidden = mir_surface_state_hidden; | ||
236 | 58 | auto const mir_window_states = mir_surface_states; | ||
237 | 59 | |||
238 | 60 | typedef struct MirSurface MirWindow; | ||
239 | 61 | typedef struct MirSurfaceParameters MirWindowParameters; | ||
240 | 62 | typedef struct MirSurfacePlacementEvent MirWindowPlacementEvent; | ||
241 | 63 | typedef struct MirSurfaceSpec MirWindowSpec; | ||
242 | 64 | #endif | ||
243 | 65 | |||
244 | 66 | |||
245 | 67 | // Types that don't exist in earlier versions of Mir's client | ||
246 | 68 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 4, 0) | ||
247 | 69 | |||
248 | 70 | // Inspired by GdkGravity | ||
249 | 71 | /** | ||
250 | 72 | * Reference point for aligning a surface relative to a rectangle. | ||
251 | 73 | * Each element (surface and rectangle) has a MirPlacementGravity assigned. | ||
252 | 74 | */ | ||
253 | 75 | typedef enum MirPlacementGravity | ||
254 | 76 | { | ||
255 | 77 | /// the reference point is at the center. | ||
256 | 78 | mir_placement_gravity_center = 0, | ||
257 | 79 | |||
258 | 80 | /// the reference point is at the middle of the left edge. | ||
259 | 81 | mir_placement_gravity_west = 1 << 0, | ||
260 | 82 | |||
261 | 83 | /// the reference point is at the middle of the right edge. | ||
262 | 84 | mir_placement_gravity_east = 1 << 1, | ||
263 | 85 | |||
264 | 86 | /// the reference point is in the middle of the top edge. | ||
265 | 87 | mir_placement_gravity_north = 1 << 2, | ||
266 | 88 | |||
267 | 89 | /// the reference point is at the middle of the lower edge. | ||
268 | 90 | mir_placement_gravity_south = 1 << 3, | ||
269 | 91 | |||
270 | 92 | /// the reference point is at the top left corner. | ||
271 | 93 | mir_placement_gravity_northwest = mir_placement_gravity_north | mir_placement_gravity_west, | ||
272 | 94 | |||
273 | 95 | /// the reference point is at the top right corner. | ||
274 | 96 | mir_placement_gravity_northeast = mir_placement_gravity_north | mir_placement_gravity_east, | ||
275 | 97 | |||
276 | 98 | /// the reference point is at the lower left corner. | ||
277 | 99 | mir_placement_gravity_southwest = mir_placement_gravity_south | mir_placement_gravity_west, | ||
278 | 100 | |||
279 | 101 | /// the reference point is at the lower right corner. | ||
280 | 102 | mir_placement_gravity_southeast = mir_placement_gravity_south | mir_placement_gravity_east | ||
281 | 103 | } MirPlacementGravity; | ||
282 | 104 | |||
283 | 105 | // Inspired by GdkAnchorHints | ||
284 | 106 | /** | ||
285 | 107 | * Positioning hints for aligning a window relative to a rectangle. | ||
286 | 108 | * | ||
287 | 109 | * These hints determine how the window should be positioned in the case that | ||
288 | 110 | * the surface would fall off-screen if placed in its ideal position. | ||
289 | 111 | * | ||
290 | 112 | * For example, \p mir_placement_hints_flip_x will invert the x component of | ||
291 | 113 | * \p aux_rect_placement_offset and replace \p mir_placement_gravity_northwest | ||
292 | 114 | * with \p mir_placement_gravity_northeast and vice versa if the window extends | ||
293 | 115 | * beyond the left or right edges of the monitor. | ||
294 | 116 | * | ||
295 | 117 | * If \p mir_placement_hints_slide_x is set, the window can be shifted | ||
296 | 118 | * horizontally to fit on-screen. | ||
297 | 119 | * | ||
298 | 120 | * If \p mir_placement_hints_resize_x is set, the window can be shrunken | ||
299 | 121 | * horizontally to fit. | ||
300 | 122 | * | ||
301 | 123 | * If \p mir_placement_hints_antipodes is set then the rect gravity may be | ||
302 | 124 | * substituted with the opposite corner (e.g. \p mir_placement_gravity_northeast | ||
303 | 125 | * to \p mir_placement_gravity_southwest) in combination with other options. | ||
304 | 126 | * | ||
305 | 127 | * When multiple flags are set, flipping should take precedence over sliding, | ||
306 | 128 | * which should take precedence over resizing. | ||
307 | 129 | */ | ||
308 | 130 | typedef enum MirPlacementHints | ||
309 | 131 | { | ||
310 | 132 | /// allow flipping anchors horizontally | ||
311 | 133 | mir_placement_hints_flip_x = 1 << 0, | ||
312 | 134 | |||
313 | 135 | /// allow flipping anchors vertically | ||
314 | 136 | mir_placement_hints_flip_y = 1 << 1, | ||
315 | 137 | |||
316 | 138 | /// allow sliding window horizontally | ||
317 | 139 | mir_placement_hints_slide_x = 1 << 2, | ||
318 | 140 | |||
319 | 141 | /// allow sliding window vertically | ||
320 | 142 | mir_placement_hints_slide_y = 1 << 3, | ||
321 | 143 | |||
322 | 144 | /// allow resizing window horizontally | ||
323 | 145 | mir_placement_hints_resize_x = 1 << 4, | ||
324 | 146 | |||
325 | 147 | /// allow resizing window vertically | ||
326 | 148 | mir_placement_hints_resize_y = 1 << 5, | ||
327 | 149 | |||
328 | 150 | /// allow flipping aux_anchor to opposite corner | ||
329 | 151 | mir_placement_hints_antipodes= 1 << 6, | ||
330 | 152 | |||
331 | 153 | /// allow flipping anchors on both axes | ||
332 | 154 | mir_placement_hints_flip_any = mir_placement_hints_flip_x|mir_placement_hints_flip_y, | ||
333 | 155 | |||
334 | 156 | /// allow sliding window on both axes | ||
335 | 157 | mir_placement_hints_slide_any = mir_placement_hints_slide_x|mir_placement_hints_slide_y, | ||
336 | 158 | |||
337 | 159 | /// allow resizing window on both axes | ||
338 | 160 | mir_placement_hints_resize_any = mir_placement_hints_resize_x|mir_placement_hints_resize_y, | ||
339 | 161 | } MirPlacementHints; | ||
340 | 162 | #endif | ||
341 | 163 | |||
342 | 164 | #if !MIRAL_MIR_DEFINES_POINTER_CONFINEMENT | ||
343 | 165 | typedef enum MirPointerConfinementState | ||
344 | 166 | { | ||
345 | 167 | mir_pointer_unconfined, | ||
346 | 168 | mir_pointer_confined_to_surface, | ||
347 | 169 | } MirPointerConfinementState; | ||
348 | 170 | #endif | ||
349 | 171 | |||
350 | 172 | #endif //MIRAL_MIR_FORWARD_COMPATIBILITY_H | ||
351 | 173 | 0 | ||
352 | === modified file 'include/mir/client/display_config.h' | |||
353 | --- include/mir/client/display_config.h 2017-02-22 12:45:01 +0000 | |||
354 | +++ include/mir/client/display_config.h 2017-06-20 16:14:05 +0000 | |||
355 | @@ -21,7 +21,6 @@ | |||
356 | 21 | 21 | ||
357 | 22 | #include <mir_toolkit/mir_connection.h> | 22 | #include <mir_toolkit/mir_connection.h> |
358 | 23 | #include <mir_toolkit/mir_display_configuration.h> | 23 | #include <mir_toolkit/mir_display_configuration.h> |
359 | 24 | #include <mir/client/detail/mir_features.h> | ||
360 | 25 | 24 | ||
361 | 26 | #include <functional> | 25 | #include <functional> |
362 | 27 | #include <memory> | 26 | #include <memory> |
363 | @@ -57,9 +56,6 @@ | |||
364 | 57 | enumerator(mir_display_config_get_output(*this, i)); | 56 | enumerator(mir_display_config_get_output(*this, i)); |
365 | 58 | } | 57 | } |
366 | 59 | 58 | ||
367 | 60 | #if MIR_DEFINES_DISPLAY_CONFIG_GET_MUTABLE_OUTPUT | ||
368 | 61 | // Is it worthwhile to emulate this functionality for Mir 0.21? | ||
369 | 62 | // Too many API gaps I think. | ||
370 | 63 | void for_each_output(std::function<void(MirOutput*)> const& enumerator) | 59 | void for_each_output(std::function<void(MirOutput*)> const& enumerator) |
371 | 64 | { | 60 | { |
372 | 65 | auto const count = mir_display_config_get_num_outputs(*this); | 61 | auto const count = mir_display_config_get_num_outputs(*this); |
373 | @@ -67,7 +63,6 @@ | |||
374 | 67 | for (int i = 0; i != count; ++i) | 63 | for (int i = 0; i != count; ++i) |
375 | 68 | enumerator(mir_display_config_get_mutable_output(*this, i)); | 64 | enumerator(mir_display_config_get_mutable_output(*this, i)); |
376 | 69 | } | 65 | } |
377 | 70 | #endif | ||
378 | 71 | 66 | ||
379 | 72 | private: | 67 | private: |
380 | 73 | static void deleter(MirDisplayConfig* config) { mir_display_config_release(config); } | 68 | static void deleter(MirDisplayConfig* config) { mir_display_config_release(config); } |
381 | 74 | 69 | ||
382 | === added file 'include/mir/client/surface.h' | |||
383 | --- include/mir/client/surface.h 1970-01-01 00:00:00 +0000 | |||
384 | +++ include/mir/client/surface.h 2017-06-20 16:14:05 +0000 | |||
385 | @@ -0,0 +1,50 @@ | |||
386 | 1 | /* | ||
387 | 2 | * Copyright © 2017 Canonical Ltd. | ||
388 | 3 | * | ||
389 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
390 | 5 | * under the terms of the GNU General Public License version 3, | ||
391 | 6 | * as published by the Free Software Foundation. | ||
392 | 7 | * | ||
393 | 8 | * This program is distributed in the hope that it will be useful, | ||
394 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
395 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
396 | 11 | * GNU General Public License for more details. | ||
397 | 12 | * | ||
398 | 13 | * You should have received a copy of the GNU General Public License | ||
399 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
400 | 15 | * | ||
401 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
402 | 17 | */ | ||
403 | 18 | |||
404 | 19 | #ifndef MIRAL_SURFACE_H | ||
405 | 20 | #define MIRAL_SURFACE_H | ||
406 | 21 | |||
407 | 22 | #include <mir_toolkit/rs/mir_render_surface.h> | ||
408 | 23 | |||
409 | 24 | #include <memory> | ||
410 | 25 | |||
411 | 26 | namespace mir | ||
412 | 27 | { | ||
413 | 28 | namespace client | ||
414 | 29 | { | ||
415 | 30 | /// Handle class for MirRenderSurface - provides automatic reference counting. | ||
416 | 31 | class Surface | ||
417 | 32 | { | ||
418 | 33 | public: | ||
419 | 34 | Surface() = default; | ||
420 | 35 | explicit Surface(MirRenderSurface* spec) : self{spec, &mir_render_surface_release} {} | ||
421 | 36 | |||
422 | 37 | operator MirRenderSurface*() const { return self.get(); } | ||
423 | 38 | |||
424 | 39 | void reset() { self.reset(); } | ||
425 | 40 | |||
426 | 41 | private: | ||
427 | 42 | std::shared_ptr<MirRenderSurface> self; | ||
428 | 43 | }; | ||
429 | 44 | |||
430 | 45 | // Provide a deleted overload to avoid double release "accidents". | ||
431 | 46 | void mir_render_surface_release(Surface const& surface) = delete; | ||
432 | 47 | } | ||
433 | 48 | } | ||
434 | 49 | |||
435 | 50 | #endif //MIRAL_SURFACE_H | ||
436 | 0 | 51 | ||
437 | === modified file 'include/mir/client/window.h' | |||
438 | --- include/mir/client/window.h 2017-02-22 12:45:01 +0000 | |||
439 | +++ include/mir/client/window.h 2017-06-20 16:14:05 +0000 | |||
440 | @@ -19,19 +19,7 @@ | |||
441 | 19 | #ifndef MIR_CLIENT_WINDOW_H | 19 | #ifndef MIR_CLIENT_WINDOW_H |
442 | 20 | #define MIR_CLIENT_WINDOW_H | 20 | #define MIR_CLIENT_WINDOW_H |
443 | 21 | 21 | ||
444 | 22 | #include <mir/client/detail/mir_forward_compatibility.h> | ||
445 | 23 | |||
446 | 24 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
447 | 25 | #include <mir_toolkit/mir_surface.h> | ||
448 | 26 | auto const mir_window_release_sync = mir_surface_release_sync; | ||
449 | 27 | auto const mir_window_release = mir_surface_release; | ||
450 | 28 | auto const mir_window_get_buffer_stream = mir_surface_get_buffer_stream; | ||
451 | 29 | auto const mir_window_is_valid = mir_surface_is_valid; | ||
452 | 30 | auto const mir_window_get_error_message = mir_surface_get_error_message; | ||
453 | 31 | auto const mir_window_set_state = mir_surface_set_state; | ||
454 | 32 | #else | ||
455 | 33 | #include <mir_toolkit/mir_window.h> | 22 | #include <mir_toolkit/mir_window.h> |
456 | 34 | #endif | ||
457 | 35 | 23 | ||
458 | 36 | #include <memory> | 24 | #include <memory> |
459 | 37 | 25 | ||
460 | 38 | 26 | ||
461 | === modified file 'include/mir/client/window_id.h' | |||
462 | --- include/mir/client/window_id.h 2017-02-24 10:36:29 +0000 | |||
463 | +++ include/mir/client/window_id.h 2017-06-20 16:14:05 +0000 | |||
464 | @@ -19,25 +19,8 @@ | |||
465 | 19 | #ifndef MIR_CLIENT_WINDOW_ID_H | 19 | #ifndef MIR_CLIENT_WINDOW_ID_H |
466 | 20 | #define MIR_CLIENT_WINDOW_ID_H | 20 | #define MIR_CLIENT_WINDOW_ID_H |
467 | 21 | 21 | ||
468 | 22 | #include <mir/client/detail/mir_forward_compatibility.h> | ||
469 | 23 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
470 | 24 | #include <mir_toolkit/mir_surface.h> | ||
471 | 25 | auto const mir_window_request_window_id_sync = mir_surface_request_persistent_id_sync; | ||
472 | 26 | #else | ||
473 | 27 | #include <mir_toolkit/mir_window.h> | 22 | #include <mir_toolkit/mir_window.h> |
474 | 28 | #endif | ||
475 | 29 | |||
476 | 30 | #if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 26, 1) | ||
477 | 31 | #if MIR_CLIENT_VERSION == MIR_VERSION_NUMBER(3, 5, 0) | ||
478 | 32 | #include <mir_toolkit/mir_persistent_id.h> | ||
479 | 33 | auto const mir_window_request_window_id_sync = mir_window_request_persistent_id_sync; | ||
480 | 34 | #endif | ||
481 | 35 | auto const mir_window_id_as_string = mir_persistent_id_as_string; | ||
482 | 36 | auto const mir_window_id_release = mir_persistent_id_release; | ||
483 | 37 | typedef struct MirPersistentId MirWindowId; | ||
484 | 38 | #else | ||
485 | 39 | #include <mir_toolkit/mir_window_id.h> | 23 | #include <mir_toolkit/mir_window_id.h> |
486 | 40 | #endif | ||
487 | 41 | 24 | ||
488 | 42 | #include <memory> | 25 | #include <memory> |
489 | 43 | 26 | ||
490 | 44 | 27 | ||
491 | === modified file 'include/mir/client/window_spec.h' | |||
492 | --- include/mir/client/window_spec.h 2017-03-03 12:31:47 +0000 | |||
493 | +++ include/mir/client/window_spec.h 2017-06-20 16:14:05 +0000 | |||
494 | @@ -20,50 +20,14 @@ | |||
495 | 20 | #define MIR_CLIENT_WINDOW_SPEC_H | 20 | #define MIR_CLIENT_WINDOW_SPEC_H |
496 | 21 | 21 | ||
497 | 22 | #include <mir/client/window.h> | 22 | #include <mir/client/window.h> |
498 | 23 | #include <mir/client/detail/mir_forward_compatibility.h> | ||
499 | 24 | 23 | ||
500 | 25 | #include <mir_toolkit/mir_connection.h> | 24 | #include <mir_toolkit/mir_connection.h> |
501 | 26 | |||
502 | 27 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
503 | 28 | #include <mir_toolkit/mir_surface.h> | ||
504 | 29 | #else | ||
505 | 30 | #include <mir_toolkit/mir_window.h> | 25 | #include <mir_toolkit/mir_window.h> |
507 | 31 | #endif | 26 | #include <mir_toolkit/version.h> |
508 | 27 | #include <mir_toolkit/rs/mir_render_surface.h> | ||
509 | 32 | 28 | ||
510 | 33 | #include <memory> | 29 | #include <memory> |
511 | 34 | 30 | ||
512 | 35 | // Forward compatibility hacks for earlier Mir versions | ||
513 | 36 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
514 | 37 | using MirWindowCallback = mir_surface_callback; | ||
515 | 38 | using MirWindowEventCallback = mir_surface_event_callback; | ||
516 | 39 | auto const mir_create_window_spec = mir_connection_create_spec_for_changes; | ||
517 | 40 | auto const mir_window_spec_set_event_handler = mir_surface_spec_set_event_handler; | ||
518 | 41 | auto const mir_window_spec_set_name = mir_surface_spec_set_name; | ||
519 | 42 | auto const mir_window_spec_set_width = mir_surface_spec_set_width; | ||
520 | 43 | auto const mir_window_spec_set_height = mir_surface_spec_set_height; | ||
521 | 44 | auto const mir_window_spec_set_width_increment = mir_surface_spec_set_width_increment; | ||
522 | 45 | auto const mir_window_spec_set_height_increment = mir_surface_spec_set_height_increment; | ||
523 | 46 | auto const mir_window_spec_set_buffer_usage = mir_surface_spec_set_buffer_usage; | ||
524 | 47 | auto const mir_window_spec_set_pixel_format = mir_surface_spec_set_pixel_format; | ||
525 | 48 | auto const mir_window_spec_set_type = mir_surface_spec_set_type; | ||
526 | 49 | auto const mir_window_spec_set_shell_chrome = mir_surface_spec_set_shell_chrome; | ||
527 | 50 | auto const mir_window_spec_set_min_width = mir_surface_spec_set_min_width; | ||
528 | 51 | auto const mir_window_spec_set_min_height = mir_surface_spec_set_min_height; | ||
529 | 52 | auto const mir_window_spec_set_max_width = mir_surface_spec_set_max_width; | ||
530 | 53 | auto const mir_window_spec_set_max_height = mir_surface_spec_set_max_height; | ||
531 | 54 | auto const mir_window_spec_set_parent = mir_surface_spec_set_parent; | ||
532 | 55 | auto const mir_window_spec_set_state = mir_surface_spec_set_state; | ||
533 | 56 | auto const mir_window_spec_set_fullscreen_on_output = mir_surface_spec_set_fullscreen_on_output; | ||
534 | 57 | auto const mir_create_window = mir_surface_create; | ||
535 | 58 | auto const mir_create_window_sync = mir_surface_create_sync; | ||
536 | 59 | auto const mir_window_apply_spec = mir_surface_apply_spec; | ||
537 | 60 | auto const mir_window_spec_release = mir_surface_spec_release; | ||
538 | 61 | |||
539 | 62 | #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) | ||
540 | 63 | auto const mir_window_spec_set_placement = mir_surface_spec_set_placement; | ||
541 | 64 | #endif | ||
542 | 65 | #endif | ||
543 | 66 | |||
544 | 67 | namespace mir | 31 | namespace mir |
545 | 68 | { | 32 | { |
546 | 69 | namespace client | 33 | namespace client |
547 | @@ -74,126 +38,87 @@ | |||
548 | 74 | public: | 38 | public: |
549 | 75 | explicit WindowSpec(MirWindowSpec* spec) : self{spec, deleter} {} | 39 | explicit WindowSpec(MirWindowSpec* spec) : self{spec, deleter} {} |
550 | 76 | 40 | ||
551 | 77 | static auto for_normal_window(MirConnection* connection, int width, int height, MirPixelFormat format) -> WindowSpec | ||
552 | 78 | { | ||
553 | 79 | #if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0) | ||
554 | 80 | return WindowSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)}; | ||
555 | 81 | #else | ||
556 | 82 | auto spec = WindowSpec{mir_create_normal_window_spec(connection, width, height)}; | ||
557 | 83 | mir_window_spec_set_pixel_format(spec, format); | ||
558 | 84 | return spec; | ||
559 | 85 | #endif | ||
560 | 86 | } | ||
561 | 87 | |||
562 | 88 | #if MIR_CLIENT_VERSION > MIR_VERSION_NUMBER(3, 4, 0) | ||
563 | 89 | static auto for_normal_window(MirConnection* connection, int width, int height) -> WindowSpec | 41 | static auto for_normal_window(MirConnection* connection, int width, int height) -> WindowSpec |
564 | 90 | { | 42 | { |
565 | 91 | return WindowSpec{mir_create_normal_window_spec(connection, width, height)}; | 43 | return WindowSpec{mir_create_normal_window_spec(connection, width, height)}; |
566 | 92 | } | 44 | } |
567 | 93 | #endif | ||
568 | 94 | 45 | ||
569 | 95 | static auto for_menu(MirConnection* connection, | 46 | static auto for_menu(MirConnection* connection, |
570 | 96 | int width, | 47 | int width, |
571 | 97 | int height, | 48 | int height, |
572 | 98 | MirPixelFormat format, | ||
573 | 99 | MirWindow* parent, | 49 | MirWindow* parent, |
574 | 100 | MirRectangle* rect, | 50 | MirRectangle* rect, |
575 | 101 | MirEdgeAttachment edge) -> WindowSpec | 51 | MirEdgeAttachment edge) -> WindowSpec |
576 | 102 | { | 52 | { |
577 | 103 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
578 | 104 | return WindowSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)}; | ||
579 | 105 | #else | ||
580 | 106 | auto spec = WindowSpec{mir_create_menu_window_spec(connection, width, height, parent, rect, edge)}; | 53 | auto spec = WindowSpec{mir_create_menu_window_spec(connection, width, height, parent, rect, edge)}; |
581 | 107 | mir_window_spec_set_pixel_format(spec, format); | ||
582 | 108 | return spec; | 54 | return spec; |
583 | 109 | #endif | ||
584 | 110 | } | 55 | } |
585 | 111 | 56 | ||
586 | 112 | static auto for_tip(MirConnection* connection, | 57 | static auto for_tip(MirConnection* connection, |
587 | 113 | int width, | 58 | int width, |
588 | 114 | int height, | 59 | int height, |
589 | 115 | MirPixelFormat format, | ||
590 | 116 | MirWindow* parent, | 60 | MirWindow* parent, |
591 | 117 | MirRectangle* rect, | 61 | MirRectangle* rect, |
592 | 118 | MirEdgeAttachment edge) -> WindowSpec | 62 | MirEdgeAttachment edge) -> WindowSpec |
593 | 119 | { | 63 | { |
594 | 120 | #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) | ||
595 | 121 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
596 | 122 | return WindowSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)}; | ||
597 | 123 | #else | ||
598 | 124 | auto spec = WindowSpec{mir_create_tip_window_spec(connection, width, height, parent, rect, edge)}; | 64 | auto spec = WindowSpec{mir_create_tip_window_spec(connection, width, height, parent, rect, edge)}; |
599 | 125 | mir_window_spec_set_pixel_format(spec, format); | ||
600 | 126 | return spec; | 65 | return spec; |
601 | 127 | #endif | ||
602 | 128 | #else | ||
603 | 129 | (void)rect; | ||
604 | 130 | (void)edge; | ||
605 | 131 | return WindowSpec{mir_create_surface_spec(connection)} | ||
606 | 132 | .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window() | ||
607 | 133 | .set_pixel_format(format) // Required protobuf field for create_window() | ||
608 | 134 | .set_size(width, height) | ||
609 | 135 | .set_parent(parent) | ||
610 | 136 | .set_type(mir_window_type_tip); | ||
611 | 137 | #endif | ||
612 | 138 | } | 66 | } |
613 | 139 | 67 | ||
614 | 140 | static auto for_dialog(MirConnection* connection, | 68 | static auto for_dialog(MirConnection* connection, |
615 | 141 | int width, | 69 | int width, |
618 | 142 | int height, | 70 | int height)-> WindowSpec |
617 | 143 | MirPixelFormat format)-> WindowSpec | ||
619 | 144 | { | 71 | { |
620 | 145 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
621 | 146 | return WindowSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)}; | ||
622 | 147 | #else | ||
623 | 148 | auto spec = WindowSpec{mir_create_dialog_window_spec(connection, width, height)}; | 72 | auto spec = WindowSpec{mir_create_dialog_window_spec(connection, width, height)}; |
624 | 149 | mir_window_spec_set_pixel_format(spec, format); | ||
625 | 150 | return spec; | 73 | return spec; |
626 | 151 | #endif | ||
627 | 152 | } | 74 | } |
628 | 153 | 75 | ||
629 | 154 | static auto for_dialog(MirConnection* connection, | 76 | static auto for_dialog(MirConnection* connection, |
630 | 155 | int width, | 77 | int width, |
631 | 156 | int height, | 78 | int height, |
632 | 157 | MirPixelFormat format, | ||
633 | 158 | MirWindow* parent) -> WindowSpec | 79 | MirWindow* parent) -> WindowSpec |
634 | 159 | { | 80 | { |
636 | 160 | return for_dialog(connection, width, height, format).set_parent(parent); | 81 | return for_dialog(connection, width, height).set_parent(parent); |
637 | 161 | } | 82 | } |
638 | 162 | 83 | ||
639 | 163 | static auto for_input_method(MirConnection* connection, int width, int height, MirWindow* parent) | 84 | static auto for_input_method(MirConnection* connection, int width, int height, MirWindow* parent) |
640 | 164 | { | 85 | { |
641 | 165 | #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 5, 0) | ||
642 | 166 | auto spec = WindowSpec{mir_create_input_method_window_spec(connection, width, height)} | 86 | auto spec = WindowSpec{mir_create_input_method_window_spec(connection, width, height)} |
643 | 167 | #else | ||
644 | 168 | auto spec = WindowSpec{mir_create_surface_spec(connection)} | ||
645 | 169 | .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window() | ||
646 | 170 | .set_pixel_format(mir_pixel_format_invalid) // Required protobuf field for create_window() | ||
647 | 171 | .set_size(width, height) | ||
648 | 172 | .set_type(mir_window_type_inputmethod) | ||
649 | 173 | #endif | ||
650 | 174 | .set_parent(parent); | 87 | .set_parent(parent); |
651 | 175 | return spec; | 88 | return spec; |
652 | 176 | } | 89 | } |
653 | 177 | 90 | ||
654 | 178 | static auto for_satellite(MirConnection* connection, int width, int height, MirWindow* parent) | 91 | static auto for_satellite(MirConnection* connection, int width, int height, MirWindow* parent) |
655 | 179 | { | 92 | { |
656 | 93 | #if MIR_CLIENT_API_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | ||
657 | 94 | return WindowSpec{mir_create_satellite_window_spec(connection, width, height, parent)}; | ||
658 | 95 | #else | ||
659 | 180 | // There's no mir_create_satellite_window_spec() | 96 | // There's no mir_create_satellite_window_spec() |
663 | 181 | return WindowSpec{mir_create_window_spec(connection)} | 97 | auto spec = WindowSpec{mir_create_window_spec(connection)} |
661 | 182 | .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window() | ||
662 | 183 | .set_pixel_format(mir_pixel_format_invalid) // Required protobuf field for create_window() | ||
664 | 184 | .set_size(width, height) | 98 | .set_size(width, height) |
665 | 185 | .set_type(mir_window_type_satellite) | 99 | .set_type(mir_window_type_satellite) |
666 | 186 | .set_parent(parent); | 100 | .set_parent(parent); |
667 | 101 | |||
668 | 102 | mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_hardware); // Required protobuf field for create_window() | ||
669 | 103 | mir_window_spec_set_pixel_format(spec, mir_pixel_format_invalid); // Required protobuf field for create_window() | ||
670 | 104 | return spec; | ||
671 | 105 | #endif | ||
672 | 187 | } | 106 | } |
673 | 188 | 107 | ||
674 | 189 | static auto for_gloss(MirConnection* connection, int width, int height) | 108 | static auto for_gloss(MirConnection* connection, int width, int height) |
675 | 190 | { | 109 | { |
676 | 110 | #if MIR_CLIENT_API_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | ||
677 | 111 | return WindowSpec{mir_create_gloss_window_spec(connection, width, height)}; | ||
678 | 112 | #else | ||
679 | 191 | // There's no mir_create_gloss_window_spec() | 113 | // There's no mir_create_gloss_window_spec() |
683 | 192 | return WindowSpec{mir_create_window_spec(connection)} | 114 | auto spec = WindowSpec{mir_create_window_spec(connection)} |
681 | 193 | .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window() | ||
682 | 194 | .set_pixel_format(mir_pixel_format_invalid) // Required protobuf field for create_window() | ||
684 | 195 | .set_size(width, height) | 115 | .set_size(width, height) |
685 | 196 | .set_type(mir_window_type_gloss); | 116 | .set_type(mir_window_type_gloss); |
686 | 117 | |||
687 | 118 | mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_hardware); // Required protobuf field for create_window() | ||
688 | 119 | mir_window_spec_set_pixel_format(spec, mir_pixel_format_invalid); // Required protobuf field for create_window() | ||
689 | 120 | return spec; | ||
690 | 121 | #endif | ||
691 | 197 | } | 122 | } |
692 | 198 | 123 | ||
693 | 199 | static auto for_changes(MirConnection* connection) -> WindowSpec | 124 | static auto for_changes(MirConnection* connection) -> WindowSpec |
694 | @@ -201,18 +126,6 @@ | |||
695 | 201 | return WindowSpec{mir_create_window_spec(connection)}; | 126 | return WindowSpec{mir_create_window_spec(connection)}; |
696 | 202 | } | 127 | } |
697 | 203 | 128 | ||
698 | 204 | auto set_buffer_usage(MirBufferUsage usage) -> WindowSpec& | ||
699 | 205 | { | ||
700 | 206 | mir_window_spec_set_buffer_usage(*this, usage); | ||
701 | 207 | return *this; | ||
702 | 208 | } | ||
703 | 209 | |||
704 | 210 | auto set_pixel_format(MirPixelFormat format) -> WindowSpec& | ||
705 | 211 | { | ||
706 | 212 | mir_window_spec_set_pixel_format(*this, format); | ||
707 | 213 | return *this; | ||
708 | 214 | } | ||
709 | 215 | |||
710 | 216 | auto set_type(MirWindowType type) -> WindowSpec& | 129 | auto set_type(MirWindowType type) -> WindowSpec& |
711 | 217 | { | 130 | { |
712 | 218 | mir_window_spec_set_type(*this, type); | 131 | mir_window_spec_set_type(*this, type); |
713 | @@ -271,7 +184,6 @@ | |||
714 | 271 | return *this; | 184 | return *this; |
715 | 272 | } | 185 | } |
716 | 273 | 186 | ||
717 | 274 | #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) | ||
718 | 275 | auto set_placement(const MirRectangle* rect, | 187 | auto set_placement(const MirRectangle* rect, |
719 | 276 | MirPlacementGravity rect_gravity, | 188 | MirPlacementGravity rect_gravity, |
720 | 277 | MirPlacementGravity surface_gravity, | 189 | MirPlacementGravity surface_gravity, |
721 | @@ -282,17 +194,6 @@ | |||
722 | 282 | mir_window_spec_set_placement(*this, rect, rect_gravity, surface_gravity, placement_hints, offset_dx, offset_dy); | 194 | mir_window_spec_set_placement(*this, rect, rect_gravity, surface_gravity, placement_hints, offset_dx, offset_dy); |
723 | 283 | return *this; | 195 | return *this; |
724 | 284 | } | 196 | } |
725 | 285 | #else | ||
726 | 286 | auto set_placement(const MirRectangle* /*rect*/, | ||
727 | 287 | MirPlacementGravity /*rect_gravity*/, | ||
728 | 288 | MirPlacementGravity /*surface_gravity*/, | ||
729 | 289 | MirPlacementHints /*placement_hints*/, | ||
730 | 290 | int /*offset_dx*/, | ||
731 | 291 | int /*offset_dy*/) -> WindowSpec& | ||
732 | 292 | { | ||
733 | 293 | return *this; | ||
734 | 294 | } | ||
735 | 295 | #endif | ||
736 | 296 | 197 | ||
737 | 297 | auto set_parent(MirWindow* parent) -> WindowSpec& | 198 | auto set_parent(MirWindow* parent) -> WindowSpec& |
738 | 298 | { | 199 | { |
739 | @@ -306,6 +207,20 @@ | |||
740 | 306 | return *this; | 207 | return *this; |
741 | 307 | } | 208 | } |
742 | 308 | 209 | ||
743 | 210 | auto add_surface(MirRenderSurface* surface, int width, int height, int displacement_x, int displacement_y) | ||
744 | 211 | -> WindowSpec& | ||
745 | 212 | { | ||
746 | 213 | #if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 27, 0) | ||
747 | 214 | #pragma GCC diagnostic push | ||
748 | 215 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
749 | 216 | #endif | ||
750 | 217 | mir_window_spec_add_render_surface(*this, surface, width, height, displacement_x, displacement_y); | ||
751 | 218 | #if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 27, 0) | ||
752 | 219 | #pragma GCC diagnostic pop | ||
753 | 220 | #endif | ||
754 | 221 | return *this; | ||
755 | 222 | } | ||
756 | 223 | |||
757 | 309 | template<typename Context> | 224 | template<typename Context> |
758 | 310 | void create_window(void (* callback)(MirWindow*, Context*), Context* context) const | 225 | void create_window(void (* callback)(MirWindow*, Context*), Context* context) const |
759 | 311 | { | 226 | { |
760 | 312 | 227 | ||
761 | === modified file 'include/miral/cursor_theme.h' | |||
762 | --- include/miral/cursor_theme.h 2016-09-28 10:38:36 +0000 | |||
763 | +++ include/miral/cursor_theme.h 2017-06-20 16:14:05 +0000 | |||
764 | @@ -25,11 +25,11 @@ | |||
765 | 25 | 25 | ||
766 | 26 | namespace miral | 26 | namespace miral |
767 | 27 | { | 27 | { |
769 | 28 | /// Load a cursor theme | 28 | /// Load an X-cursor theme, either the supplied default, or through the --cursor-theme config option |
770 | 29 | class CursorTheme | 29 | class CursorTheme |
771 | 30 | { | 30 | { |
772 | 31 | public: | 31 | public: |
774 | 32 | /// Specify a specific theme | 32 | /// Specify a default theme |
775 | 33 | explicit CursorTheme(std::string const& theme); | 33 | explicit CursorTheme(std::string const& theme); |
776 | 34 | ~CursorTheme(); | 34 | ~CursorTheme(); |
777 | 35 | 35 | ||
778 | 36 | 36 | ||
779 | === modified file 'include/miral/window_management_policy.h' | |||
780 | --- include/miral/window_management_policy.h 2017-02-14 11:49:59 +0000 | |||
781 | +++ include/miral/window_management_policy.h 2017-06-20 16:14:05 +0000 | |||
782 | @@ -23,8 +23,6 @@ | |||
783 | 23 | #include <mir/geometry/rectangles.h> | 23 | #include <mir/geometry/rectangles.h> |
784 | 24 | #include <mir_toolkit/event.h> | 24 | #include <mir_toolkit/event.h> |
785 | 25 | 25 | ||
786 | 26 | #include <mir/client/detail/mir_forward_compatibility.h> | ||
787 | 27 | |||
788 | 28 | namespace miral | 26 | namespace miral |
789 | 29 | { | 27 | { |
790 | 30 | class Window; | 28 | class Window; |
791 | 31 | 29 | ||
792 | === added file 'include/miral/window_management_policy_addendum2.h' | |||
793 | --- include/miral/window_management_policy_addendum2.h 1970-01-01 00:00:00 +0000 | |||
794 | +++ include/miral/window_management_policy_addendum2.h 2017-06-20 16:14:05 +0000 | |||
795 | @@ -0,0 +1,70 @@ | |||
796 | 1 | /* | ||
797 | 2 | * Copyright © 2017 Canonical Ltd. | ||
798 | 3 | * | ||
799 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
800 | 5 | * under the terms of the GNU General Public License version 3, | ||
801 | 6 | * as published by the Free Software Foundation. | ||
802 | 7 | * | ||
803 | 8 | * This program is distributed in the hope that it will be useful, | ||
804 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
805 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
806 | 11 | * GNU General Public License for more details. | ||
807 | 12 | * | ||
808 | 13 | * You should have received a copy of the GNU General Public License | ||
809 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
810 | 15 | * | ||
811 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
812 | 17 | */ | ||
813 | 18 | |||
814 | 19 | #ifndef MIRAL_WINDOW_MANAGEMENT_ADDENDUM2_H | ||
815 | 20 | #define MIRAL_WINDOW_MANAGEMENT_ADDENDUM2_H | ||
816 | 21 | |||
817 | 22 | #include <mir_toolkit/client_types.h> | ||
818 | 23 | #include <mir/version.h> | ||
819 | 24 | |||
820 | 25 | namespace miral | ||
821 | 26 | { | ||
822 | 27 | struct WindowInfo; | ||
823 | 28 | |||
824 | 29 | /** | ||
825 | 30 | * Handle additional client requests. | ||
826 | 31 | * | ||
827 | 32 | * \note This interface is intended to be implemented by a WindowManagementPolicy | ||
828 | 33 | * implementation, we can't add these functions directly to that interface without | ||
829 | 34 | * breaking ABI (the vtab could be incompatible). | ||
830 | 35 | * When initializing the window manager this interface will be detected by | ||
831 | 36 | * dynamic_cast and registered accordingly. | ||
832 | 37 | */ | ||
833 | 38 | class WindowManagementPolicyAddendum2 | ||
834 | 39 | { | ||
835 | 40 | public: | ||
836 | 41 | /** @name handle requests originating from the client | ||
837 | 42 | * The policy is expected to update the model as appropriate | ||
838 | 43 | * @{ */ | ||
839 | 44 | /** request from client to initiate drag and drop | ||
840 | 45 | * \note the request has already been validated against the requesting event | ||
841 | 46 | * | ||
842 | 47 | * @param window_info the window | ||
843 | 48 | */ | ||
844 | 49 | virtual void handle_request_drag_and_drop(WindowInfo& window_info) = 0; | ||
845 | 50 | |||
846 | 51 | /** request from client to initiate move | ||
847 | 52 | * \note the request has already been validated against the requesting event | ||
848 | 53 | * | ||
849 | 54 | * @param window_info the window | ||
850 | 55 | * @param input_event the requesting event | ||
851 | 56 | */ | ||
852 | 57 | virtual void handle_request_move(WindowInfo& window_info, MirInputEvent const* input_event) = 0; | ||
853 | 58 | /** @} */ | ||
854 | 59 | |||
855 | 60 | virtual ~WindowManagementPolicyAddendum2() = default; | ||
856 | 61 | WindowManagementPolicyAddendum2() = default; | ||
857 | 62 | WindowManagementPolicyAddendum2(WindowManagementPolicyAddendum2 const&) = delete; | ||
858 | 63 | WindowManagementPolicyAddendum2& operator=(WindowManagementPolicyAddendum2 const&) = delete; | ||
859 | 64 | }; | ||
860 | 65 | #if MIRAL_VERSION >= MIR_VERSION_NUMBER(2, 0, 0) | ||
861 | 66 | #error "We've presumably broken ABI - please roll this interface into WindowManagementPolicy" | ||
862 | 67 | #endif | ||
863 | 68 | } | ||
864 | 69 | |||
865 | 70 | #endif //MIRAL_WINDOW_MANAGEMENT_ADDENDUM2_H | ||
866 | 0 | 71 | ||
867 | === modified file 'include/miral/window_manager_tools.h' | |||
868 | --- include/miral/window_manager_tools.h 2017-03-02 14:29:04 +0000 | |||
869 | +++ include/miral/window_manager_tools.h 2017-06-20 16:14:05 +0000 | |||
870 | @@ -166,6 +166,18 @@ | |||
871 | 166 | /// Raise window and all its children | 166 | /// Raise window and all its children |
872 | 167 | void raise_tree(Window const& root); | 167 | void raise_tree(Window const& root); |
873 | 168 | 168 | ||
874 | 169 | /** Start drag and drop. The handle will be passed to the client which can | ||
875 | 170 | * then use it to talk to the whatever service is being used to support drag | ||
876 | 171 | * and drop (e.g. on Ubuntu the content hub). | ||
877 | 172 | * | ||
878 | 173 | * @param window_info source window | ||
879 | 174 | * @param handle drag handle | ||
880 | 175 | */ | ||
881 | 176 | void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle); | ||
882 | 177 | |||
883 | 178 | /// End drag and drop | ||
884 | 179 | void end_drag_and_drop(); | ||
885 | 180 | |||
886 | 169 | /// Apply modifications to a window | 181 | /// Apply modifications to a window |
887 | 170 | void modify_window(WindowInfo& window_info, WindowSpecification const& modifications); | 182 | void modify_window(WindowInfo& window_info, WindowSpecification const& modifications); |
888 | 171 | 183 | ||
889 | 172 | 184 | ||
890 | === modified file 'include/miral/window_specification.h' | |||
891 | --- include/miral/window_specification.h 2017-02-14 11:49:59 +0000 | |||
892 | +++ include/miral/window_specification.h 2017-06-20 16:14:05 +0000 | |||
893 | @@ -21,8 +21,6 @@ | |||
894 | 21 | 21 | ||
895 | 22 | #include <mir_toolkit/common.h> | 22 | #include <mir_toolkit/common.h> |
896 | 23 | 23 | ||
897 | 24 | #include <mir/client/detail/mir_forward_compatibility.h> | ||
898 | 25 | |||
899 | 26 | #include <mir/geometry/displacement.h> | 24 | #include <mir/geometry/displacement.h> |
900 | 27 | #include <mir/geometry/rectangles.h> | 25 | #include <mir/geometry/rectangles.h> |
901 | 28 | #include <mir/optional_value.h> | 26 | #include <mir/optional_value.h> |
902 | 29 | 27 | ||
903 | === modified file 'miral-kiosk/sw_splash.cpp' | |||
904 | --- miral-kiosk/sw_splash.cpp 2017-02-20 15:22:29 +0000 | |||
905 | +++ miral-kiosk/sw_splash.cpp 2017-06-20 16:14:05 +0000 | |||
906 | @@ -18,7 +18,10 @@ | |||
907 | 18 | 18 | ||
908 | 19 | #include "sw_splash.h" | 19 | #include "sw_splash.h" |
909 | 20 | 20 | ||
910 | 21 | #include <mir/client/display_config.h> | ||
911 | 22 | #include <mir/client/surface.h> | ||
912 | 21 | #include <mir/client/window.h> | 23 | #include <mir/client/window.h> |
913 | 24 | #include <mir/client/window_spec.h> | ||
914 | 22 | 25 | ||
915 | 23 | #include <mir_toolkit/mir_buffer_stream.h> | 26 | #include <mir_toolkit/mir_buffer_stream.h> |
916 | 24 | 27 | ||
917 | @@ -26,7 +29,6 @@ | |||
918 | 26 | #include <cstring> | 29 | #include <cstring> |
919 | 27 | #include <thread> | 30 | #include <thread> |
920 | 28 | #include <mutex> | 31 | #include <mutex> |
921 | 29 | #include <mir/client/window_spec.h> | ||
922 | 30 | 32 | ||
923 | 31 | namespace | 33 | namespace |
924 | 32 | { | 34 | { |
925 | @@ -60,12 +62,29 @@ | |||
926 | 60 | return *pixel_formats; | 62 | return *pixel_formats; |
927 | 61 | } | 63 | } |
928 | 62 | 64 | ||
930 | 63 | auto create_window(MirConnection* connection, MirPixelFormat pixel_format) -> mir::client::Window | 65 | auto create_window(MirConnection* connection, mir::client::Surface const& surface) -> mir::client::Window |
931 | 64 | { | 66 | { |
933 | 65 | return mir::client::WindowSpec::for_normal_window(connection, 42, 42, pixel_format) | 67 | int id = 0; |
934 | 68 | int width = 0; | ||
935 | 69 | int height = 0; | ||
936 | 70 | |||
937 | 71 | mir::client::DisplayConfig{connection}.for_each_output([&](MirOutput const* output) | ||
938 | 72 | { | ||
939 | 73 | if (mir_output_get_connection_state(output) == mir_output_connection_state_connected && | ||
940 | 74 | mir_output_is_enabled(output)) | ||
941 | 75 | { | ||
942 | 76 | id = mir_output_get_id(output); | ||
943 | 77 | |||
944 | 78 | MirOutputMode const* mode = mir_output_get_current_mode(output); | ||
945 | 79 | width = mir_output_mode_get_width(mode); | ||
946 | 80 | height = mir_output_mode_get_height(mode); | ||
947 | 81 | } | ||
948 | 82 | }); | ||
949 | 83 | |||
950 | 84 | return mir::client::WindowSpec::for_normal_window(connection, width, height) | ||
951 | 66 | .set_name("splash") | 85 | .set_name("splash") |
954 | 67 | .set_buffer_usage(mir_buffer_usage_software) | 86 | .set_fullscreen_on_output(id) |
955 | 68 | .set_fullscreen_on_output(0) | 87 | .add_surface(surface, width, height, 0, 0) |
956 | 69 | .create_window(); | 88 | .create_window(); |
957 | 70 | } | 89 | } |
958 | 71 | 90 | ||
959 | @@ -128,10 +147,13 @@ | |||
960 | 128 | return; | 147 | return; |
961 | 129 | }; | 148 | }; |
962 | 130 | 149 | ||
964 | 131 | auto const surface = create_window(connection, pixel_format); | 150 | |
965 | 151 | mir::client::Surface surface{mir_connection_create_render_surface_sync(connection, 42, 42)}; | ||
966 | 152 | MirBufferStream* buffer_stream = mir_render_surface_get_buffer_stream(surface, 42, 42, pixel_format); | ||
967 | 153 | |||
968 | 154 | auto const window = create_window(connection, surface); | ||
969 | 132 | 155 | ||
970 | 133 | MirGraphicsRegion graphics_region; | 156 | MirGraphicsRegion graphics_region; |
971 | 134 | MirBufferStream* buffer_stream = mir_window_get_buffer_stream(surface); | ||
972 | 135 | 157 | ||
973 | 136 | auto const time_limit = std::chrono::steady_clock::now() + std::chrono::seconds(2); | 158 | auto const time_limit = std::chrono::steady_clock::now() + std::chrono::seconds(2); |
974 | 137 | 159 | ||
975 | 138 | 160 | ||
976 | === modified file 'miral-shell/CMakeLists.txt' | |||
977 | --- miral-shell/CMakeLists.txt 2017-02-17 10:37:47 +0000 | |||
978 | +++ miral-shell/CMakeLists.txt 2017-06-20 16:14:05 +0000 | |||
979 | @@ -44,19 +44,18 @@ | |||
980 | 44 | add_executable(miral-shell | 44 | add_executable(miral-shell |
981 | 45 | shell_main.cpp | 45 | shell_main.cpp |
982 | 46 | tiling_window_manager.cpp tiling_window_manager.h | 46 | tiling_window_manager.cpp tiling_window_manager.h |
984 | 47 | titlebar_window_manager.cpp titlebar_window_manager.h | 47 | floating_window_manager.cpp floating_window_manager.h |
985 | 48 | decoration_provider.cpp decoration_provider.h | 48 | decoration_provider.cpp decoration_provider.h |
986 | 49 | titlebar_config.cpp titlebar_config.h | 49 | titlebar_config.cpp titlebar_config.h |
987 | 50 | ) | 50 | ) |
988 | 51 | 51 | ||
989 | 52 | pkg_check_modules(FREETYPE freetype2 REQUIRED) | 52 | pkg_check_modules(FREETYPE freetype2 REQUIRED) |
994 | 53 | target_include_directories(miral-shell PUBLIC ${FREETYPE_INCLUDE_DIRS}) | 53 | target_include_directories(miral-shell PRIVATE ${FREETYPE_INCLUDE_DIRS}) |
995 | 54 | target_compile_definitions(miral-shell PUBLIC -DTYPO_SUPPORTS_FREETYPE) | 54 | target_compile_definitions(miral-shell PRIVATE -DTYPO_SUPPORTS_FREETYPE) |
992 | 55 | target_link_libraries(miral-shell ${FREETYPE_LIBRARIES}) | ||
993 | 56 | |||
996 | 57 | target_link_libraries(miral-shell | 55 | target_link_libraries(miral-shell |
997 | 58 | miral-spinner | 56 | miral-spinner |
998 | 59 | miral | 57 | miral |
999 | 58 | ${FREETYPE_LIBRARIES} | ||
1000 | 60 | ) | 59 | ) |
1001 | 61 | 60 | ||
1002 | 62 | install(TARGETS miral-shell | 61 | install(TARGETS miral-shell |
1003 | 63 | 62 | ||
1004 | === modified file 'miral-shell/decoration_provider.cpp' | |||
1005 | --- miral-shell/decoration_provider.cpp 2017-03-30 14:12:50 +0000 | |||
1006 | +++ miral-shell/decoration_provider.cpp 2017-06-20 16:14:05 +0000 | |||
1007 | @@ -66,10 +66,8 @@ | |||
1008 | 66 | FT_Face face; | 66 | FT_Face face; |
1009 | 67 | }; | 67 | }; |
1010 | 68 | 68 | ||
1012 | 69 | void paint_surface(MirWindow* surface, std::string const& title, int const intensity) | 69 | void paint_surface(MirBufferStream* buffer_stream, std::string const& title, int const intensity) |
1013 | 70 | { | 70 | { |
1014 | 71 | MirBufferStream* buffer_stream = mir_window_get_buffer_stream(surface); | ||
1015 | 72 | |||
1016 | 73 | // TODO sometimes buffer_stream is nullptr - find out why (and fix). | 71 | // TODO sometimes buffer_stream is nullptr - find out why (and fix). |
1017 | 74 | // (Only observed when creating a lot of clients at once) | 72 | // (Only observed when creating a lot of clients at once) |
1018 | 75 | if (!buffer_stream) | 73 | if (!buffer_stream) |
1019 | @@ -286,11 +284,6 @@ | |||
1020 | 286 | { | 284 | { |
1021 | 287 | if (connection) | 285 | if (connection) |
1022 | 288 | { | 286 | { |
1023 | 289 | #if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 26, 2) | ||
1024 | 290 | auto const Workaround_lp_1667645 = | ||
1025 | 291 | WindowSpec::for_normal_window(connection, 100, 100, mir_pixel_format_xrgb_8888) | ||
1026 | 292 | .set_name(wallpaper_name).create_window(); | ||
1027 | 293 | #endif | ||
1028 | 294 | wallpaper.erase(begin(wallpaper), end(wallpaper)); | 287 | wallpaper.erase(begin(wallpaper), end(wallpaper)); |
1029 | 295 | } | 288 | } |
1030 | 296 | connection.reset(); | 289 | connection.reset(); |
1031 | @@ -326,24 +319,36 @@ | |||
1032 | 326 | DisplayConfig const display_conf{this->connection}; | 319 | DisplayConfig const display_conf{this->connection}; |
1033 | 327 | 320 | ||
1034 | 328 | display_conf.for_each_output([this](MirOutput const* output) | 321 | display_conf.for_each_output([this](MirOutput const* output) |
1053 | 329 | { | 322 | { |
1054 | 330 | wallpaper.push_back( | 323 | if (!mir_output_is_enabled(output)) |
1055 | 331 | WindowSpec::for_gloss(this->connection, 100, 100) | 324 | return; |
1056 | 332 | .set_pixel_format(mir_pixel_format_xrgb_8888) | 325 | |
1057 | 333 | .set_buffer_usage(mir_buffer_usage_software) | 326 | auto const mode = mir_output_get_current_mode(output); |
1058 | 334 | .set_fullscreen_on_output(mir_output_get_id(output)) | 327 | auto const output_id = mir_output_get_id(output); |
1059 | 335 | .set_name(wallpaper_name).create_window()); | 328 | auto const width = mir_output_mode_get_width(mode); |
1060 | 336 | 329 | auto const height = mir_output_mode_get_height(mode); | |
1061 | 337 | MirGraphicsRegion graphics_region; | 330 | |
1062 | 338 | MirBufferStream* buffer_stream = mir_window_get_buffer_stream(wallpaper.back()); | 331 | Surface surface{mir_connection_create_render_surface_sync(this->connection, width, height)}; |
1063 | 339 | 332 | ||
1064 | 340 | mir_buffer_stream_get_graphics_region(buffer_stream, &graphics_region); | 333 | auto const buffer_stream = |
1065 | 341 | 334 | mir_render_surface_get_buffer_stream(surface, width, height, mir_pixel_format_xrgb_8888); | |
1066 | 342 | static uint8_t const pattern[4] = { 0x00, 0x00, 0x00, 0x00 }; | 335 | |
1067 | 343 | 336 | auto window = WindowSpec::for_gloss(this->connection, width, height) | |
1068 | 344 | render_pattern(&graphics_region, pattern); | 337 | .set_fullscreen_on_output(output_id) |
1069 | 345 | mir_buffer_stream_swap_buffers_sync(buffer_stream); | 338 | .add_surface(surface, width, height, 0, 0) |
1070 | 346 | }); | 339 | .set_name(wallpaper_name).create_window(); |
1071 | 340 | |||
1072 | 341 | wallpaper.push_back(Wallpaper{surface, window, buffer_stream}); | ||
1073 | 342 | |||
1074 | 343 | MirGraphicsRegion graphics_region; | ||
1075 | 344 | |||
1076 | 345 | mir_buffer_stream_get_graphics_region(buffer_stream, &graphics_region); | ||
1077 | 346 | |||
1078 | 347 | static uint8_t const pattern[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
1079 | 348 | |||
1080 | 349 | render_pattern(&graphics_region, pattern); | ||
1081 | 350 | mir_buffer_stream_swap_buffers_sync(buffer_stream); | ||
1082 | 351 | }); | ||
1083 | 347 | 352 | ||
1084 | 348 | start_work(); | 353 | start_work(); |
1085 | 349 | } | 354 | } |
1086 | @@ -360,23 +365,54 @@ | |||
1087 | 360 | return weak_session.lock(); | 365 | return weak_session.lock(); |
1088 | 361 | } | 366 | } |
1089 | 362 | 367 | ||
1090 | 368 | void DecorationProvider::handle_event(MirWindow* window, MirEvent const* ev, void* context_) | ||
1091 | 369 | { | ||
1092 | 370 | auto* const context = (Data*)context_; | ||
1093 | 371 | |||
1094 | 372 | switch (mir_event_get_type(ev)) | ||
1095 | 373 | { | ||
1096 | 374 | case mir_event_type_resize: | ||
1097 | 375 | { | ||
1098 | 376 | MirResizeEvent const* resize = mir_event_get_resize_event(ev); | ||
1099 | 377 | int const new_width = mir_resize_event_get_width(resize); | ||
1100 | 378 | int const new_height = mir_resize_event_get_height(resize); | ||
1101 | 379 | mir_render_surface_set_size(context->surface, new_width, new_height); | ||
1102 | 380 | WindowSpec::for_changes(context->connection) | ||
1103 | 381 | .add_surface(context->surface, new_width, new_height, 0, 0) | ||
1104 | 382 | .apply_to(window); | ||
1105 | 383 | break; | ||
1106 | 384 | } | ||
1107 | 385 | |||
1108 | 386 | default: | ||
1109 | 387 | break; | ||
1110 | 388 | } | ||
1111 | 389 | } | ||
1112 | 390 | |||
1113 | 363 | void DecorationProvider::create_titlebar_for(miral::Window const& window) | 391 | void DecorationProvider::create_titlebar_for(miral::Window const& window) |
1114 | 364 | { | 392 | { |
1115 | 393 | if (is_decoration(window)) return; | ||
1116 | 394 | |||
1117 | 365 | enqueue_work([this, window] | 395 | enqueue_work([this, window] |
1118 | 366 | { | 396 | { |
1119 | 397 | auto const width = window.size().width.as_int(); | ||
1120 | 367 | std::ostringstream buffer; | 398 | std::ostringstream buffer; |
1121 | 368 | |||
1122 | 369 | buffer << std::shared_ptr<mir::scene::Surface>(window).get(); | 399 | buffer << std::shared_ptr<mir::scene::Surface>(window).get(); |
1123 | 370 | 400 | ||
1129 | 371 | auto const spec = WindowSpec::for_normal_window( | 401 | Surface surface{mir_connection_create_render_surface_sync(this->connection, width, title_bar_height)}; |
1125 | 372 | connection, window.size().width.as_int(), title_bar_height, mir_pixel_format_xrgb_8888) | ||
1126 | 373 | .set_buffer_usage(mir_buffer_usage_software) | ||
1127 | 374 | .set_type(mir_window_type_gloss) | ||
1128 | 375 | .set_name(buffer.str().c_str()); | ||
1130 | 376 | 402 | ||
1131 | 377 | std::lock_guard<decltype(mutex)> lock{mutex}; | 403 | std::lock_guard<decltype(mutex)> lock{mutex}; |
1132 | 404 | |||
1133 | 405 | auto const data = &window_to_titlebar[window]; | ||
1134 | 406 | data->connection = connection; | ||
1135 | 407 | data->surface = surface; | ||
1136 | 408 | data->stream = mir_render_surface_get_buffer_stream(surface, width, title_bar_height, mir_pixel_format_xrgb_8888); | ||
1137 | 378 | windows_awaiting_titlebar[buffer.str()] = window; | 409 | windows_awaiting_titlebar[buffer.str()] = window; |
1139 | 379 | spec.create_window(insert, &window_to_titlebar[window]); | 410 | |
1140 | 411 | WindowSpec::for_gloss(connection, width, title_bar_height) | ||
1141 | 412 | .add_surface(surface, width, title_bar_height, 0, 0) | ||
1142 | 413 | .set_name(buffer.str().c_str()) | ||
1143 | 414 | .set_event_handler(&handle_event, data) | ||
1144 | 415 | .create_window(insert, data); | ||
1145 | 380 | }); | 416 | }); |
1146 | 381 | } | 417 | } |
1147 | 382 | 418 | ||
1148 | @@ -388,15 +424,7 @@ | |||
1149 | 388 | 424 | ||
1150 | 389 | auto const title = info.name(); | 425 | auto const title = info.name(); |
1151 | 390 | 426 | ||
1161 | 391 | if (auto surface = data->titlebar.load()) | 427 | enqueue_work([this, stream=data->stream, title, intensity]{ paint_surface(stream, title, intensity); }); |
1153 | 392 | { | ||
1154 | 393 | enqueue_work([this, surface, title, intensity]{ paint_surface(surface, title, intensity); }); | ||
1155 | 394 | } | ||
1156 | 395 | else | ||
1157 | 396 | { | ||
1158 | 397 | data->on_create = [this, title, intensity](MirWindow* surface) | ||
1159 | 398 | { enqueue_work([this, surface, title, intensity]{ paint_surface(surface, title, intensity); }); }; | ||
1160 | 399 | } | ||
1162 | 400 | } | 428 | } |
1163 | 401 | } | 429 | } |
1164 | 402 | 430 | ||
1165 | @@ -511,11 +539,8 @@ | |||
1166 | 511 | { | 539 | { |
1167 | 512 | auto const title = window_info.name(); | 540 | auto const title = window_info.name(); |
1168 | 513 | 541 | ||
1174 | 514 | if (auto surface = data->titlebar.load()) | 542 | enqueue_work([this, stream=data->stream, title, intensity=data->intensity.load()] |
1175 | 515 | { | 543 | { paint_surface(stream, title, intensity); }); |
1171 | 516 | enqueue_work([this, surface, title, intensity=data->intensity.load()] | ||
1172 | 517 | { paint_surface(surface, title, intensity); }); | ||
1173 | 518 | } | ||
1176 | 519 | } | 544 | } |
1177 | 520 | } | 545 | } |
1178 | 521 | 546 | ||
1179 | 522 | 547 | ||
1180 | === modified file 'miral-shell/decoration_provider.h' | |||
1181 | --- miral-shell/decoration_provider.h 2017-03-01 14:02:59 +0000 | |||
1182 | +++ miral-shell/decoration_provider.h 2017-06-20 16:14:05 +0000 | |||
1183 | @@ -23,6 +23,7 @@ | |||
1184 | 23 | #include <miral/window_manager_tools.h> | 23 | #include <miral/window_manager_tools.h> |
1185 | 24 | 24 | ||
1186 | 25 | #include <mir/client/connection.h> | 25 | #include <mir/client/connection.h> |
1187 | 26 | #include <mir/client/surface.h> | ||
1188 | 26 | #include <mir/client/window.h> | 27 | #include <mir/client/window.h> |
1189 | 27 | 28 | ||
1190 | 28 | #include <mir/geometry/rectangle.h> | 29 | #include <mir/geometry/rectangle.h> |
1191 | @@ -81,6 +82,9 @@ | |||
1192 | 81 | private: | 82 | private: |
1193 | 82 | struct Data | 83 | struct Data |
1194 | 83 | { | 84 | { |
1195 | 85 | MirConnection* connection{nullptr}; | ||
1196 | 86 | mir::client::Surface surface; | ||
1197 | 87 | MirBufferStream* stream{nullptr}; | ||
1198 | 84 | std::atomic<MirWindow*> titlebar{nullptr}; | 88 | std::atomic<MirWindow*> titlebar{nullptr}; |
1199 | 85 | std::atomic<int> intensity{0xff}; | 89 | std::atomic<int> intensity{0xff}; |
1200 | 86 | std::function<void(MirWindow* surface)> on_create{[](MirWindow*){}}; | 90 | std::function<void(MirWindow* surface)> on_create{[](MirWindow*){}}; |
1201 | @@ -95,7 +99,8 @@ | |||
1202 | 95 | miral::WindowManagerTools tools; | 99 | miral::WindowManagerTools tools; |
1203 | 96 | std::mutex mutable mutex; | 100 | std::mutex mutable mutex; |
1204 | 97 | mir::client::Connection connection; | 101 | mir::client::Connection connection; |
1206 | 98 | std::vector<mir::client::Window> wallpaper; | 102 | struct Wallpaper { mir::client::Surface surface; mir::client::Window window; MirBufferStream* stream; }; |
1207 | 103 | std::vector<Wallpaper> wallpaper; | ||
1208 | 99 | std::weak_ptr<mir::scene::Session> weak_session; | 104 | std::weak_ptr<mir::scene::Session> weak_session; |
1209 | 100 | 105 | ||
1210 | 101 | SurfaceMap window_to_titlebar; | 106 | SurfaceMap window_to_titlebar; |
1211 | @@ -105,6 +110,7 @@ | |||
1212 | 105 | Data* find_titlebar_data(miral::Window const& window); | 110 | Data* find_titlebar_data(miral::Window const& window); |
1213 | 106 | miral::Window find_titlebar_window(miral::Window const& window) const; | 111 | miral::Window find_titlebar_window(miral::Window const& window) const; |
1214 | 107 | void repaint_titlebar_for(miral::WindowInfo const& window_info); | 112 | void repaint_titlebar_for(miral::WindowInfo const& window_info); |
1215 | 113 | static void handle_event(MirWindow* window, MirEvent const* ev, void* context_); | ||
1216 | 108 | }; | 114 | }; |
1217 | 109 | 115 | ||
1218 | 110 | 116 | ||
1219 | 111 | 117 | ||
1220 | === renamed file 'miral-shell/titlebar_window_manager.cpp' => 'miral-shell/floating_window_manager.cpp' | |||
1221 | --- miral-shell/titlebar_window_manager.cpp 2017-03-20 10:57:31 +0000 | |||
1222 | +++ miral-shell/floating_window_manager.cpp 2017-06-20 16:14:05 +0000 | |||
1223 | @@ -16,7 +16,7 @@ | |||
1224 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
1225 | 17 | */ | 17 | */ |
1226 | 18 | 18 | ||
1228 | 19 | #include "titlebar_window_manager.h" | 19 | #include "floating_window_manager.h" |
1229 | 20 | #include "decoration_provider.h" | 20 | #include "decoration_provider.h" |
1230 | 21 | 21 | ||
1231 | 22 | #include <miral/application_info.h> | 22 | #include <miral/application_info.h> |
1232 | @@ -46,7 +46,7 @@ | |||
1233 | 46 | } | 46 | } |
1234 | 47 | } | 47 | } |
1235 | 48 | 48 | ||
1237 | 49 | TitlebarWindowManagerPolicy::TitlebarWindowManagerPolicy( | 49 | FloatingWindowManagerPolicy::FloatingWindowManagerPolicy( |
1238 | 50 | WindowManagerTools const& tools, | 50 | WindowManagerTools const& tools, |
1239 | 51 | SpinnerSplash const& spinner, | 51 | SpinnerSplash const& spinner, |
1240 | 52 | miral::InternalClientLauncher const& launcher, | 52 | miral::InternalClientLauncher const& launcher, |
1241 | @@ -64,9 +64,9 @@ | |||
1242 | 64 | active_workspace = key_to_workspace[KEY_F1]; | 64 | active_workspace = key_to_workspace[KEY_F1]; |
1243 | 65 | } | 65 | } |
1244 | 66 | 66 | ||
1246 | 67 | TitlebarWindowManagerPolicy::~TitlebarWindowManagerPolicy() = default; | 67 | FloatingWindowManagerPolicy::~FloatingWindowManagerPolicy() = default; |
1247 | 68 | 68 | ||
1249 | 69 | bool TitlebarWindowManagerPolicy::handle_pointer_event(MirPointerEvent const* event) | 69 | bool FloatingWindowManagerPolicy::handle_pointer_event(MirPointerEvent const* event) |
1250 | 70 | { | 70 | { |
1251 | 71 | auto const action = mir_pointer_event_action(event); | 71 | auto const action = mir_pointer_event_action(event); |
1252 | 72 | auto const modifiers = mir_pointer_event_modifiers(event) & modifier_mask; | 72 | auto const modifiers = mir_pointer_event_modifiers(event) & modifier_mask; |
1253 | @@ -137,7 +137,7 @@ | |||
1254 | 137 | return consumes_event; | 137 | return consumes_event; |
1255 | 138 | } | 138 | } |
1256 | 139 | 139 | ||
1258 | 140 | void TitlebarWindowManagerPolicy::end_resize() | 140 | void FloatingWindowManagerPolicy::end_resize() |
1259 | 141 | { | 141 | { |
1260 | 142 | if (!resizing && !pinching) | 142 | if (!resizing && !pinching) |
1261 | 143 | return; | 143 | return; |
1262 | @@ -160,7 +160,7 @@ | |||
1263 | 160 | pinching = false; | 160 | pinching = false; |
1264 | 161 | } | 161 | } |
1265 | 162 | 162 | ||
1267 | 163 | bool TitlebarWindowManagerPolicy::handle_touch_event(MirTouchEvent const* event) | 163 | bool FloatingWindowManagerPolicy::handle_touch_event(MirTouchEvent const* event) |
1268 | 164 | { | 164 | { |
1269 | 165 | auto const count = mir_touch_event_point_count(event); | 165 | auto const count = mir_touch_event_point_count(event); |
1270 | 166 | 166 | ||
1271 | @@ -281,7 +281,7 @@ | |||
1272 | 281 | return consumes_event; | 281 | return consumes_event; |
1273 | 282 | } | 282 | } |
1274 | 283 | 283 | ||
1276 | 284 | void TitlebarWindowManagerPolicy::advise_new_window(WindowInfo const& window_info) | 284 | void FloatingWindowManagerPolicy::advise_new_window(WindowInfo const& window_info) |
1277 | 285 | { | 285 | { |
1278 | 286 | CanonicalWindowManagerPolicy::advise_new_window(window_info); | 286 | CanonicalWindowManagerPolicy::advise_new_window(window_info); |
1279 | 287 | 287 | ||
1280 | @@ -306,7 +306,7 @@ | |||
1281 | 306 | } | 306 | } |
1282 | 307 | } | 307 | } |
1283 | 308 | 308 | ||
1285 | 309 | void TitlebarWindowManagerPolicy::handle_window_ready(WindowInfo& window_info) | 309 | void FloatingWindowManagerPolicy::handle_window_ready(WindowInfo& window_info) |
1286 | 310 | { | 310 | { |
1287 | 311 | if (window_info.window().application() != spinner.session() && window_info.needs_titlebar(window_info.type())) | 311 | if (window_info.window().application() != spinner.session() && window_info.needs_titlebar(window_info.type())) |
1288 | 312 | decoration_provider->create_titlebar_for(window_info.window()); | 312 | decoration_provider->create_titlebar_for(window_info.window()); |
1289 | @@ -314,14 +314,14 @@ | |||
1290 | 314 | CanonicalWindowManagerPolicy::handle_window_ready(window_info); | 314 | CanonicalWindowManagerPolicy::handle_window_ready(window_info); |
1291 | 315 | } | 315 | } |
1292 | 316 | 316 | ||
1294 | 317 | void TitlebarWindowManagerPolicy::advise_focus_lost(WindowInfo const& info) | 317 | void FloatingWindowManagerPolicy::advise_focus_lost(WindowInfo const& info) |
1295 | 318 | { | 318 | { |
1296 | 319 | CanonicalWindowManagerPolicy::advise_focus_lost(info); | 319 | CanonicalWindowManagerPolicy::advise_focus_lost(info); |
1297 | 320 | 320 | ||
1298 | 321 | decoration_provider->paint_titlebar_for(info, 0x3F); | 321 | decoration_provider->paint_titlebar_for(info, 0x3F); |
1299 | 322 | } | 322 | } |
1300 | 323 | 323 | ||
1302 | 324 | void TitlebarWindowManagerPolicy::advise_focus_gained(WindowInfo const& info) | 324 | void FloatingWindowManagerPolicy::advise_focus_gained(WindowInfo const& info) |
1303 | 325 | { | 325 | { |
1304 | 326 | CanonicalWindowManagerPolicy::advise_focus_gained(info); | 326 | CanonicalWindowManagerPolicy::advise_focus_gained(info); |
1305 | 327 | 327 | ||
1306 | @@ -337,28 +337,28 @@ | |||
1307 | 337 | } | 337 | } |
1308 | 338 | } | 338 | } |
1309 | 339 | 339 | ||
1311 | 340 | void TitlebarWindowManagerPolicy::advise_state_change(WindowInfo const& window_info, MirWindowState state) | 340 | void FloatingWindowManagerPolicy::advise_state_change(WindowInfo const& window_info, MirWindowState state) |
1312 | 341 | { | 341 | { |
1313 | 342 | CanonicalWindowManagerPolicy::advise_state_change(window_info, state); | 342 | CanonicalWindowManagerPolicy::advise_state_change(window_info, state); |
1314 | 343 | 343 | ||
1315 | 344 | decoration_provider->advise_state_change(window_info, state); | 344 | decoration_provider->advise_state_change(window_info, state); |
1316 | 345 | } | 345 | } |
1317 | 346 | 346 | ||
1319 | 347 | void TitlebarWindowManagerPolicy::advise_resize(WindowInfo const& window_info, Size const& new_size) | 347 | void FloatingWindowManagerPolicy::advise_resize(WindowInfo const& window_info, Size const& new_size) |
1320 | 348 | { | 348 | { |
1321 | 349 | CanonicalWindowManagerPolicy::advise_resize(window_info, new_size); | 349 | CanonicalWindowManagerPolicy::advise_resize(window_info, new_size); |
1322 | 350 | 350 | ||
1323 | 351 | decoration_provider->resize_titlebar_for(window_info, new_size); | 351 | decoration_provider->resize_titlebar_for(window_info, new_size); |
1324 | 352 | } | 352 | } |
1325 | 353 | 353 | ||
1327 | 354 | void TitlebarWindowManagerPolicy::advise_delete_window(WindowInfo const& window_info) | 354 | void FloatingWindowManagerPolicy::advise_delete_window(WindowInfo const& window_info) |
1328 | 355 | { | 355 | { |
1329 | 356 | CanonicalWindowManagerPolicy::advise_delete_window(window_info); | 356 | CanonicalWindowManagerPolicy::advise_delete_window(window_info); |
1330 | 357 | 357 | ||
1331 | 358 | decoration_provider->destroy_titlebar_for(window_info.window()); | 358 | decoration_provider->destroy_titlebar_for(window_info.window()); |
1332 | 359 | } | 359 | } |
1333 | 360 | 360 | ||
1335 | 361 | bool TitlebarWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event) | 361 | bool FloatingWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event) |
1336 | 362 | { | 362 | { |
1337 | 363 | auto const action = mir_keyboard_event_action(event); | 363 | auto const action = mir_keyboard_event_action(event); |
1338 | 364 | auto const scan_code = mir_keyboard_event_scan_code(event); | 364 | auto const scan_code = mir_keyboard_event_scan_code(event); |
1339 | @@ -514,7 +514,7 @@ | |||
1340 | 514 | return false; | 514 | return false; |
1341 | 515 | } | 515 | } |
1342 | 516 | 516 | ||
1344 | 517 | void TitlebarWindowManagerPolicy::toggle(MirWindowState state) | 517 | void FloatingWindowManagerPolicy::toggle(MirWindowState state) |
1345 | 518 | { | 518 | { |
1346 | 519 | if (auto const window = tools.active_window()) | 519 | if (auto const window = tools.active_window()) |
1347 | 520 | { | 520 | { |
1348 | @@ -528,7 +528,7 @@ | |||
1349 | 528 | } | 528 | } |
1350 | 529 | } | 529 | } |
1351 | 530 | 530 | ||
1353 | 531 | bool TitlebarWindowManagerPolicy::resize(Window const& window, Point cursor, Point old_cursor) | 531 | bool FloatingWindowManagerPolicy::resize(Window const& window, Point cursor, Point old_cursor) |
1354 | 532 | { | 532 | { |
1355 | 533 | if (!window) | 533 | if (!window) |
1356 | 534 | return false; | 534 | return false; |
1357 | @@ -579,7 +579,7 @@ | |||
1358 | 579 | return true; | 579 | return true; |
1359 | 580 | } | 580 | } |
1360 | 581 | 581 | ||
1362 | 582 | void TitlebarWindowManagerPolicy::keep_size_within_limits( | 582 | void FloatingWindowManagerPolicy::keep_size_within_limits( |
1363 | 583 | WindowInfo const& window_info, Displacement& delta, Width& new_width, Height& new_height) const | 583 | WindowInfo const& window_info, Displacement& delta, Width& new_width, Height& new_height) const |
1364 | 584 | { | 584 | { |
1365 | 585 | auto const min_width = std::max(window_info.min_width(), Width{5}); | 585 | auto const min_width = std::max(window_info.min_width(), Width{5}); |
1366 | @@ -617,7 +617,7 @@ | |||
1367 | 617 | } | 617 | } |
1368 | 618 | } | 618 | } |
1369 | 619 | 619 | ||
1371 | 620 | WindowSpecification TitlebarWindowManagerPolicy::place_new_window( | 620 | WindowSpecification FloatingWindowManagerPolicy::place_new_window( |
1372 | 621 | ApplicationInfo const& app_info, WindowSpecification const& request_parameters) | 621 | ApplicationInfo const& app_info, WindowSpecification const& request_parameters) |
1373 | 622 | { | 622 | { |
1374 | 623 | auto parameters = CanonicalWindowManagerPolicy::place_new_window(app_info, request_parameters); | 623 | auto parameters = CanonicalWindowManagerPolicy::place_new_window(app_info, request_parameters); |
1375 | @@ -634,7 +634,7 @@ | |||
1376 | 634 | return parameters; | 634 | return parameters; |
1377 | 635 | } | 635 | } |
1378 | 636 | 636 | ||
1380 | 637 | void TitlebarWindowManagerPolicy::advise_adding_to_workspace( | 637 | void FloatingWindowManagerPolicy::advise_adding_to_workspace( |
1381 | 638 | std::shared_ptr<Workspace> const& workspace, std::vector<Window> const& windows) | 638 | std::shared_ptr<Workspace> const& workspace, std::vector<Window> const& windows) |
1382 | 639 | { | 639 | { |
1383 | 640 | if (windows.empty()) | 640 | if (windows.empty()) |
1384 | @@ -653,7 +653,7 @@ | |||
1385 | 653 | } | 653 | } |
1386 | 654 | } | 654 | } |
1387 | 655 | 655 | ||
1389 | 656 | void TitlebarWindowManagerPolicy::switch_workspace_to( | 656 | void FloatingWindowManagerPolicy::switch_workspace_to( |
1390 | 657 | std::shared_ptr<Workspace> const& workspace, | 657 | std::shared_ptr<Workspace> const& workspace, |
1391 | 658 | Window const& window) | 658 | Window const& window) |
1392 | 659 | { | 659 | { |
1393 | @@ -716,7 +716,7 @@ | |||
1394 | 716 | } | 716 | } |
1395 | 717 | } | 717 | } |
1396 | 718 | 718 | ||
1398 | 719 | void TitlebarWindowManagerPolicy::apply_workspace_hidden_to(Window const& window) | 719 | void FloatingWindowManagerPolicy::apply_workspace_hidden_to(Window const& window) |
1399 | 720 | { | 720 | { |
1400 | 721 | auto const& window_info = tools.info_for(window); | 721 | auto const& window_info = tools.info_for(window); |
1401 | 722 | auto& pdata = policy_data_for(window_info); | 722 | auto& pdata = policy_data_for(window_info); |
1402 | @@ -732,7 +732,7 @@ | |||
1403 | 732 | } | 732 | } |
1404 | 733 | } | 733 | } |
1405 | 734 | 734 | ||
1407 | 735 | void TitlebarWindowManagerPolicy::apply_workspace_visible_to(Window const& window) | 735 | void FloatingWindowManagerPolicy::apply_workspace_visible_to(Window const& window) |
1408 | 736 | { | 736 | { |
1409 | 737 | auto const& window_info = tools.info_for(window); | 737 | auto const& window_info = tools.info_for(window); |
1410 | 738 | auto& pdata = policy_data_for(window_info); | 738 | auto& pdata = policy_data_for(window_info); |
1411 | @@ -746,7 +746,7 @@ | |||
1412 | 746 | } | 746 | } |
1413 | 747 | } | 747 | } |
1414 | 748 | 748 | ||
1416 | 749 | void TitlebarWindowManagerPolicy::handle_modify_window(WindowInfo& window_info, WindowSpecification const& modifications) | 749 | void FloatingWindowManagerPolicy::handle_modify_window(WindowInfo& window_info, WindowSpecification const& modifications) |
1417 | 750 | { | 750 | { |
1418 | 751 | auto mods = modifications; | 751 | auto mods = modifications; |
1419 | 752 | 752 | ||
1420 | 753 | 753 | ||
1421 | === renamed file 'miral-shell/titlebar_window_manager.h' => 'miral-shell/floating_window_manager.h' | |||
1422 | --- miral-shell/titlebar_window_manager.h 2017-03-01 14:02:59 +0000 | |||
1423 | +++ miral-shell/floating_window_manager.h 2017-06-20 16:14:05 +0000 | |||
1424 | @@ -6,7 +6,7 @@ | |||
1425 | 6 | * as published by the Free Software Foundation. | 6 | * as published by the Free Software Foundation. |
1426 | 7 | * | 7 | * |
1427 | 8 | * This program is distributed in the hope that it will be useful, | 8 | * This program is distributed in the hope that it will be useful, |
1429 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty ofb |
1430 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1431 | 11 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
1432 | 12 | * | 12 | * |
1433 | @@ -16,8 +16,8 @@ | |||
1434 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
1435 | 17 | */ | 17 | */ |
1436 | 18 | 18 | ||
1439 | 19 | #ifndef MIRAL_SHELL_TITLEBAR_WINDOW_MANAGER_H | 19 | #ifndef MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H |
1440 | 20 | #define MIRAL_SHELL_TITLEBAR_WINDOW_MANAGER_H | 20 | #define MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H |
1441 | 21 | 21 | ||
1442 | 22 | #include <miral/canonical_window_manager.h> | 22 | #include <miral/canonical_window_manager.h> |
1443 | 23 | #include <miral/workspace_policy.h> | 23 | #include <miral/workspace_policy.h> |
1444 | @@ -33,15 +33,15 @@ | |||
1445 | 33 | 33 | ||
1446 | 34 | class DecorationProvider; | 34 | class DecorationProvider; |
1447 | 35 | 35 | ||
1449 | 36 | class TitlebarWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy, miral::WorkspacePolicy | 36 | class FloatingWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy, miral::WorkspacePolicy |
1450 | 37 | { | 37 | { |
1451 | 38 | public: | 38 | public: |
1453 | 39 | TitlebarWindowManagerPolicy( | 39 | FloatingWindowManagerPolicy( |
1454 | 40 | miral::WindowManagerTools const& tools, | 40 | miral::WindowManagerTools const& tools, |
1455 | 41 | SpinnerSplash const& spinner, | 41 | SpinnerSplash const& spinner, |
1456 | 42 | miral::InternalClientLauncher const& launcher, | 42 | miral::InternalClientLauncher const& launcher, |
1457 | 43 | std::function<void()>& shutdown_hook); | 43 | std::function<void()>& shutdown_hook); |
1459 | 44 | ~TitlebarWindowManagerPolicy(); | 44 | ~FloatingWindowManagerPolicy(); |
1460 | 45 | 45 | ||
1461 | 46 | virtual miral::WindowSpecification place_new_window( | 46 | virtual miral::WindowSpecification place_new_window( |
1462 | 47 | miral::ApplicationInfo const& app_info, miral::WindowSpecification const& request_parameters) override; | 47 | miral::ApplicationInfo const& app_info, miral::WindowSpecification const& request_parameters) override; |
1463 | @@ -133,4 +133,4 @@ | |||
1464 | 133 | void apply_workspace_hidden_to(miral::Window const& window); | 133 | void apply_workspace_hidden_to(miral::Window const& window); |
1465 | 134 | }; | 134 | }; |
1466 | 135 | 135 | ||
1468 | 136 | #endif //MIRAL_SHELL_TITLEBAR_WINDOW_MANAGER_H | 136 | #endif //MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H |
1469 | 137 | 137 | ||
1470 | === modified file 'miral-shell/miral-app.sh' | |||
1471 | --- miral-shell/miral-app.sh 2017-03-24 14:54:48 +0000 | |||
1472 | +++ miral-shell/miral-app.sh 2017-06-20 16:14:05 +0000 | |||
1473 | @@ -46,6 +46,6 @@ | |||
1474 | 46 | while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done | 46 | while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done |
1475 | 47 | 47 | ||
1476 | 48 | unset QT_QPA_PLATFORMTHEME | 48 | unset QT_QPA_PLATFORMTHEME |
1478 | 49 | MIR_SOCKET=${socket} GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher} | 49 | MIR_SOCKET=${socket} XDG_SESSION_TYPE=mir GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher} |
1479 | 50 | killall ${bindir}${miral_server} | 50 | killall ${bindir}${miral_server} |
1480 | 51 | 51 | ||
1481 | 52 | 52 | ||
1482 | === modified file 'miral-shell/miral-desktop.sh' | |||
1483 | --- miral-shell/miral-desktop.sh 2017-03-24 14:54:48 +0000 | |||
1484 | +++ miral-shell/miral-desktop.sh 2017-06-20 16:14:05 +0000 | |||
1485 | @@ -40,6 +40,6 @@ | |||
1486 | 40 | while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done | 40 | while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done |
1487 | 41 | 41 | ||
1488 | 42 | unset QT_QPA_PLATFORMTHEME | 42 | unset QT_QPA_PLATFORMTHEME |
1490 | 43 | MIR_SOCKET=${socket} GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher} | 43 | MIR_SOCKET=${socket} XDG_SESSION_TYPE=mir GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher} |
1491 | 44 | sudo killall ${bindir}${miral_server} | 44 | sudo killall ${bindir}${miral_server} |
1492 | 45 | 45 | ||
1493 | 46 | 46 | ||
1494 | === modified file 'miral-shell/miral-run.sh' | |||
1495 | --- miral-shell/miral-run.sh 2017-03-24 14:54:48 +0000 | |||
1496 | +++ miral-shell/miral-run.sh 2017-06-20 16:14:05 +0000 | |||
1497 | @@ -3,4 +3,4 @@ | |||
1498 | 3 | then extras='--app-id com.canonical.miral.Terminal' | 3 | then extras='--app-id com.canonical.miral.Terminal' |
1499 | 4 | fi | 4 | fi |
1500 | 5 | unset QT_QPA_PLATFORMTHEME | 5 | unset QT_QPA_PLATFORMTHEME |
1502 | 6 | MIR_SOCKET=${XDG_RUNTIME_DIR}/miral_socket GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir "$@" ${extras}& | 6 | MIR_SOCKET=${XDG_RUNTIME_DIR}/miral_socket XDG_SESSION_TYPE=mir GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir "$@" ${extras}& |
1503 | 7 | 7 | ||
1504 | === modified file 'miral-shell/miral-screencast.sh' | |||
1505 | --- miral-shell/miral-screencast.sh 2016-12-09 11:08:07 +0000 | |||
1506 | +++ miral-shell/miral-screencast.sh 2017-06-20 16:14:05 +0000 | |||
1507 | @@ -2,7 +2,7 @@ | |||
1508 | 2 | width=1920 | 2 | width=1920 |
1509 | 3 | height=1080 | 3 | height=1080 |
1510 | 4 | output=screencast.mp4 | 4 | output=screencast.mp4 |
1512 | 5 | socket=${XDG_RUNTIME_DIR}/mir_socket | 5 | socket=${XDG_RUNTIME_DIR}/miral_socket |
1513 | 6 | if [ -v MIR_SERVER ]; then socket=${MIR_SERVER}; fi | 6 | if [ -v MIR_SERVER ]; then socket=${MIR_SERVER}; fi |
1514 | 7 | 7 | ||
1515 | 8 | while [ $# -gt 0 ] | 8 | while [ $# -gt 0 ] |
1516 | 9 | 9 | ||
1517 | === modified file 'miral-shell/miral-xrun.sh' | |||
1518 | --- miral-shell/miral-xrun.sh 2017-03-24 15:47:07 +0000 | |||
1519 | +++ miral-shell/miral-xrun.sh 2017-06-20 16:14:05 +0000 | |||
1520 | @@ -21,6 +21,7 @@ | |||
1521 | 21 | exit 0 | 21 | exit 0 |
1522 | 22 | elif [ "$1" == "-force" ]; | 22 | elif [ "$1" == "-force" ]; |
1523 | 23 | then | 23 | then |
1524 | 24 | export XDG_SESSION_TYPE=x11 | ||
1525 | 24 | export GDK_BACKEND=x11 | 25 | export GDK_BACKEND=x11 |
1526 | 25 | export QT_QPA_PLATFORM=xcb | 26 | export QT_QPA_PLATFORM=xcb |
1527 | 26 | export SDL_VIDEODRIVER=x11 | 27 | export SDL_VIDEODRIVER=x11 |
1528 | 27 | 28 | ||
1529 | === modified file 'miral-shell/shell_main.cpp' | |||
1530 | --- miral-shell/shell_main.cpp 2017-03-06 09:45:37 +0000 | |||
1531 | +++ miral-shell/shell_main.cpp 2017-06-20 16:14:05 +0000 | |||
1532 | @@ -17,7 +17,7 @@ | |||
1533 | 17 | */ | 17 | */ |
1534 | 18 | 18 | ||
1535 | 19 | #include "tiling_window_manager.h" | 19 | #include "tiling_window_manager.h" |
1537 | 20 | #include "titlebar_window_manager.h" | 20 | #include "floating_window_manager.h" |
1538 | 21 | #include "titlebar_config.h" | 21 | #include "titlebar_config.h" |
1539 | 22 | #include "spinner/splash.h" | 22 | #include "spinner/splash.h" |
1540 | 23 | 23 | ||
1541 | @@ -44,7 +44,7 @@ | |||
1542 | 44 | ActiveOutputsMonitor outputs_monitor; | 44 | ActiveOutputsMonitor outputs_monitor; |
1543 | 45 | WindowManagerOptions window_managers | 45 | WindowManagerOptions window_managers |
1544 | 46 | { | 46 | { |
1546 | 47 | add_window_manager_policy<TitlebarWindowManagerPolicy>("titlebar", spinner, launcher, shutdown_hook), | 47 | add_window_manager_policy<FloatingWindowManagerPolicy>("floating", spinner, launcher, shutdown_hook), |
1547 | 48 | add_window_manager_policy<TilingWindowManagerPolicy>("tiling", spinner, launcher, outputs_monitor), | 48 | add_window_manager_policy<TilingWindowManagerPolicy>("tiling", spinner, launcher, outputs_monitor), |
1548 | 49 | }; | 49 | }; |
1549 | 50 | 50 | ||
1550 | @@ -83,7 +83,7 @@ | |||
1551 | 83 | { | 83 | { |
1552 | 84 | CommandLineOption{[&](std::string const& ) { }, | 84 | CommandLineOption{[&](std::string const& ) { }, |
1553 | 85 | "desktop_file_hint", "Ignored for Unity8 compatibility", "miral-shell.desktop"}, | 85 | "desktop_file_hint", "Ignored for Unity8 compatibility", "miral-shell.desktop"}, |
1555 | 86 | CursorTheme{"default"}, | 86 | CursorTheme{"DMZ-White"}, |
1556 | 87 | window_managers, | 87 | window_managers, |
1557 | 88 | display_configuration_options, | 88 | display_configuration_options, |
1558 | 89 | launcher, | 89 | launcher, |
1559 | 90 | 90 | ||
1560 | === modified file 'miral-shell/spinner/CMakeLists.txt' | |||
1561 | --- miral-shell/spinner/CMakeLists.txt 2016-05-20 09:20:19 +0000 | |||
1562 | +++ miral-shell/spinner/CMakeLists.txt 2017-06-20 16:14:05 +0000 | |||
1563 | @@ -59,6 +59,7 @@ | |||
1564 | 59 | ) | 59 | ) |
1565 | 60 | 60 | ||
1566 | 61 | target_link_libraries(miral-spinner | 61 | target_link_libraries(miral-spinner |
1567 | 62 | mirclientcpp | ||
1568 | 62 | EGL | 63 | EGL |
1569 | 63 | ${GLIB_LDFLAGS} | 64 | ${GLIB_LDFLAGS} |
1570 | 64 | ${GLESv2_LIBRARIES} | 65 | ${GLESv2_LIBRARIES} |
1571 | 65 | 66 | ||
1572 | === modified file 'miral-shell/spinner/eglapp.cpp' | |||
1573 | --- miral-shell/spinner/eglapp.cpp 2017-01-19 15:13:51 +0000 | |||
1574 | +++ miral-shell/spinner/eglapp.cpp 2017-06-20 16:14:05 +0000 | |||
1575 | @@ -16,61 +16,16 @@ | |||
1576 | 16 | 16 | ||
1577 | 17 | #include "eglapp.h" | 17 | #include "eglapp.h" |
1578 | 18 | 18 | ||
1579 | 19 | #include <mir/client/display_config.h> | ||
1580 | 20 | |||
1581 | 19 | #include "miregl.h" | 21 | #include "miregl.h" |
1582 | 20 | 22 | ||
1583 | 21 | #include <mir_toolkit/version.h> | ||
1584 | 22 | |||
1585 | 23 | 23 | ||
1586 | 24 | float mir_eglapp_background_opacity = 1.0f; | 24 | float mir_eglapp_background_opacity = 1.0f; |
1587 | 25 | 25 | ||
1588 | 26 | 26 | ||
1589 | 27 | namespace | 27 | namespace |
1590 | 28 | { | 28 | { |
1591 | 29 | template<typename ActiveOutputHandler> | ||
1592 | 30 | void for_each_active_output( | ||
1593 | 31 | MirConnection* const connection, ActiveOutputHandler const& handler) | ||
1594 | 32 | { | ||
1595 | 33 | /* eglapps are interested in the screen size, so | ||
1596 | 34 | use mir_connection_create_display_config */ | ||
1597 | 35 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
1598 | 36 | MirDisplayConfiguration* display_config = | ||
1599 | 37 | mir_connection_create_display_config(connection); | ||
1600 | 38 | |||
1601 | 39 | for (MirDisplayOutput* output = display_config->outputs; | ||
1602 | 40 | output != display_config->outputs + display_config->num_outputs; | ||
1603 | 41 | ++output) | ||
1604 | 42 | { | ||
1605 | 43 | if (output->used && | ||
1606 | 44 | output->connected && | ||
1607 | 45 | output->num_modes && | ||
1608 | 46 | output->current_mode < output->num_modes) | ||
1609 | 47 | { | ||
1610 | 48 | handler(output); | ||
1611 | 49 | } | ||
1612 | 50 | } | ||
1613 | 51 | |||
1614 | 52 | mir_display_config_destroy(display_config); | ||
1615 | 53 | #else | ||
1616 | 54 | MirDisplayConfig* display_config = | ||
1617 | 55 | mir_connection_create_display_configuration(connection); | ||
1618 | 56 | |||
1619 | 57 | int const n = mir_display_config_get_num_outputs(display_config); | ||
1620 | 58 | |||
1621 | 59 | for (int i = 0; i != n; ++i) | ||
1622 | 60 | { | ||
1623 | 61 | MirOutput const *const output = mir_display_config_get_output(display_config, i); | ||
1624 | 62 | if (mir_output_is_enabled(output) && | ||
1625 | 63 | mir_output_get_connection_state(output) == mir_output_connection_state_connected && | ||
1626 | 64 | mir_output_get_num_modes(output) && | ||
1627 | 65 | mir_output_get_current_mode_index(output) < (size_t)mir_output_get_num_modes(output)) | ||
1628 | 66 | { | ||
1629 | 67 | handler(output); | ||
1630 | 68 | } | ||
1631 | 69 | } | ||
1632 | 70 | mir_display_config_release(display_config); | ||
1633 | 71 | #endif | ||
1634 | 72 | } | ||
1635 | 73 | |||
1636 | 74 | MirPixelFormat select_pixel_format(MirConnection* connection) | 29 | MirPixelFormat select_pixel_format(MirConnection* connection) |
1637 | 75 | { | 30 | { |
1638 | 76 | unsigned int format[mir_pixel_formats]; | 31 | unsigned int format[mir_pixel_formats]; |
1639 | @@ -93,69 +48,33 @@ | |||
1640 | 93 | 48 | ||
1641 | 94 | std::vector<std::shared_ptr<MirEglSurface>> mir_eglapp_init(MirConnection* const connection) | 49 | std::vector<std::shared_ptr<MirEglSurface>> mir_eglapp_init(MirConnection* const connection) |
1642 | 95 | { | 50 | { |
1653 | 96 | MirWindowParameters surfaceparm = | 51 | char const * const name = "eglappsurface"; |
1644 | 97 | { | ||
1645 | 98 | "eglappsurface", | ||
1646 | 99 | 0, 0, | ||
1647 | 100 | mir_pixel_format_xbgr_8888, | ||
1648 | 101 | mir_buffer_usage_hardware, | ||
1649 | 102 | mir_display_output_id_invalid | ||
1650 | 103 | }; | ||
1651 | 104 | |||
1652 | 105 | EGLint swapinterval = 1; | ||
1654 | 106 | 52 | ||
1655 | 107 | if (!mir_connection_is_valid(connection)) | 53 | if (!mir_connection_is_valid(connection)) |
1656 | 108 | throw std::runtime_error("Can't get connection"); | 54 | throw std::runtime_error("Can't get connection"); |
1657 | 109 | 55 | ||
1658 | 110 | auto const pixel_format = select_pixel_format(connection); | 56 | auto const pixel_format = select_pixel_format(connection); |
1659 | 111 | surfaceparm.pixel_format = pixel_format; | ||
1660 | 112 | 57 | ||
1661 | 113 | auto const mir_egl_app = make_mir_eglapp(connection, pixel_format); | 58 | auto const mir_egl_app = make_mir_eglapp(connection, pixel_format); |
1662 | 114 | 59 | ||
1663 | 115 | std::vector<std::shared_ptr<MirEglSurface>> result; | 60 | std::vector<std::shared_ptr<MirEglSurface>> result; |
1664 | 116 | 61 | ||
1707 | 117 | // If a size has been specified just do that | 62 | mir::client::DisplayConfig{connection}.for_each_output([&](MirOutput const* output) |
1708 | 118 | if (surfaceparm.width && surfaceparm.height) | 63 | { |
1709 | 119 | { | 64 | if (mir_output_get_connection_state(output) == mir_output_connection_state_connected && |
1710 | 120 | result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, surfaceparm, swapinterval)); | 65 | mir_output_is_enabled(output)) |
1711 | 121 | return result; | 66 | { |
1712 | 122 | } | 67 | auto const mode = mir_output_get_current_mode(output); |
1713 | 123 | 68 | auto const output_id = mir_output_get_id(output); | |
1714 | 124 | // If an output has been specified just do that | 69 | |
1715 | 125 | if (surfaceparm.output_id != mir_display_output_id_invalid) | 70 | printf("Active output [%u] at (%d, %d) is %dx%d\n", |
1716 | 126 | { | 71 | output_id, |
1717 | 127 | result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, surfaceparm, swapinterval)); | 72 | mir_output_get_position_x(output), mir_output_get_position_y(output), |
1718 | 128 | return result; | 73 | mir_output_mode_get_width(mode), mir_output_mode_get_height(mode)); |
1719 | 129 | } | 74 | |
1720 | 130 | 75 | result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, name, output)); | |
1721 | 131 | // but normally, we're fullscreen on every active output | 76 | } |
1722 | 132 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | 77 | }); |
1681 | 133 | for_each_active_output(connection, [&](MirDisplayOutput const* output) | ||
1682 | 134 | { | ||
1683 | 135 | auto const& mode = output->modes[output->current_mode]; | ||
1684 | 136 | |||
1685 | 137 | printf("Active output [%u] at (%d, %d) is %dx%d\n", | ||
1686 | 138 | output->output_id, | ||
1687 | 139 | output->position_x, output->position_y, | ||
1688 | 140 | mode.horizontal_resolution, mode.vertical_resolution); | ||
1689 | 141 | |||
1690 | 142 | surfaceparm.output_id = output->output_id; | ||
1691 | 143 | result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, surfaceparm, swapinterval)); | ||
1692 | 144 | }); | ||
1693 | 145 | #else | ||
1694 | 146 | for_each_active_output(connection, [&](MirOutput const* output) | ||
1695 | 147 | { | ||
1696 | 148 | auto const& mode = mir_output_get_current_mode(output); | ||
1697 | 149 | |||
1698 | 150 | printf("Active output [%u] at (%d, %d) is %dx%d\n", | ||
1699 | 151 | mir_output_get_id(output), | ||
1700 | 152 | mir_output_get_position_x(output), mir_output_get_position_y(output), | ||
1701 | 153 | mir_output_mode_get_width(mode), mir_output_mode_get_height(mode)); | ||
1702 | 154 | |||
1703 | 155 | surfaceparm.output_id = mir_output_get_id(output); | ||
1704 | 156 | result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, surfaceparm, swapinterval)); | ||
1705 | 157 | }); | ||
1706 | 158 | #endif | ||
1723 | 159 | 78 | ||
1724 | 160 | if (result.empty()) | 79 | if (result.empty()) |
1725 | 161 | throw std::runtime_error("No active outputs found."); | 80 | throw std::runtime_error("No active outputs found."); |
1726 | 162 | 81 | ||
1727 | === modified file 'miral-shell/spinner/eglspinner.cpp' | |||
1728 | --- miral-shell/spinner/eglspinner.cpp 2016-04-17 00:20:00 +0000 | |||
1729 | +++ miral-shell/spinner/eglspinner.cpp 2017-06-20 16:14:05 +0000 | |||
1730 | @@ -34,6 +34,8 @@ | |||
1731 | 34 | #include <atomic> | 34 | #include <atomic> |
1732 | 35 | #include <mutex> | 35 | #include <mutex> |
1733 | 36 | 36 | ||
1734 | 37 | #include <mir_toolkit/mir_client_library.h> | ||
1735 | 38 | |||
1736 | 37 | #include "spinner_glow.h" | 39 | #include "spinner_glow.h" |
1737 | 38 | #include "spinner_logo.h" | 40 | #include "spinner_logo.h" |
1738 | 39 | 41 | ||
1739 | 40 | 42 | ||
1740 | === modified file 'miral-shell/spinner/miregl.cpp' | |||
1741 | --- miral-shell/spinner/miregl.cpp 2017-02-14 11:49:59 +0000 | |||
1742 | +++ miral-shell/spinner/miregl.cpp 2017-06-20 16:14:05 +0000 | |||
1743 | @@ -15,21 +15,22 @@ | |||
1744 | 15 | */ | 15 | */ |
1745 | 16 | 16 | ||
1746 | 17 | #include "miregl.h" | 17 | #include "miregl.h" |
1747 | 18 | #include <miral/window_specification.h> | ||
1748 | 18 | #include <mir/client/window_spec.h> | 19 | #include <mir/client/window_spec.h> |
1750 | 19 | #include <mir_toolkit/version.h> | 20 | #include <mir_toolkit/mir_client_library.h> |
1751 | 20 | 21 | ||
1752 | 21 | #include <cstring> | 22 | #include <cstring> |
1753 | 22 | 23 | ||
1754 | 23 | #include <GLES2/gl2.h> | 24 | #include <GLES2/gl2.h> |
1757 | 24 | #include <miral/window_specification.h> | 25 | |
1758 | 25 | #include <mir/client/window_spec.h> | 26 | using namespace mir::client; |
1759 | 26 | 27 | ||
1760 | 27 | class MirEglApp | 28 | class MirEglApp |
1761 | 28 | { | 29 | { |
1762 | 29 | public: | 30 | public: |
1763 | 30 | MirEglApp(MirConnection* const connection, MirPixelFormat pixel_format); | 31 | MirEglApp(MirConnection* const connection, MirPixelFormat pixel_format); |
1764 | 31 | 32 | ||
1766 | 32 | EGLSurface create_surface(MirWindow* window); | 33 | EGLSurface create_surface(MirRenderSurface* surface); |
1767 | 33 | 34 | ||
1768 | 34 | void make_current(EGLSurface eglsurface) const; | 35 | void make_current(EGLSurface eglsurface) const; |
1769 | 35 | 36 | ||
1770 | @@ -60,47 +61,37 @@ | |||
1771 | 60 | return std::make_shared<MirEglApp>(connection, pixel_format); | 61 | return std::make_shared<MirEglApp>(connection, pixel_format); |
1772 | 61 | } | 62 | } |
1773 | 62 | 63 | ||
1789 | 63 | namespace | 64 | MirEglSurface::MirEglSurface( |
1790 | 64 | { | 65 | std::shared_ptr<MirEglApp> const& mir_egl_app, |
1791 | 65 | MirWindow* create_window(MirConnection* const connection, MirWindowParameters const& parameters) | 66 | char const* name, |
1792 | 66 | { | 67 | MirOutput const* output) |
1793 | 67 | 68 | : | |
1794 | 68 | auto spec = mir::client::WindowSpec::for_normal_window( | 69 | mir_egl_app{mir_egl_app} |
1795 | 69 | connection, parameters.width, parameters.height, parameters.pixel_format) | 70 | { |
1796 | 70 | .set_name(parameters.name) | 71 | auto const mode = mir_output_get_current_mode(output); |
1797 | 71 | .set_buffer_usage(parameters.buffer_usage); | 72 | auto const output_id = mir_output_get_id(output); |
1798 | 72 | 73 | auto const width = mir_output_mode_get_width(mode); | |
1799 | 73 | 74 | auto const height = mir_output_mode_get_height(mode); | |
1800 | 74 | if (!parameters.width && !parameters.height) | 75 | |
1801 | 75 | spec.set_fullscreen_on_output(parameters.output_id); | 76 | surface = Surface{mir_connection_create_render_surface_sync(mir_egl_app->connection, width, height)}; |
1802 | 76 | 77 | ||
1803 | 77 | auto const window = mir_create_window_sync(spec); | 78 | eglsurface = mir_egl_app->create_surface(surface); |
1804 | 79 | |||
1805 | 80 | window = WindowSpec::for_normal_window(mir_egl_app->connection, width, height) | ||
1806 | 81 | .add_surface(surface, width, height, 0, 0) | ||
1807 | 82 | .set_name(name) | ||
1808 | 83 | .set_fullscreen_on_output(output_id) | ||
1809 | 84 | .create_window(); | ||
1810 | 78 | 85 | ||
1811 | 79 | if (!mir_window_is_valid(window)) | 86 | if (!mir_window_is_valid(window)) |
1812 | 80 | throw std::runtime_error(std::string("Can't create a window ") + mir_window_get_error_message(window)); | 87 | throw std::runtime_error(std::string("Can't create a window ") + mir_window_get_error_message(window)); |
1813 | 81 | 88 | ||
1830 | 82 | if (parameters.output_id != mir_display_output_id_invalid) | 89 | mir_egl_app->set_swap_interval(eglsurface, -1); |
1815 | 83 | mir_window_set_state(window, mir_window_state_fullscreen); | ||
1816 | 84 | |||
1817 | 85 | return window; | ||
1818 | 86 | } | ||
1819 | 87 | } | ||
1820 | 88 | |||
1821 | 89 | MirEglSurface::MirEglSurface( | ||
1822 | 90 | std::shared_ptr<MirEglApp> const& mir_egl_app, MirWindowParameters const& parm, int swapinterval) : | ||
1823 | 91 | mir_egl_app{mir_egl_app}, | ||
1824 | 92 | window{create_window(mir_egl_app->connection, parm)}, | ||
1825 | 93 | eglsurface{mir_egl_app->create_surface(window)}, | ||
1826 | 94 | width_{0}, | ||
1827 | 95 | height_{0} | ||
1828 | 96 | { | ||
1829 | 97 | mir_egl_app->set_swap_interval(eglsurface, swapinterval); | ||
1831 | 98 | } | 90 | } |
1832 | 99 | 91 | ||
1833 | 100 | MirEglSurface::~MirEglSurface() | 92 | MirEglSurface::~MirEglSurface() |
1834 | 101 | { | 93 | { |
1835 | 102 | mir_egl_app->destroy_surface(eglsurface); | 94 | mir_egl_app->destroy_surface(eglsurface); |
1836 | 103 | mir_window_release_sync(window); | ||
1837 | 104 | } | 95 | } |
1838 | 105 | 96 | ||
1839 | 106 | void MirEglSurface::egl_make_current() | 97 | void MirEglSurface::egl_make_current() |
1840 | @@ -139,7 +130,7 @@ | |||
1841 | 139 | EGL_NONE | 130 | EGL_NONE |
1842 | 140 | }; | 131 | }; |
1843 | 141 | 132 | ||
1845 | 142 | egldisplay = eglGetDisplay((EGLNativeDisplayType) mir_connection_get_egl_native_display(connection)); | 133 | egldisplay = eglGetDisplay((EGLNativeDisplayType)(connection)); |
1846 | 143 | if (egldisplay == EGL_NO_DISPLAY) | 134 | if (egldisplay == EGL_NO_DISPLAY) |
1847 | 144 | throw std::runtime_error("Can't eglGetDisplay"); | 135 | throw std::runtime_error("Can't eglGetDisplay"); |
1848 | 145 | 136 | ||
1849 | @@ -184,12 +175,12 @@ | |||
1850 | 184 | make_current(dummy_surface); | 175 | make_current(dummy_surface); |
1851 | 185 | } | 176 | } |
1852 | 186 | 177 | ||
1854 | 187 | EGLSurface MirEglApp::create_surface(MirWindow* window) | 178 | EGLSurface MirEglApp::create_surface(MirRenderSurface* surface) |
1855 | 188 | { | 179 | { |
1856 | 189 | auto const eglsurface = eglCreateWindowSurface( | 180 | auto const eglsurface = eglCreateWindowSurface( |
1857 | 190 | egldisplay, | 181 | egldisplay, |
1858 | 191 | eglconfig, | 182 | eglconfig, |
1860 | 192 | (EGLNativeWindowType) mir_buffer_stream_get_egl_native_window(mir_window_get_buffer_stream(window)), NULL); | 183 | (EGLNativeWindowType)surface, NULL); |
1861 | 193 | 184 | ||
1862 | 194 | if (eglsurface == EGL_NO_SURFACE) | 185 | if (eglsurface == EGL_NO_SURFACE) |
1863 | 195 | throw std::runtime_error("eglCreateWindowSurface failed"); | 186 | throw std::runtime_error("eglCreateWindowSurface failed"); |
1864 | 196 | 187 | ||
1865 | === modified file 'miral-shell/spinner/miregl.h' | |||
1866 | --- miral-shell/spinner/miregl.h 2017-03-06 09:49:23 +0000 | |||
1867 | +++ miral-shell/spinner/miregl.h 2017-06-20 16:14:05 +0000 | |||
1868 | @@ -17,9 +17,8 @@ | |||
1869 | 17 | #ifndef UNITYSYSTEMCOMPOSITOR_MIREGL_H | 17 | #ifndef UNITYSYSTEMCOMPOSITOR_MIREGL_H |
1870 | 18 | #define UNITYSYSTEMCOMPOSITOR_MIREGL_H | 18 | #define UNITYSYSTEMCOMPOSITOR_MIREGL_H |
1871 | 19 | 19 | ||
1875 | 20 | #include <mir/client/detail/mir_forward_compatibility.h> | 20 | #include <mir/client/surface.h> |
1876 | 21 | #include <mir_toolkit/client_types.h> | 21 | #include <mir/client/window.h> |
1874 | 22 | #include "mir_toolkit/mir_client_library.h" | ||
1877 | 23 | 22 | ||
1878 | 24 | #include <EGL/egl.h> | 23 | #include <EGL/egl.h> |
1879 | 25 | 24 | ||
1880 | @@ -37,8 +36,8 @@ | |||
1881 | 37 | public: | 36 | public: |
1882 | 38 | MirEglSurface( | 37 | MirEglSurface( |
1883 | 39 | std::shared_ptr<MirEglApp> const& mir_egl_app, | 38 | std::shared_ptr<MirEglApp> const& mir_egl_app, |
1886 | 40 | MirWindowParameters const& parm, | 39 | char const* name, |
1887 | 41 | int swapinterval); | 40 | MirOutput const* output); |
1888 | 42 | 41 | ||
1889 | 43 | ~MirEglSurface(); | 42 | ~MirEglSurface(); |
1890 | 44 | 43 | ||
1891 | @@ -58,8 +57,9 @@ | |||
1892 | 58 | unsigned int height() const; | 57 | unsigned int height() const; |
1893 | 59 | 58 | ||
1894 | 60 | std::shared_ptr<MirEglApp> const mir_egl_app; | 59 | std::shared_ptr<MirEglApp> const mir_egl_app; |
1897 | 61 | MirWindow* const window; | 60 | mir::client::Surface surface; |
1898 | 62 | EGLSurface const eglsurface; | 61 | mir::client::Window window; |
1899 | 62 | EGLSurface eglsurface; | ||
1900 | 63 | int width_; | 63 | int width_; |
1901 | 64 | int height_; | 64 | int height_; |
1902 | 65 | }; | 65 | }; |
1903 | 66 | 66 | ||
1904 | === modified file 'miral/CMakeLists.txt' | |||
1905 | --- miral/CMakeLists.txt 2017-03-20 12:28:06 +0000 | |||
1906 | +++ miral/CMakeLists.txt 2017-06-20 16:14:05 +0000 | |||
1907 | @@ -1,4 +1,4 @@ | |||
1909 | 1 | pkg_check_modules(MIRSERVER mirserver>=0.20 REQUIRED) | 1 | pkg_check_modules(MIRSERVER mirserver>=0.26 REQUIRED) |
1910 | 2 | 2 | ||
1911 | 3 | if(${CMAKE_COMPILER_IS_GNUCXX}) | 3 | if(${CMAKE_COMPILER_IS_GNUCXX}) |
1912 | 4 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") | 4 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto") |
1913 | @@ -11,8 +11,9 @@ | |||
1914 | 11 | 11 | ||
1915 | 12 | set(MIRAL_ABI 2) | 12 | set(MIRAL_ABI 2) |
1916 | 13 | set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map) | 13 | set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map) |
1917 | 14 | set(miral_include ${PROJECT_SOURCE_DIR}/include) | ||
1918 | 14 | 15 | ||
1920 | 15 | include_directories(include SYSTEM ${MIRSERVER_INCLUDE_DIRS}) | 16 | add_library(mirclientcpp INTERFACE) |
1921 | 16 | 17 | ||
1922 | 17 | add_library(miral-internal STATIC | 18 | add_library(miral-internal STATIC |
1923 | 18 | basic_window_manager.cpp basic_window_manager.h window_manager_tools_implementation.h | 19 | basic_window_manager.cpp basic_window_manager.h window_manager_tools_implementation.h |
1924 | @@ -28,39 +29,53 @@ | |||
1925 | 28 | set_source_files_properties(xcursor.c PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE) | 29 | set_source_files_properties(xcursor.c PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE) |
1926 | 29 | 30 | ||
1927 | 30 | add_library(miral SHARED | 31 | add_library(miral SHARED |
1961 | 31 | active_outputs.cpp ${CMAKE_SOURCE_DIR}/include/miral/active_outputs.h | 32 | active_outputs.cpp ${miral_include}/miral/active_outputs.h |
1962 | 32 | add_init_callback.cpp ${CMAKE_SOURCE_DIR}/include/miral/add_init_callback.h | 33 | add_init_callback.cpp ${miral_include}/miral/add_init_callback.h |
1963 | 33 | application.cpp ${CMAKE_SOURCE_DIR}/include/miral/application.h | 34 | application.cpp ${miral_include}/miral/application.h |
1964 | 34 | application_authorizer.cpp ${CMAKE_SOURCE_DIR}/include/miral/application_authorizer.h | 35 | application_authorizer.cpp ${miral_include}/miral/application_authorizer.h |
1965 | 35 | application_info.cpp ${CMAKE_SOURCE_DIR}/include/miral/application_info.h | 36 | application_info.cpp ${miral_include}/miral/application_info.h |
1966 | 36 | canonical_window_manager.cpp ${CMAKE_SOURCE_DIR}/include/miral/canonical_window_manager.h | 37 | canonical_window_manager.cpp ${miral_include}/miral/canonical_window_manager.h |
1967 | 37 | command_line_option.cpp ${CMAKE_SOURCE_DIR}/include/miral/command_line_option.h | 38 | command_line_option.cpp ${miral_include}/miral/command_line_option.h |
1968 | 38 | cursor_theme.cpp ${CMAKE_SOURCE_DIR}/include/miral/cursor_theme.h | 39 | cursor_theme.cpp ${miral_include}/miral/cursor_theme.h |
1969 | 39 | debug_extension.cpp ${CMAKE_SOURCE_DIR}/include/miral/debug_extension.h | 40 | debug_extension.cpp ${miral_include}/miral/debug_extension.h |
1970 | 40 | keymap.cpp ${CMAKE_SOURCE_DIR}/include/miral/keymap.h | 41 | keymap.cpp ${miral_include}/miral/keymap.h |
1971 | 41 | runner.cpp ${CMAKE_SOURCE_DIR}/include/miral/runner.h | 42 | runner.cpp ${miral_include}/miral/runner.h |
1972 | 42 | display_configuration_option.cpp ${CMAKE_SOURCE_DIR}/include/miral/display_configuration_option.h | 43 | display_configuration_option.cpp ${miral_include}/miral/display_configuration_option.h |
1973 | 43 | output.cpp ${CMAKE_SOURCE_DIR}/include/miral/output.h | 44 | output.cpp ${miral_include}/miral/output.h |
1974 | 44 | append_event_filter.cpp ${CMAKE_SOURCE_DIR}/include/miral/append_event_filter.h | 45 | append_event_filter.cpp ${miral_include}/miral/append_event_filter.h |
1975 | 45 | window.cpp ${CMAKE_SOURCE_DIR}/include/miral/window.h | 46 | window.cpp ${miral_include}/miral/window.h |
1976 | 46 | window_info.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_info.h | 47 | window_info.cpp ${miral_include}/miral/window_info.h |
1977 | 47 | window_management_options.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_management_options.h | 48 | window_management_options.cpp ${miral_include}/miral/window_management_options.h |
1978 | 48 | window_specification.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_specification.h | 49 | window_specification.cpp ${miral_include}/miral/window_specification.h |
1979 | 49 | internal_client.cpp ${CMAKE_SOURCE_DIR}/include/miral/internal_client.h | 50 | internal_client.cpp ${miral_include}/miral/internal_client.h |
1980 | 50 | set_command_line_handler.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_command_line_handler.h | 51 | set_command_line_handler.cpp ${miral_include}/miral/set_command_line_handler.h |
1981 | 51 | set_terminator.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_terminator.h | 52 | set_terminator.cpp ${miral_include}/miral/set_terminator.h |
1982 | 52 | set_window_management_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_window_management_policy.h | 53 | set_window_management_policy.cpp ${miral_include}/miral/set_window_management_policy.h |
1983 | 53 | workspace_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/workspace_policy.h | 54 | workspace_policy.cpp ${miral_include}/miral/workspace_policy.h |
1984 | 54 | window_management_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_management_policy.h | 55 | window_management_policy.cpp ${miral_include}/miral/window_management_policy.h |
1985 | 55 | window_manager_tools.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_manager_tools.h | 56 | window_manager_tools.cpp ${miral_include}/miral/window_manager_tools.h |
1986 | 56 | ${CMAKE_SOURCE_DIR}/include/mir/client/blob.h | 57 | ${miral_include}/miral/window_management_policy_addendum2.h |
1987 | 57 | ${CMAKE_SOURCE_DIR}/include/mir/client/cookie.h | 58 | ${miral_include}/mir/client/blob.h |
1988 | 58 | ${CMAKE_SOURCE_DIR}/include/mir/client/window_spec.h | 59 | ${miral_include}/mir/client/cookie.h |
1989 | 59 | ${CMAKE_SOURCE_DIR}/include/mir/client/window_id.h | 60 | ${miral_include}/mir/client/window_spec.h |
1990 | 60 | ${CMAKE_SOURCE_DIR}/include/mir/client/connection.h | 61 | ${miral_include}/mir/client/window_id.h |
1991 | 61 | ${CMAKE_SOURCE_DIR}/include/mir/client/display_config.h | 62 | ${miral_include}/mir/client/connection.h |
1992 | 62 | ${CMAKE_SOURCE_DIR}/include/mir/client/window.h | 63 | ${miral_include}/mir/client/display_config.h |
1993 | 63 | ${CMAKE_SOURCE_DIR}/include/mir/client/detail/mir_forward_compatibility.h | 64 | ${miral_include}/mir/client/window.h |
1994 | 65 | ) | ||
1995 | 66 | |||
1996 | 67 | target_include_directories(mirclientcpp | ||
1997 | 68 | INTERFACE "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS} | ||
1998 | 69 | ) | ||
1999 | 70 | |||
2000 | 71 | target_include_directories(miral-internal | ||
2001 | 72 | PRIVATE "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS} | ||
2002 | 73 | PRIVATE ${MIRSERVER_INCLUDE_DIRS} | ||
2003 | 74 | ) | ||
2004 | 75 | |||
2005 | 76 | target_include_directories(miral | ||
2006 | 77 | PUBLIC "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS} | ||
2007 | 78 | PRIVATE ${MIRSERVER_INCLUDE_DIRS} | ||
2008 | 64 | ) | 79 | ) |
2009 | 65 | 80 | ||
2010 | 66 | target_link_libraries(miral | 81 | target_link_libraries(miral |
2011 | @@ -99,26 +114,9 @@ | |||
2012 | 99 | @ONLY | 114 | @ONLY |
2013 | 100 | ) | 115 | ) |
2014 | 101 | 116 | ||
2035 | 102 | if (MIRSERVER_VERSION VERSION_LESS 0.24) | 117 | configure_file( |
2036 | 103 | set(MIR_POINTER_CONFINEMENT 0) | 118 | ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in |
2037 | 104 | else() | 119 | ${miral_include}/miral/version.h |
2018 | 105 | set(MIR_POINTER_CONFINEMENT 1) | ||
2019 | 106 | endif() | ||
2020 | 107 | |||
2021 | 108 | if (MIRSERVER_VERSION VERSION_LESS 0.22) | ||
2022 | 109 | set(MIR_DISPLAY_CONFIG_GET_MUTABLE 0) | ||
2023 | 110 | else() | ||
2024 | 111 | set(MIR_DISPLAY_CONFIG_GET_MUTABLE 1) | ||
2025 | 112 | endif() | ||
2026 | 113 | |||
2027 | 114 | configure_file( | ||
2028 | 115 | ${CMAKE_CURRENT_SOURCE_DIR}/mir_features.h.in | ||
2029 | 116 | ${PROJECT_SOURCE_DIR}/include/mir/client/detail/mir_features.h | ||
2030 | 117 | ) | ||
2031 | 118 | |||
2032 | 119 | configure_file( | ||
2033 | 120 | ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in | ||
2034 | 121 | ${PROJECT_SOURCE_DIR}/include/miral/version.h | ||
2038 | 122 | ) | 120 | ) |
2039 | 123 | 121 | ||
2040 | 124 | install(TARGETS miral LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}") | 122 | install(TARGETS miral LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}") |
2041 | 125 | 123 | ||
2042 | === modified file 'miral/active_outputs.cpp' | |||
2043 | --- miral/active_outputs.cpp 2017-01-13 18:17:01 +0000 | |||
2044 | +++ miral/active_outputs.cpp 2017-06-20 16:14:05 +0000 | |||
2045 | @@ -23,12 +23,8 @@ | |||
2046 | 23 | #include <mir/graphics/display_configuration.h> | 23 | #include <mir/graphics/display_configuration.h> |
2047 | 24 | #include <mir/server.h> | 24 | #include <mir/server.h> |
2048 | 25 | 25 | ||
2049 | 26 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0) | ||
2050 | 27 | #include <mir/graphics/display_configuration_report.h> | ||
2051 | 28 | #else | ||
2052 | 29 | #include <mir/graphics/display_configuration_observer.h> | 26 | #include <mir/graphics/display_configuration_observer.h> |
2053 | 30 | #include <mir/observer_registrar.h> | 27 | #include <mir/observer_registrar.h> |
2054 | 31 | #endif | ||
2055 | 32 | 28 | ||
2056 | 33 | #include <algorithm> | 29 | #include <algorithm> |
2057 | 34 | #include <mutex> | 30 | #include <mutex> |
2058 | @@ -40,17 +36,6 @@ | |||
2059 | 40 | void miral::ActiveOutputsListener::advise_output_update(Output const& /*updated*/, Output const& /*original*/) {} | 36 | void miral::ActiveOutputsListener::advise_output_update(Output const& /*updated*/, Output const& /*original*/) {} |
2060 | 41 | void miral::ActiveOutputsListener::advise_output_delete(Output const& /*output*/) {} | 37 | void miral::ActiveOutputsListener::advise_output_delete(Output const& /*output*/) {} |
2061 | 42 | 38 | ||
2062 | 43 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0) | ||
2063 | 44 | struct miral::ActiveOutputsMonitor::Self : mir::graphics::DisplayConfigurationReport | ||
2064 | 45 | { | ||
2065 | 46 | virtual void initial_configuration(mir::graphics::DisplayConfiguration const& configuration) override; | ||
2066 | 47 | virtual void new_configuration(mir::graphics::DisplayConfiguration const& configuration) override; | ||
2067 | 48 | |||
2068 | 49 | std::mutex mutex; | ||
2069 | 50 | std::vector<ActiveOutputsListener*> listeners; | ||
2070 | 51 | std::vector<Output> outputs; | ||
2071 | 52 | }; | ||
2072 | 53 | #else | ||
2073 | 54 | struct miral::ActiveOutputsMonitor::Self : mir::graphics::DisplayConfigurationObserver | 39 | struct miral::ActiveOutputsMonitor::Self : mir::graphics::DisplayConfigurationObserver |
2074 | 55 | { | 40 | { |
2075 | 56 | void initial_configuration(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& configuration) override; | 41 | void initial_configuration(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& configuration) override; |
2076 | @@ -79,7 +64,6 @@ | |||
2077 | 79 | std::vector<ActiveOutputsListener*> listeners; | 64 | std::vector<ActiveOutputsListener*> listeners; |
2078 | 80 | std::vector<Output> outputs; | 65 | std::vector<Output> outputs; |
2079 | 81 | }; | 66 | }; |
2080 | 82 | #endif | ||
2081 | 83 | 67 | ||
2082 | 84 | miral::ActiveOutputsMonitor::ActiveOutputsMonitor() : | 68 | miral::ActiveOutputsMonitor::ActiveOutputsMonitor() : |
2083 | 85 | self{std::make_shared<Self>()} | 69 | self{std::make_shared<Self>()} |
2084 | @@ -109,12 +93,8 @@ | |||
2085 | 109 | { | 93 | { |
2086 | 110 | std::lock_guard<decltype(self->mutex)> lock{self->mutex}; | 94 | std::lock_guard<decltype(self->mutex)> lock{self->mutex}; |
2087 | 111 | 95 | ||
2088 | 112 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0) | ||
2089 | 113 | server.override_the_display_configuration_report([this]{ return self; }); | ||
2090 | 114 | #else | ||
2091 | 115 | server.add_pre_init_callback([this, &server] | 96 | server.add_pre_init_callback([this, &server] |
2092 | 116 | { server.the_display_configuration_observer_registrar()->register_interest(self); }); | 97 | { server.the_display_configuration_observer_registrar()->register_interest(self); }); |
2093 | 117 | #endif | ||
2094 | 118 | } | 98 | } |
2095 | 119 | 99 | ||
2096 | 120 | void miral::ActiveOutputsMonitor::process_outputs( | 100 | void miral::ActiveOutputsMonitor::process_outputs( |
2097 | @@ -125,65 +105,11 @@ | |||
2098 | 125 | } | 105 | } |
2099 | 126 | 106 | ||
2100 | 127 | 107 | ||
2101 | 128 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0) | ||
2102 | 129 | void miral::ActiveOutputsMonitor::Self::initial_configuration(mir::graphics::DisplayConfiguration const& configuration) | ||
2103 | 130 | { | ||
2104 | 131 | new_configuration(configuration); | ||
2105 | 132 | } | ||
2106 | 133 | #else | ||
2107 | 134 | void miral::ActiveOutputsMonitor::Self::initial_configuration(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& configuration) | 108 | void miral::ActiveOutputsMonitor::Self::initial_configuration(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& configuration) |
2108 | 135 | { | 109 | { |
2109 | 136 | configuration_applied(configuration); | 110 | configuration_applied(configuration); |
2110 | 137 | } | 111 | } |
2160 | 138 | #endif | 112 | |
2112 | 139 | |||
2113 | 140 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0) | ||
2114 | 141 | void miral::ActiveOutputsMonitor::Self::new_configuration(mir::graphics::DisplayConfiguration const& configuration) | ||
2115 | 142 | { | ||
2116 | 143 | std::lock_guard<decltype(mutex)> lock{mutex}; | ||
2117 | 144 | |||
2118 | 145 | decltype(outputs) current_outputs; | ||
2119 | 146 | |||
2120 | 147 | for (auto const l : listeners) | ||
2121 | 148 | l->advise_output_begin(); | ||
2122 | 149 | |||
2123 | 150 | configuration.for_each_output([¤t_outputs, this](mir::graphics::DisplayConfigurationOutput const& output) | ||
2124 | 151 | { | ||
2125 | 152 | Output o{output}; | ||
2126 | 153 | |||
2127 | 154 | if (!o.connected() || !o.valid()) return; | ||
2128 | 155 | |||
2129 | 156 | auto op = find_if(begin(outputs), end(outputs), [&](Output const& oo) { return oo.is_same_output(o); }); | ||
2130 | 157 | |||
2131 | 158 | if (op == end(outputs)) | ||
2132 | 159 | { | ||
2133 | 160 | for (auto const l : listeners) | ||
2134 | 161 | l->advise_output_create(o); | ||
2135 | 162 | } | ||
2136 | 163 | else if (!equivalent_display_area(o, *op)) | ||
2137 | 164 | { | ||
2138 | 165 | for (auto const l : listeners) | ||
2139 | 166 | l->advise_output_update(o, *op); | ||
2140 | 167 | } | ||
2141 | 168 | |||
2142 | 169 | current_outputs.push_back(o); | ||
2143 | 170 | }); | ||
2144 | 171 | |||
2145 | 172 | for (auto const& o : outputs) | ||
2146 | 173 | { | ||
2147 | 174 | auto op = find_if(begin(current_outputs), end(current_outputs), [&](Output const& oo) | ||
2148 | 175 | { return oo.is_same_output(o); }); | ||
2149 | 176 | |||
2150 | 177 | if (op == end(current_outputs)) | ||
2151 | 178 | for (auto const l : listeners) | ||
2152 | 179 | l->advise_output_delete(o); | ||
2153 | 180 | } | ||
2154 | 181 | |||
2155 | 182 | current_outputs.swap(outputs); | ||
2156 | 183 | for (auto const l : listeners) | ||
2157 | 184 | l->advise_output_end(); | ||
2158 | 185 | } | ||
2159 | 186 | #else | ||
2161 | 187 | void miral::ActiveOutputsMonitor::Self::configuration_applied(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& config) | 113 | void miral::ActiveOutputsMonitor::Self::configuration_applied(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& config) |
2162 | 188 | { | 114 | { |
2163 | 189 | std::lock_guard<decltype(mutex)> lock{mutex}; | 115 | std::lock_guard<decltype(mutex)> lock{mutex}; |
2164 | @@ -233,4 +159,3 @@ | |||
2165 | 233 | for (auto const l : listeners) | 159 | for (auto const l : listeners) |
2166 | 234 | l->advise_output_end(); | 160 | l->advise_output_end(); |
2167 | 235 | } | 161 | } |
2168 | 236 | #endif | ||
2169 | 237 | 162 | ||
2170 | === modified file 'miral/basic_window_manager.cpp' | |||
2171 | --- miral/basic_window_manager.cpp 2017-03-21 12:30:42 +0000 | |||
2172 | +++ miral/basic_window_manager.cpp 2017-06-20 16:14:05 +0000 | |||
2173 | @@ -19,6 +19,7 @@ | |||
2174 | 19 | #include "basic_window_manager.h" | 19 | #include "basic_window_manager.h" |
2175 | 20 | #include "miral/window_manager_tools.h" | 20 | #include "miral/window_manager_tools.h" |
2176 | 21 | #include "miral/workspace_policy.h" | 21 | #include "miral/workspace_policy.h" |
2177 | 22 | #include "miral/window_management_policy_addendum2.h" | ||
2178 | 22 | 23 | ||
2179 | 23 | #include <mir/scene/session.h> | 24 | #include <mir/scene/session.h> |
2180 | 24 | #include <mir/scene/surface.h> | 25 | #include <mir/scene/surface.h> |
2181 | @@ -70,7 +71,6 @@ | |||
2182 | 70 | 71 | ||
2183 | 71 | namespace | 72 | namespace |
2184 | 72 | { | 73 | { |
2185 | 73 | |||
2186 | 74 | auto find_workspace_policy(std::unique_ptr<miral::WindowManagementPolicy> const& policy) -> miral::WorkspacePolicy* | 74 | auto find_workspace_policy(std::unique_ptr<miral::WindowManagementPolicy> const& policy) -> miral::WorkspacePolicy* |
2187 | 75 | { | 75 | { |
2188 | 76 | miral::WorkspacePolicy* result = dynamic_cast<miral::WorkspacePolicy*>(policy.get()); | 76 | miral::WorkspacePolicy* result = dynamic_cast<miral::WorkspacePolicy*>(policy.get()); |
2189 | @@ -82,6 +82,23 @@ | |||
2190 | 82 | 82 | ||
2191 | 83 | return &null_workspace_policy; | 83 | return &null_workspace_policy; |
2192 | 84 | } | 84 | } |
2193 | 85 | |||
2194 | 86 | auto find_policy_addendum2(std::unique_ptr<miral::WindowManagementPolicy> const& policy) -> miral::WindowManagementPolicyAddendum2* | ||
2195 | 87 | { | ||
2196 | 88 | miral::WindowManagementPolicyAddendum2* result = dynamic_cast<miral::WindowManagementPolicyAddendum2*>(policy.get()); | ||
2197 | 89 | |||
2198 | 90 | if (result) | ||
2199 | 91 | return result; | ||
2200 | 92 | |||
2201 | 93 | struct NullWindowManagementPolicyAddendum2 : miral::WindowManagementPolicyAddendum2 | ||
2202 | 94 | { | ||
2203 | 95 | void handle_request_drag_and_drop(miral::WindowInfo&) override {} | ||
2204 | 96 | void handle_request_move(miral::WindowInfo&, MirInputEvent const*) override {} | ||
2205 | 97 | }; | ||
2206 | 98 | static NullWindowManagementPolicyAddendum2 null_workspace_policy; | ||
2207 | 99 | |||
2208 | 100 | return &null_workspace_policy; | ||
2209 | 101 | } | ||
2210 | 85 | } | 102 | } |
2211 | 86 | 103 | ||
2212 | 87 | 104 | ||
2213 | @@ -94,10 +111,18 @@ | |||
2214 | 94 | display_layout(display_layout), | 111 | display_layout(display_layout), |
2215 | 95 | persistent_surface_store{persistent_surface_store}, | 112 | persistent_surface_store{persistent_surface_store}, |
2216 | 96 | policy(build(WindowManagerTools{this})), | 113 | policy(build(WindowManagerTools{this})), |
2218 | 97 | workspace_policy{find_workspace_policy(policy)} | 114 | workspace_policy{find_workspace_policy(policy)}, |
2219 | 115 | policy2{find_policy_addendum2(policy)} | ||
2220 | 98 | { | 116 | { |
2221 | 99 | } | 117 | } |
2222 | 100 | 118 | ||
2223 | 119 | miral::BasicWindowManager::~BasicWindowManager() | ||
2224 | 120 | { | ||
2225 | 121 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | ||
2226 | 122 | if (last_input_event) | ||
2227 | 123 | mir_event_unref(last_input_event); | ||
2228 | 124 | #endif | ||
2229 | 125 | } | ||
2230 | 101 | void miral::BasicWindowManager::add_session(std::shared_ptr<scene::Session> const& session) | 126 | void miral::BasicWindowManager::add_session(std::shared_ptr<scene::Session> const& session) |
2231 | 102 | { | 127 | { |
2232 | 103 | Locker lock{this}; | 128 | Locker lock{this}; |
2233 | @@ -156,14 +181,12 @@ | |||
2234 | 156 | session, | 181 | session, |
2235 | 157 | scene_surface)); | 182 | scene_surface)); |
2236 | 158 | 183 | ||
2237 | 159 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
2238 | 160 | if (parent && spec.aux_rect().is_set() && spec.placement_hints().is_set()) | 184 | if (parent && spec.aux_rect().is_set() && spec.placement_hints().is_set()) |
2239 | 161 | { | 185 | { |
2240 | 162 | Rectangle relative_placement{window.top_left() - (parent.top_left()-Point{}), window.size()}; | 186 | Rectangle relative_placement{window.top_left() - (parent.top_left()-Point{}), window.size()}; |
2241 | 163 | auto const mir_surface = std::shared_ptr<scene::Surface>(window); | 187 | auto const mir_surface = std::shared_ptr<scene::Surface>(window); |
2242 | 164 | mir_surface->placed_relative(relative_placement); | 188 | mir_surface->placed_relative(relative_placement); |
2243 | 165 | } | 189 | } |
2244 | 166 | #endif | ||
2245 | 167 | 190 | ||
2246 | 168 | return surface_id; | 191 | return surface_id; |
2247 | 169 | } | 192 | } |
2248 | @@ -362,10 +385,24 @@ | |||
2249 | 362 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | 385 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) |
2250 | 363 | void miral::BasicWindowManager::handle_request_drag_and_drop( | 386 | void miral::BasicWindowManager::handle_request_drag_and_drop( |
2251 | 364 | std::shared_ptr<mir::scene::Session> const& /*session*/, | 387 | std::shared_ptr<mir::scene::Session> const& /*session*/, |
2256 | 365 | std::shared_ptr<mir::scene::Surface> const& /*surface*/, | 388 | std::shared_ptr<mir::scene::Surface> const& surface, |
2257 | 366 | uint64_t /*timestamp*/) | 389 | uint64_t timestamp) |
2258 | 367 | { | 390 | { |
2259 | 368 | // TODO | 391 | Locker lock{this}; |
2260 | 392 | if (timestamp >= last_input_event_timestamp) | ||
2261 | 393 | policy2->handle_request_drag_and_drop(info_for(surface)); | ||
2262 | 394 | } | ||
2263 | 395 | |||
2264 | 396 | void miral::BasicWindowManager::handle_request_move( | ||
2265 | 397 | std::shared_ptr<mir::scene::Session> const& /*session*/, | ||
2266 | 398 | std::shared_ptr<mir::scene::Surface> const& surface, | ||
2267 | 399 | uint64_t timestamp) | ||
2268 | 400 | { | ||
2269 | 401 | std::lock_guard<decltype(mutex)> lock(mutex); | ||
2270 | 402 | if (timestamp >= last_input_event_timestamp && last_input_event) | ||
2271 | 403 | { | ||
2272 | 404 | policy2->handle_request_move(info_for(surface), mir_event_get_input_event(last_input_event)); | ||
2273 | 405 | } | ||
2274 | 369 | } | 406 | } |
2275 | 370 | #endif | 407 | #endif |
2276 | 371 | 408 | ||
2277 | @@ -741,6 +778,24 @@ | |||
2278 | 741 | focus_controller->raise({begin(windows), end(windows)}); | 778 | focus_controller->raise({begin(windows), end(windows)}); |
2279 | 742 | } | 779 | } |
2280 | 743 | 780 | ||
2281 | 781 | void miral::BasicWindowManager::start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) | ||
2282 | 782 | { | ||
2283 | 783 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | ||
2284 | 784 | std::shared_ptr<scene::Surface>(window_info.window())->start_drag_and_drop(handle); | ||
2285 | 785 | focus_controller->set_drag_and_drop_handle(handle); | ||
2286 | 786 | #else | ||
2287 | 787 | (void)window_info; | ||
2288 | 788 | (void)handle; | ||
2289 | 789 | #endif | ||
2290 | 790 | } | ||
2291 | 791 | |||
2292 | 792 | void miral::BasicWindowManager::end_drag_and_drop() | ||
2293 | 793 | { | ||
2294 | 794 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | ||
2295 | 795 | focus_controller->clear_drag_and_drop_handle(); | ||
2296 | 796 | #endif | ||
2297 | 797 | } | ||
2298 | 798 | |||
2299 | 744 | void miral::BasicWindowManager::move_tree(miral::WindowInfo& root, mir::geometry::Displacement movement) | 799 | void miral::BasicWindowManager::move_tree(miral::WindowInfo& root, mir::geometry::Displacement movement) |
2300 | 745 | { | 800 | { |
2301 | 746 | if (movement == mir::geometry::Displacement{}) | 801 | if (movement == mir::geometry::Displacement{}) |
2302 | @@ -900,11 +955,9 @@ | |||
2303 | 900 | if (new_pos.is_set()) | 955 | if (new_pos.is_set()) |
2304 | 901 | place_and_size(window_info, new_pos.value().top_left, new_pos.value().size); | 956 | place_and_size(window_info, new_pos.value().top_left, new_pos.value().size); |
2305 | 902 | 957 | ||
2306 | 903 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
2307 | 904 | Rectangle relative_placement{window.top_left() - (parent.top_left()-Point{}), window.size()}; | 958 | Rectangle relative_placement{window.top_left() - (parent.top_left()-Point{}), window.size()}; |
2308 | 905 | auto const mir_surface = std::shared_ptr<scene::Surface>(window); | 959 | auto const mir_surface = std::shared_ptr<scene::Surface>(window); |
2309 | 906 | mir_surface->placed_relative(relative_placement); | 960 | mir_surface->placed_relative(relative_placement); |
2310 | 907 | #endif | ||
2311 | 908 | } | 961 | } |
2312 | 909 | } | 962 | } |
2313 | 910 | 963 | ||
2314 | @@ -913,25 +966,18 @@ | |||
2315 | 913 | set_state(window_info, modifications.state().value()); | 966 | set_state(window_info, modifications.state().value()); |
2316 | 914 | } | 967 | } |
2317 | 915 | 968 | ||
2318 | 916 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
2319 | 917 | if (modifications.confine_pointer().is_set()) | 969 | if (modifications.confine_pointer().is_set()) |
2320 | 918 | std::shared_ptr<scene::Surface>(window)->set_confine_pointer_state(modifications.confine_pointer().value()); | 970 | std::shared_ptr<scene::Surface>(window)->set_confine_pointer_state(modifications.confine_pointer().value()); |
2321 | 919 | #endif | ||
2322 | 920 | } | 971 | } |
2323 | 921 | 972 | ||
2324 | 922 | auto miral::BasicWindowManager::info_for_window_id(std::string const& id) const -> WindowInfo& | 973 | auto miral::BasicWindowManager::info_for_window_id(std::string const& id) const -> WindowInfo& |
2325 | 923 | { | 974 | { |
2326 | 924 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
2327 | 925 | auto surface = persistent_surface_store->surface_for_id(mir::shell::PersistentSurfaceStore::Id{id}); | 975 | auto surface = persistent_surface_store->surface_for_id(mir::shell::PersistentSurfaceStore::Id{id}); |
2328 | 926 | 976 | ||
2329 | 927 | if (!surface) | 977 | if (!surface) |
2330 | 928 | BOOST_THROW_EXCEPTION(std::runtime_error{"No surface matching ID"}); | 978 | BOOST_THROW_EXCEPTION(std::runtime_error{"No surface matching ID"}); |
2331 | 929 | 979 | ||
2332 | 930 | return info_for(surface); | 980 | return info_for(surface); |
2333 | 931 | #else | ||
2334 | 932 | (void)id; | ||
2335 | 933 | BOOST_THROW_EXCEPTION(std::runtime_error{"No surface matching ID"}); | ||
2336 | 934 | #endif | ||
2337 | 935 | } | 981 | } |
2338 | 936 | 982 | ||
2339 | 937 | auto miral::BasicWindowManager::id_for_window(Window const& window) const -> std::string | 983 | auto miral::BasicWindowManager::id_for_window(Window const& window) const -> std::string |
2340 | @@ -939,11 +985,7 @@ | |||
2341 | 939 | if (!window) | 985 | if (!window) |
2342 | 940 | BOOST_THROW_EXCEPTION(std::runtime_error{"Null Window has no Persistent ID"}); | 986 | BOOST_THROW_EXCEPTION(std::runtime_error{"Null Window has no Persistent ID"}); |
2343 | 941 | 987 | ||
2344 | 942 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
2345 | 943 | return persistent_surface_store->id_for_surface(window).serialize_to_string(); | 988 | return persistent_surface_store->id_for_surface(window).serialize_to_string(); |
2346 | 944 | #else | ||
2347 | 945 | BOOST_THROW_EXCEPTION(std::runtime_error{"Persistent IDs unavailable with this Mir server version"}); | ||
2348 | 946 | #endif | ||
2349 | 947 | } | 989 | } |
2350 | 948 | 990 | ||
2351 | 949 | void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size) | 991 | void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size) |
2352 | @@ -1163,25 +1205,22 @@ | |||
2353 | 1163 | 1205 | ||
2354 | 1164 | void miral::BasicWindowManager::update_event_timestamp(MirKeyboardEvent const* kev) | 1206 | void miral::BasicWindowManager::update_event_timestamp(MirKeyboardEvent const* kev) |
2355 | 1165 | { | 1207 | { |
2358 | 1166 | auto iev = mir_keyboard_event_input_event(kev); | 1208 | update_event_timestamp(mir_keyboard_event_input_event(kev)); |
2357 | 1167 | last_input_event_timestamp = mir_input_event_get_event_time(iev); | ||
2359 | 1168 | } | 1209 | } |
2360 | 1169 | 1210 | ||
2361 | 1170 | void miral::BasicWindowManager::update_event_timestamp(MirPointerEvent const* pev) | 1211 | void miral::BasicWindowManager::update_event_timestamp(MirPointerEvent const* pev) |
2362 | 1171 | { | 1212 | { |
2363 | 1172 | auto iev = mir_pointer_event_input_event(pev); | ||
2364 | 1173 | auto pointer_action = mir_pointer_event_action(pev); | 1213 | auto pointer_action = mir_pointer_event_action(pev); |
2365 | 1174 | 1214 | ||
2366 | 1175 | if (pointer_action == mir_pointer_action_button_up || | 1215 | if (pointer_action == mir_pointer_action_button_up || |
2367 | 1176 | pointer_action == mir_pointer_action_button_down) | 1216 | pointer_action == mir_pointer_action_button_down) |
2368 | 1177 | { | 1217 | { |
2370 | 1178 | last_input_event_timestamp = mir_input_event_get_event_time(iev); | 1218 | update_event_timestamp(mir_pointer_event_input_event(pev)); |
2371 | 1179 | } | 1219 | } |
2372 | 1180 | } | 1220 | } |
2373 | 1181 | 1221 | ||
2374 | 1182 | void miral::BasicWindowManager::update_event_timestamp(MirTouchEvent const* tev) | 1222 | void miral::BasicWindowManager::update_event_timestamp(MirTouchEvent const* tev) |
2375 | 1183 | { | 1223 | { |
2376 | 1184 | auto iev = mir_touch_event_input_event(tev); | ||
2377 | 1185 | auto touch_count = mir_touch_event_point_count(tev); | 1224 | auto touch_count = mir_touch_event_point_count(tev); |
2378 | 1186 | for (unsigned i = 0; i < touch_count; i++) | 1225 | for (unsigned i = 0; i < touch_count; i++) |
2379 | 1187 | { | 1226 | { |
2380 | @@ -1189,12 +1228,22 @@ | |||
2381 | 1189 | if (touch_action == mir_touch_action_up || | 1228 | if (touch_action == mir_touch_action_up || |
2382 | 1190 | touch_action == mir_touch_action_down) | 1229 | touch_action == mir_touch_action_down) |
2383 | 1191 | { | 1230 | { |
2385 | 1192 | last_input_event_timestamp = mir_input_event_get_event_time(iev); | 1231 | update_event_timestamp(mir_touch_event_input_event(tev)); |
2386 | 1193 | break; | 1232 | break; |
2387 | 1194 | } | 1233 | } |
2388 | 1195 | } | 1234 | } |
2389 | 1196 | } | 1235 | } |
2390 | 1197 | 1236 | ||
2391 | 1237 | void miral::BasicWindowManager::update_event_timestamp(MirInputEvent const* iev) | ||
2392 | 1238 | { | ||
2393 | 1239 | last_input_event_timestamp = mir_input_event_get_event_time(iev); | ||
2394 | 1240 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | ||
2395 | 1241 | if (last_input_event) | ||
2396 | 1242 | mir_event_unref(last_input_event); | ||
2397 | 1243 | last_input_event = mir_event_ref(mir_input_event_get_event(iev)); | ||
2398 | 1244 | #endif | ||
2399 | 1245 | } | ||
2400 | 1246 | |||
2401 | 1198 | void miral::BasicWindowManager::invoke_under_lock(std::function<void()> const& callback) | 1247 | void miral::BasicWindowManager::invoke_under_lock(std::function<void()> const& callback) |
2402 | 1199 | { | 1248 | { |
2403 | 1200 | Locker lock{this}; | 1249 | Locker lock{this}; |
2404 | 1201 | 1250 | ||
2405 | === modified file 'miral/basic_window_manager.h' | |||
2406 | --- miral/basic_window_manager.h 2017-03-21 12:30:42 +0000 | |||
2407 | +++ miral/basic_window_manager.h 2017-06-20 16:14:05 +0000 | |||
2408 | @@ -46,6 +46,7 @@ | |||
2409 | 46 | namespace miral | 46 | namespace miral |
2410 | 47 | { | 47 | { |
2411 | 48 | class WorkspacePolicy; | 48 | class WorkspacePolicy; |
2412 | 49 | class WindowManagementPolicyAddendum2; | ||
2413 | 49 | using mir::shell::SurfaceSet; | 50 | using mir::shell::SurfaceSet; |
2414 | 50 | using WindowManagementPolicyBuilder = | 51 | using WindowManagementPolicyBuilder = |
2415 | 51 | std::function<std::unique_ptr<miral::WindowManagementPolicy>(miral::WindowManagerTools const& tools)>; | 52 | std::function<std::unique_ptr<miral::WindowManagementPolicy>(miral::WindowManagerTools const& tools)>; |
2416 | @@ -61,6 +62,7 @@ | |||
2417 | 61 | std::shared_ptr<mir::shell::DisplayLayout> const& display_layout, | 62 | std::shared_ptr<mir::shell::DisplayLayout> const& display_layout, |
2418 | 62 | std::shared_ptr<mir::shell::PersistentSurfaceStore> const& persistent_surface_store, | 63 | std::shared_ptr<mir::shell::PersistentSurfaceStore> const& persistent_surface_store, |
2419 | 63 | WindowManagementPolicyBuilder const& build); | 64 | WindowManagementPolicyBuilder const& build); |
2420 | 65 | ~BasicWindowManager(); | ||
2421 | 64 | 66 | ||
2422 | 65 | void add_session(std::shared_ptr<mir::scene::Session> const& session) override; | 67 | void add_session(std::shared_ptr<mir::scene::Session> const& session) override; |
2423 | 66 | 68 | ||
2424 | @@ -101,6 +103,11 @@ | |||
2425 | 101 | std::shared_ptr<mir::scene::Session> const& session, | 103 | std::shared_ptr<mir::scene::Session> const& session, |
2426 | 102 | std::shared_ptr<mir::scene::Surface> const& surface, | 104 | std::shared_ptr<mir::scene::Surface> const& surface, |
2427 | 103 | uint64_t timestamp) override; | 105 | uint64_t timestamp) override; |
2428 | 106 | |||
2429 | 107 | void handle_request_move( | ||
2430 | 108 | std::shared_ptr<mir::scene::Session> const& session, | ||
2431 | 109 | std::shared_ptr<mir::scene::Surface> const& surface, | ||
2432 | 110 | uint64_t timestamp) override; | ||
2433 | 104 | #endif | 111 | #endif |
2434 | 105 | 112 | ||
2435 | 106 | int set_surface_attribute( | 113 | int set_surface_attribute( |
2436 | @@ -161,6 +168,8 @@ | |||
2437 | 161 | auto active_display() -> mir::geometry::Rectangle const override; | 168 | auto active_display() -> mir::geometry::Rectangle const override; |
2438 | 162 | 169 | ||
2439 | 163 | void raise_tree(Window const& root) override; | 170 | void raise_tree(Window const& root) override; |
2440 | 171 | void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) override; | ||
2441 | 172 | void end_drag_and_drop() override; | ||
2442 | 164 | 173 | ||
2443 | 165 | void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override; | 174 | void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override; |
2444 | 166 | 175 | ||
2445 | @@ -190,6 +199,7 @@ | |||
2446 | 190 | 199 | ||
2447 | 191 | std::unique_ptr<WindowManagementPolicy> const policy; | 200 | std::unique_ptr<WindowManagementPolicy> const policy; |
2448 | 192 | WorkspacePolicy* const workspace_policy; | 201 | WorkspacePolicy* const workspace_policy; |
2449 | 202 | WindowManagementPolicyAddendum2* const policy2; | ||
2450 | 193 | 203 | ||
2451 | 194 | std::mutex mutex; | 204 | std::mutex mutex; |
2452 | 195 | SessionInfoMap app_info; | 205 | SessionInfoMap app_info; |
2453 | @@ -197,6 +207,9 @@ | |||
2454 | 197 | mir::geometry::Rectangles displays; | 207 | mir::geometry::Rectangles displays; |
2455 | 198 | mir::geometry::Point cursor; | 208 | mir::geometry::Point cursor; |
2456 | 199 | uint64_t last_input_event_timestamp{0}; | 209 | uint64_t last_input_event_timestamp{0}; |
2457 | 210 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0) | ||
2458 | 211 | MirEvent const* last_input_event{nullptr}; | ||
2459 | 212 | #endif | ||
2460 | 200 | miral::MRUWindowList mru_active_windows; | 213 | miral::MRUWindowList mru_active_windows; |
2461 | 201 | using FullscreenSurfaces = std::set<Window>; | 214 | using FullscreenSurfaces = std::set<Window>; |
2462 | 202 | FullscreenSurfaces fullscreen_surfaces; | 215 | FullscreenSurfaces fullscreen_surfaces; |
2463 | @@ -213,6 +226,7 @@ | |||
2464 | 213 | void update_event_timestamp(MirKeyboardEvent const* kev); | 226 | void update_event_timestamp(MirKeyboardEvent const* kev); |
2465 | 214 | void update_event_timestamp(MirPointerEvent const* pev); | 227 | void update_event_timestamp(MirPointerEvent const* pev); |
2466 | 215 | void update_event_timestamp(MirTouchEvent const* tev); | 228 | void update_event_timestamp(MirTouchEvent const* tev); |
2467 | 229 | void update_event_timestamp(MirInputEvent const* iev); | ||
2468 | 216 | 230 | ||
2469 | 217 | auto can_activate_window_for_session(miral::Application const& session) -> bool; | 231 | auto can_activate_window_for_session(miral::Application const& session) -> bool; |
2470 | 218 | auto can_activate_window_for_session_in_workspace( | 232 | auto can_activate_window_for_session_in_workspace( |
2471 | 219 | 233 | ||
2472 | === modified file 'miral/both_versions.h' | |||
2473 | --- miral/both_versions.h 2017-02-15 12:17:12 +0000 | |||
2474 | +++ miral/both_versions.h 2017-06-20 16:14:05 +0000 | |||
2475 | @@ -27,12 +27,7 @@ | |||
2476 | 27 | #define MIRAL_FAKE_NEW_SYMBOL(old_sym, new_sym)\ | 27 | #define MIRAL_FAKE_NEW_SYMBOL(old_sym, new_sym)\ |
2477 | 28 | extern "C" __attribute__((alias(#old_sym))) void new_sym(); | 28 | extern "C" __attribute__((alias(#old_sym))) void new_sym(); |
2478 | 29 | 29 | ||
2486 | 30 | #if (MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0)) | 30 | #define MIRAL_BOTH_VERSIONS(old_sym, new_sym)\ |
2487 | 31 | #define MIRAL_BOTH_VERSIONS(old_sym, new_sym)\ | 31 | MIRAL_FAKE_OLD_SYMBOL(old_sym, new_sym) |
2481 | 32 | MIRAL_FAKE_OLD_SYMBOL(old_sym, new_sym) | ||
2482 | 33 | #else | ||
2483 | 34 | #define MIRAL_BOTH_VERSIONS(old_sym, new_sym)\ | ||
2484 | 35 | MIRAL_FAKE_NEW_SYMBOL(old_sym, new_sym) | ||
2485 | 36 | #endif | ||
2488 | 37 | 32 | ||
2489 | 38 | #endif //MIRAL_BOTH_VERSIONS_H | 33 | #endif //MIRAL_BOTH_VERSIONS_H |
2490 | 39 | 34 | ||
2491 | === modified file 'miral/cursor_theme.cpp' | |||
2492 | --- miral/cursor_theme.cpp 2016-09-28 10:57:41 +0000 | |||
2493 | +++ miral/cursor_theme.cpp 2017-06-20 16:14:05 +0000 | |||
2494 | @@ -19,6 +19,7 @@ | |||
2495 | 19 | #include "miral/cursor_theme.h" | 19 | #include "miral/cursor_theme.h" |
2496 | 20 | #include "xcursor_loader.h" | 20 | #include "xcursor_loader.h" |
2497 | 21 | 21 | ||
2498 | 22 | #include <mir/options/option.h> | ||
2499 | 22 | #include <mir/server.h> | 23 | #include <mir/server.h> |
2500 | 23 | #include <mir_toolkit/cursors.h> | 24 | #include <mir_toolkit/cursors.h> |
2501 | 24 | 25 | ||
2502 | @@ -43,8 +44,14 @@ | |||
2503 | 43 | 44 | ||
2504 | 44 | void miral::CursorTheme::operator()(mir::Server& server) const | 45 | void miral::CursorTheme::operator()(mir::Server& server) const |
2505 | 45 | { | 46 | { |
2506 | 47 | static char const* const option = "cursor-theme"; | ||
2507 | 48 | |||
2508 | 49 | server.add_configuration_option(option, "Cursor theme (e.g. \"DMZ-Black\")", theme); | ||
2509 | 50 | |||
2510 | 46 | server.override_the_cursor_images([&] | 51 | server.override_the_cursor_images([&] |
2511 | 47 | { | 52 | { |
2512 | 53 | auto const theme = server.get_options()->get<std::string const>(option); | ||
2513 | 54 | |||
2514 | 48 | std::shared_ptr<mi::CursorImages> const xcursor_loader{std::make_shared<XCursorLoader>(theme)}; | 55 | std::shared_ptr<mi::CursorImages> const xcursor_loader{std::make_shared<XCursorLoader>(theme)}; |
2515 | 49 | 56 | ||
2516 | 50 | if (has_default_cursor(*xcursor_loader)) | 57 | if (has_default_cursor(*xcursor_loader)) |
2517 | 51 | 58 | ||
2518 | === modified file 'miral/keymap.cpp' | |||
2519 | --- miral/keymap.cpp 2017-01-17 16:42:33 +0000 | |||
2520 | +++ miral/keymap.cpp 2017-06-20 16:14:05 +0000 | |||
2521 | @@ -25,13 +25,8 @@ | |||
2522 | 25 | #include <mir/server.h> | 25 | #include <mir/server.h> |
2523 | 26 | #include <mir/version.h> | 26 | #include <mir/version.h> |
2524 | 27 | 27 | ||
2525 | 28 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0) | ||
2526 | 29 | #include <mir/input/keymap.h> | 28 | #include <mir/input/keymap.h> |
2527 | 30 | #include <mir/input/mir_keyboard_config.h> | 29 | #include <mir/input/mir_keyboard_config.h> |
2528 | 31 | #elif MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 1) | ||
2529 | 32 | #include <mir/input/keymap.h> | ||
2530 | 33 | #include <mir/input/keyboard_configuration.h> | ||
2531 | 34 | #endif | ||
2532 | 35 | 30 | ||
2533 | 36 | #define MIR_LOG_COMPONENT "miral::Keymap" | 31 | #define MIR_LOG_COMPONENT "miral::Keymap" |
2534 | 37 | #include <mir/log.h> | 32 | #include <mir/log.h> |
2535 | @@ -107,7 +102,6 @@ | |||
2536 | 107 | apply_keymap(keyboard); | 102 | apply_keymap(keyboard); |
2537 | 108 | } | 103 | } |
2538 | 109 | 104 | ||
2539 | 110 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 1) | ||
2540 | 111 | void apply_keymap(std::shared_ptr<mir::input::Device> const& keyboard) | 105 | void apply_keymap(std::shared_ptr<mir::input::Device> const& keyboard) |
2541 | 112 | { | 106 | { |
2542 | 113 | auto const keyboard_config = keyboard->keyboard_configuration(); | 107 | auto const keyboard_config = keyboard->keyboard_configuration(); |
2543 | @@ -115,11 +109,7 @@ | |||
2544 | 115 | 109 | ||
2545 | 116 | if (keyboard_config.is_set()) | 110 | if (keyboard_config.is_set()) |
2546 | 117 | { | 111 | { |
2547 | 118 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0) | ||
2548 | 119 | keymap = keyboard_config.value().device_keymap(); | 112 | keymap = keyboard_config.value().device_keymap(); |
2549 | 120 | #else | ||
2550 | 121 | keymap = keyboard_config.value().device_keymap; | ||
2551 | 122 | #endif | ||
2552 | 123 | } | 113 | } |
2553 | 124 | 114 | ||
2554 | 125 | keymap.layout = layout; | 115 | keymap.layout = layout; |
2555 | @@ -127,12 +117,6 @@ | |||
2556 | 127 | keymap.options = options; | 117 | keymap.options = options; |
2557 | 128 | keyboard->apply_keyboard_configuration(std::move(keymap)); | 118 | keyboard->apply_keyboard_configuration(std::move(keymap)); |
2558 | 129 | } | 119 | } |
2559 | 130 | #else | ||
2560 | 131 | void apply_keymap(std::shared_ptr<mir::input::Device> const&) | ||
2561 | 132 | { | ||
2562 | 133 | mir::log_warning("Cannot apply keymap - not supported for Mir versions prior to 0.24.1"); | ||
2563 | 134 | } | ||
2564 | 135 | #endif | ||
2565 | 136 | 120 | ||
2566 | 137 | void device_removed(std::shared_ptr<mir::input::Device> const& device) override | 121 | void device_removed(std::shared_ptr<mir::input::Device> const& device) override |
2567 | 138 | { | 122 | { |
2568 | 139 | 123 | ||
2569 | === removed file 'miral/mir_features.h.in' | |||
2570 | --- miral/mir_features.h.in 2017-02-17 15:06:53 +0000 | |||
2571 | +++ miral/mir_features.h.in 1970-01-01 00:00:00 +0000 | |||
2572 | @@ -1,29 +0,0 @@ | |||
2573 | 1 | /* | ||
2574 | 2 | * Copyright © 2016 Canonical Ltd. | ||
2575 | 3 | * | ||
2576 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2577 | 5 | * under the terms of the GNU General Public License version 3, | ||
2578 | 6 | * as published by the Free Software Foundation. | ||
2579 | 7 | * | ||
2580 | 8 | * This program is distributed in the hope that it will be useful, | ||
2581 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2582 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2583 | 11 | * GNU General Public License for more details. | ||
2584 | 12 | * | ||
2585 | 13 | * You should have received a copy of the GNU General Public License | ||
2586 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2587 | 15 | */ | ||
2588 | 16 | |||
2589 | 17 | #ifndef MIRAL_MIR_FEATURES_H | ||
2590 | 18 | #define MIRAL_MIR_FEATURES_H | ||
2591 | 19 | |||
2592 | 20 | // ============================================================ | ||
2593 | 21 | // ==> miral/detail/mir_features.h is generated by cmake. <== | ||
2594 | 22 | // ==> DO NOT EDIT! <== | ||
2595 | 23 | // ==> (edit mir_features.h.in instead) <== | ||
2596 | 24 | // ============================================================ | ||
2597 | 25 | |||
2598 | 26 | #define MIRAL_MIR_DEFINES_POINTER_CONFINEMENT (@MIR_POINTER_CONFINEMENT@) | ||
2599 | 27 | #define MIR_DEFINES_DISPLAY_CONFIG_GET_MUTABLE_OUTPUT (@MIR_DISPLAY_CONFIG_GET_MUTABLE@) | ||
2600 | 28 | |||
2601 | 29 | #endif // MIRAL_MIR_FEATURES_H | ||
2602 | 30 | 0 | ||
2603 | === modified file 'miral/mru_window_list.cpp' | |||
2604 | --- miral/mru_window_list.cpp 2017-02-17 15:23:49 +0000 | |||
2605 | +++ miral/mru_window_list.cpp 2017-06-20 16:14:05 +0000 | |||
2606 | @@ -18,7 +18,6 @@ | |||
2607 | 18 | 18 | ||
2608 | 19 | #include "mru_window_list.h" | 19 | #include "mru_window_list.h" |
2609 | 20 | 20 | ||
2610 | 21 | #include <mir/client/detail/mir_forward_compatibility.h> | ||
2611 | 22 | #include <mir/scene/surface.h> | 21 | #include <mir/scene/surface.h> |
2612 | 23 | 22 | ||
2613 | 24 | #include <algorithm> | 23 | #include <algorithm> |
2614 | 25 | 24 | ||
2615 | === modified file 'miral/runner.cpp' | |||
2616 | --- miral/runner.cpp 2017-03-02 13:47:28 +0000 | |||
2617 | +++ miral/runner.cpp 2017-06-20 16:14:05 +0000 | |||
2618 | @@ -30,10 +30,6 @@ | |||
2619 | 30 | #include <mutex> | 30 | #include <mutex> |
2620 | 31 | #include <thread> | 31 | #include <thread> |
2621 | 32 | 32 | ||
2622 | 33 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 24, 0) | ||
2623 | 34 | #include <csignal> | ||
2624 | 35 | #endif | ||
2625 | 36 | |||
2626 | 37 | namespace | 33 | namespace |
2627 | 38 | { | 34 | { |
2628 | 39 | inline auto filename(std::string path) -> std::string | 35 | inline auto filename(std::string path) -> std::string |
2629 | @@ -198,9 +194,7 @@ | |||
2630 | 198 | for (auto& option : options) | 194 | for (auto& option : options) |
2631 | 199 | option(*server); | 195 | option(*server); |
2632 | 200 | 196 | ||
2633 | 201 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
2634 | 202 | server->add_stop_callback(stop_callback); | 197 | server->add_stop_callback(stop_callback); |
2635 | 203 | #endif | ||
2636 | 204 | 198 | ||
2637 | 205 | // Provide the command line and run the server | 199 | // Provide the command line and run the server |
2638 | 206 | server->set_command_line(argc, argv); | 200 | server->set_command_line(argc, argv); |
2639 | @@ -220,10 +214,6 @@ | |||
2640 | 220 | auto const main_loop = server->the_main_loop(); | 214 | auto const main_loop = server->the_main_loop(); |
2641 | 221 | main_loop->enqueue(this, start_callback); | 215 | main_loop->enqueue(this, start_callback); |
2642 | 222 | 216 | ||
2643 | 223 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 24, 0) | ||
2644 | 224 | main_loop->register_signal_handler({SIGINT, SIGTERM}, [this](int) {stop_callback();}); | ||
2645 | 225 | #endif | ||
2646 | 226 | |||
2647 | 227 | server->run(); | 217 | server->run(); |
2648 | 228 | } | 218 | } |
2649 | 229 | 219 | ||
2650 | @@ -282,11 +272,6 @@ | |||
2651 | 282 | 272 | ||
2652 | 283 | if (auto const server = self->weak_server.lock()) | 273 | if (auto const server = self->weak_server.lock()) |
2653 | 284 | { | 274 | { |
2654 | 285 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 24, 0) | ||
2655 | 286 | // Before Mir-0.24 we can't intercept all stop() invocations, | ||
2656 | 287 | // but we can deal with the ones we pass on | ||
2657 | 288 | self->stop_callback(); | ||
2658 | 289 | #endif | ||
2659 | 290 | server->stop(); | 275 | server->stop(); |
2660 | 291 | } | 276 | } |
2661 | 292 | } | 277 | } |
2662 | 293 | 278 | ||
2663 | === modified file 'miral/set_window_management_policy.cpp' | |||
2664 | --- miral/set_window_management_policy.cpp 2017-03-22 10:03:25 +0000 | |||
2665 | +++ miral/set_window_management_policy.cpp 2017-06-20 16:14:05 +0000 | |||
2666 | @@ -64,11 +64,7 @@ | |||
2667 | 64 | { | 64 | { |
2668 | 65 | auto const display_layout = server.the_shell_display_layout(); | 65 | auto const display_layout = server.the_shell_display_layout(); |
2669 | 66 | 66 | ||
2670 | 67 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
2671 | 68 | auto const persistent_surface_store = server.the_persistent_surface_store(); | 67 | auto const persistent_surface_store = server.the_persistent_surface_store(); |
2672 | 69 | #else | ||
2673 | 70 | std::shared_ptr<mir::shell::PersistentSurfaceStore> const persistent_surface_store; | ||
2674 | 71 | #endif | ||
2675 | 72 | 68 | ||
2676 | 73 | if (server.get_options()->is_set(trace_option)) | 69 | if (server.get_options()->is_set(trace_option)) |
2677 | 74 | { | 70 | { |
2678 | 75 | 71 | ||
2679 | === modified file 'miral/symbols.map' | |||
2680 | --- miral/symbols.map 2017-03-15 17:44:36 +0000 | |||
2681 | +++ miral/symbols.map 2017-06-20 16:14:05 +0000 | |||
2682 | @@ -401,3 +401,24 @@ | |||
2683 | 401 | vtable?for?miral::SetWindowManagementPolicy; | 401 | vtable?for?miral::SetWindowManagementPolicy; |
2684 | 402 | }; | 402 | }; |
2685 | 403 | } MIRAL_1.3; | 403 | } MIRAL_1.3; |
2686 | 404 | |||
2687 | 405 | MIRAL_1.4.0 { | ||
2688 | 406 | global: | ||
2689 | 407 | extern "C++" { | ||
2690 | 408 | miral::WindowManagementPolicyAddendum2::?WindowManagementPolicyAddendum2*; | ||
2691 | 409 | miral::WindowManagementPolicyAddendum2::WindowManagementPolicyAddendum2*; | ||
2692 | 410 | miral::WindowManagementPolicyAddendum2::operator*; | ||
2693 | 411 | miral::WindowManagerTools::end_drag_and_drop*; | ||
2694 | 412 | miral::WindowManagerTools::start_drag_and_drop*; | ||
2695 | 413 | miral::toolkit::Window::Window*; | ||
2696 | 414 | non-virtual?thunk?to?miral::WindowManagementPolicyAddendum2::?WindowManagementPolicyAddendum2*; | ||
2697 | 415 | typeinfo?for?miral::WindowManagementPolicyAddendum2; | ||
2698 | 416 | typeinfo?for?miral::toolkit::Window; | ||
2699 | 417 | typeinfo?for?miral::toolkit::WindowId; | ||
2700 | 418 | typeinfo?for?miral::toolkit::WindowSpec; | ||
2701 | 419 | vtable?for?miral::WindowManagementPolicyAddendum2; | ||
2702 | 420 | vtable?for?miral::toolkit::Window; | ||
2703 | 421 | vtable?for?miral::toolkit::WindowId; | ||
2704 | 422 | vtable?for?miral::toolkit::WindowSpec; | ||
2705 | 423 | }; | ||
2706 | 424 | } MIRAL_1.3.1; | ||
2707 | 404 | 425 | ||
2708 | === modified file 'miral/window_management_options.cpp' | |||
2709 | --- miral/window_management_options.cpp 2016-09-21 14:43:46 +0000 | |||
2710 | +++ miral/window_management_options.cpp 2017-06-20 16:14:05 +0000 | |||
2711 | @@ -56,12 +56,8 @@ | |||
2712 | 56 | auto const selection = options->get<std::string>(wm_option); | 56 | auto const selection = options->get<std::string>(wm_option); |
2713 | 57 | 57 | ||
2714 | 58 | auto const display_layout = server.the_shell_display_layout(); | 58 | auto const display_layout = server.the_shell_display_layout(); |
2715 | 59 | |||
2716 | 60 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
2717 | 61 | auto const persistent_surface_store = server.the_persistent_surface_store(); | 59 | auto const persistent_surface_store = server.the_persistent_surface_store(); |
2721 | 62 | #else | 60 | |
2719 | 63 | std::shared_ptr<mir::shell::PersistentSurfaceStore> const persistent_surface_store; | ||
2720 | 64 | #endif | ||
2722 | 65 | for (auto const& option : policies) | 61 | for (auto const& option : policies) |
2723 | 66 | { | 62 | { |
2724 | 67 | if (selection == option.name) | 63 | if (selection == option.name) |
2725 | 68 | 64 | ||
2726 | === modified file 'miral/window_management_trace.cpp' | |||
2727 | --- miral/window_management_trace.cpp 2017-03-03 10:06:02 +0000 | |||
2728 | +++ miral/window_management_trace.cpp 2017-06-20 16:14:05 +0000 | |||
2729 | @@ -547,6 +547,24 @@ | |||
2730 | 547 | } | 547 | } |
2731 | 548 | MIRAL_TRACE_EXCEPTION | 548 | MIRAL_TRACE_EXCEPTION |
2732 | 549 | 549 | ||
2733 | 550 | void miral::WindowManagementTrace::start_drag_and_drop(miral::WindowInfo& window_info, std::vector<uint8_t> const& handle) | ||
2734 | 551 | try { | ||
2735 | 552 | log_input(); | ||
2736 | 553 | mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); | ||
2737 | 554 | trace_count++; | ||
2738 | 555 | wrapped.start_drag_and_drop(window_info, handle); | ||
2739 | 556 | } | ||
2740 | 557 | MIRAL_TRACE_EXCEPTION | ||
2741 | 558 | |||
2742 | 559 | void miral::WindowManagementTrace::end_drag_and_drop() | ||
2743 | 560 | try { | ||
2744 | 561 | log_input(); | ||
2745 | 562 | mir::log_info("%s window_info=%s", __func__); | ||
2746 | 563 | trace_count++; | ||
2747 | 564 | wrapped.end_drag_and_drop(); | ||
2748 | 565 | } | ||
2749 | 566 | MIRAL_TRACE_EXCEPTION | ||
2750 | 567 | |||
2751 | 550 | void miral::WindowManagementTrace::modify_window( | 568 | void miral::WindowManagementTrace::modify_window( |
2752 | 551 | miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) | 569 | miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) |
2753 | 552 | try { | 570 | try { |
2754 | 553 | 571 | ||
2755 | === modified file 'miral/window_management_trace.h' | |||
2756 | --- miral/window_management_trace.h 2017-03-02 14:29:04 +0000 | |||
2757 | +++ miral/window_management_trace.h 2017-06-20 16:14:05 +0000 | |||
2758 | @@ -69,6 +69,8 @@ | |||
2759 | 69 | virtual void focus_prev_within_application() override; | 69 | virtual void focus_prev_within_application() override; |
2760 | 70 | 70 | ||
2761 | 71 | virtual void raise_tree(Window const& root) override; | 71 | virtual void raise_tree(Window const& root) override; |
2762 | 72 | virtual void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) override; | ||
2763 | 73 | virtual void end_drag_and_drop() override; | ||
2764 | 72 | 74 | ||
2765 | 73 | virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override; | 75 | virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override; |
2766 | 74 | 76 | ||
2767 | 75 | 77 | ||
2768 | === modified file 'miral/window_manager_tools.cpp' | |||
2769 | --- miral/window_manager_tools.cpp 2017-03-02 14:29:04 +0000 | |||
2770 | +++ miral/window_manager_tools.cpp 2017-06-20 16:14:05 +0000 | |||
2771 | @@ -83,6 +83,12 @@ | |||
2772 | 83 | void miral::WindowManagerTools::raise_tree(Window const& root) | 83 | void miral::WindowManagerTools::raise_tree(Window const& root) |
2773 | 84 | { tools->raise_tree(root); } | 84 | { tools->raise_tree(root); } |
2774 | 85 | 85 | ||
2775 | 86 | void miral::WindowManagerTools::start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) | ||
2776 | 87 | { tools->start_drag_and_drop(window_info, handle); } | ||
2777 | 88 | |||
2778 | 89 | void miral::WindowManagerTools::end_drag_and_drop() | ||
2779 | 90 | { tools->end_drag_and_drop(); } | ||
2780 | 91 | |||
2781 | 86 | void miral::WindowManagerTools::modify_window(WindowInfo& window_info, WindowSpecification const& modifications) | 92 | void miral::WindowManagerTools::modify_window(WindowInfo& window_info, WindowSpecification const& modifications) |
2782 | 87 | { tools->modify_window(window_info,modifications); } | 93 | { tools->modify_window(window_info,modifications); } |
2783 | 88 | 94 | ||
2784 | 89 | 95 | ||
2785 | === modified file 'miral/window_manager_tools_implementation.h' | |||
2786 | --- miral/window_manager_tools_implementation.h 2017-03-02 14:29:04 +0000 | |||
2787 | +++ miral/window_manager_tools_implementation.h 2017-06-20 16:14:05 +0000 | |||
2788 | @@ -26,6 +26,7 @@ | |||
2789 | 26 | 26 | ||
2790 | 27 | #include <functional> | 27 | #include <functional> |
2791 | 28 | #include <memory> | 28 | #include <memory> |
2792 | 29 | #include <vector> | ||
2793 | 29 | 30 | ||
2794 | 30 | namespace mir { namespace scene { class Surface; } } | 31 | namespace mir { namespace scene { class Surface; } } |
2795 | 31 | 32 | ||
2796 | @@ -66,6 +67,8 @@ | |||
2797 | 66 | virtual auto window_at(mir::geometry::Point cursor) const -> Window = 0; | 67 | virtual auto window_at(mir::geometry::Point cursor) const -> Window = 0; |
2798 | 67 | virtual auto active_display() -> mir::geometry::Rectangle const = 0; | 68 | virtual auto active_display() -> mir::geometry::Rectangle const = 0; |
2799 | 68 | virtual void raise_tree(Window const& root) = 0; | 69 | virtual void raise_tree(Window const& root) = 0; |
2800 | 70 | virtual void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) = 0; | ||
2801 | 71 | virtual void end_drag_and_drop() = 0; | ||
2802 | 69 | virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0; | 72 | virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0; |
2803 | 70 | virtual auto info_for_window_id(std::string const& id) const -> WindowInfo& = 0; | 73 | virtual auto info_for_window_id(std::string const& id) const -> WindowInfo& = 0; |
2804 | 71 | virtual auto id_for_window(Window const& window) const -> std::string = 0; | 74 | virtual auto id_for_window(Window const& window) const -> std::string = 0; |
2805 | 72 | 75 | ||
2806 | === modified file 'miral/window_specification.cpp' | |||
2807 | --- miral/window_specification.cpp 2017-01-13 18:17:01 +0000 | |||
2808 | +++ miral/window_specification.cpp 2017-06-20 16:14:05 +0000 | |||
2809 | @@ -74,11 +74,9 @@ | |||
2810 | 74 | state(spec.state), | 74 | state(spec.state), |
2811 | 75 | preferred_orientation(spec.preferred_orientation), | 75 | preferred_orientation(spec.preferred_orientation), |
2812 | 76 | aux_rect(spec.aux_rect), | 76 | aux_rect(spec.aux_rect), |
2813 | 77 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
2814 | 78 | placement_hints(spec.placement_hints), | 77 | placement_hints(spec.placement_hints), |
2815 | 79 | window_placement_gravity(spec.surface_placement_gravity), | 78 | window_placement_gravity(spec.surface_placement_gravity), |
2816 | 80 | aux_rect_placement_gravity(spec.aux_rect_placement_gravity), | 79 | aux_rect_placement_gravity(spec.aux_rect_placement_gravity), |
2817 | 81 | #endif | ||
2818 | 82 | min_width(spec.min_width), | 80 | min_width(spec.min_width), |
2819 | 83 | min_height(spec.min_height), | 81 | min_height(spec.min_height), |
2820 | 84 | max_width(spec.max_width), | 82 | max_width(spec.max_width), |
2821 | @@ -92,24 +90,10 @@ | |||
2822 | 92 | input_shape(spec.input_shape), | 90 | input_shape(spec.input_shape), |
2823 | 93 | input_mode(), | 91 | input_mode(), |
2824 | 94 | shell_chrome(spec.shell_chrome) | 92 | shell_chrome(spec.shell_chrome) |
2825 | 95 | #if MIRAL_MIR_DEFINES_POINTER_CONFINEMENT | ||
2826 | 96 | ,confine_pointer(spec.confine_pointer) | 93 | ,confine_pointer(spec.confine_pointer) |
2827 | 97 | #endif | ||
2828 | 98 | { | 94 | { |
2829 | 99 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
2830 | 100 | if (spec.aux_rect_placement_offset_x.is_set() && spec.aux_rect_placement_offset_y.is_set()) | 95 | if (spec.aux_rect_placement_offset_x.is_set() && spec.aux_rect_placement_offset_y.is_set()) |
2831 | 101 | aux_rect_placement_offset = Displacement{spec.aux_rect_placement_offset_x.value(), spec.aux_rect_placement_offset_y.value()}; | 96 | aux_rect_placement_offset = Displacement{spec.aux_rect_placement_offset_x.value(), spec.aux_rect_placement_offset_y.value()}; |
2832 | 102 | #endif | ||
2833 | 103 | |||
2834 | 104 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 25, 0) | ||
2835 | 105 | // mir_connection_create_spec_for_tooltip() didn't set an edge_attachment preference | ||
2836 | 106 | if (aux_rect.is_set() && !spec.edge_attachment.is_set()) | ||
2837 | 107 | { | ||
2838 | 108 | window_placement_gravity = mir_placement_gravity_northwest; | ||
2839 | 109 | aux_rect_placement_gravity = mir_placement_gravity_northeast; | ||
2840 | 110 | placement_hints = mir_placement_hints_flip_any; | ||
2841 | 111 | } | ||
2842 | 112 | #endif | ||
2843 | 113 | 97 | ||
2844 | 114 | if (spec.edge_attachment.is_set() && !placement_hints.is_set()) | 98 | if (spec.edge_attachment.is_set() && !placement_hints.is_set()) |
2845 | 115 | { | 99 | { |
2846 | @@ -166,12 +150,6 @@ | |||
2847 | 166 | } | 150 | } |
2848 | 167 | 151 | ||
2849 | 168 | template<typename Source> | 152 | template<typename Source> |
2850 | 169 | void copy_if_set(mir::optional_value<mir::graphics::BufferUsage>& dest, mir::optional_value<Source> const& source) | ||
2851 | 170 | { | ||
2852 | 171 | if (source.is_set()) dest = static_cast<mir::graphics::BufferUsage>(source.value()); | ||
2853 | 172 | } | ||
2854 | 173 | |||
2855 | 174 | template<typename Source> | ||
2856 | 175 | void copy_if_set(mir::graphics::BufferUsage& dest, mir::optional_value<Source> const& source) | 153 | void copy_if_set(mir::graphics::BufferUsage& dest, mir::optional_value<Source> const& source) |
2857 | 176 | { | 154 | { |
2858 | 177 | if (source.is_set()) dest = static_cast<mir::graphics::BufferUsage>(source.value()); | 155 | if (source.is_set()) dest = static_cast<mir::graphics::BufferUsage>(source.value()); |
2859 | @@ -179,14 +157,6 @@ | |||
2860 | 179 | 157 | ||
2861 | 180 | template<typename Source> | 158 | template<typename Source> |
2862 | 181 | void copy_if_set( | 159 | void copy_if_set( |
2863 | 182 | mir::optional_value<mir::graphics::DisplayConfigurationOutputId>& dest, | ||
2864 | 183 | mir::optional_value<Source> const& source) | ||
2865 | 184 | { | ||
2866 | 185 | if (source.is_set()) dest = static_cast<mir::graphics::DisplayConfigurationOutputId>(source.value()); | ||
2867 | 186 | } | ||
2868 | 187 | |||
2869 | 188 | template<typename Source> | ||
2870 | 189 | void copy_if_set( | ||
2871 | 190 | mir::graphics::DisplayConfigurationOutputId& dest, | 160 | mir::graphics::DisplayConfigurationOutputId& dest, |
2872 | 191 | mir::optional_value<Source> const& source) | 161 | mir::optional_value<Source> const& source) |
2873 | 192 | { | 162 | { |
2874 | @@ -229,11 +199,9 @@ | |||
2875 | 229 | state(params.state), | 199 | state(params.state), |
2876 | 230 | preferred_orientation(params.preferred_orientation), | 200 | preferred_orientation(params.preferred_orientation), |
2877 | 231 | aux_rect(params.aux_rect), | 201 | aux_rect(params.aux_rect), |
2878 | 232 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
2879 | 233 | placement_hints(params.placement_hints), | 202 | placement_hints(params.placement_hints), |
2880 | 234 | window_placement_gravity(params.surface_placement_gravity), | 203 | window_placement_gravity(params.surface_placement_gravity), |
2881 | 235 | aux_rect_placement_gravity(params.aux_rect_placement_gravity), | 204 | aux_rect_placement_gravity(params.aux_rect_placement_gravity), |
2882 | 236 | #endif | ||
2883 | 237 | min_width(params.min_width), | 205 | min_width(params.min_width), |
2884 | 238 | min_height(params.min_height), | 206 | min_height(params.min_height), |
2885 | 239 | max_width(params.max_width), | 207 | max_width(params.max_width), |
2886 | @@ -242,33 +210,15 @@ | |||
2887 | 242 | height_inc(params.height_inc), | 210 | height_inc(params.height_inc), |
2888 | 243 | min_aspect(), | 211 | min_aspect(), |
2889 | 244 | max_aspect(), | 212 | max_aspect(), |
2890 | 245 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 22, 0) | ||
2891 | 246 | streams(params.streams), | 213 | streams(params.streams), |
2892 | 247 | #else | ||
2893 | 248 | streams(), | ||
2894 | 249 | #endif | ||
2895 | 250 | parent(params.parent), | 214 | parent(params.parent), |
2896 | 251 | input_shape(params.input_shape), | 215 | input_shape(params.input_shape), |
2897 | 252 | input_mode(static_cast<InputReceptionMode>(params.input_mode)), | 216 | input_mode(static_cast<InputReceptionMode>(params.input_mode)), |
2898 | 253 | shell_chrome(params.shell_chrome) | 217 | shell_chrome(params.shell_chrome) |
2899 | 254 | #if MIRAL_MIR_DEFINES_POINTER_CONFINEMENT | ||
2900 | 255 | ,confine_pointer(params.confine_pointer) | 218 | ,confine_pointer(params.confine_pointer) |
2901 | 256 | #endif | ||
2902 | 257 | { | 219 | { |
2903 | 258 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
2904 | 259 | if (params.aux_rect_placement_offset_x.is_set() && params.aux_rect_placement_offset_y.is_set()) | 220 | if (params.aux_rect_placement_offset_x.is_set() && params.aux_rect_placement_offset_y.is_set()) |
2905 | 260 | aux_rect_placement_offset = Displacement{params.aux_rect_placement_offset_x.value(), params.aux_rect_placement_offset_y.value()}; | 221 | aux_rect_placement_offset = Displacement{params.aux_rect_placement_offset_x.value(), params.aux_rect_placement_offset_y.value()}; |
2906 | 261 | #endif | ||
2907 | 262 | |||
2908 | 263 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 25, 0) | ||
2909 | 264 | // mir_connection_create_spec_for_tooltip() didn't set an edge_attachment preference | ||
2910 | 265 | if (aux_rect.is_set() && !params.edge_attachment.is_set()) | ||
2911 | 266 | { | ||
2912 | 267 | window_placement_gravity = mir_placement_gravity_northwest; | ||
2913 | 268 | aux_rect_placement_gravity = mir_placement_gravity_northeast; | ||
2914 | 269 | placement_hints = mir_placement_hints_flip_any; | ||
2915 | 270 | } | ||
2916 | 271 | #endif | ||
2917 | 272 | 222 | ||
2918 | 273 | if (params.edge_attachment.is_set() && !placement_hints.is_set()) | 223 | if (params.edge_attachment.is_set() && !placement_hints.is_set()) |
2919 | 274 | { | 224 | { |
2920 | @@ -325,18 +275,12 @@ | |||
2921 | 325 | copy_if_set(params.height_inc, height_inc); | 275 | copy_if_set(params.height_inc, height_inc); |
2922 | 326 | copy_if_set(params.min_aspect, min_aspect); | 276 | copy_if_set(params.min_aspect, min_aspect); |
2923 | 327 | copy_if_set(params.max_aspect, max_aspect); | 277 | copy_if_set(params.max_aspect, max_aspect); |
2924 | 328 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 22, 0) | ||
2925 | 329 | copy_if_set(params.streams, streams); | 278 | copy_if_set(params.streams, streams); |
2926 | 330 | #endif | ||
2927 | 331 | copy_if_set(params.parent, parent); | 279 | copy_if_set(params.parent, parent); |
2928 | 332 | copy_if_set(params.input_shape, input_shape); | 280 | copy_if_set(params.input_shape, input_shape); |
2929 | 333 | copy_if_set(params.input_mode, input_mode); | 281 | copy_if_set(params.input_mode, input_mode); |
2930 | 334 | copy_if_set(params.shell_chrome, shell_chrome); | 282 | copy_if_set(params.shell_chrome, shell_chrome); |
2931 | 335 | #if MIRAL_MIR_DEFINES_POINTER_CONFINEMENT | ||
2932 | 336 | copy_if_set(params.confine_pointer, confine_pointer); | 283 | copy_if_set(params.confine_pointer, confine_pointer); |
2933 | 337 | #endif | ||
2934 | 338 | |||
2935 | 339 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
2936 | 340 | copy_if_set(params.placement_hints, placement_hints); | 284 | copy_if_set(params.placement_hints, placement_hints); |
2937 | 341 | copy_if_set(params.surface_placement_gravity, window_placement_gravity); | 285 | copy_if_set(params.surface_placement_gravity, window_placement_gravity); |
2938 | 342 | copy_if_set(params.aux_rect_placement_gravity, aux_rect_placement_gravity); | 286 | copy_if_set(params.aux_rect_placement_gravity, aux_rect_placement_gravity); |
2939 | @@ -347,7 +291,6 @@ | |||
2940 | 347 | params.aux_rect_placement_offset_x = offset.dx.as_int(); | 291 | params.aux_rect_placement_offset_x = offset.dx.as_int(); |
2941 | 348 | params.aux_rect_placement_offset_y = offset.dy.as_int(); | 292 | params.aux_rect_placement_offset_y = offset.dy.as_int(); |
2942 | 349 | } | 293 | } |
2943 | 350 | #endif | ||
2944 | 351 | } | 294 | } |
2945 | 352 | 295 | ||
2946 | 353 | miral::WindowSpecification::WindowSpecification() : | 296 | miral::WindowSpecification::WindowSpecification() : |
2947 | 354 | 297 | ||
2948 | === modified file 'scripts/process_doxygen_xml.py' | |||
2949 | --- scripts/process_doxygen_xml.py 2017-03-15 17:44:36 +0000 | |||
2950 | +++ scripts/process_doxygen_xml.py 2017-06-20 16:14:05 +0000 | |||
2951 | @@ -476,10 +476,21 @@ | |||
2952 | 476 | 476 | ||
2953 | 477 | MIRAL_1.3.1 { | 477 | MIRAL_1.3.1 { |
2954 | 478 | global: | 478 | global: |
2955 | 479 | extern "C++" { | ||
2956 | 480 | miral::SetWindowManagementPolicy::?SetWindowManagementPolicy*; | ||
2957 | 481 | miral::SetWindowManagementPolicy::SetWindowManagementPolicy*; | ||
2958 | 482 | miral::SetWindowManagementPolicy::operator*; | ||
2959 | 483 | typeinfo?for?miral::SetWindowManagementPolicy; | ||
2960 | 484 | vtable?for?miral::SetWindowManagementPolicy; | ||
2961 | 485 | }; | ||
2962 | 486 | } MIRAL_1.3; | ||
2963 | 487 | |||
2964 | 488 | MIRAL_1.4.0 { | ||
2965 | 489 | global: | ||
2966 | 479 | extern "C++" {''' | 490 | extern "C++" {''' |
2967 | 480 | 491 | ||
2968 | 481 | END_NEW_STANZA = ''' }; | 492 | END_NEW_STANZA = ''' }; |
2970 | 482 | } MIRAL_1.3;''' | 493 | } MIRAL_1.3.1;''' |
2971 | 483 | 494 | ||
2972 | 484 | def _print_report(): | 495 | def _print_report(): |
2973 | 485 | print OLD_STANZAS | 496 | print OLD_STANZAS |
2974 | 486 | 497 | ||
2975 | === modified file 'test/CMakeLists.txt' | |||
2976 | --- test/CMakeLists.txt 2017-02-13 16:23:29 +0000 | |||
2977 | +++ test/CMakeLists.txt 2017-06-20 16:14:05 +0000 | |||
2978 | @@ -39,6 +39,16 @@ | |||
2979 | 39 | ${GTEST_INCLUDE_DIR} | 39 | ${GTEST_INCLUDE_DIR} |
2980 | 40 | ) | 40 | ) |
2981 | 41 | 41 | ||
2982 | 42 | # MIRAL_TEST_MODERN_FEATURES lists test sourcefiles that require a recent version of Mir | ||
2983 | 43 | if (MIRTEST_VERSION VERSION_LESS 0.27) | ||
2984 | 44 | set(MIRAL_TEST_MODERN_FEATURES) | ||
2985 | 45 | else() | ||
2986 | 46 | set(MIRAL_TEST_MODERN_FEATURES | ||
2987 | 47 | drag_and_drop.cpp | ||
2988 | 48 | client_mediated_gestures.cpp | ||
2989 | 49 | ) | ||
2990 | 50 | endif() | ||
2991 | 51 | |||
2992 | 42 | add_executable(miral-test | 52 | add_executable(miral-test |
2993 | 43 | mru_window_list.cpp | 53 | mru_window_list.cpp |
2994 | 44 | active_outputs.cpp | 54 | active_outputs.cpp |
2995 | @@ -56,7 +66,9 @@ | |||
2996 | 56 | display_reconfiguration.cpp | 66 | display_reconfiguration.cpp |
2997 | 57 | active_window.cpp | 67 | active_window.cpp |
2998 | 58 | raise_tree.cpp | 68 | raise_tree.cpp |
3000 | 59 | workspaces.cpp) | 69 | workspaces.cpp |
3001 | 70 | ${MIRAL_TEST_MODERN_FEATURES} | ||
3002 | 71 | ) | ||
3003 | 60 | 72 | ||
3004 | 61 | target_link_libraries(miral-test | 73 | target_link_libraries(miral-test |
3005 | 62 | ${MIRTEST_LDFLAGS} | 74 | ${MIRTEST_LDFLAGS} |
3006 | 63 | 75 | ||
3007 | === modified file 'test/active_window.cpp' | |||
3008 | --- test/active_window.cpp 2017-03-16 16:57:38 +0000 | |||
3009 | +++ test/active_window.cpp 2017-06-20 16:14:05 +0000 | |||
3010 | @@ -18,10 +18,10 @@ | |||
3011 | 18 | 18 | ||
3012 | 19 | #include "test_server.h" | 19 | #include "test_server.h" |
3013 | 20 | 20 | ||
3014 | 21 | #include <mir/client/surface.h> | ||
3015 | 21 | #include <mir/client/window.h> | 22 | #include <mir/client/window.h> |
3016 | 22 | #include <mir/client/window_spec.h> | 23 | #include <mir/client/window_spec.h> |
3017 | 23 | #include <mir_toolkit/mir_buffer_stream.h> | 24 | #include <mir_toolkit/mir_buffer_stream.h> |
3018 | 24 | #include <mir_toolkit/version.h> | ||
3019 | 25 | 25 | ||
3020 | 26 | #include <miral/application_info.h> | 26 | #include <miral/application_info.h> |
3021 | 27 | 27 | ||
3022 | @@ -35,11 +35,6 @@ | |||
3023 | 35 | using namespace std::chrono_literals; | 35 | using namespace std::chrono_literals; |
3024 | 36 | using miral::WindowManagerTools; | 36 | using miral::WindowManagerTools; |
3025 | 37 | 37 | ||
3026 | 38 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
3027 | 39 | auto const mir_event_type_window = mir_event_type_surface; | ||
3028 | 40 | auto const mir_window_event_get_attribute = mir_surface_event_get_attribute; | ||
3029 | 41 | auto const mir_event_get_window_event = mir_event_get_surface_event; | ||
3030 | 42 | #endif | ||
3031 | 43 | 38 | ||
3032 | 44 | namespace | 39 | namespace |
3033 | 45 | { | 40 | { |
3034 | @@ -68,58 +63,79 @@ | |||
3035 | 68 | mir::test::Signal signal; | 63 | mir::test::Signal signal; |
3036 | 69 | }; | 64 | }; |
3037 | 70 | 65 | ||
3038 | 66 | struct TestWindow : Surface, Window | ||
3039 | 67 | { | ||
3040 | 68 | using Surface::operator=; | ||
3041 | 69 | using Window::operator=; | ||
3042 | 70 | }; | ||
3043 | 71 | |||
3044 | 71 | struct ActiveWindow : public miral::TestServer | 72 | struct ActiveWindow : public miral::TestServer |
3045 | 72 | { | 73 | { |
3046 | 73 | FocusChangeSync sync1; | 74 | FocusChangeSync sync1; |
3047 | 74 | FocusChangeSync sync2; | 75 | FocusChangeSync sync2; |
3048 | 75 | 76 | ||
3053 | 76 | auto create_surface(Connection const& connection, char const* name, FocusChangeSync& sync) -> Window | 77 | void paint(Surface const& surface) |
3054 | 77 | { | 78 | { |
3055 | 78 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888) | 79 | mir_buffer_stream_swap_buffers_sync( |
3056 | 79 | .set_buffer_usage(mir_buffer_usage_software) | 80 | mir_render_surface_get_buffer_stream(surface, 50, 50, mir_pixel_format_argb_8888)); |
3057 | 81 | } | ||
3058 | 82 | |||
3059 | 83 | auto create_window(Connection const& connection, char const* name, FocusChangeSync& sync) -> TestWindow | ||
3060 | 84 | { | ||
3061 | 85 | TestWindow result; | ||
3062 | 86 | |||
3063 | 87 | result = Surface{mir_connection_create_render_surface_sync(connection, 50, 50)}; | ||
3064 | 88 | |||
3065 | 89 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50) | ||
3066 | 80 | .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync) | 90 | .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync) |
3067 | 91 | .add_surface(result, 50, 50, 0, 0) | ||
3068 | 81 | .set_name(name); | 92 | .set_name(name); |
3069 | 82 | 93 | ||
3073 | 83 | Window const surface{spec.create_window()}; | 94 | result = Window{spec.create_window()}; |
3074 | 84 | 95 | ||
3075 | 85 | sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); }); | 96 | sync.exec([&]{ paint(result); }); |
3076 | 97 | |||
3077 | 86 | EXPECT_TRUE(sync.signal_raised()); | 98 | EXPECT_TRUE(sync.signal_raised()); |
3078 | 87 | 99 | ||
3080 | 88 | return surface; | 100 | return result; |
3081 | 89 | } | 101 | } |
3082 | 90 | 102 | ||
3085 | 91 | #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) | 103 | auto create_tip(Connection const& connection, char const* name, Window const& parent, FocusChangeSync& sync) -> TestWindow |
3084 | 92 | auto create_tip(Connection const& connection, char const* name, Window const& parent, FocusChangeSync& sync) -> Window | ||
3086 | 93 | { | 104 | { |
3087 | 105 | TestWindow result; | ||
3088 | 106 | result = Surface{mir_connection_create_render_surface_sync(connection, 50, 50)}; | ||
3089 | 107 | |||
3090 | 94 | MirRectangle aux_rect{10, 10, 10, 10}; | 108 | MirRectangle aux_rect{10, 10, 10, 10}; |
3093 | 95 | auto const spec = WindowSpec::for_tip(connection, 50, 50, mir_pixel_format_argb_8888, parent, &aux_rect, mir_edge_attachment_any) | 109 | auto const spec = WindowSpec::for_tip(connection, 50, 50, parent, &aux_rect, mir_edge_attachment_any) |
3092 | 96 | .set_buffer_usage(mir_buffer_usage_software) | ||
3094 | 97 | .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync) | 110 | .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync) |
3095 | 111 | .add_surface(result, 50, 50, 0, 0) | ||
3096 | 98 | .set_name(name); | 112 | .set_name(name); |
3097 | 99 | 113 | ||
3099 | 100 | Window const surface{spec.create_window()}; | 114 | result = Window{spec.create_window()}; |
3100 | 101 | 115 | ||
3101 | 102 | // Expect this to timeout: A tip should not receive focus | 116 | // Expect this to timeout: A tip should not receive focus |
3103 | 103 | sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); }); | 117 | sync.exec([&]{ paint(result); }); |
3104 | 104 | EXPECT_FALSE(sync.signal_raised()); | 118 | EXPECT_FALSE(sync.signal_raised()); |
3105 | 105 | 119 | ||
3107 | 106 | return surface; | 120 | return result; |
3108 | 107 | } | 121 | } |
3109 | 108 | #endif | ||
3110 | 109 | 122 | ||
3112 | 110 | auto create_dialog(Connection const& connection, char const* name, Window const& parent, FocusChangeSync& sync) -> Window | 123 | auto create_dialog(Connection const& connection, char const* name, Window const& parent, FocusChangeSync& sync) -> TestWindow |
3113 | 111 | { | 124 | { |
3116 | 112 | auto const spec = WindowSpec::for_dialog(connection, 50, 50, mir_pixel_format_argb_8888, parent) | 125 | TestWindow result; |
3117 | 113 | .set_buffer_usage(mir_buffer_usage_software) | 126 | result = Surface{mir_connection_create_render_surface_sync(connection, 50, 50)}; |
3118 | 127 | |||
3119 | 128 | auto const spec = WindowSpec::for_dialog(connection, 50, 50, parent) | ||
3120 | 114 | .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync) | 129 | .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync) |
3121 | 130 | .add_surface(result, 50, 50, 0, 0) | ||
3122 | 115 | .set_name(name); | 131 | .set_name(name); |
3123 | 116 | 132 | ||
3125 | 117 | Window const surface{spec.create_window()}; | 133 | result = Window{spec.create_window()}; |
3126 | 118 | 134 | ||
3128 | 119 | sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); }); | 135 | sync.exec([&]{ paint(result); }); |
3129 | 120 | EXPECT_TRUE(sync.signal_raised()); | 136 | EXPECT_TRUE(sync.signal_raised()); |
3130 | 121 | 137 | ||
3132 | 122 | return surface; | 138 | return result; |
3133 | 123 | } | 139 | } |
3134 | 124 | 140 | ||
3135 | 125 | void assert_no_active_window() | 141 | void assert_no_active_window() |
3136 | @@ -151,7 +167,7 @@ | |||
3137 | 151 | char const* const test_name = __PRETTY_FUNCTION__; | 167 | char const* const test_name = __PRETTY_FUNCTION__; |
3138 | 152 | auto const connection = connect_client(test_name); | 168 | auto const connection = connect_client(test_name); |
3139 | 153 | 169 | ||
3141 | 154 | auto const surface = create_surface(connection, test_name, sync1); | 170 | auto const window = create_window(connection, test_name, sync1); |
3142 | 155 | 171 | ||
3143 | 156 | assert_active_window_is(test_name); | 172 | assert_active_window_is(test_name); |
3144 | 157 | } | 173 | } |
3145 | @@ -160,9 +176,9 @@ | |||
3146 | 160 | { | 176 | { |
3147 | 161 | char const* const test_name = __PRETTY_FUNCTION__; | 177 | char const* const test_name = __PRETTY_FUNCTION__; |
3148 | 162 | auto const connection = connect_client(test_name); | 178 | auto const connection = connect_client(test_name); |
3150 | 163 | auto const surface = create_surface(connection, test_name, sync1); | 179 | auto const window = create_window(connection, test_name, sync1); |
3151 | 164 | 180 | ||
3153 | 165 | sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); }); | 181 | sync1.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); }); |
3154 | 166 | 182 | ||
3155 | 167 | EXPECT_TRUE(sync1.signal_raised()); | 183 | EXPECT_TRUE(sync1.signal_raised()); |
3156 | 168 | assert_no_active_window(); | 184 | assert_no_active_window(); |
3157 | @@ -172,11 +188,11 @@ | |||
3158 | 172 | { | 188 | { |
3159 | 173 | char const* const test_name = __PRETTY_FUNCTION__; | 189 | char const* const test_name = __PRETTY_FUNCTION__; |
3160 | 174 | auto const connection = connect_client(test_name); | 190 | auto const connection = connect_client(test_name); |
3166 | 175 | auto const surface = create_surface(connection, test_name, sync1); | 191 | auto const window = create_window(connection, test_name, sync1); |
3167 | 176 | 192 | ||
3168 | 177 | sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); }); | 193 | sync1.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); }); |
3169 | 178 | 194 | ||
3170 | 179 | sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_restored); }); | 195 | sync1.exec([&]{ mir_window_set_state(window, mir_window_state_restored); }); |
3171 | 180 | 196 | ||
3172 | 181 | EXPECT_TRUE(sync1.signal_raised()); | 197 | EXPECT_TRUE(sync1.signal_raised()); |
3173 | 182 | 198 | ||
3174 | @@ -188,8 +204,8 @@ | |||
3175 | 188 | char const* const test_name = __PRETTY_FUNCTION__; | 204 | char const* const test_name = __PRETTY_FUNCTION__; |
3176 | 189 | auto const connection = connect_client(test_name); | 205 | auto const connection = connect_client(test_name); |
3177 | 190 | 206 | ||
3180 | 191 | auto const first_surface = create_surface(connection, "first", sync1); | 207 | auto const first_window = create_window(connection, "first", sync1); |
3181 | 192 | auto const surface = create_surface(connection, test_name, sync2); | 208 | auto const window = create_window(connection, test_name, sync2); |
3182 | 193 | 209 | ||
3183 | 194 | assert_active_window_is(test_name); | 210 | assert_active_window_is(test_name); |
3184 | 195 | } | 211 | } |
3185 | @@ -199,10 +215,10 @@ | |||
3186 | 199 | char const* const test_name = __PRETTY_FUNCTION__; | 215 | char const* const test_name = __PRETTY_FUNCTION__; |
3187 | 200 | auto const connection = connect_client(test_name); | 216 | auto const connection = connect_client(test_name); |
3188 | 201 | 217 | ||
3191 | 202 | auto const first_surface = create_surface(connection, test_name, sync1); | 218 | auto const first_window = create_window(connection, test_name, sync1); |
3192 | 203 | auto const surface = create_surface(connection, another_name, sync2); | 219 | auto const window = create_window(connection, another_name, sync2); |
3193 | 204 | 220 | ||
3195 | 205 | sync2.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); }); | 221 | sync2.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); }); |
3196 | 206 | 222 | ||
3197 | 207 | EXPECT_TRUE(sync2.signal_raised()); | 223 | EXPECT_TRUE(sync2.signal_raised()); |
3198 | 208 | assert_active_window_is(test_name); | 224 | assert_active_window_is(test_name); |
3199 | @@ -213,13 +229,13 @@ | |||
3200 | 213 | char const* const test_name = __PRETTY_FUNCTION__; | 229 | char const* const test_name = __PRETTY_FUNCTION__; |
3201 | 214 | auto const connection = connect_client(test_name); | 230 | auto const connection = connect_client(test_name); |
3202 | 215 | 231 | ||
3205 | 216 | auto const first_surface = create_surface(connection, test_name, sync1); | 232 | auto const first_window = create_window(connection, test_name, sync1); |
3206 | 217 | auto const surface = create_surface(connection, another_name, sync2); | 233 | auto const window = create_window(connection, another_name, sync2); |
3207 | 218 | 234 | ||
3209 | 219 | sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); }); | 235 | sync1.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); }); |
3210 | 220 | 236 | ||
3211 | 221 | // Expect this to timeout | 237 | // Expect this to timeout |
3213 | 222 | sync2.exec([&]{ mir_window_set_state(surface, mir_window_state_restored); }); | 238 | sync2.exec([&]{ mir_window_set_state(window, mir_window_state_restored); }); |
3214 | 223 | 239 | ||
3215 | 224 | EXPECT_THAT(sync2.signal_raised(), Eq(false)); | 240 | EXPECT_THAT(sync2.signal_raised(), Eq(false)); |
3216 | 225 | assert_active_window_is(test_name); | 241 | assert_active_window_is(test_name); |
3217 | @@ -230,8 +246,8 @@ | |||
3218 | 230 | char const* const test_name = __PRETTY_FUNCTION__; | 246 | char const* const test_name = __PRETTY_FUNCTION__; |
3219 | 231 | auto const connection = connect_client(test_name); | 247 | auto const connection = connect_client(test_name); |
3220 | 232 | 248 | ||
3223 | 233 | auto const first_surface = create_surface(connection, test_name, sync1); | 249 | auto const first_window = create_window(connection, test_name, sync1); |
3224 | 234 | auto const surface = create_surface(connection, another_name, sync2); | 250 | auto const window = create_window(connection, another_name, sync2); |
3225 | 235 | 251 | ||
3226 | 236 | sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_within_application(); }); }); | 252 | sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_within_application(); }); }); |
3227 | 237 | 253 | ||
3228 | @@ -245,8 +261,8 @@ | |||
3229 | 245 | auto const connection = connect_client(test_name); | 261 | auto const connection = connect_client(test_name); |
3230 | 246 | auto const second_connection = connect_client(another_name); | 262 | auto const second_connection = connect_client(another_name); |
3231 | 247 | 263 | ||
3234 | 248 | auto const first_surface = create_surface(connection, test_name, sync1); | 264 | auto const first_window = create_window(connection, test_name, sync1); |
3235 | 249 | auto const surface = create_surface(second_connection, another_name, sync2); | 265 | auto const window = create_window(second_connection, another_name, sync2); |
3236 | 250 | 266 | ||
3237 | 251 | sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_application(); }); }); | 267 | sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_application(); }); }); |
3238 | 252 | 268 | ||
3239 | @@ -259,12 +275,12 @@ | |||
3240 | 259 | char const* const test_name = __PRETTY_FUNCTION__; | 275 | char const* const test_name = __PRETTY_FUNCTION__; |
3241 | 260 | auto const connection = connect_client(test_name); | 276 | auto const connection = connect_client(test_name); |
3242 | 261 | 277 | ||
3244 | 262 | auto const first_surface = create_surface(connection, test_name, sync1); | 278 | auto const first_window = create_window(connection, test_name, sync1); |
3245 | 263 | 279 | ||
3246 | 264 | sync1.exec([&] | 280 | sync1.exec([&] |
3247 | 265 | { | 281 | { |
3248 | 266 | auto const second_connection = connect_client(another_name); | 282 | auto const second_connection = connect_client(another_name); |
3250 | 267 | auto const surface = create_surface(second_connection, another_name, sync2); | 283 | auto const window = create_window(second_connection, another_name, sync2); |
3251 | 268 | assert_active_window_is(another_name); | 284 | assert_active_window_is(another_name); |
3252 | 269 | }); | 285 | }); |
3253 | 270 | 286 | ||
3254 | @@ -272,20 +288,19 @@ | |||
3255 | 272 | assert_active_window_is(test_name); | 288 | assert_active_window_is(test_name); |
3256 | 273 | } | 289 | } |
3257 | 274 | 290 | ||
3258 | 275 | #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) | ||
3259 | 276 | TEST_F(ActiveWindow, selecting_a_tip_makes_parent_active) | 291 | TEST_F(ActiveWindow, selecting_a_tip_makes_parent_active) |
3260 | 277 | { | 292 | { |
3261 | 278 | char const* const test_name = __PRETTY_FUNCTION__; | 293 | char const* const test_name = __PRETTY_FUNCTION__; |
3262 | 279 | auto const connection = connect_client(test_name); | 294 | auto const connection = connect_client(test_name); |
3263 | 280 | 295 | ||
3265 | 281 | auto const parent = create_surface(connection, test_name, sync1); | 296 | auto const parent = create_window(connection, test_name, sync1); |
3266 | 282 | 297 | ||
3267 | 283 | miral::Window parent_window; | 298 | miral::Window parent_window; |
3268 | 284 | invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); }); | 299 | invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); }); |
3269 | 285 | 300 | ||
3270 | 286 | // Steal the focus | 301 | // Steal the focus |
3271 | 287 | auto second_connection = connect_client(another_name); | 302 | auto second_connection = connect_client(another_name); |
3273 | 288 | auto second_surface = create_surface(second_connection, another_name, sync2); | 303 | auto second_surface = create_window(second_connection, another_name, sync2); |
3274 | 289 | 304 | ||
3275 | 290 | auto const tip = create_tip(connection, "tip", parent, sync2); | 305 | auto const tip = create_tip(connection, "tip", parent, sync2); |
3276 | 291 | 306 | ||
3277 | @@ -298,7 +313,6 @@ | |||
3278 | 298 | 313 | ||
3279 | 299 | assert_active_window_is(test_name); | 314 | assert_active_window_is(test_name); |
3280 | 300 | } | 315 | } |
3281 | 301 | #endif | ||
3282 | 302 | 316 | ||
3283 | 303 | TEST_F(ActiveWindow, selecting_a_parent_makes_dialog_active) | 317 | TEST_F(ActiveWindow, selecting_a_parent_makes_dialog_active) |
3284 | 304 | { | 318 | { |
3285 | @@ -306,7 +320,7 @@ | |||
3286 | 306 | auto const dialog_name = "dialog"; | 320 | auto const dialog_name = "dialog"; |
3287 | 307 | auto const connection = connect_client(test_name); | 321 | auto const connection = connect_client(test_name); |
3288 | 308 | 322 | ||
3290 | 309 | auto const parent = create_surface(connection, test_name, sync1); | 323 | auto const parent = create_window(connection, test_name, sync1); |
3291 | 310 | 324 | ||
3292 | 311 | miral::Window parent_window; | 325 | miral::Window parent_window; |
3293 | 312 | invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); }); | 326 | invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); }); |
3294 | @@ -315,7 +329,7 @@ | |||
3295 | 315 | 329 | ||
3296 | 316 | // Steal the focus | 330 | // Steal the focus |
3297 | 317 | auto second_connection = connect_client(another_name); | 331 | auto second_connection = connect_client(another_name); |
3299 | 318 | auto second_surface = create_surface(second_connection, another_name, sync1); | 332 | auto second_surface = create_window(second_connection, another_name, sync1); |
3300 | 319 | 333 | ||
3301 | 320 | sync2.exec([&]{ invoke_tools([&](WindowManagerTools& tools){ tools.select_active_window(parent_window); }); }); | 334 | sync2.exec([&]{ invoke_tools([&](WindowManagerTools& tools){ tools.select_active_window(parent_window); }); }); |
3302 | 321 | 335 | ||
3303 | @@ -328,7 +342,7 @@ | |||
3304 | 328 | char const* const test_name = __PRETTY_FUNCTION__; | 342 | char const* const test_name = __PRETTY_FUNCTION__; |
3305 | 329 | auto const connection = connect_client(test_name); | 343 | auto const connection = connect_client(test_name); |
3306 | 330 | 344 | ||
3308 | 331 | auto const parent = create_surface(connection, test_name, sync1); | 345 | auto const parent = create_window(connection, test_name, sync1); |
3309 | 332 | auto const input_method = WindowSpec::for_input_method(connection, 50, 50, parent).create_window(); | 346 | auto const input_method = WindowSpec::for_input_method(connection, 50, 50, parent).create_window(); |
3310 | 333 | 347 | ||
3311 | 334 | assert_active_window_is(test_name); | 348 | assert_active_window_is(test_name); |
3312 | @@ -347,7 +361,7 @@ | |||
3313 | 347 | char const* const test_name = __PRETTY_FUNCTION__; | 361 | char const* const test_name = __PRETTY_FUNCTION__; |
3314 | 348 | auto const connection = connect_client(test_name); | 362 | auto const connection = connect_client(test_name); |
3315 | 349 | 363 | ||
3317 | 350 | auto const parent = create_surface(connection, test_name, sync1); | 364 | auto const parent = create_window(connection, test_name, sync1); |
3318 | 351 | auto const satellite = WindowSpec::for_satellite(connection, 50, 50, parent).create_window(); | 365 | auto const satellite = WindowSpec::for_satellite(connection, 50, 50, parent).create_window(); |
3319 | 352 | 366 | ||
3320 | 353 | assert_active_window_is(test_name); | 367 | assert_active_window_is(test_name); |
3321 | @@ -368,7 +382,7 @@ | |||
3322 | 368 | auto const dialog_name = "dialog"; | 382 | auto const dialog_name = "dialog"; |
3323 | 369 | auto const connection = connect_client(parent_name); | 383 | auto const connection = connect_client(parent_name); |
3324 | 370 | 384 | ||
3326 | 371 | auto const parent = create_surface(connection, parent_name, sync1); | 385 | auto const parent = create_window(connection, parent_name, sync1); |
3327 | 372 | auto const dialog = create_dialog(connection, dialog_name, parent, sync2); | 386 | auto const dialog = create_dialog(connection, dialog_name, parent, sync2); |
3328 | 373 | 387 | ||
3329 | 374 | sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); }); | 388 | sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); }); |
3330 | @@ -386,8 +400,8 @@ | |||
3331 | 386 | auto const another_window_name = "another window"; | 400 | auto const another_window_name = "another window"; |
3332 | 387 | auto const connection = connect_client(parent_name); | 401 | auto const connection = connect_client(parent_name); |
3333 | 388 | 402 | ||
3336 | 389 | auto const parent = create_surface(connection, parent_name, sync1); | 403 | auto const parent = create_window(connection, parent_name, sync1); |
3337 | 390 | auto const another_window = create_surface(connection, another_window_name, sync2); | 404 | auto const another_window = create_window(connection, another_window_name, sync2); |
3338 | 391 | auto const dialog = create_dialog(connection, dialog_name, parent, sync3); | 405 | auto const dialog = create_dialog(connection, dialog_name, parent, sync3); |
3339 | 392 | 406 | ||
3340 | 393 | sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); }); | 407 | sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); }); |
3341 | 394 | 408 | ||
3342 | === added file 'test/client_mediated_gestures.cpp' | |||
3343 | --- test/client_mediated_gestures.cpp 1970-01-01 00:00:00 +0000 | |||
3344 | +++ test/client_mediated_gestures.cpp 2017-06-20 16:14:05 +0000 | |||
3345 | @@ -0,0 +1,295 @@ | |||
3346 | 1 | /* | ||
3347 | 2 | * Copyright © 2017 Canonical Ltd. | ||
3348 | 3 | * | ||
3349 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
3350 | 5 | * under the terms of the GNU General Public License version 3, | ||
3351 | 6 | * as published by the Free Software Foundation. | ||
3352 | 7 | * | ||
3353 | 8 | * This program is distributed in the hope that it will be useful, | ||
3354 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3355 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3356 | 11 | * GNU General Public License for more details. | ||
3357 | 12 | * | ||
3358 | 13 | * You should have received a copy of the GNU General Public License | ||
3359 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3360 | 15 | * | ||
3361 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
3362 | 17 | */ | ||
3363 | 18 | |||
3364 | 19 | #include <mir/client/surface.h> | ||
3365 | 20 | #include <mir/client/window_spec.h> | ||
3366 | 21 | |||
3367 | 22 | #include <mir_toolkit/mir_window.h> | ||
3368 | 23 | #include <mir_toolkit/mir_blob.h> | ||
3369 | 24 | |||
3370 | 25 | #include <mir/geometry/displacement.h> | ||
3371 | 26 | #include <mir/input/input_device_info.h> | ||
3372 | 27 | #include <mir/input/device_capability.h> | ||
3373 | 28 | #include <mir/shell/canonical_window_manager.h> | ||
3374 | 29 | #include <mir/shell/shell.h> | ||
3375 | 30 | |||
3376 | 31 | #include <mir_test_framework/connected_client_with_a_window.h> | ||
3377 | 32 | #include <mir_test_framework/fake_input_device.h> | ||
3378 | 33 | #include <mir_test_framework/stub_server_platform_factory.h> | ||
3379 | 34 | #include <mir/test/event_factory.h> | ||
3380 | 35 | #include <mir/test/fake_shared.h> | ||
3381 | 36 | #include <mir/test/signal.h> | ||
3382 | 37 | |||
3383 | 38 | #include <gmock/gmock.h> | ||
3384 | 39 | #include <gtest/gtest.h> | ||
3385 | 40 | |||
3386 | 41 | #include <linux/input.h> | ||
3387 | 42 | |||
3388 | 43 | #include <atomic> | ||
3389 | 44 | |||
3390 | 45 | using namespace std::chrono_literals; | ||
3391 | 46 | using namespace mir::geometry; | ||
3392 | 47 | using namespace testing; | ||
3393 | 48 | using mir::test::fake_shared; | ||
3394 | 49 | using mir::test::Signal; | ||
3395 | 50 | |||
3396 | 51 | namespace | ||
3397 | 52 | { | ||
3398 | 53 | class Cookie | ||
3399 | 54 | { | ||
3400 | 55 | public: | ||
3401 | 56 | Cookie() = default; | ||
3402 | 57 | |||
3403 | 58 | explicit Cookie(MirCookie const* cookie) : self{cookie, deleter} {} | ||
3404 | 59 | |||
3405 | 60 | operator MirCookie const*() const { return self.get(); } | ||
3406 | 61 | |||
3407 | 62 | auto get() const -> MirCookie const* { return self.get(); } | ||
3408 | 63 | |||
3409 | 64 | void reset() { self.reset(); } | ||
3410 | 65 | |||
3411 | 66 | void reset(MirCookie const* cookie) { self.reset(cookie, deleter); } | ||
3412 | 67 | |||
3413 | 68 | private: | ||
3414 | 69 | static void deleter(MirCookie const* cookie) { mir_cookie_release(cookie); } | ||
3415 | 70 | |||
3416 | 71 | std::shared_ptr<MirCookie const> self; | ||
3417 | 72 | }; | ||
3418 | 73 | |||
3419 | 74 | void mir_cookie_release(Cookie const&) = delete; | ||
3420 | 75 | |||
3421 | 76 | struct MockWindowManager : mir::shell::CanonicalWindowManager | ||
3422 | 77 | { | ||
3423 | 78 | using mir::shell::CanonicalWindowManager::CanonicalWindowManager; | ||
3424 | 79 | |||
3425 | 80 | MOCK_METHOD3(handle_request_move, | ||
3426 | 81 | void(std::shared_ptr<mir::scene::Session> const&, std::shared_ptr<mir::scene::Surface> const&, uint64_t)); | ||
3427 | 82 | }; | ||
3428 | 83 | |||
3429 | 84 | struct MouseMoverAndFaker | ||
3430 | 85 | { | ||
3431 | 86 | void start_dragging_mouse() | ||
3432 | 87 | { | ||
3433 | 88 | using namespace mir::input::synthesis; | ||
3434 | 89 | fake_mouse->emit_event(a_button_down_event().of_button(BTN_LEFT)); | ||
3435 | 90 | } | ||
3436 | 91 | |||
3437 | 92 | void move_mouse(Displacement const& displacement) | ||
3438 | 93 | { | ||
3439 | 94 | using mir::input::synthesis::a_pointer_event; | ||
3440 | 95 | fake_mouse->emit_event(a_pointer_event().with_movement(displacement.dx.as_int(), displacement.dy.as_int())); | ||
3441 | 96 | } | ||
3442 | 97 | |||
3443 | 98 | void release_mouse() | ||
3444 | 99 | { | ||
3445 | 100 | using namespace mir::input::synthesis; | ||
3446 | 101 | fake_mouse->emit_event(a_button_up_event().of_button(BTN_LEFT)); | ||
3447 | 102 | } | ||
3448 | 103 | |||
3449 | 104 | private: | ||
3450 | 105 | std::unique_ptr<mir_test_framework::FakeInputDevice> fake_mouse{ | ||
3451 | 106 | mir_test_framework::add_fake_input_device( | ||
3452 | 107 | mir::input::InputDeviceInfo{"mouse", "mouse-uid", mir::input::DeviceCapability::pointer}) | ||
3453 | 108 | }; | ||
3454 | 109 | }; | ||
3455 | 110 | |||
3456 | 111 | Rectangle const screen_geometry{{0, 0}, {800, 600}}; | ||
3457 | 112 | auto const receive_event_timeout = 90s; | ||
3458 | 113 | |||
3459 | 114 | struct ClientMediatedUserGestures : mir_test_framework::ConnectedClientWithAWindow, | ||
3460 | 115 | MouseMoverAndFaker | ||
3461 | 116 | { | ||
3462 | 117 | void SetUp() override | ||
3463 | 118 | { | ||
3464 | 119 | initial_display_layout({screen_geometry}); | ||
3465 | 120 | server.override_the_window_manager_builder([this](mir::shell::FocusController* focus_controller) | ||
3466 | 121 | { | ||
3467 | 122 | return window_manager = | ||
3468 | 123 | std::make_shared<MockWindowManager>(focus_controller, server.the_shell_display_layout()); | ||
3469 | 124 | }); | ||
3470 | 125 | |||
3471 | 126 | mir_test_framework::ConnectedClientWithAWindow::SetUp(); | ||
3472 | 127 | mir_window_set_event_handler(window, &window_event_handler, this); | ||
3473 | 128 | |||
3474 | 129 | paint_window(); | ||
3475 | 130 | |||
3476 | 131 | center_mouse(); | ||
3477 | 132 | } | ||
3478 | 133 | |||
3479 | 134 | void TearDown() override | ||
3480 | 135 | { | ||
3481 | 136 | reset_window_event_handler(); | ||
3482 | 137 | window_manager.reset(); | ||
3483 | 138 | surface.reset(); | ||
3484 | 139 | mir_test_framework::ConnectedClientWithAWindow::TearDown(); | ||
3485 | 140 | } | ||
3486 | 141 | |||
3487 | 142 | auto user_initiates_gesture() -> Cookie; | ||
3488 | 143 | |||
3489 | 144 | std::shared_ptr<MockWindowManager> window_manager; | ||
3490 | 145 | |||
3491 | 146 | private: | ||
3492 | 147 | void center_mouse(); | ||
3493 | 148 | void paint_window(); | ||
3494 | 149 | void set_window_event_handler(std::function<void(MirEvent const* event)> const& handler); | ||
3495 | 150 | void reset_window_event_handler(); | ||
3496 | 151 | void invoke_window_event_handler(MirEvent const* event) | ||
3497 | 152 | { | ||
3498 | 153 | std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex}; | ||
3499 | 154 | window_event_handler_(event); | ||
3500 | 155 | } | ||
3501 | 156 | |||
3502 | 157 | mir::client::Surface surface; | ||
3503 | 158 | |||
3504 | 159 | std::mutex window_event_handler_mutex; | ||
3505 | 160 | std::function<void(MirEvent const* event)> window_event_handler_ = [](MirEvent const*) {}; | ||
3506 | 161 | |||
3507 | 162 | static void window_event_handler(MirWindow* window, MirEvent const* event, void* context); | ||
3508 | 163 | }; | ||
3509 | 164 | |||
3510 | 165 | void ClientMediatedUserGestures::set_window_event_handler(std::function<void(MirEvent const* event)> const& handler) | ||
3511 | 166 | { | ||
3512 | 167 | std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex}; | ||
3513 | 168 | window_event_handler_ = handler; | ||
3514 | 169 | } | ||
3515 | 170 | |||
3516 | 171 | void ClientMediatedUserGestures::reset_window_event_handler() | ||
3517 | 172 | { | ||
3518 | 173 | std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex}; | ||
3519 | 174 | window_event_handler_ = [](MirEvent const*) {}; | ||
3520 | 175 | } | ||
3521 | 176 | |||
3522 | 177 | void ClientMediatedUserGestures::window_event_handler(MirWindow* /*window*/, MirEvent const* event, void* context) | ||
3523 | 178 | { | ||
3524 | 179 | static_cast<ClientMediatedUserGestures*>(context)->invoke_window_event_handler(event); | ||
3525 | 180 | } | ||
3526 | 181 | |||
3527 | 182 | void ClientMediatedUserGestures::paint_window() | ||
3528 | 183 | { | ||
3529 | 184 | { | ||
3530 | 185 | surface = mir::client::Surface{mir_connection_create_render_surface_sync(connection, 42, 42)}; | ||
3531 | 186 | auto const spec = mir::client::WindowSpec::for_changes(connection); | ||
3532 | 187 | mir_window_spec_add_render_surface(spec, surface, 42, 42, 0, 0); | ||
3533 | 188 | mir_window_apply_spec(window, spec); | ||
3534 | 189 | } | ||
3535 | 190 | |||
3536 | 191 | Signal have_focus; | ||
3537 | 192 | |||
3538 | 193 | set_window_event_handler([&](MirEvent const* event) | ||
3539 | 194 | { | ||
3540 | 195 | if (mir_event_get_type(event) != mir_event_type_window) | ||
3541 | 196 | return; | ||
3542 | 197 | |||
3543 | 198 | auto const window_event = mir_event_get_window_event(event); | ||
3544 | 199 | if (mir_window_event_get_attribute(window_event) != mir_window_attrib_focus) | ||
3545 | 200 | return; | ||
3546 | 201 | |||
3547 | 202 | if (mir_window_event_get_attribute_value(window_event)) | ||
3548 | 203 | have_focus.raise(); | ||
3549 | 204 | }); | ||
3550 | 205 | |||
3551 | 206 | mir_buffer_stream_swap_buffers_sync(mir_render_surface_get_buffer_stream(surface, 42, 42, mir_pixel_format_argb_8888)); | ||
3552 | 207 | |||
3553 | 208 | EXPECT_THAT(have_focus.wait_for(receive_event_timeout), Eq(true)); | ||
3554 | 209 | |||
3555 | 210 | reset_window_event_handler(); | ||
3556 | 211 | } | ||
3557 | 212 | |||
3558 | 213 | void ClientMediatedUserGestures::center_mouse() | ||
3559 | 214 | { | ||
3560 | 215 | Signal have_mouseover; | ||
3561 | 216 | |||
3562 | 217 | set_window_event_handler([&](MirEvent const* event) | ||
3563 | 218 | { | ||
3564 | 219 | if (mir_event_get_type(event) != mir_event_type_input) | ||
3565 | 220 | return; | ||
3566 | 221 | |||
3567 | 222 | auto const input_event = mir_event_get_input_event(event); | ||
3568 | 223 | |||
3569 | 224 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
3570 | 225 | return; | ||
3571 | 226 | |||
3572 | 227 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
3573 | 228 | |||
3574 | 229 | if (mir_pointer_event_action(pointer_event) != mir_pointer_action_enter) | ||
3575 | 230 | return; | ||
3576 | 231 | |||
3577 | 232 | have_mouseover.raise(); | ||
3578 | 233 | }); | ||
3579 | 234 | |||
3580 | 235 | move_mouse(0.5 * as_displacement(screen_geometry.size)); | ||
3581 | 236 | |||
3582 | 237 | // We miss the "mouseover" occasionally (with valgrind and heavy stress about 1/20). | ||
3583 | 238 | // But it isn't essential for the test and we've probably waited long enough | ||
3584 | 239 | // for the mouse-down needed by the test to reach the window. | ||
3585 | 240 | // EXPECT_THAT(have_mouseover.wait_for(receive_event_timeout), Eq(true)); | ||
3586 | 241 | have_mouseover.wait_for(receive_event_timeout); | ||
3587 | 242 | |||
3588 | 243 | reset_window_event_handler(); | ||
3589 | 244 | } | ||
3590 | 245 | |||
3591 | 246 | auto ClientMediatedUserGestures::user_initiates_gesture() -> Cookie | ||
3592 | 247 | { | ||
3593 | 248 | Cookie cookie; | ||
3594 | 249 | Signal have_cookie; | ||
3595 | 250 | |||
3596 | 251 | set_window_event_handler([&](MirEvent const* event) | ||
3597 | 252 | { | ||
3598 | 253 | if (mir_event_get_type(event) != mir_event_type_input) | ||
3599 | 254 | return; | ||
3600 | 255 | |||
3601 | 256 | auto const input_event = mir_event_get_input_event(event); | ||
3602 | 257 | |||
3603 | 258 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
3604 | 259 | return; | ||
3605 | 260 | |||
3606 | 261 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
3607 | 262 | |||
3608 | 263 | if (mir_pointer_event_action(pointer_event) != mir_pointer_action_button_down) | ||
3609 | 264 | return; | ||
3610 | 265 | |||
3611 | 266 | cookie = Cookie{mir_input_event_get_cookie(input_event)}; | ||
3612 | 267 | have_cookie.raise(); | ||
3613 | 268 | }); | ||
3614 | 269 | |||
3615 | 270 | start_dragging_mouse(); | ||
3616 | 271 | |||
3617 | 272 | EXPECT_THAT(have_cookie.wait_for(receive_event_timeout), Eq(true)); | ||
3618 | 273 | |||
3619 | 274 | reset_window_event_handler(); | ||
3620 | 275 | return cookie; | ||
3621 | 276 | } | ||
3622 | 277 | } | ||
3623 | 278 | |||
3624 | 279 | TEST_F(ClientMediatedUserGestures, when_user_initiates_gesture_client_receives_cookie) | ||
3625 | 280 | { | ||
3626 | 281 | auto const cookie = user_initiates_gesture(); | ||
3627 | 282 | |||
3628 | 283 | EXPECT_THAT(cookie.get(), NotNull()); | ||
3629 | 284 | } | ||
3630 | 285 | |||
3631 | 286 | TEST_F(ClientMediatedUserGestures, when_client_initiates_move_window_manager_handles_request) | ||
3632 | 287 | { | ||
3633 | 288 | auto const cookie = user_initiates_gesture(); | ||
3634 | 289 | Signal have_request; | ||
3635 | 290 | EXPECT_CALL(*window_manager, handle_request_move(_, _, _)).WillOnce(InvokeWithoutArgs([&]{ have_request.raise(); })); | ||
3636 | 291 | |||
3637 | 292 | mir_window_request_user_move(window, cookie); | ||
3638 | 293 | |||
3639 | 294 | EXPECT_THAT(have_request.wait_for(receive_event_timeout), Eq(true)); | ||
3640 | 295 | } | ||
3641 | 0 | 296 | ||
3642 | === added file 'test/drag_and_drop.cpp' | |||
3643 | --- test/drag_and_drop.cpp 1970-01-01 00:00:00 +0000 | |||
3644 | +++ test/drag_and_drop.cpp 2017-06-20 16:14:05 +0000 | |||
3645 | @@ -0,0 +1,653 @@ | |||
3646 | 1 | /* | ||
3647 | 2 | * Copyright © 2017 Canonical Ltd. | ||
3648 | 3 | * | ||
3649 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
3650 | 5 | * under the terms of the GNU General Public License version 3, | ||
3651 | 6 | * as published by the Free Software Foundation. | ||
3652 | 7 | * | ||
3653 | 8 | * This program is distributed in the hope that it will be useful, | ||
3654 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3655 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3656 | 11 | * GNU General Public License for more details. | ||
3657 | 12 | * | ||
3658 | 13 | * You should have received a copy of the GNU General Public License | ||
3659 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3660 | 15 | * | ||
3661 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
3662 | 17 | */ | ||
3663 | 18 | |||
3664 | 19 | #include <miral/window_management_policy_addendum2.h> | ||
3665 | 20 | |||
3666 | 21 | #include <mir/client/blob.h> | ||
3667 | 22 | #include <mir/client/cookie.h> | ||
3668 | 23 | #include <mir/client/surface.h> | ||
3669 | 24 | #include <mir/client/window.h> | ||
3670 | 25 | #include <mir/client/window_spec.h> | ||
3671 | 26 | #include <mir_toolkit/mir_buffer_stream.h> | ||
3672 | 27 | #include <mir_toolkit/extensions/drag_and_drop.h> | ||
3673 | 28 | |||
3674 | 29 | #include <mir/geometry/displacement.h> | ||
3675 | 30 | #include <mir/input/input_device_info.h> | ||
3676 | 31 | #include <mir/input/device_capability.h> | ||
3677 | 32 | #include <mir/shell/shell.h> | ||
3678 | 33 | |||
3679 | 34 | #include "test_server.h" | ||
3680 | 35 | #include <mir_test_framework/fake_input_device.h> | ||
3681 | 36 | #include <mir_test_framework/stub_server_platform_factory.h> | ||
3682 | 37 | #include <mir/test/event_factory.h> | ||
3683 | 38 | #include <mir/test/signal.h> | ||
3684 | 39 | |||
3685 | 40 | #include <gmock/gmock.h> | ||
3686 | 41 | #include <gtest/gtest.h> | ||
3687 | 42 | |||
3688 | 43 | #include <linux/input.h> | ||
3689 | 44 | #include <uuid/uuid.h> | ||
3690 | 45 | |||
3691 | 46 | #include <boost/throw_exception.hpp> | ||
3692 | 47 | #include <atomic> | ||
3693 | 48 | |||
3694 | 49 | using namespace std::chrono_literals; | ||
3695 | 50 | using namespace mir::client; | ||
3696 | 51 | using namespace mir::geometry; | ||
3697 | 52 | using namespace testing; | ||
3698 | 53 | using mir::test::Signal; | ||
3699 | 54 | |||
3700 | 55 | namespace | ||
3701 | 56 | { | ||
3702 | 57 | struct MouseMoverAndFaker | ||
3703 | 58 | { | ||
3704 | 59 | void start_dragging_mouse() | ||
3705 | 60 | { | ||
3706 | 61 | using namespace mir::input::synthesis; | ||
3707 | 62 | fake_mouse->emit_event(a_button_down_event().of_button(BTN_LEFT)); | ||
3708 | 63 | } | ||
3709 | 64 | |||
3710 | 65 | void move_mouse(Displacement const& displacement) | ||
3711 | 66 | { | ||
3712 | 67 | using mir::input::synthesis::a_pointer_event; | ||
3713 | 68 | fake_mouse->emit_event(a_pointer_event().with_movement(displacement.dx.as_int(), displacement.dy.as_int())); | ||
3714 | 69 | } | ||
3715 | 70 | |||
3716 | 71 | void release_mouse() | ||
3717 | 72 | { | ||
3718 | 73 | using namespace mir::input::synthesis; | ||
3719 | 74 | fake_mouse->emit_event(a_button_up_event().of_button(BTN_LEFT)); | ||
3720 | 75 | } | ||
3721 | 76 | |||
3722 | 77 | private: | ||
3723 | 78 | std::unique_ptr<mir_test_framework::FakeInputDevice> fake_mouse{ | ||
3724 | 79 | mir_test_framework::add_fake_input_device( | ||
3725 | 80 | mir::input::InputDeviceInfo{"mouse", "mouse-uid", mir::input::DeviceCapability::pointer})}; | ||
3726 | 81 | }; | ||
3727 | 82 | |||
3728 | 83 | Rectangle const screen_geometry{{0,0}, {800,600}}; | ||
3729 | 84 | auto const receive_event_timeout = 1s; //90s; | ||
3730 | 85 | |||
3731 | 86 | struct ConnectedClientWithAWindow : miral::TestServer | ||
3732 | 87 | { | ||
3733 | 88 | Connection connection; | ||
3734 | 89 | Surface surface; | ||
3735 | 90 | Window window; | ||
3736 | 91 | |||
3737 | 92 | void SetUp() override | ||
3738 | 93 | { | ||
3739 | 94 | miral::TestServer::SetUp(); | ||
3740 | 95 | connection = connect_client(__func__); | ||
3741 | 96 | auto const width = surface_size.width.as_int(); | ||
3742 | 97 | auto const height = surface_size.height.as_int(); | ||
3743 | 98 | surface = Surface{mir_connection_create_render_surface_sync(connection, width, height)}; | ||
3744 | 99 | window = WindowSpec::for_normal_window(connection, width, height) | ||
3745 | 100 | .set_name("ConnectedClientWithAWindow") | ||
3746 | 101 | .add_surface(surface, width, height, 0, 0) | ||
3747 | 102 | .create_window(); | ||
3748 | 103 | } | ||
3749 | 104 | |||
3750 | 105 | void TearDown() override | ||
3751 | 106 | { | ||
3752 | 107 | window.reset(); | ||
3753 | 108 | surface.reset(); | ||
3754 | 109 | connection.reset(); | ||
3755 | 110 | miral::TestServer::TearDown(); | ||
3756 | 111 | } | ||
3757 | 112 | |||
3758 | 113 | mir::geometry::Size const surface_size {640, 480}; | ||
3759 | 114 | }; | ||
3760 | 115 | |||
3761 | 116 | struct DragAndDrop : ConnectedClientWithAWindow, | ||
3762 | 117 | MouseMoverAndFaker | ||
3763 | 118 | { | ||
3764 | 119 | MirDragAndDropV1 const* dnd = nullptr; | ||
3765 | 120 | |||
3766 | 121 | void SetUp() override | ||
3767 | 122 | { | ||
3768 | 123 | mir_test_framework::set_next_display_rects(std::unique_ptr<std::vector<Rectangle>>(new std::vector<Rectangle>({screen_geometry}))); | ||
3769 | 124 | |||
3770 | 125 | ConnectedClientWithAWindow::SetUp(); | ||
3771 | 126 | dnd = mir_drag_and_drop_v1(connection); | ||
3772 | 127 | mir_window_set_event_handler(window, &window_event_handler, this); | ||
3773 | 128 | if (dnd) dnd->set_start_drag_and_drop_callback(window, &window_dnd_start_handler, this); | ||
3774 | 129 | |||
3775 | 130 | create_target_window(); | ||
3776 | 131 | |||
3777 | 132 | paint_window(surface, window); | ||
3778 | 133 | |||
3779 | 134 | center_mouse(); | ||
3780 | 135 | } | ||
3781 | 136 | |||
3782 | 137 | void TearDown() override | ||
3783 | 138 | { | ||
3784 | 139 | reset_window_event_handler(target_window); | ||
3785 | 140 | reset_window_event_handler(window); | ||
3786 | 141 | target_window.reset(); | ||
3787 | 142 | target_surface.reset(); | ||
3788 | 143 | another_connection.reset(); | ||
3789 | 144 | ConnectedClientWithAWindow::TearDown(); | ||
3790 | 145 | } | ||
3791 | 146 | |||
3792 | 147 | auto user_initiates_drag() -> Cookie; | ||
3793 | 148 | auto client_requests_drag(Cookie const& cookie) -> Blob; | ||
3794 | 149 | auto handle_from_mouse_move() -> Blob; | ||
3795 | 150 | auto handle_from_mouse_leave() -> Blob; | ||
3796 | 151 | auto handle_from_mouse_enter() -> Blob; | ||
3797 | 152 | auto handle_from_mouse_release() -> Blob; | ||
3798 | 153 | auto count_of_handles_when_moving_mouse() -> int; | ||
3799 | 154 | |||
3800 | 155 | private: | ||
3801 | 156 | auto build_window_manager_policy(miral::WindowManagerTools const& tools) -> std::unique_ptr<TestWindowManagerPolicy> override; | ||
3802 | 157 | void center_mouse(); | ||
3803 | 158 | void paint_window(MirRenderSurface* s, MirWindow* w); | ||
3804 | 159 | void set_window_event_handler(MirWindow* window, std::function<void(MirEvent const* event)> const& handler); | ||
3805 | 160 | void set_window_dnd_start_handler(MirWindow* window, std::function<void(MirDragAndDropEvent const*)> const& handler); | ||
3806 | 161 | void reset_window_event_handler(MirWindow* window); | ||
3807 | 162 | |||
3808 | 163 | void create_target_window() | ||
3809 | 164 | { | ||
3810 | 165 | another_connection = connect_client("another_connection"); | ||
3811 | 166 | auto const height = screen_geometry.size.height.as_int(); | ||
3812 | 167 | auto const width = screen_geometry.size.width.as_int(); | ||
3813 | 168 | target_surface = Surface{mir_connection_create_render_surface_sync(another_connection, width,height)}; | ||
3814 | 169 | target_window = WindowSpec::for_normal_window(another_connection, width, height) | ||
3815 | 170 | .set_name("target_window") | ||
3816 | 171 | .add_surface(target_surface, width, height, 0, 0) | ||
3817 | 172 | .set_event_handler(&window_event_handler, this) | ||
3818 | 173 | .create_window(); | ||
3819 | 174 | |||
3820 | 175 | paint_window(target_surface, target_window); | ||
3821 | 176 | } | ||
3822 | 177 | |||
3823 | 178 | void invoke_window_event_handler(MirWindow* window, MirEvent const* event) | ||
3824 | 179 | { | ||
3825 | 180 | std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex}; | ||
3826 | 181 | if (window == this->window) window_event_handler_(event); | ||
3827 | 182 | if (window == target_window) target_window_event_handler_(event); | ||
3828 | 183 | } | ||
3829 | 184 | |||
3830 | 185 | void invoke_window_dnd_start_handler(MirWindow* window, MirDragAndDropEvent const* event) | ||
3831 | 186 | { | ||
3832 | 187 | std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex}; | ||
3833 | 188 | if (window == this->window) window_dnd_start_(event); | ||
3834 | 189 | } | ||
3835 | 190 | |||
3836 | 191 | std::mutex window_event_handler_mutex; | ||
3837 | 192 | std::function<void(MirDragAndDropEvent const* event)> window_dnd_start_ = [](MirDragAndDropEvent const*) {}; | ||
3838 | 193 | std::function<void(MirEvent const* event)> window_event_handler_ = [](MirEvent const*) {}; | ||
3839 | 194 | std::function<void(MirEvent const* event)> target_window_event_handler_ = [](MirEvent const*) {}; | ||
3840 | 195 | |||
3841 | 196 | static void window_event_handler(MirWindow* window, MirEvent const* event, void* context); | ||
3842 | 197 | static void window_dnd_start_handler(MirWindow* window, MirDragAndDropEvent const* event, void* context); | ||
3843 | 198 | |||
3844 | 199 | Connection another_connection; | ||
3845 | 200 | Surface target_surface; | ||
3846 | 201 | Window target_window; | ||
3847 | 202 | }; | ||
3848 | 203 | |||
3849 | 204 | void DragAndDrop::set_window_event_handler(MirWindow* window, std::function<void(MirEvent const* event)> const& handler) | ||
3850 | 205 | { | ||
3851 | 206 | std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex}; | ||
3852 | 207 | if (window == this->window) window_event_handler_ = handler; | ||
3853 | 208 | if (window == target_window) target_window_event_handler_ = handler; | ||
3854 | 209 | } | ||
3855 | 210 | |||
3856 | 211 | void DragAndDrop::set_window_dnd_start_handler(MirWindow* window, std::function<void(MirDragAndDropEvent const*)> const& handler) | ||
3857 | 212 | { | ||
3858 | 213 | std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex}; | ||
3859 | 214 | if (window == this->window) window_dnd_start_ = handler; | ||
3860 | 215 | } | ||
3861 | 216 | |||
3862 | 217 | |||
3863 | 218 | void DragAndDrop::reset_window_event_handler(MirWindow* window) | ||
3864 | 219 | { | ||
3865 | 220 | if (window == this->window) window_event_handler_ = [](MirEvent const*) {}; | ||
3866 | 221 | if (window == target_window) target_window_event_handler_ = [](MirEvent const*) {}; | ||
3867 | 222 | } | ||
3868 | 223 | |||
3869 | 224 | void DragAndDrop::paint_window(MirRenderSurface* s, MirWindow* w) | ||
3870 | 225 | { | ||
3871 | 226 | Signal have_focus; | ||
3872 | 227 | |||
3873 | 228 | set_window_event_handler(w, [&](MirEvent const* event) | ||
3874 | 229 | { | ||
3875 | 230 | if (mir_event_get_type(event) != mir_event_type_window) | ||
3876 | 231 | return; | ||
3877 | 232 | |||
3878 | 233 | auto const window_event = mir_event_get_window_event(event); | ||
3879 | 234 | if (mir_window_event_get_attribute(window_event) != mir_window_attrib_focus) | ||
3880 | 235 | return; | ||
3881 | 236 | |||
3882 | 237 | if (mir_window_event_get_attribute_value(window_event)) | ||
3883 | 238 | have_focus.raise(); | ||
3884 | 239 | }); | ||
3885 | 240 | |||
3886 | 241 | int width; | ||
3887 | 242 | int height; | ||
3888 | 243 | mir_render_surface_get_size(s, &width, &height); | ||
3889 | 244 | mir_buffer_stream_swap_buffers_sync( | ||
3890 | 245 | mir_render_surface_get_buffer_stream(s, width, height, mir_pixel_format_argb_8888)); | ||
3891 | 246 | |||
3892 | 247 | EXPECT_THAT(have_focus.wait_for(receive_event_timeout), Eq(true)); | ||
3893 | 248 | |||
3894 | 249 | reset_window_event_handler(w); | ||
3895 | 250 | } | ||
3896 | 251 | |||
3897 | 252 | void DragAndDrop::center_mouse() | ||
3898 | 253 | { | ||
3899 | 254 | Signal have_mouseover; | ||
3900 | 255 | |||
3901 | 256 | set_window_event_handler(window, [&](MirEvent const* event) | ||
3902 | 257 | { | ||
3903 | 258 | if (mir_event_get_type(event) != mir_event_type_input) | ||
3904 | 259 | return; | ||
3905 | 260 | |||
3906 | 261 | auto const input_event = mir_event_get_input_event(event); | ||
3907 | 262 | |||
3908 | 263 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
3909 | 264 | return; | ||
3910 | 265 | |||
3911 | 266 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
3912 | 267 | |||
3913 | 268 | if (mir_pointer_event_action(pointer_event) != mir_pointer_action_enter) | ||
3914 | 269 | return; | ||
3915 | 270 | |||
3916 | 271 | have_mouseover.raise(); | ||
3917 | 272 | }); | ||
3918 | 273 | |||
3919 | 274 | move_mouse(0.5 * as_displacement(screen_geometry.size)); | ||
3920 | 275 | |||
3921 | 276 | // We miss the "mouseover" occasionally (with valgrind and heavy stress about 1/20). | ||
3922 | 277 | // But it isn't essential for the test and we've probably waited long enough | ||
3923 | 278 | // for the mouse-down needed by the test to reach the window. | ||
3924 | 279 | // EXPECT_THAT(have_mouseover.wait_for(receive_event_timeout), Eq(true)); | ||
3925 | 280 | have_mouseover.wait_for(receive_event_timeout); | ||
3926 | 281 | |||
3927 | 282 | reset_window_event_handler(window); | ||
3928 | 283 | } | ||
3929 | 284 | |||
3930 | 285 | void DragAndDrop::window_event_handler(MirWindow* window, MirEvent const* event, void* context) | ||
3931 | 286 | { | ||
3932 | 287 | static_cast<DragAndDrop*>(context)->invoke_window_event_handler(window, event); | ||
3933 | 288 | } | ||
3934 | 289 | |||
3935 | 290 | void DragAndDrop::window_dnd_start_handler(MirWindow* window, MirDragAndDropEvent const* event, void* context) | ||
3936 | 291 | { | ||
3937 | 292 | static_cast<DragAndDrop*>(context)->invoke_window_dnd_start_handler(window, event); | ||
3938 | 293 | } | ||
3939 | 294 | |||
3940 | 295 | |||
3941 | 296 | auto DragAndDrop::user_initiates_drag() -> Cookie | ||
3942 | 297 | { | ||
3943 | 298 | Cookie cookie; | ||
3944 | 299 | Signal have_cookie; | ||
3945 | 300 | |||
3946 | 301 | set_window_event_handler(window, [&](MirEvent const* event) | ||
3947 | 302 | { | ||
3948 | 303 | if (mir_event_get_type(event) != mir_event_type_input) | ||
3949 | 304 | return; | ||
3950 | 305 | |||
3951 | 306 | auto const input_event = mir_event_get_input_event(event); | ||
3952 | 307 | |||
3953 | 308 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
3954 | 309 | return; | ||
3955 | 310 | |||
3956 | 311 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
3957 | 312 | |||
3958 | 313 | if (mir_pointer_event_action(pointer_event) != mir_pointer_action_button_down) | ||
3959 | 314 | return; | ||
3960 | 315 | |||
3961 | 316 | cookie = Cookie{mir_input_event_get_cookie(input_event)}; | ||
3962 | 317 | have_cookie.raise(); | ||
3963 | 318 | }); | ||
3964 | 319 | |||
3965 | 320 | start_dragging_mouse(); | ||
3966 | 321 | |||
3967 | 322 | EXPECT_THAT(have_cookie.wait_for(receive_event_timeout), Eq(true)); | ||
3968 | 323 | |||
3969 | 324 | reset_window_event_handler(window); | ||
3970 | 325 | return cookie; | ||
3971 | 326 | } | ||
3972 | 327 | |||
3973 | 328 | auto DragAndDrop::client_requests_drag(Cookie const& cookie) -> Blob | ||
3974 | 329 | { | ||
3975 | 330 | Blob blob; | ||
3976 | 331 | Signal initiated; | ||
3977 | 332 | |||
3978 | 333 | set_window_dnd_start_handler(window, [&](MirDragAndDropEvent const* event) | ||
3979 | 334 | { | ||
3980 | 335 | if (dnd) | ||
3981 | 336 | blob.reset(dnd->start_drag_and_drop(event)); | ||
3982 | 337 | |||
3983 | 338 | if (blob) | ||
3984 | 339 | initiated.raise(); | ||
3985 | 340 | }); | ||
3986 | 341 | |||
3987 | 342 | EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension"; | ||
3988 | 343 | |||
3989 | 344 | if (dnd) | ||
3990 | 345 | dnd->request_drag_and_drop(window, cookie); | ||
3991 | 346 | |||
3992 | 347 | EXPECT_TRUE(initiated.wait_for(receive_event_timeout)); | ||
3993 | 348 | |||
3994 | 349 | reset_window_event_handler(window); | ||
3995 | 350 | return blob; | ||
3996 | 351 | } | ||
3997 | 352 | |||
3998 | 353 | auto DragAndDrop::handle_from_mouse_move() -> Blob | ||
3999 | 354 | { | ||
4000 | 355 | Blob blob; | ||
4001 | 356 | Signal have_blob; | ||
4002 | 357 | |||
4003 | 358 | set_window_event_handler(window, [&](MirEvent const* event) | ||
4004 | 359 | { | ||
4005 | 360 | if (mir_event_get_type(event) != mir_event_type_input) | ||
4006 | 361 | return; | ||
4007 | 362 | |||
4008 | 363 | auto const input_event = mir_event_get_input_event(event); | ||
4009 | 364 | |||
4010 | 365 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
4011 | 366 | return; | ||
4012 | 367 | |||
4013 | 368 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
4014 | 369 | |||
4015 | 370 | EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension"; | ||
4016 | 371 | |||
4017 | 372 | if (dnd) | ||
4018 | 373 | blob.reset(dnd->pointer_drag_and_drop(pointer_event)); | ||
4019 | 374 | |||
4020 | 375 | if (blob) | ||
4021 | 376 | have_blob.raise(); | ||
4022 | 377 | }); | ||
4023 | 378 | |||
4024 | 379 | move_mouse({1,1}); | ||
4025 | 380 | |||
4026 | 381 | EXPECT_TRUE(have_blob.wait_for(receive_event_timeout)); | ||
4027 | 382 | |||
4028 | 383 | reset_window_event_handler(window); | ||
4029 | 384 | return blob; | ||
4030 | 385 | } | ||
4031 | 386 | |||
4032 | 387 | auto DragAndDrop::handle_from_mouse_leave() -> Blob | ||
4033 | 388 | { | ||
4034 | 389 | Blob blob; | ||
4035 | 390 | Signal have_blob; | ||
4036 | 391 | |||
4037 | 392 | set_window_event_handler(window, [&](MirEvent const* event) | ||
4038 | 393 | { | ||
4039 | 394 | if (mir_event_get_type(event) != mir_event_type_input) | ||
4040 | 395 | return; | ||
4041 | 396 | |||
4042 | 397 | auto const input_event = mir_event_get_input_event(event); | ||
4043 | 398 | |||
4044 | 399 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
4045 | 400 | return; | ||
4046 | 401 | |||
4047 | 402 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
4048 | 403 | |||
4049 | 404 | if (mir_pointer_event_action(pointer_event) != mir_pointer_action_leave) | ||
4050 | 405 | return; | ||
4051 | 406 | |||
4052 | 407 | EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension"; | ||
4053 | 408 | |||
4054 | 409 | if (dnd) | ||
4055 | 410 | blob.reset(dnd->pointer_drag_and_drop(pointer_event)); | ||
4056 | 411 | |||
4057 | 412 | if (blob) | ||
4058 | 413 | have_blob.raise(); | ||
4059 | 414 | }); | ||
4060 | 415 | |||
4061 | 416 | move_mouse({1,1}); | ||
4062 | 417 | move_mouse(0.5 * as_displacement(surface_size)); | ||
4063 | 418 | |||
4064 | 419 | EXPECT_TRUE(have_blob.wait_for(receive_event_timeout)); | ||
4065 | 420 | |||
4066 | 421 | reset_window_event_handler(window); | ||
4067 | 422 | return blob; | ||
4068 | 423 | } | ||
4069 | 424 | |||
4070 | 425 | auto DragAndDrop::handle_from_mouse_enter() -> Blob | ||
4071 | 426 | { | ||
4072 | 427 | Blob blob; | ||
4073 | 428 | Signal have_blob; | ||
4074 | 429 | |||
4075 | 430 | set_window_event_handler(target_window, [&](MirEvent const* event) | ||
4076 | 431 | { | ||
4077 | 432 | if (mir_event_get_type(event) != mir_event_type_input) | ||
4078 | 433 | return; | ||
4079 | 434 | |||
4080 | 435 | auto const input_event = mir_event_get_input_event(event); | ||
4081 | 436 | |||
4082 | 437 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
4083 | 438 | return; | ||
4084 | 439 | |||
4085 | 440 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
4086 | 441 | |||
4087 | 442 | if (mir_pointer_event_action(pointer_event) != mir_pointer_action_enter) | ||
4088 | 443 | return; | ||
4089 | 444 | |||
4090 | 445 | EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension"; | ||
4091 | 446 | |||
4092 | 447 | if (dnd) | ||
4093 | 448 | blob.reset(dnd->pointer_drag_and_drop(pointer_event)); | ||
4094 | 449 | |||
4095 | 450 | if (blob) | ||
4096 | 451 | have_blob.raise(); | ||
4097 | 452 | }); | ||
4098 | 453 | |||
4099 | 454 | move_mouse({1,1}); | ||
4100 | 455 | move_mouse(0.5 * as_displacement(surface_size)); | ||
4101 | 456 | |||
4102 | 457 | EXPECT_TRUE(have_blob.wait_for(receive_event_timeout)); | ||
4103 | 458 | |||
4104 | 459 | reset_window_event_handler(target_window); | ||
4105 | 460 | return blob; | ||
4106 | 461 | } | ||
4107 | 462 | |||
4108 | 463 | auto DragAndDrop::handle_from_mouse_release() -> Blob | ||
4109 | 464 | { | ||
4110 | 465 | Blob blob; | ||
4111 | 466 | Signal have_blob; | ||
4112 | 467 | |||
4113 | 468 | set_window_event_handler(target_window, [&](MirEvent const* event) | ||
4114 | 469 | { | ||
4115 | 470 | if (mir_event_get_type(event) != mir_event_type_input) | ||
4116 | 471 | return; | ||
4117 | 472 | |||
4118 | 473 | auto const input_event = mir_event_get_input_event(event); | ||
4119 | 474 | |||
4120 | 475 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
4121 | 476 | return; | ||
4122 | 477 | |||
4123 | 478 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
4124 | 479 | |||
4125 | 480 | if (mir_pointer_event_action(pointer_event) != mir_pointer_action_button_up) | ||
4126 | 481 | return; | ||
4127 | 482 | |||
4128 | 483 | EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension"; | ||
4129 | 484 | |||
4130 | 485 | if (dnd) | ||
4131 | 486 | blob.reset(dnd->pointer_drag_and_drop(pointer_event)); | ||
4132 | 487 | |||
4133 | 488 | if (blob) | ||
4134 | 489 | have_blob.raise(); | ||
4135 | 490 | }); | ||
4136 | 491 | |||
4137 | 492 | move_mouse({1,1}); | ||
4138 | 493 | move_mouse(0.5 * as_displacement(surface_size)); | ||
4139 | 494 | release_mouse(); | ||
4140 | 495 | |||
4141 | 496 | EXPECT_TRUE(have_blob.wait_for(receive_event_timeout)); | ||
4142 | 497 | |||
4143 | 498 | reset_window_event_handler(target_window); | ||
4144 | 499 | return blob; | ||
4145 | 500 | } | ||
4146 | 501 | |||
4147 | 502 | auto DragAndDrop::count_of_handles_when_moving_mouse() -> int | ||
4148 | 503 | { | ||
4149 | 504 | Signal have_3_events; | ||
4150 | 505 | std::atomic<int> events{0}; | ||
4151 | 506 | std::atomic<int> handles{0}; | ||
4152 | 507 | |||
4153 | 508 | auto counter = [&](MirEvent const* event) | ||
4154 | 509 | { | ||
4155 | 510 | if (mir_event_get_type(event) != mir_event_type_input) | ||
4156 | 511 | return; | ||
4157 | 512 | |||
4158 | 513 | auto const input_event = mir_event_get_input_event(event); | ||
4159 | 514 | |||
4160 | 515 | if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer) | ||
4161 | 516 | return; | ||
4162 | 517 | |||
4163 | 518 | auto const pointer_event = mir_input_event_get_pointer_event(input_event); | ||
4164 | 519 | |||
4165 | 520 | EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension"; | ||
4166 | 521 | |||
4167 | 522 | Blob blob; | ||
4168 | 523 | if (dnd) | ||
4169 | 524 | blob.reset(dnd->pointer_drag_and_drop(pointer_event)); | ||
4170 | 525 | |||
4171 | 526 | if (blob) | ||
4172 | 527 | handles.fetch_add(1); | ||
4173 | 528 | |||
4174 | 529 | if (events.fetch_add(1) == 2) | ||
4175 | 530 | have_3_events.raise(); | ||
4176 | 531 | }; | ||
4177 | 532 | |||
4178 | 533 | set_window_event_handler(window, counter); | ||
4179 | 534 | set_window_event_handler(target_window, counter); | ||
4180 | 535 | |||
4181 | 536 | start_dragging_mouse(); | ||
4182 | 537 | move_mouse({1,1}); | ||
4183 | 538 | release_mouse(); | ||
4184 | 539 | |||
4185 | 540 | EXPECT_TRUE(have_3_events.wait_for(receive_event_timeout)); | ||
4186 | 541 | |||
4187 | 542 | reset_window_event_handler(window); | ||
4188 | 543 | reset_window_event_handler(target_window); | ||
4189 | 544 | return handles; | ||
4190 | 545 | } | ||
4191 | 546 | |||
4192 | 547 | auto DragAndDrop::build_window_manager_policy(miral::WindowManagerTools const& tools) -> std::unique_ptr<TestWindowManagerPolicy> | ||
4193 | 548 | { | ||
4194 | 549 | struct DnDWindowManagerPolicy : miral::TestServer::TestWindowManagerPolicy, miral::WindowManagementPolicyAddendum2 | ||
4195 | 550 | { | ||
4196 | 551 | using miral::TestServer::TestWindowManagerPolicy::TestWindowManagerPolicy; | ||
4197 | 552 | |||
4198 | 553 | void handle_request_drag_and_drop(miral::WindowInfo& window_info) override | ||
4199 | 554 | { | ||
4200 | 555 | uuid_t uuid; | ||
4201 | 556 | uuid_generate(uuid); | ||
4202 | 557 | std::vector<uint8_t> const handle{std::begin(uuid), std::end(uuid)}; | ||
4203 | 558 | |||
4204 | 559 | tools.start_drag_and_drop(window_info, handle); | ||
4205 | 560 | } | ||
4206 | 561 | |||
4207 | 562 | void handle_request_move(miral::WindowInfo&, MirInputEvent const*) override {} | ||
4208 | 563 | }; | ||
4209 | 564 | |||
4210 | 565 | return std::make_unique<DnDWindowManagerPolicy>(tools, *this); | ||
4211 | 566 | } | ||
4212 | 567 | |||
4213 | 568 | MATCHER_P(BlobContentEq, p, "") | ||
4214 | 569 | { | ||
4215 | 570 | if (!arg || !p) | ||
4216 | 571 | return false; | ||
4217 | 572 | if (mir_blob_size(arg) != mir_blob_size(p)) | ||
4218 | 573 | return false; | ||
4219 | 574 | return !memcmp(mir_blob_data(arg), mir_blob_data(p), mir_blob_size(p)); | ||
4220 | 575 | } | ||
4221 | 576 | } | ||
4222 | 577 | |||
4223 | 578 | TEST_F(DragAndDrop, when_user_initiates_drag_client_receives_cookie) | ||
4224 | 579 | { | ||
4225 | 580 | auto const cookie = user_initiates_drag(); | ||
4226 | 581 | |||
4227 | 582 | EXPECT_THAT(cookie, NotNull()); | ||
4228 | 583 | } | ||
4229 | 584 | |||
4230 | 585 | TEST_F(DragAndDrop, when_client_requests_drags_it_receives_handle) | ||
4231 | 586 | { | ||
4232 | 587 | auto const cookie = user_initiates_drag(); | ||
4233 | 588 | ASSERT_THAT(cookie, NotNull()); | ||
4234 | 589 | |||
4235 | 590 | auto const handle = client_requests_drag(cookie); | ||
4236 | 591 | |||
4237 | 592 | EXPECT_THAT(handle, NotNull()); | ||
4238 | 593 | } | ||
4239 | 594 | |||
4240 | 595 | TEST_F(DragAndDrop, during_drag_when_user_moves_mouse_client_receives_handle) | ||
4241 | 596 | { | ||
4242 | 597 | auto const cookie = user_initiates_drag(); | ||
4243 | 598 | ASSERT_THAT(cookie, NotNull()); | ||
4244 | 599 | auto const handle_from_request = client_requests_drag(cookie); | ||
4245 | 600 | |||
4246 | 601 | auto const handle = handle_from_mouse_move(); | ||
4247 | 602 | |||
4248 | 603 | EXPECT_THAT(handle, NotNull()); | ||
4249 | 604 | EXPECT_THAT(handle, BlobContentEq(handle_from_request)); | ||
4250 | 605 | } | ||
4251 | 606 | |||
4252 | 607 | TEST_F(DragAndDrop, when_drag_moves_from_window_leave_event_contains_handle) | ||
4253 | 608 | { | ||
4254 | 609 | auto const cookie = user_initiates_drag(); | ||
4255 | 610 | ASSERT_THAT(cookie, NotNull()); | ||
4256 | 611 | auto const handle_from_request = client_requests_drag(cookie); | ||
4257 | 612 | |||
4258 | 613 | auto const handle = handle_from_mouse_leave(); | ||
4259 | 614 | |||
4260 | 615 | EXPECT_THAT(handle, NotNull()); | ||
4261 | 616 | EXPECT_THAT(handle, BlobContentEq(handle_from_request)); | ||
4262 | 617 | } | ||
4263 | 618 | |||
4264 | 619 | TEST_F(DragAndDrop, when_drag_enters_target_window_enter_event_contains_handle) | ||
4265 | 620 | { | ||
4266 | 621 | auto const cookie = user_initiates_drag(); | ||
4267 | 622 | ASSERT_THAT(cookie, NotNull()); | ||
4268 | 623 | auto const handle_from_request = client_requests_drag(cookie); | ||
4269 | 624 | |||
4270 | 625 | auto const handle = handle_from_mouse_enter(); | ||
4271 | 626 | |||
4272 | 627 | EXPECT_THAT(handle, NotNull()); | ||
4273 | 628 | EXPECT_THAT(handle, BlobContentEq(handle_from_request)); | ||
4274 | 629 | } | ||
4275 | 630 | |||
4276 | 631 | TEST_F(DragAndDrop, when_drag_releases_target_window_release_event_contains_handle) | ||
4277 | 632 | { | ||
4278 | 633 | auto const cookie = user_initiates_drag(); | ||
4279 | 634 | ASSERT_THAT(cookie, NotNull()); | ||
4280 | 635 | auto const handle_from_request = client_requests_drag(cookie); | ||
4281 | 636 | |||
4282 | 637 | auto const handle = handle_from_mouse_release(); | ||
4283 | 638 | |||
4284 | 639 | EXPECT_THAT(handle, NotNull()); | ||
4285 | 640 | EXPECT_THAT(handle, BlobContentEq(handle_from_request)); | ||
4286 | 641 | } | ||
4287 | 642 | |||
4288 | 643 | TEST_F(DragAndDrop, after_drag_finishes_pointer_events_no_longer_contain_handle) | ||
4289 | 644 | { | ||
4290 | 645 | auto const cookie = user_initiates_drag(); | ||
4291 | 646 | ASSERT_THAT(cookie, NotNull()); | ||
4292 | 647 | client_requests_drag(cookie); | ||
4293 | 648 | handle_from_mouse_release(); | ||
4294 | 649 | |||
4295 | 650 | invoke_tools([](miral::WindowManagerTools& tools) { tools.end_drag_and_drop(); }); | ||
4296 | 651 | |||
4297 | 652 | EXPECT_THAT(count_of_handles_when_moving_mouse(), Eq(0)); | ||
4298 | 653 | } | ||
4299 | 0 | 654 | ||
4300 | === modified file 'test/select_active_window.cpp' | |||
4301 | --- test/select_active_window.cpp 2017-01-13 18:17:01 +0000 | |||
4302 | +++ test/select_active_window.cpp 2017-06-20 16:14:05 +0000 | |||
4303 | @@ -32,8 +32,6 @@ | |||
4304 | 32 | Rectangle const display_area{{display_left, display_top}, | 32 | Rectangle const display_area{{display_left, display_top}, |
4305 | 33 | {display_width, display_height}}; | 33 | {display_width, display_height}}; |
4306 | 34 | 34 | ||
4307 | 35 | auto const null_window = Window{}; | ||
4308 | 36 | |||
4309 | 37 | struct SelectActiveWindow : TestWindowManagerTools | 35 | struct SelectActiveWindow : TestWindowManagerTools |
4310 | 38 | { | 36 | { |
4311 | 39 | 37 | ||
4312 | 40 | 38 | ||
4313 | === modified file 'test/test_server.cpp' | |||
4314 | --- test/test_server.cpp 2017-03-20 12:28:06 +0000 | |||
4315 | +++ test/test_server.cpp 2017-06-20 16:14:05 +0000 | |||
4316 | @@ -29,9 +29,7 @@ | |||
4317 | 29 | #include <mir/server.h> | 29 | #include <mir/server.h> |
4318 | 30 | #include <mir/version.h> | 30 | #include <mir/version.h> |
4319 | 31 | 31 | ||
4320 | 32 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
4321 | 33 | #include <mir_test_framework/headless_display_buffer_compositor_factory.h> | 32 | #include <mir_test_framework/headless_display_buffer_compositor_factory.h> |
4322 | 34 | #endif | ||
4323 | 35 | 33 | ||
4324 | 36 | #include <boost/throw_exception.hpp> | 34 | #include <boost/throw_exception.hpp> |
4325 | 37 | 35 | ||
4326 | @@ -52,7 +50,6 @@ | |||
4327 | 52 | CanonicalWindowManagerPolicy{tools} | 50 | CanonicalWindowManagerPolicy{tools} |
4328 | 53 | { | 51 | { |
4329 | 54 | test_fixture.tools = tools; | 52 | test_fixture.tools = tools; |
4330 | 55 | test_fixture.policy = this; | ||
4331 | 56 | } | 53 | } |
4332 | 57 | 54 | ||
4333 | 58 | miral::TestServer::TestServer() : | 55 | miral::TestServer::TestServer() : |
4334 | @@ -71,10 +68,6 @@ | |||
4335 | 71 | 68 | ||
4336 | 72 | void miral::TestServer::SetUp() | 69 | void miral::TestServer::SetUp() |
4337 | 73 | { | 70 | { |
4338 | 74 | #if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 25, 0) | ||
4339 | 75 | mtf::set_next_preset_display({}); // Workaround for lp:1611337 | ||
4340 | 76 | #endif | ||
4341 | 77 | |||
4342 | 78 | mir::test::AutoJoinThread t([this] | 71 | mir::test::AutoJoinThread t([this] |
4343 | 79 | { | 72 | { |
4344 | 80 | auto init = [this](mir::Server& server) | 73 | auto init = [this](mir::Server& server) |
4345 | @@ -93,23 +86,17 @@ | |||
4346 | 93 | }); | 86 | }); |
4347 | 94 | }); | 87 | }); |
4348 | 95 | 88 | ||
4349 | 96 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
4350 | 97 | server.override_the_display_buffer_compositor_factory([] | 89 | server.override_the_display_buffer_compositor_factory([] |
4351 | 98 | { | 90 | { |
4352 | 99 | return std::make_shared<mtf::HeadlessDisplayBufferCompositorFactory>(); | 91 | return std::make_shared<mtf::HeadlessDisplayBufferCompositorFactory>(); |
4353 | 100 | }); | 92 | }); |
4354 | 101 | #endif | ||
4355 | 102 | 93 | ||
4356 | 103 | server.override_the_window_manager_builder([this, &server](msh::FocusController* focus_controller) | 94 | server.override_the_window_manager_builder([this, &server](msh::FocusController* focus_controller) |
4357 | 104 | -> std::shared_ptr<msh::WindowManager> | 95 | -> std::shared_ptr<msh::WindowManager> |
4358 | 105 | { | 96 | { |
4359 | 106 | auto const display_layout = server.the_shell_display_layout(); | 97 | auto const display_layout = server.the_shell_display_layout(); |
4360 | 107 | 98 | ||
4361 | 108 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
4362 | 109 | auto const persistent_surface_store = server.the_persistent_surface_store(); | 99 | auto const persistent_surface_store = server.the_persistent_surface_store(); |
4363 | 110 | #else | ||
4364 | 111 | std::shared_ptr<mir::shell::PersistentSurfaceStore> const persistent_surface_store; | ||
4365 | 112 | #endif | ||
4366 | 113 | 100 | ||
4367 | 114 | auto builder = [this](WindowManagerTools const& tools) -> std::unique_ptr<miral::WindowManagementPolicy> | 101 | auto builder = [this](WindowManagerTools const& tools) -> std::unique_ptr<miral::WindowManagementPolicy> |
4368 | 115 | { | 102 | { |
4369 | 116 | 103 | ||
4370 | === modified file 'test/test_server.h' | |||
4371 | --- test/test_server.h 2017-02-14 17:11:07 +0000 | |||
4372 | +++ test/test_server.h 2017-06-20 16:14:05 +0000 | |||
4373 | @@ -69,7 +69,6 @@ | |||
4374 | 69 | 69 | ||
4375 | 70 | private: | 70 | private: |
4376 | 71 | WindowManagerTools tools{nullptr}; | 71 | WindowManagerTools tools{nullptr}; |
4377 | 72 | WindowManagementPolicy* policy{nullptr}; | ||
4378 | 73 | std::weak_ptr<mir::shell::WindowManager> window_manager; | 72 | std::weak_ptr<mir::shell::WindowManager> window_manager; |
4379 | 74 | mir::test::AutoJoinThread server_thread; | 73 | mir::test::AutoJoinThread server_thread; |
4380 | 75 | std::mutex mutex; | 74 | std::mutex mutex; |
4381 | 76 | 75 | ||
4382 | === modified file 'test/window_id.cpp' | |||
4383 | --- test/window_id.cpp 2017-03-03 12:31:47 +0000 | |||
4384 | +++ test/window_id.cpp 2017-06-20 16:14:05 +0000 | |||
4385 | @@ -42,14 +42,13 @@ | |||
4386 | 42 | } | 42 | } |
4387 | 43 | }; | 43 | }; |
4388 | 44 | 44 | ||
4389 | 45 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0) | ||
4390 | 46 | TEST_F(WindowId, server_can_identify_window_specified_by_client) | 45 | TEST_F(WindowId, server_can_identify_window_specified_by_client) |
4391 | 47 | { | 46 | { |
4392 | 48 | char const* const test_name = __PRETTY_FUNCTION__; | 47 | char const* const test_name = __PRETTY_FUNCTION__; |
4393 | 49 | using namespace mir::client; | 48 | using namespace mir::client; |
4394 | 50 | 49 | ||
4395 | 51 | auto const connection = connect_client(test_name); | 50 | auto const connection = connect_client(test_name); |
4397 | 52 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888) | 51 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50) |
4398 | 53 | .set_name(test_name); | 52 | .set_name(test_name); |
4399 | 54 | 53 | ||
4400 | 55 | Window const surface{spec.create_window()}; | 54 | Window const surface{spec.create_window()}; |
4401 | @@ -71,7 +70,7 @@ | |||
4402 | 71 | using namespace mir::client; | 70 | using namespace mir::client; |
4403 | 72 | 71 | ||
4404 | 73 | auto const connection = connect_client(test_name); | 72 | auto const connection = connect_client(test_name); |
4406 | 74 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888) | 73 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50) |
4407 | 75 | .set_name(test_name); | 74 | .set_name(test_name); |
4408 | 76 | 75 | ||
4409 | 77 | Window const surface{spec.create_window()}; | 76 | Window const surface{spec.create_window()}; |
4410 | @@ -86,46 +85,6 @@ | |||
4411 | 86 | ASSERT_THAT(client_surface_id.c_str(), Eq(id)); | 85 | ASSERT_THAT(client_surface_id.c_str(), Eq(id)); |
4412 | 87 | }); | 86 | }); |
4413 | 88 | } | 87 | } |
4414 | 89 | #else | ||
4415 | 90 | TEST_F(WindowId, server_fails_gracefully_to_identify_window_specified_by_client) | ||
4416 | 91 | { | ||
4417 | 92 | char const* const test_name = __PRETTY_FUNCTION__; | ||
4418 | 93 | using namespace mir::client; | ||
4419 | 94 | |||
4420 | 95 | auto const connection = connect_client(test_name); | ||
4421 | 96 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888) | ||
4422 | 97 | .set_name(test_name); | ||
4423 | 98 | |||
4424 | 99 | Window const surface{spec.create_window()}; | ||
4425 | 100 | |||
4426 | 101 | mir::client::WindowId client_surface_id{surface}; | ||
4427 | 102 | |||
4428 | 103 | invoke_tools([&](miral::WindowManagerTools& tools) | ||
4429 | 104 | { | ||
4430 | 105 | EXPECT_THROW(tools.info_for_window_id(client_surface_id.c_str()), std::runtime_error); | ||
4431 | 106 | }); | ||
4432 | 107 | } | ||
4433 | 108 | |||
4434 | 109 | TEST_F(WindowId, server_fails_gracefully_to_return_id_for_window) | ||
4435 | 110 | { | ||
4436 | 111 | char const* const test_name = __PRETTY_FUNCTION__; | ||
4437 | 112 | using namespace mir::client; | ||
4438 | 113 | |||
4439 | 114 | auto const connection = connect_client(test_name); | ||
4440 | 115 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888) | ||
4441 | 116 | .set_name(test_name); | ||
4442 | 117 | |||
4443 | 118 | Window const surface{spec.create_window()}; | ||
4444 | 119 | |||
4445 | 120 | mir::client::WindowId client_surface_id{surface}; | ||
4446 | 121 | |||
4447 | 122 | invoke_tools([&](miral::WindowManagerTools& tools) | ||
4448 | 123 | { | ||
4449 | 124 | auto window = get_first_window(tools); | ||
4450 | 125 | EXPECT_THROW(tools.id_for_window(window), std::runtime_error); | ||
4451 | 126 | }); | ||
4452 | 127 | } | ||
4453 | 128 | #endif | ||
4454 | 129 | 88 | ||
4455 | 130 | TEST_F(WindowId, server_fails_gracefully_to_identify_window_from_garbage_id) | 89 | TEST_F(WindowId, server_fails_gracefully_to_identify_window_from_garbage_id) |
4456 | 131 | { | 90 | { |
4457 | @@ -133,8 +92,7 @@ | |||
4458 | 133 | using namespace mir::client; | 92 | using namespace mir::client; |
4459 | 134 | 93 | ||
4460 | 135 | auto const connection = connect_client(test_name); | 94 | auto const connection = connect_client(test_name); |
4463 | 136 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888) | 95 | auto const spec = WindowSpec::for_normal_window(connection, 50, 50).set_name(test_name); |
4462 | 137 | .set_name(test_name); | ||
4464 | 138 | 96 | ||
4465 | 139 | Window const surface{spec.create_window()}; | 97 | Window const surface{spec.create_window()}; |
4466 | 140 | 98 | ||
4467 | 141 | 99 | ||
4468 | === modified file 'test/window_placement_client_api.cpp' | |||
4469 | --- test/window_placement_client_api.cpp 2017-02-14 11:49:59 +0000 | |||
4470 | +++ test/window_placement_client_api.cpp 2017-06-20 16:14:05 +0000 | |||
4471 | @@ -16,19 +16,8 @@ | |||
4472 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
4473 | 17 | */ | 17 | */ |
4474 | 18 | 18 | ||
4475 | 19 | #include <mir/version.h> | ||
4476 | 20 | #include <mir_toolkit/version.h> | ||
4477 | 21 | |||
4478 | 22 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
4479 | 23 | #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) | ||
4480 | 24 | #include <mir_toolkit/events/surface_placement.h> | ||
4481 | 25 | auto const mir_event_get_window_placement_event = mir_event_get_surface_placement_event; | ||
4482 | 26 | #else | ||
4483 | 27 | #include <mir_toolkit/events/window_placement.h> | 19 | #include <mir_toolkit/events/window_placement.h> |
4484 | 28 | #endif | ||
4485 | 29 | #endif | ||
4486 | 30 | 20 | ||
4487 | 31 | #include <mir/client/detail/mir_forward_compatibility.h> | ||
4488 | 32 | #include <mir/client/window_spec.h> | 21 | #include <mir/client/window_spec.h> |
4489 | 33 | #include <mir/client/window.h> | 22 | #include <mir/client/window.h> |
4490 | 34 | 23 | ||
4491 | @@ -57,7 +46,7 @@ | |||
4492 | 57 | char const* const test_name = __PRETTY_FUNCTION__; | 46 | char const* const test_name = __PRETTY_FUNCTION__; |
4493 | 58 | 47 | ||
4494 | 59 | connection = connect_client(test_name); | 48 | connection = connect_client(test_name); |
4496 | 60 | auto spec = WindowSpec::for_normal_window(connection, 400, 400, mir_pixel_format_argb_8888) | 49 | auto spec = WindowSpec::for_normal_window(connection, 400, 400) |
4497 | 61 | .set_name(test_name); | 50 | .set_name(test_name); |
4498 | 62 | 51 | ||
4499 | 63 | parent = spec.create_window(); | 52 | parent = spec.create_window(); |
4500 | @@ -78,12 +67,6 @@ | |||
4501 | 78 | }; | 67 | }; |
4502 | 79 | } | 68 | } |
4503 | 80 | 69 | ||
4504 | 81 | #if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) | ||
4505 | 82 | |||
4506 | 83 | #if MIR_CLIENT_VERSION == MIR_VERSION_NUMBER(3, 4, 0) | ||
4507 | 84 | auto const mir_event_type_window_placement = mir_event_type_surface_placement; | ||
4508 | 85 | #endif | ||
4509 | 86 | |||
4510 | 87 | namespace | 70 | namespace |
4511 | 88 | { | 71 | { |
4512 | 89 | struct CheckPlacement | 72 | struct CheckPlacement |
4513 | @@ -137,7 +120,7 @@ | |||
4514 | 137 | CheckPlacement expected{aux_rect.left+(int)aux_rect.width, aux_rect.top, dx, dy}; | 120 | CheckPlacement expected{aux_rect.left+(int)aux_rect.width, aux_rect.top, dx, dy}; |
4515 | 138 | 121 | ||
4516 | 139 | auto const spec = WindowSpec:: | 122 | auto const spec = WindowSpec:: |
4518 | 140 | for_menu(connection, dx, dy, mir_pixel_format_argb_8888, parent, &aux_rect, mir_edge_attachment_any) | 123 | for_menu(connection, dx, dy, parent, &aux_rect, mir_edge_attachment_any) |
4519 | 141 | .set_event_handler(&CheckPlacement::callback, &expected) | 124 | .set_event_handler(&CheckPlacement::callback, &expected) |
4520 | 142 | .set_name(test_name); | 125 | .set_name(test_name); |
4521 | 143 | 126 | ||
4522 | @@ -156,4 +139,3 @@ | |||
4523 | 156 | spec.apply_to(child); | 139 | spec.apply_to(child); |
4524 | 157 | } | 140 | } |
4525 | 158 | } | 141 | } |
4526 | 159 | #endif | ||
4527 | 160 | 142 | ||
4528 | === modified file 'test/window_properties.cpp' | |||
4529 | --- test/window_properties.cpp 2017-02-21 15:49:58 +0000 | |||
4530 | +++ test/window_properties.cpp 2017-06-20 16:14:05 +0000 | |||
4531 | @@ -18,6 +18,7 @@ | |||
4532 | 18 | 18 | ||
4533 | 19 | #include <miral/window_manager_tools.h> | 19 | #include <miral/window_manager_tools.h> |
4534 | 20 | 20 | ||
4535 | 21 | #include <mir/client/surface.h> | ||
4536 | 21 | #include <mir/client/window.h> | 22 | #include <mir/client/window.h> |
4537 | 22 | #include <mir/client/window_spec.h> | 23 | #include <mir/client/window_spec.h> |
4538 | 23 | #include <mir_toolkit/mir_buffer_stream.h> | 24 | #include <mir_toolkit/mir_buffer_stream.h> |
4539 | @@ -45,18 +46,27 @@ | |||
4540 | 45 | { | 46 | { |
4541 | 46 | miral::TestServer::SetUp(); | 47 | miral::TestServer::SetUp(); |
4542 | 47 | client_connection = connect_client("WindowProperties"); | 48 | client_connection = connect_client("WindowProperties"); |
4543 | 49 | surface = Surface{mir_connection_create_render_surface_sync(client_connection, 40, 40)}; | ||
4544 | 48 | } | 50 | } |
4545 | 49 | 51 | ||
4546 | 50 | void TearDown() override | 52 | void TearDown() override |
4547 | 51 | { | 53 | { |
4548 | 54 | surface.reset(); | ||
4549 | 52 | client_connection.reset(); | 55 | client_connection.reset(); |
4550 | 53 | miral::TestServer::TearDown(); | 56 | miral::TestServer::TearDown(); |
4551 | 54 | } | 57 | } |
4552 | 55 | 58 | ||
4553 | 56 | Connection client_connection; | 59 | Connection client_connection; |
4554 | 60 | Surface surface; | ||
4555 | 57 | 61 | ||
4556 | 58 | std::unique_ptr<TestWindowManagerPolicy> build_window_manager_policy(WindowManagerTools const& tools) override; | 62 | std::unique_ptr<TestWindowManagerPolicy> build_window_manager_policy(WindowManagerTools const& tools) override; |
4557 | 59 | 63 | ||
4558 | 64 | void paint(Surface const& surface) | ||
4559 | 65 | { | ||
4560 | 66 | mir_buffer_stream_swap_buffers_sync( | ||
4561 | 67 | mir_render_surface_get_buffer_stream(surface, 50, 50, mir_pixel_format_argb_8888)); | ||
4562 | 68 | } | ||
4563 | 69 | |||
4564 | 60 | mir::test::Signal window_ready; | 70 | mir::test::Signal window_ready; |
4565 | 61 | }; | 71 | }; |
4566 | 62 | 72 | ||
4567 | @@ -80,12 +90,12 @@ | |||
4568 | 80 | 90 | ||
4569 | 81 | TEST_F(WindowProperties, on_creation_default_shell_chrome_is_normal) | 91 | TEST_F(WindowProperties, on_creation_default_shell_chrome_is_normal) |
4570 | 82 | { | 92 | { |
4573 | 83 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50, mir_pixel_format_argb_8888) | 93 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50) |
4572 | 84 | .set_buffer_usage(mir_buffer_usage_software) | ||
4574 | 85 | .set_name(a_window.c_str()) | 94 | .set_name(a_window.c_str()) |
4575 | 95 | .add_surface(surface, 50, 50, 0, 0) | ||
4576 | 86 | .create_window(); | 96 | .create_window(); |
4577 | 87 | 97 | ||
4579 | 88 | mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window)); | 98 | paint(surface); |
4580 | 89 | ASSERT_TRUE(window_ready.wait_for(400ms)); | 99 | ASSERT_TRUE(window_ready.wait_for(400ms)); |
4581 | 90 | 100 | ||
4582 | 91 | invoke_tools([&, this](WindowManagerTools& tools) | 101 | invoke_tools([&, this](WindowManagerTools& tools) |
4583 | @@ -96,13 +106,13 @@ | |||
4584 | 96 | 106 | ||
4585 | 97 | TEST_F(WindowProperties, on_creation_client_setting_shell_chrome_low_is_seen_by_window_manager) | 107 | TEST_F(WindowProperties, on_creation_client_setting_shell_chrome_low_is_seen_by_window_manager) |
4586 | 98 | { | 108 | { |
4589 | 99 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50, mir_pixel_format_argb_8888) | 109 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50) |
4588 | 100 | .set_buffer_usage(mir_buffer_usage_software) | ||
4590 | 101 | .set_name(a_window.c_str()) | 110 | .set_name(a_window.c_str()) |
4591 | 102 | .set_shell_chrome(mir_shell_chrome_low) | 111 | .set_shell_chrome(mir_shell_chrome_low) |
4592 | 112 | .add_surface(surface, 50, 50, 0, 0) | ||
4593 | 103 | .create_window(); | 113 | .create_window(); |
4594 | 104 | 114 | ||
4596 | 105 | mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window)); | 115 | paint(surface); |
4597 | 106 | ASSERT_TRUE(window_ready.wait_for(400ms)); | 116 | ASSERT_TRUE(window_ready.wait_for(400ms)); |
4598 | 107 | 117 | ||
4599 | 108 | invoke_tools([&, this](WindowManagerTools& tools) | 118 | invoke_tools([&, this](WindowManagerTools& tools) |
4600 | @@ -113,16 +123,17 @@ | |||
4601 | 113 | 123 | ||
4602 | 114 | TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_low_is_seen_by_window_manager) | 124 | TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_low_is_seen_by_window_manager) |
4603 | 115 | { | 125 | { |
4606 | 116 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50, mir_pixel_format_argb_8888) | 126 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50) |
4605 | 117 | .set_buffer_usage(mir_buffer_usage_software) | ||
4607 | 118 | .set_name(a_window.c_str()) | 127 | .set_name(a_window.c_str()) |
4608 | 128 | .add_surface(surface, 50, 50, 0, 0) | ||
4609 | 119 | .create_window(); | 129 | .create_window(); |
4610 | 120 | 130 | ||
4611 | 121 | WindowSpec::for_changes(client_connection) | 131 | WindowSpec::for_changes(client_connection) |
4612 | 122 | .set_shell_chrome(mir_shell_chrome_low) | 132 | .set_shell_chrome(mir_shell_chrome_low) |
4613 | 123 | .apply_to(window); | 133 | .apply_to(window); |
4614 | 124 | 134 | ||
4616 | 125 | mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window)); | 135 | paint(surface); |
4617 | 136 | |||
4618 | 126 | ASSERT_TRUE(window_ready.wait_for(400ms)); | 137 | ASSERT_TRUE(window_ready.wait_for(400ms)); |
4619 | 127 | 138 | ||
4620 | 128 | invoke_tools([&, this](WindowManagerTools& tools) | 139 | invoke_tools([&, this](WindowManagerTools& tools) |
4621 | @@ -133,17 +144,17 @@ | |||
4622 | 133 | 144 | ||
4623 | 134 | TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_normal_is_seen_by_window_manager) | 145 | TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_normal_is_seen_by_window_manager) |
4624 | 135 | { | 146 | { |
4627 | 136 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50, mir_pixel_format_argb_8888) | 147 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50) |
4626 | 137 | .set_buffer_usage(mir_buffer_usage_software) | ||
4628 | 138 | .set_name(a_window.c_str()) | 148 | .set_name(a_window.c_str()) |
4629 | 139 | .set_shell_chrome(mir_shell_chrome_low) | 149 | .set_shell_chrome(mir_shell_chrome_low) |
4630 | 150 | .add_surface(surface, 50, 50, 0, 0) | ||
4631 | 140 | .create_window(); | 151 | .create_window(); |
4632 | 141 | 152 | ||
4633 | 142 | WindowSpec::for_changes(client_connection) | 153 | WindowSpec::for_changes(client_connection) |
4634 | 143 | .set_shell_chrome(mir_shell_chrome_normal) | 154 | .set_shell_chrome(mir_shell_chrome_normal) |
4635 | 144 | .apply_to(window); | 155 | .apply_to(window); |
4636 | 145 | 156 | ||
4638 | 146 | mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window)); | 157 | paint(surface); |
4639 | 147 | ASSERT_TRUE(window_ready.wait_for(400ms)); | 158 | ASSERT_TRUE(window_ready.wait_for(400ms)); |
4640 | 148 | 159 | ||
4641 | 149 | invoke_tools([&, this](WindowManagerTools& tools) | 160 | invoke_tools([&, this](WindowManagerTools& tools) |
4642 | 150 | 161 | ||
4643 | === modified file 'test/workspaces.cpp' | |||
4644 | --- test/workspaces.cpp 2017-03-30 09:42:17 +0000 | |||
4645 | +++ test/workspaces.cpp 2017-06-20 16:14:05 +0000 | |||
4646 | @@ -19,6 +19,7 @@ | |||
4647 | 19 | #include <miral/workspace_policy.h> | 19 | #include <miral/workspace_policy.h> |
4648 | 20 | #include <miral/window_manager_tools.h> | 20 | #include <miral/window_manager_tools.h> |
4649 | 21 | 21 | ||
4650 | 22 | #include <mir/client/surface.h> | ||
4651 | 22 | #include <mir/client/window.h> | 23 | #include <mir/client/window.h> |
4652 | 23 | #include <mir/client/window_spec.h> | 24 | #include <mir/client/window_spec.h> |
4653 | 24 | #include <mir_toolkit/mir_buffer_stream.h> | 25 | #include <mir_toolkit/mir_buffer_stream.h> |
4654 | @@ -65,57 +66,74 @@ | |||
4655 | 65 | Workspaces& test_fixture; | 66 | Workspaces& test_fixture; |
4656 | 66 | }; | 67 | }; |
4657 | 67 | 68 | ||
4658 | 69 | struct TestWindow : Surface, Window | ||
4659 | 70 | { | ||
4660 | 71 | using Surface::operator=; | ||
4661 | 72 | using Window::operator=; | ||
4662 | 73 | }; | ||
4663 | 74 | |||
4664 | 68 | struct Workspaces : public miral::TestServer | 75 | struct Workspaces : public miral::TestServer |
4665 | 69 | { | 76 | { |
4667 | 70 | auto create_window(std::string const& name) -> Window | 77 | auto create_window(std::string const& name) -> TestWindow |
4668 | 71 | { | 78 | { |
4671 | 72 | auto const window = WindowSpec::for_normal_window(client_connection, 50, 50, mir_pixel_format_argb_8888) | 79 | TestWindow result; |
4672 | 73 | .set_buffer_usage(mir_buffer_usage_software) | 80 | |
4673 | 81 | result = Surface{mir_connection_create_render_surface_sync(client_connection, 50, 50)}; | ||
4674 | 82 | result = WindowSpec::for_normal_window(client_connection, 50, 50) | ||
4675 | 74 | .set_name(name.c_str()) | 83 | .set_name(name.c_str()) |
4676 | 84 | .add_surface(result, 50, 50, 0, 0) | ||
4677 | 75 | .create_window(); | 85 | .create_window(); |
4678 | 76 | 86 | ||
4681 | 77 | client_windows[name] = window; | 87 | client_windows[name] = result; |
4682 | 78 | init_window(window); | 88 | init_window(result); |
4683 | 79 | 89 | ||
4685 | 80 | return window; | 90 | return result; |
4686 | 81 | } | 91 | } |
4687 | 82 | 92 | ||
4689 | 83 | void init_window(Window const& window) | 93 | void init_window(TestWindow const& window) |
4690 | 84 | { | 94 | { |
4691 | 85 | mir::test::Signal window_ready; | 95 | mir::test::Signal window_ready; |
4692 | 86 | EXPECT_CALL(policy(), advise_window_ready(_)).WillOnce(InvokeWithoutArgs([&]{ window_ready.raise(); })); | 96 | EXPECT_CALL(policy(), advise_window_ready(_)).WillOnce(InvokeWithoutArgs([&]{ window_ready.raise(); })); |
4693 | 87 | 97 | ||
4695 | 88 | mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window)); | 98 | mir_buffer_stream_swap_buffers_sync( |
4696 | 99 | mir_render_surface_get_buffer_stream(window, 50, 50, mir_pixel_format_argb_8888)); | ||
4697 | 89 | 100 | ||
4698 | 90 | EXPECT_TRUE(window_ready.wait_for(1s)); | 101 | EXPECT_TRUE(window_ready.wait_for(1s)); |
4699 | 91 | } | 102 | } |
4700 | 92 | 103 | ||
4702 | 93 | auto create_tip(std::string const& name, Window const& parent) -> Window | 104 | auto create_tip(std::string const& name, Window const& parent) -> TestWindow |
4703 | 94 | { | 105 | { |
4704 | 106 | TestWindow result; | ||
4705 | 107 | |||
4706 | 108 | result = Surface{mir_connection_create_render_surface_sync(client_connection, 50, 50)}; | ||
4707 | 109 | |||
4708 | 95 | MirRectangle aux_rect{10, 10, 10, 10}; | 110 | MirRectangle aux_rect{10, 10, 10, 10}; |
4712 | 96 | auto const window = WindowSpec::for_tip(client_connection, 50, 50, mir_pixel_format_argb_8888, parent, | 111 | result = WindowSpec::for_tip(client_connection, 50, 50, parent, &aux_rect, mir_edge_attachment_any) |
4710 | 97 | &aux_rect, mir_edge_attachment_any) | ||
4711 | 98 | .set_buffer_usage(mir_buffer_usage_software) | ||
4713 | 99 | .set_name(name.c_str()) | 112 | .set_name(name.c_str()) |
4714 | 113 | .add_surface(result, 50, 50, 0, 0) | ||
4715 | 100 | .create_window(); | 114 | .create_window(); |
4716 | 101 | 115 | ||
4719 | 102 | client_windows[name] = window; | 116 | client_windows[name] = result; |
4720 | 103 | init_window(window); | 117 | init_window(result); |
4721 | 104 | 118 | ||
4723 | 105 | return window; | 119 | return result; |
4724 | 106 | } | 120 | } |
4725 | 107 | 121 | ||
4727 | 108 | auto create_dialog(std::string const& name, Window const& parent) -> Window | 122 | auto create_dialog(std::string const& name, Window const& parent) -> TestWindow |
4728 | 109 | { | 123 | { |
4731 | 110 | auto const window = WindowSpec::for_dialog(client_connection, 50, 50, mir_pixel_format_argb_8888, parent) | 124 | TestWindow result; |
4732 | 111 | .set_buffer_usage(mir_buffer_usage_software) | 125 | |
4733 | 126 | result = Surface{mir_connection_create_render_surface_sync(client_connection, 50, 50)}; | ||
4734 | 127 | |||
4735 | 128 | result = WindowSpec::for_dialog(client_connection, 50, 50, parent) | ||
4736 | 112 | .set_name(name.c_str()) | 129 | .set_name(name.c_str()) |
4737 | 130 | .add_surface(result, 50, 50, 0, 0) | ||
4738 | 113 | .create_window(); | 131 | .create_window(); |
4739 | 114 | 132 | ||
4742 | 115 | client_windows[name] = window; | 133 | client_windows[name] = result; |
4743 | 116 | init_window(window); | 134 | init_window(result); |
4744 | 117 | 135 | ||
4746 | 118 | return window; | 136 | return result; |
4747 | 119 | } | 137 | } |
4748 | 120 | 138 | ||
4749 | 121 | auto create_workspace() -> std::shared_ptr<miral::Workspace> | 139 | auto create_workspace() -> std::shared_ptr<miral::Workspace> |
4750 | @@ -202,7 +220,7 @@ | |||
4751 | 202 | 220 | ||
4752 | 203 | private: | 221 | private: |
4753 | 204 | std::mutex mutable mutex; | 222 | std::mutex mutable mutex; |
4755 | 205 | std::map<std::string, Window> client_windows; | 223 | std::map<std::string, TestWindow> client_windows; |
4756 | 206 | std::map<std::string, miral::Window> server_windows; | 224 | std::map<std::string, miral::Window> server_windows; |
4757 | 207 | WorkspacesWindowManagerPolicy* the_policy{nullptr}; | 225 | WorkspacesWindowManagerPolicy* the_policy{nullptr}; |
4758 | 208 | 226 | ||
4759 | @@ -466,9 +484,11 @@ | |||
4760 | 466 | 484 | ||
4761 | 467 | { | 485 | { |
4762 | 468 | auto const another_app = connect_client("another app"); | 486 | auto const another_app = connect_client("another app"); |
4765 | 469 | auto const window = WindowSpec::for_normal_window(another_app, 50, 50, mir_pixel_format_argb_8888) | 487 | TestWindow window; |
4766 | 470 | .set_buffer_usage(mir_buffer_usage_software) | 488 | window = Surface{mir_connection_create_render_surface_sync(another_app, 50, 50)}; |
4767 | 489 | window = WindowSpec::for_normal_window(another_app, 50, 50) | ||
4768 | 471 | .set_name(a_window.c_str()) | 490 | .set_name(a_window.c_str()) |
4769 | 491 | .add_surface(window, 50, 50, 0, 0) | ||
4770 | 472 | .create_window(); | 492 | .create_window(); |
4771 | 473 | 493 | ||
4772 | 474 | init_window(window); | 494 | init_window(window); |
4773 | @@ -527,9 +547,11 @@ | |||
4774 | 527 | create_window(another_window); | 547 | create_window(another_window); |
4775 | 528 | 548 | ||
4776 | 529 | auto const another_app = connect_client("another app"); | 549 | auto const another_app = connect_client("another app"); |
4779 | 530 | auto const window = WindowSpec::for_normal_window(another_app, 50, 50, mir_pixel_format_argb_8888) | 550 | TestWindow window; |
4780 | 531 | .set_buffer_usage(mir_buffer_usage_software) | 551 | window = Surface{mir_connection_create_render_surface_sync(another_app, 50, 50)}; |
4781 | 552 | window = WindowSpec::for_normal_window(another_app, 50, 50) | ||
4782 | 532 | .set_name(a_window.c_str()) | 553 | .set_name(a_window.c_str()) |
4783 | 554 | .add_surface(window, 50, 50, 0, 0) | ||
4784 | 533 | .create_window(); | 555 | .create_window(); |
4785 | 534 | 556 | ||
4786 | 535 | init_window(window); | 557 | init_window(window); |
4787 | @@ -590,9 +612,11 @@ | |||
4788 | 590 | create_window(another_window); | 612 | create_window(another_window); |
4789 | 591 | 613 | ||
4790 | 592 | auto const another_app = connect_client("another app"); | 614 | auto const another_app = connect_client("another app"); |
4793 | 593 | auto const window = WindowSpec::for_normal_window(another_app, 50, 50, mir_pixel_format_argb_8888) | 615 | TestWindow window; |
4794 | 594 | .set_buffer_usage(mir_buffer_usage_software) | 616 | window = Surface{mir_connection_create_render_surface_sync(another_app, 50, 50)}; |
4795 | 617 | window = WindowSpec::for_normal_window(another_app, 50, 50) | ||
4796 | 595 | .set_name(a_window.c_str()) | 618 | .set_name(a_window.c_str()) |
4797 | 619 | .add_surface(window, 50, 50, 0, 0) | ||
4798 | 596 | .create_window(); | 620 | .create_window(); |
4799 | 597 | 621 | ||
4800 | 598 | init_window(window); | 622 | init_window(window); |