Merge lp:~dandrader/unity-api/mousePointer into lp:unity-api

Proposed by Michał Sawicz
Status: Merged
Approved by: Lukáš Tinkl
Approved revision: 190
Merged at revision: 189
Proposed branch: lp:~dandrader/unity-api/mousePointer
Merge into: lp:unity-api
Diff against target: 222 lines (+166/-4)
5 files modified
debian/changelog (+8/-0)
include/unity/shell/application/CMakeLists.txt (+1/-1)
include/unity/shell/application/Mir.h (+20/-3)
include/unity/shell/application/MirMousePointerInterface.h (+99/-0)
include/unity/shell/application/MirPlatformCursor.h (+38/-0)
To merge this branch: bzr merge lp:~dandrader/unity-api/mousePointer
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Lukáš Tinkl (community) Approve
Gerry Boland (community) Approve
Review via email: mp+271620@code.launchpad.net

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

Commit message

unity/shell/application: add some mouse cursor headers and properties

Add Mir.cursorName, MirMousePointerInterface.h and MirPlatformCursor.h

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

+ Q_PROPERTY(qreal hotspotX READ hotspotX NOTIFY hotspotXChanged)
+ Q_PROPERTY(qreal hotspotY READ hotspotY NOTIFY hotspotYChanged)
QPoint?

+ * @brief Handler for Mir mouse events
+ virtual void handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButton buttons,
+ Qt::KeyboardModifiers modifiers) = 0;
These are relative mouse events, right? Please make that clear in the description and method argument.

Looking good otherwise!

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

On 09/09/15 07:54, Gerry Boland wrote:
> Review: Needs Information
>
> + Q_PROPERTY(qreal hotspotX READ hotspotX NOTIFY hotspotXChanged)
> + Q_PROPERTY(qreal hotspotY READ hotspotY NOTIFY hotspotYChanged)
> QPoint?

Please don't! This is the most convenient way for using it in QML.

>
> + * @brief Handler for Mir mouse events
> + virtual void handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButton buttons,
> + Qt::KeyboardModifiers modifiers) = 0;
> These are relative mouse events, right? Please make that clear in the description and method argument.
>
Well, the argument is called "movement", not "position". Movement is
relative by definition.
But sure, I can add documentation on this argument.

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

> On 09/09/15 07:54, Gerry Boland wrote:
> > Review: Needs Information
> >
> > + Q_PROPERTY(qreal hotspotX READ hotspotX NOTIFY hotspotXChanged)
> > + Q_PROPERTY(qreal hotspotY READ hotspotY NOTIFY hotspotYChanged)
> > QPoint?
>
> Please don't! This is the most convenient way for using it in QML.

That's
x: hotspotX
y: hotspotY
versus
x: hotspot.x
y: hotspot.y
I know which I prefer ;)

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

On 16/09/15 07:40, Gerry Boland wrote:
>> On 09/09/15 07:54, Gerry Boland wrote:
>>> Review: Needs Information
>>>
>>> + Q_PROPERTY(qreal hotspotX READ hotspotX NOTIFY hotspotXChanged)
>>> + Q_PROPERTY(qreal hotspotY READ hotspotY NOTIFY hotspotYChanged)
>>> QPoint?
>> Please don't! This is the most convenient way for using it in QML.
> That's
> x: hotspotX
> y: hotspotY
> versus
> x: hotspot.x
> y: hotspot.y
> I know which I prefer ;)

Does QQuickItem have item.pos.x and item.pos.y? Or item.size.width and
item.size.height?

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 :

debian/changelog has a conflict

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

Alright alright. It'll do! :)

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

> debian/changelog has a conflict

Merged fine locally but launchpad web diff still didn't like it.

Did a fresh rebase and launchpad is now happy.

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

+ virtual void handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButton buttons, ...

Needs to pass Qt::MouseButton_s_ around, see https://code.launchpad.net/~dandrader/qtmir/mousePointer/+merge/272027/comments/692411

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~dandrader/unity-api/mousePointer updated
190. By Daniel d'Andrada

s/Qt::MouseButton/Qt::MouseButtons

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

