Merge lp:~alan-griffiths/miral/1.4 into lp:miral/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
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+325737@code.launchpad.net

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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2017-03-24 17:44:48 +0000
+++ CMakeLists.txt 2017-06-20 16:14:05 +0000
@@ -1,16 +1,12 @@
1cmake_minimum_required(VERSION 3.1)1cmake_minimum_required(VERSION 3.5)
2cmake_policy(SET CMP0015 NEW)
3cmake_policy(SET CMP0022 NEW)
4
2project(miral)5project(miral)
36
4if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
5 set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "/usr install prefix" FORCE)
6endif()
7
8include (GNUInstallDirs)7include (GNUInstallDirs)
9include(CheckCXXCompilerFlag)8include(CheckCXXCompilerFlag)
109
11cmake_policy(SET CMP0015 NEW)
12cmake_policy(SET CMP0022 NEW)
13
14set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)10set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
1511
16set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)12set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -36,16 +32,21 @@
3632
37include(FindPkgConfig)33include(FindPkgConfig)
3834
39pkg_check_modules(MIRCLIENT mirclient>=0.20 REQUIRED)35pkg_check_modules(MIRCLIENT mirclient>=0.26 REQUIRED)
4036
41include_directories(include SYSTEM ${MIRCLIENT_INCLUDE_DIRS})37include_directories(include SYSTEM ${MIRCLIENT_INCLUDE_DIRS})
4238
43set(MIRAL_VERSION_MAJOR 1)39set(MIRAL_VERSION_MAJOR 1)
44set(MIRAL_VERSION_MINOR 3)40set(MIRAL_VERSION_MINOR 4)
45set(MIRAL_VERSION_PATCH 2)41set(MIRAL_VERSION_PATCH 0)
4642
47set(MIRAL_VERSION ${MIRAL_VERSION_MAJOR}.${MIRAL_VERSION_MINOR}.${MIRAL_VERSION_PATCH})43set(MIRAL_VERSION ${MIRAL_VERSION_MAJOR}.${MIRAL_VERSION_MINOR}.${MIRAL_VERSION_PATCH})
4844
45if (MIRCLIENT_VERSION VERSION_LESS 0.26.3)
46 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
47 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
48endif()
49
49add_subdirectory(miral)50add_subdirectory(miral)
50add_subdirectory(miral-shell)51add_subdirectory(miral-shell)
51add_subdirectory(miral-kiosk)52add_subdirectory(miral-kiosk)
@@ -54,19 +55,13 @@
54if(NOT MIRTEST_FOUND)55if(NOT MIRTEST_FOUND)
55 message(WARNING "mirtest-dev package not installed - tests cannot be built")56 message(WARNING "mirtest-dev package not installed - tests cannot be built")
56else()57else()
57 if (MIRTEST_VERSION VERSION_LESS 0.24)58 option(MIRAL_ENABLE_TESTS "Build tests" on)
58 # building the tests is disabled by default because the mirtest-dev package is broken on xenial59
59 # (lp:1583536 and lp:1603080)60 if (MIRAL_ENABLE_TESTS)
60 option(MIRAL_ENABLE_TESTS "Build tests" off)61 enable_testing()
61 else()62 find_package(GMock REQUIRED)
62 option(MIRAL_ENABLE_TESTS "Build tests" on)63 add_subdirectory(test)
63 endif()64 endif()
64
65if (MIRAL_ENABLE_TESTS)
66 enable_testing()
67 find_package(GMock REQUIRED)
68 add_subdirectory(test)
69endif()
70endif()65endif()
7166
72include (cmake/Doxygen.cmake)67include (cmake/Doxygen.cmake)
7368
=== modified file 'debian/changelog'
--- debian/changelog 2017-03-30 14:18:38 +0000
+++ debian/changelog 2017-06-20 16:14:05 +0000
@@ -1,3 +1,18 @@
1miral (1.4.0) UNRELEASED; urgency=medium
2
3 * New upstream release 1.4.0 (https://launchpad.net/miral/+milestone/1.4.0)
4 - ABI summary:
5 . miral ABI unchanged at 2
6 - Enhancements:
7 . Support for passing messages to enable Drag & Drop
8 . Support for client requested move
9 . Port to the undeprecated Mir APIs
10 . Added "--cursor-theme" option when configuring a cursor theme
11 . Drop support for Mir versions before 0.26
12 - Bugs fixed:
13
14 -- Alan Griffiths <alan.griffiths@canonical.com> Tue, 21 Mar 2017 17:57:20 +0000
15
1miral (1.3.2+17.04.20170330.5-0ubuntu1) zesty; urgency=medium16miral (1.3.2+17.04.20170330.5-0ubuntu1) zesty; urgency=medium
217
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)
@@ -74,11 +89,11 @@
74 . Chrome-less shell hint does not work any more (LP: #1658117)89 . Chrome-less shell hint does not work any more (LP: #1658117)
75 . WindowSpec::set_state() wrapper for mir_window_spec_set_state()90 . WindowSpec::set_state() wrapper for mir_window_spec_set_state()
76 (LP: #1661256)91 (LP: #1661256)
77 . "$ miral-app -kiosk" fails with "Unknown command line options: 92 . "$ miral-app -kiosk" fails with "Unknown command line options:
78 --desktop_file_hint=miral-shell.desktop" (LP: #1660933)93 --desktop_file_hint=miral-shell.desktop" (LP: #1660933)
79 . libmiral] Fix focus and movement rules for Input Method and Satellite94 . libmiral] Fix focus and movement rules for Input Method and Satellite
80 windows. (LP: #1660691)95 windows. (LP: #1660691)
81 96
8297
83 -- Alan Griffiths <alan.griffiths@canonical.com> Wed, 15 Feb 2017 14:05:46 +000098 -- Alan Griffiths <alan.griffiths@canonical.com> Wed, 15 Feb 2017 14:05:46 +0000
8499
85100
=== modified file 'debian/control'
--- debian/control 2017-02-16 11:13:26 +0000
+++ debian/control 2017-06-20 16:14:05 +0000
@@ -14,18 +14,13 @@
14 python-pil,14 python-pil,
15 google-mock (>= 1.6.0+svn437),15 google-mock (>= 1.6.0+svn437),
16 python3:any,16 python3:any,
17 libmirserver-dev,17 libmirserver-dev (>= 0.26),
18 libmirclient-dev,18 libmirclient-dev (>= 0.26),
19 mirtest-dev,19 mirtest-dev (>= 0.26),
20 mir-test-tools (>= 0.26),
20 libglib2.0-dev,21 libglib2.0-dev,
21 libgles2-mesa-dev,22 libgles2-mesa-dev,
22 libfreetype6-dev,23 libfreetype6-dev,
23# The following workaround missing dependencies in Mir packages
24 uuid-dev,
25 libboost-system-dev,
26 libboost-filesystem-dev,
27 mir-test-tools,
28 mir-renderer-gl-dev,
29Standards-Version: 3.9.824Standards-Version: 3.9.8
30Homepage: https://launchpad.net/miral25Homepage: https://launchpad.net/miral
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,
3227
=== modified file 'debian/libmiral2.symbols'
--- debian/libmiral2.symbols 2017-03-15 17:44:36 +0000
+++ debian/libmiral2.symbols 2017-06-20 16:14:05 +0000
@@ -389,3 +389,7 @@
389 (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1389 (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1
390 (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1390 (c++)"miral::SetWindowManagementPolicy::~SetWindowManagementPolicy()@MIRAL_1.3.1" 1.3.1
391 (c++)"miral::SetWindowManagementPolicy::operator()(mir::Server&) const@MIRAL_1.3.1" 1.3.1391 (c++)"miral::SetWindowManagementPolicy::operator()(mir::Server&) const@MIRAL_1.3.1" 1.3.1
392 MIRAL_1.4.0@MIRAL_1.4.0 1.4.0
393 (c++)"miral::WindowManagerTools::end_drag_and_drop()@MIRAL_1.4.0" 1.4.0
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
395 (c++)"typeinfo for miral::WindowManagementPolicyAddendum2@MIRAL_1.4.0" 1.4.0
392396
=== removed directory 'debian/tmp'
=== modified file 'doc/introducing_the_miral_api.md'
--- doc/introducing_the_miral_api.md 2016-08-02 13:25:18 +0000
+++ doc/introducing_the_miral_api.md 2017-06-20 16:14:05 +0000
@@ -8,14 +8,14 @@
88
9\include shell_main.cpp9\include shell_main.cpp
1010
11This shell is providing TitlebarWindowManagerPolicy, TilingWindowManagerPolicy11This shell is providing FloatingWindowManagerPolicy, TilingWindowManagerPolicy
12and SpinnerSplash. The rest is from MirAL.12and SpinnerSplash. The rest is from MirAL.
1313
14If you look for the corresponding code in lp:qtmir and lp:mir you’ll find it14If you look for the corresponding code in lp:qtmir and lp:mir you’ll find it
15less clear, more verbose and scattered over multiple files.15less clear, more verbose and scattered over multiple files.
1616
17A shell has to provide a window management policy (miral-shell provides two: 17A shell has to provide a window management policy (miral-shell provides two:
18TitlebarWindowManagerPolicy and TilingWindowManagerPolicy). A window management18FloatingWindowManagerPolicy and TilingWindowManagerPolicy). A window management
19policy needs to implement the \ref miral::WindowManagementPolicy interface for19policy needs to implement the \ref miral::WindowManagementPolicy interface for
20handling a set of window management events.20handling a set of window management events.
2121
2222
=== removed file 'include/mir/client/detail/mir_forward_compatibility.h'
--- include/mir/client/detail/mir_forward_compatibility.h 2017-02-14 13:50:07 +0000
+++ include/mir/client/detail/mir_forward_compatibility.h 1970-01-01 00:00:00 +0000
@@ -1,172 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIRAL_MIR_FORWARD_COMPATIBILITY_H
20#define MIRAL_MIR_FORWARD_COMPATIBILITY_H
21
22#include <mir_toolkit/version.h>
23#include <mir_toolkit/common.h>
24#include <mir/client/detail/mir_features.h>
25
26#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
27using MirWindowAttrib = MirSurfaceAttrib;
28auto const mir_window_attrib_type = mir_surface_attrib_type;
29auto const mir_window_attrib_state = mir_surface_attrib_state;
30auto const mir_window_attrib_swapinterval = mir_surface_attrib_swapinterval;
31auto const mir_window_attrib_focus = mir_surface_attrib_focus;
32auto const mir_window_attrib_dpi = mir_surface_attrib_dpi;
33auto const mir_window_attrib_visibility = mir_surface_attrib_visibility;
34auto const mir_window_attrib_preferred_orientation = mir_surface_attrib_preferred_orientation;
35auto const mir_window_attribs = mir_surface_attribs;
36
37using MirWindowType = MirSurfaceType;
38auto const mir_window_type_normal = mir_surface_type_normal;
39auto const mir_window_type_utility = mir_surface_type_utility;
40auto const mir_window_type_dialog = mir_surface_type_dialog;
41auto const mir_window_type_gloss = mir_surface_type_gloss;
42auto const mir_window_type_freestyle = mir_surface_type_freestyle;
43auto const mir_window_type_menu = mir_surface_type_menu;
44auto const mir_window_type_inputmethod = mir_surface_type_inputmethod;
45auto const mir_window_type_satellite = mir_surface_type_satellite;
46auto const mir_window_type_tip = mir_surface_type_tip;
47auto const mir_window_types = mir_surface_types;
48
49using MirWindowState = MirSurfaceState;
50auto const mir_window_state_unknown = mir_surface_state_unknown;
51auto const mir_window_state_restored = mir_surface_state_restored;
52auto const mir_window_state_minimized = mir_surface_state_minimized;
53auto const mir_window_state_maximized = mir_surface_state_maximized;
54auto const mir_window_state_vertmaximized = mir_surface_state_vertmaximized;
55auto const mir_window_state_fullscreen = mir_surface_state_fullscreen;
56auto const mir_window_state_horizmaximized = mir_surface_state_horizmaximized;
57auto const mir_window_state_hidden = mir_surface_state_hidden;
58auto const mir_window_states = mir_surface_states;
59
60typedef struct MirSurface MirWindow;
61typedef struct MirSurfaceParameters MirWindowParameters;
62typedef struct MirSurfacePlacementEvent MirWindowPlacementEvent;
63typedef struct MirSurfaceSpec MirWindowSpec;
64#endif
65
66
67// Types that don't exist in earlier versions of Mir's client
68#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 4, 0)
69
70// Inspired by GdkGravity
71/**
72 * Reference point for aligning a surface relative to a rectangle.
73 * Each element (surface and rectangle) has a MirPlacementGravity assigned.
74 */
75typedef enum MirPlacementGravity
76{
77 /// the reference point is at the center.
78 mir_placement_gravity_center = 0,
79
80 /// the reference point is at the middle of the left edge.
81 mir_placement_gravity_west = 1 << 0,
82
83 /// the reference point is at the middle of the right edge.
84 mir_placement_gravity_east = 1 << 1,
85
86 /// the reference point is in the middle of the top edge.
87 mir_placement_gravity_north = 1 << 2,
88
89 /// the reference point is at the middle of the lower edge.
90 mir_placement_gravity_south = 1 << 3,
91
92 /// the reference point is at the top left corner.
93 mir_placement_gravity_northwest = mir_placement_gravity_north | mir_placement_gravity_west,
94
95 /// the reference point is at the top right corner.
96 mir_placement_gravity_northeast = mir_placement_gravity_north | mir_placement_gravity_east,
97
98 /// the reference point is at the lower left corner.
99 mir_placement_gravity_southwest = mir_placement_gravity_south | mir_placement_gravity_west,
100
101 /// the reference point is at the lower right corner.
102 mir_placement_gravity_southeast = mir_placement_gravity_south | mir_placement_gravity_east
103} MirPlacementGravity;
104
105// Inspired by GdkAnchorHints
106/**
107 * Positioning hints for aligning a window relative to a rectangle.
108 *
109 * These hints determine how the window should be positioned in the case that
110 * the surface would fall off-screen if placed in its ideal position.
111 *
112 * For example, \p mir_placement_hints_flip_x will invert the x component of
113 * \p aux_rect_placement_offset and replace \p mir_placement_gravity_northwest
114 * with \p mir_placement_gravity_northeast and vice versa if the window extends
115 * beyond the left or right edges of the monitor.
116 *
117 * If \p mir_placement_hints_slide_x is set, the window can be shifted
118 * horizontally to fit on-screen.
119 *
120 * If \p mir_placement_hints_resize_x is set, the window can be shrunken
121 * horizontally to fit.
122 *
123 * If \p mir_placement_hints_antipodes is set then the rect gravity may be
124 * substituted with the opposite corner (e.g. \p mir_placement_gravity_northeast
125 * to \p mir_placement_gravity_southwest) in combination with other options.
126 *
127 * When multiple flags are set, flipping should take precedence over sliding,
128 * which should take precedence over resizing.
129 */
130typedef enum MirPlacementHints
131{
132 /// allow flipping anchors horizontally
133 mir_placement_hints_flip_x = 1 << 0,
134
135 /// allow flipping anchors vertically
136 mir_placement_hints_flip_y = 1 << 1,
137
138 /// allow sliding window horizontally
139 mir_placement_hints_slide_x = 1 << 2,
140
141 /// allow sliding window vertically
142 mir_placement_hints_slide_y = 1 << 3,
143
144 /// allow resizing window horizontally
145 mir_placement_hints_resize_x = 1 << 4,
146
147 /// allow resizing window vertically
148 mir_placement_hints_resize_y = 1 << 5,
149
150 /// allow flipping aux_anchor to opposite corner
151 mir_placement_hints_antipodes= 1 << 6,
152
153 /// allow flipping anchors on both axes
154 mir_placement_hints_flip_any = mir_placement_hints_flip_x|mir_placement_hints_flip_y,
155
156 /// allow sliding window on both axes
157 mir_placement_hints_slide_any = mir_placement_hints_slide_x|mir_placement_hints_slide_y,
158
159 /// allow resizing window on both axes
160 mir_placement_hints_resize_any = mir_placement_hints_resize_x|mir_placement_hints_resize_y,
161} MirPlacementHints;
162#endif
163
164#if !MIRAL_MIR_DEFINES_POINTER_CONFINEMENT
165typedef enum MirPointerConfinementState
166{
167 mir_pointer_unconfined,
168 mir_pointer_confined_to_surface,
169} MirPointerConfinementState;
170#endif
171
172#endif //MIRAL_MIR_FORWARD_COMPATIBILITY_H
1730
=== modified file 'include/mir/client/display_config.h'
--- include/mir/client/display_config.h 2017-02-22 12:45:01 +0000
+++ include/mir/client/display_config.h 2017-06-20 16:14:05 +0000
@@ -21,7 +21,6 @@
2121
22#include <mir_toolkit/mir_connection.h>22#include <mir_toolkit/mir_connection.h>
23#include <mir_toolkit/mir_display_configuration.h>23#include <mir_toolkit/mir_display_configuration.h>
24#include <mir/client/detail/mir_features.h>
2524
26#include <functional>25#include <functional>
27#include <memory>26#include <memory>
@@ -57,9 +56,6 @@
57 enumerator(mir_display_config_get_output(*this, i));56 enumerator(mir_display_config_get_output(*this, i));
58 }57 }
5958
60#if MIR_DEFINES_DISPLAY_CONFIG_GET_MUTABLE_OUTPUT
61 // Is it worthwhile to emulate this functionality for Mir 0.21?
62 // Too many API gaps I think.
63 void for_each_output(std::function<void(MirOutput*)> const& enumerator)59 void for_each_output(std::function<void(MirOutput*)> const& enumerator)
64 {60 {
65 auto const count = mir_display_config_get_num_outputs(*this);61 auto const count = mir_display_config_get_num_outputs(*this);
@@ -67,7 +63,6 @@
67 for (int i = 0; i != count; ++i)63 for (int i = 0; i != count; ++i)
68 enumerator(mir_display_config_get_mutable_output(*this, i));64 enumerator(mir_display_config_get_mutable_output(*this, i));
69 }65 }
70#endif
7166
72private:67private:
73 static void deleter(MirDisplayConfig* config) { mir_display_config_release(config); }68 static void deleter(MirDisplayConfig* config) { mir_display_config_release(config); }
7469
=== added file 'include/mir/client/surface.h'
--- include/mir/client/surface.h 1970-01-01 00:00:00 +0000
+++ include/mir/client/surface.h 2017-06-20 16:14:05 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIRAL_SURFACE_H
20#define MIRAL_SURFACE_H
21
22#include <mir_toolkit/rs/mir_render_surface.h>
23
24#include <memory>
25
26namespace mir
27{
28namespace client
29{
30/// Handle class for MirRenderSurface - provides automatic reference counting.
31class Surface
32{
33public:
34 Surface() = default;
35 explicit Surface(MirRenderSurface* spec) : self{spec, &mir_render_surface_release} {}
36
37 operator MirRenderSurface*() const { return self.get(); }
38
39 void reset() { self.reset(); }
40
41private:
42 std::shared_ptr<MirRenderSurface> self;
43};
44
45// Provide a deleted overload to avoid double release "accidents".
46void mir_render_surface_release(Surface const& surface) = delete;
47}
48}
49
50#endif //MIRAL_SURFACE_H
051
=== modified file 'include/mir/client/window.h'
--- include/mir/client/window.h 2017-02-22 12:45:01 +0000
+++ include/mir/client/window.h 2017-06-20 16:14:05 +0000
@@ -19,19 +19,7 @@
19#ifndef MIR_CLIENT_WINDOW_H19#ifndef MIR_CLIENT_WINDOW_H
20#define MIR_CLIENT_WINDOW_H20#define MIR_CLIENT_WINDOW_H
2121
22#include <mir/client/detail/mir_forward_compatibility.h>
23
24#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
25#include <mir_toolkit/mir_surface.h>
26auto const mir_window_release_sync = mir_surface_release_sync;
27auto const mir_window_release = mir_surface_release;
28auto const mir_window_get_buffer_stream = mir_surface_get_buffer_stream;
29auto const mir_window_is_valid = mir_surface_is_valid;
30auto const mir_window_get_error_message = mir_surface_get_error_message;
31auto const mir_window_set_state = mir_surface_set_state;
32#else
33#include <mir_toolkit/mir_window.h>22#include <mir_toolkit/mir_window.h>
34#endif
3523
36#include <memory>24#include <memory>
3725
3826
=== modified file 'include/mir/client/window_id.h'
--- include/mir/client/window_id.h 2017-02-24 10:36:29 +0000
+++ include/mir/client/window_id.h 2017-06-20 16:14:05 +0000
@@ -19,25 +19,8 @@
19#ifndef MIR_CLIENT_WINDOW_ID_H19#ifndef MIR_CLIENT_WINDOW_ID_H
20#define MIR_CLIENT_WINDOW_ID_H20#define MIR_CLIENT_WINDOW_ID_H
2121
22#include <mir/client/detail/mir_forward_compatibility.h>
23#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
24#include <mir_toolkit/mir_surface.h>
25auto const mir_window_request_window_id_sync = mir_surface_request_persistent_id_sync;
26#else
27#include <mir_toolkit/mir_window.h>22#include <mir_toolkit/mir_window.h>
28#endif
29
30#if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 26, 1)
31#if MIR_CLIENT_VERSION == MIR_VERSION_NUMBER(3, 5, 0)
32#include <mir_toolkit/mir_persistent_id.h>
33auto const mir_window_request_window_id_sync = mir_window_request_persistent_id_sync;
34#endif
35auto const mir_window_id_as_string = mir_persistent_id_as_string;
36auto const mir_window_id_release = mir_persistent_id_release;
37typedef struct MirPersistentId MirWindowId;
38#else
39#include <mir_toolkit/mir_window_id.h>23#include <mir_toolkit/mir_window_id.h>
40#endif
4124
42#include <memory>25#include <memory>
4326
4427
=== modified file 'include/mir/client/window_spec.h'
--- include/mir/client/window_spec.h 2017-03-03 12:31:47 +0000
+++ include/mir/client/window_spec.h 2017-06-20 16:14:05 +0000
@@ -20,50 +20,14 @@
20#define MIR_CLIENT_WINDOW_SPEC_H20#define MIR_CLIENT_WINDOW_SPEC_H
2121
22#include <mir/client/window.h>22#include <mir/client/window.h>
23#include <mir/client/detail/mir_forward_compatibility.h>
2423
25#include <mir_toolkit/mir_connection.h>24#include <mir_toolkit/mir_connection.h>
26
27#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
28#include <mir_toolkit/mir_surface.h>
29#else
30#include <mir_toolkit/mir_window.h>25#include <mir_toolkit/mir_window.h>
31#endif26#include <mir_toolkit/version.h>
27#include <mir_toolkit/rs/mir_render_surface.h>
3228
33#include <memory>29#include <memory>
3430
35// Forward compatibility hacks for earlier Mir versions
36#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
37using MirWindowCallback = mir_surface_callback;
38using MirWindowEventCallback = mir_surface_event_callback;
39auto const mir_create_window_spec = mir_connection_create_spec_for_changes;
40auto const mir_window_spec_set_event_handler = mir_surface_spec_set_event_handler;
41auto const mir_window_spec_set_name = mir_surface_spec_set_name;
42auto const mir_window_spec_set_width = mir_surface_spec_set_width;
43auto const mir_window_spec_set_height = mir_surface_spec_set_height;
44auto const mir_window_spec_set_width_increment = mir_surface_spec_set_width_increment;
45auto const mir_window_spec_set_height_increment = mir_surface_spec_set_height_increment;
46auto const mir_window_spec_set_buffer_usage = mir_surface_spec_set_buffer_usage;
47auto const mir_window_spec_set_pixel_format = mir_surface_spec_set_pixel_format;
48auto const mir_window_spec_set_type = mir_surface_spec_set_type;
49auto const mir_window_spec_set_shell_chrome = mir_surface_spec_set_shell_chrome;
50auto const mir_window_spec_set_min_width = mir_surface_spec_set_min_width;
51auto const mir_window_spec_set_min_height = mir_surface_spec_set_min_height;
52auto const mir_window_spec_set_max_width = mir_surface_spec_set_max_width;
53auto const mir_window_spec_set_max_height = mir_surface_spec_set_max_height;
54auto const mir_window_spec_set_parent = mir_surface_spec_set_parent;
55auto const mir_window_spec_set_state = mir_surface_spec_set_state;
56auto const mir_window_spec_set_fullscreen_on_output = mir_surface_spec_set_fullscreen_on_output;
57auto const mir_create_window = mir_surface_create;
58auto const mir_create_window_sync = mir_surface_create_sync;
59auto const mir_window_apply_spec = mir_surface_apply_spec;
60auto const mir_window_spec_release = mir_surface_spec_release;
61
62#if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0)
63auto const mir_window_spec_set_placement = mir_surface_spec_set_placement;
64#endif
65#endif
66
67namespace mir31namespace mir
68{32{
69namespace client33namespace client
@@ -74,126 +38,87 @@
74public:38public:
75 explicit WindowSpec(MirWindowSpec* spec) : self{spec, deleter} {}39 explicit WindowSpec(MirWindowSpec* spec) : self{spec, deleter} {}
7640
77 static auto for_normal_window(MirConnection* connection, int width, int height, MirPixelFormat format) -> WindowSpec
78 {
79#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
80 return WindowSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)};
81#else
82 auto spec = WindowSpec{mir_create_normal_window_spec(connection, width, height)};
83 mir_window_spec_set_pixel_format(spec, format);
84 return spec;
85#endif
86 }
87
88#if MIR_CLIENT_VERSION > MIR_VERSION_NUMBER(3, 4, 0)
89 static auto for_normal_window(MirConnection* connection, int width, int height) -> WindowSpec41 static auto for_normal_window(MirConnection* connection, int width, int height) -> WindowSpec
90 {42 {
91 return WindowSpec{mir_create_normal_window_spec(connection, width, height)};43 return WindowSpec{mir_create_normal_window_spec(connection, width, height)};
92 }44 }
93#endif
9445
95 static auto for_menu(MirConnection* connection,46 static auto for_menu(MirConnection* connection,
96 int width,47 int width,
97 int height,48 int height,
98 MirPixelFormat format,
99 MirWindow* parent,49 MirWindow* parent,
100 MirRectangle* rect,50 MirRectangle* rect,
101 MirEdgeAttachment edge) -> WindowSpec51 MirEdgeAttachment edge) -> WindowSpec
102 {52 {
103#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
104 return WindowSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)};
105#else
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)};
107 mir_window_spec_set_pixel_format(spec, format);
108 return spec;54 return spec;
109#endif
110 }55 }
11156
112 static auto for_tip(MirConnection* connection,57 static auto for_tip(MirConnection* connection,
113 int width,58 int width,
114 int height,59 int height,
115 MirPixelFormat format,
116 MirWindow* parent,60 MirWindow* parent,
117 MirRectangle* rect,61 MirRectangle* rect,
118 MirEdgeAttachment edge) -> WindowSpec62 MirEdgeAttachment edge) -> WindowSpec
119 {63 {
120#if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0)
121#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
122 return WindowSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)};
123#else
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)};
125 mir_window_spec_set_pixel_format(spec, format);
126 return spec;65 return spec;
127#endif
128#else
129 (void)rect;
130 (void)edge;
131 return WindowSpec{mir_create_surface_spec(connection)}
132 .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window()
133 .set_pixel_format(format) // Required protobuf field for create_window()
134 .set_size(width, height)
135 .set_parent(parent)
136 .set_type(mir_window_type_tip);
137#endif
138 }66 }
13967
140 static auto for_dialog(MirConnection* connection,68 static auto for_dialog(MirConnection* connection,
141 int width,69 int width,
142 int height,70 int height)-> WindowSpec
143 MirPixelFormat format)-> WindowSpec
144 {71 {
145#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
146 return WindowSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)};
147#else
148 auto spec = WindowSpec{mir_create_dialog_window_spec(connection, width, height)};72 auto spec = WindowSpec{mir_create_dialog_window_spec(connection, width, height)};
149 mir_window_spec_set_pixel_format(spec, format);
150 return spec;73 return spec;
151#endif
152 }74 }
15375
154 static auto for_dialog(MirConnection* connection,76 static auto for_dialog(MirConnection* connection,
155 int width,77 int width,
156 int height,78 int height,
157 MirPixelFormat format,
158 MirWindow* parent) -> WindowSpec79 MirWindow* parent) -> WindowSpec
159 {80 {
160 return for_dialog(connection, width, height, format).set_parent(parent);81 return for_dialog(connection, width, height).set_parent(parent);
161 }82 }
16283
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)
164 {85 {
165#if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 5, 0)
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)}
167#else
168 auto spec = WindowSpec{mir_create_surface_spec(connection)}
169 .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window()
170 .set_pixel_format(mir_pixel_format_invalid) // Required protobuf field for create_window()
171 .set_size(width, height)
172 .set_type(mir_window_type_inputmethod)
173#endif
174 .set_parent(parent);87 .set_parent(parent);
175 return spec;88 return spec;
176 }89 }
17790
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)
179 {92 {
93#if MIR_CLIENT_API_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
94 return WindowSpec{mir_create_satellite_window_spec(connection, width, height, parent)};
95#else
180 // There's no mir_create_satellite_window_spec()96 // There's no mir_create_satellite_window_spec()
181 return WindowSpec{mir_create_window_spec(connection)}97 auto spec = WindowSpec{mir_create_window_spec(connection)}
182 .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window()
183 .set_pixel_format(mir_pixel_format_invalid) // Required protobuf field for create_window()
184 .set_size(width, height)98 .set_size(width, height)
185 .set_type(mir_window_type_satellite)99 .set_type(mir_window_type_satellite)
186 .set_parent(parent);100 .set_parent(parent);
101
102 mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_hardware); // Required protobuf field for create_window()
103 mir_window_spec_set_pixel_format(spec, mir_pixel_format_invalid); // Required protobuf field for create_window()
104 return spec;
105#endif
187 }106 }
188107
189 static auto for_gloss(MirConnection* connection, int width, int height)108 static auto for_gloss(MirConnection* connection, int width, int height)
190 {109 {
110#if MIR_CLIENT_API_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
111 return WindowSpec{mir_create_gloss_window_spec(connection, width, height)};
112#else
191 // There's no mir_create_gloss_window_spec()113 // There's no mir_create_gloss_window_spec()
192 return WindowSpec{mir_create_window_spec(connection)}114 auto spec = WindowSpec{mir_create_window_spec(connection)}
193 .set_buffer_usage(mir_buffer_usage_hardware) // Required protobuf field for create_window()
194 .set_pixel_format(mir_pixel_format_invalid) // Required protobuf field for create_window()
195 .set_size(width, height)115 .set_size(width, height)
196 .set_type(mir_window_type_gloss);116 .set_type(mir_window_type_gloss);
117
118 mir_window_spec_set_buffer_usage(spec, mir_buffer_usage_hardware); // Required protobuf field for create_window()
119 mir_window_spec_set_pixel_format(spec, mir_pixel_format_invalid); // Required protobuf field for create_window()
120 return spec;
121#endif
197 }122 }
198123
199 static auto for_changes(MirConnection* connection) -> WindowSpec124 static auto for_changes(MirConnection* connection) -> WindowSpec
@@ -201,18 +126,6 @@
201 return WindowSpec{mir_create_window_spec(connection)};126 return WindowSpec{mir_create_window_spec(connection)};
202 }127 }
203128
204 auto set_buffer_usage(MirBufferUsage usage) -> WindowSpec&
205 {
206 mir_window_spec_set_buffer_usage(*this, usage);
207 return *this;
208 }
209
210 auto set_pixel_format(MirPixelFormat format) -> WindowSpec&
211 {
212 mir_window_spec_set_pixel_format(*this, format);
213 return *this;
214 }
215
216 auto set_type(MirWindowType type) -> WindowSpec&129 auto set_type(MirWindowType type) -> WindowSpec&
217 {130 {
218 mir_window_spec_set_type(*this, type);131 mir_window_spec_set_type(*this, type);
@@ -271,7 +184,6 @@
271 return *this;184 return *this;
272 }185 }
273186
274#if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0)
275 auto set_placement(const MirRectangle* rect,187 auto set_placement(const MirRectangle* rect,
276 MirPlacementGravity rect_gravity,188 MirPlacementGravity rect_gravity,
277 MirPlacementGravity surface_gravity,189 MirPlacementGravity surface_gravity,
@@ -282,17 +194,6 @@
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);
283 return *this;195 return *this;
284 }196 }
285#else
286 auto set_placement(const MirRectangle* /*rect*/,
287 MirPlacementGravity /*rect_gravity*/,
288 MirPlacementGravity /*surface_gravity*/,
289 MirPlacementHints /*placement_hints*/,
290 int /*offset_dx*/,
291 int /*offset_dy*/) -> WindowSpec&
292 {
293 return *this;
294 }
295#endif
296197
297 auto set_parent(MirWindow* parent) -> WindowSpec&198 auto set_parent(MirWindow* parent) -> WindowSpec&
298 {199 {
@@ -306,6 +207,20 @@
306 return *this;207 return *this;
307 }208 }
308209
210 auto add_surface(MirRenderSurface* surface, int width, int height, int displacement_x, int displacement_y)
211 -> WindowSpec&
212 {
213#if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 27, 0)
214#pragma GCC diagnostic push
215#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
216#endif
217 mir_window_spec_add_render_surface(*this, surface, width, height, displacement_x, displacement_y);
218#if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 27, 0)
219#pragma GCC diagnostic pop
220#endif
221 return *this;
222 }
223
309 template<typename Context>224 template<typename Context>
310 void create_window(void (* callback)(MirWindow*, Context*), Context* context) const225 void create_window(void (* callback)(MirWindow*, Context*), Context* context) const
311 {226 {
312227
=== modified file 'include/miral/cursor_theme.h'
--- include/miral/cursor_theme.h 2016-09-28 10:38:36 +0000
+++ include/miral/cursor_theme.h 2017-06-20 16:14:05 +0000
@@ -25,11 +25,11 @@
2525
26namespace miral26namespace miral
27{27{
28/// Load a cursor theme28/// Load an X-cursor theme, either the supplied default, or through the --cursor-theme config option
29class CursorTheme29class CursorTheme
30{30{
31public:31public:
32 /// Specify a specific theme32 /// Specify a default theme
33 explicit CursorTheme(std::string const& theme);33 explicit CursorTheme(std::string const& theme);
34 ~CursorTheme();34 ~CursorTheme();
3535
3636
=== modified file 'include/miral/window_management_policy.h'
--- include/miral/window_management_policy.h 2017-02-14 11:49:59 +0000
+++ include/miral/window_management_policy.h 2017-06-20 16:14:05 +0000
@@ -23,8 +23,6 @@
23#include <mir/geometry/rectangles.h>23#include <mir/geometry/rectangles.h>
24#include <mir_toolkit/event.h>24#include <mir_toolkit/event.h>
2525
26#include <mir/client/detail/mir_forward_compatibility.h>
27
28namespace miral26namespace miral
29{27{
30class Window;28class Window;
3129
=== added file 'include/miral/window_management_policy_addendum2.h'
--- include/miral/window_management_policy_addendum2.h 1970-01-01 00:00:00 +0000
+++ include/miral/window_management_policy_addendum2.h 2017-06-20 16:14:05 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIRAL_WINDOW_MANAGEMENT_ADDENDUM2_H
20#define MIRAL_WINDOW_MANAGEMENT_ADDENDUM2_H
21
22#include <mir_toolkit/client_types.h>
23#include <mir/version.h>
24
25namespace miral
26{
27struct WindowInfo;
28
29/**
30 * Handle additional client requests.
31 *
32 * \note This interface is intended to be implemented by a WindowManagementPolicy
33 * implementation, we can't add these functions directly to that interface without
34 * breaking ABI (the vtab could be incompatible).
35 * When initializing the window manager this interface will be detected by
36 * dynamic_cast and registered accordingly.
37 */
38class WindowManagementPolicyAddendum2
39{
40public:
41/** @name handle requests originating from the client
42 * The policy is expected to update the model as appropriate
43 * @{ */
44 /** request from client to initiate drag and drop
45 * \note the request has already been validated against the requesting event
46 *
47 * @param window_info the window
48 */
49 virtual void handle_request_drag_and_drop(WindowInfo& window_info) = 0;
50
51 /** request from client to initiate move
52 * \note the request has already been validated against the requesting event
53 *
54 * @param window_info the window
55 * @param input_event the requesting event
56 */
57 virtual void handle_request_move(WindowInfo& window_info, MirInputEvent const* input_event) = 0;
58/** @} */
59
60 virtual ~WindowManagementPolicyAddendum2() = default;
61 WindowManagementPolicyAddendum2() = default;
62 WindowManagementPolicyAddendum2(WindowManagementPolicyAddendum2 const&) = delete;
63 WindowManagementPolicyAddendum2& operator=(WindowManagementPolicyAddendum2 const&) = delete;
64};
65#if MIRAL_VERSION >= MIR_VERSION_NUMBER(2, 0, 0)
66#error "We've presumably broken ABI - please roll this interface into WindowManagementPolicy"
67#endif
68}
69
70#endif //MIRAL_WINDOW_MANAGEMENT_ADDENDUM2_H
071
=== modified file 'include/miral/window_manager_tools.h'
--- include/miral/window_manager_tools.h 2017-03-02 14:29:04 +0000
+++ include/miral/window_manager_tools.h 2017-06-20 16:14:05 +0000
@@ -166,6 +166,18 @@
166 /// Raise window and all its children166 /// Raise window and all its children
167 void raise_tree(Window const& root);167 void raise_tree(Window const& root);
168168
169 /** Start drag and drop. The handle will be passed to the client which can
170 * then use it to talk to the whatever service is being used to support drag
171 * and drop (e.g. on Ubuntu the content hub).
172 *
173 * @param window_info source window
174 * @param handle drag handle
175 */
176 void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle);
177
178 /// End drag and drop
179 void end_drag_and_drop();
180
169 /// Apply modifications to a window181 /// Apply modifications to a window
170 void modify_window(WindowInfo& window_info, WindowSpecification const& modifications);182 void modify_window(WindowInfo& window_info, WindowSpecification const& modifications);
171183
172184
=== modified file 'include/miral/window_specification.h'
--- include/miral/window_specification.h 2017-02-14 11:49:59 +0000
+++ include/miral/window_specification.h 2017-06-20 16:14:05 +0000
@@ -21,8 +21,6 @@
2121
22#include <mir_toolkit/common.h>22#include <mir_toolkit/common.h>
2323
24#include <mir/client/detail/mir_forward_compatibility.h>
25
26#include <mir/geometry/displacement.h>24#include <mir/geometry/displacement.h>
27#include <mir/geometry/rectangles.h>25#include <mir/geometry/rectangles.h>
28#include <mir/optional_value.h>26#include <mir/optional_value.h>
2927
=== modified file 'miral-kiosk/sw_splash.cpp'
--- miral-kiosk/sw_splash.cpp 2017-02-20 15:22:29 +0000
+++ miral-kiosk/sw_splash.cpp 2017-06-20 16:14:05 +0000
@@ -18,7 +18,10 @@
1818
19#include "sw_splash.h"19#include "sw_splash.h"
2020
21#include <mir/client/display_config.h>
22#include <mir/client/surface.h>
21#include <mir/client/window.h>23#include <mir/client/window.h>
24#include <mir/client/window_spec.h>
2225
23#include <mir_toolkit/mir_buffer_stream.h>26#include <mir_toolkit/mir_buffer_stream.h>
2427
@@ -26,7 +29,6 @@
26#include <cstring>29#include <cstring>
27#include <thread>30#include <thread>
28#include <mutex>31#include <mutex>
29#include <mir/client/window_spec.h>
3032
31namespace33namespace
32{34{
@@ -60,12 +62,29 @@
60 return *pixel_formats;62 return *pixel_formats;
61}63}
6264
63auto create_window(MirConnection* connection, MirPixelFormat pixel_format) -> mir::client::Window65auto create_window(MirConnection* connection, mir::client::Surface const& surface) -> mir::client::Window
64{66{
65 return mir::client::WindowSpec::for_normal_window(connection, 42, 42, pixel_format)67 int id = 0;
68 int width = 0;
69 int height = 0;
70
71 mir::client::DisplayConfig{connection}.for_each_output([&](MirOutput const* output)
72 {
73 if (mir_output_get_connection_state(output) == mir_output_connection_state_connected &&
74 mir_output_is_enabled(output))
75 {
76 id = mir_output_get_id(output);
77
78 MirOutputMode const* mode = mir_output_get_current_mode(output);
79 width = mir_output_mode_get_width(mode);
80 height = mir_output_mode_get_height(mode);
81 }
82 });
83
84 return mir::client::WindowSpec::for_normal_window(connection, width, height)
66 .set_name("splash")85 .set_name("splash")
67 .set_buffer_usage(mir_buffer_usage_software)86 .set_fullscreen_on_output(id)
68 .set_fullscreen_on_output(0)87 .add_surface(surface, width, height, 0, 0)
69 .create_window();88 .create_window();
70}89}
7190
@@ -128,10 +147,13 @@
128 return;147 return;
129 };148 };
130149
131 auto const surface = create_window(connection, pixel_format);150
151 mir::client::Surface surface{mir_connection_create_render_surface_sync(connection, 42, 42)};
152 MirBufferStream* buffer_stream = mir_render_surface_get_buffer_stream(surface, 42, 42, pixel_format);
153
154 auto const window = create_window(connection, surface);
132155
133 MirGraphicsRegion graphics_region;156 MirGraphicsRegion graphics_region;
134 MirBufferStream* buffer_stream = mir_window_get_buffer_stream(surface);
135157
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);
137159
138160
=== modified file 'miral-shell/CMakeLists.txt'
--- miral-shell/CMakeLists.txt 2017-02-17 10:37:47 +0000
+++ miral-shell/CMakeLists.txt 2017-06-20 16:14:05 +0000
@@ -44,19 +44,18 @@
44add_executable(miral-shell44add_executable(miral-shell
45 shell_main.cpp45 shell_main.cpp
46 tiling_window_manager.cpp tiling_window_manager.h46 tiling_window_manager.cpp tiling_window_manager.h
47 titlebar_window_manager.cpp titlebar_window_manager.h47 floating_window_manager.cpp floating_window_manager.h
48 decoration_provider.cpp decoration_provider.h48 decoration_provider.cpp decoration_provider.h
49 titlebar_config.cpp titlebar_config.h49 titlebar_config.cpp titlebar_config.h
50)50)
5151
52pkg_check_modules(FREETYPE freetype2 REQUIRED)52pkg_check_modules(FREETYPE freetype2 REQUIRED)
53target_include_directories(miral-shell PUBLIC ${FREETYPE_INCLUDE_DIRS})53target_include_directories(miral-shell PRIVATE ${FREETYPE_INCLUDE_DIRS})
54target_compile_definitions(miral-shell PUBLIC -DTYPO_SUPPORTS_FREETYPE)54target_compile_definitions(miral-shell PRIVATE -DTYPO_SUPPORTS_FREETYPE)
55target_link_libraries(miral-shell ${FREETYPE_LIBRARIES})
56
57target_link_libraries(miral-shell55target_link_libraries(miral-shell
58 miral-spinner56 miral-spinner
59 miral57 miral
58 ${FREETYPE_LIBRARIES}
60)59)
6160
62install(TARGETS miral-shell61install(TARGETS miral-shell
6362
=== modified file 'miral-shell/decoration_provider.cpp'
--- miral-shell/decoration_provider.cpp 2017-03-30 14:12:50 +0000
+++ miral-shell/decoration_provider.cpp 2017-06-20 16:14:05 +0000
@@ -66,10 +66,8 @@
66 FT_Face face;66 FT_Face face;
67};67};
6868
69void paint_surface(MirWindow* surface, std::string const& title, int const intensity)69void paint_surface(MirBufferStream* buffer_stream, std::string const& title, int const intensity)
70{70{
71 MirBufferStream* buffer_stream = mir_window_get_buffer_stream(surface);
72
73 // TODO sometimes buffer_stream is nullptr - find out why (and fix).71 // TODO sometimes buffer_stream is nullptr - find out why (and fix).
74 // (Only observed when creating a lot of clients at once)72 // (Only observed when creating a lot of clients at once)
75 if (!buffer_stream)73 if (!buffer_stream)
@@ -286,11 +284,6 @@
286 {284 {
287 if (connection)285 if (connection)
288 {286 {
289#if MIR_CLIENT_API_VERSION < MIR_VERSION_NUMBER(0, 26, 2)
290 auto const Workaround_lp_1667645 =
291 WindowSpec::for_normal_window(connection, 100, 100, mir_pixel_format_xrgb_8888)
292 .set_name(wallpaper_name).create_window();
293#endif
294 wallpaper.erase(begin(wallpaper), end(wallpaper));287 wallpaper.erase(begin(wallpaper), end(wallpaper));
295 }288 }
296 connection.reset();289 connection.reset();
@@ -326,24 +319,36 @@
326 DisplayConfig const display_conf{this->connection};319 DisplayConfig const display_conf{this->connection};
327320
328 display_conf.for_each_output([this](MirOutput const* output)321 display_conf.for_each_output([this](MirOutput const* output)
329 {322 {
330 wallpaper.push_back(323 if (!mir_output_is_enabled(output))
331 WindowSpec::for_gloss(this->connection, 100, 100)324 return;
332 .set_pixel_format(mir_pixel_format_xrgb_8888)325
333 .set_buffer_usage(mir_buffer_usage_software)326 auto const mode = mir_output_get_current_mode(output);
334 .set_fullscreen_on_output(mir_output_get_id(output))327 auto const output_id = mir_output_get_id(output);
335 .set_name(wallpaper_name).create_window());328 auto const width = mir_output_mode_get_width(mode);
336329 auto const height = mir_output_mode_get_height(mode);
337 MirGraphicsRegion graphics_region;330
338 MirBufferStream* buffer_stream = mir_window_get_buffer_stream(wallpaper.back());331 Surface surface{mir_connection_create_render_surface_sync(this->connection, width, height)};
339332
340 mir_buffer_stream_get_graphics_region(buffer_stream, &graphics_region);333 auto const buffer_stream =
341334 mir_render_surface_get_buffer_stream(surface, width, height, mir_pixel_format_xrgb_8888);
342 static uint8_t const pattern[4] = { 0x00, 0x00, 0x00, 0x00 };335
343336 auto window = WindowSpec::for_gloss(this->connection, width, height)
344 render_pattern(&graphics_region, pattern);337 .set_fullscreen_on_output(output_id)
345 mir_buffer_stream_swap_buffers_sync(buffer_stream);338 .add_surface(surface, width, height, 0, 0)
346 });339 .set_name(wallpaper_name).create_window();
340
341 wallpaper.push_back(Wallpaper{surface, window, buffer_stream});
342
343 MirGraphicsRegion graphics_region;
344
345 mir_buffer_stream_get_graphics_region(buffer_stream, &graphics_region);
346
347 static uint8_t const pattern[4] = { 0x00, 0x00, 0x00, 0x00 };
348
349 render_pattern(&graphics_region, pattern);
350 mir_buffer_stream_swap_buffers_sync(buffer_stream);
351 });
347352
348 start_work();353 start_work();
349}354}
@@ -360,23 +365,54 @@
360 return weak_session.lock();365 return weak_session.lock();
361}366}
362367
368void DecorationProvider::handle_event(MirWindow* window, MirEvent const* ev, void* context_)
369{
370 auto* const context = (Data*)context_;
371
372 switch (mir_event_get_type(ev))
373 {
374 case mir_event_type_resize:
375 {
376 MirResizeEvent const* resize = mir_event_get_resize_event(ev);
377 int const new_width = mir_resize_event_get_width(resize);
378 int const new_height = mir_resize_event_get_height(resize);
379 mir_render_surface_set_size(context->surface, new_width, new_height);
380 WindowSpec::for_changes(context->connection)
381 .add_surface(context->surface, new_width, new_height, 0, 0)
382 .apply_to(window);
383 break;
384 }
385
386 default:
387 break;
388 }
389}
390
363void DecorationProvider::create_titlebar_for(miral::Window const& window)391void DecorationProvider::create_titlebar_for(miral::Window const& window)
364{392{
393 if (is_decoration(window)) return;
394
365 enqueue_work([this, window]395 enqueue_work([this, window]
366 {396 {
397 auto const width = window.size().width.as_int();
367 std::ostringstream buffer;398 std::ostringstream buffer;
368
369 buffer << std::shared_ptr<mir::scene::Surface>(window).get();399 buffer << std::shared_ptr<mir::scene::Surface>(window).get();
370400
371 auto const spec = WindowSpec::for_normal_window(401 Surface surface{mir_connection_create_render_surface_sync(this->connection, width, title_bar_height)};
372 connection, window.size().width.as_int(), title_bar_height, mir_pixel_format_xrgb_8888)
373 .set_buffer_usage(mir_buffer_usage_software)
374 .set_type(mir_window_type_gloss)
375 .set_name(buffer.str().c_str());
376402
377 std::lock_guard<decltype(mutex)> lock{mutex};403 std::lock_guard<decltype(mutex)> lock{mutex};
404
405 auto const data = &window_to_titlebar[window];
406 data->connection = connection;
407 data->surface = surface;
408 data->stream = mir_render_surface_get_buffer_stream(surface, width, title_bar_height, mir_pixel_format_xrgb_8888);
378 windows_awaiting_titlebar[buffer.str()] = window;409 windows_awaiting_titlebar[buffer.str()] = window;
379 spec.create_window(insert, &window_to_titlebar[window]);410
411 WindowSpec::for_gloss(connection, width, title_bar_height)
412 .add_surface(surface, width, title_bar_height, 0, 0)
413 .set_name(buffer.str().c_str())
414 .set_event_handler(&handle_event, data)
415 .create_window(insert, data);
380 });416 });
381}417}
382418
@@ -388,15 +424,7 @@
388424
389 auto const title = info.name();425 auto const title = info.name();
390426
391 if (auto surface = data->titlebar.load())427 enqueue_work([this, stream=data->stream, title, intensity]{ paint_surface(stream, title, intensity); });
392 {
393 enqueue_work([this, surface, title, intensity]{ paint_surface(surface, title, intensity); });
394 }
395 else
396 {
397 data->on_create = [this, title, intensity](MirWindow* surface)
398 { enqueue_work([this, surface, title, intensity]{ paint_surface(surface, title, intensity); }); };
399 }
400 }428 }
401}429}
402430
@@ -511,11 +539,8 @@
511 {539 {
512 auto const title = window_info.name();540 auto const title = window_info.name();
513541
514 if (auto surface = data->titlebar.load())542 enqueue_work([this, stream=data->stream, title, intensity=data->intensity.load()]
515 {543 { paint_surface(stream, title, intensity); });
516 enqueue_work([this, surface, title, intensity=data->intensity.load()]
517 { paint_surface(surface, title, intensity); });
518 }
519 }544 }
520}545}
521546
522547
=== modified file 'miral-shell/decoration_provider.h'
--- miral-shell/decoration_provider.h 2017-03-01 14:02:59 +0000
+++ miral-shell/decoration_provider.h 2017-06-20 16:14:05 +0000
@@ -23,6 +23,7 @@
23#include <miral/window_manager_tools.h>23#include <miral/window_manager_tools.h>
2424
25#include <mir/client/connection.h>25#include <mir/client/connection.h>
26#include <mir/client/surface.h>
26#include <mir/client/window.h>27#include <mir/client/window.h>
2728
28#include <mir/geometry/rectangle.h>29#include <mir/geometry/rectangle.h>
@@ -81,6 +82,9 @@
81private:82private:
82 struct Data83 struct Data
83 {84 {
85 MirConnection* connection{nullptr};
86 mir::client::Surface surface;
87 MirBufferStream* stream{nullptr};
84 std::atomic<MirWindow*> titlebar{nullptr};88 std::atomic<MirWindow*> titlebar{nullptr};
85 std::atomic<int> intensity{0xff};89 std::atomic<int> intensity{0xff};
86 std::function<void(MirWindow* surface)> on_create{[](MirWindow*){}};90 std::function<void(MirWindow* surface)> on_create{[](MirWindow*){}};
@@ -95,7 +99,8 @@
95 miral::WindowManagerTools tools;99 miral::WindowManagerTools tools;
96 std::mutex mutable mutex;100 std::mutex mutable mutex;
97 mir::client::Connection connection;101 mir::client::Connection connection;
98 std::vector<mir::client::Window> wallpaper;102 struct Wallpaper { mir::client::Surface surface; mir::client::Window window; MirBufferStream* stream; };
103 std::vector<Wallpaper> wallpaper;
99 std::weak_ptr<mir::scene::Session> weak_session;104 std::weak_ptr<mir::scene::Session> weak_session;
100105
101 SurfaceMap window_to_titlebar;106 SurfaceMap window_to_titlebar;
@@ -105,6 +110,7 @@
105 Data* find_titlebar_data(miral::Window const& window);110 Data* find_titlebar_data(miral::Window const& window);
106 miral::Window find_titlebar_window(miral::Window const& window) const;111 miral::Window find_titlebar_window(miral::Window const& window) const;
107 void repaint_titlebar_for(miral::WindowInfo const& window_info);112 void repaint_titlebar_for(miral::WindowInfo const& window_info);
113 static void handle_event(MirWindow* window, MirEvent const* ev, void* context_);
108};114};
109115
110116
111117
=== renamed file 'miral-shell/titlebar_window_manager.cpp' => 'miral-shell/floating_window_manager.cpp'
--- miral-shell/titlebar_window_manager.cpp 2017-03-20 10:57:31 +0000
+++ miral-shell/floating_window_manager.cpp 2017-06-20 16:14:05 +0000
@@ -16,7 +16,7 @@
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */17 */
1818
19#include "titlebar_window_manager.h"19#include "floating_window_manager.h"
20#include "decoration_provider.h"20#include "decoration_provider.h"
2121
22#include <miral/application_info.h>22#include <miral/application_info.h>
@@ -46,7 +46,7 @@
46}46}
47}47}
4848
49TitlebarWindowManagerPolicy::TitlebarWindowManagerPolicy(49FloatingWindowManagerPolicy::FloatingWindowManagerPolicy(
50 WindowManagerTools const& tools,50 WindowManagerTools const& tools,
51 SpinnerSplash const& spinner,51 SpinnerSplash const& spinner,
52 miral::InternalClientLauncher const& launcher,52 miral::InternalClientLauncher const& launcher,
@@ -64,9 +64,9 @@
64 active_workspace = key_to_workspace[KEY_F1];64 active_workspace = key_to_workspace[KEY_F1];
65}65}
6666
67TitlebarWindowManagerPolicy::~TitlebarWindowManagerPolicy() = default;67FloatingWindowManagerPolicy::~FloatingWindowManagerPolicy() = default;
6868
69bool TitlebarWindowManagerPolicy::handle_pointer_event(MirPointerEvent const* event)69bool FloatingWindowManagerPolicy::handle_pointer_event(MirPointerEvent const* event)
70{70{
71 auto const action = mir_pointer_event_action(event);71 auto const action = mir_pointer_event_action(event);
72 auto const modifiers = mir_pointer_event_modifiers(event) & modifier_mask;72 auto const modifiers = mir_pointer_event_modifiers(event) & modifier_mask;
@@ -137,7 +137,7 @@
137 return consumes_event;137 return consumes_event;
138}138}
139139
140void TitlebarWindowManagerPolicy::end_resize()140void FloatingWindowManagerPolicy::end_resize()
141{141{
142 if (!resizing && !pinching)142 if (!resizing && !pinching)
143 return;143 return;
@@ -160,7 +160,7 @@
160 pinching = false;160 pinching = false;
161}161}
162162
163bool TitlebarWindowManagerPolicy::handle_touch_event(MirTouchEvent const* event)163bool FloatingWindowManagerPolicy::handle_touch_event(MirTouchEvent const* event)
164{164{
165 auto const count = mir_touch_event_point_count(event);165 auto const count = mir_touch_event_point_count(event);
166166
@@ -281,7 +281,7 @@
281 return consumes_event;281 return consumes_event;
282}282}
283283
284void TitlebarWindowManagerPolicy::advise_new_window(WindowInfo const& window_info)284void FloatingWindowManagerPolicy::advise_new_window(WindowInfo const& window_info)
285{285{
286 CanonicalWindowManagerPolicy::advise_new_window(window_info);286 CanonicalWindowManagerPolicy::advise_new_window(window_info);
287287
@@ -306,7 +306,7 @@
306 }306 }
307}307}
308308
309void TitlebarWindowManagerPolicy::handle_window_ready(WindowInfo& window_info)309void FloatingWindowManagerPolicy::handle_window_ready(WindowInfo& window_info)
310{310{
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()))
312 decoration_provider->create_titlebar_for(window_info.window());312 decoration_provider->create_titlebar_for(window_info.window());
@@ -314,14 +314,14 @@
314 CanonicalWindowManagerPolicy::handle_window_ready(window_info);314 CanonicalWindowManagerPolicy::handle_window_ready(window_info);
315}315}
316316
317void TitlebarWindowManagerPolicy::advise_focus_lost(WindowInfo const& info)317void FloatingWindowManagerPolicy::advise_focus_lost(WindowInfo const& info)
318{318{
319 CanonicalWindowManagerPolicy::advise_focus_lost(info);319 CanonicalWindowManagerPolicy::advise_focus_lost(info);
320320
321 decoration_provider->paint_titlebar_for(info, 0x3F);321 decoration_provider->paint_titlebar_for(info, 0x3F);
322}322}
323323
324void TitlebarWindowManagerPolicy::advise_focus_gained(WindowInfo const& info)324void FloatingWindowManagerPolicy::advise_focus_gained(WindowInfo const& info)
325{325{
326 CanonicalWindowManagerPolicy::advise_focus_gained(info);326 CanonicalWindowManagerPolicy::advise_focus_gained(info);
327327
@@ -337,28 +337,28 @@
337 }337 }
338}338}
339339
340void TitlebarWindowManagerPolicy::advise_state_change(WindowInfo const& window_info, MirWindowState state)340void FloatingWindowManagerPolicy::advise_state_change(WindowInfo const& window_info, MirWindowState state)
341{341{
342 CanonicalWindowManagerPolicy::advise_state_change(window_info, state);342 CanonicalWindowManagerPolicy::advise_state_change(window_info, state);
343343
344 decoration_provider->advise_state_change(window_info, state);344 decoration_provider->advise_state_change(window_info, state);
345}345}
346346
347void TitlebarWindowManagerPolicy::advise_resize(WindowInfo const& window_info, Size const& new_size)347void FloatingWindowManagerPolicy::advise_resize(WindowInfo const& window_info, Size const& new_size)
348{348{
349 CanonicalWindowManagerPolicy::advise_resize(window_info, new_size);349 CanonicalWindowManagerPolicy::advise_resize(window_info, new_size);
350350
351 decoration_provider->resize_titlebar_for(window_info, new_size);351 decoration_provider->resize_titlebar_for(window_info, new_size);
352}352}
353353
354void TitlebarWindowManagerPolicy::advise_delete_window(WindowInfo const& window_info)354void FloatingWindowManagerPolicy::advise_delete_window(WindowInfo const& window_info)
355{355{
356 CanonicalWindowManagerPolicy::advise_delete_window(window_info);356 CanonicalWindowManagerPolicy::advise_delete_window(window_info);
357357
358 decoration_provider->destroy_titlebar_for(window_info.window());358 decoration_provider->destroy_titlebar_for(window_info.window());
359}359}
360360
361bool TitlebarWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event)361bool FloatingWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event)
362{362{
363 auto const action = mir_keyboard_event_action(event);363 auto const action = mir_keyboard_event_action(event);
364 auto const scan_code = mir_keyboard_event_scan_code(event);364 auto const scan_code = mir_keyboard_event_scan_code(event);
@@ -514,7 +514,7 @@
514 return false;514 return false;
515}515}
516516
517void TitlebarWindowManagerPolicy::toggle(MirWindowState state)517void FloatingWindowManagerPolicy::toggle(MirWindowState state)
518{518{
519 if (auto const window = tools.active_window())519 if (auto const window = tools.active_window())
520 {520 {
@@ -528,7 +528,7 @@
528 }528 }
529}529}
530530
531bool TitlebarWindowManagerPolicy::resize(Window const& window, Point cursor, Point old_cursor)531bool FloatingWindowManagerPolicy::resize(Window const& window, Point cursor, Point old_cursor)
532{532{
533 if (!window)533 if (!window)
534 return false;534 return false;
@@ -579,7 +579,7 @@
579 return true;579 return true;
580}580}
581581
582void TitlebarWindowManagerPolicy::keep_size_within_limits(582void FloatingWindowManagerPolicy::keep_size_within_limits(
583 WindowInfo const& window_info, Displacement& delta, Width& new_width, Height& new_height) const583 WindowInfo const& window_info, Displacement& delta, Width& new_width, Height& new_height) const
584{584{
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});
@@ -617,7 +617,7 @@
617 }617 }
618}618}
619619
620WindowSpecification TitlebarWindowManagerPolicy::place_new_window(620WindowSpecification FloatingWindowManagerPolicy::place_new_window(
621 ApplicationInfo const& app_info, WindowSpecification const& request_parameters)621 ApplicationInfo const& app_info, WindowSpecification const& request_parameters)
622{622{
623 auto parameters = CanonicalWindowManagerPolicy::place_new_window(app_info, request_parameters);623 auto parameters = CanonicalWindowManagerPolicy::place_new_window(app_info, request_parameters);
@@ -634,7 +634,7 @@
634 return parameters;634 return parameters;
635}635}
636636
637void TitlebarWindowManagerPolicy::advise_adding_to_workspace(637void FloatingWindowManagerPolicy::advise_adding_to_workspace(
638 std::shared_ptr<Workspace> const& workspace, std::vector<Window> const& windows)638 std::shared_ptr<Workspace> const& workspace, std::vector<Window> const& windows)
639{639{
640 if (windows.empty())640 if (windows.empty())
@@ -653,7 +653,7 @@
653 }653 }
654}654}
655655
656void TitlebarWindowManagerPolicy::switch_workspace_to(656void FloatingWindowManagerPolicy::switch_workspace_to(
657 std::shared_ptr<Workspace> const& workspace,657 std::shared_ptr<Workspace> const& workspace,
658 Window const& window)658 Window const& window)
659{659{
@@ -716,7 +716,7 @@
716 }716 }
717}717}
718718
719void TitlebarWindowManagerPolicy::apply_workspace_hidden_to(Window const& window)719void FloatingWindowManagerPolicy::apply_workspace_hidden_to(Window const& window)
720{720{
721 auto const& window_info = tools.info_for(window);721 auto const& window_info = tools.info_for(window);
722 auto& pdata = policy_data_for(window_info);722 auto& pdata = policy_data_for(window_info);
@@ -732,7 +732,7 @@
732 }732 }
733}733}
734734
735void TitlebarWindowManagerPolicy::apply_workspace_visible_to(Window const& window)735void FloatingWindowManagerPolicy::apply_workspace_visible_to(Window const& window)
736{736{
737 auto const& window_info = tools.info_for(window);737 auto const& window_info = tools.info_for(window);
738 auto& pdata = policy_data_for(window_info);738 auto& pdata = policy_data_for(window_info);
@@ -746,7 +746,7 @@
746 }746 }
747}747}
748748
749void TitlebarWindowManagerPolicy::handle_modify_window(WindowInfo& window_info, WindowSpecification const& modifications)749void FloatingWindowManagerPolicy::handle_modify_window(WindowInfo& window_info, WindowSpecification const& modifications)
750{750{
751 auto mods = modifications;751 auto mods = modifications;
752752
753753
=== renamed file 'miral-shell/titlebar_window_manager.h' => 'miral-shell/floating_window_manager.h'
--- miral-shell/titlebar_window_manager.h 2017-03-01 14:02:59 +0000
+++ miral-shell/floating_window_manager.h 2017-06-20 16:14:05 +0000
@@ -6,7 +6,7 @@
6 * as published by the Free Software Foundation.6 * as published by the Free Software Foundation.
7 *7 *
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,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty ofb
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.11 * GNU General Public License for more details.
12 *12 *
@@ -16,8 +16,8 @@
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */17 */
1818
19#ifndef MIRAL_SHELL_TITLEBAR_WINDOW_MANAGER_H19#ifndef MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
20#define MIRAL_SHELL_TITLEBAR_WINDOW_MANAGER_H20#define MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
2121
22#include <miral/canonical_window_manager.h>22#include <miral/canonical_window_manager.h>
23#include <miral/workspace_policy.h>23#include <miral/workspace_policy.h>
@@ -33,15 +33,15 @@
3333
34class DecorationProvider;34class DecorationProvider;
3535
36class TitlebarWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy, miral::WorkspacePolicy36class FloatingWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy, miral::WorkspacePolicy
37{37{
38public:38public:
39 TitlebarWindowManagerPolicy(39 FloatingWindowManagerPolicy(
40 miral::WindowManagerTools const& tools,40 miral::WindowManagerTools const& tools,
41 SpinnerSplash const& spinner,41 SpinnerSplash const& spinner,
42 miral::InternalClientLauncher const& launcher,42 miral::InternalClientLauncher const& launcher,
43 std::function<void()>& shutdown_hook);43 std::function<void()>& shutdown_hook);
44 ~TitlebarWindowManagerPolicy();44 ~FloatingWindowManagerPolicy();
4545
46 virtual miral::WindowSpecification place_new_window(46 virtual miral::WindowSpecification place_new_window(
47 miral::ApplicationInfo const& app_info, miral::WindowSpecification const& request_parameters) override;47 miral::ApplicationInfo const& app_info, miral::WindowSpecification const& request_parameters) override;
@@ -133,4 +133,4 @@
133 void apply_workspace_hidden_to(miral::Window const& window);133 void apply_workspace_hidden_to(miral::Window const& window);
134};134};
135135
136#endif //MIRAL_SHELL_TITLEBAR_WINDOW_MANAGER_H136#endif //MIRAL_SHELL_FLOATING_WINDOW_MANAGER_H
137137
=== modified file 'miral-shell/miral-app.sh'
--- miral-shell/miral-app.sh 2017-03-24 14:54:48 +0000
+++ miral-shell/miral-app.sh 2017-06-20 16:14:05 +0000
@@ -46,6 +46,6 @@
46while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done46while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done
4747
48unset QT_QPA_PLATFORMTHEME48unset QT_QPA_PLATFORMTHEME
49MIR_SOCKET=${socket} GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher}49MIR_SOCKET=${socket} XDG_SESSION_TYPE=mir GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher}
50killall ${bindir}${miral_server}50killall ${bindir}${miral_server}
5151
5252
=== modified file 'miral-shell/miral-desktop.sh'
--- miral-shell/miral-desktop.sh 2017-03-24 14:54:48 +0000
+++ miral-shell/miral-desktop.sh 2017-06-20 16:14:05 +0000
@@ -40,6 +40,6 @@
40while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done40while [ ! -e "${socket}" ]; do echo "waiting for ${socket}"; sleep 1 ;done
4141
42unset QT_QPA_PLATFORMTHEME42unset QT_QPA_PLATFORMTHEME
43MIR_SOCKET=${socket} GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher}43MIR_SOCKET=${socket} XDG_SESSION_TYPE=mir GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir dbus-run-session -- ${launcher}
44sudo killall ${bindir}${miral_server}44sudo killall ${bindir}${miral_server}
4545
4646
=== modified file 'miral-shell/miral-run.sh'
--- miral-shell/miral-run.sh 2017-03-24 14:54:48 +0000
+++ miral-shell/miral-run.sh 2017-06-20 16:14:05 +0000
@@ -3,4 +3,4 @@
3then extras='--app-id com.canonical.miral.Terminal'3then extras='--app-id com.canonical.miral.Terminal'
4fi4fi
5unset QT_QPA_PLATFORMTHEME5unset QT_QPA_PLATFORMTHEME
6MIR_SOCKET=${XDG_RUNTIME_DIR}/miral_socket GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir "$@" ${extras}&6MIR_SOCKET=${XDG_RUNTIME_DIR}/miral_socket XDG_SESSION_TYPE=mir GDK_BACKEND=mir QT_QPA_PLATFORM=ubuntumirclient SDL_VIDEODRIVER=mir "$@" ${extras}&
77
=== modified file 'miral-shell/miral-screencast.sh'
--- miral-shell/miral-screencast.sh 2016-12-09 11:08:07 +0000
+++ miral-shell/miral-screencast.sh 2017-06-20 16:14:05 +0000
@@ -2,7 +2,7 @@
2width=19202width=1920
3height=10803height=1080
4output=screencast.mp44output=screencast.mp4
5socket=${XDG_RUNTIME_DIR}/mir_socket5socket=${XDG_RUNTIME_DIR}/miral_socket
6if [ -v MIR_SERVER ]; then socket=${MIR_SERVER}; fi6if [ -v MIR_SERVER ]; then socket=${MIR_SERVER}; fi
77
8while [ $# -gt 0 ]8while [ $# -gt 0 ]
99
=== modified file 'miral-shell/miral-xrun.sh'
--- miral-shell/miral-xrun.sh 2017-03-24 15:47:07 +0000
+++ miral-shell/miral-xrun.sh 2017-06-20 16:14:05 +0000
@@ -21,6 +21,7 @@
21 exit 021 exit 0
22 elif [ "$1" == "-force" ];22 elif [ "$1" == "-force" ];
23 then23 then
24 export XDG_SESSION_TYPE=x11
24 export GDK_BACKEND=x1125 export GDK_BACKEND=x11
25 export QT_QPA_PLATFORM=xcb26 export QT_QPA_PLATFORM=xcb
26 export SDL_VIDEODRIVER=x1127 export SDL_VIDEODRIVER=x11
2728
=== modified file 'miral-shell/shell_main.cpp'
--- miral-shell/shell_main.cpp 2017-03-06 09:45:37 +0000
+++ miral-shell/shell_main.cpp 2017-06-20 16:14:05 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "tiling_window_manager.h"19#include "tiling_window_manager.h"
20#include "titlebar_window_manager.h"20#include "floating_window_manager.h"
21#include "titlebar_config.h"21#include "titlebar_config.h"
22#include "spinner/splash.h"22#include "spinner/splash.h"
2323
@@ -44,7 +44,7 @@
44 ActiveOutputsMonitor outputs_monitor;44 ActiveOutputsMonitor outputs_monitor;
45 WindowManagerOptions window_managers45 WindowManagerOptions window_managers
46 {46 {
47 add_window_manager_policy<TitlebarWindowManagerPolicy>("titlebar", spinner, launcher, shutdown_hook),47 add_window_manager_policy<FloatingWindowManagerPolicy>("floating", spinner, launcher, shutdown_hook),
48 add_window_manager_policy<TilingWindowManagerPolicy>("tiling", spinner, launcher, outputs_monitor),48 add_window_manager_policy<TilingWindowManagerPolicy>("tiling", spinner, launcher, outputs_monitor),
49 };49 };
5050
@@ -83,7 +83,7 @@
83 {83 {
84 CommandLineOption{[&](std::string const& ) { },84 CommandLineOption{[&](std::string const& ) { },
85 "desktop_file_hint", "Ignored for Unity8 compatibility", "miral-shell.desktop"},85 "desktop_file_hint", "Ignored for Unity8 compatibility", "miral-shell.desktop"},
86 CursorTheme{"default"},86 CursorTheme{"DMZ-White"},
87 window_managers,87 window_managers,
88 display_configuration_options,88 display_configuration_options,
89 launcher,89 launcher,
9090
=== modified file 'miral-shell/spinner/CMakeLists.txt'
--- miral-shell/spinner/CMakeLists.txt 2016-05-20 09:20:19 +0000
+++ miral-shell/spinner/CMakeLists.txt 2017-06-20 16:14:05 +0000
@@ -59,6 +59,7 @@
59)59)
6060
61target_link_libraries(miral-spinner61target_link_libraries(miral-spinner
62 mirclientcpp
62 EGL63 EGL
63 ${GLIB_LDFLAGS}64 ${GLIB_LDFLAGS}
64 ${GLESv2_LIBRARIES}65 ${GLESv2_LIBRARIES}
6566
=== modified file 'miral-shell/spinner/eglapp.cpp'
--- miral-shell/spinner/eglapp.cpp 2017-01-19 15:13:51 +0000
+++ miral-shell/spinner/eglapp.cpp 2017-06-20 16:14:05 +0000
@@ -16,61 +16,16 @@
1616
17#include "eglapp.h"17#include "eglapp.h"
1818
19#include <mir/client/display_config.h>
20
19#include "miregl.h"21#include "miregl.h"
2022
21#include <mir_toolkit/version.h>
22
2323
24float mir_eglapp_background_opacity = 1.0f;24float mir_eglapp_background_opacity = 1.0f;
2525
2626
27namespace27namespace
28{28{
29template<typename ActiveOutputHandler>
30void for_each_active_output(
31 MirConnection* const connection, ActiveOutputHandler const& handler)
32{
33 /* eglapps are interested in the screen size, so
34 use mir_connection_create_display_config */
35#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
36 MirDisplayConfiguration* display_config =
37 mir_connection_create_display_config(connection);
38
39 for (MirDisplayOutput* output = display_config->outputs;
40 output != display_config->outputs + display_config->num_outputs;
41 ++output)
42 {
43 if (output->used &&
44 output->connected &&
45 output->num_modes &&
46 output->current_mode < output->num_modes)
47 {
48 handler(output);
49 }
50 }
51
52 mir_display_config_destroy(display_config);
53#else
54 MirDisplayConfig* display_config =
55 mir_connection_create_display_configuration(connection);
56
57 int const n = mir_display_config_get_num_outputs(display_config);
58
59 for (int i = 0; i != n; ++i)
60 {
61 MirOutput const *const output = mir_display_config_get_output(display_config, i);
62 if (mir_output_is_enabled(output) &&
63 mir_output_get_connection_state(output) == mir_output_connection_state_connected &&
64 mir_output_get_num_modes(output) &&
65 mir_output_get_current_mode_index(output) < (size_t)mir_output_get_num_modes(output))
66 {
67 handler(output);
68 }
69 }
70 mir_display_config_release(display_config);
71#endif
72}
73
74MirPixelFormat select_pixel_format(MirConnection* connection)29MirPixelFormat select_pixel_format(MirConnection* connection)
75{30{
76 unsigned int format[mir_pixel_formats];31 unsigned int format[mir_pixel_formats];
@@ -93,69 +48,33 @@
9348
94std::vector<std::shared_ptr<MirEglSurface>> mir_eglapp_init(MirConnection* const connection)49std::vector<std::shared_ptr<MirEglSurface>> mir_eglapp_init(MirConnection* const connection)
95{50{
96 MirWindowParameters surfaceparm =51 char const * const name = "eglappsurface";
97 {
98 "eglappsurface",
99 0, 0,
100 mir_pixel_format_xbgr_8888,
101 mir_buffer_usage_hardware,
102 mir_display_output_id_invalid
103 };
104
105 EGLint swapinterval = 1;
10652
107 if (!mir_connection_is_valid(connection))53 if (!mir_connection_is_valid(connection))
108 throw std::runtime_error("Can't get connection");54 throw std::runtime_error("Can't get connection");
10955
110 auto const pixel_format = select_pixel_format(connection);56 auto const pixel_format = select_pixel_format(connection);
111 surfaceparm.pixel_format = pixel_format;
11257
113 auto const mir_egl_app = make_mir_eglapp(connection, pixel_format);58 auto const mir_egl_app = make_mir_eglapp(connection, pixel_format);
11459
115 std::vector<std::shared_ptr<MirEglSurface>> result;60 std::vector<std::shared_ptr<MirEglSurface>> result;
11661
117 // If a size has been specified just do that62 mir::client::DisplayConfig{connection}.for_each_output([&](MirOutput const* output)
118 if (surfaceparm.width && surfaceparm.height)63 {
119 {64 if (mir_output_get_connection_state(output) == mir_output_connection_state_connected &&
120 result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, surfaceparm, swapinterval));65 mir_output_is_enabled(output))
121 return result;66 {
122 }67 auto const mode = mir_output_get_current_mode(output);
12368 auto const output_id = mir_output_get_id(output);
124 // If an output has been specified just do that69
125 if (surfaceparm.output_id != mir_display_output_id_invalid)70 printf("Active output [%u] at (%d, %d) is %dx%d\n",
126 {71 output_id,
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),
128 return result;73 mir_output_mode_get_width(mode), mir_output_mode_get_height(mode));
129 }74
13075 result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, name, output));
131 // but normally, we're fullscreen on every active output76 }
132#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)77 });
133 for_each_active_output(connection, [&](MirDisplayOutput const* output)
134 {
135 auto const& mode = output->modes[output->current_mode];
136
137 printf("Active output [%u] at (%d, %d) is %dx%d\n",
138 output->output_id,
139 output->position_x, output->position_y,
140 mode.horizontal_resolution, mode.vertical_resolution);
141
142 surfaceparm.output_id = output->output_id;
143 result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, surfaceparm, swapinterval));
144 });
145#else
146 for_each_active_output(connection, [&](MirOutput const* output)
147 {
148 auto const& mode = mir_output_get_current_mode(output);
149
150 printf("Active output [%u] at (%d, %d) is %dx%d\n",
151 mir_output_get_id(output),
152 mir_output_get_position_x(output), mir_output_get_position_y(output),
153 mir_output_mode_get_width(mode), mir_output_mode_get_height(mode));
154
155 surfaceparm.output_id = mir_output_get_id(output);
156 result.push_back(std::make_shared<MirEglSurface>(mir_egl_app, surfaceparm, swapinterval));
157 });
158#endif
15978
160 if (result.empty())79 if (result.empty())
161 throw std::runtime_error("No active outputs found.");80 throw std::runtime_error("No active outputs found.");
16281
=== modified file 'miral-shell/spinner/eglspinner.cpp'
--- miral-shell/spinner/eglspinner.cpp 2016-04-17 00:20:00 +0000
+++ miral-shell/spinner/eglspinner.cpp 2017-06-20 16:14:05 +0000
@@ -34,6 +34,8 @@
34#include <atomic>34#include <atomic>
35#include <mutex>35#include <mutex>
3636
37#include <mir_toolkit/mir_client_library.h>
38
37#include "spinner_glow.h"39#include "spinner_glow.h"
38#include "spinner_logo.h"40#include "spinner_logo.h"
3941
4042
=== modified file 'miral-shell/spinner/miregl.cpp'
--- miral-shell/spinner/miregl.cpp 2017-02-14 11:49:59 +0000
+++ miral-shell/spinner/miregl.cpp 2017-06-20 16:14:05 +0000
@@ -15,21 +15,22 @@
15 */15 */
1616
17#include "miregl.h"17#include "miregl.h"
18#include <miral/window_specification.h>
18#include <mir/client/window_spec.h>19#include <mir/client/window_spec.h>
19#include <mir_toolkit/version.h>20#include <mir_toolkit/mir_client_library.h>
2021
21#include <cstring>22#include <cstring>
2223
23#include <GLES2/gl2.h>24#include <GLES2/gl2.h>
24#include <miral/window_specification.h>25
25#include <mir/client/window_spec.h>26using namespace mir::client;
2627
27class MirEglApp28class MirEglApp
28{29{
29public:30public:
30 MirEglApp(MirConnection* const connection, MirPixelFormat pixel_format);31 MirEglApp(MirConnection* const connection, MirPixelFormat pixel_format);
3132
32 EGLSurface create_surface(MirWindow* window);33 EGLSurface create_surface(MirRenderSurface* surface);
3334
34 void make_current(EGLSurface eglsurface) const;35 void make_current(EGLSurface eglsurface) const;
3536
@@ -60,47 +61,37 @@
60 return std::make_shared<MirEglApp>(connection, pixel_format);61 return std::make_shared<MirEglApp>(connection, pixel_format);
61}62}
6263
63namespace64MirEglSurface::MirEglSurface(
64{65 std::shared_ptr<MirEglApp> const& mir_egl_app,
65MirWindow* create_window(MirConnection* const connection, MirWindowParameters const& parameters)66 char const* name,
66{67 MirOutput const* output)
6768:
68 auto spec = mir::client::WindowSpec::for_normal_window(69 mir_egl_app{mir_egl_app}
69 connection, parameters.width, parameters.height, parameters.pixel_format)70{
70 .set_name(parameters.name)71 auto const mode = mir_output_get_current_mode(output);
71 .set_buffer_usage(parameters.buffer_usage);72 auto const output_id = mir_output_get_id(output);
7273 auto const width = mir_output_mode_get_width(mode);
7374 auto const height = mir_output_mode_get_height(mode);
74 if (!parameters.width && !parameters.height)75
75 spec.set_fullscreen_on_output(parameters.output_id);76 surface = Surface{mir_connection_create_render_surface_sync(mir_egl_app->connection, width, height)};
7677
77 auto const window = mir_create_window_sync(spec);78 eglsurface = mir_egl_app->create_surface(surface);
79
80 window = WindowSpec::for_normal_window(mir_egl_app->connection, width, height)
81 .add_surface(surface, width, height, 0, 0)
82 .set_name(name)
83 .set_fullscreen_on_output(output_id)
84 .create_window();
7885
79 if (!mir_window_is_valid(window))86 if (!mir_window_is_valid(window))
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));
8188
82 if (parameters.output_id != mir_display_output_id_invalid)89 mir_egl_app->set_swap_interval(eglsurface, -1);
83 mir_window_set_state(window, mir_window_state_fullscreen);
84
85 return window;
86}
87}
88
89MirEglSurface::MirEglSurface(
90 std::shared_ptr<MirEglApp> const& mir_egl_app, MirWindowParameters const& parm, int swapinterval) :
91 mir_egl_app{mir_egl_app},
92 window{create_window(mir_egl_app->connection, parm)},
93 eglsurface{mir_egl_app->create_surface(window)},
94 width_{0},
95 height_{0}
96{
97 mir_egl_app->set_swap_interval(eglsurface, swapinterval);
98}90}
9991
100MirEglSurface::~MirEglSurface()92MirEglSurface::~MirEglSurface()
101{93{
102 mir_egl_app->destroy_surface(eglsurface);94 mir_egl_app->destroy_surface(eglsurface);
103 mir_window_release_sync(window);
104}95}
10596
106void MirEglSurface::egl_make_current()97void MirEglSurface::egl_make_current()
@@ -139,7 +130,7 @@
139 EGL_NONE130 EGL_NONE
140 };131 };
141132
142 egldisplay = eglGetDisplay((EGLNativeDisplayType) mir_connection_get_egl_native_display(connection));133 egldisplay = eglGetDisplay((EGLNativeDisplayType)(connection));
143 if (egldisplay == EGL_NO_DISPLAY)134 if (egldisplay == EGL_NO_DISPLAY)
144 throw std::runtime_error("Can't eglGetDisplay");135 throw std::runtime_error("Can't eglGetDisplay");
145136
@@ -184,12 +175,12 @@
184 make_current(dummy_surface);175 make_current(dummy_surface);
185}176}
186177
187EGLSurface MirEglApp::create_surface(MirWindow* window)178EGLSurface MirEglApp::create_surface(MirRenderSurface* surface)
188{179{
189 auto const eglsurface = eglCreateWindowSurface(180 auto const eglsurface = eglCreateWindowSurface(
190 egldisplay,181 egldisplay,
191 eglconfig,182 eglconfig,
192 (EGLNativeWindowType) mir_buffer_stream_get_egl_native_window(mir_window_get_buffer_stream(window)), NULL);183 (EGLNativeWindowType)surface, NULL);
193184
194 if (eglsurface == EGL_NO_SURFACE)185 if (eglsurface == EGL_NO_SURFACE)
195 throw std::runtime_error("eglCreateWindowSurface failed");186 throw std::runtime_error("eglCreateWindowSurface failed");
196187
=== modified file 'miral-shell/spinner/miregl.h'
--- miral-shell/spinner/miregl.h 2017-03-06 09:49:23 +0000
+++ miral-shell/spinner/miregl.h 2017-06-20 16:14:05 +0000
@@ -17,9 +17,8 @@
17#ifndef UNITYSYSTEMCOMPOSITOR_MIREGL_H17#ifndef UNITYSYSTEMCOMPOSITOR_MIREGL_H
18#define UNITYSYSTEMCOMPOSITOR_MIREGL_H18#define UNITYSYSTEMCOMPOSITOR_MIREGL_H
1919
20#include <mir/client/detail/mir_forward_compatibility.h>20#include <mir/client/surface.h>
21#include <mir_toolkit/client_types.h>21#include <mir/client/window.h>
22#include "mir_toolkit/mir_client_library.h"
2322
24#include <EGL/egl.h>23#include <EGL/egl.h>
2524
@@ -37,8 +36,8 @@
37public:36public:
38 MirEglSurface(37 MirEglSurface(
39 std::shared_ptr<MirEglApp> const& mir_egl_app,38 std::shared_ptr<MirEglApp> const& mir_egl_app,
40 MirWindowParameters const& parm,39 char const* name,
41 int swapinterval);40 MirOutput const* output);
4241
43 ~MirEglSurface();42 ~MirEglSurface();
4443
@@ -58,8 +57,9 @@
58 unsigned int height() const;57 unsigned int height() const;
5958
60 std::shared_ptr<MirEglApp> const mir_egl_app;59 std::shared_ptr<MirEglApp> const mir_egl_app;
61 MirWindow* const window;60 mir::client::Surface surface;
62 EGLSurface const eglsurface;61 mir::client::Window window;
62 EGLSurface eglsurface;
63 int width_;63 int width_;
64 int height_;64 int height_;
65};65};
6666
=== modified file 'miral/CMakeLists.txt'
--- miral/CMakeLists.txt 2017-03-20 12:28:06 +0000
+++ miral/CMakeLists.txt 2017-06-20 16:14:05 +0000
@@ -1,4 +1,4 @@
1pkg_check_modules(MIRSERVER mirserver>=0.20 REQUIRED)1pkg_check_modules(MIRSERVER mirserver>=0.26 REQUIRED)
22
3if(${CMAKE_COMPILER_IS_GNUCXX})3if(${CMAKE_COMPILER_IS_GNUCXX})
4 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")4 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
@@ -11,8 +11,9 @@
1111
12set(MIRAL_ABI 2)12set(MIRAL_ABI 2)
13set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)13set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
14set(miral_include ${PROJECT_SOURCE_DIR}/include)
1415
15include_directories(include SYSTEM ${MIRSERVER_INCLUDE_DIRS})16add_library(mirclientcpp INTERFACE)
1617
17add_library(miral-internal STATIC18add_library(miral-internal STATIC
18 basic_window_manager.cpp basic_window_manager.h window_manager_tools_implementation.h19 basic_window_manager.cpp basic_window_manager.h window_manager_tools_implementation.h
@@ -28,39 +29,53 @@
28set_source_files_properties(xcursor.c PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)29set_source_files_properties(xcursor.c PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
2930
30add_library(miral SHARED31add_library(miral SHARED
31 active_outputs.cpp ${CMAKE_SOURCE_DIR}/include/miral/active_outputs.h32 active_outputs.cpp ${miral_include}/miral/active_outputs.h
32 add_init_callback.cpp ${CMAKE_SOURCE_DIR}/include/miral/add_init_callback.h33 add_init_callback.cpp ${miral_include}/miral/add_init_callback.h
33 application.cpp ${CMAKE_SOURCE_DIR}/include/miral/application.h34 application.cpp ${miral_include}/miral/application.h
34 application_authorizer.cpp ${CMAKE_SOURCE_DIR}/include/miral/application_authorizer.h35 application_authorizer.cpp ${miral_include}/miral/application_authorizer.h
35 application_info.cpp ${CMAKE_SOURCE_DIR}/include/miral/application_info.h36 application_info.cpp ${miral_include}/miral/application_info.h
36 canonical_window_manager.cpp ${CMAKE_SOURCE_DIR}/include/miral/canonical_window_manager.h37 canonical_window_manager.cpp ${miral_include}/miral/canonical_window_manager.h
37 command_line_option.cpp ${CMAKE_SOURCE_DIR}/include/miral/command_line_option.h38 command_line_option.cpp ${miral_include}/miral/command_line_option.h
38 cursor_theme.cpp ${CMAKE_SOURCE_DIR}/include/miral/cursor_theme.h39 cursor_theme.cpp ${miral_include}/miral/cursor_theme.h
39 debug_extension.cpp ${CMAKE_SOURCE_DIR}/include/miral/debug_extension.h40 debug_extension.cpp ${miral_include}/miral/debug_extension.h
40 keymap.cpp ${CMAKE_SOURCE_DIR}/include/miral/keymap.h41 keymap.cpp ${miral_include}/miral/keymap.h
41 runner.cpp ${CMAKE_SOURCE_DIR}/include/miral/runner.h42 runner.cpp ${miral_include}/miral/runner.h
42 display_configuration_option.cpp ${CMAKE_SOURCE_DIR}/include/miral/display_configuration_option.h43 display_configuration_option.cpp ${miral_include}/miral/display_configuration_option.h
43 output.cpp ${CMAKE_SOURCE_DIR}/include/miral/output.h44 output.cpp ${miral_include}/miral/output.h
44 append_event_filter.cpp ${CMAKE_SOURCE_DIR}/include/miral/append_event_filter.h45 append_event_filter.cpp ${miral_include}/miral/append_event_filter.h
45 window.cpp ${CMAKE_SOURCE_DIR}/include/miral/window.h46 window.cpp ${miral_include}/miral/window.h
46 window_info.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_info.h47 window_info.cpp ${miral_include}/miral/window_info.h
47 window_management_options.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_management_options.h48 window_management_options.cpp ${miral_include}/miral/window_management_options.h
48 window_specification.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_specification.h49 window_specification.cpp ${miral_include}/miral/window_specification.h
49 internal_client.cpp ${CMAKE_SOURCE_DIR}/include/miral/internal_client.h50 internal_client.cpp ${miral_include}/miral/internal_client.h
50 set_command_line_handler.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_command_line_handler.h51 set_command_line_handler.cpp ${miral_include}/miral/set_command_line_handler.h
51 set_terminator.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_terminator.h52 set_terminator.cpp ${miral_include}/miral/set_terminator.h
52 set_window_management_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_window_management_policy.h53 set_window_management_policy.cpp ${miral_include}/miral/set_window_management_policy.h
53 workspace_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/workspace_policy.h54 workspace_policy.cpp ${miral_include}/miral/workspace_policy.h
54 window_management_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_management_policy.h55 window_management_policy.cpp ${miral_include}/miral/window_management_policy.h
55 window_manager_tools.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_manager_tools.h56 window_manager_tools.cpp ${miral_include}/miral/window_manager_tools.h
56 ${CMAKE_SOURCE_DIR}/include/mir/client/blob.h57 ${miral_include}/miral/window_management_policy_addendum2.h
57 ${CMAKE_SOURCE_DIR}/include/mir/client/cookie.h58 ${miral_include}/mir/client/blob.h
58 ${CMAKE_SOURCE_DIR}/include/mir/client/window_spec.h59 ${miral_include}/mir/client/cookie.h
59 ${CMAKE_SOURCE_DIR}/include/mir/client/window_id.h60 ${miral_include}/mir/client/window_spec.h
60 ${CMAKE_SOURCE_DIR}/include/mir/client/connection.h61 ${miral_include}/mir/client/window_id.h
61 ${CMAKE_SOURCE_DIR}/include/mir/client/display_config.h62 ${miral_include}/mir/client/connection.h
62 ${CMAKE_SOURCE_DIR}/include/mir/client/window.h63 ${miral_include}/mir/client/display_config.h
63 ${CMAKE_SOURCE_DIR}/include/mir/client/detail/mir_forward_compatibility.h64 ${miral_include}/mir/client/window.h
65)
66
67target_include_directories(mirclientcpp
68 INTERFACE "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS}
69)
70
71target_include_directories(miral-internal
72 PRIVATE "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS}
73 PRIVATE ${MIRSERVER_INCLUDE_DIRS}
74)
75
76target_include_directories(miral
77 PUBLIC "${miral_include}" ${MIRCLIENT_INCLUDE_DIRS}
78 PRIVATE ${MIRSERVER_INCLUDE_DIRS}
64)79)
6580
66target_link_libraries(miral81target_link_libraries(miral
@@ -99,26 +114,9 @@
99 @ONLY114 @ONLY
100)115)
101116
102if (MIRSERVER_VERSION VERSION_LESS 0.24)117configure_file(
103 set(MIR_POINTER_CONFINEMENT 0)118 ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
104else()119 ${miral_include}/miral/version.h
105 set(MIR_POINTER_CONFINEMENT 1)
106endif()
107
108if (MIRSERVER_VERSION VERSION_LESS 0.22)
109 set(MIR_DISPLAY_CONFIG_GET_MUTABLE 0)
110else()
111 set(MIR_DISPLAY_CONFIG_GET_MUTABLE 1)
112endif()
113
114configure_file(
115 ${CMAKE_CURRENT_SOURCE_DIR}/mir_features.h.in
116 ${PROJECT_SOURCE_DIR}/include/mir/client/detail/mir_features.h
117)
118
119configure_file(
120 ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
121 ${PROJECT_SOURCE_DIR}/include/miral/version.h
122)120)
123121
124install(TARGETS miral LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")122install(TARGETS miral LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
125123
=== modified file 'miral/active_outputs.cpp'
--- miral/active_outputs.cpp 2017-01-13 18:17:01 +0000
+++ miral/active_outputs.cpp 2017-06-20 16:14:05 +0000
@@ -23,12 +23,8 @@
23#include <mir/graphics/display_configuration.h>23#include <mir/graphics/display_configuration.h>
24#include <mir/server.h>24#include <mir/server.h>
2525
26#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0)
27#include <mir/graphics/display_configuration_report.h>
28#else
29#include <mir/graphics/display_configuration_observer.h>26#include <mir/graphics/display_configuration_observer.h>
30#include <mir/observer_registrar.h>27#include <mir/observer_registrar.h>
31#endif
3228
33#include <algorithm>29#include <algorithm>
34#include <mutex>30#include <mutex>
@@ -40,17 +36,6 @@
40void miral::ActiveOutputsListener::advise_output_update(Output const& /*updated*/, Output const& /*original*/) {}36void miral::ActiveOutputsListener::advise_output_update(Output const& /*updated*/, Output const& /*original*/) {}
41void miral::ActiveOutputsListener::advise_output_delete(Output const& /*output*/) {}37void miral::ActiveOutputsListener::advise_output_delete(Output const& /*output*/) {}
4238
43#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0)
44struct miral::ActiveOutputsMonitor::Self : mir::graphics::DisplayConfigurationReport
45{
46 virtual void initial_configuration(mir::graphics::DisplayConfiguration const& configuration) override;
47 virtual void new_configuration(mir::graphics::DisplayConfiguration const& configuration) override;
48
49 std::mutex mutex;
50 std::vector<ActiveOutputsListener*> listeners;
51 std::vector<Output> outputs;
52};
53#else
54struct miral::ActiveOutputsMonitor::Self : mir::graphics::DisplayConfigurationObserver39struct miral::ActiveOutputsMonitor::Self : mir::graphics::DisplayConfigurationObserver
55{40{
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;
@@ -79,7 +64,6 @@
79 std::vector<ActiveOutputsListener*> listeners;64 std::vector<ActiveOutputsListener*> listeners;
80 std::vector<Output> outputs;65 std::vector<Output> outputs;
81};66};
82#endif
8367
84miral::ActiveOutputsMonitor::ActiveOutputsMonitor() :68miral::ActiveOutputsMonitor::ActiveOutputsMonitor() :
85 self{std::make_shared<Self>()}69 self{std::make_shared<Self>()}
@@ -109,12 +93,8 @@
109{93{
110 std::lock_guard<decltype(self->mutex)> lock{self->mutex};94 std::lock_guard<decltype(self->mutex)> lock{self->mutex};
11195
112#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0)
113 server.override_the_display_configuration_report([this]{ return self; });
114#else
115 server.add_pre_init_callback([this, &server]96 server.add_pre_init_callback([this, &server]
116 { server.the_display_configuration_observer_registrar()->register_interest(self); });97 { server.the_display_configuration_observer_registrar()->register_interest(self); });
117#endif
118}98}
11999
120void miral::ActiveOutputsMonitor::process_outputs(100void miral::ActiveOutputsMonitor::process_outputs(
@@ -125,65 +105,11 @@
125}105}
126106
127107
128#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0)
129void miral::ActiveOutputsMonitor::Self::initial_configuration(mir::graphics::DisplayConfiguration const& configuration)
130{
131 new_configuration(configuration);
132}
133#else
134void miral::ActiveOutputsMonitor::Self::initial_configuration(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& configuration)108void miral::ActiveOutputsMonitor::Self::initial_configuration(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& configuration)
135{109{
136 configuration_applied(configuration);110 configuration_applied(configuration);
137}111}
138#endif112
139
140#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 26, 0)
141void miral::ActiveOutputsMonitor::Self::new_configuration(mir::graphics::DisplayConfiguration const& configuration)
142{
143 std::lock_guard<decltype(mutex)> lock{mutex};
144
145 decltype(outputs) current_outputs;
146
147 for (auto const l : listeners)
148 l->advise_output_begin();
149
150 configuration.for_each_output([&current_outputs, this](mir::graphics::DisplayConfigurationOutput const& output)
151 {
152 Output o{output};
153
154 if (!o.connected() || !o.valid()) return;
155
156 auto op = find_if(begin(outputs), end(outputs), [&](Output const& oo) { return oo.is_same_output(o); });
157
158 if (op == end(outputs))
159 {
160 for (auto const l : listeners)
161 l->advise_output_create(o);
162 }
163 else if (!equivalent_display_area(o, *op))
164 {
165 for (auto const l : listeners)
166 l->advise_output_update(o, *op);
167 }
168
169 current_outputs.push_back(o);
170 });
171
172 for (auto const& o : outputs)
173 {
174 auto op = find_if(begin(current_outputs), end(current_outputs), [&](Output const& oo)
175 { return oo.is_same_output(o); });
176
177 if (op == end(current_outputs))
178 for (auto const l : listeners)
179 l->advise_output_delete(o);
180 }
181
182 current_outputs.swap(outputs);
183 for (auto const l : listeners)
184 l->advise_output_end();
185}
186#else
187void miral::ActiveOutputsMonitor::Self::configuration_applied(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& config)113void miral::ActiveOutputsMonitor::Self::configuration_applied(std::shared_ptr<mir::graphics::DisplayConfiguration const> const& config)
188{114{
189 std::lock_guard<decltype(mutex)> lock{mutex};115 std::lock_guard<decltype(mutex)> lock{mutex};
@@ -233,4 +159,3 @@
233 for (auto const l : listeners)159 for (auto const l : listeners)
234 l->advise_output_end();160 l->advise_output_end();
235}161}
236#endif
237162
=== modified file 'miral/basic_window_manager.cpp'
--- miral/basic_window_manager.cpp 2017-03-21 12:30:42 +0000
+++ miral/basic_window_manager.cpp 2017-06-20 16:14:05 +0000
@@ -19,6 +19,7 @@
19#include "basic_window_manager.h"19#include "basic_window_manager.h"
20#include "miral/window_manager_tools.h"20#include "miral/window_manager_tools.h"
21#include "miral/workspace_policy.h"21#include "miral/workspace_policy.h"
22#include "miral/window_management_policy_addendum2.h"
2223
23#include <mir/scene/session.h>24#include <mir/scene/session.h>
24#include <mir/scene/surface.h>25#include <mir/scene/surface.h>
@@ -70,7 +71,6 @@
7071
71namespace72namespace
72{73{
73
74auto find_workspace_policy(std::unique_ptr<miral::WindowManagementPolicy> const& policy) -> miral::WorkspacePolicy*74auto find_workspace_policy(std::unique_ptr<miral::WindowManagementPolicy> const& policy) -> miral::WorkspacePolicy*
75{75{
76 miral::WorkspacePolicy* result = dynamic_cast<miral::WorkspacePolicy*>(policy.get());76 miral::WorkspacePolicy* result = dynamic_cast<miral::WorkspacePolicy*>(policy.get());
@@ -82,6 +82,23 @@
8282
83 return &null_workspace_policy;83 return &null_workspace_policy;
84}84}
85
86auto find_policy_addendum2(std::unique_ptr<miral::WindowManagementPolicy> const& policy) -> miral::WindowManagementPolicyAddendum2*
87{
88 miral::WindowManagementPolicyAddendum2* result = dynamic_cast<miral::WindowManagementPolicyAddendum2*>(policy.get());
89
90 if (result)
91 return result;
92
93 struct NullWindowManagementPolicyAddendum2 : miral::WindowManagementPolicyAddendum2
94 {
95 void handle_request_drag_and_drop(miral::WindowInfo&) override {}
96 void handle_request_move(miral::WindowInfo&, MirInputEvent const*) override {}
97 };
98 static NullWindowManagementPolicyAddendum2 null_workspace_policy;
99
100 return &null_workspace_policy;
101}
85}102}
86103
87104
@@ -94,10 +111,18 @@
94 display_layout(display_layout),111 display_layout(display_layout),
95 persistent_surface_store{persistent_surface_store},112 persistent_surface_store{persistent_surface_store},
96 policy(build(WindowManagerTools{this})),113 policy(build(WindowManagerTools{this})),
97 workspace_policy{find_workspace_policy(policy)}114 workspace_policy{find_workspace_policy(policy)},
115 policy2{find_policy_addendum2(policy)}
98{116{
99}117}
100118
119miral::BasicWindowManager::~BasicWindowManager()
120{
121#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
122 if (last_input_event)
123 mir_event_unref(last_input_event);
124#endif
125}
101void miral::BasicWindowManager::add_session(std::shared_ptr<scene::Session> const& session)126void miral::BasicWindowManager::add_session(std::shared_ptr<scene::Session> const& session)
102{127{
103 Locker lock{this};128 Locker lock{this};
@@ -156,14 +181,12 @@
156 session,181 session,
157 scene_surface));182 scene_surface));
158183
159#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
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())
161 {185 {
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()};
163 auto const mir_surface = std::shared_ptr<scene::Surface>(window);187 auto const mir_surface = std::shared_ptr<scene::Surface>(window);
164 mir_surface->placed_relative(relative_placement);188 mir_surface->placed_relative(relative_placement);
165 }189 }
166#endif
167190
168 return surface_id;191 return surface_id;
169}192}
@@ -362,10 +385,24 @@
362#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)385#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
363void miral::BasicWindowManager::handle_request_drag_and_drop(386void miral::BasicWindowManager::handle_request_drag_and_drop(
364 std::shared_ptr<mir::scene::Session> const& /*session*/,387 std::shared_ptr<mir::scene::Session> const& /*session*/,
365 std::shared_ptr<mir::scene::Surface> const& /*surface*/,388 std::shared_ptr<mir::scene::Surface> const& surface,
366 uint64_t /*timestamp*/)389 uint64_t timestamp)
367{390{
368 // TODO391 Locker lock{this};
392 if (timestamp >= last_input_event_timestamp)
393 policy2->handle_request_drag_and_drop(info_for(surface));
394}
395
396void miral::BasicWindowManager::handle_request_move(
397 std::shared_ptr<mir::scene::Session> const& /*session*/,
398 std::shared_ptr<mir::scene::Surface> const& surface,
399 uint64_t timestamp)
400{
401 std::lock_guard<decltype(mutex)> lock(mutex);
402 if (timestamp >= last_input_event_timestamp && last_input_event)
403 {
404 policy2->handle_request_move(info_for(surface), mir_event_get_input_event(last_input_event));
405 }
369}406}
370#endif407#endif
371408
@@ -741,6 +778,24 @@
741 focus_controller->raise({begin(windows), end(windows)});778 focus_controller->raise({begin(windows), end(windows)});
742}779}
743780
781void miral::BasicWindowManager::start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle)
782{
783#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
784 std::shared_ptr<scene::Surface>(window_info.window())->start_drag_and_drop(handle);
785 focus_controller->set_drag_and_drop_handle(handle);
786#else
787 (void)window_info;
788 (void)handle;
789#endif
790}
791
792void miral::BasicWindowManager::end_drag_and_drop()
793{
794#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
795 focus_controller->clear_drag_and_drop_handle();
796#endif
797}
798
744void miral::BasicWindowManager::move_tree(miral::WindowInfo& root, mir::geometry::Displacement movement)799void miral::BasicWindowManager::move_tree(miral::WindowInfo& root, mir::geometry::Displacement movement)
745{800{
746 if (movement == mir::geometry::Displacement{})801 if (movement == mir::geometry::Displacement{})
@@ -900,11 +955,9 @@
900 if (new_pos.is_set())955 if (new_pos.is_set())
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);
902957
903#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
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()};
905 auto const mir_surface = std::shared_ptr<scene::Surface>(window);959 auto const mir_surface = std::shared_ptr<scene::Surface>(window);
906 mir_surface->placed_relative(relative_placement);960 mir_surface->placed_relative(relative_placement);
907#endif
908 }961 }
909 }962 }
910963
@@ -913,25 +966,18 @@
913 set_state(window_info, modifications.state().value());966 set_state(window_info, modifications.state().value());
914 }967 }
915968
916#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
917 if (modifications.confine_pointer().is_set())969 if (modifications.confine_pointer().is_set())
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());
919#endif
920}971}
921972
922auto miral::BasicWindowManager::info_for_window_id(std::string const& id) const -> WindowInfo&973auto miral::BasicWindowManager::info_for_window_id(std::string const& id) const -> WindowInfo&
923{974{
924#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
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});
926976
927 if (!surface)977 if (!surface)
928 BOOST_THROW_EXCEPTION(std::runtime_error{"No surface matching ID"});978 BOOST_THROW_EXCEPTION(std::runtime_error{"No surface matching ID"});
929979
930 return info_for(surface);980 return info_for(surface);
931#else
932 (void)id;
933 BOOST_THROW_EXCEPTION(std::runtime_error{"No surface matching ID"});
934#endif
935}981}
936982
937auto miral::BasicWindowManager::id_for_window(Window const& window) const -> std::string983auto miral::BasicWindowManager::id_for_window(Window const& window) const -> std::string
@@ -939,11 +985,7 @@
939 if (!window)985 if (!window)
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"});
941987
942#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
943 return persistent_surface_store->id_for_surface(window).serialize_to_string();988 return persistent_surface_store->id_for_surface(window).serialize_to_string();
944#else
945 BOOST_THROW_EXCEPTION(std::runtime_error{"Persistent IDs unavailable with this Mir server version"});
946#endif
947}989}
948990
949void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size)991void miral::BasicWindowManager::place_and_size(WindowInfo& root, Point const& new_pos, Size const& new_size)
@@ -1163,25 +1205,22 @@
11631205
1164void miral::BasicWindowManager::update_event_timestamp(MirKeyboardEvent const* kev)1206void miral::BasicWindowManager::update_event_timestamp(MirKeyboardEvent const* kev)
1165{1207{
1166 auto iev = mir_keyboard_event_input_event(kev);1208 update_event_timestamp(mir_keyboard_event_input_event(kev));
1167 last_input_event_timestamp = mir_input_event_get_event_time(iev);
1168}1209}
11691210
1170void miral::BasicWindowManager::update_event_timestamp(MirPointerEvent const* pev)1211void miral::BasicWindowManager::update_event_timestamp(MirPointerEvent const* pev)
1171{1212{
1172 auto iev = mir_pointer_event_input_event(pev);
1173 auto pointer_action = mir_pointer_event_action(pev);1213 auto pointer_action = mir_pointer_event_action(pev);
11741214
1175 if (pointer_action == mir_pointer_action_button_up ||1215 if (pointer_action == mir_pointer_action_button_up ||
1176 pointer_action == mir_pointer_action_button_down)1216 pointer_action == mir_pointer_action_button_down)
1177 {1217 {
1178 last_input_event_timestamp = mir_input_event_get_event_time(iev);1218 update_event_timestamp(mir_pointer_event_input_event(pev));
1179 }1219 }
1180}1220}
11811221
1182void miral::BasicWindowManager::update_event_timestamp(MirTouchEvent const* tev)1222void miral::BasicWindowManager::update_event_timestamp(MirTouchEvent const* tev)
1183{1223{
1184 auto iev = mir_touch_event_input_event(tev);
1185 auto touch_count = mir_touch_event_point_count(tev);1224 auto touch_count = mir_touch_event_point_count(tev);
1186 for (unsigned i = 0; i < touch_count; i++)1225 for (unsigned i = 0; i < touch_count; i++)
1187 {1226 {
@@ -1189,12 +1228,22 @@
1189 if (touch_action == mir_touch_action_up ||1228 if (touch_action == mir_touch_action_up ||
1190 touch_action == mir_touch_action_down)1229 touch_action == mir_touch_action_down)
1191 {1230 {
1192 last_input_event_timestamp = mir_input_event_get_event_time(iev);1231 update_event_timestamp(mir_touch_event_input_event(tev));
1193 break;1232 break;
1194 }1233 }
1195 }1234 }
1196}1235}
11971236
1237void miral::BasicWindowManager::update_event_timestamp(MirInputEvent const* iev)
1238{
1239 last_input_event_timestamp = mir_input_event_get_event_time(iev);
1240#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
1241 if (last_input_event)
1242 mir_event_unref(last_input_event);
1243 last_input_event = mir_event_ref(mir_input_event_get_event(iev));
1244#endif
1245}
1246
1198void miral::BasicWindowManager::invoke_under_lock(std::function<void()> const& callback)1247void miral::BasicWindowManager::invoke_under_lock(std::function<void()> const& callback)
1199{1248{
1200 Locker lock{this};1249 Locker lock{this};
12011250
=== modified file 'miral/basic_window_manager.h'
--- miral/basic_window_manager.h 2017-03-21 12:30:42 +0000
+++ miral/basic_window_manager.h 2017-06-20 16:14:05 +0000
@@ -46,6 +46,7 @@
46namespace miral46namespace miral
47{47{
48class WorkspacePolicy;48class WorkspacePolicy;
49class WindowManagementPolicyAddendum2;
49using mir::shell::SurfaceSet;50using mir::shell::SurfaceSet;
50using WindowManagementPolicyBuilder =51using WindowManagementPolicyBuilder =
51 std::function<std::unique_ptr<miral::WindowManagementPolicy>(miral::WindowManagerTools const& tools)>;52 std::function<std::unique_ptr<miral::WindowManagementPolicy>(miral::WindowManagerTools const& tools)>;
@@ -61,6 +62,7 @@
61 std::shared_ptr<mir::shell::DisplayLayout> const& display_layout,62 std::shared_ptr<mir::shell::DisplayLayout> const& display_layout,
62 std::shared_ptr<mir::shell::PersistentSurfaceStore> const& persistent_surface_store,63 std::shared_ptr<mir::shell::PersistentSurfaceStore> const& persistent_surface_store,
63 WindowManagementPolicyBuilder const& build);64 WindowManagementPolicyBuilder const& build);
65 ~BasicWindowManager();
6466
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;
6668
@@ -101,6 +103,11 @@
101 std::shared_ptr<mir::scene::Session> const& session,103 std::shared_ptr<mir::scene::Session> const& session,
102 std::shared_ptr<mir::scene::Surface> const& surface,104 std::shared_ptr<mir::scene::Surface> const& surface,
103 uint64_t timestamp) override;105 uint64_t timestamp) override;
106
107 void handle_request_move(
108 std::shared_ptr<mir::scene::Session> const& session,
109 std::shared_ptr<mir::scene::Surface> const& surface,
110 uint64_t timestamp) override;
104#endif111#endif
105112
106 int set_surface_attribute(113 int set_surface_attribute(
@@ -161,6 +168,8 @@
161 auto active_display() -> mir::geometry::Rectangle const override;168 auto active_display() -> mir::geometry::Rectangle const override;
162169
163 void raise_tree(Window const& root) override;170 void raise_tree(Window const& root) override;
171 void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) override;
172 void end_drag_and_drop() override;
164173
165 void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override;174 void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override;
166175
@@ -190,6 +199,7 @@
190199
191 std::unique_ptr<WindowManagementPolicy> const policy;200 std::unique_ptr<WindowManagementPolicy> const policy;
192 WorkspacePolicy* const workspace_policy;201 WorkspacePolicy* const workspace_policy;
202 WindowManagementPolicyAddendum2* const policy2;
193203
194 std::mutex mutex;204 std::mutex mutex;
195 SessionInfoMap app_info;205 SessionInfoMap app_info;
@@ -197,6 +207,9 @@
197 mir::geometry::Rectangles displays;207 mir::geometry::Rectangles displays;
198 mir::geometry::Point cursor;208 mir::geometry::Point cursor;
199 uint64_t last_input_event_timestamp{0};209 uint64_t last_input_event_timestamp{0};
210#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 27, 0)
211 MirEvent const* last_input_event{nullptr};
212#endif
200 miral::MRUWindowList mru_active_windows;213 miral::MRUWindowList mru_active_windows;
201 using FullscreenSurfaces = std::set<Window>;214 using FullscreenSurfaces = std::set<Window>;
202 FullscreenSurfaces fullscreen_surfaces;215 FullscreenSurfaces fullscreen_surfaces;
@@ -213,6 +226,7 @@
213 void update_event_timestamp(MirKeyboardEvent const* kev);226 void update_event_timestamp(MirKeyboardEvent const* kev);
214 void update_event_timestamp(MirPointerEvent const* pev);227 void update_event_timestamp(MirPointerEvent const* pev);
215 void update_event_timestamp(MirTouchEvent const* tev);228 void update_event_timestamp(MirTouchEvent const* tev);
229 void update_event_timestamp(MirInputEvent const* iev);
216230
217 auto can_activate_window_for_session(miral::Application const& session) -> bool;231 auto can_activate_window_for_session(miral::Application const& session) -> bool;
218 auto can_activate_window_for_session_in_workspace(232 auto can_activate_window_for_session_in_workspace(
219233
=== modified file 'miral/both_versions.h'
--- miral/both_versions.h 2017-02-15 12:17:12 +0000
+++ miral/both_versions.h 2017-06-20 16:14:05 +0000
@@ -27,12 +27,7 @@
27#define MIRAL_FAKE_NEW_SYMBOL(old_sym, new_sym)\27#define MIRAL_FAKE_NEW_SYMBOL(old_sym, new_sym)\
28 extern "C" __attribute__((alias(#old_sym))) void new_sym();28 extern "C" __attribute__((alias(#old_sym))) void new_sym();
2929
30#if (MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0))30#define MIRAL_BOTH_VERSIONS(old_sym, new_sym)\
31 #define MIRAL_BOTH_VERSIONS(old_sym, new_sym)\31MIRAL_FAKE_OLD_SYMBOL(old_sym, new_sym)
32 MIRAL_FAKE_OLD_SYMBOL(old_sym, new_sym)
33#else
34 #define MIRAL_BOTH_VERSIONS(old_sym, new_sym)\
35 MIRAL_FAKE_NEW_SYMBOL(old_sym, new_sym)
36#endif
3732
38#endif //MIRAL_BOTH_VERSIONS_H33#endif //MIRAL_BOTH_VERSIONS_H
3934
=== modified file 'miral/cursor_theme.cpp'
--- miral/cursor_theme.cpp 2016-09-28 10:57:41 +0000
+++ miral/cursor_theme.cpp 2017-06-20 16:14:05 +0000
@@ -19,6 +19,7 @@
19#include "miral/cursor_theme.h"19#include "miral/cursor_theme.h"
20#include "xcursor_loader.h"20#include "xcursor_loader.h"
2121
22#include <mir/options/option.h>
22#include <mir/server.h>23#include <mir/server.h>
23#include <mir_toolkit/cursors.h>24#include <mir_toolkit/cursors.h>
2425
@@ -43,8 +44,14 @@
4344
44void miral::CursorTheme::operator()(mir::Server& server) const45void miral::CursorTheme::operator()(mir::Server& server) const
45{46{
47 static char const* const option = "cursor-theme";
48
49 server.add_configuration_option(option, "Cursor theme (e.g. \"DMZ-Black\")", theme);
50
46 server.override_the_cursor_images([&]51 server.override_the_cursor_images([&]
47 {52 {
53 auto const theme = server.get_options()->get<std::string const>(option);
54
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)};
4956
50 if (has_default_cursor(*xcursor_loader))57 if (has_default_cursor(*xcursor_loader))
5158
=== modified file 'miral/keymap.cpp'
--- miral/keymap.cpp 2017-01-17 16:42:33 +0000
+++ miral/keymap.cpp 2017-06-20 16:14:05 +0000
@@ -25,13 +25,8 @@
25#include <mir/server.h>25#include <mir/server.h>
26#include <mir/version.h>26#include <mir/version.h>
2727
28#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0)
29#include <mir/input/keymap.h>28#include <mir/input/keymap.h>
30#include <mir/input/mir_keyboard_config.h>29#include <mir/input/mir_keyboard_config.h>
31#elif MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 1)
32#include <mir/input/keymap.h>
33#include <mir/input/keyboard_configuration.h>
34#endif
3530
36#define MIR_LOG_COMPONENT "miral::Keymap"31#define MIR_LOG_COMPONENT "miral::Keymap"
37#include <mir/log.h>32#include <mir/log.h>
@@ -107,7 +102,6 @@
107 apply_keymap(keyboard);102 apply_keymap(keyboard);
108 }103 }
109104
110#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 1)
111 void apply_keymap(std::shared_ptr<mir::input::Device> const& keyboard)105 void apply_keymap(std::shared_ptr<mir::input::Device> const& keyboard)
112 {106 {
113 auto const keyboard_config = keyboard->keyboard_configuration();107 auto const keyboard_config = keyboard->keyboard_configuration();
@@ -115,11 +109,7 @@
115109
116 if (keyboard_config.is_set())110 if (keyboard_config.is_set())
117 {111 {
118#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0)
119 keymap = keyboard_config.value().device_keymap();112 keymap = keyboard_config.value().device_keymap();
120#else
121 keymap = keyboard_config.value().device_keymap;
122#endif
123 }113 }
124114
125 keymap.layout = layout;115 keymap.layout = layout;
@@ -127,12 +117,6 @@
127 keymap.options = options;117 keymap.options = options;
128 keyboard->apply_keyboard_configuration(std::move(keymap));118 keyboard->apply_keyboard_configuration(std::move(keymap));
129 }119 }
130#else
131 void apply_keymap(std::shared_ptr<mir::input::Device> const&)
132 {
133 mir::log_warning("Cannot apply keymap - not supported for Mir versions prior to 0.24.1");
134 }
135#endif
136120
137 void device_removed(std::shared_ptr<mir::input::Device> const& device) override121 void device_removed(std::shared_ptr<mir::input::Device> const& device) override
138 {122 {
139123
=== removed file 'miral/mir_features.h.in'
--- miral/mir_features.h.in 2017-02-17 15:06:53 +0000
+++ miral/mir_features.h.in 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MIRAL_MIR_FEATURES_H
18#define MIRAL_MIR_FEATURES_H
19
20// ============================================================
21// ==> miral/detail/mir_features.h is generated by cmake. <==
22// ==> DO NOT EDIT! <==
23// ==> (edit mir_features.h.in instead) <==
24// ============================================================
25
26#define MIRAL_MIR_DEFINES_POINTER_CONFINEMENT (@MIR_POINTER_CONFINEMENT@)
27#define MIR_DEFINES_DISPLAY_CONFIG_GET_MUTABLE_OUTPUT (@MIR_DISPLAY_CONFIG_GET_MUTABLE@)
28
29#endif // MIRAL_MIR_FEATURES_H
300
=== modified file 'miral/mru_window_list.cpp'
--- miral/mru_window_list.cpp 2017-02-17 15:23:49 +0000
+++ miral/mru_window_list.cpp 2017-06-20 16:14:05 +0000
@@ -18,7 +18,6 @@
1818
19#include "mru_window_list.h"19#include "mru_window_list.h"
2020
21#include <mir/client/detail/mir_forward_compatibility.h>
22#include <mir/scene/surface.h>21#include <mir/scene/surface.h>
2322
24#include <algorithm>23#include <algorithm>
2524
=== modified file 'miral/runner.cpp'
--- miral/runner.cpp 2017-03-02 13:47:28 +0000
+++ miral/runner.cpp 2017-06-20 16:14:05 +0000
@@ -30,10 +30,6 @@
30#include <mutex>30#include <mutex>
31#include <thread>31#include <thread>
3232
33#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 24, 0)
34#include <csignal>
35#endif
36
37namespace33namespace
38{34{
39inline auto filename(std::string path) -> std::string35inline auto filename(std::string path) -> std::string
@@ -198,9 +194,7 @@
198 for (auto& option : options)194 for (auto& option : options)
199 option(*server);195 option(*server);
200196
201#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
202 server->add_stop_callback(stop_callback);197 server->add_stop_callback(stop_callback);
203#endif
204198
205 // Provide the command line and run the server199 // Provide the command line and run the server
206 server->set_command_line(argc, argv);200 server->set_command_line(argc, argv);
@@ -220,10 +214,6 @@
220 auto const main_loop = server->the_main_loop();214 auto const main_loop = server->the_main_loop();
221 main_loop->enqueue(this, start_callback);215 main_loop->enqueue(this, start_callback);
222216
223#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 24, 0)
224 main_loop->register_signal_handler({SIGINT, SIGTERM}, [this](int) {stop_callback();});
225#endif
226
227 server->run();217 server->run();
228 }218 }
229219
@@ -282,11 +272,6 @@
282272
283 if (auto const server = self->weak_server.lock())273 if (auto const server = self->weak_server.lock())
284 {274 {
285#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 24, 0)
286 // Before Mir-0.24 we can't intercept all stop() invocations,
287 // but we can deal with the ones we pass on
288 self->stop_callback();
289#endif
290 server->stop();275 server->stop();
291 }276 }
292}277}
293278
=== modified file 'miral/set_window_management_policy.cpp'
--- miral/set_window_management_policy.cpp 2017-03-22 10:03:25 +0000
+++ miral/set_window_management_policy.cpp 2017-06-20 16:14:05 +0000
@@ -64,11 +64,7 @@
64 {64 {
65 auto const display_layout = server.the_shell_display_layout();65 auto const display_layout = server.the_shell_display_layout();
6666
67#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
68 auto const persistent_surface_store = server.the_persistent_surface_store();67 auto const persistent_surface_store = server.the_persistent_surface_store();
69#else
70 std::shared_ptr<mir::shell::PersistentSurfaceStore> const persistent_surface_store;
71#endif
7268
73 if (server.get_options()->is_set(trace_option))69 if (server.get_options()->is_set(trace_option))
74 {70 {
7571
=== modified file 'miral/symbols.map'
--- miral/symbols.map 2017-03-15 17:44:36 +0000
+++ miral/symbols.map 2017-06-20 16:14:05 +0000
@@ -401,3 +401,24 @@
401 vtable?for?miral::SetWindowManagementPolicy;401 vtable?for?miral::SetWindowManagementPolicy;
402 };402 };
403} MIRAL_1.3;403} MIRAL_1.3;
404
405MIRAL_1.4.0 {
406global:
407 extern "C++" {
408 miral::WindowManagementPolicyAddendum2::?WindowManagementPolicyAddendum2*;
409 miral::WindowManagementPolicyAddendum2::WindowManagementPolicyAddendum2*;
410 miral::WindowManagementPolicyAddendum2::operator*;
411 miral::WindowManagerTools::end_drag_and_drop*;
412 miral::WindowManagerTools::start_drag_and_drop*;
413 miral::toolkit::Window::Window*;
414 non-virtual?thunk?to?miral::WindowManagementPolicyAddendum2::?WindowManagementPolicyAddendum2*;
415 typeinfo?for?miral::WindowManagementPolicyAddendum2;
416 typeinfo?for?miral::toolkit::Window;
417 typeinfo?for?miral::toolkit::WindowId;
418 typeinfo?for?miral::toolkit::WindowSpec;
419 vtable?for?miral::WindowManagementPolicyAddendum2;
420 vtable?for?miral::toolkit::Window;
421 vtable?for?miral::toolkit::WindowId;
422 vtable?for?miral::toolkit::WindowSpec;
423 };
424} MIRAL_1.3.1;
404425
=== modified file 'miral/window_management_options.cpp'
--- miral/window_management_options.cpp 2016-09-21 14:43:46 +0000
+++ miral/window_management_options.cpp 2017-06-20 16:14:05 +0000
@@ -56,12 +56,8 @@
56 auto const selection = options->get<std::string>(wm_option);56 auto const selection = options->get<std::string>(wm_option);
5757
58 auto const display_layout = server.the_shell_display_layout();58 auto const display_layout = server.the_shell_display_layout();
59
60#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
61 auto const persistent_surface_store = server.the_persistent_surface_store();59 auto const persistent_surface_store = server.the_persistent_surface_store();
62#else60
63 std::shared_ptr<mir::shell::PersistentSurfaceStore> const persistent_surface_store;
64#endif
65 for (auto const& option : policies)61 for (auto const& option : policies)
66 {62 {
67 if (selection == option.name)63 if (selection == option.name)
6864
=== modified file 'miral/window_management_trace.cpp'
--- miral/window_management_trace.cpp 2017-03-03 10:06:02 +0000
+++ miral/window_management_trace.cpp 2017-06-20 16:14:05 +0000
@@ -547,6 +547,24 @@
547}547}
548MIRAL_TRACE_EXCEPTION548MIRAL_TRACE_EXCEPTION
549549
550void miral::WindowManagementTrace::start_drag_and_drop(miral::WindowInfo& window_info, std::vector<uint8_t> const& handle)
551try {
552 log_input();
553 mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str());
554 trace_count++;
555 wrapped.start_drag_and_drop(window_info, handle);
556}
557MIRAL_TRACE_EXCEPTION
558
559void miral::WindowManagementTrace::end_drag_and_drop()
560try {
561 log_input();
562 mir::log_info("%s window_info=%s", __func__);
563 trace_count++;
564 wrapped.end_drag_and_drop();
565}
566MIRAL_TRACE_EXCEPTION
567
550void miral::WindowManagementTrace::modify_window(568void miral::WindowManagementTrace::modify_window(
551 miral::WindowInfo& window_info, miral::WindowSpecification const& modifications)569 miral::WindowInfo& window_info, miral::WindowSpecification const& modifications)
552try {570try {
553571
=== modified file 'miral/window_management_trace.h'
--- miral/window_management_trace.h 2017-03-02 14:29:04 +0000
+++ miral/window_management_trace.h 2017-06-20 16:14:05 +0000
@@ -69,6 +69,8 @@
69 virtual void focus_prev_within_application() override;69 virtual void focus_prev_within_application() override;
7070
71 virtual void raise_tree(Window const& root) override;71 virtual void raise_tree(Window const& root) override;
72 virtual void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) override;
73 virtual void end_drag_and_drop() override;
7274
73 virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override;75 virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) override;
7476
7577
=== modified file 'miral/window_manager_tools.cpp'
--- miral/window_manager_tools.cpp 2017-03-02 14:29:04 +0000
+++ miral/window_manager_tools.cpp 2017-06-20 16:14:05 +0000
@@ -83,6 +83,12 @@
83void miral::WindowManagerTools::raise_tree(Window const& root)83void miral::WindowManagerTools::raise_tree(Window const& root)
84{ tools->raise_tree(root); }84{ tools->raise_tree(root); }
8585
86void miral::WindowManagerTools::start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle)
87{ tools->start_drag_and_drop(window_info, handle); }
88
89void miral::WindowManagerTools::end_drag_and_drop()
90{ tools->end_drag_and_drop(); }
91
86void miral::WindowManagerTools::modify_window(WindowInfo& window_info, WindowSpecification const& modifications)92void miral::WindowManagerTools::modify_window(WindowInfo& window_info, WindowSpecification const& modifications)
87{ tools->modify_window(window_info,modifications); }93{ tools->modify_window(window_info,modifications); }
8894
8995
=== modified file 'miral/window_manager_tools_implementation.h'
--- miral/window_manager_tools_implementation.h 2017-03-02 14:29:04 +0000
+++ miral/window_manager_tools_implementation.h 2017-06-20 16:14:05 +0000
@@ -26,6 +26,7 @@
2626
27#include <functional>27#include <functional>
28#include <memory>28#include <memory>
29#include <vector>
2930
30namespace mir { namespace scene { class Surface; } }31namespace mir { namespace scene { class Surface; } }
3132
@@ -66,6 +67,8 @@
66 virtual auto window_at(mir::geometry::Point cursor) const -> Window = 0;67 virtual auto window_at(mir::geometry::Point cursor) const -> Window = 0;
67 virtual auto active_display() -> mir::geometry::Rectangle const = 0;68 virtual auto active_display() -> mir::geometry::Rectangle const = 0;
68 virtual void raise_tree(Window const& root) = 0;69 virtual void raise_tree(Window const& root) = 0;
70 virtual void start_drag_and_drop(WindowInfo& window_info, std::vector<uint8_t> const& handle) = 0;
71 virtual void end_drag_and_drop() = 0;
69 virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0;72 virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0;
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;
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;
7275
=== modified file 'miral/window_specification.cpp'
--- miral/window_specification.cpp 2017-01-13 18:17:01 +0000
+++ miral/window_specification.cpp 2017-06-20 16:14:05 +0000
@@ -74,11 +74,9 @@
74 state(spec.state),74 state(spec.state),
75 preferred_orientation(spec.preferred_orientation),75 preferred_orientation(spec.preferred_orientation),
76 aux_rect(spec.aux_rect),76 aux_rect(spec.aux_rect),
77#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
78 placement_hints(spec.placement_hints),77 placement_hints(spec.placement_hints),
79 window_placement_gravity(spec.surface_placement_gravity),78 window_placement_gravity(spec.surface_placement_gravity),
80 aux_rect_placement_gravity(spec.aux_rect_placement_gravity),79 aux_rect_placement_gravity(spec.aux_rect_placement_gravity),
81#endif
82 min_width(spec.min_width),80 min_width(spec.min_width),
83 min_height(spec.min_height),81 min_height(spec.min_height),
84 max_width(spec.max_width),82 max_width(spec.max_width),
@@ -92,24 +90,10 @@
92 input_shape(spec.input_shape),90 input_shape(spec.input_shape),
93 input_mode(),91 input_mode(),
94 shell_chrome(spec.shell_chrome)92 shell_chrome(spec.shell_chrome)
95#if MIRAL_MIR_DEFINES_POINTER_CONFINEMENT
96 ,confine_pointer(spec.confine_pointer)93 ,confine_pointer(spec.confine_pointer)
97#endif
98{94{
99#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
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())
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()};
102#endif
103
104#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 25, 0)
105 // mir_connection_create_spec_for_tooltip() didn't set an edge_attachment preference
106 if (aux_rect.is_set() && !spec.edge_attachment.is_set())
107 {
108 window_placement_gravity = mir_placement_gravity_northwest;
109 aux_rect_placement_gravity = mir_placement_gravity_northeast;
110 placement_hints = mir_placement_hints_flip_any;
111 }
112#endif
11397
114 if (spec.edge_attachment.is_set() && !placement_hints.is_set())98 if (spec.edge_attachment.is_set() && !placement_hints.is_set())
115 {99 {
@@ -166,12 +150,6 @@
166}150}
167151
168template<typename Source>152template<typename Source>
169void copy_if_set(mir::optional_value<mir::graphics::BufferUsage>& dest, mir::optional_value<Source> const& source)
170{
171 if (source.is_set()) dest = static_cast<mir::graphics::BufferUsage>(source.value());
172}
173
174template<typename Source>
175void copy_if_set(mir::graphics::BufferUsage& dest, mir::optional_value<Source> const& source)153void copy_if_set(mir::graphics::BufferUsage& dest, mir::optional_value<Source> const& source)
176{154{
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());
@@ -179,14 +157,6 @@
179157
180template<typename Source>158template<typename Source>
181void copy_if_set(159void copy_if_set(
182 mir::optional_value<mir::graphics::DisplayConfigurationOutputId>& dest,
183 mir::optional_value<Source> const& source)
184{
185 if (source.is_set()) dest = static_cast<mir::graphics::DisplayConfigurationOutputId>(source.value());
186}
187
188template<typename Source>
189void copy_if_set(
190 mir::graphics::DisplayConfigurationOutputId& dest,160 mir::graphics::DisplayConfigurationOutputId& dest,
191 mir::optional_value<Source> const& source)161 mir::optional_value<Source> const& source)
192{162{
@@ -229,11 +199,9 @@
229 state(params.state),199 state(params.state),
230 preferred_orientation(params.preferred_orientation),200 preferred_orientation(params.preferred_orientation),
231 aux_rect(params.aux_rect),201 aux_rect(params.aux_rect),
232#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
233 placement_hints(params.placement_hints),202 placement_hints(params.placement_hints),
234 window_placement_gravity(params.surface_placement_gravity),203 window_placement_gravity(params.surface_placement_gravity),
235 aux_rect_placement_gravity(params.aux_rect_placement_gravity),204 aux_rect_placement_gravity(params.aux_rect_placement_gravity),
236#endif
237 min_width(params.min_width),205 min_width(params.min_width),
238 min_height(params.min_height),206 min_height(params.min_height),
239 max_width(params.max_width),207 max_width(params.max_width),
@@ -242,33 +210,15 @@
242 height_inc(params.height_inc),210 height_inc(params.height_inc),
243 min_aspect(),211 min_aspect(),
244 max_aspect(),212 max_aspect(),
245#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 22, 0)
246 streams(params.streams),213 streams(params.streams),
247#else
248 streams(),
249#endif
250 parent(params.parent),214 parent(params.parent),
251 input_shape(params.input_shape),215 input_shape(params.input_shape),
252 input_mode(static_cast<InputReceptionMode>(params.input_mode)),216 input_mode(static_cast<InputReceptionMode>(params.input_mode)),
253 shell_chrome(params.shell_chrome)217 shell_chrome(params.shell_chrome)
254#if MIRAL_MIR_DEFINES_POINTER_CONFINEMENT
255 ,confine_pointer(params.confine_pointer)218 ,confine_pointer(params.confine_pointer)
256#endif
257{219{
258#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
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())
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()};
261#endif
262
263#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 25, 0)
264 // mir_connection_create_spec_for_tooltip() didn't set an edge_attachment preference
265 if (aux_rect.is_set() && !params.edge_attachment.is_set())
266 {
267 window_placement_gravity = mir_placement_gravity_northwest;
268 aux_rect_placement_gravity = mir_placement_gravity_northeast;
269 placement_hints = mir_placement_hints_flip_any;
270 }
271#endif
272222
273 if (params.edge_attachment.is_set() && !placement_hints.is_set())223 if (params.edge_attachment.is_set() && !placement_hints.is_set())
274 {224 {
@@ -325,18 +275,12 @@
325 copy_if_set(params.height_inc, height_inc);275 copy_if_set(params.height_inc, height_inc);
326 copy_if_set(params.min_aspect, min_aspect);276 copy_if_set(params.min_aspect, min_aspect);
327 copy_if_set(params.max_aspect, max_aspect);277 copy_if_set(params.max_aspect, max_aspect);
328#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 22, 0)
329 copy_if_set(params.streams, streams);278 copy_if_set(params.streams, streams);
330#endif
331 copy_if_set(params.parent, parent);279 copy_if_set(params.parent, parent);
332 copy_if_set(params.input_shape, input_shape);280 copy_if_set(params.input_shape, input_shape);
333 copy_if_set(params.input_mode, input_mode);281 copy_if_set(params.input_mode, input_mode);
334 copy_if_set(params.shell_chrome, shell_chrome);282 copy_if_set(params.shell_chrome, shell_chrome);
335#if MIRAL_MIR_DEFINES_POINTER_CONFINEMENT
336 copy_if_set(params.confine_pointer, confine_pointer);283 copy_if_set(params.confine_pointer, confine_pointer);
337#endif
338
339#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
340 copy_if_set(params.placement_hints, placement_hints);284 copy_if_set(params.placement_hints, placement_hints);
341 copy_if_set(params.surface_placement_gravity, window_placement_gravity);285 copy_if_set(params.surface_placement_gravity, window_placement_gravity);
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);
@@ -347,7 +291,6 @@
347 params.aux_rect_placement_offset_x = offset.dx.as_int();291 params.aux_rect_placement_offset_x = offset.dx.as_int();
348 params.aux_rect_placement_offset_y = offset.dy.as_int();292 params.aux_rect_placement_offset_y = offset.dy.as_int();
349 }293 }
350#endif
351}294}
352295
353miral::WindowSpecification::WindowSpecification() :296miral::WindowSpecification::WindowSpecification() :
354297
=== modified file 'scripts/process_doxygen_xml.py'
--- scripts/process_doxygen_xml.py 2017-03-15 17:44:36 +0000
+++ scripts/process_doxygen_xml.py 2017-06-20 16:14:05 +0000
@@ -476,10 +476,21 @@
476476
477MIRAL_1.3.1 {477MIRAL_1.3.1 {
478global:478global:
479 extern "C++" {
480 miral::SetWindowManagementPolicy::?SetWindowManagementPolicy*;
481 miral::SetWindowManagementPolicy::SetWindowManagementPolicy*;
482 miral::SetWindowManagementPolicy::operator*;
483 typeinfo?for?miral::SetWindowManagementPolicy;
484 vtable?for?miral::SetWindowManagementPolicy;
485 };
486} MIRAL_1.3;
487
488MIRAL_1.4.0 {
489global:
479 extern "C++" {'''490 extern "C++" {'''
480491
481END_NEW_STANZA = ''' };492END_NEW_STANZA = ''' };
482} MIRAL_1.3;'''493} MIRAL_1.3.1;'''
483494
484def _print_report():495def _print_report():
485 print OLD_STANZAS496 print OLD_STANZAS
486497
=== modified file 'test/CMakeLists.txt'
--- test/CMakeLists.txt 2017-02-13 16:23:29 +0000
+++ test/CMakeLists.txt 2017-06-20 16:14:05 +0000
@@ -39,6 +39,16 @@
39 ${GTEST_INCLUDE_DIR}39 ${GTEST_INCLUDE_DIR}
40)40)
4141
42# MIRAL_TEST_MODERN_FEATURES lists test sourcefiles that require a recent version of Mir
43if (MIRTEST_VERSION VERSION_LESS 0.27)
44 set(MIRAL_TEST_MODERN_FEATURES)
45else()
46 set(MIRAL_TEST_MODERN_FEATURES
47 drag_and_drop.cpp
48 client_mediated_gestures.cpp
49 )
50endif()
51
42add_executable(miral-test52add_executable(miral-test
43 mru_window_list.cpp53 mru_window_list.cpp
44 active_outputs.cpp54 active_outputs.cpp
@@ -56,7 +66,9 @@
56 display_reconfiguration.cpp66 display_reconfiguration.cpp
57 active_window.cpp67 active_window.cpp
58 raise_tree.cpp68 raise_tree.cpp
59 workspaces.cpp)69 workspaces.cpp
70 ${MIRAL_TEST_MODERN_FEATURES}
71)
6072
61target_link_libraries(miral-test73target_link_libraries(miral-test
62 ${MIRTEST_LDFLAGS}74 ${MIRTEST_LDFLAGS}
6375
=== modified file 'test/active_window.cpp'
--- test/active_window.cpp 2017-03-16 16:57:38 +0000
+++ test/active_window.cpp 2017-06-20 16:14:05 +0000
@@ -18,10 +18,10 @@
1818
19#include "test_server.h"19#include "test_server.h"
2020
21#include <mir/client/surface.h>
21#include <mir/client/window.h>22#include <mir/client/window.h>
22#include <mir/client/window_spec.h>23#include <mir/client/window_spec.h>
23#include <mir_toolkit/mir_buffer_stream.h>24#include <mir_toolkit/mir_buffer_stream.h>
24#include <mir_toolkit/version.h>
2525
26#include <miral/application_info.h>26#include <miral/application_info.h>
2727
@@ -35,11 +35,6 @@
35using namespace std::chrono_literals;35using namespace std::chrono_literals;
36using miral::WindowManagerTools;36using miral::WindowManagerTools;
3737
38#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
39auto const mir_event_type_window = mir_event_type_surface;
40auto const mir_window_event_get_attribute = mir_surface_event_get_attribute;
41auto const mir_event_get_window_event = mir_event_get_surface_event;
42#endif
4338
44namespace39namespace
45{40{
@@ -68,58 +63,79 @@
68 mir::test::Signal signal;63 mir::test::Signal signal;
69};64};
7065
66struct TestWindow : Surface, Window
67{
68 using Surface::operator=;
69 using Window::operator=;
70};
71
71struct ActiveWindow : public miral::TestServer72struct ActiveWindow : public miral::TestServer
72{73{
73 FocusChangeSync sync1;74 FocusChangeSync sync1;
74 FocusChangeSync sync2;75 FocusChangeSync sync2;
7576
76 auto create_surface(Connection const& connection, char const* name, FocusChangeSync& sync) -> Window77 void paint(Surface const& surface)
77 {78 {
78 auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888)79 mir_buffer_stream_swap_buffers_sync(
79 .set_buffer_usage(mir_buffer_usage_software)80 mir_render_surface_get_buffer_stream(surface, 50, 50, mir_pixel_format_argb_8888));
81 }
82
83 auto create_window(Connection const& connection, char const* name, FocusChangeSync& sync) -> TestWindow
84 {
85 TestWindow result;
86
87 result = Surface{mir_connection_create_render_surface_sync(connection, 50, 50)};
88
89 auto const spec = WindowSpec::for_normal_window(connection, 50, 50)
80 .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)90 .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)
91 .add_surface(result, 50, 50, 0, 0)
81 .set_name(name);92 .set_name(name);
8293
83 Window const surface{spec.create_window()};94 result = Window{spec.create_window()};
8495
85 sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); });96 sync.exec([&]{ paint(result); });
97
86 EXPECT_TRUE(sync.signal_raised());98 EXPECT_TRUE(sync.signal_raised());
8799
88 return surface;100 return result;
89 }101 }
90102
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
92 auto create_tip(Connection const& connection, char const* name, Window const& parent, FocusChangeSync& sync) -> Window
93 {104 {
105 TestWindow result;
106 result = Surface{mir_connection_create_render_surface_sync(connection, 50, 50)};
107
94 MirRectangle aux_rect{10, 10, 10, 10};108 MirRectangle aux_rect{10, 10, 10, 10};
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)
96 .set_buffer_usage(mir_buffer_usage_software)
97 .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)110 .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)
111 .add_surface(result, 50, 50, 0, 0)
98 .set_name(name);112 .set_name(name);
99113
100 Window const surface{spec.create_window()};114 result = Window{spec.create_window()};
101115
102 // Expect this to timeout: A tip should not receive focus116 // Expect this to timeout: A tip should not receive focus
103 sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); });117 sync.exec([&]{ paint(result); });
104 EXPECT_FALSE(sync.signal_raised());118 EXPECT_FALSE(sync.signal_raised());
105119
106 return surface;120 return result;
107 }121 }
108#endif
109122
110 auto create_dialog(Connection const& connection, char const* name, Window const& parent, FocusChangeSync& sync) -> Window123 auto create_dialog(Connection const& connection, char const* name, Window const& parent, FocusChangeSync& sync) -> TestWindow
111 {124 {
112 auto const spec = WindowSpec::for_dialog(connection, 50, 50, mir_pixel_format_argb_8888, parent)125 TestWindow result;
113 .set_buffer_usage(mir_buffer_usage_software)126 result = Surface{mir_connection_create_render_surface_sync(connection, 50, 50)};
127
128 auto const spec = WindowSpec::for_dialog(connection, 50, 50, parent)
114 .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)129 .set_event_handler(&FocusChangeSync::raise_signal_on_focus_change, &sync)
130 .add_surface(result, 50, 50, 0, 0)
115 .set_name(name);131 .set_name(name);
116132
117 Window const surface{spec.create_window()};133 result = Window{spec.create_window()};
118134
119 sync.exec([&]{ mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(surface)); });135 sync.exec([&]{ paint(result); });
120 EXPECT_TRUE(sync.signal_raised());136 EXPECT_TRUE(sync.signal_raised());
121137
122 return surface;138 return result;
123 }139 }
124140
125 void assert_no_active_window()141 void assert_no_active_window()
@@ -151,7 +167,7 @@
151 char const* const test_name = __PRETTY_FUNCTION__;167 char const* const test_name = __PRETTY_FUNCTION__;
152 auto const connection = connect_client(test_name);168 auto const connection = connect_client(test_name);
153169
154 auto const surface = create_surface(connection, test_name, sync1);170 auto const window = create_window(connection, test_name, sync1);
155171
156 assert_active_window_is(test_name);172 assert_active_window_is(test_name);
157}173}
@@ -160,9 +176,9 @@
160{176{
161 char const* const test_name = __PRETTY_FUNCTION__;177 char const* const test_name = __PRETTY_FUNCTION__;
162 auto const connection = connect_client(test_name);178 auto const connection = connect_client(test_name);
163 auto const surface = create_surface(connection, test_name, sync1);179 auto const window = create_window(connection, test_name, sync1);
164180
165 sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); });181 sync1.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); });
166182
167 EXPECT_TRUE(sync1.signal_raised());183 EXPECT_TRUE(sync1.signal_raised());
168 assert_no_active_window();184 assert_no_active_window();
@@ -172,11 +188,11 @@
172{188{
173 char const* const test_name = __PRETTY_FUNCTION__;189 char const* const test_name = __PRETTY_FUNCTION__;
174 auto const connection = connect_client(test_name);190 auto const connection = connect_client(test_name);
175 auto const surface = create_surface(connection, test_name, sync1);191 auto const window = create_window(connection, test_name, sync1);
176192
177 sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); });193 sync1.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); });
178194
179 sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_restored); });195 sync1.exec([&]{ mir_window_set_state(window, mir_window_state_restored); });
180196
181 EXPECT_TRUE(sync1.signal_raised());197 EXPECT_TRUE(sync1.signal_raised());
182198
@@ -188,8 +204,8 @@
188 char const* const test_name = __PRETTY_FUNCTION__;204 char const* const test_name = __PRETTY_FUNCTION__;
189 auto const connection = connect_client(test_name);205 auto const connection = connect_client(test_name);
190206
191 auto const first_surface = create_surface(connection, "first", sync1);207 auto const first_window = create_window(connection, "first", sync1);
192 auto const surface = create_surface(connection, test_name, sync2);208 auto const window = create_window(connection, test_name, sync2);
193209
194 assert_active_window_is(test_name);210 assert_active_window_is(test_name);
195}211}
@@ -199,10 +215,10 @@
199 char const* const test_name = __PRETTY_FUNCTION__;215 char const* const test_name = __PRETTY_FUNCTION__;
200 auto const connection = connect_client(test_name);216 auto const connection = connect_client(test_name);
201217
202 auto const first_surface = create_surface(connection, test_name, sync1);218 auto const first_window = create_window(connection, test_name, sync1);
203 auto const surface = create_surface(connection, another_name, sync2);219 auto const window = create_window(connection, another_name, sync2);
204220
205 sync2.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); });221 sync2.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); });
206222
207 EXPECT_TRUE(sync2.signal_raised());223 EXPECT_TRUE(sync2.signal_raised());
208 assert_active_window_is(test_name);224 assert_active_window_is(test_name);
@@ -213,13 +229,13 @@
213 char const* const test_name = __PRETTY_FUNCTION__;229 char const* const test_name = __PRETTY_FUNCTION__;
214 auto const connection = connect_client(test_name);230 auto const connection = connect_client(test_name);
215231
216 auto const first_surface = create_surface(connection, test_name, sync1);232 auto const first_window = create_window(connection, test_name, sync1);
217 auto const surface = create_surface(connection, another_name, sync2);233 auto const window = create_window(connection, another_name, sync2);
218234
219 sync1.exec([&]{ mir_window_set_state(surface, mir_window_state_hidden); });235 sync1.exec([&]{ mir_window_set_state(window, mir_window_state_hidden); });
220236
221 // Expect this to timeout237 // Expect this to timeout
222 sync2.exec([&]{ mir_window_set_state(surface, mir_window_state_restored); });238 sync2.exec([&]{ mir_window_set_state(window, mir_window_state_restored); });
223239
224 EXPECT_THAT(sync2.signal_raised(), Eq(false));240 EXPECT_THAT(sync2.signal_raised(), Eq(false));
225 assert_active_window_is(test_name);241 assert_active_window_is(test_name);
@@ -230,8 +246,8 @@
230 char const* const test_name = __PRETTY_FUNCTION__;246 char const* const test_name = __PRETTY_FUNCTION__;
231 auto const connection = connect_client(test_name);247 auto const connection = connect_client(test_name);
232248
233 auto const first_surface = create_surface(connection, test_name, sync1);249 auto const first_window = create_window(connection, test_name, sync1);
234 auto const surface = create_surface(connection, another_name, sync2);250 auto const window = create_window(connection, another_name, sync2);
235251
236 sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_within_application(); }); });252 sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_within_application(); }); });
237253
@@ -245,8 +261,8 @@
245 auto const connection = connect_client(test_name);261 auto const connection = connect_client(test_name);
246 auto const second_connection = connect_client(another_name);262 auto const second_connection = connect_client(another_name);
247263
248 auto const first_surface = create_surface(connection, test_name, sync1);264 auto const first_window = create_window(connection, test_name, sync1);
249 auto const surface = create_surface(second_connection, another_name, sync2);265 auto const window = create_window(second_connection, another_name, sync2);
250266
251 sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_application(); }); });267 sync1.exec([&]{ invoke_tools([](WindowManagerTools& tools){ tools.focus_next_application(); }); });
252268
@@ -259,12 +275,12 @@
259 char const* const test_name = __PRETTY_FUNCTION__;275 char const* const test_name = __PRETTY_FUNCTION__;
260 auto const connection = connect_client(test_name);276 auto const connection = connect_client(test_name);
261277
262 auto const first_surface = create_surface(connection, test_name, sync1);278 auto const first_window = create_window(connection, test_name, sync1);
263279
264 sync1.exec([&]280 sync1.exec([&]
265 {281 {
266 auto const second_connection = connect_client(another_name);282 auto const second_connection = connect_client(another_name);
267 auto const surface = create_surface(second_connection, another_name, sync2);283 auto const window = create_window(second_connection, another_name, sync2);
268 assert_active_window_is(another_name);284 assert_active_window_is(another_name);
269 });285 });
270286
@@ -272,20 +288,19 @@
272 assert_active_window_is(test_name);288 assert_active_window_is(test_name);
273}289}
274290
275#if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0)
276TEST_F(ActiveWindow, selecting_a_tip_makes_parent_active)291TEST_F(ActiveWindow, selecting_a_tip_makes_parent_active)
277{292{
278 char const* const test_name = __PRETTY_FUNCTION__;293 char const* const test_name = __PRETTY_FUNCTION__;
279 auto const connection = connect_client(test_name);294 auto const connection = connect_client(test_name);
280295
281 auto const parent = create_surface(connection, test_name, sync1);296 auto const parent = create_window(connection, test_name, sync1);
282297
283 miral::Window parent_window;298 miral::Window parent_window;
284 invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); });299 invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); });
285300
286 // Steal the focus301 // Steal the focus
287 auto second_connection = connect_client(another_name);302 auto second_connection = connect_client(another_name);
288 auto second_surface = create_surface(second_connection, another_name, sync2);303 auto second_surface = create_window(second_connection, another_name, sync2);
289304
290 auto const tip = create_tip(connection, "tip", parent, sync2);305 auto const tip = create_tip(connection, "tip", parent, sync2);
291306
@@ -298,7 +313,6 @@
298313
299 assert_active_window_is(test_name);314 assert_active_window_is(test_name);
300}315}
301#endif
302316
303TEST_F(ActiveWindow, selecting_a_parent_makes_dialog_active)317TEST_F(ActiveWindow, selecting_a_parent_makes_dialog_active)
304{318{
@@ -306,7 +320,7 @@
306 auto const dialog_name = "dialog";320 auto const dialog_name = "dialog";
307 auto const connection = connect_client(test_name);321 auto const connection = connect_client(test_name);
308322
309 auto const parent = create_surface(connection, test_name, sync1);323 auto const parent = create_window(connection, test_name, sync1);
310324
311 miral::Window parent_window;325 miral::Window parent_window;
312 invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); });326 invoke_tools([&](WindowManagerTools& tools){ parent_window = tools.active_window(); });
@@ -315,7 +329,7 @@
315329
316 // Steal the focus330 // Steal the focus
317 auto second_connection = connect_client(another_name);331 auto second_connection = connect_client(another_name);
318 auto second_surface = create_surface(second_connection, another_name, sync1);332 auto second_surface = create_window(second_connection, another_name, sync1);
319333
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); }); });
321335
@@ -328,7 +342,7 @@
328 char const* const test_name = __PRETTY_FUNCTION__;342 char const* const test_name = __PRETTY_FUNCTION__;
329 auto const connection = connect_client(test_name);343 auto const connection = connect_client(test_name);
330344
331 auto const parent = create_surface(connection, test_name, sync1);345 auto const parent = create_window(connection, test_name, sync1);
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();
333347
334 assert_active_window_is(test_name);348 assert_active_window_is(test_name);
@@ -347,7 +361,7 @@
347 char const* const test_name = __PRETTY_FUNCTION__;361 char const* const test_name = __PRETTY_FUNCTION__;
348 auto const connection = connect_client(test_name);362 auto const connection = connect_client(test_name);
349363
350 auto const parent = create_surface(connection, test_name, sync1);364 auto const parent = create_window(connection, test_name, sync1);
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();
352366
353 assert_active_window_is(test_name);367 assert_active_window_is(test_name);
@@ -368,7 +382,7 @@
368 auto const dialog_name = "dialog";382 auto const dialog_name = "dialog";
369 auto const connection = connect_client(parent_name);383 auto const connection = connect_client(parent_name);
370384
371 auto const parent = create_surface(connection, parent_name, sync1);385 auto const parent = create_window(connection, parent_name, sync1);
372 auto const dialog = create_dialog(connection, dialog_name, parent, sync2);386 auto const dialog = create_dialog(connection, dialog_name, parent, sync2);
373387
374 sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });388 sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });
@@ -386,8 +400,8 @@
386 auto const another_window_name = "another window";400 auto const another_window_name = "another window";
387 auto const connection = connect_client(parent_name);401 auto const connection = connect_client(parent_name);
388402
389 auto const parent = create_surface(connection, parent_name, sync1);403 auto const parent = create_window(connection, parent_name, sync1);
390 auto const another_window = create_surface(connection, another_window_name, sync2);404 auto const another_window = create_window(connection, another_window_name, sync2);
391 auto const dialog = create_dialog(connection, dialog_name, parent, sync3);405 auto const dialog = create_dialog(connection, dialog_name, parent, sync3);
392406
393 sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });407 sync1.exec([&]{ mir_window_set_state(dialog, mir_window_state_hidden); });
394408
=== added file 'test/client_mediated_gestures.cpp'
--- test/client_mediated_gestures.cpp 1970-01-01 00:00:00 +0000
+++ test/client_mediated_gestures.cpp 2017-06-20 16:14:05 +0000
@@ -0,0 +1,295 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include <mir/client/surface.h>
20#include <mir/client/window_spec.h>
21
22#include <mir_toolkit/mir_window.h>
23#include <mir_toolkit/mir_blob.h>
24
25#include <mir/geometry/displacement.h>
26#include <mir/input/input_device_info.h>
27#include <mir/input/device_capability.h>
28#include <mir/shell/canonical_window_manager.h>
29#include <mir/shell/shell.h>
30
31#include <mir_test_framework/connected_client_with_a_window.h>
32#include <mir_test_framework/fake_input_device.h>
33#include <mir_test_framework/stub_server_platform_factory.h>
34#include <mir/test/event_factory.h>
35#include <mir/test/fake_shared.h>
36#include <mir/test/signal.h>
37
38#include <gmock/gmock.h>
39#include <gtest/gtest.h>
40
41#include <linux/input.h>
42
43#include <atomic>
44
45using namespace std::chrono_literals;
46using namespace mir::geometry;
47using namespace testing;
48using mir::test::fake_shared;
49using mir::test::Signal;
50
51namespace
52{
53class Cookie
54{
55public:
56 Cookie() = default;
57
58 explicit Cookie(MirCookie const* cookie) : self{cookie, deleter} {}
59
60 operator MirCookie const*() const { return self.get(); }
61
62 auto get() const -> MirCookie const* { return self.get(); }
63
64 void reset() { self.reset(); }
65
66 void reset(MirCookie const* cookie) { self.reset(cookie, deleter); }
67
68private:
69 static void deleter(MirCookie const* cookie) { mir_cookie_release(cookie); }
70
71 std::shared_ptr<MirCookie const> self;
72};
73
74void mir_cookie_release(Cookie const&) = delete;
75
76struct MockWindowManager : mir::shell::CanonicalWindowManager
77{
78 using mir::shell::CanonicalWindowManager::CanonicalWindowManager;
79
80 MOCK_METHOD3(handle_request_move,
81 void(std::shared_ptr<mir::scene::Session> const&, std::shared_ptr<mir::scene::Surface> const&, uint64_t));
82};
83
84struct MouseMoverAndFaker
85{
86 void start_dragging_mouse()
87 {
88 using namespace mir::input::synthesis;
89 fake_mouse->emit_event(a_button_down_event().of_button(BTN_LEFT));
90 }
91
92 void move_mouse(Displacement const& displacement)
93 {
94 using mir::input::synthesis::a_pointer_event;
95 fake_mouse->emit_event(a_pointer_event().with_movement(displacement.dx.as_int(), displacement.dy.as_int()));
96 }
97
98 void release_mouse()
99 {
100 using namespace mir::input::synthesis;
101 fake_mouse->emit_event(a_button_up_event().of_button(BTN_LEFT));
102 }
103
104private:
105 std::unique_ptr<mir_test_framework::FakeInputDevice> fake_mouse{
106 mir_test_framework::add_fake_input_device(
107 mir::input::InputDeviceInfo{"mouse", "mouse-uid", mir::input::DeviceCapability::pointer})
108 };
109};
110
111Rectangle const screen_geometry{{0, 0}, {800, 600}};
112auto const receive_event_timeout = 90s;
113
114struct ClientMediatedUserGestures : mir_test_framework::ConnectedClientWithAWindow,
115 MouseMoverAndFaker
116{
117 void SetUp() override
118 {
119 initial_display_layout({screen_geometry});
120 server.override_the_window_manager_builder([this](mir::shell::FocusController* focus_controller)
121 {
122 return window_manager =
123 std::make_shared<MockWindowManager>(focus_controller, server.the_shell_display_layout());
124 });
125
126 mir_test_framework::ConnectedClientWithAWindow::SetUp();
127 mir_window_set_event_handler(window, &window_event_handler, this);
128
129 paint_window();
130
131 center_mouse();
132 }
133
134 void TearDown() override
135 {
136 reset_window_event_handler();
137 window_manager.reset();
138 surface.reset();
139 mir_test_framework::ConnectedClientWithAWindow::TearDown();
140 }
141
142 auto user_initiates_gesture() -> Cookie;
143
144 std::shared_ptr<MockWindowManager> window_manager;
145
146private:
147 void center_mouse();
148 void paint_window();
149 void set_window_event_handler(std::function<void(MirEvent const* event)> const& handler);
150 void reset_window_event_handler();
151 void invoke_window_event_handler(MirEvent const* event)
152 {
153 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
154 window_event_handler_(event);
155 }
156
157 mir::client::Surface surface;
158
159 std::mutex window_event_handler_mutex;
160 std::function<void(MirEvent const* event)> window_event_handler_ = [](MirEvent const*) {};
161
162 static void window_event_handler(MirWindow* window, MirEvent const* event, void* context);
163};
164
165void ClientMediatedUserGestures::set_window_event_handler(std::function<void(MirEvent const* event)> const& handler)
166{
167 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
168 window_event_handler_ = handler;
169}
170
171void ClientMediatedUserGestures::reset_window_event_handler()
172{
173 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
174 window_event_handler_ = [](MirEvent const*) {};
175}
176
177void ClientMediatedUserGestures::window_event_handler(MirWindow* /*window*/, MirEvent const* event, void* context)
178{
179 static_cast<ClientMediatedUserGestures*>(context)->invoke_window_event_handler(event);
180}
181
182void ClientMediatedUserGestures::paint_window()
183{
184 {
185 surface = mir::client::Surface{mir_connection_create_render_surface_sync(connection, 42, 42)};
186 auto const spec = mir::client::WindowSpec::for_changes(connection);
187 mir_window_spec_add_render_surface(spec, surface, 42, 42, 0, 0);
188 mir_window_apply_spec(window, spec);
189 }
190
191 Signal have_focus;
192
193 set_window_event_handler([&](MirEvent const* event)
194 {
195 if (mir_event_get_type(event) != mir_event_type_window)
196 return;
197
198 auto const window_event = mir_event_get_window_event(event);
199 if (mir_window_event_get_attribute(window_event) != mir_window_attrib_focus)
200 return;
201
202 if (mir_window_event_get_attribute_value(window_event))
203 have_focus.raise();
204 });
205
206 mir_buffer_stream_swap_buffers_sync(mir_render_surface_get_buffer_stream(surface, 42, 42, mir_pixel_format_argb_8888));
207
208 EXPECT_THAT(have_focus.wait_for(receive_event_timeout), Eq(true));
209
210 reset_window_event_handler();
211}
212
213void ClientMediatedUserGestures::center_mouse()
214{
215 Signal have_mouseover;
216
217 set_window_event_handler([&](MirEvent const* event)
218 {
219 if (mir_event_get_type(event) != mir_event_type_input)
220 return;
221
222 auto const input_event = mir_event_get_input_event(event);
223
224 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
225 return;
226
227 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
228
229 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_enter)
230 return;
231
232 have_mouseover.raise();
233 });
234
235 move_mouse(0.5 * as_displacement(screen_geometry.size));
236
237// We miss the "mouseover" occasionally (with valgrind and heavy stress about 1/20).
238// But it isn't essential for the test and we've probably waited long enough
239// for the mouse-down needed by the test to reach the window.
240// EXPECT_THAT(have_mouseover.wait_for(receive_event_timeout), Eq(true));
241 have_mouseover.wait_for(receive_event_timeout);
242
243 reset_window_event_handler();
244}
245
246auto ClientMediatedUserGestures::user_initiates_gesture() -> Cookie
247{
248 Cookie cookie;
249 Signal have_cookie;
250
251 set_window_event_handler([&](MirEvent const* event)
252 {
253 if (mir_event_get_type(event) != mir_event_type_input)
254 return;
255
256 auto const input_event = mir_event_get_input_event(event);
257
258 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
259 return;
260
261 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
262
263 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_button_down)
264 return;
265
266 cookie = Cookie{mir_input_event_get_cookie(input_event)};
267 have_cookie.raise();
268 });
269
270 start_dragging_mouse();
271
272 EXPECT_THAT(have_cookie.wait_for(receive_event_timeout), Eq(true));
273
274 reset_window_event_handler();
275 return cookie;
276}
277}
278
279TEST_F(ClientMediatedUserGestures, when_user_initiates_gesture_client_receives_cookie)
280{
281 auto const cookie = user_initiates_gesture();
282
283 EXPECT_THAT(cookie.get(), NotNull());
284}
285
286TEST_F(ClientMediatedUserGestures, when_client_initiates_move_window_manager_handles_request)
287{
288 auto const cookie = user_initiates_gesture();
289 Signal have_request;
290 EXPECT_CALL(*window_manager, handle_request_move(_, _, _)).WillOnce(InvokeWithoutArgs([&]{ have_request.raise(); }));
291
292 mir_window_request_user_move(window, cookie);
293
294 EXPECT_THAT(have_request.wait_for(receive_event_timeout), Eq(true));
295}
0296
=== added file 'test/drag_and_drop.cpp'
--- test/drag_and_drop.cpp 1970-01-01 00:00:00 +0000
+++ test/drag_and_drop.cpp 2017-06-20 16:14:05 +0000
@@ -0,0 +1,653 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include <miral/window_management_policy_addendum2.h>
20
21#include <mir/client/blob.h>
22#include <mir/client/cookie.h>
23#include <mir/client/surface.h>
24#include <mir/client/window.h>
25#include <mir/client/window_spec.h>
26#include <mir_toolkit/mir_buffer_stream.h>
27#include <mir_toolkit/extensions/drag_and_drop.h>
28
29#include <mir/geometry/displacement.h>
30#include <mir/input/input_device_info.h>
31#include <mir/input/device_capability.h>
32#include <mir/shell/shell.h>
33
34#include "test_server.h"
35#include <mir_test_framework/fake_input_device.h>
36#include <mir_test_framework/stub_server_platform_factory.h>
37#include <mir/test/event_factory.h>
38#include <mir/test/signal.h>
39
40#include <gmock/gmock.h>
41#include <gtest/gtest.h>
42
43#include <linux/input.h>
44#include <uuid/uuid.h>
45
46#include <boost/throw_exception.hpp>
47#include <atomic>
48
49using namespace std::chrono_literals;
50using namespace mir::client;
51using namespace mir::geometry;
52using namespace testing;
53using mir::test::Signal;
54
55namespace
56{
57struct MouseMoverAndFaker
58{
59 void start_dragging_mouse()
60 {
61 using namespace mir::input::synthesis;
62 fake_mouse->emit_event(a_button_down_event().of_button(BTN_LEFT));
63 }
64
65 void move_mouse(Displacement const& displacement)
66 {
67 using mir::input::synthesis::a_pointer_event;
68 fake_mouse->emit_event(a_pointer_event().with_movement(displacement.dx.as_int(), displacement.dy.as_int()));
69 }
70
71 void release_mouse()
72 {
73 using namespace mir::input::synthesis;
74 fake_mouse->emit_event(a_button_up_event().of_button(BTN_LEFT));
75 }
76
77private:
78 std::unique_ptr<mir_test_framework::FakeInputDevice> fake_mouse{
79 mir_test_framework::add_fake_input_device(
80 mir::input::InputDeviceInfo{"mouse", "mouse-uid", mir::input::DeviceCapability::pointer})};
81};
82
83Rectangle const screen_geometry{{0,0}, {800,600}};
84auto const receive_event_timeout = 1s; //90s;
85
86struct ConnectedClientWithAWindow : miral::TestServer
87{
88 Connection connection;
89 Surface surface;
90 Window window;
91
92 void SetUp() override
93 {
94 miral::TestServer::SetUp();
95 connection = connect_client(__func__);
96 auto const width = surface_size.width.as_int();
97 auto const height = surface_size.height.as_int();
98 surface = Surface{mir_connection_create_render_surface_sync(connection, width, height)};
99 window = WindowSpec::for_normal_window(connection, width, height)
100 .set_name("ConnectedClientWithAWindow")
101 .add_surface(surface, width, height, 0, 0)
102 .create_window();
103 }
104
105 void TearDown() override
106 {
107 window.reset();
108 surface.reset();
109 connection.reset();
110 miral::TestServer::TearDown();
111 }
112
113 mir::geometry::Size const surface_size {640, 480};
114};
115
116struct DragAndDrop : ConnectedClientWithAWindow,
117 MouseMoverAndFaker
118{
119 MirDragAndDropV1 const* dnd = nullptr;
120
121 void SetUp() override
122 {
123 mir_test_framework::set_next_display_rects(std::unique_ptr<std::vector<Rectangle>>(new std::vector<Rectangle>({screen_geometry})));
124
125 ConnectedClientWithAWindow::SetUp();
126 dnd = mir_drag_and_drop_v1(connection);
127 mir_window_set_event_handler(window, &window_event_handler, this);
128 if (dnd) dnd->set_start_drag_and_drop_callback(window, &window_dnd_start_handler, this);
129
130 create_target_window();
131
132 paint_window(surface, window);
133
134 center_mouse();
135 }
136
137 void TearDown() override
138 {
139 reset_window_event_handler(target_window);
140 reset_window_event_handler(window);
141 target_window.reset();
142 target_surface.reset();
143 another_connection.reset();
144 ConnectedClientWithAWindow::TearDown();
145 }
146
147 auto user_initiates_drag() -> Cookie;
148 auto client_requests_drag(Cookie const& cookie) -> Blob;
149 auto handle_from_mouse_move() -> Blob;
150 auto handle_from_mouse_leave() -> Blob;
151 auto handle_from_mouse_enter() -> Blob;
152 auto handle_from_mouse_release() -> Blob;
153 auto count_of_handles_when_moving_mouse() -> int;
154
155private:
156 auto build_window_manager_policy(miral::WindowManagerTools const& tools) -> std::unique_ptr<TestWindowManagerPolicy> override;
157 void center_mouse();
158 void paint_window(MirRenderSurface* s, MirWindow* w);
159 void set_window_event_handler(MirWindow* window, std::function<void(MirEvent const* event)> const& handler);
160 void set_window_dnd_start_handler(MirWindow* window, std::function<void(MirDragAndDropEvent const*)> const& handler);
161 void reset_window_event_handler(MirWindow* window);
162
163 void create_target_window()
164 {
165 another_connection = connect_client("another_connection");
166 auto const height = screen_geometry.size.height.as_int();
167 auto const width = screen_geometry.size.width.as_int();
168 target_surface = Surface{mir_connection_create_render_surface_sync(another_connection, width,height)};
169 target_window = WindowSpec::for_normal_window(another_connection, width, height)
170 .set_name("target_window")
171 .add_surface(target_surface, width, height, 0, 0)
172 .set_event_handler(&window_event_handler, this)
173 .create_window();
174
175 paint_window(target_surface, target_window);
176 }
177
178 void invoke_window_event_handler(MirWindow* window, MirEvent const* event)
179 {
180 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
181 if (window == this->window) window_event_handler_(event);
182 if (window == target_window) target_window_event_handler_(event);
183 }
184
185 void invoke_window_dnd_start_handler(MirWindow* window, MirDragAndDropEvent const* event)
186 {
187 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
188 if (window == this->window) window_dnd_start_(event);
189 }
190
191 std::mutex window_event_handler_mutex;
192 std::function<void(MirDragAndDropEvent const* event)> window_dnd_start_ = [](MirDragAndDropEvent const*) {};
193 std::function<void(MirEvent const* event)> window_event_handler_ = [](MirEvent const*) {};
194 std::function<void(MirEvent const* event)> target_window_event_handler_ = [](MirEvent const*) {};
195
196 static void window_event_handler(MirWindow* window, MirEvent const* event, void* context);
197 static void window_dnd_start_handler(MirWindow* window, MirDragAndDropEvent const* event, void* context);
198
199 Connection another_connection;
200 Surface target_surface;
201 Window target_window;
202};
203
204void DragAndDrop::set_window_event_handler(MirWindow* window, std::function<void(MirEvent const* event)> const& handler)
205{
206 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
207 if (window == this->window) window_event_handler_ = handler;
208 if (window == target_window) target_window_event_handler_ = handler;
209}
210
211void DragAndDrop::set_window_dnd_start_handler(MirWindow* window, std::function<void(MirDragAndDropEvent const*)> const& handler)
212{
213std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
214if (window == this->window) window_dnd_start_ = handler;
215}
216
217
218void DragAndDrop::reset_window_event_handler(MirWindow* window)
219{
220 if (window == this->window) window_event_handler_ = [](MirEvent const*) {};
221 if (window == target_window) target_window_event_handler_ = [](MirEvent const*) {};
222}
223
224void DragAndDrop::paint_window(MirRenderSurface* s, MirWindow* w)
225{
226 Signal have_focus;
227
228 set_window_event_handler(w, [&](MirEvent const* event)
229 {
230 if (mir_event_get_type(event) != mir_event_type_window)
231 return;
232
233 auto const window_event = mir_event_get_window_event(event);
234 if (mir_window_event_get_attribute(window_event) != mir_window_attrib_focus)
235 return;
236
237 if (mir_window_event_get_attribute_value(window_event))
238 have_focus.raise();
239 });
240
241 int width;
242 int height;
243 mir_render_surface_get_size(s, &width, &height);
244 mir_buffer_stream_swap_buffers_sync(
245 mir_render_surface_get_buffer_stream(s, width, height, mir_pixel_format_argb_8888));
246
247 EXPECT_THAT(have_focus.wait_for(receive_event_timeout), Eq(true));
248
249 reset_window_event_handler(w);
250}
251
252void DragAndDrop::center_mouse()
253{
254 Signal have_mouseover;
255
256 set_window_event_handler(window, [&](MirEvent const* event)
257 {
258 if (mir_event_get_type(event) != mir_event_type_input)
259 return;
260
261 auto const input_event = mir_event_get_input_event(event);
262
263 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
264 return;
265
266 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
267
268 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_enter)
269 return;
270
271 have_mouseover.raise();
272 });
273
274 move_mouse(0.5 * as_displacement(screen_geometry.size));
275
276// We miss the "mouseover" occasionally (with valgrind and heavy stress about 1/20).
277// But it isn't essential for the test and we've probably waited long enough
278// for the mouse-down needed by the test to reach the window.
279// EXPECT_THAT(have_mouseover.wait_for(receive_event_timeout), Eq(true));
280 have_mouseover.wait_for(receive_event_timeout);
281
282 reset_window_event_handler(window);
283}
284
285void DragAndDrop::window_event_handler(MirWindow* window, MirEvent const* event, void* context)
286{
287 static_cast<DragAndDrop*>(context)->invoke_window_event_handler(window, event);
288}
289
290void DragAndDrop::window_dnd_start_handler(MirWindow* window, MirDragAndDropEvent const* event, void* context)
291{
292 static_cast<DragAndDrop*>(context)->invoke_window_dnd_start_handler(window, event);
293}
294
295
296auto DragAndDrop::user_initiates_drag() -> Cookie
297{
298 Cookie cookie;
299 Signal have_cookie;
300
301 set_window_event_handler(window, [&](MirEvent const* event)
302 {
303 if (mir_event_get_type(event) != mir_event_type_input)
304 return;
305
306 auto const input_event = mir_event_get_input_event(event);
307
308 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
309 return;
310
311 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
312
313 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_button_down)
314 return;
315
316 cookie = Cookie{mir_input_event_get_cookie(input_event)};
317 have_cookie.raise();
318 });
319
320 start_dragging_mouse();
321
322 EXPECT_THAT(have_cookie.wait_for(receive_event_timeout), Eq(true));
323
324 reset_window_event_handler(window);
325 return cookie;
326}
327
328auto DragAndDrop::client_requests_drag(Cookie const& cookie) -> Blob
329{
330 Blob blob;
331 Signal initiated;
332
333 set_window_dnd_start_handler(window, [&](MirDragAndDropEvent const* event)
334 {
335 if (dnd)
336 blob.reset(dnd->start_drag_and_drop(event));
337
338 if (blob)
339 initiated.raise();
340 });
341
342 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
343
344 if (dnd)
345 dnd->request_drag_and_drop(window, cookie);
346
347 EXPECT_TRUE(initiated.wait_for(receive_event_timeout));
348
349 reset_window_event_handler(window);
350 return blob;
351}
352
353auto DragAndDrop::handle_from_mouse_move() -> Blob
354{
355 Blob blob;
356 Signal have_blob;
357
358 set_window_event_handler(window, [&](MirEvent const* event)
359 {
360 if (mir_event_get_type(event) != mir_event_type_input)
361 return;
362
363 auto const input_event = mir_event_get_input_event(event);
364
365 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
366 return;
367
368 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
369
370 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
371
372 if (dnd)
373 blob.reset(dnd->pointer_drag_and_drop(pointer_event));
374
375 if (blob)
376 have_blob.raise();
377 });
378
379 move_mouse({1,1});
380
381 EXPECT_TRUE(have_blob.wait_for(receive_event_timeout));
382
383 reset_window_event_handler(window);
384 return blob;
385}
386
387auto DragAndDrop::handle_from_mouse_leave() -> Blob
388{
389 Blob blob;
390 Signal have_blob;
391
392 set_window_event_handler(window, [&](MirEvent const* event)
393 {
394 if (mir_event_get_type(event) != mir_event_type_input)
395 return;
396
397 auto const input_event = mir_event_get_input_event(event);
398
399 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
400 return;
401
402 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
403
404 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_leave)
405 return;
406
407 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
408
409 if (dnd)
410 blob.reset(dnd->pointer_drag_and_drop(pointer_event));
411
412 if (blob)
413 have_blob.raise();
414 });
415
416 move_mouse({1,1});
417 move_mouse(0.5 * as_displacement(surface_size));
418
419 EXPECT_TRUE(have_blob.wait_for(receive_event_timeout));
420
421 reset_window_event_handler(window);
422 return blob;
423}
424
425auto DragAndDrop::handle_from_mouse_enter() -> Blob
426{
427 Blob blob;
428 Signal have_blob;
429
430 set_window_event_handler(target_window, [&](MirEvent const* event)
431 {
432 if (mir_event_get_type(event) != mir_event_type_input)
433 return;
434
435 auto const input_event = mir_event_get_input_event(event);
436
437 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
438 return;
439
440 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
441
442 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_enter)
443 return;
444
445 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
446
447 if (dnd)
448 blob.reset(dnd->pointer_drag_and_drop(pointer_event));
449
450 if (blob)
451 have_blob.raise();
452 });
453
454 move_mouse({1,1});
455 move_mouse(0.5 * as_displacement(surface_size));
456
457 EXPECT_TRUE(have_blob.wait_for(receive_event_timeout));
458
459 reset_window_event_handler(target_window);
460 return blob;
461}
462
463auto DragAndDrop::handle_from_mouse_release() -> Blob
464{
465 Blob blob;
466 Signal have_blob;
467
468 set_window_event_handler(target_window, [&](MirEvent const* event)
469 {
470 if (mir_event_get_type(event) != mir_event_type_input)
471 return;
472
473 auto const input_event = mir_event_get_input_event(event);
474
475 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
476 return;
477
478 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
479
480 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_button_up)
481 return;
482
483 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
484
485 if (dnd)
486 blob.reset(dnd->pointer_drag_and_drop(pointer_event));
487
488 if (blob)
489 have_blob.raise();
490 });
491
492 move_mouse({1,1});
493 move_mouse(0.5 * as_displacement(surface_size));
494 release_mouse();
495
496 EXPECT_TRUE(have_blob.wait_for(receive_event_timeout));
497
498 reset_window_event_handler(target_window);
499 return blob;
500}
501
502auto DragAndDrop::count_of_handles_when_moving_mouse() -> int
503{
504 Signal have_3_events;
505 std::atomic<int> events{0};
506 std::atomic<int> handles{0};
507
508 auto counter = [&](MirEvent const* event)
509 {
510 if (mir_event_get_type(event) != mir_event_type_input)
511 return;
512
513 auto const input_event = mir_event_get_input_event(event);
514
515 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
516 return;
517
518 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
519
520 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
521
522 Blob blob;
523 if (dnd)
524 blob.reset(dnd->pointer_drag_and_drop(pointer_event));
525
526 if (blob)
527 handles.fetch_add(1);
528
529 if (events.fetch_add(1) == 2)
530 have_3_events.raise();
531 };
532
533 set_window_event_handler(window, counter);
534 set_window_event_handler(target_window, counter);
535
536 start_dragging_mouse();
537 move_mouse({1,1});
538 release_mouse();
539
540 EXPECT_TRUE(have_3_events.wait_for(receive_event_timeout));
541
542 reset_window_event_handler(window);
543 reset_window_event_handler(target_window);
544 return handles;
545}
546
547auto DragAndDrop::build_window_manager_policy(miral::WindowManagerTools const& tools) -> std::unique_ptr<TestWindowManagerPolicy>
548{
549 struct DnDWindowManagerPolicy : miral::TestServer::TestWindowManagerPolicy, miral::WindowManagementPolicyAddendum2
550 {
551 using miral::TestServer::TestWindowManagerPolicy::TestWindowManagerPolicy;
552
553 void handle_request_drag_and_drop(miral::WindowInfo& window_info) override
554 {
555 uuid_t uuid;
556 uuid_generate(uuid);
557 std::vector<uint8_t> const handle{std::begin(uuid), std::end(uuid)};
558
559 tools.start_drag_and_drop(window_info, handle);
560 }
561
562 void handle_request_move(miral::WindowInfo&, MirInputEvent const*) override {}
563 };
564
565 return std::make_unique<DnDWindowManagerPolicy>(tools, *this);
566}
567
568MATCHER_P(BlobContentEq, p, "")
569{
570 if (!arg || !p)
571 return false;
572 if (mir_blob_size(arg) != mir_blob_size(p))
573 return false;
574 return !memcmp(mir_blob_data(arg), mir_blob_data(p), mir_blob_size(p));
575}
576}
577
578TEST_F(DragAndDrop, when_user_initiates_drag_client_receives_cookie)
579{
580 auto const cookie = user_initiates_drag();
581
582 EXPECT_THAT(cookie, NotNull());
583}
584
585TEST_F(DragAndDrop, when_client_requests_drags_it_receives_handle)
586{
587 auto const cookie = user_initiates_drag();
588 ASSERT_THAT(cookie, NotNull());
589
590 auto const handle = client_requests_drag(cookie);
591
592 EXPECT_THAT(handle, NotNull());
593}
594
595TEST_F(DragAndDrop, during_drag_when_user_moves_mouse_client_receives_handle)
596{
597 auto const cookie = user_initiates_drag();
598 ASSERT_THAT(cookie, NotNull());
599 auto const handle_from_request = client_requests_drag(cookie);
600
601 auto const handle = handle_from_mouse_move();
602
603 EXPECT_THAT(handle, NotNull());
604 EXPECT_THAT(handle, BlobContentEq(handle_from_request));
605}
606
607TEST_F(DragAndDrop, when_drag_moves_from_window_leave_event_contains_handle)
608{
609 auto const cookie = user_initiates_drag();
610 ASSERT_THAT(cookie, NotNull());
611 auto const handle_from_request = client_requests_drag(cookie);
612
613 auto const handle = handle_from_mouse_leave();
614
615 EXPECT_THAT(handle, NotNull());
616 EXPECT_THAT(handle, BlobContentEq(handle_from_request));
617}
618
619TEST_F(DragAndDrop, when_drag_enters_target_window_enter_event_contains_handle)
620{
621 auto const cookie = user_initiates_drag();
622 ASSERT_THAT(cookie, NotNull());
623 auto const handle_from_request = client_requests_drag(cookie);
624
625 auto const handle = handle_from_mouse_enter();
626
627 EXPECT_THAT(handle, NotNull());
628 EXPECT_THAT(handle, BlobContentEq(handle_from_request));
629}
630
631TEST_F(DragAndDrop, when_drag_releases_target_window_release_event_contains_handle)
632{
633 auto const cookie = user_initiates_drag();
634 ASSERT_THAT(cookie, NotNull());
635 auto const handle_from_request = client_requests_drag(cookie);
636
637 auto const handle = handle_from_mouse_release();
638
639 EXPECT_THAT(handle, NotNull());
640 EXPECT_THAT(handle, BlobContentEq(handle_from_request));
641}
642
643TEST_F(DragAndDrop, after_drag_finishes_pointer_events_no_longer_contain_handle)
644{
645 auto const cookie = user_initiates_drag();
646 ASSERT_THAT(cookie, NotNull());
647 client_requests_drag(cookie);
648 handle_from_mouse_release();
649
650 invoke_tools([](miral::WindowManagerTools& tools) { tools.end_drag_and_drop(); });
651
652 EXPECT_THAT(count_of_handles_when_moving_mouse(), Eq(0));
653}
0654
=== modified file 'test/select_active_window.cpp'
--- test/select_active_window.cpp 2017-01-13 18:17:01 +0000
+++ test/select_active_window.cpp 2017-06-20 16:14:05 +0000
@@ -32,8 +32,6 @@
32Rectangle const display_area{{display_left, display_top},32Rectangle const display_area{{display_left, display_top},
33 {display_width, display_height}};33 {display_width, display_height}};
3434
35auto const null_window = Window{};
36
37struct SelectActiveWindow : TestWindowManagerTools35struct SelectActiveWindow : TestWindowManagerTools
38{36{
3937
4038
=== modified file 'test/test_server.cpp'
--- test/test_server.cpp 2017-03-20 12:28:06 +0000
+++ test/test_server.cpp 2017-06-20 16:14:05 +0000
@@ -29,9 +29,7 @@
29#include <mir/server.h>29#include <mir/server.h>
30#include <mir/version.h>30#include <mir/version.h>
3131
32#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
33#include <mir_test_framework/headless_display_buffer_compositor_factory.h>32#include <mir_test_framework/headless_display_buffer_compositor_factory.h>
34#endif
3533
36#include <boost/throw_exception.hpp>34#include <boost/throw_exception.hpp>
3735
@@ -52,7 +50,6 @@
52 CanonicalWindowManagerPolicy{tools}50 CanonicalWindowManagerPolicy{tools}
53{51{
54 test_fixture.tools = tools;52 test_fixture.tools = tools;
55 test_fixture.policy = this;
56}53}
5754
58miral::TestServer::TestServer() :55miral::TestServer::TestServer() :
@@ -71,10 +68,6 @@
7168
72void miral::TestServer::SetUp()69void miral::TestServer::SetUp()
73{70{
74#if MIR_SERVER_VERSION < MIR_VERSION_NUMBER(0, 25, 0)
75 mtf::set_next_preset_display({}); // Workaround for lp:1611337
76#endif
77
78 mir::test::AutoJoinThread t([this]71 mir::test::AutoJoinThread t([this]
79 {72 {
80 auto init = [this](mir::Server& server)73 auto init = [this](mir::Server& server)
@@ -93,23 +86,17 @@
93 });86 });
94 });87 });
9588
96#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
97 server.override_the_display_buffer_compositor_factory([]89 server.override_the_display_buffer_compositor_factory([]
98 {90 {
99 return std::make_shared<mtf::HeadlessDisplayBufferCompositorFactory>();91 return std::make_shared<mtf::HeadlessDisplayBufferCompositorFactory>();
100 });92 });
101#endif
10293
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)
104 -> std::shared_ptr<msh::WindowManager>95 -> std::shared_ptr<msh::WindowManager>
105 {96 {
106 auto const display_layout = server.the_shell_display_layout();97 auto const display_layout = server.the_shell_display_layout();
10798
108#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
109 auto const persistent_surface_store = server.the_persistent_surface_store();99 auto const persistent_surface_store = server.the_persistent_surface_store();
110#else
111 std::shared_ptr<mir::shell::PersistentSurfaceStore> const persistent_surface_store;
112#endif
113100
114 auto builder = [this](WindowManagerTools const& tools) -> std::unique_ptr<miral::WindowManagementPolicy>101 auto builder = [this](WindowManagerTools const& tools) -> std::unique_ptr<miral::WindowManagementPolicy>
115 {102 {
116103
=== modified file 'test/test_server.h'
--- test/test_server.h 2017-02-14 17:11:07 +0000
+++ test/test_server.h 2017-06-20 16:14:05 +0000
@@ -69,7 +69,6 @@
6969
70private:70private:
71 WindowManagerTools tools{nullptr};71 WindowManagerTools tools{nullptr};
72 WindowManagementPolicy* policy{nullptr};
73 std::weak_ptr<mir::shell::WindowManager> window_manager;72 std::weak_ptr<mir::shell::WindowManager> window_manager;
74 mir::test::AutoJoinThread server_thread;73 mir::test::AutoJoinThread server_thread;
75 std::mutex mutex;74 std::mutex mutex;
7675
=== modified file 'test/window_id.cpp'
--- test/window_id.cpp 2017-03-03 12:31:47 +0000
+++ test/window_id.cpp 2017-06-20 16:14:05 +0000
@@ -42,14 +42,13 @@
42 }42 }
43};43};
4444
45#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 24, 0)
46TEST_F(WindowId, server_can_identify_window_specified_by_client)45TEST_F(WindowId, server_can_identify_window_specified_by_client)
47{46{
48 char const* const test_name = __PRETTY_FUNCTION__;47 char const* const test_name = __PRETTY_FUNCTION__;
49 using namespace mir::client;48 using namespace mir::client;
5049
51 auto const connection = connect_client(test_name);50 auto const connection = connect_client(test_name);
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)
53 .set_name(test_name);52 .set_name(test_name);
5453
55 Window const surface{spec.create_window()};54 Window const surface{spec.create_window()};
@@ -71,7 +70,7 @@
71 using namespace mir::client;70 using namespace mir::client;
7271
73 auto const connection = connect_client(test_name);72 auto const connection = connect_client(test_name);
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)
75 .set_name(test_name);74 .set_name(test_name);
7675
77 Window const surface{spec.create_window()};76 Window const surface{spec.create_window()};
@@ -86,46 +85,6 @@
86 ASSERT_THAT(client_surface_id.c_str(), Eq(id));85 ASSERT_THAT(client_surface_id.c_str(), Eq(id));
87 });86 });
88}87}
89#else
90TEST_F(WindowId, server_fails_gracefully_to_identify_window_specified_by_client)
91{
92 char const* const test_name = __PRETTY_FUNCTION__;
93 using namespace mir::client;
94
95 auto const connection = connect_client(test_name);
96 auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888)
97 .set_name(test_name);
98
99 Window const surface{spec.create_window()};
100
101 mir::client::WindowId client_surface_id{surface};
102
103 invoke_tools([&](miral::WindowManagerTools& tools)
104 {
105 EXPECT_THROW(tools.info_for_window_id(client_surface_id.c_str()), std::runtime_error);
106 });
107}
108
109TEST_F(WindowId, server_fails_gracefully_to_return_id_for_window)
110{
111 char const* const test_name = __PRETTY_FUNCTION__;
112 using namespace mir::client;
113
114 auto const connection = connect_client(test_name);
115 auto const spec = WindowSpec::for_normal_window(connection, 50, 50, mir_pixel_format_argb_8888)
116 .set_name(test_name);
117
118 Window const surface{spec.create_window()};
119
120 mir::client::WindowId client_surface_id{surface};
121
122 invoke_tools([&](miral::WindowManagerTools& tools)
123 {
124 auto window = get_first_window(tools);
125 EXPECT_THROW(tools.id_for_window(window), std::runtime_error);
126 });
127}
128#endif
12988
130TEST_F(WindowId, server_fails_gracefully_to_identify_window_from_garbage_id)89TEST_F(WindowId, server_fails_gracefully_to_identify_window_from_garbage_id)
131{90{
@@ -133,8 +92,7 @@
133 using namespace mir::client;92 using namespace mir::client;
13493
135 auto const connection = connect_client(test_name);94 auto const connection = connect_client(test_name);
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);
137 .set_name(test_name);
13896
139 Window const surface{spec.create_window()};97 Window const surface{spec.create_window()};
14098
14199
=== modified file 'test/window_placement_client_api.cpp'
--- test/window_placement_client_api.cpp 2017-02-14 11:49:59 +0000
+++ test/window_placement_client_api.cpp 2017-06-20 16:14:05 +0000
@@ -16,19 +16,8 @@
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */17 */
1818
19#include <mir/version.h>
20#include <mir_toolkit/version.h>
21
22#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
23#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0)
24#include <mir_toolkit/events/surface_placement.h>
25auto const mir_event_get_window_placement_event = mir_event_get_surface_placement_event;
26#else
27#include <mir_toolkit/events/window_placement.h>19#include <mir_toolkit/events/window_placement.h>
28#endif
29#endif
3020
31#include <mir/client/detail/mir_forward_compatibility.h>
32#include <mir/client/window_spec.h>21#include <mir/client/window_spec.h>
33#include <mir/client/window.h>22#include <mir/client/window.h>
3423
@@ -57,7 +46,7 @@
57 char const* const test_name = __PRETTY_FUNCTION__;46 char const* const test_name = __PRETTY_FUNCTION__;
5847
59 connection = connect_client(test_name);48 connection = connect_client(test_name);
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)
61 .set_name(test_name);50 .set_name(test_name);
6251
63 parent = spec.create_window();52 parent = spec.create_window();
@@ -78,12 +67,6 @@
78};67};
79}68}
8069
81#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
82
83#if MIR_CLIENT_VERSION == MIR_VERSION_NUMBER(3, 4, 0)
84auto const mir_event_type_window_placement = mir_event_type_surface_placement;
85#endif
86
87namespace70namespace
88{71{
89struct CheckPlacement72struct CheckPlacement
@@ -137,7 +120,7 @@
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};
138121
139 auto const spec = WindowSpec::122 auto const spec = WindowSpec::
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)
141 .set_event_handler(&CheckPlacement::callback, &expected)124 .set_event_handler(&CheckPlacement::callback, &expected)
142 .set_name(test_name);125 .set_name(test_name);
143126
@@ -156,4 +139,3 @@
156 spec.apply_to(child);139 spec.apply_to(child);
157 }140 }
158}141}
159#endif
160142
=== modified file 'test/window_properties.cpp'
--- test/window_properties.cpp 2017-02-21 15:49:58 +0000
+++ test/window_properties.cpp 2017-06-20 16:14:05 +0000
@@ -18,6 +18,7 @@
1818
19#include <miral/window_manager_tools.h>19#include <miral/window_manager_tools.h>
2020
21#include <mir/client/surface.h>
21#include <mir/client/window.h>22#include <mir/client/window.h>
22#include <mir/client/window_spec.h>23#include <mir/client/window_spec.h>
23#include <mir_toolkit/mir_buffer_stream.h>24#include <mir_toolkit/mir_buffer_stream.h>
@@ -45,18 +46,27 @@
45 {46 {
46 miral::TestServer::SetUp();47 miral::TestServer::SetUp();
47 client_connection = connect_client("WindowProperties");48 client_connection = connect_client("WindowProperties");
49 surface = Surface{mir_connection_create_render_surface_sync(client_connection, 40, 40)};
48 }50 }
4951
50 void TearDown() override52 void TearDown() override
51 {53 {
54 surface.reset();
52 client_connection.reset();55 client_connection.reset();
53 miral::TestServer::TearDown();56 miral::TestServer::TearDown();
54 }57 }
5558
56 Connection client_connection;59 Connection client_connection;
60 Surface surface;
5761
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;
5963
64 void paint(Surface const& surface)
65 {
66 mir_buffer_stream_swap_buffers_sync(
67 mir_render_surface_get_buffer_stream(surface, 50, 50, mir_pixel_format_argb_8888));
68 }
69
60 mir::test::Signal window_ready;70 mir::test::Signal window_ready;
61};71};
6272
@@ -80,12 +90,12 @@
8090
81TEST_F(WindowProperties, on_creation_default_shell_chrome_is_normal)91TEST_F(WindowProperties, on_creation_default_shell_chrome_is_normal)
82{92{
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)
84 .set_buffer_usage(mir_buffer_usage_software)
85 .set_name(a_window.c_str())94 .set_name(a_window.c_str())
95 .add_surface(surface, 50, 50, 0, 0)
86 .create_window();96 .create_window();
8797
88 mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window));98 paint(surface);
89 ASSERT_TRUE(window_ready.wait_for(400ms));99 ASSERT_TRUE(window_ready.wait_for(400ms));
90100
91 invoke_tools([&, this](WindowManagerTools& tools)101 invoke_tools([&, this](WindowManagerTools& tools)
@@ -96,13 +106,13 @@
96106
97TEST_F(WindowProperties, on_creation_client_setting_shell_chrome_low_is_seen_by_window_manager)107TEST_F(WindowProperties, on_creation_client_setting_shell_chrome_low_is_seen_by_window_manager)
98{108{
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)
100 .set_buffer_usage(mir_buffer_usage_software)
101 .set_name(a_window.c_str())110 .set_name(a_window.c_str())
102 .set_shell_chrome(mir_shell_chrome_low)111 .set_shell_chrome(mir_shell_chrome_low)
112 .add_surface(surface, 50, 50, 0, 0)
103 .create_window();113 .create_window();
104114
105 mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window));115 paint(surface);
106 ASSERT_TRUE(window_ready.wait_for(400ms));116 ASSERT_TRUE(window_ready.wait_for(400ms));
107117
108 invoke_tools([&, this](WindowManagerTools& tools)118 invoke_tools([&, this](WindowManagerTools& tools)
@@ -113,16 +123,17 @@
113123
114TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_low_is_seen_by_window_manager)124TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_low_is_seen_by_window_manager)
115{125{
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)
117 .set_buffer_usage(mir_buffer_usage_software)
118 .set_name(a_window.c_str())127 .set_name(a_window.c_str())
128 .add_surface(surface, 50, 50, 0, 0)
119 .create_window();129 .create_window();
120130
121 WindowSpec::for_changes(client_connection)131 WindowSpec::for_changes(client_connection)
122 .set_shell_chrome(mir_shell_chrome_low)132 .set_shell_chrome(mir_shell_chrome_low)
123 .apply_to(window);133 .apply_to(window);
124134
125 mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window));135 paint(surface);
136
126 ASSERT_TRUE(window_ready.wait_for(400ms));137 ASSERT_TRUE(window_ready.wait_for(400ms));
127138
128 invoke_tools([&, this](WindowManagerTools& tools)139 invoke_tools([&, this](WindowManagerTools& tools)
@@ -133,17 +144,17 @@
133144
134TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_normal_is_seen_by_window_manager)145TEST_F(WindowProperties, after_creation_client_setting_shell_chrome_normal_is_seen_by_window_manager)
135{146{
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)
137 .set_buffer_usage(mir_buffer_usage_software)
138 .set_name(a_window.c_str())148 .set_name(a_window.c_str())
139 .set_shell_chrome(mir_shell_chrome_low)149 .set_shell_chrome(mir_shell_chrome_low)
150 .add_surface(surface, 50, 50, 0, 0)
140 .create_window();151 .create_window();
141152
142 WindowSpec::for_changes(client_connection)153 WindowSpec::for_changes(client_connection)
143 .set_shell_chrome(mir_shell_chrome_normal)154 .set_shell_chrome(mir_shell_chrome_normal)
144 .apply_to(window);155 .apply_to(window);
145156
146 mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window));157 paint(surface);
147 ASSERT_TRUE(window_ready.wait_for(400ms));158 ASSERT_TRUE(window_ready.wait_for(400ms));
148159
149 invoke_tools([&, this](WindowManagerTools& tools)160 invoke_tools([&, this](WindowManagerTools& tools)
150161
=== modified file 'test/workspaces.cpp'
--- test/workspaces.cpp 2017-03-30 09:42:17 +0000
+++ test/workspaces.cpp 2017-06-20 16:14:05 +0000
@@ -19,6 +19,7 @@
19#include <miral/workspace_policy.h>19#include <miral/workspace_policy.h>
20#include <miral/window_manager_tools.h>20#include <miral/window_manager_tools.h>
2121
22#include <mir/client/surface.h>
22#include <mir/client/window.h>23#include <mir/client/window.h>
23#include <mir/client/window_spec.h>24#include <mir/client/window_spec.h>
24#include <mir_toolkit/mir_buffer_stream.h>25#include <mir_toolkit/mir_buffer_stream.h>
@@ -65,57 +66,74 @@
65 Workspaces& test_fixture;66 Workspaces& test_fixture;
66};67};
6768
69struct TestWindow : Surface, Window
70{
71 using Surface::operator=;
72 using Window::operator=;
73};
74
68struct Workspaces : public miral::TestServer75struct Workspaces : public miral::TestServer
69{76{
70 auto create_window(std::string const& name) -> Window77 auto create_window(std::string const& name) -> TestWindow
71 {78 {
72 auto const window = WindowSpec::for_normal_window(client_connection, 50, 50, mir_pixel_format_argb_8888)79 TestWindow result;
73 .set_buffer_usage(mir_buffer_usage_software)80
81 result = Surface{mir_connection_create_render_surface_sync(client_connection, 50, 50)};
82 result = WindowSpec::for_normal_window(client_connection, 50, 50)
74 .set_name(name.c_str())83 .set_name(name.c_str())
84 .add_surface(result, 50, 50, 0, 0)
75 .create_window();85 .create_window();
7686
77 client_windows[name] = window;87 client_windows[name] = result;
78 init_window(window);88 init_window(result);
7989
80 return window;90 return result;
81 }91 }
8292
83 void init_window(Window const& window)93 void init_window(TestWindow const& window)
84 {94 {
85 mir::test::Signal window_ready;95 mir::test::Signal window_ready;
86 EXPECT_CALL(policy(), advise_window_ready(_)).WillOnce(InvokeWithoutArgs([&]{ window_ready.raise(); }));96 EXPECT_CALL(policy(), advise_window_ready(_)).WillOnce(InvokeWithoutArgs([&]{ window_ready.raise(); }));
8797
88 mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window));98 mir_buffer_stream_swap_buffers_sync(
99 mir_render_surface_get_buffer_stream(window, 50, 50, mir_pixel_format_argb_8888));
89100
90 EXPECT_TRUE(window_ready.wait_for(1s));101 EXPECT_TRUE(window_ready.wait_for(1s));
91 }102 }
92103
93 auto create_tip(std::string const& name, Window const& parent) -> Window104 auto create_tip(std::string const& name, Window const& parent) -> TestWindow
94 {105 {
106 TestWindow result;
107
108 result = Surface{mir_connection_create_render_surface_sync(client_connection, 50, 50)};
109
95 MirRectangle aux_rect{10, 10, 10, 10};110 MirRectangle aux_rect{10, 10, 10, 10};
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)
97 &aux_rect, mir_edge_attachment_any)
98 .set_buffer_usage(mir_buffer_usage_software)
99 .set_name(name.c_str())112 .set_name(name.c_str())
113 .add_surface(result, 50, 50, 0, 0)
100 .create_window();114 .create_window();
101115
102 client_windows[name] = window;116 client_windows[name] = result;
103 init_window(window);117 init_window(result);
104118
105 return window;119 return result;
106 }120 }
107121
108 auto create_dialog(std::string const& name, Window const& parent) -> Window122 auto create_dialog(std::string const& name, Window const& parent) -> TestWindow
109 {123 {
110 auto const window = WindowSpec::for_dialog(client_connection, 50, 50, mir_pixel_format_argb_8888, parent)124 TestWindow result;
111 .set_buffer_usage(mir_buffer_usage_software)125
126 result = Surface{mir_connection_create_render_surface_sync(client_connection, 50, 50)};
127
128 result = WindowSpec::for_dialog(client_connection, 50, 50, parent)
112 .set_name(name.c_str())129 .set_name(name.c_str())
130 .add_surface(result, 50, 50, 0, 0)
113 .create_window();131 .create_window();
114132
115 client_windows[name] = window;133 client_windows[name] = result;
116 init_window(window);134 init_window(result);
117135
118 return window;136 return result;
119 }137 }
120138
121 auto create_workspace() -> std::shared_ptr<miral::Workspace>139 auto create_workspace() -> std::shared_ptr<miral::Workspace>
@@ -202,7 +220,7 @@
202220
203private:221private:
204 std::mutex mutable mutex;222 std::mutex mutable mutex;
205 std::map<std::string, Window> client_windows;223 std::map<std::string, TestWindow> client_windows;
206 std::map<std::string, miral::Window> server_windows;224 std::map<std::string, miral::Window> server_windows;
207 WorkspacesWindowManagerPolicy* the_policy{nullptr};225 WorkspacesWindowManagerPolicy* the_policy{nullptr};
208226
@@ -466,9 +484,11 @@
466484
467 {485 {
468 auto const another_app = connect_client("another app");486 auto const another_app = connect_client("another app");
469 auto const window = WindowSpec::for_normal_window(another_app, 50, 50, mir_pixel_format_argb_8888)487 TestWindow window;
470 .set_buffer_usage(mir_buffer_usage_software)488 window = Surface{mir_connection_create_render_surface_sync(another_app, 50, 50)};
489 window = WindowSpec::for_normal_window(another_app, 50, 50)
471 .set_name(a_window.c_str())490 .set_name(a_window.c_str())
491 .add_surface(window, 50, 50, 0, 0)
472 .create_window();492 .create_window();
473493
474 init_window(window);494 init_window(window);
@@ -527,9 +547,11 @@
527 create_window(another_window);547 create_window(another_window);
528548
529 auto const another_app = connect_client("another app");549 auto const another_app = connect_client("another app");
530 auto const window = WindowSpec::for_normal_window(another_app, 50, 50, mir_pixel_format_argb_8888)550 TestWindow window;
531 .set_buffer_usage(mir_buffer_usage_software)551 window = Surface{mir_connection_create_render_surface_sync(another_app, 50, 50)};
552 window = WindowSpec::for_normal_window(another_app, 50, 50)
532 .set_name(a_window.c_str())553 .set_name(a_window.c_str())
554 .add_surface(window, 50, 50, 0, 0)
533 .create_window();555 .create_window();
534556
535 init_window(window);557 init_window(window);
@@ -590,9 +612,11 @@
590 create_window(another_window);612 create_window(another_window);
591613
592 auto const another_app = connect_client("another app");614 auto const another_app = connect_client("another app");
593 auto const window = WindowSpec::for_normal_window(another_app, 50, 50, mir_pixel_format_argb_8888)615 TestWindow window;
594 .set_buffer_usage(mir_buffer_usage_software)616 window = Surface{mir_connection_create_render_surface_sync(another_app, 50, 50)};
617 window = WindowSpec::for_normal_window(another_app, 50, 50)
595 .set_name(a_window.c_str())618 .set_name(a_window.c_str())
619 .add_surface(window, 50, 50, 0, 0)
596 .create_window();620 .create_window();
597621
598 init_window(window);622 init_window(window);

Subscribers

People subscribed via source and target branches