Merge lp:~unity-team/qtmir/miral-qt-integration into lp:qtmir
- miral-qt-integration
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Gerry Boland |
Approved revision: | 587 |
Merged at revision: | 577 |
Proposed branch: | lp:~unity-team/qtmir/miral-qt-integration |
Merge into: | lp:qtmir |
Diff against target: |
12804 lines (+5168/-3676) 139 files modified
CMakeLists.txt (+7/-4) debian/changelog (+6/-0) debian/control (+8/-4) debian/gles-patches/convert-to-gles.patch (+1/-1) demos/paths.h.in (+19/-1) demos/qml-demo-shell/CMakeLists.txt (+1/-0) demos/qml-demo-shell/WindowModelDebugView.qml (+72/-0) demos/qml-demo-shell/main.cpp (+10/-6) demos/qml-demo-shell/pointerposition.cpp (+56/-0) demos/qml-demo-shell/pointerposition.h (+49/-0) demos/qml-demo-shell/windowModel.qml (+136/-0) src/common/appnotifier.h (+39/-0) src/common/debughelpers.cpp (+50/-16) src/common/debughelpers.h (+2/-0) src/common/mirqtconversion.h (+118/-0) src/common/windowcontrollerinterface.h (+58/-0) src/common/windowmodelnotifier.h (+95/-0) src/modules/Unity/Application/CMakeLists.txt (+4/-3) src/modules/Unity/Application/application.cpp (+7/-6) src/modules/Unity/Application/application.h (+1/-8) src/modules/Unity/Application/application_manager.cpp (+40/-75) src/modules/Unity/Application/application_manager.h (+7/-9) src/modules/Unity/Application/dbusfocusinfo.cpp (+12/-18) src/modules/Unity/Application/dbusfocusinfo.h (+0/-1) src/modules/Unity/Application/mirfocuscontroller.cpp (+0/-69) src/modules/Unity/Application/mirfocuscontroller.h (+0/-49) src/modules/Unity/Application/mirsurface.cpp (+476/-248) src/modules/Unity/Application/mirsurface.h (+61/-51) src/modules/Unity/Application/mirsurfaceinterface.h (+6/-12) src/modules/Unity/Application/mirsurfaceitem.cpp (+4/-33) src/modules/Unity/Application/mirsurfaceitem.h (+1/-5) src/modules/Unity/Application/mirsurfacelistmodel.cpp (+10/-4) src/modules/Unity/Application/mirsurfacemanager.cpp (+0/-188) src/modules/Unity/Application/mirsurfacemanager.h (+0/-99) src/modules/Unity/Application/plugin.cpp (+6/-18) src/modules/Unity/Application/session.cpp (+42/-28) src/modules/Unity/Application/session.h (+11/-12) src/modules/Unity/Application/session_interface.h (+8/-6) src/modules/Unity/Application/sessionmanager.cpp (+24/-37) src/modules/Unity/Application/sessionmanager.h (+11/-8) src/modules/Unity/Application/surfacemanager.cpp (+174/-0) src/modules/Unity/Application/surfacemanager.h (+73/-0) src/modules/Unity/Application/windowmodel.cpp (+235/-0) src/modules/Unity/Application/windowmodel.h (+83/-0) src/modules/Unity/Screens/CMakeLists.txt (+1/-1) src/modules/Unity/Screens/plugin.cpp (+1/-1) src/modules/Unity/Screens/qquickscreenwindow.cpp (+6/-6) src/modules/Unity/Screens/qquickscreenwindow.h (+6/-6) src/modules/Unity/Screens/screens.cpp (+1/-1) src/modules/Unity/Screens/screens.h (+2/-29) src/platforms/mirserver/CMakeLists.txt (+39/-25) src/platforms/mirserver/creationhints.cpp (+0/-67) src/platforms/mirserver/creationhints.h (+0/-56) src/platforms/mirserver/cursor.cpp (+1/-1) src/platforms/mirserver/customscreenconfiguration.h (+4/-2) src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp (+26/-1) src/platforms/mirserver/mirdisplayconfigurationpolicy.h (+6/-14) src/platforms/mirserver/miropenglcontext.cpp (+1/-0) src/platforms/mirserver/mirserver.cpp (+0/-234) src/platforms/mirserver/mirserver.h (+0/-71) src/platforms/mirserver/mirserverhooks.cpp (+184/-0) src/platforms/mirserver/mirserverhooks.h (+54/-0) src/platforms/mirserver/mirserverintegration.cpp (+2/-2) src/platforms/mirserver/mirserverstatuslistener.h (+1/-0) src/platforms/mirserver/mirsingleton.cpp (+1/-0) src/platforms/mirserver/mirwindowmanager.cpp (+0/-227) src/platforms/mirserver/mirwindowmanager.h (+0/-49) src/platforms/mirserver/nativeinterface.cpp (+1/-5) src/platforms/mirserver/nativeinterface.h (+2/-2) src/platforms/mirserver/offscreensurface.cpp (+0/-7) src/platforms/mirserver/openglcontextfactory.cpp (+51/-0) src/platforms/mirserver/openglcontextfactory.h (+47/-0) src/platforms/mirserver/promptsession.h (+62/-0) src/platforms/mirserver/promptsessionlistener.cpp (+2/-45) src/platforms/mirserver/promptsessionlistener.h (+19/-21) src/platforms/mirserver/promptsessionmanager.cpp (+47/-0) src/platforms/mirserver/promptsessionmanager.h (+49/-0) src/platforms/mirserver/qmirserver.cpp (+25/-52) src/platforms/mirserver/qmirserver.h (+4/-7) src/platforms/mirserver/qmirserver_p.cpp (+117/-25) src/platforms/mirserver/qmirserver_p.h (+56/-10) src/platforms/mirserver/qteventfeeder.cpp (+47/-23) src/platforms/mirserver/qteventfeeder.h (+6/-12) src/platforms/mirserver/screen.cpp (+26/-27) src/platforms/mirserver/screen.h (+9/-14) src/platforms/mirserver/screenscontroller.cpp (+1/-0) src/platforms/mirserver/screenscontroller.h (+4/-1) src/platforms/mirserver/screensmodel.cpp (+11/-5) src/platforms/mirserver/screensmodel.h (+8/-4) src/platforms/mirserver/screentypes.h (+60/-0) src/platforms/mirserver/sessionauthorizer.cpp (+5/-10) src/platforms/mirserver/sessionauthorizer.h (+7/-7) src/platforms/mirserver/sessionlistener.cpp (+0/-96) src/platforms/mirserver/sessionlistener.h (+0/-63) src/platforms/mirserver/setqtcompositor.cpp (+55/-0) src/platforms/mirserver/setqtcompositor.h (+47/-0) src/platforms/mirserver/surfaceobserver.cpp (+36/-177) src/platforms/mirserver/surfaceobserver.h (+9/-41) src/platforms/mirserver/windowcontroller.cpp (+103/-0) src/platforms/mirserver/windowcontroller.h (+54/-0) src/platforms/mirserver/windowmanagementpolicy.cpp (+335/-0) src/platforms/mirserver/windowmanagementpolicy.h (+96/-0) tests/framework/CMakeLists.txt (+2/-0) tests/framework/fake_displayconfigurationoutput.h (+1/-0) tests/framework/fake_mirsurface.cpp (+31/-10) tests/framework/fake_mirsurface.h (+18/-23) tests/framework/fake_session.cpp (+7/-5) tests/framework/fake_session.h (+5/-4) tests/framework/fake_surface.h (+2/-0) tests/framework/mock_mir_session.h (+9/-4) tests/framework/mock_session.h (+5/-4) tests/framework/mock_surface.h (+1/-0) tests/framework/qtmir_test.cpp (+28/-4) tests/framework/qtmir_test.h (+8/-5) tests/framework/stub_scene_surface.h (+108/-0) tests/framework/stub_windowcontroller.h (+44/-0) tests/mirserver/CMakeLists.txt (+0/-1) tests/mirserver/Screen/screen_test.cpp (+2/-2) tests/mirserver/ScreensModel/screensmodel_test.cpp (+3/-1) tests/mirserver/ScreensModel/stub_display.h (+10/-0) tests/mirserver/ScreensModel/testable_screensmodel.h (+3/-2) tests/mirserver/WindowManager/CMakeLists.txt (+0/-27) tests/mirserver/WindowManager/stub_session.cpp (+0/-147) tests/mirserver/WindowManager/stub_session.h (+0/-64) tests/mirserver/WindowManager/stub_surface.cpp (+0/-212) tests/mirserver/WindowManager/stub_surface.h (+0/-71) tests/mirserver/WindowManager/window_manager.cpp (+0/-332) tests/modules/Application/CMakeLists.txt (+1/-0) tests/modules/Application/application_test.cpp (+10/-10) tests/modules/ApplicationManager/CMakeLists.txt (+1/-0) tests/modules/ApplicationManager/application_manager_test.cpp (+202/-192) tests/modules/CMakeLists.txt (+1/-1) tests/modules/SessionManager/CMakeLists.txt (+1/-0) tests/modules/SessionManager/session_manager_test.cpp (+24/-16) tests/modules/SessionManager/session_test.cpp (+14/-13) tests/modules/WindowManager/CMakeLists.txt (+12/-6) tests/modules/WindowManager/mirsurface_test.cpp (+67/-52) tests/modules/WindowManager/mirsurfaceitem_test.cpp (+2/-2) tests/modules/WindowManager/windowmodel_test.cpp (+786/-0) |
To merge this branch: | bzr merge lp:~unity-team/qtmir/miral-qt-integration |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity8 CI Bot (community) | continuous-integration | Approve | |
Gerry Boland (community) | code | Approve | |
Review via email: mp+312244@code.launchpad.net |
This proposal supersedes a proposal from 2016-11-03.
Commit message
Depend on MirAL
Import code from lp:miral/miral-qt (revision 435) where we had a fork of qtmir and were rewriting it to use MirAL's APIs
Description of the change
Prereq-archive: ppa:ci-
Needed:
https:/
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:572
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:573
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:574
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:575
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:576
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:577
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:578
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:579
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:580
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:581
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:582
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:583
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:584
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:584
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 585. By Daniel d'Andrada
-
Fix order of entries in debian/changelog
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:585
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Gerry Boland (gerboland) wrote : | # |
+++ src/common/
missing licence header
- 586. By Daniel d'Andrada
-
Add missing license header
Daniel d'Andrada (dandrader) wrote : | # |
On 05/12/2016 12:59, Gerry Boland wrote:
> Review: Needs Fixing
>
> +++ src/common/
> missing licence header
Fixed
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:586
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 587. By Daniel d'Andrada
-
findApplication
WithSurface is const
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:587
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Gerry Boland (gerboland) : | # |
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:587
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 588. By Daniel d'Andrada
-
Mir 0.25 compat (merging upcoming trunk)
- 589. By Daniel d'Andrada
-
Bump dependency version of other mir packages
- 590. By Daniel d'Andrada
-
Fix bad merge
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2016-12-03 12:37:37 +0000 |
3 | +++ CMakeLists.txt 2016-12-16 08:22:54 +0000 |
4 | @@ -3,7 +3,7 @@ |
5 | project(qtmir) |
6 | |
7 | set(QTMIR_VERSION_MAJOR 0) |
8 | -set(QTMIR_VERSION_MINOR 1) |
9 | +set(QTMIR_VERSION_MINOR 2) |
10 | set(QTMIR_VERSION_PATCH 0) |
11 | |
12 | if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
13 | @@ -30,6 +30,10 @@ |
14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wall -fno-strict-aliasing -Werror -Wextra") |
15 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") |
16 | |
17 | +if ("${CMAKE_CXX_COMPILER}" MATCHES "clang") |
18 | + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-mismatched-tags -Wno-inconsistent-missing-override -Wno-implicit-exception-spec-mismatch -Wno-unknown-pragmas") |
19 | +endif() |
20 | + |
21 | |
22 | include(EnableCoverageReport) |
23 | ##################################################################### |
24 | @@ -70,6 +74,7 @@ |
25 | pkg_check_modules(MIRSERVER mirserver>=0.25 REQUIRED) |
26 | pkg_check_modules(MIRCLIENT mirclient>=0.25 REQUIRED) |
27 | pkg_check_modules(MIRRENDERERGLDEV mir-renderer-gl-dev>=0.24 REQUIRED) |
28 | +pkg_check_modules(MIRAL miral>=0.4 REQUIRED) |
29 | |
30 | pkg_check_modules(XKBCOMMON xkbcommon REQUIRED) |
31 | pkg_check_modules(GLIB glib-2.0 REQUIRED) |
32 | @@ -83,15 +88,13 @@ |
33 | pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt) |
34 | pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED) |
35 | pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED) |
36 | -pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=22) |
37 | +pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=23) |
38 | pkg_check_modules(CGMANAGER libcgmanager REQUIRED) |
39 | pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED) |
40 | |
41 | include_directories(SYSTEM ${APPLICATION_API_INCLUDE_DIRS}) |
42 | |
43 | |
44 | -add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1) |
45 | - |
46 | # Use the fast string builder |
47 | add_definitions(-DQT_USE_QSTRINGBUILDER) |
48 | |
49 | |
50 | === modified file 'debian/changelog' |
51 | --- debian/changelog 2016-12-03 12:38:04 +0000 |
52 | +++ debian/changelog 2016-12-16 08:22:54 +0000 |
53 | @@ -1,3 +1,9 @@ |
54 | +qtmir (0.5.1) UNRELEASED; urgency=medium |
55 | + |
56 | + * First release using MirAL |
57 | + |
58 | + -- Gerry Boland <gerry.boland@canonical.com> Fri, 14 Oct 2016 16:51:26 +0100 |
59 | + |
60 | qtmir (0.5.0+17.04.20161203-0ubuntu1) zesty; urgency=medium |
61 | |
62 | * Mir 0.25 compat |
63 | |
64 | === modified file 'debian/control' |
65 | --- debian/control 2016-11-16 17:49:19 +0000 |
66 | +++ debian/control 2016-12-16 08:22:54 +0000 |
67 | @@ -13,6 +13,7 @@ |
68 | libglib2.0-dev, |
69 | libgsettings-qt-dev, |
70 | liblttng-ust-dev, |
71 | + libmiral-dev (>= 0.4), |
72 | libmirclient-dev (>= 0.25.0), |
73 | libmircommon-dev (>= 0.25.0), |
74 | libmirserver-dev (>= 0.25.0), |
75 | @@ -24,12 +25,12 @@ |
76 | libubuntu-app-launch2-dev (>= 0.9), |
77 | libubuntu-application-api-dev (>= 2.1.0), |
78 | libudev-dev, |
79 | - libunity-api-dev (>= 7.119), |
80 | + libunity-api-dev (>= 8.0), |
81 | liburl-dispatcher1-dev, |
82 | libxkbcommon-dev, |
83 | libxrender-dev, |
84 | - mir-renderer-gl-dev (>= 0.24.0), |
85 | - mirtest-dev (>= 0.24.0), |
86 | + mir-renderer-gl-dev (>= 0.25.0), |
87 | + mirtest-dev (>= 0.25.0), |
88 | pkg-config, |
89 | # lttng-gen-ts needs python3, but doesn't depend on it itself: bug 1359147 |
90 | python3:any, |
91 | @@ -41,6 +42,9 @@ |
92 | quilt, |
93 | # libmirserver-dev should have brought this dep. Bug lp:1617435 |
94 | uuid-dev, |
95 | +# mirtest pkgconfig requires these, but doesn't have a deb dependency. Bug lp:1633537 |
96 | + libboost-filesystem-dev, |
97 | + libboost-system-dev, |
98 | Standards-Version: 3.9.5 |
99 | Homepage: https://launchpad.net/qtmir |
100 | # if you don't have have commit access to this branch but would like to upload |
101 | @@ -98,7 +102,7 @@ |
102 | Conflicts: libqtmir, |
103 | libunity-mir1, |
104 | Provides: unity-application-impl, |
105 | - unity-application-impl-22, |
106 | + unity-application-impl-23, |
107 | Description: Qt plugin for Unity specific Mir APIs |
108 | QtMir provides Qt/QML bindings for Mir features that are exposed through the |
109 | qtmir-desktop or qtmir-android QPA plugin such as Application management |
110 | |
111 | === modified file 'debian/gles-patches/convert-to-gles.patch' |
112 | --- debian/gles-patches/convert-to-gles.patch 2016-11-23 19:46:24 +0000 |
113 | +++ debian/gles-patches/convert-to-gles.patch 2016-12-16 08:22:54 +0000 |
114 | @@ -84,7 +84,7 @@ |
115 | -Conflicts: libqtmir, |
116 | - libunity-mir1, |
117 | -Provides: unity-application-impl, |
118 | -- unity-application-impl-22, |
119 | +- unity-application-impl-23, |
120 | -Description: Qt plugin for Unity specific Mir APIs |
121 | - QtMir provides Qt/QML bindings for Mir features that are exposed through the |
122 | - qtmir-desktop or qtmir-android QPA plugin such as Application management |
123 | |
124 | === modified file 'demos/paths.h.in' |
125 | --- demos/paths.h.in 2015-09-01 16:16:47 +0000 |
126 | +++ demos/paths.h.in 2016-12-16 08:22:54 +0000 |
127 | @@ -37,4 +37,22 @@ |
128 | return QString("@CMAKE_SOURCE_DIR@/demos/"); |
129 | } |
130 | } |
131 | -#endif |
132 | \ No newline at end of file |
133 | + |
134 | +inline QString qmlPluginDirectory() { |
135 | + if (isRunningInstalled()) { |
136 | + return QString("@QML_MODULE_INSTALL_DIR@/"); |
137 | + } else { |
138 | + return QString("@CMAKE_BINARY_DIR@/src/modules/"); |
139 | + } |
140 | +} |
141 | + |
142 | +inline QString qpaPluginDirectory() { |
143 | + if (isRunningInstalled()) { |
144 | + return QString("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/qt5/plugins/platforms/"); |
145 | + } else { |
146 | + return QString("@CMAKE_BINARY_DIR@/src/platforms/mirserver/"); |
147 | + } |
148 | +} |
149 | + |
150 | +#endif |
151 | + |
152 | |
153 | === modified file 'demos/qml-demo-shell/CMakeLists.txt' |
154 | --- demos/qml-demo-shell/CMakeLists.txt 2016-06-06 18:12:07 +0000 |
155 | +++ demos/qml-demo-shell/CMakeLists.txt 2016-12-16 08:22:54 +0000 |
156 | @@ -8,6 +8,7 @@ |
157 | ) |
158 | |
159 | add_executable(${DEMO_SHELL} |
160 | + pointerposition.cpp |
161 | main.cpp |
162 | ) |
163 | |
164 | |
165 | === added file 'demos/qml-demo-shell/WindowModelDebugView.qml' |
166 | --- demos/qml-demo-shell/WindowModelDebugView.qml 1970-01-01 00:00:00 +0000 |
167 | +++ demos/qml-demo-shell/WindowModelDebugView.qml 2016-12-16 08:22:54 +0000 |
168 | @@ -0,0 +1,72 @@ |
169 | +import QtQuick 2.0 |
170 | +import Unity.Application 0.1 |
171 | + |
172 | +Column { |
173 | + id: root |
174 | + width: childrenRect.width |
175 | + height: childrenRect.height |
176 | + focus: false |
177 | + |
178 | + property alias model: repeater.model |
179 | + |
180 | + function stateString(state) { |
181 | + switch(state) { |
182 | + case Mir.HiddenState: return "Hidden" |
183 | + case Mir.RestoredState: return "Restored" |
184 | + case Mir.MinimizedState: return "Minimized" |
185 | + case Mir.MaximizedState: return "Maximized" |
186 | + case Mir.VertMaximizedState: return "VertMax" |
187 | + case Mir.FullscreenState: return "Fullscreen" |
188 | + case Mir.HorizMaximizedState: return "HorizMax" |
189 | + case Mir.UnknownState: return "Unknown" |
190 | + } |
191 | + return "Invalid" |
192 | + } |
193 | + function typeString(type) { |
194 | + switch(type) { |
195 | + case Mir.UnknownType: return "Unknown" |
196 | + case Mir.NormalType: return "Normal" |
197 | + case Mir.UtilityType: return "Utility" |
198 | + case Mir.DialogType: return "Dialog" |
199 | + case Mir.GlossType: return "Gloss" |
200 | + case Mir.FreeStyleType: return "FreeStyle" |
201 | + case Mir.MenuType: return "Menu" |
202 | + case Mir.InputMethodType: return "InputMethod" |
203 | + case Mir.SatelliteType: return "Satellite" |
204 | + case Mir.TipType: return "Tip" |
205 | + } |
206 | + return "Invalid" |
207 | + } |
208 | + |
209 | + function geometryString(surface) { |
210 | + return surface.position.x + "," + surface.position.y + " " + surface.size.width + "x" + surface.size.height |
211 | + } |
212 | + |
213 | + |
214 | + Text { |
215 | + text: "Index\t\Name\tVisible\tState\tType\tGeometry" |
216 | + height: (visible) ? implicitHeight : 0 |
217 | + visible: repeater.count > 0 |
218 | + color: "white" |
219 | + |
220 | + Rectangle { |
221 | + anchors.fill: parent |
222 | + color: "blue" |
223 | + z: -1 |
224 | + } |
225 | + } |
226 | + Repeater { |
227 | + id: repeater |
228 | + delegate: Text { |
229 | + text: index + "\t" + surface.name + "\t" + surface.visible + "\t" |
230 | + + stateString(surface.state) + "\t" + typeString(surface.type) + "\t" + geometryString(surface) |
231 | + font.bold: surface.focused |
232 | + |
233 | + Rectangle { |
234 | + anchors.fill: parent |
235 | + color: (index % 2) ? "white" : "lightblue" |
236 | + z: -1 |
237 | + } |
238 | + } |
239 | + } |
240 | +} |
241 | |
242 | === modified file 'demos/qml-demo-shell/main.cpp' |
243 | --- demos/qml-demo-shell/main.cpp 2015-09-17 11:20:00 +0000 |
244 | +++ demos/qml-demo-shell/main.cpp 2016-12-16 08:22:54 +0000 |
245 | @@ -15,34 +15,38 @@ |
246 | */ |
247 | |
248 | // Qt |
249 | -#include <QCommandLineParser> |
250 | #include <QtQuick/QQuickView> |
251 | #include <QtGui/QGuiApplication> |
252 | #include <QtQml/QQmlEngine> |
253 | #include <QtQml/QQmlContext> |
254 | -#include <QLibrary> |
255 | #include <QDebug> |
256 | -#include <csignal> |
257 | #include <libintl.h> |
258 | #include "../paths.h" |
259 | |
260 | -#include <private/qobject_p.h> |
261 | +#include "pointerposition.h" |
262 | |
263 | // REMOVEME - Should be able to use qmlscene, but in order to use the mir benchmarking we need |
264 | // to parse command line switches. Wait until MIR_SOCKET supported by the benchmark framework. |
265 | |
266 | int main(int argc, const char *argv[]) |
267 | { |
268 | + setenv("QT_QPA_PLATFORM_PLUGIN_PATH", qPrintable(::qpaPluginDirectory()), 1 /* overwrite */); |
269 | + setenv("QT_QPA_PLATFORM", "mirserver", 1 /* overwrite */); |
270 | + |
271 | QGuiApplication::setApplicationName("qml-demo-shell"); |
272 | QGuiApplication *application; |
273 | |
274 | application = new QGuiApplication(argc, (char**)argv); |
275 | QQuickView* view = new QQuickView(); |
276 | + view->engine()->addImportPath(::qmlPluginDirectory()); |
277 | view->setResizeMode(QQuickView::SizeRootObjectToView); |
278 | - view->setColor("black"); |
279 | + view->setColor("lightgray"); |
280 | view->setTitle("Demo Shell"); |
281 | |
282 | - QUrl source(::qmlDirectory() + "qtmir-demo-shell/qml-demo-shell.qml"); |
283 | + qmlRegisterSingletonType<PointerPosition>("Mir.Pointer", 0, 1, "PointerPosition", |
284 | + [](QQmlEngine*, QJSEngine*) -> QObject* { return PointerPosition::instance(); }); |
285 | + |
286 | + QUrl source(::qmlDirectory() + "qml-demo-shell/windowModel.qml"); |
287 | |
288 | view->setSource(source); |
289 | QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit())); |
290 | |
291 | === added file 'demos/qml-demo-shell/pointerposition.cpp' |
292 | --- demos/qml-demo-shell/pointerposition.cpp 1970-01-01 00:00:00 +0000 |
293 | +++ demos/qml-demo-shell/pointerposition.cpp 2016-12-16 08:22:54 +0000 |
294 | @@ -0,0 +1,56 @@ |
295 | +/* |
296 | + * Copyright (C) 2016 Canonical, Ltd. |
297 | + * |
298 | + * This program is free software; you can redistribute it and/or modify |
299 | + * it under the terms of the GNU General Public License as published by |
300 | + * the Free Software Foundation; version 3. |
301 | + * |
302 | + * This program is distributed in the hope that it will be useful, |
303 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
304 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
305 | + * GNU General Public License for more details. |
306 | + * |
307 | + * You should have received a copy of the GNU General Public License |
308 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
309 | + */ |
310 | + |
311 | +#include "pointerposition.h" |
312 | + |
313 | +#include <QGuiApplication> |
314 | +#include <QMouseEvent> |
315 | + |
316 | +PointerPosition *PointerPosition::instance() |
317 | +{ |
318 | + static PointerPosition *pointerPosition = nullptr; |
319 | + if (!pointerPosition) { |
320 | + pointerPosition = new PointerPosition(); |
321 | + } |
322 | + return pointerPosition; |
323 | +} |
324 | + |
325 | +bool PointerPosition::eventFilter(QObject */*object*/, QEvent *event) |
326 | +{ |
327 | + if (event->type() == QEvent::MouseMove) { |
328 | + auto mouseEvent = static_cast<QMouseEvent*>(event); |
329 | + if (m_x != mouseEvent->globalX()) { |
330 | + m_x = mouseEvent->globalX(); |
331 | + Q_EMIT xChanged(); |
332 | + } |
333 | + if (m_y != mouseEvent->globalY()) { |
334 | + m_y = mouseEvent->globalY(); |
335 | + Q_EMIT yChanged(); |
336 | + } |
337 | + } |
338 | + return false; |
339 | +} |
340 | + |
341 | +PointerPosition::PointerPosition() |
342 | + : QObject() |
343 | +{ |
344 | + qGuiApp->installEventFilter(this); |
345 | +} |
346 | + |
347 | +PointerPosition::~PointerPosition() |
348 | +{ |
349 | + qGuiApp->removeEventFilter(this); |
350 | +} |
351 | |
352 | === added file 'demos/qml-demo-shell/pointerposition.h' |
353 | --- demos/qml-demo-shell/pointerposition.h 1970-01-01 00:00:00 +0000 |
354 | +++ demos/qml-demo-shell/pointerposition.h 2016-12-16 08:22:54 +0000 |
355 | @@ -0,0 +1,49 @@ |
356 | +/* |
357 | + * Copyright (C) 2016 Canonical, Ltd. |
358 | + * |
359 | + * This program is free software; you can redistribute it and/or modify |
360 | + * it under the terms of the GNU General Public License as published by |
361 | + * the Free Software Foundation; version 3. |
362 | + * |
363 | + * This program is distributed in the hope that it will be useful, |
364 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
365 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
366 | + * GNU General Public License for more details. |
367 | + * |
368 | + * You should have received a copy of the GNU General Public License |
369 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
370 | + */ |
371 | + |
372 | +#ifndef POINTERPOSITION_H |
373 | +#define POINTERPOSITION_H |
374 | + |
375 | +#include <QObject> |
376 | + |
377 | +class PointerPosition : public QObject |
378 | +{ |
379 | + Q_OBJECT |
380 | + Q_PROPERTY(int x READ x NOTIFY xChanged) |
381 | + Q_PROPERTY(int y READ y NOTIFY yChanged) |
382 | + |
383 | +public: |
384 | + static PointerPosition *instance(); |
385 | + |
386 | + int x() const { return m_x; } |
387 | + int y() const { return m_y; } |
388 | + |
389 | +Q_SIGNALS: |
390 | + void xChanged(); |
391 | + void yChanged(); |
392 | + |
393 | +protected: |
394 | + bool eventFilter(QObject *object, QEvent *event); |
395 | + |
396 | +private: |
397 | + Q_DISABLE_COPY(PointerPosition) |
398 | + PointerPosition(); |
399 | + ~PointerPosition(); |
400 | + |
401 | + int m_x{0}, m_y{0}; |
402 | +}; |
403 | + |
404 | +#endif // POINTERPOSITION_H |
405 | |
406 | === added file 'demos/qml-demo-shell/windowModel.qml' |
407 | --- demos/qml-demo-shell/windowModel.qml 1970-01-01 00:00:00 +0000 |
408 | +++ demos/qml-demo-shell/windowModel.qml 2016-12-16 08:22:54 +0000 |
409 | @@ -0,0 +1,136 @@ |
410 | +import QtQuick 2.4 |
411 | +import Unity.Application 0.1 |
412 | +import Mir.Pointer 0.1 |
413 | + |
414 | +FocusScope { |
415 | + id: root |
416 | + focus: true |
417 | + |
418 | + WindowModel { |
419 | + id: windowModel; |
420 | + } |
421 | + |
422 | + Item { |
423 | + id: windowViewContainer |
424 | + anchors.fill: parent |
425 | + |
426 | + Repeater { |
427 | + model: windowModel |
428 | + |
429 | + delegate: MirSurfaceItem { |
430 | + id: surfaceItem |
431 | + surface: model.surface |
432 | + consumesInput: true // QUESTION: why is this non-default? |
433 | + x: surface.position.x |
434 | + y: surface.position.y |
435 | + width: surface.size.width |
436 | + height: surface.size.height |
437 | + focus: surface.focused |
438 | + visible: surface.visible |
439 | + |
440 | + Rectangle { |
441 | + anchors { top: parent.bottom; right: parent.right } |
442 | + width: childrenRect.width |
443 | + height: childrenRect.height |
444 | + color: surface.focused ? "red" : "lightsteelblue" |
445 | + opacity: 0.8 |
446 | + Text { |
447 | + text: surface.position.x + "," + surface.position.y + " " + surface.size.width + "x" + surface.size.height |
448 | + font.pixelSize: 10 |
449 | + } |
450 | + } |
451 | + |
452 | + Rectangle { anchors.fill: parent; z: -1; color: "black"; opacity: 0.3 } |
453 | + } |
454 | + } |
455 | + } |
456 | + |
457 | + Button { |
458 | + anchors { right: parent.right; top: parent.top } |
459 | + height: 30 |
460 | + width: 80 |
461 | + text: "Quit" |
462 | + onClicked: Qt.quit() |
463 | + } |
464 | + |
465 | + WindowModelDebugView { |
466 | + anchors { right: parent.right; bottom: parent.bottom } |
467 | + model: windowModel |
468 | + } |
469 | + |
470 | + Text { |
471 | + anchors { left: parent.left; bottom: parent.bottom } |
472 | + text: "Move window: Ctrl+click\n |
473 | +Resize window: Ctrl+Right click" |
474 | + } |
475 | + |
476 | + Rectangle { |
477 | + id: mousePointer |
478 | + color: "black" |
479 | + width: 6 |
480 | + height: 10 |
481 | + x: PointerPosition.x |
482 | + y: PointerPosition.y |
483 | + } |
484 | + |
485 | + MouseArea { |
486 | + anchors.fill: parent |
487 | + acceptedButtons: Qt.LeftButton | Qt.RightButton |
488 | + hoverEnabled: false |
489 | + property variant window: null |
490 | + property int initialWindowXPosition |
491 | + property int initialWindowYPosition |
492 | + property int initialWindowWidth |
493 | + property int initialWindowHeight |
494 | + property int initialMouseXPosition |
495 | + property int initialMouseYPosition |
496 | + property var action |
497 | + |
498 | + function moveWindowBy(window, delta) { |
499 | + window.surface.requestedPosition = Qt.point(initialWindowXPosition + delta.x, |
500 | + initialWindowYPosition + delta.y); |
501 | + } |
502 | + function resizeWindowBy(window, delta) { |
503 | + window.surface.resize(Qt.size(initialWindowWidth + delta.x, |
504 | + initialWindowHeight + delta.y)) |
505 | + } |
506 | + |
507 | + onPressed: { |
508 | + if (mouse.modifiers & Qt.ControlModifier) { |
509 | + window = windowViewContainer.childAt(mouse.x, mouse.y) |
510 | + if (!window) return; |
511 | + |
512 | + if (mouse.button == Qt.LeftButton) { |
513 | + initialWindowXPosition = window.surface.position.x |
514 | + initialWindowYPosition = window.surface.position.y |
515 | + action = moveWindowBy |
516 | + } else if (mouse.button == Qt.RightButton) { |
517 | + initialWindowHeight = window.surface.size.height |
518 | + initialWindowWidth = window.surface.size.width |
519 | + action = resizeWindowBy |
520 | + } |
521 | + initialMouseXPosition = mouse.x |
522 | + initialMouseYPosition = mouse.y |
523 | + } else { |
524 | + mouse.accepted = false |
525 | + } |
526 | + } |
527 | + |
528 | + onPositionChanged: { |
529 | + if (!window) { |
530 | + mouse.accepted = false |
531 | + return |
532 | + } |
533 | + action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition)) |
534 | + } |
535 | + |
536 | + onReleased: { |
537 | + if (!window) { |
538 | + mouse.accepted = false |
539 | + return |
540 | + } |
541 | + action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition)) |
542 | + window = null; |
543 | + } |
544 | + } |
545 | +} |
546 | |
547 | === added file 'src/common/appnotifier.h' |
548 | --- src/common/appnotifier.h 1970-01-01 00:00:00 +0000 |
549 | +++ src/common/appnotifier.h 2016-12-16 08:22:54 +0000 |
550 | @@ -0,0 +1,39 @@ |
551 | +/* |
552 | + * Copyright (C) 2016 Canonical, Ltd. |
553 | + * |
554 | + * This program is free software: you can redistribute it and/or modify it under |
555 | + * the terms of the GNU Lesser General Public License version 3, as published by |
556 | + * the Free Software Foundation. |
557 | + * |
558 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
559 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
560 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
561 | + * Lesser General Public License for more details. |
562 | + * |
563 | + * You should have received a copy of the GNU Lesser General Public License |
564 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
565 | + */ |
566 | + |
567 | +#ifndef APPNOTIFIER_H |
568 | +#define APPNOTIFIER_H |
569 | + |
570 | +#include <QObject> |
571 | +#include <miral/application_info.h> |
572 | + |
573 | +namespace qtmir { |
574 | + |
575 | +class AppNotifier : public QObject |
576 | +{ |
577 | + Q_OBJECT |
578 | + |
579 | +Q_SIGNALS: |
580 | + void appAdded(const miral::ApplicationInfo &app); |
581 | + void appRemoved(const miral::ApplicationInfo &app); |
582 | + void appCreatedWindow(const miral::ApplicationInfo &app); |
583 | +}; |
584 | + |
585 | +} // namespace qtmir |
586 | + |
587 | +Q_DECLARE_METATYPE(miral::ApplicationInfo) |
588 | + |
589 | +#endif // APPNOTIFIER_H |
590 | |
591 | === modified file 'src/common/debughelpers.cpp' |
592 | --- src/common/debughelpers.cpp 2016-06-06 19:25:20 +0000 |
593 | +++ src/common/debughelpers.cpp 2016-12-16 08:22:54 +0000 |
594 | @@ -21,6 +21,7 @@ |
595 | |
596 | // Unity API |
597 | #include <unity/shell/application/ApplicationInfoInterface.h> |
598 | +#include <unity/shell/application/Mir.h> |
599 | |
600 | const char *touchPointStateToString(Qt::TouchPointState state) |
601 | { |
602 | @@ -114,23 +115,18 @@ |
603 | const char *mirSurfaceTypeToStr(int value) |
604 | { |
605 | switch (value) { |
606 | - case mir_surface_type_normal: |
607 | - return "normal"; |
608 | - case mir_surface_type_utility: |
609 | - return "utility"; |
610 | - case mir_surface_type_dialog: |
611 | - return "dialog"; |
612 | - case mir_surface_type_overlay: |
613 | - return "overlay"; |
614 | - case mir_surface_type_freestyle: |
615 | - return "freestyle"; |
616 | - case mir_surface_type_popover: |
617 | - return "popover"; |
618 | - case mir_surface_type_inputmethod: |
619 | - return "inputmethod"; |
620 | - default: |
621 | - return "???"; |
622 | + case mir_surface_type_normal: return "normal"; /**< AKA "regular" */ |
623 | + case mir_surface_type_utility: return "utility"; /**< AKA "floating regular" */ |
624 | + case mir_surface_type_dialog: return "dialog"; |
625 | + case mir_surface_type_gloss: return "gloss"; |
626 | + case mir_surface_type_freestyle: return "freestyle"; |
627 | + case mir_surface_type_menu: return "menu"; |
628 | + case mir_surface_type_inputmethod: return "input Method"; /**< AKA "OSK" or handwriting etc. */ |
629 | + case mir_surface_type_satellite: return "satellite"; /**< AKA "toolbox"/"toolbar" */ |
630 | + case mir_surface_type_tip: return "tip"; /**< AKA "tooltip" */ |
631 | + case mir_surface_types: Q_UNREACHABLE(); |
632 | } |
633 | + Q_UNREACHABLE(); |
634 | } |
635 | |
636 | const char *mirSurfaceStateToStr(int value) |
637 | @@ -148,6 +144,8 @@ |
638 | return "vertmaximized"; |
639 | case mir_surface_state_fullscreen: |
640 | return "fullscreen"; |
641 | + case mir_surface_state_hidden: |
642 | + return "hidden"; |
643 | default: |
644 | return "???"; |
645 | } |
646 | @@ -349,3 +347,39 @@ |
647 | return "???"; |
648 | } |
649 | } |
650 | + |
651 | +const char *unityapiMirStateToStr(int state) |
652 | +{ |
653 | + switch (state) { |
654 | + case Mir::UnknownState: |
655 | + return "unknown"; |
656 | + case Mir::RestoredState: |
657 | + return "restored"; |
658 | + case Mir::MinimizedState: |
659 | + return "minimized"; |
660 | + case Mir::MaximizedState: |
661 | + return "maximized"; |
662 | + case Mir::VertMaximizedState: |
663 | + return "vertMaximized"; |
664 | + case Mir::FullscreenState: |
665 | + return "fullscreen"; |
666 | + case Mir::HorizMaximizedState: |
667 | + return "horizMaximized"; |
668 | + case Mir::MaximizedLeftState: |
669 | + return "maximizedLeft"; |
670 | + case Mir::MaximizedRightState: |
671 | + return "maximizedRight"; |
672 | + case Mir::MaximizedTopLeftState: |
673 | + return "maximizedTopLeft"; |
674 | + case Mir::MaximizedTopRightState: |
675 | + return "maximizedTopRight"; |
676 | + case Mir::MaximizedBottomLeftState: |
677 | + return "maximizedBottomLeft"; |
678 | + case Mir::MaximizedBottomRightState: |
679 | + return "maximizedBottomRight"; |
680 | + case Mir::HiddenState: |
681 | + return "hidden"; |
682 | + default: |
683 | + return "???"; |
684 | + } |
685 | +} |
686 | |
687 | === modified file 'src/common/debughelpers.h' |
688 | --- src/common/debughelpers.h 2015-11-10 11:07:23 +0000 |
689 | +++ src/common/debughelpers.h 2016-12-16 08:22:54 +0000 |
690 | @@ -43,4 +43,6 @@ |
691 | |
692 | const char *qtCursorShapeToStr(Qt::CursorShape shape); |
693 | |
694 | +const char *unityapiMirStateToStr(int state); |
695 | + |
696 | #endif // UBUNTUGESTURES_DEBUG_HELPER_H |
697 | |
698 | === added file 'src/common/mirqtconversion.h' |
699 | --- src/common/mirqtconversion.h 1970-01-01 00:00:00 +0000 |
700 | +++ src/common/mirqtconversion.h 2016-12-16 08:22:54 +0000 |
701 | @@ -0,0 +1,118 @@ |
702 | +/* |
703 | + * Copyright (C) 2016 Canonical, Ltd. |
704 | + * |
705 | + * This program is free software: you can redistribute it and/or modify it under |
706 | + * the terms of the GNU Lesser General Public License version 3, as published by |
707 | + * the Free Software Foundation. |
708 | + * |
709 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
710 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
711 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
712 | + * Lesser General Public License for more details. |
713 | + * |
714 | + * You should have received a copy of the GNU Lesser General Public License |
715 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
716 | + */ |
717 | + |
718 | +#ifndef MIRQTCONVERSION_H |
719 | +#define MIRQTCONVERSION_H |
720 | + |
721 | +#include <QSize> |
722 | +#include <QPoint> |
723 | +#include <QRect> |
724 | + |
725 | +#include <mir/geometry/size.h> |
726 | +#include <mir/geometry/point.h> |
727 | +#include <mir/geometry/rectangle.h> |
728 | + |
729 | +#include <mir_toolkit/common.h> |
730 | + |
731 | +#include <unity/shell/application/Mir.h> |
732 | + |
733 | +namespace qtmir { |
734 | + |
735 | +/* |
736 | + * Some handy conversions from Mir types to Qt types and back |
737 | + */ |
738 | + |
739 | +inline QSize toQSize(const mir::geometry::Size size) |
740 | +{ |
741 | + return QSize(size.width.as_int(), size.height.as_int()); |
742 | +} |
743 | + |
744 | +inline mir::geometry::Size toMirSize(const QSize size) |
745 | +{ |
746 | + namespace mg = mir::geometry; |
747 | + return mg::Size{ mg::Width{ size.width()}, mg::Height{ size.height()} }; |
748 | +} |
749 | + |
750 | +inline QPoint toQPoint(const mir::geometry::Point point) |
751 | +{ |
752 | + return QPoint(point.x.as_int(), point.y.as_int()); |
753 | +} |
754 | + |
755 | +inline mir::geometry::Point toMirPoint(const QPoint point) |
756 | +{ |
757 | + namespace mg = mir::geometry; |
758 | + return mg::Point{ mg::X{ point.x()}, mg::Y{ point.y()} }; |
759 | +} |
760 | + |
761 | +inline QRect toQRect(const mir::geometry::Rectangle rect) |
762 | +{ |
763 | + return QRect(rect.top_left.x.as_int(), rect.top_left.y.as_int(), |
764 | + rect.size.width.as_int(), rect.size.height.as_int()); |
765 | +} |
766 | + |
767 | +inline mir::geometry::Rectangle toMirRectangle(const QRect rect) |
768 | +{ |
769 | + namespace mg = mir::geometry; |
770 | + return mg::Rectangle{ |
771 | + mg::Point{ mg::X{ rect.x()}, mg::Y{ rect.y()} }, |
772 | + mg::Size{ mg::Width{ rect.width()}, mg::Height{ rect.height()} } |
773 | + }; |
774 | +} |
775 | + |
776 | +inline Mir::State toQtState(MirSurfaceState state) |
777 | +{ |
778 | + switch (state) { |
779 | + case mir_surface_state_unknown: return Mir::UnknownState; |
780 | + case mir_surface_state_restored: return Mir::RestoredState; |
781 | + case mir_surface_state_minimized: return Mir::MinimizedState; |
782 | + case mir_surface_state_maximized: return Mir::MaximizedState; |
783 | + case mir_surface_state_vertmaximized: return Mir::VertMaximizedState; |
784 | + case mir_surface_state_fullscreen: return Mir::FullscreenState; |
785 | + case mir_surface_state_horizmaximized: return Mir::HorizMaximizedState; |
786 | + case mir_surface_state_hidden: return Mir::HiddenState; |
787 | + case mir_surface_states: Q_UNREACHABLE(); |
788 | + } |
789 | + Q_UNREACHABLE(); |
790 | +} |
791 | + |
792 | +inline MirSurfaceState toMirState(Mir::State state) |
793 | +{ |
794 | + switch (state) { |
795 | + case Mir::UnknownState: return mir_surface_state_unknown; |
796 | + case Mir::RestoredState: return mir_surface_state_restored; |
797 | + case Mir::MinimizedState: return mir_surface_state_minimized; |
798 | + case Mir::MaximizedState: return mir_surface_state_maximized; |
799 | + case Mir::VertMaximizedState: return mir_surface_state_vertmaximized; |
800 | + case Mir::FullscreenState: return mir_surface_state_fullscreen; |
801 | + case Mir::HorizMaximizedState: return mir_surface_state_horizmaximized; |
802 | + |
803 | + // FIXME: Map to the corresponding MirSurfaceState enum value once available |
804 | + case Mir::MaximizedLeftState: |
805 | + case Mir::MaximizedRightState: |
806 | + case Mir::MaximizedTopLeftState: |
807 | + case Mir::MaximizedTopRightState: |
808 | + case Mir::MaximizedBottomLeftState: |
809 | + case Mir::MaximizedBottomRightState: |
810 | + return mir_surface_state_restored; |
811 | + |
812 | + case Mir::HiddenState: return mir_surface_state_hidden; |
813 | + default: Q_UNREACHABLE(); |
814 | + } |
815 | +} |
816 | + |
817 | +} // namespace qtmir |
818 | + |
819 | +#endif // MIRQTCONVERSION_H |
820 | |
821 | === added file 'src/common/windowcontrollerinterface.h' |
822 | --- src/common/windowcontrollerinterface.h 1970-01-01 00:00:00 +0000 |
823 | +++ src/common/windowcontrollerinterface.h 2016-12-16 08:22:54 +0000 |
824 | @@ -0,0 +1,58 @@ |
825 | +/* |
826 | + * Copyright (C) 2016 Canonical, Ltd. |
827 | + * |
828 | + * This program is free software: you can redistribute it and/or modify it under |
829 | + * the terms of the GNU Lesser General Public License version 3, as published by |
830 | + * the Free Software Foundation. |
831 | + * |
832 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
833 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
834 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
835 | + * Lesser General Public License for more details. |
836 | + * |
837 | + * You should have received a copy of the GNU Lesser General Public License |
838 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
839 | + */ |
840 | + |
841 | +#ifndef WINDOWCONTROLLERINTERFACE_H |
842 | +#define WINDOWCONTROLLERINTERFACE_H |
843 | + |
844 | +#include <miral/window.h> |
845 | + |
846 | +#include <mir_toolkit/event.h> |
847 | + |
848 | +#include <QPoint> |
849 | +#include <QSize> |
850 | + |
851 | +// Unity API |
852 | +#include <unity/shell/application/Mir.h> |
853 | + |
854 | +namespace qtmir { |
855 | + |
856 | +class MirSurface; |
857 | + |
858 | +class WindowControllerInterface { |
859 | +public: |
860 | + WindowControllerInterface() = default; |
861 | + virtual ~WindowControllerInterface() = default; |
862 | + |
863 | + // activate() asks Mir to bring particular window to the front and recommend to shell that it be focused |
864 | + virtual void activate (const miral::Window &window) = 0; |
865 | + virtual void raise(const miral::Window &window) = 0; |
866 | + |
867 | + virtual void resize(const miral::Window &window, const QSize &size) = 0; |
868 | + virtual void move (const miral::Window &window, const QPoint &topLeft) = 0; |
869 | + |
870 | + virtual void requestClose(const miral::Window &window) = 0; |
871 | + virtual void forceClose(const miral::Window &window) = 0; |
872 | + |
873 | + virtual void requestState(const miral::Window &window, const Mir::State state) = 0; |
874 | + |
875 | + virtual void deliverKeyboardEvent(const miral::Window &window, const MirKeyboardEvent *event) = 0; |
876 | + virtual void deliverTouchEvent (const miral::Window &window, const MirTouchEvent *event) = 0; |
877 | + virtual void deliverPointerEvent (const miral::Window &window, const MirPointerEvent *event) = 0; |
878 | +}; |
879 | + |
880 | +} // namespace qtmir |
881 | + |
882 | +#endif // WINDOWCONTROLLERINTERFACE_H |
883 | |
884 | === added file 'src/common/windowmodelnotifier.h' |
885 | --- src/common/windowmodelnotifier.h 1970-01-01 00:00:00 +0000 |
886 | +++ src/common/windowmodelnotifier.h 2016-12-16 08:22:54 +0000 |
887 | @@ -0,0 +1,95 @@ |
888 | +/* |
889 | + * Copyright (C) 2016 Canonical, Ltd. |
890 | + * |
891 | + * This program is free software: you can redistribute it and/or modify it under |
892 | + * the terms of the GNU Lesser General Public License version 3, as published by |
893 | + * the Free Software Foundation. |
894 | + * |
895 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
896 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
897 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
898 | + * Lesser General Public License for more details. |
899 | + * |
900 | + * You should have received a copy of the GNU Lesser General Public License |
901 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
902 | + */ |
903 | + |
904 | +#ifndef WINDOWMODELNOTIFIER_H |
905 | +#define WINDOWMODELNOTIFIER_H |
906 | + |
907 | +#include <QObject> |
908 | +#include <QPoint> |
909 | +#include <QSize> |
910 | + |
911 | +#include <miral/window_info.h> |
912 | + |
913 | +// Unity API |
914 | +#include <unity/shell/application/Mir.h> |
915 | + |
916 | +namespace qtmir { |
917 | + |
918 | +class NewWindow { |
919 | +public: |
920 | + NewWindow() = default; |
921 | + NewWindow(const miral::WindowInfo &windowInfo) |
922 | + : windowInfo(windowInfo) |
923 | + , surface(windowInfo.window()) |
924 | + {} |
925 | + |
926 | + miral::WindowInfo windowInfo; |
927 | + |
928 | + // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface |
929 | + // but MirSurface needs to share ownership of the Surface with Mir |
930 | + std::shared_ptr<mir::scene::Surface> surface; |
931 | +}; |
932 | + |
933 | +struct ExtraWindowInfo { |
934 | + QString persistentId; |
935 | + |
936 | + // FIXME Use MirSurfaceState when possible. |
937 | + Mir::State previousState{Mir::UnknownState}; |
938 | + |
939 | + // FIXME: Remove when possible. This exists just because MirSurfaceState has no equivalent |
940 | + // for the following states: |
941 | + // Mir::MaximizedLeftState: |
942 | + // Mir::MaximizedRightState: |
943 | + // Mir::MaximizedTopLeftState: |
944 | + // Mir::MaximizedTopRightState: |
945 | + // Mir::MaximizedBottomLeftState: |
946 | + // Mir::MaximizedBottomRightState: |
947 | + Mir::State state{Mir::UnknownState}; |
948 | +}; |
949 | + |
950 | +std::shared_ptr<ExtraWindowInfo> getExtraInfo(const miral::WindowInfo &windowInfo); |
951 | + |
952 | +class WindowModelNotifier : public QObject |
953 | +{ |
954 | + Q_OBJECT |
955 | +public: |
956 | + WindowModelNotifier() = default; |
957 | + |
958 | +Q_SIGNALS: // **Must used Queued Connection or else events will be out of order** |
959 | + void windowAdded(const qtmir::NewWindow &window); |
960 | + void windowRemoved(const miral::WindowInfo &window); |
961 | + void windowReady(const miral::WindowInfo &window); |
962 | + void windowMoved(const miral::WindowInfo &window, const QPoint topLeft); |
963 | + void windowResized(const miral::WindowInfo &window, const QSize size); |
964 | + void windowStateChanged(const miral::WindowInfo &window, Mir::State state); |
965 | + void windowFocusChanged(const miral::WindowInfo &window, bool focused); |
966 | + void windowsRaised(const std::vector<miral::Window> &windows); // results in deep copy when passed over Queued connection:( |
967 | + void windowRequestedRaise(const miral::WindowInfo &window); |
968 | + void modificationsStarted(); |
969 | + void modificationsEnded(); |
970 | + |
971 | +private: |
972 | + Q_DISABLE_COPY(WindowModelNotifier) |
973 | +}; |
974 | + |
975 | +} // namespace qtmir |
976 | + |
977 | +Q_DECLARE_METATYPE(qtmir::NewWindow) |
978 | +Q_DECLARE_METATYPE(miral::WindowInfo) |
979 | +Q_DECLARE_METATYPE(std::vector<miral::Window>) |
980 | +Q_DECLARE_METATYPE(MirSurfaceState) |
981 | + |
982 | +#endif // WINDOWMODELNOTIFIER_H |
983 | |
984 | === modified file 'src/modules/Unity/Application/CMakeLists.txt' |
985 | --- src/modules/Unity/Application/CMakeLists.txt 2016-07-30 21:19:45 +0000 |
986 | +++ src/modules/Unity/Application/CMakeLists.txt 2016-12-16 08:22:54 +0000 |
987 | @@ -8,6 +8,7 @@ |
988 | ${GLIB_INCLUDE_DIRS} |
989 | ${GIO_INCLUDE_DIRS} |
990 | ${GIO_UNIX_INCLUDE_DIRS} |
991 | + ${MIRAL_INCLUDE_DIRS} |
992 | ${MIRSERVER_INCLUDE_DIRS} |
993 | ${MIRRENDERERGLDEV_INCLUDE_DIRS} |
994 | ${PROCESS_CPP_INCLUDE_DIRS} |
995 | @@ -35,8 +36,6 @@ |
996 | ../../../common/debughelpers.cpp |
997 | dbusfocusinfo.cpp |
998 | plugin.cpp |
999 | - mirsurfacemanager.cpp |
1000 | - mirfocuscontroller.cpp |
1001 | mirsurface.cpp |
1002 | mirsurfaceinterface.h |
1003 | mirsurfaceitem.cpp |
1004 | @@ -46,20 +45,22 @@ |
1005 | session.cpp |
1006 | sessionmanager.cpp |
1007 | sharedwakelock.cpp |
1008 | + surfacemanager.cpp |
1009 | upstart/applicationinfo.cpp |
1010 | upstart/taskcontroller.cpp |
1011 | timer.cpp |
1012 | timesource.cpp |
1013 | tracepoints.c |
1014 | settings.cpp |
1015 | + windowmodel.cpp |
1016 | # We need to run moc on these headers |
1017 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h |
1018 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h |
1019 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h |
1020 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirFocusControllerInterface.h |
1021 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h |
1022 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceItemInterface.h |
1023 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h |
1024 | + ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/SurfaceManagerInterface.h |
1025 | # Feed the automoc monster |
1026 | session_interface.h |
1027 | applicationinfo.h |
1028 | |
1029 | === modified file 'src/modules/Unity/Application/application.cpp' |
1030 | --- src/modules/Unity/Application/application.cpp 2016-08-10 06:52:18 +0000 |
1031 | +++ src/modules/Unity/Application/application.cpp 2016-12-16 08:22:54 +0000 |
1032 | @@ -409,11 +409,7 @@ |
1033 | |
1034 | bool Application::focused() const |
1035 | { |
1036 | - bool someSurfaceHasFocus = false; // to be proven wrong |
1037 | - for (int i = 0; i < m_proxySurfaceList->rowCount() && !someSurfaceHasFocus; ++i) { |
1038 | - someSurfaceHasFocus |= m_proxySurfaceList->get(i)->focused(); |
1039 | - } |
1040 | - return someSurfaceHasFocus; |
1041 | + return m_session && m_session->focused(); |
1042 | } |
1043 | |
1044 | bool Application::fullscreen() const |
1045 | @@ -512,6 +508,10 @@ |
1046 | connect(m_session, &SessionInterface::hasClosingSurfacesChanged, this, &Application::updateState); |
1047 | connect(m_session, &SessionInterface::focusRequested, this, &Application::focusRequested); |
1048 | connect(m_session->surfaceList(), &MirSurfaceListModel::emptyChanged, this, &Application::updateState); |
1049 | + connect(m_session, &SessionInterface::focusedChanged, this, [&](bool focused) { |
1050 | + qCDebug(QTMIR_APPLICATIONS).nospace() << "Application[" << appId() <<"]::focusedChanged(" << focused << ")"; |
1051 | + Q_EMIT focusedChanged(focused); |
1052 | + }); |
1053 | |
1054 | if (oldFullscreen != fullscreen()) |
1055 | Q_EMIT fullscreenChanged(fullscreen()); |
1056 | @@ -852,7 +852,8 @@ |
1057 | { |
1058 | if (m_proxySurfaceList->rowCount() > 0) { |
1059 | DEBUG_MSG << "() - Requesting focus for most recent app surface"; |
1060 | - m_proxySurfaceList->get(0)->requestFocus(); |
1061 | + auto surface = static_cast<MirSurfaceInterface*>(m_proxySurfaceList->get(0)); |
1062 | + surface->requestFocus(); |
1063 | } else { |
1064 | DEBUG_MSG << "() - emitting focusRequested()"; |
1065 | Q_EMIT focusRequested(); |
1066 | |
1067 | === modified file 'src/modules/Unity/Application/application.h' |
1068 | --- src/modules/Unity/Application/application.h 2016-08-10 06:52:18 +0000 |
1069 | +++ src/modules/Unity/Application/application.h 2016-12-16 08:22:54 +0000 |
1070 | @@ -31,12 +31,6 @@ |
1071 | #include "mirsurfacelistmodel.h" |
1072 | #include "session_interface.h" |
1073 | |
1074 | -namespace mir { |
1075 | - namespace scene { |
1076 | - class Session; |
1077 | - } |
1078 | -} |
1079 | - |
1080 | namespace qtmir |
1081 | { |
1082 | |
1083 | @@ -109,6 +103,7 @@ |
1084 | unity::shell::application::MirSurfaceListInterface* surfaceList() const override; |
1085 | unity::shell::application::MirSurfaceListInterface* promptSurfaceList() const override; |
1086 | int surfaceCount() const override { return surfaceList()->count(); } |
1087 | + void close() override; |
1088 | |
1089 | ProcessState processState() const { return m_processState; } |
1090 | void setProcessState(ProcessState value); |
1091 | @@ -125,8 +120,6 @@ |
1092 | |
1093 | pid_t pid() const; |
1094 | |
1095 | - void close(); |
1096 | - |
1097 | // internal as in "not exposed in unity-api", so qtmir-internal. |
1098 | InternalState internalState() const { return m_state; } |
1099 | |
1100 | |
1101 | === modified file 'src/modules/Unity/Application/application_manager.cpp' |
1102 | --- src/modules/Unity/Application/application_manager.cpp 2016-08-26 09:08:55 +0000 |
1103 | +++ src/modules/Unity/Application/application_manager.cpp 2016-12-16 08:22:54 +0000 |
1104 | @@ -19,7 +19,7 @@ |
1105 | #include "application.h" |
1106 | #include "applicationinfo.h" |
1107 | #include "dbusfocusinfo.h" |
1108 | -#include "mirfocuscontroller.h" |
1109 | +#include "mirsurfaceinterface.h" |
1110 | #include "session.h" |
1111 | #include "sharedwakelock.h" |
1112 | #include "proc_info.h" |
1113 | @@ -31,12 +31,11 @@ |
1114 | #include "nativeinterface.h" |
1115 | #include "sessionauthorizer.h" |
1116 | #include "logging.h" |
1117 | -#include <mirwindowmanager.h> |
1118 | + |
1119 | +//miral |
1120 | +#include <miral/application.h> |
1121 | |
1122 | // mir |
1123 | -#include <mir/scene/surface.h> |
1124 | -#include <mir/graphics/display.h> |
1125 | -#include <mir/graphics/display_buffer.h> |
1126 | #include <mir/geometry/rectangles.h> |
1127 | |
1128 | // Qt |
1129 | @@ -82,15 +81,8 @@ |
1130 | |
1131 | void connectToTaskController(ApplicationManager *manager, TaskController *controller) |
1132 | { |
1133 | - // TaskController::processStarting blocks Ubuntu-App-Launch from executing the process, have it return |
1134 | - // as fast as possible! Using a Queued connection will push an event on the event queue before the |
1135 | - // (blocking) event for authorizeSession is pushed on the same queue - so the application's processState |
1136 | - // will be up-to-date when authorizeSession is called. |
1137 | - // |
1138 | - // TODO: Unfortunately making this queued unearths a crash (likely in Qt) (LP: #1616842). |
1139 | QObject::connect(controller, &TaskController::processStarting, |
1140 | manager, &ApplicationManager::onProcessStarting); |
1141 | - |
1142 | QObject::connect(controller, &TaskController::processStopped, |
1143 | manager, &ApplicationManager::onProcessStopped); |
1144 | QObject::connect(controller, &TaskController::processSuspended, |
1145 | @@ -115,7 +107,6 @@ |
1146 | return nullptr; |
1147 | } |
1148 | |
1149 | - MirWindowManager *windowManager = static_cast<MirWindowManager*>(nativeInterface->nativeResourceForIntegration("WindowManager")); |
1150 | SessionAuthorizer *sessionAuthorizer = static_cast<SessionAuthorizer*>(nativeInterface->nativeResourceForIntegration("SessionAuthorizer")); |
1151 | |
1152 | QSharedPointer<TaskController> taskController(new upstart::TaskController()); |
1153 | @@ -137,9 +128,10 @@ |
1154 | |
1155 | connectToSessionAuthorizer(appManager, sessionAuthorizer); |
1156 | connectToTaskController(appManager, taskController.data()); |
1157 | - connect(windowManager, &MirWindowManager::sessionAboutToCreateSurface, |
1158 | - appManager, &ApplicationManager::onSessionAboutToCreateSurface, |
1159 | - Qt::BlockingQueuedConnection); |
1160 | +// TODO - re-implement this functionality using the new Mir WindowManagement API |
1161 | +// connect(windowManager, &MirWindowManager::sessionAboutToCreateSurface, |
1162 | +// appManager, &ApplicationManager::onSessionAboutToCreateSurface, |
1163 | +// Qt::BlockingQueuedConnection); |
1164 | |
1165 | // Emit signal to notify Upstart that Mir is ready to receive client connections |
1166 | // see http://upstart.ubuntu.com/cookbook/#expect-stop |
1167 | @@ -179,17 +171,6 @@ |
1168 | { |
1169 | qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this; |
1170 | setObjectName(QStringLiteral("qtmir::ApplicationManager")); |
1171 | - |
1172 | - /* |
1173 | - All begin[...]Rows() and end[...]Rows() functions cause signal emissions which can |
1174 | - be processed by slots immediately and then trigger yet more model changes. |
1175 | - |
1176 | - The connection below is queued to avoid stacked model change attempts cause by the above, |
1177 | - such as attempting to raise the newly focused application while another one is still |
1178 | - getting removed from the model. |
1179 | - */ |
1180 | - connect(MirFocusController::instance(), &MirFocusController::focusedSurfaceChanged, |
1181 | - this, &ApplicationManager::updateFocusedApplication, Qt::QueuedConnection); |
1182 | } |
1183 | |
1184 | ApplicationManager::~ApplicationManager() |
1185 | @@ -273,18 +254,12 @@ |
1186 | |
1187 | QString ApplicationManager::focusedApplicationId() const |
1188 | { |
1189 | - Application *focusedApplication = nullptr; |
1190 | - auto surface = static_cast<qtmir::MirSurfaceInterface*>(MirFocusController::instance()->focusedSurface()); |
1191 | - if (surface) { |
1192 | - auto self = const_cast<ApplicationManager*>(this); |
1193 | - focusedApplication = self->findApplication(surface); |
1194 | - } |
1195 | - |
1196 | - if (focusedApplication) { |
1197 | - return focusedApplication->appId(); |
1198 | - } else { |
1199 | - return QString(); |
1200 | - } |
1201 | + for (const auto application : m_applications) { |
1202 | + if (application->focused()) { |
1203 | + return application->appId(); |
1204 | + } |
1205 | + } |
1206 | + return QString(); |
1207 | } |
1208 | |
1209 | /** |
1210 | @@ -602,16 +577,22 @@ |
1211 | authorized = true; |
1212 | } |
1213 | |
1214 | + |
1215 | +unityapi::ApplicationInfoInterface *ApplicationManager::findApplicationWithSurface(unityapi::MirSurfaceInterface* surface) const |
1216 | +{ |
1217 | + if (!surface) |
1218 | + return nullptr; |
1219 | + |
1220 | + auto qtmirSurface = static_cast<qtmir::MirSurfaceInterface*>(surface); |
1221 | + |
1222 | + return findApplicationWithPid(miral::pid_of(qtmirSurface->session()->session())); |
1223 | +} |
1224 | + |
1225 | Application* ApplicationManager::findApplicationWithSession(const std::shared_ptr<ms::Session> &session) |
1226 | { |
1227 | - return findApplicationWithSession(session.get()); |
1228 | -} |
1229 | - |
1230 | -Application* ApplicationManager::findApplicationWithSession(const ms::Session *session) |
1231 | -{ |
1232 | if (!session) |
1233 | return nullptr; |
1234 | - return findApplicationWithPid(session->process_id()); |
1235 | + return findApplicationWithPid(miral::pid_of(session)); |
1236 | } |
1237 | |
1238 | Application* ApplicationManager::findApplicationWithPid(const pid_t pid) const |
1239 | @@ -640,7 +621,20 @@ |
1240 | Q_ASSERT(!m_modelUnderChange); |
1241 | m_modelUnderChange = true; |
1242 | |
1243 | - connect(application, &Application::focusedChanged, this, [this](bool) { onAppDataChanged(RoleFocused); }); |
1244 | + /* |
1245 | + All begin[...]Rows() and end[...]Rows() functions cause signal emissions which can |
1246 | + be processed by slots immediately and then trigger yet more model changes. |
1247 | + |
1248 | + The connection below is queued to avoid stacked model change attempts cause by the above, |
1249 | + such as attempting to raise the newly focused application while another one is still |
1250 | + getting removed from the model. |
1251 | + */ |
1252 | + // TODO: That might not be the case anymore with miral. Investigate if we can do a direct connection now |
1253 | + connect(application, &Application::focusedChanged, this, [this](bool) { |
1254 | + onAppDataChanged(RoleFocused); |
1255 | + Q_EMIT focusedApplicationIdChanged(); |
1256 | + }, Qt::QueuedConnection); |
1257 | + |
1258 | connect(application, &Application::stateChanged, this, [this](Application::State) { onAppDataChanged(RoleState); }); |
1259 | connect(application, &Application::closing, this, [this, application]() { onApplicationClosing(application); }); |
1260 | connect(application, &unityapi::ApplicationInfoInterface::focusRequested, this, [this, application]() { |
1261 | @@ -805,35 +799,6 @@ |
1262 | } |
1263 | } |
1264 | |
1265 | -void ApplicationManager::updateFocusedApplication() |
1266 | -{ |
1267 | - Application *focusedApplication = nullptr; |
1268 | - Application *previouslyFocusedApplication = nullptr; |
1269 | - |
1270 | - auto surface = static_cast<qtmir::MirSurfaceInterface*>(MirFocusController::instance()->focusedSurface()); |
1271 | - if (surface) { |
1272 | - focusedApplication = findApplication(surface); |
1273 | - } |
1274 | - |
1275 | - surface = static_cast<qtmir::MirSurfaceInterface*>(MirFocusController::instance()->previouslyFocusedSurface()); |
1276 | - if (surface) { |
1277 | - previouslyFocusedApplication = findApplication(surface); |
1278 | - } |
1279 | - |
1280 | - if (focusedApplication != previouslyFocusedApplication) { |
1281 | - if (focusedApplication) { |
1282 | - DEBUG_MSG << "() focused " << focusedApplication->appId(); |
1283 | - Q_EMIT focusedApplication->focusedChanged(true); |
1284 | - this->move(this->m_applications.indexOf(focusedApplication), 0); |
1285 | - } |
1286 | - if (previouslyFocusedApplication) { |
1287 | - DEBUG_MSG << "() unfocused " << previouslyFocusedApplication->appId(); |
1288 | - Q_EMIT previouslyFocusedApplication->focusedChanged(false); |
1289 | - } |
1290 | - Q_EMIT focusedApplicationIdChanged(); |
1291 | - } |
1292 | -} |
1293 | - |
1294 | Application *ApplicationManager::findApplication(qtmir::MirSurfaceInterface* surface) |
1295 | { |
1296 | Q_FOREACH (Application *app, m_applications) { |
1297 | |
1298 | === modified file 'src/modules/Unity/Application/application_manager.h' |
1299 | --- src/modules/Unity/Application/application_manager.h 2016-08-08 13:10:40 +0000 |
1300 | +++ src/modules/Unity/Application/application_manager.h 2016-12-16 08:22:54 +0000 |
1301 | @@ -24,13 +24,13 @@ |
1302 | #include <QObject> |
1303 | #include <QStringList> |
1304 | |
1305 | -// Unity API |
1306 | -#include <unity/shell/application/ApplicationManagerInterface.h> |
1307 | - |
1308 | // local |
1309 | #include "application.h" |
1310 | #include "taskcontroller.h" |
1311 | |
1312 | +// Unity API |
1313 | +#include <unity/shell/application/ApplicationManagerInterface.h> |
1314 | + |
1315 | namespace mir { |
1316 | namespace scene { |
1317 | class Session; |
1318 | @@ -51,7 +51,6 @@ |
1319 | |
1320 | class DBusFocusInfo; |
1321 | class DBusWindowStack; |
1322 | -class MirSurfaceManager; |
1323 | class ProcInfo; |
1324 | class SharedWakelock; |
1325 | class SettingsInterface; |
1326 | @@ -80,10 +79,11 @@ |
1327 | QObject *parent = 0); |
1328 | virtual ~ApplicationManager(); |
1329 | |
1330 | - // ApplicationManagerInterface |
1331 | + // unity::shell::application::ApplicationManagerInterface |
1332 | QString focusedApplicationId() const override; |
1333 | Q_INVOKABLE qtmir::Application* get(int index) const override; |
1334 | Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override; |
1335 | + unity::shell::application::ApplicationInfoInterface *findApplicationWithSurface(unity::shell::application::MirSurfaceInterface* surface) const override; |
1336 | Q_INVOKABLE bool requestFocusApplication(const QString &appId) override; |
1337 | Q_INVOKABLE qtmir::Application* startApplication(const QString &appId, const QStringList &arguments = QStringList()) override; |
1338 | Q_INVOKABLE bool stopApplication(const QString &appId) override; |
1339 | @@ -117,14 +117,13 @@ |
1340 | void onSessionAboutToCreateSurface(const std::shared_ptr<mir::scene::Session> &session, |
1341 | int type, QSize &size); |
1342 | void onApplicationClosing(Application *application); |
1343 | - void updateFocusedApplication(); |
1344 | |
1345 | private: |
1346 | + Application* findApplicationWithSession(const std::shared_ptr<mir::scene::Session> &session); |
1347 | void setFocused(Application *application); |
1348 | void add(Application *application); |
1349 | void remove(Application* application); |
1350 | - Application* findApplicationWithSession(const std::shared_ptr<mir::scene::Session> &session); |
1351 | - Application* findApplicationWithSession(const mir::scene::Session *session); |
1352 | + |
1353 | QModelIndex findIndex(Application* application); |
1354 | void resumeApplication(Application *application); |
1355 | QString toString() const; |
1356 | @@ -146,7 +145,6 @@ |
1357 | |
1358 | friend class Application; |
1359 | friend class DBusWindowStack; |
1360 | - friend class MirSurfaceManager; |
1361 | friend class SessionManager; |
1362 | }; |
1363 | |
1364 | |
1365 | === modified file 'src/modules/Unity/Application/dbusfocusinfo.cpp' |
1366 | --- src/modules/Unity/Application/dbusfocusinfo.cpp 2016-08-30 12:32:13 +0000 |
1367 | +++ src/modules/Unity/Application/dbusfocusinfo.cpp 2016-12-16 08:22:54 +0000 |
1368 | @@ -75,29 +75,23 @@ |
1369 | SessionInterface* DBusFocusInfo::findSessionWithPid(const QSet<pid_t> &pidSet) |
1370 | { |
1371 | Q_FOREACH (Application* application, m_applications) { |
1372 | - SessionInterface *sessionWithPid = findSessionWithPid(application->session(), pidSet); |
1373 | - if (sessionWithPid) { |
1374 | - return sessionWithPid; |
1375 | + auto session = application->session(); |
1376 | + if (pidSet.contains(session->pid())) { |
1377 | + return session; |
1378 | + } |
1379 | + SessionInterface *chosenChildSession = nullptr; |
1380 | + session->foreachChildSession([&](SessionInterface* childSession) { |
1381 | + if (pidSet.contains(childSession->pid())) { |
1382 | + chosenChildSession = childSession; |
1383 | + } |
1384 | + }); |
1385 | + if (chosenChildSession) { |
1386 | + return chosenChildSession; |
1387 | } |
1388 | } |
1389 | return nullptr; |
1390 | } |
1391 | |
1392 | -SessionInterface* DBusFocusInfo::findSessionWithPid(SessionInterface* session, const QSet<pid_t> &pidSet) |
1393 | -{ |
1394 | - if (pidSet.contains(session->pid())) { |
1395 | - return session; |
1396 | - } |
1397 | - |
1398 | - SessionInterface *sessionWithPid = nullptr; |
1399 | - session->foreachChildSession([&](SessionInterface* childSession) { |
1400 | - if (!sessionWithPid) { |
1401 | - sessionWithPid = findSessionWithPid(childSession, pidSet); |
1402 | - } |
1403 | - }); |
1404 | - return sessionWithPid; |
1405 | -} |
1406 | - |
1407 | bool DBusFocusInfo::isSurfaceFocused(const QString &serializedId) |
1408 | { |
1409 | // TODO: Implement a penalty for negative queries, such as stalling for some time before answering |
1410 | |
1411 | === modified file 'src/modules/Unity/Application/dbusfocusinfo.h' |
1412 | --- src/modules/Unity/Application/dbusfocusinfo.h 2016-08-30 12:29:32 +0000 |
1413 | +++ src/modules/Unity/Application/dbusfocusinfo.h 2016-12-16 08:22:54 +0000 |
1414 | @@ -54,7 +54,6 @@ |
1415 | private: |
1416 | QSet<pid_t> fetchAssociatedPids(pid_t pid); |
1417 | SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet); |
1418 | - SessionInterface* findSessionWithPid(SessionInterface* session, const QSet<pid_t> &pidSet); |
1419 | MirSurfaceInterface *findQmlSurface(const QString &serializedId); |
1420 | |
1421 | const QList<Application*> &m_applications; |
1422 | |
1423 | === removed file 'src/modules/Unity/Application/mirfocuscontroller.cpp' |
1424 | --- src/modules/Unity/Application/mirfocuscontroller.cpp 2016-04-05 18:58:38 +0000 |
1425 | +++ src/modules/Unity/Application/mirfocuscontroller.cpp 1970-01-01 00:00:00 +0000 |
1426 | @@ -1,69 +0,0 @@ |
1427 | -/* |
1428 | - * Copyright (C) 2016 Canonical, Ltd. |
1429 | - * |
1430 | - * This program is free software; you can redistribute it and/or modify |
1431 | - * it under the terms of the GNU General Public License as published by |
1432 | - * the Free Software Foundation; version 3. |
1433 | - * |
1434 | - * This program is distributed in the hope that it will be useful, |
1435 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1436 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1437 | - * GNU General Public License for more details. |
1438 | - * |
1439 | - * You should have received a copy of the GNU General Public License |
1440 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1441 | - */ |
1442 | - |
1443 | -#include "mirfocuscontroller.h" |
1444 | - |
1445 | -#include "mirsurfaceinterface.h" |
1446 | - |
1447 | -// mirserver |
1448 | -#include <logging.h> |
1449 | - |
1450 | -namespace unityapp = unity::shell::application; |
1451 | -using namespace qtmir; |
1452 | - |
1453 | -#define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirFocusController::" << __func__ |
1454 | - |
1455 | -MirFocusController *MirFocusController::m_instance = nullptr; |
1456 | - |
1457 | -void MirFocusController::setFocusedSurface(unityapp::MirSurfaceInterface *unityAppSurface) |
1458 | -{ |
1459 | - auto surface = static_cast<qtmir::MirSurfaceInterface*>(unityAppSurface); |
1460 | - |
1461 | - if (m_focusedSurface == surface) { |
1462 | - return; |
1463 | - } |
1464 | - |
1465 | - DEBUG_MSG << "(" << surface << ")"; |
1466 | - |
1467 | - m_previouslyFocusedSurface = m_focusedSurface; |
1468 | - m_focusedSurface = surface; |
1469 | - |
1470 | - if (m_previouslyFocusedSurface) { |
1471 | - m_previouslyFocusedSurface->setFocused(false); |
1472 | - } |
1473 | - |
1474 | - if (m_focusedSurface) { |
1475 | - m_focusedSurface->setFocused(true); |
1476 | - m_focusedSurface->raise(); |
1477 | - } |
1478 | - |
1479 | - if (m_previouslyFocusedSurface != m_focusedSurface) { |
1480 | - Q_EMIT focusedSurfaceChanged(); |
1481 | - } |
1482 | -} |
1483 | - |
1484 | -unity::shell::application::MirSurfaceInterface* MirFocusController::focusedSurface() const |
1485 | -{ |
1486 | - return m_focusedSurface; |
1487 | -} |
1488 | - |
1489 | -MirFocusController* MirFocusController::instance() |
1490 | -{ |
1491 | - if (!m_instance) { |
1492 | - m_instance = new MirFocusController; |
1493 | - } |
1494 | - return m_instance; |
1495 | -} |
1496 | |
1497 | === removed file 'src/modules/Unity/Application/mirfocuscontroller.h' |
1498 | --- src/modules/Unity/Application/mirfocuscontroller.h 2016-03-28 18:02:26 +0000 |
1499 | +++ src/modules/Unity/Application/mirfocuscontroller.h 1970-01-01 00:00:00 +0000 |
1500 | @@ -1,49 +0,0 @@ |
1501 | -/* |
1502 | - * Copyright (C) 2016 Canonical, Ltd. |
1503 | - * |
1504 | - * This program is free software; you can redistribute it and/or modify |
1505 | - * it under the terms of the GNU General Public License as published by |
1506 | - * the Free Software Foundation; version 3. |
1507 | - * |
1508 | - * This program is distributed in the hope that it will be useful, |
1509 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1510 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1511 | - * GNU General Public License for more details. |
1512 | - * |
1513 | - * You should have received a copy of the GNU General Public License |
1514 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1515 | - */ |
1516 | - |
1517 | -#ifndef QTMIR_MIRFOCUSCONTROLLER_H |
1518 | -#define QTMIR_MIRFOCUSCONTROLLER_H |
1519 | - |
1520 | -// unity-api |
1521 | -#include <unity/shell/application/MirFocusControllerInterface.h> |
1522 | - |
1523 | -#include <QPointer> |
1524 | - |
1525 | -#include "mirsurfaceinterface.h" |
1526 | - |
1527 | -namespace qtmir { |
1528 | - |
1529 | -class MirSurfaceInterface; |
1530 | - |
1531 | -class MirFocusController : public unity::shell::application::MirFocusControllerInterface |
1532 | -{ |
1533 | - Q_OBJECT |
1534 | -public: |
1535 | - MirFocusController(){} |
1536 | - static MirFocusController* instance(); |
1537 | - |
1538 | - void setFocusedSurface(unity::shell::application::MirSurfaceInterface *surface) override; |
1539 | - unity::shell::application::MirSurfaceInterface* focusedSurface() const override; |
1540 | - MirSurfaceInterface* previouslyFocusedSurface() { return m_previouslyFocusedSurface.data(); } |
1541 | -private: |
1542 | - static MirFocusController *m_instance; |
1543 | - QPointer<MirSurfaceInterface> m_previouslyFocusedSurface; |
1544 | - QPointer<MirSurfaceInterface> m_focusedSurface; |
1545 | -}; |
1546 | - |
1547 | -} // namespace qtmir |
1548 | - |
1549 | -#endif // QTMIR_MIRFOCUSCONTROLLER_H |
1550 | |
1551 | === modified file 'src/modules/Unity/Application/mirsurface.cpp' |
1552 | --- src/modules/Unity/Application/mirsurface.cpp 2016-10-11 20:50:50 +0000 |
1553 | +++ src/modules/Unity/Application/mirsurface.cpp 2016-12-16 08:22:54 +0000 |
1554 | @@ -16,11 +16,14 @@ |
1555 | |
1556 | #include "mirsurface.h" |
1557 | #include "mirsurfacelistmodel.h" |
1558 | +#include "namedcursor.h" |
1559 | +#include "session_interface.h" |
1560 | #include "timer.h" |
1561 | #include "timestamp.h" |
1562 | |
1563 | // from common dir |
1564 | #include <debughelpers.h> |
1565 | +#include "mirqtconversion.h" |
1566 | |
1567 | // mirserver |
1568 | #include <eventbuilder.h> |
1569 | @@ -29,11 +32,9 @@ |
1570 | |
1571 | // Mir |
1572 | #include <mir/geometry/rectangle.h> |
1573 | -#include <mir/events/event_builders.h> |
1574 | -#include <mir/shell/shell.h> |
1575 | #include <mir/scene/surface.h> |
1576 | -#include <mir/scene/session.h> |
1577 | -#include <mir_toolkit/event.h> |
1578 | +#include <mir/scene/surface_observer.h> |
1579 | +#include <mir/version.h> |
1580 | |
1581 | // mirserver |
1582 | #include <logging.h> |
1583 | @@ -42,60 +43,125 @@ |
1584 | #include <QQmlEngine> |
1585 | #include <QScreen> |
1586 | |
1587 | +// std |
1588 | +#include <limits> |
1589 | + |
1590 | using namespace qtmir; |
1591 | |
1592 | #define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__ |
1593 | #define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__ |
1594 | |
1595 | -MirSurface::MirSurface(std::shared_ptr<mir::scene::Surface> surface, |
1596 | - const QString& persistentId, |
1597 | - SessionInterface* session, |
1598 | - mir::shell::Shell* shell, |
1599 | - std::shared_ptr<SurfaceObserver> observer, |
1600 | - const CreationHints &creationHints) |
1601 | +namespace { |
1602 | + |
1603 | +enum class DirtyState { |
1604 | + Clean = 0, |
1605 | + Name = 1 << 1, |
1606 | + Type = 1 << 2, |
1607 | + State = 1 << 3, |
1608 | + RestoreRect = 1 << 4, |
1609 | + Children = 1 << 5, |
1610 | + MinSize = 1 << 6, |
1611 | + MaxSize = 1 << 7, |
1612 | +}; |
1613 | +Q_DECLARE_FLAGS(DirtyStates, DirtyState) |
1614 | + |
1615 | +} // namespace { |
1616 | + |
1617 | +class MirSurface::SurfaceObserverImpl : public SurfaceObserver, public mir::scene::SurfaceObserver |
1618 | +{ |
1619 | +public: |
1620 | + SurfaceObserverImpl(); |
1621 | + virtual ~SurfaceObserverImpl(); |
1622 | + |
1623 | + void setListener(QObject *listener); |
1624 | + |
1625 | + void attrib_changed(MirSurfaceAttrib, int) override; |
1626 | + void resized_to(mir::geometry::Size const&) override; |
1627 | + void moved_to(mir::geometry::Point const&) override {} |
1628 | + void hidden_set_to(bool) override {} |
1629 | + |
1630 | + // Get new frame notifications from Mir, called from a Mir thread. |
1631 | + void frame_posted(int frames_available, mir::geometry::Size const& size ) override; |
1632 | + |
1633 | + void alpha_set_to(float) override {} |
1634 | + void transformation_set_to(glm::mat4 const&) override {} |
1635 | + void reception_mode_set_to(mir::input::InputReceptionMode) override {} |
1636 | + void cursor_image_set_to(mir::graphics::CursorImage const&) override; |
1637 | + void orientation_set_to(MirOrientation) override {} |
1638 | + void client_surface_close_requested() override {} |
1639 | + void keymap_changed(MirInputDeviceId, std::string const& model, std::string const& layout, |
1640 | + std::string const& variant, std::string const& options) override; |
1641 | + void renamed(char const * name) override; |
1642 | + void cursor_image_removed() override; |
1643 | + |
1644 | +#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) |
1645 | + void placed_relative(mir::geometry::Rectangle const& placement) override; |
1646 | +#endif |
1647 | + |
1648 | +private: |
1649 | + QCursor createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage); |
1650 | + QObject *m_listener; |
1651 | + bool m_framesPosted; |
1652 | + QMap<QByteArray, Qt::CursorShape> m_cursorNameToShape; |
1653 | +}; |
1654 | + |
1655 | + |
1656 | +MirSurface::MirSurface(NewWindow newWindowInfo, |
1657 | + WindowControllerInterface* controller, |
1658 | + SessionInterface *session) |
1659 | : MirSurfaceInterface() |
1660 | - , m_surface(surface) |
1661 | + , m_window{newWindowInfo.windowInfo.window()} |
1662 | + , m_extraInfo{getExtraInfo(newWindowInfo.windowInfo)} |
1663 | + , m_name{QString::fromStdString(newWindowInfo.windowInfo.name())} |
1664 | + , m_type{newWindowInfo.windowInfo.type()} |
1665 | + , m_minWidth{newWindowInfo.windowInfo.min_width().as_int()} |
1666 | + , m_minHeight{newWindowInfo.windowInfo.min_height().as_int()} |
1667 | + , m_maxWidth{newWindowInfo.windowInfo.max_width().as_int()} |
1668 | + , m_maxHeight{newWindowInfo.windowInfo.max_height().as_int()} |
1669 | + , m_incWidth{newWindowInfo.windowInfo.width_inc().as_int()} |
1670 | + , m_incHeight{newWindowInfo.windowInfo.height_inc().as_int()} |
1671 | + , m_surface(newWindowInfo.surface) |
1672 | , m_session(session) |
1673 | - , m_shell(shell) |
1674 | - , m_persistentId(persistentId) |
1675 | - , m_firstFrameDrawn(false) |
1676 | + , m_controller(controller) |
1677 | , m_orientationAngle(Mir::Angle0) |
1678 | , m_textureUpdated(false) |
1679 | , m_currentFrameNumber(0) |
1680 | + , m_visible(newWindowInfo.windowInfo.is_visible()) |
1681 | , m_live(true) |
1682 | + , m_surfaceObserver(std::make_shared<SurfaceObserverImpl>()) |
1683 | + , m_position(toQPoint(m_window.top_left())) |
1684 | + , m_size(toQSize(m_window.size())) |
1685 | + , m_state(toQtState(newWindowInfo.windowInfo.state())) |
1686 | , m_shellChrome(Mir::NormalChrome) |
1687 | { |
1688 | - DEBUG_MSG << "()"; |
1689 | - |
1690 | - m_minimumWidth = creationHints.minWidth; |
1691 | - m_minimumHeight = creationHints.minHeight; |
1692 | - m_maximumWidth = creationHints.maxWidth; |
1693 | - m_maximumHeight = creationHints.maxHeight; |
1694 | - m_widthIncrement = creationHints.widthIncrement; |
1695 | - m_heightIncrement = creationHints.heightIncrement; |
1696 | - m_shellChrome = creationHints.shellChrome; |
1697 | - |
1698 | - m_surfaceObserver = observer; |
1699 | - if (observer) { |
1700 | - connect(observer.get(), &SurfaceObserver::framesPosted, this, &MirSurface::onFramesPostedObserved); |
1701 | - connect(observer.get(), &SurfaceObserver::attributeChanged, this, &MirSurface::onAttributeChanged); |
1702 | - connect(observer.get(), &SurfaceObserver::nameChanged, this, &MirSurface::nameChanged); |
1703 | - connect(observer.get(), &SurfaceObserver::cursorChanged, this, &MirSurface::setCursor); |
1704 | - connect(observer.get(), &SurfaceObserver::minimumWidthChanged, this, &MirSurface::setMinimumWidth); |
1705 | - connect(observer.get(), &SurfaceObserver::minimumHeightChanged, this, &MirSurface::setMinimumHeight); |
1706 | - connect(observer.get(), &SurfaceObserver::maximumWidthChanged, this, &MirSurface::setMaximumWidth); |
1707 | - connect(observer.get(), &SurfaceObserver::maximumHeightChanged, this, &MirSurface::setMaximumHeight); |
1708 | - connect(observer.get(), &SurfaceObserver::widthIncrementChanged, this, &MirSurface::setWidthIncrement); |
1709 | - connect(observer.get(), &SurfaceObserver::heightIncrementChanged, this, &MirSurface::setHeightIncrement); |
1710 | - connect(observer.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) { |
1711 | - setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome)); |
1712 | - }); |
1713 | - connect(observer.get(), &SurfaceObserver::inputBoundsChanged, this, &MirSurface::setInputBounds); |
1714 | - connect(observer.get(), &SurfaceObserver::confinesMousePointerChanged, this, &MirSurface::confinesMousePointerChanged); |
1715 | - observer->setListener(this); |
1716 | - } |
1717 | - |
1718 | - connect(session, &QObject::destroyed, this, &MirSurface::onSessionDestroyed); |
1719 | + DEBUG_MSG << "(" |
1720 | + << "type=" << mirSurfaceTypeToStr(m_type) |
1721 | + << ",state=" << unityapiMirStateToStr(m_state) |
1722 | + << ")"; |
1723 | + |
1724 | + SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get()); |
1725 | + m_surface->add_observer(m_surfaceObserver); |
1726 | + |
1727 | + //m_shellChrome = creationHints.shellChrome; TODO - where will this come from now? |
1728 | + |
1729 | + connect(m_surfaceObserver.get(), &SurfaceObserver::framesPosted, this, &MirSurface::onFramesPostedObserved); |
1730 | + connect(m_surfaceObserver.get(), &SurfaceObserver::attributeChanged, this, &MirSurface::onAttributeChanged); |
1731 | + connect(m_surfaceObserver.get(), &SurfaceObserver::nameChanged, this, &MirSurface::onNameChanged); |
1732 | + connect(m_surfaceObserver.get(), &SurfaceObserver::cursorChanged, this, &MirSurface::setCursor); |
1733 | + connect(m_surfaceObserver.get(), &SurfaceObserver::minimumWidthChanged, this, &MirSurface::onMinimumWidthChanged); |
1734 | + connect(m_surfaceObserver.get(), &SurfaceObserver::minimumHeightChanged, this, &MirSurface::onMinimumHeightChanged); |
1735 | + connect(m_surfaceObserver.get(), &SurfaceObserver::maximumWidthChanged, this, &MirSurface::onMaximumWidthChanged); |
1736 | + connect(m_surfaceObserver.get(), &SurfaceObserver::maximumHeightChanged, this, &MirSurface::onMaximumHeightChanged); |
1737 | + connect(m_surfaceObserver.get(), &SurfaceObserver::widthIncrementChanged, this, &MirSurface::onWidthIncrementChanged); |
1738 | + connect(m_surfaceObserver.get(), &SurfaceObserver::heightIncrementChanged, this, &MirSurface::onHeightIncrementChanged); |
1739 | + connect(m_surfaceObserver.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) { |
1740 | + setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome)); |
1741 | + }); |
1742 | + connect(m_surfaceObserver.get(), &SurfaceObserver::inputBoundsChanged, this, &MirSurface::setInputBounds); |
1743 | + connect(m_surfaceObserver.get(), &SurfaceObserver::confinesMousePointerChanged, this, &MirSurface::confinesMousePointerChanged); |
1744 | + m_surfaceObserver->setListener(this); |
1745 | + |
1746 | + //connect(session, &QObject::destroyed, this, &MirSurface::onSessionDestroyed); // TODO try using Shared pointer for lifecycle |
1747 | connect(session, &SessionInterface::stateChanged, this, [this]() { |
1748 | if (clientIsRunning() && m_pendingResize.isValid()) { |
1749 | resize(m_pendingResize.width(), m_pendingResize.height()); |
1750 | @@ -124,10 +190,8 @@ |
1751 | |
1752 | setCloseTimer(new Timer); |
1753 | |
1754 | - QTimer::singleShot(m_minimumAgeForOcclusion, this, [this]() { |
1755 | - m_oldEnoughToBeOccluded = true; |
1756 | - updateVisibility(); |
1757 | - }); |
1758 | + m_requestedPosition.rx() = std::numeric_limits<int>::min(); |
1759 | + m_requestedPosition.ry() = std::numeric_limits<int>::min(); |
1760 | } |
1761 | |
1762 | MirSurface::~MirSurface() |
1763 | @@ -146,11 +210,6 @@ |
1764 | |
1765 | void MirSurface::onFramesPostedObserved() |
1766 | { |
1767 | - if (!m_firstFrameDrawn) { |
1768 | - m_firstFrameDrawn = true; |
1769 | - Q_EMIT firstFrameDrawn(); |
1770 | - } |
1771 | - |
1772 | // restart the frame dropper so that items have enough time to render the next frame. |
1773 | m_frameDropperTimer.start(); |
1774 | |
1775 | @@ -164,14 +223,6 @@ |
1776 | DEBUG_MSG << " type = " << mirSurfaceTypeToStr(state()); |
1777 | Q_EMIT typeChanged(type()); |
1778 | break; |
1779 | - case mir_surface_attrib_state: |
1780 | - DEBUG_MSG << " state = " << mirSurfaceStateToStr(state()); |
1781 | - Q_EMIT stateChanged(state()); |
1782 | - break; |
1783 | - case mir_surface_attrib_visibility: |
1784 | - DEBUG_MSG << " visible = " << visible(); |
1785 | - Q_EMIT visibleChanged(visible()); |
1786 | - break; |
1787 | default: |
1788 | break; |
1789 | } |
1790 | @@ -179,7 +230,7 @@ |
1791 | |
1792 | Mir::Type MirSurface::type() const |
1793 | { |
1794 | - switch (m_surface->type()) { |
1795 | + switch (m_type) { |
1796 | case mir_surface_type_normal: |
1797 | return Mir::NormalType; |
1798 | |
1799 | @@ -218,7 +269,7 @@ |
1800 | |
1801 | const void* const userId = (void*)123; // TODO: Multimonitor support |
1802 | |
1803 | - int framesPending = m_surface->buffers_ready_for_compositor(userId); |
1804 | + const int framesPending = m_surface->buffers_ready_for_compositor(userId); |
1805 | if (framesPending > 0) { |
1806 | m_textureUpdated = false; |
1807 | |
1808 | @@ -290,7 +341,7 @@ |
1809 | texture->setBuffer(renderables[0]->buffer()); |
1810 | ++m_currentFrameNumber; |
1811 | |
1812 | - if (texture->textureSize() != m_size) { |
1813 | + if (texture->textureSize() != size()) { |
1814 | m_size = texture->textureSize(); |
1815 | QMetaObject::invokeMethod(this, "emitSizeChanged", Qt::QueuedConnection); |
1816 | } |
1817 | @@ -325,6 +376,8 @@ |
1818 | if (m_focused == value) |
1819 | return; |
1820 | |
1821 | + DEBUG_MSG << "(" << value << ")"; |
1822 | + |
1823 | m_focused = value; |
1824 | Q_EMIT focusedChanged(value); |
1825 | } |
1826 | @@ -358,17 +411,30 @@ |
1827 | return; |
1828 | } |
1829 | |
1830 | + // TODO Figure out what to do here |
1831 | + /* |
1832 | if (m_activelyFocusedViews.isEmpty()) { |
1833 | DEBUG_MSG << "() unfocused"; |
1834 | - m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_focus, mir_surface_unfocused); |
1835 | + m_controller->setActiveFocus(m_window, false); |
1836 | } else { |
1837 | DEBUG_MSG << "() focused"; |
1838 | - m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_focus, mir_surface_focused); |
1839 | + m_controller->setActiveFocus(m_window, true); |
1840 | } |
1841 | + */ |
1842 | |
1843 | m_neverSetSurfaceFocus = false; |
1844 | } |
1845 | |
1846 | +void MirSurface::updateVisible() |
1847 | +{ |
1848 | + const bool visible = !(m_state == Mir::HiddenState || m_state == Mir::MinimizedState) && m_surface->visible(); |
1849 | + |
1850 | + if (m_visible != visible) { |
1851 | + m_visible = visible; |
1852 | + Q_EMIT visibleChanged(visible); |
1853 | + } |
1854 | +} |
1855 | + |
1856 | void MirSurface::close() |
1857 | { |
1858 | if (m_closingState != NotClosing) { |
1859 | @@ -381,8 +447,8 @@ |
1860 | Q_EMIT closeRequested(); |
1861 | m_closeTimer->start(); |
1862 | |
1863 | - if (m_surface) { |
1864 | - m_surface->request_client_surface_close(); |
1865 | + if (m_window) { |
1866 | + m_controller->requestClose(m_window); |
1867 | } |
1868 | } |
1869 | |
1870 | @@ -393,19 +459,28 @@ |
1871 | return; |
1872 | } |
1873 | |
1874 | - int mirWidth = m_surface->size().width.as_int(); |
1875 | - int mirHeight = m_surface->size().height.as_int(); |
1876 | - |
1877 | - bool mirSizeIsDifferent = width != mirWidth || height != mirHeight; |
1878 | + bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height(); |
1879 | |
1880 | if (mirSizeIsDifferent) { |
1881 | - mir::geometry::Size newMirSize(width, height); |
1882 | - m_surface->resize(newMirSize); |
1883 | - DEBUG_MSG << " old (" << mirWidth << "," << mirHeight << ")" |
1884 | + m_controller->resize(m_window, QSize(width, height)); |
1885 | + DEBUG_MSG << " old (" << m_size.width() << "," << m_size.height() << ")" |
1886 | << ", new (" << width << "," << height << ")"; |
1887 | } |
1888 | } |
1889 | |
1890 | +QPoint MirSurface::position() const |
1891 | +{ |
1892 | + return m_position; |
1893 | +} |
1894 | + |
1895 | +void MirSurface::setPosition(const QPoint newPosition) |
1896 | +{ |
1897 | + if (m_position != newPosition) { |
1898 | + m_position = newPosition; |
1899 | + Q_EMIT positionChanged(newPosition); |
1900 | + } |
1901 | +} |
1902 | + |
1903 | QSize MirSurface::size() const |
1904 | { |
1905 | return m_size; |
1906 | @@ -413,26 +488,7 @@ |
1907 | |
1908 | Mir::State MirSurface::state() const |
1909 | { |
1910 | - switch (m_surface->state()) { |
1911 | - case mir_surface_state_unknown: |
1912 | - return Mir::UnknownState; |
1913 | - case mir_surface_state_restored: |
1914 | - return Mir::RestoredState; |
1915 | - case mir_surface_state_minimized: |
1916 | - return Mir::MinimizedState; |
1917 | - case mir_surface_state_maximized: |
1918 | - return Mir::MaximizedState; |
1919 | - case mir_surface_state_vertmaximized: |
1920 | - return Mir::VertMaximizedState; |
1921 | - case mir_surface_state_fullscreen: |
1922 | - return Mir::FullscreenState; |
1923 | - case mir_surface_state_horizmaximized: |
1924 | - return Mir::HorizMaximizedState; |
1925 | - case mir_surface_state_hidden: |
1926 | - return Mir::HiddenState; |
1927 | - default: |
1928 | - return Mir::UnknownState; |
1929 | - } |
1930 | + return m_state; |
1931 | } |
1932 | |
1933 | Mir::OrientationAngle MirSurface::orientationAngle() const |
1934 | @@ -477,54 +533,18 @@ |
1935 | |
1936 | QString MirSurface::name() const |
1937 | { |
1938 | - return QString::fromStdString(m_surface->name()); |
1939 | + return m_name; |
1940 | } |
1941 | |
1942 | QString MirSurface::persistentId() const |
1943 | { |
1944 | - return m_persistentId; |
1945 | + return m_extraInfo->persistentId; |
1946 | } |
1947 | |
1948 | -void MirSurface::setState(Mir::State qmlState) |
1949 | +void MirSurface::requestState(Mir::State state) |
1950 | { |
1951 | - int mirState; |
1952 | - |
1953 | - switch (qmlState) { |
1954 | - default: |
1955 | - case Mir::UnknownState: |
1956 | - mirState = mir_surface_state_unknown; |
1957 | - break; |
1958 | - |
1959 | - case Mir::RestoredState: |
1960 | - mirState = mir_surface_state_restored; |
1961 | - break; |
1962 | - |
1963 | - case Mir::MinimizedState: |
1964 | - mirState = mir_surface_state_minimized; |
1965 | - break; |
1966 | - |
1967 | - case Mir::MaximizedState: |
1968 | - mirState = mir_surface_state_maximized; |
1969 | - break; |
1970 | - |
1971 | - case Mir::VertMaximizedState: |
1972 | - mirState = mir_surface_state_vertmaximized; |
1973 | - break; |
1974 | - |
1975 | - case Mir::FullscreenState: |
1976 | - mirState = mir_surface_state_fullscreen; |
1977 | - break; |
1978 | - |
1979 | - case Mir::HorizMaximizedState: |
1980 | - mirState = mir_surface_state_horizmaximized; |
1981 | - break; |
1982 | - |
1983 | - case Mir::HiddenState: |
1984 | - mirState = mir_surface_state_hidden; |
1985 | - break; |
1986 | - } |
1987 | - |
1988 | - m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_state, mirState); |
1989 | + DEBUG_MSG << "(" << unityapiMirStateToStr(state) << ")"; |
1990 | + m_controller->requestState(m_window, state); |
1991 | } |
1992 | |
1993 | void MirSurface::setLive(bool value) |
1994 | @@ -546,69 +566,78 @@ |
1995 | |
1996 | bool MirSurface::visible() const |
1997 | { |
1998 | - return m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed; |
1999 | + return m_visible; |
2000 | } |
2001 | - |
2002 | +#include <mir_toolkit/event.h> |
2003 | void MirSurface::mousePressEvent(QMouseEvent *event) |
2004 | { |
2005 | auto ev = EventBuilder::instance()->reconstructMirEvent(event); |
2006 | - m_surface->consume(ev.get()); |
2007 | + auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
2008 | + m_controller->deliverPointerEvent(m_window, ev1); |
2009 | event->accept(); |
2010 | } |
2011 | |
2012 | void MirSurface::mouseMoveEvent(QMouseEvent *event) |
2013 | { |
2014 | auto ev = EventBuilder::instance()->reconstructMirEvent(event); |
2015 | - m_surface->consume(ev.get()); |
2016 | + auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
2017 | + m_controller->deliverPointerEvent(m_window, ev1); |
2018 | event->accept(); |
2019 | } |
2020 | |
2021 | void MirSurface::mouseReleaseEvent(QMouseEvent *event) |
2022 | { |
2023 | auto ev = EventBuilder::instance()->reconstructMirEvent(event); |
2024 | - m_surface->consume(ev.get()); |
2025 | + auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
2026 | + m_controller->deliverPointerEvent(m_window, ev1); |
2027 | event->accept(); |
2028 | } |
2029 | |
2030 | void MirSurface::hoverEnterEvent(QHoverEvent *event) |
2031 | { |
2032 | auto ev = EventBuilder::instance()->reconstructMirEvent(event); |
2033 | - m_surface->consume(ev.get()); |
2034 | + auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
2035 | + m_controller->deliverPointerEvent(m_window, ev1); |
2036 | event->accept(); |
2037 | } |
2038 | |
2039 | void MirSurface::hoverLeaveEvent(QHoverEvent *event) |
2040 | { |
2041 | auto ev = EventBuilder::instance()->reconstructMirEvent(event); |
2042 | - m_surface->consume(ev.get()); |
2043 | + auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
2044 | + m_controller->deliverPointerEvent(m_window, ev1); |
2045 | event->accept(); |
2046 | } |
2047 | |
2048 | void MirSurface::hoverMoveEvent(QHoverEvent *event) |
2049 | { |
2050 | auto ev = EventBuilder::instance()->reconstructMirEvent(event); |
2051 | - m_surface->consume(ev.get()); |
2052 | + auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
2053 | + m_controller->deliverPointerEvent(m_window, ev1); |
2054 | event->accept(); |
2055 | } |
2056 | |
2057 | void MirSurface::wheelEvent(QWheelEvent *event) |
2058 | { |
2059 | auto ev = EventBuilder::instance()->makeMirEvent(event); |
2060 | - m_surface->consume(ev.get()); |
2061 | + auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get()); |
2062 | + m_controller->deliverPointerEvent(m_window, ev1); |
2063 | event->accept(); |
2064 | } |
2065 | |
2066 | void MirSurface::keyPressEvent(QKeyEvent *qtEvent) |
2067 | { |
2068 | auto ev = EventBuilder::instance()->makeMirEvent(qtEvent); |
2069 | - m_surface->consume(ev.get()); |
2070 | + auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); |
2071 | + m_controller->deliverKeyboardEvent(m_window, ev1); |
2072 | qtEvent->accept(); |
2073 | } |
2074 | |
2075 | void MirSurface::keyReleaseEvent(QKeyEvent *qtEvent) |
2076 | { |
2077 | auto ev = EventBuilder::instance()->makeMirEvent(qtEvent); |
2078 | - m_surface->consume(ev.get()); |
2079 | + auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get()); |
2080 | + m_controller->deliverKeyboardEvent(m_window, ev1); |
2081 | qtEvent->accept(); |
2082 | } |
2083 | |
2084 | @@ -618,15 +647,16 @@ |
2085 | ulong timestamp) |
2086 | { |
2087 | auto ev = EventBuilder::instance()->makeMirEvent(mods, touchPoints, touchPointStates, timestamp); |
2088 | - m_surface->consume(ev.get()); |
2089 | + auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get()); |
2090 | + m_controller->deliverTouchEvent(m_window, ev1); |
2091 | } |
2092 | |
2093 | bool MirSurface::clientIsRunning() const |
2094 | { |
2095 | return (m_session && |
2096 | - (m_session->state() == Session::State::Running |
2097 | - || m_session->state() == Session::State::Starting |
2098 | - || m_session->state() == Session::State::Suspending)) |
2099 | + (m_session->state() == SessionInterface::State::Running |
2100 | + || m_session->state() == SessionInterface::State::Starting |
2101 | + || m_session->state() == SessionInterface::State::Suspending)) |
2102 | || !m_session; |
2103 | } |
2104 | |
2105 | @@ -654,39 +684,40 @@ |
2106 | deleteLater(); |
2107 | } |
2108 | } |
2109 | - updateVisibility(); |
2110 | + updateExposure(); |
2111 | setViewActiveFocus(viewId, false); |
2112 | } |
2113 | |
2114 | -void MirSurface::setViewVisibility(qintptr viewId, bool visible) |
2115 | +void MirSurface::setViewExposure(qintptr viewId, bool exposed) |
2116 | { |
2117 | if (!m_views.contains(viewId)) return; |
2118 | |
2119 | - m_views[viewId].visible = visible; |
2120 | - updateVisibility(); |
2121 | + m_views[viewId].exposed = exposed; |
2122 | + updateExposure(); |
2123 | } |
2124 | |
2125 | -void MirSurface::updateVisibility() |
2126 | +void MirSurface::updateExposure() |
2127 | { |
2128 | - bool newVisible = false; |
2129 | - |
2130 | - if (m_oldEnoughToBeOccluded) { |
2131 | - QHashIterator<qintptr, View> i(m_views); |
2132 | - while (i.hasNext()) { |
2133 | - i.next(); |
2134 | - newVisible |= i.value().visible; |
2135 | - } |
2136 | - } else { |
2137 | - // Surface is too young to get occluded. Let it remain exposed for a bit to ensure that it displays |
2138 | - // a properly formed UI on start up. |
2139 | - newVisible = true; |
2140 | - } |
2141 | - |
2142 | - if (newVisible != visible()) { |
2143 | - DEBUG_MSG << "(" << newVisible << ")"; |
2144 | + // Only update exposure after client has swapped a frame (aka surface is "ready"). MirAL only considers |
2145 | + // a surface visible after it has drawn something |
2146 | + if (!m_ready) { |
2147 | + return; |
2148 | + } |
2149 | + |
2150 | + bool newExposed = false; |
2151 | + QHashIterator<qintptr, View> i(m_views); |
2152 | + while (i.hasNext()) { |
2153 | + i.next(); |
2154 | + newExposed |= i.value().exposed; |
2155 | + } |
2156 | + |
2157 | + const bool oldExposed = (m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed); |
2158 | + |
2159 | + if (newExposed != oldExposed) { |
2160 | + DEBUG_MSG << "(" << newExposed << ")"; |
2161 | |
2162 | m_surface->configure(mir_surface_attrib_visibility, |
2163 | - newVisible ? mir_surface_visibility_exposed : mir_surface_visibility_occluded); |
2164 | + newExposed ? mir_surface_visibility_exposed : mir_surface_visibility_occluded); |
2165 | } |
2166 | } |
2167 | |
2168 | @@ -777,15 +808,6 @@ |
2169 | } |
2170 | } |
2171 | |
2172 | -void MirSurface::setScreen(QScreen *screen) |
2173 | -{ |
2174 | - using namespace mir::geometry; |
2175 | - // in Mir, this means moving the surface in Mir's scene to the matching display |
2176 | - auto targetScreenTopLeftPx = screen->geometry().topLeft(); // * screen->devicePixelRatio(); GERRY? |
2177 | - DEBUG_MSG << "moved to" << targetScreenTopLeftPx << "px"; |
2178 | - m_surface->move_to(Point{ X{targetScreenTopLeftPx.x()}, Y{targetScreenTopLeftPx.y()} }); |
2179 | -} |
2180 | - |
2181 | bool MirSurface::inputAreaContains(const QPoint &point) const |
2182 | { |
2183 | bool result; |
2184 | @@ -804,6 +826,30 @@ |
2185 | return result; |
2186 | } |
2187 | |
2188 | +void MirSurface::updateState(Mir::State newState) |
2189 | +{ |
2190 | + if (newState == m_state) { |
2191 | + return; |
2192 | + } |
2193 | + DEBUG_MSG << "(" << unityapiMirStateToStr(newState) << ")"; |
2194 | + |
2195 | + m_state = newState; |
2196 | + Q_EMIT stateChanged(state()); |
2197 | + |
2198 | + // Mir determines visibility from the state, it may have changed |
2199 | + updateVisible(); |
2200 | +} |
2201 | + |
2202 | +void MirSurface::setReady() |
2203 | +{ |
2204 | + if (!m_ready) { |
2205 | + DEBUG_MSG << "()"; |
2206 | + m_ready = true; |
2207 | + Q_EMIT ready(); |
2208 | + updateExposure(); |
2209 | + } |
2210 | +} |
2211 | + |
2212 | void MirSurface::setCursor(const QCursor &cursor) |
2213 | { |
2214 | DEBUG_MSG << "(" << qtCursorShapeToStr(cursor.shape()) << ")"; |
2215 | @@ -814,80 +860,32 @@ |
2216 | |
2217 | int MirSurface::minimumWidth() const |
2218 | { |
2219 | - return m_minimumWidth; |
2220 | + return m_minWidth; |
2221 | } |
2222 | |
2223 | int MirSurface::minimumHeight() const |
2224 | { |
2225 | - return m_minimumHeight; |
2226 | + return m_minHeight; |
2227 | } |
2228 | |
2229 | int MirSurface::maximumWidth() const |
2230 | { |
2231 | - return m_maximumWidth; |
2232 | + return m_maxWidth; |
2233 | } |
2234 | |
2235 | int MirSurface::maximumHeight() const |
2236 | { |
2237 | - return m_maximumHeight; |
2238 | + return m_maxHeight; |
2239 | } |
2240 | |
2241 | int MirSurface::widthIncrement() const |
2242 | { |
2243 | - return m_widthIncrement; |
2244 | + return m_incWidth; |
2245 | } |
2246 | |
2247 | int MirSurface::heightIncrement() const |
2248 | { |
2249 | - return m_heightIncrement; |
2250 | -} |
2251 | - |
2252 | -void MirSurface::setMinimumWidth(int value) |
2253 | -{ |
2254 | - if (value != m_minimumWidth) { |
2255 | - m_minimumWidth = value; |
2256 | - Q_EMIT minimumWidthChanged(value); |
2257 | - } |
2258 | -} |
2259 | - |
2260 | -void MirSurface::setMinimumHeight(int value) |
2261 | -{ |
2262 | - if (value != m_minimumHeight) { |
2263 | - m_minimumHeight = value; |
2264 | - Q_EMIT minimumHeightChanged(value); |
2265 | - } |
2266 | -} |
2267 | - |
2268 | -void MirSurface::setMaximumWidth(int value) |
2269 | -{ |
2270 | - if (value != m_maximumWidth) { |
2271 | - m_maximumWidth = value; |
2272 | - Q_EMIT maximumWidthChanged(value); |
2273 | - } |
2274 | -} |
2275 | - |
2276 | -void MirSurface::setMaximumHeight(int value) |
2277 | -{ |
2278 | - if (value != m_maximumHeight) { |
2279 | - m_maximumHeight = value; |
2280 | - Q_EMIT maximumHeightChanged(value); |
2281 | - } |
2282 | -} |
2283 | - |
2284 | -void MirSurface::setWidthIncrement(int value) |
2285 | -{ |
2286 | - if (value != m_widthIncrement) { |
2287 | - m_widthIncrement = value; |
2288 | - Q_EMIT widthIncrementChanged(value); |
2289 | - } |
2290 | -} |
2291 | - |
2292 | -void MirSurface::setHeightIncrement(int value) |
2293 | -{ |
2294 | - if (value != m_heightIncrement) { |
2295 | - m_heightIncrement = value; |
2296 | - Q_EMIT heightIncrementChanged(value); |
2297 | - } |
2298 | + return m_incHeight; |
2299 | } |
2300 | |
2301 | bool MirSurface::focused() const |
2302 | @@ -905,16 +903,12 @@ |
2303 | return m_surface->confine_pointer_state() == mir_pointer_confined_to_surface; |
2304 | } |
2305 | |
2306 | -void MirSurface::requestFocus() |
2307 | -{ |
2308 | - DEBUG_MSG << "()"; |
2309 | - Q_EMIT focusRequested(); |
2310 | -} |
2311 | - |
2312 | -void MirSurface::raise() |
2313 | -{ |
2314 | - DEBUG_MSG << "()"; |
2315 | - Q_EMIT raiseRequested(); |
2316 | +void MirSurface::activate() |
2317 | +{ |
2318 | + DEBUG_MSG << "()"; |
2319 | + if (m_live) { |
2320 | + m_controller->activate(m_window); |
2321 | + } |
2322 | } |
2323 | |
2324 | void MirSurface::onCloseTimedOut() |
2325 | @@ -925,7 +919,9 @@ |
2326 | |
2327 | m_closingState = CloseOverdue; |
2328 | |
2329 | - m_session->session()->destroy_surface(m_surface); |
2330 | + if (m_live) { |
2331 | + m_controller->forceClose(m_window); |
2332 | + } |
2333 | } |
2334 | |
2335 | void MirSurface::setCloseTimer(AbstractTimer *timer) |
2336 | @@ -947,6 +943,11 @@ |
2337 | } |
2338 | } |
2339 | |
2340 | +std::shared_ptr<SurfaceObserver> MirSurface::surfaceObserver() const |
2341 | +{ |
2342 | + return m_surfaceObserver; |
2343 | +} |
2344 | + |
2345 | void MirSurface::setInputBounds(const QRect &rect) |
2346 | { |
2347 | if (m_inputBounds != rect) { |
2348 | @@ -955,3 +956,230 @@ |
2349 | Q_EMIT inputBoundsChanged(m_inputBounds); |
2350 | } |
2351 | } |
2352 | + |
2353 | +QPoint MirSurface::requestedPosition() const |
2354 | +{ |
2355 | + return m_requestedPosition; |
2356 | +} |
2357 | + |
2358 | +void MirSurface::setRequestedPosition(const QPoint &point) |
2359 | +{ |
2360 | + if (point != m_requestedPosition) { |
2361 | + m_requestedPosition = point; |
2362 | + Q_EMIT requestedPositionChanged(m_requestedPosition); |
2363 | + |
2364 | + if (m_live) { |
2365 | + m_controller->move(m_window, m_requestedPosition); |
2366 | + } |
2367 | + } |
2368 | +} |
2369 | + |
2370 | +void MirSurface::onMinimumWidthChanged(int minWidth) |
2371 | +{ |
2372 | + if (m_minWidth != minWidth) |
2373 | + { |
2374 | + m_minWidth = minWidth; |
2375 | + Q_EMIT minimumWidthChanged(minWidth); |
2376 | + } |
2377 | +} |
2378 | + |
2379 | +void MirSurface::onMinimumHeightChanged(int minHeight) |
2380 | +{ |
2381 | + if (m_minHeight != minHeight) |
2382 | + { |
2383 | + m_minHeight = minHeight; |
2384 | + Q_EMIT minimumHeightChanged(minHeight); |
2385 | + } |
2386 | +} |
2387 | + |
2388 | +void MirSurface::onMaximumWidthChanged(int maxWidth) |
2389 | +{ |
2390 | + if (m_maxWidth != maxWidth) |
2391 | + { |
2392 | + m_maxWidth = maxWidth; |
2393 | + Q_EMIT maximumWidthChanged(maxWidth); |
2394 | + } |
2395 | +} |
2396 | + |
2397 | +void MirSurface::onMaximumHeightChanged(int maxHeight) |
2398 | +{ |
2399 | + if (m_maxHeight != maxHeight) |
2400 | + { |
2401 | + m_maxHeight = maxHeight; |
2402 | + Q_EMIT maximumHeightChanged(maxHeight); |
2403 | + } |
2404 | +} |
2405 | + |
2406 | +void MirSurface::onWidthIncrementChanged(int incWidth) |
2407 | +{ |
2408 | + if (m_incWidth != incWidth) |
2409 | + { |
2410 | + m_incWidth = incWidth; |
2411 | + Q_EMIT widthIncrementChanged(incWidth); |
2412 | + } |
2413 | +} |
2414 | + |
2415 | +void MirSurface::onHeightIncrementChanged(int incHeight) |
2416 | +{ |
2417 | + if (m_incHeight != incHeight) |
2418 | + { |
2419 | + m_incHeight = incHeight; |
2420 | + Q_EMIT heightIncrementChanged(incHeight); |
2421 | + } |
2422 | +} |
2423 | + |
2424 | +void MirSurface::onNameChanged(const QString &name) |
2425 | +{ |
2426 | + if (m_name != name) |
2427 | + { |
2428 | + m_name = name; |
2429 | + Q_EMIT nameChanged(name); |
2430 | + } |
2431 | +} |
2432 | + |
2433 | +MirSurface::SurfaceObserverImpl::SurfaceObserverImpl() |
2434 | + : m_listener(nullptr) |
2435 | + , m_framesPosted(false) |
2436 | +{ |
2437 | + m_cursorNameToShape["left_ptr"] = Qt::ArrowCursor; |
2438 | + m_cursorNameToShape["up_arrow"] = Qt::UpArrowCursor; |
2439 | + m_cursorNameToShape["cross"] = Qt::CrossCursor; |
2440 | + m_cursorNameToShape["watch"] = Qt::WaitCursor; |
2441 | + m_cursorNameToShape["xterm"] = Qt::IBeamCursor; |
2442 | + m_cursorNameToShape["size_ver"] = Qt::SizeVerCursor; |
2443 | + m_cursorNameToShape["size_hor"] = Qt::SizeHorCursor; |
2444 | + m_cursorNameToShape["size_bdiag"] = Qt::SizeBDiagCursor; |
2445 | + m_cursorNameToShape["size_fdiag"] = Qt::SizeFDiagCursor; |
2446 | + m_cursorNameToShape["size_all"] = Qt::SizeAllCursor; |
2447 | + m_cursorNameToShape["blank"] = Qt::BlankCursor; |
2448 | + m_cursorNameToShape["split_v"] = Qt::SplitVCursor; |
2449 | + m_cursorNameToShape["split_h"] = Qt::SplitHCursor; |
2450 | + m_cursorNameToShape["hand"] = Qt::PointingHandCursor; |
2451 | + m_cursorNameToShape["forbidden"] = Qt::ForbiddenCursor; |
2452 | + m_cursorNameToShape["whats_this"] = Qt::WhatsThisCursor; |
2453 | + m_cursorNameToShape["left_ptr_watch"] = Qt::BusyCursor; |
2454 | + m_cursorNameToShape["openhand"] = Qt::OpenHandCursor; |
2455 | + m_cursorNameToShape["closedhand"] = Qt::ClosedHandCursor; |
2456 | + m_cursorNameToShape["dnd-copy"] = Qt::DragCopyCursor; |
2457 | + m_cursorNameToShape["dnd-move"] = Qt::DragMoveCursor; |
2458 | + m_cursorNameToShape["dnd-link"] = Qt::DragLinkCursor; |
2459 | + |
2460 | + // Used by Mir client API (mir_*_cursor_name strings) |
2461 | + m_cursorNameToShape["default"] = Qt::ArrowCursor; |
2462 | + m_cursorNameToShape["disabled"] = Qt::BlankCursor; |
2463 | + m_cursorNameToShape["arrow"] = Qt::ArrowCursor; |
2464 | + m_cursorNameToShape["busy"] = Qt::WaitCursor; |
2465 | + m_cursorNameToShape["caret"] = Qt::IBeamCursor; |
2466 | + m_cursorNameToShape["pointing-hand"] = Qt::PointingHandCursor; |
2467 | + m_cursorNameToShape["open-hand"] = Qt::OpenHandCursor; |
2468 | + m_cursorNameToShape["closed-hand"] = Qt::ClosedHandCursor; |
2469 | + m_cursorNameToShape["horizontal-resize"] = Qt::SizeHorCursor; |
2470 | + m_cursorNameToShape["vertical-resize"] = Qt::SizeVerCursor; |
2471 | + m_cursorNameToShape["diagonal-resize-bottom-to-top"] = Qt::SizeBDiagCursor; |
2472 | + m_cursorNameToShape["diagonal-resize-top_to_bottom"] = Qt::SizeFDiagCursor; // current string with typo |
2473 | + m_cursorNameToShape["diagonal-resize-top-to-bottom"] = Qt::SizeFDiagCursor; // how it will be when they fix it (if ever) |
2474 | + m_cursorNameToShape["omnidirectional-resize"] = Qt::SizeAllCursor; |
2475 | + m_cursorNameToShape["vsplit-resize"] = Qt::SplitVCursor; |
2476 | + m_cursorNameToShape["hsplit-resize"] = Qt::SplitHCursor; |
2477 | + m_cursorNameToShape["crosshair"] = Qt::CrossCursor; |
2478 | + |
2479 | + qRegisterMetaType<MirShellChrome>("MirShellChrome"); |
2480 | +} |
2481 | + |
2482 | +MirSurface::SurfaceObserverImpl::~SurfaceObserverImpl() |
2483 | +{ |
2484 | +} |
2485 | + |
2486 | +void MirSurface::SurfaceObserverImpl::setListener(QObject *listener) |
2487 | +{ |
2488 | + m_listener = listener; |
2489 | + if (m_framesPosted) { |
2490 | + Q_EMIT framesPosted(); |
2491 | + } |
2492 | +} |
2493 | + |
2494 | +void MirSurface::SurfaceObserverImpl::frame_posted(int /*frames_available*/, mir::geometry::Size const& /*size*/) |
2495 | +{ |
2496 | + m_framesPosted = true; |
2497 | + if (m_listener) { |
2498 | + Q_EMIT framesPosted(); |
2499 | + } |
2500 | +} |
2501 | + |
2502 | +void MirSurface::SurfaceObserverImpl::renamed(char const * name) |
2503 | +{ |
2504 | + Q_EMIT nameChanged(QString::fromUtf8(name)); |
2505 | +} |
2506 | + |
2507 | +void MirSurface::SurfaceObserverImpl::cursor_image_removed() |
2508 | +{ |
2509 | + Q_EMIT cursorChanged(QCursor()); |
2510 | +} |
2511 | + |
2512 | +#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0) |
2513 | +void MirSurface::SurfaceObserverImpl::placed_relative(mir::geometry::Rectangle const& /*placement*/) |
2514 | +{ |
2515 | +} |
2516 | +#endif |
2517 | + |
2518 | +void MirSurface::SurfaceObserverImpl::attrib_changed(MirSurfaceAttrib attribute, int value) |
2519 | +{ |
2520 | + if (m_listener) { |
2521 | + Q_EMIT attributeChanged(attribute, value); |
2522 | + } |
2523 | +} |
2524 | + |
2525 | +void MirSurface::SurfaceObserverImpl::resized_to(mir::geometry::Size const&size) |
2526 | +{ |
2527 | + Q_EMIT resized(QSize(size.width.as_int(), size.height.as_int())); |
2528 | +} |
2529 | + |
2530 | +void MirSurface::SurfaceObserverImpl::cursor_image_set_to(const mir::graphics::CursorImage &cursorImage) |
2531 | +{ |
2532 | + QCursor qcursor = createQCursorFromMirCursorImage(cursorImage); |
2533 | + Q_EMIT cursorChanged(qcursor); |
2534 | +} |
2535 | + |
2536 | +void MirSurface::SurfaceObserverImpl::keymap_changed(MirInputDeviceId, const std::string &, const std::string &layout, |
2537 | + const std::string &variant, const std::string &) |
2538 | +{ |
2539 | + Q_EMIT keymapChanged(QString::fromStdString(layout), QString::fromStdString(variant)); |
2540 | +} |
2541 | + |
2542 | +QCursor MirSurface::SurfaceObserverImpl::createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage) { |
2543 | + if (cursorImage.as_argb_8888() == nullptr) { |
2544 | + // Must be a named cursor |
2545 | + auto namedCursor = dynamic_cast<const qtmir::NamedCursor*>(&cursorImage); |
2546 | + Q_ASSERT(namedCursor != nullptr); |
2547 | + if (namedCursor) { |
2548 | + // NB: If we need a named cursor not covered by Qt::CursorShape, we won't be able to |
2549 | + // used Qt's cursor API anymore for transmitting MirSurface's cursor image. |
2550 | + |
2551 | + Qt::CursorShape cursorShape = Qt::ArrowCursor; |
2552 | + { |
2553 | + auto iterator = m_cursorNameToShape.constFind(namedCursor->name()); |
2554 | + if (iterator == m_cursorNameToShape.constEnd()) { |
2555 | + qCWarning(QTMIR_SURFACES).nospace() << "SurfaceObserver: unrecognized cursor name " |
2556 | + << namedCursor->name(); |
2557 | + } else { |
2558 | + cursorShape = iterator.value(); |
2559 | + } |
2560 | + } |
2561 | + return QCursor(cursorShape); |
2562 | + } else { |
2563 | + // shouldn't happen |
2564 | + return QCursor(); |
2565 | + } |
2566 | + } else { |
2567 | + QImage image((const uchar*)cursorImage.as_argb_8888(), |
2568 | + cursorImage.size().width.as_int(), cursorImage.size().height.as_int(), QImage::Format_ARGB32); |
2569 | + |
2570 | + return QCursor(QPixmap::fromImage(image), cursorImage.hotspot().dx.as_int(), cursorImage.hotspot().dy.as_int()); |
2571 | + } |
2572 | +} |
2573 | + |
2574 | +void MirSurface::requestFocus() |
2575 | +{ |
2576 | + DEBUG_MSG << "()"; |
2577 | + Q_EMIT focusRequested(); |
2578 | +} |
2579 | |
2580 | === modified file 'src/modules/Unity/Application/mirsurface.h' |
2581 | --- src/modules/Unity/Application/mirsurface.h 2016-10-11 20:50:50 +0000 |
2582 | +++ src/modules/Unity/Application/mirsurface.h 2016-12-16 08:22:54 +0000 |
2583 | @@ -22,45 +22,37 @@ |
2584 | |
2585 | // Qt |
2586 | #include <QCursor> |
2587 | -#include <QElapsedTimer> |
2588 | #include <QMutex> |
2589 | #include <QPointer> |
2590 | #include <QRect> |
2591 | #include <QSharedPointer> |
2592 | #include <QWeakPointer> |
2593 | #include <QSet> |
2594 | +#include <QTimer> |
2595 | |
2596 | #include "mirbuffersgtexture.h" |
2597 | -#include "session.h" |
2598 | - |
2599 | -// mirserver |
2600 | -#include "creationhints.h" |
2601 | +#include "windowcontrollerinterface.h" |
2602 | +#include "windowmodelnotifier.h" |
2603 | |
2604 | // mir |
2605 | #include <mir_toolkit/common.h> |
2606 | |
2607 | -namespace mir { |
2608 | -namespace shell { class Shell; } |
2609 | -namespace scene {class Surface; } |
2610 | -} |
2611 | |
2612 | class SurfaceObserver; |
2613 | |
2614 | namespace qtmir { |
2615 | |
2616 | class AbstractTimer; |
2617 | +class SessionInterface; |
2618 | |
2619 | class MirSurface : public MirSurfaceInterface |
2620 | { |
2621 | Q_OBJECT |
2622 | |
2623 | public: |
2624 | - MirSurface(std::shared_ptr<mir::scene::Surface> surface, |
2625 | - const QString& persistentId, |
2626 | - SessionInterface* session, |
2627 | - mir::shell::Shell *shell, |
2628 | - std::shared_ptr<SurfaceObserver> observer, |
2629 | - const CreationHints &); |
2630 | + MirSurface(NewWindow windowInfo, |
2631 | + WindowControllerInterface *controller, |
2632 | + SessionInterface *session = nullptr); |
2633 | virtual ~MirSurface(); |
2634 | |
2635 | //// |
2636 | @@ -74,10 +66,14 @@ |
2637 | |
2638 | QSize size() const override; |
2639 | void resize(int width, int height) override; |
2640 | - void resize(const QSize &size) override { resize(size.width(), size.height()); } |
2641 | + Q_INVOKABLE void resize(const QSize &size) override { resize(size.width(), size.height()); } |
2642 | + |
2643 | + QPoint position() const override; |
2644 | + |
2645 | + QPoint requestedPosition() const override; |
2646 | + void setRequestedPosition(const QPoint &) override; |
2647 | |
2648 | Mir::State state() const override; |
2649 | - void setState(Mir::State qmlState) override; |
2650 | |
2651 | bool live() const override; |
2652 | |
2653 | @@ -98,16 +94,15 @@ |
2654 | |
2655 | bool confinesMousePointer() const override; |
2656 | |
2657 | - Q_INVOKABLE void requestFocus() override; |
2658 | + Q_INVOKABLE void activate() override; |
2659 | Q_INVOKABLE void close() override; |
2660 | - Q_INVOKABLE void raise() override; |
2661 | |
2662 | //// |
2663 | // qtmir::MirSurfaceInterface |
2664 | |
2665 | void setLive(bool value) override; |
2666 | |
2667 | - bool isFirstFrameDrawn() const override { return m_firstFrameDrawn; } |
2668 | + bool isReady() const override { return m_ready; } |
2669 | |
2670 | void stopFrameDropper() override; |
2671 | void startFrameDropper() override; |
2672 | @@ -116,7 +111,7 @@ |
2673 | |
2674 | void registerView(qintptr viewId) override; |
2675 | void unregisterView(qintptr viewId) override; |
2676 | - void setViewVisibility(qintptr viewId, bool visible) override; |
2677 | + void setViewExposure(qintptr viewId, bool exposed) override; |
2678 | |
2679 | // methods called from the rendering (scene graph) thread: |
2680 | QSharedPointer<QSGTexture> texture() override; |
2681 | @@ -156,27 +151,31 @@ |
2682 | |
2683 | Mir::ShellChrome shellChrome() const override; |
2684 | |
2685 | - void setScreen(QScreen *screen) override; |
2686 | - |
2687 | SessionInterface* session() override { return m_session.data(); } |
2688 | |
2689 | bool inputAreaContains(const QPoint &) const override; |
2690 | |
2691 | + void requestFocus() override; |
2692 | + |
2693 | //// |
2694 | // Own API |
2695 | + void setPosition(const QPoint newPosition); |
2696 | + void updateState(Mir::State state); |
2697 | + void setReady(); |
2698 | + miral::Window window() const { return m_window; } |
2699 | |
2700 | // useful for tests |
2701 | void setCloseTimer(AbstractTimer *timer); |
2702 | + std::shared_ptr<SurfaceObserver> surfaceObserver() const; |
2703 | |
2704 | public Q_SLOTS: |
2705 | + //// |
2706 | + // unity::shell::application::MirSurfaceInterface |
2707 | + void requestState(Mir::State qmlState) override; |
2708 | + |
2709 | + //// |
2710 | + // qtmir::MirSurfaceInterface |
2711 | void onCompositorSwappedBuffers() override; |
2712 | - |
2713 | - void setMinimumWidth(int) override; |
2714 | - void setMinimumHeight(int) override; |
2715 | - void setMaximumWidth(int) override; |
2716 | - void setMaximumHeight(int) override; |
2717 | - void setWidthIncrement(int) override; |
2718 | - void setHeightIncrement(int) override; |
2719 | void setShellChrome(Mir::ShellChrome shellChrome) override; |
2720 | |
2721 | private Q_SLOTS: |
2722 | @@ -192,15 +191,32 @@ |
2723 | private: |
2724 | void syncSurfaceSizeWithItemSize(); |
2725 | bool clientIsRunning() const; |
2726 | - void updateVisibility(); |
2727 | + void updateExposure(); |
2728 | void applyKeymap(); |
2729 | void updateActiveFocus(); |
2730 | - |
2731 | - std::shared_ptr<mir::scene::Surface> m_surface; |
2732 | + void updateVisible(); |
2733 | + void onNameChanged(const QString &name); |
2734 | + void onMinimumWidthChanged(int minWidth); |
2735 | + void onMinimumHeightChanged(int minHeight); |
2736 | + void onMaximumWidthChanged(int maxWidth); |
2737 | + void onMaximumHeightChanged(int maxHeight); |
2738 | + void onWidthIncrementChanged(int incWidth); |
2739 | + void onHeightIncrementChanged(int incHeight); |
2740 | + |
2741 | + const miral::Window m_window; |
2742 | + const std::shared_ptr<ExtraWindowInfo> m_extraInfo; |
2743 | + QString m_name; |
2744 | + MirSurfaceType m_type; |
2745 | + int m_minWidth; |
2746 | + int m_minHeight; |
2747 | + int m_maxWidth; |
2748 | + int m_maxHeight; |
2749 | + int m_incWidth; |
2750 | + int m_incHeight; |
2751 | + |
2752 | + const std::shared_ptr<mir::scene::Surface> m_surface; // keep copy of the Surface for lifecycle |
2753 | QPointer<SessionInterface> m_session; |
2754 | - mir::shell::Shell *const m_shell; |
2755 | - QString m_persistentId; |
2756 | - bool m_firstFrameDrawn; |
2757 | + WindowControllerInterface *const m_controller; |
2758 | |
2759 | //FIXME - have to save the state as Mir has no getter for it (bug:1357429) |
2760 | Mir::OrientationAngle m_orientationAngle; |
2761 | @@ -214,31 +230,30 @@ |
2762 | bool m_textureUpdated; |
2763 | unsigned int m_currentFrameNumber; |
2764 | |
2765 | + bool m_ready{false}; |
2766 | + bool m_visible; |
2767 | bool m_live; |
2768 | struct View { |
2769 | - bool visible; |
2770 | + bool exposed; |
2771 | }; |
2772 | QHash<qintptr, View> m_views; |
2773 | |
2774 | QSet<qintptr> m_activelyFocusedViews; |
2775 | bool m_neverSetSurfaceFocus{true}; |
2776 | |
2777 | - std::shared_ptr<SurfaceObserver> m_surfaceObserver; |
2778 | + class SurfaceObserverImpl; |
2779 | + std::shared_ptr<SurfaceObserverImpl> m_surfaceObserver; |
2780 | |
2781 | + QPoint m_position; |
2782 | + QPoint m_requestedPosition; |
2783 | QSize m_size; |
2784 | + QSize m_pendingResize; |
2785 | QString m_keymap; |
2786 | |
2787 | QCursor m_cursor; |
2788 | + Mir::State m_state; // FIXME: remove when Mir gains additional window states to match Mir::State |
2789 | Mir::ShellChrome m_shellChrome; |
2790 | |
2791 | - int m_minimumWidth{0}; |
2792 | - int m_minimumHeight{0}; |
2793 | - int m_maximumWidth{0}; |
2794 | - int m_maximumHeight{0}; |
2795 | - int m_widthIncrement{0}; |
2796 | - int m_heightIncrement{0}; |
2797 | - QSize m_pendingResize; |
2798 | - |
2799 | QRect m_inputBounds; |
2800 | |
2801 | bool m_focused{false}; |
2802 | @@ -250,11 +265,6 @@ |
2803 | }; |
2804 | ClosingState m_closingState{NotClosing}; |
2805 | AbstractTimer *m_closeTimer{nullptr}; |
2806 | - |
2807 | - // TODO: Make it configurable, exposing it as a QML property to shell. |
2808 | - // In milliseconds. |
2809 | - const int m_minimumAgeForOcclusion{10000}; |
2810 | - bool m_oldEnoughToBeOccluded{false}; |
2811 | }; |
2812 | |
2813 | } // namespace qtmir |
2814 | |
2815 | === modified file 'src/modules/Unity/Application/mirsurfaceinterface.h' |
2816 | --- src/modules/Unity/Application/mirsurfaceinterface.h 2016-07-05 12:41:04 +0000 |
2817 | +++ src/modules/Unity/Application/mirsurfaceinterface.h 2016-12-16 08:22:54 +0000 |
2818 | @@ -24,6 +24,7 @@ |
2819 | |
2820 | // Qt |
2821 | #include <QCursor> |
2822 | +#include <QPoint> |
2823 | #include <QSharedPointer> |
2824 | #include <QTouchEvent> |
2825 | |
2826 | @@ -44,7 +45,7 @@ |
2827 | |
2828 | virtual void setLive(bool value) = 0; |
2829 | |
2830 | - virtual bool isFirstFrameDrawn() const = 0; |
2831 | + virtual bool isReady() const = 0; |
2832 | |
2833 | virtual void stopFrameDropper() = 0; |
2834 | virtual void startFrameDropper() = 0; |
2835 | @@ -53,7 +54,7 @@ |
2836 | |
2837 | virtual void registerView(qintptr viewId) = 0; |
2838 | virtual void unregisterView(qintptr viewId) = 0; |
2839 | - virtual void setViewVisibility(qintptr viewId, bool visible) = 0; |
2840 | + virtual void setViewExposure(qintptr viewId, bool exposed) = 0; |
2841 | |
2842 | // methods called from the rendering (scene graph) thread: |
2843 | virtual QSharedPointer<QSGTexture> texture() = 0; |
2844 | @@ -102,28 +103,21 @@ |
2845 | |
2846 | virtual QCursor cursor() const = 0; |
2847 | |
2848 | - virtual void setScreen(QScreen *screen) = 0; |
2849 | - |
2850 | virtual SessionInterface* session() = 0; |
2851 | |
2852 | virtual bool inputAreaContains(const QPoint &) const = 0; |
2853 | |
2854 | + virtual void requestFocus() = 0; |
2855 | + |
2856 | public Q_SLOTS: |
2857 | virtual void onCompositorSwappedBuffers() = 0; |
2858 | |
2859 | - virtual void setMinimumWidth(int) = 0; |
2860 | - virtual void setMinimumHeight(int) = 0; |
2861 | - virtual void setMaximumWidth(int) = 0; |
2862 | - virtual void setMaximumHeight(int) = 0; |
2863 | - virtual void setWidthIncrement(int) = 0; |
2864 | - virtual void setHeightIncrement(int) = 0; |
2865 | virtual void setShellChrome(Mir::ShellChrome shellChrome) = 0; |
2866 | |
2867 | Q_SIGNALS: |
2868 | + void ready(); |
2869 | void cursorChanged(const QCursor &cursor); |
2870 | void raiseRequested(); |
2871 | - void closeRequested(); |
2872 | - void firstFrameDrawn(); |
2873 | void framesPosted(); |
2874 | void isBeingDisplayedChanged(); |
2875 | void frameDropped(); |
2876 | |
2877 | === modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp' |
2878 | --- src/modules/Unity/Application/mirsurfaceitem.cpp 2016-07-15 15:38:04 +0000 |
2879 | +++ src/modules/Unity/Application/mirsurfaceitem.cpp 2016-12-16 08:22:54 +0000 |
2880 | @@ -18,7 +18,6 @@ |
2881 | #include "application.h" |
2882 | #include "session.h" |
2883 | #include "mirsurfaceitem.h" |
2884 | -#include "mirfocuscontroller.h" |
2885 | #include "logging.h" |
2886 | #include "tracepoints.h" // generated from tracepoints.tp |
2887 | #include "timestamp.h" |
2888 | @@ -104,18 +103,10 @@ |
2889 | connect(&m_updateMirSurfaceSizeTimer, &QTimer::timeout, this, &MirSurfaceItem::updateMirSurfaceSize); |
2890 | |
2891 | connect(this, &QQuickItem::activeFocusChanged, this, &MirSurfaceItem::updateMirSurfaceActiveFocus); |
2892 | - connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceVisibility); |
2893 | + connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceExposure); |
2894 | connect(this, &QQuickItem::windowChanged, this, &MirSurfaceItem::onWindowChanged); |
2895 | } |
2896 | |
2897 | -void MirSurfaceItem::componentComplete() |
2898 | -{ |
2899 | - QQuickItem::componentComplete(); |
2900 | - if (window()) { |
2901 | - updateScreen(window()->screen()); |
2902 | - } |
2903 | -} |
2904 | - |
2905 | MirSurfaceItem::~MirSurfaceItem() |
2906 | { |
2907 | qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::~MirSurfaceItem - this=" << this; |
2908 | @@ -492,13 +483,6 @@ |
2909 | } |
2910 | } |
2911 | |
2912 | -void MirSurfaceItem::setSurfaceState(Mir::State state) |
2913 | -{ |
2914 | - if (m_surface) { |
2915 | - m_surface->setState(state); |
2916 | - } |
2917 | -} |
2918 | - |
2919 | void MirSurfaceItem::scheduleMirSurfaceSizeUpdate() |
2920 | { |
2921 | if (!m_updateMirSurfaceSizeTimer.isActive()) { |
2922 | @@ -519,13 +503,13 @@ |
2923 | m_surface->resize(width, height); |
2924 | } |
2925 | |
2926 | -void MirSurfaceItem::updateMirSurfaceVisibility() |
2927 | +void MirSurfaceItem::updateMirSurfaceExposure() |
2928 | { |
2929 | if (!m_surface || !m_surface->live()) { |
2930 | return; |
2931 | } |
2932 | |
2933 | - m_surface->setViewVisibility((qintptr)this, isVisible()); |
2934 | + m_surface->setViewExposure((qintptr)this, isVisible()); |
2935 | } |
2936 | |
2937 | void MirSurfaceItem::updateMirSurfaceActiveFocus() |
2938 | @@ -628,10 +612,7 @@ |
2939 | |
2940 | updateMirSurfaceSize(); |
2941 | setImplicitSize(m_surface->size().width(), m_surface->size().height()); |
2942 | - updateMirSurfaceVisibility(); |
2943 | - if (window()) { |
2944 | - updateScreen(window()->screen()); |
2945 | - } |
2946 | + updateMirSurfaceExposure(); |
2947 | |
2948 | // Qt::ArrowCursor is the default when no cursor has been explicitly set, so no point forwarding it. |
2949 | if (m_surface->cursor().shape() != Qt::ArrowCursor) { |
2950 | @@ -672,16 +653,6 @@ |
2951 | if (m_window) { |
2952 | connect(m_window, &QQuickWindow::frameSwapped, this, &MirSurfaceItem::onCompositorSwappedBuffers, |
2953 | Qt::DirectConnection); |
2954 | - |
2955 | - updateScreen(m_window->screen()); |
2956 | - connect(m_window, &QQuickWindow::screenChanged, this, &MirSurfaceItem::updateScreen); |
2957 | - } |
2958 | -} |
2959 | - |
2960 | -void MirSurfaceItem::updateScreen(QScreen *screen) |
2961 | -{ |
2962 | - if (screen && m_surface) { |
2963 | - m_surface->setScreen(screen); |
2964 | } |
2965 | } |
2966 | |
2967 | |
2968 | === modified file 'src/modules/Unity/Application/mirsurfaceitem.h' |
2969 | --- src/modules/Unity/Application/mirsurfaceitem.h 2016-07-15 15:38:04 +0000 |
2970 | +++ src/modules/Unity/Application/mirsurfaceitem.h 2016-12-16 08:22:54 +0000 |
2971 | @@ -31,7 +31,6 @@ |
2972 | |
2973 | namespace qtmir { |
2974 | |
2975 | -class MirSurfaceManager; |
2976 | class QSGMirSurfaceNode; |
2977 | class MirTextureProvider; |
2978 | |
2979 | @@ -52,7 +51,6 @@ |
2980 | Mir::ShellChrome shellChrome() const override; |
2981 | |
2982 | Mir::State surfaceState() const override; |
2983 | - void setSurfaceState(Mir::State) override; |
2984 | |
2985 | Mir::OrientationAngle orientationAngle() const override; |
2986 | void setOrientationAngle(Mir::OrientationAngle angle) override; |
2987 | @@ -109,7 +107,6 @@ |
2988 | |
2989 | QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; |
2990 | |
2991 | - void componentComplete() override; |
2992 | void releaseResources() override; |
2993 | |
2994 | private Q_SLOTS: |
2995 | @@ -117,13 +114,12 @@ |
2996 | void updateMirSurfaceSize(); |
2997 | |
2998 | void updateMirSurfaceActiveFocus(); |
2999 | - void updateMirSurfaceVisibility(); |
3000 | + void updateMirSurfaceExposure(); |
3001 | |
3002 | void onActualSurfaceSizeChanged(QSize size); |
3003 | void onCompositorSwappedBuffers(); |
3004 | |
3005 | void onWindowChanged(QQuickWindow *window); |
3006 | - void updateScreen(QScreen *screen); |
3007 | |
3008 | private: |
3009 | void ensureTextureProvider(); |
3010 | |
3011 | === modified file 'src/modules/Unity/Application/mirsurfacelistmodel.cpp' |
3012 | --- src/modules/Unity/Application/mirsurfacelistmodel.cpp 2016-07-15 15:38:04 +0000 |
3013 | +++ src/modules/Unity/Application/mirsurfacelistmodel.cpp 2016-12-16 08:22:54 +0000 |
3014 | @@ -77,7 +77,11 @@ |
3015 | |
3016 | void MirSurfaceListModel::connectSurface(MirSurfaceInterface *surface) |
3017 | { |
3018 | - connect(surface, &MirSurfaceInterface::raiseRequested, this, [this, surface](){ this->raise(surface); }); |
3019 | + connect(surface, &MirSurfaceInterface::focusedChanged, this, [this, surface](bool focused){ |
3020 | + if (focused) { |
3021 | + this->raise(surface); |
3022 | + } |
3023 | + }); |
3024 | connect(surface, &QObject::destroyed, this, [this, surface](){ this->removeSurface(surface); }); |
3025 | } |
3026 | |
3027 | @@ -143,10 +147,12 @@ |
3028 | for (int i = prependLast; i >= prependFirst; --i) { |
3029 | auto surface = surfaceList[i]; |
3030 | m_surfaceList.prepend(surface); |
3031 | - connect(surface, &MirSurfaceInterface::raiseRequested, this, |
3032 | - [this, surface]() |
3033 | + connect(surface, &MirSurfaceInterface::focusedChanged, this, |
3034 | + [this, surface](bool focused) |
3035 | { |
3036 | - this->raise(surface); |
3037 | + if (focused) { |
3038 | + this->raise(surface); |
3039 | + } |
3040 | }); |
3041 | } |
3042 | endInsertRows(); |
3043 | |
3044 | === removed file 'src/modules/Unity/Application/mirsurfacemanager.cpp' |
3045 | --- src/modules/Unity/Application/mirsurfacemanager.cpp 2016-08-30 12:24:51 +0000 |
3046 | +++ src/modules/Unity/Application/mirsurfacemanager.cpp 1970-01-01 00:00:00 +0000 |
3047 | @@ -1,188 +0,0 @@ |
3048 | -/* |
3049 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
3050 | - * |
3051 | - * This program is free software: you can redistribute it and/or modify it under |
3052 | - * the terms of the GNU Lesser General Public License version 3, as published by |
3053 | - * the Free Software Foundation. |
3054 | - * |
3055 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
3056 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
3057 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3058 | - * Lesser General Public License for more details. |
3059 | - * |
3060 | - * You should have received a copy of the GNU Lesser General Public License |
3061 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3062 | - */ |
3063 | - |
3064 | -#include "mirsurfacemanager.h" |
3065 | - |
3066 | -// Qt |
3067 | -#include <QGuiApplication> |
3068 | -#include <QMutexLocker> |
3069 | - |
3070 | -// local |
3071 | -#include "mirsurface.h" |
3072 | -#include "sessionmanager.h" |
3073 | -#include "application_manager.h" |
3074 | -#include "tracepoints.h" // generated from tracepoints.tp |
3075 | - |
3076 | -// common |
3077 | -#include <debughelpers.h> |
3078 | - |
3079 | -// QPA mirserver |
3080 | -#include "nativeinterface.h" |
3081 | -#include "sessionlistener.h" |
3082 | -#include "logging.h" |
3083 | -#include "creationhints.h" |
3084 | -#include "mirserver.h" |
3085 | - |
3086 | -// mir |
3087 | -#include <mir/scene/surface.h> |
3088 | -#include <mir/shell/persistent_surface_store.h> |
3089 | - |
3090 | - |
3091 | -namespace ms = mir::scene; |
3092 | -namespace msh = mir::shell; |
3093 | - |
3094 | -namespace qtmir { |
3095 | - |
3096 | -MirSurfaceManager *MirSurfaceManager::instance = nullptr; |
3097 | - |
3098 | - |
3099 | -void connectToSessionListener(MirSurfaceManager *manager, SessionListener *listener) |
3100 | -{ |
3101 | - QObject::connect(listener, &SessionListener::sessionCreatedSurface, |
3102 | - manager, &MirSurfaceManager::onSessionCreatedSurface); |
3103 | - QObject::connect(listener, &SessionListener::sessionDestroyingSurface, |
3104 | - manager, &MirSurfaceManager::onSessionDestroyingSurface); |
3105 | -} |
3106 | - |
3107 | -MirSurfaceManager* MirSurfaceManager::singleton() |
3108 | -{ |
3109 | - if (!instance) { |
3110 | - |
3111 | - NativeInterface *nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface()); |
3112 | - |
3113 | - if (!nativeInterface) { |
3114 | - qCritical("ERROR: Unity.Application QML plugin requires use of the 'mirserver' QPA plugin"); |
3115 | - QGuiApplication::quit(); |
3116 | - return nullptr; |
3117 | - } |
3118 | - |
3119 | - SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener")); |
3120 | - mir::shell::Shell *shell = static_cast<mir::shell::Shell*>(nativeInterface->nativeResourceForIntegration("Shell")); |
3121 | - |
3122 | - |
3123 | - instance = new MirSurfaceManager(shell, |
3124 | - SessionManager::singleton(), |
3125 | - nativeInterface->thePersistentSurfaceStore()); |
3126 | - |
3127 | - connectToSessionListener(instance, sessionListener); |
3128 | - } |
3129 | - return instance; |
3130 | -} |
3131 | - |
3132 | -MirSurfaceManager::MirSurfaceManager( |
3133 | - mir::shell::Shell* shell, |
3134 | - SessionManager* sessionManager, |
3135 | - std::shared_ptr<msh::PersistentSurfaceStore> surfaceStore, |
3136 | - QObject* parent) |
3137 | - : QObject(parent) |
3138 | - , m_shell(shell) |
3139 | - , m_sessionManager(sessionManager) |
3140 | - , m_surfaceStore(surfaceStore) |
3141 | -{ |
3142 | - qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::MirSurfaceManager - this=" << this; |
3143 | - setObjectName(QStringLiteral("qtmir::SurfaceManager")); |
3144 | -} |
3145 | - |
3146 | -MirSurfaceManager::~MirSurfaceManager() |
3147 | -{ |
3148 | - qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::~MirSurfaceManager - this=" << this; |
3149 | - |
3150 | - m_mirSurfaceToQmlSurfaceHash.clear(); |
3151 | -} |
3152 | - |
3153 | -void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *mirSession, |
3154 | - const std::shared_ptr<mir::scene::Surface> &surface, |
3155 | - const std::shared_ptr<SurfaceObserver> &observer, |
3156 | - const qtmir::CreationHints &creationHints) |
3157 | -{ |
3158 | - qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionCreatedSurface - mirSession=" << mirSession |
3159 | - << "surface=" << surface.get() << "surface.name=" << surface->name().c_str() |
3160 | - << "creationHints=" << creationHints.toString(); |
3161 | - |
3162 | - SessionInterface* session = m_sessionManager->findSession(mirSession); |
3163 | - auto qmlSurface = new MirSurface(surface, |
3164 | - QString::fromStdString(m_surfaceStore->id_for_surface(surface).serialize_to_string()), |
3165 | - session, |
3166 | - m_shell, |
3167 | - observer, |
3168 | - creationHints); |
3169 | - { |
3170 | - QMutexLocker lock(&m_mutex); |
3171 | - m_mirSurfaceToQmlSurfaceHash.insert(surface.get(), qmlSurface); |
3172 | - } |
3173 | - |
3174 | - if (session) |
3175 | - session->registerSurface(qmlSurface); |
3176 | - |
3177 | - if (qmlSurface->type() == Mir::InputMethodType) { |
3178 | - m_inputMethodSurface = qmlSurface; |
3179 | - Q_EMIT inputMethodSurfaceChanged(); |
3180 | - } |
3181 | - |
3182 | - // Only notify QML of surface creation once it has drawn its first frame. |
3183 | - connect(qmlSurface, &MirSurfaceInterface::firstFrameDrawn, this, [=]() { |
3184 | - tracepoint(qtmir, firstFrameDrawn); |
3185 | - Q_EMIT surfaceCreated(qmlSurface); |
3186 | - }); |
3187 | - |
3188 | - // clean up after MirSurface is destroyed |
3189 | - connect(qmlSurface, &QObject::destroyed, this, [&](QObject *obj) { |
3190 | - auto qmlSurface = static_cast<MirSurfaceInterface*>(obj); |
3191 | - { |
3192 | - QMutexLocker lock(&m_mutex); |
3193 | - m_mirSurfaceToQmlSurfaceHash.remove(m_mirSurfaceToQmlSurfaceHash.key(qmlSurface)); |
3194 | - } |
3195 | - |
3196 | - tracepoint(qtmir, surfaceDestroyed); |
3197 | - }); |
3198 | - tracepoint(qtmir, surfaceCreated); |
3199 | -} |
3200 | - |
3201 | -void MirSurfaceManager::onSessionDestroyingSurface(const mir::scene::Session *session, |
3202 | - const std::shared_ptr<mir::scene::Surface> &surface) |
3203 | -{ |
3204 | - qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionDestroyingSurface - session=" << session |
3205 | - << "surface=" << surface.get() << "surface.name=" << surface->name().c_str(); |
3206 | - |
3207 | - MirSurfaceInterface* qmlSurface = nullptr; |
3208 | - { |
3209 | - QMutexLocker lock(&m_mutex); |
3210 | - auto it = m_mirSurfaceToQmlSurfaceHash.find(surface.get()); |
3211 | - if (it != m_mirSurfaceToQmlSurfaceHash.end()) { |
3212 | - qmlSurface = it.value(); |
3213 | - m_mirSurfaceToQmlSurfaceHash.erase(it); |
3214 | - } else { |
3215 | - qCritical() << "MirSurfaceManager::onSessionDestroyingSurface: unable to find MirSurface corresponding" |
3216 | - << "to surface=" << surface.get() << "surface.name=" << surface->name().c_str(); |
3217 | - return; |
3218 | - } |
3219 | - } |
3220 | - |
3221 | - if (qmlSurface->type() == Mir::InputMethodType) { |
3222 | - m_inputMethodSurface = nullptr; |
3223 | - Q_EMIT inputMethodSurfaceChanged(); |
3224 | - } |
3225 | - |
3226 | - qmlSurface->setLive(false); |
3227 | - Q_EMIT surfaceDestroyed(qmlSurface); |
3228 | -} |
3229 | - |
3230 | -MirSurfaceInterface* MirSurfaceManager::inputMethodSurface() const |
3231 | -{ |
3232 | - return m_inputMethodSurface; |
3233 | -} |
3234 | - |
3235 | -} // namespace qtmir |
3236 | |
3237 | === removed file 'src/modules/Unity/Application/mirsurfacemanager.h' |
3238 | --- src/modules/Unity/Application/mirsurfacemanager.h 2016-08-30 12:24:19 +0000 |
3239 | +++ src/modules/Unity/Application/mirsurfacemanager.h 1970-01-01 00:00:00 +0000 |
3240 | @@ -1,99 +0,0 @@ |
3241 | -/* |
3242 | - * Copyright (C) 2013-2015 Canonical, Ltd. |
3243 | - * |
3244 | - * This program is free software: you can redistribute it and/or modify it under |
3245 | - * the terms of the GNU Lesser General Public License version 3, as published by |
3246 | - * the Free Software Foundation. |
3247 | - * |
3248 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
3249 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
3250 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3251 | - * Lesser General Public License for more details. |
3252 | - * |
3253 | - * You should have received a copy of the GNU Lesser General Public License |
3254 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3255 | - */ |
3256 | - |
3257 | -#ifndef MIR_SURFACE_MANAGER_H |
3258 | -#define MIR_SURFACE_MANAGER_H |
3259 | - |
3260 | -// std |
3261 | -#include <memory> |
3262 | - |
3263 | -// Qt |
3264 | -#include <QObject> |
3265 | -#include <QHash> |
3266 | -#include <QMutex> |
3267 | -#include <QSharedPointer> |
3268 | - |
3269 | -// Mir |
3270 | -#include <mir_toolkit/common.h> |
3271 | - |
3272 | -// mirserver qpa |
3273 | -#include <creationhints.h> |
3274 | - |
3275 | -namespace mir { |
3276 | - namespace scene { |
3277 | - class Surface; |
3278 | - class Session; |
3279 | - class PromptSession; |
3280 | - } |
3281 | - namespace shell { |
3282 | - class Shell; |
3283 | - class PersistentSurfaceStore; |
3284 | - } |
3285 | -} |
3286 | - |
3287 | -class SurfaceObserver; |
3288 | - |
3289 | -namespace qtmir { |
3290 | - |
3291 | -class Application; |
3292 | -class ApplicationManager; |
3293 | -class MirSurfaceInterface; |
3294 | -class SessionManager; |
3295 | - |
3296 | -class MirSurfaceManager : public QObject |
3297 | -{ |
3298 | - Q_OBJECT |
3299 | - Q_PROPERTY(MirSurfaceInterface* inputMethodSurface READ inputMethodSurface NOTIFY inputMethodSurfaceChanged) |
3300 | -public: |
3301 | - explicit MirSurfaceManager( |
3302 | - mir::shell::Shell* shell, |
3303 | - SessionManager* sessionManager, |
3304 | - std::shared_ptr<mir::shell::PersistentSurfaceStore> surfaceStore, |
3305 | - QObject* parent = nullptr |
3306 | - ); |
3307 | - ~MirSurfaceManager(); |
3308 | - |
3309 | - static MirSurfaceManager* singleton(); |
3310 | - |
3311 | - MirSurfaceInterface* inputMethodSurface() const; |
3312 | - |
3313 | -Q_SIGNALS: |
3314 | - void inputMethodSurfaceChanged(); |
3315 | - void surfaceCreated(MirSurfaceInterface* surface); |
3316 | - void surfaceDestroyed(MirSurfaceInterface* surface); |
3317 | - |
3318 | -public Q_SLOTS: |
3319 | - void onSessionCreatedSurface(const mir::scene::Session *, |
3320 | - const std::shared_ptr<mir::scene::Surface> &, |
3321 | - std::shared_ptr<SurfaceObserver> const&, |
3322 | - const qtmir::CreationHints &); |
3323 | - void onSessionDestroyingSurface(const mir::scene::Session *, const std::shared_ptr<mir::scene::Surface> &); |
3324 | - |
3325 | -protected: |
3326 | - QHash<const mir::scene::Surface *, MirSurfaceInterface *> m_mirSurfaceToQmlSurfaceHash; |
3327 | - QMutex m_mutex; |
3328 | - |
3329 | -private: |
3330 | - mir::shell::Shell *const m_shell; |
3331 | - SessionManager* m_sessionManager; |
3332 | - std::shared_ptr<mir::shell::PersistentSurfaceStore> m_surfaceStore; |
3333 | - static MirSurfaceManager *instance; |
3334 | - MirSurfaceInterface* m_inputMethodSurface = nullptr; |
3335 | -}; |
3336 | - |
3337 | -} // namespace qtmir |
3338 | - |
3339 | -#endif // MIR_SURFACE_MANAGER_H |
3340 | |
3341 | === modified file 'src/modules/Unity/Application/plugin.cpp' |
3342 | --- src/modules/Unity/Application/plugin.cpp 2016-07-15 15:38:04 +0000 |
3343 | +++ src/modules/Unity/Application/plugin.cpp 2016-12-16 08:22:54 +0000 |
3344 | @@ -20,11 +20,11 @@ |
3345 | // local |
3346 | #include "application.h" |
3347 | #include "application_manager.h" |
3348 | -#include "mirfocuscontroller.h" |
3349 | -#include "mirsurfacemanager.h" |
3350 | #include "mirsurfaceinterface.h" |
3351 | #include "mirsurfaceitem.h" |
3352 | #include "mirsurfacelistmodel.h" |
3353 | +#include "windowmodel.h" |
3354 | +#include "surfacemanager.h" |
3355 | |
3356 | // platforms/mirserver |
3357 | #include <mirsingleton.h> |
3358 | @@ -46,22 +46,9 @@ |
3359 | return qtmir::ApplicationManager::singleton(); |
3360 | } |
3361 | |
3362 | -QObject* surfaceManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) { |
3363 | - Q_UNUSED(engine); |
3364 | - Q_UNUSED(scriptEngine); |
3365 | - qCDebug(QTMIR_APPLICATIONS) << "surfaceManagerSingleton - engine=" << engine << "scriptEngine=" << scriptEngine; |
3366 | - |
3367 | - return qtmir::MirSurfaceManager::singleton(); |
3368 | -} |
3369 | - |
3370 | QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) { |
3371 | return qtmir::Mir::instance(); |
3372 | } |
3373 | - |
3374 | -QObject* mirFocusControllerSingleton(QQmlEngine*, QJSEngine*) |
3375 | -{ |
3376 | - return MirFocusController::instance(); |
3377 | -} |
3378 | } // anonymous namespace |
3379 | |
3380 | class UnityApplicationPlugin : public QQmlExtensionPlugin { |
3381 | @@ -77,6 +64,7 @@ |
3382 | qRegisterMetaType<qtmir::Application*>("Application*"); |
3383 | qRegisterMetaType<unity::shell::application::MirSurfaceInterface*>("MirSurfaceInterface*"); |
3384 | qRegisterMetaType<unity::shell::application::MirSurfaceListInterface*>("unity::shell::application::MirSurfaceListInterface*"); |
3385 | + qRegisterMetaType<unity::shell::application::SurfaceManagerInterface*>("unity::shell::application::SurfaceManagerInterface*"); |
3386 | qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib"); |
3387 | |
3388 | qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>( |
3389 | @@ -87,13 +75,13 @@ |
3390 | uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML"); |
3391 | qmlRegisterUncreatableType<qtmir::Application>( |
3392 | uri, 0, 1, "ApplicationInfo", "Application can't be instantiated"); |
3393 | - qmlRegisterSingletonType<qtmir::MirSurfaceManager>( |
3394 | - uri, 0, 1, "SurfaceManager", surfaceManagerSingleton); |
3395 | - qmlRegisterSingletonType<MirFocusController>(uri, 0, 1, "MirFocusController", mirFocusControllerSingleton); |
3396 | qmlRegisterUncreatableType<unity::shell::application::MirSurfaceInterface>( |
3397 | uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML"); |
3398 | qmlRegisterType<qtmir::MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem"); |
3399 | qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton); |
3400 | + qmlRegisterType<qtmir::SurfaceManager>(uri, 0, 1, "SurfaceManager"); |
3401 | + |
3402 | + qmlRegisterType<qtmir::WindowModel>(uri, 0, 1, "WindowModel"); |
3403 | } |
3404 | |
3405 | virtual void initializeEngine(QQmlEngine *engine, const char *uri) |
3406 | |
3407 | === modified file 'src/modules/Unity/Application/session.cpp' |
3408 | --- src/modules/Unity/Application/session.cpp 2016-09-22 15:58:26 +0000 |
3409 | +++ src/modules/Unity/Application/session.cpp 2016-12-16 08:22:54 +0000 |
3410 | @@ -19,16 +19,14 @@ |
3411 | #include "debughelpers.h" |
3412 | #include "session.h" |
3413 | #include "mirsurfaceinterface.h" |
3414 | -#include "mirsurfacemanager.h" |
3415 | #include "mirsurfaceitem.h" |
3416 | +#include "promptsession.h" |
3417 | |
3418 | // mirserver |
3419 | #include "logging.h" |
3420 | |
3421 | -// mir |
3422 | -#include <mir/scene/session.h> |
3423 | -#include <mir/scene/prompt_session.h> |
3424 | -#include <mir/scene/prompt_session_manager.h> |
3425 | +// miral |
3426 | +#include <miral/application.h> |
3427 | |
3428 | // Qt |
3429 | #include <QPainter> |
3430 | @@ -66,7 +64,7 @@ |
3431 | } |
3432 | |
3433 | Session::Session(const std::shared_ptr<ms::Session>& session, |
3434 | - const std::shared_ptr<ms::PromptSessionManager>& promptSessionManager, |
3435 | + const std::shared_ptr<PromptSessionManager>& promptSessionManager, |
3436 | QObject *parent) |
3437 | : SessionInterface(parent) |
3438 | , m_session(session) |
3439 | @@ -121,7 +119,7 @@ |
3440 | |
3441 | QString Session::name() const |
3442 | { |
3443 | - return QString::fromStdString(m_session->name()); |
3444 | + return QString::fromStdString(miral::name_of(m_session)); |
3445 | } |
3446 | |
3447 | std::shared_ptr<ms::Session> Session::session() const |
3448 | @@ -202,10 +200,10 @@ |
3449 | DEBUG_MSG << "(surface=" << newSurface << ")"; |
3450 | |
3451 | // Only notify QML of surface creation once it has drawn its first frame. |
3452 | - if (newSurface->isFirstFrameDrawn()) { |
3453 | + if (newSurface->isReady()) { |
3454 | prependSurface(newSurface); |
3455 | } else { |
3456 | - connect(newSurface, &MirSurfaceInterface::firstFrameDrawn, this, [this, newSurface]() |
3457 | + connect(newSurface, &MirSurfaceInterface::ready, this, [this, newSurface]() |
3458 | { |
3459 | newSurface->disconnect(this); |
3460 | this->prependSurface(newSurface); |
3461 | @@ -234,6 +232,10 @@ |
3462 | this->removeSurface(newSurface); |
3463 | }); |
3464 | connect(newSurface, &MirSurfaceInterface::focusRequested, this, &SessionInterface::focusRequested); |
3465 | + connect(newSurface, &MirSurfaceInterface::focusedChanged, this, [&](bool /*value*/) { |
3466 | + // TODO: May want to optimize that in the future. |
3467 | + Q_EMIT focusedChanged(focused()); |
3468 | + }); |
3469 | |
3470 | m_surfaceList.prependSurface(newSurface); |
3471 | m_hadSurface = true; |
3472 | @@ -289,11 +291,11 @@ |
3473 | { |
3474 | DEBUG_MSG << " state=" << sessionStateToString(m_state); |
3475 | if (m_state == Running) { |
3476 | - session()->set_lifecycle_state(mir_lifecycle_state_will_suspend); |
3477 | + miral::apply_lifecycle_state_to(session(), mir_lifecycle_state_will_suspend); |
3478 | m_suspendTimer->start(); |
3479 | |
3480 | - foreachPromptSession([this](const std::shared_ptr<ms::PromptSession>& promptSession) { |
3481 | - m_promptSessionManager->suspend_prompt_session(promptSession); |
3482 | + foreachPromptSession([this](const qtmir::PromptSession &promptSession) { |
3483 | + m_promptSessionManager->suspendPromptSession(promptSession); |
3484 | }); |
3485 | |
3486 | foreachChildSession([](SessionInterface* session) { |
3487 | @@ -322,10 +324,10 @@ |
3488 | } |
3489 | } |
3490 | |
3491 | - session()->set_lifecycle_state(mir_lifecycle_state_resumed); |
3492 | + miral::apply_lifecycle_state_to(session(), mir_lifecycle_state_resumed); |
3493 | |
3494 | - foreachPromptSession([this](const std::shared_ptr<ms::PromptSession>& promptSession) { |
3495 | - m_promptSessionManager->resume_prompt_session(promptSession); |
3496 | + foreachPromptSession([this](const qtmir::PromptSession &promptSession) { |
3497 | + m_promptSessionManager->resumePromptSession(promptSession); |
3498 | }); |
3499 | |
3500 | foreachChildSession([](SessionInterface* session) { |
3501 | @@ -453,16 +455,16 @@ |
3502 | return m_children; |
3503 | } |
3504 | |
3505 | -void Session::appendPromptSession(const std::shared_ptr<ms::PromptSession>& promptSession) |
3506 | +void Session::appendPromptSession(const qtmir::PromptSession &promptSession) |
3507 | { |
3508 | - DEBUG_MSG << "(promptSession=" << (promptSession ? promptSession.get() : nullptr) << ")"; |
3509 | + DEBUG_MSG << "(promptSession=" << promptSession.get() << ")"; |
3510 | |
3511 | m_promptSessions.append(promptSession); |
3512 | } |
3513 | |
3514 | -void Session::removePromptSession(const std::shared_ptr<ms::PromptSession>& promptSession) |
3515 | +void Session::removePromptSession(const qtmir::PromptSession &promptSession) |
3516 | { |
3517 | - DEBUG_MSG << "(promptSession=" << (promptSession ? promptSession.get() : nullptr) << ")"; |
3518 | + DEBUG_MSG << "(promptSession=" << promptSession.get() << ")"; |
3519 | |
3520 | m_promptSessions.removeAll(promptSession); |
3521 | } |
3522 | @@ -474,26 +476,26 @@ |
3523 | static_cast<Session*>(child)->stopPromptSessions(); |
3524 | } |
3525 | |
3526 | - QVector<std::shared_ptr<ms::PromptSession>> copy(m_promptSessions); |
3527 | - QVectorIterator<std::shared_ptr<ms::PromptSession>> it(copy); |
3528 | + QVector<qtmir::PromptSession> copy(m_promptSessions); |
3529 | + QVectorIterator<qtmir::PromptSession> it(copy); |
3530 | for ( it.toBack(); it.hasPrevious(); ) { |
3531 | - std::shared_ptr<ms::PromptSession> promptSession = it.previous(); |
3532 | + qtmir::PromptSession promptSession = it.previous(); |
3533 | DEBUG_MSG << " - promptSession=" << promptSession.get(); |
3534 | |
3535 | - m_promptSessionManager->stop_prompt_session(promptSession); |
3536 | + m_promptSessionManager->stopPromptSession(promptSession); |
3537 | } |
3538 | } |
3539 | |
3540 | -std::shared_ptr<ms::PromptSession> Session::activePromptSession() const |
3541 | +qtmir::PromptSession Session::activePromptSession() const |
3542 | { |
3543 | if (m_promptSessions.count() > 0) |
3544 | return m_promptSessions.back(); |
3545 | - return nullptr; |
3546 | + return {}; |
3547 | } |
3548 | |
3549 | -void Session::foreachPromptSession(const std::function<void(const std::shared_ptr<ms::PromptSession>&)>& f) const |
3550 | +void Session::foreachPromptSession(const std::function<void(const qtmir::PromptSession&)>& f) const |
3551 | { |
3552 | - Q_FOREACH (std::shared_ptr<ms::PromptSession> promptSession, m_promptSessions) { |
3553 | + Q_FOREACH (qtmir::PromptSession promptSession, m_promptSessions) { |
3554 | f(promptSession); |
3555 | } |
3556 | } |
3557 | @@ -516,6 +518,18 @@ |
3558 | return m_hadSurface; |
3559 | } |
3560 | |
3561 | +bool Session::focused() const |
3562 | +{ |
3563 | + for (int i = 0; i < m_surfaceList.count(); ++i) { |
3564 | + auto surface = static_cast<const MirSurfaceInterface*>(m_surfaceList.get(i)); |
3565 | + if (surface->focused()) { |
3566 | + return true; |
3567 | + } |
3568 | + } |
3569 | + |
3570 | + return false; |
3571 | +} |
3572 | + |
3573 | bool Session::activeFocus() const |
3574 | { |
3575 | for (int i = 0; i < m_surfaceList.count(); ++i) { |
3576 | @@ -530,7 +544,7 @@ |
3577 | |
3578 | pid_t Session::pid() const |
3579 | { |
3580 | - return m_session->process_id(); |
3581 | + return miral::pid_of(m_session); |
3582 | } |
3583 | |
3584 | void Session::setSuspendTimer(AbstractTimer *timer) |
3585 | |
3586 | === modified file 'src/modules/Unity/Application/session.h' |
3587 | --- src/modules/Unity/Application/session.h 2016-07-15 15:38:04 +0000 |
3588 | +++ src/modules/Unity/Application/session.h 2016-12-16 08:22:54 +0000 |
3589 | @@ -23,19 +23,17 @@ |
3590 | // local |
3591 | #include "session_interface.h" |
3592 | #include "mirsurfacelistmodel.h" |
3593 | +#include "promptsessionmanager.h" |
3594 | #include "timer.h" |
3595 | |
3596 | // Qt |
3597 | #include <QObject> |
3598 | |
3599 | -namespace mir { |
3600 | - namespace scene { |
3601 | - class PromptSessionManager; |
3602 | - } |
3603 | -} |
3604 | |
3605 | namespace qtmir { |
3606 | |
3607 | +class PromptSessionManager; |
3608 | + |
3609 | class Application; |
3610 | |
3611 | class Session : public SessionInterface |
3612 | @@ -43,7 +41,7 @@ |
3613 | Q_OBJECT |
3614 | public: |
3615 | explicit Session(const std::shared_ptr<mir::scene::Session>& session, |
3616 | - const std::shared_ptr<mir::scene::PromptSessionManager>& promptSessionManager, |
3617 | + const std::shared_ptr<PromptSessionManager>& promptSessionManager, |
3618 | QObject *parent = 0); |
3619 | virtual ~Session(); |
3620 | |
3621 | @@ -66,6 +64,7 @@ |
3622 | void stop() override; |
3623 | bool hadSurface() const override; |
3624 | bool hasClosingSurfaces() const override; |
3625 | + bool focused() const override; |
3626 | |
3627 | bool activeFocus() const override; |
3628 | |
3629 | @@ -78,15 +77,15 @@ |
3630 | |
3631 | std::shared_ptr<mir::scene::Session> session() const override; |
3632 | |
3633 | - std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override; |
3634 | - void foreachPromptSession(const std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)> &f) const override; |
3635 | + PromptSession activePromptSession() const override; |
3636 | + void foreachPromptSession(const std::function<void(const PromptSession&)> &f) const override; |
3637 | |
3638 | SessionModel* childSessions() const override; |
3639 | |
3640 | void setFullscreen(bool fullscreen) override; |
3641 | void setLive(const bool) override; |
3642 | - void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override; |
3643 | - void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override; |
3644 | + void appendPromptSession(const PromptSession& session) override; |
3645 | + void removePromptSession(const PromptSession& session) override; |
3646 | |
3647 | // useful for tests |
3648 | void setSuspendTimer(AbstractTimer *timer); |
3649 | @@ -119,8 +118,8 @@ |
3650 | State m_state; |
3651 | bool m_live; |
3652 | AbstractTimer* m_suspendTimer{nullptr}; |
3653 | - QVector<std::shared_ptr<mir::scene::PromptSession>> m_promptSessions; |
3654 | - std::shared_ptr<mir::scene::PromptSessionManager> const m_promptSessionManager; |
3655 | + QVector<PromptSession> m_promptSessions; |
3656 | + std::shared_ptr<PromptSessionManager> const m_promptSessionManager; |
3657 | QList<MirSurfaceInterface*> m_closingSurfaces; |
3658 | bool m_hadSurface{false}; |
3659 | }; |
3660 | |
3661 | === modified file 'src/modules/Unity/Application/session_interface.h' |
3662 | --- src/modules/Unity/Application/session_interface.h 2016-07-15 15:38:04 +0000 |
3663 | +++ src/modules/Unity/Application/session_interface.h 2016-12-16 08:22:54 +0000 |
3664 | @@ -33,7 +33,6 @@ |
3665 | namespace mir { |
3666 | namespace scene { |
3667 | class Session; |
3668 | - class PromptSession; |
3669 | } |
3670 | } |
3671 | |
3672 | @@ -41,6 +40,7 @@ |
3673 | |
3674 | class MirSurfaceInterface; |
3675 | class MirSurfaceListModel; |
3676 | +class PromptSession; |
3677 | |
3678 | class SessionInterface : public QObject { |
3679 | Q_OBJECT |
3680 | @@ -78,7 +78,7 @@ |
3681 | |
3682 | virtual std::shared_ptr<mir::scene::Session> session() const = 0; |
3683 | |
3684 | - // For MirSurface and MirSurfaceManager use |
3685 | + // For MirSurface use |
3686 | |
3687 | virtual void registerSurface(MirSurfaceInterface* surface) = 0; |
3688 | |
3689 | @@ -91,6 +91,7 @@ |
3690 | virtual void stop() = 0; |
3691 | virtual bool hadSurface() const = 0; // whether this session ever had any surface (currently or in the past) |
3692 | virtual bool hasClosingSurfaces() const = 0; // whether it has surfaces being forcibly closed |
3693 | + virtual bool focused() const = 0; // whether any surface in its list is focused() |
3694 | |
3695 | // Whether any of its MirSurfaces has activeFocus() |
3696 | // See qtmir::MirSurfaceInterface::activeFocus |
3697 | @@ -105,19 +106,20 @@ |
3698 | virtual void removeChildSession(SessionInterface* session) = 0; |
3699 | virtual void foreachChildSession(const std::function<void(SessionInterface* session)>& f) const = 0; |
3700 | |
3701 | - virtual std::shared_ptr<mir::scene::PromptSession> activePromptSession() const = 0; |
3702 | - virtual void foreachPromptSession(const std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)>& f) const = 0; |
3703 | + virtual PromptSession activePromptSession() const = 0; |
3704 | + virtual void foreachPromptSession(const std::function<void(const PromptSession&)>& f) const = 0; |
3705 | |
3706 | virtual void setFullscreen(bool fullscreen) = 0; |
3707 | virtual void setLive(const bool) = 0; |
3708 | - virtual void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0; |
3709 | - virtual void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0; |
3710 | + virtual void appendPromptSession(const PromptSession& session) = 0; |
3711 | + virtual void removePromptSession(const PromptSession& session) = 0; |
3712 | |
3713 | Q_SIGNALS: |
3714 | void applicationChanged(unity::shell::application::ApplicationInfoInterface* application); |
3715 | void stateChanged(State state); |
3716 | void fullscreenChanged(bool fullscreen); |
3717 | void liveChanged(bool live); |
3718 | + void focusedChanged(bool focused); |
3719 | |
3720 | // Emitted when any surface in this session emits focusRequested() |
3721 | void focusRequested(); |
3722 | |
3723 | === modified file 'src/modules/Unity/Application/sessionmanager.cpp' |
3724 | --- src/modules/Unity/Application/sessionmanager.cpp 2016-08-10 06:51:55 +0000 |
3725 | +++ src/modules/Unity/Application/sessionmanager.cpp 2016-12-16 08:22:54 +0000 |
3726 | @@ -23,28 +23,23 @@ |
3727 | #include "sessionmanager.h" |
3728 | |
3729 | // QPA mirserver |
3730 | +#include "appnotifier.h" |
3731 | +#include "logging.h" |
3732 | #include "nativeinterface.h" |
3733 | -#include "sessionlistener.h" |
3734 | -#include "logging.h" |
3735 | #include "promptsessionlistener.h" |
3736 | - |
3737 | -// mir |
3738 | -#include <mir/scene/prompt_session.h> |
3739 | -#include <mir/scene/prompt_session_manager.h> |
3740 | -#include <mir/report_exception.h> |
3741 | - |
3742 | -namespace ms = mir::scene; |
3743 | +#include "promptsession.h" |
3744 | + |
3745 | |
3746 | namespace qtmir { |
3747 | |
3748 | SessionManager *SessionManager::the_session_manager = nullptr; |
3749 | |
3750 | |
3751 | -void connectToSessionListener(SessionManager *manager, SessionListener *listener) |
3752 | +void connectToAppNotifier(SessionManager *manager, AppNotifier *appNotifier) |
3753 | { |
3754 | - QObject::connect(listener, &SessionListener::sessionStarting, |
3755 | + QObject::connect(appNotifier, &AppNotifier::appAdded, |
3756 | manager, &SessionManager::onSessionStarting); |
3757 | - QObject::connect(listener, &SessionListener::sessionStopping, |
3758 | + QObject::connect(appNotifier, &AppNotifier::appRemoved, |
3759 | manager, &SessionManager::onSessionStopping); |
3760 | } |
3761 | |
3762 | @@ -61,7 +56,6 @@ |
3763 | } |
3764 | |
3765 | SessionManager* SessionManager::singleton() |
3766 | -try |
3767 | { |
3768 | if (!the_session_manager) { |
3769 | |
3770 | @@ -73,27 +67,19 @@ |
3771 | return nullptr; |
3772 | } |
3773 | |
3774 | - SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener")); |
3775 | + auto appNotifier = static_cast<AppNotifier*>(nativeInterface->nativeResourceForIntegration("AppNotifier")); |
3776 | PromptSessionListener *promptSessionListener = static_cast<PromptSessionListener*>(nativeInterface->nativeResourceForIntegration("PromptSessionListener")); |
3777 | |
3778 | the_session_manager = new SessionManager(nativeInterface->thePromptSessionManager(), ApplicationManager::singleton()); |
3779 | |
3780 | - connectToSessionListener(the_session_manager, sessionListener); |
3781 | + connectToAppNotifier(the_session_manager, appNotifier); |
3782 | connectToPromptSessionListener(the_session_manager, promptSessionListener); |
3783 | } |
3784 | return the_session_manager; |
3785 | } |
3786 | -catch (...) |
3787 | -{ |
3788 | - // We only call mir::report_exception() here to force linkage against libmirserver. |
3789 | - // Unless we force this module to have a link dependency on libmirserver we get |
3790 | - // several tests hanging during link loading. I wish I understood why. alan_g |
3791 | - mir::report_exception(); |
3792 | - throw; |
3793 | -} |
3794 | |
3795 | SessionManager::SessionManager( |
3796 | - const std::shared_ptr<mir::scene::PromptSessionManager>& promptSessionManager, |
3797 | + const std::shared_ptr<qtmir::PromptSessionManager>& promptSessionManager, |
3798 | ApplicationManager* applicationManager, |
3799 | QObject *parent) |
3800 | : SessionModel(parent) |
3801 | @@ -120,10 +106,11 @@ |
3802 | return nullptr; |
3803 | } |
3804 | |
3805 | -void SessionManager::onSessionStarting(std::shared_ptr<mir::scene::Session> const& session) |
3806 | +void SessionManager::onSessionStarting(const miral::ApplicationInfo &appInfo) |
3807 | { |
3808 | - qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStarting - sessionName=" << session->name().c_str(); |
3809 | + qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStarting - sessionName=" << appInfo.name().c_str(); |
3810 | |
3811 | + const auto &session = appInfo.application(); |
3812 | Session* qmlSession = new Session(session, m_promptSessionManager); |
3813 | insert(0, qmlSession); |
3814 | |
3815 | @@ -140,11 +127,11 @@ |
3816 | Q_EMIT sessionStarting(qmlSession); |
3817 | } |
3818 | |
3819 | -void SessionManager::onSessionStopping(std::shared_ptr<mir::scene::Session> const& session) |
3820 | +void SessionManager::onSessionStopping(const miral::ApplicationInfo &appInfo) |
3821 | { |
3822 | - qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStopping - sessionName=" << session->name().c_str(); |
3823 | + qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStopping - sessionName=" << appInfo.name().c_str(); |
3824 | |
3825 | - SessionInterface* qmlSession = findSession(session.get()); |
3826 | + SessionInterface* qmlSession = findSession(appInfo.application().get()); |
3827 | if (!qmlSession) return; |
3828 | |
3829 | remove(qmlSession); |
3830 | @@ -153,11 +140,11 @@ |
3831 | Q_EMIT sessionStopping(qmlSession); |
3832 | } |
3833 | |
3834 | -void SessionManager::onPromptSessionStarting(const std::shared_ptr<ms::PromptSession>& promptSession) |
3835 | +void SessionManager::onPromptSessionStarting(const qtmir::PromptSession &promptSession) |
3836 | { |
3837 | qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStarting - promptSession=" << promptSession.get(); |
3838 | |
3839 | - std::shared_ptr<mir::scene::Session> appSession = m_promptSessionManager->application_for(promptSession); |
3840 | + std::shared_ptr<mir::scene::Session> appSession = m_promptSessionManager->applicationFor(promptSession); |
3841 | SessionInterface *qmlAppSession = findSession(appSession.get()); |
3842 | if (qmlAppSession) { |
3843 | m_mirPromptToSessionHash[promptSession.get()] = qmlAppSession; |
3844 | @@ -167,7 +154,7 @@ |
3845 | } |
3846 | } |
3847 | |
3848 | -void SessionManager::onPromptSessionStopping(const std::shared_ptr<ms::PromptSession>& promptSession) |
3849 | +void SessionManager::onPromptSessionStopping(const qtmir::PromptSession &promptSession) |
3850 | { |
3851 | qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStopping - promptSession=" << promptSession.get(); |
3852 | |
3853 | @@ -177,12 +164,12 @@ |
3854 | m_mirPromptToSessionHash.remove(promptSession.get()); |
3855 | } |
3856 | |
3857 | -void SessionManager::onPromptProviderAdded(const mir::scene::PromptSession *promptSession, |
3858 | +void SessionManager::onPromptProviderAdded(const qtmir::PromptSession &promptSession, |
3859 | const std::shared_ptr<mir::scene::Session> &promptProvider) |
3860 | { |
3861 | - qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - promptSession=" << promptSession << " promptProvider=" << promptProvider.get(); |
3862 | + qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - promptSession=" << promptSession.get() << " promptProvider=" << promptProvider.get(); |
3863 | |
3864 | - SessionInterface* qmlAppSession = m_mirPromptToSessionHash.value(promptSession, nullptr); |
3865 | + SessionInterface* qmlAppSession = m_mirPromptToSessionHash.value(promptSession.get(), nullptr); |
3866 | if (!qmlAppSession) { |
3867 | qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - could not find session item for app session"; |
3868 | return; |
3869 | @@ -197,10 +184,10 @@ |
3870 | qmlAppSession->addChildSession(qmlPromptProvider); |
3871 | } |
3872 | |
3873 | -void SessionManager::onPromptProviderRemoved(const mir::scene::PromptSession *promptSession, |
3874 | +void SessionManager::onPromptProviderRemoved(const qtmir::PromptSession &promptSession, |
3875 | const std::shared_ptr<mir::scene::Session> &promptProvider) |
3876 | { |
3877 | - qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderRemoved - promptSession=" << promptSession << " promptProvider=" << promptProvider.get(); |
3878 | + qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderRemoved - promptSession=" << promptSession.get() << " promptProvider=" << promptProvider.get(); |
3879 | |
3880 | SessionInterface* qmlPromptProvider = findSession(promptProvider.get()); |
3881 | if (!qmlPromptProvider) { |
3882 | |
3883 | === modified file 'src/modules/Unity/Application/sessionmanager.h' |
3884 | --- src/modules/Unity/Application/sessionmanager.h 2016-08-10 06:51:37 +0000 |
3885 | +++ src/modules/Unity/Application/sessionmanager.h 2016-12-16 08:22:54 +0000 |
3886 | @@ -27,6 +27,9 @@ |
3887 | // Mir |
3888 | #include <mir_toolkit/common.h> |
3889 | |
3890 | +// miral |
3891 | +#include <miral/application_info.h> |
3892 | + |
3893 | // local |
3894 | #include "session.h" |
3895 | #include "sessionmodel.h" |
3896 | @@ -49,7 +52,7 @@ |
3897 | |
3898 | public: |
3899 | explicit SessionManager( |
3900 | - const std::shared_ptr<mir::scene::PromptSessionManager>& promptSessionManager, |
3901 | + const std::shared_ptr<PromptSessionManager>& promptSessionManager, |
3902 | ApplicationManager* applicationManager, |
3903 | QObject *parent = 0 |
3904 | ); |
3905 | @@ -64,18 +67,18 @@ |
3906 | void sessionStopping(SessionInterface* session); |
3907 | |
3908 | public Q_SLOTS: |
3909 | - void onSessionStarting(std::shared_ptr<mir::scene::Session> const& session); |
3910 | - void onSessionStopping(std::shared_ptr<mir::scene::Session> const& session); |
3911 | + void onSessionStarting(const miral::ApplicationInfo &appInfo); |
3912 | + void onSessionStopping(const miral::ApplicationInfo &appInfo); |
3913 | |
3914 | - void onPromptSessionStarting(const std::shared_ptr<mir::scene::PromptSession>& promptSession); |
3915 | - void onPromptSessionStopping(const std::shared_ptr<mir::scene::PromptSession>& promptSession); |
3916 | - void onPromptProviderAdded(const mir::scene::PromptSession *, const std::shared_ptr<mir::scene::Session> &); |
3917 | - void onPromptProviderRemoved(const mir::scene::PromptSession *, const std::shared_ptr<mir::scene::Session> &); |
3918 | + void onPromptSessionStarting(const PromptSession& promptSession); |
3919 | + void onPromptSessionStopping(const PromptSession& promptSession); |
3920 | + void onPromptProviderAdded(const qtmir::PromptSession &promptSession, const std::shared_ptr<mir::scene::Session> &); |
3921 | + void onPromptProviderRemoved(const qtmir::PromptSession &promptSession, const std::shared_ptr<mir::scene::Session> &); |
3922 | |
3923 | protected: |
3924 | |
3925 | private: |
3926 | - const std::shared_ptr<mir::scene::PromptSessionManager> m_promptSessionManager; |
3927 | + const std::shared_ptr<PromptSessionManager> m_promptSessionManager; |
3928 | ApplicationManager* m_applicationManager; |
3929 | static SessionManager *the_session_manager; |
3930 | |
3931 | |
3932 | === added file 'src/modules/Unity/Application/surfacemanager.cpp' |
3933 | --- src/modules/Unity/Application/surfacemanager.cpp 1970-01-01 00:00:00 +0000 |
3934 | +++ src/modules/Unity/Application/surfacemanager.cpp 2016-12-16 08:22:54 +0000 |
3935 | @@ -0,0 +1,174 @@ |
3936 | +/* |
3937 | + * Copyright (C) 2016 Canonical, Ltd. |
3938 | + * |
3939 | + * This program is free software: you can redistribute it and/or modify it under |
3940 | + * the terms of the GNU Lesser General Public License version 3, as published by |
3941 | + * the Free Software Foundation. |
3942 | + * |
3943 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
3944 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
3945 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3946 | + * Lesser General Public License for more details. |
3947 | + * |
3948 | + * You should have received a copy of the GNU Lesser General Public License |
3949 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3950 | + */ |
3951 | + |
3952 | +#include "surfacemanager.h" |
3953 | + |
3954 | +#include "mirsurface.h" |
3955 | +#include "sessionmanager.h" |
3956 | + |
3957 | +// mirserver |
3958 | +#include "nativeinterface.h" |
3959 | + |
3960 | +// Qt |
3961 | +#include <QGuiApplication> |
3962 | + |
3963 | +Q_LOGGING_CATEGORY(QTMIR_SURFACEMANAGER, "qtmir.surfacemanager", QtInfoMsg) |
3964 | + |
3965 | +#define DEBUG_MSG qCDebug(QTMIR_SURFACEMANAGER).nospace().noquote() << __func__ |
3966 | + |
3967 | +using namespace qtmir; |
3968 | +namespace unityapi = unity::shell::application; |
3969 | + |
3970 | +SurfaceManager::SurfaceManager(QObject *) |
3971 | +{ |
3972 | + DEBUG_MSG << "()"; |
3973 | + |
3974 | + auto nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface()); |
3975 | + |
3976 | + if (!nativeInterface) { |
3977 | + qFatal("ERROR: Unity.Application QML plugin requires use of the 'mirserver' QPA plugin"); |
3978 | + } |
3979 | + |
3980 | + m_windowController = static_cast<WindowControllerInterface*>(nativeInterface->nativeResourceForIntegration("WindowController")); |
3981 | + |
3982 | + auto windowModel = static_cast<WindowModelNotifier*>(nativeInterface->nativeResourceForIntegration("WindowModelNotifier")); |
3983 | + connectToWindowModelNotifier(windowModel); |
3984 | + |
3985 | + m_sessionManager = SessionManager::singleton(); |
3986 | +} |
3987 | + |
3988 | +void SurfaceManager::connectToWindowModelNotifier(WindowModelNotifier *notifier) |
3989 | +{ |
3990 | + connect(notifier, &WindowModelNotifier::windowAdded, this, &SurfaceManager::onWindowAdded, Qt::QueuedConnection); |
3991 | + connect(notifier, &WindowModelNotifier::windowRemoved, this, &SurfaceManager::onWindowRemoved, Qt::QueuedConnection); |
3992 | + connect(notifier, &WindowModelNotifier::windowReady, this, &SurfaceManager::onWindowReady, Qt::QueuedConnection); |
3993 | + connect(notifier, &WindowModelNotifier::windowMoved, this, &SurfaceManager::onWindowMoved, Qt::QueuedConnection); |
3994 | + connect(notifier, &WindowModelNotifier::windowStateChanged, this, &SurfaceManager::onWindowStateChanged, Qt::QueuedConnection); |
3995 | + connect(notifier, &WindowModelNotifier::windowFocusChanged, this, &SurfaceManager::onWindowFocusChanged, Qt::QueuedConnection); |
3996 | + connect(notifier, &WindowModelNotifier::windowsRaised, this, &SurfaceManager::onWindowsRaised, Qt::QueuedConnection); |
3997 | + connect(notifier, &WindowModelNotifier::windowRequestedRaise, this, &SurfaceManager::onWindowsRequestedRaise, Qt::QueuedConnection); |
3998 | + connect(notifier, &WindowModelNotifier::modificationsStarted, this, &SurfaceManager::modificationsStarted, Qt::QueuedConnection); |
3999 | + connect(notifier, &WindowModelNotifier::modificationsEnded, this, &SurfaceManager::modificationsEnded, Qt::QueuedConnection); |
4000 | +} |
4001 | + |
4002 | +void SurfaceManager::rememberMirSurface(MirSurface *surface) |
4003 | +{ |
4004 | + m_allSurfaces.append(surface); |
4005 | +} |
4006 | + |
4007 | +void SurfaceManager::forgetMirSurface(const miral::Window &window) |
4008 | +{ |
4009 | + for (int i = 0; i < m_allSurfaces.count(); ++i) { |
4010 | + if (m_allSurfaces[i]->window() == window) { |
4011 | + m_allSurfaces.removeAt(i); |
4012 | + return; |
4013 | + } |
4014 | + } |
4015 | +} |
4016 | +void SurfaceManager::onWindowAdded(const NewWindow &window) |
4017 | +{ |
4018 | + auto mirSession = window.windowInfo.window().application(); |
4019 | + SessionInterface* session = m_sessionManager->findSession(mirSession.get()); |
4020 | + |
4021 | + auto surface = new MirSurface(window, m_windowController, session); |
4022 | + rememberMirSurface(surface); |
4023 | + |
4024 | + if (session) |
4025 | + session->registerSurface(surface); |
4026 | + |
4027 | + Q_EMIT surfaceCreated(surface); |
4028 | +} |
4029 | + |
4030 | +void SurfaceManager::onWindowRemoved(const miral::WindowInfo &windowInfo) |
4031 | +{ |
4032 | + MirSurface *surface = find(windowInfo); |
4033 | + forgetMirSurface(windowInfo.window()); |
4034 | + surface->setLive(false); |
4035 | +} |
4036 | + |
4037 | +MirSurface *SurfaceManager::find(const miral::WindowInfo &needle) const |
4038 | +{ |
4039 | + return find(needle.window()); |
4040 | +} |
4041 | + |
4042 | +MirSurface *SurfaceManager::find(const miral::Window &window) const |
4043 | +{ |
4044 | + Q_FOREACH(const auto surface, m_allSurfaces) { |
4045 | + if (surface->window() == window) { |
4046 | + return surface; |
4047 | + } |
4048 | + } |
4049 | + return nullptr; |
4050 | +} |
4051 | + |
4052 | +void SurfaceManager::onWindowReady(const miral::WindowInfo &windowInfo) |
4053 | +{ |
4054 | + if (auto mirSurface = find(windowInfo)) { |
4055 | + mirSurface->setReady(); |
4056 | + } |
4057 | +} |
4058 | + |
4059 | +void SurfaceManager::onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft) |
4060 | +{ |
4061 | + if (auto mirSurface = find(windowInfo)) { |
4062 | + mirSurface->setPosition(topLeft); |
4063 | + } |
4064 | +} |
4065 | + |
4066 | +void SurfaceManager::onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused) |
4067 | +{ |
4068 | + if (auto mirSurface = find(windowInfo)) { |
4069 | + mirSurface->setFocused(focused); |
4070 | + } |
4071 | +} |
4072 | + |
4073 | +void SurfaceManager::onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state) |
4074 | +{ |
4075 | + if (auto mirSurface = find(windowInfo)) { |
4076 | + mirSurface->updateState(state); |
4077 | + } |
4078 | +} |
4079 | + |
4080 | +void SurfaceManager::onWindowsRaised(const std::vector<miral::Window> &windows) |
4081 | +{ |
4082 | + // sad inefficiency when crossing API boundaries (from miral to qt) |
4083 | + const int raiseCount = windows.size(); |
4084 | + QVector<unityapi::MirSurfaceInterface*> surfaces(raiseCount); |
4085 | + for (int i = 0; i < raiseCount; i++) { |
4086 | + auto mirSurface = find(windows[i]); |
4087 | + surfaces.append(mirSurface); |
4088 | + } |
4089 | + Q_EMIT surfacesRaised(surfaces); |
4090 | +} |
4091 | + |
4092 | +void SurfaceManager::onWindowsRequestedRaise(const miral::WindowInfo &windowInfo) |
4093 | +{ |
4094 | + if (auto mirSurface = find(windowInfo)) { |
4095 | + mirSurface->requestFocus(); |
4096 | + } |
4097 | +} |
4098 | + |
4099 | +void SurfaceManager::raise(unityapi::MirSurfaceInterface *surface) |
4100 | +{ |
4101 | + auto qtmirSurface = static_cast<qtmir::MirSurface*>(surface); |
4102 | + m_windowController->raise(qtmirSurface->window()); |
4103 | +} |
4104 | + |
4105 | +void SurfaceManager::activate(unityapi::MirSurfaceInterface *surface) |
4106 | +{ |
4107 | + auto qtmirSurface = static_cast<qtmir::MirSurface*>(surface); |
4108 | + m_windowController->activate(qtmirSurface ? qtmirSurface->window() : miral::Window()); |
4109 | +} |
4110 | |
4111 | === added file 'src/modules/Unity/Application/surfacemanager.h' |
4112 | --- src/modules/Unity/Application/surfacemanager.h 1970-01-01 00:00:00 +0000 |
4113 | +++ src/modules/Unity/Application/surfacemanager.h 2016-12-16 08:22:54 +0000 |
4114 | @@ -0,0 +1,73 @@ |
4115 | +/* |
4116 | + * Copyright (C) 2016 Canonical, Ltd. |
4117 | + * |
4118 | + * This program is free software: you can redistribute it and/or modify it under |
4119 | + * the terms of the GNU Lesser General Public License version 3, as published by |
4120 | + * the Free Software Foundation. |
4121 | + * |
4122 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
4123 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
4124 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4125 | + * Lesser General Public License for more details. |
4126 | + * |
4127 | + * You should have received a copy of the GNU Lesser General Public License |
4128 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4129 | + */ |
4130 | + |
4131 | +#ifndef QTMIR_SURFACEMANAGER_H |
4132 | +#define QTMIR_SURFACEMANAGER_H |
4133 | + |
4134 | +// common |
4135 | +#include "windowmodelnotifier.h" |
4136 | + |
4137 | +// Unity API |
4138 | +#include <unity/shell/application/SurfaceManagerInterface.h> |
4139 | + |
4140 | +#include <QVector> |
4141 | +#include <QLoggingCategory> |
4142 | + |
4143 | +Q_DECLARE_LOGGING_CATEGORY(QTMIR_SURFACEMANAGER) |
4144 | + |
4145 | +namespace qtmir { |
4146 | + |
4147 | +class MirSurface; |
4148 | +class SessionManager; |
4149 | +class WindowControllerInterface; |
4150 | + |
4151 | +class SurfaceManager : public unity::shell::application::SurfaceManagerInterface |
4152 | +{ |
4153 | + Q_OBJECT |
4154 | + |
4155 | +public: |
4156 | + explicit SurfaceManager(QObject *parent = 0); |
4157 | + virtual ~SurfaceManager() {} |
4158 | + |
4159 | + void raise(unity::shell::application::MirSurfaceInterface *surface) override; |
4160 | + void activate(unity::shell::application::MirSurfaceInterface *surface) override; |
4161 | + |
4162 | +private Q_SLOTS: |
4163 | + void onWindowAdded(const qtmir::NewWindow &windowInfo); |
4164 | + void onWindowRemoved(const miral::WindowInfo &windowInfo); |
4165 | + void onWindowReady(const miral::WindowInfo &windowInfo); |
4166 | + void onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft); |
4167 | + void onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state); |
4168 | + void onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused); |
4169 | + void onWindowsRaised(const std::vector<miral::Window> &windows); |
4170 | + void onWindowsRequestedRaise(const miral::WindowInfo &windowInfo); |
4171 | + |
4172 | +private: |
4173 | + void connectToWindowModelNotifier(WindowModelNotifier *notifier); |
4174 | + void rememberMirSurface(MirSurface *surface); |
4175 | + void forgetMirSurface(const miral::Window &window); |
4176 | + MirSurface* find(const miral::WindowInfo &needle) const; |
4177 | + MirSurface* find(const miral::Window &needle) const; |
4178 | + |
4179 | + QVector<MirSurface*> m_allSurfaces; |
4180 | + |
4181 | + WindowControllerInterface *m_windowController; |
4182 | + SessionManager* m_sessionManager; |
4183 | +}; |
4184 | + |
4185 | +} // namespace qtmir |
4186 | + |
4187 | +#endif // QTMIR_SURFACEMANAGER_H |
4188 | |
4189 | === added file 'src/modules/Unity/Application/windowmodel.cpp' |
4190 | --- src/modules/Unity/Application/windowmodel.cpp 1970-01-01 00:00:00 +0000 |
4191 | +++ src/modules/Unity/Application/windowmodel.cpp 2016-12-16 08:22:54 +0000 |
4192 | @@ -0,0 +1,235 @@ |
4193 | +/* |
4194 | + * Copyright (C) 2016 Canonical, Ltd. |
4195 | + * |
4196 | + * This program is free software: you can redistribute it and/or modify it under |
4197 | + * the terms of the GNU Lesser General Public License version 3, as published by |
4198 | + * the Free Software Foundation. |
4199 | + * |
4200 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
4201 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
4202 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4203 | + * Lesser General Public License for more details. |
4204 | + * |
4205 | + * You should have received a copy of the GNU Lesser General Public License |
4206 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4207 | + */ |
4208 | + |
4209 | +#include "windowmodel.h" |
4210 | + |
4211 | +#include "mirsurface.h" |
4212 | + |
4213 | +// mirserver |
4214 | +#include "nativeinterface.h" |
4215 | + |
4216 | +// Qt |
4217 | +#include <QGuiApplication> |
4218 | +#include <QDebug> |
4219 | + |
4220 | +using namespace qtmir; |
4221 | + |
4222 | +WindowModel::WindowModel() |
4223 | +{ |
4224 | + auto nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface()); |
4225 | + |
4226 | + if (!nativeInterface) { |
4227 | + qFatal("ERROR: Unity.Application QML plugin requires use of the 'mirserver' QPA plugin"); |
4228 | + } |
4229 | + |
4230 | + m_windowController = static_cast<WindowControllerInterface*>(nativeInterface->nativeResourceForIntegration("WindowController")); |
4231 | + |
4232 | + auto windowModel = static_cast<WindowModelNotifier*>(nativeInterface->nativeResourceForIntegration("WindowModelNotifier")); |
4233 | + connectToWindowModelNotifier(windowModel); |
4234 | +} |
4235 | + |
4236 | +WindowModel::WindowModel(WindowModelNotifier *notifier, |
4237 | + WindowControllerInterface *controller) |
4238 | + : m_windowController(controller) |
4239 | +{ |
4240 | + connectToWindowModelNotifier(notifier); |
4241 | +} |
4242 | + |
4243 | +void WindowModel::connectToWindowModelNotifier(WindowModelNotifier *notifier) |
4244 | +{ |
4245 | + connect(notifier, &WindowModelNotifier::windowAdded, this, &WindowModel::onWindowAdded, Qt::QueuedConnection); |
4246 | + connect(notifier, &WindowModelNotifier::windowRemoved, this, &WindowModel::onWindowRemoved, Qt::QueuedConnection); |
4247 | + connect(notifier, &WindowModelNotifier::windowReady, this, &WindowModel::onWindowReady, Qt::QueuedConnection); |
4248 | + connect(notifier, &WindowModelNotifier::windowMoved, this, &WindowModel::onWindowMoved, Qt::QueuedConnection); |
4249 | + connect(notifier, &WindowModelNotifier::windowStateChanged, this, &WindowModel::onWindowStateChanged, Qt::QueuedConnection); |
4250 | + connect(notifier, &WindowModelNotifier::windowFocusChanged, this, &WindowModel::onWindowFocusChanged, Qt::QueuedConnection); |
4251 | + connect(notifier, &WindowModelNotifier::windowsRaised, this, &WindowModel::onWindowsRaised, Qt::QueuedConnection); |
4252 | +} |
4253 | + |
4254 | +QHash<int, QByteArray> WindowModel::roleNames() const |
4255 | +{ |
4256 | + QHash<int, QByteArray> roleNames; |
4257 | + roleNames.insert(SurfaceRole, "surface"); |
4258 | + return roleNames; |
4259 | +} |
4260 | + |
4261 | +void WindowModel::onWindowAdded(const NewWindow &window) |
4262 | +{ |
4263 | + if (window.windowInfo.type() == mir_surface_type_inputmethod) { |
4264 | + addInputMethodWindow(window); |
4265 | + return; |
4266 | + } |
4267 | + |
4268 | + const int index = m_windowModel.count(); |
4269 | + beginInsertRows(QModelIndex(), index, index); |
4270 | + m_windowModel.append(new MirSurface(window, m_windowController)); |
4271 | + endInsertRows(); |
4272 | + Q_EMIT countChanged(); |
4273 | +} |
4274 | + |
4275 | +void WindowModel::onWindowRemoved(const miral::WindowInfo &windowInfo) |
4276 | +{ |
4277 | + if (windowInfo.type() == mir_surface_type_inputmethod) { |
4278 | + removeInputMethodWindow(); |
4279 | + return; |
4280 | + } |
4281 | + |
4282 | + const int index = findIndexOf(windowInfo.window()); |
4283 | + |
4284 | + beginRemoveRows(QModelIndex(), index, index); |
4285 | + m_windowModel.takeAt(index); |
4286 | + endRemoveRows(); |
4287 | + Q_EMIT countChanged(); |
4288 | +} |
4289 | + |
4290 | +void WindowModel::onWindowReady(const miral::WindowInfo &windowInfo) |
4291 | +{ |
4292 | + if (auto mirSurface = find(windowInfo)) { |
4293 | + mirSurface->setReady(); |
4294 | + } |
4295 | +} |
4296 | + |
4297 | +void WindowModel::onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft) |
4298 | +{ |
4299 | + if (auto mirSurface = find(windowInfo)) { |
4300 | + mirSurface->setPosition(topLeft); |
4301 | + } |
4302 | +} |
4303 | + |
4304 | +void WindowModel::onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused) |
4305 | +{ |
4306 | + if (auto mirSurface = find(windowInfo)) { |
4307 | + mirSurface->setFocused(focused); |
4308 | + } |
4309 | +} |
4310 | + |
4311 | +void WindowModel::onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state) |
4312 | +{ |
4313 | + if (auto mirSurface = find(windowInfo)) { |
4314 | + mirSurface->updateState(state); |
4315 | + } |
4316 | +} |
4317 | + |
4318 | +void WindowModel::addInputMethodWindow(const NewWindow &windowInfo) |
4319 | +{ |
4320 | + if (m_inputMethodSurface) { |
4321 | + qDebug("Multiple Input Method Surfaces created, removing the old one!"); |
4322 | + delete m_inputMethodSurface; |
4323 | + } |
4324 | + m_inputMethodSurface = new MirSurface(windowInfo, m_windowController); |
4325 | + Q_EMIT inputMethodSurfaceChanged(m_inputMethodSurface); |
4326 | +} |
4327 | + |
4328 | +void WindowModel::removeInputMethodWindow() |
4329 | +{ |
4330 | + if (m_inputMethodSurface) { |
4331 | + delete m_inputMethodSurface; |
4332 | + m_inputMethodSurface = nullptr; |
4333 | + Q_EMIT inputMethodSurfaceChanged(m_inputMethodSurface); |
4334 | + } |
4335 | +} |
4336 | + |
4337 | +void WindowModel::onWindowsRaised(const std::vector<miral::Window> &windows) |
4338 | +{ |
4339 | + // Reminder: last item in the "windows" list should end up at the top of the model |
4340 | + const int modelCount = m_windowModel.count(); |
4341 | + const int raiseCount = windows.size(); |
4342 | + |
4343 | + // Assumption: no NO-OPs are in this list - Qt will crash on endMoveRows() if you try NO-OPs!!! |
4344 | + // A NO-OP is if |
4345 | + // 1. "indices" is an empty list |
4346 | + // 2. "indices" of the form (..., modelCount - 2, modelCount - 1) which results in an unchanged list |
4347 | + |
4348 | + // Precompute the list of indices of Windows/Surfaces to raise, including the offsets due to |
4349 | + // indices which have already been moved. |
4350 | + QVector<QPair<int /*from*/, int /*to*/>> moveList; |
4351 | + |
4352 | + for (int i=raiseCount-1; i>=0; i--) { |
4353 | + int from = findIndexOf(windows[i]); |
4354 | + const int to = modelCount - raiseCount + i; |
4355 | + |
4356 | + int moveCount = 0; |
4357 | + // how many list items under "index" have been moved so far, correct "from" to suit |
4358 | + for (int j=raiseCount-1; j>i; j--) { |
4359 | + if (findIndexOf(windows[j]) < from) { |
4360 | + moveCount++; |
4361 | + } |
4362 | + } |
4363 | + from -= moveCount; |
4364 | + |
4365 | + if (from == to) { |
4366 | + // is NO-OP, would result in moving element to itself |
4367 | + } else { |
4368 | + moveList.prepend({from, to}); |
4369 | + } |
4370 | + } |
4371 | + |
4372 | + // Perform the moving, trusting the moveList is correct for each iteration. |
4373 | + QModelIndex parent; |
4374 | + for (int i=moveList.count()-1; i>=0; i--) { |
4375 | + const int from = moveList[i].first; |
4376 | + const int to = moveList[i].second; |
4377 | + |
4378 | + beginMoveRows(parent, from, from, parent, to+1); |
4379 | +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) |
4380 | + const auto &window = m_windowModel.takeAt(from); |
4381 | + m_windowModel.insert(to, window); |
4382 | +#else |
4383 | + m_windowModel.move(from, to); |
4384 | +#endif |
4385 | + |
4386 | + endMoveRows(); |
4387 | + } |
4388 | +} |
4389 | + |
4390 | +int WindowModel::rowCount(const QModelIndex &/*parent*/) const |
4391 | +{ |
4392 | + return m_windowModel.count(); |
4393 | +} |
4394 | + |
4395 | +QVariant WindowModel::data(const QModelIndex &index, int role) const |
4396 | +{ |
4397 | + if (index.row() < 0 || index.row() >= m_windowModel.count()) |
4398 | + return QVariant(); |
4399 | + |
4400 | + if (role == SurfaceRole) { |
4401 | + auto &surface = m_windowModel.at(index.row()); |
4402 | + return QVariant::fromValue(surface); |
4403 | + } else { |
4404 | + return QVariant(); |
4405 | + } |
4406 | +} |
4407 | + |
4408 | +MirSurface *WindowModel::find(const miral::WindowInfo &needle) const |
4409 | +{ |
4410 | + auto window = needle.window(); |
4411 | + Q_FOREACH(const auto mirSurface, m_windowModel) { |
4412 | + if (mirSurface->window() == window) { |
4413 | + return mirSurface; |
4414 | + } |
4415 | + } |
4416 | + return nullptr; |
4417 | +} |
4418 | + |
4419 | +int WindowModel::findIndexOf(const miral::Window &needle) const |
4420 | +{ |
4421 | + for (int i=0; i<m_windowModel.count(); i++) { |
4422 | + if (m_windowModel[i]->window() == needle) { |
4423 | + return i; |
4424 | + } |
4425 | + } |
4426 | + return -1; |
4427 | +} |
4428 | |
4429 | === added file 'src/modules/Unity/Application/windowmodel.h' |
4430 | --- src/modules/Unity/Application/windowmodel.h 1970-01-01 00:00:00 +0000 |
4431 | +++ src/modules/Unity/Application/windowmodel.h 2016-12-16 08:22:54 +0000 |
4432 | @@ -0,0 +1,83 @@ |
4433 | +/* |
4434 | + * Copyright (C) 2016 Canonical, Ltd. |
4435 | + * |
4436 | + * This program is free software: you can redistribute it and/or modify it under |
4437 | + * the terms of the GNU Lesser General Public License version 3, as published by |
4438 | + * the Free Software Foundation. |
4439 | + * |
4440 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
4441 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
4442 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4443 | + * Lesser General Public License for more details. |
4444 | + * |
4445 | + * You should have received a copy of the GNU Lesser General Public License |
4446 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4447 | + */ |
4448 | + |
4449 | +#ifndef WINDOWMODEL_H |
4450 | +#define WINDOWMODEL_H |
4451 | + |
4452 | +#include <QAbstractListModel> |
4453 | + |
4454 | +#include "mirsurface.h" |
4455 | +#include "windowmodelnotifier.h" |
4456 | + |
4457 | +namespace qtmir { |
4458 | + |
4459 | +class WindowControllerInterface; |
4460 | + |
4461 | +class WindowModel : public QAbstractListModel |
4462 | +{ |
4463 | + Q_OBJECT |
4464 | + |
4465 | + Q_PROPERTY(int count READ count NOTIFY countChanged) |
4466 | + |
4467 | + Q_PROPERTY(MirSurfaceInterface* inputMethodSurface READ inputMethodSurface NOTIFY inputMethodSurfaceChanged) |
4468 | + |
4469 | +public: |
4470 | + enum Roles { |
4471 | + SurfaceRole = Qt::UserRole |
4472 | + }; |
4473 | + |
4474 | + WindowModel(); |
4475 | + explicit WindowModel(WindowModelNotifier *notifier, |
4476 | + WindowControllerInterface *controller); // For testing |
4477 | + |
4478 | + // QAbstractItemModel methods |
4479 | + int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
4480 | + QVariant data(const QModelIndex& index, int role) const override; |
4481 | + |
4482 | + QHash<int, QByteArray> roleNames() const override; |
4483 | + |
4484 | + int count() const { return rowCount(); } |
4485 | + |
4486 | + MirSurface* inputMethodSurface() const { return m_inputMethodSurface; } |
4487 | + |
4488 | +Q_SIGNALS: |
4489 | + void countChanged(); |
4490 | + void inputMethodSurfaceChanged(MirSurfaceInterface* inputMethodSurface); |
4491 | + |
4492 | +private Q_SLOTS: |
4493 | + void onWindowAdded(const qtmir::NewWindow &windowInfo); |
4494 | + void onWindowRemoved(const miral::WindowInfo &windowInfo); |
4495 | + void onWindowReady(const miral::WindowInfo &windowInfo); |
4496 | + void onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft); |
4497 | + void onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state); |
4498 | + void onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused); |
4499 | + void onWindowsRaised(const std::vector<miral::Window> &windows); |
4500 | + |
4501 | +private: |
4502 | + void connectToWindowModelNotifier(WindowModelNotifier *notifier); |
4503 | + |
4504 | + void addInputMethodWindow(const NewWindow &windowInfo); |
4505 | + void removeInputMethodWindow(); |
4506 | + MirSurface* find(const miral::WindowInfo &needle) const; |
4507 | + int findIndexOf(const miral::Window &needle) const; |
4508 | + |
4509 | + QVector<MirSurface*> m_windowModel; |
4510 | + WindowControllerInterface *m_windowController; |
4511 | + MirSurface* m_inputMethodSurface{nullptr}; |
4512 | +}; |
4513 | + |
4514 | +} // namespace qtmir |
4515 | +#endif // WINDOWMODEL_H |
4516 | |
4517 | === modified file 'src/modules/Unity/Screens/CMakeLists.txt' |
4518 | --- src/modules/Unity/Screens/CMakeLists.txt 2016-06-06 18:12:07 +0000 |
4519 | +++ src/modules/Unity/Screens/CMakeLists.txt 2016-12-16 08:22:54 +0000 |
4520 | @@ -4,9 +4,9 @@ |
4521 | |
4522 | include_directories( |
4523 | SYSTEM |
4524 | + ${MIRCLIENT_INCLUDE_DIRS} |
4525 | ${Qt5Gui_PRIVATE_INCLUDE_DIRS} |
4526 | ${Qt5Quick_INCLUDE_DIRS} |
4527 | - ${MIRSERVER_INCLUDE_DIRS} |
4528 | ) |
4529 | |
4530 | set(SCREENSPLUGIN_SRC |
4531 | |
4532 | === modified file 'src/modules/Unity/Screens/plugin.cpp' |
4533 | --- src/modules/Unity/Screens/plugin.cpp 2016-04-29 15:41:00 +0000 |
4534 | +++ src/modules/Unity/Screens/plugin.cpp 2016-12-16 08:22:54 +0000 |
4535 | @@ -36,7 +36,7 @@ |
4536 | qRegisterMetaType<QScreen*>("QScreen*"); |
4537 | |
4538 | qmlRegisterType<qtmir::Screens>(uri, 0, 1, "Screens"); |
4539 | - qRegisterMetaType<qtmir::Screens::FormFactor>("Screens::FormFactor"); |
4540 | + qRegisterMetaType<qtmir::FormFactor>("qtmir::FormFactor"); |
4541 | |
4542 | qmlRegisterType<qtmir::QQuickScreenWindow>(uri, 0, 1, "ScreenWindow"); |
4543 | } |
4544 | |
4545 | === modified file 'src/modules/Unity/Screens/qquickscreenwindow.cpp' |
4546 | --- src/modules/Unity/Screens/qquickscreenwindow.cpp 2016-06-06 19:25:20 +0000 |
4547 | +++ src/modules/Unity/Screens/qquickscreenwindow.cpp 2016-12-16 08:22:54 +0000 |
4548 | @@ -48,7 +48,7 @@ |
4549 | QQuickScreenWindow::QQuickScreenWindow(QQuickWindow *parent) |
4550 | : QQuickWindow(parent) |
4551 | , m_scale(-1.0) // start with invalid initial state, fetch correct value on first invokation |
4552 | - , m_formFactor(Screens::FormFactorUnknown) |
4553 | + , m_formFactor(FormFactorUnknown) |
4554 | { |
4555 | if (qGuiApp->platformName() == QLatin1String("mirserver")) { |
4556 | connect(qGuiApp->platformNativeInterface(), &QPlatformNativeInterface::windowPropertyChanged, |
4557 | @@ -91,7 +91,7 @@ |
4558 | return m_scale; |
4559 | } |
4560 | |
4561 | -bool QQuickScreenWindow::setScaleAndFormFactor(const float scale, const Screens::FormFactor formFactor) |
4562 | +bool QQuickScreenWindow::setScaleAndFormFactor(const float scale, const FormFactor formFactor) |
4563 | { |
4564 | if (qFuzzyCompare(scale, m_scale) && formFactor == m_formFactor) { |
4565 | return true; |
4566 | @@ -125,9 +125,9 @@ |
4567 | return controller->setConfiguration(configs); |
4568 | } |
4569 | |
4570 | -Screens::FormFactor QQuickScreenWindow::formFactor() |
4571 | +FormFactor QQuickScreenWindow::formFactor() |
4572 | { |
4573 | - if (m_formFactor == Screens::FormFactorUnknown) { |
4574 | + if (m_formFactor == FormFactorUnknown) { |
4575 | m_formFactor = getFormFactorNativeProperty(); |
4576 | } |
4577 | return m_formFactor; |
4578 | @@ -173,7 +173,7 @@ |
4579 | return scale; |
4580 | } |
4581 | |
4582 | -Screens::FormFactor QQuickScreenWindow::getFormFactorNativeProperty() const |
4583 | +FormFactor QQuickScreenWindow::getFormFactorNativeProperty() const |
4584 | { |
4585 | QVariant formFactorVal = qGuiApp->platformNativeInterface() |
4586 | ->windowProperty(handle(), QStringLiteral("formFactor")); |
4587 | @@ -181,5 +181,5 @@ |
4588 | return m_formFactor; |
4589 | } |
4590 | |
4591 | - return static_cast<Screens::FormFactor>(formFactorVal.toInt()); |
4592 | + return static_cast<FormFactor>(formFactorVal.toInt()); |
4593 | } |
4594 | |
4595 | === modified file 'src/modules/Unity/Screens/qquickscreenwindow.h' |
4596 | --- src/modules/Unity/Screens/qquickscreenwindow.h 2016-01-28 23:32:53 +0000 |
4597 | +++ src/modules/Unity/Screens/qquickscreenwindow.h 2016-12-16 08:22:54 +0000 |
4598 | @@ -28,7 +28,7 @@ |
4599 | |
4600 | Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged) |
4601 | Q_PROPERTY(float scale READ scale NOTIFY scaleChanged) |
4602 | - Q_PROPERTY(Screens::FormFactor formFactor READ formFactor NOTIFY formFactorChanged) |
4603 | + Q_PROPERTY(FormFactor formFactor READ formFactor NOTIFY formFactorChanged) |
4604 | |
4605 | public: |
4606 | explicit QQuickScreenWindow(QQuickWindow *parent = 0); |
4607 | @@ -37,13 +37,13 @@ |
4608 | void setScreen(QScreen *screen); |
4609 | |
4610 | qreal scale(); |
4611 | - Screens::FormFactor formFactor(); |
4612 | - Q_INVOKABLE bool setScaleAndFormFactor(const float scale, const Screens::FormFactor formFactor); |
4613 | + FormFactor formFactor(); |
4614 | + Q_INVOKABLE bool setScaleAndFormFactor(const float scale, const FormFactor formFactor); |
4615 | |
4616 | Q_SIGNALS: |
4617 | void screenChanged(QScreen *screen); |
4618 | void scaleChanged(qreal scale); |
4619 | - void formFactorChanged(Screens::FormFactor arg); |
4620 | + void formFactorChanged(FormFactor arg); |
4621 | |
4622 | private Q_SLOTS: |
4623 | void nativePropertyChanged(QPlatformWindow *window, const QString &propertyName); |
4624 | @@ -51,8 +51,8 @@ |
4625 | private: |
4626 | float getScaleNativeProperty() const; |
4627 | float m_scale; |
4628 | - Screens::FormFactor getFormFactorNativeProperty() const; |
4629 | - Screens::FormFactor m_formFactor; |
4630 | + FormFactor getFormFactorNativeProperty() const; |
4631 | + FormFactor m_formFactor; |
4632 | }; |
4633 | |
4634 | } //namespace qtmir |
4635 | |
4636 | === modified file 'src/modules/Unity/Screens/screens.cpp' |
4637 | --- src/modules/Unity/Screens/screens.cpp 2016-04-29 15:41:00 +0000 |
4638 | +++ src/modules/Unity/Screens/screens.cpp 2016-12-16 08:22:54 +0000 |
4639 | @@ -62,7 +62,7 @@ |
4640 | case OutputTypeRole: { |
4641 | auto screen = static_cast<Screen*>(m_screenList.at(index.row())->handle()); |
4642 | if (screen) { |
4643 | - return QVariant(static_cast<OutputTypes>(screen->outputType())); //FIXME: cheeky |
4644 | + return QVariant(screen->outputType()); |
4645 | } else { |
4646 | return OutputTypes::Unknown; |
4647 | } |
4648 | |
4649 | === modified file 'src/modules/Unity/Screens/screens.h' |
4650 | --- src/modules/Unity/Screens/screens.h 2016-04-29 15:41:00 +0000 |
4651 | +++ src/modules/Unity/Screens/screens.h 2016-12-16 08:22:54 +0000 |
4652 | @@ -17,6 +17,8 @@ |
4653 | #ifndef SCREENS_H |
4654 | #define SCREENS_H |
4655 | |
4656 | +#include "screentypes.h" |
4657 | + |
4658 | #include <QAbstractListModel> |
4659 | |
4660 | class QScreen; |
4661 | @@ -39,33 +41,6 @@ |
4662 | FormFactorRole, |
4663 | }; |
4664 | |
4665 | - enum OutputTypes { |
4666 | - Unknown, |
4667 | - VGA, |
4668 | - DVII, |
4669 | - DVID, |
4670 | - DVIA, |
4671 | - Composite, |
4672 | - SVideo, |
4673 | - LVDS, |
4674 | - Component, |
4675 | - NinePinDIN, |
4676 | - DisplayPort, |
4677 | - HDMIA, |
4678 | - HDMIB, |
4679 | - TV, |
4680 | - EDP |
4681 | - }; |
4682 | - |
4683 | - enum FormFactor { |
4684 | - FormFactorUnknown, |
4685 | - FormFactorPhone, |
4686 | - FormFactorTablet, |
4687 | - FormFactorMonitor, |
4688 | - FormFactorTV, |
4689 | - FormFactorProjector, |
4690 | - }; |
4691 | - |
4692 | explicit Screens(QObject *parent = 0); |
4693 | virtual ~Screens() noexcept = default; |
4694 | |
4695 | @@ -91,6 +66,4 @@ |
4696 | |
4697 | } // namespace qtmir |
4698 | |
4699 | -Q_DECLARE_METATYPE(qtmir::Screens::FormFactor) |
4700 | - |
4701 | #endif // SCREENS_H |
4702 | |
4703 | === modified file 'src/platforms/mirserver/CMakeLists.txt' |
4704 | --- src/platforms/mirserver/CMakeLists.txt 2016-09-08 22:46:57 +0000 |
4705 | +++ src/platforms/mirserver/CMakeLists.txt 2016-12-16 08:22:54 +0000 |
4706 | @@ -25,11 +25,11 @@ |
4707 | |
4708 | include_directories( |
4709 | ${CMAKE_SOURCE_DIR}/src/common |
4710 | - |
4711 | ) |
4712 | |
4713 | include_directories( |
4714 | - SYSTEM |
4715 | + SYSTEM |
4716 | + ${MIRAL_INCLUDE_DIRS} |
4717 | ${MIRCOMMON_INCLUDE_DIRS} |
4718 | ${MIRSERVER_INCLUDE_DIRS} |
4719 | ${MIRRENDERERGLDEV_INCLUDE_DIRS} |
4720 | @@ -53,56 +53,70 @@ |
4721 | # Needed to compile tracepoints in C99 mode. |
4722 | add_definitions(-DBYTE_ORDER=__BYTE_ORDER) |
4723 | |
4724 | -set(MIRSERVER_QPA_PLUGIN_SRC |
4725 | - ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp |
4726 | +# These files will compile without mirserver-dev |
4727 | +add_library(qpa-mirserver-nomirserver OBJECT |
4728 | ${CMAKE_SOURCE_DIR}/src/common/timestamp.cpp |
4729 | - cursor.cpp |
4730 | - eventbuilder.cpp |
4731 | logging.cpp |
4732 | + plugin.cpp |
4733 | + shelluuid.cpp |
4734 | + ubuntutheme.cpp |
4735 | + clipboard.cpp |
4736 | + openglcontextfactory.cpp openglcontextfactory.h |
4737 | mircursorimages.cpp |
4738 | mirdisplayconfigurationpolicy.cpp |
4739 | - mirwindowmanager.cpp |
4740 | mirsingleton.cpp |
4741 | + sessionauthorizer.cpp |
4742 | + promptsessionlistener.cpp |
4743 | + mirserverstatuslistener.cpp |
4744 | + screenscontroller.cpp |
4745 | + nativeinterface.cpp |
4746 | + qtcompositor.cpp |
4747 | + services.cpp |
4748 | + windowcontroller.cpp |
4749 | + windowmanagementpolicy.cpp |
4750 | + mirserverhooks.cpp mirserverhooks.h |
4751 | + setqtcompositor.cpp setqtcompositor.h |
4752 | + tracepoints.c |
4753 | +# We need to run moc on these headers |
4754 | + ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h |
4755 | + ${CMAKE_SOURCE_DIR}/src/common/appnotifier.h |
4756 | + ${CMAKE_SOURCE_DIR}/src/common/windowcontrollerinterface.h |
4757 | + ${CMAKE_SOURCE_DIR}/src/common/windowmodelnotifier.h |
4758 | +) |
4759 | +set_source_files_properties(tracepoints.c PROPERTIES COMPILE_FLAGS "${CMAKE_CFLAGS} -fPIC") |
4760 | + |
4761 | +include_directories(SYSTEM ${MIRSERVER_INCLUDE_DIRS}) |
4762 | + |
4763 | +set(MIRSERVER_QPA_PLUGIN_SRC |
4764 | + ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp |
4765 | + cursor.cpp |
4766 | + eventbuilder.cpp |
4767 | qteventfeeder.cpp |
4768 | - plugin.cpp |
4769 | qmirserver.cpp |
4770 | qmirserver_p.cpp |
4771 | - sessionauthorizer.cpp |
4772 | - sessionlistener.cpp |
4773 | - shelluuid.cpp |
4774 | surfaceobserver.cpp |
4775 | - promptsessionlistener.cpp |
4776 | - mirserver.cpp |
4777 | - mirserverstatuslistener.cpp |
4778 | screen.cpp |
4779 | screenwindow.cpp |
4780 | - screenscontroller.cpp |
4781 | screensmodel.cpp |
4782 | mirserverintegration.cpp |
4783 | miropenglcontext.cpp |
4784 | - nativeinterface.cpp |
4785 | offscreensurface.cpp |
4786 | - qtcompositor.cpp |
4787 | - services.cpp |
4788 | - ubuntutheme.cpp |
4789 | - clipboard.cpp |
4790 | - creationhints.cpp |
4791 | - tracepoints.c |
4792 | + promptsessionmanager.cpp promptsessionmanager.h promptsession.h |
4793 | # We need to run moc on these headers |
4794 | - ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h |
4795 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h |
4796 | - ) |
4797 | +) |
4798 | |
4799 | add_library(qpa-mirserver SHARED |
4800 | ${MIRSERVER_QPA_PLUGIN_SRC} |
4801 | + $<TARGET_OBJECTS:qpa-mirserver-nomirserver> |
4802 | ) |
4803 | |
4804 | target_link_libraries( |
4805 | qpa-mirserver |
4806 | Qt5PlatformSupport |
4807 | |
4808 | + ${MIRAL_LDFLAGS} |
4809 | ${MIRSERVER_LDFLAGS} |
4810 | - ${MIRCLIENT_LDFLAGS} |
4811 | ${URL_DISPATCHER_LDFLAGS} |
4812 | ${EGL_LDFLAGS} |
4813 | ${GL_LIBRARIES} |
4814 | |
4815 | === removed file 'src/platforms/mirserver/creationhints.cpp' |
4816 | --- src/platforms/mirserver/creationhints.cpp 2016-06-06 19:25:20 +0000 |
4817 | +++ src/platforms/mirserver/creationhints.cpp 1970-01-01 00:00:00 +0000 |
4818 | @@ -1,67 +0,0 @@ |
4819 | -/* |
4820 | - * Copyright (C) 2016 Canonical, Ltd. |
4821 | - * |
4822 | - * This program is free software: you can redistribute it and/or modify it under |
4823 | - * the terms of the GNU Lesser General Public License version 3, as published by |
4824 | - * the Free Software Foundation. |
4825 | - * |
4826 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
4827 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
4828 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4829 | - * Lesser General Public License for more details. |
4830 | - * |
4831 | - * You should have received a copy of the GNU Lesser General Public License |
4832 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4833 | - */ |
4834 | - |
4835 | -#include <mir/scene/surface_creation_parameters.h> |
4836 | - |
4837 | -#include "creationhints.h" |
4838 | - |
4839 | -using namespace qtmir; |
4840 | - |
4841 | -inline const char* shellChromeToString(Mir::ShellChrome chrome) { |
4842 | - switch (chrome) { |
4843 | - case Mir::ShellChrome::NormalChrome: |
4844 | - return "normal"; |
4845 | - case Mir::ShellChrome::LowChrome: |
4846 | - return "low"; |
4847 | - } |
4848 | - return "unknown"; |
4849 | -} |
4850 | - |
4851 | -CreationHints::CreationHints(const mir::scene::SurfaceCreationParameters ¶ms) |
4852 | -{ |
4853 | - minWidth = params.min_width.is_set() ? params.min_width.value().as_int() : 0; |
4854 | - maxWidth = params.max_width.is_set() ? params.max_width.value().as_int() : 0; |
4855 | - |
4856 | - minHeight = params.min_height.is_set() ? params.min_height.value().as_int() : 0; |
4857 | - maxHeight = params.max_height.is_set() ? params.max_height.value().as_int() : 0; |
4858 | - |
4859 | - widthIncrement = params.width_inc.is_set() ? params.width_inc.value().as_int() : 0; |
4860 | - heightIncrement = params.height_inc.is_set() ? params.height_inc.value().as_int() : 0; |
4861 | - |
4862 | - if (params.shell_chrome.is_set()) { |
4863 | - switch (params.shell_chrome.value()) { |
4864 | - case mir_shell_chrome_normal: |
4865 | - default: |
4866 | - shellChrome = Mir::ShellChrome::NormalChrome; |
4867 | - break; |
4868 | - case mir_shell_chrome_low: |
4869 | - shellChrome = Mir::ShellChrome::LowChrome; |
4870 | - break; |
4871 | - } |
4872 | - } |
4873 | -} |
4874 | - |
4875 | -QString CreationHints::toString() const |
4876 | -{ |
4877 | - return QStringLiteral("CreationHints(minW=%1,minH=%2,maxW=%3,maxH=%4,wIncr=%5,hInc=%6,shellChrome=%7)") |
4878 | - .arg(minWidth) |
4879 | - .arg(minHeight) |
4880 | - .arg(maxWidth) |
4881 | - .arg(maxHeight) |
4882 | - .arg(widthIncrement) |
4883 | - .arg(heightIncrement) |
4884 | - .arg(shellChromeToString(shellChrome)); |
4885 | -} |
4886 | |
4887 | === removed file 'src/platforms/mirserver/creationhints.h' |
4888 | --- src/platforms/mirserver/creationhints.h 2016-06-06 19:25:20 +0000 |
4889 | +++ src/platforms/mirserver/creationhints.h 1970-01-01 00:00:00 +0000 |
4890 | @@ -1,56 +0,0 @@ |
4891 | -/* |
4892 | - * Copyright (C) 2016 Canonical, Ltd. |
4893 | - * |
4894 | - * This program is free software: you can redistribute it and/or modify it under |
4895 | - * the terms of the GNU Lesser General Public License version 3, as published by |
4896 | - * the Free Software Foundation. |
4897 | - * |
4898 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
4899 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
4900 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4901 | - * Lesser General Public License for more details. |
4902 | - * |
4903 | - * You should have received a copy of the GNU Lesser General Public License |
4904 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4905 | - */ |
4906 | - |
4907 | -#ifndef QTMIR_CREATIONHINTS_H |
4908 | -#define QTMIR_CREATIONHINTS_H |
4909 | - |
4910 | -#include <QMetaType> |
4911 | -#include <QString> |
4912 | - |
4913 | -#include <unity/shell/application/Mir.h> |
4914 | - |
4915 | -namespace mir { |
4916 | - namespace scene { |
4917 | - struct SurfaceCreationParameters; |
4918 | - } |
4919 | -} |
4920 | - |
4921 | -namespace qtmir { |
4922 | - |
4923 | -class CreationHints { |
4924 | -public: |
4925 | - CreationHints() {} |
4926 | - CreationHints(const mir::scene::SurfaceCreationParameters&); |
4927 | - |
4928 | - QString toString() const; |
4929 | - |
4930 | - int minWidth{0}; |
4931 | - int maxWidth{0}; |
4932 | - |
4933 | - int minHeight{0}; |
4934 | - int maxHeight{0}; |
4935 | - |
4936 | - int widthIncrement{0}; |
4937 | - int heightIncrement{0}; |
4938 | - |
4939 | - Mir::ShellChrome shellChrome{Mir::ShellChrome::NormalChrome}; |
4940 | -}; |
4941 | - |
4942 | -} // namespace qtmir |
4943 | - |
4944 | -Q_DECLARE_METATYPE(qtmir::CreationHints) |
4945 | - |
4946 | -#endif // QTMIR_CREATIONHINTS_H |
4947 | |
4948 | === modified file 'src/platforms/mirserver/cursor.cpp' |
4949 | --- src/platforms/mirserver/cursor.cpp 2016-08-08 13:10:40 +0000 |
4950 | +++ src/platforms/mirserver/cursor.cpp 2016-12-16 08:22:54 +0000 |
4951 | @@ -69,7 +69,7 @@ |
4952 | // just different from the previous custom cursor name, which is enough to trigger a change in the cursor |
4953 | // source image URL in the QML side which on is turn makes QML request the new cursor image. |
4954 | static quint8 serialNumber = 1; |
4955 | - m_qtCursorName = QStringLiteral("custom%1").arg(serialNumber++); |
4956 | + m_qtCursorName = QString("custom%1").arg(serialNumber++); |
4957 | m_mousePointer->setCustomCursor(*windowCursor); |
4958 | } |
4959 | } else { |
4960 | |
4961 | === modified file 'src/platforms/mirserver/customscreenconfiguration.h' |
4962 | --- src/platforms/mirserver/customscreenconfiguration.h 2016-01-11 14:29:06 +0000 |
4963 | +++ src/platforms/mirserver/customscreenconfiguration.h 2016-12-16 08:22:54 +0000 |
4964 | @@ -20,11 +20,13 @@ |
4965 | #include <QPoint> |
4966 | #include <QVector> |
4967 | |
4968 | -#include <mir/graphics/display_configuration.h> |
4969 | +#include "screentypes.h" |
4970 | +#include <mir_toolkit/common.h> |
4971 | + |
4972 | |
4973 | struct CustomScreenConfiguration |
4974 | { |
4975 | - mir::graphics::DisplayConfigurationOutputId id; |
4976 | + qtmir::OutputId id; |
4977 | |
4978 | QPoint topLeft; |
4979 | uint32_t currentModeIndex; |
4980 | |
4981 | === modified file 'src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp' |
4982 | --- src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp 2016-04-29 15:41:00 +0000 |
4983 | +++ src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp 2016-12-16 08:22:54 +0000 |
4984 | @@ -16,8 +16,10 @@ |
4985 | |
4986 | #include "mirdisplayconfigurationpolicy.h" |
4987 | |
4988 | +#include <mir/graphics/display_configuration_policy.h> |
4989 | #include <mir/graphics/display_configuration.h> |
4990 | #include <mir/geometry/point.h> |
4991 | +#include <mir/server.h> |
4992 | |
4993 | #include <qglobal.h> |
4994 | #include <QByteArray> |
4995 | @@ -28,6 +30,18 @@ |
4996 | #define DEFAULT_GRID_UNIT_PX 8 |
4997 | |
4998 | namespace { |
4999 | +class MirDisplayConfigurationPolicy : public mir::graphics::DisplayConfigurationPolicy |
5000 | +{ |
FAILED: Continuous integration, rev:571 /unity8- jenkins. ubuntu. com/job/ lp-qtmir- ci/393/ /unity8- jenkins. ubuntu. com/job/ build/3249/ console /unity8- jenkins. ubuntu. com/job/ build-0- fetch/3277 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 3131/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 3131/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= zesty/3131/ console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 3131/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 3131/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= zesty/3131/ console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 3131/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 3131/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= zesty/3131/ console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-qtmir- ci/393/ rebuild
https:/