summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerry Boland <gerry.boland@canonical.com>2015-05-18 15:39:09 -0500
committerGerry Boland <gerry.boland@canonical.com>2015-05-18 15:39:09 -0500
commit2e6d31f621312867eb749198799b03adc66c4f33 (patch)
tree01fd6933ca2ea80ef71458c761d194870fb06bac /src
parentee86c12c557e142ad664253aab8fc43cddc9f5cf (diff)
parent604609b7d8923a72a01c9ad621381717b80ac1e4 (diff)
Merge qtmir trunk
Diffstat (limited to 'src')
-rw-r--r--src/common/debughelpers.cpp47
-rw-r--r--src/common/debughelpers.h6
-rw-r--r--src/modules/Unity/Application/CMakeLists.txt11
-rw-r--r--src/modules/Unity/Application/application_manager.cpp40
-rw-r--r--src/modules/Unity/Application/application_manager.h4
-rw-r--r--src/modules/Unity/Application/com.canonical.qtmir.gschema.xml10
-rw-r--r--src/modules/Unity/Application/mirbuffersgtexture.cpp42
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.cpp4
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.h2
-rw-r--r--src/modules/Unity/Application/mirsurfacemanager.cpp22
-rw-r--r--src/modules/Unity/Application/mirsurfacemanager.h3
-rw-r--r--src/modules/Unity/Application/proc_info.cpp6
-rw-r--r--src/modules/Unity/Application/proc_info.h2
-rw-r--r--src/modules/Unity/Application/settings.cpp39
-rw-r--r--src/modules/Unity/Application/settings.h45
-rw-r--r--src/modules/Unity/Application/settings_interface.h40
-rw-r--r--src/platforms/mirserver/CMakeLists.txt10
-rw-r--r--src/platforms/mirserver/mirserverintegration.cpp4
-rw-r--r--src/platforms/mirserver/mirshell.cpp12
-rw-r--r--src/platforms/mirserver/mirshell.h9
-rw-r--r--src/platforms/mirserver/qmirserver.cpp5
-rw-r--r--src/platforms/mirserver/qmirserver.h2
-rw-r--r--src/platforms/mirserver/qteventfeeder.cpp85
-rw-r--r--src/platforms/mirserver/qteventfeeder.h5
-rw-r--r--src/platforms/mirserver/surfaceobserver.cpp14
-rw-r--r--src/platforms/mirserver/surfaceobserver.h6
26 files changed, 330 insertions, 145 deletions
diff --git a/src/common/debughelpers.cpp b/src/common/debughelpers.cpp
index dcf557c..553eb4f 100644
--- a/src/common/debughelpers.cpp
+++ b/src/common/debughelpers.cpp
@@ -207,3 +207,50 @@ const char *applicationStateToStr(int state)
return "???";
}
}
+
+QString mirTouchEventToString(MirTouchInputEvent const* event)
+{
+ const int pointerCount = mir_touch_input_event_get_touch_count(event);
+
+ QString string("MirTouchInputEvent(");
+
+ for (int i = 0; i < pointerCount; ++i) {
+
+ if (i > 0) {
+ string.append(",");
+ }
+
+ MirTouchInputEventTouchAction touchAction = mir_touch_input_event_get_touch_action(event, i);
+
+ QString touchStr = QString("(id=%1,action=%2,x=%3,y=%4)")
+ .arg(mir_touch_input_event_get_touch_id(event, i))
+ .arg(mirTouchActionToString(touchAction))
+ .arg(mir_touch_input_event_get_touch_axis_value(event, i, mir_touch_input_axis_x))
+ .arg(mir_touch_input_event_get_touch_axis_value(event, i, mir_touch_input_axis_y));
+
+ string.append(touchStr);
+ }
+
+ string.append(")");
+
+ return string;
+}
+
+const char *mirTouchActionToString(MirTouchInputEventTouchAction touchAction)
+{
+ switch (touchAction)
+ {
+ case mir_touch_input_event_action_up:
+ return "up";
+ break;
+ case mir_touch_input_event_action_down:
+ return "down";
+ break;
+ case mir_touch_input_event_action_change:
+ return "change";
+ break;
+ default:
+ return "???";
+ break;
+ }
+}
diff --git a/src/common/debughelpers.h b/src/common/debughelpers.h
index 2672246..484decf 100644
--- a/src/common/debughelpers.h
+++ b/src/common/debughelpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2014 Canonical, Ltd.
+ * Copyright (C) 2013-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
@@ -20,6 +20,7 @@
#include <QString>
#include <mir_toolkit/common.h>
+#include <mir_toolkit/events/input/input_event.h>
class QTouchEvent;
@@ -35,4 +36,7 @@ const char *mirMotionActionToStr(int value);
const char *applicationStateToStr(int state);
+QString mirTouchEventToString(MirTouchInputEvent const* event);
+const char *mirTouchActionToString(MirTouchInputEventTouchAction touchAction);
+
#endif // UBUNTUGESTURES_DEBUG_HELPER_H
diff --git a/src/modules/Unity/Application/CMakeLists.txt b/src/modules/Unity/Application/CMakeLists.txt
index 62dc79d..2128e4b 100644
--- a/src/modules/Unity/Application/CMakeLists.txt
+++ b/src/modules/Unity/Application/CMakeLists.txt
@@ -1,4 +1,5 @@
include_directories(
+ ${APPLICATION_API_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${GIO_INCLUDE_DIRS}
${GIO_UNIX_INCLUDE_DIRS}
@@ -9,6 +10,7 @@ include_directories(
${UBUNTU_APP_LAUNCH_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src/platforms/mirserver
${CMAKE_SOURCE_DIR}/src/common
+ ${GSETTINGS_QT_INCLUDE_DIRS}
${LTTNG_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
@@ -41,12 +43,14 @@ set(QMLMIRPLUGIN_SRC
sharedwakelock.cpp
upstart/applicationcontroller.cpp
tracepoints.c
+ settings.cpp
# We need to run moc on these headers
- /usr/include/unity/shell/application/ApplicationInfoInterface.h
- /usr/include/unity/shell/application/ApplicationManagerInterface.h
+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
# Feed the automoc monster
session_interface.h
applicationcontroller.h
+ settings_interface.h
)
add_library(unityapplicationplugin SHARED
@@ -64,6 +68,7 @@ target_link_libraries(
${PROCESS_CPP_LDFLAGS}
${UBUNTU_APP_LAUNCH_LDFLAGS}
${LTTNG_LDFLAGS}
+ ${GSETTINGS_QT_LDFLAGS}
${GL_LIBRARIES}
@@ -82,3 +87,5 @@ add_lttng_gen_tp(NAME tracepoints)
# install
add_qml_plugin(Unity.Application 0.1 Unity/Application TARGETS unityapplicationplugin)
+install(FILES com.canonical.qtmir.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
+
diff --git a/src/modules/Unity/Application/application_manager.cpp b/src/modules/Unity/Application/application_manager.cpp
index 17643c1..c24345d 100644
--- a/src/modules/Unity/Application/application_manager.cpp
+++ b/src/modules/Unity/Application/application_manager.cpp
@@ -25,6 +25,7 @@
#include "taskcontroller.h"
#include "upstart/applicationcontroller.h"
#include "tracepoints.h" // generated from tracepoints.tp
+#include "settings.h"
// mirserver
#include "mirserver.h"
@@ -152,6 +153,7 @@ ApplicationManager* ApplicationManager::Factory::Factory::create()
QSharedPointer<DesktopFileReader::Factory> fileReaderFactory(new DesktopFileReader::Factory());
QSharedPointer<ProcInfo> procInfo(new ProcInfo());
QSharedPointer<SharedWakelock> sharedWakelock(new SharedWakelock);
+ QSharedPointer<Settings> settings(new Settings());
// FIXME: We should use a QSharedPointer to wrap this ApplicationManager object, which requires us
// to use the data() method to pass the raw pointer to the QML engine. However the QML engine appears
@@ -163,7 +165,8 @@ ApplicationManager* ApplicationManager::Factory::Factory::create()
taskController,
sharedWakelock,
fileReaderFactory,
- procInfo
+ procInfo,
+ settings
);
connectToSessionListener(appManager, sessionListener);
@@ -199,18 +202,19 @@ ApplicationManager::ApplicationManager(
const QSharedPointer<SharedWakelock>& sharedWakelock,
const QSharedPointer<DesktopFileReader::Factory>& desktopFileReaderFactory,
const QSharedPointer<ProcInfo>& procInfo,
+ const QSharedPointer<SettingsInterface>& settings,
QObject *parent)
: ApplicationManagerInterface(parent)
, m_mirServer(mirServer)
, m_focusedApplication(nullptr)
, m_mainStageApplication(nullptr)
, m_sideStageApplication(nullptr)
- , m_lifecycleExceptions(QStringList() << "com.ubuntu.music")
, m_dbusWindowStack(new DBusWindowStack(this))
, m_taskController(taskController)
, m_desktopFileReaderFactory(desktopFileReaderFactory)
, m_procInfo(procInfo)
, m_sharedWakelock(sharedWakelock)
+ , m_settings(settings)
, m_suspended(false)
, m_forceDashActive(false)
{
@@ -219,6 +223,11 @@ ApplicationManager::ApplicationManager(
m_roleNames.insert(RoleSession, "session");
m_roleNames.insert(RoleFullscreen, "fullscreen");
+
+ if (settings.data()) {
+ m_lifecycleExceptions = m_settings->get("lifecycleExemptAppids").toStringList();
+ connect(m_settings.data(), &Settings::changed, this, &ApplicationManager::onSettingsChanged);
+ }
}
ApplicationManager::~ApplicationManager()
@@ -706,12 +715,19 @@ void ApplicationManager::onAppDataChanged(const int role)
QModelIndex appIndex = findIndex(application);
Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << role);
- qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::onAppDataChanged: Received " << m_roleNames[role] << " update", application->appId();
+ qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::onAppDataChanged: Received " << m_roleNames[role] << " update" << application->appId();
} else {
qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::onAppDataChanged: Received " << m_roleNames[role] << " signal but application has disappeard.";
}
}
+void ApplicationManager::onSettingsChanged(const QString &key)
+{
+ if (key == "lifecycleExemptAppids") {
+ m_lifecycleExceptions = m_settings->get("lifecycleExemptAppids").toStringList();
+ }
+}
+
void ApplicationManager::authorizeSession(const quint64 pid, bool &authorized)
{
tracepoint(qtmir, authorizeSession);
@@ -751,26 +767,26 @@ void ApplicationManager::authorizeSession(const quint64 pid, bool &authorized)
return;
}
- boost::optional<QString> desktopFileName{ info->getParameter("--desktop_file_hint=") };
+ QString desktopFileName = info->getParameter("--desktop_file_hint=");
- if (!desktopFileName) {
+ if (desktopFileName.isNull()) {
qCritical() << "ApplicationManager REJECTED connection from app with pid" << pid
- << "as no desktop_file_hint specified";
+ << "as it was not launched by upstart, and no desktop_file_hint is specified";
return;
}
qCDebug(QTMIR_APPLICATIONS) << "Process supplied desktop_file_hint, loading:" << desktopFileName;
// Guess appId from the desktop file hint
- QString appId = toShortAppIdIfPossible(desktopFileName.get().remove(QRegExp(".desktop$")).split('/').last());
+ QString appId = toShortAppIdIfPossible(desktopFileName.remove(QRegExp(".desktop$")).split('/').last());
// FIXME: right now we support --desktop_file_hint=appId for historical reasons. So let's try that in
// case we didn't get an existing .desktop file path
DesktopFileReader* desktopData;
- if (QFileInfo::exists(desktopFileName.get())) {
- desktopData = m_desktopFileReaderFactory->createInstance(appId, QFileInfo(desktopFileName.get()));
+ if (QFileInfo::exists(desktopFileName)) {
+ desktopData = m_desktopFileReaderFactory->createInstance(appId, QFileInfo(desktopFileName));
} else {
- qCDebug(QTMIR_APPLICATIONS) << "Unable to find file:" << desktopFileName.get()
+ qCDebug(QTMIR_APPLICATIONS) << "Unable to find file:" << desktopFileName
<< "so will search standard paths for one named" << appId << ".desktop";
desktopData = m_desktopFileReaderFactory->createInstance(appId, m_taskController->findDesktopFileForAppId(appId));
}
@@ -796,9 +812,9 @@ void ApplicationManager::authorizeSession(const quint64 pid, bool &authorized)
// if stage supplied in CLI, fetch that
Application::Stage stage = Application::MainStage;
- boost::optional<QString> stageParam = info->getParameter("--stage_hint=");
+ QString stageParam = info->getParameter("--stage_hint=");
- if (stageParam && stageParam.get() == "side_stage") {
+ if (stageParam == "side_stage") {
stage = Application::SideStage;
}
diff --git a/src/modules/Unity/Application/application_manager.h b/src/modules/Unity/Application/application_manager.h
index c7d87a2..77ee097 100644
--- a/src/modules/Unity/Application/application_manager.h
+++ b/src/modules/Unity/Application/application_manager.h
@@ -48,6 +48,7 @@ class MirSurfaceManager;
class ProcInfo;
class SharedWakelock;
class TaskController;
+class SettingsInterface;
class ApplicationManager : public unity::shell::application::ApplicationManagerInterface
{
@@ -86,6 +87,7 @@ public:
const QSharedPointer<SharedWakelock> &sharedWakelock,
const QSharedPointer<DesktopFileReader::Factory> &desktopFileReaderFactory,
const QSharedPointer<ProcInfo> &processInfo,
+ const QSharedPointer<SettingsInterface> &settings,
QObject *parent = 0);
virtual ~ApplicationManager();
@@ -136,6 +138,7 @@ Q_SIGNALS:
private Q_SLOTS:
void onAppDataChanged(const int role);
+ void onSettingsChanged(const QString &key);
private:
void setFocused(Application *application);
@@ -163,6 +166,7 @@ private:
QSharedPointer<DesktopFileReader::Factory> m_desktopFileReaderFactory;
QSharedPointer<ProcInfo> m_procInfo;
QSharedPointer<SharedWakelock> m_sharedWakelock;
+ QSharedPointer<SettingsInterface> m_settings;
static ApplicationManager* the_application_manager;
QList<pid_t> m_hiddenPIDs;
bool m_suspended;
diff --git a/src/modules/Unity/Application/com.canonical.qtmir.gschema.xml b/src/modules/Unity/Application/com.canonical.qtmir.gschema.xml
new file mode 100644
index 0000000..4bd3ed5
--- /dev/null
+++ b/src/modules/Unity/Application/com.canonical.qtmir.gschema.xml
@@ -0,0 +1,10 @@
+<schemalist>
+ <schema path="/com/canonical/qtmir/" id="com.canonical.qtmir" gettext-domain="qtmir">
+ <key type="as" name="lifecycle-exempt-appids">
+ <default>[
+ 'com.ubuntu.music'
+ ]</default>
+ <summary>List of apps that should be excluded from the app lifecycle</summary>
+ </key>
+ </schema>
+</schemalist>
diff --git a/src/modules/Unity/Application/mirbuffersgtexture.cpp b/src/modules/Unity/Application/mirbuffersgtexture.cpp
index d1db1da..a8d5db9 100644
--- a/src/modules/Unity/Application/mirbuffersgtexture.cpp
+++ b/src/modules/Unity/Application/mirbuffersgtexture.cpp
@@ -20,18 +20,6 @@
#include <mir/graphics/buffer.h>
#include <mir/geometry/size.h>
-// QQuickProfiler uses the pretty syntax for emit, signal & slot
-#define emit Q_EMIT
-#define signals Q_SIGNALS
-#define slots Q_SLOTS
-#include <private/qquickprofiler_p.h>
-#undef emit
-#undef signals
-#undef slots
-#include <QElapsedTimer>
-static QElapsedTimer qsg_renderer_timer;
-static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
-
namespace mg = mir::geometry;
MirBufferSGTexture::MirBufferSGTexture(std::shared_ptr<mir::graphics::Buffer> buffer)
@@ -88,37 +76,7 @@ bool MirBufferSGTexture::hasAlphaChannel() const
void MirBufferSGTexture::bind()
{
-#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
- bool profileFrames = qsg_render_timing || QQuickProfiler::enabled;
-#else
- bool profileFrames = qsg_render_timing || QQuickProfiler::profilingSceneGraph();
-#endif
- if (profileFrames)
- qsg_renderer_timer.start();
-
glBindTexture(GL_TEXTURE_2D, m_textureId);
updateBindOptions(true/* force */);
m_mirBuffer->gl_bind_to_texture();
-
- qint64 bindTime = 0;
- if (profileFrames)
- bindTime = qsg_renderer_timer.nsecsElapsed();
-
- if (qsg_render_timing) {
- printf(" - mirbuffertexture(%dx%d) bind=%d, total=%d\n",
- m_width, m_height,
- int(bindTime/1000000),
- (int) qsg_renderer_timer.elapsed());
- }
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
- Q_QUICK_SG_PROFILE1(QQuickProfiler::SceneGraphTexturePrepare, (
-#else
- Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphTexturePrepare, (
-#endif
- bindTime, // bind (all this does)
- 0, // convert (not relevant)
- 0, // swizzle (not relevant)
- 0, // upload (not relevant)
- 0)); // mipmap (not used ever...)
}
diff --git a/src/modules/Unity/Application/mirsurfaceitem.cpp b/src/modules/Unity/Application/mirsurfaceitem.cpp
index 2697e84..3cd9e67 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.cpp
+++ b/src/modules/Unity/Application/mirsurfaceitem.cpp
@@ -205,6 +205,7 @@ MirSurfaceItem::MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
m_surfaceObserver = observer;
if (observer) {
connect(observer.get(), &SurfaceObserver::framesPosted, this, &MirSurfaceItem::surfaceDamaged);
+ connect(observer.get(), &SurfaceObserver::attributeChanged, this, &MirSurfaceItem::onAttributeChanged);
observer->setListener(this);
}
@@ -687,8 +688,7 @@ void MirSurfaceItem::setLive(const bool live)
}
}
-// Called by MirSurfaceItemManager upon a msh::Surface attribute change
-void MirSurfaceItem::setAttribute(const MirSurfaceAttrib attribute, const int /*value*/)
+void MirSurfaceItem::onAttributeChanged(const MirSurfaceAttrib attribute, const int /*value*/)
{
switch (attribute) {
case mir_surface_attrib_type:
diff --git a/src/modules/Unity/Application/mirsurfaceitem.h b/src/modules/Unity/Application/mirsurfaceitem.h
index a686f05..769f4bb 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.h
+++ b/src/modules/Unity/Application/mirsurfaceitem.h
@@ -148,6 +148,7 @@ private Q_SLOTS:
void updateMirSurfaceSize();
void updateMirSurfaceFocus(bool focused);
+ void onAttributeChanged(const MirSurfaceAttrib, const int);
private:
bool updateTexture();
@@ -158,7 +159,6 @@ private:
void setLive(const bool);
// called by MirSurfaceManager
- void setAttribute(const MirSurfaceAttrib, const int);
void setSurfaceValid(const bool);
bool hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints);
diff --git a/src/modules/Unity/Application/mirsurfacemanager.cpp b/src/modules/Unity/Application/mirsurfacemanager.cpp
index 5ab108e..183c3a5 100644
--- a/src/modules/Unity/Application/mirsurfacemanager.cpp
+++ b/src/modules/Unity/Application/mirsurfacemanager.cpp
@@ -51,12 +51,6 @@ void connectToSessionListener(MirSurfaceManager *manager, SessionListener *liste
manager, &MirSurfaceManager::onSessionDestroyingSurface);
}
-void connectToShell(MirSurfaceManager *manager, MirShell *shell)
-{
- QObject::connect(shell, &MirShell::surfaceAttributeChanged,
- manager, &MirSurfaceManager::onSurfaceAttributeChanged);
-}
-
MirSurfaceManager* MirSurfaceManager::singleton()
{
if (!the_surface_manager) {
@@ -75,7 +69,6 @@ MirSurfaceManager* MirSurfaceManager::singleton()
the_surface_manager = new MirSurfaceManager(nativeInterface->m_mirServer, shell, SessionManager::singleton());
connectToSessionListener(the_surface_manager, sessionListener);
- connectToShell(the_surface_manager, shell);
}
return the_surface_manager;
}
@@ -167,19 +160,4 @@ void MirSurfaceManager::onSessionDestroyingSurface(const mir::scene::Session *se
Q_EMIT surfaceDestroyed(item);
}
-// NB: Surface might be a dangling pointer here, so refrain from dereferencing it.
-void MirSurfaceManager::onSurfaceAttributeChanged(const ms::Surface *surface,
- const MirSurfaceAttrib attribute, const int value)
-{
- qCDebug(QTMIR_SURFACES) << "MirSurfaceManager::onSurfaceAttributeChanged - surface=" << surface
- << qPrintable(mirSurfaceAttribAndValueToString(attribute, value));
-
- QMutexLocker lock(&m_mutex);
- auto it = m_mirSurfaceToItemHash.find(surface);
- if (it != m_mirSurfaceToItemHash.end()) {
- it.value()->setAttribute(attribute, value);
- }
-}
-
-
} // namespace qtmir
diff --git a/src/modules/Unity/Application/mirsurfacemanager.h b/src/modules/Unity/Application/mirsurfacemanager.h
index df1971c..b9e5533 100644
--- a/src/modules/Unity/Application/mirsurfacemanager.h
+++ b/src/modules/Unity/Application/mirsurfacemanager.h
@@ -73,10 +73,7 @@ public Q_SLOTS:
void onSessionCreatedSurface(const mir::scene::Session *, const std::shared_ptr<mir::scene::Surface> &, std::shared_ptr<SurfaceObserver> const&);
void onSessionDestroyingSurface(const mir::scene::Session *, const std::shared_ptr<mir::scene::Surface> &);
- void onSurfaceAttributeChanged(const mir::scene::Surface *, MirSurfaceAttrib, int);
-
protected:
-
QHash<const mir::scene::Surface *, MirSurfaceItem *> m_mirSurfaceToItemHash;
QMutex m_mutex;
diff --git a/src/modules/Unity/Application/proc_info.cpp b/src/modules/Unity/Application/proc_info.cpp
index e80aa64..1bd0d51 100644
--- a/src/modules/Unity/Application/proc_info.cpp
+++ b/src/modules/Unity/Application/proc_info.cpp
@@ -46,16 +46,16 @@ bool ProcInfo::CommandLine::contains(char const* prefix) const {
return m_command.contains(prefix);
}
-boost::optional<QString> ProcInfo::CommandLine::getParameter(const char* name) const {
+QString ProcInfo::CommandLine::getParameter(const char* name) const {
QString pattern = QRegularExpression::escape(name) + "(\\S+)";
QRegularExpression regExp(pattern);
QRegularExpressionMatch regExpMatch = regExp.match(m_command);
if (!regExpMatch.hasMatch()) {
- return boost::optional<QString>{};
+ return QString();
}
- return boost::optional<QString>{regExpMatch.captured(1)};
+ return QString(regExpMatch.captured(1));
}
} // namespace qtmir
diff --git a/src/modules/Unity/Application/proc_info.h b/src/modules/Unity/Application/proc_info.h
index f4c2a4f..a5501ad 100644
--- a/src/modules/Unity/Application/proc_info.h
+++ b/src/modules/Unity/Application/proc_info.h
@@ -44,7 +44,7 @@ public:
bool startsWith(const char* prefix) const;
bool contains(const char* prefix) const;
- boost::optional<QString> getParameter(const char* name) const;
+ QString getParameter(const char* name) const;
QStringList asStringList() const;
};
virtual std::unique_ptr<CommandLine> commandLine(quint64 pid);
diff --git a/src/modules/Unity/Application/settings.cpp b/src/modules/Unity/Application/settings.cpp
new file mode 100644
index 0000000..e7ffe01
--- /dev/null
+++ b/src/modules/Unity/Application/settings.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 Canonical, Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License version 3, as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Ubuntu
+#include <QGSettings>
+#include <QVariant>
+
+// local
+#include "settings.h"
+
+namespace qtmir
+{
+
+Settings::Settings(QObject *parent)
+ :SettingsInterface(parent)
+ ,m_settings(new QGSettings("com.canonical.qtmir", "/com/canonical/qtmir/"))
+{
+ connect(m_settings, &QGSettings::changed, this, &Settings::changed);
+}
+
+QVariant Settings::get(const QString &key) const
+{
+ return m_settings->get(key);
+}
+
+} // namespace qtmir
diff --git a/src/modules/Unity/Application/settings.h b/src/modules/Unity/Application/settings.h
new file mode 100644
index 0000000..992b76a
--- /dev/null
+++ b/src/modules/Unity/Application/settings.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2015 Canonical, Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License version 3, as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
+//Qt
+#include <QObject>
+
+// local
+#include "settings_interface.h"
+
+class QGSettings;
+
+namespace qtmir
+{
+
+class Settings: public SettingsInterface
+{
+ Q_OBJECT
+public:
+ explicit Settings(QObject *parent = 0);
+
+ QVariant get(const QString &key) const override;
+
+private:
+ QGSettings *m_settings;
+};
+
+}
+
+#endif // SETTINGS_H
diff --git a/src/modules/Unity/Application/settings_interface.h b/src/modules/Unity/Application/settings_interface.h
new file mode 100644
index 0000000..1170591
--- /dev/null
+++ b/src/modules/Unity/Application/settings_interface.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 Canonical, Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License version 3, as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SETTINGS_INTERFACE_H
+#define SETTINGS_INTERFACE_H
+
+//Qt
+#include <QObject>
+
+namespace qtmir
+{
+
+class SettingsInterface: public QObject
+{
+ Q_OBJECT
+public:
+ explicit SettingsInterface(QObject *parent = 0): QObject(parent) {}
+
+ virtual QVariant get(const QString &key) const = 0;
+
+Q_SIGNALS:
+ void changed(const QString &key);
+};
+
+}
+
+#endif // SETTINGS_INTERFACE_H
diff --git a/src/platforms/mirserver/CMakeLists.txt b/src/platforms/mirserver/CMakeLists.txt
index eb807f8..6d69c69 100644
--- a/src/platforms/mirserver/CMakeLists.txt
+++ b/src/platforms/mirserver/CMakeLists.txt
@@ -18,9 +18,11 @@ foreach(item ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endforeach(item ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
include_directories(
+ ${CMAKE_SOURCE_DIR}/src/common
+
${MIRCOMMON_INCLUDE_DIRS}
${MIRSERVER_INCLUDE_DIRS}
-
+
${URL_DISPATCHER_INCLUDE_DIRS}
${PROTOBUF_INCLUDE_DIRS}
${EGL_INCLUDE_DIRS}
@@ -37,7 +39,7 @@ string (REPLACE " -pedantic " " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
add_definitions(-DBYTE_ORDER=__BYTE_ORDER)
set(MIRSERVER_QPA_PLUGIN_SRC
- ../../common/debughelpers.cpp
+ ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
mirshell.cpp
qteventfeeder.cpp
plugin.cpp
@@ -75,7 +77,7 @@ target_link_libraries(
${EGL_LDFLAGS}
${GL_LIBRARIES}
${LTTNG_LIBRARIES}
-
+
${QT5PLATFORM_SUPPORT_LDFLAGS}
# TODO Qt5Platform support LDFLAGS dont provide actual required ldflags...
# I found these were needed...perhaps there is some way to query qmake/qconfig?
@@ -87,8 +89,6 @@ target_link_libraries(
Qt5::DBus
Qt5::Quick
Qt5::Sensors
-
- -lboost_system
)
include(UseLttngGenTp)
diff --git a/src/platforms/mirserver/mirserverintegration.cpp b/src/platforms/mirserver/mirserverintegration.cpp
index 3c9a7a8..dfc9bce 100644
--- a/src/platforms/mirserver/mirserverintegration.cpp
+++ b/src/platforms/mirserver/mirserverintegration.cpp
@@ -156,7 +156,9 @@ QAbstractEventDispatcher *MirServerIntegration::createEventDispatcher() const
void MirServerIntegration::initialize()
{
// Creates instance of and start the Mir server in a separate thread
- m_mirServer->start();
+ if (!m_mirServer->start()) {
+ exit(2);
+ }
m_display = new Display(m_mirServer->mirServer());
m_nativeInterface = new NativeInterface(m_mirServer->mirServer());
diff --git a/src/platforms/mirserver/mirshell.cpp b/src/platforms/mirserver/mirshell.cpp
index fac7ec3..bb13b7b 100644
--- a/src/platforms/mirserver/mirshell.cpp
+++ b/src/platforms/mirserver/mirshell.cpp
@@ -61,15 +61,3 @@ mir::frontend::SurfaceId MirShell::create_surface(const std::shared_ptr<ms::Sess
return AbstractShell::create_surface(session, placedParameters);
}
-
-int MirShell::set_surface_attribute(
- const std::shared_ptr<mir::scene::Session> &session,
- const std::shared_ptr<mir::scene::Surface> &surface,
- MirSurfaceAttrib attrib,
- int value)
-{
- auto const result = AbstractShell::set_surface_attribute(session, surface, attrib, value);
- Q_EMIT surfaceAttributeChanged(surface.get(), attrib, result);
-
- return result;
-}
diff --git a/src/platforms/mirserver/mirshell.h b/src/platforms/mirserver/mirshell.h
index 386a491..85c243e 100644
--- a/src/platforms/mirserver/mirshell.h
+++ b/src/platforms/mirserver/mirshell.h
@@ -40,15 +40,6 @@ public:
virtual mir::frontend::SurfaceId create_surface(const std::shared_ptr<mir::scene::Session>& session, const mir::scene::SurfaceCreationParameters &params);
- int set_surface_attribute(
- const std::shared_ptr<mir::scene::Session> &session,
- const std::shared_ptr<mir::scene::Surface> &surface,
- MirSurfaceAttrib attrib,
- int value) override;
-
-Q_SIGNALS:
- void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int);
-
private:
std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
};
diff --git a/src/platforms/mirserver/qmirserver.cpp b/src/platforms/mirserver/qmirserver.cpp
index c48c2c7..58ee365 100644
--- a/src/platforms/mirserver/qmirserver.cpp
+++ b/src/platforms/mirserver/qmirserver.cpp
@@ -53,7 +53,7 @@ QMirServer::~QMirServer()
stop();
}
-void QMirServer::start()
+bool QMirServer::start()
{
Q_D(QMirServer);
@@ -62,10 +62,11 @@ void QMirServer::start()
if (!d->serverThread->waitForMirStartup())
{
qCritical() << "ERROR: QMirServer - Mir failed to start";
- return;
+ return false;
}
Q_EMIT started();
+ return true;
}
void QMirServer::stop()
diff --git a/src/platforms/mirserver/qmirserver.h b/src/platforms/mirserver/qmirserver.h
index 0f98131..ecb943b 100644
--- a/src/platforms/mirserver/qmirserver.h
+++ b/src/platforms/mirserver/qmirserver.h
@@ -32,7 +32,7 @@ public:
QMirServer(const QStringList &arguments, QObject* parent=0);
virtual ~QMirServer();
- void start();
+ bool start();
Q_SLOT void stop();
bool isRunning() const;
diff --git a/src/platforms/mirserver/qteventfeeder.cpp b/src/platforms/mirserver/qteventfeeder.cpp
index 948164f..385b915 100644
--- a/src/platforms/mirserver/qteventfeeder.cpp
+++ b/src/platforms/mirserver/qteventfeeder.cpp
@@ -30,7 +30,10 @@
#include <QDebug>
-Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input")
+// common dir
+#include <debughelpers.h>
+
+Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input", QtWarningMsg)
// XKB Keysyms which do not map directly to Qt types (i.e. Unicode points)
static const uint32_t KeyTable[] = {
@@ -355,6 +358,7 @@ void QtEventFeeder::dispatchTouch(MirInputEvent const* event)
return;
auto tev = mir_input_event_get_touch_input_event(event);
+ qCDebug(QTMIR_MIR_INPUT) << "Received" << qPrintable(mirTouchEventToString(tev));
// FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That
// needs to be fixed as soon as the compat input lib adds query support.
@@ -398,9 +402,10 @@ void QtEventFeeder::dispatchTouch(MirInputEvent const* event)
// Qt needs a happy, sane stream of touch events. So let's make sure we're not forwarding
// any insanity.
- validateTouches(touchPoints);
+ validateTouches(mir_input_event_get_event_time(event) / 1000000, touchPoints);
// Touch event propagation.
+ qCDebug(QTMIR_MIR_INPUT) << "Sending to Qt" << qPrintable(touchesToString(touchPoints));
mQtWindowSystem->handleTouchEvent(
//scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable
mir_input_event_get_event_time(event) / 1000000,
@@ -429,7 +434,8 @@ void QtEventFeeder::device_reset(int32_t device_id, std::chrono::nanoseconds whe
Q_UNUSED(when);
}
-void QtEventFeeder::validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints)
+void QtEventFeeder::validateTouches(ulong timestamp,
+ QList<QWindowSystemInterface::TouchPoint> &touchPoints)
{
QSet<int> updatedTouches;
@@ -446,23 +452,47 @@ void QtEventFeeder::validateTouches(QList<QWindowSystemInterface::TouchPoint> &t
}
}
- // Release all unmentioned touches.
- {
- QHash<int, QWindowSystemInterface::TouchPoint>::iterator it = mActiveTouches.begin();
- while (it != mActiveTouches.end()) {
- if (!updatedTouches.contains(it.key())) {
- qCWarning(QTMIR_MIR_INPUT)
- << "There's a touch (id =" << it.key() << ") missing. Releasing it.";
- it.value().state = Qt::TouchPointReleased;
- touchPoints.append(it.value());
- it = mActiveTouches.erase(it);
- } else {
- ++it;
- }
+ // Release all unmentioned touches, one by one.
+ QHash<int, QWindowSystemInterface::TouchPoint>::iterator it = mActiveTouches.begin();
+ while (it != mActiveTouches.end()) {
+ if (!updatedTouches.contains(it.key())) {
+ qCWarning(QTMIR_MIR_INPUT)
+ << "There's a touch (id =" << it.key() << ") missing. Releasing it.";
+ sendActiveTouchRelease(timestamp, it.key());
+ it = mActiveTouches.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+ // update mActiveTouches
+ for (int i = 0; i < touchPoints.count(); ++i) {
+ auto &touchPoint = touchPoints.at(i);
+ if (touchPoint.state == Qt::TouchPointReleased) {
+ mActiveTouches.remove(touchPoint.id);
+ } else {
+ mActiveTouches[touchPoint.id] = touchPoint;
}
}
}
+void QtEventFeeder::sendActiveTouchRelease(ulong timestamp, int id)
+{
+ QList<QWindowSystemInterface::TouchPoint> touchPoints = mActiveTouches.values();
+
+ for (int i = 0; i < touchPoints.count(); ++i) {
+ QWindowSystemInterface::TouchPoint &touchPoint = touchPoints[i];
+ if (touchPoint.id == id) {
+ touchPoint.state = Qt::TouchPointReleased;
+ } else {
+ touchPoint.state = Qt::TouchPointStationary;
+ }
+ }
+
+ qCDebug(QTMIR_MIR_INPUT) << "Sending to Qt" << qPrintable(touchesToString(touchPoints));
+ mQtWindowSystem->handleTouchEvent(timestamp, mTouchDevice, touchPoints);
+}
+
bool QtEventFeeder::validateTouch(QWindowSystemInterface::TouchPoint &touchPoint)
{
bool ok = true;
@@ -475,7 +505,6 @@ bool QtEventFeeder::validateTouch(QWindowSystemInterface::TouchPoint &touchPoint
<< "). Making it move instead.";
touchPoint.state = Qt::TouchPointMoved;
}
- mActiveTouches[touchPoint.id] = touchPoint;
break;
case Qt::TouchPointMoved:
if (!mActiveTouches.contains(touchPoint.id)) {
@@ -484,7 +513,6 @@ bool QtEventFeeder::validateTouch(QWindowSystemInterface::TouchPoint &touchPoint
<< "). Making it press instead.";
touchPoint.state = Qt::TouchPointPressed;
}
- mActiveTouches[touchPoint.id] = touchPoint;
break;
case Qt::TouchPointStationary:
if (!mActiveTouches.contains(touchPoint.id)) {
@@ -493,7 +521,6 @@ bool QtEventFeeder::validateTouch(QWindowSystemInterface::TouchPoint &touchPoint
<< "). Making it press instead.";
touchPoint.state = Qt::TouchPointPressed;
}
- mActiveTouches[touchPoint.id] = touchPoint;
break;
case Qt::TouchPointReleased:
if (!mActiveTouches.contains(touchPoint.id)) {
@@ -501,8 +528,6 @@ bool QtEventFeeder::validateTouch(QWindowSystemInterface::TouchPoint &touchPoint
<< "Would release a touch that wasn't pressed before (id =" << touchPoint.id
<< "). Ignoring it.";
ok = false;
- } else {
- mActiveTouches.remove(touchPoint.id);
}
break;
default:
@@ -511,3 +536,21 @@ bool QtEventFeeder::validateTouch(QWindowSystemInterface::TouchPoint &touchPoint
return ok;
}
+
+QString QtEventFeeder::touchesToString(const QList<struct QWindowSystemInterface::TouchPoint> &points)
+{
+ QString result;
+ for (int i = 0; i < points.count(); ++i) {
+ if (i > 0) {
+ result.append(",");
+ }
+ const struct QWindowSystemInterface::TouchPoint &point = points.at(i);
+ result.append(QString("(id=%1,state=%2,normalPosition=(%3,%4))")
+ .arg(point.id)
+ .arg(touchPointStateToString(point.state))
+ .arg(point.normalPosition.x())
+ .arg(point.normalPosition.y())
+ );
+ }
+ return result;
+}
diff --git a/src/platforms/mirserver/qteventfeeder.h b/src/platforms/mirserver/qteventfeeder.h
index a57ea62..48113bf 100644
--- a/src/platforms/mirserver/qteventfeeder.h
+++ b/src/platforms/mirserver/qteventfeeder.h
@@ -71,8 +71,11 @@ private:
void dispatchKey(MirInputEvent const* event);
void dispatchTouch(MirInputEvent const* event);
void dispatchPointer(MirInputEvent const* event);
- void validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints);
+ void validateTouches(ulong timestamp, QList<QWindowSystemInterface::TouchPoint> &touchPoints);
bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint);
+ void sendActiveTouchRelease(ulong timestamp, int id);
+
+ QString touchesToString(const QList<struct QWindowSystemInterface::TouchPoint> &points);
QTouchDevice *mTouchDevice;
QtWindowSystemInterface *mQtWindowSystem;
diff --git a/src/platforms/mirserver/surfaceobserver.cpp b/src/platforms/mirserver/surfaceobserver.cpp
index db7a912..97f2733 100644
--- a/src/platforms/mirserver/surfaceobserver.cpp
+++ b/src/platforms/mirserver/surfaceobserver.cpp
@@ -24,16 +24,26 @@ SurfaceObserver::SurfaceObserver()
{
}
-void SurfaceObserver::setListener(QObject *listener) {
+void SurfaceObserver::setListener(QObject *listener)
+{
m_listener = listener;
if (m_framesPosted) {
Q_EMIT framesPosted();
}
}
-void SurfaceObserver::frame_posted(int /*frames_available*/) {
+void SurfaceObserver::frame_posted(int /*frames_available*/)
+{
m_framesPosted = true;
if (m_listener) {
Q_EMIT framesPosted();
}
}
+
+void SurfaceObserver::attrib_changed(MirSurfaceAttrib attribute, int value)
+{
+ if (m_listener) {
+ Q_EMIT attributeChanged(attribute, value);
+ }
+}
+
diff --git a/src/platforms/mirserver/surfaceobserver.h b/src/platforms/mirserver/surfaceobserver.h
index db90765..ca63025 100644
--- a/src/platforms/mirserver/surfaceobserver.h
+++ b/src/platforms/mirserver/surfaceobserver.h
@@ -20,7 +20,8 @@
#include <QObject>
#include <mir/scene/surface_observer.h>
-class SurfaceObserver : public QObject, public mir::scene::SurfaceObserver {
+class SurfaceObserver : public QObject, public mir::scene::SurfaceObserver
+{
Q_OBJECT
public:
@@ -28,7 +29,7 @@ public:
void setListener(QObject *listener);
- void attrib_changed(MirSurfaceAttrib, int) override {}
+ void attrib_changed(MirSurfaceAttrib, int) override;
void resized_to(mir::geometry::Size const&) override {}
void moved_to(mir::geometry::Point const&) override {}
void hidden_set_to(bool) override {}
@@ -44,6 +45,7 @@ public:
void client_surface_close_requested() override {}
Q_SIGNALS:
+ void attributeChanged(const MirSurfaceAttrib attribute, const int value);
void framesPosted();
private: