Merge lp:~mir-team/qtubuntu/ubuntumirclient-only into lp:qtubuntu

Proposed by Gerry Boland
Status: Merged
Approved by: Ricardo Mendoza
Approved revision: 244
Merged at revision: 234
Proposed branch: lp:~mir-team/qtubuntu/ubuntumirclient-only
Merge into: lp:qtubuntu
Diff against target: 6556 lines (+2200/-3743)
72 files modified
README (+4/-42)
TODO (+0/-4)
debian/changelog (+7/-0)
debian/control (+1/-4)
debian/copyright (+2/-2)
debian/docs (+0/-1)
debian/rules (+2/-2)
deploy.sh (+0/-16)
qtubuntu.pro (+1/-6)
src/platforms/platforms.pro (+0/-5)
src/platforms/ubuntu/ubuntu.pro (+0/-14)
src/platforms/ubuntu/ubuntu/main.cc (+0/-67)
src/platforms/ubuntu/ubuntu/ubuntu.json (+0/-3)
src/platforms/ubuntu/ubuntu/ubuntu.pro (+0/-25)
src/platforms/ubuntu/ubuntucommon/clipboard.cc (+0/-126)
src/platforms/ubuntu/ubuntucommon/clipboard.h (+0/-34)
src/platforms/ubuntu/ubuntucommon/input.cc (+0/-51)
src/platforms/ubuntu/ubuntucommon/input.h (+0/-38)
src/platforms/ubuntu/ubuntucommon/input_adaptor_factory.h (+0/-32)
src/platforms/ubuntu/ubuntucommon/integration.cc (+0/-177)
src/platforms/ubuntu/ubuntucommon/integration.h (+0/-55)
src/platforms/ubuntu/ubuntucommon/screen.cc (+0/-192)
src/platforms/ubuntu/ubuntucommon/screen.h (+0/-59)
src/platforms/ubuntu/ubuntucommon/ubuntucommon.pro (+0/-30)
src/platforms/ubuntu/ubuntucommon/window.cc (+0/-230)
src/platforms/ubuntu/ubuntucommon/window.h (+0/-58)
src/platforms/ubuntu/ubuntumir/ubuntumir.pro (+0/-16)
src/platforms/ubuntu/ubuntumir/ubuntumirclient/ubuntumirclient.pro (+0/-25)
src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.cc (+0/-184)
src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.h (+0/-31)
src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.cc (+0/-43)
src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.h (+0/-27)
src/platforms/ubuntu/ubuntumir/ubuntumircommon/ubuntumircommon.pro (+0/-21)
src/platforms/ubuntu/ubuntumir/ubuntumirserver/main.cc (+0/-53)
src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.json (+0/-3)
src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.pro (+0/-25)
src/platforms/ubuntulegacy/input.cc (+0/-56)
src/platforms/ubuntulegacy/input.h (+0/-37)
src/platforms/ubuntulegacy/integration.cc (+0/-75)
src/platforms/ubuntulegacy/integration.h (+0/-53)
src/platforms/ubuntulegacy/main.cc (+0/-47)
src/platforms/ubuntulegacy/screen.cc (+0/-34)
src/platforms/ubuntulegacy/screen.h (+0/-39)
src/platforms/ubuntulegacy/ubuntulegacy.json (+0/-3)
src/platforms/ubuntulegacy/ubuntulegacy.pro (+0/-35)
src/platforms/ubuntulegacy/window.cc (+0/-120)
src/platforms/ubuntulegacy/window.h (+0/-47)
src/src.pro (+1/-1)
src/ubuntumirclient/backingstore.cpp (+58/-52)
src/ubuntumirclient/backingstore.h (+34/-32)
src/ubuntumirclient/clipboard.cpp (+135/-33)
src/ubuntumirclient/clipboard.h (+32/-27)
src/ubuntumirclient/glcontext.cpp (+107/-91)
src/ubuntumirclient/glcontext.h (+38/-36)
src/ubuntumirclient/input.cpp (+385/-502)
src/ubuntumirclient/input.h (+47/-49)
src/ubuntumirclient/integration.cpp (+202/-99)
src/ubuntumirclient/integration.h (+72/-47)
src/ubuntumirclient/logging.h (+15/-14)
src/ubuntumirclient/nativeinterface.cpp (+105/-106)
src/ubuntumirclient/nativeinterface.h (+39/-35)
src/ubuntumirclient/platformservices.cpp (+26/-25)
src/ubuntumirclient/platformservices.h (+23/-20)
src/ubuntumirclient/plugin.cpp (+32/-45)
src/ubuntumirclient/plugin.h (+32/-0)
src/ubuntumirclient/screen.cpp (+180/-70)
src/ubuntumirclient/screen.h (+61/-39)
src/ubuntumirclient/theme.cpp (+36/-36)
src/ubuntumirclient/theme.h (+26/-23)
src/ubuntumirclient/ubuntumirclient.pro (+45/-35)
src/ubuntumirclient/window.cpp (+393/-41)
src/ubuntumirclient/window.h (+59/-38)
To merge this branch: bzr merge lp:~mir-team/qtubuntu/ubuntumirclient-only
Reviewer Review Type Date Requested Status
Ricardo Mendoza (community) Approve
Michael Terry debian-packaging Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+224978@code.launchpad.net

Commit message

Major refactor: remove SurfaceFlinger & Mir in-server-process-client support, flatten class hierarchy. Only Mir client QPA remains

Description of the change

Major refactor: remove SF support, remove mir in-server-process-client support, flatten class hierarchy

NOTE: Do not merge independently, must land as part of QtCompositor work only!!!

Depends:
https://code.launchpad.net/~unity-team/platform-api/devel-for-qtmircompositor/+merge/225320

 * Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Y
 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
Y - has been in silo6 for >1 week now
 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
Y - has been in silo6 for >1 week now
 * Has your component "TestPlan” been executed successfully on emulator, N4?
Y
 * Has a 5 minute exploratory testing run been executed on N4?
Oh more than 5 mins.
 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
Y
 * What components might get impacted by your changes?
All apps.
 * Have you requested review by the teams of these owning components?
Was a call for testing announced, some bugs were found and have been fixed:
https://bugs.launchpad.net/unity8/+bugs?field.tag=qtcomp

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ricardo Mendoza (ricmm) wrote :

This looks generally fine to me, I will however mark it as needs information due to the API changes required in the platform-api MR.

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
244. By Daniel d'Andrada

Adapt to latest platform-api API

- The new papi Event struct is called WindowEvent
- WindowEvent types have WEVENT instead of EVENT prefixes
- WindowEvent struct is simpler: It does not have the "details" member.

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

From a packaging point of view, this is fine, sure. I might have left the copyright lines as "2013,2014" instead of just "2014" though.

review: Approve (debian-packaging)
Revision history for this message
Ricardo Mendoza (ricmm) :
review: Approve
245. By Gerry Boland

HACK: implement hackish Window::mapToGlobal and isExposed to work around Autopilot relying on QWindow::mapToGlobal for coordinates in screen space

Revision history for this message
Ricardo Mendoza (ricmm) wrote :

