mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 977959 part.4 Remove nsINativeKeyBindings r=roc+karlt
--HG-- rename : widget/gtk/nsNativeKeyBindings.cpp => widget/gtk/NativeKeyBindings.cpp rename : widget/gtk/nsNativeKeyBindings.h => widget/gtk/NativeKeyBindings.h
This commit is contained in:
parent
f2734aa16b
commit
8626bd713a
@ -3,31 +3,14 @@
|
||||
* 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 NativeKeyBindings_h_
|
||||
#define NativeKeyBindings_h_
|
||||
|
||||
#include "nsINativeKeyBindings.h"
|
||||
#include "nsIWidget.h"
|
||||
#ifndef mozilla_widget_NativeKeyBindings_h_
|
||||
#define mozilla_widget_NativeKeyBindings_h_
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "nsDataHashtable.h"
|
||||
|
||||
// 8477f934-febf-4c79-b7fe-bb7f9ebb9b4f
|
||||
#define NS_NATIVEKEYBINDINGS_INPUT_CID \
|
||||
{ 0x8477f934, 0xfebf, 0x4c79, \
|
||||
{ 0xb7, 0xfe, 0xbb, 0x7f, 0x9e, 0xbb, 0x9b, 0x4f } }
|
||||
|
||||
// 13a6e56f-f00b-4e19-8cf6-1a51ee7cc4bf
|
||||
#define NS_NATIVEKEYBINDINGS_TEXTAREA_CID \
|
||||
{ 0x13a6e56f, 0xf00b, 0x4e19, \
|
||||
{ 0x8c, 0xf6, 0x1a, 0x51, 0xee, 0x7c, 0xc4, 0xbf } }
|
||||
|
||||
// 36bfbd29-4e02-40f4-8fff-094f1a9ec97c
|
||||
#define NS_NATIVEKEYBINDINGS_EDITOR_CID \
|
||||
{ 0x36bfbd29, 0x4e02, 0x40f4, \
|
||||
{ 0x8f, 0xff, 0x09, 0x4f, 0x1a, 0x9e, 0xc9, 0x7c } }
|
||||
#include "nsIWidget.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
@ -35,28 +18,27 @@ namespace widget {
|
||||
typedef nsDataHashtable<nsPtrHashKey<struct objc_selector>, CommandInt>
|
||||
SelectorCommandHashtable;
|
||||
|
||||
class NativeKeyBindings MOZ_FINAL : public nsINativeKeyBindings
|
||||
class NativeKeyBindings MOZ_FINAL
|
||||
{
|
||||
typedef nsIWidget::NativeKeyBindingsType NativeKeyBindingsType;
|
||||
typedef nsIWidget::DoCommandCallback DoCommandCallback;
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(NativeKeyBindings)
|
||||
|
||||
public:
|
||||
static already_AddRefed<NativeKeyBindings>
|
||||
GetInstance(NativeKeyBindingsType aType);
|
||||
static void Shutdown();
|
||||
|
||||
NativeKeyBindings();
|
||||
void Init(NativeKeyBindingsType aType);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(NativeKeyBindingsType aType);
|
||||
|
||||
// nsINativeKeyBindings
|
||||
NS_IMETHOD_(bool) KeyPress(const WidgetKeyboardEvent& aEvent,
|
||||
bool Execute(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData);
|
||||
|
||||
private:
|
||||
NativeKeyBindings();
|
||||
|
||||
SelectorCommandHashtable mSelectorToCommand;
|
||||
|
||||
static NativeKeyBindings* sInstanceForSingleLineEditor;
|
||||
@ -66,4 +48,4 @@ private:
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* NativeKeyBindings_h_ */
|
||||
#endif // mozilla_widget_NativeKeyBindings_h_
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include "prlog.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* gNativeKeyBindingsLog = nullptr;
|
||||
@ -62,7 +62,7 @@ NativeKeyBindings::NativeKeyBindings()
|
||||
mSelectorToCommand.Put( \
|
||||
reinterpret_cast<struct objc_selector *>(@selector(aSel)), aCommand)
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
NativeKeyBindings::Init(NativeKeyBindingsType aType)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
@ -198,17 +198,14 @@ NativeKeyBindings::Init(NativeKeyBindingsType aType)
|
||||
// SEL_TO_COMMAND(transposeWords:, );
|
||||
// SEL_TO_COMMAND(uppercaseWord:, );
|
||||
// SEL_TO_COMMAND(yank:, );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#undef SEL_TO_COMMAND
|
||||
|
||||
NS_IMPL_ISUPPORTS1(NativeKeyBindings, nsINativeKeyBindings)
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
NativeKeyBindings::KeyPress(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback, void* aCallbackData)
|
||||
bool
|
||||
NativeKeyBindings::Execute(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData)
|
||||
{
|
||||
PR_LOG(gNativeKeyBindingsLog, PR_LOG_ALWAYS,
|
||||
("%p NativeKeyBindings::KeyPress", this));
|
||||
@ -296,3 +293,6 @@ NativeKeyBindings::KeyPress(const WidgetKeyboardEvent& aEvent,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
@ -1971,7 +1971,7 @@ nsChildView::ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
|
||||
{
|
||||
nsRefPtr<NativeKeyBindings> keyBindings =
|
||||
NativeKeyBindings::GetInstance(aType);
|
||||
return keyBindings->KeyPress(aEvent, aCallback, aCallbackData);
|
||||
return keyBindings->Execute(aEvent, aCallback, aCallbackData);
|
||||
}
|
||||
|
||||
nsIMEUpdatePreference
|
||||
|
@ -2172,7 +2172,7 @@ nsCocoaWindow::ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
|
||||
{
|
||||
nsRefPtr<NativeKeyBindings> keyBindings =
|
||||
NativeKeyBindings::GetInstance(aType);
|
||||
return keyBindings->KeyPress(aEvent, aCallback, aCallbackData);
|
||||
return keyBindings->Execute(aEvent, aCallback, aCallbackData);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "nsSound.h"
|
||||
#include "nsIdleServiceX.h"
|
||||
#include "NativeKeyBindings.h"
|
||||
#include "OSXNotificationCenter.h"
|
||||
|
||||
#include "nsScreenManagerCocoa.h"
|
||||
@ -40,6 +41,7 @@
|
||||
#include "mozilla/Module.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
|
||||
@ -85,40 +87,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
|
||||
}
|
||||
}
|
||||
|
||||
#include "NativeKeyBindings.h"
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
static nsresult
|
||||
NativeKeyBindingsInputConstructor(nsISupports* aOuter, REFNSIID aIID,
|
||||
void** aResult)
|
||||
{
|
||||
*aResult = NativeKeyBindings::GetInstance(
|
||||
nsIWidget::NativeKeyBindingsForSingleLineEditor).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
NativeKeyBindingsTextAreaConstructor(nsISupports* aOuter, REFNSIID aIID,
|
||||
void** aResult)
|
||||
{
|
||||
*aResult = NativeKeyBindings::GetInstance(
|
||||
nsIWidget::NativeKeyBindingsForMultiLineEditor).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
NativeKeyBindingsEditorConstructor(nsISupports* aOuter, REFNSIID aIID,
|
||||
void** aResult)
|
||||
{
|
||||
*aResult = NativeKeyBindings::GetInstance(
|
||||
nsIWidget::NativeKeyBindingsForRichTextEditor).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_POPUP_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_CHILD_CID);
|
||||
@ -145,10 +113,6 @@ NS_DEFINE_NAMED_CID(NS_MACDOCKSUPPORT_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_MACWEBAPPUTILS_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_STANDALONENATIVEMENU_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGS_INPUT_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGS_TEXTAREA_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGS_EDITOR_CID);
|
||||
|
||||
|
||||
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
||||
{ &kNS_WINDOW_CID, false, NULL, nsCocoaWindowConstructor },
|
||||
@ -185,12 +149,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
||||
{ &kNS_MACWEBAPPUTILS_CID, false, NULL, nsMacWebAppUtilsConstructor },
|
||||
{ &kNS_STANDALONENATIVEMENU_CID, false, NULL, nsStandaloneNativeMenuConstructor },
|
||||
{ &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
|
||||
{ &kNS_NATIVEKEYBINDINGS_INPUT_CID, false, NULL,
|
||||
mozilla::widget::NativeKeyBindingsInputConstructor },
|
||||
{ &kNS_NATIVEKEYBINDINGS_TEXTAREA_CID, false, NULL,
|
||||
mozilla::widget::NativeKeyBindingsTextAreaConstructor },
|
||||
{ &kNS_NATIVEKEYBINDINGS_EDITOR_CID, false, NULL,
|
||||
mozilla::widget::NativeKeyBindingsEditorConstructor },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -229,17 +187,13 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
||||
{ "@mozilla.org/widget/mac-web-app-utils;1", &kNS_MACWEBAPPUTILS_CID },
|
||||
{ "@mozilla.org/widget/standalonenativemenu;1", &kNS_STANDALONENATIVEMENU_CID },
|
||||
{ "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
|
||||
{ NS_NATIVEKEYBINDINGSINPUT_CONTRACTID, &kNS_NATIVEKEYBINDINGS_INPUT_CID },
|
||||
{ NS_NATIVEKEYBINDINGSTEXTAREA_CONTRACTID,
|
||||
&kNS_NATIVEKEYBINDINGS_TEXTAREA_CID },
|
||||
{ NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID, &kNS_NATIVEKEYBINDINGS_EDITOR_CID },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
nsWidgetCocoaModuleDtor()
|
||||
{
|
||||
mozilla::widget::NativeKeyBindings::Shutdown();
|
||||
NativeKeyBindings::Shutdown();
|
||||
nsLookAndFeel::Shutdown();
|
||||
nsToolkit::Shutdown();
|
||||
nsAppShellShutdown();
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
||||
#include "nsNativeKeyBindings.h"
|
||||
#include "NativeKeyBindings.h"
|
||||
#include "nsString.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsGtkKeyUtils.h"
|
||||
@ -16,13 +16,8 @@
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
// X.h defines KeyPress
|
||||
#ifdef KeyPress
|
||||
#undef KeyPress
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
static nsIWidget::DoCommandCallback gCurrentCallback;
|
||||
static void *gCurrentCallbackData;
|
||||
@ -198,19 +193,17 @@ select_all_cb(GtkWidget *w, gboolean select, gpointer user_data)
|
||||
gHandled = true;
|
||||
}
|
||||
|
||||
nsNativeKeyBindings*
|
||||
nsNativeKeyBindings::sInstanceForSingleLineEditor = nullptr;
|
||||
nsNativeKeyBindings*
|
||||
nsNativeKeyBindings::sInstanceForMultiLineEditor = nullptr;
|
||||
NativeKeyBindings* NativeKeyBindings::sInstanceForSingleLineEditor = nullptr;
|
||||
NativeKeyBindings* NativeKeyBindings::sInstanceForMultiLineEditor = nullptr;
|
||||
|
||||
// static
|
||||
already_AddRefed<nsNativeKeyBindings>
|
||||
nsNativeKeyBindings::GetInstance(NativeKeyBindingsType aType)
|
||||
already_AddRefed<NativeKeyBindings>
|
||||
NativeKeyBindings::GetInstance(NativeKeyBindingsType aType)
|
||||
{
|
||||
switch (aType) {
|
||||
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
||||
if (!sInstanceForSingleLineEditor) {
|
||||
NS_ADDREF(sInstanceForSingleLineEditor = new nsNativeKeyBindings());
|
||||
NS_ADDREF(sInstanceForSingleLineEditor = new NativeKeyBindings());
|
||||
sInstanceForSingleLineEditor->Init(aType);
|
||||
}
|
||||
NS_ADDREF(sInstanceForSingleLineEditor);
|
||||
@ -222,7 +215,7 @@ nsNativeKeyBindings::GetInstance(NativeKeyBindingsType aType)
|
||||
case nsIWidget::NativeKeyBindingsForMultiLineEditor:
|
||||
case nsIWidget::NativeKeyBindingsForRichTextEditor:
|
||||
if (!sInstanceForMultiLineEditor) {
|
||||
NS_ADDREF(sInstanceForMultiLineEditor = new nsNativeKeyBindings());
|
||||
NS_ADDREF(sInstanceForMultiLineEditor = new NativeKeyBindings());
|
||||
sInstanceForMultiLineEditor->Init(aType);
|
||||
}
|
||||
NS_ADDREF(sInstanceForMultiLineEditor);
|
||||
@ -232,14 +225,14 @@ nsNativeKeyBindings::GetInstance(NativeKeyBindingsType aType)
|
||||
|
||||
// static
|
||||
void
|
||||
nsNativeKeyBindings::Shutdown()
|
||||
NativeKeyBindings::Shutdown()
|
||||
{
|
||||
NS_IF_RELEASE(sInstanceForSingleLineEditor);
|
||||
NS_IF_RELEASE(sInstanceForMultiLineEditor);
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeKeyBindings::Init(NativeKeyBindingsType aType)
|
||||
NativeKeyBindings::Init(NativeKeyBindingsType aType)
|
||||
{
|
||||
switch (aType) {
|
||||
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
||||
@ -273,17 +266,16 @@ nsNativeKeyBindings::Init(NativeKeyBindingsType aType)
|
||||
G_CALLBACK(paste_clipboard_cb), this);
|
||||
}
|
||||
|
||||
nsNativeKeyBindings::~nsNativeKeyBindings()
|
||||
NativeKeyBindings::~NativeKeyBindings()
|
||||
{
|
||||
gtk_widget_destroy(mNativeTarget);
|
||||
g_object_unref(mNativeTarget);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsNativeKeyBindings, nsINativeKeyBindings)
|
||||
|
||||
bool
|
||||
nsNativeKeyBindings::KeyPress(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback, void *aCallbackData)
|
||||
NativeKeyBindings::Execute(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData)
|
||||
{
|
||||
// If the native key event is set, it must be synthesized for tests.
|
||||
// We just ignore such events because this behavior depends on system
|
||||
@ -302,7 +294,7 @@ nsNativeKeyBindings::KeyPress(const WidgetKeyboardEvent& aEvent,
|
||||
static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->keyval;
|
||||
}
|
||||
|
||||
if (KeyPressInternal(aEvent, aCallback, aCallbackData, keyval)) {
|
||||
if (ExecuteInternal(aEvent, aCallback, aCallbackData, keyval)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -312,7 +304,7 @@ nsNativeKeyBindings::KeyPress(const WidgetKeyboardEvent& aEvent,
|
||||
aEvent.alternativeCharCodes[i].mUnshiftedCharCode;
|
||||
if (ch && ch != aEvent.charCode) {
|
||||
keyval = gdk_unicode_to_keyval(ch);
|
||||
if (KeyPressInternal(aEvent, aCallback, aCallbackData, keyval)) {
|
||||
if (ExecuteInternal(aEvent, aCallback, aCallbackData, keyval)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -336,9 +328,9 @@ Code, which should be used after fixing GNOME bug 162726:
|
||||
}
|
||||
|
||||
bool
|
||||
nsNativeKeyBindings::KeyPressInternal(const WidgetKeyboardEvent& aEvent,
|
||||
NativeKeyBindings::ExecuteInternal(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void *aCallbackData,
|
||||
void* aCallbackData,
|
||||
guint aKeyval)
|
||||
{
|
||||
guint modifiers =
|
||||
@ -361,3 +353,6 @@ nsNativeKeyBindings::KeyPressInternal(const WidgetKeyboardEvent& aEvent,
|
||||
|
||||
return gHandled;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
52
widget/gtk/NativeKeyBindings.h
Normal file
52
widget/gtk/NativeKeyBindings.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 mozilla_widget_NativeKeyBindings_h_
|
||||
#define mozilla_widget_NativeKeyBindings_h_
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
class NativeKeyBindings MOZ_FINAL
|
||||
{
|
||||
typedef nsIWidget::NativeKeyBindingsType NativeKeyBindingsType;
|
||||
typedef nsIWidget::DoCommandCallback DoCommandCallback;
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(NativeKeyBindings)
|
||||
|
||||
public:
|
||||
static already_AddRefed<NativeKeyBindings>
|
||||
GetInstance(NativeKeyBindingsType aType);
|
||||
static void Shutdown();
|
||||
|
||||
void Init(NativeKeyBindingsType aType);
|
||||
|
||||
bool Execute(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData);
|
||||
|
||||
private:
|
||||
~NativeKeyBindings();
|
||||
|
||||
bool ExecuteInternal(const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData,
|
||||
guint aKeyval);
|
||||
|
||||
GtkWidget* mNativeTarget;
|
||||
|
||||
static NativeKeyBindings* sInstanceForSingleLineEditor;
|
||||
static NativeKeyBindings* sInstanceForMultiLineEditor;
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_widget_NativeKeyBindings_h_
|
@ -17,13 +17,13 @@ EXPORTS += [
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'mozcontainer.c',
|
||||
'NativeKeyBindings.cpp',
|
||||
'nsBidiKeyboard.cpp',
|
||||
'nsColorPicker.cpp',
|
||||
'nsFilePicker.cpp',
|
||||
'nsGtkKeyUtils.cpp',
|
||||
'nsImageToPixbuf.cpp',
|
||||
'nsLookAndFeel.cpp',
|
||||
'nsNativeKeyBindings.cpp',
|
||||
'nsNativeThemeGTK.cpp',
|
||||
'nsScreenGtk.cpp',
|
||||
'nsScreenManagerGtk.cpp',
|
||||
|
@ -1,61 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 nsNativeKeyBindings_h_
|
||||
#define nsNativeKeyBindings_h_
|
||||
|
||||
// X.h defines KeyPress
|
||||
#ifdef KeyPress
|
||||
#undef KeyPress
|
||||
#endif
|
||||
|
||||
#include "nsINativeKeyBindings.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define NS_NATIVEKEYBINDINGSINPUT_CID \
|
||||
{0x5c337258, 0xa580, 0x472e, {0x86, 0x15, 0xf2, 0x77, 0xdd, 0xc5, 0xbb, 0x06}}
|
||||
|
||||
#define NS_NATIVEKEYBINDINGSTEXTAREA_CID \
|
||||
{0x2a898043, 0x180f, 0x4c8b, {0x8e, 0x54, 0x41, 0x0c, 0x7a, 0x54, 0x0f, 0x27}}
|
||||
|
||||
#define NS_NATIVEKEYBINDINGSEDITOR_CID \
|
||||
{0xf916ebfb, 0x78ef, 0x464b, {0x94, 0xd0, 0xa6, 0xf2, 0xca, 0x32, 0x00, 0xae}}
|
||||
|
||||
class nsNativeKeyBindings MOZ_FINAL : public nsINativeKeyBindings
|
||||
{
|
||||
typedef nsIWidget::NativeKeyBindingsType NativeKeyBindingsType;
|
||||
typedef nsIWidget::DoCommandCallback DoCommandCallback;
|
||||
|
||||
public:
|
||||
static already_AddRefed<nsNativeKeyBindings>
|
||||
GetInstance(NativeKeyBindingsType aType);
|
||||
static void Shutdown();
|
||||
|
||||
NS_HIDDEN_(void) Init(NativeKeyBindingsType aType);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsINativeKeyBindings
|
||||
virtual NS_HIDDEN_(bool) KeyPress(const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void *aCallbackData);
|
||||
|
||||
private:
|
||||
~nsNativeKeyBindings() NS_HIDDEN;
|
||||
|
||||
bool KeyPressInternal(const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void *aCallbackData,
|
||||
guint aKeyval);
|
||||
|
||||
GtkWidget *mNativeTarget;
|
||||
|
||||
static nsNativeKeyBindings* sInstanceForSingleLineEditor;
|
||||
static nsNativeKeyBindings* sInstanceForMultiLineEditor;
|
||||
};
|
||||
|
||||
#endif
|
@ -6,6 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
#include "NativeKeyBindings.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsAppShell.h"
|
||||
#include "nsAppShellSingleton.h"
|
||||
@ -23,7 +24,6 @@
|
||||
#include "nsFilePicker.h"
|
||||
#include "nsSound.h"
|
||||
#include "nsBidiKeyboard.h"
|
||||
#include "nsNativeKeyBindings.h"
|
||||
#include "nsScreenManagerGtk.h"
|
||||
#include "nsGTKToolkit.h"
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
/* from nsFilePicker.js */
|
||||
#define XULFILEPICKER_CID \
|
||||
@ -167,24 +168,6 @@ nsColorPickerConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
return picker->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsNativeKeyBindingsInputConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
*aResult = nsNativeKeyBindings::GetInstance(
|
||||
nsIWidget::NativeKeyBindingsForSingleLineEditor).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsNativeKeyBindingsTextAreaConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
*aResult = nsNativeKeyBindings::GetInstance(
|
||||
nsIWidget::NativeKeyBindingsForMultiLineEditor).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_CHILD_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
|
||||
@ -199,9 +182,6 @@ NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
|
||||
#endif
|
||||
NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGSINPUT_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGSTEXTAREA_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NATIVEKEYBINDINGSEDITOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_THEMERENDERER_CID);
|
||||
#ifdef NS_PRINTING
|
||||
@ -233,9 +213,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
||||
#endif
|
||||
{ &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor },
|
||||
{ &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor },
|
||||
{ &kNS_NATIVEKEYBINDINGSINPUT_CID, false, nullptr, nsNativeKeyBindingsInputConstructor },
|
||||
{ &kNS_NATIVEKEYBINDINGSTEXTAREA_CID, false, nullptr, nsNativeKeyBindingsTextAreaConstructor },
|
||||
{ &kNS_NATIVEKEYBINDINGSEDITOR_CID, false, nullptr, nsNativeKeyBindingsTextAreaConstructor },
|
||||
{ &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerGtkConstructor },
|
||||
{ &kNS_THEMERENDERER_CID, false, nullptr, nsNativeThemeGTKConstructor },
|
||||
#ifdef NS_PRINTING
|
||||
@ -272,9 +249,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
||||
#endif
|
||||
{ "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
|
||||
{ "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
|
||||
{ NS_NATIVEKEYBINDINGSINPUT_CONTRACTID, &kNS_NATIVEKEYBINDINGSINPUT_CID },
|
||||
{ NS_NATIVEKEYBINDINGSTEXTAREA_CONTRACTID, &kNS_NATIVEKEYBINDINGSTEXTAREA_CID },
|
||||
{ NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID, &kNS_NATIVEKEYBINDINGSEDITOR_CID },
|
||||
{ "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
|
||||
{ "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
|
||||
#ifdef NS_PRINTING
|
||||
@ -299,7 +273,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
||||
static void
|
||||
nsWidgetGtk2ModuleDtor()
|
||||
{
|
||||
nsNativeKeyBindings::Shutdown();
|
||||
NativeKeyBindings::Shutdown();
|
||||
nsLookAndFeel::Shutdown();
|
||||
nsFilePicker::Shutdown();
|
||||
nsSound::Shutdown();
|
||||
|
@ -119,7 +119,7 @@ extern "C" {
|
||||
|
||||
#include "nsIDOMWheelEvent.h"
|
||||
|
||||
#include "nsNativeKeyBindings.h"
|
||||
#include "NativeKeyBindings.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -5980,9 +5980,9 @@ nsWindow::ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData)
|
||||
{
|
||||
nsRefPtr<nsNativeKeyBindings> keyBindings =
|
||||
nsNativeKeyBindings::GetInstance(aType);
|
||||
return keyBindings->KeyPress(aEvent, aCallback, aCallbackData);
|
||||
nsRefPtr<NativeKeyBindings> keyBindings =
|
||||
NativeKeyBindings::GetInstance(aType);
|
||||
return keyBindings->Execute(aEvent, aCallback, aCallbackData);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -95,7 +95,6 @@ XPIDL_MODULE = 'widget'
|
||||
EXPORTS += [
|
||||
'InputData.h',
|
||||
'nsIDeviceContextSpec.h',
|
||||
'nsINativeKeyBindings.h',
|
||||
'nsIPluginWidget.h',
|
||||
'nsIRollupListener.h',
|
||||
'nsIWidget.h',
|
||||
|
@ -1,41 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 nsINativeKeyBindings_h_
|
||||
#define nsINativeKeyBindings_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
|
||||
#define NS_INATIVEKEYBINDINGS_IID \
|
||||
{ 0x98290677, 0xfdac, 0x414a, \
|
||||
{ 0x81, 0x5c, 0x20, 0xe2, 0xd4, 0xcd, 0x8c, 0x47 } }
|
||||
|
||||
#define NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX \
|
||||
"@mozilla.org/widget/native-key-bindings;1?type="
|
||||
|
||||
#define NS_NATIVEKEYBINDINGSINPUT_CONTRACTID \
|
||||
NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "input"
|
||||
|
||||
#define NS_NATIVEKEYBINDINGSTEXTAREA_CONTRACTID \
|
||||
NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "textarea"
|
||||
|
||||
#define NS_NATIVEKEYBINDINGSEDITOR_CONTRACTID \
|
||||
NS_NATIVEKEYBINDINGS_CONTRACTID_PREFIX "editor"
|
||||
|
||||
class nsINativeKeyBindings : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INATIVEKEYBINDINGS_IID)
|
||||
|
||||
virtual NS_HIDDEN_(bool) KeyPress(const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
nsIWidget::DoCommandCallback aCallback,
|
||||
void *aCallbackData) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsINativeKeyBindings, NS_INATIVEKEYBINDINGS_IID)
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user