Merge lp:~unity-team/qtmir/miral-qt-integration into lp:qtmir

Proposed by Daniel d'Andrada
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
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

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
585. By Daniel d'Andrada

Fix order of entries in debian/changelog

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+++ src/common/mirqtconversion.h
missing licence header

review: Needs Fixing
586. By Daniel d'Andrada

Add missing license header

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 05/12/2016 12:59, Gerry Boland wrote:
> Review: Needs Fixing
>
> +++ src/common/mirqtconversion.h
> missing licence header

Fixed

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
587. By Daniel d'Andrada

findApplicationWithSurface is const

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) :
review: Approve (code)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:587
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/426/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3519
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3547
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3394
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3394/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3394
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3394/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3394
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3394/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3394
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3394/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3394
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3394/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3394
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3394/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/426/rebuild

review: Approve (continuous-integration)
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-12-03 12:37:37 +0000
+++ CMakeLists.txt 2016-12-16 08:22:54 +0000
@@ -3,7 +3,7 @@
3project(qtmir)3project(qtmir)
44
5set(QTMIR_VERSION_MAJOR 0)5set(QTMIR_VERSION_MAJOR 0)
6set(QTMIR_VERSION_MINOR 1)6set(QTMIR_VERSION_MINOR 2)
7set(QTMIR_VERSION_PATCH 0)7set(QTMIR_VERSION_PATCH 0)
88
9if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})9if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
@@ -30,6 +30,10 @@
30set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wall -fno-strict-aliasing -Werror -Wextra")30set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wall -fno-strict-aliasing -Werror -Wextra")
31set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")31set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
3232
33if ("${CMAKE_CXX_COMPILER}" MATCHES "clang")
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")
35endif()
36
3337
34include(EnableCoverageReport)38include(EnableCoverageReport)
35#####################################################################39#####################################################################
@@ -70,6 +74,7 @@
70pkg_check_modules(MIRSERVER mirserver>=0.25 REQUIRED)74pkg_check_modules(MIRSERVER mirserver>=0.25 REQUIRED)
71pkg_check_modules(MIRCLIENT mirclient>=0.25 REQUIRED)75pkg_check_modules(MIRCLIENT mirclient>=0.25 REQUIRED)
72pkg_check_modules(MIRRENDERERGLDEV mir-renderer-gl-dev>=0.24 REQUIRED)76pkg_check_modules(MIRRENDERERGLDEV mir-renderer-gl-dev>=0.24 REQUIRED)
77pkg_check_modules(MIRAL miral>=0.4 REQUIRED)
7378
74pkg_check_modules(XKBCOMMON xkbcommon REQUIRED)79pkg_check_modules(XKBCOMMON xkbcommon REQUIRED)
75pkg_check_modules(GLIB glib-2.0 REQUIRED)80pkg_check_modules(GLIB glib-2.0 REQUIRED)
@@ -83,15 +88,13 @@
83pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)88pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
84pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)89pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
85pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)90pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
86pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=22)91pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=23)
87pkg_check_modules(CGMANAGER libcgmanager REQUIRED)92pkg_check_modules(CGMANAGER libcgmanager REQUIRED)
88pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)93pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)
8994
90include_directories(SYSTEM ${APPLICATION_API_INCLUDE_DIRS})95include_directories(SYSTEM ${APPLICATION_API_INCLUDE_DIRS})
9196
9297
93add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)
94
95# Use the fast string builder98# Use the fast string builder
96add_definitions(-DQT_USE_QSTRINGBUILDER)99add_definitions(-DQT_USE_QSTRINGBUILDER)
97100
98101
=== modified file 'debian/changelog'
--- debian/changelog 2016-12-03 12:38:04 +0000
+++ debian/changelog 2016-12-16 08:22:54 +0000
@@ -1,3 +1,9 @@
1qtmir (0.5.1) UNRELEASED; urgency=medium
2
3 * First release using MirAL
4
5 -- Gerry Boland <gerry.boland@canonical.com> Fri, 14 Oct 2016 16:51:26 +0100
6
1qtmir (0.5.0+17.04.20161203-0ubuntu1) zesty; urgency=medium7qtmir (0.5.0+17.04.20161203-0ubuntu1) zesty; urgency=medium
28
3 * Mir 0.25 compat9 * Mir 0.25 compat
410
=== modified file 'debian/control'
--- debian/control 2016-11-16 17:49:19 +0000
+++ debian/control 2016-12-16 08:22:54 +0000
@@ -13,6 +13,7 @@
13 libglib2.0-dev,13 libglib2.0-dev,
14 libgsettings-qt-dev,14 libgsettings-qt-dev,
15 liblttng-ust-dev,15 liblttng-ust-dev,
16 libmiral-dev (>= 0.4),
16 libmirclient-dev (>= 0.25.0),17 libmirclient-dev (>= 0.25.0),
17 libmircommon-dev (>= 0.25.0),18 libmircommon-dev (>= 0.25.0),
18 libmirserver-dev (>= 0.25.0),19 libmirserver-dev (>= 0.25.0),
@@ -24,12 +25,12 @@
24 libubuntu-app-launch2-dev (>= 0.9),25 libubuntu-app-launch2-dev (>= 0.9),
25 libubuntu-application-api-dev (>= 2.1.0),26 libubuntu-application-api-dev (>= 2.1.0),
26 libudev-dev,27 libudev-dev,
27 libunity-api-dev (>= 7.119),28 libunity-api-dev (>= 8.0),
28 liburl-dispatcher1-dev,29 liburl-dispatcher1-dev,
29 libxkbcommon-dev,30 libxkbcommon-dev,
30 libxrender-dev,31 libxrender-dev,
31 mir-renderer-gl-dev (>= 0.24.0),32 mir-renderer-gl-dev (>= 0.25.0),
32 mirtest-dev (>= 0.24.0),33 mirtest-dev (>= 0.25.0),
33 pkg-config,34 pkg-config,
34# lttng-gen-ts needs python3, but doesn't depend on it itself: bug 135914735# lttng-gen-ts needs python3, but doesn't depend on it itself: bug 1359147
35 python3:any,36 python3:any,
@@ -41,6 +42,9 @@
41 quilt,42 quilt,
42# libmirserver-dev should have brought this dep. Bug lp:161743543# libmirserver-dev should have brought this dep. Bug lp:1617435
43 uuid-dev,44 uuid-dev,
45# mirtest pkgconfig requires these, but doesn't have a deb dependency. Bug lp:1633537
46 libboost-filesystem-dev,
47 libboost-system-dev,
44Standards-Version: 3.9.548Standards-Version: 3.9.5
45Homepage: https://launchpad.net/qtmir49Homepage: https://launchpad.net/qtmir
46# if you don't have have commit access to this branch but would like to upload50# if you don't have have commit access to this branch but would like to upload
@@ -98,7 +102,7 @@
98Conflicts: libqtmir,102Conflicts: libqtmir,
99 libunity-mir1,103 libunity-mir1,
100Provides: unity-application-impl,104Provides: unity-application-impl,
101 unity-application-impl-22,105 unity-application-impl-23,
102Description: Qt plugin for Unity specific Mir APIs106Description: Qt plugin for Unity specific Mir APIs
103 QtMir provides Qt/QML bindings for Mir features that are exposed through the107 QtMir provides Qt/QML bindings for Mir features that are exposed through the
104 qtmir-desktop or qtmir-android QPA plugin such as Application management108 qtmir-desktop or qtmir-android QPA plugin such as Application management
105109
=== modified file 'debian/gles-patches/convert-to-gles.patch'
--- debian/gles-patches/convert-to-gles.patch 2016-11-23 19:46:24 +0000
+++ debian/gles-patches/convert-to-gles.patch 2016-12-16 08:22:54 +0000
@@ -84,7 +84,7 @@
84-Conflicts: libqtmir,84-Conflicts: libqtmir,
85- libunity-mir1,85- libunity-mir1,
86-Provides: unity-application-impl,86-Provides: unity-application-impl,
87- unity-application-impl-22,87- unity-application-impl-23,
88-Description: Qt plugin for Unity specific Mir APIs88-Description: Qt plugin for Unity specific Mir APIs
89- QtMir provides Qt/QML bindings for Mir features that are exposed through the89- QtMir provides Qt/QML bindings for Mir features that are exposed through the
90- qtmir-desktop or qtmir-android QPA plugin such as Application management90- qtmir-desktop or qtmir-android QPA plugin such as Application management
9191
=== modified file 'demos/paths.h.in'
--- demos/paths.h.in 2015-09-01 16:16:47 +0000
+++ demos/paths.h.in 2016-12-16 08:22:54 +0000
@@ -37,4 +37,22 @@
37 return QString("@CMAKE_SOURCE_DIR@/demos/");37 return QString("@CMAKE_SOURCE_DIR@/demos/");
38 }38 }
39}39}
40#endif
41\ No newline at end of file40\ No newline at end of file
41
42inline QString qmlPluginDirectory() {
43 if (isRunningInstalled()) {
44 return QString("@QML_MODULE_INSTALL_DIR@/");
45 } else {
46 return QString("@CMAKE_BINARY_DIR@/src/modules/");
47 }
48}
49
50inline QString qpaPluginDirectory() {
51 if (isRunningInstalled()) {
52 return QString("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/qt5/plugins/platforms/");
53 } else {
54 return QString("@CMAKE_BINARY_DIR@/src/platforms/mirserver/");
55 }
56}
57
58#endif
59
4260
=== modified file 'demos/qml-demo-shell/CMakeLists.txt'
--- demos/qml-demo-shell/CMakeLists.txt 2016-06-06 18:12:07 +0000
+++ demos/qml-demo-shell/CMakeLists.txt 2016-12-16 08:22:54 +0000
@@ -8,6 +8,7 @@
8)8)
99
10add_executable(${DEMO_SHELL}10add_executable(${DEMO_SHELL}
11 pointerposition.cpp
11 main.cpp12 main.cpp
12)13)
1314
1415
=== added file 'demos/qml-demo-shell/WindowModelDebugView.qml'
--- demos/qml-demo-shell/WindowModelDebugView.qml 1970-01-01 00:00:00 +0000
+++ demos/qml-demo-shell/WindowModelDebugView.qml 2016-12-16 08:22:54 +0000
@@ -0,0 +1,72 @@
1import QtQuick 2.0
2import Unity.Application 0.1
3
4Column {
5 id: root
6 width: childrenRect.width
7 height: childrenRect.height
8 focus: false
9
10 property alias model: repeater.model
11
12 function stateString(state) {
13 switch(state) {
14 case Mir.HiddenState: return "Hidden"
15 case Mir.RestoredState: return "Restored"
16 case Mir.MinimizedState: return "Minimized"
17 case Mir.MaximizedState: return "Maximized"
18 case Mir.VertMaximizedState: return "VertMax"
19 case Mir.FullscreenState: return "Fullscreen"
20 case Mir.HorizMaximizedState: return "HorizMax"
21 case Mir.UnknownState: return "Unknown"
22 }
23 return "Invalid"
24 }
25 function typeString(type) {
26 switch(type) {
27 case Mir.UnknownType: return "Unknown"
28 case Mir.NormalType: return "Normal"
29 case Mir.UtilityType: return "Utility"
30 case Mir.DialogType: return "Dialog"
31 case Mir.GlossType: return "Gloss"
32 case Mir.FreeStyleType: return "FreeStyle"
33 case Mir.MenuType: return "Menu"
34 case Mir.InputMethodType: return "InputMethod"
35 case Mir.SatelliteType: return "Satellite"
36 case Mir.TipType: return "Tip"
37 }
38 return "Invalid"
39 }
40
41 function geometryString(surface) {
42 return surface.position.x + "," + surface.position.y + " " + surface.size.width + "x" + surface.size.height
43 }
44
45
46 Text {
47 text: "Index\t\Name\tVisible\tState\tType\tGeometry"
48 height: (visible) ? implicitHeight : 0
49 visible: repeater.count > 0
50 color: "white"
51
52 Rectangle {
53 anchors.fill: parent
54 color: "blue"
55 z: -1
56 }
57 }
58 Repeater {
59 id: repeater
60 delegate: Text {
61 text: index + "\t" + surface.name + "\t" + surface.visible + "\t"
62 + stateString(surface.state) + "\t" + typeString(surface.type) + "\t" + geometryString(surface)
63 font.bold: surface.focused
64
65 Rectangle {
66 anchors.fill: parent
67 color: (index % 2) ? "white" : "lightblue"
68 z: -1
69 }
70 }
71 }
72}
073
=== modified file 'demos/qml-demo-shell/main.cpp'
--- demos/qml-demo-shell/main.cpp 2015-09-17 11:20:00 +0000
+++ demos/qml-demo-shell/main.cpp 2016-12-16 08:22:54 +0000
@@ -15,34 +15,38 @@
15 */15 */
1616
17// Qt17// Qt
18#include <QCommandLineParser>
19#include <QtQuick/QQuickView>18#include <QtQuick/QQuickView>
20#include <QtGui/QGuiApplication>19#include <QtGui/QGuiApplication>
21#include <QtQml/QQmlEngine>20#include <QtQml/QQmlEngine>
22#include <QtQml/QQmlContext>21#include <QtQml/QQmlContext>
23#include <QLibrary>
24#include <QDebug>22#include <QDebug>
25#include <csignal>
26#include <libintl.h>23#include <libintl.h>
27#include "../paths.h"24#include "../paths.h"
2825
29#include <private/qobject_p.h>26#include "pointerposition.h"
3027
31// REMOVEME - Should be able to use qmlscene, but in order to use the mir benchmarking we need28// REMOVEME - Should be able to use qmlscene, but in order to use the mir benchmarking we need
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.
3330
34int main(int argc, const char *argv[])31int main(int argc, const char *argv[])
35{32{
33 setenv("QT_QPA_PLATFORM_PLUGIN_PATH", qPrintable(::qpaPluginDirectory()), 1 /* overwrite */);
34 setenv("QT_QPA_PLATFORM", "mirserver", 1 /* overwrite */);
35
36 QGuiApplication::setApplicationName("qml-demo-shell");36 QGuiApplication::setApplicationName("qml-demo-shell");
37 QGuiApplication *application;37 QGuiApplication *application;
3838
39 application = new QGuiApplication(argc, (char**)argv);39 application = new QGuiApplication(argc, (char**)argv);
40 QQuickView* view = new QQuickView();40 QQuickView* view = new QQuickView();
41 view->engine()->addImportPath(::qmlPluginDirectory());
41 view->setResizeMode(QQuickView::SizeRootObjectToView);42 view->setResizeMode(QQuickView::SizeRootObjectToView);
42 view->setColor("black");43 view->setColor("lightgray");
43 view->setTitle("Demo Shell");44 view->setTitle("Demo Shell");
44 45
45 QUrl source(::qmlDirectory() + "qtmir-demo-shell/qml-demo-shell.qml");46 qmlRegisterSingletonType<PointerPosition>("Mir.Pointer", 0, 1, "PointerPosition",
47 [](QQmlEngine*, QJSEngine*) -> QObject* { return PointerPosition::instance(); });
48
49 QUrl source(::qmlDirectory() + "qml-demo-shell/windowModel.qml");
4650
47 view->setSource(source);51 view->setSource(source);
48 QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));52 QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
4953
=== added file 'demos/qml-demo-shell/pointerposition.cpp'
--- demos/qml-demo-shell/pointerposition.cpp 1970-01-01 00:00:00 +0000
+++ demos/qml-demo-shell/pointerposition.cpp 2016-12-16 08:22:54 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "pointerposition.h"
18
19#include <QGuiApplication>
20#include <QMouseEvent>
21
22PointerPosition *PointerPosition::instance()
23{
24 static PointerPosition *pointerPosition = nullptr;
25 if (!pointerPosition) {
26 pointerPosition = new PointerPosition();
27 }
28 return pointerPosition;
29}
30
31bool PointerPosition::eventFilter(QObject */*object*/, QEvent *event)
32{
33 if (event->type() == QEvent::MouseMove) {
34 auto mouseEvent = static_cast<QMouseEvent*>(event);
35 if (m_x != mouseEvent->globalX()) {
36 m_x = mouseEvent->globalX();
37 Q_EMIT xChanged();
38 }
39 if (m_y != mouseEvent->globalY()) {
40 m_y = mouseEvent->globalY();
41 Q_EMIT yChanged();
42 }
43 }
44 return false;
45}
46
47PointerPosition::PointerPosition()
48 : QObject()
49{
50 qGuiApp->installEventFilter(this);
51}
52
53PointerPosition::~PointerPosition()
54{
55 qGuiApp->removeEventFilter(this);
56}
057
=== added file 'demos/qml-demo-shell/pointerposition.h'
--- demos/qml-demo-shell/pointerposition.h 1970-01-01 00:00:00 +0000
+++ demos/qml-demo-shell/pointerposition.h 2016-12-16 08:22:54 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef POINTERPOSITION_H
18#define POINTERPOSITION_H
19
20#include <QObject>
21
22class PointerPosition : public QObject
23{
24 Q_OBJECT
25 Q_PROPERTY(int x READ x NOTIFY xChanged)
26 Q_PROPERTY(int y READ y NOTIFY yChanged)
27
28public:
29 static PointerPosition *instance();
30
31 int x() const { return m_x; }
32 int y() const { return m_y; }
33
34Q_SIGNALS:
35 void xChanged();
36 void yChanged();
37
38protected:
39 bool eventFilter(QObject *object, QEvent *event);
40
41private:
42 Q_DISABLE_COPY(PointerPosition)
43 PointerPosition();
44 ~PointerPosition();
45
46 int m_x{0}, m_y{0};
47};
48
49#endif // POINTERPOSITION_H
050
=== added file 'demos/qml-demo-shell/windowModel.qml'
--- demos/qml-demo-shell/windowModel.qml 1970-01-01 00:00:00 +0000
+++ demos/qml-demo-shell/windowModel.qml 2016-12-16 08:22:54 +0000
@@ -0,0 +1,136 @@
1import QtQuick 2.4
2import Unity.Application 0.1
3import Mir.Pointer 0.1
4
5FocusScope {
6 id: root
7 focus: true
8
9 WindowModel {
10 id: windowModel;
11 }
12
13 Item {
14 id: windowViewContainer
15 anchors.fill: parent
16
17 Repeater {
18 model: windowModel
19
20 delegate: MirSurfaceItem {
21 id: surfaceItem
22 surface: model.surface
23 consumesInput: true // QUESTION: why is this non-default?
24 x: surface.position.x
25 y: surface.position.y
26 width: surface.size.width
27 height: surface.size.height
28 focus: surface.focused
29 visible: surface.visible
30
31 Rectangle {
32 anchors { top: parent.bottom; right: parent.right }
33 width: childrenRect.width
34 height: childrenRect.height
35 color: surface.focused ? "red" : "lightsteelblue"
36 opacity: 0.8
37 Text {
38 text: surface.position.x + "," + surface.position.y + " " + surface.size.width + "x" + surface.size.height
39 font.pixelSize: 10
40 }
41 }
42
43 Rectangle { anchors.fill: parent; z: -1; color: "black"; opacity: 0.3 }
44 }
45 }
46 }
47
48 Button {
49 anchors { right: parent.right; top: parent.top }
50 height: 30
51 width: 80
52 text: "Quit"
53 onClicked: Qt.quit()
54 }
55
56 WindowModelDebugView {
57 anchors { right: parent.right; bottom: parent.bottom }
58 model: windowModel
59 }
60
61 Text {
62 anchors { left: parent.left; bottom: parent.bottom }
63 text: "Move window: Ctrl+click\n
64Resize window: Ctrl+Right click"
65 }
66
67 Rectangle {
68 id: mousePointer
69 color: "black"
70 width: 6
71 height: 10
72 x: PointerPosition.x
73 y: PointerPosition.y
74 }
75
76 MouseArea {
77 anchors.fill: parent
78 acceptedButtons: Qt.LeftButton | Qt.RightButton
79 hoverEnabled: false
80 property variant window: null
81 property int initialWindowXPosition
82 property int initialWindowYPosition
83 property int initialWindowWidth
84 property int initialWindowHeight
85 property int initialMouseXPosition
86 property int initialMouseYPosition
87 property var action
88
89 function moveWindowBy(window, delta) {
90 window.surface.requestedPosition = Qt.point(initialWindowXPosition + delta.x,
91 initialWindowYPosition + delta.y);
92 }
93 function resizeWindowBy(window, delta) {
94 window.surface.resize(Qt.size(initialWindowWidth + delta.x,
95 initialWindowHeight + delta.y))
96 }
97
98 onPressed: {
99 if (mouse.modifiers & Qt.ControlModifier) {
100 window = windowViewContainer.childAt(mouse.x, mouse.y)
101 if (!window) return;
102
103 if (mouse.button == Qt.LeftButton) {
104 initialWindowXPosition = window.surface.position.x
105 initialWindowYPosition = window.surface.position.y
106 action = moveWindowBy
107 } else if (mouse.button == Qt.RightButton) {
108 initialWindowHeight = window.surface.size.height
109 initialWindowWidth = window.surface.size.width
110 action = resizeWindowBy
111 }
112 initialMouseXPosition = mouse.x
113 initialMouseYPosition = mouse.y
114 } else {
115 mouse.accepted = false
116 }
117 }
118
119 onPositionChanged: {
120 if (!window) {
121 mouse.accepted = false
122 return
123 }
124 action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition))
125 }
126
127 onReleased: {
128 if (!window) {
129 mouse.accepted = false
130 return
131 }
132 action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition))
133 window = null;
134 }
135 }
136}
0137
=== added file 'src/common/appnotifier.h'
--- src/common/appnotifier.h 1970-01-01 00:00:00 +0000
+++ src/common/appnotifier.h 2016-12-16 08:22:54 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef APPNOTIFIER_H
18#define APPNOTIFIER_H
19
20#include <QObject>
21#include <miral/application_info.h>
22
23namespace qtmir {
24
25class AppNotifier : public QObject
26{
27 Q_OBJECT
28
29Q_SIGNALS:
30 void appAdded(const miral::ApplicationInfo &app);
31 void appRemoved(const miral::ApplicationInfo &app);
32 void appCreatedWindow(const miral::ApplicationInfo &app);
33};
34
35} // namespace qtmir
36
37Q_DECLARE_METATYPE(miral::ApplicationInfo)
38
39#endif // APPNOTIFIER_H
040
=== modified file 'src/common/debughelpers.cpp'
--- src/common/debughelpers.cpp 2016-06-06 19:25:20 +0000
+++ src/common/debughelpers.cpp 2016-12-16 08:22:54 +0000
@@ -21,6 +21,7 @@
2121
22// Unity API22// Unity API
23#include <unity/shell/application/ApplicationInfoInterface.h>23#include <unity/shell/application/ApplicationInfoInterface.h>
24#include <unity/shell/application/Mir.h>
2425
25const char *touchPointStateToString(Qt::TouchPointState state)26const char *touchPointStateToString(Qt::TouchPointState state)
26{27{
@@ -114,23 +115,18 @@
114const char *mirSurfaceTypeToStr(int value)115const char *mirSurfaceTypeToStr(int value)
115{116{
116 switch (value) {117 switch (value) {
117 case mir_surface_type_normal:118 case mir_surface_type_normal: return "normal"; /**< AKA "regular" */
118 return "normal";119 case mir_surface_type_utility: return "utility"; /**< AKA "floating regular" */
119 case mir_surface_type_utility:120 case mir_surface_type_dialog: return "dialog";
120 return "utility";121 case mir_surface_type_gloss: return "gloss";
121 case mir_surface_type_dialog:122 case mir_surface_type_freestyle: return "freestyle";
122 return "dialog";123 case mir_surface_type_menu: return "menu";
123 case mir_surface_type_overlay:124 case mir_surface_type_inputmethod: return "input Method"; /**< AKA "OSK" or handwriting etc. */
124 return "overlay";125 case mir_surface_type_satellite: return "satellite"; /**< AKA "toolbox"/"toolbar" */
125 case mir_surface_type_freestyle:126 case mir_surface_type_tip: return "tip"; /**< AKA "tooltip" */
126 return "freestyle";127 case mir_surface_types: Q_UNREACHABLE();
127 case mir_surface_type_popover:
128 return "popover";
129 case mir_surface_type_inputmethod:
130 return "inputmethod";
131 default:
132 return "???";
133 }128 }
129 Q_UNREACHABLE();
134}130}
135131
136const char *mirSurfaceStateToStr(int value)132const char *mirSurfaceStateToStr(int value)
@@ -148,6 +144,8 @@
148 return "vertmaximized";144 return "vertmaximized";
149 case mir_surface_state_fullscreen:145 case mir_surface_state_fullscreen:
150 return "fullscreen";146 return "fullscreen";
147 case mir_surface_state_hidden:
148 return "hidden";
151 default:149 default:
152 return "???";150 return "???";
153 }151 }
@@ -349,3 +347,39 @@
349 return "???";347 return "???";
350 }348 }
351}349}
350
351const char *unityapiMirStateToStr(int state)
352{
353 switch (state) {
354 case Mir::UnknownState:
355 return "unknown";
356 case Mir::RestoredState:
357 return "restored";
358 case Mir::MinimizedState:
359 return "minimized";
360 case Mir::MaximizedState:
361 return "maximized";
362 case Mir::VertMaximizedState:
363 return "vertMaximized";
364 case Mir::FullscreenState:
365 return "fullscreen";
366 case Mir::HorizMaximizedState:
367 return "horizMaximized";
368 case Mir::MaximizedLeftState:
369 return "maximizedLeft";
370 case Mir::MaximizedRightState:
371 return "maximizedRight";
372 case Mir::MaximizedTopLeftState:
373 return "maximizedTopLeft";
374 case Mir::MaximizedTopRightState:
375 return "maximizedTopRight";
376 case Mir::MaximizedBottomLeftState:
377 return "maximizedBottomLeft";
378 case Mir::MaximizedBottomRightState:
379 return "maximizedBottomRight";
380 case Mir::HiddenState:
381 return "hidden";
382 default:
383 return "???";
384 }
385}
352386
=== modified file 'src/common/debughelpers.h'
--- src/common/debughelpers.h 2015-11-10 11:07:23 +0000
+++ src/common/debughelpers.h 2016-12-16 08:22:54 +0000
@@ -43,4 +43,6 @@
4343
44const char *qtCursorShapeToStr(Qt::CursorShape shape);44const char *qtCursorShapeToStr(Qt::CursorShape shape);
4545
46const char *unityapiMirStateToStr(int state);
47
46#endif // UBUNTUGESTURES_DEBUG_HELPER_H48#endif // UBUNTUGESTURES_DEBUG_HELPER_H
4749
=== added file 'src/common/mirqtconversion.h'
--- src/common/mirqtconversion.h 1970-01-01 00:00:00 +0000
+++ src/common/mirqtconversion.h 2016-12-16 08:22:54 +0000
@@ -0,0 +1,118 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MIRQTCONVERSION_H
18#define MIRQTCONVERSION_H
19
20#include <QSize>
21#include <QPoint>
22#include <QRect>
23
24#include <mir/geometry/size.h>
25#include <mir/geometry/point.h>
26#include <mir/geometry/rectangle.h>
27
28#include <mir_toolkit/common.h>
29
30#include <unity/shell/application/Mir.h>
31
32namespace qtmir {
33
34/*
35 * Some handy conversions from Mir types to Qt types and back
36 */
37
38inline QSize toQSize(const mir::geometry::Size size)
39{
40 return QSize(size.width.as_int(), size.height.as_int());
41}
42
43inline mir::geometry::Size toMirSize(const QSize size)
44{
45 namespace mg = mir::geometry;
46 return mg::Size{ mg::Width{ size.width()}, mg::Height{ size.height()} };
47}
48
49inline QPoint toQPoint(const mir::geometry::Point point)
50{
51 return QPoint(point.x.as_int(), point.y.as_int());
52}
53
54inline mir::geometry::Point toMirPoint(const QPoint point)
55{
56 namespace mg = mir::geometry;
57 return mg::Point{ mg::X{ point.x()}, mg::Y{ point.y()} };
58}
59
60inline QRect toQRect(const mir::geometry::Rectangle rect)
61{
62 return QRect(rect.top_left.x.as_int(), rect.top_left.y.as_int(),
63 rect.size.width.as_int(), rect.size.height.as_int());
64}
65
66inline mir::geometry::Rectangle toMirRectangle(const QRect rect)
67{
68 namespace mg = mir::geometry;
69 return mg::Rectangle{
70 mg::Point{ mg::X{ rect.x()}, mg::Y{ rect.y()} },
71 mg::Size{ mg::Width{ rect.width()}, mg::Height{ rect.height()} }
72 };
73}
74
75inline Mir::State toQtState(MirSurfaceState state)
76{
77 switch (state) {
78 case mir_surface_state_unknown: return Mir::UnknownState;
79 case mir_surface_state_restored: return Mir::RestoredState;
80 case mir_surface_state_minimized: return Mir::MinimizedState;
81 case mir_surface_state_maximized: return Mir::MaximizedState;
82 case mir_surface_state_vertmaximized: return Mir::VertMaximizedState;
83 case mir_surface_state_fullscreen: return Mir::FullscreenState;
84 case mir_surface_state_horizmaximized: return Mir::HorizMaximizedState;
85 case mir_surface_state_hidden: return Mir::HiddenState;
86 case mir_surface_states: Q_UNREACHABLE();
87 }
88 Q_UNREACHABLE();
89}
90
91inline MirSurfaceState toMirState(Mir::State state)
92{
93 switch (state) {
94 case Mir::UnknownState: return mir_surface_state_unknown;
95 case Mir::RestoredState: return mir_surface_state_restored;
96 case Mir::MinimizedState: return mir_surface_state_minimized;
97 case Mir::MaximizedState: return mir_surface_state_maximized;
98 case Mir::VertMaximizedState: return mir_surface_state_vertmaximized;
99 case Mir::FullscreenState: return mir_surface_state_fullscreen;
100 case Mir::HorizMaximizedState: return mir_surface_state_horizmaximized;
101
102 // FIXME: Map to the corresponding MirSurfaceState enum value once available
103 case Mir::MaximizedLeftState:
104 case Mir::MaximizedRightState:
105 case Mir::MaximizedTopLeftState:
106 case Mir::MaximizedTopRightState:
107 case Mir::MaximizedBottomLeftState:
108 case Mir::MaximizedBottomRightState:
109 return mir_surface_state_restored;
110
111 case Mir::HiddenState: return mir_surface_state_hidden;
112 default: Q_UNREACHABLE();
113 }
114}
115
116} // namespace qtmir
117
118#endif // MIRQTCONVERSION_H
0119
=== added file 'src/common/windowcontrollerinterface.h'
--- src/common/windowcontrollerinterface.h 1970-01-01 00:00:00 +0000
+++ src/common/windowcontrollerinterface.h 2016-12-16 08:22:54 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef WINDOWCONTROLLERINTERFACE_H
18#define WINDOWCONTROLLERINTERFACE_H
19
20#include <miral/window.h>
21
22#include <mir_toolkit/event.h>
23
24#include <QPoint>
25#include <QSize>
26
27// Unity API
28#include <unity/shell/application/Mir.h>
29
30namespace qtmir {
31
32class MirSurface;
33
34class WindowControllerInterface {
35public:
36 WindowControllerInterface() = default;
37 virtual ~WindowControllerInterface() = default;
38
39 // activate() asks Mir to bring particular window to the front and recommend to shell that it be focused
40 virtual void activate (const miral::Window &window) = 0;
41 virtual void raise(const miral::Window &window) = 0;
42
43 virtual void resize(const miral::Window &window, const QSize &size) = 0;
44 virtual void move (const miral::Window &window, const QPoint &topLeft) = 0;
45
46 virtual void requestClose(const miral::Window &window) = 0;
47 virtual void forceClose(const miral::Window &window) = 0;
48
49 virtual void requestState(const miral::Window &window, const Mir::State state) = 0;
50
51 virtual void deliverKeyboardEvent(const miral::Window &window, const MirKeyboardEvent *event) = 0;
52 virtual void deliverTouchEvent (const miral::Window &window, const MirTouchEvent *event) = 0;
53 virtual void deliverPointerEvent (const miral::Window &window, const MirPointerEvent *event) = 0;
54};
55
56} // namespace qtmir
57
58#endif // WINDOWCONTROLLERINTERFACE_H
059
=== added file 'src/common/windowmodelnotifier.h'
--- src/common/windowmodelnotifier.h 1970-01-01 00:00:00 +0000
+++ src/common/windowmodelnotifier.h 2016-12-16 08:22:54 +0000
@@ -0,0 +1,95 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef WINDOWMODELNOTIFIER_H
18#define WINDOWMODELNOTIFIER_H
19
20#include <QObject>
21#include <QPoint>
22#include <QSize>
23
24#include <miral/window_info.h>
25
26// Unity API
27#include <unity/shell/application/Mir.h>
28
29namespace qtmir {
30
31class NewWindow {
32public:
33 NewWindow() = default;
34 NewWindow(const miral::WindowInfo &windowInfo)
35 : windowInfo(windowInfo)
36 , surface(windowInfo.window())
37 {}
38
39 miral::WindowInfo windowInfo;
40
41 // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface
42 // but MirSurface needs to share ownership of the Surface with Mir
43 std::shared_ptr<mir::scene::Surface> surface;
44};
45
46struct ExtraWindowInfo {
47 QString persistentId;
48
49 // FIXME Use MirSurfaceState when possible.
50 Mir::State previousState{Mir::UnknownState};
51
52 // FIXME: Remove when possible. This exists just because MirSurfaceState has no equivalent
53 // for the following states:
54 // Mir::MaximizedLeftState:
55 // Mir::MaximizedRightState:
56 // Mir::MaximizedTopLeftState:
57 // Mir::MaximizedTopRightState:
58 // Mir::MaximizedBottomLeftState:
59 // Mir::MaximizedBottomRightState:
60 Mir::State state{Mir::UnknownState};
61};
62
63std::shared_ptr<ExtraWindowInfo> getExtraInfo(const miral::WindowInfo &windowInfo);
64
65class WindowModelNotifier : public QObject
66{
67 Q_OBJECT
68public:
69 WindowModelNotifier() = default;
70
71Q_SIGNALS: // **Must used Queued Connection or else events will be out of order**
72 void windowAdded(const qtmir::NewWindow &window);
73 void windowRemoved(const miral::WindowInfo &window);
74 void windowReady(const miral::WindowInfo &window);
75 void windowMoved(const miral::WindowInfo &window, const QPoint topLeft);
76 void windowResized(const miral::WindowInfo &window, const QSize size);
77 void windowStateChanged(const miral::WindowInfo &window, Mir::State state);
78 void windowFocusChanged(const miral::WindowInfo &window, bool focused);
79 void windowsRaised(const std::vector<miral::Window> &windows); // results in deep copy when passed over Queued connection:(
80 void windowRequestedRaise(const miral::WindowInfo &window);
81 void modificationsStarted();
82 void modificationsEnded();
83
84private:
85 Q_DISABLE_COPY(WindowModelNotifier)
86};
87
88} // namespace qtmir
89
90Q_DECLARE_METATYPE(qtmir::NewWindow)
91Q_DECLARE_METATYPE(miral::WindowInfo)
92Q_DECLARE_METATYPE(std::vector<miral::Window>)
93Q_DECLARE_METATYPE(MirSurfaceState)
94
95#endif // WINDOWMODELNOTIFIER_H
096
=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
--- src/modules/Unity/Application/CMakeLists.txt 2016-07-30 21:19:45 +0000
+++ src/modules/Unity/Application/CMakeLists.txt 2016-12-16 08:22:54 +0000
@@ -8,6 +8,7 @@
8 ${GLIB_INCLUDE_DIRS}8 ${GLIB_INCLUDE_DIRS}
9 ${GIO_INCLUDE_DIRS}9 ${GIO_INCLUDE_DIRS}
10 ${GIO_UNIX_INCLUDE_DIRS}10 ${GIO_UNIX_INCLUDE_DIRS}
11 ${MIRAL_INCLUDE_DIRS}
11 ${MIRSERVER_INCLUDE_DIRS}12 ${MIRSERVER_INCLUDE_DIRS}
12 ${MIRRENDERERGLDEV_INCLUDE_DIRS}13 ${MIRRENDERERGLDEV_INCLUDE_DIRS}
13 ${PROCESS_CPP_INCLUDE_DIRS}14 ${PROCESS_CPP_INCLUDE_DIRS}
@@ -35,8 +36,6 @@
35 ../../../common/debughelpers.cpp36 ../../../common/debughelpers.cpp
36 dbusfocusinfo.cpp37 dbusfocusinfo.cpp
37 plugin.cpp38 plugin.cpp
38 mirsurfacemanager.cpp
39 mirfocuscontroller.cpp
40 mirsurface.cpp39 mirsurface.cpp
41 mirsurfaceinterface.h40 mirsurfaceinterface.h
42 mirsurfaceitem.cpp41 mirsurfaceitem.cpp
@@ -46,20 +45,22 @@
46 session.cpp45 session.cpp
47 sessionmanager.cpp46 sessionmanager.cpp
48 sharedwakelock.cpp47 sharedwakelock.cpp
48 surfacemanager.cpp
49 upstart/applicationinfo.cpp49 upstart/applicationinfo.cpp
50 upstart/taskcontroller.cpp50 upstart/taskcontroller.cpp
51 timer.cpp51 timer.cpp
52 timesource.cpp52 timesource.cpp
53 tracepoints.c53 tracepoints.c
54 settings.cpp54 settings.cpp
55 windowmodel.cpp
55# We need to run moc on these headers56# We need to run moc on these headers
56 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h57 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
57 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h58 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
58 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h59 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
59 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirFocusControllerInterface.h
60 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h60 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
61 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceItemInterface.h61 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceItemInterface.h
62 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h62 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
63 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/SurfaceManagerInterface.h
63# Feed the automoc monster64# Feed the automoc monster
64 session_interface.h65 session_interface.h
65 applicationinfo.h66 applicationinfo.h
6667
=== modified file 'src/modules/Unity/Application/application.cpp'
--- src/modules/Unity/Application/application.cpp 2016-08-10 06:52:18 +0000
+++ src/modules/Unity/Application/application.cpp 2016-12-16 08:22:54 +0000
@@ -409,11 +409,7 @@
409409
410bool Application::focused() const410bool Application::focused() const
411{411{
412 bool someSurfaceHasFocus = false; // to be proven wrong412 return m_session && m_session->focused();
413 for (int i = 0; i < m_proxySurfaceList->rowCount() && !someSurfaceHasFocus; ++i) {
414 someSurfaceHasFocus |= m_proxySurfaceList->get(i)->focused();
415 }
416 return someSurfaceHasFocus;
417}413}
418414
419bool Application::fullscreen() const415bool Application::fullscreen() const
@@ -512,6 +508,10 @@
512 connect(m_session, &SessionInterface::hasClosingSurfacesChanged, this, &Application::updateState);508 connect(m_session, &SessionInterface::hasClosingSurfacesChanged, this, &Application::updateState);
513 connect(m_session, &SessionInterface::focusRequested, this, &Application::focusRequested);509 connect(m_session, &SessionInterface::focusRequested, this, &Application::focusRequested);
514 connect(m_session->surfaceList(), &MirSurfaceListModel::emptyChanged, this, &Application::updateState);510 connect(m_session->surfaceList(), &MirSurfaceListModel::emptyChanged, this, &Application::updateState);
511 connect(m_session, &SessionInterface::focusedChanged, this, [&](bool focused) {
512 qCDebug(QTMIR_APPLICATIONS).nospace() << "Application[" << appId() <<"]::focusedChanged(" << focused << ")";
513 Q_EMIT focusedChanged(focused);
514 });
515515
516 if (oldFullscreen != fullscreen())516 if (oldFullscreen != fullscreen())
517 Q_EMIT fullscreenChanged(fullscreen());517 Q_EMIT fullscreenChanged(fullscreen());
@@ -852,7 +852,8 @@
852{852{
853 if (m_proxySurfaceList->rowCount() > 0) {853 if (m_proxySurfaceList->rowCount() > 0) {
854 DEBUG_MSG << "() - Requesting focus for most recent app surface";854 DEBUG_MSG << "() - Requesting focus for most recent app surface";
855 m_proxySurfaceList->get(0)->requestFocus();855 auto surface = static_cast<MirSurfaceInterface*>(m_proxySurfaceList->get(0));
856 surface->requestFocus();
856 } else {857 } else {
857 DEBUG_MSG << "() - emitting focusRequested()";858 DEBUG_MSG << "() - emitting focusRequested()";
858 Q_EMIT focusRequested();859 Q_EMIT focusRequested();
859860
=== modified file 'src/modules/Unity/Application/application.h'
--- src/modules/Unity/Application/application.h 2016-08-10 06:52:18 +0000
+++ src/modules/Unity/Application/application.h 2016-12-16 08:22:54 +0000
@@ -31,12 +31,6 @@
31#include "mirsurfacelistmodel.h"31#include "mirsurfacelistmodel.h"
32#include "session_interface.h"32#include "session_interface.h"
3333
34namespace mir {
35 namespace scene {
36 class Session;
37 }
38}
39
40namespace qtmir34namespace qtmir
41{35{
4236
@@ -109,6 +103,7 @@
109 unity::shell::application::MirSurfaceListInterface* surfaceList() const override;103 unity::shell::application::MirSurfaceListInterface* surfaceList() const override;
110 unity::shell::application::MirSurfaceListInterface* promptSurfaceList() const override;104 unity::shell::application::MirSurfaceListInterface* promptSurfaceList() const override;
111 int surfaceCount() const override { return surfaceList()->count(); }105 int surfaceCount() const override { return surfaceList()->count(); }
106 void close() override;
112107
113 ProcessState processState() const { return m_processState; }108 ProcessState processState() const { return m_processState; }
114 void setProcessState(ProcessState value);109 void setProcessState(ProcessState value);
@@ -125,8 +120,6 @@
125120
126 pid_t pid() const;121 pid_t pid() const;
127122
128 void close();
129
130 // internal as in "not exposed in unity-api", so qtmir-internal.123 // internal as in "not exposed in unity-api", so qtmir-internal.
131 InternalState internalState() const { return m_state; }124 InternalState internalState() const { return m_state; }
132125
133126
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2016-08-26 09:08:55 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2016-12-16 08:22:54 +0000
@@ -19,7 +19,7 @@
19#include "application.h"19#include "application.h"
20#include "applicationinfo.h"20#include "applicationinfo.h"
21#include "dbusfocusinfo.h"21#include "dbusfocusinfo.h"
22#include "mirfocuscontroller.h"22#include "mirsurfaceinterface.h"
23#include "session.h"23#include "session.h"
24#include "sharedwakelock.h"24#include "sharedwakelock.h"
25#include "proc_info.h"25#include "proc_info.h"
@@ -31,12 +31,11 @@
31#include "nativeinterface.h"31#include "nativeinterface.h"
32#include "sessionauthorizer.h"32#include "sessionauthorizer.h"
33#include "logging.h"33#include "logging.h"
34#include <mirwindowmanager.h>34
35//miral
36#include <miral/application.h>
3537
36// mir38// mir
37#include <mir/scene/surface.h>
38#include <mir/graphics/display.h>
39#include <mir/graphics/display_buffer.h>
40#include <mir/geometry/rectangles.h>39#include <mir/geometry/rectangles.h>
4140
42// Qt41// Qt
@@ -82,15 +81,8 @@
8281
83void connectToTaskController(ApplicationManager *manager, TaskController *controller)82void connectToTaskController(ApplicationManager *manager, TaskController *controller)
84{83{
85 // TaskController::processStarting blocks Ubuntu-App-Launch from executing the process, have it return
86 // as fast as possible! Using a Queued connection will push an event on the event queue before the
87 // (blocking) event for authorizeSession is pushed on the same queue - so the application's processState
88 // will be up-to-date when authorizeSession is called.
89 //
90 // TODO: Unfortunately making this queued unearths a crash (likely in Qt) (LP: #1616842).
91 QObject::connect(controller, &TaskController::processStarting,84 QObject::connect(controller, &TaskController::processStarting,
92 manager, &ApplicationManager::onProcessStarting);85 manager, &ApplicationManager::onProcessStarting);
93
94 QObject::connect(controller, &TaskController::processStopped,86 QObject::connect(controller, &TaskController::processStopped,
95 manager, &ApplicationManager::onProcessStopped);87 manager, &ApplicationManager::onProcessStopped);
96 QObject::connect(controller, &TaskController::processSuspended,88 QObject::connect(controller, &TaskController::processSuspended,
@@ -115,7 +107,6 @@
115 return nullptr;107 return nullptr;
116 }108 }
117109
118 MirWindowManager *windowManager = static_cast<MirWindowManager*>(nativeInterface->nativeResourceForIntegration("WindowManager"));
119 SessionAuthorizer *sessionAuthorizer = static_cast<SessionAuthorizer*>(nativeInterface->nativeResourceForIntegration("SessionAuthorizer"));110 SessionAuthorizer *sessionAuthorizer = static_cast<SessionAuthorizer*>(nativeInterface->nativeResourceForIntegration("SessionAuthorizer"));
120111
121 QSharedPointer<TaskController> taskController(new upstart::TaskController());112 QSharedPointer<TaskController> taskController(new upstart::TaskController());
@@ -137,9 +128,10 @@
137128
138 connectToSessionAuthorizer(appManager, sessionAuthorizer);129 connectToSessionAuthorizer(appManager, sessionAuthorizer);
139 connectToTaskController(appManager, taskController.data());130 connectToTaskController(appManager, taskController.data());
140 connect(windowManager, &MirWindowManager::sessionAboutToCreateSurface,131// TODO - re-implement this functionality using the new Mir WindowManagement API
141 appManager, &ApplicationManager::onSessionAboutToCreateSurface,132// connect(windowManager, &MirWindowManager::sessionAboutToCreateSurface,
142 Qt::BlockingQueuedConnection);133// appManager, &ApplicationManager::onSessionAboutToCreateSurface,
134// Qt::BlockingQueuedConnection);
143135
144 // Emit signal to notify Upstart that Mir is ready to receive client connections136 // Emit signal to notify Upstart that Mir is ready to receive client connections
145 // see http://upstart.ubuntu.com/cookbook/#expect-stop137 // see http://upstart.ubuntu.com/cookbook/#expect-stop
@@ -179,17 +171,6 @@
179{171{
180 qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this;172 qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this;
181 setObjectName(QStringLiteral("qtmir::ApplicationManager"));173 setObjectName(QStringLiteral("qtmir::ApplicationManager"));
182
183 /*
184 All begin[...]Rows() and end[...]Rows() functions cause signal emissions which can
185 be processed by slots immediately and then trigger yet more model changes.
186
187 The connection below is queued to avoid stacked model change attempts cause by the above,
188 such as attempting to raise the newly focused application while another one is still
189 getting removed from the model.
190 */
191 connect(MirFocusController::instance(), &MirFocusController::focusedSurfaceChanged,
192 this, &ApplicationManager::updateFocusedApplication, Qt::QueuedConnection);
193}174}
194175
195ApplicationManager::~ApplicationManager()176ApplicationManager::~ApplicationManager()
@@ -273,18 +254,12 @@
273254
274QString ApplicationManager::focusedApplicationId() const255QString ApplicationManager::focusedApplicationId() const
275{256{
276 Application *focusedApplication = nullptr;257 for (const auto application : m_applications) {
277 auto surface = static_cast<qtmir::MirSurfaceInterface*>(MirFocusController::instance()->focusedSurface());258 if (application->focused()) {
278 if (surface) {259 return application->appId();
279 auto self = const_cast<ApplicationManager*>(this);260 }
280 focusedApplication = self->findApplication(surface);261 }
281 }262 return QString();
282
283 if (focusedApplication) {
284 return focusedApplication->appId();
285 } else {
286 return QString();
287 }
288}263}
289264
290/**265/**
@@ -602,16 +577,22 @@
602 authorized = true;577 authorized = true;
603}578}
604579
580
581unityapi::ApplicationInfoInterface *ApplicationManager::findApplicationWithSurface(unityapi::MirSurfaceInterface* surface) const
582{
583 if (!surface)
584 return nullptr;
585
586 auto qtmirSurface = static_cast<qtmir::MirSurfaceInterface*>(surface);
587
588 return findApplicationWithPid(miral::pid_of(qtmirSurface->session()->session()));
589}
590
605Application* ApplicationManager::findApplicationWithSession(const std::shared_ptr<ms::Session> &session)591Application* ApplicationManager::findApplicationWithSession(const std::shared_ptr<ms::Session> &session)
606{592{
607 return findApplicationWithSession(session.get());
608}
609
610Application* ApplicationManager::findApplicationWithSession(const ms::Session *session)
611{
612 if (!session)593 if (!session)
613 return nullptr;594 return nullptr;
614 return findApplicationWithPid(session->process_id());595 return findApplicationWithPid(miral::pid_of(session));
615}596}
616597
617Application* ApplicationManager::findApplicationWithPid(const pid_t pid) const598Application* ApplicationManager::findApplicationWithPid(const pid_t pid) const
@@ -640,7 +621,20 @@
640 Q_ASSERT(!m_modelUnderChange);621 Q_ASSERT(!m_modelUnderChange);
641 m_modelUnderChange = true;622 m_modelUnderChange = true;
642623
643 connect(application, &Application::focusedChanged, this, [this](bool) { onAppDataChanged(RoleFocused); });624 /*
625 All begin[...]Rows() and end[...]Rows() functions cause signal emissions which can
626 be processed by slots immediately and then trigger yet more model changes.
627
628 The connection below is queued to avoid stacked model change attempts cause by the above,
629 such as attempting to raise the newly focused application while another one is still
630 getting removed from the model.
631 */
632 // TODO: That might not be the case anymore with miral. Investigate if we can do a direct connection now
633 connect(application, &Application::focusedChanged, this, [this](bool) {
634 onAppDataChanged(RoleFocused);
635 Q_EMIT focusedApplicationIdChanged();
636 }, Qt::QueuedConnection);
637
644 connect(application, &Application::stateChanged, this, [this](Application::State) { onAppDataChanged(RoleState); });638 connect(application, &Application::stateChanged, this, [this](Application::State) { onAppDataChanged(RoleState); });
645 connect(application, &Application::closing, this, [this, application]() { onApplicationClosing(application); });639 connect(application, &Application::closing, this, [this, application]() { onApplicationClosing(application); });
646 connect(application, &unityapi::ApplicationInfoInterface::focusRequested, this, [this, application]() {640 connect(application, &unityapi::ApplicationInfoInterface::focusRequested, this, [this, application]() {
@@ -805,35 +799,6 @@
805 }799 }
806}800}
807801
808void ApplicationManager::updateFocusedApplication()
809{
810 Application *focusedApplication = nullptr;
811 Application *previouslyFocusedApplication = nullptr;
812
813 auto surface = static_cast<qtmir::MirSurfaceInterface*>(MirFocusController::instance()->focusedSurface());
814 if (surface) {
815 focusedApplication = findApplication(surface);
816 }
817
818 surface = static_cast<qtmir::MirSurfaceInterface*>(MirFocusController::instance()->previouslyFocusedSurface());
819 if (surface) {
820 previouslyFocusedApplication = findApplication(surface);
821 }
822
823 if (focusedApplication != previouslyFocusedApplication) {
824 if (focusedApplication) {
825 DEBUG_MSG << "() focused " << focusedApplication->appId();
826 Q_EMIT focusedApplication->focusedChanged(true);
827 this->move(this->m_applications.indexOf(focusedApplication), 0);
828 }
829 if (previouslyFocusedApplication) {
830 DEBUG_MSG << "() unfocused " << previouslyFocusedApplication->appId();
831 Q_EMIT previouslyFocusedApplication->focusedChanged(false);
832 }
833 Q_EMIT focusedApplicationIdChanged();
834 }
835}
836
837Application *ApplicationManager::findApplication(qtmir::MirSurfaceInterface* surface)802Application *ApplicationManager::findApplication(qtmir::MirSurfaceInterface* surface)
838{803{
839 Q_FOREACH (Application *app, m_applications) {804 Q_FOREACH (Application *app, m_applications) {
840805
=== modified file 'src/modules/Unity/Application/application_manager.h'
--- src/modules/Unity/Application/application_manager.h 2016-08-08 13:10:40 +0000
+++ src/modules/Unity/Application/application_manager.h 2016-12-16 08:22:54 +0000
@@ -24,13 +24,13 @@
24#include <QObject>24#include <QObject>
25#include <QStringList>25#include <QStringList>
2626
27// Unity API
28#include <unity/shell/application/ApplicationManagerInterface.h>
29
30// local27// local
31#include "application.h"28#include "application.h"
32#include "taskcontroller.h"29#include "taskcontroller.h"
3330
31// Unity API
32#include <unity/shell/application/ApplicationManagerInterface.h>
33
34namespace mir {34namespace mir {
35 namespace scene {35 namespace scene {
36 class Session;36 class Session;
@@ -51,7 +51,6 @@
5151
52class DBusFocusInfo;52class DBusFocusInfo;
53class DBusWindowStack;53class DBusWindowStack;
54class MirSurfaceManager;
55class ProcInfo;54class ProcInfo;
56class SharedWakelock;55class SharedWakelock;
57class SettingsInterface;56class SettingsInterface;
@@ -80,10 +79,11 @@
80 QObject *parent = 0);79 QObject *parent = 0);
81 virtual ~ApplicationManager();80 virtual ~ApplicationManager();
8281
83 // ApplicationManagerInterface82 // unity::shell::application::ApplicationManagerInterface
84 QString focusedApplicationId() const override;83 QString focusedApplicationId() const override;
85 Q_INVOKABLE qtmir::Application* get(int index) const override;84 Q_INVOKABLE qtmir::Application* get(int index) const override;
86 Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override;85 Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override;
86 unity::shell::application::ApplicationInfoInterface *findApplicationWithSurface(unity::shell::application::MirSurfaceInterface* surface) const override;
87 Q_INVOKABLE bool requestFocusApplication(const QString &appId) override;87 Q_INVOKABLE bool requestFocusApplication(const QString &appId) override;
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;
89 Q_INVOKABLE bool stopApplication(const QString &appId) override;89 Q_INVOKABLE bool stopApplication(const QString &appId) override;
@@ -117,14 +117,13 @@
117 void onSessionAboutToCreateSurface(const std::shared_ptr<mir::scene::Session> &session,117 void onSessionAboutToCreateSurface(const std::shared_ptr<mir::scene::Session> &session,
118 int type, QSize &size);118 int type, QSize &size);
119 void onApplicationClosing(Application *application);119 void onApplicationClosing(Application *application);
120 void updateFocusedApplication();
121120
122private:121private:
122 Application* findApplicationWithSession(const std::shared_ptr<mir::scene::Session> &session);
123 void setFocused(Application *application);123 void setFocused(Application *application);
124 void add(Application *application);124 void add(Application *application);
125 void remove(Application* application);125 void remove(Application* application);
126 Application* findApplicationWithSession(const std::shared_ptr<mir::scene::Session> &session);126
127 Application* findApplicationWithSession(const mir::scene::Session *session);
128 QModelIndex findIndex(Application* application);127 QModelIndex findIndex(Application* application);
129 void resumeApplication(Application *application);128 void resumeApplication(Application *application);
130 QString toString() const;129 QString toString() const;
@@ -146,7 +145,6 @@
146145
147 friend class Application;146 friend class Application;
148 friend class DBusWindowStack;147 friend class DBusWindowStack;
149 friend class MirSurfaceManager;
150 friend class SessionManager;148 friend class SessionManager;
151};149};
152150
153151
=== modified file 'src/modules/Unity/Application/dbusfocusinfo.cpp'
--- src/modules/Unity/Application/dbusfocusinfo.cpp 2016-08-30 12:32:13 +0000
+++ src/modules/Unity/Application/dbusfocusinfo.cpp 2016-12-16 08:22:54 +0000
@@ -75,29 +75,23 @@
75SessionInterface* DBusFocusInfo::findSessionWithPid(const QSet<pid_t> &pidSet)75SessionInterface* DBusFocusInfo::findSessionWithPid(const QSet<pid_t> &pidSet)
76{76{
77 Q_FOREACH (Application* application, m_applications) {77 Q_FOREACH (Application* application, m_applications) {
78 SessionInterface *sessionWithPid = findSessionWithPid(application->session(), pidSet);78 auto session = application->session();
79 if (sessionWithPid) {79 if (pidSet.contains(session->pid())) {
80 return sessionWithPid;80 return session;
81 }
82 SessionInterface *chosenChildSession = nullptr;
83 session->foreachChildSession([&](SessionInterface* childSession) {
84 if (pidSet.contains(childSession->pid())) {
85 chosenChildSession = childSession;
86 }
87 });
88 if (chosenChildSession) {
89 return chosenChildSession;
81 }90 }
82 }91 }
83 return nullptr;92 return nullptr;
84}93}
8594
86SessionInterface* DBusFocusInfo::findSessionWithPid(SessionInterface* session, const QSet<pid_t> &pidSet)
87{
88 if (pidSet.contains(session->pid())) {
89 return session;
90 }
91
92 SessionInterface *sessionWithPid = nullptr;
93 session->foreachChildSession([&](SessionInterface* childSession) {
94 if (!sessionWithPid) {
95 sessionWithPid = findSessionWithPid(childSession, pidSet);
96 }
97 });
98 return sessionWithPid;
99}
100
101bool DBusFocusInfo::isSurfaceFocused(const QString &serializedId)95bool DBusFocusInfo::isSurfaceFocused(const QString &serializedId)
102{96{
103 // TODO: Implement a penalty for negative queries, such as stalling for some time before answering97 // TODO: Implement a penalty for negative queries, such as stalling for some time before answering
10498
=== modified file 'src/modules/Unity/Application/dbusfocusinfo.h'
--- src/modules/Unity/Application/dbusfocusinfo.h 2016-08-30 12:29:32 +0000
+++ src/modules/Unity/Application/dbusfocusinfo.h 2016-12-16 08:22:54 +0000
@@ -54,7 +54,6 @@
54private:54private:
55 QSet<pid_t> fetchAssociatedPids(pid_t pid);55 QSet<pid_t> fetchAssociatedPids(pid_t pid);
56 SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet);56 SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet);
57 SessionInterface* findSessionWithPid(SessionInterface* session, const QSet<pid_t> &pidSet);
58 MirSurfaceInterface *findQmlSurface(const QString &serializedId);57 MirSurfaceInterface *findQmlSurface(const QString &serializedId);
5958
60 const QList<Application*> &m_applications;59 const QList<Application*> &m_applications;
6160
=== removed file 'src/modules/Unity/Application/mirfocuscontroller.cpp'
--- src/modules/Unity/Application/mirfocuscontroller.cpp 2016-04-05 18:58:38 +0000
+++ src/modules/Unity/Application/mirfocuscontroller.cpp 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "mirfocuscontroller.h"
18
19#include "mirsurfaceinterface.h"
20
21// mirserver
22#include <logging.h>
23
24namespace unityapp = unity::shell::application;
25using namespace qtmir;
26
27#define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirFocusController::" << __func__
28
29MirFocusController *MirFocusController::m_instance = nullptr;
30
31void MirFocusController::setFocusedSurface(unityapp::MirSurfaceInterface *unityAppSurface)
32{
33 auto surface = static_cast<qtmir::MirSurfaceInterface*>(unityAppSurface);
34
35 if (m_focusedSurface == surface) {
36 return;
37 }
38
39 DEBUG_MSG << "(" << surface << ")";
40
41 m_previouslyFocusedSurface = m_focusedSurface;
42 m_focusedSurface = surface;
43
44 if (m_previouslyFocusedSurface) {
45 m_previouslyFocusedSurface->setFocused(false);
46 }
47
48 if (m_focusedSurface) {
49 m_focusedSurface->setFocused(true);
50 m_focusedSurface->raise();
51 }
52
53 if (m_previouslyFocusedSurface != m_focusedSurface) {
54 Q_EMIT focusedSurfaceChanged();
55 }
56}
57
58unity::shell::application::MirSurfaceInterface* MirFocusController::focusedSurface() const
59{
60 return m_focusedSurface;
61}
62
63MirFocusController* MirFocusController::instance()
64{
65 if (!m_instance) {
66 m_instance = new MirFocusController;
67 }
68 return m_instance;
69}
700
=== removed file 'src/modules/Unity/Application/mirfocuscontroller.h'
--- src/modules/Unity/Application/mirfocuscontroller.h 2016-03-28 18:02:26 +0000
+++ src/modules/Unity/Application/mirfocuscontroller.h 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef QTMIR_MIRFOCUSCONTROLLER_H
18#define QTMIR_MIRFOCUSCONTROLLER_H
19
20// unity-api
21#include <unity/shell/application/MirFocusControllerInterface.h>
22
23#include <QPointer>
24
25#include "mirsurfaceinterface.h"
26
27namespace qtmir {
28
29class MirSurfaceInterface;
30
31class MirFocusController : public unity::shell::application::MirFocusControllerInterface
32{
33 Q_OBJECT
34public:
35 MirFocusController(){}
36 static MirFocusController* instance();
37
38 void setFocusedSurface(unity::shell::application::MirSurfaceInterface *surface) override;
39 unity::shell::application::MirSurfaceInterface* focusedSurface() const override;
40 MirSurfaceInterface* previouslyFocusedSurface() { return m_previouslyFocusedSurface.data(); }
41private:
42 static MirFocusController *m_instance;
43 QPointer<MirSurfaceInterface> m_previouslyFocusedSurface;
44 QPointer<MirSurfaceInterface> m_focusedSurface;
45};
46
47} // namespace qtmir
48
49#endif // QTMIR_MIRFOCUSCONTROLLER_H
500
=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
--- src/modules/Unity/Application/mirsurface.cpp 2016-10-11 20:50:50 +0000
+++ src/modules/Unity/Application/mirsurface.cpp 2016-12-16 08:22:54 +0000
@@ -16,11 +16,14 @@
1616
17#include "mirsurface.h"17#include "mirsurface.h"
18#include "mirsurfacelistmodel.h"18#include "mirsurfacelistmodel.h"
19#include "namedcursor.h"
20#include "session_interface.h"
19#include "timer.h"21#include "timer.h"
20#include "timestamp.h"22#include "timestamp.h"
2123
22// from common dir24// from common dir
23#include <debughelpers.h>25#include <debughelpers.h>
26#include "mirqtconversion.h"
2427
25// mirserver28// mirserver
26#include <eventbuilder.h>29#include <eventbuilder.h>
@@ -29,11 +32,9 @@
2932
30// Mir33// Mir
31#include <mir/geometry/rectangle.h>34#include <mir/geometry/rectangle.h>
32#include <mir/events/event_builders.h>
33#include <mir/shell/shell.h>
34#include <mir/scene/surface.h>35#include <mir/scene/surface.h>
35#include <mir/scene/session.h>36#include <mir/scene/surface_observer.h>
36#include <mir_toolkit/event.h>37#include <mir/version.h>
3738
38// mirserver39// mirserver
39#include <logging.h>40#include <logging.h>
@@ -42,60 +43,125 @@
42#include <QQmlEngine>43#include <QQmlEngine>
43#include <QScreen>44#include <QScreen>
4445
46// std
47#include <limits>
48
45using namespace qtmir;49using namespace qtmir;
4650
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__
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__
4953
50MirSurface::MirSurface(std::shared_ptr<mir::scene::Surface> surface,54namespace {
51 const QString& persistentId,55
52 SessionInterface* session,56enum class DirtyState {
53 mir::shell::Shell* shell,57 Clean = 0,
54 std::shared_ptr<SurfaceObserver> observer,58 Name = 1 << 1,
55 const CreationHints &creationHints)59 Type = 1 << 2,
60 State = 1 << 3,
61 RestoreRect = 1 << 4,
62 Children = 1 << 5,
63 MinSize = 1 << 6,
64 MaxSize = 1 << 7,
65};
66Q_DECLARE_FLAGS(DirtyStates, DirtyState)
67
68} // namespace {
69
70class MirSurface::SurfaceObserverImpl : public SurfaceObserver, public mir::scene::SurfaceObserver
71{
72public:
73 SurfaceObserverImpl();
74 virtual ~SurfaceObserverImpl();
75
76 void setListener(QObject *listener);
77
78 void attrib_changed(MirSurfaceAttrib, int) override;
79 void resized_to(mir::geometry::Size const&) override;
80 void moved_to(mir::geometry::Point const&) override {}
81 void hidden_set_to(bool) override {}
82
83 // Get new frame notifications from Mir, called from a Mir thread.
84 void frame_posted(int frames_available, mir::geometry::Size const& size ) override;
85
86 void alpha_set_to(float) override {}
87 void transformation_set_to(glm::mat4 const&) override {}
88 void reception_mode_set_to(mir::input::InputReceptionMode) override {}
89 void cursor_image_set_to(mir::graphics::CursorImage const&) override;
90 void orientation_set_to(MirOrientation) override {}
91 void client_surface_close_requested() override {}
92 void keymap_changed(MirInputDeviceId, std::string const& model, std::string const& layout,
93 std::string const& variant, std::string const& options) override;
94 void renamed(char const * name) override;
95 void cursor_image_removed() override;
96
97#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
98 void placed_relative(mir::geometry::Rectangle const& placement) override;
99#endif
100
101private:
102 QCursor createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage);
103 QObject *m_listener;
104 bool m_framesPosted;
105 QMap<QByteArray, Qt::CursorShape> m_cursorNameToShape;
106};
107
108
109MirSurface::MirSurface(NewWindow newWindowInfo,
110 WindowControllerInterface* controller,
111 SessionInterface *session)
56 : MirSurfaceInterface()112 : MirSurfaceInterface()
57 , m_surface(surface)113 , m_window{newWindowInfo.windowInfo.window()}
114 , m_extraInfo{getExtraInfo(newWindowInfo.windowInfo)}
115 , m_name{QString::fromStdString(newWindowInfo.windowInfo.name())}
116 , m_type{newWindowInfo.windowInfo.type()}
117 , m_minWidth{newWindowInfo.windowInfo.min_width().as_int()}
118 , m_minHeight{newWindowInfo.windowInfo.min_height().as_int()}
119 , m_maxWidth{newWindowInfo.windowInfo.max_width().as_int()}
120 , m_maxHeight{newWindowInfo.windowInfo.max_height().as_int()}
121 , m_incWidth{newWindowInfo.windowInfo.width_inc().as_int()}
122 , m_incHeight{newWindowInfo.windowInfo.height_inc().as_int()}
123 , m_surface(newWindowInfo.surface)
58 , m_session(session)124 , m_session(session)
59 , m_shell(shell)125 , m_controller(controller)
60 , m_persistentId(persistentId)
61 , m_firstFrameDrawn(false)
62 , m_orientationAngle(Mir::Angle0)126 , m_orientationAngle(Mir::Angle0)
63 , m_textureUpdated(false)127 , m_textureUpdated(false)
64 , m_currentFrameNumber(0)128 , m_currentFrameNumber(0)
129 , m_visible(newWindowInfo.windowInfo.is_visible())
65 , m_live(true)130 , m_live(true)
131 , m_surfaceObserver(std::make_shared<SurfaceObserverImpl>())
132 , m_position(toQPoint(m_window.top_left()))
133 , m_size(toQSize(m_window.size()))
134 , m_state(toQtState(newWindowInfo.windowInfo.state()))
66 , m_shellChrome(Mir::NormalChrome)135 , m_shellChrome(Mir::NormalChrome)
67{136{
68 DEBUG_MSG << "()";137 DEBUG_MSG << "("
69138 << "type=" << mirSurfaceTypeToStr(m_type)
70 m_minimumWidth = creationHints.minWidth;139 << ",state=" << unityapiMirStateToStr(m_state)
71 m_minimumHeight = creationHints.minHeight;140 << ")";
72 m_maximumWidth = creationHints.maxWidth;141
73 m_maximumHeight = creationHints.maxHeight;142 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());
74 m_widthIncrement = creationHints.widthIncrement;143 m_surface->add_observer(m_surfaceObserver);
75 m_heightIncrement = creationHints.heightIncrement;144
76 m_shellChrome = creationHints.shellChrome;145 //m_shellChrome = creationHints.shellChrome; TODO - where will this come from now?
77146
78 m_surfaceObserver = observer;147 connect(m_surfaceObserver.get(), &SurfaceObserver::framesPosted, this, &MirSurface::onFramesPostedObserved);
79 if (observer) {148 connect(m_surfaceObserver.get(), &SurfaceObserver::attributeChanged, this, &MirSurface::onAttributeChanged);
80 connect(observer.get(), &SurfaceObserver::framesPosted, this, &MirSurface::onFramesPostedObserved);149 connect(m_surfaceObserver.get(), &SurfaceObserver::nameChanged, this, &MirSurface::onNameChanged);
81 connect(observer.get(), &SurfaceObserver::attributeChanged, this, &MirSurface::onAttributeChanged);150 connect(m_surfaceObserver.get(), &SurfaceObserver::cursorChanged, this, &MirSurface::setCursor);
82 connect(observer.get(), &SurfaceObserver::nameChanged, this, &MirSurface::nameChanged);151 connect(m_surfaceObserver.get(), &SurfaceObserver::minimumWidthChanged, this, &MirSurface::onMinimumWidthChanged);
83 connect(observer.get(), &SurfaceObserver::cursorChanged, this, &MirSurface::setCursor);152 connect(m_surfaceObserver.get(), &SurfaceObserver::minimumHeightChanged, this, &MirSurface::onMinimumHeightChanged);
84 connect(observer.get(), &SurfaceObserver::minimumWidthChanged, this, &MirSurface::setMinimumWidth);153 connect(m_surfaceObserver.get(), &SurfaceObserver::maximumWidthChanged, this, &MirSurface::onMaximumWidthChanged);
85 connect(observer.get(), &SurfaceObserver::minimumHeightChanged, this, &MirSurface::setMinimumHeight);154 connect(m_surfaceObserver.get(), &SurfaceObserver::maximumHeightChanged, this, &MirSurface::onMaximumHeightChanged);
86 connect(observer.get(), &SurfaceObserver::maximumWidthChanged, this, &MirSurface::setMaximumWidth);155 connect(m_surfaceObserver.get(), &SurfaceObserver::widthIncrementChanged, this, &MirSurface::onWidthIncrementChanged);
87 connect(observer.get(), &SurfaceObserver::maximumHeightChanged, this, &MirSurface::setMaximumHeight);156 connect(m_surfaceObserver.get(), &SurfaceObserver::heightIncrementChanged, this, &MirSurface::onHeightIncrementChanged);
88 connect(observer.get(), &SurfaceObserver::widthIncrementChanged, this, &MirSurface::setWidthIncrement);157 connect(m_surfaceObserver.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) {
89 connect(observer.get(), &SurfaceObserver::heightIncrementChanged, this, &MirSurface::setHeightIncrement);158 setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome));
90 connect(observer.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) {159 });
91 setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome));160 connect(m_surfaceObserver.get(), &SurfaceObserver::inputBoundsChanged, this, &MirSurface::setInputBounds);
92 });161 connect(m_surfaceObserver.get(), &SurfaceObserver::confinesMousePointerChanged, this, &MirSurface::confinesMousePointerChanged);
93 connect(observer.get(), &SurfaceObserver::inputBoundsChanged, this, &MirSurface::setInputBounds);162 m_surfaceObserver->setListener(this);
94 connect(observer.get(), &SurfaceObserver::confinesMousePointerChanged, this, &MirSurface::confinesMousePointerChanged);163
95 observer->setListener(this);164 //connect(session, &QObject::destroyed, this, &MirSurface::onSessionDestroyed); // TODO try using Shared pointer for lifecycle
96 }
97
98 connect(session, &QObject::destroyed, this, &MirSurface::onSessionDestroyed);
99 connect(session, &SessionInterface::stateChanged, this, [this]() {165 connect(session, &SessionInterface::stateChanged, this, [this]() {
100 if (clientIsRunning() && m_pendingResize.isValid()) {166 if (clientIsRunning() && m_pendingResize.isValid()) {
101 resize(m_pendingResize.width(), m_pendingResize.height());167 resize(m_pendingResize.width(), m_pendingResize.height());
@@ -124,10 +190,8 @@
124190
125 setCloseTimer(new Timer);191 setCloseTimer(new Timer);
126192
127 QTimer::singleShot(m_minimumAgeForOcclusion, this, [this]() {193 m_requestedPosition.rx() = std::numeric_limits<int>::min();
128 m_oldEnoughToBeOccluded = true;194 m_requestedPosition.ry() = std::numeric_limits<int>::min();
129 updateVisibility();
130 });
131}195}
132196
133MirSurface::~MirSurface()197MirSurface::~MirSurface()
@@ -146,11 +210,6 @@
146210
147void MirSurface::onFramesPostedObserved()211void MirSurface::onFramesPostedObserved()
148{212{
149 if (!m_firstFrameDrawn) {
150 m_firstFrameDrawn = true;
151 Q_EMIT firstFrameDrawn();
152 }
153
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.
155 m_frameDropperTimer.start();214 m_frameDropperTimer.start();
156215
@@ -164,14 +223,6 @@
164 DEBUG_MSG << " type = " << mirSurfaceTypeToStr(state());223 DEBUG_MSG << " type = " << mirSurfaceTypeToStr(state());
165 Q_EMIT typeChanged(type());224 Q_EMIT typeChanged(type());
166 break;225 break;
167 case mir_surface_attrib_state:
168 DEBUG_MSG << " state = " << mirSurfaceStateToStr(state());
169 Q_EMIT stateChanged(state());
170 break;
171 case mir_surface_attrib_visibility:
172 DEBUG_MSG << " visible = " << visible();
173 Q_EMIT visibleChanged(visible());
174 break;
175 default:226 default:
176 break;227 break;
177 }228 }
@@ -179,7 +230,7 @@
179230
180Mir::Type MirSurface::type() const231Mir::Type MirSurface::type() const
181{232{
182 switch (m_surface->type()) {233 switch (m_type) {
183 case mir_surface_type_normal:234 case mir_surface_type_normal:
184 return Mir::NormalType;235 return Mir::NormalType;
185236
@@ -218,7 +269,7 @@
218269
219 const void* const userId = (void*)123; // TODO: Multimonitor support270 const void* const userId = (void*)123; // TODO: Multimonitor support
220271
221 int framesPending = m_surface->buffers_ready_for_compositor(userId);272 const int framesPending = m_surface->buffers_ready_for_compositor(userId);
222 if (framesPending > 0) {273 if (framesPending > 0) {
223 m_textureUpdated = false;274 m_textureUpdated = false;
224275
@@ -290,7 +341,7 @@
290 texture->setBuffer(renderables[0]->buffer());341 texture->setBuffer(renderables[0]->buffer());
291 ++m_currentFrameNumber;342 ++m_currentFrameNumber;
292343
293 if (texture->textureSize() != m_size) {344 if (texture->textureSize() != size()) {
294 m_size = texture->textureSize();345 m_size = texture->textureSize();
295 QMetaObject::invokeMethod(this, "emitSizeChanged", Qt::QueuedConnection);346 QMetaObject::invokeMethod(this, "emitSizeChanged", Qt::QueuedConnection);
296 }347 }
@@ -325,6 +376,8 @@
325 if (m_focused == value)376 if (m_focused == value)
326 return;377 return;
327378
379 DEBUG_MSG << "(" << value << ")";
380
328 m_focused = value;381 m_focused = value;
329 Q_EMIT focusedChanged(value);382 Q_EMIT focusedChanged(value);
330}383}
@@ -358,17 +411,30 @@
358 return;411 return;
359 }412 }
360413
414 // TODO Figure out what to do here
415 /*
361 if (m_activelyFocusedViews.isEmpty()) {416 if (m_activelyFocusedViews.isEmpty()) {
362 DEBUG_MSG << "() unfocused";417 DEBUG_MSG << "() unfocused";
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);
364 } else {419 } else {
365 DEBUG_MSG << "() focused";420 DEBUG_MSG << "() focused";
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);
367 }422 }
423 */
368424
369 m_neverSetSurfaceFocus = false;425 m_neverSetSurfaceFocus = false;
370}426}
371427
428void MirSurface::updateVisible()
429{
430 const bool visible = !(m_state == Mir::HiddenState || m_state == Mir::MinimizedState) && m_surface->visible();
431
432 if (m_visible != visible) {
433 m_visible = visible;
434 Q_EMIT visibleChanged(visible);
435 }
436}
437
372void MirSurface::close()438void MirSurface::close()
373{439{
374 if (m_closingState != NotClosing) {440 if (m_closingState != NotClosing) {
@@ -381,8 +447,8 @@
381 Q_EMIT closeRequested();447 Q_EMIT closeRequested();
382 m_closeTimer->start();448 m_closeTimer->start();
383449
384 if (m_surface) {450 if (m_window) {
385 m_surface->request_client_surface_close();451 m_controller->requestClose(m_window);
386 }452 }
387}453}
388454
@@ -393,19 +459,28 @@
393 return;459 return;
394 }460 }
395461
396 int mirWidth = m_surface->size().width.as_int();462 bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height();
397 int mirHeight = m_surface->size().height.as_int();
398
399 bool mirSizeIsDifferent = width != mirWidth || height != mirHeight;
400463
401 if (mirSizeIsDifferent) {464 if (mirSizeIsDifferent) {
402 mir::geometry::Size newMirSize(width, height);465 m_controller->resize(m_window, QSize(width, height));
403 m_surface->resize(newMirSize);466 DEBUG_MSG << " old (" << m_size.width() << "," << m_size.height() << ")"
404 DEBUG_MSG << " old (" << mirWidth << "," << mirHeight << ")"
405 << ", new (" << width << "," << height << ")";467 << ", new (" << width << "," << height << ")";
406 }468 }
407}469}
408470
471QPoint MirSurface::position() const
472{
473 return m_position;
474}
475
476void MirSurface::setPosition(const QPoint newPosition)
477{
478 if (m_position != newPosition) {
479 m_position = newPosition;
480 Q_EMIT positionChanged(newPosition);
481 }
482}
483
409QSize MirSurface::size() const484QSize MirSurface::size() const
410{485{
411 return m_size;486 return m_size;
@@ -413,26 +488,7 @@
413488
414Mir::State MirSurface::state() const489Mir::State MirSurface::state() const
415{490{
416 switch (m_surface->state()) {491 return m_state;
417 case mir_surface_state_unknown:
418 return Mir::UnknownState;
419 case mir_surface_state_restored:
420 return Mir::RestoredState;
421 case mir_surface_state_minimized:
422 return Mir::MinimizedState;
423 case mir_surface_state_maximized:
424 return Mir::MaximizedState;
425 case mir_surface_state_vertmaximized:
426 return Mir::VertMaximizedState;
427 case mir_surface_state_fullscreen:
428 return Mir::FullscreenState;
429 case mir_surface_state_horizmaximized:
430 return Mir::HorizMaximizedState;
431 case mir_surface_state_hidden:
432 return Mir::HiddenState;
433 default:
434 return Mir::UnknownState;
435 }
436}492}
437493
438Mir::OrientationAngle MirSurface::orientationAngle() const494Mir::OrientationAngle MirSurface::orientationAngle() const
@@ -477,54 +533,18 @@
477533
478QString MirSurface::name() const534QString MirSurface::name() const
479{535{
480 return QString::fromStdString(m_surface->name());536 return m_name;
481}537}
482538
483QString MirSurface::persistentId() const539QString MirSurface::persistentId() const
484{540{
485 return m_persistentId;541 return m_extraInfo->persistentId;
486}542}
487543
488void MirSurface::setState(Mir::State qmlState)544void MirSurface::requestState(Mir::State state)
489{545{
490 int mirState;546 DEBUG_MSG << "(" << unityapiMirStateToStr(state) << ")";
491547 m_controller->requestState(m_window, state);
492 switch (qmlState) {
493 default:
494 case Mir::UnknownState:
495 mirState = mir_surface_state_unknown;
496 break;
497
498 case Mir::RestoredState:
499 mirState = mir_surface_state_restored;
500 break;
501
502 case Mir::MinimizedState:
503 mirState = mir_surface_state_minimized;
504 break;
505
506 case Mir::MaximizedState:
507 mirState = mir_surface_state_maximized;
508 break;
509
510 case Mir::VertMaximizedState:
511 mirState = mir_surface_state_vertmaximized;
512 break;
513
514 case Mir::FullscreenState:
515 mirState = mir_surface_state_fullscreen;
516 break;
517
518 case Mir::HorizMaximizedState:
519 mirState = mir_surface_state_horizmaximized;
520 break;
521
522 case Mir::HiddenState:
523 mirState = mir_surface_state_hidden;
524 break;
525 }
526
527 m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_state, mirState);
528}548}
529549
530void MirSurface::setLive(bool value)550void MirSurface::setLive(bool value)
@@ -546,69 +566,78 @@
546566
547bool MirSurface::visible() const567bool MirSurface::visible() const
548{568{
549 return m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed;569 return m_visible;
550}570}
551571#include <mir_toolkit/event.h>
552void MirSurface::mousePressEvent(QMouseEvent *event)572void MirSurface::mousePressEvent(QMouseEvent *event)
553{573{
554 auto ev = EventBuilder::instance()->reconstructMirEvent(event);574 auto ev = EventBuilder::instance()->reconstructMirEvent(event);
555 m_surface->consume(ev.get());575 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
576 m_controller->deliverPointerEvent(m_window, ev1);
556 event->accept();577 event->accept();
557}578}
558579
559void MirSurface::mouseMoveEvent(QMouseEvent *event)580void MirSurface::mouseMoveEvent(QMouseEvent *event)
560{581{
561 auto ev = EventBuilder::instance()->reconstructMirEvent(event);582 auto ev = EventBuilder::instance()->reconstructMirEvent(event);
562 m_surface->consume(ev.get());583 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
584 m_controller->deliverPointerEvent(m_window, ev1);
563 event->accept();585 event->accept();
564}586}
565587
566void MirSurface::mouseReleaseEvent(QMouseEvent *event)588void MirSurface::mouseReleaseEvent(QMouseEvent *event)
567{589{
568 auto ev = EventBuilder::instance()->reconstructMirEvent(event);590 auto ev = EventBuilder::instance()->reconstructMirEvent(event);
569 m_surface->consume(ev.get());591 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
592 m_controller->deliverPointerEvent(m_window, ev1);
570 event->accept();593 event->accept();
571}594}
572595
573void MirSurface::hoverEnterEvent(QHoverEvent *event)596void MirSurface::hoverEnterEvent(QHoverEvent *event)
574{597{
575 auto ev = EventBuilder::instance()->reconstructMirEvent(event);598 auto ev = EventBuilder::instance()->reconstructMirEvent(event);
576 m_surface->consume(ev.get());599 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
600 m_controller->deliverPointerEvent(m_window, ev1);
577 event->accept();601 event->accept();
578}602}
579603
580void MirSurface::hoverLeaveEvent(QHoverEvent *event)604void MirSurface::hoverLeaveEvent(QHoverEvent *event)
581{605{
582 auto ev = EventBuilder::instance()->reconstructMirEvent(event);606 auto ev = EventBuilder::instance()->reconstructMirEvent(event);
583 m_surface->consume(ev.get());607 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
608 m_controller->deliverPointerEvent(m_window, ev1);
584 event->accept();609 event->accept();
585}610}
586611
587void MirSurface::hoverMoveEvent(QHoverEvent *event)612void MirSurface::hoverMoveEvent(QHoverEvent *event)
588{613{
589 auto ev = EventBuilder::instance()->reconstructMirEvent(event);614 auto ev = EventBuilder::instance()->reconstructMirEvent(event);
590 m_surface->consume(ev.get());615 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
616 m_controller->deliverPointerEvent(m_window, ev1);
591 event->accept();617 event->accept();
592}618}
593619
594void MirSurface::wheelEvent(QWheelEvent *event)620void MirSurface::wheelEvent(QWheelEvent *event)
595{621{
596 auto ev = EventBuilder::instance()->makeMirEvent(event);622 auto ev = EventBuilder::instance()->makeMirEvent(event);
597 m_surface->consume(ev.get());623 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
624 m_controller->deliverPointerEvent(m_window, ev1);
598 event->accept();625 event->accept();
599}626}
600627
601void MirSurface::keyPressEvent(QKeyEvent *qtEvent)628void MirSurface::keyPressEvent(QKeyEvent *qtEvent)
602{629{
603 auto ev = EventBuilder::instance()->makeMirEvent(qtEvent);630 auto ev = EventBuilder::instance()->makeMirEvent(qtEvent);
604 m_surface->consume(ev.get());631 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());
632 m_controller->deliverKeyboardEvent(m_window, ev1);
605 qtEvent->accept();633 qtEvent->accept();
606}634}
607635
608void MirSurface::keyReleaseEvent(QKeyEvent *qtEvent)636void MirSurface::keyReleaseEvent(QKeyEvent *qtEvent)
609{637{
610 auto ev = EventBuilder::instance()->makeMirEvent(qtEvent);638 auto ev = EventBuilder::instance()->makeMirEvent(qtEvent);
611 m_surface->consume(ev.get());639 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());
640 m_controller->deliverKeyboardEvent(m_window, ev1);
612 qtEvent->accept();641 qtEvent->accept();
613}642}
614643
@@ -618,15 +647,16 @@
618 ulong timestamp)647 ulong timestamp)
619{648{
620 auto ev = EventBuilder::instance()->makeMirEvent(mods, touchPoints, touchPointStates, timestamp);649 auto ev = EventBuilder::instance()->makeMirEvent(mods, touchPoints, touchPointStates, timestamp);
621 m_surface->consume(ev.get());650 auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get());
651 m_controller->deliverTouchEvent(m_window, ev1);
622}652}
623653
624bool MirSurface::clientIsRunning() const654bool MirSurface::clientIsRunning() const
625{655{
626 return (m_session &&656 return (m_session &&
627 (m_session->state() == Session::State::Running657 (m_session->state() == SessionInterface::State::Running
628 || m_session->state() == Session::State::Starting658 || m_session->state() == SessionInterface::State::Starting
629 || m_session->state() == Session::State::Suspending))659 || m_session->state() == SessionInterface::State::Suspending))
630 || !m_session;660 || !m_session;
631}661}
632662
@@ -654,39 +684,40 @@
654 deleteLater();684 deleteLater();
655 }685 }
656 }686 }
657 updateVisibility();687 updateExposure();
658 setViewActiveFocus(viewId, false);688 setViewActiveFocus(viewId, false);
659}689}
660690
661void MirSurface::setViewVisibility(qintptr viewId, bool visible)691void MirSurface::setViewExposure(qintptr viewId, bool exposed)
662{692{
663 if (!m_views.contains(viewId)) return;693 if (!m_views.contains(viewId)) return;
664694
665 m_views[viewId].visible = visible;695 m_views[viewId].exposed = exposed;
666 updateVisibility();696 updateExposure();
667}697}
668698
669void MirSurface::updateVisibility()699void MirSurface::updateExposure()
670{700{
671 bool newVisible = false;701 // Only update exposure after client has swapped a frame (aka surface is "ready"). MirAL only considers
672702 // a surface visible after it has drawn something
673 if (m_oldEnoughToBeOccluded) {703 if (!m_ready) {
674 QHashIterator<qintptr, View> i(m_views);704 return;
675 while (i.hasNext()) {705 }
676 i.next();706
677 newVisible |= i.value().visible;707 bool newExposed = false;
678 }708 QHashIterator<qintptr, View> i(m_views);
679 } else {709 while (i.hasNext()) {
680 // Surface is too young to get occluded. Let it remain exposed for a bit to ensure that it displays710 i.next();
681 // a properly formed UI on start up.711 newExposed |= i.value().exposed;
682 newVisible = true;712 }
683 }713
684714 const bool oldExposed = (m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed);
685 if (newVisible != visible()) {715
686 DEBUG_MSG << "(" << newVisible << ")";716 if (newExposed != oldExposed) {
717 DEBUG_MSG << "(" << newExposed << ")";
687718
688 m_surface->configure(mir_surface_attrib_visibility,719 m_surface->configure(mir_surface_attrib_visibility,
689 newVisible ? mir_surface_visibility_exposed : mir_surface_visibility_occluded);720 newExposed ? mir_surface_visibility_exposed : mir_surface_visibility_occluded);
690 }721 }
691}722}
692723
@@ -777,15 +808,6 @@
777 }808 }
778}809}
779810
780void MirSurface::setScreen(QScreen *screen)
781{
782 using namespace mir::geometry;
783 // in Mir, this means moving the surface in Mir's scene to the matching display
784 auto targetScreenTopLeftPx = screen->geometry().topLeft(); // * screen->devicePixelRatio(); GERRY?
785 DEBUG_MSG << "moved to" << targetScreenTopLeftPx << "px";
786 m_surface->move_to(Point{ X{targetScreenTopLeftPx.x()}, Y{targetScreenTopLeftPx.y()} });
787}
788
789bool MirSurface::inputAreaContains(const QPoint &point) const811bool MirSurface::inputAreaContains(const QPoint &point) const
790{812{
791 bool result;813 bool result;
@@ -804,6 +826,30 @@
804 return result;826 return result;
805}827}
806828
829void MirSurface::updateState(Mir::State newState)
830{
831 if (newState == m_state) {
832 return;
833 }
834 DEBUG_MSG << "(" << unityapiMirStateToStr(newState) << ")";
835
836 m_state = newState;
837 Q_EMIT stateChanged(state());
838
839 // Mir determines visibility from the state, it may have changed
840 updateVisible();
841}
842
843void MirSurface::setReady()
844{
845 if (!m_ready) {
846 DEBUG_MSG << "()";
847 m_ready = true;
848 Q_EMIT ready();
849 updateExposure();
850 }
851}
852
807void MirSurface::setCursor(const QCursor &cursor)853void MirSurface::setCursor(const QCursor &cursor)
808{854{
809 DEBUG_MSG << "(" << qtCursorShapeToStr(cursor.shape()) << ")";855 DEBUG_MSG << "(" << qtCursorShapeToStr(cursor.shape()) << ")";
@@ -814,80 +860,32 @@
814860
815int MirSurface::minimumWidth() const861int MirSurface::minimumWidth() const
816{862{
817 return m_minimumWidth;863 return m_minWidth;
818}864}
819865
820int MirSurface::minimumHeight() const866int MirSurface::minimumHeight() const
821{867{
822 return m_minimumHeight;868 return m_minHeight;
823}869}
824870
825int MirSurface::maximumWidth() const871int MirSurface::maximumWidth() const
826{872{
827 return m_maximumWidth;873 return m_maxWidth;
828}874}
829875
830int MirSurface::maximumHeight() const876int MirSurface::maximumHeight() const
831{877{
832 return m_maximumHeight;878 return m_maxHeight;
833}879}
834880
835int MirSurface::widthIncrement() const881int MirSurface::widthIncrement() const
836{882{
837 return m_widthIncrement;883 return m_incWidth;
838}884}
839885
840int MirSurface::heightIncrement() const886int MirSurface::heightIncrement() const
841{887{
842 return m_heightIncrement;888 return m_incHeight;
843}
844
845void MirSurface::setMinimumWidth(int value)
846{
847 if (value != m_minimumWidth) {
848 m_minimumWidth = value;
849 Q_EMIT minimumWidthChanged(value);
850 }
851}
852
853void MirSurface::setMinimumHeight(int value)
854{
855 if (value != m_minimumHeight) {
856 m_minimumHeight = value;
857 Q_EMIT minimumHeightChanged(value);
858 }
859}
860
861void MirSurface::setMaximumWidth(int value)
862{
863 if (value != m_maximumWidth) {
864 m_maximumWidth = value;
865 Q_EMIT maximumWidthChanged(value);
866 }
867}
868
869void MirSurface::setMaximumHeight(int value)
870{
871 if (value != m_maximumHeight) {
872 m_maximumHeight = value;
873 Q_EMIT maximumHeightChanged(value);
874 }
875}
876
877void MirSurface::setWidthIncrement(int value)
878{
879 if (value != m_widthIncrement) {
880 m_widthIncrement = value;
881 Q_EMIT widthIncrementChanged(value);
882 }
883}
884
885void MirSurface::setHeightIncrement(int value)
886{
887 if (value != m_heightIncrement) {
888 m_heightIncrement = value;
889 Q_EMIT heightIncrementChanged(value);
890 }
891}889}
892890
893bool MirSurface::focused() const891bool MirSurface::focused() const
@@ -905,16 +903,12 @@
905 return m_surface->confine_pointer_state() == mir_pointer_confined_to_surface;903 return m_surface->confine_pointer_state() == mir_pointer_confined_to_surface;
906}904}
907905
908void MirSurface::requestFocus()906void MirSurface::activate()
909{907{
910 DEBUG_MSG << "()";908 DEBUG_MSG << "()";
911 Q_EMIT focusRequested();909 if (m_live) {
912}910 m_controller->activate(m_window);
913911 }
914void MirSurface::raise()
915{
916 DEBUG_MSG << "()";
917 Q_EMIT raiseRequested();
918}912}
919913
920void MirSurface::onCloseTimedOut()914void MirSurface::onCloseTimedOut()
@@ -925,7 +919,9 @@
925919
926 m_closingState = CloseOverdue;920 m_closingState = CloseOverdue;
927921
928 m_session->session()->destroy_surface(m_surface);922 if (m_live) {
923 m_controller->forceClose(m_window);
924 }
929}925}
930926
931void MirSurface::setCloseTimer(AbstractTimer *timer)927void MirSurface::setCloseTimer(AbstractTimer *timer)
@@ -947,6 +943,11 @@
947 }943 }
948}944}
949945
946std::shared_ptr<SurfaceObserver> MirSurface::surfaceObserver() const
947{
948 return m_surfaceObserver;
949}
950
950void MirSurface::setInputBounds(const QRect &rect)951void MirSurface::setInputBounds(const QRect &rect)
951{952{
952 if (m_inputBounds != rect) {953 if (m_inputBounds != rect) {
@@ -955,3 +956,230 @@
955 Q_EMIT inputBoundsChanged(m_inputBounds);956 Q_EMIT inputBoundsChanged(m_inputBounds);
956 }957 }
957}958}
959
960QPoint MirSurface::requestedPosition() const
961{
962 return m_requestedPosition;
963}
964
965void MirSurface::setRequestedPosition(const QPoint &point)
966{
967 if (point != m_requestedPosition) {
968 m_requestedPosition = point;
969 Q_EMIT requestedPositionChanged(m_requestedPosition);
970
971 if (m_live) {
972 m_controller->move(m_window, m_requestedPosition);
973 }
974 }
975}
976
977void MirSurface::onMinimumWidthChanged(int minWidth)
978{
979 if (m_minWidth != minWidth)
980 {
981 m_minWidth = minWidth;
982 Q_EMIT minimumWidthChanged(minWidth);
983 }
984}
985
986void MirSurface::onMinimumHeightChanged(int minHeight)
987{
988 if (m_minHeight != minHeight)
989 {
990 m_minHeight = minHeight;
991 Q_EMIT minimumHeightChanged(minHeight);
992 }
993}
994
995void MirSurface::onMaximumWidthChanged(int maxWidth)
996{
997 if (m_maxWidth != maxWidth)
998 {
999 m_maxWidth = maxWidth;
1000 Q_EMIT maximumWidthChanged(maxWidth);
1001 }
1002}
1003
1004void MirSurface::onMaximumHeightChanged(int maxHeight)
1005{
1006 if (m_maxHeight != maxHeight)
1007 {
1008 m_maxHeight = maxHeight;
1009 Q_EMIT maximumHeightChanged(maxHeight);
1010 }
1011}
1012
1013void MirSurface::onWidthIncrementChanged(int incWidth)
1014{
1015 if (m_incWidth != incWidth)
1016 {
1017 m_incWidth = incWidth;
1018 Q_EMIT widthIncrementChanged(incWidth);
1019 }
1020}
1021
1022void MirSurface::onHeightIncrementChanged(int incHeight)
1023{
1024 if (m_incHeight != incHeight)
1025 {
1026 m_incHeight = incHeight;
1027 Q_EMIT heightIncrementChanged(incHeight);
1028 }
1029}
1030
1031void MirSurface::onNameChanged(const QString &name)
1032{
1033 if (m_name != name)
1034 {
1035 m_name = name;
1036 Q_EMIT nameChanged(name);
1037 }
1038}
1039
1040MirSurface::SurfaceObserverImpl::SurfaceObserverImpl()
1041 : m_listener(nullptr)
1042 , m_framesPosted(false)
1043{
1044 m_cursorNameToShape["left_ptr"] = Qt::ArrowCursor;
1045 m_cursorNameToShape["up_arrow"] = Qt::UpArrowCursor;
1046 m_cursorNameToShape["cross"] = Qt::CrossCursor;
1047 m_cursorNameToShape["watch"] = Qt::WaitCursor;
1048 m_cursorNameToShape["xterm"] = Qt::IBeamCursor;
1049 m_cursorNameToShape["size_ver"] = Qt::SizeVerCursor;
1050 m_cursorNameToShape["size_hor"] = Qt::SizeHorCursor;
1051 m_cursorNameToShape["size_bdiag"] = Qt::SizeBDiagCursor;
1052 m_cursorNameToShape["size_fdiag"] = Qt::SizeFDiagCursor;
1053 m_cursorNameToShape["size_all"] = Qt::SizeAllCursor;
1054 m_cursorNameToShape["blank"] = Qt::BlankCursor;
1055 m_cursorNameToShape["split_v"] = Qt::SplitVCursor;
1056 m_cursorNameToShape["split_h"] = Qt::SplitHCursor;
1057 m_cursorNameToShape["hand"] = Qt::PointingHandCursor;
1058 m_cursorNameToShape["forbidden"] = Qt::ForbiddenCursor;
1059 m_cursorNameToShape["whats_this"] = Qt::WhatsThisCursor;
1060 m_cursorNameToShape["left_ptr_watch"] = Qt::BusyCursor;
1061 m_cursorNameToShape["openhand"] = Qt::OpenHandCursor;
1062 m_cursorNameToShape["closedhand"] = Qt::ClosedHandCursor;
1063 m_cursorNameToShape["dnd-copy"] = Qt::DragCopyCursor;
1064 m_cursorNameToShape["dnd-move"] = Qt::DragMoveCursor;
1065 m_cursorNameToShape["dnd-link"] = Qt::DragLinkCursor;
1066
1067 // Used by Mir client API (mir_*_cursor_name strings)
1068 m_cursorNameToShape["default"] = Qt::ArrowCursor;
1069 m_cursorNameToShape["disabled"] = Qt::BlankCursor;
1070 m_cursorNameToShape["arrow"] = Qt::ArrowCursor;
1071 m_cursorNameToShape["busy"] = Qt::WaitCursor;
1072 m_cursorNameToShape["caret"] = Qt::IBeamCursor;
1073 m_cursorNameToShape["pointing-hand"] = Qt::PointingHandCursor;
1074 m_cursorNameToShape["open-hand"] = Qt::OpenHandCursor;
1075 m_cursorNameToShape["closed-hand"] = Qt::ClosedHandCursor;
1076 m_cursorNameToShape["horizontal-resize"] = Qt::SizeHorCursor;
1077 m_cursorNameToShape["vertical-resize"] = Qt::SizeVerCursor;
1078 m_cursorNameToShape["diagonal-resize-bottom-to-top"] = Qt::SizeBDiagCursor;
1079 m_cursorNameToShape["diagonal-resize-top_to_bottom"] = Qt::SizeFDiagCursor; // current string with typo
1080 m_cursorNameToShape["diagonal-resize-top-to-bottom"] = Qt::SizeFDiagCursor; // how it will be when they fix it (if ever)
1081 m_cursorNameToShape["omnidirectional-resize"] = Qt::SizeAllCursor;
1082 m_cursorNameToShape["vsplit-resize"] = Qt::SplitVCursor;
1083 m_cursorNameToShape["hsplit-resize"] = Qt::SplitHCursor;
1084 m_cursorNameToShape["crosshair"] = Qt::CrossCursor;
1085
1086 qRegisterMetaType<MirShellChrome>("MirShellChrome");
1087}
1088
1089MirSurface::SurfaceObserverImpl::~SurfaceObserverImpl()
1090{
1091}
1092
1093void MirSurface::SurfaceObserverImpl::setListener(QObject *listener)
1094{
1095 m_listener = listener;
1096 if (m_framesPosted) {
1097 Q_EMIT framesPosted();
1098 }
1099}
1100
1101void MirSurface::SurfaceObserverImpl::frame_posted(int /*frames_available*/, mir::geometry::Size const& /*size*/)
1102{
1103 m_framesPosted = true;
1104 if (m_listener) {
1105 Q_EMIT framesPosted();
1106 }
1107}
1108
1109void MirSurface::SurfaceObserverImpl::renamed(char const * name)
1110{
1111 Q_EMIT nameChanged(QString::fromUtf8(name));
1112}
1113
1114void MirSurface::SurfaceObserverImpl::cursor_image_removed()
1115{
1116 Q_EMIT cursorChanged(QCursor());
1117}
1118
1119#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
1120void MirSurface::SurfaceObserverImpl::placed_relative(mir::geometry::Rectangle const& /*placement*/)
1121{
1122}
1123#endif
1124
1125void MirSurface::SurfaceObserverImpl::attrib_changed(MirSurfaceAttrib attribute, int value)
1126{
1127 if (m_listener) {
1128 Q_EMIT attributeChanged(attribute, value);
1129 }
1130}
1131
1132void MirSurface::SurfaceObserverImpl::resized_to(mir::geometry::Size const&size)
1133{
1134 Q_EMIT resized(QSize(size.width.as_int(), size.height.as_int()));
1135}
1136
1137void MirSurface::SurfaceObserverImpl::cursor_image_set_to(const mir::graphics::CursorImage &cursorImage)
1138{
1139 QCursor qcursor = createQCursorFromMirCursorImage(cursorImage);
1140 Q_EMIT cursorChanged(qcursor);
1141}
1142
1143void MirSurface::SurfaceObserverImpl::keymap_changed(MirInputDeviceId, const std::string &, const std::string &layout,
1144 const std::string &variant, const std::string &)
1145{
1146 Q_EMIT keymapChanged(QString::fromStdString(layout), QString::fromStdString(variant));
1147}
1148
1149QCursor MirSurface::SurfaceObserverImpl::createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage) {
1150 if (cursorImage.as_argb_8888() == nullptr) {
1151 // Must be a named cursor
1152 auto namedCursor = dynamic_cast<const qtmir::NamedCursor*>(&cursorImage);
1153 Q_ASSERT(namedCursor != nullptr);
1154 if (namedCursor) {
1155 // NB: If we need a named cursor not covered by Qt::CursorShape, we won't be able to
1156 // used Qt's cursor API anymore for transmitting MirSurface's cursor image.
1157
1158 Qt::CursorShape cursorShape = Qt::ArrowCursor;
1159 {
1160 auto iterator = m_cursorNameToShape.constFind(namedCursor->name());
1161 if (iterator == m_cursorNameToShape.constEnd()) {
1162 qCWarning(QTMIR_SURFACES).nospace() << "SurfaceObserver: unrecognized cursor name "
1163 << namedCursor->name();
1164 } else {
1165 cursorShape = iterator.value();
1166 }
1167 }
1168 return QCursor(cursorShape);
1169 } else {
1170 // shouldn't happen
1171 return QCursor();
1172 }
1173 } else {
1174 QImage image((const uchar*)cursorImage.as_argb_8888(),
1175 cursorImage.size().width.as_int(), cursorImage.size().height.as_int(), QImage::Format_ARGB32);
1176
1177 return QCursor(QPixmap::fromImage(image), cursorImage.hotspot().dx.as_int(), cursorImage.hotspot().dy.as_int());
1178 }
1179}
1180
1181void MirSurface::requestFocus()
1182{
1183 DEBUG_MSG << "()";
1184 Q_EMIT focusRequested();
1185}
9581186
=== modified file 'src/modules/Unity/Application/mirsurface.h'
--- src/modules/Unity/Application/mirsurface.h 2016-10-11 20:50:50 +0000
+++ src/modules/Unity/Application/mirsurface.h 2016-12-16 08:22:54 +0000
@@ -22,45 +22,37 @@
2222
23// Qt23// Qt
24#include <QCursor>24#include <QCursor>
25#include <QElapsedTimer>
26#include <QMutex>25#include <QMutex>
27#include <QPointer>26#include <QPointer>
28#include <QRect>27#include <QRect>
29#include <QSharedPointer>28#include <QSharedPointer>
30#include <QWeakPointer>29#include <QWeakPointer>
31#include <QSet>30#include <QSet>
31#include <QTimer>
3232
33#include "mirbuffersgtexture.h"33#include "mirbuffersgtexture.h"
34#include "session.h"34#include "windowcontrollerinterface.h"
3535#include "windowmodelnotifier.h"
36// mirserver
37#include "creationhints.h"
3836
39// mir37// mir
40#include <mir_toolkit/common.h>38#include <mir_toolkit/common.h>
4139
42namespace mir {
43namespace shell { class Shell; }
44namespace scene {class Surface; }
45}
4640
47class SurfaceObserver;41class SurfaceObserver;
4842
49namespace qtmir {43namespace qtmir {
5044
51class AbstractTimer;45class AbstractTimer;
46class SessionInterface;
5247
53class MirSurface : public MirSurfaceInterface48class MirSurface : public MirSurfaceInterface
54{49{
55 Q_OBJECT50 Q_OBJECT
5651
57public:52public:
58 MirSurface(std::shared_ptr<mir::scene::Surface> surface,53 MirSurface(NewWindow windowInfo,
59 const QString& persistentId,54 WindowControllerInterface *controller,
60 SessionInterface* session,55 SessionInterface *session = nullptr);
61 mir::shell::Shell *shell,
62 std::shared_ptr<SurfaceObserver> observer,
63 const CreationHints &);
64 virtual ~MirSurface();56 virtual ~MirSurface();
6557
66 ////58 ////
@@ -74,10 +66,14 @@
7466
75 QSize size() const override;67 QSize size() const override;
76 void resize(int width, int height) override;68 void resize(int width, int height) override;
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()); }
70
71 QPoint position() const override;
72
73 QPoint requestedPosition() const override;
74 void setRequestedPosition(const QPoint &) override;
7875
79 Mir::State state() const override;76 Mir::State state() const override;
80 void setState(Mir::State qmlState) override;
8177
82 bool live() const override;78 bool live() const override;
8379
@@ -98,16 +94,15 @@
9894
99 bool confinesMousePointer() const override;95 bool confinesMousePointer() const override;
10096
101 Q_INVOKABLE void requestFocus() override;97 Q_INVOKABLE void activate() override;
102 Q_INVOKABLE void close() override;98 Q_INVOKABLE void close() override;
103 Q_INVOKABLE void raise() override;
10499
105 ////100 ////
106 // qtmir::MirSurfaceInterface101 // qtmir::MirSurfaceInterface
107102
108 void setLive(bool value) override;103 void setLive(bool value) override;
109104
110 bool isFirstFrameDrawn() const override { return m_firstFrameDrawn; }105 bool isReady() const override { return m_ready; }
111106
112 void stopFrameDropper() override;107 void stopFrameDropper() override;
113 void startFrameDropper() override;108 void startFrameDropper() override;
@@ -116,7 +111,7 @@
116111
117 void registerView(qintptr viewId) override;112 void registerView(qintptr viewId) override;
118 void unregisterView(qintptr viewId) override;113 void unregisterView(qintptr viewId) override;
119 void setViewVisibility(qintptr viewId, bool visible) override;114 void setViewExposure(qintptr viewId, bool exposed) override;
120115
121 // methods called from the rendering (scene graph) thread:116 // methods called from the rendering (scene graph) thread:
122 QSharedPointer<QSGTexture> texture() override;117 QSharedPointer<QSGTexture> texture() override;
@@ -156,27 +151,31 @@
156151
157 Mir::ShellChrome shellChrome() const override;152 Mir::ShellChrome shellChrome() const override;
158153
159 void setScreen(QScreen *screen) override;
160
161 SessionInterface* session() override { return m_session.data(); }154 SessionInterface* session() override { return m_session.data(); }
162155
163 bool inputAreaContains(const QPoint &) const override;156 bool inputAreaContains(const QPoint &) const override;
164157
158 void requestFocus() override;
159
165 ////160 ////
166 // Own API161 // Own API
162 void setPosition(const QPoint newPosition);
163 void updateState(Mir::State state);
164 void setReady();
165 miral::Window window() const { return m_window; }
167166
168 // useful for tests167 // useful for tests
169 void setCloseTimer(AbstractTimer *timer);168 void setCloseTimer(AbstractTimer *timer);
169 std::shared_ptr<SurfaceObserver> surfaceObserver() const;
170170
171public Q_SLOTS:171public Q_SLOTS:
172 ////
173 // unity::shell::application::MirSurfaceInterface
174 void requestState(Mir::State qmlState) override;
175
176 ////
177 // qtmir::MirSurfaceInterface
172 void onCompositorSwappedBuffers() override;178 void onCompositorSwappedBuffers() override;
173
174 void setMinimumWidth(int) override;
175 void setMinimumHeight(int) override;
176 void setMaximumWidth(int) override;
177 void setMaximumHeight(int) override;
178 void setWidthIncrement(int) override;
179 void setHeightIncrement(int) override;
180 void setShellChrome(Mir::ShellChrome shellChrome) override;179 void setShellChrome(Mir::ShellChrome shellChrome) override;
181180
182private Q_SLOTS:181private Q_SLOTS:
@@ -192,15 +191,32 @@
192private:191private:
193 void syncSurfaceSizeWithItemSize();192 void syncSurfaceSizeWithItemSize();
194 bool clientIsRunning() const;193 bool clientIsRunning() const;
195 void updateVisibility();194 void updateExposure();
196 void applyKeymap();195 void applyKeymap();
197 void updateActiveFocus();196 void updateActiveFocus();
198197 void updateVisible();
199 std::shared_ptr<mir::scene::Surface> m_surface;198 void onNameChanged(const QString &name);
199 void onMinimumWidthChanged(int minWidth);
200 void onMinimumHeightChanged(int minHeight);
201 void onMaximumWidthChanged(int maxWidth);
202 void onMaximumHeightChanged(int maxHeight);
203 void onWidthIncrementChanged(int incWidth);
204 void onHeightIncrementChanged(int incHeight);
205
206 const miral::Window m_window;
207 const std::shared_ptr<ExtraWindowInfo> m_extraInfo;
208 QString m_name;
209 MirSurfaceType m_type;
210 int m_minWidth;
211 int m_minHeight;
212 int m_maxWidth;
213 int m_maxHeight;
214 int m_incWidth;
215 int m_incHeight;
216
217 const std::shared_ptr<mir::scene::Surface> m_surface; // keep copy of the Surface for lifecycle
200 QPointer<SessionInterface> m_session;218 QPointer<SessionInterface> m_session;
201 mir::shell::Shell *const m_shell;219 WindowControllerInterface *const m_controller;
202 QString m_persistentId;
203 bool m_firstFrameDrawn;
204220
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)
206 Mir::OrientationAngle m_orientationAngle;222 Mir::OrientationAngle m_orientationAngle;
@@ -214,31 +230,30 @@
214 bool m_textureUpdated;230 bool m_textureUpdated;
215 unsigned int m_currentFrameNumber;231 unsigned int m_currentFrameNumber;
216232
233 bool m_ready{false};
234 bool m_visible;
217 bool m_live;235 bool m_live;
218 struct View {236 struct View {
219 bool visible;237 bool exposed;
220 };238 };
221 QHash<qintptr, View> m_views;239 QHash<qintptr, View> m_views;
222240
223 QSet<qintptr> m_activelyFocusedViews;241 QSet<qintptr> m_activelyFocusedViews;
224 bool m_neverSetSurfaceFocus{true};242 bool m_neverSetSurfaceFocus{true};
225243
226 std::shared_ptr<SurfaceObserver> m_surfaceObserver;244 class SurfaceObserverImpl;
245 std::shared_ptr<SurfaceObserverImpl> m_surfaceObserver;
227246
247 QPoint m_position;
248 QPoint m_requestedPosition;
228 QSize m_size;249 QSize m_size;
250 QSize m_pendingResize;
229 QString m_keymap;251 QString m_keymap;
230252
231 QCursor m_cursor;253 QCursor m_cursor;
254 Mir::State m_state; // FIXME: remove when Mir gains additional window states to match Mir::State
232 Mir::ShellChrome m_shellChrome;255 Mir::ShellChrome m_shellChrome;
233256
234 int m_minimumWidth{0};
235 int m_minimumHeight{0};
236 int m_maximumWidth{0};
237 int m_maximumHeight{0};
238 int m_widthIncrement{0};
239 int m_heightIncrement{0};
240 QSize m_pendingResize;
241
242 QRect m_inputBounds;257 QRect m_inputBounds;
243258
244 bool m_focused{false};259 bool m_focused{false};
@@ -250,11 +265,6 @@
250 };265 };
251 ClosingState m_closingState{NotClosing};266 ClosingState m_closingState{NotClosing};
252 AbstractTimer *m_closeTimer{nullptr};267 AbstractTimer *m_closeTimer{nullptr};
253
254 // TODO: Make it configurable, exposing it as a QML property to shell.
255 // In milliseconds.
256 const int m_minimumAgeForOcclusion{10000};
257 bool m_oldEnoughToBeOccluded{false};
258};268};
259269
260} // namespace qtmir270} // namespace qtmir
261271
=== modified file 'src/modules/Unity/Application/mirsurfaceinterface.h'
--- src/modules/Unity/Application/mirsurfaceinterface.h 2016-07-05 12:41:04 +0000
+++ src/modules/Unity/Application/mirsurfaceinterface.h 2016-12-16 08:22:54 +0000
@@ -24,6 +24,7 @@
2424
25// Qt25// Qt
26#include <QCursor>26#include <QCursor>
27#include <QPoint>
27#include <QSharedPointer>28#include <QSharedPointer>
28#include <QTouchEvent>29#include <QTouchEvent>
2930
@@ -44,7 +45,7 @@
4445
45 virtual void setLive(bool value) = 0;46 virtual void setLive(bool value) = 0;
4647
47 virtual bool isFirstFrameDrawn() const = 0;48 virtual bool isReady() const = 0;
4849
49 virtual void stopFrameDropper() = 0;50 virtual void stopFrameDropper() = 0;
50 virtual void startFrameDropper() = 0;51 virtual void startFrameDropper() = 0;
@@ -53,7 +54,7 @@
5354
54 virtual void registerView(qintptr viewId) = 0;55 virtual void registerView(qintptr viewId) = 0;
55 virtual void unregisterView(qintptr viewId) = 0;56 virtual void unregisterView(qintptr viewId) = 0;
56 virtual void setViewVisibility(qintptr viewId, bool visible) = 0;57 virtual void setViewExposure(qintptr viewId, bool exposed) = 0;
5758
58 // methods called from the rendering (scene graph) thread:59 // methods called from the rendering (scene graph) thread:
59 virtual QSharedPointer<QSGTexture> texture() = 0;60 virtual QSharedPointer<QSGTexture> texture() = 0;
@@ -102,28 +103,21 @@
102103
103 virtual QCursor cursor() const = 0;104 virtual QCursor cursor() const = 0;
104105
105 virtual void setScreen(QScreen *screen) = 0;
106
107 virtual SessionInterface* session() = 0;106 virtual SessionInterface* session() = 0;
108107
109 virtual bool inputAreaContains(const QPoint &) const = 0;108 virtual bool inputAreaContains(const QPoint &) const = 0;
110109
110 virtual void requestFocus() = 0;
111
111public Q_SLOTS:112public Q_SLOTS:
112 virtual void onCompositorSwappedBuffers() = 0;113 virtual void onCompositorSwappedBuffers() = 0;
113114
114 virtual void setMinimumWidth(int) = 0;
115 virtual void setMinimumHeight(int) = 0;
116 virtual void setMaximumWidth(int) = 0;
117 virtual void setMaximumHeight(int) = 0;
118 virtual void setWidthIncrement(int) = 0;
119 virtual void setHeightIncrement(int) = 0;
120 virtual void setShellChrome(Mir::ShellChrome shellChrome) = 0;115 virtual void setShellChrome(Mir::ShellChrome shellChrome) = 0;
121116
122Q_SIGNALS:117Q_SIGNALS:
118 void ready();
123 void cursorChanged(const QCursor &cursor);119 void cursorChanged(const QCursor &cursor);
124 void raiseRequested();120 void raiseRequested();
125 void closeRequested();
126 void firstFrameDrawn();
127 void framesPosted();121 void framesPosted();
128 void isBeingDisplayedChanged();122 void isBeingDisplayedChanged();
129 void frameDropped();123 void frameDropped();
130124
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
--- src/modules/Unity/Application/mirsurfaceitem.cpp 2016-07-15 15:38:04 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2016-12-16 08:22:54 +0000
@@ -18,7 +18,6 @@
18#include "application.h"18#include "application.h"
19#include "session.h"19#include "session.h"
20#include "mirsurfaceitem.h"20#include "mirsurfaceitem.h"
21#include "mirfocuscontroller.h"
22#include "logging.h"21#include "logging.h"
23#include "tracepoints.h" // generated from tracepoints.tp22#include "tracepoints.h" // generated from tracepoints.tp
24#include "timestamp.h"23#include "timestamp.h"
@@ -104,18 +103,10 @@
104 connect(&m_updateMirSurfaceSizeTimer, &QTimer::timeout, this, &MirSurfaceItem::updateMirSurfaceSize);103 connect(&m_updateMirSurfaceSizeTimer, &QTimer::timeout, this, &MirSurfaceItem::updateMirSurfaceSize);
105104
106 connect(this, &QQuickItem::activeFocusChanged, this, &MirSurfaceItem::updateMirSurfaceActiveFocus);105 connect(this, &QQuickItem::activeFocusChanged, this, &MirSurfaceItem::updateMirSurfaceActiveFocus);
107 connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceVisibility);106 connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceExposure);
108 connect(this, &QQuickItem::windowChanged, this, &MirSurfaceItem::onWindowChanged);107 connect(this, &QQuickItem::windowChanged, this, &MirSurfaceItem::onWindowChanged);
109}108}
110109
111void MirSurfaceItem::componentComplete()
112{
113 QQuickItem::componentComplete();
114 if (window()) {
115 updateScreen(window()->screen());
116 }
117}
118
119MirSurfaceItem::~MirSurfaceItem()110MirSurfaceItem::~MirSurfaceItem()
120{111{
121 qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::~MirSurfaceItem - this=" << this;112 qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::~MirSurfaceItem - this=" << this;
@@ -492,13 +483,6 @@
492 }483 }
493}484}
494485
495void MirSurfaceItem::setSurfaceState(Mir::State state)
496{
497 if (m_surface) {
498 m_surface->setState(state);
499 }
500}
501
502void MirSurfaceItem::scheduleMirSurfaceSizeUpdate()486void MirSurfaceItem::scheduleMirSurfaceSizeUpdate()
503{487{
504 if (!m_updateMirSurfaceSizeTimer.isActive()) {488 if (!m_updateMirSurfaceSizeTimer.isActive()) {
@@ -519,13 +503,13 @@
519 m_surface->resize(width, height);503 m_surface->resize(width, height);
520}504}
521505
522void MirSurfaceItem::updateMirSurfaceVisibility()506void MirSurfaceItem::updateMirSurfaceExposure()
523{507{
524 if (!m_surface || !m_surface->live()) {508 if (!m_surface || !m_surface->live()) {
525 return;509 return;
526 }510 }
527511
528 m_surface->setViewVisibility((qintptr)this, isVisible());512 m_surface->setViewExposure((qintptr)this, isVisible());
529}513}
530514
531void MirSurfaceItem::updateMirSurfaceActiveFocus()515void MirSurfaceItem::updateMirSurfaceActiveFocus()
@@ -628,10 +612,7 @@
628612
629 updateMirSurfaceSize();613 updateMirSurfaceSize();
630 setImplicitSize(m_surface->size().width(), m_surface->size().height());614 setImplicitSize(m_surface->size().width(), m_surface->size().height());
631 updateMirSurfaceVisibility();615 updateMirSurfaceExposure();
632 if (window()) {
633 updateScreen(window()->screen());
634 }
635616
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.
637 if (m_surface->cursor().shape() != Qt::ArrowCursor) {618 if (m_surface->cursor().shape() != Qt::ArrowCursor) {
@@ -672,16 +653,6 @@
672 if (m_window) {653 if (m_window) {
673 connect(m_window, &QQuickWindow::frameSwapped, this, &MirSurfaceItem::onCompositorSwappedBuffers,654 connect(m_window, &QQuickWindow::frameSwapped, this, &MirSurfaceItem::onCompositorSwappedBuffers,
674 Qt::DirectConnection);655 Qt::DirectConnection);
675
676 updateScreen(m_window->screen());
677 connect(m_window, &QQuickWindow::screenChanged, this, &MirSurfaceItem::updateScreen);
678 }
679}
680
681void MirSurfaceItem::updateScreen(QScreen *screen)
682{
683 if (screen && m_surface) {
684 m_surface->setScreen(screen);
685 }656 }
686}657}
687658
688659
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
--- src/modules/Unity/Application/mirsurfaceitem.h 2016-07-15 15:38:04 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.h 2016-12-16 08:22:54 +0000
@@ -31,7 +31,6 @@
3131
32namespace qtmir {32namespace qtmir {
3333
34class MirSurfaceManager;
35class QSGMirSurfaceNode;34class QSGMirSurfaceNode;
36class MirTextureProvider;35class MirTextureProvider;
3736
@@ -52,7 +51,6 @@
52 Mir::ShellChrome shellChrome() const override;51 Mir::ShellChrome shellChrome() const override;
5352
54 Mir::State surfaceState() const override;53 Mir::State surfaceState() const override;
55 void setSurfaceState(Mir::State) override;
5654
57 Mir::OrientationAngle orientationAngle() const override;55 Mir::OrientationAngle orientationAngle() const override;
58 void setOrientationAngle(Mir::OrientationAngle angle) override;56 void setOrientationAngle(Mir::OrientationAngle angle) override;
@@ -109,7 +107,6 @@
109107
110 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;108 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
111109
112 void componentComplete() override;
113 void releaseResources() override;110 void releaseResources() override;
114111
115private Q_SLOTS:112private Q_SLOTS:
@@ -117,13 +114,12 @@
117 void updateMirSurfaceSize();114 void updateMirSurfaceSize();
118115
119 void updateMirSurfaceActiveFocus();116 void updateMirSurfaceActiveFocus();
120 void updateMirSurfaceVisibility();117 void updateMirSurfaceExposure();
121118
122 void onActualSurfaceSizeChanged(QSize size);119 void onActualSurfaceSizeChanged(QSize size);
123 void onCompositorSwappedBuffers();120 void onCompositorSwappedBuffers();
124121
125 void onWindowChanged(QQuickWindow *window);122 void onWindowChanged(QQuickWindow *window);
126 void updateScreen(QScreen *screen);
127123
128private:124private:
129 void ensureTextureProvider();125 void ensureTextureProvider();
130126
=== modified file 'src/modules/Unity/Application/mirsurfacelistmodel.cpp'
--- src/modules/Unity/Application/mirsurfacelistmodel.cpp 2016-07-15 15:38:04 +0000
+++ src/modules/Unity/Application/mirsurfacelistmodel.cpp 2016-12-16 08:22:54 +0000
@@ -77,7 +77,11 @@
7777
78void MirSurfaceListModel::connectSurface(MirSurfaceInterface *surface)78void MirSurfaceListModel::connectSurface(MirSurfaceInterface *surface)
79{79{
80 connect(surface, &MirSurfaceInterface::raiseRequested, this, [this, surface](){ this->raise(surface); });80 connect(surface, &MirSurfaceInterface::focusedChanged, this, [this, surface](bool focused){
81 if (focused) {
82 this->raise(surface);
83 }
84 });
81 connect(surface, &QObject::destroyed, this, [this, surface](){ this->removeSurface(surface); });85 connect(surface, &QObject::destroyed, this, [this, surface](){ this->removeSurface(surface); });
82}86}
8387
@@ -143,10 +147,12 @@
143 for (int i = prependLast; i >= prependFirst; --i) {147 for (int i = prependLast; i >= prependFirst; --i) {
144 auto surface = surfaceList[i];148 auto surface = surfaceList[i];
145 m_surfaceList.prepend(surface);149 m_surfaceList.prepend(surface);
146 connect(surface, &MirSurfaceInterface::raiseRequested, this,150 connect(surface, &MirSurfaceInterface::focusedChanged, this,
147 [this, surface]()151 [this, surface](bool focused)
148 {152 {
149 this->raise(surface);153 if (focused) {
154 this->raise(surface);
155 }
150 });156 });
151 }157 }
152 endInsertRows();158 endInsertRows();
153159
=== removed file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
--- src/modules/Unity/Application/mirsurfacemanager.cpp 2016-08-30 12:24:51 +0000
+++ src/modules/Unity/Application/mirsurfacemanager.cpp 1970-01-01 00:00:00 +0000
@@ -1,188 +0,0 @@
1/*
2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "mirsurfacemanager.h"
18
19// Qt
20#include <QGuiApplication>
21#include <QMutexLocker>
22
23// local
24#include "mirsurface.h"
25#include "sessionmanager.h"
26#include "application_manager.h"
27#include "tracepoints.h" // generated from tracepoints.tp
28
29// common
30#include <debughelpers.h>
31
32// QPA mirserver
33#include "nativeinterface.h"
34#include "sessionlistener.h"
35#include "logging.h"
36#include "creationhints.h"
37#include "mirserver.h"
38
39// mir
40#include <mir/scene/surface.h>
41#include <mir/shell/persistent_surface_store.h>
42
43
44namespace ms = mir::scene;
45namespace msh = mir::shell;
46
47namespace qtmir {
48
49MirSurfaceManager *MirSurfaceManager::instance = nullptr;
50
51
52void connectToSessionListener(MirSurfaceManager *manager, SessionListener *listener)
53{
54 QObject::connect(listener, &SessionListener::sessionCreatedSurface,
55 manager, &MirSurfaceManager::onSessionCreatedSurface);
56 QObject::connect(listener, &SessionListener::sessionDestroyingSurface,
57 manager, &MirSurfaceManager::onSessionDestroyingSurface);
58}
59
60MirSurfaceManager* MirSurfaceManager::singleton()
61{
62 if (!instance) {
63
64 NativeInterface *nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface());
65
66 if (!nativeInterface) {
67 qCritical("ERROR: Unity.Application QML plugin requires use of the 'mirserver' QPA plugin");
68 QGuiApplication::quit();
69 return nullptr;
70 }
71
72 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));
73 mir::shell::Shell *shell = static_cast<mir::shell::Shell*>(nativeInterface->nativeResourceForIntegration("Shell"));
74
75
76 instance = new MirSurfaceManager(shell,
77 SessionManager::singleton(),
78 nativeInterface->thePersistentSurfaceStore());
79
80 connectToSessionListener(instance, sessionListener);
81 }
82 return instance;
83}
84
85MirSurfaceManager::MirSurfaceManager(
86 mir::shell::Shell* shell,
87 SessionManager* sessionManager,
88 std::shared_ptr<msh::PersistentSurfaceStore> surfaceStore,
89 QObject* parent)
90 : QObject(parent)
91 , m_shell(shell)
92 , m_sessionManager(sessionManager)
93 , m_surfaceStore(surfaceStore)
94{
95 qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::MirSurfaceManager - this=" << this;
96 setObjectName(QStringLiteral("qtmir::SurfaceManager"));
97}
98
99MirSurfaceManager::~MirSurfaceManager()
100{
101 qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::~MirSurfaceManager - this=" << this;
102
103 m_mirSurfaceToQmlSurfaceHash.clear();
104}
105
106void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *mirSession,
107 const std::shared_ptr<mir::scene::Surface> &surface,
108 const std::shared_ptr<SurfaceObserver> &observer,
109 const qtmir::CreationHints &creationHints)
110{
111 qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionCreatedSurface - mirSession=" << mirSession
112 << "surface=" << surface.get() << "surface.name=" << surface->name().c_str()
113 << "creationHints=" << creationHints.toString();
114
115 SessionInterface* session = m_sessionManager->findSession(mirSession);
116 auto qmlSurface = new MirSurface(surface,
117 QString::fromStdString(m_surfaceStore->id_for_surface(surface).serialize_to_string()),
118 session,
119 m_shell,
120 observer,
121 creationHints);
122 {
123 QMutexLocker lock(&m_mutex);
124 m_mirSurfaceToQmlSurfaceHash.insert(surface.get(), qmlSurface);
125 }
126
127 if (session)
128 session->registerSurface(qmlSurface);
129
130 if (qmlSurface->type() == Mir::InputMethodType) {
131 m_inputMethodSurface = qmlSurface;
132 Q_EMIT inputMethodSurfaceChanged();
133 }
134
135 // Only notify QML of surface creation once it has drawn its first frame.
136 connect(qmlSurface, &MirSurfaceInterface::firstFrameDrawn, this, [=]() {
137 tracepoint(qtmir, firstFrameDrawn);
138 Q_EMIT surfaceCreated(qmlSurface);
139 });
140
141 // clean up after MirSurface is destroyed
142 connect(qmlSurface, &QObject::destroyed, this, [&](QObject *obj) {
143 auto qmlSurface = static_cast<MirSurfaceInterface*>(obj);
144 {
145 QMutexLocker lock(&m_mutex);
146 m_mirSurfaceToQmlSurfaceHash.remove(m_mirSurfaceToQmlSurfaceHash.key(qmlSurface));
147 }
148
149 tracepoint(qtmir, surfaceDestroyed);
150 });
151 tracepoint(qtmir, surfaceCreated);
152}
153
154void MirSurfaceManager::onSessionDestroyingSurface(const mir::scene::Session *session,
155 const std::shared_ptr<mir::scene::Surface> &surface)
156{
157 qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSessionDestroyingSurface - session=" << session
158 << "surface=" << surface.get() << "surface.name=" << surface->name().c_str();
159
160 MirSurfaceInterface* qmlSurface = nullptr;
161 {
162 QMutexLocker lock(&m_mutex);
163 auto it = m_mirSurfaceToQmlSurfaceHash.find(surface.get());
164 if (it != m_mirSurfaceToQmlSurfaceHash.end()) {
165 qmlSurface = it.value();
166 m_mirSurfaceToQmlSurfaceHash.erase(it);
167 } else {
168 qCritical() << "MirSurfaceManager::onSessionDestroyingSurface: unable to find MirSurface corresponding"
169 << "to surface=" << surface.get() << "surface.name=" << surface->name().c_str();
170 return;
171 }
172 }
173
174 if (qmlSurface->type() == Mir::InputMethodType) {
175 m_inputMethodSurface = nullptr;
176 Q_EMIT inputMethodSurfaceChanged();
177 }
178
179 qmlSurface->setLive(false);
180 Q_EMIT surfaceDestroyed(qmlSurface);
181}
182
183MirSurfaceInterface* MirSurfaceManager::inputMethodSurface() const
184{
185 return m_inputMethodSurface;
186}
187
188} // namespace qtmir
1890
=== removed file 'src/modules/Unity/Application/mirsurfacemanager.h'
--- src/modules/Unity/Application/mirsurfacemanager.h 2016-08-30 12:24:19 +0000
+++ src/modules/Unity/Application/mirsurfacemanager.h 1970-01-01 00:00:00 +0000
@@ -1,99 +0,0 @@
1/*
2 * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MIR_SURFACE_MANAGER_H
18#define MIR_SURFACE_MANAGER_H
19
20// std
21#include <memory>
22
23// Qt
24#include <QObject>
25#include <QHash>
26#include <QMutex>
27#include <QSharedPointer>
28
29// Mir
30#include <mir_toolkit/common.h>
31
32// mirserver qpa
33#include <creationhints.h>
34
35namespace mir {
36 namespace scene {
37 class Surface;
38 class Session;
39 class PromptSession;
40 }
41 namespace shell {
42 class Shell;
43 class PersistentSurfaceStore;
44 }
45}
46
47class SurfaceObserver;
48
49namespace qtmir {
50
51class Application;
52class ApplicationManager;
53class MirSurfaceInterface;
54class SessionManager;
55
56class MirSurfaceManager : public QObject
57{
58 Q_OBJECT
59 Q_PROPERTY(MirSurfaceInterface* inputMethodSurface READ inputMethodSurface NOTIFY inputMethodSurfaceChanged)
60public:
61 explicit MirSurfaceManager(
62 mir::shell::Shell* shell,
63 SessionManager* sessionManager,
64 std::shared_ptr<mir::shell::PersistentSurfaceStore> surfaceStore,
65 QObject* parent = nullptr
66 );
67 ~MirSurfaceManager();
68
69 static MirSurfaceManager* singleton();
70
71 MirSurfaceInterface* inputMethodSurface() const;
72
73Q_SIGNALS:
74 void inputMethodSurfaceChanged();
75 void surfaceCreated(MirSurfaceInterface* surface);
76 void surfaceDestroyed(MirSurfaceInterface* surface);
77
78public Q_SLOTS:
79 void onSessionCreatedSurface(const mir::scene::Session *,
80 const std::shared_ptr<mir::scene::Surface> &,
81 std::shared_ptr<SurfaceObserver> const&,
82 const qtmir::CreationHints &);
83 void onSessionDestroyingSurface(const mir::scene::Session *, const std::shared_ptr<mir::scene::Surface> &);
84
85protected:
86 QHash<const mir::scene::Surface *, MirSurfaceInterface *> m_mirSurfaceToQmlSurfaceHash;
87 QMutex m_mutex;
88
89private:
90 mir::shell::Shell *const m_shell;
91 SessionManager* m_sessionManager;
92 std::shared_ptr<mir::shell::PersistentSurfaceStore> m_surfaceStore;
93 static MirSurfaceManager *instance;
94 MirSurfaceInterface* m_inputMethodSurface = nullptr;
95};
96
97} // namespace qtmir
98
99#endif // MIR_SURFACE_MANAGER_H
1000
=== modified file 'src/modules/Unity/Application/plugin.cpp'
--- src/modules/Unity/Application/plugin.cpp 2016-07-15 15:38:04 +0000
+++ src/modules/Unity/Application/plugin.cpp 2016-12-16 08:22:54 +0000
@@ -20,11 +20,11 @@
20// local20// local
21#include "application.h"21#include "application.h"
22#include "application_manager.h"22#include "application_manager.h"
23#include "mirfocuscontroller.h"
24#include "mirsurfacemanager.h"
25#include "mirsurfaceinterface.h"23#include "mirsurfaceinterface.h"
26#include "mirsurfaceitem.h"24#include "mirsurfaceitem.h"
27#include "mirsurfacelistmodel.h"25#include "mirsurfacelistmodel.h"
26#include "windowmodel.h"
27#include "surfacemanager.h"
2828
29// platforms/mirserver29// platforms/mirserver
30#include <mirsingleton.h>30#include <mirsingleton.h>
@@ -46,22 +46,9 @@
46 return qtmir::ApplicationManager::singleton();46 return qtmir::ApplicationManager::singleton();
47}47}
4848
49QObject* surfaceManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
50 Q_UNUSED(engine);
51 Q_UNUSED(scriptEngine);
52 qCDebug(QTMIR_APPLICATIONS) << "surfaceManagerSingleton - engine=" << engine << "scriptEngine=" << scriptEngine;
53
54 return qtmir::MirSurfaceManager::singleton();
55}
56
57QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) {49QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) {
58 return qtmir::Mir::instance();50 return qtmir::Mir::instance();
59}51}
60
61QObject* mirFocusControllerSingleton(QQmlEngine*, QJSEngine*)
62{
63 return MirFocusController::instance();
64}
65} // anonymous namespace52} // anonymous namespace
6653
67class UnityApplicationPlugin : public QQmlExtensionPlugin {54class UnityApplicationPlugin : public QQmlExtensionPlugin {
@@ -77,6 +64,7 @@
77 qRegisterMetaType<qtmir::Application*>("Application*");64 qRegisterMetaType<qtmir::Application*>("Application*");
78 qRegisterMetaType<unity::shell::application::MirSurfaceInterface*>("MirSurfaceInterface*");65 qRegisterMetaType<unity::shell::application::MirSurfaceInterface*>("MirSurfaceInterface*");
79 qRegisterMetaType<unity::shell::application::MirSurfaceListInterface*>("unity::shell::application::MirSurfaceListInterface*");66 qRegisterMetaType<unity::shell::application::MirSurfaceListInterface*>("unity::shell::application::MirSurfaceListInterface*");
67 qRegisterMetaType<unity::shell::application::SurfaceManagerInterface*>("unity::shell::application::SurfaceManagerInterface*");
80 qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib");68 qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib");
8169
82 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(70 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(
@@ -87,13 +75,13 @@
87 uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");75 uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
88 qmlRegisterUncreatableType<qtmir::Application>(76 qmlRegisterUncreatableType<qtmir::Application>(
89 uri, 0, 1, "ApplicationInfo", "Application can't be instantiated");77 uri, 0, 1, "ApplicationInfo", "Application can't be instantiated");
90 qmlRegisterSingletonType<qtmir::MirSurfaceManager>(
91 uri, 0, 1, "SurfaceManager", surfaceManagerSingleton);
92 qmlRegisterSingletonType<MirFocusController>(uri, 0, 1, "MirFocusController", mirFocusControllerSingleton);
93 qmlRegisterUncreatableType<unity::shell::application::MirSurfaceInterface>(78 qmlRegisterUncreatableType<unity::shell::application::MirSurfaceInterface>(
94 uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");79 uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");
95 qmlRegisterType<qtmir::MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem");80 qmlRegisterType<qtmir::MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem");
96 qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton);81 qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton);
82 qmlRegisterType<qtmir::SurfaceManager>(uri, 0, 1, "SurfaceManager");
83
84 qmlRegisterType<qtmir::WindowModel>(uri, 0, 1, "WindowModel");
97 }85 }
9886
99 virtual void initializeEngine(QQmlEngine *engine, const char *uri)87 virtual void initializeEngine(QQmlEngine *engine, const char *uri)
10088
=== modified file 'src/modules/Unity/Application/session.cpp'
--- src/modules/Unity/Application/session.cpp 2016-09-22 15:58:26 +0000
+++ src/modules/Unity/Application/session.cpp 2016-12-16 08:22:54 +0000
@@ -19,16 +19,14 @@
19#include "debughelpers.h"19#include "debughelpers.h"
20#include "session.h"20#include "session.h"
21#include "mirsurfaceinterface.h"21#include "mirsurfaceinterface.h"
22#include "mirsurfacemanager.h"
23#include "mirsurfaceitem.h"22#include "mirsurfaceitem.h"
23#include "promptsession.h"
2424
25// mirserver25// mirserver
26#include "logging.h"26#include "logging.h"
2727
28// mir28// miral
29#include <mir/scene/session.h>29#include <miral/application.h>
30#include <mir/scene/prompt_session.h>
31#include <mir/scene/prompt_session_manager.h>
3230
33// Qt31// Qt
34#include <QPainter>32#include <QPainter>
@@ -66,7 +64,7 @@
66}64}
6765
68Session::Session(const std::shared_ptr<ms::Session>& session,66Session::Session(const std::shared_ptr<ms::Session>& session,
69 const std::shared_ptr<ms::PromptSessionManager>& promptSessionManager,67 const std::shared_ptr<PromptSessionManager>& promptSessionManager,
70 QObject *parent)68 QObject *parent)
71 : SessionInterface(parent)69 : SessionInterface(parent)
72 , m_session(session)70 , m_session(session)
@@ -121,7 +119,7 @@
121119
122QString Session::name() const120QString Session::name() const
123{121{
124 return QString::fromStdString(m_session->name());122 return QString::fromStdString(miral::name_of(m_session));
125}123}
126124
127std::shared_ptr<ms::Session> Session::session() const125std::shared_ptr<ms::Session> Session::session() const
@@ -202,10 +200,10 @@
202 DEBUG_MSG << "(surface=" << newSurface << ")";200 DEBUG_MSG << "(surface=" << newSurface << ")";
203201
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.
205 if (newSurface->isFirstFrameDrawn()) {203 if (newSurface->isReady()) {
206 prependSurface(newSurface);204 prependSurface(newSurface);
207 } else {205 } else {
208 connect(newSurface, &MirSurfaceInterface::firstFrameDrawn, this, [this, newSurface]()206 connect(newSurface, &MirSurfaceInterface::ready, this, [this, newSurface]()
209 {207 {
210 newSurface->disconnect(this);208 newSurface->disconnect(this);
211 this->prependSurface(newSurface);209 this->prependSurface(newSurface);
@@ -234,6 +232,10 @@
234 this->removeSurface(newSurface);232 this->removeSurface(newSurface);
235 });233 });
236 connect(newSurface, &MirSurfaceInterface::focusRequested, this, &SessionInterface::focusRequested);234 connect(newSurface, &MirSurfaceInterface::focusRequested, this, &SessionInterface::focusRequested);
235 connect(newSurface, &MirSurfaceInterface::focusedChanged, this, [&](bool /*value*/) {
236 // TODO: May want to optimize that in the future.
237 Q_EMIT focusedChanged(focused());
238 });
237239
238 m_surfaceList.prependSurface(newSurface);240 m_surfaceList.prependSurface(newSurface);
239 m_hadSurface = true;241 m_hadSurface = true;
@@ -289,11 +291,11 @@
289{291{
290 DEBUG_MSG << " state=" << sessionStateToString(m_state);292 DEBUG_MSG << " state=" << sessionStateToString(m_state);
291 if (m_state == Running) {293 if (m_state == Running) {
292 session()->set_lifecycle_state(mir_lifecycle_state_will_suspend);294 miral::apply_lifecycle_state_to(session(), mir_lifecycle_state_will_suspend);
293 m_suspendTimer->start();295 m_suspendTimer->start();
294296
295 foreachPromptSession([this](const std::shared_ptr<ms::PromptSession>& promptSession) {297 foreachPromptSession([this](const qtmir::PromptSession &promptSession) {
296 m_promptSessionManager->suspend_prompt_session(promptSession);298 m_promptSessionManager->suspendPromptSession(promptSession);
297 });299 });
298300
299 foreachChildSession([](SessionInterface* session) {301 foreachChildSession([](SessionInterface* session) {
@@ -322,10 +324,10 @@
322 }324 }
323 }325 }
324326
325 session()->set_lifecycle_state(mir_lifecycle_state_resumed);327 miral::apply_lifecycle_state_to(session(), mir_lifecycle_state_resumed);
326328
327 foreachPromptSession([this](const std::shared_ptr<ms::PromptSession>& promptSession) {329 foreachPromptSession([this](const qtmir::PromptSession &promptSession) {
328 m_promptSessionManager->resume_prompt_session(promptSession);330 m_promptSessionManager->resumePromptSession(promptSession);
329 });331 });
330332
331 foreachChildSession([](SessionInterface* session) {333 foreachChildSession([](SessionInterface* session) {
@@ -453,16 +455,16 @@
453 return m_children;455 return m_children;
454}456}
455457
456void Session::appendPromptSession(const std::shared_ptr<ms::PromptSession>& promptSession)458void Session::appendPromptSession(const qtmir::PromptSession &promptSession)
457{459{
458 DEBUG_MSG << "(promptSession=" << (promptSession ? promptSession.get() : nullptr) << ")";460 DEBUG_MSG << "(promptSession=" << promptSession.get() << ")";
459461
460 m_promptSessions.append(promptSession);462 m_promptSessions.append(promptSession);
461}463}
462464
463void Session::removePromptSession(const std::shared_ptr<ms::PromptSession>& promptSession)465void Session::removePromptSession(const qtmir::PromptSession &promptSession)
464{466{
465 DEBUG_MSG << "(promptSession=" << (promptSession ? promptSession.get() : nullptr) << ")";467 DEBUG_MSG << "(promptSession=" << promptSession.get() << ")";
466468
467 m_promptSessions.removeAll(promptSession);469 m_promptSessions.removeAll(promptSession);
468}470}
@@ -474,26 +476,26 @@
474 static_cast<Session*>(child)->stopPromptSessions();476 static_cast<Session*>(child)->stopPromptSessions();
475 }477 }
476478
477 QVector<std::shared_ptr<ms::PromptSession>> copy(m_promptSessions);479 QVector<qtmir::PromptSession> copy(m_promptSessions);
478 QVectorIterator<std::shared_ptr<ms::PromptSession>> it(copy);480 QVectorIterator<qtmir::PromptSession> it(copy);
479 for ( it.toBack(); it.hasPrevious(); ) {481 for ( it.toBack(); it.hasPrevious(); ) {
480 std::shared_ptr<ms::PromptSession> promptSession = it.previous();482 qtmir::PromptSession promptSession = it.previous();
481 DEBUG_MSG << " - promptSession=" << promptSession.get();483 DEBUG_MSG << " - promptSession=" << promptSession.get();
482484
483 m_promptSessionManager->stop_prompt_session(promptSession);485 m_promptSessionManager->stopPromptSession(promptSession);
484 }486 }
485}487}
486488
487std::shared_ptr<ms::PromptSession> Session::activePromptSession() const489qtmir::PromptSession Session::activePromptSession() const
488{490{
489 if (m_promptSessions.count() > 0)491 if (m_promptSessions.count() > 0)
490 return m_promptSessions.back();492 return m_promptSessions.back();
491 return nullptr;493 return {};
492}494}
493495
494void Session::foreachPromptSession(const std::function<void(const std::shared_ptr<ms::PromptSession>&)>& f) const496void Session::foreachPromptSession(const std::function<void(const qtmir::PromptSession&)>& f) const
495{497{
496 Q_FOREACH (std::shared_ptr<ms::PromptSession> promptSession, m_promptSessions) {498 Q_FOREACH (qtmir::PromptSession promptSession, m_promptSessions) {
497 f(promptSession);499 f(promptSession);
498 }500 }
499}501}
@@ -516,6 +518,18 @@
516 return m_hadSurface;518 return m_hadSurface;
517}519}
518520
521bool Session::focused() const
522{
523 for (int i = 0; i < m_surfaceList.count(); ++i) {
524 auto surface = static_cast<const MirSurfaceInterface*>(m_surfaceList.get(i));
525 if (surface->focused()) {
526 return true;
527 }
528 }
529
530 return false;
531}
532
519bool Session::activeFocus() const533bool Session::activeFocus() const
520{534{
521 for (int i = 0; i < m_surfaceList.count(); ++i) {535 for (int i = 0; i < m_surfaceList.count(); ++i) {
@@ -530,7 +544,7 @@
530544
531pid_t Session::pid() const545pid_t Session::pid() const
532{546{
533 return m_session->process_id();547 return miral::pid_of(m_session);
534}548}
535549
536void Session::setSuspendTimer(AbstractTimer *timer)550void Session::setSuspendTimer(AbstractTimer *timer)
537551
=== modified file 'src/modules/Unity/Application/session.h'
--- src/modules/Unity/Application/session.h 2016-07-15 15:38:04 +0000
+++ src/modules/Unity/Application/session.h 2016-12-16 08:22:54 +0000
@@ -23,19 +23,17 @@
23// local23// local
24#include "session_interface.h"24#include "session_interface.h"
25#include "mirsurfacelistmodel.h"25#include "mirsurfacelistmodel.h"
26#include "promptsessionmanager.h"
26#include "timer.h"27#include "timer.h"
2728
28// Qt29// Qt
29#include <QObject>30#include <QObject>
3031
31namespace mir {
32 namespace scene {
33 class PromptSessionManager;
34 }
35}
3632
37namespace qtmir {33namespace qtmir {
3834
35class PromptSessionManager;
36
39class Application;37class Application;
4038
41class Session : public SessionInterface39class Session : public SessionInterface
@@ -43,7 +41,7 @@
43 Q_OBJECT41 Q_OBJECT
44public:42public:
45 explicit Session(const std::shared_ptr<mir::scene::Session>& session,43 explicit Session(const std::shared_ptr<mir::scene::Session>& session,
46 const std::shared_ptr<mir::scene::PromptSessionManager>& promptSessionManager,44 const std::shared_ptr<PromptSessionManager>& promptSessionManager,
47 QObject *parent = 0);45 QObject *parent = 0);
48 virtual ~Session();46 virtual ~Session();
4947
@@ -66,6 +64,7 @@
66 void stop() override;64 void stop() override;
67 bool hadSurface() const override;65 bool hadSurface() const override;
68 bool hasClosingSurfaces() const override;66 bool hasClosingSurfaces() const override;
67 bool focused() const override;
6968
70 bool activeFocus() const override;69 bool activeFocus() const override;
7170
@@ -78,15 +77,15 @@
7877
79 std::shared_ptr<mir::scene::Session> session() const override;78 std::shared_ptr<mir::scene::Session> session() const override;
8079
81 std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override;80 PromptSession activePromptSession() const override;
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;
8382
84 SessionModel* childSessions() const override;83 SessionModel* childSessions() const override;
8584
86 void setFullscreen(bool fullscreen) override;85 void setFullscreen(bool fullscreen) override;
87 void setLive(const bool) override;86 void setLive(const bool) override;
88 void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override;87 void appendPromptSession(const PromptSession& session) override;
89 void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) override;88 void removePromptSession(const PromptSession& session) override;
9089
91 // useful for tests90 // useful for tests
92 void setSuspendTimer(AbstractTimer *timer);91 void setSuspendTimer(AbstractTimer *timer);
@@ -119,8 +118,8 @@
119 State m_state;118 State m_state;
120 bool m_live;119 bool m_live;
121 AbstractTimer* m_suspendTimer{nullptr};120 AbstractTimer* m_suspendTimer{nullptr};
122 QVector<std::shared_ptr<mir::scene::PromptSession>> m_promptSessions;121 QVector<PromptSession> m_promptSessions;
123 std::shared_ptr<mir::scene::PromptSessionManager> const m_promptSessionManager;122 std::shared_ptr<PromptSessionManager> const m_promptSessionManager;
124 QList<MirSurfaceInterface*> m_closingSurfaces;123 QList<MirSurfaceInterface*> m_closingSurfaces;
125 bool m_hadSurface{false};124 bool m_hadSurface{false};
126};125};
127126
=== modified file 'src/modules/Unity/Application/session_interface.h'
--- src/modules/Unity/Application/session_interface.h 2016-07-15 15:38:04 +0000
+++ src/modules/Unity/Application/session_interface.h 2016-12-16 08:22:54 +0000
@@ -33,7 +33,6 @@
33namespace mir {33namespace mir {
34 namespace scene {34 namespace scene {
35 class Session;35 class Session;
36 class PromptSession;
37 }36 }
38}37}
3938
@@ -41,6 +40,7 @@
4140
42class MirSurfaceInterface;41class MirSurfaceInterface;
43class MirSurfaceListModel;42class MirSurfaceListModel;
43class PromptSession;
4444
45class SessionInterface : public QObject {45class SessionInterface : public QObject {
46 Q_OBJECT46 Q_OBJECT
@@ -78,7 +78,7 @@
7878
79 virtual std::shared_ptr<mir::scene::Session> session() const = 0;79 virtual std::shared_ptr<mir::scene::Session> session() const = 0;
8080
81 // For MirSurface and MirSurfaceManager use81 // For MirSurface use
8282
83 virtual void registerSurface(MirSurfaceInterface* surface) = 0;83 virtual void registerSurface(MirSurfaceInterface* surface) = 0;
8484
@@ -91,6 +91,7 @@
91 virtual void stop() = 0;91 virtual void stop() = 0;
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)
93 virtual bool hasClosingSurfaces() const = 0; // whether it has surfaces being forcibly closed93 virtual bool hasClosingSurfaces() const = 0; // whether it has surfaces being forcibly closed
94 virtual bool focused() const = 0; // whether any surface in its list is focused()
9495
95 // Whether any of its MirSurfaces has activeFocus()96 // Whether any of its MirSurfaces has activeFocus()
96 // See qtmir::MirSurfaceInterface::activeFocus97 // See qtmir::MirSurfaceInterface::activeFocus
@@ -105,19 +106,20 @@
105 virtual void removeChildSession(SessionInterface* session) = 0;106 virtual void removeChildSession(SessionInterface* session) = 0;
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;
107108
108 virtual std::shared_ptr<mir::scene::PromptSession> activePromptSession() const = 0;109 virtual PromptSession activePromptSession() const = 0;
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;
110111
111 virtual void setFullscreen(bool fullscreen) = 0;112 virtual void setFullscreen(bool fullscreen) = 0;
112 virtual void setLive(const bool) = 0;113 virtual void setLive(const bool) = 0;
113 virtual void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0;114 virtual void appendPromptSession(const PromptSession& session) = 0;
114 virtual void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>& session) = 0;115 virtual void removePromptSession(const PromptSession& session) = 0;
115116
116Q_SIGNALS:117Q_SIGNALS:
117 void applicationChanged(unity::shell::application::ApplicationInfoInterface* application);118 void applicationChanged(unity::shell::application::ApplicationInfoInterface* application);
118 void stateChanged(State state);119 void stateChanged(State state);
119 void fullscreenChanged(bool fullscreen);120 void fullscreenChanged(bool fullscreen);
120 void liveChanged(bool live);121 void liveChanged(bool live);
122 void focusedChanged(bool focused);
121123
122 // Emitted when any surface in this session emits focusRequested()124 // Emitted when any surface in this session emits focusRequested()
123 void focusRequested();125 void focusRequested();
124126
=== modified file 'src/modules/Unity/Application/sessionmanager.cpp'
--- src/modules/Unity/Application/sessionmanager.cpp 2016-08-10 06:51:55 +0000
+++ src/modules/Unity/Application/sessionmanager.cpp 2016-12-16 08:22:54 +0000
@@ -23,28 +23,23 @@
23#include "sessionmanager.h"23#include "sessionmanager.h"
2424
25// QPA mirserver25// QPA mirserver
26#include "appnotifier.h"
27#include "logging.h"
26#include "nativeinterface.h"28#include "nativeinterface.h"
27#include "sessionlistener.h"
28#include "logging.h"
29#include "promptsessionlistener.h"29#include "promptsessionlistener.h"
3030#include "promptsession.h"
31// mir31
32#include <mir/scene/prompt_session.h>
33#include <mir/scene/prompt_session_manager.h>
34#include <mir/report_exception.h>
35
36namespace ms = mir::scene;
3732
38namespace qtmir {33namespace qtmir {
3934
40SessionManager *SessionManager::the_session_manager = nullptr;35SessionManager *SessionManager::the_session_manager = nullptr;
4136
4237
43void connectToSessionListener(SessionManager *manager, SessionListener *listener)38void connectToAppNotifier(SessionManager *manager, AppNotifier *appNotifier)
44{39{
45 QObject::connect(listener, &SessionListener::sessionStarting,40 QObject::connect(appNotifier, &AppNotifier::appAdded,
46 manager, &SessionManager::onSessionStarting);41 manager, &SessionManager::onSessionStarting);
47 QObject::connect(listener, &SessionListener::sessionStopping,42 QObject::connect(appNotifier, &AppNotifier::appRemoved,
48 manager, &SessionManager::onSessionStopping);43 manager, &SessionManager::onSessionStopping);
49}44}
5045
@@ -61,7 +56,6 @@
61}56}
6257
63SessionManager* SessionManager::singleton()58SessionManager* SessionManager::singleton()
64try
65{59{
66 if (!the_session_manager) {60 if (!the_session_manager) {
6761
@@ -73,27 +67,19 @@
73 return nullptr;67 return nullptr;
74 }68 }
7569
76 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));70 auto appNotifier = static_cast<AppNotifier*>(nativeInterface->nativeResourceForIntegration("AppNotifier"));
77 PromptSessionListener *promptSessionListener = static_cast<PromptSessionListener*>(nativeInterface->nativeResourceForIntegration("PromptSessionListener"));71 PromptSessionListener *promptSessionListener = static_cast<PromptSessionListener*>(nativeInterface->nativeResourceForIntegration("PromptSessionListener"));
7872
79 the_session_manager = new SessionManager(nativeInterface->thePromptSessionManager(), ApplicationManager::singleton());73 the_session_manager = new SessionManager(nativeInterface->thePromptSessionManager(), ApplicationManager::singleton());
8074
81 connectToSessionListener(the_session_manager, sessionListener);75 connectToAppNotifier(the_session_manager, appNotifier);
82 connectToPromptSessionListener(the_session_manager, promptSessionListener);76 connectToPromptSessionListener(the_session_manager, promptSessionListener);
83 }77 }
84 return the_session_manager;78 return the_session_manager;
85}79}
86catch (...)
87{
88 // We only call mir::report_exception() here to force linkage against libmirserver.
89 // Unless we force this module to have a link dependency on libmirserver we get
90 // several tests hanging during link loading. I wish I understood why. alan_g
91 mir::report_exception();
92 throw;
93}
9480
95SessionManager::SessionManager(81SessionManager::SessionManager(
96 const std::shared_ptr<mir::scene::PromptSessionManager>& promptSessionManager,82 const std::shared_ptr<qtmir::PromptSessionManager>& promptSessionManager,
97 ApplicationManager* applicationManager,83 ApplicationManager* applicationManager,
98 QObject *parent)84 QObject *parent)
99 : SessionModel(parent)85 : SessionModel(parent)
@@ -120,10 +106,11 @@
120 return nullptr;106 return nullptr;
121}107}
122108
123void SessionManager::onSessionStarting(std::shared_ptr<mir::scene::Session> const& session)109void SessionManager::onSessionStarting(const miral::ApplicationInfo &appInfo)
124{110{
125 qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStarting - sessionName=" << session->name().c_str();111 qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStarting - sessionName=" << appInfo.name().c_str();
126112
113 const auto &session = appInfo.application();
127 Session* qmlSession = new Session(session, m_promptSessionManager);114 Session* qmlSession = new Session(session, m_promptSessionManager);
128 insert(0, qmlSession);115 insert(0, qmlSession);
129116
@@ -140,11 +127,11 @@
140 Q_EMIT sessionStarting(qmlSession);127 Q_EMIT sessionStarting(qmlSession);
141}128}
142129
143void SessionManager::onSessionStopping(std::shared_ptr<mir::scene::Session> const& session)130void SessionManager::onSessionStopping(const miral::ApplicationInfo &appInfo)
144{131{
145 qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStopping - sessionName=" << session->name().c_str();132 qCDebug(QTMIR_SESSIONS) << "SessionManager::onSessionStopping - sessionName=" << appInfo.name().c_str();
146133
147 SessionInterface* qmlSession = findSession(session.get());134 SessionInterface* qmlSession = findSession(appInfo.application().get());
148 if (!qmlSession) return;135 if (!qmlSession) return;
149136
150 remove(qmlSession);137 remove(qmlSession);
@@ -153,11 +140,11 @@
153 Q_EMIT sessionStopping(qmlSession);140 Q_EMIT sessionStopping(qmlSession);
154}141}
155142
156void SessionManager::onPromptSessionStarting(const std::shared_ptr<ms::PromptSession>& promptSession)143void SessionManager::onPromptSessionStarting(const qtmir::PromptSession &promptSession)
157{144{
158 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStarting - promptSession=" << promptSession.get();145 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStarting - promptSession=" << promptSession.get();
159146
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);
161 SessionInterface *qmlAppSession = findSession(appSession.get());148 SessionInterface *qmlAppSession = findSession(appSession.get());
162 if (qmlAppSession) {149 if (qmlAppSession) {
163 m_mirPromptToSessionHash[promptSession.get()] = qmlAppSession;150 m_mirPromptToSessionHash[promptSession.get()] = qmlAppSession;
@@ -167,7 +154,7 @@
167 }154 }
168}155}
169156
170void SessionManager::onPromptSessionStopping(const std::shared_ptr<ms::PromptSession>& promptSession)157void SessionManager::onPromptSessionStopping(const qtmir::PromptSession &promptSession)
171{158{
172 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStopping - promptSession=" << promptSession.get();159 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptSessionStopping - promptSession=" << promptSession.get();
173160
@@ -177,12 +164,12 @@
177 m_mirPromptToSessionHash.remove(promptSession.get());164 m_mirPromptToSessionHash.remove(promptSession.get());
178}165}
179166
180void SessionManager::onPromptProviderAdded(const mir::scene::PromptSession *promptSession,167void SessionManager::onPromptProviderAdded(const qtmir::PromptSession &promptSession,
181 const std::shared_ptr<mir::scene::Session> &promptProvider)168 const std::shared_ptr<mir::scene::Session> &promptProvider)
182{169{
183 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - promptSession=" << promptSession << " promptProvider=" << promptProvider.get();170 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderAdded - promptSession=" << promptSession.get() << " promptProvider=" << promptProvider.get();
184171
185 SessionInterface* qmlAppSession = m_mirPromptToSessionHash.value(promptSession, nullptr);172 SessionInterface* qmlAppSession = m_mirPromptToSessionHash.value(promptSession.get(), nullptr);
186 if (!qmlAppSession) {173 if (!qmlAppSession) {
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";
188 return;175 return;
@@ -197,10 +184,10 @@
197 qmlAppSession->addChildSession(qmlPromptProvider);184 qmlAppSession->addChildSession(qmlPromptProvider);
198}185}
199186
200void SessionManager::onPromptProviderRemoved(const mir::scene::PromptSession *promptSession,187void SessionManager::onPromptProviderRemoved(const qtmir::PromptSession &promptSession,
201 const std::shared_ptr<mir::scene::Session> &promptProvider)188 const std::shared_ptr<mir::scene::Session> &promptProvider)
202{189{
203 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderRemoved - promptSession=" << promptSession << " promptProvider=" << promptProvider.get();190 qCDebug(QTMIR_SESSIONS) << "SessionManager::onPromptProviderRemoved - promptSession=" << promptSession.get() << " promptProvider=" << promptProvider.get();
204191
205 SessionInterface* qmlPromptProvider = findSession(promptProvider.get());192 SessionInterface* qmlPromptProvider = findSession(promptProvider.get());
206 if (!qmlPromptProvider) {193 if (!qmlPromptProvider) {
207194
=== modified file 'src/modules/Unity/Application/sessionmanager.h'
--- src/modules/Unity/Application/sessionmanager.h 2016-08-10 06:51:37 +0000
+++ src/modules/Unity/Application/sessionmanager.h 2016-12-16 08:22:54 +0000
@@ -27,6 +27,9 @@
27// Mir27// Mir
28#include <mir_toolkit/common.h>28#include <mir_toolkit/common.h>
2929
30// miral
31#include <miral/application_info.h>
32
30// local33// local
31#include "session.h"34#include "session.h"
32#include "sessionmodel.h"35#include "sessionmodel.h"
@@ -49,7 +52,7 @@
4952
50public:53public:
51 explicit SessionManager(54 explicit SessionManager(
52 const std::shared_ptr<mir::scene::PromptSessionManager>& promptSessionManager,55 const std::shared_ptr<PromptSessionManager>& promptSessionManager,
53 ApplicationManager* applicationManager,56 ApplicationManager* applicationManager,
54 QObject *parent = 057 QObject *parent = 0
55 );58 );
@@ -64,18 +67,18 @@
64 void sessionStopping(SessionInterface* session);67 void sessionStopping(SessionInterface* session);
6568
66public Q_SLOTS:69public Q_SLOTS:
67 void onSessionStarting(std::shared_ptr<mir::scene::Session> const& session);70 void onSessionStarting(const miral::ApplicationInfo &appInfo);
68 void onSessionStopping(std::shared_ptr<mir::scene::Session> const& session);71 void onSessionStopping(const miral::ApplicationInfo &appInfo);
6972
70 void onPromptSessionStarting(const std::shared_ptr<mir::scene::PromptSession>& promptSession);73 void onPromptSessionStarting(const PromptSession& promptSession);
71 void onPromptSessionStopping(const std::shared_ptr<mir::scene::PromptSession>& promptSession);74 void onPromptSessionStopping(const PromptSession& promptSession);
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> &);
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> &);
7477
75protected:78protected:
7679
77private:80private:
78 const std::shared_ptr<mir::scene::PromptSessionManager> m_promptSessionManager;81 const std::shared_ptr<PromptSessionManager> m_promptSessionManager;
79 ApplicationManager* m_applicationManager;82 ApplicationManager* m_applicationManager;
80 static SessionManager *the_session_manager;83 static SessionManager *the_session_manager;
8184
8285
=== added file 'src/modules/Unity/Application/surfacemanager.cpp'
--- src/modules/Unity/Application/surfacemanager.cpp 1970-01-01 00:00:00 +0000
+++ src/modules/Unity/Application/surfacemanager.cpp 2016-12-16 08:22:54 +0000
@@ -0,0 +1,174 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "surfacemanager.h"
18
19#include "mirsurface.h"
20#include "sessionmanager.h"
21
22// mirserver
23#include "nativeinterface.h"
24
25// Qt
26#include <QGuiApplication>
27
28Q_LOGGING_CATEGORY(QTMIR_SURFACEMANAGER, "qtmir.surfacemanager", QtInfoMsg)
29
30#define DEBUG_MSG qCDebug(QTMIR_SURFACEMANAGER).nospace().noquote() << __func__
31
32using namespace qtmir;
33namespace unityapi = unity::shell::application;
34
35SurfaceManager::SurfaceManager(QObject *)
36{
37 DEBUG_MSG << "()";
38
39 auto nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface());
40
41 if (!nativeInterface) {
42 qFatal("ERROR: Unity.Application QML plugin requires use of the 'mirserver' QPA plugin");
43 }
44
45 m_windowController = static_cast<WindowControllerInterface*>(nativeInterface->nativeResourceForIntegration("WindowController"));
46
47 auto windowModel = static_cast<WindowModelNotifier*>(nativeInterface->nativeResourceForIntegration("WindowModelNotifier"));
48 connectToWindowModelNotifier(windowModel);
49
50 m_sessionManager = SessionManager::singleton();
51}
52
53void SurfaceManager::connectToWindowModelNotifier(WindowModelNotifier *notifier)
54{
55 connect(notifier, &WindowModelNotifier::windowAdded, this, &SurfaceManager::onWindowAdded, Qt::QueuedConnection);
56 connect(notifier, &WindowModelNotifier::windowRemoved, this, &SurfaceManager::onWindowRemoved, Qt::QueuedConnection);
57 connect(notifier, &WindowModelNotifier::windowReady, this, &SurfaceManager::onWindowReady, Qt::QueuedConnection);
58 connect(notifier, &WindowModelNotifier::windowMoved, this, &SurfaceManager::onWindowMoved, Qt::QueuedConnection);
59 connect(notifier, &WindowModelNotifier::windowStateChanged, this, &SurfaceManager::onWindowStateChanged, Qt::QueuedConnection);
60 connect(notifier, &WindowModelNotifier::windowFocusChanged, this, &SurfaceManager::onWindowFocusChanged, Qt::QueuedConnection);
61 connect(notifier, &WindowModelNotifier::windowsRaised, this, &SurfaceManager::onWindowsRaised, Qt::QueuedConnection);
62 connect(notifier, &WindowModelNotifier::windowRequestedRaise, this, &SurfaceManager::onWindowsRequestedRaise, Qt::QueuedConnection);
63 connect(notifier, &WindowModelNotifier::modificationsStarted, this, &SurfaceManager::modificationsStarted, Qt::QueuedConnection);
64 connect(notifier, &WindowModelNotifier::modificationsEnded, this, &SurfaceManager::modificationsEnded, Qt::QueuedConnection);
65}
66
67void SurfaceManager::rememberMirSurface(MirSurface *surface)
68{
69 m_allSurfaces.append(surface);
70}
71
72void SurfaceManager::forgetMirSurface(const miral::Window &window)
73{
74 for (int i = 0; i < m_allSurfaces.count(); ++i) {
75 if (m_allSurfaces[i]->window() == window) {
76 m_allSurfaces.removeAt(i);
77 return;
78 }
79 }
80}
81void SurfaceManager::onWindowAdded(const NewWindow &window)
82{
83 auto mirSession = window.windowInfo.window().application();
84 SessionInterface* session = m_sessionManager->findSession(mirSession.get());
85
86 auto surface = new MirSurface(window, m_windowController, session);
87 rememberMirSurface(surface);
88
89 if (session)
90 session->registerSurface(surface);
91
92 Q_EMIT surfaceCreated(surface);
93}
94
95void SurfaceManager::onWindowRemoved(const miral::WindowInfo &windowInfo)
96{
97 MirSurface *surface = find(windowInfo);
98 forgetMirSurface(windowInfo.window());
99 surface->setLive(false);
100}
101
102MirSurface *SurfaceManager::find(const miral::WindowInfo &needle) const
103{
104 return find(needle.window());
105}
106
107MirSurface *SurfaceManager::find(const miral::Window &window) const
108{
109 Q_FOREACH(const auto surface, m_allSurfaces) {
110 if (surface->window() == window) {
111 return surface;
112 }
113 }
114 return nullptr;
115}
116
117void SurfaceManager::onWindowReady(const miral::WindowInfo &windowInfo)
118{
119 if (auto mirSurface = find(windowInfo)) {
120 mirSurface->setReady();
121 }
122}
123
124void SurfaceManager::onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft)
125{
126 if (auto mirSurface = find(windowInfo)) {
127 mirSurface->setPosition(topLeft);
128 }
129}
130
131void SurfaceManager::onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused)
132{
133 if (auto mirSurface = find(windowInfo)) {
134 mirSurface->setFocused(focused);
135 }
136}
137
138void SurfaceManager::onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state)
139{
140 if (auto mirSurface = find(windowInfo)) {
141 mirSurface->updateState(state);
142 }
143}
144
145void SurfaceManager::onWindowsRaised(const std::vector<miral::Window> &windows)
146{
147 // sad inefficiency when crossing API boundaries (from miral to qt)
148 const int raiseCount = windows.size();
149 QVector<unityapi::MirSurfaceInterface*> surfaces(raiseCount);
150 for (int i = 0; i < raiseCount; i++) {
151 auto mirSurface = find(windows[i]);
152 surfaces.append(mirSurface);
153 }
154 Q_EMIT surfacesRaised(surfaces);
155}
156
157void SurfaceManager::onWindowsRequestedRaise(const miral::WindowInfo &windowInfo)
158{
159 if (auto mirSurface = find(windowInfo)) {
160 mirSurface->requestFocus();
161 }
162}
163
164void SurfaceManager::raise(unityapi::MirSurfaceInterface *surface)
165{
166 auto qtmirSurface = static_cast<qtmir::MirSurface*>(surface);
167 m_windowController->raise(qtmirSurface->window());
168}
169
170void SurfaceManager::activate(unityapi::MirSurfaceInterface *surface)
171{
172 auto qtmirSurface = static_cast<qtmir::MirSurface*>(surface);
173 m_windowController->activate(qtmirSurface ? qtmirSurface->window() : miral::Window());
174}
0175
=== added file 'src/modules/Unity/Application/surfacemanager.h'
--- src/modules/Unity/Application/surfacemanager.h 1970-01-01 00:00:00 +0000
+++ src/modules/Unity/Application/surfacemanager.h 2016-12-16 08:22:54 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef QTMIR_SURFACEMANAGER_H
18#define QTMIR_SURFACEMANAGER_H
19
20// common
21#include "windowmodelnotifier.h"
22
23// Unity API
24#include <unity/shell/application/SurfaceManagerInterface.h>
25
26#include <QVector>
27#include <QLoggingCategory>
28
29Q_DECLARE_LOGGING_CATEGORY(QTMIR_SURFACEMANAGER)
30
31namespace qtmir {
32
33class MirSurface;
34class SessionManager;
35class WindowControllerInterface;
36
37class SurfaceManager : public unity::shell::application::SurfaceManagerInterface
38{
39 Q_OBJECT
40
41public:
42 explicit SurfaceManager(QObject *parent = 0);
43 virtual ~SurfaceManager() {}
44
45 void raise(unity::shell::application::MirSurfaceInterface *surface) override;
46 void activate(unity::shell::application::MirSurfaceInterface *surface) override;
47
48private Q_SLOTS:
49 void onWindowAdded(const qtmir::NewWindow &windowInfo);
50 void onWindowRemoved(const miral::WindowInfo &windowInfo);
51 void onWindowReady(const miral::WindowInfo &windowInfo);
52 void onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft);
53 void onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state);
54 void onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused);
55 void onWindowsRaised(const std::vector<miral::Window> &windows);
56 void onWindowsRequestedRaise(const miral::WindowInfo &windowInfo);
57
58private:
59 void connectToWindowModelNotifier(WindowModelNotifier *notifier);
60 void rememberMirSurface(MirSurface *surface);
61 void forgetMirSurface(const miral::Window &window);
62 MirSurface* find(const miral::WindowInfo &needle) const;
63 MirSurface* find(const miral::Window &needle) const;
64
65 QVector<MirSurface*> m_allSurfaces;
66
67 WindowControllerInterface *m_windowController;
68 SessionManager* m_sessionManager;
69};
70
71} // namespace qtmir
72
73#endif // QTMIR_SURFACEMANAGER_H
074
=== added file 'src/modules/Unity/Application/windowmodel.cpp'
--- src/modules/Unity/Application/windowmodel.cpp 1970-01-01 00:00:00 +0000
+++ src/modules/Unity/Application/windowmodel.cpp 2016-12-16 08:22:54 +0000
@@ -0,0 +1,235 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "windowmodel.h"
18
19#include "mirsurface.h"
20
21// mirserver
22#include "nativeinterface.h"
23
24// Qt
25#include <QGuiApplication>
26#include <QDebug>
27
28using namespace qtmir;
29
30WindowModel::WindowModel()
31{
32 auto nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface());
33
34 if (!nativeInterface) {
35 qFatal("ERROR: Unity.Application QML plugin requires use of the 'mirserver' QPA plugin");
36 }
37
38 m_windowController = static_cast<WindowControllerInterface*>(nativeInterface->nativeResourceForIntegration("WindowController"));
39
40 auto windowModel = static_cast<WindowModelNotifier*>(nativeInterface->nativeResourceForIntegration("WindowModelNotifier"));
41 connectToWindowModelNotifier(windowModel);
42}
43
44WindowModel::WindowModel(WindowModelNotifier *notifier,
45 WindowControllerInterface *controller)
46 : m_windowController(controller)
47{
48 connectToWindowModelNotifier(notifier);
49}
50
51void WindowModel::connectToWindowModelNotifier(WindowModelNotifier *notifier)
52{
53 connect(notifier, &WindowModelNotifier::windowAdded, this, &WindowModel::onWindowAdded, Qt::QueuedConnection);
54 connect(notifier, &WindowModelNotifier::windowRemoved, this, &WindowModel::onWindowRemoved, Qt::QueuedConnection);
55 connect(notifier, &WindowModelNotifier::windowReady, this, &WindowModel::onWindowReady, Qt::QueuedConnection);
56 connect(notifier, &WindowModelNotifier::windowMoved, this, &WindowModel::onWindowMoved, Qt::QueuedConnection);
57 connect(notifier, &WindowModelNotifier::windowStateChanged, this, &WindowModel::onWindowStateChanged, Qt::QueuedConnection);
58 connect(notifier, &WindowModelNotifier::windowFocusChanged, this, &WindowModel::onWindowFocusChanged, Qt::QueuedConnection);
59 connect(notifier, &WindowModelNotifier::windowsRaised, this, &WindowModel::onWindowsRaised, Qt::QueuedConnection);
60}
61
62QHash<int, QByteArray> WindowModel::roleNames() const
63{
64 QHash<int, QByteArray> roleNames;
65 roleNames.insert(SurfaceRole, "surface");
66 return roleNames;
67}
68
69void WindowModel::onWindowAdded(const NewWindow &window)
70{
71 if (window.windowInfo.type() == mir_surface_type_inputmethod) {
72 addInputMethodWindow(window);
73 return;
74 }
75
76 const int index = m_windowModel.count();
77 beginInsertRows(QModelIndex(), index, index);
78 m_windowModel.append(new MirSurface(window, m_windowController));
79 endInsertRows();
80 Q_EMIT countChanged();
81}
82
83void WindowModel::onWindowRemoved(const miral::WindowInfo &windowInfo)
84{
85 if (windowInfo.type() == mir_surface_type_inputmethod) {
86 removeInputMethodWindow();
87 return;
88 }
89
90 const int index = findIndexOf(windowInfo.window());
91
92 beginRemoveRows(QModelIndex(), index, index);
93 m_windowModel.takeAt(index);
94 endRemoveRows();
95 Q_EMIT countChanged();
96}
97
98void WindowModel::onWindowReady(const miral::WindowInfo &windowInfo)
99{
100 if (auto mirSurface = find(windowInfo)) {
101 mirSurface->setReady();
102 }
103}
104
105void WindowModel::onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft)
106{
107 if (auto mirSurface = find(windowInfo)) {
108 mirSurface->setPosition(topLeft);
109 }
110}
111
112void WindowModel::onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused)
113{
114 if (auto mirSurface = find(windowInfo)) {
115 mirSurface->setFocused(focused);
116 }
117}
118
119void WindowModel::onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state)
120{
121 if (auto mirSurface = find(windowInfo)) {
122 mirSurface->updateState(state);
123 }
124}
125
126void WindowModel::addInputMethodWindow(const NewWindow &windowInfo)
127{
128 if (m_inputMethodSurface) {
129 qDebug("Multiple Input Method Surfaces created, removing the old one!");
130 delete m_inputMethodSurface;
131 }
132 m_inputMethodSurface = new MirSurface(windowInfo, m_windowController);
133 Q_EMIT inputMethodSurfaceChanged(m_inputMethodSurface);
134}
135
136void WindowModel::removeInputMethodWindow()
137{
138 if (m_inputMethodSurface) {
139 delete m_inputMethodSurface;
140 m_inputMethodSurface = nullptr;
141 Q_EMIT inputMethodSurfaceChanged(m_inputMethodSurface);
142 }
143}
144
145void WindowModel::onWindowsRaised(const std::vector<miral::Window> &windows)
146{
147 // Reminder: last item in the "windows" list should end up at the top of the model
148 const int modelCount = m_windowModel.count();
149 const int raiseCount = windows.size();
150
151 // Assumption: no NO-OPs are in this list - Qt will crash on endMoveRows() if you try NO-OPs!!!
152 // A NO-OP is if
153 // 1. "indices" is an empty list
154 // 2. "indices" of the form (..., modelCount - 2, modelCount - 1) which results in an unchanged list
155
156 // Precompute the list of indices of Windows/Surfaces to raise, including the offsets due to
157 // indices which have already been moved.
158 QVector<QPair<int /*from*/, int /*to*/>> moveList;
159
160 for (int i=raiseCount-1; i>=0; i--) {
161 int from = findIndexOf(windows[i]);
162 const int to = modelCount - raiseCount + i;
163
164 int moveCount = 0;
165 // how many list items under "index" have been moved so far, correct "from" to suit
166 for (int j=raiseCount-1; j>i; j--) {
167 if (findIndexOf(windows[j]) < from) {
168 moveCount++;
169 }
170 }
171 from -= moveCount;
172
173 if (from == to) {
174 // is NO-OP, would result in moving element to itself
175 } else {
176 moveList.prepend({from, to});
177 }
178 }
179
180 // Perform the moving, trusting the moveList is correct for each iteration.
181 QModelIndex parent;
182 for (int i=moveList.count()-1; i>=0; i--) {
183 const int from = moveList[i].first;
184 const int to = moveList[i].second;
185
186 beginMoveRows(parent, from, from, parent, to+1);
187#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
188 const auto &window = m_windowModel.takeAt(from);
189 m_windowModel.insert(to, window);
190#else
191 m_windowModel.move(from, to);
192#endif
193
194 endMoveRows();
195 }
196}
197
198int WindowModel::rowCount(const QModelIndex &/*parent*/) const
199{
200 return m_windowModel.count();
201}
202
203QVariant WindowModel::data(const QModelIndex &index, int role) const
204{
205 if (index.row() < 0 || index.row() >= m_windowModel.count())
206 return QVariant();
207
208 if (role == SurfaceRole) {
209 auto &surface = m_windowModel.at(index.row());
210 return QVariant::fromValue(surface);
211 } else {
212 return QVariant();
213 }
214}
215
216MirSurface *WindowModel::find(const miral::WindowInfo &needle) const
217{
218 auto window = needle.window();
219 Q_FOREACH(const auto mirSurface, m_windowModel) {
220 if (mirSurface->window() == window) {
221 return mirSurface;
222 }
223 }
224 return nullptr;
225}
226
227int WindowModel::findIndexOf(const miral::Window &needle) const
228{
229 for (int i=0; i<m_windowModel.count(); i++) {
230 if (m_windowModel[i]->window() == needle) {
231 return i;
232 }
233 }
234 return -1;
235}
0236
=== added file 'src/modules/Unity/Application/windowmodel.h'
--- src/modules/Unity/Application/windowmodel.h 1970-01-01 00:00:00 +0000
+++ src/modules/Unity/Application/windowmodel.h 2016-12-16 08:22:54 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef WINDOWMODEL_H
18#define WINDOWMODEL_H
19
20#include <QAbstractListModel>
21
22#include "mirsurface.h"
23#include "windowmodelnotifier.h"
24
25namespace qtmir {
26
27class WindowControllerInterface;
28
29class WindowModel : public QAbstractListModel
30{
31 Q_OBJECT
32
33 Q_PROPERTY(int count READ count NOTIFY countChanged)
34
35 Q_PROPERTY(MirSurfaceInterface* inputMethodSurface READ inputMethodSurface NOTIFY inputMethodSurfaceChanged)
36
37public:
38 enum Roles {
39 SurfaceRole = Qt::UserRole
40 };
41
42 WindowModel();
43 explicit WindowModel(WindowModelNotifier *notifier,
44 WindowControllerInterface *controller); // For testing
45
46 // QAbstractItemModel methods
47 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
48 QVariant data(const QModelIndex& index, int role) const override;
49
50 QHash<int, QByteArray> roleNames() const override;
51
52 int count() const { return rowCount(); }
53
54 MirSurface* inputMethodSurface() const { return m_inputMethodSurface; }
55
56Q_SIGNALS:
57 void countChanged();
58 void inputMethodSurfaceChanged(MirSurfaceInterface* inputMethodSurface);
59
60private Q_SLOTS:
61 void onWindowAdded(const qtmir::NewWindow &windowInfo);
62 void onWindowRemoved(const miral::WindowInfo &windowInfo);
63 void onWindowReady(const miral::WindowInfo &windowInfo);
64 void onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft);
65 void onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state);
66 void onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused);
67 void onWindowsRaised(const std::vector<miral::Window> &windows);
68
69private:
70 void connectToWindowModelNotifier(WindowModelNotifier *notifier);
71
72 void addInputMethodWindow(const NewWindow &windowInfo);
73 void removeInputMethodWindow();
74 MirSurface* find(const miral::WindowInfo &needle) const;
75 int findIndexOf(const miral::Window &needle) const;
76
77 QVector<MirSurface*> m_windowModel;
78 WindowControllerInterface *m_windowController;
79 MirSurface* m_inputMethodSurface{nullptr};
80};
81
82} // namespace qtmir
83#endif // WINDOWMODEL_H
084
=== modified file 'src/modules/Unity/Screens/CMakeLists.txt'
--- src/modules/Unity/Screens/CMakeLists.txt 2016-06-06 18:12:07 +0000
+++ src/modules/Unity/Screens/CMakeLists.txt 2016-12-16 08:22:54 +0000
@@ -4,9 +4,9 @@
44
5include_directories(5include_directories(
6 SYSTEM6 SYSTEM
7 ${MIRCLIENT_INCLUDE_DIRS}
7 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}8 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
8 ${Qt5Quick_INCLUDE_DIRS}9 ${Qt5Quick_INCLUDE_DIRS}
9 ${MIRSERVER_INCLUDE_DIRS}
10 )10 )
1111
12set(SCREENSPLUGIN_SRC12set(SCREENSPLUGIN_SRC
1313
=== modified file 'src/modules/Unity/Screens/plugin.cpp'
--- src/modules/Unity/Screens/plugin.cpp 2016-04-29 15:41:00 +0000
+++ src/modules/Unity/Screens/plugin.cpp 2016-12-16 08:22:54 +0000
@@ -36,7 +36,7 @@
36 qRegisterMetaType<QScreen*>("QScreen*");36 qRegisterMetaType<QScreen*>("QScreen*");
3737
38 qmlRegisterType<qtmir::Screens>(uri, 0, 1, "Screens");38 qmlRegisterType<qtmir::Screens>(uri, 0, 1, "Screens");
39 qRegisterMetaType<qtmir::Screens::FormFactor>("Screens::FormFactor");39 qRegisterMetaType<qtmir::FormFactor>("qtmir::FormFactor");
4040
41 qmlRegisterType<qtmir::QQuickScreenWindow>(uri, 0, 1, "ScreenWindow");41 qmlRegisterType<qtmir::QQuickScreenWindow>(uri, 0, 1, "ScreenWindow");
42 }42 }
4343
=== modified file 'src/modules/Unity/Screens/qquickscreenwindow.cpp'
--- src/modules/Unity/Screens/qquickscreenwindow.cpp 2016-06-06 19:25:20 +0000
+++ src/modules/Unity/Screens/qquickscreenwindow.cpp 2016-12-16 08:22:54 +0000
@@ -48,7 +48,7 @@
48QQuickScreenWindow::QQuickScreenWindow(QQuickWindow *parent)48QQuickScreenWindow::QQuickScreenWindow(QQuickWindow *parent)
49 : QQuickWindow(parent)49 : QQuickWindow(parent)
50 , m_scale(-1.0) // start with invalid initial state, fetch correct value on first invokation50 , m_scale(-1.0) // start with invalid initial state, fetch correct value on first invokation
51 , m_formFactor(Screens::FormFactorUnknown)51 , m_formFactor(FormFactorUnknown)
52{52{
53 if (qGuiApp->platformName() == QLatin1String("mirserver")) {53 if (qGuiApp->platformName() == QLatin1String("mirserver")) {
54 connect(qGuiApp->platformNativeInterface(), &QPlatformNativeInterface::windowPropertyChanged,54 connect(qGuiApp->platformNativeInterface(), &QPlatformNativeInterface::windowPropertyChanged,
@@ -91,7 +91,7 @@
91 return m_scale;91 return m_scale;
92}92}
9393
94bool QQuickScreenWindow::setScaleAndFormFactor(const float scale, const Screens::FormFactor formFactor)94bool QQuickScreenWindow::setScaleAndFormFactor(const float scale, const FormFactor formFactor)
95{95{
96 if (qFuzzyCompare(scale, m_scale) && formFactor == m_formFactor) {96 if (qFuzzyCompare(scale, m_scale) && formFactor == m_formFactor) {
97 return true;97 return true;
@@ -125,9 +125,9 @@
125 return controller->setConfiguration(configs);125 return controller->setConfiguration(configs);
126}126}
127127
128Screens::FormFactor QQuickScreenWindow::formFactor()128FormFactor QQuickScreenWindow::formFactor()
129{129{
130 if (m_formFactor == Screens::FormFactorUnknown) {130 if (m_formFactor == FormFactorUnknown) {
131 m_formFactor = getFormFactorNativeProperty();131 m_formFactor = getFormFactorNativeProperty();
132 }132 }
133 return m_formFactor;133 return m_formFactor;
@@ -173,7 +173,7 @@
173 return scale;173 return scale;
174}174}
175175
176Screens::FormFactor QQuickScreenWindow::getFormFactorNativeProperty() const176FormFactor QQuickScreenWindow::getFormFactorNativeProperty() const
177{177{
178 QVariant formFactorVal = qGuiApp->platformNativeInterface()178 QVariant formFactorVal = qGuiApp->platformNativeInterface()
179 ->windowProperty(handle(), QStringLiteral("formFactor"));179 ->windowProperty(handle(), QStringLiteral("formFactor"));
@@ -181,5 +181,5 @@
181 return m_formFactor;181 return m_formFactor;
182 }182 }
183183
184 return static_cast<Screens::FormFactor>(formFactorVal.toInt());184 return static_cast<FormFactor>(formFactorVal.toInt());
185}185}
186186
=== modified file 'src/modules/Unity/Screens/qquickscreenwindow.h'
--- src/modules/Unity/Screens/qquickscreenwindow.h 2016-01-28 23:32:53 +0000
+++ src/modules/Unity/Screens/qquickscreenwindow.h 2016-12-16 08:22:54 +0000
@@ -28,7 +28,7 @@
2828
29 Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)29 Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
30 Q_PROPERTY(float scale READ scale NOTIFY scaleChanged)30 Q_PROPERTY(float scale READ scale NOTIFY scaleChanged)
31 Q_PROPERTY(Screens::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)31 Q_PROPERTY(FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
3232
33public:33public:
34 explicit QQuickScreenWindow(QQuickWindow *parent = 0);34 explicit QQuickScreenWindow(QQuickWindow *parent = 0);
@@ -37,13 +37,13 @@
37 void setScreen(QScreen *screen);37 void setScreen(QScreen *screen);
3838
39 qreal scale();39 qreal scale();
40 Screens::FormFactor formFactor();40 FormFactor formFactor();
41 Q_INVOKABLE bool setScaleAndFormFactor(const float scale, const Screens::FormFactor formFactor);41 Q_INVOKABLE bool setScaleAndFormFactor(const float scale, const FormFactor formFactor);
4242
43Q_SIGNALS:43Q_SIGNALS:
44 void screenChanged(QScreen *screen);44 void screenChanged(QScreen *screen);
45 void scaleChanged(qreal scale);45 void scaleChanged(qreal scale);
46 void formFactorChanged(Screens::FormFactor arg);46 void formFactorChanged(FormFactor arg);
4747
48private Q_SLOTS:48private Q_SLOTS:
49 void nativePropertyChanged(QPlatformWindow *window, const QString &propertyName);49 void nativePropertyChanged(QPlatformWindow *window, const QString &propertyName);
@@ -51,8 +51,8 @@
51private:51private:
52 float getScaleNativeProperty() const;52 float getScaleNativeProperty() const;
53 float m_scale;53 float m_scale;
54 Screens::FormFactor getFormFactorNativeProperty() const;54 FormFactor getFormFactorNativeProperty() const;
55 Screens::FormFactor m_formFactor;55 FormFactor m_formFactor;
56};56};
5757
58} //namespace qtmir58} //namespace qtmir
5959
=== modified file 'src/modules/Unity/Screens/screens.cpp'
--- src/modules/Unity/Screens/screens.cpp 2016-04-29 15:41:00 +0000
+++ src/modules/Unity/Screens/screens.cpp 2016-12-16 08:22:54 +0000
@@ -62,7 +62,7 @@
62 case OutputTypeRole: {62 case OutputTypeRole: {
63 auto screen = static_cast<Screen*>(m_screenList.at(index.row())->handle());63 auto screen = static_cast<Screen*>(m_screenList.at(index.row())->handle());
64 if (screen) {64 if (screen) {
65 return QVariant(static_cast<OutputTypes>(screen->outputType())); //FIXME: cheeky65 return QVariant(screen->outputType());
66 } else {66 } else {
67 return OutputTypes::Unknown;67 return OutputTypes::Unknown;
68 }68 }
6969
=== modified file 'src/modules/Unity/Screens/screens.h'
--- src/modules/Unity/Screens/screens.h 2016-04-29 15:41:00 +0000
+++ src/modules/Unity/Screens/screens.h 2016-12-16 08:22:54 +0000
@@ -17,6 +17,8 @@
17#ifndef SCREENS_H17#ifndef SCREENS_H
18#define SCREENS_H18#define SCREENS_H
1919
20#include "screentypes.h"
21
20#include <QAbstractListModel>22#include <QAbstractListModel>
2123
22class QScreen;24class QScreen;
@@ -39,33 +41,6 @@
39 FormFactorRole,41 FormFactorRole,
40 };42 };
4143
42 enum OutputTypes {
43 Unknown,
44 VGA,
45 DVII,
46 DVID,
47 DVIA,
48 Composite,
49 SVideo,
50 LVDS,
51 Component,
52 NinePinDIN,
53 DisplayPort,
54 HDMIA,
55 HDMIB,
56 TV,
57 EDP
58 };
59
60 enum FormFactor {
61 FormFactorUnknown,
62 FormFactorPhone,
63 FormFactorTablet,
64 FormFactorMonitor,
65 FormFactorTV,
66 FormFactorProjector,
67 };
68
69 explicit Screens(QObject *parent = 0);44 explicit Screens(QObject *parent = 0);
70 virtual ~Screens() noexcept = default;45 virtual ~Screens() noexcept = default;
7146
@@ -91,6 +66,4 @@
9166
92} // namespace qtmir67} // namespace qtmir
9368
94Q_DECLARE_METATYPE(qtmir::Screens::FormFactor)
95
96#endif // SCREENS_H69#endif // SCREENS_H
9770
=== modified file 'src/platforms/mirserver/CMakeLists.txt'
--- src/platforms/mirserver/CMakeLists.txt 2016-09-08 22:46:57 +0000
+++ src/platforms/mirserver/CMakeLists.txt 2016-12-16 08:22:54 +0000
@@ -25,11 +25,11 @@
2525
26include_directories(26include_directories(
27 ${CMAKE_SOURCE_DIR}/src/common27 ${CMAKE_SOURCE_DIR}/src/common
28
29)28)
3029
31include_directories(30include_directories(
32 SYSTEM31 SYSTEM
32 ${MIRAL_INCLUDE_DIRS}
33 ${MIRCOMMON_INCLUDE_DIRS}33 ${MIRCOMMON_INCLUDE_DIRS}
34 ${MIRSERVER_INCLUDE_DIRS}34 ${MIRSERVER_INCLUDE_DIRS}
35 ${MIRRENDERERGLDEV_INCLUDE_DIRS}35 ${MIRRENDERERGLDEV_INCLUDE_DIRS}
@@ -53,56 +53,70 @@
53# Needed to compile tracepoints in C99 mode.53# Needed to compile tracepoints in C99 mode.
54add_definitions(-DBYTE_ORDER=__BYTE_ORDER)54add_definitions(-DBYTE_ORDER=__BYTE_ORDER)
5555
56set(MIRSERVER_QPA_PLUGIN_SRC56# These files will compile without mirserver-dev
57 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp57add_library(qpa-mirserver-nomirserver OBJECT
58 ${CMAKE_SOURCE_DIR}/src/common/timestamp.cpp58 ${CMAKE_SOURCE_DIR}/src/common/timestamp.cpp
59 cursor.cpp
60 eventbuilder.cpp
61 logging.cpp59 logging.cpp
60 plugin.cpp
61 shelluuid.cpp
62 ubuntutheme.cpp
63 clipboard.cpp
64 openglcontextfactory.cpp openglcontextfactory.h
62 mircursorimages.cpp65 mircursorimages.cpp
63 mirdisplayconfigurationpolicy.cpp66 mirdisplayconfigurationpolicy.cpp
64 mirwindowmanager.cpp
65 mirsingleton.cpp67 mirsingleton.cpp
68 sessionauthorizer.cpp
69 promptsessionlistener.cpp
70 mirserverstatuslistener.cpp
71 screenscontroller.cpp
72 nativeinterface.cpp
73 qtcompositor.cpp
74 services.cpp
75 windowcontroller.cpp
76 windowmanagementpolicy.cpp
77 mirserverhooks.cpp mirserverhooks.h
78 setqtcompositor.cpp setqtcompositor.h
79 tracepoints.c
80# We need to run moc on these headers
81 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
82 ${CMAKE_SOURCE_DIR}/src/common/appnotifier.h
83 ${CMAKE_SOURCE_DIR}/src/common/windowcontrollerinterface.h
84 ${CMAKE_SOURCE_DIR}/src/common/windowmodelnotifier.h
85)
86set_source_files_properties(tracepoints.c PROPERTIES COMPILE_FLAGS "${CMAKE_CFLAGS} -fPIC")
87
88include_directories(SYSTEM ${MIRSERVER_INCLUDE_DIRS})
89
90set(MIRSERVER_QPA_PLUGIN_SRC
91 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
92 cursor.cpp
93 eventbuilder.cpp
66 qteventfeeder.cpp94 qteventfeeder.cpp
67 plugin.cpp
68 qmirserver.cpp95 qmirserver.cpp
69 qmirserver_p.cpp96 qmirserver_p.cpp
70 sessionauthorizer.cpp
71 sessionlistener.cpp
72 shelluuid.cpp
73 surfaceobserver.cpp97 surfaceobserver.cpp
74 promptsessionlistener.cpp
75 mirserver.cpp
76 mirserverstatuslistener.cpp
77 screen.cpp98 screen.cpp
78 screenwindow.cpp99 screenwindow.cpp
79 screenscontroller.cpp
80 screensmodel.cpp100 screensmodel.cpp
81 mirserverintegration.cpp101 mirserverintegration.cpp
82 miropenglcontext.cpp102 miropenglcontext.cpp
83 nativeinterface.cpp
84 offscreensurface.cpp103 offscreensurface.cpp
85 qtcompositor.cpp104 promptsessionmanager.cpp promptsessionmanager.h promptsession.h
86 services.cpp
87 ubuntutheme.cpp
88 clipboard.cpp
89 creationhints.cpp
90 tracepoints.c
91# We need to run moc on these headers105# We need to run moc on these headers
92 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
93 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h106 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h
94 )107)
95108
96add_library(qpa-mirserver SHARED109add_library(qpa-mirserver SHARED
97 ${MIRSERVER_QPA_PLUGIN_SRC}110 ${MIRSERVER_QPA_PLUGIN_SRC}
111 $<TARGET_OBJECTS:qpa-mirserver-nomirserver>
98)112)
99113
100target_link_libraries(114target_link_libraries(
101 qpa-mirserver115 qpa-mirserver
102 Qt5PlatformSupport116 Qt5PlatformSupport
103117
118 ${MIRAL_LDFLAGS}
104 ${MIRSERVER_LDFLAGS}119 ${MIRSERVER_LDFLAGS}
105 ${MIRCLIENT_LDFLAGS}
106 ${URL_DISPATCHER_LDFLAGS}120 ${URL_DISPATCHER_LDFLAGS}
107 ${EGL_LDFLAGS}121 ${EGL_LDFLAGS}
108 ${GL_LIBRARIES}122 ${GL_LIBRARIES}
109123
=== removed file 'src/platforms/mirserver/creationhints.cpp'
--- src/platforms/mirserver/creationhints.cpp 2016-06-06 19:25:20 +0000
+++ src/platforms/mirserver/creationhints.cpp 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <mir/scene/surface_creation_parameters.h>
18
19#include "creationhints.h"
20
21using namespace qtmir;
22
23inline const char* shellChromeToString(Mir::ShellChrome chrome) {
24 switch (chrome) {
25 case Mir::ShellChrome::NormalChrome:
26 return "normal";
27 case Mir::ShellChrome::LowChrome:
28 return "low";
29 }
30 return "unknown";
31}
32
33CreationHints::CreationHints(const mir::scene::SurfaceCreationParameters &params)
34{
35 minWidth = params.min_width.is_set() ? params.min_width.value().as_int() : 0;
36 maxWidth = params.max_width.is_set() ? params.max_width.value().as_int() : 0;
37
38 minHeight = params.min_height.is_set() ? params.min_height.value().as_int() : 0;
39 maxHeight = params.max_height.is_set() ? params.max_height.value().as_int() : 0;
40
41 widthIncrement = params.width_inc.is_set() ? params.width_inc.value().as_int() : 0;
42 heightIncrement = params.height_inc.is_set() ? params.height_inc.value().as_int() : 0;
43
44 if (params.shell_chrome.is_set()) {
45 switch (params.shell_chrome.value()) {
46 case mir_shell_chrome_normal:
47 default:
48 shellChrome = Mir::ShellChrome::NormalChrome;
49 break;
50 case mir_shell_chrome_low:
51 shellChrome = Mir::ShellChrome::LowChrome;
52 break;
53 }
54 }
55}
56
57QString CreationHints::toString() const
58{
59 return QStringLiteral("CreationHints(minW=%1,minH=%2,maxW=%3,maxH=%4,wIncr=%5,hInc=%6,shellChrome=%7)")
60 .arg(minWidth)
61 .arg(minHeight)
62 .arg(maxWidth)
63 .arg(maxHeight)
64 .arg(widthIncrement)
65 .arg(heightIncrement)
66 .arg(shellChromeToString(shellChrome));
67}
680
=== removed file 'src/platforms/mirserver/creationhints.h'
--- src/platforms/mirserver/creationhints.h 2016-06-06 19:25:20 +0000
+++ src/platforms/mirserver/creationhints.h 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef QTMIR_CREATIONHINTS_H
18#define QTMIR_CREATIONHINTS_H
19
20#include <QMetaType>
21#include <QString>
22
23#include <unity/shell/application/Mir.h>
24
25namespace mir {
26 namespace scene {
27 struct SurfaceCreationParameters;
28 }
29}
30
31namespace qtmir {
32
33class CreationHints {
34public:
35 CreationHints() {}
36 CreationHints(const mir::scene::SurfaceCreationParameters&);
37
38 QString toString() const;
39
40 int minWidth{0};
41 int maxWidth{0};
42
43 int minHeight{0};
44 int maxHeight{0};
45
46 int widthIncrement{0};
47 int heightIncrement{0};
48
49 Mir::ShellChrome shellChrome{Mir::ShellChrome::NormalChrome};
50};
51
52} // namespace qtmir
53
54Q_DECLARE_METATYPE(qtmir::CreationHints)
55
56#endif // QTMIR_CREATIONHINTS_H
570
=== modified file 'src/platforms/mirserver/cursor.cpp'
--- src/platforms/mirserver/cursor.cpp 2016-08-08 13:10:40 +0000
+++ src/platforms/mirserver/cursor.cpp 2016-12-16 08:22:54 +0000
@@ -69,7 +69,7 @@
69 // just different from the previous custom cursor name, which is enough to trigger a change in the cursor69 // just different from the previous custom cursor name, which is enough to trigger a change in the cursor
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.
71 static quint8 serialNumber = 1;71 static quint8 serialNumber = 1;
72 m_qtCursorName = QStringLiteral("custom%1").arg(serialNumber++);72 m_qtCursorName = QString("custom%1").arg(serialNumber++);
73 m_mousePointer->setCustomCursor(*windowCursor);73 m_mousePointer->setCustomCursor(*windowCursor);
74 }74 }
75 } else {75 } else {
7676
=== modified file 'src/platforms/mirserver/customscreenconfiguration.h'
--- src/platforms/mirserver/customscreenconfiguration.h 2016-01-11 14:29:06 +0000
+++ src/platforms/mirserver/customscreenconfiguration.h 2016-12-16 08:22:54 +0000
@@ -20,11 +20,13 @@
20#include <QPoint>20#include <QPoint>
21#include <QVector>21#include <QVector>
2222
23#include <mir/graphics/display_configuration.h>23#include "screentypes.h"
24#include <mir_toolkit/common.h>
25
2426
25struct CustomScreenConfiguration27struct CustomScreenConfiguration
26{28{
27 mir::graphics::DisplayConfigurationOutputId id;29 qtmir::OutputId id;
2830
29 QPoint topLeft;31 QPoint topLeft;
30 uint32_t currentModeIndex;32 uint32_t currentModeIndex;
3133
=== modified file 'src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp'
--- src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp 2016-04-29 15:41:00 +0000
+++ src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp 2016-12-16 08:22:54 +0000
@@ -16,8 +16,10 @@
1616
17#include "mirdisplayconfigurationpolicy.h"17#include "mirdisplayconfigurationpolicy.h"
1818
19#include <mir/graphics/display_configuration_policy.h>
19#include <mir/graphics/display_configuration.h>20#include <mir/graphics/display_configuration.h>
20#include <mir/geometry/point.h>21#include <mir/geometry/point.h>
22#include <mir/server.h>
2123
22#include <qglobal.h>24#include <qglobal.h>
23#include <QByteArray>25#include <QByteArray>
@@ -28,6 +30,18 @@
28#define DEFAULT_GRID_UNIT_PX 830#define DEFAULT_GRID_UNIT_PX 8
2931
30namespace {32namespace {
33class MirDisplayConfigurationPolicy : public mir::graphics::DisplayConfigurationPolicy
34{
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches