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

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Lukáš Tinkl
Approved revision: 380
Merged at revision: 388
Proposed branch: lp:~dandrader/qtmir/mousePointer
Merge into: lp:qtmir
Diff against target: 897 lines (+508/-104)
19 files modified
CMakeLists.txt (+1/-1)
debian/control (+2/-2)
demos/qml-demo-shell/ResizeArea.qml (+128/-0)
demos/qml-demo-shell/TitleBar.qml (+4/-1)
demos/qml-demo-shell/Window.qml (+4/-81)
demos/qml-demo-shell/qml-demo-shell.qml (+19/-1)
src/modules/Unity/Application/CMakeLists.txt (+0/-1)
src/modules/Unity/Application/plugin.cpp (+8/-1)
src/platforms/mirserver/CMakeLists.txt (+5/-1)
src/platforms/mirserver/cursor.cpp (+152/-0)
src/platforms/mirserver/cursor.h (+66/-0)
src/platforms/mirserver/mirserver.cpp (+6/-0)
src/platforms/mirserver/mirsingleton.cpp (+33/-0)
src/platforms/mirserver/mirsingleton.h (+46/-0)
src/platforms/mirserver/qteventfeeder.cpp (+19/-12)
src/platforms/mirserver/qteventfeeder.h (+2/-1)
src/platforms/mirserver/screen.cpp (+6/-0)
src/platforms/mirserver/screen.h (+6/-1)
tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h (+1/-1)
To merge this branch: bzr merge lp:~dandrader/qtmir/mousePointer
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Lukáš Tinkl (community) Approve
Gerry Boland (community) Approve
Review via email: mp+272027@code.launchpad.net

This proposal supersedes a proposal from 2015-09-09.

Commit message

Shell draws its own cursor using the new Cursor QML element

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/mousePointer/+merge/271620
https://code.launchpad.net/~unity-team/unity8/mousePointer/+merge/273369

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

* 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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

=== added file 'src/modules/Unity/Application/Cursor.qml'
=== added file 'src/modules/Unity/Application/cursorimageprovider.cpp'
I'm beginning to wonder if most of this code needs to live in qtmir at all. Since Unity8 draws it, why does QtMir need to do this work to find the image for it?

I also don't think it's QtMir's job to know anything about cursor themes.

Why doesn't QtMir just inform the shell of:
1. the position the cursor should be located at
2. the name of the desired cursor
Then unity8 can find the themed cursor image, figure out the hotspot and draw the cursor itself.

review: Needs Information
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

=== added file 'demos/qml-demo-shell/ResizeArea.qml'
I like your code, neat and clean as always. But if I was writing this, I would have a single MouseArea behind the surface, instead of 8. It's ok for a demo, but that's a lot for a real shell.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

> === added file 'demos/qml-demo-shell/ResizeArea.qml'
> I like your code, neat and clean as always. But if I was writing this, I would
> have a single MouseArea behind the surface, instead of 8. It's ok for a demo,
> but that's a lot for a real shell.

If I recall correctly, the main reason was because of the MouseArea.cursorShape property. If you set it, the cursor will automatically assume the given shape when hovering the mouse area. So I cannot be a single one.

But later on the cursor shape enumeration proved insufficient for exposing all the different shapes unity uses, forcing me to introduce the Mir.cursorName API.

So yeah, now that I've given up using MouseArea.cursorShape, maybe I could use a single mouse area.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

> > === added file 'demos/qml-demo-shell/ResizeArea.qml'
> > I like your code, neat and clean as always. But if I was writing this, I
> would
> > have a single MouseArea behind the surface, instead of 8. It's ok for a
> demo,
> > but that's a lot for a real shell.
>
> If I recall correctly, the main reason was because of the
> MouseArea.cursorShape property. If you set it, the cursor will automatically
> assume the given shape when hovering the mouse area. So I cannot be a single
> one.
>
> But later on the cursor shape enumeration proved insufficient for exposing all
> the different shapes unity uses, forcing me to introduce the Mir.cursorName
> API.
>
> So yeah, now that I've given up using MouseArea.cursorShape, maybe I could use
> a single mouse area.

FYI: I also copy-pasted ResizeArea.qml into unity8/mousePointer

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

> === added file 'src/modules/Unity/Application/Cursor.qml'
> === added file 'src/modules/Unity/Application/cursorimageprovider.cpp'
> I'm beginning to wonder if most of this code needs to live in qtmir at all.
> Since Unity8 draws it, why does QtMir need to do this work to find the image
> for it?
>
> I also don't think it's QtMir's job to know anything about cursor themes.
>
>
> Why doesn't QtMir just inform the shell of:
> 1. the position the cursor should be located at
> 2. the name of the desired cursor
> Then unity8 can find the themed cursor image, figure out the hotspot and draw
> the cursor itself.

Following the same rationale, one might also argue: "Why does qtmir has to know about application processes and upstart at all? let unity8 figure it out. qtmir should just spit out Sessions, MirSurfaces and MirSurfaceItems".

Also, by having this in qtmir, we pretty much shield unity8 from architectural changes down the road, once we ditch the QML cursor approach in favor of a unity-system-settings one.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

On 02/09/15 13:16, Gerry Boland wrote:
> === added file 'demos/qml-demo-shell/ResizeArea.qml'
> I like your code, neat and clean as always. But if I was writing this, I would have a single MouseArea behind the surface, instead of 8. It's ok for a demo, but that's a lot for a real shell.
>
>

Fixed. Will do likewise in untiy8 tomorrow.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

