2004-09-08 01:21:48 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2013-02-16 07:55:36 +04:00
|
|
|
#include "mozilla/MathAlgorithms.h"
|
2013-09-25 15:21:19 +04:00
|
|
|
#include "mozilla/TextEvents.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2014-03-14 17:13:32 +04:00
|
|
|
#include "NativeKeyBindings.h"
|
2004-09-08 01:21:48 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsMemory.h"
|
|
|
|
#include "nsGtkKeyUtils.h"
|
|
|
|
|
2009-01-03 10:37:52 +03:00
|
|
|
#include <gtk/gtk.h>
|
2004-09-08 01:21:48 +04:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2009-01-03 10:37:52 +03:00
|
|
|
#include <gdk/gdk.h>
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2014-03-14 17:13:32 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2014-03-14 17:13:31 +04:00
|
|
|
static nsIWidget::DoCommandCallback gCurrentCallback;
|
2004-09-08 01:21:48 +04:00
|
|
|
static void *gCurrentCallbackData;
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gHandled;
|
2004-09-08 01:21:48 +04:00
|
|
|
|
|
|
|
// Common GtkEntry and GtkTextView signals
|
|
|
|
static void
|
|
|
|
copy_clipboard_cb(GtkWidget *w, gpointer user_data)
|
|
|
|
{
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandCopy, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
g_signal_stop_emission_by_name(w, "copy_clipboard");
|
2011-10-03 11:56:21 +04:00
|
|
|
gHandled = true;
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cut_clipboard_cb(GtkWidget *w, gpointer user_data)
|
|
|
|
{
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandCut, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
g_signal_stop_emission_by_name(w, "cut_clipboard");
|
2011-10-03 11:56:21 +04:00
|
|
|
gHandled = true;
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// GTK distinguishes between display lines (wrapped, as they appear on the
|
|
|
|
// screen) and paragraphs, which are runs of text terminated by a newline.
|
|
|
|
// We don't have this distinction, so we always use editor's notion of
|
|
|
|
// lines, which are newline-terminated.
|
|
|
|
|
2014-03-14 17:13:30 +04:00
|
|
|
static const Command sDeleteCommands[][2] = {
|
2004-09-08 01:21:48 +04:00
|
|
|
// backward, forward
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandDeleteCharBackward, CommandDeleteCharForward }, // CHARS
|
|
|
|
{ CommandDeleteWordBackward, CommandDeleteWordForward }, // WORD_ENDS
|
|
|
|
{ CommandDeleteWordBackward, CommandDeleteWordForward }, // WORDS
|
|
|
|
{ CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine }, // LINES
|
|
|
|
{ CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine }, // LINE_ENDS
|
|
|
|
{ CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine }, // PARAGRAPH_ENDS
|
|
|
|
{ CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine }, // PARAGRAPHS
|
2004-09-08 01:21:48 +04:00
|
|
|
// This deletes from the end of the previous word to the beginning of the
|
|
|
|
// next word, but only if the caret is not in a word.
|
|
|
|
// XXX need to implement in editor
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandDoNothing, CommandDoNothing } // WHITESPACE
|
2004-09-08 01:21:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
delete_from_cursor_cb(GtkWidget *w, GtkDeleteType del_type,
|
|
|
|
gint count, gpointer user_data)
|
|
|
|
{
|
|
|
|
g_signal_stop_emission_by_name(w, "delete_from_cursor");
|
2011-10-03 11:56:21 +04:00
|
|
|
gHandled = true;
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool forward = count > 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
if (uint32_t(del_type) >= ArrayLength(sDeleteCommands)) {
|
2004-09-08 01:21:48 +04:00
|
|
|
// unsupported deletion type
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (del_type == GTK_DELETE_WORDS) {
|
|
|
|
// This works like word_ends, except we first move the caret to the
|
|
|
|
// beginning/end of the current word.
|
|
|
|
if (forward) {
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandWordNext, gCurrentCallbackData);
|
|
|
|
gCurrentCallback(CommandWordPrevious, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
} else {
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandWordPrevious, gCurrentCallbackData);
|
|
|
|
gCurrentCallback(CommandWordNext, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
} else if (del_type == GTK_DELETE_DISPLAY_LINES ||
|
|
|
|
del_type == GTK_DELETE_PARAGRAPHS) {
|
|
|
|
|
|
|
|
// This works like display_line_ends, except we first move the caret to the
|
|
|
|
// beginning/end of the current line.
|
|
|
|
if (forward) {
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandBeginLine, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
} else {
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandEndLine, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:13:30 +04:00
|
|
|
Command command = sDeleteCommands[del_type][forward];
|
|
|
|
if (!command) {
|
2004-09-08 01:21:48 +04:00
|
|
|
return; // unsupported command
|
2014-03-14 17:13:30 +04:00
|
|
|
}
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2013-03-06 03:43:53 +04:00
|
|
|
unsigned int absCount = Abs(count);
|
|
|
|
for (unsigned int i = 0; i < absCount; ++i) {
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(command, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:13:30 +04:00
|
|
|
static const Command sMoveCommands[][2][2] = {
|
2004-09-08 01:21:48 +04:00
|
|
|
// non-extend { backward, forward }, extend { backward, forward }
|
|
|
|
// GTK differentiates between logical position, which is prev/next,
|
|
|
|
// and visual position, which is always left/right.
|
|
|
|
// We should fix this to work the same way for RTL text input.
|
|
|
|
{ // LOGICAL_POSITIONS
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandCharPrevious, CommandCharNext },
|
|
|
|
{ CommandSelectCharPrevious, CommandSelectCharNext }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // VISUAL_POSITIONS
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandCharPrevious, CommandCharNext },
|
|
|
|
{ CommandSelectCharPrevious, CommandSelectCharNext }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // WORDS
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandWordPrevious, CommandWordNext },
|
|
|
|
{ CommandSelectWordPrevious, CommandSelectWordNext }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // DISPLAY_LINES
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandLinePrevious, CommandLineNext },
|
|
|
|
{ CommandSelectLinePrevious, CommandSelectLineNext }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // DISPLAY_LINE_ENDS
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandBeginLine, CommandEndLine },
|
|
|
|
{ CommandSelectBeginLine, CommandSelectEndLine }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // PARAGRAPHS
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandLinePrevious, CommandLineNext },
|
|
|
|
{ CommandSelectLinePrevious, CommandSelectLineNext }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // PARAGRAPH_ENDS
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandBeginLine, CommandEndLine },
|
|
|
|
{ CommandSelectBeginLine, CommandSelectEndLine }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // PAGES
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandMovePageUp, CommandMovePageDown },
|
|
|
|
{ CommandSelectPageUp, CommandSelectPageDown }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // BUFFER_ENDS
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandMoveTop, CommandMoveBottom },
|
|
|
|
{ CommandSelectTop, CommandSelectBottom }
|
2004-09-08 01:21:48 +04:00
|
|
|
},
|
|
|
|
{ // HORIZONTAL_PAGES (unsupported)
|
2014-03-14 17:13:30 +04:00
|
|
|
{ CommandDoNothing, CommandDoNothing },
|
|
|
|
{ CommandDoNothing, CommandDoNothing }
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
move_cursor_cb(GtkWidget *w, GtkMovementStep step, gint count,
|
|
|
|
gboolean extend_selection, gpointer user_data)
|
|
|
|
{
|
|
|
|
g_signal_stop_emission_by_name(w, "move_cursor");
|
2011-10-03 11:56:21 +04:00
|
|
|
gHandled = true;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool forward = count > 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
if (uint32_t(step) >= ArrayLength(sMoveCommands)) {
|
2004-09-08 01:21:48 +04:00
|
|
|
// unsupported movement type
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:13:30 +04:00
|
|
|
Command command = sMoveCommands[step][extend_selection][forward];
|
|
|
|
if (!command) {
|
2004-09-08 01:21:48 +04:00
|
|
|
return; // unsupported command
|
2014-03-14 17:13:30 +04:00
|
|
|
}
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2013-03-06 03:43:53 +04:00
|
|
|
unsigned int absCount = Abs(count);
|
|
|
|
for (unsigned int i = 0; i < absCount; ++i) {
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(command, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paste_clipboard_cb(GtkWidget *w, gpointer user_data)
|
|
|
|
{
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandPaste, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
g_signal_stop_emission_by_name(w, "paste_clipboard");
|
2011-10-03 11:56:21 +04:00
|
|
|
gHandled = true;
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// GtkTextView-only signals
|
|
|
|
static void
|
|
|
|
select_all_cb(GtkWidget *w, gboolean select, gpointer user_data)
|
|
|
|
{
|
2014-03-14 17:13:30 +04:00
|
|
|
gCurrentCallback(CommandSelectAll, gCurrentCallbackData);
|
2004-09-08 01:21:48 +04:00
|
|
|
g_signal_stop_emission_by_name(w, "select_all");
|
2011-10-03 11:56:21 +04:00
|
|
|
gHandled = true;
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings* NativeKeyBindings::sInstanceForSingleLineEditor = nullptr;
|
|
|
|
NativeKeyBindings* NativeKeyBindings::sInstanceForMultiLineEditor = nullptr;
|
2014-03-14 17:13:31 +04:00
|
|
|
|
|
|
|
// static
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings*
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings::GetInstance(NativeKeyBindingsType aType)
|
2014-03-14 17:13:31 +04:00
|
|
|
{
|
|
|
|
switch (aType) {
|
|
|
|
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
|
|
|
if (!sInstanceForSingleLineEditor) {
|
2014-03-14 17:13:32 +04:00
|
|
|
sInstanceForSingleLineEditor = new NativeKeyBindings();
|
2014-03-14 17:13:31 +04:00
|
|
|
sInstanceForSingleLineEditor->Init(aType);
|
|
|
|
}
|
|
|
|
return sInstanceForSingleLineEditor;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// fallback to multiline editor case in release build
|
|
|
|
MOZ_ASSERT(false, "aType is invalid or not yet implemented");
|
|
|
|
case nsIWidget::NativeKeyBindingsForMultiLineEditor:
|
|
|
|
case nsIWidget::NativeKeyBindingsForRichTextEditor:
|
|
|
|
if (!sInstanceForMultiLineEditor) {
|
2014-03-14 17:13:32 +04:00
|
|
|
sInstanceForMultiLineEditor = new NativeKeyBindings();
|
2014-03-14 17:13:31 +04:00
|
|
|
sInstanceForMultiLineEditor->Init(aType);
|
|
|
|
}
|
|
|
|
return sInstanceForMultiLineEditor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings::Shutdown()
|
2014-03-14 17:13:31 +04:00
|
|
|
{
|
2014-03-14 17:13:32 +04:00
|
|
|
delete sInstanceForSingleLineEditor;
|
|
|
|
sInstanceForSingleLineEditor = nullptr;
|
|
|
|
delete sInstanceForMultiLineEditor;
|
|
|
|
sInstanceForMultiLineEditor = nullptr;
|
2014-03-14 17:13:31 +04:00
|
|
|
}
|
|
|
|
|
2004-09-08 01:21:48 +04:00
|
|
|
void
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings::Init(NativeKeyBindingsType aType)
|
2004-09-08 01:21:48 +04:00
|
|
|
{
|
|
|
|
switch (aType) {
|
2014-03-14 17:13:31 +04:00
|
|
|
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
2004-09-08 01:21:48 +04:00
|
|
|
mNativeTarget = gtk_entry_new();
|
|
|
|
break;
|
2014-03-14 17:13:31 +04:00
|
|
|
default:
|
2004-09-08 01:21:48 +04:00
|
|
|
mNativeTarget = gtk_text_view_new();
|
2004-10-14 00:35:06 +04:00
|
|
|
if (gtk_major_version > 2 ||
|
|
|
|
(gtk_major_version == 2 && (gtk_minor_version > 2 ||
|
|
|
|
(gtk_minor_version == 2 &&
|
|
|
|
gtk_micro_version >= 2)))) {
|
|
|
|
// select_all only exists in gtk >= 2.2.2. Prior to that,
|
|
|
|
// ctrl+a is bound to (move to beginning, select to end).
|
2011-05-11 17:10:36 +04:00
|
|
|
g_signal_connect(mNativeTarget, "select_all",
|
2004-10-14 00:35:06 +04:00
|
|
|
G_CALLBACK(select_all_cb), this);
|
|
|
|
}
|
2004-09-08 01:21:48 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-13 19:28:58 +04:00
|
|
|
g_object_ref_sink(mNativeTarget);
|
|
|
|
|
2011-05-11 17:10:36 +04:00
|
|
|
g_signal_connect(mNativeTarget, "copy_clipboard",
|
2004-09-08 01:21:48 +04:00
|
|
|
G_CALLBACK(copy_clipboard_cb), this);
|
2011-05-11 17:10:36 +04:00
|
|
|
g_signal_connect(mNativeTarget, "cut_clipboard",
|
2004-09-08 01:21:48 +04:00
|
|
|
G_CALLBACK(cut_clipboard_cb), this);
|
2011-05-11 17:10:36 +04:00
|
|
|
g_signal_connect(mNativeTarget, "delete_from_cursor",
|
2004-09-08 01:21:48 +04:00
|
|
|
G_CALLBACK(delete_from_cursor_cb), this);
|
2011-05-11 17:10:36 +04:00
|
|
|
g_signal_connect(mNativeTarget, "move_cursor",
|
2004-09-08 01:21:48 +04:00
|
|
|
G_CALLBACK(move_cursor_cb), this);
|
2011-05-11 17:10:36 +04:00
|
|
|
g_signal_connect(mNativeTarget, "paste_clipboard",
|
2004-09-08 01:21:48 +04:00
|
|
|
G_CALLBACK(paste_clipboard_cb), this);
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings::~NativeKeyBindings()
|
2004-09-08 01:21:48 +04:00
|
|
|
{
|
|
|
|
gtk_widget_destroy(mNativeTarget);
|
2009-04-13 19:28:58 +04:00
|
|
|
g_object_unref(mNativeTarget);
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings::Execute(const WidgetKeyboardEvent& aEvent,
|
|
|
|
DoCommandCallback aCallback,
|
|
|
|
void* aCallbackData)
|
2004-09-08 01:21:48 +04:00
|
|
|
{
|
2013-08-24 11:24:32 +04:00
|
|
|
// If the native key event is set, it must be synthesized for tests.
|
|
|
|
// We just ignore such events because this behavior depends on system
|
|
|
|
// settings.
|
2013-08-24 11:24:32 +04:00
|
|
|
if (!aEvent.mNativeKeyEvent) {
|
2013-08-24 11:24:32 +04:00
|
|
|
// It must be synthesized event or dispatched DOM event from chrome.
|
|
|
|
return false;
|
|
|
|
}
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2013-08-24 11:24:32 +04:00
|
|
|
guint keyval;
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2013-08-24 11:24:32 +04:00
|
|
|
if (aEvent.charCode) {
|
|
|
|
keyval = gdk_unicode_to_keyval(aEvent.charCode);
|
|
|
|
} else {
|
|
|
|
keyval =
|
2013-08-24 11:24:32 +04:00
|
|
|
static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->keyval;
|
2013-08-24 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
2014-03-14 17:13:32 +04:00
|
|
|
if (ExecuteInternal(aEvent, aCallback, aCallbackData, keyval)) {
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2013-08-24 11:24:32 +04:00
|
|
|
}
|
2008-04-15 08:16:24 +04:00
|
|
|
|
2013-08-24 11:24:32 +04:00
|
|
|
for (uint32_t i = 0; i < aEvent.alternativeCharCodes.Length(); ++i) {
|
|
|
|
uint32_t ch = aEvent.IsShift() ?
|
|
|
|
aEvent.alternativeCharCodes[i].mShiftedCharCode :
|
|
|
|
aEvent.alternativeCharCodes[i].mUnshiftedCharCode;
|
2008-04-15 08:16:24 +04:00
|
|
|
if (ch && ch != aEvent.charCode) {
|
2013-08-24 11:24:32 +04:00
|
|
|
keyval = gdk_unicode_to_keyval(ch);
|
2014-03-14 17:13:32 +04:00
|
|
|
if (ExecuteInternal(aEvent, aCallback, aCallbackData, keyval)) {
|
2011-10-03 11:56:21 +04:00
|
|
|
return true;
|
2013-08-24 11:24:32 +04:00
|
|
|
}
|
2008-04-15 08:16:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-24 11:24:32 +04:00
|
|
|
/*
|
|
|
|
gtk_bindings_activate_event is preferable, but it has unresolved bug:
|
|
|
|
http://bugzilla.gnome.org/show_bug.cgi?id=162726
|
|
|
|
The bug was already marked as FIXED. However, somebody reports that the
|
|
|
|
bug still exists.
|
|
|
|
Also gtk_bindings_activate may work with some non-shortcuts operations
|
|
|
|
(todo: check it). See bug 411005 and bug 406407.
|
|
|
|
|
|
|
|
Code, which should be used after fixing GNOME bug 162726:
|
|
|
|
|
|
|
|
gtk_bindings_activate_event(GTK_OBJECT(mNativeTarget),
|
|
|
|
static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent));
|
2008-04-15 08:16:24 +04:00
|
|
|
*/
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2008-04-15 08:16:24 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2014-03-14 17:13:32 +04:00
|
|
|
NativeKeyBindings::ExecuteInternal(const WidgetKeyboardEvent& aEvent,
|
|
|
|
DoCommandCallback aCallback,
|
|
|
|
void* aCallbackData,
|
|
|
|
guint aKeyval)
|
2008-04-15 08:16:24 +04:00
|
|
|
{
|
2013-08-24 11:24:32 +04:00
|
|
|
guint modifiers =
|
2013-08-24 11:24:32 +04:00
|
|
|
static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->state;
|
2004-09-08 01:21:48 +04:00
|
|
|
|
|
|
|
gCurrentCallback = aCallback;
|
|
|
|
gCurrentCallbackData = aCallbackData;
|
|
|
|
|
2011-10-03 11:56:21 +04:00
|
|
|
gHandled = false;
|
2012-09-14 05:56:59 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2008-02-10 09:34:46 +03:00
|
|
|
gtk_bindings_activate(GTK_OBJECT(mNativeTarget),
|
2013-08-24 11:24:32 +04:00
|
|
|
aKeyval, GdkModifierType(modifiers));
|
2012-09-14 05:56:59 +04:00
|
|
|
#else
|
|
|
|
gtk_bindings_activate(G_OBJECT(mNativeTarget),
|
2013-08-24 11:24:32 +04:00
|
|
|
aKeyval, GdkModifierType(modifiers));
|
2012-09-14 05:56:59 +04:00
|
|
|
#endif
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
gCurrentCallback = nullptr;
|
|
|
|
gCurrentCallbackData = nullptr;
|
2004-09-08 01:21:48 +04:00
|
|
|
|
2005-05-01 13:44:41 +04:00
|
|
|
return gHandled;
|
2004-09-08 01:21:48 +04:00
|
|
|
}
|
2014-03-14 17:13:32 +04:00
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|