Bug 1777562 [wpt PR 34663] - [FedCM] Rename FederatedCredential to IdentityCredential...
[gecko.git] / widget / cocoa / MediaHardwareKeysEventSourceMac.h
blobda08b8108d249c793b118cabf0c6ce847e386331
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"
14 namespace mozilla {
15 namespace widget {
17 class MediaHardwareKeysEventSourceMac final
18 : public mozilla::dom::MediaControlKeySource {
19 public:
20 NS_INLINE_DECL_REFCOUNTING(MediaHardwareKeysEventSourceMac, override)
21 MediaHardwareKeysEventSourceMac() = default;
23 static CGEventRef EventTapCallback(CGEventTapProxy proxy, CGEventType type,
24 CGEventRef event, void* refcon);
26 bool Open() override;
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 {}
33 private:
34 ~MediaHardwareKeysEventSourceMac() = default;
36 bool StartEventTap();
37 void StopEventTap();
39 // They are used to intercept mac hardware media keys.
40 CFMachPortRef mEventTap = nullptr;
41 CFRunLoopSourceRef mEventTapSource = nullptr;
44 } // namespace widget
45 } // namespace mozilla
47 #endif