> > === added file 'src/modules/Unity/Application/Cursor.qml'
> > === added file 'src/modules/Unity/Application/cursorimageprovider.cpp'
> > I'm beginning to wonder if most of this code needs to live in qtmir at all.
> > Since Unity8 draws it, why does QtMir need to do this work to find the image
> > for it?
> >
> > I also don't think it's QtMir's job to know anything about cursor themes.
> >
> >
> > Why doesn't QtMir just inform the shell of:
> > 1. the position the cursor should be located at
> > 2. the name of the desired cursor
> > Then unity8 can find the themed cursor image, figure out the hotspot and
> draw
> > the cursor itself.
>
> Following the same rationale, one might also argue: "Why does qtmir has to
> know about application processes and upstart at all? let unity8 figure it out.
> qtmir should just spit out Sessions, MirSurfaces and MirSurfaceItems".

Actually that's the longer-term goal.
https://trello.com/c/4uBsKNVT/133-split-applicationmanager-out-of-qtmir
Zanetti wants to move such logic into Unity itself. This will make QtMir a thin wrapper of Mir functionality for Qt users, which is a much clearer purpose than what it currently has.

If somebody would like to make their own shell, then can make use of QtMir without being forced to use upstart for instance. If they want to use upstart, then they can use the Unity.Application plugin.

> Also, by having this in qtmir, we pretty much shield unity8 from architectural
> changes down the road, once we ditch the QML cursor approach in favor of a
> unity-system-settings one.

I don't think that will happen. We need the shell to manage the cursor position, in order to do fancy things like edge-push detection, slowing cursor over buttons (a11y) or moving cursor with keyboard (a11y).

My main reasons for wanting USC to draw cursor were:
1. latency, cursor will react as quickly as possible
2. hardware compositing, cursor lives in a special hardware buffer which the hardware composites on top of everything. Means moving cursor doesn't require entire screen re-renders.

Mir team have plans for both problems
1. not use the mir protobuf for input, but have unity8 open socket with event stream coming in. Should reduce latency
2. Mir adding API to allow shell to designate certain buffers/surfaces as being hardware composable. Cursor will definitely be one of those, if available.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

Ok, moved all Cursor stuff from qtmir to unity8.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

=== modified file 'debian/copyright'
can undo this.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

On 09/09/15 07:57, Gerry Boland wrote:
> === modified file 'debian/copyright'
> can undo this.
Done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Ok ignore my relativeMovement thing. I'll not object to the usual terminology.

However I fear I need to ask you to rebase on top of
https://code.launchpad.net/~gerboland/qtmir/multimonitor/+merge/269906
as there's a few conflicts, and the concept of multiple qwindows does make this more complex.

+ // We will draw our own cursor.
+ add_init_callback([this](){ the_cursor()->hide(); });
This isn't great, as the mir cursor object is still being created. Can we replace Mir's implementation with our own one? -- not a blocker on this MR, can consider this later.

++ src/platforms/mirserver/mirsingleton.cpp
+qtmir::Mir::~Mir()
+{
+ m_instance = nullptr;
+}
You're not deleting what you potentially "new"ed. QScopedPointer helps prevent such accidents...

+++ src/platforms/mirserver/mirsingleton.h
+private:
+ Mir();
maybe http://doc.qt.io/qt-5/qobject.html#Q_DISABLE_COPY

Using this Mir singleton to save the cursorName will do fine for now, but I'm wary of it being a dumping ground for lots of little things.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

On 09/09/15 10:36, Gerry Boland wrote:
> Review: Needs Fixing
>
> Ok ignore my relativeMovement thing. I'll not object to the usual terminology.
>
> However I fear I need to ask you to rebase on top of
> https://code.launchpad.net/~gerboland/qtmir/multimonitor/+merge/269906
> as there's a few conflicts, and the concept of multiple qwindows does make this more complex.

Done.

>
> + // We will draw our own cursor.
> + add_init_callback([this](){ the_cursor()->hide(); });
> This isn't great, as the mir cursor object is still being created. Can we replace Mir's implementation with our own one? -- not a blocker on this MR, can consider this later.

This will be the u-s-c cursor, and u-s-c will always have its own cursor
no matter what, I think. Don't think it's worth investigating this idea.

>
> ++ src/platforms/mirserver/mirsingleton.cpp
> +qtmir::Mir::~Mir()
> +{
> + m_instance = nullptr;
> +}
> You're not deleting what you potentially "new"ed. QScopedPointer helps prevent such accidents...

I am. The only place that does "new Mir" is Mir::instance() and it's
done only once. This is a simple, no-nonsense, singleton implementation
that does its job AFAICT. You want the global, static, Mir::m_instance
to be a QScopedPointer? I fail to see how would that work and how it
would be better than the current code. If you really want to see a
QScopedPointer there please give me a diff as I didn't get the point.

>
> +++ src/platforms/mirserver/mirsingleton.h
> +private:
> + Mir();
> maybe http://doc.qt.io/qt-5/qobject.html#Q_DISABLE_COPY

Done.

> Using this Mir singleton to save the cursorName will do fine for now, but I'm wary of it being a dumping ground for lots of little things.

Yes, Mir.cursorName is surely not the best solution but anything better
would require way more work. This is like a stop-gap measure. Also given
the uncertainty of the current cursor approach (as we will eventually
move to u-s-c cursor) I didn't want to invest a lot of effort on
something that could evaporate in the near term.

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

removed the multimonitor branch as a prerequisite as it still has issues.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

The text input cursor (ibeam) is not mapped correctly; to xterm?

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

Replied to inline comment

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

> The text input cursor (ibeam) is not mapped correctly; to xterm?

It's mapped correctly, as I commented in the inline diff.

PS: Could please refrain from using inline comments in the future (for my MPs at least). I find it a badly implemented feature in launchpad. It's disjointed from the main comments and is kinda lost in the middle of the diff (there are hotkeys to jump between diff comments, but I find it gimmicky)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

> > The text input cursor (ibeam) is not mapped correctly; to xterm?
>
> It's mapped correctly, as I commented in the inline diff.

I see, thanks for the explanation