Blessing the hack.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README'
--- README 2013-02-12 16:56:42 +0000
+++ README 2014-07-21 23:47:35 +0000
@@ -8,11 +8,8 @@
81. Description81. Description
9--------------9--------------
1010
11 QtUbuntu is a set of Qt5 components for the Ubuntu Platform API. It11 QtUbuntu contains a QPA (Qt Platform Abstraction) plugin based on the Ubuntu
12 contains a QPA (Qt Platform Abstraction) plugin based on the Ubuntu12 Platform API
13 Platform API and a legacy QPA plugin based on the compatibility
14 layers. It also provides Qt bindings for Ubuntu Platform API
15 features that are not exposed through the QPA plugins.
1613
1714
182 Running152 Running
@@ -23,13 +20,8 @@
23 "-platformpluginpath" command line switch, the following commands20 "-platformpluginpath" command line switch, the following commands
24 can be used to run with the Ubuntu QPA plugin:21 can be used to run with the Ubuntu QPA plugin:
2522
26 $ qmlscene -platform ubuntu Foo.qml23 $ qmlscene -platform ubuntumirclient Foo.qml
27 $ QT_QPA_PLATFORM=ubuntu qmlscene Foo.qml24 $ QT_QPA_PLATFORM=ubuntumirclient qmlscene Foo.qml
28
29 and the following ones to run with the Ubuntu legacy QPA plugin:
30
31 $ qmlscene -platform ubuntulegacy Foo.qml
32 $ QT_QPA_PLATFORM=ubuntulegacy qmlscene Foo.qml
3325
34 The QPA plugins expose the following environment variables:26 The QPA plugins expose the following environment variables:
3527
@@ -44,9 +36,6 @@
4436
45 QTUBUNTU_NO_INPUT: Disables touchscreen and buttons.37 QTUBUNTU_NO_INPUT: Disables touchscreen and buttons.
4638
47 QTUBUNTU_INPUT_DELAY: Specifies a delay in milliseconds for input
48 initialization (ubuntulegacy plugin only).
49
50 QTUBUNTU_ICON_THEME: Specifies the default icon theme name.39 QTUBUNTU_ICON_THEME: Specifies the default icon theme name.
5140
5241
@@ -97,30 +86,3 @@
97 [1] http://doc-snapshot.qt-project.org/5.0/qabstractnativeeventfilter.html86 [1] http://doc-snapshot.qt-project.org/5.0/qabstractnativeeventfilter.html
98 [2] http://doc-snapshot.qt-project.org/5.0/qcoreapplication.html#installNativeEventFilter87 [2] http://doc-snapshot.qt-project.org/5.0/qcoreapplication.html#installNativeEventFilter
9988
100
1015. QPA properties
102-----------------
103
104 The QPA plugin for Ubuntu looks for a "session" dynamic property on
105 the QPlatformNativeInterface object in order to know the session
106 type to request. That property can be set to an integer representing
107 a SessionType specified in the Ubuntu Platform API before the first
108 window is shown. In order to request a system session type, the
109 following code can be used:
110
111 #include <qpa/qplatformnativeinterface.h>
112 ...
113 QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface();
114 native->setProperty("session", static_cast<int>(USER_SESSION_TYPE));
115
116 The plugin also looks for "role" and "opaque" dynamic properties on
117 the QWindow object. The "role" property can be set to an integer
118 representing a SurfaceRole and the "opaque" property can be set to 0
119 or 1 to specify whether or not the surface shoud be considered
120 opaque by the compositor. Note that these properties must be set
121 before the window is shown. In order to request a launcher role and
122 an opaque window, the following code can be used:
123
124 QQuickView* view = new QQuickView();
125 view->setProperty("role", static_cast<int>(LAUNCHER_ACTOR_ROLE));
126 view->setProperty("opaque", 1);
12789
=== removed file 'TODO'
--- TODO 2012-10-16 15:41:36 +0000
+++ TODO 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1To do
2-----
3
4 Empty!
50
=== modified file 'debian/changelog'
--- debian/changelog 2014-06-13 05:37:53 +0000
+++ debian/changelog 2014-07-21 23:47:35 +0000
@@ -1,3 +1,10 @@
1qtubuntu (0.60) UNRELEASED; urgency=medium
2
3 * Major refactor: remove SurfaceFlinger & Mir in-server-process-client support,
4 flatten class hierarchy. Only Mir client QPA remains
5
6 -- Gerry Boland <gerry.boland@canonical.com> Mon, 30 Jun 2014 12:05:37 +0100
7
1qtubuntu (0.54+14.10.20140613-0ubuntu1) utopic; urgency=low8qtubuntu (0.54+14.10.20140613-0ubuntu1) utopic; urgency=low
29
3 [ Ubuntu daily release ]10 [ Ubuntu daily release ]
411
=== modified file 'debian/control'
--- debian/control 2014-05-29 10:28:33 +0000
+++ debian/control 2014-07-21 23:47:35 +0000
@@ -3,14 +3,12 @@
3Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>3Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
4Build-Depends: debhelper (>= 9),4Build-Depends: debhelper (>= 9),
5 libatspi2.0-dev,5 libatspi2.0-dev,
6 libdbus-1-dev,
7 libegl1-mesa-dev,6 libegl1-mesa-dev,
8 libfontconfig1-dev,7 libfontconfig1-dev,
9 libfreetype6-dev,8 libfreetype6-dev,
10 libgles2-mesa-dev,9 libgles2-mesa-dev,
11 libglib2.0-dev,10 libglib2.0-dev,
12 libhybris-dev,11 libubuntu-application-api-dev (>= 2.2.0),
13 libubuntu-application-api-dev (>= 2.0.0),
14 libudev-dev,12 libudev-dev,
15 libxrender-dev,13 libxrender-dev,
16 libxkbcommon-dev,14 libxkbcommon-dev,
@@ -18,7 +16,6 @@
18 qtbase5-private-dev,16 qtbase5-private-dev,
19 qtdeclarative5-dev,17 qtdeclarative5-dev,
20 libqt5sensors5-dev,18 libqt5sensors5-dev,
21 zlib1g-dev,
22# if you don't have have commit access to this branch but would like to upload19# if you don't have have commit access to this branch but would like to upload
23# directly to Ubuntu, don't worry: your changes will be merged back into the20# directly to Ubuntu, don't worry: your changes will be merged back into the
24# upstream branch21# upstream branch
2522
=== modified file 'debian/copyright'
--- debian/copyright 2013-03-13 02:30:19 +0000
+++ debian/copyright 2014-07-21 23:47:35 +0000
@@ -2,11 +2,11 @@
2Upstream-Name: qtubuntu2Upstream-Name: qtubuntu
33
4Files: *4Files: *
5Copyright: 2013 Canonical Ltd.5Copyright: 2014 Canonical Ltd.
6License: LGPL-36License: LGPL-3
77
8Files: debian/*8Files: debian/*
9Copyright: 2013 Canonical Ltd.9Copyright: 2014 Canonical Ltd.
10License: GPL-310License: GPL-3
1111
12Files: tests/*12Files: tests/*
1313
=== modified file 'debian/docs'
--- debian/docs 2012-10-03 16:16:07 +0000
+++ debian/docs 2014-07-21 23:47:35 +0000
@@ -1,2 +1,1 @@
1README1README
2TODO
32
=== modified file 'debian/rules' (properties changed: -x to +x)
--- debian/rules 2014-05-29 10:26:54 +0000
+++ debian/rules 2014-07-21 23:47:35 +0000
@@ -24,9 +24,9 @@
2424
25override_dh_auto_configure:25override_dh_auto_configure:
26ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(gles2_architectures)))26ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(gles2_architectures)))
27 mkdir -p $(ANDROID_DIR) && dh_auto_configure -B$(ANDROID_DIR) -- "CONFIG+=mirserver" "CONFIG+=mirclient" "CONFIG+=hybris" "QMAKE_CXXFLAGS=-DPLATFORM_API_TOUCH" $(CURDIR)27 mkdir -p $(ANDROID_DIR) && dh_auto_configure -B$(ANDROID_DIR) -- "QMAKE_CXXFLAGS=-DPLATFORM_API_TOUCH" $(CURDIR)
28endif28endif
29 mkdir -p $(DESKTOP_DIR) && dh_auto_configure -B$(DESKTOP_DIR) -- "CONFIG+=mirserver" "CONFIG+=mirclient" "QMAKE_CXXFLAGS=-DQTUBUNTU_USE_OPENGL" $(CURDIR)29 mkdir -p $(DESKTOP_DIR) && dh_auto_configure -B$(DESKTOP_DIR) -- "QMAKE_CXXFLAGS=-DQTUBUNTU_USE_OPENGL" $(CURDIR)
3030
31override_dh_auto_build:31override_dh_auto_build:
32ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(gles2_architectures)))32ifeq ($(DEB_HOST_ARCH),$(findstring $(DEB_HOST_ARCH), $(gles2_architectures)))
3333
=== removed file 'deploy.sh'
--- deploy.sh 2014-03-25 17:42:14 +0000
+++ deploy.sh 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1#!/bin/bash -i
2
3adb push src/platforms/ubuntu/libqubuntu.so /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms
4adb push src/platforms/ubuntu/libqubuntumir.so /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms
5adb push src/platforms/ubuntu/libqubuntumirserver.so /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms
6adb push src/platforms/ubuntulegacy/libqubuntulegacy.so /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms
7adb push tests/qmlscene_ubuntu/qmlscene-ubuntu /data/ubuntu/usr/bin
8adb push tests/clipboard/clipboard /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
9adb push tests/Logo.qml /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
10adb push tests/MovingLogo.qml /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
11adb push tests/WarpingLogo.qml /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
12adb push tests/Input.qml /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
13adb push tests/Application.qml /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
14adb push tests/Fullscreen.qml /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
15adb push tests/logo.png /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
16adb push tests/noise.png /data/ubuntu/usr/lib/arm-linux-gnueabihf/qt5/tests
170
=== modified file 'qtubuntu.pro'
--- qtubuntu.pro 2013-02-05 02:05:42 +0000
+++ qtubuntu.pro 2014-07-21 23:47:35 +0000
@@ -1,7 +1,2 @@
1load(configure)
2load(qt_parts)
3
4# FIXME(loicm) I don't get why qmake automatically detects src/ but not
5# tests/. Doing it that way makes make warn about the generated Makefile.
6TEMPLATE = subdirs1TEMPLATE = subdirs
7SUBDIRS += tests2SUBDIRS += src tests
83
=== removed directory 'src/platforms'
=== removed file 'src/platforms/platforms.pro'
--- src/platforms/platforms.pro 2013-06-21 17:23:48 +0000
+++ src/platforms/platforms.pro 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1TEMPLATE = subdirs
2
3SUBDIRS += base ubuntu
4
5ubuntu.depends = base
60
=== removed directory 'src/platforms/ubuntu'
=== removed directory 'src/platforms/ubuntu/ubuntu'
=== removed file 'src/platforms/ubuntu/ubuntu.pro'
--- src/platforms/ubuntu/ubuntu.pro 2013-06-21 18:04:03 +0000
+++ src/platforms/ubuntu/ubuntu.pro 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1TEMPLATE = subdirs
2
3!mirclient:!mirserver {
4CONFIG += hybris
5}
6
7hybris {
8SUBDIRS += ubuntu
9}
10
11SUBDIRS += ubuntucommon ubuntumir
12
13ubuntu.depends = ubuntucommon
14ubuntumir.depends = ubuntucommon
150
=== removed file 'src/platforms/ubuntu/ubuntu/main.cc'
--- src/platforms/ubuntu/ubuntu/main.cc 2013-11-19 09:00:47 +0000
+++ src/platforms/ubuntu/ubuntu/main.cc 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include <qpa/qplatformintegrationplugin.h>
17#include "ubuntucommon/integration.h"
18#include "ubuntucommon/input.h"
19#include "ubuntucommon/input_adaptor_factory.h"
20
21namespace
22{
23struct InputAdaptorFactory : public QUbuntuInputAdaptorFactory {
24 InputAdaptorFactory() {}
25 ~InputAdaptorFactory() {}
26
27 QUbuntuInput* create_input_adaptor(QUbuntuIntegration *integration){
28 return new QUbuntuInput(integration);
29 }
30
31 static InputAdaptorFactory* instance(){
32 static InputAdaptorFactory global_instance;
33 return &global_instance;
34 }
35};
36}
37
38
39QT_BEGIN_NAMESPACE
40
41class QUbuntuIntegrationPlugin : public QPlatformIntegrationPlugin {
42 Q_OBJECT
43 Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid
44 FILE "ubuntu.json")
45
46 public:
47 QStringList keys() const;
48 QPlatformIntegration* create(const QString&, const QStringList&);
49};
50
51QStringList QUbuntuIntegrationPlugin::keys() const {
52 QStringList list;
53 list << "ubuntu";
54 return list;
55}
56
57QPlatformIntegration* QUbuntuIntegrationPlugin::create(
58 const QString& system, const QStringList& paramList) {
59 Q_UNUSED(paramList);
60 if (system.toLower() == "ubuntu")
61 return new QUbuntuIntegration(InputAdaptorFactory::instance());
62 return 0;
63}
64
65QT_END_NAMESPACE
66
67#include "main.moc"
680
=== removed file 'src/platforms/ubuntu/ubuntu/ubuntu.json'
--- src/platforms/ubuntu/ubuntu/ubuntu.json 2013-06-10 20:48:03 +0000
+++ src/platforms/ubuntu/ubuntu/ubuntu.json 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1{
2 "Keys": [ "ubuntu" ]
3}
40
=== removed file 'src/platforms/ubuntu/ubuntu/ubuntu.pro'
--- src/platforms/ubuntu/ubuntu/ubuntu.pro 2013-11-22 15:30:14 +0000
+++ src/platforms/ubuntu/ubuntu/ubuntu.pro 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1TARGET = qubuntu
2TEMPLATE = lib
3
4QT += gui-private platformsupport-private sensors
5
6DEFINES += MESA_EGL_NO_X11_HEADERS
7QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
8QMAKE_LFLAGS += -Wl,-no-undefined
9
10CONFIG(debug) {
11 QMAKE_CXXFLAGS_DEBUG += -Werror
12}
13
14SOURCES = main.cc
15
16CONFIG += plugin link_prl link_pkgconfig
17
18PKGCONFIG += egl
19INCLUDEPATH += ../../ ../
20LIBS += -L../ubuntucommon -lqubuntucommon -lubuntu_application_api -L../../base -lubuntubase
21
22OTHER_FILES += ubuntu.json
23
24target.path += $$[QT_INSTALL_PLUGINS]/platforms
25INSTALLS += target
260
=== removed directory 'src/platforms/ubuntu/ubuntucommon'
=== removed file 'src/platforms/ubuntu/ubuntucommon/clipboard.cc'
--- src/platforms/ubuntu/ubuntucommon/clipboard.cc 2013-05-21 22:11:57 +0000
+++ src/platforms/ubuntu/ubuntucommon/clipboard.cc 1970-01-01 00:00:00 +0000
@@ -1,126 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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// FIXME(loicm) The clipboard data format is not defined by Ubuntu Platform API
17// which makes it impossible to have non-Qt applications communicate with Qt
18// applications through the clipboard API. The solution would be to have
19// Ubuntu Platform define the data format or propose an API that supports
20// embedding different mime types in the clipboard.
21
22// Data format:
23// number of mime types (4 bytes)
24// data layout (16 bytes * number of mime types)
25// mime type string offset (4 bytes)
26// mime type string size (4 bytes)
27// data offset (4 bytes)
28// data size (4 bytes)
29// data (n bytes)
30
31#include "clipboard.h"
32#include "base/logging.h"
33#include <QtCore/QMimeData>
34#include <QtCore/QStringList>
35#include <ubuntu/application/ui/clipboard.h>
36
37const int maxFormatsCount = 16;
38const int maxBufferSize = 4 * 1024 * 1024; // 4 Mb
39
40QUbuntuClipboard::QUbuntuClipboard()
41 : QUbuntuBaseClipboard()
42 , mimeData_(new QMimeData()) {
43 DLOG("QUbuntuClipboard::QUbuntuClipboard (this=%p)", this);
44}
45
46QUbuntuClipboard::~QUbuntuClipboard() {
47 DLOG("QUbuntuClipboard::~QUbuntuClipboard");
48 delete mimeData_;
49}
50
51QMimeData* QUbuntuClipboard::mimeData(QClipboard::Mode mode) {
52 Q_UNUSED(mode);
53 DLOG("QUbuntuClipboard::mimeData (this=%p, mode=%d)", this, static_cast<int>(mode));
54 // Get clipboard data.
55 void* data = NULL;
56 size_t size = 0;
57 ua_ui_get_clipboard_content(&data, &size);
58
59 // Deserialize, update and return mime data taking care of incorrectly
60 // formatted input.
61 mimeData_->clear();
62 if (static_cast<size_t>(size) > sizeof(int) // Should be at least that big to read the count.
63 && data != NULL) {
64 const char* const buffer = reinterpret_cast<char*>(data);
65 const int* const header = reinterpret_cast<int*>(data);
66 const int count = qMin(header[0], maxFormatsCount);
67 for (int i = 0; i < count; i++) {
68 const unsigned int formatOffset = header[i*4+1];
69 const unsigned int formatSize = header[i*4+2];
70 const unsigned int dataOffset = header[i*4+3];
71 const unsigned int dataSize = header[i*4+4];
72 if (formatOffset + formatSize <= size && dataOffset + dataSize <= size) {
73 mimeData_->setData(QString(&buffer[formatOffset]),
74 QByteArray(&buffer[dataOffset], dataSize));
75 }
76 }
77 }
78 return mimeData_;
79}
80
81void QUbuntuClipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode) {
82 Q_UNUSED(mode);
83 DLOG("QUbuntuClipboard::setMimeData (this=%p, data=%p, mode=%d)", this, mimeData,
84 static_cast<int>(mode));
85 if (mimeData == NULL) {
86 ua_ui_set_clipboard_content(NULL, 0);
87 return;
88 }
89
90 const QStringList formats = mimeData->formats();
91 const int count = qMin(formats.size(), maxFormatsCount);
92 const int headerSize = sizeof(int) + count * 4 * sizeof(int);
93 int bufferSize = headerSize;
94 char* buffer;
95
96 // Get the buffer size considering the header size, the NULL-terminated
97 // formats and the non NULL-terminated data.
98 for (int i = 0; i < count; i++)
99 bufferSize += formats[i].size() + 1 + mimeData->data(formats[i]).size();
100 // FIXME(loicm) Implement max buffer size limitation.
101 // FIXME(loicm) Remove ASSERT before release.
102 ASSERT(bufferSize <= maxBufferSize);
103
104 // Serialize data.
105 buffer = new char[bufferSize];
106 int* header = reinterpret_cast<int*>(buffer);
107 int offset = headerSize;
108 header[0] = count;
109 for (int i = 0; i < count; i++) {
110 const int formatOffset = offset;
111 const int formatSize = formats[i].size() + 1;
112 const int dataOffset = offset + formatSize;
113 const int dataSize = mimeData->data(formats[i]).size();
114 memcpy(&buffer[formatOffset], formats[i].toLatin1().data(), formatSize);
115 memcpy(&buffer[dataOffset], mimeData->data(formats[i]).data(), dataSize);
116 header[i*4+1] = formatOffset;
117 header[i*4+2] = formatSize;
118 header[i*4+3] = dataOffset;
119 header[i*4+4] = dataSize;
120 offset += formatSize + dataSize;
121 }
122
123 // Set clipboard content.
124 ua_ui_set_clipboard_content(reinterpret_cast<void*>(buffer), bufferSize);
125 delete [] buffer;
126}
1270
=== removed file 'src/platforms/ubuntu/ubuntucommon/clipboard.h'
--- src/platforms/ubuntu/ubuntucommon/clipboard.h 2013-02-05 02:05:42 +0000
+++ src/platforms/ubuntu/ubuntucommon/clipboard.h 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTUCLIPBOARD_H
17#define QUBUNTUCLIPBOARD_H
18
19#include "base/clipboard.h"
20
21class QUbuntuClipboard : public QUbuntuBaseClipboard {
22 public:
23 QUbuntuClipboard();
24 ~QUbuntuClipboard();
25
26 // QUbuntuBaseClipboard methods.
27 QMimeData* mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
28 void setMimeData(QMimeData* data, QClipboard::Mode mode = QClipboard::Clipboard);
29
30 private:
31 QMimeData* mimeData_;
32};
33
34#endif // QUBUNTUCLIPBOARD_H
350
=== removed file 'src/platforms/ubuntu/ubuntucommon/input.cc'
--- src/platforms/ubuntu/ubuntucommon/input.cc 2013-10-17 18:38:03 +0000
+++ src/platforms/ubuntu/ubuntucommon/input.cc 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "input.h"
17#include "integration.h"
18#include "base/logging.h"
19#include <ubuntu/application/ui/input/event.h>
20
21QUbuntuInput::QUbuntuInput(QUbuntuIntegration* integration)
22 : QUbuntuBaseInput(integration)
23 , sessionType_(0) {
24 DLOG("QUbuntuInput::QUbuntuInput (this=%p integration=%p)", this, integration);
25}
26
27QUbuntuInput::~QUbuntuInput() {
28 DLOG("QUbuntuInput::~QUbuntuInput");
29}
30
31void QUbuntuInput::handleTouchEvent(
32 QWindow* window, ulong timestamp, QTouchDevice* device,
33 const QList<struct QWindowSystemInterface::TouchPoint> &points) {
34 DLOG("QUbuntuInput::handleTouchEvent (this=%p, window=%p, timestamp=%lu, device=%p)",
35 this, window, timestamp, device);
36 if (sessionType_ != 1) {
37 QUbuntuBaseInput::handleTouchEvent(window, timestamp, device, points);
38 } else {
39 // Ubuntu platform API creates an input handler per window. Since system sessions have
40 // fullscreen input handlers, the last created window has an input handler that takes precedence
41 // over the others. Because of that, only the last created window receives touch input. In order
42 // to fix that issue for system sessions, we pass the NULL pointer to the Qt handler as window
43 // argument so that it pushes the event to the window that's located at the touch point.
44 QUbuntuBaseInput::handleTouchEvent(NULL, timestamp, device, points);
45 }
46}
47
48void QUbuntuInput::setSessionType(uint sessionType) {
49 DLOG("QUbuntuInput::setSessionType (this=%p, window=%u)", this, sessionType);
50 sessionType_ = sessionType;
51}
520
=== removed file 'src/platforms/ubuntu/ubuntucommon/input.h'
--- src/platforms/ubuntu/ubuntucommon/input.h 2013-02-14 16:31:33 +0000
+++ src/platforms/ubuntu/ubuntucommon/input.h 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTUINPUT_H
17#define QUBUNTUINPUT_H
18
19#include "base/input.h"
20
21class QUbuntuIntegration;
22
23class QUbuntuInput : public QUbuntuBaseInput {
24 public:
25 QUbuntuInput(QUbuntuIntegration* integration);
26 ~QUbuntuInput();
27
28 // QUbuntuBaseInput methods.
29 void handleTouchEvent(QWindow* window, ulong timestamp, QTouchDevice* device,
30 const QList<struct QWindowSystemInterface::TouchPoint> &points);
31
32 void setSessionType(uint sessionType);
33
34 private:
35 uint sessionType_;
36};
37
38#endif // QUBUNTUINPUT_H
390
=== removed file 'src/platforms/ubuntu/ubuntucommon/input_adaptor_factory.h'
--- src/platforms/ubuntu/ubuntucommon/input_adaptor_factory.h 2013-06-24 17:52:59 +0000
+++ src/platforms/ubuntu/ubuntucommon/input_adaptor_factory.h 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTU_INPUT_ADAPTOR_FACTORY_H_
17#define QUBUNTU_INPUT_ADAPTOR_FACTORY_H_
18
19class QUbuntuInput;
20class QUbuntuIntegration;
21
22class QUbuntuInputAdaptorFactory {
23 public:
24 virtual ~QUbuntuInputAdaptorFactory() {}
25
26 virtual QUbuntuInput* create_input_adaptor(QUbuntuIntegration* integration) = 0;
27
28 protected:
29 QUbuntuInputAdaptorFactory() {}
30};
31
32#endif
330
=== removed file 'src/platforms/ubuntu/ubuntucommon/integration.cc'
--- src/platforms/ubuntu/ubuntucommon/integration.cc 2014-05-22 01:25:21 +0000
+++ src/platforms/ubuntu/ubuntucommon/integration.cc 1970-01-01 00:00:00 +0000
@@ -1,177 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "integration.h"
17#include "window.h"
18#include "input.h"
19#include "clipboard.h"
20#include "input_adaptor_factory.h"
21#include "base/logging.h"
22#include <QGuiApplication>
23#include <qpa/qplatformnativeinterface.h>
24#include <qpa/qplatforminputcontextfactory_p.h>
25#include <qpa/qplatforminputcontext.h>
26#include <ubuntu/application/lifecycle_delegate.h>
27#include <ubuntu/application/id.h>
28#include <ubuntu/application/options.h>
29#include <ubuntu/application/ui/options.h>
30#include <ubuntu/application/ui/session.h>
31
32static void resumedCallback(const UApplicationOptions *options, void* context) {
33 DLOG("resumedCallback (options=%p, context=%p)", options, context);
34 DASSERT(context != NULL);
35 QUbuntuIntegration* integration = static_cast<QUbuntuIntegration*>(context);
36 integration->screen()->toggleSensors(true);
37 QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::ApplicationActivate));
38
39 Q_FOREACH(QWindow *window, QGuiApplication::allWindows()) {
40 QGuiApplication::postEvent(window, new QExposeEvent( window->geometry() ));
41 }
42}
43
44static void aboutToStopCallback(UApplicationArchive *archive, void* context) {
45 DLOG("aboutToStopCallback (archive=%p, context=%p)", archive, context);
46 DASSERT(context != NULL);
47 QUbuntuIntegration* integration = static_cast<QUbuntuIntegration*>(context);
48 integration->screen()->toggleSensors(false);
49 integration->inputContext()->hideInputPanel();
50
51 Q_FOREACH(QWindow *window, QGuiApplication::allWindows()) {
52 QGuiApplication::postEvent(window, new QExposeEvent( QRegion() ));
53 }
54
55 QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::ApplicationDeactivate));
56}
57
58QUbuntuIntegration::QUbuntuIntegration(QUbuntuInputAdaptorFactory *input_factory)
59 : clipboard_(new QUbuntuClipboard()) {
60 // Init Ubuntu Platform library.
61 QStringList args = QCoreApplication::arguments();
62 argc_ = args.size() + 1;
63 argv_ = new char*[argc_];
64 for (int i = 0; i < argc_ - 1; i++)
65 argv_[i] = qstrdup(args.at(i).toLocal8Bit());
66 argv_[argc_ - 1] = NULL;
67 // Setup options
68 options_ = u_application_options_new_from_cmd_line(argc_ - 1, argv_);
69
70 // Setup application description
71 desc_ = u_application_description_new();
72 UApplicationId* id = u_application_id_new_from_stringn("QtUbuntu", 8);
73 u_application_description_set_application_id(desc_, id);
74 UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new();
75 u_application_lifecycle_delegate_set_application_resumed_cb(delegate, &resumedCallback);
76 u_application_lifecycle_delegate_set_application_about_to_stop_cb(delegate, &aboutToStopCallback);
77 u_application_lifecycle_delegate_set_context(delegate, this);
78 u_application_description_set_application_lifecycle_delegate(desc_, delegate);
79
80 // Create new application instance
81 instance_ = u_application_instance_new_from_description_with_options(desc_, options_);
82
83 if (instance_ == NULL)
84 qFatal("QUbuntu: Could not create application instance");
85
86 // Create default screen.
87 screen_ = new QUbuntuScreen(options_);
88 screenAdded(screen_);
89
90 // FIXME (ricmm) We shouldn't disable sensors for the shell process
91 // it is only valid right now because the shell doesnt use them
92 screen_->toggleSensors(false);
93 isShell_ = false;
94 if (args.contains("unity8") || args.contains("/usr/bin/unity8") ||
95 args.contains("unity8-greeter") || args.contains("/usr/bin/unity8-greeter"))
96 isShell_ = true;
97
98 // Initialize input.
99 if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_INPUT")) {
100 input_ = input_factory->create_input_adaptor(this);
101 inputContext_ = QPlatformInputContextFactory::create();
102 } else {
103 input_ = NULL;
104 inputContext_ = NULL;
105 }
106
107 DLOG("QUbuntuIntegration::QUbuntuIntegration (this=%p)", this);
108}
109
110QUbuntuIntegration::~QUbuntuIntegration() {
111 DLOG("QUbuntuIntegration::~QUbuntuIntegration");
112 delete clipboard_;
113 delete input_;
114 delete inputContext_;
115 delete screen_;
116 for (int i = 0; i < argc_; i++)
117 delete [] argv_[i];
118 delete [] argv_;
119}
120
121QPlatformWindow* QUbuntuIntegration::createPlatformWindow(QWindow* window) const {
122 DLOG("QUbuntuIntegration::createPlatformWindow const (this=%p, window=%p)", this, window);
123 return const_cast<QUbuntuIntegration*>(this)->createPlatformWindow(window);
124}
125
126QPlatformWindow* QUbuntuIntegration::createPlatformWindow(QWindow* window) {
127 DLOG("QUbuntuIntegration::createPlatformWindow (this=%p, window=%p)", this, window);
128 static uint sessionType;
129
130 // Start a session before creating the first window.
131 static bool once = false;
132 if (!once) {
133 sessionType = nativeInterface()->property("session").toUInt();
134 // FIXME(loicm) Remove that once all system applications have been ported to the new property.
135 if (sessionType == 0) {
136 sessionType = nativeInterface()->property("ubuntuSessionType").toUInt();
137 }
138#if !defined(QT_NO_DEBUG)
139 ASSERT(sessionType <= U_SYSTEM_SESSION);
140 const char* const sessionTypeString[] = {
141 "User", "System"
142 };
143 const char* const stageHintString[] = {
144 "Main", "Integration", "Share", "Content picking", "Side", "Configuration",
145 };
146 const char* const formFactorHintString[] = {
147 "Desktop", "Phone", "Tablet"
148 };
149 LOG("ubuntu session type: '%s'", sessionTypeString[sessionType]);
150 LOG("ubuntu application stage hint: '%s'",
151 stageHintString[u_application_options_get_stage(options_)]);
152 LOG("ubuntu application form factor: '%s'",
153 formFactorHintString[u_application_options_get_form_factor(options_)]);
154#endif
155
156 LOG("callbacks %p %p", &resumedCallback, &aboutToStopCallback);
157
158 props_ = ua_ui_session_properties_new();
159 ua_ui_session_properties_set_type(props_, static_cast<UAUiSessionType>(sessionType));
160
161 ua_ui_session_properties_set_remote_pid(props_,
162 static_cast<uint32_t>(QCoreApplication::applicationPid()));
163
164 session_ = ua_ui_session_new_with_properties(props_);
165
166 input_->setSessionType(sessionType);
167 once = true;
168 }
169
170 QStringList args = QCoreApplication::arguments();
171
172 // Create the window.
173 QPlatformWindow* platformWindow = new QUbuntuWindow(
174 window, static_cast<QUbuntuScreen*>(screen_), input_, static_cast<bool>(sessionType), instance_, isShell_);
175 platformWindow->requestActivateWindow();
176 return platformWindow;
177}
1780
=== removed file 'src/platforms/ubuntu/ubuntucommon/integration.h'
--- src/platforms/ubuntu/ubuntucommon/integration.h 2013-08-08 15:29:08 +0000
+++ src/platforms/ubuntu/ubuntucommon/integration.h 1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTUINTEGRATION_H
17#define QUBUNTUINTEGRATION_H
18
19#include "base/integration.h"
20#include "screen.h"
21#include <ubuntu/application/instance.h>
22#include <ubuntu/application/ui/session.h>
23
24class QUbuntuInputAdaptorFactory;
25class QUbuntuInput;
26
27class QUbuntuIntegration : public QUbuntuBaseIntegration {
28 public:
29 QUbuntuIntegration(QUbuntuInputAdaptorFactory* input_factory);
30 ~QUbuntuIntegration();
31
32 // QPlatformIntegration methods.
33 QPlatformWindow* createPlatformWindow(QWindow* window) const;
34 QPlatformWindow* createPlatformWindow(QWindow* window);
35 QPlatformInputContext* inputContext() const { return inputContext_; }
36 QPlatformClipboard* clipboard() const { return clipboard_; }
37 QUbuntuScreen* screen() const { return screen_; }
38
39 private:
40 int argc_;
41 char** argv_;
42 QUbuntuScreen* screen_;
43 QUbuntuInput* input_;
44 QPlatformInputContext* inputContext_;
45 QPlatformClipboard* clipboard_;
46 bool isShell_;
47
48 UApplicationOptions* options_;
49 UApplicationDescription* desc_;
50 UApplicationInstance* instance_;
51 UAUiSessionProperties* props_;
52 UAUiSession* session_;
53};
54
55#endif // QUBUNTUINTEGRATION_H
560
=== removed file 'src/platforms/ubuntu/ubuntucommon/screen.cc'
--- src/platforms/ubuntu/ubuntucommon/screen.cc 2014-02-20 23:03:54 +0000
+++ src/platforms/ubuntu/ubuntucommon/screen.cc 1970-01-01 00:00:00 +0000
@@ -1,192 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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// Unit conversion code has been extracted from the Ubuntu UI toolkit.
17
18#include "screen.h"
19#include "base/logging.h"
20#include <QtCore/QCoreApplication>
21#include <QtCore/qmath.h>
22#include <QtSensors/QOrientationSensor>
23#include <QtSensors/QOrientationReading>
24#include <QtGui/QScreen>
25#include <QtCore/QThread>
26#include <qpa/qwindowsysteminterface.h>
27#include <ubuntu/application/ui/options.h>
28#include <ubuntu/application/ui/display.h>
29
30class OrientationReadingEvent : public QEvent {
31 public:
32 OrientationReadingEvent(QEvent::Type type, QOrientationReading::Orientation orientation)
33 : QEvent(type)
34 , orientation_(orientation) {
35 DLOG("OrientationReadingEvent::OrientationReadingEvent()");
36 }
37 ~OrientationReadingEvent() {
38 DLOG("OrientationReadingEvent::~OrientationReadingEvent()");
39 }
40 static const QEvent::Type type_;
41 QOrientationReading::Orientation orientation_;
42};
43
44const QEvent::Type OrientationReadingEvent::type_ =
45 static_cast<QEvent::Type>(QEvent::registerEventType());
46
47// Grid unit used if GRID_UNIT_PX is not in the environment.
48const int kDefaultGridUnit = 8;
49
50// Size of the side stage in grid units.
51// FIXME(loicm) Hard-coded to 40 grid units for now.
52const int kSideStageWidth = 40;
53
54// Lifted from shell to determine form factor
55const int kTabletMinSize = 100;
56
57QUbuntuScreen::QUbuntuScreen(UApplicationOptions *options) {
58 // Retrieve units from the environment.
59 int gridUnit = kDefaultGridUnit;
60 QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
61 if (!gridUnitString.isEmpty()) {
62 bool ok;
63 gridUnit = gridUnitString.toInt(&ok);
64 if (!ok) {
65 gridUnit = kDefaultGridUnit;
66 }
67 }
68 gridUnit_ = gridUnit;
69 densityPixelRatio_ = static_cast<float>(gridUnit) / kDefaultGridUnit;
70 DLOG("grid unit is %d", gridUnit);
71 DLOG("density pixel ratio is %.2f", densityPixelRatio_);
72
73 // Compute menubar strut.
74 // FIXME(loicm) Hard-coded to 3 grid units plus 2 density independent pixels for now.
75 struct { int left; int right; int top; int bottom; } strut = {
76 0, 0, gridUnitToPixel(3) + densityPixelToPixel(2), 0
77 };
78 DLOG("menu bar height is %d pixels", strut.top);
79
80 // Get screen resolution.
81 UAUiDisplay* display = ua_ui_display_new_with_index(0);
82 const int kScreenWidth = ua_ui_display_query_horizontal_res(display);
83 const int kScreenHeight = ua_ui_display_query_vertical_res(display);
84 ASSERT(kScreenWidth > 0 && kScreenHeight > 0);
85 DLOG("screen resolution: %dx%d", kScreenWidth, kScreenHeight);
86 ua_ui_display_destroy(display);
87
88 // Store geometries depending on the stage hint.
89 UAUiStage kStageHint = static_cast<UAUiStage>(u_application_options_get_stage(options));
90 if (kScreenWidth/gridUnit < kTabletMinSize)
91 kStageHint = U_MAIN_STAGE;
92
93 DASSERT(kStageHint == U_MAIN_STAGE || kStageHint == U_SIDE_STAGE);
94 if (kStageHint != U_SIDE_STAGE) {
95 geometry_ = QRect(0, 0, kScreenWidth, kScreenHeight);
96 availableGeometry_ = QRect(
97 strut.left, strut.top, kScreenWidth - strut.left - strut.right,
98 kScreenHeight - strut.top - strut.bottom);
99 } else {
100 const int kSideStageWidthPixels = gridUnitToPixel(kSideStageWidth);
101 geometry_ = QRect(kScreenWidth - kSideStageWidthPixels, 0, kSideStageWidthPixels,
102 kScreenHeight);
103 availableGeometry_ = QRect(
104 kScreenWidth - kSideStageWidthPixels + strut.left, strut.top,
105 kSideStageWidthPixels - strut.left - strut.right, kScreenHeight - strut.top - strut.bottom);
106 }
107
108 DLOG("QUbuntuScreen::QUbuntuScreen (this=%p)", this);
109
110 // Set the default orientation based on the initial screen dimmensions.
111 nativeOrientation_ = (availableGeometry_.width() >= availableGeometry_.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
112
113 // If it's a landscape device (i.e. some tablets), start in landscape, otherwise portrait
114 currentOrientation_ = (nativeOrientation_ == Qt::LandscapeOrientation) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
115
116 orientationSensor_ = new QOrientationSensor();
117 QObject::connect(orientationSensor_, SIGNAL(readingChanged()), this, SLOT(onOrientationReadingChanged()));
118 orientationSensor_->start();
119}
120
121QUbuntuScreen::~QUbuntuScreen() {
122 DLOG("QUbuntuScreen::~QUbuntuScreen");
123
124 delete orientationSensor_;
125}
126
127void QUbuntuScreen::toggleSensors(bool enable) const {
128 DLOG("QUbuntuScreen::toggleSensors (this=%p, enable=%d)", this, enable);
129 if (enable)
130 orientationSensor_->start();
131 else
132 orientationSensor_->stop();
133}
134
135int QUbuntuScreen::gridUnitToPixel(int value) const {
136 DLOG("QUbuntuScreen::gridUnitToPixel (this=%p, value=%d)", this, value);
137 return value * gridUnit_;
138}
139
140int QUbuntuScreen::densityPixelToPixel(int value) const {
141 DLOG("QUbuntuScreen::densityPixelToPixel (this=%p, value=%d)", this, value);
142 if (value <= 2) {
143 // For values under 2dp, return only multiples of the value.
144 return static_cast<int>(value * qFloor(densityPixelRatio_));
145 } else {
146 return static_cast<int>(qRound(value * densityPixelRatio_));
147 }
148}
149
150void QUbuntuScreen::customEvent(QEvent* event) {
151 DLOG("QUbuntuScreen::customEvent (event: %p)", event);
152 DASSERT(QThread::currentThread() == thread());
153
154 OrientationReadingEvent* oReadingEvent = static_cast<OrientationReadingEvent*>(event);
155 switch (oReadingEvent->orientation_) {
156 case QOrientationReading::LeftUp: {
157 currentOrientation_ = (nativeOrientation_ == Qt::LandscapeOrientation) ?
158 Qt::InvertedPortraitOrientation : Qt::LandscapeOrientation;
159 break;
160 }
161 case QOrientationReading::TopUp: {
162 currentOrientation_ = (nativeOrientation_ == Qt::LandscapeOrientation) ?
163 Qt::LandscapeOrientation : Qt::PortraitOrientation;
164 break;
165 }
166 case QOrientationReading::RightUp: {
167 currentOrientation_ = (nativeOrientation_ == Qt::LandscapeOrientation) ?
168 Qt::PortraitOrientation : Qt::InvertedLandscapeOrientation;
169 break;
170 }
171 case QOrientationReading::TopDown: {
172 currentOrientation_ = (nativeOrientation_ == Qt::LandscapeOrientation) ?
173 Qt::InvertedLandscapeOrientation : Qt::InvertedPortraitOrientation;
174 break;
175 }
176 default: {
177 DLOG("Unknown orientation.");
178 }
179 }
180
181 // Raise the event signal so that client apps know the orientation changed
182 QWindowSystemInterface::handleScreenOrientationChange(screen(), currentOrientation_);
183}
184
185void QUbuntuScreen::onOrientationReadingChanged() {
186 DLOG("QUbuntuScreen::onOrientationReadingChanged");
187 DASSERT(orientationSensor_ != NULL);
188
189 // Make sure to switch to the main Qt thread context
190 QCoreApplication::postEvent(this, new OrientationReadingEvent(
191 OrientationReadingEvent::type_, orientationSensor_->reading()->orientation()));
192}
1930
=== removed file 'src/platforms/ubuntu/ubuntucommon/screen.h'
--- src/platforms/ubuntu/ubuntucommon/screen.h 2013-08-02 16:34:13 +0000
+++ src/platforms/ubuntu/ubuntucommon/screen.h 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTUSCREEN_H
17#define QUBUNTUSCREEN_H
18
19#include "base/screen.h"
20#include <ubuntu/application/ui/options.h>
21
22#include <QObject>
23
24class QOrientationSensor;
25
26class QUbuntuScreen : public QObject, public QUbuntuBaseScreen {
27 Q_OBJECT
28 public:
29 QUbuntuScreen(UApplicationOptions *options);
30 ~QUbuntuScreen();
31
32 // QPlatformScreen methods.
33 QRect geometry() const { return geometry_; }
34 QRect availableGeometry() const { return availableGeometry_; }
35
36 Qt::ScreenOrientation nativeOrientation() const { return nativeOrientation_; }
37 Qt::ScreenOrientation orientation() const { return currentOrientation_; }
38 int gridUnitToPixel(int value) const;
39 int densityPixelToPixel(int value) const;
40
41 void toggleSensors(bool enable) const;
42
43 // QObject methods.
44 void customEvent(QEvent* event);
45
46 public Q_SLOTS:
47 void onOrientationReadingChanged();
48
49 private:
50 QRect geometry_;
51 QRect availableGeometry_;
52 int gridUnit_;
53 float densityPixelRatio_;
54 Qt::ScreenOrientation nativeOrientation_;
55 Qt::ScreenOrientation currentOrientation_;
56 QOrientationSensor* orientationSensor_;
57};
58
59#endif // QUBUNTUSCREEN_H
600
=== removed file 'src/platforms/ubuntu/ubuntucommon/ubuntucommon.pro'
--- src/platforms/ubuntu/ubuntucommon/ubuntucommon.pro 2013-11-22 15:24:44 +0000
+++ src/platforms/ubuntu/ubuntucommon/ubuntucommon.pro 1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
1TARGET = qubuntucommon
2TEMPLATE = lib
3
4QT += gui-private
5
6DEFINES += MESA_EGL_NO_X11_HEADERS
7QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
8QMAKE_LFLAGS += -Wl,-no-undefined
9
10CONFIG(debug) {
11 QMAKE_CXXFLAGS_DEBUG += -Werror
12}
13
14SOURCES = integration.cc \
15 window.cc \
16 screen.cc \
17 input.cc \
18 clipboard.cc
19
20HEADERS = integration.h \
21 window.h \
22 screen.h \
23 input.h \
24 clipboard.h \
25 input_adaptor_factory.h
26
27CONFIG += static plugin create_prl link_prl
28
29INCLUDEPATH += ../../
30LIBS += -L../base -Wl,--whole-archive -lubuntubase -Wl,--no-whole-archive
310
=== removed file 'src/platforms/ubuntu/ubuntucommon/window.cc'
--- src/platforms/ubuntu/ubuntucommon/window.cc 2014-04-16 16:27:37 +0000
+++ src/platforms/ubuntu/ubuntucommon/window.cc 1970-01-01 00:00:00 +0000
@@ -1,230 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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// FIXME(loicm) The fullscreen API from Ubuntu Platform isn't good enough as we can't leave
17// fullscreen. The current Ubuntu Platform fullscreen call allows the application manager to
18// know the fullscreen state of an application, it's still the application responsibility to set
19// the right surface geometry.
20
21#include "window.h"
22#include "screen.h"
23#include "input.h"
24#include "base/logging.h"
25#include <qpa/qwindowsysteminterface.h>
26#include <ubuntu/application/ui/window.h>
27#include <QRegion>
28
29static void eventCallback(void* context, const Event* event) {
30 DLOG("eventCallback (context=%p, event=%p)", context, event);
31 DASSERT(context != NULL);
32 QUbuntuWindow* window = static_cast<QUbuntuWindow*>(context);
33 window->input_->postEvent(window->window(), event);
34}
35
36QUbuntuWindow::QUbuntuWindow(
37 QWindow* w, QUbuntuScreen* screen, QUbuntuInput* input,
38 bool systemSession, UApplicationInstance* instance, bool isShell)
39 : QUbuntuBaseWindow(w, screen)
40 , input_(input)
41 , state_(window()->windowState())
42 , systemSession_(systemSession)
43 , uainstance_(instance)
44 , screen_(screen)
45 , isShell_(isShell)
46 , exposed_(false)
47{
48 if (!systemSession) {
49 // Non-system sessions can't resize the window geometry.
50 geometry_ = screen->availableGeometry();
51 } else {
52 // Use client geometry if set explicitly, use available screen geometry otherwise.
53 geometry_ = window()->geometry() != screen->geometry() ?
54 window()->geometry() : screen->availableGeometry();
55 }
56 createWindow();
57 DLOG("QUbuntuWindow::QUbuntuWindow (this=%p, w=%p, screen=%p, input=%p)", this, w, screen, input);
58}
59
60QUbuntuWindow::~QUbuntuWindow() {
61 DLOG("QUbuntuWindow::~QUbuntuWindow");
62 destroyEGLSurface();
63 ua_ui_window_destroy(window_);
64}
65
66void QUbuntuWindow::createWindow() {
67 DLOG("QUbuntuWindow::createWindow (this=%p)", this);
68
69 // Get surface role and flags.
70 QVariant roleVariant = window()->property("role");
71 int role = roleVariant.isValid() ? roleVariant.toUInt() : 1; // 1 is the default role for apps.
72 QVariant opaqueVariant = window()->property("opaque");
73 uint flags = opaqueVariant.isValid() ?
74 opaqueVariant.toUInt() ? static_cast<uint>(IS_OPAQUE_FLAG) : 0 : 0;
75 if (!systemSession_) {
76 // FIXME(loicm) Opaque flag is forced for now for non-system sessions (applications) for
77 // performance reasons.
78 flags |= static_cast<uint>(IS_OPAQUE_FLAG);
79 }
80
81 const QByteArray title = (!window()->title().isNull()) ? window()->title().toUtf8() : "Window 1"; // legacy title
82
83#if !defined(QT_NO_DEBUG)
84 //ASSERT(role <= ON_SCREEN_KEYBOARD_ACTOR_ROLE);
85 const char* const roleString[] = {
86 "Dash", "Default", "Indicator", "Notifications", "Greeter", "Launcher", "OSK", "ShutdownDialog"
87 };
88 LOG("role: '%s'", roleString[role]);
89 LOG("flags: '%s'", (flags & static_cast<uint>(1)) ? "Opaque" : "NotOpaque");
90 LOG("title: '%s'", title.constData());
91#endif
92
93 // Get surface geometry.
94 QRect geometry;
95 if (state_ == Qt::WindowFullScreen) {
96 geometry = screen()->geometry();
97 } else if (state_ == Qt::WindowMaximized) {
98 geometry = screen()->availableGeometry();
99 } else {
100 geometry = geometry_;
101 }
102
103 fprintf(stderr, "creating surface at (%d, %d) with size (%d, %d) with title '%s'", geometry.x(), geometry.y(),
104 geometry.width(), geometry.height(), title.data());
105
106 // Setup platform window creation properties
107 wprops_ = ua_ui_window_properties_new_for_normal_window();
108 ua_ui_window_properties_set_titlen(wprops_, title.data(), title.size());
109 ua_ui_window_properties_set_role(wprops_, static_cast<UAUiWindowRole>(role));
110 ua_ui_window_properties_set_input_cb_and_ctx(wprops_, &eventCallback, this);
111 ua_ui_window_properties_set_dimensions(wprops_, geometry.width(), geometry.height());
112
113 // Create platform window
114 window_ = ua_ui_window_new_for_application_with_properties(uainstance_, wprops_);
115
116 if (geometry.width() != 0 || geometry.height() != 0)
117 ua_ui_window_resize(window_, geometry.width(), geometry.height());
118
119 if (geometry.x() != 0 || geometry.y() != 0)
120 ua_ui_window_move(window_, geometry.x(), geometry.y());
121
122 ASSERT(window_ != NULL);
123 createEGLSurface(ua_ui_window_get_native_type(window_));
124 if (state_ == Qt::WindowFullScreen) {
125 ua_ui_window_request_fullscreen(window_);
126 }
127
128 // Tell Qt about the geometry.
129 QWindowSystemInterface::handleGeometryChange(window(), geometry);
130 QPlatformWindow::setGeometry(geometry);
131}
132
133void QUbuntuWindow::moveResize(const QRect& rect) {
134 fprintf(stderr, "\nQUbuntuWindow::moveResize (this=%p, x=%d, y=%d, w=%d, h=%d)\n", this, rect.x(), rect.y(),
135 rect.width(), rect.height());
136 ua_ui_window_move(window_, rect.x(), rect.y());
137 ua_ui_window_resize(window_, rect.width(), rect.height());
138 QWindowSystemInterface::handleGeometryChange(window(), rect);
139 QPlatformWindow::setGeometry(rect);
140}
141
142void QUbuntuWindow::setWindowState(Qt::WindowState state) {
143 DLOG("QUbuntuWindow::setWindowState (this=%p, state=%d)", this, state);
144 if (state == state_)
145 return;
146
147 switch (state) {
148 case Qt::WindowNoState: {
149 DLOG("setting window state: 'NoState'");
150 moveResize(geometry_);
151 state_ = Qt::WindowNoState;
152 break;
153 }
154 case Qt::WindowFullScreen: {
155 DLOG("setting window state: 'FullScreen'");
156 ua_ui_window_request_fullscreen(window_);
157 moveResize(screen()->geometry());
158 state_ = Qt::WindowFullScreen;
159 break;
160 }
161 case Qt::WindowMaximized: {
162 DLOG("setting window state: 'Maximized'");
163 moveResize(screen()->availableGeometry());
164 state_ = Qt::WindowMaximized;
165 break;
166 }
167 case Qt::WindowActive:
168 case Qt::WindowMinimized:
169 default: {
170 DLOG("setting window state: 'Active|Minimized'");
171 break;
172 }
173 }
174}
175
176void QUbuntuWindow::setGeometry(const QRect& rect) {
177 fprintf(stderr, "QUbuntuWindow::setGeometry (this=%p)", this);
178 if (systemSession_) {
179 // Non-system sessions can't resize the window geometry.
180 geometry_ = rect;
181 if (state_ != Qt::WindowFullScreen && state_ != Qt::WindowMaximized)
182 moveResize(rect);
183 }
184}
185
186void QUbuntuWindow::setVisible(bool visible) {
187 DLOG("QUbuntuWindow::setVisible (this=%p, visible=%s)", this, visible ? "true" : "false");
188 if (isShell_ == false)
189 screen_->toggleSensors(visible);
190
191 setExposed(visible);
192
193 if (visible) {
194 ua_ui_window_show(window_);
195 } else {
196 ua_ui_window_hide(window_);
197 }
198}
199
200bool QUbuntuWindow::isExposed() const {
201 return exposed_;
202}
203
204void QUbuntuWindow::setExposed(const bool exposed) {
205 DLOG("QUbuntuWindow::setExposed (this=%p, exposed=%s)", this, exposed ? "true" : "false");
206
207 if (exposed_ == exposed)
208 return;
209
210 exposed_ = exposed;
211 if (exposed_) {
212 QWindowSystemInterface::handleExposeEvent(window(), geometry());
213 } else {
214 QWindowSystemInterface::handleExposeEvent(window(), QRect());
215 }
216}
217
218void QUbuntuWindow::windowEvent(QEvent *event) {
219 if (event->type() == QEvent::Expose) {
220 QRegion region = static_cast<QExposeEvent *>(event)->region();
221
222 if (region.isEmpty()) {
223 // hiding window causes Qt to release the GL context and its resources, which is a bit severe
224 // Instead can use the exposure system to stop the rendering loop, but hold onto the resources
225 setExposed(false);
226 } else {
227 setExposed(true);
228 }
229 }
230}
2310
=== removed file 'src/platforms/ubuntu/ubuntucommon/window.h'
--- src/platforms/ubuntu/ubuntucommon/window.h 2014-04-16 11:32:13 +0000
+++ src/platforms/ubuntu/ubuntucommon/window.h 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTUWINDOW_H
17#define QUBUNTUWINDOW_H
18
19#include "base/window.h"
20#include <ubuntu/application/instance.h>
21#include <ubuntu/application/ui/window.h>
22
23#define IS_OPAQUE_FLAG 1
24
25class QUbuntuScreen;
26class QUbuntuInput;
27
28class QUbuntuWindow : public QUbuntuBaseWindow {
29 public:
30 QUbuntuWindow(QWindow* w, QUbuntuScreen* screen, QUbuntuInput* input, bool systemSession, UApplicationInstance* instance, bool isShell);
31 ~QUbuntuWindow();
32
33 // QPlatformWindow methods.
34 void setGeometry(const QRect&);
35 void setWindowState(Qt::WindowState state);
36 void setVisible(bool visible);
37 bool isExposed() const;
38 void windowEvent(QEvent *event);
39
40 QUbuntuInput* input_;
41
42 private:
43 void createWindow();
44 void moveResize(const QRect& rect);
45 void setExposed(const bool exposed);
46
47 UAUiWindow* window_;
48 Qt::WindowState state_;
49 QRect geometry_;
50 bool systemSession_;
51 UApplicationInstance* uainstance_;
52 UAUiWindowProperties* wprops_;
53 QUbuntuScreen* screen_;
54 bool isShell_;
55 bool exposed_;
56};
57
58#endif // QUBUNTUWINDOW_H
590
=== removed directory 'src/platforms/ubuntu/ubuntumir'
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumir.pro'
--- src/platforms/ubuntu/ubuntumir/ubuntumir.pro 2013-06-21 17:48:36 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumir.pro 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1TEMPLATE = subdirs
2
3mirclient|mirserver{
4SUBDIRS += ubuntumircommon
5}
6
7mirclient {
8SUBDIRS += ubuntumirclient
9}
10mirserver {
11SUBDIRS += ubuntumirserver
12}
13
14ubuntumirclient.depends = ubuntumircommon
15ubuntumirserver.depends = ubuntumircommon
16
170
=== removed directory 'src/platforms/ubuntu/ubuntumir/ubuntumirclient'
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumirclient/ubuntumirclient.pro'
--- src/platforms/ubuntu/ubuntumir/ubuntumirclient/ubuntumirclient.pro 2014-05-29 10:28:33 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumirclient/ubuntumirclient.pro 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1TARGET = qubuntumirclient
2TEMPLATE = lib
3
4QT += gui-private platformsupport-private sensors
5
6DEFINES += MESA_EGL_NO_X11_HEADERS
7QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
8QMAKE_LFLAGS += -Wl,-no-undefined
9
10CONFIG(debug) {
11 QMAKE_CXXFLAGS_DEBUG += -Werror
12}
13
14SOURCES = main.cc
15
16CONFIG += plugin link_prl link_pkgconfig
17
18PKGCONFIG += egl
19INCLUDEPATH += ../../../ ../../ ../
20LIBS += -Wl,--whole-archive -L../../../base -lubuntubase -L../../ubuntucommon -lqubuntucommon -L../ubuntumircommon -lqubuntumircommon -Wl,--no-whole-archive -lubuntu_application_api
21
22OTHER_FILES += ubuntumirclient.json
23
24target.path += $$[QT_INSTALL_PLUGINS]/platforms
25INSTALLS += target
260
=== removed directory 'src/platforms/ubuntu/ubuntumir/ubuntumircommon'
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.cc'
--- src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.cc 2013-10-15 21:50:17 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.cc 1970-01-01 00:00:00 +0000
@@ -1,184 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "input.h"
17#include "integration.h"
18#include "base/logging.h"
19
20#include <QtCore/qglobal.h>
21#include <QtCore/QCoreApplication>
22#include <private/qguiapplication_p.h>
23#include <qpa/qplatforminputcontext.h>
24#include <qpa/qwindowsysteminterface.h>
25
26#include <xkbcommon/xkbcommon.h>
27#include <xkbcommon/xkbcommon-keysyms.h>
28
29#include <ubuntu/application/ui/input/event.h>
30
31// XKB Keysyms which do not map directly to Qt types (i.e. Unicode points)
32static const uint32_t KeyTable[] = {
33 XKB_KEY_Escape, Qt::Key_Escape,
34 XKB_KEY_Tab, Qt::Key_Tab,
35 XKB_KEY_ISO_Left_Tab, Qt::Key_Backtab,
36 XKB_KEY_BackSpace, Qt::Key_Backspace,
37 XKB_KEY_Return, Qt::Key_Return,
38 XKB_KEY_Insert, Qt::Key_Insert,
39 XKB_KEY_Delete, Qt::Key_Delete,
40 XKB_KEY_Clear, Qt::Key_Delete,
41 XKB_KEY_Pause, Qt::Key_Pause,
42 XKB_KEY_Print, Qt::Key_Print,
43
44 XKB_KEY_Home, Qt::Key_Home,
45 XKB_KEY_End, Qt::Key_End,
46 XKB_KEY_Left, Qt::Key_Left,
47 XKB_KEY_Up, Qt::Key_Up,
48 XKB_KEY_Right, Qt::Key_Right,
49 XKB_KEY_Down, Qt::Key_Down,
50 XKB_KEY_Prior, Qt::Key_PageUp,
51 XKB_KEY_Next, Qt::Key_PageDown,
52
53 XKB_KEY_Shift_L, Qt::Key_Shift,
54 XKB_KEY_Shift_R, Qt::Key_Shift,
55 XKB_KEY_Shift_Lock, Qt::Key_Shift,
56 XKB_KEY_Control_L, Qt::Key_Control,
57 XKB_KEY_Control_R, Qt::Key_Control,
58 XKB_KEY_Meta_L, Qt::Key_Meta,
59 XKB_KEY_Meta_R, Qt::Key_Meta,
60 XKB_KEY_Alt_L, Qt::Key_Alt,
61 XKB_KEY_Alt_R, Qt::Key_Alt,
62 XKB_KEY_Caps_Lock, Qt::Key_CapsLock,
63 XKB_KEY_Num_Lock, Qt::Key_NumLock,
64 XKB_KEY_Scroll_Lock, Qt::Key_ScrollLock,
65 XKB_KEY_Super_L, Qt::Key_Super_L,
66 XKB_KEY_Super_R, Qt::Key_Super_R,
67 XKB_KEY_Menu, Qt::Key_Menu,
68 XKB_KEY_Hyper_L, Qt::Key_Hyper_L,
69 XKB_KEY_Hyper_R, Qt::Key_Hyper_R,
70 XKB_KEY_Help, Qt::Key_Help,
71
72 XKB_KEY_KP_Space, Qt::Key_Space,
73 XKB_KEY_KP_Tab, Qt::Key_Tab,
74 XKB_KEY_KP_Enter, Qt::Key_Enter,
75 XKB_KEY_KP_Home, Qt::Key_Home,
76 XKB_KEY_KP_Left, Qt::Key_Left,
77 XKB_KEY_KP_Up, Qt::Key_Up,
78 XKB_KEY_KP_Right, Qt::Key_Right,
79 XKB_KEY_KP_Down, Qt::Key_Down,
80 XKB_KEY_KP_Prior, Qt::Key_PageUp,
81 XKB_KEY_KP_Next, Qt::Key_PageDown,
82 XKB_KEY_KP_End, Qt::Key_End,
83 XKB_KEY_KP_Begin, Qt::Key_Clear,
84 XKB_KEY_KP_Insert, Qt::Key_Insert,
85 XKB_KEY_KP_Delete, Qt::Key_Delete,
86 XKB_KEY_KP_Equal, Qt::Key_Equal,
87 XKB_KEY_KP_Multiply, Qt::Key_Asterisk,
88 XKB_KEY_KP_Add, Qt::Key_Plus,
89 XKB_KEY_KP_Separator, Qt::Key_Comma,
90 XKB_KEY_KP_Subtract, Qt::Key_Minus,
91 XKB_KEY_KP_Decimal, Qt::Key_Period,
92 XKB_KEY_KP_Divide, Qt::Key_Slash,
93
94 XKB_KEY_ISO_Level3_Shift, Qt::Key_AltGr,
95 XKB_KEY_Multi_key, Qt::Key_Multi_key,
96 XKB_KEY_Codeinput, Qt::Key_Codeinput,
97 XKB_KEY_SingleCandidate, Qt::Key_SingleCandidate,
98 XKB_KEY_MultipleCandidate, Qt::Key_MultipleCandidate,
99 XKB_KEY_PreviousCandidate, Qt::Key_PreviousCandidate,
100
101 XKB_KEY_Mode_switch, Qt::Key_Mode_switch,
102 XKB_KEY_script_switch, Qt::Key_Mode_switch,
103 XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp,
104 XKB_KEY_XF86AudioLowerVolume, Qt::Key_VolumeDown,
105 XKB_KEY_XF86PowerOff, Qt::Key_PowerOff,
106 XKB_KEY_XF86PowerDown, Qt::Key_PowerDown,
107
108 0, 0
109};
110
111QUbuntuMirInput::QUbuntuMirInput(QUbuntuIntegration* integration)
112 : QUbuntuInput(integration) {
113}
114
115QUbuntuMirInput::~QUbuntuMirInput() {
116}
117
118static uint32_t translateKeysym(uint32_t sym, char *string, size_t size) {
119 Q_UNUSED(size);
120 string[0] = '\0';
121
122 if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F35)
123 return Qt::Key_F1 + (int(sym) - XKB_KEY_F1);
124
125 for (int i = 0; KeyTable[i]; i += 2)
126 if (sym == KeyTable[i])
127 return KeyTable[i + 1];
128
129 string[0] = sym;
130 string[1] = '\0';
131 return toupper(sym);
132}
133
134void QUbuntuMirInput::dispatchKeyEvent(QWindow* window, const void* ev) {
135 DLOG("QUbuntuBaseInput::dispatchKeyEvent (this=%p, window=%p, event=%p)", this, window, ev);
136 const Event* event = reinterpret_cast<const Event*>(ev);
137
138#if (LOG_EVENTS != 0)
139 // Key event logging.
140 LOG("KEY device_id:%d source_id:%d action:%d flags:%d meta_state:%d key_code:%d "
141 "scan_code:%d repeat_count:%d down_time:%lld event_time:%lld is_system_key:%d",
142 event->device_id, event->source_id, event->action, event->flags, event->meta_state,
143 event->details.key.key_code, event->details.key.scan_code,
144 event->details.key.repeat_count, event->details.key.down_time,
145 event->details.key.event_time, event->details.key.is_system_key);
146#endif
147
148 ulong timestamp = event->details.key.event_time / 1000000;
149 xkb_keysym_t xk_sym = (xkb_keysym_t)event->details.key.key_code;
150
151 // Key modifier and unicode index mapping.
152 const int kMetaState = event->meta_state;
153 Qt::KeyboardModifiers modifiers = Qt::NoModifier;
154 if (kMetaState & U_KEY_MODIFIER_SHIFT) {
155 modifiers |= Qt::ShiftModifier;
156 }
157 if (kMetaState & U_KEY_MODIFIER_CTRL) {
158 modifiers |= Qt::ControlModifier;
159 }
160 if (kMetaState & U_KEY_MODIFIER_ALT) {
161 modifiers |= Qt::AltModifier;
162 }
163 if (kMetaState & U_KEY_MODIFIER_META) {
164 modifiers |= Qt::MetaModifier;
165 }
166
167 QEvent::Type keyType = event->action == U_KEY_ACTION_DOWN ? QEvent::KeyPress : QEvent::KeyRelease;
168
169 char s[2];
170 int sym = translateKeysym(xk_sym, s, sizeof(s));
171 QString text = QString::fromLatin1(s);
172
173 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();
174 if (context) {
175 QKeyEvent qKeyEvent(keyType, sym, modifiers, text);
176 qKeyEvent.setTimestamp(timestamp);
177 if (context->filterEvent(&qKeyEvent)) {
178 DLOG("key event filtered out by input context");
179 return;
180 }
181 }
182
183 handleKeyEvent(window, timestamp, keyType, sym, modifiers, text);
184}
1850
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.h'
--- src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.h 2013-06-24 15:58:01 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumircommon/input.h 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTU_MIR_INPUT_H
17#define QUBUNTU_MIR_INPUT_H
18
19#include "ubuntucommon/input.h"
20
21class QUbuntuIntegration;
22
23class QUbuntuMirInput : public QUbuntuInput {
24public:
25 QUbuntuMirInput(QUbuntuIntegration* integration);
26 ~QUbuntuMirInput();
27
28 virtual void dispatchKeyEvent(QWindow* window, const void* event);
29};
30
31#endif // QUBUNTU_MIR_INPUT_H
320
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.cc'
--- src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.cc 2013-06-24 17:52:59 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.cc 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "input.h"
17#include "integration.h"
18#include "ubuntucommon/input_adaptor_factory.h"
19
20namespace
21{
22struct InputAdaptorFactory : public QUbuntuInputAdaptorFactory {
23 InputAdaptorFactory() {}
24 ~InputAdaptorFactory() {}
25
26 QUbuntuInput *create_input_adaptor(QUbuntuIntegration* integration)
27 {
28 return new QUbuntuMirInput(integration);
29 }
30 static InputAdaptorFactory* instance()
31 {
32 static InputAdaptorFactory global_instance;
33 return &global_instance;
34 }
35};
36}
37
38QUbuntuMirIntegration::QUbuntuMirIntegration()
39 : QUbuntuIntegration(InputAdaptorFactory::instance()) {
40}
41
42QUbuntuMirIntegration::~QUbuntuMirIntegration() {
43}
440
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.h'
--- src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.h 2013-06-21 20:46:06 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumircommon/integration.h 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTU_MIR_INTEGRATION_H
17#define QUBUNTU_MIR_INTEGRATION_H
18
19#include "ubuntucommon/integration.h"
20
21class QUbuntuMirIntegration : public QUbuntuIntegration {
22public:
23 QUbuntuMirIntegration();
24 ~QUbuntuMirIntegration();
25};
26
27#endif // QUBUNTU_MIR_INTEGRATION_H
280
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumircommon/ubuntumircommon.pro'
--- src/platforms/ubuntu/ubuntumir/ubuntumircommon/ubuntumircommon.pro 2013-11-22 15:24:44 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumircommon/ubuntumircommon.pro 1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
1TARGET = qubuntumircommon
2TEMPLATE = lib
3
4QT += core-private gui-private
5
6DEFINES += MESA_EGL_NO_X11_HEADERS
7QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
8QMAKE_LFLAGS += -Wl,-no-undefined -L../ubuntucommon
9
10CONFIG(debug) {
11 QMAKE_CXXFLAGS_DEBUG += -Werror
12}
13
14SOURCES = input.cc integration.cc
15
16HEADERS = input.h integration.h
17
18CONFIG += static plugin create_prl link_prl
19
20INCLUDEPATH += ../../../ ../../
21LIBS += -Wl,--whole-archive -lqubuntucommon -Wl,--no-whole-archive
220
=== removed directory 'src/platforms/ubuntu/ubuntumir/ubuntumirserver'
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumirserver/main.cc'
--- src/platforms/ubuntu/ubuntumir/ubuntumirserver/main.cc 2014-05-29 10:28:33 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumirserver/main.cc 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include <qpa/qplatformintegrationplugin.h>
17#include "ubuntumircommon/integration.h"
18
19QT_BEGIN_NAMESPACE
20
21class QUbuntuMirServerIntegrationPlugin : public QPlatformIntegrationPlugin {
22 Q_OBJECT
23 Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid
24 FILE "ubuntumirserver.json")
25
26 public:
27 QStringList keys() const;
28 QPlatformIntegration* create(const QString&, const QStringList&);
29};
30
31QStringList QUbuntuMirServerIntegrationPlugin::keys() const {
32 QStringList list;
33 list << "ubuntumirserver";
34 return list;
35}
36
37QPlatformIntegration* QUbuntuMirServerIntegrationPlugin::create(
38 const QString& system, const QStringList& paramList) {
39 Q_UNUSED(paramList);
40 if (system.toLower() == "ubuntumirserver") {
41#ifdef PLATFORM_API_TOUCH
42 setenv("UBUNTU_PLATFORM_API_BACKEND", "touch_mirserver", 1);
43#else
44 setenv("UBUNTU_PLATFORM_API_BACKEND", "desktop_mirserver", 1);
45#endif
46 return new QUbuntuMirIntegration();
47 }
48 return 0;
49}
50
51QT_END_NAMESPACE
52
53#include "main.moc"
540
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.json'
--- src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.json 2013-06-10 20:48:03 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.json 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1{
2 "Keys": [ "ubuntumirserver" ]
3}
40
=== removed file 'src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.pro'
--- src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.pro 2014-05-29 10:28:33 +0000
+++ src/platforms/ubuntu/ubuntumir/ubuntumirserver/ubuntumirserver.pro 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1TARGET = qubuntumirserver
2TEMPLATE = lib
3
4QT += gui-private platformsupport-private sensors
5
6DEFINES += MESA_EGL_NO_X11_HEADERS
7QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
8QMAKE_LFLAGS += -Wl,-no-undefined
9
10CONFIG(debug) {
11 QMAKE_CXXFLAGS_DEBUG += -Werror
12}
13
14SOURCES = main.cc
15
16CONFIG += plugin link_prl link_pkgconfig
17
18PKGCONFIG += egl
19INCLUDEPATH += ../../../ ../../ ../
20LIBS += -Wl,--whole-archive -L../../../base -lubuntubase -L../../ubuntucommon -lqubuntucommon -L../ubuntumircommon -lqubuntumircommon -Wl,--no-whole-archive -lubuntu_application_api
21
22OTHER_FILES += ubuntu.json
23
24target.path += $$[QT_INSTALL_PLUGINS]/platforms
25INSTALLS += target
260
=== removed directory 'src/platforms/ubuntulegacy'
=== removed file 'src/platforms/ubuntulegacy/input.cc'
--- src/platforms/ubuntulegacy/input.cc 2013-10-17 18:38:03 +0000
+++ src/platforms/ubuntulegacy/input.cc 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "input.h"
17#include "integration.h"
18#include "base/logging.h"
19#include <qpa/qplatformwindow.h>
20
21static void eventCallback(Event* event, void* context) {
22 DLOG("eventCallback (event=%p, context=%p)", event, context);
23 QUbuntuLegacyInput* input = static_cast<QUbuntuLegacyInput*>(context);
24 if (!input->stopping_.testAndSetRelease(1, 1)) {
25 // FIXME(loicm) We need to be able to retrieve the window from an event in order to support
26 // multiple surfaces.
27 QPlatformWindow* window = static_cast<QUbuntuLegacyIntegration*>(
28 input->integration())->platformWindow();
29 if (window) {
30 input->postEvent(window->window(), event);
31 }
32 }
33}
34
35QUbuntuLegacyInput::QUbuntuLegacyInput(QUbuntuLegacyIntegration* integration)
36 : QUbuntuBaseInput(integration)
37 , stopping_(0) {
38 config_.enable_touch_point_visualization = false;
39 config_.default_layer_for_touch_point_visualization = 1;
40 listener_.on_new_event = eventCallback;
41 listener_.context = this;
42 DLOG("initializing input stack");
43 android_input_stack_initialize(&listener_, &config_);
44 DLOG("starting input stack");
45 android_input_stack_start();
46 DLOG("QUbuntuLegacyInput::QUbuntuLegacyInput (this=%p, integration=%p)", this, integration);
47}
48
49QUbuntuLegacyInput::~QUbuntuLegacyInput() {
50 DLOG("QUbuntuLegacyInput::~QUbuntuLegacyInput");
51 stopping_.fetchAndStoreRelease(1);
52 DLOG("stopping input stack");
53 android_input_stack_stop();
54 DLOG("shutting down input stack");
55 android_input_stack_shutdown();
56}
570
=== removed file 'src/platforms/ubuntulegacy/input.h'
--- src/platforms/ubuntulegacy/input.h 2013-02-14 16:31:33 +0000
+++ src/platforms/ubuntulegacy/input.h 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTULEGACYINPUT_H
17#define QUBUNTULEGACYINPUT_H
18
19#include "base/input.h"
20#include <cstring> // input_stack_compatibility_layer.h needs this for size_t.
21#include <input/input_stack_compatibility_layer.h>
22
23class QUbuntuLegacyIntegration;
24
25class QUbuntuLegacyInput : public QUbuntuBaseInput {
26 public:
27 QUbuntuLegacyInput(QUbuntuLegacyIntegration* integration);
28 ~QUbuntuLegacyInput();
29
30 QAtomicInt stopping_;
31
32 private:
33 InputStackConfiguration config_;
34 AndroidEventListener listener_;
35};
36
37#endif // QUBUNTULEGACYINPUT_H
380
=== removed file 'src/platforms/ubuntulegacy/integration.cc'
--- src/platforms/ubuntulegacy/integration.cc 2013-02-14 16:31:33 +0000
+++ src/platforms/ubuntulegacy/integration.cc 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "integration.h"
17#include "window.h"
18#include "input.h"
19#include "base/clipboard.h"
20#include "base/logging.h"
21#include <qpa/qplatforminputcontextfactory_p.h>
22#include <qpa/qplatforminputcontext.h>
23#include <QTimer>
24
25// That value seems to work on every systems and applications tested so far.
26static const int kInputDelay = 1000;
27
28QUbuntuLegacyIntegration::QUbuntuLegacyIntegration()
29 : window_(NULL)
30 , screen_(new QUbuntuLegacyScreen())
31 , input_(NULL)
32 , clipboard_(new QUbuntuBaseClipboard()) {
33 screenAdded(screen_);
34 if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_INPUT")) {
35 // Input initialization needs to be delayed in order to avoid crashes in the input stack.
36 int delay = kInputDelay;
37 QByteArray swapIntervalString = qgetenv("QTUBUNTU_INPUT_DELAY");
38 if (!swapIntervalString.isEmpty()) {
39 bool valid;
40 delay = qMax(1, swapIntervalString.toInt(&valid));
41 if (!valid)
42 delay = kInputDelay;
43 }
44 DLOG("delaying input initialization for %d ms", delay);
45 QTimer::singleShot(delay, this, SLOT(initInput()));
46 }
47 DLOG("QUbuntuLegacyIntegration::QUbuntuLegacyIntegration (this=%p)", this);
48}
49
50QUbuntuLegacyIntegration::~QUbuntuLegacyIntegration() {
51 DLOG("QUbuntuLegacyIntegration::~QUbuntuLegacyIntegration");
52 delete clipboard_;
53 delete input_;
54 delete inputContext_;
55 delete screen_;
56}
57
58void QUbuntuLegacyIntegration::initInput() {
59 DLOG("QUbuntuLegacyIntegration::initInput (this=%p)", this);
60 input_ = new QUbuntuLegacyInput(this);
61 inputContext_ = QPlatformInputContextFactory::create();
62}
63
64QPlatformWindow* QUbuntuLegacyIntegration::createPlatformWindow(QWindow* window) const {
65 DLOG("QUbuntuLegacyIntegration::createPlatformWindow const (this=%p, window=%p)", this, window);
66 return const_cast<QUbuntuLegacyIntegration*>(this)->createPlatformWindow(window);
67}
68
69QPlatformWindow* QUbuntuLegacyIntegration::createPlatformWindow(QWindow* window) {
70 DLOG("QUbuntuLegacyIntegration::createPlatformWindow (this=%p, window=%p)", this, window);
71 ASSERT(window_ == NULL); // FIXME(loicm) Multiple windows are not supported yet.
72 window_ = new QUbuntuLegacyWindow(window, static_cast<QUbuntuLegacyScreen*>(screen_));
73 window_->requestActivateWindow();
74 return window_;
75}
760
=== removed file 'src/platforms/ubuntulegacy/integration.h'
--- src/platforms/ubuntulegacy/integration.h 2013-02-14 16:31:33 +0000
+++ src/platforms/ubuntulegacy/integration.h 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTULEGACYINTEGRATION_H
17#define QUBUNTULEGACYINTEGRATION_H
18
19#include "base/integration.h"
20#include "screen.h"
21
22class QUbuntuLegacyInput;
23
24class QUbuntuLegacyIntegration : public QObject, public QUbuntuBaseIntegration {
25 Q_OBJECT
26
27 public:
28 QUbuntuLegacyIntegration();
29 ~QUbuntuLegacyIntegration();
30
31 // QPlatformIntegration methods.
32 QPlatformWindow* createPlatformWindow(QWindow* window) const;
33 QPlatformWindow* createPlatformWindow(QWindow* window);
34 QPlatformInputContext* inputContext() const { return inputContext_; }
35 QPlatformClipboard* clipboard() const { return clipboard_; }
36
37 // New methods.
38 // FIXME(loicm) Only one window can be created for now, remove that function when adding support
39 // for multiple windows.
40 QPlatformWindow* platformWindow() const { return window_; }
41
42 private slots:
43 void initInput();
44
45 private:
46 QPlatformWindow* window_;
47 QPlatformScreen* screen_;
48 QUbuntuLegacyInput* input_;
49 QPlatformInputContext* inputContext_;
50 QPlatformClipboard* clipboard_;
51};
52
53#endif // QUBUNTULEGACYINTEGRATION_H
540
=== removed file 'src/platforms/ubuntulegacy/main.cc'
--- src/platforms/ubuntulegacy/main.cc 2013-11-19 09:00:47 +0000
+++ src/platforms/ubuntulegacy/main.cc 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include <qpa/qplatformintegrationplugin.h>
17#include "integration.h"
18
19QT_BEGIN_NAMESPACE
20
21class QUbuntuLegacyIntegrationPlugin : public QPlatformIntegrationPlugin {
22 Q_OBJECT
23 Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid
24 FILE "ubuntulegacy.json")
25
26 public:
27 QStringList keys() const;
28 QPlatformIntegration* create(const QString&, const QStringList&);
29};
30
31QStringList QUbuntuLegacyIntegrationPlugin::keys() const {
32 QStringList list;
33 list << "ubuntulegacy";
34 return list;
35}
36
37QPlatformIntegration* QUbuntuLegacyIntegrationPlugin::create(
38 const QString& system, const QStringList& paramList) {
39 Q_UNUSED(paramList);
40 if (system.toLower() == "ubuntulegacy")
41 return new QUbuntuLegacyIntegration();
42 return 0;
43}
44
45QT_END_NAMESPACE
46
47#include "main.moc"
480
=== removed file 'src/platforms/ubuntulegacy/screen.cc'
--- src/platforms/ubuntulegacy/screen.cc 2013-02-14 16:31:33 +0000
+++ src/platforms/ubuntulegacy/screen.cc 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "screen.h"
17#include "base/logging.h"
18#include <surface_flinger/surface_flinger_compatibility_layer.h>
19
20QUbuntuLegacyScreen::QUbuntuLegacyScreen() {
21 const int kScreenWidth = sf_get_display_width(SURFACE_FLINGER_DEFAULT_DISPLAY_ID);
22 const int kScreenHeight = sf_get_display_height(SURFACE_FLINGER_DEFAULT_DISPLAY_ID);
23 ASSERT(kScreenWidth > 0 && kScreenHeight > 0);
24 geometry_ = QRect(0, 0, kScreenWidth, kScreenHeight);
25 ASSERT((sfClient_ = sf_client_create_full(false)) != NULL);
26 DLOG("QUbuntuLegacyScreen::QUbuntuLegacyScreen (this=%p)", this);
27}
28
29QUbuntuLegacyScreen::~QUbuntuLegacyScreen() {
30 DLOG("QUbuntuLegacyScreen::~QUbuntuLegacyScreen");
31 // FIXME(loicm) Invalid because the struct is forward declarated, we need a way to clean the
32 // handle correctly.
33 // delete sfClient_;
34}
350
=== removed file 'src/platforms/ubuntulegacy/screen.h'
--- src/platforms/ubuntulegacy/screen.h 2013-02-14 16:31:33 +0000
+++ src/platforms/ubuntulegacy/screen.h 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTULEGACYSCREEN_H
17#define QUBUNTULEGACYSCREEN_H
18
19#include "base/screen.h"
20
21struct SfClient;
22
23class QUbuntuLegacyScreen : public QUbuntuBaseScreen {
24 public:
25 QUbuntuLegacyScreen();
26 ~QUbuntuLegacyScreen();
27
28 // QPlatformScreen methods.
29 QRect geometry() const { return geometry_; }
30
31 // New methods.
32 SfClient* sfClient() const { return sfClient_; }
33
34 private:
35 QRect geometry_;
36 SfClient* sfClient_;
37};
38
39#endif // QUBUNTULEGACYSCREEN_H
400
=== removed file 'src/platforms/ubuntulegacy/ubuntulegacy.json'
--- src/platforms/ubuntulegacy/ubuntulegacy.json 2013-01-17 19:51:06 +0000
+++ src/platforms/ubuntulegacy/ubuntulegacy.json 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1{
2 "Keys": [ "ubuntulegacy" ]
3}
40
=== removed file 'src/platforms/ubuntulegacy/ubuntulegacy.pro'
--- src/platforms/ubuntulegacy/ubuntulegacy.pro 2013-01-17 19:51:06 +0000
+++ src/platforms/ubuntulegacy/ubuntulegacy.pro 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1TARGET = qubuntulegacy
2TEMPLATE = lib
3
4QT += core-private gui-private platformsupport-private
5
6DEFINES += MESA_EGL_NO_X11_HEADERS
7QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
8QMAKE_LFLAGS += -Wl,-no-undefined
9
10CONFIG(debug) {
11 QMAKE_CXXFLAGS_DEBUG += -Werror
12}
13
14SOURCES = main.cc \
15 integration.cc \
16 window.cc \
17 screen.cc \
18 input.cc
19
20HEADERS = integration.h \
21 window.h \
22 screen.h \
23 input.h
24
25CONFIG += plugin link_prl
26
27PRE_TARGETDEPS = ../base/libubuntubase.a
28
29INCLUDEPATH += .. /usr/include/hybris
30LIBS += -L../base -lubuntubase -lhybris_ics -lsf -lis
31
32OTHER_FILES += ubuntulegacy.json
33
34target.path += $$[QT_INSTALL_PLUGINS]/platforms
35INSTALLS += target
360
=== removed file 'src/platforms/ubuntulegacy/window.cc'
--- src/platforms/ubuntulegacy/window.cc 2013-10-09 12:11:20 +0000
+++ src/platforms/ubuntulegacy/window.cc 1970-01-01 00:00:00 +0000
@@ -1,120 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#include "window.h"
17#include "screen.h"
18#include "base/logging.h"
19#include <qpa/qwindowsysteminterface.h>
20#include <surface_flinger/surface_flinger_compatibility_layer.h>
21
22QUbuntuLegacyWindow::QUbuntuLegacyWindow(QWindow* w, QUbuntuLegacyScreen* screen)
23 : QUbuntuBaseWindow(w, screen)
24 , geometry_(window()->geometry())
25 , layer_((INT_MAX / 2) + winId()) {
26 // FIXME(loicm) SF compat set_size() function doesn't seem to work as expected, surfaces are
27 // created fullscreen and never resized for now.
28 QRect screenGeometry(screen->availableGeometry());
29 SfSurfaceCreationParameters parameters = {
30 screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height(), -1,
31 layer_, 1.0f, false, "QUbuntuLegacyWindow"
32 };
33 // SfSurfaceCreationParameters parameters = {
34 // geometry_.x(), geometry_.y(), geometry_.width(), geometry_.height(), -1, layer_, 1.0f, false,
35 // "QUbuntuLegacyWindow"
36 // };
37 ASSERT((sfSurface_ = sf_surface_create(screen->sfClient(), &parameters)) != NULL);
38 createEGLSurface(sf_surface_get_egl_native_window(sfSurface_));
39 setWindowState(window()->windowState());
40 DLOG("QUbuntuLegacyWindow::QUbuntuLegacyWindow (this=%p, w=%p, screen=%p)", this, w, screen);
41}
42
43QUbuntuLegacyWindow::~QUbuntuLegacyWindow() {
44 DLOG("QUbuntuLegacyWindow::~QUbuntuLegacyWindow");
45 destroyEGLSurface();
46 // FIXME(loicm) Invalid because the struct is forward declarated, we need a way to clean the
47 // handle correctly.
48 // delete sfSurface_;
49}
50
51void QUbuntuLegacyWindow::setWindowState(Qt::WindowState state) {
52 if (state == state_)
53 return;
54
55 switch (state) {
56 case Qt::WindowNoState: {
57 DLOG("QUbuntuLegacyWindow::setWindowState (this=%p, state='NoState')", this);
58 moveResize(geometry_);
59 state_ = Qt::WindowNoState;
60 break;
61 }
62 case Qt::WindowFullScreen: {
63 DLOG("QUbuntuLegacyWindow::setWindowState (this=%p, state='FullScreen')", this);
64 QRect screenGeometry(screen()->availableGeometry());
65 moveResize(screenGeometry);
66 state_ = Qt::WindowFullScreen;
67 break;
68 }
69 case Qt::WindowActive:
70 case Qt::WindowMinimized:
71 case Qt::WindowMaximized:
72 default: {
73 DLOG("QUbuntuLegacyWindow::setWindowState (this=%p, state='Active|Minimized|Maximized')", this);
74 break;
75 }
76 }
77}
78
79void QUbuntuLegacyWindow::setGeometry(const QRect& rect) {
80 DLOG("QUbuntuLegacyWindow::setGeometry (this=%p)", this);
81 geometry_ = rect;
82 if (state_ != Qt::WindowFullScreen)
83 moveResize(rect);
84}
85
86void QUbuntuLegacyWindow::setOpacity(qreal level) {
87 DLOG("QUbuntuLegacyWindow::setOpacity (this=%p, level=%.2f)", this, level);
88 sf_client_begin_transaction(screen_->sfClient());
89 sf_surface_set_alpha(sfSurface_, level);
90 sf_client_end_transaction(screen_->sfClient());
91}
92
93void QUbuntuLegacyWindow::raise() {
94 DLOG("QUbuntuLegacyWindow::raise (this=%p)", this);
95 layer_ = qMax(0, qMin(layer_ + 1, INT_MAX));
96 sf_client_begin_transaction(screen_->sfClient());
97 sf_surface_set_layer(sfSurface_, layer_);
98 sf_client_end_transaction(screen_->sfClient());
99}
100
101void QUbuntuLegacyWindow::lower() {
102 DLOG("QUbuntuLegacyWindow::lower (this=%p)", this);
103 layer_ = qMax(0, qMin(layer_ - 1, INT_MAX));
104 sf_client_begin_transaction(screen_->sfClient());
105 sf_surface_set_alpha(sfSurface_, layer_);
106 sf_client_end_transaction(screen_->sfClient());
107}
108
109void QUbuntuLegacyWindow::moveResize(const QRect& rect) {
110 DLOG("QUbuntuLegacyWindow::moveResize (this=%p, x=%d, y=%d, w=%d, h=%d)", this, rect.x(),
111 rect.y(), rect.width(), rect.height());
112 // FIXME(loicm) SF compat set_size() function doesn't seem to work as expected, surfaces are
113 // created fullscreen and never moved nor resized for now.
114 // sf_client_begin_transaction(screen_->sfClient());
115 // sf_surface_move_to(sfSurface_, rect.x(), rect.y());
116 // sf_surface_set_size(sfSurface_, rect.width(), rect.height());
117 // sf_client_end_transaction(screen_->sfClient());
118 QWindowSystemInterface::handleGeometryChange(window(), rect);
119 QPlatformWindow::setGeometry(rect);
120}
1210
=== removed file 'src/platforms/ubuntulegacy/window.h'
--- src/platforms/ubuntulegacy/window.h 2013-02-14 16:31:33 +0000
+++ src/platforms/ubuntulegacy/window.h 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2// Copyright © 2013 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#ifndef QUBUNTULEGACYWINDOW_H
17#define QUBUNTULEGACYWINDOW_H
18
19#include "base/window.h"
20
21struct SfClient;
22struct SfSurface;
23class QUbuntuLegacyScreen;
24
25class QUbuntuLegacyWindow : public QUbuntuBaseWindow {
26 public:
27 QUbuntuLegacyWindow(QWindow* w, QUbuntuLegacyScreen* screen);
28 ~QUbuntuLegacyWindow();
29
30 // QPlatformWindow methods.
31 void setGeometry(const QRect&);
32 void setWindowState(Qt::WindowState state);
33 void setOpacity(qreal level);
34 void raise();
35 void lower();
36
37 private:
38 void moveResize(const QRect& rect);
39
40 QUbuntuLegacyScreen* screen_;
41 SfSurface* sfSurface_;
42 Qt::WindowState state_;
43 QRect geometry_;
44 int layer_;
45};
46
47#endif // QUBUNTULEGACYWINDOW_H
480
=== modified file 'src/src.pro'
--- src/src.pro 2014-03-25 17:42:14 +0000
+++ src/src.pro 2014-07-21 23:47:35 +0000
@@ -1,3 +1,3 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
22
3SUBDIRS += platforms3SUBDIRS += ubuntumirclient
44
=== renamed directory 'src/platforms/base' => 'src/ubuntumirclient'
=== renamed file 'src/platforms/base/backing_store.cc' => 'src/ubuntumirclient/backingstore.cpp'
--- src/platforms/base/backing_store.cc 2013-02-14 16:31:33 +0000
+++ src/ubuntumirclient/backingstore.cpp 2014-07-21 23:47:35 +0000
@@ -1,59 +1,65 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#include "backing_store.h"17#include "backingstore.h"
17#include "logging.h"18#include "logging.h"
18#include <QtGui/QOpenGLContext>19#include <QtGui/QOpenGLContext>
19#include <QtGui/QOpenGLPaintDevice>20#include <QtGui/QOpenGLPaintDevice>
2021
21QUbuntuBaseBackingStore::QUbuntuBaseBackingStore(QWindow* window)22UbuntuBackingStore::UbuntuBackingStore(QWindow* window)
22 : QPlatformBackingStore(window)23 : QPlatformBackingStore(window)
23 , context_(new QOpenGLContext) {24 , mContext(new QOpenGLContext)
24 context_->setFormat(window->requestedFormat());25{
25 context_->setScreen(window->screen());26 mContext->setFormat(window->requestedFormat());
26 context_->create();27 mContext->setScreen(window->screen());
27 DLOG("QUbuntuBaseBackingStore::QUbuntuBaseBackingStore (this=%p, window=%p)", this, window);28 mContext->create();
28}29}
2930
30QUbuntuBaseBackingStore::~QUbuntuBaseBackingStore() {31UbuntuBackingStore::~UbuntuBackingStore()
31 DLOG("QUbuntuBaseBackingStore::~QUbuntuBaseBackingStore");32{
32 delete context_;33 delete mContext;
33}34}
3435
35void QUbuntuBaseBackingStore::flush(QWindow* window, const QRegion& region, const QPoint& offset) {36void UbuntuBackingStore::flush(QWindow* window, const QRegion& region, const QPoint& offset)
36 Q_UNUSED(region);37{
37 Q_UNUSED(offset);38 Q_UNUSED(region);
38 DLOG("QUbuntuBaseBackingStore::flush (this=%p, window=%p)", this, window);39 Q_UNUSED(offset);
39 context_->swapBuffers(window);40 mContext->swapBuffers(window);
40}41}
4142
42void QUbuntuBaseBackingStore::beginPaint(const QRegion& region) {43void UbuntuBackingStore::beginPaint(const QRegion& region)
43 Q_UNUSED(region);44{
44 DLOG("QUbuntuBaseBackingStore::beginPaint (this=%p)", this);45 Q_UNUSED(region);
45 window()->setSurfaceType(QSurface::OpenGLSurface);46 window()->setSurfaceType(QSurface::OpenGLSurface);
46 context_->makeCurrent(window());47 mContext->makeCurrent(window());
47 device_ = new QOpenGLPaintDevice(window()->size());48 mDevice = new QOpenGLPaintDevice(window()->size());
48}49}
4950
50void QUbuntuBaseBackingStore::endPaint() {51void UbuntuBackingStore::endPaint()
51 DLOG("QUbuntuBaseBackingStore::endPaint (this=%p)", this);52{
52 delete device_;53 delete mDevice;
53}54}
5455
55void QUbuntuBaseBackingStore::resize(const QSize& size, const QRegion& staticContents) {56void UbuntuBackingStore::resize(const QSize& size, const QRegion& staticContents)
56 Q_UNUSED(size);57{
57 Q_UNUSED(staticContents);58 Q_UNUSED(size);
58 DLOG("QUbuntuBaseBackingStore::resize (this=%p)", this);59 Q_UNUSED(staticContents);
60}
61
62QPaintDevice* UbuntuBackingStore::paintDevice()
63{
64 return reinterpret_cast<QPaintDevice*>(mDevice);
59}65}
6066
=== renamed file 'src/platforms/base/backing_store.h' => 'src/ubuntumirclient/backingstore.h'
--- src/platforms/base/backing_store.h 2013-02-14 16:31:33 +0000
+++ src/ubuntumirclient/backingstore.h 2014-07-21 23:47:35 +0000
@@ -1,41 +1,43 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#ifndef QUBUNTUBASEBACKINGSTORE_H17#ifndef UBUNTU_BACKING_STORE_H
17#define QUBUNTUBASEBACKINGSTORE_H18#define UBUNTU_BACKING_STORE_H
1819
19#include <qpa/qplatformbackingstore.h>20#include <qpa/qplatformbackingstore.h>
2021
21class QOpenGLContext;22class QOpenGLContext;
22class QOpenGLPaintDevice;23class QOpenGLPaintDevice;
2324
24class QUbuntuBaseBackingStore : public QPlatformBackingStore {25class UbuntuBackingStore : public QPlatformBackingStore
25 public:26{
26 QUbuntuBaseBackingStore(QWindow* window);27public:
27 ~QUbuntuBaseBackingStore();28 UbuntuBackingStore(QWindow* window);
2829 virtual ~UbuntuBackingStore();
29 // QPlatformBackingStore methods.30
30 void beginPaint(const QRegion&);31 // QPlatformBackingStore methods.
31 void endPaint();32 void beginPaint(const QRegion&) override;
32 void flush(QWindow* window, const QRegion& region, const QPoint& offset);33 void endPaint() override;
33 void resize(const QSize& size, const QRegion& staticContents);34 void flush(QWindow* window, const QRegion& region, const QPoint& offset) override;
34 QPaintDevice* paintDevice() { return reinterpret_cast<QPaintDevice*>(device_); }35 void resize(const QSize& size, const QRegion& staticContents) override;
3536 QPaintDevice* paintDevice() override;
36 private:37
37 QOpenGLContext* context_;38private:
38 QOpenGLPaintDevice* device_;39 QOpenGLContext* mContext;
40 QOpenGLPaintDevice* mDevice;
39};41};
4042
41#endif // QUBUNTUBASEBACKINGSTORE_H43#endif // UBUNTU_BACKING_STORE_H
4244
=== renamed file 'src/platforms/base/clipboard.cc' => 'src/ubuntumirclient/clipboard.cpp'
--- src/platforms/base/clipboard.cc 2013-02-05 02:05:42 +0000
+++ src/ubuntumirclient/clipboard.cpp 2014-07-21 23:47:35 +0000
@@ -1,36 +1,138 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#include "clipboard.h"17#include "clipboard.h"
17#include "logging.h"18
1819#include <QtCore/QMimeData>
19QUbuntuBaseClipboard::QUbuntuBaseClipboard() {20#include <QtCore/QStringList>
20 DLOG("QUbuntuBaseClipboard::QUbuntuBaseClipboard (this=%p)", this);21
21}22// Platform API
2223#include <ubuntu/application/ui/clipboard.h>
23QUbuntuBaseClipboard::~QUbuntuBaseClipboard() {24
24 DLOG("QUbuntuBaseClipboard::~QUbuntuBaseClipboard");25// FIXME(loicm) The clipboard data format is not defined by Ubuntu Platform API
25}26// which makes it impossible to have non-Qt applications communicate with Qt
2627// applications through the clipboard API. The solution would be to have
27QMimeData* QUbuntuBaseClipboard::mimeData(QClipboard::Mode mode) {28// Ubuntu Platform define the data format or propose an API that supports
28 DLOG("QUbuntuBaseClipboard::mimeData (this=%p, mode=%d)", this, static_cast<int>(mode));29// embedding different mime types in the clipboard.
29 return QPlatformClipboard::mimeData(mode);30
30}31// Data format:
3132// number of mime types (4 bytes)
32void QUbuntuBaseClipboard::setMimeData(QMimeData* data, QClipboard::Mode mode) {33// data layout (16 bytes * number of mime types)
33 DLOG("QUbuntuBaseClipboard::setMimeData (this=%p, data=%p, mode=%d)", this, data,34// mime type string offset (4 bytes)
34 static_cast<int>(mode));35// mime type string size (4 bytes)
35 QPlatformClipboard::setMimeData(data, mode);36// data offset (4 bytes)
37// data size (4 bytes)
38// data (n bytes)
39
40const int maxFormatsCount = 16;
41const int maxBufferSize = 4 * 1024 * 1024; // 4 Mb
42
43UbuntuClipboard::UbuntuClipboard()
44 : mMimeData(new QMimeData)
45{
46}
47
48UbuntuClipboard::~UbuntuClipboard()
49{
50 delete mMimeData;
51}
52
53QMimeData* UbuntuClipboard::mimeData(QClipboard::Mode mode)
54{
55 Q_UNUSED(mode);
56 // Get clipboard data.
57 void* data = NULL;
58 size_t size = 0;
59 ua_ui_get_clipboard_content(&data, &size);
60
61 // Deserialize, update and return mime data taking care of incorrectly
62 // formatted input.
63 mMimeData->clear();
64 if (static_cast<size_t>(size) > sizeof(int) // Should be at least that big to read the count.
65 && data != NULL) {
66 const char* const buffer = reinterpret_cast<char*>(data);
67 const int* const header = reinterpret_cast<int*>(data);
68 const int count = qMin(header[0], maxFormatsCount);
69 for (int i = 0; i < count; i++) {
70 const unsigned int formatOffset = header[i*4+1];
71 const unsigned int formatSize = header[i*4+2];
72 const unsigned int dataOffset = header[i*4+3];
73 const unsigned int dataSize = header[i*4+4];
74 if (formatOffset + formatSize <= size && dataOffset + dataSize <= size) {
75 mMimeData->setData(QString(&buffer[formatOffset]),
76 QByteArray(&buffer[dataOffset], dataSize));
77 }
78 }
79 }
80 return mMimeData;
81}
82
83void UbuntuClipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode)
84{
85 Q_UNUSED(mode);
86 if (mimeData == NULL) {
87 ua_ui_set_clipboard_content(NULL, 0);
88 return;
89 }
90
91 const QStringList formats = mimeData->formats();
92 const int count = qMin(formats.size(), maxFormatsCount);
93 const int headerSize = sizeof(int) + count * 4 * sizeof(int);
94 int bufferSize = headerSize;
95 char* buffer;
96
97 // Get the buffer size considering the header size, the NULL-terminated
98 // formats and the non NULL-terminated data.
99 for (int i = 0; i < count; i++)
100 bufferSize += formats[i].size() + 1 + mimeData->data(formats[i]).size();
101 // FIXME(loicm) Implement max buffer size limitation.
102 // FIXME(loicm) Remove ASSERT before release.
103 Q_ASSERT(bufferSize <= maxBufferSize);
104
105 // Serialize data.
106 buffer = new char[bufferSize];
107 int* header = reinterpret_cast<int*>(buffer);
108 int offset = headerSize;
109 header[0] = count;
110 for (int i = 0; i < count; i++) {
111 const int formatOffset = offset;
112 const int formatSize = formats[i].size() + 1;
113 const int dataOffset = offset + formatSize;
114 const int dataSize = mimeData->data(formats[i]).size();
115 memcpy(&buffer[formatOffset], formats[i].toLatin1().data(), formatSize);
116 memcpy(&buffer[dataOffset], mimeData->data(formats[i]).data(), dataSize);
117 header[i*4+1] = formatOffset;
118 header[i*4+2] = formatSize;
119 header[i*4+3] = dataOffset;
120 header[i*4+4] = dataSize;
121 offset += formatSize + dataSize;
122 }
123
124 // Set clipboard content.
125 ua_ui_set_clipboard_content(reinterpret_cast<void*>(buffer), bufferSize);
126 delete [] buffer;
127}
128
129bool UbuntuClipboard::supportsMode(QClipboard::Mode mode) const
130{
131 return mode == QClipboard::Clipboard;
132}
133
134bool UbuntuClipboard::ownsMode(QClipboard::Mode mode) const
135{
136 Q_UNUSED(mode);
137 return false;
36}138}
37139
=== modified file 'src/ubuntumirclient/clipboard.h'
--- src/platforms/base/clipboard.h 2013-02-05 02:05:42 +0000
+++ src/ubuntumirclient/clipboard.h 2014-07-21 23:47:35 +0000
@@ -1,33 +1,38 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#ifndef QUBUNTUBASECLIPBOARD_H17#ifndef UBUNTU_CLIPBOARD_H
17#define QUBUNTUBASECLIPBOARD_H18#define UBUNTU_CLIPBOARD_H
1819
19#include <qpa/qplatformclipboard.h>20#include <qpa/qplatformclipboard.h>
2021
21class QUbuntuBaseClipboard : public QPlatformClipboard {22class UbuntuClipboard : public QPlatformClipboard
22 public:23{
23 QUbuntuBaseClipboard();24public:
24 ~QUbuntuBaseClipboard();25 UbuntuClipboard();
2526 virtual ~UbuntuClipboard();
26 // QPlatformClipboard methods.27
27 virtual QMimeData* mimeData(QClipboard::Mode mode = QClipboard::Clipboard);28 // QPlatformClipboard methods.
28 virtual void setMimeData(QMimeData* data, QClipboard::Mode mode = QClipboard::Clipboard);29 QMimeData* mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override;
29 virtual bool supportsMode(QClipboard::Mode mode) const { return mode == QClipboard::Clipboard; }30 void setMimeData(QMimeData* data, QClipboard::Mode mode = QClipboard::Clipboard) override;
30 virtual bool ownsMode(QClipboard::Mode mode) const { Q_UNUSED(mode); return false; }31 bool supportsMode(QClipboard::Mode mode) const override;
32 bool ownsMode(QClipboard::Mode mode) const override;
33
34private:
35 QMimeData* mMimeData;
31};36};
3237
33#endif // QUBUNTUBASECLIPBOARD_H38#endif // UBUNTU_CLIPBOARD_H
3439
=== renamed file 'src/platforms/base/context.cc' => 'src/ubuntumirclient/glcontext.cpp'
--- src/platforms/base/context.cc 2014-03-18 16:38:52 +0000
+++ src/ubuntumirclient/glcontext.cpp 2014-07-21 23:47:35 +0000
@@ -1,19 +1,20 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#include "context.h"17#include "glcontext.h"
17#include "window.h"18#include "window.h"
18#include "logging.h"19#include "logging.h"
19#include <QtPlatformSupport/private/qeglconvenience_p.h>20#include <QtPlatformSupport/private/qeglconvenience_p.h>
@@ -40,80 +41,95 @@
40static EGLenum api_in_use()41static EGLenum api_in_use()
41{42{
42#ifdef QTUBUNTU_USE_OPENGL43#ifdef QTUBUNTU_USE_OPENGL
43 return EGL_OPENGL_API;44 return EGL_OPENGL_API;
44#else45#else
45 return EGL_OPENGL_ES_API;46 return EGL_OPENGL_ES_API;
46#endif47#endif
47}48}
4849
49QUbuntuBaseContext::QUbuntuBaseContext(QUbuntuBaseScreen* screen,50UbuntuOpenGLContext::UbuntuOpenGLContext(UbuntuScreen* screen, UbuntuOpenGLContext* share)
50 QUbuntuBaseContext* share) {51{
51 DASSERT(screen != NULL);52 ASSERT(screen != NULL);
52 eglDisplay_ = screen->eglDisplay();53 mEglDisplay = screen->eglDisplay();
53 screen_ = screen;54 mScreen = screen;
5455
55 // Create an OpenGL ES 2 context.56 // Create an OpenGL ES 2 context.
56 QVector<EGLint> attribs;57 QVector<EGLint> attribs;
57 attribs.append(EGL_CONTEXT_CLIENT_VERSION);58 attribs.append(EGL_CONTEXT_CLIENT_VERSION);
58 attribs.append(2);59 attribs.append(2);
59 attribs.append(EGL_NONE);60 attribs.append(EGL_NONE);
60 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);61 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);
61 ASSERT((eglContext_ = eglCreateContext(62
62 eglDisplay_, screen->eglConfig(), share ? share->eglContext() : EGL_NO_CONTEXT,63 mEglContext = eglCreateContext(mEglDisplay, screen->eglConfig(), share ? share->eglContext() : EGL_NO_CONTEXT,
63 attribs.constData())) != EGL_NO_CONTEXT);64 attribs.constData());
6465 DASSERT(mEglContext != EGL_NO_CONTEXT);
65 DLOG("QUbuntuBaseContext::QUbuntuBaseContext (this=%p, screen=%p)", this, screen);66}
66}67
6768UbuntuOpenGLContext::~UbuntuOpenGLContext()
68QUbuntuBaseContext::~QUbuntuBaseContext() {69{
69 DLOG("QUbuntuBaseContext::~QUbuntuBaseContext");70 ASSERT(eglDestroyContext(mEglDisplay, mEglContext) == EGL_TRUE);
70 ASSERT(eglDestroyContext(eglDisplay_, eglContext_) == EGL_TRUE);71}
71}72
7273bool UbuntuOpenGLContext::makeCurrent(QPlatformSurface* surface)
73bool QUbuntuBaseContext::makeCurrent(QPlatformSurface* surface) {74{
74 // DLOG("QUbuntuBaseContext::makeCurrent (this=%p, surface=%p)", this, surface);75 DASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
75 DASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);76 EGLSurface eglSurface = static_cast<UbuntuWindow*>(surface)->eglSurface();
76 EGLSurface eglSurface = static_cast<QUbuntuBaseWindow*>(surface)->eglSurface();77#if defined(QT_NO_DEBUG)
77#if defined(QT_NO_DEBUG)78 eglBindAPI(api_in_use());
78 eglBindAPI(api_in_use());79 eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext);
79 eglMakeCurrent(eglDisplay_, eglSurface, eglSurface, eglContext_);80#else
80#else81 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);
81 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);82 ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE);
82 ASSERT(eglMakeCurrent(eglDisplay_, eglSurface, eglSurface, eglContext_) == EGL_TRUE);83 printOpenGLESConfig();
83 printOpenGLESConfig();84#endif
84#endif85 return true;
85 return true;86}
86}87
8788void UbuntuOpenGLContext::doneCurrent()
88void QUbuntuBaseContext::doneCurrent() {89{
89 DLOG("QUbuntuBaseContext::doneCurrent (this=%p)", this);90#if defined(QT_NO_DEBUG)
90#if defined(QT_NO_DEBUG)91 eglBindAPI(api_in_use());
91 eglBindAPI(api_in_use());92 eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
92 eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);93#else
93#else94 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);
94 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);95 ASSERT(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_TRUE);
95 ASSERT(eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_TRUE);96#endif
96#endif97}
97}98
9899void UbuntuOpenGLContext::swapBuffers(QPlatformSurface* surface)
99void QUbuntuBaseContext::swapBuffers(QPlatformSurface* surface) {100{
100 // DLOG("QUbuntuBaseContext::swapBuffers (this=%p, surface=%p)", this, surface);101 UbuntuWindow *ubuntuWindow = static_cast<UbuntuWindow*>(surface);
101 EGLSurface eglSurface = static_cast<QUbuntuBaseWindow*>(surface)->eglSurface();102
102#if defined(QT_NO_DEBUG)103 EGLSurface eglSurface = ubuntuWindow->eglSurface();
103 eglBindAPI(api_in_use());104#if defined(QT_NO_DEBUG)
104 eglSwapBuffers(eglDisplay_, eglSurface);105 eglBindAPI(api_in_use());
105#else106 eglSwapBuffers(mEglDisplay, eglSurface);
106 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);107#else
107 ASSERT(eglSwapBuffers(eglDisplay_, eglSurface) == EGL_TRUE);108 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);
108#endif109 ASSERT(eglSwapBuffers(mEglDisplay, eglSurface) == EGL_TRUE);
109}110#endif
110111
111void (*QUbuntuBaseContext::getProcAddress(const QByteArray& procName)) () {112 // "Technique" copied from mir, in examples/eglapp.c around line 96
112 DLOG("QUbuntuBaseContext::getProcAddress (this=%p, procName=%s)", this, procName.constData());113 EGLint newBufferWidth = -1;
113#if defined(QT_NO_DEBUG)114 EGLint newBufferHeight = -1;
114 eglBindAPI(api_in_use());115 /*
115#else116 * Querying the surface (actually the current buffer) dimensions here is
116 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);117 * the only truly safe way to be sure that the dimensions we think we
117#endif118 * have are those of the buffer being rendered to. But this should be
118 return eglGetProcAddress(procName.constData());119 * improved in future; https://bugs.launchpad.net/mir/+bug/1194384
120 */
121 eglQuerySurface(mEglDisplay, eglSurface, EGL_WIDTH, &newBufferWidth);
122 eglQuerySurface(mEglDisplay, eglSurface, EGL_HEIGHT, &newBufferHeight);
123
124 ubuntuWindow->onBuffersSwapped_threadSafe(newBufferWidth, newBufferHeight);
125}
126
127void (*UbuntuOpenGLContext::getProcAddress(const QByteArray& procName)) ()
128{
129#if defined(QT_NO_DEBUG)
130 eglBindAPI(api_in_use());
131#else
132 ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);
133#endif
134 return eglGetProcAddress(procName.constData());
119}135}
120136
=== renamed file 'src/platforms/base/context.h' => 'src/ubuntumirclient/glcontext.h'
--- src/platforms/base/context.h 2014-02-10 15:26:25 +0000
+++ src/ubuntumirclient/glcontext.h 2014-07-21 23:47:35 +0000
@@ -1,43 +1,45 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#ifndef QUBUNTUBASECONTEXT_H17#ifndef UBUNTU_OPENGL_CONTEXT_H
17#define QUBUNTUBASECONTEXT_H18#define UBUNTU_OPENGL_CONTEXT_H
1819
19#include <qpa/qplatformopenglcontext.h>20#include <qpa/qplatformopenglcontext.h>
20#include "screen.h"21#include "screen.h"
2122
22class QUbuntuBaseContext : public QPlatformOpenGLContext {23class UbuntuOpenGLContext : public QPlatformOpenGLContext
23 public:24{
24 QUbuntuBaseContext(QUbuntuBaseScreen* screen,25public:
25 QUbuntuBaseContext* share);26 UbuntuOpenGLContext(UbuntuScreen* screen, UbuntuOpenGLContext* share);
26 ~QUbuntuBaseContext();27 virtual ~UbuntuOpenGLContext();
2728
28 // QPlatformOpenGLContext methods.29 // QPlatformOpenGLContext methods.
29 QSurfaceFormat format() const { return screen_->surfaceFormat(); }30 QSurfaceFormat format() const override { return mScreen->surfaceFormat(); }
30 void swapBuffers(QPlatformSurface* surface);31 void swapBuffers(QPlatformSurface* surface) override;
31 bool makeCurrent(QPlatformSurface* surface);32 bool makeCurrent(QPlatformSurface* surface) override;
32 void doneCurrent();33 void doneCurrent() override;
33 bool isValid() const { return eglContext_ != EGL_NO_CONTEXT; }34 bool isValid() const override { return mEglContext != EGL_NO_CONTEXT; }
34 void (*getProcAddress(const QByteArray& procName)) ();35 void (*getProcAddress(const QByteArray& procName)) ();
35 EGLContext eglContext() const { return eglContext_; }36
3637 EGLContext eglContext() const { return mEglContext; }
37 private:38
38 QUbuntuBaseScreen* screen_;39private:
39 EGLContext eglContext_;40 UbuntuScreen* mScreen;
40 EGLDisplay eglDisplay_;41 EGLContext mEglContext;
42 EGLDisplay mEglDisplay;
41};43};
4244
43#endif //QUBUNTUBASECONTEXT_H45#endif // UBUNTU_OPENGL_CONTEXT_H
4446
=== renamed file 'src/platforms/base/input.cc' => 'src/ubuntumirclient/input.cpp'
--- src/platforms/base/input.cc 2013-10-17 18:38:03 +0000
+++ src/ubuntumirclient/input.cpp 2014-07-21 23:47:35 +0000
@@ -1,22 +1,27 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
17// Local
16#include "input.h"18#include "input.h"
17#include "integration.h"19#include "integration.h"
18#include "native_interface.h"20#include "nativeinterface.h"
21#include "window.h"
19#include "logging.h"22#include "logging.h"
23
24// Qt
20#if !defined(QT_NO_DEBUG)25#if !defined(QT_NO_DEBUG)
21#include <QtCore/QThread>26#include <QtCore/QThread>
22#endif27#endif
@@ -24,499 +29,377 @@
24#include <QtCore/QCoreApplication>29#include <QtCore/QCoreApplication>
25#include <private/qguiapplication_p.h>30#include <private/qguiapplication_p.h>
26#include <qpa/qplatforminputcontext.h>31#include <qpa/qplatforminputcontext.h>
32#include <qpa/qwindowsysteminterface.h>
33
34#include <xkbcommon/xkbcommon.h>
35#include <xkbcommon/xkbcommon-keysyms.h>
36
37// Platform API
27#include <ubuntu/application/ui/input/event.h>38#include <ubuntu/application/ui/input/event.h>
28#include <input/input_stack_compatibility_layer_flags.h>
2939
30#define LOG_EVENTS 040#define LOG_EVENTS 0
3141
42// XKB Keysyms which do not map directly to Qt types (i.e. Unicode points)
43static const uint32_t KeyTable[] = {
44 XKB_KEY_Escape, Qt::Key_Escape,
45 XKB_KEY_Tab, Qt::Key_Tab,
46 XKB_KEY_ISO_Left_Tab, Qt::Key_Backtab,
47 XKB_KEY_BackSpace, Qt::Key_Backspace,
48 XKB_KEY_Return, Qt::Key_Return,
49 XKB_KEY_Insert, Qt::Key_Insert,
50 XKB_KEY_Delete, Qt::Key_Delete,
51 XKB_KEY_Clear, Qt::Key_Delete,
52 XKB_KEY_Pause, Qt::Key_Pause,
53 XKB_KEY_Print, Qt::Key_Print,
54
55 XKB_KEY_Home, Qt::Key_Home,
56 XKB_KEY_End, Qt::Key_End,
57 XKB_KEY_Left, Qt::Key_Left,
58 XKB_KEY_Up, Qt::Key_Up,
59 XKB_KEY_Right, Qt::Key_Right,
60 XKB_KEY_Down, Qt::Key_Down,
61 XKB_KEY_Prior, Qt::Key_PageUp,
62 XKB_KEY_Next, Qt::Key_PageDown,
63
64 XKB_KEY_Shift_L, Qt::Key_Shift,
65 XKB_KEY_Shift_R, Qt::Key_Shift,
66 XKB_KEY_Shift_Lock, Qt::Key_Shift,
67 XKB_KEY_Control_L, Qt::Key_Control,
68 XKB_KEY_Control_R, Qt::Key_Control,
69 XKB_KEY_Meta_L, Qt::Key_Meta,
70 XKB_KEY_Meta_R, Qt::Key_Meta,
71 XKB_KEY_Alt_L, Qt::Key_Alt,
72 XKB_KEY_Alt_R, Qt::Key_Alt,
73 XKB_KEY_Caps_Lock, Qt::Key_CapsLock,
74 XKB_KEY_Num_Lock, Qt::Key_NumLock,
75 XKB_KEY_Scroll_Lock, Qt::Key_ScrollLock,
76 XKB_KEY_Super_L, Qt::Key_Super_L,
77 XKB_KEY_Super_R, Qt::Key_Super_R,
78 XKB_KEY_Menu, Qt::Key_Menu,
79 XKB_KEY_Hyper_L, Qt::Key_Hyper_L,
80 XKB_KEY_Hyper_R, Qt::Key_Hyper_R,
81 XKB_KEY_Help, Qt::Key_Help,
82
83 XKB_KEY_KP_Space, Qt::Key_Space,
84 XKB_KEY_KP_Tab, Qt::Key_Tab,
85 XKB_KEY_KP_Enter, Qt::Key_Enter,
86 XKB_KEY_KP_Home, Qt::Key_Home,
87 XKB_KEY_KP_Left, Qt::Key_Left,
88 XKB_KEY_KP_Up, Qt::Key_Up,
89 XKB_KEY_KP_Right, Qt::Key_Right,
90 XKB_KEY_KP_Down, Qt::Key_Down,
91 XKB_KEY_KP_Prior, Qt::Key_PageUp,
92 XKB_KEY_KP_Next, Qt::Key_PageDown,
93 XKB_KEY_KP_End, Qt::Key_End,
94 XKB_KEY_KP_Begin, Qt::Key_Clear,
95 XKB_KEY_KP_Insert, Qt::Key_Insert,
96 XKB_KEY_KP_Delete, Qt::Key_Delete,
97 XKB_KEY_KP_Equal, Qt::Key_Equal,
98 XKB_KEY_KP_Multiply, Qt::Key_Asterisk,
99 XKB_KEY_KP_Add, Qt::Key_Plus,
100 XKB_KEY_KP_Separator, Qt::Key_Comma,
101 XKB_KEY_KP_Subtract, Qt::Key_Minus,
102 XKB_KEY_KP_Decimal, Qt::Key_Period,
103 XKB_KEY_KP_Divide, Qt::Key_Slash,
104
105 XKB_KEY_ISO_Level3_Shift, Qt::Key_AltGr,
106 XKB_KEY_Multi_key, Qt::Key_Multi_key,
107 XKB_KEY_Codeinput, Qt::Key_Codeinput,
108 XKB_KEY_SingleCandidate, Qt::Key_SingleCandidate,
109 XKB_KEY_MultipleCandidate, Qt::Key_MultipleCandidate,
110 XKB_KEY_PreviousCandidate, Qt::Key_PreviousCandidate,
111
112 XKB_KEY_Mode_switch, Qt::Key_Mode_switch,
113 XKB_KEY_script_switch, Qt::Key_Mode_switch,
114 XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp,
115 XKB_KEY_XF86AudioLowerVolume, Qt::Key_VolumeDown,
116 XKB_KEY_XF86PowerOff, Qt::Key_PowerOff,
117 XKB_KEY_XF86PowerDown, Qt::Key_PowerDown,
118
119 0, 0
120};
121
32// Lookup table for the key types.122// Lookup table for the key types.
33// FIXME(loicm) Not sure what to do with that multiple thing.123// FIXME(loicm) Not sure what to do with that multiple thing.
34static const QEvent::Type kEventType[] = {124static const QEvent::Type kEventType[] = {
35 QEvent::KeyPress, // ISCL_KEY_EVENT_ACTION_DOWN = 0125 QEvent::KeyPress, // U_KEY_ACTION_DOWN = 0
36 QEvent::KeyRelease, // ISCL_KEY_EVENT_ACTION_UP = 1126 QEvent::KeyRelease, // U_KEY_ACTION_UP = 1
37 QEvent::KeyPress // ISCL_KEY_EVENT_ACTION_MULTIPLE = 2127 QEvent::KeyPress // U_KEY_ACTION_MULTIPLE = 2
38};128};
39129
40// Lookup table for the key codes and unicode values.130class UbuntuEvent : public QEvent
41static const struct {131{
42 const quint32 keycode;132public:
43 const quint16 unicode[3]; // { no modifier, shift modifier, other modifiers }133 UbuntuEvent(UbuntuWindow* window, const WindowEvent* event, QEvent::Type type)
44} kKeyCode[] = {134 : QEvent(type), window(window) {
45 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_UNKNOWN = 0135 memcpy(&nativeEvent, event, sizeof(WindowEvent));
46 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SOFT_LEFT = 1136 }
47 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SOFT_RIGHT = 2137 UbuntuWindow* window;
48 { Qt::Key_Home, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_HOME = 3138 WindowEvent nativeEvent;
49 { Qt::Key_Back, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BACK = 4139};
50 { Qt::Key_Call, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CALL = 5140
51 { Qt::Key_Hangup, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ENDCALL = 6141UbuntuInput::UbuntuInput(UbuntuClientIntegration* integration)
52 { Qt::Key_0, { 0x0030, 0x0029, 0xffff } }, // ISCL_KEYCODE_0 = 7142 : QObject(nullptr)
53 { Qt::Key_1, { 0x0031, 0xffff, 0xffff } }, // ISCL_KEYCODE_1 = 8143 , mIntegration(integration)
54 { Qt::Key_2, { 0x0032, 0xffff, 0xffff } }, // ISCL_KEYCODE_2 = 9144 , mEventFilterType(static_cast<UbuntuNativeInterface*>(
55 { Qt::Key_3, { 0x0033, 0xffff, 0xffff } }, // ISCL_KEYCODE_3 = 10
56 { Qt::Key_4, { 0x0034, 0xffff, 0xffff } }, // ISCL_KEYCODE_4 = 11
57 { Qt::Key_5, { 0x0035, 0xffff, 0xffff } }, // ISCL_KEYCODE_5 = 12
58 { Qt::Key_6, { 0x0036, 0xffff, 0xffff } }, // ISCL_KEYCODE_6 = 13
59 { Qt::Key_7, { 0x0037, 0xffff, 0xffff } }, // ISCL_KEYCODE_7 = 14
60 { Qt::Key_8, { 0x0038, 0xffff, 0xffff } }, // ISCL_KEYCODE_8 = 15
61 { Qt::Key_9, { 0x0039, 0x0028, 0xffff } }, // ISCL_KEYCODE_9 = 16
62 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_STAR = 17
63 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_POUND = 18
64 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_DPAD_UP = 19
65 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_DPAD_DOWN = 20
66 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_DPAD_LEFT = 21
67 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_DPAD_RIGHT = 22
68 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_DPAD_CENTER = 23
69 { Qt::Key_VolumeUp, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_VOLUME_UP = 24
70 { Qt::Key_VolumeDown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_VOLUME_DOWN = 25
71 { Qt::Key_PowerOff, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_POWER = 26
72 { Qt::Key_Camera, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CAMERA = 27
73 { Qt::Key_Clear, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CLEAR = 28
74 { Qt::Key_A, { 0x0061, 0x0041, 0xffff } }, // ISCL_KEYCODE_A = 29
75 { Qt::Key_B, { 0x0062, 0x0042, 0xffff } }, // ISCL_KEYCODE_B = 30
76 { Qt::Key_C, { 0x0063, 0x0043, 0xffff } }, // ISCL_KEYCODE_C = 31
77 { Qt::Key_D, { 0x0064, 0x0044, 0xffff } }, // ISCL_KEYCODE_D = 32
78 { Qt::Key_E, { 0x0065, 0x0045, 0xffff } }, // ISCL_KEYCODE_E = 33
79 { Qt::Key_F, { 0x0066, 0x0046, 0xffff } }, // ISCL_KEYCODE_F = 34
80 { Qt::Key_G, { 0x0067, 0x0047, 0xffff } }, // ISCL_KEYCODE_G = 35
81 { Qt::Key_H, { 0x0068, 0x0048, 0xffff } }, // ISCL_KEYCODE_H = 36
82 { Qt::Key_I, { 0x0069, 0x0049, 0xffff } }, // ISCL_KEYCODE_I = 37
83 { Qt::Key_J, { 0x006a, 0x004a, 0xffff } }, // ISCL_KEYCODE_J = 38
84 { Qt::Key_K, { 0x006b, 0x004b, 0xffff } }, // ISCL_KEYCODE_K = 39
85 { Qt::Key_L, { 0x006c, 0x004c, 0xffff } }, // ISCL_KEYCODE_L = 40
86 { Qt::Key_M, { 0x006d, 0x004d, 0xffff } }, // ISCL_KEYCODE_M = 41
87 { Qt::Key_N, { 0x006e, 0x004e, 0xffff } }, // ISCL_KEYCODE_N = 42
88 { Qt::Key_O, { 0x006f, 0x004f, 0xffff } }, // ISCL_KEYCODE_O = 43
89 { Qt::Key_P, { 0x0070, 0x0050, 0xffff } }, // ISCL_KEYCODE_P = 44
90 { Qt::Key_Q, { 0x0071, 0x0051, 0xffff } }, // ISCL_KEYCODE_Q = 45
91 { Qt::Key_R, { 0x0072, 0x0052, 0xffff } }, // ISCL_KEYCODE_R = 46
92 { Qt::Key_S, { 0x0073, 0x0053, 0xffff } }, // ISCL_KEYCODE_S = 47
93 { Qt::Key_T, { 0x0074, 0x0054, 0xffff } }, // ISCL_KEYCODE_T = 48
94 { Qt::Key_U, { 0x0075, 0x0055, 0xffff } }, // ISCL_KEYCODE_U = 49
95 { Qt::Key_V, { 0x0076, 0x0056, 0xffff } }, // ISCL_KEYCODE_V = 50
96 { Qt::Key_W, { 0x0077, 0x0057, 0xffff } }, // ISCL_KEYCODE_W = 51
97 { Qt::Key_X, { 0x0078, 0x0058, 0xffff } }, // ISCL_KEYCODE_X = 52
98 { Qt::Key_Y, { 0x0079, 0x0059, 0xffff } }, // ISCL_KEYCODE_Y = 53
99 { Qt::Key_Z, { 0x007a, 0x005a, 0xffff } }, // ISCL_KEYCODE_Z = 54
100 { Qt::Key_Comma, { 0x002c, 0xffff, 0xffff } }, // ISCL_KEYCODE_COMMA = 55
101 { Qt::Key_Period, { 0x002e, 0xffff, 0xffff } }, // ISCL_KEYCODE_PERIOD = 56
102 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ALT_LEFT = 57
103 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ALT_RIGHT = 58
104 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SHIFT_LEFT = 59
105 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SHIFT_RIGHT = 60
106 { Qt::Key_Tab, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_TAB = 61
107 { Qt::Key_Space, { 0x0020, 0xffff, 0xffff } }, // ISCL_KEYCODE_SPACE = 62
108 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SYM = 63
109 { Qt::Key_Explorer, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_EXPLORER = 64
110 { Qt::Key_LaunchMail, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ENVELOPE = 65
111 { Qt::Key_Enter, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ENTER = 66
112 { Qt::Key_Delete, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_DEL = 67
113 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_GRAVE = 68
114 { Qt::Key_Minus, { 0x002d, 0x005f, 0xffff } }, // ISCL_KEYCODE_MINUS = 69
115 { Qt::Key_Equal, { 0x003d, 0xffff, 0xffff } }, // ISCL_KEYCODE_EQUALS = 70
116 { Qt::Key_BracketLeft, { 0x005b, 0xffff, 0xffff } }, // ISCL_KEYCODE_LEFT_BRACKET = 71
117 { Qt::Key_BracketRight, { 0x005d, 0xffff, 0xffff } }, // ISCL_KEYCODE_RIGHT_BRACKET = 72
118 { Qt::Key_Backslash, { 0x005c, 0xffff, 0xffff } }, // ISCL_KEYCODE_BACKSLASH = 73
119 { Qt::Key_Semicolon, { 0x003b, 0x003a, 0xffff } }, // ISCL_KEYCODE_SEMICOLON = 74
120 { Qt::Key_Apostrophe, { 0x0027, 0xffff, 0xffff } }, // ISCL_KEYCODE_APOSTROPHE = 75
121 { Qt::Key_Slash, { 0x002f, 0xffff, 0xffff } }, // ISCL_KEYCODE_SLASH = 76
122 { Qt::Key_At, { 0x0040, 0xffff, 0xffff } }, // ISCL_KEYCODE_AT = 77
123 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUM = 78
124 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_HEADSETHOOK = 79
125 { Qt::Key_CameraFocus, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_FOCUS = 80 // *Camera* focus
126 { Qt::Key_Plus, { 0x002b, 0xffff, 0xffff } }, // ISCL_KEYCODE_PLUS = 81
127 { Qt::Key_Menu, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MENU = 82
128 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_NOTIFICATION = 83
129 { Qt::Key_Search, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SEARCH = 84
130 { Qt::Key_MediaTogglePlayPause, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_PLAY_PAUSE= 85
131 { Qt::Key_MediaStop, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_STOP = 86
132 { Qt::Key_MediaNext, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_NEXT = 87
133 { Qt::Key_MediaPrevious, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_PREVIOUS = 88
134 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_REWIND = 89
135 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_FAST_FORWARD = 90
136 { Qt::Key_VolumeMute, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MUTE = 91
137 { Qt::Key_PageUp, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_PAGE_UP = 92
138 { Qt::Key_PageDown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_PAGE_DOWN = 93
139 { Qt::Key_Pictures, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_PICTSYMBOLS = 94
140 { Qt::Key_Mode_switch, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SWITCH_CHARSET = 95
141 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_A = 96
142 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_B = 97
143 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_C = 98
144 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_X = 99
145 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_Y = 100
146 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_Z = 101
147 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_L1 = 102
148 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_R1 = 103
149 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_L2 = 104
150 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_R2 = 105
151 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_THUMBL = 106
152 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_THUMBR = 107
153 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_START = 108
154 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_SELECT = 109
155 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_MODE = 110
156 { Qt::Key_Escape, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ESCAPE = 111
157 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_FORWARD_DEL = 112
158 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CTRL_LEFT = 113
159 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CTRL_RIGHT = 114
160 { Qt::Key_CapsLock, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CAPS_LOCK = 115
161 { Qt::Key_ScrollLock, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SCROLL_LOCK = 116
162 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_META_LEFT = 117
163 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_META_RIGHT = 118
164 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_FUNCTION = 119
165 { Qt::Key_SysReq, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SYSRQ = 120
166 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BREAK = 121
167 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MOVE_HOME = 122
168 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MOVE_END = 123
169 { Qt::Key_Insert, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_INSERT = 124
170 { Qt::Key_Forward, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_FORWARD = 125
171 { Qt::Key_MediaPlay, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_PLAY = 126
172 { Qt::Key_MediaPause, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_PAUSE = 127
173 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_CLOSE = 128
174 { Qt::Key_Eject, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_EJECT = 129
175 { Qt::Key_MediaRecord, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MEDIA_RECORD = 130
176 { Qt::Key_F1, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F1 = 131
177 { Qt::Key_F2, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F2 = 132
178 { Qt::Key_F3, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F3 = 133
179 { Qt::Key_F4, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F4 = 134
180 { Qt::Key_F5, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F5 = 135
181 { Qt::Key_F6, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F6 = 136
182 { Qt::Key_F7, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F7 = 137
183 { Qt::Key_F8, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F8 = 138
184 { Qt::Key_F9, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F9 = 139
185 { Qt::Key_F10, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F10 = 140
186 { Qt::Key_F11, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F11 = 141
187 { Qt::Key_F12, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_F12 = 142
188 { Qt::Key_NumLock, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUM_LOCK = 143
189 { Qt::Key_0, { 0x0030, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_0 = 144
190 { Qt::Key_1, { 0x0031, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_1 = 145
191 { Qt::Key_2, { 0x0032, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_2 = 146
192 { Qt::Key_3, { 0x0033, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_3 = 147
193 { Qt::Key_4, { 0x0034, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_4 = 148
194 { Qt::Key_5, { 0x0035, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_5 = 149
195 { Qt::Key_6, { 0x0036, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_6 = 150
196 { Qt::Key_7, { 0x0037, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_7 = 151
197 { Qt::Key_8, { 0x0038, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_8 = 152
198 { Qt::Key_9, { 0x0039, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_9 = 153
199 { Qt::Key_Slash, { 0x002f, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_DIVIDE = 154
200 { Qt::Key_Asterisk, { 0x002a, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_MULTIPLY = 155
201 { Qt::Key_Minus, { 0x002d, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_SUBTRACT = 156
202 { Qt::Key_Plus, { 0x002b, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_ADD = 157
203 { Qt::Key_Period, { 0x002e, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_DOT = 158
204 { Qt::Key_Comma, { 0x002c, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_COMMA = 159
205 { Qt::Key_Enter, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_ENTER = 160
206 { Qt::Key_Equal, { 0x003d, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_EQUALS = 161
207 { Qt::Key_ParenLeft, { 0x0028, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_LEFT_PAREN = 162
208 { Qt::Key_ParenRight, { 0x0029, 0xffff, 0xffff } }, // ISCL_KEYCODE_NUMPAD_RIGHT_PAREN = 163
209 { Qt::Key_VolumeMute, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_VOLUME_MUTE = 164
210 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_INFO = 165
211 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CHANNEL_UP = 166
212 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CHANNEL_DOWN = 167
213 { Qt::Key_ZoomIn, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ZOOM_IN = 168
214 { Qt::Key_ZoomOut, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_ZOOM_OUT = 169
215 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_TV = 170
216 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_WINDOW = 171
217 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_GUIDE = 172
218 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_DVR = 173
219 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BOOKMARK = 174
220 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CAPTIONS = 175
221 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_SETTINGS = 176
222 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_TV_POWER = 177
223 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_TV_INPUT = 178
224 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_STB_POWER = 179
225 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_STB_INPUT = 180
226 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_AVR_POWER = 181
227 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_AVR_INPUT = 182
228 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_PROG_RED = 183
229 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_PROG_GREEN = 184
230 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_PROG_YELLOW = 185
231 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_PROG_BLUE = 186
232 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_APP_SWITCH = 187
233 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_1 = 188
234 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_2 = 189
235 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_3 = 190
236 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_4 = 191
237 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_5 = 192
238 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_6 = 193
239 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_7 = 194
240 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_8 = 195
241 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_9 = 196
242 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_10 = 197
243 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_11 = 198
244 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_12 = 199
245 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_13 = 200
246 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_14 = 201
247 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_15 = 202
248 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_BUTTON_16 = 203
249 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_LANGUAGE_SWITCH = 204
250 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MANNER_MODE = 205
251 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_3D_MODE = 206
252 { Qt::Key_unknown, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CONTACTS = 207
253 { Qt::Key_Calendar, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_CALENDAR = 208
254 { Qt::Key_Music, { 0xffff, 0xffff, 0xffff } }, // ISCL_KEYCODE_MUSIC = 209
255 { Qt::Key_Calculator, { 0xffff, 0xffff, 0xffff } } // ISCL_KEYCODE_CALCULATOR = 210
256};
257
258class QUbuntuBaseEvent : public QEvent {
259 public:
260 QUbuntuBaseEvent(QWindow* window, const Event* event, QEvent::Type type)
261 : QEvent(type)
262 , window_(window) {
263 memcpy(&nativeEvent_, event, sizeof(Event));
264 }
265 QWindow* window_;
266 Event nativeEvent_;
267};
268
269QUbuntuBaseInput::QUbuntuBaseInput(QUbuntuBaseIntegration* integration)
270 : integration_(integration)
271 , eventFilterType_(static_cast<QUbuntuBaseNativeInterface*>(
272 integration->nativeInterface())->genericEventFilterType())145 integration->nativeInterface())->genericEventFilterType())
273 , eventType_(static_cast<QEvent::Type>(QEvent::registerEventType())) {146 , mEventType(static_cast<QEvent::Type>(QEvent::registerEventType()))
274147{
275 // Initialize touch device.148 // Initialize touch device.
276 touchDevice_ = new QTouchDevice();149 mTouchDevice = new QTouchDevice;
277 touchDevice_->setType(QTouchDevice::TouchScreen);150 mTouchDevice->setType(QTouchDevice::TouchScreen);
278 touchDevice_->setCapabilities(151 mTouchDevice->setCapabilities(
279 QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::Pressure |152 QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::Pressure |
280 QTouchDevice::NormalizedPosition);153 QTouchDevice::NormalizedPosition);
281 QWindowSystemInterface::registerTouchDevice(touchDevice_);154 QWindowSystemInterface::registerTouchDevice(mTouchDevice);
282155}
283 DLOG("QUbuntuBaseInput::QUbuntuBaseInput (this=%p, integration=%p)", this, integration);156
284}157UbuntuInput::~UbuntuInput()
285158{
286QUbuntuBaseInput::~QUbuntuBaseInput() {159 // Qt will take care of deleting mTouchDevice.
287 DLOG("QUbuntuBaseInput::~QUbuntuBaseInput");160}
288 // touchDevice_ isn't cleaned up on purpose as it crashes or asserts on "Bus Error".161
289}162#ifndef QT_NO_DEBUG
290163static const char* nativeEventTypeToStr(int eventType)
291void QUbuntuBaseInput::customEvent(QEvent* event) {164{
292 DLOG("QUbuntuBaseInput::customEvent (this=%p, event=%p)", this, event);165 switch (eventType) {
293 DASSERT(QThread::currentThread() == thread());166 case MOTION_WEVENT_TYPE:
294 QUbuntuBaseEvent* ubuntuEvent = static_cast<QUbuntuBaseEvent*>(event);167 return "MOTION_WEVENT_TYPE";
295168 break;
296 // Event filtering.169 case KEY_WEVENT_TYPE:
297 long result;170 return "KEY_WEVENT_TYPE";
298 if (QWindowSystemInterface::handleNativeEvent(171 break;
299 ubuntuEvent->window_, eventFilterType_, &ubuntuEvent->nativeEvent_, &result) == true) {172 case RESIZE_WEVENT_TYPE:
300 DLOG("event filtered out by native interface");173 return "RESIZE_WEVENT_TYPE";
301 return;174 break;
302 }175 case SURFACE_WEVENT_TYPE:
303176 return "SURFACE_WEVENT_TYPE";
304 // Event dispatching.177 default:
305 switch (ubuntuEvent->nativeEvent_.type) {178 return "INVALID!";
306 case MOTION_EVENT_TYPE: {179 }
307 dispatchMotionEvent(ubuntuEvent->window_, &ubuntuEvent->nativeEvent_);180}
308 break;181#endif
309 }182
310 case KEY_EVENT_TYPE: {183void UbuntuInput::customEvent(QEvent* event)
311 dispatchKeyEvent(ubuntuEvent->window_, &ubuntuEvent->nativeEvent_);184{
312 break;185 DASSERT(QThread::currentThread() == thread());
313 }186 UbuntuEvent* ubuntuEvent = static_cast<UbuntuEvent*>(event);
314 case HW_SWITCH_EVENT_TYPE: {187 WindowEvent *nativeEvent = &ubuntuEvent->nativeEvent;
315 dispatchHWSwitchEvent(ubuntuEvent->window_, &ubuntuEvent->nativeEvent_);188
316 break;189 // Event filtering.
317 }190 long result;
318 default: {191 if (QWindowSystemInterface::handleNativeEvent(
319 DLOG("unhandled event type %d", ubuntuEvent->nativeEvent_.type);192 ubuntuEvent->window->window(), mEventFilterType, nativeEvent, &result) == true) {
320 }193 DLOG("event filtered out by native interface");
321 }194 return;
322}195 }
323196
324void QUbuntuBaseInput::postEvent(QWindow* window, const void* event) {197 DLOG("UbuntuInput::customEvent(type=%s)", nativeEventTypeToStr(nativeEvent->type));
325 DLOG("QUbuntuBaseInput::postEvent (this=%p, window=%p, event=%p)", this, window, event);198
326 QCoreApplication::postEvent(this, new QUbuntuBaseEvent(199 // Event dispatching.
327 window, reinterpret_cast<const Event*>(event), eventType_));200 switch (nativeEvent->type) {
328201 case MOTION_WEVENT_TYPE:
329 if ((window->flags() && Qt::WindowTransparentForInput) && window->parent()) {202 dispatchMotionEvent(ubuntuEvent->window->window(), nativeEvent);
330 DLOG("QUbuntuBaseInput::postEvent (this=%p, window=%p, event=%p)", this, window->parent(), event);203 break;
331 QCoreApplication::postEvent(this, new QUbuntuBaseEvent(204 case KEY_WEVENT_TYPE:
332 window->parent(), reinterpret_cast<const Event*>(event), eventType_));205 dispatchKeyEvent(ubuntuEvent->window->window(), nativeEvent);
333 }206 break;
334}207 case RESIZE_WEVENT_TYPE:
335208 ubuntuEvent->window->handleSurfaceResize(nativeEvent->resize.width,
336void QUbuntuBaseInput::dispatchMotionEvent(QWindow* window, const void* ev) {209 nativeEvent->resize.height);
337 DLOG("QUbuntuBaseInput::dispatchMotionEvent (this=%p, window=%p, event=%p)", this, window, ev);210 break;
338 const Event* event = reinterpret_cast<const Event*>(ev);211 case SURFACE_WEVENT_TYPE:
339212 if (nativeEvent->surface.attribute == SURFACE_ATTRIBUTE_FOCUS) {
340#if (LOG_EVENTS != 0)213 ubuntuEvent->window->handleSurfaceFocusChange(nativeEvent->surface.value == 1);
341 // Motion event logging.214 }
342 LOG("MOTION device_id:%d source_id:%d action:%d flags:%d meta_state:%d edge_flags:%d "215 break;
343 "button_state:%d x_offset:%.2f y_offset:%.2f x_precision:%.2f y_precision:%.2f "216 default:
344 "down_time:%lld event_time:%lld pointer_count:%d {", event->device_id,217 DLOG("unhandled event type %d", nativeEvent->type);
345 event->source_id, event->action, event->flags, event->meta_state,218 }
346 event->details.motion.edge_flags, event->details.motion.button_state,219}
347 event->details.motion.x_offset, event->details.motion.y_offset,220
348 event->details.motion.x_precision, event->details.motion.y_precision,221void UbuntuInput::postEvent(UbuntuWindow* platformWindow, const void* event)
349 event->details.motion.down_time, event->details.motion.event_time,222{
350 event->details.motion.pointer_count);223 QWindow *window = platformWindow->window();
351 for (size_t i = 0; i < event->details.motion.pointer_count; i++) {224
352 LOG(" id:%d x:%.2f y:%.2f rx:%.2f ry:%.2f maj:%.2f min:%.2f sz:%.2f press:%.2f",225 QCoreApplication::postEvent(this, new UbuntuEvent(
353 event->details.motion.pointer_coordinates[i].id,226 platformWindow, reinterpret_cast<const WindowEvent*>(event), mEventType));
354 event->details.motion.pointer_coordinates[i].x,227
355 event->details.motion.pointer_coordinates[i].y,228 if ((window->flags() && Qt::WindowTransparentForInput) && window->parent()) {
356 event->details.motion.pointer_coordinates[i].raw_x,229 QCoreApplication::postEvent(this, new UbuntuEvent(
357 event->details.motion.pointer_coordinates[i].raw_y,230 static_cast<UbuntuWindow*>(platformWindow->QPlatformWindow::parent()),
358 event->details.motion.pointer_coordinates[i].touch_major,231 reinterpret_cast<const WindowEvent*>(event), mEventType));
359 event->details.motion.pointer_coordinates[i].touch_minor,232 }
360 event->details.motion.pointer_coordinates[i].size,233}
361 event->details.motion.pointer_coordinates[i].pressure234
362 // event->details.motion.pointer_coordinates[i].orientation -> Always 0.0.235void UbuntuInput::dispatchMotionEvent(QWindow* window, const void* ev)
363 );236{
364 }237 const WindowEvent* event = reinterpret_cast<const WindowEvent*>(ev);
365 LOG("}");238
366#endif239 #if (LOG_EVENTS != 0)
367240 // Motion event logging.
368 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That241 LOG("MOTION device_id:%d source_id:%d action:%d flags:%d meta_state:%d edge_flags:%d "
369 // needs to be fixed as soon as the compat input lib adds query support.242 "button_state:%d x_offset:%.2f y_offset:%.2f x_precision:%.2f y_precision:%.2f "
370 const float kMaxPressure = 1.28;243 "down_time:%lld event_time:%lld pointer_count:%d {", event->motion.device_id,
371 const QRect kWindowGeometry = window->geometry();244 event->motion.source_id, event->motion.action,
372 QList<QWindowSystemInterface::TouchPoint> touchPoints;245 event->motion.flags, event->motion.meta_state,
373246 event->motion.edge_flags, event->motion.button_state,
374247 event->motion.x_offset, event->motion.y_offset,
375 // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left248 event->motion.x_precision, event->motion.y_precision,
376 // as Qt::TouchPointMoved249 event->motion.down_time, event->motion.event_time,
377 const int kPointerCount = event->details.motion.pointer_count;250 event->motion.pointer_count);
378 for (int i = 0; i < kPointerCount; ++i) {251 for (size_t i = 0; i < event->motion.pointer_count; i++) {
379 QWindowSystemInterface::TouchPoint touchPoint;252 LOG(" id:%d x:%.2f y:%.2f rx:%.2f ry:%.2f maj:%.2f min:%.2f sz:%.2f press:%.2f",
380253 event->motion.pointer_coordinates[i].id,
381 const float kX = event->details.motion.pointer_coordinates[i].raw_x;254 event->motion.pointer_coordinates[i].x,
382 const float kY = event->details.motion.pointer_coordinates[i].raw_y;255 event->motion.pointer_coordinates[i].y,
383 const float kW = event->details.motion.pointer_coordinates[i].touch_major;256 event->motion.pointer_coordinates[i].raw_x,
384 const float kH = event->details.motion.pointer_coordinates[i].touch_minor;257 event->motion.pointer_coordinates[i].raw_y,
385 const float kP = event->details.motion.pointer_coordinates[i].pressure;258 event->motion.pointer_coordinates[i].touch_major,
386 touchPoint.id = event->details.motion.pointer_coordinates[i].id;259 event->motion.pointer_coordinates[i].touch_minor,
387 touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height());260 event->motion.pointer_coordinates[i].size,
388 touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH);261 event->motion.pointer_coordinates[i].pressure
389 touchPoint.pressure = kP / kMaxPressure;262 // event->motion.pointer_coordinates[i].orientation -> Always 0.0.
390 touchPoint.state = Qt::TouchPointMoved;263 );
391264 }
392 touchPoints.append(touchPoint);265 LOG("}");
393 }266 #endif
394267
395 switch (event->action & ISCL_MOTION_EVENT_ACTION_MASK) {268 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That
396 case ISCL_MOTION_EVENT_ACTION_MOVE:269 // needs to be fixed as soon as the compat input lib adds query support.
397 // No extra work needed.270 const float kMaxPressure = 1.28;
398 break;271 const QRect kWindowGeometry = window->geometry();
399272 QList<QWindowSystemInterface::TouchPoint> touchPoints;
400 case ISCL_MOTION_EVENT_ACTION_DOWN:273
401 touchPoints[0].state = Qt::TouchPointPressed;274
402 break;275 // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left
403276 // as Qt::TouchPointMoved
404 case ISCL_MOTION_EVENT_ACTION_UP:277 const int kPointerCount = event->motion.pointer_count;
405 touchPoints[0].state = Qt::TouchPointReleased;278 for (int i = 0; i < kPointerCount; ++i) {
406 break;279 QWindowSystemInterface::TouchPoint touchPoint;
407280
408 case ISCL_MOTION_EVENT_ACTION_POINTER_DOWN: {281 const float kX = event->motion.pointer_coordinates[i].raw_x;
409 const int index = (event->action & ISCL_MOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>282 const float kY = event->motion.pointer_coordinates[i].raw_y;
410 ISCL_MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;283 const float kW = event->motion.pointer_coordinates[i].touch_major;
411 touchPoints[index].state = Qt::TouchPointPressed;284 const float kH = event->motion.pointer_coordinates[i].touch_minor;
412 break;285 const float kP = event->motion.pointer_coordinates[i].pressure;
413 }286 touchPoint.id = event->motion.pointer_coordinates[i].id;
414287 touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height());
415 case ISCL_MOTION_EVENT_ACTION_CANCEL:288 touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH);
416 case ISCL_MOTION_EVENT_ACTION_POINTER_UP: {289 touchPoint.pressure = kP / kMaxPressure;
417 const int index = (event->action & ISCL_MOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>290 touchPoint.state = Qt::TouchPointMoved;
418 ISCL_MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;291
419 touchPoints[index].state = Qt::TouchPointReleased;292 touchPoints.append(touchPoint);
420 break;293 }
421 }294
422295 switch (event->motion.action & U_MOTION_ACTION_MASK) {
423 case ISCL_MOTION_EVENT_ACTION_OUTSIDE:296 case U_MOTION_ACTION_MOVE:
424 case ISCL_MOTION_EVENT_ACTION_HOVER_MOVE:297 // No extra work needed.
425 case ISCL_MOTION_EVENT_ACTION_SCROLL:298 break;
426 case ISCL_MOTION_EVENT_ACTION_HOVER_ENTER:299
427 case ISCL_MOTION_EVENT_ACTION_HOVER_EXIT:300 case U_MOTION_ACTION_DOWN:
428 default:301 touchPoints[0].state = Qt::TouchPointPressed;
429 DLOG("unhandled motion event action %d", event->action & ISCL_MOTION_EVENT_ACTION_MASK);302 break;
430 }303
431304 case U_MOTION_ACTION_UP:
432 // Touch event propagation.305 touchPoints[0].state = Qt::TouchPointReleased;
433 handleTouchEvent(window, event->details.motion.event_time / 1000000, touchDevice_, touchPoints);306 break;
434}307
435308 case U_MOTION_ACTION_POINTER_DOWN: {
436void QUbuntuBaseInput::handleTouchEvent(309 const int index = (event->motion.action & U_MOTION_ACTION_POINTER_INDEX_MASK) >>
437 QWindow* window, ulong timestamp, QTouchDevice* device,310 U_MOTION_ACTION_POINTER_INDEX_SHIFT;
438 const QList<struct QWindowSystemInterface::TouchPoint> &points) {311 touchPoints[index].state = Qt::TouchPointPressed;
439 DLOG("QUbuntuBaseInput::handleTouchEvent (this=%p, window=%p, timestamp=%lu, device=%p)",312 break;
440 this, window, timestamp, device);313 }
441 QWindowSystemInterface::handleTouchEvent(window, timestamp, device, points);314
442}315 case U_MOTION_ACTION_CANCEL:
443316 case U_MOTION_ACTION_POINTER_UP: {
444void QUbuntuBaseInput::dispatchKeyEvent(QWindow* window, const void* ev) {317 const int index = (event->motion.action & U_MOTION_ACTION_POINTER_INDEX_MASK) >>
445 DLOG("QUbuntuBaseInput::dispatchKeyEvent (this=%p, window=%p, event=%p)", this, window, ev);318 U_MOTION_ACTION_POINTER_INDEX_SHIFT;
446 const Event* event = reinterpret_cast<const Event*>(ev);319 touchPoints[index].state = Qt::TouchPointReleased;
447320 break;
448#if (LOG_EVENTS != 0)321 }
449 // Key event logging.322
450 LOG("KEY device_id:%d source_id:%d action:%d flags:%d meta_state:%d key_code:%d "323 case U_MOTION_ACTION_OUTSIDE:
451 "scan_code:%d repeat_count:%d down_time:%lld event_time:%lld is_system_key:%d",324 case U_MOTION_ACTION_HOVER_MOVE:
452 event->device_id, event->source_id, event->action, event->flags, event->meta_state,325 case U_MOTION_ACTION_SCROLL:
453 event->details.key.key_code, event->details.key.scan_code,326 case U_MOTION_ACTION_HOVER_ENTER:
454 event->details.key.repeat_count, event->details.key.down_time,327 case U_MOTION_ACTION_HOVER_EXIT:
455 event->details.key.event_time, event->details.key.is_system_key);328 default:
456#endif329 DLOG("unhandled motion event action %d", event->motion.action & U_MOTION_ACTION_MASK);
457330 }
458 // Key modifier and unicode index mapping.331
459 const int kMetaState = event->meta_state;332 QWindowSystemInterface::handleTouchEvent(window, event->motion.event_time / 1000000,
460 Qt::KeyboardModifiers modifiers = Qt::NoModifier;333 mTouchDevice, touchPoints);
461 int unicodeIndex = 0;334}
462 if (kMetaState & ISCL_META_SHIFT_ON) {335
463 modifiers |= Qt::ShiftModifier;336static uint32_t translateKeysym(uint32_t sym, char *string, size_t size)
464 unicodeIndex = 1;337{
465 }338 Q_UNUSED(size);
466 if (kMetaState & ISCL_META_CTRL_ON) {339 string[0] = '\0';
467 modifiers |= Qt::ControlModifier;340
468 unicodeIndex = 2;341 if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F35)
469 }342 return Qt::Key_F1 + (int(sym) - XKB_KEY_F1);
470 if (kMetaState & ISCL_META_ALT_ON) {343
471 modifiers |= Qt::AltModifier;344 for (int i = 0; KeyTable[i]; i += 2) {
472 unicodeIndex = 2;345 if (sym == KeyTable[i])
473 }346 return KeyTable[i + 1];
474 if (kMetaState & ISCL_META_META_ON) {347 }
475 modifiers |= Qt::MetaModifier;348
476 unicodeIndex = 2;349 string[0] = sym;
477 }350 string[1] = '\0';
478351 return toupper(sym);
479 // Key event propagation.352}
480 QEvent::Type keyType = kEventType[event->action];353
481 quint32 keyCode = kKeyCode[event->details.key.key_code].keycode;354void UbuntuInput::dispatchKeyEvent(QWindow* window, const void* ev)
482 QString text(kKeyCode[event->details.key.key_code].unicode[unicodeIndex]);355{
483 ulong timestamp = event->details.key.event_time / 1000000;356 const WindowEvent* event = reinterpret_cast<const WindowEvent*>(ev);
484 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();357
485 if (context) {358 #if (LOG_EVENTS != 0)
486 QKeyEvent qKeyEvent(keyType, keyCode, modifiers, text);359 // Key event logging.
487 qKeyEvent.setTimestamp(timestamp);360 LOG("KEY device_id:%d source_id:%d action:%d flags:%d meta_state:%d key_code:%d "
488 if (context->filterEvent(&qKeyEvent)) {361 "scan_code:%d repeat_count:%d down_time:%lld event_time:%lld is_system_key:%d",
489 DLOG("key event filtered out by input context");362 event->key.device_id, event->key.source_id,
490 return;363 event->key.action, event->key.flags, event->key.meta_state,
491 }364 event->key.key_code, event->key.scan_code,
492 }365 event->key.repeat_count, event->key.down_time,
493 handleKeyEvent(window, timestamp, keyType, keyCode, modifiers, text);366 event->key.event_time, event->key.is_system_key);
494}367 #endif
495368
496void QUbuntuBaseInput::handleKeyEvent(369 ulong timestamp = event->key.event_time / 1000000;
497 QWindow* window, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,370 xkb_keysym_t xk_sym = (xkb_keysym_t)event->key.key_code;
498 const QString& text) {371
499 DLOG("QUbuntuBaseInput::handleKeyEvent (this=%p window=%p, timestamp=%lu, type=%d, key=%d, "372 // Key modifier and unicode index mapping.
500 "modifiers=%d, text='%s')", this, window, timestamp, static_cast<int>(type), key,373 const int kMetaState = event->key.meta_state;
501 static_cast<int>(modifiers), text.toUtf8().data());374 Qt::KeyboardModifiers modifiers = Qt::NoModifier;
502 QWindowSystemInterface::handleKeyEvent(window, timestamp, type, key, modifiers, text);375 if (kMetaState & U_KEY_MODIFIER_SHIFT) {
503}376 modifiers |= Qt::ShiftModifier;
504377 }
505void QUbuntuBaseInput::dispatchHWSwitchEvent(QWindow* window, const void* ev) {378 if (kMetaState & U_KEY_MODIFIER_CTRL) {
506 Q_UNUSED(window);379 modifiers |= Qt::ControlModifier;
507 Q_UNUSED(ev);380 }
508 DLOG("QUbuntuBaseInput::dispatchSwitchEvent (this=%p, window=%p, event=%p)", this, window, ev);381 if (kMetaState & U_KEY_MODIFIER_ALT) {
509382 modifiers |= Qt::AltModifier;
510#if (LOG_EVENTS != 0)383 }
511 // HW switch event logging.384 if (kMetaState & U_KEY_MODIFIER_META) {
512 const Event* event = reinterpret_cast<const Event*>(ev);385 modifiers |= Qt::MetaModifier;
513 LOG("HWSWITCH device_id:%d source_id:%d action:%d flags:%d meta_state:%d event_time:%lld "386 }
514 "policy_flags:%u switch_values:%d switch_mask:%d", event->device_id, event->source_id,387
515 event->action, event->flags, event->meta_state, event->details.hw_switch.event_time,388 QEvent::Type keyType = event->key.action == U_KEY_ACTION_DOWN ? QEvent::KeyPress : QEvent::KeyRelease;
516 event->details.hw_switch.policy_flags, event->details.hw_switch.switch_values,389
517 event->details.hw_switch.switch_mask);390 char s[2];
518#endif391 int sym = translateKeysym(xk_sym, s, sizeof(s));
519392 QString text = QString::fromLatin1(s);
520 // FIXME(loicm) Not sure how to interpret that kind of event.393
521 DLOG("hw switch events are not handled");394 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();
395 if (context) {
396 QKeyEvent qKeyEvent(keyType, sym, modifiers, text);
397 qKeyEvent.setTimestamp(timestamp);
398 if (context->filterEvent(&qKeyEvent)) {
399 DLOG("key event filtered out by input context");
400 return;
401 }
402 }
403
404 QWindowSystemInterface::handleKeyEvent(window, timestamp, keyType, sym, modifiers, text);
522}405}
523406
=== modified file 'src/ubuntumirclient/input.h'
--- src/platforms/base/input.h 2013-10-17 18:38:03 +0000
+++ src/ubuntumirclient/input.h 2014-07-21 23:47:35 +0000
@@ -1,53 +1,51 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
16#ifndef QUBUNTUBASEINPUT_H16
17#define QUBUNTUBASEINPUT_H17#ifndef UBUNTU_INPUT_H
1818#define UBUNTU_INPUT_H
19
20// Qt
19#include <qpa/qwindowsysteminterface.h>21#include <qpa/qwindowsysteminterface.h>
2022
21class QUbuntuBaseIntegration;23class UbuntuClientIntegration;
2224class UbuntuWindow;
23class QUbuntuBaseInput : public QObject {25
24 Q_OBJECT26class UbuntuInput : public QObject
2527{
26 public:28 Q_OBJECT
27 QUbuntuBaseInput(QUbuntuBaseIntegration* integration);29
28 ~QUbuntuBaseInput();30public:
2931 UbuntuInput(UbuntuClientIntegration* integration);
30 // QObject methods.32 virtual ~UbuntuInput();
31 void customEvent(QEvent* event);33
3234 // QObject methods.
33 virtual void handleTouchEvent(QWindow* window, ulong timestamp, QTouchDevice* device,35 void customEvent(QEvent* event) override;
34 const QList<struct QWindowSystemInterface::TouchPoint> &points);36
35 virtual void handleKeyEvent(QWindow* window, ulong timestamp, QEvent::Type type, int key,37 void postEvent(UbuntuWindow* window, const void* event);
36 Qt::KeyboardModifiers modifiers, const QString& text);38 UbuntuClientIntegration* integration() const { return mIntegration; }
3739
38 void postEvent(QWindow* window, const void* event);40protected:
39 QUbuntuBaseIntegration* integration() const { return integration_; }41 void dispatchKeyEvent(QWindow* window, const void* event);
4042 void dispatchMotionEvent(QWindow* window, const void* event);
41 protected:43
42 virtual void dispatchKeyEvent(QWindow* window, const void* event);44private:
43 void dispatchMotionEvent(QWindow* window, const void* event);45 UbuntuClientIntegration* mIntegration;
44 void dispatchHWSwitchEvent(QWindow* window, const void* event);46 QTouchDevice* mTouchDevice;
4547 const QByteArray mEventFilterType;
46 private:48 const QEvent::Type mEventType;
47 QUbuntuBaseIntegration* integration_;
48 QTouchDevice* touchDevice_;
49 const QByteArray eventFilterType_;
50 const QEvent::Type eventType_;
51};49};
5250
53#endif // QUBUNTUBASEINPUT_H51#endif // UBUNTU_INPUT_H
5452
=== renamed file 'src/platforms/base/integration.cc' => 'src/ubuntumirclient/integration.cpp'
--- src/platforms/base/integration.cc 2014-02-10 15:26:25 +0000
+++ src/ubuntumirclient/integration.cpp 2014-07-21 23:47:35 +0000
@@ -1,105 +1,208 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
16
17// Qt
18#include <QGuiApplication>
19#include <private/qguiapplication_p.h>
20#include <qpa/qplatformnativeinterface.h>
21#include <qpa/qplatforminputcontextfactory_p.h>
22#include <qpa/qplatforminputcontext.h>
23#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
24#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
25#include <QOpenGLContext>
26
27// Local
28#include "backingstore.h"
29#include "clipboard.h"
30#include "glcontext.h"
31#include "input.h"
16#include "integration.h"32#include "integration.h"
17#include "native_interface.h"33#include "logging.h"
18#include "backing_store.h"34#include "nativeinterface.h"
19#include "screen.h"35#include "screen.h"
20#include "context.h"
21#include "logging.h"
22#include "theme.h"36#include "theme.h"
23#include "platformservices.h"37#include "window.h"
24#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>38
25#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>39// platform-api
26#include <QtGui/private/qguiapplication_p.h>40#include <ubuntu/application/lifecycle_delegate.h>
27#include <QtGui/QOpenGLContext>41#include <ubuntu/application/id.h>
2842#include <ubuntu/application/options.h>
29QUbuntuBaseIntegration::QUbuntuBaseIntegration()43
30 : nativeInterface_(new QUbuntuBaseNativeInterface())44static void resumedCallback(const UApplicationOptions *options, void* context)
31#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)45{
32 , eventDispatcher_(createUnixEventDispatcher())46 Q_UNUSED(options)
33#endif47 Q_UNUSED(context)
34 , fontDb_(new QGenericUnixFontDatabase())48 DASSERT(context != NULL);
35 , platformServices_(new QUbuntuBasePlatformServices()) {49 QCoreApplication::postEvent(QCoreApplication::instance(),
36#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)50 new QEvent(QEvent::ApplicationActivate));
37 QGuiApplicationPrivate::instance()->setEventDispatcher(eventDispatcher_);51}
38#endif52
39 DLOG("QUbuntuBaseIntegration::QUbuntuBaseIntegration (this=%p)", this);53static void aboutToStopCallback(UApplicationArchive *archive, void* context)
40}54{
4155 Q_UNUSED(archive)
42QUbuntuBaseIntegration::~QUbuntuBaseIntegration() {56 DASSERT(context != NULL);
43 DLOG("QUbuntuBaseIntegration::~QUbuntuBaseIntegration");57 UbuntuClientIntegration* integration = static_cast<UbuntuClientIntegration*>(context);
44 delete fontDb_;58 integration->inputContext()->hideInputPanel();
45 delete nativeInterface_;59 QCoreApplication::postEvent(QCoreApplication::instance(),
46}60 new QEvent(QEvent::ApplicationDeactivate));
4761}
48bool QUbuntuBaseIntegration::hasCapability(QPlatformIntegration::Capability cap) const {62
49 DLOG("QUbuntuBaseIntegration::hasCapability (this=%p)", this);63UbuntuClientIntegration::UbuntuClientIntegration()
50 switch (cap) {64 : QPlatformIntegration()
51 case ThreadedPixmaps: {65 , mNativeInterface(new UbuntuNativeInterface)
52 return true;66 , mFontDb(new QGenericUnixFontDatabase)
53 } case OpenGL: {67 , mServices(new UbuntuPlatformServices)
54 return true;68 , mClipboard(new UbuntuClipboard)
55 }69{
56 case ThreadedOpenGL: {70 setupOptions();
57 if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_THREADED_OPENGL")) {71 setupDescription();
58 return true;72
59 } else {73 // Create new application instance
60 DLOG("disabled threaded OpenGL");74 mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions);
61 return false;75
62 }76 if (mInstance == nullptr)
63 }77 qFatal("UbuntuClientIntegration: connection to Mir server failed. Check that a Mir server is\n"
64 default: {78 "running, and the correct socket is being used and is accessible. The shell may have\n"
65 return QPlatformIntegration::hasCapability(cap);79 "rejected the incoming connection, so check its log file");
66 }80
67 }81 // Create default screen.
68}82 mScreen = new UbuntuScreen;
6983 screenAdded(mScreen);
70#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)84
71QAbstractEventDispatcher *QUbuntuBaseIntegration::createEventDispatcher() const {85 // Initialize input.
86 if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_INPUT")) {
87 mInput = new UbuntuInput(this);
88 mInputContext = QPlatformInputContextFactory::create();
89 } else {
90 mInput = nullptr;
91 mInputContext = nullptr;
92 }
93}
94
95UbuntuClientIntegration::~UbuntuClientIntegration()
96{
97 delete mClipboard;
98 delete mInput;
99 delete mInputContext;
100 delete mScreen;
101 delete mServices;
102}
103
104QPlatformServices *UbuntuClientIntegration::services() const
105{
106 return mServices;
107}
108
109void UbuntuClientIntegration::setupOptions()
110{
111 QStringList args = QCoreApplication::arguments();
112 int argc = args.size() + 1;
113 char **argv = new char*[argc];
114 for (int i = 0; i < argc - 1; i++)
115 argv[i] = qstrdup(args.at(i).toLocal8Bit());
116 argv[argc - 1] = nullptr;
117
118 mOptions = u_application_options_new_from_cmd_line(argc - 1, argv);
119
120 for (int i = 0; i < argc; i++)
121 delete [] argv[i];
122 delete [] argv;
123}
124
125void UbuntuClientIntegration::setupDescription()
126{
127 mDesc = u_application_description_new();
128 UApplicationId* id = u_application_id_new_from_stringn("QtUbuntu", 8);
129 u_application_description_set_application_id(mDesc, id);
130
131 UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new();
132 u_application_lifecycle_delegate_set_application_resumed_cb(delegate, &resumedCallback);
133 u_application_lifecycle_delegate_set_application_about_to_stop_cb(delegate, &aboutToStopCallback);
134 u_application_lifecycle_delegate_set_context(delegate, this);
135 u_application_description_set_application_lifecycle_delegate(mDesc, delegate);
136}
137
138QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) const
139{
140 return const_cast<UbuntuClientIntegration*>(this)->createPlatformWindow(window);
141}
142
143QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window)
144{
145 QPlatformWindow* platformWindow = new UbuntuWindow(
146 window, static_cast<UbuntuScreen*>(mScreen), mInput, mInstance);
147 platformWindow->requestActivateWindow();
148 return platformWindow;
149}
150
151bool UbuntuClientIntegration::hasCapability(QPlatformIntegration::Capability cap) const
152{
153 switch (cap) {
154 case ThreadedPixmaps:
155 return true;
156 break;
157
158 case OpenGL:
159 return true;
160 break;
161
162 case ThreadedOpenGL:
163 if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_THREADED_OPENGL")) {
164 return true;
165 } else {
166 DLOG("ubuntumirclient: disabled threaded OpenGL");
167 return false;
168 }
169 break;
170
171 default:
172 return QPlatformIntegration::hasCapability(cap);
173 }
174}
175
176QAbstractEventDispatcher *UbuntuClientIntegration::createEventDispatcher() const
177{
72 return createUnixEventDispatcher();178 return createUnixEventDispatcher();
73}179}
74#endif180
75181QPlatformBackingStore* UbuntuClientIntegration::createPlatformBackingStore(QWindow* window) const
76QPlatformBackingStore* QUbuntuBaseIntegration::createPlatformBackingStore(QWindow* window) const {182{
77 DLOG("QUbuntuBaseIntegration::createPlatformBackingStore (this=%p, window=%p)", this, window);183 return new UbuntuBackingStore(window);
78 return new QUbuntuBaseBackingStore(window);184}
79}185
80186QPlatformOpenGLContext* UbuntuClientIntegration::createPlatformOpenGLContext(
81QPlatformOpenGLContext* QUbuntuBaseIntegration::createPlatformOpenGLContext(187 QOpenGLContext* context) const
82 QOpenGLContext* context) const {188{
83 DLOG("QUbuntuBaseIntegration::createPlatformOpenGLContext const (this=%p, context=%p)", this,189 return const_cast<UbuntuClientIntegration*>(this)->createPlatformOpenGLContext(context);
84 context);190}
85 return const_cast<QUbuntuBaseIntegration*>(this)->createPlatformOpenGLContext(context);191
86}192QPlatformOpenGLContext* UbuntuClientIntegration::createPlatformOpenGLContext(
87193 QOpenGLContext* context)
88QPlatformOpenGLContext* QUbuntuBaseIntegration::createPlatformOpenGLContext(194{
89 QOpenGLContext* context) {195 return new UbuntuOpenGLContext(static_cast<UbuntuScreen*>(context->screen()->handle()),
90 DLOG("QUbuntuBaseIntegration::createPlatformOpenGLContext (this=%p, context=%p)", this, context);196 static_cast<UbuntuOpenGLContext*>(context->shareHandle()));
91 return new QUbuntuBaseContext(197}
92 static_cast<QUbuntuBaseScreen*>(context->screen()->handle()),198
93 static_cast<QUbuntuBaseContext*>(context->shareHandle()));199QStringList UbuntuClientIntegration::themeNames() const
94}200{
95201 return QStringList(UbuntuTheme::name);
96QStringList QUbuntuBaseIntegration::themeNames() const {202}
97 DLOG("QUbuntuBaseIntegration::themeNames (this=%p)", this);203
98 return QStringList(QUbuntuTheme::name);204QPlatformTheme* UbuntuClientIntegration::createPlatformTheme(const QString& name) const
99}205{
100206 Q_UNUSED(name);
101QPlatformTheme* QUbuntuBaseIntegration::createPlatformTheme(const QString& name) const {207 return new UbuntuTheme;
102 Q_UNUSED(name);
103 DLOG("QUbuntuBaseIntegration::createPlatformTheme (this=%p)", this);
104 return new QUbuntuTheme();
105}208}
106209
=== modified file 'src/ubuntumirclient/integration.h'
--- src/platforms/base/integration.h 2013-11-06 12:39:51 +0000
+++ src/ubuntumirclient/integration.h 2014-07-21 23:47:35 +0000
@@ -1,53 +1,78 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#ifndef QUBUNTUBASEINTEGRATION_H17#ifndef UBUNTU_CLIENT_INTEGRATION_H
17#define QUBUNTUBASEINTEGRATION_H18#define UBUNTU_CLIENT_INTEGRATION_H
1819
19#include <qpa/qplatformintegration.h>20#include <qpa/qplatformintegration.h>
2021
21class QAbstractEventDispatcher;22#include "platformservices.h"
2223
23class QUbuntuBaseIntegration : public QPlatformIntegration {24// platform-api
24 public:25#include <ubuntu/application/description.h>
25 QUbuntuBaseIntegration();26#include <ubuntu/application/instance.h>
26 ~QUbuntuBaseIntegration();27#include <ubuntu/application/ui/options.h>
2728#include <ubuntu/application/ui/session.h>
28 // QPlatformIntegration methods.29
29 bool hasCapability(QPlatformIntegration::Capability cap) const;30class UbuntuInput;
30#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)31class UbuntuScreen;
31 QAbstractEventDispatcher* guiThreadEventDispatcher() const { return eventDispatcher_; }32
32#else33class UbuntuClientIntegration : public QPlatformIntegration {
33 QAbstractEventDispatcher *createEventDispatcher() const;34public:
34#endif35 UbuntuClientIntegration();
35 QPlatformNativeInterface* nativeInterface() const { return nativeInterface_; }36 virtual ~UbuntuClientIntegration();
36 QPlatformServices *services() const { return platformServices_; }37
37 QPlatformBackingStore* createPlatformBackingStore(QWindow* window) const;38 // QPlatformIntegration methods.
38 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context) const;39 bool hasCapability(QPlatformIntegration::Capability cap) const override;
39 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context);40 QAbstractEventDispatcher *createEventDispatcher() const override;
40 QPlatformFontDatabase* fontDatabase() const { return fontDb_; }41 QPlatformNativeInterface* nativeInterface() const override { return mNativeInterface; }
41 QStringList themeNames() const;42 QPlatformBackingStore* createPlatformBackingStore(QWindow* window) const override;
42 QPlatformTheme* createPlatformTheme(const QString& name) const;43 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context) const override;
4344 QPlatformFontDatabase* fontDatabase() const override { return mFontDb; }
44 private:45 QStringList themeNames() const override;
45 QPlatformNativeInterface* nativeInterface_;46 QPlatformTheme* createPlatformTheme(const QString& name) const override;
46#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)47 QPlatformServices *services() const override;
47 QAbstractEventDispatcher* eventDispatcher_;48 QPlatformWindow* createPlatformWindow(QWindow* window) const override;
48#endif49 QPlatformInputContext* inputContext() const override { return mInputContext; }
49 QPlatformFontDatabase* fontDb_;50 QPlatformClipboard* clipboard() const override { return mClipboard; }
50 QPlatformServices* platformServices_;51
52 QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context);
53 QPlatformWindow* createPlatformWindow(QWindow* window);
54 UbuntuScreen* screen() const { return mScreen; }
55
56private:
57 void setupOptions();
58 void setupDescription();
59
60 QPlatformNativeInterface* mNativeInterface;
61 QPlatformFontDatabase* mFontDb;
62
63 UbuntuPlatformServices* mServices;
64
65 UbuntuScreen* mScreen;
66 UbuntuInput* mInput;
67 QPlatformInputContext* mInputContext;
68 QPlatformClipboard* mClipboard;
69
70 // Platform API stuff
71 UApplicationOptions* mOptions;
72 UApplicationDescription* mDesc;
73 UApplicationInstance* mInstance;
74 UAUiSessionProperties* mProps;
75 UAUiSession* mSession;
51};76};
5277
53#endif // QUBUNTUBASEINTEGRATION_H78#endif // UBUNTU_CLIENT_INTEGRATION_H
5479
=== modified file 'src/ubuntumirclient/logging.h'
--- src/platforms/base/logging.h 2013-02-14 16:31:33 +0000
+++ src/ubuntumirclient/logging.h 2014-07-21 23:47:35 +0000
@@ -1,17 +1,18 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
1516
16#ifndef QUBUNTULOGGING_H17#ifndef QUBUNTULOGGING_H
17#define QUBUNTULOGGING_H18#define QUBUNTULOGGING_H
1819
=== renamed file 'src/platforms/base/native_interface.cc' => 'src/ubuntumirclient/nativeinterface.cpp'
--- src/platforms/base/native_interface.cc 2014-02-11 13:34:38 +0000
+++ src/ubuntumirclient/nativeinterface.cpp 2014-07-21 23:47:35 +0000
@@ -1,114 +1,113 @@
1// This file is part of QtUbuntu, a set of Qt components for Ubuntu.1/*
2// Copyright © 2013 Canonical Ltd.2 * Copyright (C) 2014 Canonical, Ltd.
3//3 *
4// This program is free software: you can redistribute it and/or modify it under4 * 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 by5 * the terms of the GNU Lesser General Public License version 3, as published by
6// the Free Software Foundation.6 * the Free Software Foundation.
7//7 *
8// This program is distributed in the hope that it will be useful, but WITHOUT8 * This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.11 * Lesser General Public License for more details.
12//12 *
13// You should have received a copy of the GNU Lesser General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
16// FIXME(loicm) "nativeorientation" should be implemented in the Ubuntu plugin16
17// and not include headers from it, base isn't meant to know about plugins.17// Qt
18// FIXME(loicm) Why return a pointer to the screen orientation enum? The enum
19// can just fit in the returned pointer.
20
21#include "native_interface.h"
22#include "screen.h"
23#include "ubuntu/ubuntucommon/screen.h"
24#include "context.h"
25#include "logging.h"
26#include <private/qguiapplication_p.h>18#include <private/qguiapplication_p.h>
27#include <QtGui/qopenglcontext.h>19#include <QtGui/qopenglcontext.h>
28#include <QtGui/qscreen.h>20#include <QtGui/qscreen.h>
29#include <QtCore/QMap>21#include <QtCore/QMap>
3022
31class QUbuntuBaseResourceMap : public QMap<QByteArray, QUbuntuBaseNativeInterface::ResourceType> {23// Local
32 public:24#include "nativeinterface.h"
33 QUbuntuBaseResourceMap()25#include "screen.h"
34 : QMap<QByteArray, QUbuntuBaseNativeInterface::ResourceType>() {26#include "glcontext.h"
35 insert("egldisplay", QUbuntuBaseNativeInterface::EglDisplay);27
36 insert("eglcontext", QUbuntuBaseNativeInterface::EglContext);28class UbuntuResourceMap : public QMap<QByteArray, UbuntuNativeInterface::ResourceType>
37 insert("nativeorientation", QUbuntuBaseNativeInterface::NativeOrientation);29{
38 insert("display", QUbuntuBaseNativeInterface::Display);30public:
39 }31 UbuntuResourceMap()
32 : QMap<QByteArray, UbuntuNativeInterface::ResourceType>() {
33 insert("egldisplay", UbuntuNativeInterface::EglDisplay);
34 insert("eglcontext", UbuntuNativeInterface::EglContext);
35 insert("nativeorientation", UbuntuNativeInterface::NativeOrientation);
36 insert("display", UbuntuNativeInterface::Display);
37 }
40};38};
4139
42Q_GLOBAL_STATIC(QUbuntuBaseResourceMap, ubuntuResourceMap)40Q_GLOBAL_STATIC(UbuntuResourceMap, ubuntuResourceMap)
4341
44QUbuntuBaseNativeInterface::QUbuntuBaseNativeInterface()42UbuntuNativeInterface::UbuntuNativeInterface()
45 : genericEventFilterType_(QByteArrayLiteral("Event"))43 : mGenericEventFilterType(QByteArrayLiteral("Event"))
46 , nativeOrientation_(NULL) {44 , mNativeOrientation(nullptr)
47 DLOG("QUbuntuBaseNativeInterface::QUbuntuBaseNativeInterface (this=%p)", this);45{
48}46}
4947
50QUbuntuBaseNativeInterface::~QUbuntuBaseNativeInterface() {48UbuntuNativeInterface::~UbuntuNativeInterface()
51 DLOG("QUbuntuBaseNativeInterface::~QUbuntuBaseNativeInterface");49{
52 if (nativeOrientation_)50 delete mNativeOrientation;
53 delete nativeOrientation_;51 mNativeOrientation = nullptr;
54}52}
5553
56void* QUbuntuBaseNativeInterface::nativeResourceForContext(54void* UbuntuNativeInterface::nativeResourceForContext(
57 const QByteArray& resourceString, QOpenGLContext* context) {55 const QByteArray& resourceString, QOpenGLContext* context)
58 DLOG("QUbuntuBaseNativeInterface::nativeResourceForContext (this=%p, resourceString=%s, "56{
59 "context=%p)", this, resourceString.constData(), context);57 if (!context)
60 if (!context)58 return nullptr;
61 return NULL;59
62 const QByteArray kLowerCaseResource = resourceString.toLower();60 const QByteArray kLowerCaseResource = resourceString.toLower();
63 if (!ubuntuResourceMap()->contains(kLowerCaseResource))61
64 return NULL;62 if (!ubuntuResourceMap()->contains(kLowerCaseResource))
65 const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource);63 return nullptr;
66 if (kResourceType == QUbuntuBaseNativeInterface::EglContext)64
67 return static_cast<QUbuntuBaseContext*>(context->handle())->eglContext();65 const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource);
68 else66
69 return NULL;67 if (kResourceType == UbuntuNativeInterface::EglContext)
70}
71
72void* QUbuntuBaseNativeInterface::nativeResourceForScreen(
73 const QByteArray& resourceString, QScreen* screen) {
74 DLOG("QUbuntuBaseNativeInterface::nativeResourceForScreen (this=%p, resourceString=%s, "
75 "screen=%p)", this, resourceString.constData(), screen);
76 const QByteArray kLowerCaseResource = resourceString.toLower();
77 if (!ubuntuResourceMap()->contains(kLowerCaseResource))
78 return NULL;
79 const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource);
80 if (kResourceType == QUbuntuBaseNativeInterface::Display) {
81 if (!screen)
82 screen = QGuiApplication::primaryScreen();
83 return static_cast<QUbuntuBaseScreen*>(screen->handle())->nativeDisplay();
84 } else
85 return NULL;
86}
87
88void* QUbuntuBaseNativeInterface::nativeResourceForWindow(
89 const QByteArray& resourceString, QWindow* window) {
90 DLOG("QUbuntuBaseNativeInterface::nativeResourceForWindow (this=%p, resourceString=%s, "
91 "window=%p)", this, resourceString.constData(), window);
92 const QByteArray kLowerCaseResource = resourceString.toLower();
93 if (!ubuntuResourceMap()->contains(kLowerCaseResource))
94 return NULL;
95 const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource);
96 if (kResourceType == QUbuntuBaseNativeInterface::EglDisplay) {
97 if (window) {
98 return static_cast<QUbuntuBaseScreen*>(window->screen()->handle())->eglDisplay();
99 } else {
100 return static_cast<QUbuntuBaseScreen*>(
101 QGuiApplication::primaryScreen()->handle())->eglDisplay();
102 }
103 } else if (kResourceType == QUbuntuBaseNativeInterface::NativeOrientation) {
104 // Return the device's native screen orientation.
105 if (window) {
106 nativeOrientation_ = new Qt::ScreenOrientation(static_cast<QUbuntuScreen*>(window->screen()->handle())->nativeOrientation());
107 } else {
108 nativeOrientation_ = new Qt::ScreenOrientation(QGuiApplication::primaryScreen()->handle()->nativeOrientation());
109 }
110 return nativeOrientation_;
111 } else {
112 return NULL;
113 }
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches