Merge lp:~gerboland/unity-mir/add-InputArea-to-any-surface into lp:unity-mir

Proposed by Gerry Boland
Status: Rejected
Rejected by: Albert Astals Cid
Proposed branch: lp:~gerboland/unity-mir/add-InputArea-to-any-surface
Merge into: lp:unity-mir
Diff against target: 146 lines (+54/-18)
2 files modified
src/modules/Unity/SurfaceManager/inputarea.cpp (+47/-17)
src/modules/Unity/SurfaceManager/inputarea.h (+7/-1)
To merge this branch: bzr merge lp:~gerboland/unity-mir/add-InputArea-to-any-surface
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Disapprove
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+180963@code.launchpad.net

Commit message

Allow any surface to have InputAreas defined, not just shell surface. Adds a "surface" property to InputArea.

Description of the change

Adds a "surface" property to InputArea, so can define InputArea for any MirSurface. Will be needed for OSK.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
45. By Gerry Boland

Small logic improvement

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :
review: Disapprove

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/SurfaceManager/inputarea.cpp'
2--- src/modules/Unity/SurfaceManager/inputarea.cpp 2013-08-09 13:16:13 +0000
3+++ src/modules/Unity/SurfaceManager/inputarea.cpp 2013-08-20 08:39:23 +0000
4@@ -34,16 +34,17 @@
5 InputArea::InputArea(QQuickItem *parent)
6 : QQuickItem(parent)
7 , m_enabled(true)
8+ , m_surface(nullptr)
9 {
10 DLOG("InputArea::InputArea (this=%p)", this);
11
12- m_surface = MirSurfaceManager::singleton()->shellSurface();
13- if (m_surface) {
14- registerWithSurface(m_surface);
15+ m_shellSurface = MirSurfaceManager::singleton()->shellSurface();
16+ if (m_shellSurface) {
17+ setShellSurface(m_shellSurface);
18 }
19
20 QObject::connect(MirSurfaceManager::singleton(), &MirSurfaceManager::shellSurfaceChanged,
21- this, &InputArea::registerWithSurface);
22+ this, &InputArea::setShellSurface);
23 }
24
25 InputArea::~InputArea()
26@@ -52,20 +53,16 @@
27 m_surface->removeInputArea(this);
28 }
29
30-void InputArea::registerWithSurface(MirSurface *surface)
31+void InputArea::setShellSurface(MirSurface *surface)
32 {
33- DLOG("InputArea::registerWithSurface (this=%p, surface=%p)", this, surface);
34-
35- if (!surface || surface == m_surface) return;
36-
37- if (m_surface) {
38- m_surface->removeInputArea(this);
39- }
40-
41- m_surface = surface;
42- if (m_enabled) {
43- m_surface->installInputArea(this);
44- }
45+ DLOG("InputArea::setShellSurface (this=%p, surface=%p)", this, surface);
46+
47+ if (!surface || surface == m_shellSurface) return;
48+
49+ if (!m_surface) {
50+ setSurface(surface);
51+ }
52+ m_shellSurface = surface;
53 }
54
55 bool InputArea::enabled() const
56@@ -75,15 +72,48 @@
57
58 void InputArea::setEnabled(bool enabled)
59 {
60+ DLOG("InputArea::setEnabled (this=%p, enabled=%p)", this, enabled ? "yes" : "no");
61+
62 if (enabled != m_enabled) {
63 m_enabled = enabled;
64 if (m_surface) {
65 m_surface->enableInputArea(this, enabled);
66+ } else if (m_shellSurface) {
67+ m_shellSurface->enableInputArea(this, enabled);
68 }
69 Q_EMIT enabledChanged();
70 }
71 }
72
73+MirSurface *InputArea::surface() const
74+{
75+ return (m_surface) ? m_surface : m_shellSurface;
76+}
77+
78+void InputArea::setSurface(MirSurface *surface)
79+{
80+ DLOG("InputArea::setSurface (this=%p, surface=%p)", this, surface);
81+
82+ if (surface == m_surface) return;
83+
84+ if (m_surface) {
85+ m_surface->removeInputArea(this);
86+ } else {
87+ m_shellSurface->removeInputArea(this);
88+ }
89+
90+ m_surface = surface;
91+
92+ if (m_enabled) {
93+ if (m_surface) {
94+ m_surface->installInputArea(this);
95+ } else {
96+ m_shellSurface->installInputArea(this);
97+ }
98+ }
99+ Q_EMIT surfaceChanged();
100+}
101+
102 void InputArea::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
103 {
104 DLOG("InputArea::geometryChanged (this=%p)", this);
105
106=== modified file 'src/modules/Unity/SurfaceManager/inputarea.h'
107--- src/modules/Unity/SurfaceManager/inputarea.h 2013-08-09 13:16:13 +0000
108+++ src/modules/Unity/SurfaceManager/inputarea.h 2013-08-20 08:39:23 +0000
109@@ -34,16 +34,21 @@
110 {
111 Q_OBJECT
112 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
113+ Q_PROPERTY(MirSurface* surface READ surface WRITE setSurface NOTIFY surfaceChanged) // if not defined, shell surface used
114
115 public:
116 explicit InputArea(QQuickItem *parent = 0);
117 ~InputArea();
118
119 bool enabled() const;
120+ MirSurface *surface() const;
121+
122 void setEnabled(bool enabled);
123+ void setSurface(MirSurface *surface);
124
125 Q_SIGNALS:
126 void enabledChanged();
127+ void surfaceChanged();
128
129 protected:
130 virtual void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
131@@ -51,7 +56,7 @@
132 private Q_SLOTS:
133 void onAscendantChanged();
134 void onAscendantGeometryChanged();
135- void registerWithSurface(MirSurface *surface);
136+ void setShellSurface(MirSurface *surface);
137
138 private:
139 void listenToAscendantsChanges();
140@@ -61,6 +66,7 @@
141 bool m_enabled;
142 QRectF m_geometry;
143 MirSurface* m_surface;
144+ MirSurface* m_shellSurface;
145 mir::geometry::Rectangle m_mirInputArea;
146 QLinkedList<QMetaObject::Connection> m_connections;
147

Subscribers

People subscribed via source and target branches