> PS: Could please refrain from using inline comments in the future (for my MPs
> at least). I find it a badly implemented feature in launchpad. It's disjointed
> from the main comments and is kinda lost in the middle of the diff (there are
> hotkeys to jump between diff comments, but I find it gimmicky)

Noted

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Have tested this with silo22, it's working good. Code is good. LGTM

review: Approve
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

bool Cursor::handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButton buttons,...)

Needs changing from Qt::MouseButton -> Qt::MouseButtons as the latter is expected by methods in QWindowSystemInterface. A single "button" would prevent stuff like emulating middle mouse click by pressing both left and right mouse buttons at once.

review: Needs Fixing
lp:~dandrader/qtmir/mousePointer updated
380. By Daniel d'Andrada

s/Qt::MouseButton/Qt::MouseButtons

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

> bool Cursor::handleMouseEvent(ulong timestamp, QPointF movement,
> Qt::MouseButton buttons,...)
>
> Needs changing from Qt::MouseButton -> Qt::MouseButtons as the latter is
> expected by methods in QWindowSystemInterface. A single "button" would prevent
> stuff like emulating middle mouse click by pressing both left and right mouse
> buttons at once.

Fixed.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-09-17 20:17:17 +0000
+++ CMakeLists.txt 2015-10-13 20:19:37 +0000
@@ -75,7 +75,7 @@
75pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)75pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
76pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)76pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
77pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)77pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
78pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=8)78pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=9)
7979
80include_directories(${APPLICATION_API_INCLUDE_DIRS})80include_directories(${APPLICATION_API_INCLUDE_DIRS})
8181
8282
=== modified file 'debian/control'
--- debian/control 2015-09-25 12:11:08 +0000
+++ debian/control 2015-10-13 20:19:37 +0000
@@ -23,7 +23,7 @@
23 libubuntu-app-launch2-dev,23 libubuntu-app-launch2-dev,
24 libubuntu-application-api-dev (>= 2.1.0),24 libubuntu-application-api-dev (>= 2.1.0),
25 libudev-dev,25 libudev-dev,
26 libunity-api-dev (>= 7.100),26 libunity-api-dev (>= 7.101),
27 liburl-dispatcher1-dev,27 liburl-dispatcher1-dev,
28 libxkbcommon-dev,28 libxkbcommon-dev,
29 libxrender-dev,29 libxrender-dev,
@@ -93,7 +93,7 @@
93Conflicts: libqtmir,93Conflicts: libqtmir,
94 libunity-mir1,94 libunity-mir1,
95Provides: unity-application-impl,95Provides: unity-application-impl,
96 unity-application-impl-8,96 unity-application-impl-9,
97Description: Qt plugin for Unity specific Mir APIs97Description: Qt plugin for Unity specific Mir APIs
98 QtMir provides Qt/QML bindings for Mir features that are exposed through the98 QtMir provides Qt/QML bindings for Mir features that are exposed through the
99 qtmir-desktop or qtmir-android QPA plugin such as Application management99 qtmir-desktop or qtmir-android QPA plugin such as Application management
100100
=== added file 'demos/qml-demo-shell/ResizeArea.qml'
--- demos/qml-demo-shell/ResizeArea.qml 1970-01-01 00:00:00 +0000
+++ demos/qml-demo-shell/ResizeArea.qml 2015-10-13 20:19:37 +0000
@@ -0,0 +1,128 @@
1import QtQuick 2.4
2import Unity.Application 0.1
3
4MouseArea {
5 id: root
6
7 // to be set from outside
8 property Item target
9 property real borderThickness
10
11 property bool leftBorder: false
12 property bool rightBorder: false
13 property bool topBorder: false
14 property bool bottomBorder: false
15
16 property bool dragging: false
17 property real startX
18 property real startY
19 property real startWidth
20 property real startHeight
21
22 hoverEnabled: true
23
24 property string cursorName: {
25 if (containsMouse || pressed) {
26 if (leftBorder && !topBorder && !bottomBorder) {
27 return "left_side";
28 } else if (rightBorder && !topBorder && !bottomBorder) {
29 return "right_side";
30 } else if (topBorder && !leftBorder && !rightBorder) {
31 return "top_side";
32 } else if (bottomBorder && !leftBorder && !rightBorder) {
33 return "bottom_side";
34 } else if (leftBorder && topBorder) {
35 return "top_left_corner";
36 } else if (leftBorder && bottomBorder) {
37 return "bottom_left_corner";
38 } else if (rightBorder && topBorder) {
39 return "top_right_corner";
40 } else if (rightBorder && bottomBorder) {
41 return "bottom_right_corner";
42 } else {
43 return "";
44 }
45 } else {
46 return "";
47 }
48 }
49 onCursorNameChanged: {
50 Mir.cursorName = cursorName;
51 }
52
53 function updateBorders() {
54 leftBorder = mouseX <= borderThickness;
55 rightBorder = mouseX >= width - borderThickness;
56 topBorder = mouseY <= borderThickness;
57 bottomBorder = mouseY >= height - borderThickness;
58 }
59
60 onPressedChanged: {
61 if (pressed) {
62 var pos = mapToItem(target.parent, mouseX, mouseY);
63 startX = pos.x;
64 startY = pos.y;
65 startWidth = target.width;
66 startHeight = target.height;
67 dragging = true;
68 } else {
69 dragging = false;
70 if (containsMouse) {
71 updateBorders();
72 }
73 }
74 }
75
76 onEntered: {
77 if (!pressed) {
78 updateBorders();
79 }
80 }
81
82 onPositionChanged: {
83 if (!pressed) {
84 updateBorders();
85 }
86
87 if (!dragging) {
88 return;
89 }
90
91 var pos = mapToItem(target.parent, mouse.x, mouse.y);
92
93 if (leftBorder) {
94 if (startX + startWidth - pos.x > target.minWidth) {
95 target.x = pos.x;
96 target.width = startX + startWidth - target.x;
97 startX = target.x;
98 startWidth = target.width;
99 }
100
101 } else if (rightBorder) {
102 var deltaX = pos.x - startX;
103 if (startWidth + deltaX >= target.minWidth) {
104 target.width = startWidth + deltaX;
105 } else {
106 target.width = target.minWidth;
107 }
108 }
109
110 if (topBorder) {
111 if (startY + startHeight - pos.y > target.minHeight) {
112 target.y = pos.y;
113 target.height = startY + startHeight - target.y;
114 startY = target.y;
115 startHeight = target.height;
116 }
117
118 } else if (bottomBorder) {
119 var deltaY = pos.y - startY;
120 if (startHeight + deltaY >= target.minHeight) {
121 target.height = startHeight + deltaY;
122 } else {
123 target.height = target.minHeight;
124 }
125 }
126 }
127}
128
0129
=== modified file 'demos/qml-demo-shell/TitleBar.qml'
--- demos/qml-demo-shell/TitleBar.qml 2015-08-24 12:43:01 +0000
+++ demos/qml-demo-shell/TitleBar.qml 2015-10-13 20:19:37 +0000
@@ -1,4 +1,5 @@
1import QtQuick 2.01import QtQuick 2.4
2import Unity.Application 0.1
23
3Rectangle {4Rectangle {
4 id: root5 id: root
@@ -21,8 +22,10 @@
21 distanceX = pos.x;22 distanceX = pos.x;
22 distanceY = pos.y;23 distanceY = pos.y;
23 dragging = true;24 dragging = true;
25 Mir.cursorName = "grabbing";
24 } else {26 } else {
25 dragging = false;27 dragging = false;
28 Mir.cursorName = "";
26 }29 }
27 }30 }
28 onMouseXChanged: {31 onMouseXChanged: {
2932
=== modified file 'demos/qml-demo-shell/Window.qml'
--- demos/qml-demo-shell/Window.qml 2015-08-31 09:51:28 +0000
+++ demos/qml-demo-shell/Window.qml 2015-10-13 20:19:37 +0000
@@ -58,87 +58,10 @@
58 }58 }
59 ]59 ]
6060
6161 ResizeArea {
62 MouseArea {62 anchors.fill: root
63 anchors.fill: parent63 borderThickness: root.borderThickness
6464 target: root
65 property real startX
66 property real startY
67 property real startWidth
68 property real startHeight
69 property bool leftBorder
70 property bool rightBorder
71 property bool topBorder
72 property bool bottomBorder
73 property bool dragging
74 onPressedChanged: {
75 if (pressed) {
76 var pos = mapToItem(root.parent, mouseX, mouseY);
77 startX = pos.x;
78 startY = pos.y;
79 startWidth = width;
80 startHeight = height;
81 leftBorder = mouseX > 0 && mouseX < root.borderThickness;
82 rightBorder = mouseX > (root.width - root.borderThickness) && mouseX < root.width;
83 topBorder = mouseY > 0 && mouseY < root.borderThickness;
84 bottomBorder = mouseY > (root.height - root.borderThickness) && mouseY < root.height;
85 dragging = true;
86 } else {
87 dragging = false;
88 }
89 }
90
91 onMouseXChanged: {
92 if (!pressed || !dragging) {
93 return;
94 }
95
96 var pos = mapToItem(root.parent, mouseX, mouseY);
97
98 if (leftBorder) {
99
100 if (startX + startWidth - pos.x > root.minWidth) {
101 root.x = pos.x;
102 root.width = startX + startWidth - root.x;
103 startX = root.x;
104 startWidth = root.width;
105 }
106
107 } else if (rightBorder) {
108 var deltaX = pos.x - startX;
109 if (startWidth + deltaX >= root.minWidth) {
110 root.width = startWidth + deltaX;
111 } else {
112 root.width = root.minWidth;
113 }
114 }
115 }
116
117 onMouseYChanged: {
118 if (!pressed || !dragging) {
119 return;
120 }
121
122 var pos = mapToItem(root.parent, mouseX, mouseY);
123
124 if (topBorder) {
125
126 if (startY + startHeight - pos.y > root.minHeight) {
127 root.y = pos.y;
128 root.height = startY + startHeight - root.y;
129 startY = root.y;
130 startHeight = root.height;
131 }
132
133 } else if (bottomBorder) {
134 var deltaY = pos.y - startY;
135 if (startHeight + deltaY >= root.minHeight) {
136 root.height = startHeight + deltaY;
137 } else {
138 root.height = root.minHeight;
139 }
140 }
141 }
142 }65 }
14366
144 TitleBar {67 TitleBar {
14568
=== modified file 'demos/qml-demo-shell/qml-demo-shell.qml'
--- demos/qml-demo-shell/qml-demo-shell.qml 2015-08-31 09:51:28 +0000
+++ demos/qml-demo-shell/qml-demo-shell.qml 2015-10-13 20:19:37 +0000
@@ -1,4 +1,4 @@
1import QtQuick 2.01import QtQuick 2.4
2import Unity.Application 0.12import Unity.Application 0.1
33
4Rectangle {4Rectangle {
@@ -88,6 +88,7 @@
88 }88 }
8989
90 Rectangle {90 Rectangle {
91 id: resizeButton
91 width: 9092 width: 90
92 height: 4093 height: 40
93 color: "blue"94 color: "blue"
@@ -103,6 +104,23 @@
103 }104 }
104 }105 }
105106
107 Rectangle {
108 width: 40
109 height: 40
110 color: "green"
111 anchors { right: resizeButton.left; bottom: parent.bottom }
112 Text {
113 anchors.centerIn: parent
114 text: "⟳"
115 color: "white"
116 font.pixelSize: 35
117 }
118 MouseArea {
119 anchors.fill: parent
120 onClicked: { root.rotation += 180; }
121 }
122 }
123
106 Component {124 Component {
107 id: windowStretchComponent125 id: windowStretchComponent
108 Window {126 Window {
109127
=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
--- src/modules/Unity/Application/CMakeLists.txt 2015-09-17 16:17:17 +0000
+++ src/modules/Unity/Application/CMakeLists.txt 2015-10-13 20:19:37 +0000
@@ -92,4 +92,3 @@
92# install92# install
93add_qml_plugin(Unity.Application 0.1 Unity/Application TARGETS unityapplicationplugin)93add_qml_plugin(Unity.Application 0.1 Unity/Application TARGETS unityapplicationplugin)
94install(FILES com.canonical.qtmir.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)94install(FILES com.canonical.qtmir.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
95
9695
=== modified file 'src/modules/Unity/Application/plugin.cpp'
--- src/modules/Unity/Application/plugin.cpp 2015-08-31 09:51:28 +0000
+++ src/modules/Unity/Application/plugin.cpp 2015-10-13 20:19:37 +0000
@@ -27,6 +27,9 @@
27#include "sessionmanager.h"27#include "sessionmanager.h"
28#include "ubuntukeyboardinfo.h"28#include "ubuntukeyboardinfo.h"
2929
30// platforms/mirserver
31#include <mirsingleton.h>
32
30// qtmir33// qtmir
31#include "logging.h"34#include "logging.h"
3235
@@ -64,6 +67,10 @@
64 }67 }
65 return UbuntuKeyboardInfo::instance();68 return UbuntuKeyboardInfo::instance();
66}69}
70
71QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) {
72 return qtmir::Mir::instance();
73}
67} // anonymous namespace74} // anonymous namespace
6875
69class UnityApplicationPlugin : public QQmlExtensionPlugin {76class UnityApplicationPlugin : public QQmlExtensionPlugin {
@@ -102,7 +109,7 @@
102 uri, 0, 1, "Session", "Session can't be instantiated from QML");109 uri, 0, 1, "Session", "Session can't be instantiated from QML");
103 qmlRegisterSingletonType<qtmir::UbuntuKeyboardInfo>(110 qmlRegisterSingletonType<qtmir::UbuntuKeyboardInfo>(
104 uri, 0, 1, "UbuntuKeyboardInfo", ubuntuKeyboardInfoSingleton);111 uri, 0, 1, "UbuntuKeyboardInfo", ubuntuKeyboardInfoSingleton);
105 qmlRegisterUncreatableType<Mir>(uri, 0, 1, "Mir", "Mir provides enum values, it can't be instantiated");112 qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton);
106 }113 }
107114
108 virtual void initializeEngine(QQmlEngine *engine, const char *uri)115 virtual void initializeEngine(QQmlEngine *engine, const char *uri)
109116
=== modified file 'src/platforms/mirserver/CMakeLists.txt'
--- src/platforms/mirserver/CMakeLists.txt 2015-08-11 19:25:04 +0000
+++ src/platforms/mirserver/CMakeLists.txt 2015-10-13 20:19:37 +0000
@@ -41,7 +41,9 @@
4141
42set(MIRSERVER_QPA_PLUGIN_SRC42set(MIRSERVER_QPA_PLUGIN_SRC
43 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp43 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
44 cursor.cpp
44 mirwindowmanager.cpp45 mirwindowmanager.cpp
46 mirsingleton.cpp
45 qteventfeeder.cpp47 qteventfeeder.cpp
46 plugin.cpp48 plugin.cpp
47 qmirserver.cpp49 qmirserver.cpp
@@ -63,6 +65,8 @@
63 ubuntutheme.cpp65 ubuntutheme.cpp
64 clipboard.cpp66 clipboard.cpp
65 tracepoints.c67 tracepoints.c
68# We need to run moc on these headers
69 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
66 )70 )
6771
68add_library(qpa-mirserver SHARED72add_library(qpa-mirserver SHARED
@@ -82,7 +86,7 @@
82 ${QT5PLATFORM_SUPPORT_LDFLAGS}86 ${QT5PLATFORM_SUPPORT_LDFLAGS}
83 # TODO Qt5Platform support LDFLAGS dont provide actual required ldflags...87 # TODO Qt5Platform support LDFLAGS dont provide actual required ldflags...
84 # I found these were needed...perhaps there is some way to query qmake/qconfig?88 # I found these were needed...perhaps there is some way to query qmake/qconfig?
85 -lfreetype 89 -lfreetype
86 ${GIO_LDFLAGS}90 ${GIO_LDFLAGS}
87 ${FONTCONFIG_LDFLAGS}91 ${FONTCONFIG_LDFLAGS}
8892
8993
=== added file 'src/platforms/mirserver/cursor.cpp'
--- src/platforms/mirserver/cursor.cpp 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/cursor.cpp 2015-10-13 20:19:37 +0000
@@ -0,0 +1,152 @@
1/*
2 * Copyright (C) 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
18#include "cursor.h"
19#include "logging.h"
20
21#include "mirsingleton.h"
22
23// Unity API
24#include <unity/shell/application/MirMousePointerInterface.h>
25
26using namespace qtmir;
27
28Cursor::Cursor()
29{
30 m_shapeToCursorName[Qt::ArrowCursor] = "left_ptr";
31 m_shapeToCursorName[Qt::UpArrowCursor] = "up_arrow";
32 m_shapeToCursorName[Qt::CrossCursor] = "cross";
33 m_shapeToCursorName[Qt::WaitCursor] = "watch";
34 m_shapeToCursorName[Qt::IBeamCursor] = "xterm";
35 m_shapeToCursorName[Qt::SizeVerCursor] = "size_ver";
36 m_shapeToCursorName[Qt::SizeHorCursor] = "size_hor";
37 m_shapeToCursorName[Qt::SizeBDiagCursor] = "size_bdiag";
38 m_shapeToCursorName[Qt::SizeFDiagCursor] = "size_fdiag";
39 m_shapeToCursorName[Qt::SizeAllCursor] = "size_all";
40 m_shapeToCursorName[Qt::BlankCursor] = "blank";
41 m_shapeToCursorName[Qt::SplitVCursor] = "split_v";
42 m_shapeToCursorName[Qt::SplitHCursor] = "split_h";
43 m_shapeToCursorName[Qt::PointingHandCursor] = "pointing_hand";
44 m_shapeToCursorName[Qt::ForbiddenCursor] = "forbidden";
45 m_shapeToCursorName[Qt::WhatsThisCursor] = "whats_this";
46 m_shapeToCursorName[Qt::BusyCursor] = "left_ptr_watch";
47 m_shapeToCursorName[Qt::OpenHandCursor] = "openhand";
48 m_shapeToCursorName[Qt::ClosedHandCursor] = "closedhand";
49 m_shapeToCursorName[Qt::DragCopyCursor] = "copy";
50 m_shapeToCursorName[Qt::DragMoveCursor] = "move";
51 m_shapeToCursorName[Qt::DragLinkCursor] = "link";
52
53 connect(Mir::instance(), &Mir::cursorNameChanged, this, &Cursor::setMirCursorName);
54}
55
56void Cursor::changeCursor(QCursor *windowCursor, QWindow * /*window*/)
57{
58 if (m_mousePointer.isNull()) {
59 return;
60 }
61
62 if (windowCursor) {
63 m_qtCursorName = m_shapeToCursorName.value(windowCursor->shape(), QString("left_ptr"));
64 } else {
65 m_qtCursorName.clear();
66 }
67
68 updateMousePointerCursorName();
69}
70
71void Cursor::setMirCursorName(const QString &mirCursorName)
72{
73 m_mirCursorName = mirCursorName;
74 updateMousePointerCursorName();
75}
76
77void Cursor::setMousePointer(MirMousePointerInterface *mousePointer)
78{
79 QMutexLocker locker(&m_mutex);
80
81 if (mousePointer && !m_mousePointer.isNull()) {
82 qFatal("QPA mirserver: Only one MousePointer per screen is allowed!");
83 }
84
85 m_mousePointer = mousePointer;
86 updateMousePointerCursorName();
87}
88
89bool Cursor::handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons,
90 Qt::KeyboardModifiers modifiers)
91{
92 QMutexLocker locker(&m_mutex);
93
94 if (!m_mousePointer || !m_mousePointer->isVisible()) {
95 return false;
96 }
97
98 // Must not be called directly as we're most likely not in Qt's GUI (main) thread.
99 bool ok = QMetaObject::invokeMethod(m_mousePointer, "handleMouseEvent", Qt::AutoConnection,
100 Q_ARG(ulong, timestamp),
101 Q_ARG(QPointF, movement),
102 Q_ARG(Qt::MouseButtons, buttons),
103 Q_ARG(Qt::KeyboardModifiers, modifiers));
104
105 if (!ok) {
106 qCWarning(QTMIR_MIR_INPUT) << "Failed to invoke MousePointer::handleMouseEvent";
107 }
108
109 return ok;
110}
111
112void Cursor::setPos(const QPoint &pos)
113{
114 if (!m_mousePointer) {
115 QPlatformCursor::setPos(pos);
116 return;
117 }
118
119 QPointF movement;
120 QPointF mouseScenePos = m_mousePointer->mapToItem(nullptr, QPointF(0, 0));
121
122 movement.setX(pos.x() - mouseScenePos.x());
123 movement.setY(pos.y() - mouseScenePos.y());
124
125 m_mousePointer->handleMouseEvent(0 /*timestamp*/, movement, Qt::NoButton, Qt::NoModifier);
126}
127
128QPoint Cursor::pos() const
129{
130 if (m_mousePointer) {
131 return m_mousePointer->mapToItem(nullptr, QPointF(0, 0)).toPoint();
132 } else {
133 return QPlatformCursor::pos();
134 }
135}
136
137void Cursor::updateMousePointerCursorName()
138{
139 if (!m_mousePointer) {
140 return;
141 }
142
143 if (m_mirCursorName.isEmpty()) {
144 if (m_qtCursorName.isEmpty()) {
145 m_mousePointer->setCursorName("left_ptr");
146 } else {
147 m_mousePointer->setCursorName(m_qtCursorName);
148 }
149 } else {
150 m_mousePointer->setCursorName(m_mirCursorName);
151 }
152}
0153
=== added file 'src/platforms/mirserver/cursor.h'
--- src/platforms/mirserver/cursor.h 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/cursor.h 2015-10-13 20:19:37 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 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
18#ifndef QTMIR_CURSOR_H
19#define QTMIR_CURSOR_H
20
21#include <QMutex>
22#include <QPointer>
23
24// Unity API
25#include <unity/shell/application/MirPlatformCursor.h>
26
27namespace qtmir {
28
29class Cursor : public MirPlatformCursor
30{
31public:
32 Cursor();
33
34 // Called form Mir input thread
35 bool handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons,
36 Qt::KeyboardModifiers modifiers);
37
38 ////
39 // MirPlatformCursor
40
41 // Called from Qt's GUI thread
42 void setMousePointer(MirMousePointerInterface *mousePointer) override;
43
44 ////
45 // QPlatformCursor
46
47 void changeCursor(QCursor *windowCursor, QWindow *window) override;
48
49 void setPos(const QPoint &pos) override;
50 QPoint pos() const override;
51
52private Q_SLOTS:
53 void setMirCursorName(const QString &mirCursorName);
54
55private:
56 void updateMousePointerCursorName();
57 QMutex m_mutex;
58 QPointer<MirMousePointerInterface> m_mousePointer;
59 QMap<int,QString> m_shapeToCursorName;
60 QString m_qtCursorName;
61 QString m_mirCursorName;
62};
63
64} // namespace qtmir
65
66#endif // QTMIR_CURSOR_H
067
=== modified file 'src/platforms/mirserver/mirserver.cpp'
--- src/platforms/mirserver/mirserver.cpp 2015-08-11 12:08:32 +0000
+++ src/platforms/mirserver/mirserver.cpp 2015-10-13 20:19:37 +0000
@@ -32,6 +32,9 @@
32// egl32// egl
33#include <EGL/egl.h>33#include <EGL/egl.h>
3434
35// mir
36#include <mir/graphics/cursor.h>
37
35namespace mo = mir::options;38namespace mo = mir::options;
36namespace msh = mir::shell;39namespace msh = mir::shell;
37namespace ms = mir::scene;40namespace ms = mir::scene;
@@ -100,6 +103,9 @@
100103
101 apply_settings();104 apply_settings();
102105
106 // We will draw our own cursor.
107 add_init_callback([this](){ the_cursor()->hide(); });
108
103 qCDebug(QTMIR_MIR_MESSAGES) << "MirServer created";109 qCDebug(QTMIR_MIR_MESSAGES) << "MirServer created";
104}110}
105111
106112
=== added file 'src/platforms/mirserver/mirsingleton.cpp'
--- src/platforms/mirserver/mirsingleton.cpp 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/mirsingleton.cpp 2015-10-13 20:19:37 +0000
@@ -0,0 +1,33 @@
1#include "mirsingleton.h"
2
3qtmir::Mir *qtmir::Mir::m_instance = nullptr;
4
5qtmir::Mir::Mir()
6{
7}
8
9qtmir::Mir::~Mir()
10{
11 m_instance = nullptr;
12}
13
14qtmir::Mir *qtmir::Mir::instance()
15{
16 if (!m_instance) {
17 m_instance = new qtmir::Mir;
18 }
19 return m_instance;
20}
21
22void qtmir::Mir::setCursorName(const QString &cursorName)
23{
24 if (m_cursorName != cursorName) {
25 m_cursorName = cursorName;
26 Q_EMIT cursorNameChanged(m_cursorName);
27 }
28}
29
30QString qtmir::Mir::cursorName() const
31{
32 return m_cursorName;
33}
034
=== added file 'src/platforms/mirserver/mirsingleton.h'
--- src/platforms/mirserver/mirsingleton.h 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/mirsingleton.h 2015-10-13 20:19:37 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright (C) 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 QTMIR_MIRSINGLETON_H
18#define QTMIR_MIRSINGLETON_H
19
20// unity-api
21#include <unity/shell/application/Mir.h>
22
23namespace qtmir {
24
25class Mir : public ::Mir
26{
27 Q_OBJECT
28public:
29 virtual ~Mir();
30
31 static Mir *instance();
32
33 void setCursorName(const QString &cursorName) override;
34 QString cursorName() const override;
35
36private:
37 Mir();
38 Q_DISABLE_COPY(Mir)
39
40 QString m_cursorName;
41 static qtmir::Mir *m_instance;
42};
43
44} // namespace qtmir
45
46#endif // QTMIR_MIRSINGLETON_H
047
=== modified file 'src/platforms/mirserver/qteventfeeder.cpp'
--- src/platforms/mirserver/qteventfeeder.cpp 2015-08-27 16:10:20 +0000
+++ src/platforms/mirserver/qteventfeeder.cpp 2015-10-13 20:19:37 +0000
@@ -15,7 +15,9 @@
15 */15 */
1616
17#include "qteventfeeder.h"17#include "qteventfeeder.h"
18#include "cursor.h"
18#include "logging.h"19#include "logging.h"
20#include "screen.h"
1921
20#include <qpa/qplatforminputcontext.h>22#include <qpa/qplatforminputcontext.h>
21#include <qpa/qplatformintegration.h>23#include <qpa/qplatformintegration.h>
@@ -366,6 +368,13 @@
366namespace {368namespace {
367369
368class QtWindowSystem : public QtEventFeeder::QtWindowSystemInterface {370class QtWindowSystem : public QtEventFeeder::QtWindowSystemInterface {
371public:
372 QtWindowSystem()
373 {
374 // because we're using QMetaObject::invoke with arguments of those types
375 qRegisterMetaType<Qt::KeyboardModifiers>("Qt::KeyboardModifiers");
376 qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
377 }
369378
370 bool hasTargetWindow() override379 bool hasTargetWindow() override
371 {380 {
@@ -404,11 +413,11 @@
404 QWindowSystemInterface::handleTouchEvent(mTopLevelWindow.data(), timestamp, device, points, mods);413 QWindowSystemInterface::handleTouchEvent(mTopLevelWindow.data(), timestamp, device, points, mods);
405 }414 }
406415
407 void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) override416 void handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) override
408 {417 {
409 Q_ASSERT(!mTopLevelWindow.isNull());418 Q_ASSERT(!mTopLevelWindow.isNull());
410 QWindowSystemInterface::handleMouseEvent(mTopLevelWindow.data(), timestamp, point, point, // local and global point are the same419 auto platformCursor = static_cast<qtmir::Cursor*>(mTopLevelWindow->screen()->handle()->cursor());
411 buttons, modifiers);420 platformCursor->handleMouseEvent(timestamp, movement, buttons, modifiers);
412 }421 }
413422
414423
@@ -488,9 +497,9 @@
488 return static_cast<Qt::KeyboardModifiers>(qtModifiers);497 return static_cast<Qt::KeyboardModifiers>(qtModifiers);
489}498}
490499
491Qt::MouseButton getQtMouseButtonsfromMirPointerEvent(MirPointerEvent const* pev)500Qt::MouseButtons getQtMouseButtonsfromMirPointerEvent(MirPointerEvent const* pev)
492{501{
493 int buttons = Qt::NoButton;502 Qt::MouseButtons buttons = Qt::NoButton;
494 if (mir_pointer_event_button_state(pev, mir_pointer_button_primary))503 if (mir_pointer_event_button_state(pev, mir_pointer_button_primary))
495 buttons |= Qt::LeftButton;504 buttons |= Qt::LeftButton;
496 if (mir_pointer_event_button_state(pev, mir_pointer_button_secondary))505 if (mir_pointer_event_button_state(pev, mir_pointer_button_secondary))
@@ -502,7 +511,7 @@
502 if (mir_pointer_event_button_state(pev, mir_pointer_button_forward))511 if (mir_pointer_event_button_state(pev, mir_pointer_button_forward))
503 buttons |= Qt::ForwardButton;512 buttons |= Qt::ForwardButton;
504513
505 return static_cast<Qt::MouseButton>(buttons);514 return buttons;
506}515}
507}516}
508517
@@ -518,12 +527,10 @@
518527
519 auto modifiers = getQtModifiersFromMir(mir_pointer_event_modifiers(pev));528 auto modifiers = getQtModifiersFromMir(mir_pointer_event_modifiers(pev));
520 auto buttons = getQtMouseButtonsfromMirPointerEvent(pev);529 auto buttons = getQtMouseButtonsfromMirPointerEvent(pev);
521530 auto movement = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x),
522 auto local_point = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_x),531 mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y));
523 mir_pointer_event_axis_value(pev, mir_pointer_axis_y));532
524533 mQtWindowSystem->handleMouseEvent(timestamp, movement, buttons, modifiers);
525 mQtWindowSystem->handleMouseEvent(timestamp, local_point,
526 buttons, modifiers);
527}534}
528535
529void QtEventFeeder::dispatchKey(MirInputEvent const* event)536void QtEventFeeder::dispatchKey(MirInputEvent const* event)
530537
=== modified file 'src/platforms/mirserver/qteventfeeder.h'
--- src/platforms/mirserver/qteventfeeder.h 2015-08-11 12:08:32 +0000
+++ src/platforms/mirserver/qteventfeeder.h 2015-10-13 20:19:37 +0000
@@ -49,7 +49,8 @@
49 virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device,49 virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device,
50 const QList<struct QWindowSystemInterface::TouchPoint> &points,50 const QList<struct QWindowSystemInterface::TouchPoint> &points,
51 Qt::KeyboardModifiers mods = Qt::NoModifier) = 0;51 Qt::KeyboardModifiers mods = Qt::NoModifier) = 0;
52 virtual void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) = 0;52 virtual void handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons,
53 Qt::KeyboardModifiers modifiers) = 0;
53 };54 };
5455
55 QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr);56 QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr);
5657
=== modified file 'src/platforms/mirserver/screen.cpp'
--- src/platforms/mirserver/screen.cpp 2015-08-11 12:08:32 +0000
+++ src/platforms/mirserver/screen.cpp 2015-10-13 20:19:37 +0000
@@ -226,3 +226,9 @@
226 OrientationReadingEvent::m_type,226 OrientationReadingEvent::m_type,
227 m_orientationSensor->reading()->orientation()));227 m_orientationSensor->reading()->orientation()));
228}228}
229
230QPlatformCursor *Screen::cursor() const
231{
232 const QPlatformCursor *platformCursor = &m_cursor;
233 return const_cast<QPlatformCursor *>(platformCursor);
234}
229235
=== modified file 'src/platforms/mirserver/screen.h'
--- src/platforms/mirserver/screen.h 2015-08-11 12:08:32 +0000
+++ src/platforms/mirserver/screen.h 2015-10-13 20:19:37 +0000
@@ -22,7 +22,9 @@
22#include <QtDBus/QDBusInterface>22#include <QtDBus/QDBusInterface>
23#include <qpa/qplatformscreen.h>23#include <qpa/qplatformscreen.h>
2424
25#include "mir/graphics/display_configuration.h"25#include <mir/graphics/display_configuration.h>
26
27#include "cursor.h"
2628
27class QOrientationSensor;29class QOrientationSensor;
2830
@@ -40,6 +42,7 @@
40 qreal refreshRate() const override { return m_refreshRate; }42 qreal refreshRate() const override { return m_refreshRate; }
41 Qt::ScreenOrientation nativeOrientation() const override { return m_nativeOrientation; }43 Qt::ScreenOrientation nativeOrientation() const override { return m_nativeOrientation; }
42 Qt::ScreenOrientation orientation() const override { return m_currentOrientation; }44 Qt::ScreenOrientation orientation() const override { return m_currentOrientation; }
45 QPlatformCursor *cursor() const override;
4346
44 void toggleSensors(const bool enable) const;47 void toggleSensors(const bool enable) const;
4548
@@ -68,6 +71,8 @@
68 QOrientationSensor *m_orientationSensor;71 QOrientationSensor *m_orientationSensor;
6972
70 QDBusInterface *m_unityScreen;73 QDBusInterface *m_unityScreen;
74
75 qtmir::Cursor m_cursor;
71};76};
7277
73#endif // SCREEN_H78#endif // SCREEN_H
7479
=== modified file 'tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h'
--- tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2015-04-01 15:02:36 +0000
+++ tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2015-10-13 20:19:37 +0000
@@ -34,7 +34,7 @@
34 MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device,34 MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device,
35 const QList<struct QWindowSystemInterface::TouchPoint> &points,35 const QList<struct QWindowSystemInterface::TouchPoint> &points,
36 Qt::KeyboardModifiers mods));36 Qt::KeyboardModifiers mods));
37 MOCK_METHOD4(handleMouseEvent, void(ulong, QPointF, Qt::MouseButton, Qt::KeyboardModifiers));37 MOCK_METHOD4(handleMouseEvent, void(ulong, QPointF, Qt::MouseButtons, Qt::KeyboardModifiers));
38};38};
3939
40namespace testing40namespace testing

Subscribers

People subscribed via source and target branches