1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMAC_H_
6 #define WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMAC_H_
8 #import <ApplicationServices/ApplicationServices.h>
9 #import <CoreFoundation/CoreFoundation.h>
11 #include "mozilla/dom/MediaControlKeySource.h"
12 #include "nsISupportsImpl.h"
17 class MediaHardwareKeysEventSourceMac final
18 : public mozilla::dom::MediaControlKeySource
{
20 NS_INLINE_DECL_REFCOUNTING(MediaHardwareKeysEventSourceMac
, override
)
21 MediaHardwareKeysEventSourceMac() = default;
23 static CGEventRef
EventTapCallback(CGEventTapProxy proxy
, CGEventType type
,
24 CGEventRef event
, void* refcon
);
27 void Close() override
;
28 bool IsOpened() const override
;
30 // Currently we don't support showing supported keys on the touch bar.
31 void SetSupportedMediaKeys(const MediaKeysArray
& aSupportedKeys
) override
{}
34 ~MediaHardwareKeysEventSourceMac() = default;
39 // They are used to intercept mac hardware media keys.
40 CFMachPortRef mEventTap
= nullptr;
41 CFRunLoopSourceRef mEventTapSource
= nullptr;
45 } // namespace mozilla