Merge lp:~gerboland/miral/qt-bump-to-qtmir-529 into lp:miral
- qt-bump-to-qtmir-529
- Merge into trunk
Proposed by
Gerry Boland
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | 239 |
Merged at revision: | 237 |
Proposed branch: | lp:~gerboland/miral/qt-bump-to-qtmir-529 |
Merge into: | lp:miral |
Diff against target: |
1275 lines (+453/-333) 29 files modified
miral-qt/CMakeLists.txt (+2/-3) miral-qt/debian/control (+3/-2) miral-qt/debian/gles-patches/convert-to-gles.patch (+1/-1) miral-qt/src/modules/Unity/Application/CMakeLists.txt (+3/-1) miral-qt/src/modules/Unity/Application/application.cpp (+1/-0) miral-qt/src/modules/Unity/Application/application_manager.cpp (+3/-0) miral-qt/src/modules/Unity/Application/application_manager.h (+2/-0) miral-qt/src/modules/Unity/Application/cgmanager.cpp (+117/-0) miral-qt/src/modules/Unity/Application/cgmanager.h (+42/-0) miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp (+89/-0) miral-qt/src/modules/Unity/Application/dbusfocusinfo.h (+54/-0) miral-qt/src/modules/Unity/Application/mirsurface.cpp (+41/-0) miral-qt/src/modules/Unity/Application/mirsurface.h (+8/-0) miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h (+6/-0) miral-qt/src/modules/Unity/Application/mirsurfaceitem.cpp (+11/-49) miral-qt/src/modules/Unity/Application/mirsurfaceitem.h (+1/-2) miral-qt/src/modules/Unity/Application/plugin.cpp (+0/-10) miral-qt/src/modules/Unity/Application/session.cpp (+17/-0) miral-qt/src/modules/Unity/Application/session.h (+4/-0) miral-qt/src/modules/Unity/Application/session_interface.h (+6/-0) miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.cpp (+0/-173) miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.h (+0/-87) miral-qt/src/platforms/mirserver/logging.cpp (+1/-0) miral-qt/src/platforms/mirserver/logging.h (+1/-0) miral-qt/src/platforms/mirserver/mirwindowmanager.cpp (+9/-4) miral-qt/src/platforms/mirserver/surfaceobserver.cpp (+20/-0) miral-qt/src/platforms/mirserver/surfaceobserver.h (+3/-1) miral-qt/tests/framework/fake_mirsurface.h (+4/-0) miral-qt/tests/framework/fake_session.h (+4/-0) |
To merge this branch: | bzr merge lp:~gerboland/miral/qt-bump-to-qtmir-529 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Approve | ||
Review via email: mp+301168@code.launchpad.net |
Commit message
[miral-qt] Bump to rev 529 of qtmir
Description of the change
To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : | # |
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : | # |
+ QRect inputBounds() const override { return QRect(0,0,10,10); }
Is this really an override? It seems to be missing in the MirSurfaceInterface base class.
review:
Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : | # |
+ void inputBoundsChan
Neither the linker nor I can find the implementation.
review:
Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : | # |
Hmm. A clean rebuild fixed those. (Is there a depends missing somewhere in CMakeLists.txt?)
review:
Approve
Revision history for this message
Gerry Boland (gerboland) wrote : | # |
> DBusFocusInfo *m_dbusFocusInfo
good point, I didn't see it as it landed while I was on hols!
Build fail - am surprised, I bumped the required unity-shell-
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'miral-qt/CMakeLists.txt' | |||
2 | --- miral-qt/CMakeLists.txt 2016-06-21 13:38:53 +0000 | |||
3 | +++ miral-qt/CMakeLists.txt 2016-07-26 12:46:18 +0000 | |||
4 | @@ -90,9 +90,8 @@ | |||
5 | 90 | pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt) | 90 | pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt) |
6 | 91 | pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED) | 91 | pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED) |
7 | 92 | pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED) | 92 | pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED) |
11 | 93 | pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=18) | 93 | pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=19) |
12 | 94 | 94 | pkg_check_modules(CGMANAGER libcgmanager REQUIRED) | |
10 | 95 | include_directories(${APPLICATION_API_INCLUDE_DIRS}) | ||
13 | 96 | 95 | ||
14 | 97 | add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1) | 96 | add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1) |
15 | 98 | 97 | ||
16 | 99 | 98 | ||
17 | === modified file 'miral-qt/debian/control' | |||
18 | --- miral-qt/debian/control 2016-06-21 13:38:53 +0000 | |||
19 | +++ miral-qt/debian/control 2016-07-26 12:46:18 +0000 | |||
20 | @@ -6,6 +6,7 @@ | |||
21 | 6 | cmake-extras (>= 0.3), | 6 | cmake-extras (>= 0.3), |
22 | 7 | debhelper (>= 9), | 7 | debhelper (>= 9), |
23 | 8 | google-mock (>= 1.6.0+svn437), | 8 | google-mock (>= 1.6.0+svn437), |
24 | 9 | libcgmanager-dev, | ||
25 | 9 | libfontconfig1-dev, | 10 | libfontconfig1-dev, |
26 | 10 | libgles2-mesa-dev, | 11 | libgles2-mesa-dev, |
27 | 11 | libglib2.0-dev, | 12 | libglib2.0-dev, |
28 | @@ -22,7 +23,7 @@ | |||
29 | 22 | libubuntu-app-launch2-dev (>= 0.9), | 23 | libubuntu-app-launch2-dev (>= 0.9), |
30 | 23 | libubuntu-application-api-dev (>= 2.1.0), | 24 | libubuntu-application-api-dev (>= 2.1.0), |
31 | 24 | libudev-dev, | 25 | libudev-dev, |
33 | 25 | libunity-api-dev (>= 7.114), | 26 | libunity-api-dev (>= 7.116), |
34 | 26 | liburl-dispatcher1-dev, | 27 | liburl-dispatcher1-dev, |
35 | 27 | libxkbcommon-dev, | 28 | libxkbcommon-dev, |
36 | 28 | libxrender-dev, | 29 | libxrender-dev, |
37 | @@ -93,7 +94,7 @@ | |||
38 | 93 | Conflicts: libqtmir, | 94 | Conflicts: libqtmir, |
39 | 94 | libunity-mir1, | 95 | libunity-mir1, |
40 | 95 | Provides: unity-application-impl, | 96 | Provides: unity-application-impl, |
42 | 96 | unity-application-impl-17, | 97 | unity-application-impl-19, |
43 | 97 | Description: Qt plugin for Unity specific Mir APIs | 98 | Description: Qt plugin for Unity specific Mir APIs |
44 | 98 | QtMir provides Qt/QML bindings for Mir features that are exposed through the | 99 | QtMir provides Qt/QML bindings for Mir features that are exposed through the |
45 | 99 | qtmir-desktop or qtmir-android QPA plugin such as Application management | 100 | qtmir-desktop or qtmir-android QPA plugin such as Application management |
46 | 100 | 101 | ||
47 | === modified file 'miral-qt/debian/gles-patches/convert-to-gles.patch' | |||
48 | --- miral-qt/debian/gles-patches/convert-to-gles.patch 2016-06-07 20:32:04 +0000 | |||
49 | +++ miral-qt/debian/gles-patches/convert-to-gles.patch 2016-07-26 12:46:18 +0000 | |||
50 | @@ -84,7 +84,7 @@ | |||
51 | 84 | -Conflicts: libqtmir, | 84 | -Conflicts: libqtmir, |
52 | 85 | - libunity-mir1, | 85 | - libunity-mir1, |
53 | 86 | -Provides: unity-application-impl, | 86 | -Provides: unity-application-impl, |
55 | 87 | - unity-application-impl-17, | 87 | - unity-application-impl-19, |
56 | 88 | -Description: Qt plugin for Unity specific Mir APIs | 88 | -Description: Qt plugin for Unity specific Mir APIs |
57 | 89 | - QtMir provides Qt/QML bindings for Mir features that are exposed through the | 89 | - QtMir provides Qt/QML bindings for Mir features that are exposed through the |
58 | 90 | - qtmir-desktop or qtmir-android QPA plugin such as Application management | 90 | - qtmir-desktop or qtmir-android QPA plugin such as Application management |
59 | 91 | 91 | ||
60 | === modified file 'miral-qt/src/modules/Unity/Application/CMakeLists.txt' | |||
61 | --- miral-qt/src/modules/Unity/Application/CMakeLists.txt 2016-06-01 22:06:51 +0000 | |||
62 | +++ miral-qt/src/modules/Unity/Application/CMakeLists.txt 2016-07-26 12:46:18 +0000 | |||
63 | @@ -10,6 +10,7 @@ | |||
64 | 10 | ${MIRAL_QT_SOURCE_DIR}/src/platforms/mirserver | 10 | ${MIRAL_QT_SOURCE_DIR}/src/platforms/mirserver |
65 | 11 | ${MIRAL_QT_SOURCE_DIR}/src/common | 11 | ${MIRAL_QT_SOURCE_DIR}/src/common |
66 | 12 | ${GSETTINGS_QT_INCLUDE_DIRS} | 12 | ${GSETTINGS_QT_INCLUDE_DIRS} |
67 | 13 | ${CGMANAGER_INCLUDE_DIRS} | ||
68 | 13 | 14 | ||
69 | 14 | ${LTTNG_INCLUDE_DIRS} | 15 | ${LTTNG_INCLUDE_DIRS} |
70 | 15 | ${Qt5Gui_PRIVATE_INCLUDE_DIRS} | 16 | ${Qt5Gui_PRIVATE_INCLUDE_DIRS} |
71 | @@ -25,12 +26,13 @@ | |||
72 | 25 | set(QMLMIRPLUGIN_SRC | 26 | set(QMLMIRPLUGIN_SRC |
73 | 26 | application_manager.cpp | 27 | application_manager.cpp |
74 | 27 | application.cpp | 28 | application.cpp |
75 | 29 | cgmanager.cpp | ||
76 | 28 | ../../../common/abstractdbusservicemonitor.cpp | 30 | ../../../common/abstractdbusservicemonitor.cpp |
77 | 29 | ../../../common/debughelpers.cpp | 31 | ../../../common/debughelpers.cpp |
78 | 32 | dbusfocusinfo.cpp | ||
79 | 30 | plugin.cpp | 33 | plugin.cpp |
80 | 31 | dbuswindowstack.cpp | 34 | dbuswindowstack.cpp |
81 | 32 | mirsurfacemanager.cpp | 35 | mirsurfacemanager.cpp |
82 | 33 | ubuntukeyboardinfo.cpp | ||
83 | 34 | mirfocuscontroller.cpp | 36 | mirfocuscontroller.cpp |
84 | 35 | mirsurface.cpp | 37 | mirsurface.cpp |
85 | 36 | mirsurfaceinterface.h | 38 | mirsurfaceinterface.h |
86 | 37 | 39 | ||
87 | === modified file 'miral-qt/src/modules/Unity/Application/application.cpp' | |||
88 | --- miral-qt/src/modules/Unity/Application/application.cpp 2016-06-21 13:38:53 +0000 | |||
89 | +++ miral-qt/src/modules/Unity/Application/application.cpp 2016-07-26 12:46:18 +0000 | |||
90 | @@ -18,6 +18,7 @@ | |||
91 | 18 | #include "application.h" | 18 | #include "application.h" |
92 | 19 | #include "applicationinfo.h" | 19 | #include "applicationinfo.h" |
93 | 20 | #include "application_manager.h" | 20 | #include "application_manager.h" |
94 | 21 | #include "mirsurfaceinterface.h" | ||
95 | 21 | #include "session.h" | 22 | #include "session.h" |
96 | 22 | #include "sharedwakelock.h" | 23 | #include "sharedwakelock.h" |
97 | 23 | #include "timer.h" | 24 | #include "timer.h" |
98 | 24 | 25 | ||
99 | === modified file 'miral-qt/src/modules/Unity/Application/application_manager.cpp' | |||
100 | --- miral-qt/src/modules/Unity/Application/application_manager.cpp 2016-06-01 22:06:51 +0000 | |||
101 | +++ miral-qt/src/modules/Unity/Application/application_manager.cpp 2016-07-26 12:46:18 +0000 | |||
102 | @@ -18,6 +18,7 @@ | |||
103 | 18 | #include "application_manager.h" | 18 | #include "application_manager.h" |
104 | 19 | #include "application.h" | 19 | #include "application.h" |
105 | 20 | #include "applicationinfo.h" | 20 | #include "applicationinfo.h" |
106 | 21 | #include "dbusfocusinfo.h" | ||
107 | 21 | #include "dbuswindowstack.h" | 22 | #include "dbuswindowstack.h" |
108 | 22 | #include "mirfocuscontroller.h" | 23 | #include "mirfocuscontroller.h" |
109 | 23 | #include "session.h" | 24 | #include "session.h" |
110 | @@ -176,6 +177,7 @@ | |||
111 | 176 | const QSharedPointer<SettingsInterface>& settings, | 177 | const QSharedPointer<SettingsInterface>& settings, |
112 | 177 | QObject *parent) | 178 | QObject *parent) |
113 | 178 | : ApplicationManagerInterface(parent) | 179 | : ApplicationManagerInterface(parent) |
114 | 180 | , m_dbusFocusInfo(new DBusFocusInfo(m_applications)) | ||
115 | 179 | , m_dbusWindowStack(new DBusWindowStack(this)) | 181 | , m_dbusWindowStack(new DBusWindowStack(this)) |
116 | 180 | , m_taskController(taskController) | 182 | , m_taskController(taskController) |
117 | 181 | , m_procInfo(procInfo) | 183 | , m_procInfo(procInfo) |
118 | @@ -200,6 +202,7 @@ | |||
119 | 200 | ApplicationManager::~ApplicationManager() | 202 | ApplicationManager::~ApplicationManager() |
120 | 201 | { | 203 | { |
121 | 202 | qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::~ApplicationManager"; | 204 | qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::~ApplicationManager"; |
122 | 205 | delete m_dbusFocusInfo; | ||
123 | 203 | } | 206 | } |
124 | 204 | 207 | ||
125 | 205 | int ApplicationManager::rowCount(const QModelIndex &parent) const | 208 | int ApplicationManager::rowCount(const QModelIndex &parent) const |
126 | 206 | 209 | ||
127 | === modified file 'miral-qt/src/modules/Unity/Application/application_manager.h' | |||
128 | --- miral-qt/src/modules/Unity/Application/application_manager.h 2016-06-01 22:06:51 +0000 | |||
129 | +++ miral-qt/src/modules/Unity/Application/application_manager.h 2016-07-26 12:46:18 +0000 | |||
130 | @@ -49,6 +49,7 @@ | |||
131 | 49 | 49 | ||
132 | 50 | namespace qtmir { | 50 | namespace qtmir { |
133 | 51 | 51 | ||
134 | 52 | class DBusFocusInfo; | ||
135 | 52 | class DBusWindowStack; | 53 | class DBusWindowStack; |
136 | 53 | class MirSurfaceManager; | 54 | class MirSurfaceManager; |
137 | 54 | class ProcInfo; | 55 | class ProcInfo; |
138 | @@ -138,6 +139,7 @@ | |||
139 | 138 | Application *findApplication(MirSurfaceInterface* surface); | 139 | Application *findApplication(MirSurfaceInterface* surface); |
140 | 139 | 140 | ||
141 | 140 | QList<Application*> m_applications; | 141 | QList<Application*> m_applications; |
142 | 142 | DBusFocusInfo *m_dbusFocusInfo; | ||
143 | 141 | DBusWindowStack* m_dbusWindowStack; | 143 | DBusWindowStack* m_dbusWindowStack; |
144 | 142 | QSharedPointer<TaskController> m_taskController; | 144 | QSharedPointer<TaskController> m_taskController; |
145 | 143 | QSharedPointer<ProcInfo> m_procInfo; | 145 | QSharedPointer<ProcInfo> m_procInfo; |
146 | 144 | 146 | ||
147 | === added file 'miral-qt/src/modules/Unity/Application/cgmanager.cpp' | |||
148 | --- miral-qt/src/modules/Unity/Application/cgmanager.cpp 1970-01-01 00:00:00 +0000 | |||
149 | +++ miral-qt/src/modules/Unity/Application/cgmanager.cpp 2016-07-26 12:46:18 +0000 | |||
150 | @@ -0,0 +1,117 @@ | |||
151 | 1 | /* | ||
152 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
153 | 3 | * | ||
154 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
155 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
156 | 6 | * the Free Software Foundation. | ||
157 | 7 | * | ||
158 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
159 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
160 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
161 | 11 | * Lesser General Public License for more details. | ||
162 | 12 | * | ||
163 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
164 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
165 | 15 | */ | ||
166 | 16 | |||
167 | 17 | #include "cgmanager.h" | ||
168 | 18 | |||
169 | 19 | // QPA mirserver | ||
170 | 20 | #include <logging.h> | ||
171 | 21 | |||
172 | 22 | #include <cgmanager/cgmanager.h> | ||
173 | 23 | |||
174 | 24 | #include <QDBusArgument> | ||
175 | 25 | #include <QDBusMessage> | ||
176 | 26 | |||
177 | 27 | using namespace qtmir; | ||
178 | 28 | |||
179 | 29 | // According to D-Bus interface defined in: | ||
180 | 30 | // https://github.com/lxc/cgmanager/blob/master/org.linuxcontainers.cgmanager.xml | ||
181 | 31 | |||
182 | 32 | CGManager::CGManager(QObject *parent) | ||
183 | 33 | : QObject(parent) | ||
184 | 34 | { | ||
185 | 35 | } | ||
186 | 36 | |||
187 | 37 | CGManager::~CGManager() | ||
188 | 38 | { | ||
189 | 39 | QDBusConnection::disconnectFromPeer("cgmanager"); | ||
190 | 40 | } | ||
191 | 41 | |||
192 | 42 | QDBusConnection CGManager::getConnection() | ||
193 | 43 | { | ||
194 | 44 | auto connection = QDBusConnection("cgmanager"); | ||
195 | 45 | |||
196 | 46 | if (!connection.isConnected()) { | ||
197 | 47 | connection = QDBusConnection::connectToPeer(CGMANAGER_DBUS_PATH, "cgmanager"); | ||
198 | 48 | if (!connection.isConnected()) { | ||
199 | 49 | qCWarning(QTMIR_DBUS, "CGManager: Failed to connect to %s", CGMANAGER_DBUS_PATH); | ||
200 | 50 | } | ||
201 | 51 | } | ||
202 | 52 | |||
203 | 53 | return connection; | ||
204 | 54 | } | ||
205 | 55 | |||
206 | 56 | QString CGManager::getCGroupOfPid(const QString &controller, pid_t pid) | ||
207 | 57 | { | ||
208 | 58 | auto connection = getConnection(); | ||
209 | 59 | if (!connection.isConnected()) { | ||
210 | 60 | return QString(); | ||
211 | 61 | } | ||
212 | 62 | |||
213 | 63 | auto message = QDBusMessage::createMethodCall(QString() /*service*/, m_path, m_interface, "GetPidCgroup"); | ||
214 | 64 | |||
215 | 65 | QList<QVariant> arguments; | ||
216 | 66 | arguments << QVariant(controller); | ||
217 | 67 | arguments << QVariant((int)pid); | ||
218 | 68 | |||
219 | 69 | message.setArguments(arguments); | ||
220 | 70 | |||
221 | 71 | QDBusMessage reply = connection.call(message); | ||
222 | 72 | |||
223 | 73 | if (reply.type() == QDBusMessage::ReplyMessage) { | ||
224 | 74 | return reply.arguments()[0].toString(); | ||
225 | 75 | } else { | ||
226 | 76 | Q_ASSERT(reply.type() == QDBusMessage::ErrorMessage); | ||
227 | 77 | qCWarning(QTMIR_DBUS) << "CGManager::getCGroupOfPid failed." << reply.errorMessage(); | ||
228 | 78 | return QString(); | ||
229 | 79 | } | ||
230 | 80 | } | ||
231 | 81 | |||
232 | 82 | QSet<pid_t> CGManager::getTasks(const QString &controller, const QString &cgroup) | ||
233 | 83 | { | ||
234 | 84 | auto connection = getConnection(); | ||
235 | 85 | if (!connection.isConnected()) { | ||
236 | 86 | return QSet<pid_t>(); | ||
237 | 87 | } | ||
238 | 88 | |||
239 | 89 | auto message = QDBusMessage::createMethodCall(QString() /*service*/, m_path, m_interface, "GetTasks"); | ||
240 | 90 | |||
241 | 91 | QList<QVariant> arguments; | ||
242 | 92 | arguments << QVariant(controller); | ||
243 | 93 | arguments << QVariant(cgroup); | ||
244 | 94 | |||
245 | 95 | message.setArguments(arguments); | ||
246 | 96 | |||
247 | 97 | QDBusMessage reply = connection.call(message); | ||
248 | 98 | |||
249 | 99 | if (reply.type() == QDBusMessage::ErrorMessage) { | ||
250 | 100 | qCWarning(QTMIR_DBUS) << "CGManager::getCGroupOfPid failed." << reply.errorMessage(); | ||
251 | 101 | return QSet<pid_t>(); | ||
252 | 102 | } | ||
253 | 103 | |||
254 | 104 | Q_ASSERT(reply.type() == QDBusMessage::ReplyMessage); | ||
255 | 105 | |||
256 | 106 | auto arg = reply.arguments()[0].value<QDBusArgument>(); | ||
257 | 107 | Q_ASSERT(arg.currentType() == QDBusArgument::ArrayType); | ||
258 | 108 | |||
259 | 109 | auto pidList = qdbus_cast<QList<int>>(arg); | ||
260 | 110 | Q_ASSERT(pidList.count() > 0); | ||
261 | 111 | |||
262 | 112 | QSet<pid_t> pidSet; | ||
263 | 113 | for (int i = 0; i < pidList.count(); ++i) { | ||
264 | 114 | pidSet << (pid_t)pidList[i]; | ||
265 | 115 | } | ||
266 | 116 | return pidSet; | ||
267 | 117 | } | ||
268 | 0 | 118 | ||
269 | === added file 'miral-qt/src/modules/Unity/Application/cgmanager.h' | |||
270 | --- miral-qt/src/modules/Unity/Application/cgmanager.h 1970-01-01 00:00:00 +0000 | |||
271 | +++ miral-qt/src/modules/Unity/Application/cgmanager.h 2016-07-26 12:46:18 +0000 | |||
272 | @@ -0,0 +1,42 @@ | |||
273 | 1 | /* | ||
274 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
275 | 3 | * | ||
276 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
277 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
278 | 6 | * the Free Software Foundation. | ||
279 | 7 | * | ||
280 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
281 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
282 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
283 | 11 | * Lesser General Public License for more details. | ||
284 | 12 | * | ||
285 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
286 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
287 | 15 | */ | ||
288 | 16 | |||
289 | 17 | #ifndef QTMIR_CGMANAGER_H | ||
290 | 18 | #define QTMIR_CGMANAGER_H | ||
291 | 19 | |||
292 | 20 | #include <QDBusConnection> | ||
293 | 21 | |||
294 | 22 | namespace qtmir { | ||
295 | 23 | |||
296 | 24 | class CGManager : public QObject { | ||
297 | 25 | Q_OBJECT | ||
298 | 26 | public: | ||
299 | 27 | CGManager(QObject *parent = nullptr); | ||
300 | 28 | virtual ~CGManager(); | ||
301 | 29 | |||
302 | 30 | QString getCGroupOfPid(const QString &controller, pid_t pid); | ||
303 | 31 | |||
304 | 32 | QSet<pid_t> getTasks(const QString &controller, const QString &cgroup); | ||
305 | 33 | |||
306 | 34 | private: | ||
307 | 35 | const QString m_interface{"org.linuxcontainers.cgmanager0_0"}; | ||
308 | 36 | const QString m_path{"/org/linuxcontainers/cgmanager"}; | ||
309 | 37 | QDBusConnection getConnection(); | ||
310 | 38 | }; | ||
311 | 39 | |||
312 | 40 | } // namespace qtmir | ||
313 | 41 | |||
314 | 42 | #endif // QTMIR_CGMANAGER_H | ||
315 | 0 | 43 | ||
316 | === added file 'miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp' | |||
317 | --- miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp 1970-01-01 00:00:00 +0000 | |||
318 | +++ miral-qt/src/modules/Unity/Application/dbusfocusinfo.cpp 2016-07-26 12:46:18 +0000 | |||
319 | @@ -0,0 +1,89 @@ | |||
320 | 1 | /* | ||
321 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
322 | 3 | * | ||
323 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
324 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
325 | 6 | * the Free Software Foundation. | ||
326 | 7 | * | ||
327 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
328 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
329 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
330 | 11 | * Lesser General Public License for more details. | ||
331 | 12 | * | ||
332 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
333 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
334 | 15 | */ | ||
335 | 16 | |||
336 | 17 | #include "dbusfocusinfo.h" | ||
337 | 18 | |||
338 | 19 | // local | ||
339 | 20 | #include "cgmanager.h" | ||
340 | 21 | |||
341 | 22 | // QPA mirserver | ||
342 | 23 | #include <logging.h> | ||
343 | 24 | |||
344 | 25 | #include <QDBusConnection> | ||
345 | 26 | |||
346 | 27 | using namespace qtmir; | ||
347 | 28 | |||
348 | 29 | DBusFocusInfo::DBusFocusInfo(const QList<Application*> &applications) | ||
349 | 30 | : m_applications(applications) | ||
350 | 31 | { | ||
351 | 32 | QDBusConnection::sessionBus().registerService("com.canonical.Unity.FocusInfo"); | ||
352 | 33 | QDBusConnection::sessionBus().registerObject("/com/canonical/Unity/FocusInfo", this, QDBusConnection::ExportScriptableSlots); | ||
353 | 34 | |||
354 | 35 | m_cgManager = new CGManager(this); | ||
355 | 36 | } | ||
356 | 37 | |||
357 | 38 | bool DBusFocusInfo::isPidFocused(unsigned int pid) | ||
358 | 39 | { | ||
359 | 40 | if (QCoreApplication::applicationPid() == (qint64)pid) { | ||
360 | 41 | // Shell itself. | ||
361 | 42 | // Don't bother checking if it has a QML with activeFocus() which is not a MirSurfaceItem. | ||
362 | 43 | return true; | ||
363 | 44 | } else { | ||
364 | 45 | auto pidSet = fetchAssociatedPids((pid_t)pid); | ||
365 | 46 | SessionInterface *session = findSessionWithPid(pidSet); | ||
366 | 47 | return session ? session->activeFocus() : false; | ||
367 | 48 | } | ||
368 | 49 | } | ||
369 | 50 | |||
370 | 51 | QSet<pid_t> DBusFocusInfo::fetchAssociatedPids(pid_t pid) | ||
371 | 52 | { | ||
372 | 53 | QString cgroup = m_cgManager->getCGroupOfPid("freezer", pid); | ||
373 | 54 | |||
374 | 55 | // If a cgroup has a format like this: | ||
375 | 56 | // /user.slice/user-32011.slice/session-c3.scope/upstart/application-legacy-puritine_gedit_0.0- | ||
376 | 57 | // All PIds in it are associated with a single application. | ||
377 | 58 | if (cgroup.split("/").contains("upstart")) { | ||
378 | 59 | QSet<pid_t> pidSet = m_cgManager->getTasks("freezer", cgroup); | ||
379 | 60 | qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "is in cgroup" << cgroup << "along with:" << pidSet; | ||
380 | 61 | if (pidSet.isEmpty()) { | ||
381 | 62 | pidSet << pid; | ||
382 | 63 | } | ||
383 | 64 | return pidSet; | ||
384 | 65 | } else { | ||
385 | 66 | qCDebug(QTMIR_DBUS) << "DBusFocusInfo: pid" << pid << "is in cgroup" << cgroup << "which is not app-specific"; | ||
386 | 67 | return QSet<pid_t>({pid}); | ||
387 | 68 | } | ||
388 | 69 | } | ||
389 | 70 | |||
390 | 71 | SessionInterface* DBusFocusInfo::findSessionWithPid(const QSet<pid_t> &pidSet) | ||
391 | 72 | { | ||
392 | 73 | Q_FOREACH (Application* application, m_applications) { | ||
393 | 74 | auto session = application->session(); | ||
394 | 75 | if (pidSet.contains(session->pid())) { | ||
395 | 76 | return session; | ||
396 | 77 | } | ||
397 | 78 | SessionInterface *chosenChildSession = nullptr; | ||
398 | 79 | session->foreachChildSession([&](SessionInterface* childSession) { | ||
399 | 80 | if (pidSet.contains(childSession->pid())) { | ||
400 | 81 | chosenChildSession = childSession; | ||
401 | 82 | } | ||
402 | 83 | }); | ||
403 | 84 | if (chosenChildSession) { | ||
404 | 85 | return chosenChildSession; | ||
405 | 86 | } | ||
406 | 87 | } | ||
407 | 88 | return nullptr; | ||
408 | 89 | } | ||
409 | 0 | 90 | ||
410 | === added file 'miral-qt/src/modules/Unity/Application/dbusfocusinfo.h' | |||
411 | --- miral-qt/src/modules/Unity/Application/dbusfocusinfo.h 1970-01-01 00:00:00 +0000 | |||
412 | +++ miral-qt/src/modules/Unity/Application/dbusfocusinfo.h 2016-07-26 12:46:18 +0000 | |||
413 | @@ -0,0 +1,54 @@ | |||
414 | 1 | /* | ||
415 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
416 | 3 | * | ||
417 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
418 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
419 | 6 | * the Free Software Foundation. | ||
420 | 7 | * | ||
421 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
422 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
423 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
424 | 11 | * Lesser General Public License for more details. | ||
425 | 12 | * | ||
426 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
427 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
428 | 15 | */ | ||
429 | 16 | |||
430 | 17 | #include <QList> | ||
431 | 18 | #include <QSet> | ||
432 | 19 | |||
433 | 20 | #include "application.h" | ||
434 | 21 | |||
435 | 22 | namespace qtmir { | ||
436 | 23 | |||
437 | 24 | class CGManager; | ||
438 | 25 | |||
439 | 26 | /* | ||
440 | 27 | FIXME: This is a hack to provide OSK with needed info for avoiding input snooping. | ||
441 | 28 | Remove when possible | ||
442 | 29 | */ | ||
443 | 30 | class DBusFocusInfo : public QObject | ||
444 | 31 | { | ||
445 | 32 | Q_OBJECT | ||
446 | 33 | Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.FocusInfo") | ||
447 | 34 | public: | ||
448 | 35 | explicit DBusFocusInfo(const QList<Application*> &applications); | ||
449 | 36 | virtual ~DBusFocusInfo() {} | ||
450 | 37 | |||
451 | 38 | public Q_SLOTS: | ||
452 | 39 | |||
453 | 40 | /* | ||
454 | 41 | Returns true if the application with the given PID has input focus | ||
455 | 42 | */ | ||
456 | 43 | Q_SCRIPTABLE bool isPidFocused(unsigned int pid); | ||
457 | 44 | |||
458 | 45 | private: | ||
459 | 46 | QSet<pid_t> fetchAssociatedPids(pid_t pid); | ||
460 | 47 | SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet); | ||
461 | 48 | |||
462 | 49 | const QList<Application*> &m_applications; | ||
463 | 50 | |||
464 | 51 | CGManager *m_cgManager; | ||
465 | 52 | }; | ||
466 | 53 | |||
467 | 54 | } // namespace qtmir | ||
468 | 0 | 55 | ||
469 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurface.cpp' | |||
470 | --- miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-07-25 13:48:41 +0000 | |||
471 | +++ miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-07-26 12:46:18 +0000 | |||
472 | @@ -219,6 +219,7 @@ | |||
473 | 219 | connect(observer.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) { | 219 | connect(observer.get(), &SurfaceObserver::shellChromeChanged, this, [&](MirShellChrome shell_chrome) { |
474 | 220 | setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome)); | 220 | setShellChrome(static_cast<Mir::ShellChrome>(shell_chrome)); |
475 | 221 | }); | 221 | }); |
476 | 222 | connect(observer.get(), &SurfaceObserver::inputBoundsChanged, this, &MirSurface::setInputBounds); | ||
477 | 222 | observer->setListener(this); | 223 | observer->setListener(this); |
478 | 223 | } | 224 | } |
479 | 224 | 225 | ||
480 | @@ -277,12 +278,15 @@ | |||
481 | 277 | { | 278 | { |
482 | 278 | switch (attribute) { | 279 | switch (attribute) { |
483 | 279 | case mir_surface_attrib_type: | 280 | case mir_surface_attrib_type: |
484 | 281 | DEBUG_MSG << " type = " << mirSurfaceTypeToStr(state()); | ||
485 | 280 | Q_EMIT typeChanged(type()); | 282 | Q_EMIT typeChanged(type()); |
486 | 281 | break; | 283 | break; |
487 | 282 | case mir_surface_attrib_state: | 284 | case mir_surface_attrib_state: |
488 | 285 | DEBUG_MSG << " state = " << mirSurfaceStateToStr(state()); | ||
489 | 283 | Q_EMIT stateChanged(state()); | 286 | Q_EMIT stateChanged(state()); |
490 | 284 | break; | 287 | break; |
491 | 285 | case mir_surface_attrib_visibility: | 288 | case mir_surface_attrib_visibility: |
492 | 289 | DEBUG_MSG << " visible = " << visible(); | ||
493 | 286 | Q_EMIT visibleChanged(visible()); | 290 | Q_EMIT visibleChanged(visible()); |
494 | 287 | break; | 291 | break; |
495 | 288 | default: | 292 | default: |
496 | @@ -453,6 +457,11 @@ | |||
497 | 453 | } | 457 | } |
498 | 454 | } | 458 | } |
499 | 455 | 459 | ||
500 | 460 | bool MirSurface::activeFocus() const | ||
501 | 461 | { | ||
502 | 462 | return !m_activelyFocusedViews.empty(); | ||
503 | 463 | } | ||
504 | 464 | |||
505 | 456 | void MirSurface::updateActiveFocus() | 465 | void MirSurface::updateActiveFocus() |
506 | 457 | { | 466 | { |
507 | 458 | if (!m_session) { | 467 | if (!m_session) { |
508 | @@ -871,6 +880,24 @@ | |||
509 | 871 | } | 880 | } |
510 | 872 | } | 881 | } |
511 | 873 | 882 | ||
512 | 883 | bool MirSurface::inputAreaContains(const QPoint &point) const | ||
513 | 884 | { | ||
514 | 885 | bool result; | ||
515 | 886 | |||
516 | 887 | |||
517 | 888 | // Can't use it due to https://bugs.launchpad.net/mir/+bug/1598936 | ||
518 | 889 | // FIXME: Use the line below instead of m_inputBounds once this bug gets fixed. | ||
519 | 890 | //result = m_surface->input_area_contains(mir::geometry::Point(point.x(), point.y())); | ||
520 | 891 | |||
521 | 892 | if (m_inputBounds.isNull()) { | ||
522 | 893 | result = true; | ||
523 | 894 | } else { | ||
524 | 895 | result = m_inputBounds.contains(point); | ||
525 | 896 | } | ||
526 | 897 | |||
527 | 898 | return result; | ||
528 | 899 | } | ||
529 | 900 | |||
530 | 874 | void MirSurface::setCursor(const QCursor &cursor) | 901 | void MirSurface::setCursor(const QCursor &cursor) |
531 | 875 | { | 902 | { |
532 | 876 | DEBUG_MSG << "(" << qtCursorShapeToStr(cursor.shape()) << ")"; | 903 | DEBUG_MSG << "(" << qtCursorShapeToStr(cursor.shape()) << ")"; |
533 | @@ -962,6 +989,11 @@ | |||
534 | 962 | return m_focused; | 989 | return m_focused; |
535 | 963 | } | 990 | } |
536 | 964 | 991 | ||
537 | 992 | QRect MirSurface::inputBounds() const | ||
538 | 993 | { | ||
539 | 994 | return m_inputBounds; | ||
540 | 995 | } | ||
541 | 996 | |||
542 | 965 | void MirSurface::requestFocus() | 997 | void MirSurface::requestFocus() |
543 | 966 | { | 998 | { |
544 | 967 | DEBUG_MSG << "()"; | 999 | DEBUG_MSG << "()"; |
545 | @@ -1003,3 +1035,12 @@ | |||
546 | 1003 | m_closeTimer->start(); | 1035 | m_closeTimer->start(); |
547 | 1004 | } | 1036 | } |
548 | 1005 | } | 1037 | } |
549 | 1038 | |||
550 | 1039 | void MirSurface::setInputBounds(const QRect &rect) | ||
551 | 1040 | { | ||
552 | 1041 | if (m_inputBounds != rect) { | ||
553 | 1042 | DEBUG_MSG << "(" << rect << ")"; | ||
554 | 1043 | m_inputBounds = rect; | ||
555 | 1044 | Q_EMIT inputBoundsChanged(m_inputBounds); | ||
556 | 1045 | } | ||
557 | 1046 | } | ||
558 | 1006 | 1047 | ||
559 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurface.h' | |||
560 | --- miral-qt/src/modules/Unity/Application/mirsurface.h 2016-07-25 13:48:41 +0000 | |||
561 | +++ miral-qt/src/modules/Unity/Application/mirsurface.h 2016-07-26 12:46:18 +0000 | |||
562 | @@ -24,6 +24,7 @@ | |||
563 | 24 | #include <QCursor> | 24 | #include <QCursor> |
564 | 25 | #include <QMutex> | 25 | #include <QMutex> |
565 | 26 | #include <QPointer> | 26 | #include <QPointer> |
566 | 27 | #include <QRect> | ||
567 | 27 | #include <QSharedPointer> | 28 | #include <QSharedPointer> |
568 | 28 | #include <QWeakPointer> | 29 | #include <QWeakPointer> |
569 | 29 | #include <QSet> | 30 | #include <QSet> |
570 | @@ -89,6 +90,7 @@ | |||
571 | 89 | int heightIncrement() const override; | 90 | int heightIncrement() const override; |
572 | 90 | 91 | ||
573 | 91 | bool focused() const override; | 92 | bool focused() const override; |
574 | 93 | QRect inputBounds() const override; | ||
575 | 92 | 94 | ||
576 | 93 | Q_INVOKABLE void requestFocus() override; | 95 | Q_INVOKABLE void requestFocus() override; |
577 | 94 | Q_INVOKABLE void close() override; | 96 | Q_INVOKABLE void close() override; |
578 | @@ -121,6 +123,7 @@ | |||
579 | 121 | void setFocused(bool focus) override; | 123 | void setFocused(bool focus) override; |
580 | 122 | 124 | ||
581 | 123 | void setViewActiveFocus(qintptr viewId, bool value) override; | 125 | void setViewActiveFocus(qintptr viewId, bool value) override; |
582 | 126 | bool activeFocus() const override; | ||
583 | 124 | 127 | ||
584 | 125 | void mousePressEvent(QMouseEvent *event) override; | 128 | void mousePressEvent(QMouseEvent *event) override; |
585 | 126 | void mouseMoveEvent(QMouseEvent *event) override; | 129 | void mouseMoveEvent(QMouseEvent *event) override; |
586 | @@ -149,6 +152,8 @@ | |||
587 | 149 | 152 | ||
588 | 150 | SessionInterface* session() override { return m_session.data(); } | 153 | SessionInterface* session() override { return m_session.data(); } |
589 | 151 | 154 | ||
590 | 155 | bool inputAreaContains(const QPoint &) const override; | ||
591 | 156 | |||
592 | 152 | //// | 157 | //// |
593 | 153 | // Own API | 158 | // Own API |
594 | 154 | 159 | ||
595 | @@ -174,6 +179,7 @@ | |||
596 | 174 | void emitSizeChanged(); | 179 | void emitSizeChanged(); |
597 | 175 | void setCursor(const QCursor &cursor); | 180 | void setCursor(const QCursor &cursor); |
598 | 176 | void onCloseTimedOut(); | 181 | void onCloseTimedOut(); |
599 | 182 | void setInputBounds(const QRect &rect); | ||
600 | 177 | 183 | ||
601 | 178 | private: | 184 | private: |
602 | 179 | void syncSurfaceSizeWithItemSize(); | 185 | void syncSurfaceSizeWithItemSize(); |
603 | @@ -223,6 +229,8 @@ | |||
604 | 223 | int m_widthIncrement{0}; | 229 | int m_widthIncrement{0}; |
605 | 224 | int m_heightIncrement{0}; | 230 | int m_heightIncrement{0}; |
606 | 225 | 231 | ||
607 | 232 | QRect m_inputBounds; | ||
608 | 233 | |||
609 | 226 | bool m_focused{false}; | 234 | bool m_focused{false}; |
610 | 227 | 235 | ||
611 | 228 | enum ClosingState { | 236 | enum ClosingState { |
612 | 229 | 237 | ||
613 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h' | |||
614 | --- miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h 2016-07-25 13:48:41 +0000 | |||
615 | +++ miral-qt/src/modules/Unity/Application/mirsurfaceinterface.h 2016-07-26 12:46:18 +0000 | |||
616 | @@ -77,6 +77,10 @@ | |||
617 | 77 | the name. | 77 | the name. |
618 | 78 | */ | 78 | */ |
619 | 79 | virtual void setViewActiveFocus(qintptr viewId, bool value) = 0; | 79 | virtual void setViewActiveFocus(qintptr viewId, bool value) = 0; |
620 | 80 | /* | ||
621 | 81 | Whether any view of this surface currently has QML active focus | ||
622 | 82 | */ | ||
623 | 83 | virtual bool activeFocus() const = 0; | ||
624 | 80 | 84 | ||
625 | 81 | virtual void mousePressEvent(QMouseEvent *event) = 0; | 85 | virtual void mousePressEvent(QMouseEvent *event) = 0; |
626 | 82 | virtual void mouseMoveEvent(QMouseEvent *event) = 0; | 86 | virtual void mouseMoveEvent(QMouseEvent *event) = 0; |
627 | @@ -100,6 +104,8 @@ | |||
628 | 100 | 104 | ||
629 | 101 | virtual SessionInterface* session() = 0; | 105 | virtual SessionInterface* session() = 0; |
630 | 102 | 106 | ||
631 | 107 | virtual bool inputAreaContains(const QPoint &) const = 0; | ||
632 | 108 | |||
633 | 103 | public Q_SLOTS: | 109 | public Q_SLOTS: |
634 | 104 | virtual void onCompositorSwappedBuffers() = 0; | 110 | virtual void onCompositorSwappedBuffers() = 0; |
635 | 105 | 111 | ||
636 | 106 | 112 | ||
637 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurfaceitem.cpp' | |||
638 | --- miral-qt/src/modules/Unity/Application/mirsurfaceitem.cpp 2016-07-25 13:48:41 +0000 | |||
639 | +++ miral-qt/src/modules/Unity/Application/mirsurfaceitem.cpp 2016-07-26 12:46:18 +0000 | |||
640 | @@ -20,7 +20,6 @@ | |||
641 | 20 | #include "mirsurfaceitem.h" | 20 | #include "mirsurfaceitem.h" |
642 | 21 | #include "mirfocuscontroller.h" | 21 | #include "mirfocuscontroller.h" |
643 | 22 | #include "logging.h" | 22 | #include "logging.h" |
644 | 23 | #include "ubuntukeyboardinfo.h" | ||
645 | 24 | #include "tracepoints.h" // generated from tracepoints.tp | 23 | #include "tracepoints.h" // generated from tracepoints.tp |
646 | 25 | #include "timestamp.h" | 24 | #include "timestamp.h" |
647 | 26 | 25 | ||
648 | @@ -103,10 +102,6 @@ | |||
649 | 103 | setSmooth(true); | 102 | setSmooth(true); |
650 | 104 | setFlag(QQuickItem::ItemHasContents, true); //so scene graph will render this item | 103 | setFlag(QQuickItem::ItemHasContents, true); //so scene graph will render this item |
651 | 105 | 104 | ||
652 | 106 | if (!UbuntuKeyboardInfo::instance()) { | ||
653 | 107 | new UbuntuKeyboardInfo; | ||
654 | 108 | } | ||
655 | 109 | |||
656 | 110 | m_updateMirSurfaceSizeTimer.setSingleShot(true); | 105 | m_updateMirSurfaceSizeTimer.setSingleShot(true); |
657 | 111 | m_updateMirSurfaceSizeTimer.setInterval(1); | 106 | m_updateMirSurfaceSizeTimer.setInterval(1); |
658 | 112 | connect(&m_updateMirSurfaceSizeTimer, &QTimer::timeout, this, &MirSurfaceItem::updateMirSurfaceSize); | 107 | connect(&m_updateMirSurfaceSizeTimer, &QTimer::timeout, this, &MirSurfaceItem::updateMirSurfaceSize); |
659 | @@ -290,17 +285,9 @@ | |||
660 | 290 | 285 | ||
661 | 291 | void MirSurfaceItem::mousePressEvent(QMouseEvent *event) | 286 | void MirSurfaceItem::mousePressEvent(QMouseEvent *event) |
662 | 292 | { | 287 | { |
674 | 293 | if (m_consumesInput && m_surface && m_surface->live()) { | 288 | auto mousePos = event->localPos().toPoint(); |
675 | 294 | if (type() == Mir::InputMethodType) { | 289 | if (m_consumesInput && m_surface && m_surface->live() && m_surface->inputAreaContains(mousePos)) { |
676 | 295 | // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place. | 290 | m_surface->mousePressEvent(event); |
666 | 296 | if (isMouseInsideUbuntuKeyboard(event)) { | ||
667 | 297 | m_surface->mousePressEvent(event); | ||
668 | 298 | } else { | ||
669 | 299 | event->ignore(); | ||
670 | 300 | } | ||
671 | 301 | } else { | ||
672 | 302 | m_surface->mousePressEvent(event); | ||
673 | 303 | } | ||
677 | 304 | } else { | 291 | } else { |
678 | 305 | event->ignore(); | 292 | event->ignore(); |
679 | 306 | } | 293 | } |
680 | @@ -471,51 +458,26 @@ | |||
681 | 471 | return false; | 458 | return false; |
682 | 472 | } | 459 | } |
683 | 473 | 460 | ||
697 | 474 | bool accepted = true; | 461 | if (eventType == QEvent::TouchBegin && !hasTouchInsideInputRegion(touchPoints)) { |
698 | 475 | if (type() == Mir::InputMethodType && eventType == QEvent::TouchBegin) { | 462 | return false; |
686 | 476 | // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place. | ||
687 | 477 | if (hasTouchInsideUbuntuKeyboard(touchPoints)) { | ||
688 | 478 | validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates); | ||
689 | 479 | } else { | ||
690 | 480 | accepted = false; | ||
691 | 481 | } | ||
692 | 482 | |||
693 | 483 | } else { | ||
694 | 484 | // NB: If we are getting QEvent::TouchUpdate or QEvent::TouchEnd it's because we've | ||
695 | 485 | // previously accepted the corresponding QEvent::TouchBegin | ||
696 | 486 | validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates); | ||
699 | 487 | } | 463 | } |
701 | 488 | return accepted; | 464 | |
702 | 465 | validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates); | ||
703 | 466 | |||
704 | 467 | return true; | ||
705 | 489 | } | 468 | } |
706 | 490 | 469 | ||
708 | 491 | bool MirSurfaceItem::hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints) | 470 | bool MirSurfaceItem::hasTouchInsideInputRegion(const QList<QTouchEvent::TouchPoint> &touchPoints) |
709 | 492 | { | 471 | { |
710 | 493 | UbuntuKeyboardInfo *ubuntuKeyboardInfo = UbuntuKeyboardInfo::instance(); | ||
711 | 494 | |||
712 | 495 | for (int i = 0; i < touchPoints.count(); ++i) { | 472 | for (int i = 0; i < touchPoints.count(); ++i) { |
713 | 496 | QPoint pos = touchPoints.at(i).pos().toPoint(); | 473 | QPoint pos = touchPoints.at(i).pos().toPoint(); |
718 | 497 | if (pos.x() >= ubuntuKeyboardInfo->x() | 474 | if (m_surface->inputAreaContains(pos)) { |
715 | 498 | && pos.x() <= (ubuntuKeyboardInfo->x() + ubuntuKeyboardInfo->width()) | ||
716 | 499 | && pos.y() >= ubuntuKeyboardInfo->y() | ||
717 | 500 | && pos.y() <= (ubuntuKeyboardInfo->y() + ubuntuKeyboardInfo->height())) { | ||
719 | 501 | return true; | 475 | return true; |
720 | 502 | } | 476 | } |
721 | 503 | } | 477 | } |
722 | 504 | return false; | 478 | return false; |
723 | 505 | } | 479 | } |
724 | 506 | 480 | ||
725 | 507 | bool MirSurfaceItem::isMouseInsideUbuntuKeyboard(const QMouseEvent *event) | ||
726 | 508 | { | ||
727 | 509 | UbuntuKeyboardInfo *ubuntuKeyboardInfo = UbuntuKeyboardInfo::instance(); | ||
728 | 510 | |||
729 | 511 | const QPointF &pos = event->localPos(); | ||
730 | 512 | |||
731 | 513 | return pos.x() >= ubuntuKeyboardInfo->x() | ||
732 | 514 | && pos.x() <= (ubuntuKeyboardInfo->x() + ubuntuKeyboardInfo->width()) | ||
733 | 515 | && pos.y() >= ubuntuKeyboardInfo->y() | ||
734 | 516 | && pos.y() <= (ubuntuKeyboardInfo->y() + ubuntuKeyboardInfo->height()); | ||
735 | 517 | } | ||
736 | 518 | |||
737 | 519 | Mir::State MirSurfaceItem::surfaceState() const | 481 | Mir::State MirSurfaceItem::surfaceState() const |
738 | 520 | { | 482 | { |
739 | 521 | if (m_surface) { | 483 | if (m_surface) { |
740 | 522 | 484 | ||
741 | === modified file 'miral-qt/src/modules/Unity/Application/mirsurfaceitem.h' | |||
742 | --- miral-qt/src/modules/Unity/Application/mirsurfaceitem.h 2016-07-25 13:48:41 +0000 | |||
743 | +++ miral-qt/src/modules/Unity/Application/mirsurfaceitem.h 2016-07-26 12:46:18 +0000 | |||
744 | @@ -126,8 +126,7 @@ | |||
745 | 126 | private: | 126 | private: |
746 | 127 | void ensureTextureProvider(); | 127 | void ensureTextureProvider(); |
747 | 128 | 128 | ||
750 | 129 | bool hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints); | 129 | bool hasTouchInsideInputRegion(const QList<QTouchEvent::TouchPoint> &touchPoints); |
749 | 130 | bool isMouseInsideUbuntuKeyboard(const QMouseEvent *event); | ||
751 | 131 | 130 | ||
752 | 132 | QString appId() const; | 131 | QString appId() const; |
753 | 133 | void endCurrentTouchSequence(ulong timestamp); | 132 | void endCurrentTouchSequence(ulong timestamp); |
754 | 134 | 133 | ||
755 | === modified file 'miral-qt/src/modules/Unity/Application/plugin.cpp' | |||
756 | --- miral-qt/src/modules/Unity/Application/plugin.cpp 2016-06-01 22:06:51 +0000 | |||
757 | +++ miral-qt/src/modules/Unity/Application/plugin.cpp 2016-07-26 12:46:18 +0000 | |||
758 | @@ -25,7 +25,6 @@ | |||
759 | 25 | #include "mirsurfaceinterface.h" | 25 | #include "mirsurfaceinterface.h" |
760 | 26 | #include "mirsurfaceitem.h" | 26 | #include "mirsurfaceitem.h" |
761 | 27 | #include "mirsurfacelistmodel.h" | 27 | #include "mirsurfacelistmodel.h" |
762 | 28 | #include "ubuntukeyboardinfo.h" | ||
763 | 29 | 28 | ||
764 | 30 | // platforms/mirserver | 29 | // platforms/mirserver |
765 | 31 | #include <mirsingleton.h> | 30 | #include <mirsingleton.h> |
766 | @@ -55,13 +54,6 @@ | |||
767 | 55 | return qtmir::MirSurfaceManager::singleton(); | 54 | return qtmir::MirSurfaceManager::singleton(); |
768 | 56 | } | 55 | } |
769 | 57 | 56 | ||
770 | 58 | QObject* ubuntuKeyboardInfoSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) { | ||
771 | 59 | if (!UbuntuKeyboardInfo::instance()) { | ||
772 | 60 | new UbuntuKeyboardInfo; | ||
773 | 61 | } | ||
774 | 62 | return UbuntuKeyboardInfo::instance(); | ||
775 | 63 | } | ||
776 | 64 | |||
777 | 65 | QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) { | 57 | QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) { |
778 | 66 | return qtmir::Mir::instance(); | 58 | return qtmir::Mir::instance(); |
779 | 67 | } | 59 | } |
780 | @@ -101,8 +93,6 @@ | |||
781 | 101 | qmlRegisterUncreatableType<unity::shell::application::MirSurfaceInterface>( | 93 | qmlRegisterUncreatableType<unity::shell::application::MirSurfaceInterface>( |
782 | 102 | uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML"); | 94 | uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML"); |
783 | 103 | qmlRegisterType<qtmir::MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem"); | 95 | qmlRegisterType<qtmir::MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem"); |
784 | 104 | qmlRegisterSingletonType<qtmir::UbuntuKeyboardInfo>( | ||
785 | 105 | uri, 0, 1, "UbuntuKeyboardInfo", ubuntuKeyboardInfoSingleton); | ||
786 | 106 | qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton); | 96 | qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton); |
787 | 107 | } | 97 | } |
788 | 108 | 98 | ||
789 | 109 | 99 | ||
790 | === modified file 'miral-qt/src/modules/Unity/Application/session.cpp' | |||
791 | --- miral-qt/src/modules/Unity/Application/session.cpp 2016-06-21 13:38:53 +0000 | |||
792 | +++ miral-qt/src/modules/Unity/Application/session.cpp 2016-07-26 12:46:18 +0000 | |||
793 | @@ -514,6 +514,23 @@ | |||
794 | 514 | return m_hadSurface; | 514 | return m_hadSurface; |
795 | 515 | } | 515 | } |
796 | 516 | 516 | ||
797 | 517 | bool Session::activeFocus() const | ||
798 | 518 | { | ||
799 | 519 | for (int i = 0; i < m_surfaceList.count(); ++i) { | ||
800 | 520 | auto surface = static_cast<const MirSurfaceInterface*>(m_surfaceList.get(i)); | ||
801 | 521 | if (surface->activeFocus()) { | ||
802 | 522 | return true; | ||
803 | 523 | } | ||
804 | 524 | } | ||
805 | 525 | |||
806 | 526 | return false; | ||
807 | 527 | } | ||
808 | 528 | |||
809 | 529 | pid_t Session::pid() const | ||
810 | 530 | { | ||
811 | 531 | return m_session->process_id(); | ||
812 | 532 | } | ||
813 | 533 | |||
814 | 517 | void Session::setSuspendTimer(AbstractTimer *timer) | 534 | void Session::setSuspendTimer(AbstractTimer *timer) |
815 | 518 | { | 535 | { |
816 | 519 | bool timerWasRunning = false; | 536 | bool timerWasRunning = false; |
817 | 520 | 537 | ||
818 | === modified file 'miral-qt/src/modules/Unity/Application/session.h' | |||
819 | --- miral-qt/src/modules/Unity/Application/session.h 2016-06-01 22:06:51 +0000 | |||
820 | +++ miral-qt/src/modules/Unity/Application/session.h 2016-07-26 12:46:18 +0000 | |||
821 | @@ -67,6 +67,10 @@ | |||
822 | 67 | bool hadSurface() const override; | 67 | bool hadSurface() const override; |
823 | 68 | bool hasClosingSurfaces() const override; | 68 | bool hasClosingSurfaces() const override; |
824 | 69 | 69 | ||
825 | 70 | bool activeFocus() const override; | ||
826 | 71 | |||
827 | 72 | pid_t pid() const override; | ||
828 | 73 | |||
829 | 70 | void addChildSession(SessionInterface* session) override; | 74 | void addChildSession(SessionInterface* session) override; |
830 | 71 | void insertChildSession(uint index, SessionInterface* session) override; | 75 | void insertChildSession(uint index, SessionInterface* session) override; |
831 | 72 | void removeChildSession(SessionInterface* session) override; | 76 | void removeChildSession(SessionInterface* session) override; |
832 | 73 | 77 | ||
833 | === modified file 'miral-qt/src/modules/Unity/Application/session_interface.h' | |||
834 | --- miral-qt/src/modules/Unity/Application/session_interface.h 2016-06-01 22:06:51 +0000 | |||
835 | +++ miral-qt/src/modules/Unity/Application/session_interface.h 2016-07-26 12:46:18 +0000 | |||
836 | @@ -92,6 +92,12 @@ | |||
837 | 92 | virtual bool hadSurface() const = 0; // whether this session ever had any surface (currently or in the past) | 92 | virtual bool hadSurface() const = 0; // whether this session ever had any surface (currently or in the past) |
838 | 93 | virtual bool hasClosingSurfaces() const = 0; // whether it has surfaces being forcibly closed | 93 | virtual bool hasClosingSurfaces() const = 0; // whether it has surfaces being forcibly closed |
839 | 94 | 94 | ||
840 | 95 | // Whether any of its MirSurfaces has activeFocus() | ||
841 | 96 | // See qtmir::MirSurfaceInterface::activeFocus | ||
842 | 97 | virtual bool activeFocus() const = 0; | ||
843 | 98 | |||
844 | 99 | virtual pid_t pid() const = 0; | ||
845 | 100 | |||
846 | 95 | // For SessionManager use | 101 | // For SessionManager use |
847 | 96 | 102 | ||
848 | 97 | virtual void addChildSession(SessionInterface* session) = 0; | 103 | virtual void addChildSession(SessionInterface* session) = 0; |
849 | 98 | 104 | ||
850 | === removed file 'miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.cpp' | |||
851 | --- miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.cpp 2016-06-21 13:38:53 +0000 | |||
852 | +++ miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.cpp 1970-01-01 00:00:00 +0000 | |||
853 | @@ -1,173 +0,0 @@ | |||
854 | 1 | /* | ||
855 | 2 | * Copyright (C) 2013-2015 Canonical, Ltd. | ||
856 | 3 | * | ||
857 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
858 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
859 | 6 | * the Free Software Foundation. | ||
860 | 7 | * | ||
861 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
862 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
863 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
864 | 11 | * Lesser General Public License for more details. | ||
865 | 12 | * | ||
866 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
867 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
868 | 15 | */ | ||
869 | 16 | |||
870 | 17 | #include "ubuntukeyboardinfo.h" | ||
871 | 18 | |||
872 | 19 | #include <QDir> | ||
873 | 20 | |||
874 | 21 | namespace qtmir { | ||
875 | 22 | |||
876 | 23 | namespace { | ||
877 | 24 | const int gConnectionAttemptIntervalMs = 5000; | ||
878 | 25 | const int gMaxConsecutiveAttempts = 10; | ||
879 | 26 | const char gServerName[] = "ubuntu-keyboard-info"; | ||
880 | 27 | } | ||
881 | 28 | |||
882 | 29 | UbuntuKeyboardInfo* UbuntuKeyboardInfo::m_instance = nullptr; | ||
883 | 30 | |||
884 | 31 | UbuntuKeyboardInfo* UbuntuKeyboardInfo::instance() | ||
885 | 32 | { | ||
886 | 33 | return m_instance; | ||
887 | 34 | } | ||
888 | 35 | |||
889 | 36 | UbuntuKeyboardInfo::UbuntuKeyboardInfo(QObject *parent) | ||
890 | 37 | : QObject(parent), | ||
891 | 38 | m_consecutiveAttempts(0), | ||
892 | 39 | m_lastX(0), | ||
893 | 40 | m_lastY(0), | ||
894 | 41 | m_lastWidth(0), | ||
895 | 42 | m_lastHeight(0) | ||
896 | 43 | { | ||
897 | 44 | if (m_instance) { | ||
898 | 45 | qFatal("Cannot have more than one instance of UbuntuKeyboardInfo simultaneously."); | ||
899 | 46 | } | ||
900 | 47 | m_instance = this; | ||
901 | 48 | |||
902 | 49 | connect(&m_socket, &QLocalSocket::stateChanged, this, &UbuntuKeyboardInfo::onSocketStateChanged); | ||
903 | 50 | connect(&m_socket, &QIODevice::readyRead, | ||
904 | 51 | this, &UbuntuKeyboardInfo::readAllBytesFromSocket); | ||
905 | 52 | |||
906 | 53 | buildSocketFilePath(); | ||
907 | 54 | |||
908 | 55 | typedef void (QLocalSocket::*MemberFunctionType)(QLocalSocket::LocalSocketError); | ||
909 | 56 | MemberFunctionType funcPointer = &QLocalSocket::error; | ||
910 | 57 | connect(&m_socket, funcPointer, | ||
911 | 58 | this, &UbuntuKeyboardInfo::onSocketError); | ||
912 | 59 | |||
913 | 60 | m_connectionRetryTimer.setInterval(gConnectionAttemptIntervalMs); | ||
914 | 61 | m_connectionRetryTimer.setSingleShot(true); | ||
915 | 62 | connect(&m_connectionRetryTimer, &QTimer::timeout, | ||
916 | 63 | this, &UbuntuKeyboardInfo::tryConnectingToServer); | ||
917 | 64 | tryConnectingToServer(); | ||
918 | 65 | } | ||
919 | 66 | |||
920 | 67 | UbuntuKeyboardInfo::~UbuntuKeyboardInfo() | ||
921 | 68 | { | ||
922 | 69 | // Make sure we don't get onSocketStateChanged() called during | ||
923 | 70 | // destruction. | ||
924 | 71 | m_socket.disconnect(this); | ||
925 | 72 | |||
926 | 73 | Q_ASSERT(m_instance); | ||
927 | 74 | m_instance = nullptr; | ||
928 | 75 | } | ||
929 | 76 | |||
930 | 77 | void UbuntuKeyboardInfo::tryConnectingToServer() | ||
931 | 78 | { | ||
932 | 79 | ++m_consecutiveAttempts; | ||
933 | 80 | Q_ASSERT(!m_socketFilePath.isEmpty()); | ||
934 | 81 | m_socket.connectToServer(m_socketFilePath, QIODevice::ReadOnly); | ||
935 | 82 | } | ||
936 | 83 | |||
937 | 84 | void UbuntuKeyboardInfo::onSocketStateChanged(QLocalSocket::LocalSocketState socketState) | ||
938 | 85 | { | ||
939 | 86 | switch (socketState) { | ||
940 | 87 | case QLocalSocket::UnconnectedState: | ||
941 | 88 | retryConnection(); | ||
942 | 89 | break; | ||
943 | 90 | case QLocalSocket::ConnectedState: | ||
944 | 91 | m_consecutiveAttempts = 0; | ||
945 | 92 | break; | ||
946 | 93 | default: | ||
947 | 94 | break; | ||
948 | 95 | } | ||
949 | 96 | } | ||
950 | 97 | |||
951 | 98 | void UbuntuKeyboardInfo::onSocketError(QLocalSocket::LocalSocketError socketError) | ||
952 | 99 | { | ||
953 | 100 | Q_UNUSED(socketError); | ||
954 | 101 | qWarning() << "UbuntuKeyboardInfo - socket error:" << m_socket.errorString(); | ||
955 | 102 | } | ||
956 | 103 | |||
957 | 104 | void UbuntuKeyboardInfo::retryConnection() | ||
958 | 105 | { | ||
959 | 106 | // Polling every gConnectionAttemptIntervalMs. Not the best approach but could be worse. | ||
960 | 107 | if (m_consecutiveAttempts < gMaxConsecutiveAttempts) { | ||
961 | 108 | if (!m_connectionRetryTimer.isActive()) { | ||
962 | 109 | m_connectionRetryTimer.start(); | ||
963 | 110 | } | ||
964 | 111 | } else { | ||
965 | 112 | qCritical() << "Failed to connect to" << m_socketFilePath << "after" | ||
966 | 113 | << m_consecutiveAttempts << "failed attempts"; | ||
967 | 114 | |||
968 | 115 | // it shouldn't be running, but just to be sure. | ||
969 | 116 | m_connectionRetryTimer.stop(); | ||
970 | 117 | } | ||
971 | 118 | } | ||
972 | 119 | |||
973 | 120 | void UbuntuKeyboardInfo::readAllBytesFromSocket() | ||
974 | 121 | { | ||
975 | 122 | while (m_socket.bytesAvailable() > 0) { | ||
976 | 123 | readInfoFromSocket(); | ||
977 | 124 | } | ||
978 | 125 | } | ||
979 | 126 | |||
980 | 127 | void UbuntuKeyboardInfo::readInfoFromSocket() | ||
981 | 128 | { | ||
982 | 129 | const size_t sharedInfoSize = sizeof(struct SharedInfo); | ||
983 | 130 | QByteArray bytes = m_socket.read(sharedInfoSize); | ||
984 | 131 | if (bytes.size() != sharedInfoSize) { | ||
985 | 132 | qWarning() << "UbuntuKeyboardInfo: expected to receive" << sharedInfoSize | ||
986 | 133 | << "but got" << bytes.size(); | ||
987 | 134 | return; | ||
988 | 135 | } | ||
989 | 136 | |||
990 | 137 | { | ||
991 | 138 | struct SharedInfo *sharedInfo = reinterpret_cast<struct SharedInfo*>(bytes.data()); | ||
992 | 139 | |||
993 | 140 | if (m_lastX != sharedInfo->keyboardX) { | ||
994 | 141 | m_lastX = sharedInfo->keyboardX; | ||
995 | 142 | Q_EMIT xChanged(m_lastX); | ||
996 | 143 | } | ||
997 | 144 | |||
998 | 145 | if (m_lastY != sharedInfo->keyboardY) { | ||
999 | 146 | m_lastY = sharedInfo->keyboardY; | ||
1000 | 147 | Q_EMIT yChanged(m_lastY); | ||
1001 | 148 | } | ||
1002 | 149 | |||
1003 | 150 | if (m_lastWidth != sharedInfo->keyboardWidth) { | ||
1004 | 151 | m_lastWidth = sharedInfo->keyboardWidth; | ||
1005 | 152 | Q_EMIT widthChanged(m_lastWidth); | ||
1006 | 153 | } | ||
1007 | 154 | |||
1008 | 155 | if (m_lastHeight != sharedInfo->keyboardHeight) { | ||
1009 | 156 | m_lastHeight = sharedInfo->keyboardHeight; | ||
1010 | 157 | Q_EMIT heightChanged(m_lastHeight); | ||
1011 | 158 | } | ||
1012 | 159 | } | ||
1013 | 160 | } | ||
1014 | 161 | |||
1015 | 162 | void UbuntuKeyboardInfo::buildSocketFilePath() | ||
1016 | 163 | { | ||
1017 | 164 | char *xdgRuntimeDir = getenv("XDG_RUNTIME_DIR"); | ||
1018 | 165 | |||
1019 | 166 | if (xdgRuntimeDir) { | ||
1020 | 167 | m_socketFilePath = QDir(xdgRuntimeDir).filePath(gServerName); | ||
1021 | 168 | } else { | ||
1022 | 169 | m_socketFilePath = QDir("/tmp").filePath(gServerName); | ||
1023 | 170 | } | ||
1024 | 171 | } | ||
1025 | 172 | |||
1026 | 173 | } // namespace qtmir | ||
1027 | 174 | 0 | ||
1028 | === removed file 'miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.h' | |||
1029 | --- miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.h 2016-06-01 22:06:51 +0000 | |||
1030 | +++ miral-qt/src/modules/Unity/Application/ubuntukeyboardinfo.h 1970-01-01 00:00:00 +0000 | |||
1031 | @@ -1,87 +0,0 @@ | |||
1032 | 1 | /* | ||
1033 | 2 | * Copyright (C) 2013-2015 Canonical, Ltd. | ||
1034 | 3 | * | ||
1035 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1036 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1037 | 6 | * the Free Software Foundation. | ||
1038 | 7 | * | ||
1039 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1040 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1041 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1042 | 11 | * Lesser General Public License for more details. | ||
1043 | 12 | * | ||
1044 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1045 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1046 | 15 | */ | ||
1047 | 16 | |||
1048 | 17 | #ifndef UBUNTU_KEYBOARD_INFO_H | ||
1049 | 18 | #define UBUNTU_KEYBOARD_INFO_H | ||
1050 | 19 | |||
1051 | 20 | #include <QLocalSocket> | ||
1052 | 21 | #include <QTimer> | ||
1053 | 22 | |||
1054 | 23 | namespace qtmir { | ||
1055 | 24 | |||
1056 | 25 | // Temporary solution to get information about the onscreen keyboard | ||
1057 | 26 | // This shouldn't be needed once the OSK is a properly sized surface | ||
1058 | 27 | // instead of a fullscreen one. | ||
1059 | 28 | class UbuntuKeyboardInfo : public QObject { | ||
1060 | 29 | Q_OBJECT | ||
1061 | 30 | Q_PROPERTY(qreal x READ x NOTIFY xChanged) | ||
1062 | 31 | Q_PROPERTY(qreal y READ y NOTIFY yChanged) | ||
1063 | 32 | Q_PROPERTY(qreal width READ width NOTIFY widthChanged) | ||
1064 | 33 | Q_PROPERTY(qreal height READ height NOTIFY heightChanged) | ||
1065 | 34 | public: | ||
1066 | 35 | UbuntuKeyboardInfo(QObject *parent = 0); | ||
1067 | 36 | virtual ~UbuntuKeyboardInfo(); | ||
1068 | 37 | |||
1069 | 38 | static UbuntuKeyboardInfo* instance(); | ||
1070 | 39 | |||
1071 | 40 | qreal x() const { return m_lastX; } | ||
1072 | 41 | qreal y() const { return m_lastY; } | ||
1073 | 42 | qreal width() const { return m_lastWidth; } | ||
1074 | 43 | qreal height() const { return m_lastHeight; } | ||
1075 | 44 | |||
1076 | 45 | Q_SIGNALS: | ||
1077 | 46 | void xChanged(qreal x); | ||
1078 | 47 | void yChanged(qreal y); | ||
1079 | 48 | void widthChanged(qreal width); | ||
1080 | 49 | void heightChanged(qreal height); | ||
1081 | 50 | |||
1082 | 51 | private Q_SLOTS: | ||
1083 | 52 | void tryConnectingToServer(); | ||
1084 | 53 | void onSocketStateChanged(QLocalSocket::LocalSocketState socketState); | ||
1085 | 54 | void onSocketError(QLocalSocket::LocalSocketError socketError); | ||
1086 | 55 | void readAllBytesFromSocket(); | ||
1087 | 56 | |||
1088 | 57 | private: | ||
1089 | 58 | // NB! Must match the definition in ubuntu-keyboard. Not worth creating a shared header | ||
1090 | 59 | // just for that. | ||
1091 | 60 | struct SharedInfo { | ||
1092 | 61 | qint32 keyboardX; | ||
1093 | 62 | qint32 keyboardY; | ||
1094 | 63 | qint32 keyboardWidth; | ||
1095 | 64 | qint32 keyboardHeight; | ||
1096 | 65 | }; | ||
1097 | 66 | void readInfoFromSocket(); | ||
1098 | 67 | void retryConnection(); | ||
1099 | 68 | void buildSocketFilePath(); | ||
1100 | 69 | |||
1101 | 70 | int m_consecutiveAttempts; | ||
1102 | 71 | |||
1103 | 72 | QLocalSocket m_socket; | ||
1104 | 73 | qint32 m_lastX; | ||
1105 | 74 | qint32 m_lastY; | ||
1106 | 75 | qint32 m_lastWidth; | ||
1107 | 76 | qint32 m_lastHeight; | ||
1108 | 77 | QTimer m_connectionRetryTimer; | ||
1109 | 78 | |||
1110 | 79 | // Path to the socket file created by ubuntu-keyboard | ||
1111 | 80 | QString m_socketFilePath; | ||
1112 | 81 | |||
1113 | 82 | static UbuntuKeyboardInfo* m_instance; | ||
1114 | 83 | }; | ||
1115 | 84 | |||
1116 | 85 | } // namespace qtmir | ||
1117 | 86 | |||
1118 | 87 | #endif // UBUNTU_KEYBOARD_INFO_H | ||
1119 | 88 | 0 | ||
1120 | === modified file 'miral-qt/src/platforms/mirserver/logging.cpp' | |||
1121 | --- miral-qt/src/platforms/mirserver/logging.cpp 2016-06-01 22:06:51 +0000 | |||
1122 | +++ miral-qt/src/platforms/mirserver/logging.cpp 2016-07-26 12:46:18 +0000 | |||
1123 | @@ -24,3 +24,4 @@ | |||
1124 | 24 | Q_LOGGING_CATEGORY(QTMIR_CLIPBOARD, "qtmir.clipboard") | 24 | Q_LOGGING_CATEGORY(QTMIR_CLIPBOARD, "qtmir.clipboard") |
1125 | 25 | Q_LOGGING_CATEGORY(QTMIR_SENSOR_MESSAGES, "qtmir.sensor") | 25 | Q_LOGGING_CATEGORY(QTMIR_SENSOR_MESSAGES, "qtmir.sensor") |
1126 | 26 | Q_LOGGING_CATEGORY(QTMIR_SCREENS, "qtmir.screens") | 26 | Q_LOGGING_CATEGORY(QTMIR_SCREENS, "qtmir.screens") |
1127 | 27 | Q_LOGGING_CATEGORY(QTMIR_DBUS, "qtmir.dbus", QtWarningMsg) | ||
1128 | 27 | 28 | ||
1129 | === modified file 'miral-qt/src/platforms/mirserver/logging.h' | |||
1130 | --- miral-qt/src/platforms/mirserver/logging.h 2016-06-01 22:06:51 +0000 | |||
1131 | +++ miral-qt/src/platforms/mirserver/logging.h 2016-07-26 12:46:18 +0000 | |||
1132 | @@ -26,5 +26,6 @@ | |||
1133 | 26 | Q_DECLARE_LOGGING_CATEGORY(QTMIR_MIR_INPUT) | 26 | Q_DECLARE_LOGGING_CATEGORY(QTMIR_MIR_INPUT) |
1134 | 27 | Q_DECLARE_LOGGING_CATEGORY(QTMIR_CLIPBOARD) | 27 | Q_DECLARE_LOGGING_CATEGORY(QTMIR_CLIPBOARD) |
1135 | 28 | Q_DECLARE_LOGGING_CATEGORY(QTMIR_SCREENS) | 28 | Q_DECLARE_LOGGING_CATEGORY(QTMIR_SCREENS) |
1136 | 29 | Q_DECLARE_LOGGING_CATEGORY(QTMIR_DBUS) | ||
1137 | 29 | 30 | ||
1138 | 30 | #endif // UBUNTU_APPLICATION_PLUGIN_LOGGING_H | 31 | #endif // UBUNTU_APPLICATION_PLUGIN_LOGGING_H |
1139 | 31 | 32 | ||
1140 | === modified file 'miral-qt/src/platforms/mirserver/mirwindowmanager.cpp' | |||
1141 | --- miral-qt/src/platforms/mirserver/mirwindowmanager.cpp 2016-06-07 18:03:38 +0000 | |||
1142 | +++ miral-qt/src/platforms/mirserver/mirwindowmanager.cpp 2016-07-26 12:46:18 +0000 | |||
1143 | @@ -197,14 +197,19 @@ | |||
1144 | 197 | const mir::shell::SurfaceSpecification& modifications) | 197 | const mir::shell::SurfaceSpecification& modifications) |
1145 | 198 | { | 198 | { |
1146 | 199 | QMutexLocker lock(&SurfaceObserver::mutex); | 199 | QMutexLocker lock(&SurfaceObserver::mutex); |
1147 | 200 | |||
1148 | 201 | if (modifications.name.is_set()) { | ||
1149 | 202 | surface->rename(modifications.name.value()); | ||
1150 | 203 | } | ||
1151 | 204 | |||
1152 | 205 | if (modifications.input_shape.is_set()) { | ||
1153 | 206 | surface->set_input_region(modifications.input_shape.value()); | ||
1154 | 207 | } | ||
1155 | 208 | |||
1156 | 200 | SurfaceObserver *observer = SurfaceObserver::observerForSurface(surface.get()); | 209 | SurfaceObserver *observer = SurfaceObserver::observerForSurface(surface.get()); |
1157 | 201 | if (observer) { | 210 | if (observer) { |
1158 | 202 | observer->notifySurfaceModifications(modifications); | 211 | observer->notifySurfaceModifications(modifications); |
1159 | 203 | } | 212 | } |
1160 | 204 | |||
1161 | 205 | if (modifications.name.is_set()) { | ||
1162 | 206 | surface->rename(modifications.name.value()); | ||
1163 | 207 | } | ||
1164 | 208 | } | 213 | } |
1165 | 209 | 214 | ||
1166 | 210 | std::shared_ptr<MirWindowManager> MirWindowManager::create( | 215 | std::shared_ptr<MirWindowManager> MirWindowManager::create( |
1167 | 211 | 216 | ||
1168 | === modified file 'miral-qt/src/platforms/mirserver/surfaceobserver.cpp' | |||
1169 | --- miral-qt/src/platforms/mirserver/surfaceobserver.cpp 2016-06-01 22:06:51 +0000 | |||
1170 | +++ miral-qt/src/platforms/mirserver/surfaceobserver.cpp 2016-07-26 12:46:18 +0000 | |||
1171 | @@ -28,6 +28,22 @@ | |||
1172 | 28 | #include <mir/geometry/size.h> | 28 | #include <mir/geometry/size.h> |
1173 | 29 | #include <mir/shell/surface_specification.h> | 29 | #include <mir/shell/surface_specification.h> |
1174 | 30 | 30 | ||
1175 | 31 | namespace { | ||
1176 | 32 | |||
1177 | 33 | QRect calculateBoundingRect(const std::vector<mir::geometry::Rectangle> &rectVector) | ||
1178 | 34 | { | ||
1179 | 35 | QRect boundingRect; | ||
1180 | 36 | for (auto mirRect : rectVector) { | ||
1181 | 37 | boundingRect |= QRect(mirRect.top_left.x.as_int(), | ||
1182 | 38 | mirRect.top_left.y.as_int(), | ||
1183 | 39 | mirRect.size.width.as_int(), | ||
1184 | 40 | mirRect.size.height.as_int()); | ||
1185 | 41 | } | ||
1186 | 42 | return boundingRect; | ||
1187 | 43 | } | ||
1188 | 44 | |||
1189 | 45 | } // anonymous namespace | ||
1190 | 46 | |||
1191 | 31 | QMap<const mir::scene::Surface*, SurfaceObserver*> SurfaceObserver::m_surfaceToObserverMap; | 47 | QMap<const mir::scene::Surface*, SurfaceObserver*> SurfaceObserver::m_surfaceToObserverMap; |
1192 | 32 | QMutex SurfaceObserver::mutex; | 48 | QMutex SurfaceObserver::mutex; |
1193 | 33 | 49 | ||
1194 | @@ -154,6 +170,10 @@ | |||
1195 | 154 | if (modifications.shell_chrome.is_set()) { | 170 | if (modifications.shell_chrome.is_set()) { |
1196 | 155 | Q_EMIT shellChromeChanged(modifications.shell_chrome.value()); | 171 | Q_EMIT shellChromeChanged(modifications.shell_chrome.value()); |
1197 | 156 | } | 172 | } |
1198 | 173 | if (modifications.input_shape.is_set()) { | ||
1199 | 174 | QRect qRect = calculateBoundingRect(modifications.input_shape.value()); | ||
1200 | 175 | Q_EMIT inputBoundsChanged(qRect); | ||
1201 | 176 | } | ||
1202 | 157 | } | 177 | } |
1203 | 158 | 178 | ||
1204 | 159 | SurfaceObserver *SurfaceObserver::observerForSurface(const mir::scene::Surface *surface) | 179 | SurfaceObserver *SurfaceObserver::observerForSurface(const mir::scene::Surface *surface) |
1205 | 160 | 180 | ||
1206 | === modified file 'miral-qt/src/platforms/mirserver/surfaceobserver.h' | |||
1207 | --- miral-qt/src/platforms/mirserver/surfaceobserver.h 2016-06-01 22:06:51 +0000 | |||
1208 | +++ miral-qt/src/platforms/mirserver/surfaceobserver.h 2016-07-26 12:46:18 +0000 | |||
1209 | @@ -1,5 +1,5 @@ | |||
1210 | 1 | /* | 1 | /* |
1212 | 2 | * Copyright (C) 2014-2015 Canonical, Ltd. | 2 | * Copyright (C) 2014-2016 Canonical, Ltd. |
1213 | 3 | * | 3 | * |
1214 | 4 | * This program is free software: you can redistribute it and/or modify it under | 4 | * This program is free software: you can redistribute it and/or modify it under |
1215 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | 5 | * the terms of the GNU Lesser General Public License version 3, as published by |
1216 | @@ -22,6 +22,7 @@ | |||
1217 | 22 | #include <QObject> | 22 | #include <QObject> |
1218 | 23 | #include <QMap> | 23 | #include <QMap> |
1219 | 24 | #include <QMutex> | 24 | #include <QMutex> |
1220 | 25 | #include <QRect> | ||
1221 | 25 | #include <QSize> | 26 | #include <QSize> |
1222 | 26 | #include <mir/scene/surface_observer.h> | 27 | #include <mir/scene/surface_observer.h> |
1223 | 27 | 28 | ||
1224 | @@ -84,6 +85,7 @@ | |||
1225 | 84 | void widthIncrementChanged(int); | 85 | void widthIncrementChanged(int); |
1226 | 85 | void heightIncrementChanged(int); | 86 | void heightIncrementChanged(int); |
1227 | 86 | void shellChromeChanged(MirShellChrome); | 87 | void shellChromeChanged(MirShellChrome); |
1228 | 88 | void inputBoundsChanged(const QRect &rect); | ||
1229 | 87 | 89 | ||
1230 | 88 | private: | 90 | private: |
1231 | 89 | QCursor createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage); | 91 | QCursor createQCursorFromMirCursorImage(const mir::graphics::CursorImage &cursorImage); |
1232 | 90 | 92 | ||
1233 | === modified file 'miral-qt/tests/framework/fake_mirsurface.h' | |||
1234 | --- miral-qt/tests/framework/fake_mirsurface.h 2016-07-25 13:48:41 +0000 | |||
1235 | +++ miral-qt/tests/framework/fake_mirsurface.h 2016-07-26 12:46:18 +0000 | |||
1236 | @@ -76,6 +76,7 @@ | |||
1237 | 76 | Mir::ShellChrome shellChrome() const override { return Mir::NormalChrome; } | 76 | Mir::ShellChrome shellChrome() const override { return Mir::NormalChrome; } |
1238 | 77 | 77 | ||
1239 | 78 | bool focused() const override { return false; } | 78 | bool focused() const override { return false; } |
1240 | 79 | QRect inputBounds() const override { return QRect(0,0,10,10); } | ||
1241 | 79 | 80 | ||
1242 | 80 | void requestFocus() override { | 81 | void requestFocus() override { |
1243 | 81 | Q_EMIT focusRequested(); | 82 | Q_EMIT focusRequested(); |
1244 | @@ -110,6 +111,7 @@ | |||
1245 | 110 | void setFocused(bool focus) override; | 111 | void setFocused(bool focus) override; |
1246 | 111 | 112 | ||
1247 | 112 | void setViewActiveFocus(qintptr, bool) override {}; | 113 | void setViewActiveFocus(qintptr, bool) override {}; |
1248 | 114 | bool activeFocus() const override { return false; } | ||
1249 | 113 | 115 | ||
1250 | 114 | void mousePressEvent(QMouseEvent *) override; | 116 | void mousePressEvent(QMouseEvent *) override; |
1251 | 115 | void mouseMoveEvent(QMouseEvent *) override; | 117 | void mouseMoveEvent(QMouseEvent *) override; |
1252 | @@ -132,6 +134,8 @@ | |||
1253 | 132 | 134 | ||
1254 | 133 | SessionInterface* session() override { return m_session; } | 135 | SessionInterface* session() override { return m_session; } |
1255 | 134 | 136 | ||
1256 | 137 | bool inputAreaContains(const QPoint &) const override { return true; } | ||
1257 | 138 | |||
1258 | 135 | public Q_SLOTS: | 139 | public Q_SLOTS: |
1259 | 136 | void onCompositorSwappedBuffers() override; | 140 | void onCompositorSwappedBuffers() override; |
1260 | 137 | 141 | ||
1261 | 138 | 142 | ||
1262 | === modified file 'miral-qt/tests/framework/fake_session.h' | |||
1263 | --- miral-qt/tests/framework/fake_session.h 2016-06-07 20:32:04 +0000 | |||
1264 | +++ miral-qt/tests/framework/fake_session.h 2016-07-26 12:46:18 +0000 | |||
1265 | @@ -58,6 +58,10 @@ | |||
1266 | 58 | 58 | ||
1267 | 59 | void close() override; | 59 | void close() override; |
1268 | 60 | 60 | ||
1269 | 61 | bool activeFocus() const override { return false; } | ||
1270 | 62 | |||
1271 | 63 | pid_t pid() const override { return 0; } | ||
1272 | 64 | |||
1273 | 61 | // For SessionManager use | 65 | // For SessionManager use |
1274 | 62 | 66 | ||
1275 | 63 | void addChildSession(SessionInterface*) override; | 67 | void addChildSession(SessionInterface*) override; |
I wonder why "DBusFocusInfo *m_dbusFocusInfo;" isn't "DBusFocusInfo m_dbusFocusInfo;" (avoiding explicit memory management) but I guess this is the wrong project in which to ask that.