diff --git a/debian/unity8-private.install b/debian/unity8-private.install
index 23f86ab8ac..018f9bf64e 100644
--- a/debian/unity8-private.install
+++ b/debian/unity8-private.install
@@ -1,5 +1,6 @@
usr/lib/*/libunity8-private.*
usr/lib/*/unity8/qml/AccountsService
+usr/lib/*/unity8/qml/Broadcaster
usr/lib/*/unity8/qml/Cursor
usr/lib/*/unity8/qml/GlobalShortcut
usr/lib/*/unity8/qml/Greeter
diff --git a/plugins/Broadcaster/Broadcaster.cpp b/plugins/Broadcaster/Broadcaster.cpp
new file mode 100644
index 0000000000..0c9720694a
--- /dev/null
+++ b/plugins/Broadcaster/Broadcaster.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 UBports Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "Broadcaster.h"
+#include
+#include
+#include
+#include
+
+#include
+
+#define BROADCAST_SERVICE "com.ubports.Lomiri.Broadcast"
+#define BROADCAST_PATH "/com/ubports/Lomiri/Broadcast"
+#define BROADCAST_INTERFACE "com.ubports.Lomiri.Broadcast"
+
+Broadcaster::Broadcaster(QObject* parent)
+ : QObject(parent)
+{
+}
+
+void Broadcaster::notifyMediaKey(const QString &keyMsg)
+{
+
+ auto connection = QDBusConnection::SM_BUSNAME();
+ QDBusMessage msg = QDBusMessage::createSignal(BROADCAST_PATH, BROADCAST_INTERFACE, "MediaKey");
+
+ QVariantMap args;
+ args.insert("key-msg", keyMsg);
+ msg << args;
+
+ connection.send(msg);
+}
diff --git a/plugins/Broadcaster/Broadcaster.h b/plugins/Broadcaster/Broadcaster.h
new file mode 100644
index 0000000000..b3e4a7cb97
--- /dev/null
+++ b/plugins/Broadcaster/Broadcaster.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 UBports Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef LOMIRI_BROADCASTER_H
+#define LOMIRI_BROADCASTER_H
+
+#include
+#include
+
+class QDBusInterface;
+
+class Broadcaster: public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit Broadcaster(QObject *parent = 0);
+
+ Q_INVOKABLE void notifyMediaKey(const QString &keyMsg);
+
+};
+
+#endif
diff --git a/plugins/Broadcaster/CMakeLists.txt b/plugins/Broadcaster/CMakeLists.txt
new file mode 100644
index 0000000000..e3576fc3a0
--- /dev/null
+++ b/plugins/Broadcaster/CMakeLists.txt
@@ -0,0 +1,15 @@
+include_directories(${GLIB_INCLUDE_DIRS})
+add_definitions(-DSM_BUSNAME=sessionBus)
+
+add_library(Broadcaster-qml MODULE
+ Broadcaster.cpp
+ plugin.cpp
+ )
+
+qt5_use_modules(Broadcaster-qml DBus Qml)
+
+target_link_libraries(Broadcaster-qml
+ ${GLIB_LIBRARIES}
+ )
+
+add_unity8_plugin(Broadcaster 0.1 Broadcaster TARGETS Broadcaster-qml)
diff --git a/plugins/Broadcaster/plugin.cpp b/plugins/Broadcaster/plugin.cpp
new file mode 100644
index 0000000000..8d43f96a23
--- /dev/null
+++ b/plugins/Broadcaster/plugin.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2020 UBports Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "plugin.h"
+#include "Broadcaster.h"
+
+#include
+
+static QObject *broadcast_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+ return new Broadcaster();
+}
+
+void BroadcasterPlugin::registerTypes(const char *uri)
+{
+ Q_ASSERT(uri == QLatin1String("Broadcaster"));
+ qmlRegisterSingletonType(uri, 0, 1, "Broadcaster", broadcast_provider);
+}
diff --git a/plugins/Broadcaster/plugin.h b/plugins/Broadcaster/plugin.h
new file mode 100644
index 0000000000..7d9d7e71b8
--- /dev/null
+++ b/plugins/Broadcaster/plugin.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2020 UBports Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#ifndef LOMIRI_BROADCASTER_PLUGIN
+#define LOMIRI_BROADCASTER_PLUGIN
+
+#include
+
+class BroadcasterPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+ void registerTypes(const char *uri) override;
+};
+
+#endif
diff --git a/plugins/Broadcaster/qmldir b/plugins/Broadcaster/qmldir
new file mode 100644
index 0000000000..2301cd91e9
--- /dev/null
+++ b/plugins/Broadcaster/qmldir
@@ -0,0 +1,3 @@
+module Broadcaster
+plugin Broadcaster-qml
+typeinfo Broadcaster.qmltypes
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 4841bcc529..372aa076dc 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -15,6 +15,7 @@ add_subdirectory(AccountsService)
add_subdirectory(Cursor)
add_subdirectory(GlobalShortcut)
add_subdirectory(Greeter)
+add_subdirectory(Broadcaster)
add_subdirectory(LightDM)
add_subdirectory(Lights)
add_subdirectory(Powerd)
diff --git a/qml/Components/PhysicalKeysMapper.qml b/qml/Components/PhysicalKeysMapper.qml
index b3f8417061..9469da3d73 100644
--- a/qml/Components/PhysicalKeysMapper.qml
+++ b/qml/Components/PhysicalKeysMapper.qml
@@ -40,6 +40,7 @@ Item {
signal volumeDownTriggered;
signal volumeUpTriggered;
signal screenshotTriggered;
+ signal mediaKey(var keyMsg);
readonly property bool altTabPressed: d.altTabPressed
readonly property bool superPressed: d.superPressed
@@ -130,7 +131,34 @@ Item {
}
}
+ function getMediaKeyBroadcastString(event) {
+ var keyStr = ""
+ switch(event.key) {
+ case Qt.Key_MediaNext:
+ keyStr = "next-track"
+ break
+ case Qt.Key_MediaPrevious:
+ keyStr = "previous-track"
+ break
+ case Qt.Key_MediaPlay:
+ keyStr = "play-pause"
+ break
+ case Qt.Key_WebCam:
+ keyStr = "camera"
+ break
+ default:
+ switch(event.nativeScanCode) {
+ case 541: // KEY_ATTENDANT_TOGGLE
+ keyStr = "toggle-flash"
+ break
+ }
+ break
+ }
+ return keyStr
+ }
+
function onKeyReleased(event, currentEventTimestamp) {
+ console.log("onKeyReleased key: " + event.key + ", scan code: " + event.nativeScanCode)
if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
d.powerButtonPressStart = 0;
event.accepted = true;
@@ -158,6 +186,10 @@ Item {
d.superTabPressed = false;
event.accepted = true;
}
+ } else {
+ var keyMsg = getMediaKeyBroadcastString(event)
+ if (keyMsg != "")
+ root.mediaKey(keyMsg)
}
}
}
diff --git a/qml/Shell.qml b/qml/Shell.qml
index 75414bebd1..e849b26f91 100644
--- a/qml/Shell.qml
+++ b/qml/Shell.qml
@@ -30,6 +30,7 @@ import GSettings 1.0
import Utils 0.1
import Powerd 0.1
import SessionBroadcast 0.1
+import Broadcaster 0.1
import "Greeter"
import "Launcher"
import "Panel"
@@ -236,6 +237,8 @@ StyledItem {
onVolumeDownTriggered: volumeControl.volumeDown();
onVolumeUpTriggered: volumeControl.volumeUp();
onScreenshotTriggered: itemGrabber.capture(shell);
+
+ onMediaKey: Broadcaster.notifyMediaKey(keyMsg);
}
GlobalShortcut {