summaryrefslogtreecommitdiffstats
path: root/widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h')
-rw-r--r--widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h b/widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h
new file mode 100644
index 0000000000..04a3aeba48
--- /dev/null
+++ b/widget/cocoa/MediaHardwareKeysEventSourceMacMediaCenter.h
@@ -0,0 +1,60 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMACMEDIACENTER_H_
+#define WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMACMEDIACENTER_H_
+
+#include "mozilla/dom/MediaControlKeySource.h"
+
+#ifdef __OBJC__
+@class MPRemoteCommandEvent;
+#else
+typedef struct objc_object MPRemoteCommandEvent;
+#endif
+enum MPRemoteCommandHandlerStatus : long;
+
+namespace mozilla {
+namespace widget {
+
+typedef MPRemoteCommandHandlerStatus (^MediaCenterEventHandler)(MPRemoteCommandEvent* event);
+
+class MediaHardwareKeysEventSourceMacMediaCenter final
+ : public mozilla::dom::MediaControlKeySource {
+ public:
+ NS_INLINE_DECL_REFCOUNTING(MediaHardwareKeysEventSourceMacMediaCenter, override)
+ MediaHardwareKeysEventSourceMacMediaCenter();
+
+ MediaCenterEventHandler CreatePlayPauseHandler();
+ MediaCenterEventHandler CreateNextTrackHandler();
+ MediaCenterEventHandler CreatePreviousTrackHandler();
+ MediaCenterEventHandler CreatePlayHandler();
+ MediaCenterEventHandler CreatePauseHandler();
+
+ bool Open() override;
+ void Close() override;
+ bool IsOpened() const override;
+ void SetPlaybackState(dom::MediaSessionPlaybackState aState) override;
+ void SetMediaMetadata(const dom::MediaMetadataBase& aMetadata) override;
+ // Currently we don't support showing supported keys on the touch bar.
+ void SetSupportedMediaKeys(const MediaKeysArray& aSupportedKeys) override {}
+
+ private:
+ ~MediaHardwareKeysEventSourceMacMediaCenter();
+ void BeginListeningForEvents();
+ void EndListeningForEvents();
+ void HandleEvent(dom::MediaControlKey aKey);
+
+ bool mOpened = false;
+
+ MediaCenterEventHandler mPlayPauseHandler;
+ MediaCenterEventHandler mNextTrackHandler;
+ MediaCenterEventHandler mPreviousTrackHandler;
+ MediaCenterEventHandler mPauseHandler;
+ MediaCenterEventHandler mPlayHandler;
+};
+
+} // namespace widget
+} // namespace mozilla
+
+#endif // WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMACMEDIACENTER_H_