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