aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/EventContext.cpp19
-rw-r--r--embed/mozilla/mozilla-embed.cpp67
2 files changed, 57 insertions, 29 deletions
diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp
index 229f8d3be..5d8e30075 100644
--- a/embed/mozilla/EventContext.cpp
+++ b/embed/mozilla/EventContext.cpp
@@ -525,7 +525,22 @@ nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, EphyEmb
/* casting 32-bit guint* to PRUint16* below will break on big-endian */
PRUint16 btn;
aMouseEvent->GetButton (&btn);
- info->mouse_button = (guint)btn;
+
+ switch (btn)
+ {
+ case 0:
+ info->type = EPHY_EMBED_EVENT_MOUSE_BUTTON1;
+ break;
+ case 1:
+ info->type = EPHY_EMBED_EVENT_MOUSE_BUTTON2;
+ break;
+ case 2:
+ info->type = EPHY_EMBED_EVENT_MOUSE_BUTTON3;
+ break;
+
+ default:
+ g_warning ("Unknown mouse button");
+ }
/* OTOH, casting only between (un)signedness is safe */
aMouseEvent->GetScreenX ((PRInt32*)&info->x);
@@ -590,6 +605,8 @@ nsresult EventContext::GetKeyEventInfo (nsIDOMKeyEvent *aKeyEvent, EphyEmbedEven
{
nsresult rv;
+ info->type = EPHY_EMBED_EVENT_KEY;
+
PRUint32 keyCode;
rv = aKeyEvent->GetKeyCode(&keyCode);
if (NS_FAILED(rv)) return rv;
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 95dd0190e..0e69d58fb 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -1334,12 +1334,6 @@ mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed, gpointer dom_event,
gboolean ret = FALSE;
- // Just check for Shift-F10 so that we know to popup the context menu.
- //
- // The DOM_VK_* keycodes are not compatible with the keycodes defined
- // in GDK, so making a generic dom_key_down signal is probably not
- // worth the trouble.
-
nsresult rv;
EventContext ctx;
ctx.Init (wrapper);
@@ -1348,8 +1342,8 @@ mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed, gpointer dom_event,
(info->keycode == nsIDOMKeyEvent::DOM_VK_F10 &&
info->modifier == GDK_SHIFT_MASK))
{
- // Translate relative coordinates to absolute values, and try
- // to avoid covering links by adding a little offset.
+ /* Translate relative coordinates to absolute values, and try
+ to avoid covering links by adding a little offset. */
int x, y;
gdk_window_get_origin (GTK_WIDGET(membed)->window, &x, &y);
@@ -1381,9 +1375,8 @@ mozilla_embed_destroy_brsr_cb (GtkMozEmbed *embed,
}
static gint
-mozilla_embed_emit_mouse_signal (MozillaEmbed *membed,
- gpointer dom_event,
- const char *signal_name)
+mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event,
+ MozillaEmbed *membed)
{
EphyEmbedEvent *info;
EventContext event_context;
@@ -1398,6 +1391,7 @@ mozilla_embed_emit_mouse_signal (MozillaEmbed *membed,
event_context.Init (wrapper);
result = event_context.GetMouseEventInfo (static_cast<nsIDOMMouseEvent*>(dom_event), info);
+
if (NS_SUCCEEDED(result))
{
nsCOMPtr<nsIDOMDocument> domDoc;
@@ -1407,7 +1401,7 @@ mozilla_embed_emit_mouse_signal (MozillaEmbed *membed,
result = wrapper->PushTargetDocument (domDoc);
if (NS_SUCCEEDED(result))
{
- g_signal_emit_by_name (membed, signal_name,
+ g_signal_emit_by_name (membed, "ge_dom_mouse_click",
info, &return_value);
wrapper->PopTargetDocument ();
}
@@ -1416,34 +1410,51 @@ mozilla_embed_emit_mouse_signal (MozillaEmbed *membed,
}
g_object_unref (info);
-
- return return_value;
-}
-static gint
-mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event,
- MozillaEmbed *membed)
-{
- return mozilla_embed_emit_mouse_signal
- (membed, dom_event, "ge_dom_mouse_click");
+ return return_value;
}
static gint
mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event,
MozillaEmbed *membed)
{
- int ret;
+ EphyEmbedEvent *info;
+ EventContext event_context;
+ gint return_value = 0;
+ EphyWrapper *wrapper;
+ nsresult result;
+ EphyEmbedEventType type;
- ret = mozilla_embed_emit_mouse_signal
- (membed, dom_event, "ge_dom_mouse_down");
+ info = ephy_embed_event_new ();
+
+ wrapper = MOZILLA_EMBED(membed)->priv->wrapper;
+ g_return_val_if_fail (wrapper != NULL, G_FAILED);
+
+ event_context.Init (wrapper);
+ result = event_context.GetMouseEventInfo (static_cast<nsIDOMMouseEvent*>(dom_event), info);
- if (!ret)
+ ephy_embed_event_get_event_type (info, &type);
+
+ if (NS_SUCCEEDED(result) && (type == EPHY_EMBED_EVENT_MOUSE_BUTTON3))
{
- ret = mozilla_embed_emit_mouse_signal
- (membed, dom_event, "ge_context_menu");
+ nsCOMPtr<nsIDOMDocument> domDoc;
+ result = event_context.GetTargetDocument (getter_AddRefs(domDoc));
+ if (NS_SUCCEEDED(result))
+ {
+ result = wrapper->PushTargetDocument (domDoc);
+ if (NS_SUCCEEDED(result))
+ {
+ g_signal_emit_by_name (membed, "ge_context_menu",
+ info, &return_value);
+ wrapper->PopTargetDocument ();
+ }
+ }
+
}
- return ret;
+ g_object_unref (info);
+
+ return return_value;
}
static void