Merge lp:~dandrader/qtmir/supportedOrientations into lp:qtmir

Proposed by Daniel d'Andrada on 2014-11-19
Status: Merged
Approved by: Gerry Boland on 2015-04-16
Approved revision: 303
Merged at revision: 340
Proposed branch: lp:~dandrader/qtmir/supportedOrientations
Merge into: lp:qtmir
Diff against target: 594 lines (+238/-94)
12 files modified
CMakeLists.txt (+3/-1)
debian/changelog (+6/-0)
debian/control (+2/-2)
src/modules/Unity/Application/CMakeLists.txt (+0/-1)
src/modules/Unity/Application/application.cpp (+9/-7)
src/modules/Unity/Application/application.h (+4/-15)
src/modules/Unity/Application/application_manager.cpp (+0/-34)
src/modules/Unity/Application/desktopfilereader.cpp (+96/-0)
src/modules/Unity/Application/desktopfilereader.h (+5/-0)
src/modules/Unity/Application/mirsurfaceitem.cpp (+22/-29)
src/modules/Unity/Application/mirsurfaceitem.h (+21/-5)
tests/modules/DesktopFileReader/desktopfilereader_test.cpp (+70/-0)
To merge this branch: bzr merge lp:~dandrader/qtmir/supportedOrientations
Reviewer Review Type Date Requested Status
Michał Sawicz Approve on 2015-04-16
Gerry Boland 2014-11-19 Approve on 2015-04-16
PS Jenkins bot continuous-integration Needs Fixing on 2015-04-13
Review via email: mp+242213@code.launchpad.net

Commit Message

X-Ubuntu-Supported-Orientations and X-Ubuntu-Rotates-Window-Contents desktop entries

With the corresponding ApplicationInfo.supportedOrientations and
ApplicationInfo.rotatesWindowContents properties

MirSurfaceItem was also changed to hold an orientationAngle instead
of an orientation as that maps directly to the corresponding
Mir surface property, making the whole thing easier/simpler.

Description of the Change

* Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~dandrader/unity-api/shellRotation/+merge/242212
https://code.launchpad.net/~dandrader/qtubuntu/shellRotation/+merge/242215
https://code.launchpad.net/~phablet-team/ubuntu-keyboard/shellRotation
https://code.launchpad.net/~dandrader/ubuntu-ui-toolkit/shellRotation
https://code.launchpad.net/~unity-team/unity8/shellRotation

It's all in this PPA:
https://launchpad.net/~unity-team/+archive/ubuntu/demo-stuff

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Gerry Boland (gerboland) wrote :

I'm a teeny bit concerned with the name "X-Ubuntu-Rotates-Window-Contents" - is it obvious that you have a "window" on phablet? I'd almost read it as a switch to tell shell if it supports rotation at all or not.

s/Window/Surface/ maybe? Or Manage-Own-Orientation. Not sure. I won't block on this anyway.

+++ debian/changelog
+ * Add X-Ubuntu-Supported-Orientations desktop file entry
please mention the other desktop file entry and what they mean.

+ bool rotatesWindowContents() const override;
I'd rather not use term "Window" in qtmir, that's more a shell construct.

+++ src/modules/Unity/Application/desktopfilereader.cpp
+ Qt::ScreenOrientations result;
I'd prefer you set the default here, and if parseOrientations fails, it leaves it untouched.

+ bool result;
Same here.

- Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false)
+
+ // How many degrees, clockwise, the UI in the surface has to rotate to match with the
+ // shell UI orientation
+ Q_PROPERTY(int orientationAngle READ orientationAngle WRITE setOrientationAngle
+ NOTIFY orientationAngleChanged DESIGNABLE false)
I dislike the API as what if I call it with angle=30 - a warning is not enough. Would be better to define an enum which actually suits the task.

Looking good otherwise

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

On 19/11/14 15:16, Gerry Boland wrote:
> +++ src/modules/Unity/Application/desktopfilereader.cpp
> + Qt::ScreenOrientations result;
> I'd prefer you set the default here, and if parseOrientations fails, it leaves it untouched.
I disagree. The default value is a policy thing, which has nothing to do
with ".desktop" file parsing. Thus I would rather have it at a higher level.

Gerry Boland (gerboland) wrote :

> On 19/11/14 15:16, Gerry Boland wrote:
> > +++ src/modules/Unity/Application/desktopfilereader.cpp
> > + Qt::ScreenOrientations result;
> > I'd prefer you set the default here, and if parseOrientations fails, it
> leaves it untouched.
> I disagree. The default value is a policy thing, which has nothing to do
> with ".desktop" file parsing. Thus I would rather have it at a higher level.

So you want to advertise to the higher level that the parsing failed? But 0 = Qt::PrimaryOrientation. Are you using that enum to advertise failure?

Why not a sensible default of all orientations supported, if the parsing fails? That's our default anyway, no?

Daniel d'Andrada (dandrader) wrote :

On 20/11/14 11:14, Gerry Boland wrote:
>> On 19/11/14 15:16, Gerry Boland wrote:
>>> +++ src/modules/Unity/Application/desktopfilereader.cpp
>>> + Qt::ScreenOrientations result;
>>> I'd prefer you set the default here, and if parseOrientations fails, it
>> leaves it untouched.
>> I disagree. The default value is a policy thing, which has nothing to do
>> with ".desktop" file parsing. Thus I would rather have it at a higher level.
> So you want to advertise to the higher level that the parsing failed? But 0 = Qt::PrimaryOrientation. Are you using that enum to advertise failure?