> + virtual void handleMouseEvent(ulong timestamp, QPointF movement,
> Qt::MouseButton buttons, ...
>
> Needs to pass Qt::MouseButton_s_ around, see https://code.launchpad.net/~dandr
> ader/qtmir/mousePointer/+merge/272027/comments/692411

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-09-15 09:15:11 +0000
3+++ debian/changelog 2015-10-13 20:18:17 +0000
4@@ -1,3 +1,11 @@
5+unity-api (7.101) UNRELEASED; urgency=medium
6+
7+ * unity/shell/application: Add Mir.cursorName
8+ * unity/shell/application: Added MirMousePointerInterface.h
9+ * unity/shell/application: Added MirPlatformCursor.h
10+
11+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Tue, 01 Sep 2015 13:38:11 -0300
12+
13 unity-api (7.100+15.10.20150903-0ubuntu1) wily; urgency=medium
14
15 [ Michal Sawicz ]
16
17=== modified file 'include/unity/shell/application/CMakeLists.txt'
18--- include/unity/shell/application/CMakeLists.txt 2015-08-19 13:18:09 +0000
19+++ include/unity/shell/application/CMakeLists.txt 2015-10-13 20:18:17 +0000
20@@ -7,7 +7,7 @@
21
22 set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
23
24-set(VERSION 8)
25+set(VERSION 9)
26 set(PKGCONFIG_NAME "unity-shell-application")
27 set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")
28 set(PKGCONFIG_REQUIRES "Qt5Core")
29
30=== modified file 'include/unity/shell/application/Mir.h'
31--- include/unity/shell/application/Mir.h 2015-08-19 13:18:09 +0000
32+++ include/unity/shell/application/Mir.h 2015-10-13 20:18:17 +0000
33@@ -20,15 +20,22 @@
34 #include <QObject>
35
36 /**
37- @brief Acting as a namespace to hold enums and such for use in QML
38+ @brief Acting mostly as a namespace to hold enums and such for use in QML
39 */
40-class Mir
41+class Mir : public QObject
42 {
43- Q_GADGET
44+ Q_OBJECT
45 Q_ENUMS(Type)
46 Q_ENUMS(State)
47 Q_ENUMS(OrientationAngle)
48
49+ /**
50+ @brief Name of the mouse cursor to be used. Follows the X Cursor naming convention.
51+
52+ Eg.: "left_ptr" is a left-sided pointer arrow
53+ */
54+ Q_PROPERTY(QString cursorName READ cursorName WRITE setCursorName NOTIFY cursorNameChanged)
55+
56 public:
57 /**
58 @brief Surface type
59@@ -69,6 +76,16 @@
60 Angle180 = 180,
61 Angle270 = 270
62 };
63+
64+ /// @cond
65+ virtual void setCursorName(const QString &cursorName) = 0;
66+ virtual QString cursorName() const = 0;
67+ /// @endcond
68+
69+Q_SIGNALS:
70+ /// @cond
71+ void cursorNameChanged(const QString &cursorName);
72+ /// @endcond
73 };
74
75 Q_DECLARE_METATYPE(Mir::OrientationAngle)
76
77=== added file 'include/unity/shell/application/MirMousePointerInterface.h'
78--- include/unity/shell/application/MirMousePointerInterface.h 1970-01-01 00:00:00 +0000
79+++ include/unity/shell/application/MirMousePointerInterface.h 2015-10-13 20:18:17 +0000
80@@ -0,0 +1,99 @@
81+/*
82+ * Copyright (C) 2015 Canonical, Ltd.
83+ *
84+ * This program is free software: you can redistribute it and/or modify it under
85+ * the terms of the GNU Lesser General Public License version 3, as published by
86+ * the Free Software Foundation.
87+ *
88+ * This program is distributed in the hope that it will be useful, but WITHOUT
89+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
90+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
91+ * Lesser General Public License for more details.
92+ *
93+ * You should have received a copy of the GNU Lesser General Public License
94+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
95+ */
96+
97+#ifndef MIR_MOUSE_POINTER_INTERFACE_H
98+#define MIR_MOUSE_POINTER_INTERFACE_H
99+
100+#include <QQuickItem>
101+
102+/**
103+ * @brief The QML mouse pointer
104+ *
105+ * FIXME: Get this out of unity-api
106+ *
107+ * This QML item drives the position of the Mir mouse pointer on the scene
108+ */
109+class MirMousePointerInterface : public QQuickItem {
110+ Q_OBJECT
111+
112+ /**
113+ * @brief Name of the cursor
114+ * Defines the look of the mouse pointer along with themeName
115+ */
116+ Q_PROPERTY(QString cursorName READ cursorName NOTIFY cursorNameChanged)
117+
118+ /**
119+ * @brief Name of the cursor theme
120+ * Defines the look of the mouse pointer along with cursorName
121+ * Its default value is "default".
122+ */
123+ Q_PROPERTY(QString themeName READ themeName NOTIFY themeNameChanged)
124+
125+ /**
126+ * @brief X coordinate of the cursor hotspot
127+ * Is value depends on the current cursor name and theme
128+ */
129+ Q_PROPERTY(qreal hotspotX READ hotspotX NOTIFY hotspotXChanged)
130+
131+ /**
132+ * @brief Y coordinate of the cursor hotspot
133+ * Is value depends on the current cursor name and theme
134+ */
135+ Q_PROPERTY(qreal hotspotY READ hotspotY NOTIFY hotspotYChanged)
136+public:
137+ /**
138+ * @brief The constructor
139+ */
140+ MirMousePointerInterface(QQuickItem *parent = nullptr) : QQuickItem(parent) {}
141+
142+ /// @cond
143+ virtual void setCursorName(const QString &cursorName) = 0;
144+ virtual QString cursorName() const = 0;
145+
146+ virtual void setThemeName(const QString &themeName) = 0;
147+ virtual QString themeName() const = 0;
148+
149+ virtual qreal hotspotX() const = 0;
150+ virtual qreal hotspotY() const = 0;
151+ /// @endcond
152+
153+Q_SIGNALS:
154+ /// @cond
155+ void cursorNameChanged(QString name);
156+ void themeNameChanged(QString name);
157+ void hotspotXChanged(qreal value);
158+ void hotspotYChanged(qreal value);
159+ /// @endcond
160+
161+public Q_SLOTS:
162+ /**
163+ * @brief Handler for Mir mouse events
164+ * The implementation should respond to Mir mouse events by moving itself along its parent
165+ * area.
166+ * This is called by Mir's platform cursor.
167+ *
168+ * Note that we get only relative mouse movement, since the mouse pointer position is defined
169+ * by this very item. Ie., it's up to this class to decide whether or not it (the mouse pointer)
170+ * should move (and how much) due to movement in a mouse device.
171+ *
172+ * @param movement Movement vector
173+ */
174+ virtual void handleMouseEvent(ulong timestamp, QPointF movement, Qt::MouseButtons buttons,
175+ Qt::KeyboardModifiers modifiers) = 0;
176+
177+};
178+
179+#endif // MIR_MOUSE_POINTER_INTERFACE_H
180
181=== added file 'include/unity/shell/application/MirPlatformCursor.h'
182--- include/unity/shell/application/MirPlatformCursor.h 1970-01-01 00:00:00 +0000
183+++ include/unity/shell/application/MirPlatformCursor.h 2015-10-13 20:18:17 +0000
184@@ -0,0 +1,38 @@
185+/*
186+ * Copyright (C) 2015 Canonical, Ltd.
187+ *
188+ * This program is free software; you can redistribute it and/or modify
189+ * it under the terms of the GNU General Public License as published by
190+ * the Free Software Foundation; version 3.
191+ *
192+ * This program is distributed in the hope that it will be useful,
193+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
194+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
195+ * GNU General Public License for more details.
196+ *
197+ * You should have received a copy of the GNU General Public License
198+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
199+ */
200+
201+#ifndef MIR_PLATFORM_CURSOR_H
202+#define MIR_PLATFORM_CURSOR_H
203+
204+#include <qpa/qplatformcursor.h>
205+
206+class MirMousePointerInterface;
207+
208+/**
209+ * @brief Cursor interface for Mir platform
210+ *
211+ * FIXME: Get this out of unity-api
212+ */
213+class MirPlatformCursor : public QPlatformCursor
214+{
215+public:
216+ /**
217+ * @brief Set the QML mouse pointer that this platform cursor will talk to
218+ */
219+ virtual void setMousePointer(MirMousePointerInterface *mousePointer) = 0;
220+};
221+
222+#endif // MIR_PLATFORM_CURSOR_H

Subscribers

People subscribed via source and target branches

to all changes: