зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1601508 - create a general interface for getting platform-specific media keys event source r=spohl
Create a general interface for getting platform-specific media keys event source in order to remove platform specific code from non-platform related folder `dom/media`. Differential Revision: https://phabricator.services.mozilla.com/D55892 --HG-- rename : dom/media/mediacontrol/MediaHardwareKeysEventSourceMac.h => widget/cocoa/MediaHardwareKeysEventSourceMac.h rename : dom/media/mediacontrol/MediaHardwareKeysEventSourceMac.mm => widget/cocoa/MediaHardwareKeysEventSourceMac.mm extra : moz-landing-system : lando
This commit is contained in:
Родитель
319f5700e2
Коммит
a7c687ab30
|
@ -10,10 +10,7 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/StaticPrefs_media.h"
|
||||
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
# include "MediaHardwareKeysEventSourceMac.h"
|
||||
#endif
|
||||
#include "mozilla/widget/MediaKeysEventSourceFactory.h"
|
||||
|
||||
#undef LOG
|
||||
#define LOG(msg, ...) \
|
||||
|
@ -48,9 +45,7 @@ void MediaControlKeysManager::StartMonitoringControlKeys() {
|
|||
}
|
||||
|
||||
void MediaControlKeysManager::CreateEventSource() {
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
mEventSource = new MediaHardwareKeysEventSourceMac();
|
||||
#endif
|
||||
mEventSource = widget::CreateMediaControlKeysEventSource();
|
||||
if (mEventSource) {
|
||||
mEventSource->AddListener(this);
|
||||
}
|
||||
|
|
|
@ -17,14 +17,6 @@ EXPORTS.ipc += [
|
|||
'MediaControlIPC.h',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_APPLEMEDIA']:
|
||||
EXPORTS += [
|
||||
'MediaHardwareKeysEventSourceMac.h',
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'MediaHardwareKeysEventSourceMac.mm',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'AudioFocusManager.cpp',
|
||||
'MediaControlKeysEvent.cpp',
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "MediaHardwareKeysEventSourceMac.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
static const int kSystemDefinedEventMediaKeysSubtype = 8;
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/* 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_MEDIAKEYSEVENTSOURCEFACTORY_H_
|
||||
#define WIDGET_MEDIAKEYSEVENTSOURCEFACTORY_H_
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class MediaControlKeysEventSource;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
// This function declaration is used to create a media keys event source on
|
||||
// different platforms, each platform should have their own implementation.
|
||||
extern mozilla::dom::MediaControlKeysEventSource*
|
||||
CreateMediaControlKeysEventSource();
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -0,0 +1,16 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "MediaKeysEventSourceFactory.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
mozilla::dom::MediaControlKeysEventSource* CreateMediaControlKeysEventSource() {
|
||||
// TODO : will implement this in bug 1601510.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
|
@ -40,6 +40,7 @@ EXPORTS.mozilla.widget += [
|
|||
|
||||
SOURCES += [
|
||||
'!GeneratedJNIWrappers.cpp',
|
||||
'MediaKeysEventSourceFactory.cpp',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
* 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 DOM_MEDIA_MEDIACONTROL_MEDIAHARDWAREKEYSEVENTSOURCEMAC_H_
|
||||
#define DOM_MEDIA_MEDIACONTROL_MEDIAHARDWAREKEYSEVENTSOURCEMAC_H_
|
||||
#ifndef WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMAC_H_
|
||||
#define WIDGET_COCOA_MEDIAHARDWAREKEYSEVENTSOURCEMAC_H_
|
||||
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#include "MediaControlKeysEvent.h"
|
||||
#include "mozilla/dom/MediaControlKeysEvent.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace widget {
|
||||
|
||||
class MediaHardwareKeysEventSourceMac final
|
||||
: public MediaControlKeysEventSource {
|
||||
: public mozilla::dom::MediaControlKeysEventSource {
|
||||
public:
|
||||
MediaHardwareKeysEventSourceMac();
|
||||
~MediaHardwareKeysEventSourceMac();
|
||||
|
@ -32,7 +32,7 @@ class MediaHardwareKeysEventSourceMac final
|
|||
CFRunLoopSourceRef mEventTapSource = nullptr;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -2,12 +2,15 @@
|
|||
* 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/. */
|
||||
|
||||
#include "MediaHardwareKeysEventSourceMac.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <AppKit/NSEvent.h>
|
||||
#import <IOKit/hidsystem/ev_keymap.h>
|
||||
|
||||
#include "MediaHardwareKeysEventSourceMac.h"
|
||||
#include "MediaControlUtils.h"
|
||||
#include "mozilla/dom/MediaControlUtils.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
// avoid redefined macro in unified build
|
||||
#undef LOG
|
||||
|
@ -43,9 +46,6 @@ static const char* ToMediaControlKeyStr(int aKeyCode) {
|
|||
// http://lists.apple.com/archives/cocoa-dev/2007/Aug/msg00499.html
|
||||
const int kSystemDefinedEventMediaKeysSubtype = 8;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
static MediaControlKeysEvent ToMediaControlKeysEvent(int aKeyCode) {
|
||||
switch (aKeyCode) {
|
||||
case NX_KEYTYPE_PLAY:
|
||||
|
@ -62,6 +62,9 @@ static MediaControlKeysEvent ToMediaControlKeysEvent(int aKeyCode) {
|
|||
return MediaControlKeysEvent::eNone;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
MediaHardwareKeysEventSourceMac::MediaHardwareKeysEventSourceMac() {
|
||||
LOG("Create MediaHardwareKeysEventSourceMac");
|
||||
StartEventTap();
|
||||
|
@ -163,5 +166,5 @@ CGEventRef MediaHardwareKeysEventSourceMac::EventTapCallback(CGEventTapProxy pro
|
|||
return event;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,17 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "MediaKeysEventSourceFactory.h"
|
||||
|
||||
#include "MediaHardwareKeysEventSourceMac.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
mozilla::dom::MediaControlKeysEventSource* CreateMediaControlKeysEventSource() {
|
||||
return new MediaHardwareKeysEventSourceMac();
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
|
@ -15,6 +15,7 @@ XPIDL_MODULE = 'widget_cocoa'
|
|||
|
||||
EXPORTS += [
|
||||
'CFTypeRefPtr.h',
|
||||
'MediaHardwareKeysEventSourceMac.h',
|
||||
'mozView.h',
|
||||
'nsBidiKeyboard.h',
|
||||
'nsChangeObserver.h',
|
||||
|
@ -74,6 +75,8 @@ UNIFIED_SOURCES += [
|
|||
|
||||
# These files cannot be built in unified mode because they cause symbol conflicts
|
||||
SOURCES += [
|
||||
'MediaHardwareKeysEventSourceMac.mm',
|
||||
'MediaKeysEventSourceFactory.cpp',
|
||||
'nsChildView.mm',
|
||||
'nsClipboard.mm',
|
||||
'nsCocoaDebugUtils.mm',
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "MediaKeysEventSourceFactory.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
mozilla::dom::MediaControlKeysEventSource* CreateMediaControlKeysEventSource() {
|
||||
// TODO : will implement this in bug 1353652.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
|
@ -53,6 +53,7 @@ UNIFIED_SOURCES += [
|
|||
]
|
||||
|
||||
SOURCES += [
|
||||
'MediaKeysEventSourceFactory.cpp',
|
||||
'nsWindow.cpp', # conflicts with X11 headers
|
||||
'WaylandVsyncSource.cpp', # conflicts with X11 headers
|
||||
]
|
||||
|
|
|
@ -173,6 +173,7 @@ EXPORTS.mozilla.widget += [
|
|||
'CompositorWidget.h',
|
||||
'IMEData.h',
|
||||
'InProcessCompositorWidget.h',
|
||||
'MediaKeysEventSourceFactory.h',
|
||||
'nsAutoRollup.h',
|
||||
'PuppetBidiKeyboard.h',
|
||||
'Screen.h',
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "MediaKeysEventSourceFactory.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
mozilla::dom::MediaControlKeysEventSource* CreateMediaControlKeysEventSource() {
|
||||
// TODO : will implement this in bug 1584501.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
|
@ -89,6 +89,7 @@ UNIFIED_SOURCES += [
|
|||
# The following files cannot be built in unified mode because of name clashes.
|
||||
SOURCES += [
|
||||
'JumpListBuilder.cpp',
|
||||
'MediaKeysEventSourceFactory.cpp',
|
||||
'nsBidiKeyboard.cpp',
|
||||
'nsFilePicker.cpp',
|
||||
'nsWidgetFactory.cpp',
|
||||
|
|
Загрузка…
Ссылка в новой задаче