Yes, to advertise that the desktop entry is either not present or is
invalid. But that won't cut it anymore as I'm thinking we will want to
have "primary" as a valid entry value as well.

>
> Why not a sensible default of all orientations supported, if the parsing fails? That's our default anyway, no?
Now that we will want "primary" as a valid desktop entry value as well,
that seems to be the easiest way to proceed. Otherwise we would have to
return -1 or a separate boolean for informing success/failure.

Gerry Boland (gerboland) wrote :

> On 20/11/14 11:14, Gerry Boland wrote:
> >> On 19/11/14 15:16, Gerry Boland wrote:
> >>> +++ src/modules/Unity/Application/desktopfilereader.cpp
> >>> + Qt::ScreenOrientations result;
> >>> I'd prefer you set the default here, and if parseOrientations fails, it
> >> leaves it untouched.
> >> I disagree. The default value is a policy thing, which has nothing to do
> >> with ".desktop" file parsing. Thus I would rather have it at a higher
> level.
> > So you want to advertise to the higher level that the parsing failed? But 0
> = Qt::PrimaryOrientation. Are you using that enum to advertise failure?
>
> Yes, to advertise that the desktop entry is either not present or is
> invalid. But that won't cut it anymore as I'm thinking we will want to
> have "primary" as a valid entry value as well.

Why?

> > Why not a sensible default of all orientations supported, if the parsing
> fails? That's our default anyway, no?
> Now that we will want "primary" as a valid desktop entry value as well,
> that seems to be the easiest way to proceed. Otherwise we would have to
> return -1 or a separate boolean for informing success/failure.

Which is why I think just using a fallback to all orientations is much easier, than trying to pass an error state up to the shell. I'm not sure what the shell can really do with that error state anyway.

Daniel d'Andrada (dandrader) wrote :

On 20/11/14 13:04, Gerry Boland wrote:
>>> > > Why not a sensible default of all orientations supported, if the parsing
>> > fails? That's our default anyway, no?
>> > Now that we will want "primary" as a valid desktop entry value as well,
>> > that seems to be the easiest way to proceed. Otherwise we would have to
>> > return -1 or a separate boolean for informing success/failure.
> Which is why I think just using a fallback to all orientations is much easier, than trying to pass an error state up to the shell. I'm not sure what the shell can really do with that error state anyway.
Not up to shell. Up to ApplicationInfo.

Daniel d'Andrada (dandrader) wrote :

On 20/11/14 13:04, Gerry Boland wrote:
>> Yes, to advertise that the desktop entry is either not present or is
>> > invalid. But that won't cut it anymore as I'm thinking we will want to
>> > have "primary" as a valid entry value as well.
> Why?
>
>
For the Dash desktop entry, for instance. it's landscape in tablets and
portrait in phones. So its supported orientation is "primary".

284. By Daniel d'Andrada on 2014-11-24

DesktopFileReader: "primary" is also a valid orientation string

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
285. By Daniel d'Andrada on 2014-11-27

Fix default orientations and add a bit of debugging

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
286. By Daniel d'Andrada on 2014-11-28

Merge trunk

[ Alberto Aguirre ]
* No-change rebuild againts mir 0.9.0
[ Ubuntu daily release ]
* New rebuild forced

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Gerry Boland (gerboland) wrote :

"No use for ApplicationManager ExecFlags anymore" - this could have been done in a separate MR. Please separate.

My objection to
- Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false)
+
+ // How many degrees, clockwise, the UI in the surface has to rotate to match with the
+ // shell UI orientation
+ Q_PROPERTY(int orientationAngle READ orientationAngle WRITE setOrientationAngle
+ NOTIFY orientationAngleChanged DESIGNABLE false)
remains. Using an int to describe 4 states is not good api design IMO. An enum would work better.

review: Needs Fixing
287. By Daniel d'Andrada on 2014-12-03

Remove side stage decision override

288. By Daniel d'Andrada on 2014-12-09

Make MirsufaceItem::orientationAngle use an enum

Daniel d'Andrada (dandrader) wrote :

> "No use for ApplicationManager ExecFlags anymore" - this could have been done
> in a separate MR. Please separate.
>
> My objection to
> - Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE
> setOrientation NOTIFY orientationChanged DESIGNABLE false)
> +
> + // How many degrees, clockwise, the UI in the surface has to rotate to match
> with the
> + // shell UI orientation
> + Q_PROPERTY(int orientationAngle READ orientationAngle WRITE
> setOrientationAngle
> + NOTIFY orientationAngleChanged DESIGNABLE false)
> remains. Using an int to describe 4 states is not good api design IMO. An enum
> would work better.

All done.

289. By Daniel d'Andrada on 2014-12-09

declare a metatype for the new enum

290. By Daniel d'Andrada on 2014-12-09

Merge trunk

[ CI Train Bot ]
* Resync trunk
* Resync trunk
* Resync trunk
* Resync trunk
* Resync trunk
[ Ricardo Salveti de Araujo ]
* qteventfeeder: adding bt and wired headset multimedia keys (LP:
  #1398427)
[ Gerry Boland ]
* Port qmake->cmake to enable sbuild usage for crosscompiling.
* Fix build with Qt5.4 (LP: #1394884)
[ Michał Sawicz ]
* Port qmake->cmake to enable sbuild usage for crosscompiling.
[ Robert Carr ]
* Port qmake->cmake to enable sbuild usage for crosscompiling.
[ Alberto Aguirre ]
* Select mirclient backend for platform-api instead of mirserver.

Gerry Boland (gerboland) wrote :

Code looks good, will test when PPA has all built

review: Approve (code)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
291. By Daniel d'Andrada on 2015-01-12

Merge trunk

[ Ubuntu daily release ]
* New rebuild forced
[ Nick Dedekind ]
* Notify prompt sessions that sessions have been suspended/resumed.
  (LP: #1355173, #1384950)
[ Ubuntu daily release ]
* New rebuild forced
[ Cemil Azizoglu ]
* Rebuild for Mir 0.10.
[ Nick Dedekind ]
* Compatibility for Mir 0.10.0
[ Daniel d'Andrada ]
* Update README and readd option to disable building tests
[ Gerry Boland ]
* Emit SIGSTOP when AppMan fully initialized, when Mir is ready is too
  soon (LP: #1394208)
[ Ubuntu daily release ]
* New rebuild forced
[ Alan Griffiths ]
* Migration of qtmir from the legacy Mir API
* Refactor to better reflect the code structure following new-migrate-
  to-mir-Server-API

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
292. By Daniel d'Andrada on 2015-01-15

Merge trunk

[ Gerry Boland ]
* Depend on :native version of g++ to allow cross-compiling to work.
  (LP: #1353855)
[ Michał Sawicz ]
* Declare the QByteArray in callDispatcher so it doesn't get deleted
  before it's copied. (LP: #1408819)
[ Josh Arenson ]
* Assign touch events area to the correct values.
[ Albert Astals ]
* Move the creation of the surface observer to
  SessionListener::surface_created

293. By Daniel d'Andrada on 2015-01-15

Remove :native

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
294. By Daniel d'Andrada on 2015-01-19

Merge trunk

[ Gerry Boland ]
* Add Wakelock support - ensures device drops to deep-sleep mode only
  when all AppMan suspend tasks have completed
[ Ricardo Mendoza ]
* Reduce suspend timeout to half of the previous value because the
  long value was too apparent on fast paced apps, like web games of
  music players; it broke the user experience according to design.
  (LP: #1402650)

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
295. By Daniel d'Andrada on 2015-01-27

Don't suspend&resume the main stage app when switching focus from side to main stage

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
296. By Daniel d'Andrada on 2015-02-11

Merge trunk

[ Daniel van Vugt ]
* QtMir changes required to support the Mir branch of the same name.
  Landing soon. (LP: #1395581)
[ Alan Griffiths ]
* Port to the msh::Shell API in Mir
[ Robert Carr ]
* Bump build-dep to mir 0.11.
[ Gerry Boland ]
* Explicitly setting GL-mode breaks GTK app rendering. Removing the
  hack appears to just work (LP: #1401968)
[ Michał Sawicz ]
* Add moot autopkgtest to run the standard unit tests
[ Albert Astals Cid ]
* Fix demo shell import name
[ Daniel d'Andrada ]
* Don't suspend&resume the main stage app when switching focus from
  side to main stage

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Michał Sawicz (saviq) wrote :

Please merge:
https://code.launchpad.net/~saviq/qtmir/fix-application-api-deps/+merge/255839

And apply:
http://paste.ubuntu.com/10792055/

Otherwise there's broken dependencies between the packages and the test didn't build.

review: Needs Fixing
297. By Daniel d'Andrada on 2015-04-10

Merge trunk

298. By Daniel d'Andrada on 2015-04-10

Merge lp:~saviq/qtmir/fix-application-api-deps

299. By Michał Sawicz on 2015-04-10

Saviq's changes

Daniel d'Andrada (dandrader) wrote :

> Please merge:
> https://code.launchpad.net/~saviq/qtmir/fix-application-api-deps/+merge/255839
>
> And apply:
> http://paste.ubuntu.com/10792055/
>
> Otherwise there's broken dependencies between the packages and the test didn't
> build.

Done.

Michał Sawicz (saviq) :
review: Abstain
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Michał Sawicz (saviq) wrote :

The DesktopFileReader test failed:

[ RUN ] DesktopFileReader.parseBoolean
/build/buildd/qtmir-0.4.5.4+bzr299~ubuntu15.04.1/tests/modules/DesktopFileReader/desktopfilereader_test.cpp:189: Failure
Value of: boolean
  Actual: true
Expected: false
[ FAILED ] DesktopFileReader.parseBoolean (0 ms)
qtmir.applications: Loading desktop file "/build/buildd/qtmir-0.4.5.4+bzr299~ubuntu15.04.1/tests/modules/DesktopFileReader/calculator.desktop" for appId "calculator"
qtmir.applications: Loading desktop file "/build/buildd/qtmir-0.4.5.4+bzr299~ubuntu15.04.1/tests/modules/DesktopFileReader/calculator.desktop" for appId "calculator"
qtmir.applications: Loading desktop file "/build/buildd/qtmir-0.4.5.4+bzr299~ubuntu15.04.1/tests/modules/DesktopFileReader/missing.desktop" for appId "calculator"
qtmir.applications: Desktop file for appId: "calculator" at: "/build/buildd/qtmir-0.4.5.4+bzr299~ubuntu15.04.1/tests/modules/DesktopFileReader/missing.desktop" does not exist
qtmir.applications: Loading desktop file "/build/buildd/qtmir-0.4.5.4+bzr299~ubuntu15.04.1/tests/modules/DesktopFileReader/calculator.desktop" for appId "calculator"

review: Needs Fixing
300. By Daniel d'Andrada on 2015-04-13

Tests also need to be pointed to the location of unity-api headers

301. By Daniel d'Andrada on 2015-04-13

Fix bug in Saviq's patch

Daniel d'Andrada (dandrader) wrote :

> The DesktopFileReader test failed:
>
> [ RUN ] DesktopFileReader.parseBoolean
> /build/buildd/qtmir-0.4.5.4+bzr299~ubuntu15.04.1/tests/modules/DesktopFileRead
> er/desktopfilereader_test.cpp:189: Failure
> Value of: boolean
> Actual: true
> Expected: false
> [ FAILED ] DesktopFileReader.parseBoolean (0 ms)

Fixed. Your patch caused it!

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Michał Sawicz (saviq) :
review: Abstain
302. By Daniel d'Andrada on 2015-04-16

Put g++-4.9:native back

303. By Daniel d'Andrada on 2015-04-16

Update changelog date & time

Gerry Boland (gerboland) :
review: Approve
Michał Sawicz (saviq) wrote :

Does this include an option for the app to only support native orientation?

review: Needs Fixing
Michał Sawicz (saviq) wrote :

Ah, *primary*, not native :), as you were.

Daniel d'Andrada (dandrader) wrote :

On 16/04/15 13:35, Michał Sawicz wrote:
>> > === modified file 'CMakeLists.txt'
>> > --- CMakeLists.txt 2015-03-18 10:12:16 +0000
>> > +++ CMakeLists.txt 2015-04-16 16:26:05 +0000
>> > @@ -79,6 +79,7 @@
>> > pkg_check_modules(LTTNG lttng-ust)
>> > pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
>> > pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
>> > +pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=6)
> This somewhat conflicts with the changes in lp:~saviq/qtmir/fix-application-api-deps...
>
It's needed when unity-api is installed somewhere other than /usr.

This pkg_check_modules call has to be in the root dir otherwise I'll have to repeat it in several test dirs in addition to src dir. Repetition is bad in my book. It gets particularly tedious when you have to bump the API number.

Michał Sawicz (saviq) wrote :

OK, resolved.

review: Approve
304. By Daniel d'Andrada on 2015-05-13

Merge trunk

[ Albert Astals Cid ]
* Fix debug line
[ Daniel d'Andrada ]
* When synthesizing touch releases for absent touches, send them in
  separate events (LP: #1437357)
[ Gerry Boland ]
* If Mir fails to start, exit the process immediately as nothing else
  can be done
* Remove boost dependence, it supplies almost nothing of benefit to
  offset its cost
* Remove legacy surface configuration change code, use newer
  SurfaceObserver
* Remove useless profiling information, fixes build with Qt5.5 (LP:
  #1437181)
[ Michael Zanetti ]
* read exception list from gsettings instead of a hardcoded list
[ Michał Sawicz ]
* Require an application API version, fix the provided version and use
  include dir from the .pc file

305. By Daniel d'Andrada on 2015-05-21

Merge trunk

[ Alan Griffiths ]
* Release in step with Mir 0.13.0
[ Daniel van Vugt ]
* Release in step with Mir 0.13.0
[ Gerry Boland ]
* Release in step with Mir 0.13.0

306. By Daniel d'Andrada on 2015-05-21

One include_directories(${APPLICATION_API_INCLUDE_DIRS}) to rule them all

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-05-13 09:40:03 +0000
3+++ CMakeLists.txt 2015-05-21 18:49:54 +0000
4@@ -80,10 +80,12 @@
5 pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
6 pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
7 pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
8-pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
9+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=6)
10
11 add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)
12
13+include_directories( ${APPLICATION_API_INCLUDE_DIRS} )
14+
15 # We expect this to be set via debian/rules for GLES builds
16 if ("${USE_OPENGLES}" STREQUAL 1)
17 message(STATUS "Qt5 determined to be compiled with GLES support")
18
19=== modified file 'debian/changelog'
20--- debian/changelog 2015-05-13 09:44:13 +0000
21+++ debian/changelog 2015-05-21 18:49:54 +0000
22@@ -1,3 +1,9 @@
23+qtmir (0.4.5) UNRELEASED; urgency=medium
24+
25+ * Add X-Ubuntu-Supported-Orientations desktop file entry
26+
27+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Thu, 16 Apr 2015 13:25:08 -0300
28+
29 qtmir (0.4.4+15.04.20150513-0ubuntu1) vivid; urgency=medium
30
31 [ Alan Griffiths ]
32
33=== modified file 'debian/control'
34--- debian/control 2015-05-13 09:40:03 +0000
35+++ debian/control 2015-05-21 18:49:54 +0000
36@@ -28,7 +28,7 @@
37 libubuntu-app-launch2-dev,
38 libubuntu-application-api-dev (>= 2.1.0),
39 libudev-dev,
40- libunity-api-dev (>= 7.92),
41+ libunity-api-dev (>= 7.97),
42 liburl-dispatcher1-dev,
43 libxkbcommon-dev,
44 libxrender-dev,
45@@ -99,7 +99,7 @@
46 Conflicts: libqtmir,
47 libunity-mir1,
48 Provides: unity-application-impl,
49- unity-application-impl-5,
50+ unity-application-impl-6,
51 Description: Qt plugin for Unity specific Mir APIs
52 QtMir provides Qt/QML bindings for Mir features that are exposed through the
53 qtmir-desktop or qtmir-android QPA plugin such as Application management
54
55=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
56--- src/modules/Unity/Application/CMakeLists.txt 2015-05-13 09:40:03 +0000
57+++ src/modules/Unity/Application/CMakeLists.txt 2015-05-21 18:49:54 +0000
58@@ -1,5 +1,4 @@
59 include_directories(
60- ${APPLICATION_API_INCLUDE_DIRS}
61 ${GLIB_INCLUDE_DIRS}
62 ${GIO_INCLUDE_DIRS}
63 ${GIO_UNIX_INCLUDE_DIRS}
64
65=== modified file 'src/modules/Unity/Application/application.cpp'
66--- src/modules/Unity/Application/application.cpp 2015-02-26 16:07:10 +0000
67+++ src/modules/Unity/Application/application.cpp 2015-05-21 18:49:54 +0000
68@@ -60,12 +60,9 @@
69 // FIXME(greyback) need to save long appId internally until ubuntu-app-launch can hide it from us
70 m_longAppId = desktopFileReader->file().remove(QRegExp(".desktop$")).split('/').last();
71
72- // FIXME: This is a hack. Remove once we have a real implementation for knowing the supported
73- // orientations of an app
74- m_supportedOrientations = PortraitOrientation
75- | LandscapeOrientation
76- | InvertedPortraitOrientation
77- | InvertedLandscapeOrientation;
78+ m_supportedOrientations = m_desktopData->supportedOrientations();
79+
80+ m_rotatesWindowContents = m_desktopData->rotatesWindowContents();
81 }
82
83 Application::~Application()
84@@ -355,11 +352,16 @@
85 return m_longAppId;
86 }
87
88-Application::SupportedOrientations Application::supportedOrientations() const
89+Qt::ScreenOrientations Application::supportedOrientations() const
90 {
91 return m_supportedOrientations;
92 }
93
94+bool Application::rotatesWindowContents() const
95+{
96+ return m_rotatesWindowContents;
97+}
98+
99 Session* Application::session() const
100 {
101 return m_session;
102
103=== modified file 'src/modules/Unity/Application/application.h'
104--- src/modules/Unity/Application/application.h 2015-01-08 12:35:41 +0000
105+++ src/modules/Unity/Application/application.h 2015-05-21 18:49:54 +0000
106@@ -47,27 +47,15 @@
107 {
108 Q_OBJECT
109
110- Q_FLAGS(Orientation SupportedOrientations)
111-
112 Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT)
113 Q_PROPERTY(QString exec READ exec CONSTANT)
114 Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
115 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
116- Q_PROPERTY(SupportedOrientations supportedOrientations READ supportedOrientations CONSTANT)
117 Q_PROPERTY(Session* session READ session NOTIFY sessionChanged DESIGNABLE false)
118
119 public:
120 Q_DECLARE_FLAGS(Stages, Stage)
121
122- // Matching Qt::ScreenOrientation values for convenience
123- enum Orientation {
124- PortraitOrientation = 0x1,
125- LandscapeOrientation = 0x2,
126- InvertedPortraitOrientation = 0x4,
127- InvertedLandscapeOrientation = 0x8
128- };
129- Q_DECLARE_FLAGS(SupportedOrientations, Orientation)
130-
131 Application(const QSharedPointer<TaskController>& taskController,
132 const QSharedPointer<SharedWakelock>& sharedWakelock,
133 DesktopFileReader *desktopFileReader,
134@@ -90,6 +78,8 @@
135 QColor splashColor() const override;
136 QColor splashColorHeader() const override;
137 QColor splashColorFooter() const override;
138+ Qt::ScreenOrientations supportedOrientations() const override;
139+ bool rotatesWindowContents() const override;
140
141 void setStage(Stage stage);
142 void setState(State state);
143@@ -105,7 +95,6 @@
144 bool fullscreen() const;
145
146 Stages supportedStages() const;
147- SupportedOrientations supportedOrientations() const;
148
149 pid_t pid() const;
150
151@@ -140,7 +129,8 @@
152 bool m_focused;
153 bool m_canBeResumed;
154 QStringList m_arguments;
155- SupportedOrientations m_supportedOrientations;
156+ Qt::ScreenOrientations m_supportedOrientations;
157+ bool m_rotatesWindowContents;
158 Session *m_session;
159
160 friend class ApplicationManager;
161@@ -151,6 +141,5 @@
162 } // namespace qtmir
163
164 Q_DECLARE_METATYPE(qtmir::Application*)
165-Q_DECLARE_OPERATORS_FOR_FLAGS(qtmir::Application::SupportedOrientations)
166
167 #endif // APPLICATION_H
168
169=== modified file 'src/modules/Unity/Application/application_manager.cpp'
170--- src/modules/Unity/Application/application_manager.cpp 2015-05-13 09:40:03 +0000
171+++ src/modules/Unity/Application/application_manager.cpp 2015-05-21 18:49:54 +0000
172@@ -62,36 +62,6 @@
173
174 namespace {
175
176-// FIXME: AppManager should not implement policy based on display geometry, shell should do that
177-bool forceAllAppsIntoMainStage(const QSharedPointer<MirServer> &mirServer)
178-{
179- const int tabletModeMinimimWithGU = 100;
180-
181- // Obtain display size
182- //TODO: should use mir::graphics::Display::configuration
183- mir::geometry::Rectangles view_area;
184- mirServer->the_display()->for_each_display_sync_group(
185- [&view_area](mir::graphics::DisplaySyncGroup &group) {
186- group.for_each_display_buffer(
187- [&view_area](const mir::graphics::DisplayBuffer &db) {
188- view_area.add(db.view_area());
189- });
190- });
191-
192- // Get current Grid Unit value
193- int gridUnitPx = 8;
194- QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
195- if (!gridUnitString.isEmpty()) {
196- bool ok;
197- int value = gridUnitString.toInt(&ok);
198- if (ok) {
199- gridUnitPx = value;
200- }
201- }
202-
203- return (view_area.bounding_rectangle().size.width.as_int() < tabletModeMinimimWithGU * gridUnitPx);
204-}
205-
206 // FIXME: To be removed once shell has fully adopted short appIds!!
207 QString toShortAppIdIfPossible(const QString &appId) {
208 QRegExp longAppIdMask("[a-z0-9][a-z0-9+.-]+_[a-zA-Z0-9+.-]+_[0-9][a-zA-Z0-9.+:~-]*");
209@@ -556,10 +526,6 @@
210 return;
211 }
212
213- // override stage if necessary (i.e. side stage invalid on phone)
214- if (application->stage() == Application::SideStage && forceAllAppsIntoMainStage(m_mirServer))
215- application->setStage(Application::MainStage);
216-
217 add(application);
218 Q_EMIT focusRequested(appId);
219 }
220
221=== modified file 'src/modules/Unity/Application/desktopfilereader.cpp'
222--- src/modules/Unity/Application/desktopfilereader.cpp 2014-10-07 13:43:17 +0000
223+++ src/modules/Unity/Application/desktopfilereader.cpp 2015-05-21 18:49:54 +0000
224@@ -68,6 +68,8 @@
225 : d_ptr(new DesktopFileReaderPrivate(this))
226 {
227 Q_D(DesktopFileReader);
228+ qCDebug(QTMIR_APPLICATIONS) << "Loading desktop file" << desktopFile.absoluteFilePath()
229+ << "for appId" << appId;
230
231 d->appId = appId;
232 d->file = desktopFile.absoluteFilePath();
233@@ -202,6 +204,100 @@
234 return d->getKey("X-Ubuntu-Splash-Color-Footer");
235 }
236
237+Qt::ScreenOrientations DesktopFileReader::supportedOrientations() const
238+{
239+ Q_D(const DesktopFileReader);
240+ Qt::ScreenOrientations result;
241+
242+ if (!parseOrientations(d->getKey("X-Ubuntu-Supported-Orientations"), result)) {
243+ qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Supported-Orientations entry.";
244+ }
245+
246+ return result;
247+}
248+
249+bool DesktopFileReader::rotatesWindowContents() const
250+{
251+ Q_D(const DesktopFileReader);
252+ bool result;
253+
254+ if (!parseBoolean(d->getKey("X-Ubuntu-Rotates-Window-Contents"), result)) {
255+ qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Rotates-Window-Contents entry.";
256+ }
257+
258+ return result;
259+}
260+
261+bool DesktopFileReader::parseOrientations(const QString &rawString, Qt::ScreenOrientations &result)
262+{
263+ // Default to all orientations
264+ result = Qt::PortraitOrientation | Qt::LandscapeOrientation
265+ | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation;
266+
267+ if (rawString.isEmpty()) {
268+ return true;
269+ }
270+
271+ Qt::ScreenOrientations parsedOrientations = 0;
272+ bool ok = true;
273+
274+ QStringList orientationsList = rawString
275+ .simplified()
276+ .replace(QChar(','), ";")
277+ .remove(QChar(' '))
278+ .remove(QChar('-'))
279+ .remove(QChar('_'))
280+ .toLower()
281+ .split(";");
282+
283+ for (int i = 0; i < orientationsList.count() && ok; ++i) {
284+ const QString &orientationString = orientationsList.at(i);
285+ if (orientationString.isEmpty()) {
286+ // skip it
287+ continue;
288+ }
289+
290+ if (orientationString == "portrait") {
291+ parsedOrientations |= Qt::PortraitOrientation;
292+ } else if (orientationString == "landscape") {
293+ parsedOrientations |= Qt::LandscapeOrientation;
294+ } else if (orientationString == "invertedportrait") {
295+ parsedOrientations |= Qt::InvertedPortraitOrientation;
296+ } else if (orientationString == "invertedlandscape") {
297+ parsedOrientations |= Qt::InvertedLandscapeOrientation;
298+ } else if (orientationsList.count() == 1 && orientationString == "primary") {
299+ // Special case: primary orientation must be alone
300+ // There's no sense in supporting primary orientation + other orientations
301+ // like "primary,landscape"
302+ parsedOrientations = Qt::PrimaryOrientation;
303+ } else {
304+ ok = false;
305+ }
306+ }
307+
308+ if (ok) {
309+ result = parsedOrientations;
310+ }
311+
312+ return ok;
313+}
314+
315+bool DesktopFileReader::parseBoolean(const QString &rawString, bool &result)
316+{
317+ QString cookedString = rawString.trimmed().toLower();
318+
319+ result = cookedString == "y"
320+ || cookedString == "1"
321+ || cookedString == "yes"
322+ || cookedString == "true";
323+
324+ return result || rawString.isEmpty()
325+ || cookedString == "n"
326+ || cookedString == "0"
327+ || cookedString == "no"
328+ || cookedString == "false";
329+}
330+
331 bool DesktopFileReader::loaded() const
332 {
333 Q_D(const DesktopFileReader);
334
335=== modified file 'src/modules/Unity/Application/desktopfilereader.h'
336--- src/modules/Unity/Application/desktopfilereader.h 2014-10-14 19:39:43 +0000
337+++ src/modules/Unity/Application/desktopfilereader.h 2015-05-21 18:49:54 +0000
338@@ -55,8 +55,13 @@
339 virtual QString splashColor() const;
340 virtual QString splashColorHeader() const;
341 virtual QString splashColorFooter() const;
342+ virtual Qt::ScreenOrientations supportedOrientations() const;
343+ virtual bool rotatesWindowContents() const;
344 virtual bool loaded() const;
345
346+ static bool parseOrientations(const QString &rawString, Qt::ScreenOrientations &result);
347+ static bool parseBoolean(const QString &rawString, bool &result);
348+
349 protected:
350 DesktopFileReader(const QString &appId, const QFileInfo &desktopFile);
351
352
353=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
354--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-05-13 09:40:03 +0000
355+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-05-21 18:49:54 +0000
356@@ -196,7 +196,7 @@
357 , m_shell(shell)
358 , m_firstFrameDrawn(false)
359 , m_live(true)
360- , m_orientation(Qt::PortraitOrientation)
361+ , m_orientationAngle(Angle0)
362 , m_textureProvider(nullptr)
363 , m_lastTouchEvent(nullptr)
364 {
365@@ -306,49 +306,42 @@
366 return static_cast<MirSurfaceItem::State>(m_surface->state());
367 }
368
369-Qt::ScreenOrientation MirSurfaceItem::orientation() const
370+MirSurfaceItem::OrientationAngle MirSurfaceItem::orientationAngle() const
371 {
372- return m_orientation;
373+ return m_orientationAngle;
374 }
375
376-void MirSurfaceItem::setOrientation(const Qt::ScreenOrientation orientation)
377+void MirSurfaceItem::setOrientationAngle(MirSurfaceItem::OrientationAngle angle)
378 {
379- qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::setOrientation - orientation=" << orientation;
380+ qCDebug(QTMIR_SURFACES, "MirSurfaceItem::setOrientationAngle(%d)", angle);
381
382- if (m_orientation == orientation)
383+ if (m_orientationAngle == angle)
384 return;
385
386 MirOrientation mirOrientation;
387- Qt::ScreenOrientation nativeOrientation = QGuiApplication::primaryScreen()->nativeOrientation();
388- const bool landscapeNativeOrientation = (nativeOrientation == Qt::LandscapeOrientation);
389-
390- Qt::ScreenOrientation requestedOrientation = orientation;
391- if (orientation == Qt::PrimaryOrientation) { // means orientation equals native orientation, set it as such
392- requestedOrientation = nativeOrientation;
393- }
394-
395- switch(requestedOrientation) {
396- case Qt::PortraitOrientation:
397- mirOrientation = (landscapeNativeOrientation) ? mir_orientation_right : mir_orientation_normal;
398- break;
399- case Qt::LandscapeOrientation:
400- mirOrientation = (landscapeNativeOrientation) ? mir_orientation_normal : mir_orientation_left;
401- break;
402- case Qt::InvertedPortraitOrientation:
403- mirOrientation = (landscapeNativeOrientation) ? mir_orientation_left : mir_orientation_inverted;
404- break;
405- case Qt::InvertedLandscapeOrientation:
406- mirOrientation = (landscapeNativeOrientation) ? mir_orientation_inverted : mir_orientation_right;
407+
408+ switch (angle) {
409+ case Angle0:
410+ mirOrientation = mir_orientation_normal;
411+ break;
412+ case Angle90:
413+ mirOrientation = mir_orientation_right;
414+ break;
415+ case Angle180:
416+ mirOrientation = mir_orientation_inverted;
417+ break;
418+ case Angle270:
419+ mirOrientation = mir_orientation_left;
420 break;
421 default:
422- qWarning("Unrecognized Qt::ScreenOrientation!");
423+ qCWarning(QTMIR_SURFACES, "Unsupported orientation angle: %d", angle);
424 return;
425 }
426
427 m_surface->set_orientation(mirOrientation);
428
429- m_orientation = orientation;
430- Q_EMIT orientationChanged();
431+ m_orientationAngle = angle;
432+ Q_EMIT orientationAngleChanged(angle);
433 }
434
435 QString MirSurfaceItem::name() const
436
437=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
438--- src/modules/Unity/Application/mirsurfaceitem.h 2015-05-11 13:15:53 +0000
439+++ src/modules/Unity/Application/mirsurfaceitem.h 2015-05-21 18:49:54 +0000
440@@ -48,12 +48,17 @@
441 Q_OBJECT
442 Q_ENUMS(Type)
443 Q_ENUMS(State)
444+ Q_ENUMS(OrientationAngle)
445
446 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
447 Q_PROPERTY(State state READ state NOTIFY stateChanged)
448 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
449 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
450- Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false)
451+
452+ // How many degrees, clockwise, the UI in the surface has to rotate to match with the
453+ // shell UI orientation
454+ Q_PROPERTY(OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
455+ NOTIFY orientationAngleChanged DESIGNABLE false)
456
457 public:
458 explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
459@@ -83,12 +88,18 @@
460 Fullscreen = mir_surface_state_fullscreen,
461 };
462
463+ enum OrientationAngle {
464+ Angle0 = 0,
465+ Angle90 = 90,
466+ Angle180 = 180,
467+ Angle270 = 270
468+ };
469+
470 //getters
471 Type type() const;
472 State state() const;
473 QString name() const;
474 bool live() const;
475- Qt::ScreenOrientation orientation() const;
476 SessionInterface *session() const;
477
478 Q_INVOKABLE void release();
479@@ -102,7 +113,9 @@
480
481 bool isFirstFrameDrawn() const { return m_firstFrameDrawn; }
482
483- void setOrientation(const Qt::ScreenOrientation orientation);
484+ OrientationAngle orientationAngle() const;
485+ void setOrientationAngle(OrientationAngle angle);
486+
487 void setSession(SessionInterface *app);
488
489 // to allow easy touch event injection from tests
490@@ -116,7 +129,7 @@
491 void typeChanged();
492 void stateChanged();
493 void nameChanged();
494- void orientationChanged();
495+ void orientationAngleChanged(OrientationAngle angle);
496 void liveChanged(bool live);
497 void firstFrameDrawn(MirSurfaceItem *item);
498
499@@ -182,7 +195,9 @@
500 MirShell *const m_shell;
501 bool m_firstFrameDrawn;
502 bool m_live;
503- Qt::ScreenOrientation m_orientation; //FIXME - have to save the state as Mir has no getter for it (bug:1357429)
504+
505+ //FIXME - have to save the state as Mir has no getter for it (bug:1357429)
506+ OrientationAngle m_orientationAngle;
507
508 QMirSurfaceTextureProvider *m_textureProvider;
509
510@@ -218,5 +233,6 @@
511 } // namespace qtmir
512
513 Q_DECLARE_METATYPE(qtmir::MirSurfaceItem*)
514+Q_DECLARE_METATYPE(qtmir::MirSurfaceItem::OrientationAngle)
515
516 #endif // MIRSURFACEITEM_H
517
518=== modified file 'tests/modules/DesktopFileReader/desktopfilereader_test.cpp'
519--- tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2014-10-14 23:15:46 +0000
520+++ tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2015-05-21 18:49:54 +0000
521@@ -126,3 +126,73 @@
522 EXPECT_EQ(reader->comment(), "Ubuntu 简易计算器");
523 EXPECT_EQ(reader->splashTitle(), "计算器 2.0");
524 }
525+
526+TEST(DesktopFileReader, parseOrientations)
527+{
528+ using namespace ::testing;
529+
530+ const Qt::ScreenOrientations defaultOrientations = Qt::PortraitOrientation | Qt::LandscapeOrientation
531+ | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation;
532+ bool ok;
533+ Qt::ScreenOrientations orientations;
534+
535+ ok = DesktopFileReader::parseOrientations(QString(), orientations);
536+ ASSERT_TRUE(ok);
537+ EXPECT_EQ(defaultOrientations, orientations);
538+
539+ ok = DesktopFileReader::parseOrientations("An invalid string!", orientations);
540+ ASSERT_FALSE(ok);
541+ EXPECT_EQ(defaultOrientations, orientations);
542+
543+ ok = DesktopFileReader::parseOrientations("landscape", orientations);
544+ ASSERT_TRUE(ok);
545+ EXPECT_EQ(Qt::LandscapeOrientation, orientations);
546+
547+ ok = DesktopFileReader::parseOrientations(" InvertedPortrait , Portrait ", orientations);
548+ ASSERT_TRUE(ok);
549+ EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::PortraitOrientation, orientations);
550+
551+ ok = DesktopFileReader::parseOrientations(",inverted-landscape, inverted_portrait, ", orientations);
552+ ASSERT_TRUE(ok);
553+ EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation, orientations);
554+
555+ ok = DesktopFileReader::parseOrientations(",inverted-landscape, some-invalid-text, ", orientations);
556+ ASSERT_FALSE(ok);
557+ EXPECT_EQ(defaultOrientations, orientations);
558+
559+ ok = DesktopFileReader::parseOrientations("landscape;portrait", orientations);
560+ ASSERT_TRUE(ok);
561+ EXPECT_EQ(Qt::PortraitOrientation | Qt::LandscapeOrientation, orientations);
562+
563+ ok = DesktopFileReader::parseOrientations("primary", orientations);
564+ ASSERT_TRUE(ok);
565+ EXPECT_EQ(Qt::PrimaryOrientation, orientations);
566+
567+ ok = DesktopFileReader::parseOrientations("landscpe,primary", orientations);
568+ ASSERT_FALSE(ok);
569+ EXPECT_EQ(defaultOrientations, orientations);
570+}
571+
572+TEST(DesktopFileReader, parseBoolean)
573+{
574+ using namespace ::testing;
575+
576+ bool ok;
577+ bool boolean;
578+
579+ ok = DesktopFileReader::parseBoolean(QString(), boolean);
580+ ASSERT_TRUE(ok);
581+ EXPECT_FALSE(boolean);
582+
583+ ok = DesktopFileReader::parseBoolean(" Yes ", boolean);
584+ ASSERT_TRUE(ok);
585+ EXPECT_TRUE(boolean);
586+
587+ ok = DesktopFileReader::parseBoolean("False", boolean);
588+ ASSERT_TRUE(ok);
589+ EXPECT_FALSE(boolean);
590+
591+ ok = DesktopFileReader::parseBoolean("Hello World!", boolean);
592+ ASSERT_FALSE(ok);
593+ EXPECT_FALSE(boolean);
594+}

Subscribers

People subscribed via source and target branches