aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cvsignore2
-rw-r--r--ChangeLog34
-rw-r--r--configure.ac17
-rw-r--r--embed/ephy-embed-event.c12
-rw-r--r--embed/ephy-embed-event.h14
-rw-r--r--embed/mozilla/EphyBrowser.cpp113
-rw-r--r--embed/mozilla/EphyBrowser.h22
-rw-r--r--embed/mozilla/EventContext.cpp94
-rw-r--r--embed/mozilla/EventContext.h2
-rw-r--r--embed/mozilla/mozilla-embed-event.cpp20
-rw-r--r--embed/mozilla/mozilla-embed-event.h12
-rw-r--r--embed/mozilla/mozilla-embed.cpp92
-rw-r--r--src/ephy-tab.c13
-rw-r--r--src/ephy-window.c16
14 files changed, 290 insertions, 173 deletions
diff --git a/.cvsignore b/.cvsignore
index 450d6694b..976d09899 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -22,3 +22,5 @@ gtk-doc.make
install-sh
missing
build
+INSTALL
+
diff --git a/ChangeLog b/ChangeLog
index a1d3b6d1b..14d2b27a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,39 @@
2005-01-23 Christian Persch <chpe@cvs.gnome.org>
+ * configure.ac:
+
+ Check for broken context event button.
+
+ * embed/ephy-embed-event.c: (ephy_embed_event_get_context),
+ (ephy_embed_event_get_button):
+ * embed/ephy-embed-event.h:
+ * embed/mozilla/mozilla-embed-event.cpp:
+ * embed/mozilla/mozilla-embed-event.h:
+
+ Change get_type to get_button, and don't store a nsCOMPtr in .priv.
+
+ * src/ephy-tab.c: (ephy_tab_dom_mouse_click_cb):
+ * src/ephy-window.c: (show_embed_popup), (tab_context_menu_cb),
+ (ephy_window_set_active_tab):
+
+ Adapted for above change.
+
+ * embed/mozilla/EphyBrowser.cpp:
+ * embed/mozilla/EphyBrowser.h:
+
+ Attach listener to oncontextmenu event.
+
+ * embed/mozilla/EventContext.cpp:
+ * embed/mozilla/EventContext.h:
+
+ Get event target coordinates also for 'mouse' context events.
+
+ * embed/mozilla/mozilla-embed.cpp:
+
+ Remove key-down handler, and context code from mouse-down handler.
+
+2005-01-23 Christian Persch <chpe@cvs.gnome.org>
+
* data/default-prefs-common.js:
* data/default-prefs-toolkit.js:
diff --git a/configure.ac b/configure.ac
index db8e1106d..6124780be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -429,6 +429,23 @@ fi
AC_MSG_RESULT([$broken_reload])
+dnl check for broken contextmenu event
+dnl This is fixed since 1.8a4
+dnl https://bugzilla.mozilla.org/show_bug.cgi?id=258193
+
+AC_MSG_CHECKING([for broken context menu event])
+
+if $PKG_CONFIG --atleast-version 1.8 $MOZILLA-gtkmozembed; then
+ broken_context_event=no
+else
+ broken_context_event="couldn't autodetect, assuming yes"
+ AC_DEFINE([MOZ_BROKEN_CTX_MENU_EVENT],[1],[Define if mozilla has a broken context menu event])
+fi
+
+AC_MSG_RESULT([$broken_context_event])
+
+dnl changed location in 1.8a6
+
AC_MSG_CHECKING([for mozilla security compoment])
AC_COMPILE_IFELSE(
diff --git a/embed/ephy-embed-event.c b/embed/ephy-embed-event.c
index 37e2a8a82..7a4ef6826 100644
--- a/embed/ephy-embed-event.c
+++ b/embed/ephy-embed-event.c
@@ -59,18 +59,18 @@ ephy_embed_event_base_init (gpointer g_class)
initialised = TRUE;
}
-EphyEmbedEventType
-ephy_embed_event_get_event_type (EphyEmbedEvent *event)
+EphyEmbedEventContext
+ephy_embed_event_get_context (EphyEmbedEvent *event)
{
EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->get_type (event);
+ return iface->get_context (event);
}
-EphyEmbedEventContext
-ephy_embed_event_get_context (EphyEmbedEvent *event)
+guint
+ephy_embed_event_get_button (EphyEmbedEvent *event)
{
EphyEmbedEventIface *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
- return iface->get_context (event);
+ return iface->get_button (event);
}
guint
diff --git a/embed/ephy-embed-event.h b/embed/ephy-embed-event.h
index 35af428dd..99cca384c 100644
--- a/embed/ephy-embed-event.h
+++ b/embed/ephy-embed-event.h
@@ -49,21 +49,13 @@ typedef enum
EPHY_EMBED_CONTEXT_EMAIL_LINK = 1 << 8
} EphyEmbedEventContext;
-typedef enum
-{
- EPHY_EMBED_EVENT_MOUSE_BUTTON1,
- EPHY_EMBED_EVENT_MOUSE_BUTTON2,
- EPHY_EMBED_EVENT_MOUSE_BUTTON3,
- EPHY_EMBED_EVENT_KEY
-} EphyEmbedEventType;
-
struct _EphyEmbedEventIface
{
GTypeInterface parent_iface;
/* Methods */
- EphyEmbedEventType (* get_type) (EphyEmbedEvent *event);
EphyEmbedEventContext (* get_context) (EphyEmbedEvent *event);
+ guint (* get_button) (EphyEmbedEvent *event);
guint (* get_modifier) (EphyEmbedEvent *event);
void (* get_coordinates) (EphyEmbedEvent *event,
guint *x,
@@ -82,10 +74,10 @@ GType ephy_embed_event_context_get_type (void);
GType ephy_embed_event_type_get_type (void);
-EphyEmbedEventType ephy_embed_event_get_event_type (EphyEmbedEvent *event);
-
EphyEmbedEventContext ephy_embed_event_get_context (EphyEmbedEvent *event);
+guint ephy_embed_event_get_button (EphyEmbedEvent *event);
+
guint ephy_embed_event_get_modifier (EphyEmbedEvent *event);
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index b2c623a6b..03076ef21 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -24,10 +24,13 @@
#include "EphyBrowser.h"
#include "EphyUtils.h"
+#include "EventContext.h"
#include "ephy-embed.h"
#include "ephy-string.h"
#include "ephy-debug.h"
#include "print-dialog.h"
+#include "mozilla-embed.h"
+#include "mozilla-embed-event.h"
#include <gtkmozembed_internal.h>
#include <unistd.h>
@@ -57,6 +60,8 @@
#include "nsIDOMDocument.h"
#include "nsIDOM3Document.h"
#include "nsIDOMEvent.h"
+#include "nsIDOMKeyEvent.h"
+#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMPopupBlockedEvent.h"
@@ -96,6 +101,8 @@
static PRUnichar DOMLinkAdded[] = { 'D', 'O', 'M', 'L', 'i', 'n', 'k',
'A', 'd', 'd', 'e', 'd', '\0' };
+static PRUnichar ContextMenu[] = { 'c', 'o', 'n', 't', 'e', 'x', 't', 'm',
+ 'e', 'n', 'u', '\0' };
static PRUnichar DOMPopupBlocked[] = { 'D', 'O', 'M', 'P', 'o', 'p',
'u', 'p', 'B', 'l', 'o', 'c',
'k', 'e', 'd', '\0' };
@@ -107,7 +114,7 @@ static PRUnichar DOMModalDialogClosed[] = { 'D', 'O', 'M', 'M', 'o', 'd', 'a',
'l', 'D', 'i', 'a', 'l', 'o', 'g',
'C', 'l', 'o', 's', 'e', 'd', '\0' };
-EphyEventListener::EphyEventListener(void)
+EphyEventListener::EphyEventListener()
: mOwner(nsnull)
{
LOG ("EphyEventListener ctor (%p)", this)
@@ -328,10 +335,104 @@ EphyModalAlertEventListener::HandleEvent (nsIDOMEvent * aDOMEvent)
return NS_OK;
}
+EphyContextMenuListener::EphyContextMenuListener()
+: mOwner(nsnull)
+{
+ LOG ("EphyContextMenuListener ctor (%p)", this)
+}
+
+EphyContextMenuListener::~EphyContextMenuListener()
+{
+ LOG ("EphyContextMenuListener dtor (%p)", this)
+}
+
+NS_IMPL_ISUPPORTS1(EphyContextMenuListener, nsIDOMContextMenuListener)
+
+nsresult
+EphyContextMenuListener::Init(EphyBrowser *aOwner)
+{
+ mOwner = aOwner;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+EphyContextMenuListener::ContextMenu (nsIDOMEvent* aDOMEvent)
+{
+ nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aDOMEvent);
+ NS_ENSURE_TRUE (mouseEvent, NS_ERROR_FAILURE);
+
+ MozillaEmbedEvent *info;
+ info = mozilla_embed_event_new (NS_STATIC_CAST (gpointer, aDOMEvent));
+
+ nsresult rv;
+ EventContext context;
+ context.Init (mOwner);
+ rv = context.GetMouseEventInfo (mouseEvent, MOZILLA_EMBED_EVENT (info));
+
+ /* Don't do any magic handling if we can't actually show the context
+ * menu, this can happen for XUL pages (e.g. about:config)
+ */
+ if (NS_FAILED (rv))
+ {
+ g_object_unref (info);
+ return NS_OK;
+ }
+
+ if (info->button == 0)
+ {
+ /* 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 (mOwner->mEmbed)->window, &x, &y);
+ info->x += x + 6;
+ info->y += y + 6;
+
+ // Set the keycode to something sensible
+ info->keycode = nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU;
+ }
+
+ if (info->modifier == GDK_CONTROL_MASK)
+ {
+ info->context = EPHY_EMBED_CONTEXT_DOCUMENT;
+ }
+
+ gboolean retval = FALSE;
+ nsCOMPtr<nsIDOMDocument> domDoc;
+ rv = context.GetTargetDocument (getter_AddRefs(domDoc));
+ if (NS_SUCCEEDED(rv))
+ {
+ mOwner->PushTargetDocument (domDoc);
+
+ g_signal_emit_by_name (mOwner->mEmbed, "ge_context_menu",
+ info, &retval);
+
+ mOwner->PopTargetDocument ();
+ }
+
+ /* We handled the event, block javascript calls */
+ if (retval)
+ {
+ aDOMEvent->PreventDefault();
+ aDOMEvent->StopPropagation();
+ }
+
+ g_object_unref (info);
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+EphyContextMenuListener::HandleEvent (nsIDOMEvent* aDOMEvent)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
EphyBrowser::EphyBrowser ()
: mFaviconEventListener(nsnull)
, mPopupBlockEventListener(nsnull)
, mModalAlertListener(nsnull)
+, mContextMenuListener(nsnull)
, mInitialized(PR_FALSE)
{
LOG ("EphyBrowser ctor (%p)", this)
@@ -379,6 +480,12 @@ nsresult EphyBrowser::Init (GtkMozEmbed *mozembed)
rv = mModalAlertListener->Init (this);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ mContextMenuListener = new EphyContextMenuListener();
+ if (!mContextMenuListener) return NS_ERROR_OUT_OF_MEMORY;
+
+ rv = mContextMenuListener->Init (this);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
rv = GetListener();
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
@@ -431,6 +538,8 @@ EphyBrowser::AttachListeners(void)
mModalAlertListener, PR_TRUE);
rv |= mEventTarget->AddEventListener(nsEmbedString(DOMModalDialogClosed),
mModalAlertListener, PR_TRUE);
+ rv |= mEventTarget->AddEventListener(nsEmbedString(ContextMenu),
+ mContextMenuListener, PR_TRUE /* capture */);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
return NS_OK;
@@ -450,6 +559,8 @@ EphyBrowser::DetachListeners(void)
mModalAlertListener, PR_TRUE);
rv |= mEventTarget->RemoveEventListener(nsEmbedString(DOMModalDialogClosed),
mModalAlertListener, PR_TRUE);
+ rv |= mEventTarget->RemoveEventListener(nsEmbedString(ContextMenu),
+ mContextMenuListener, PR_TRUE /* capture */);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
return NS_OK;
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index 3b4f4ce06..4878dc412 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -29,6 +29,7 @@
#include <gtkmozembed.h>
#include <nsCOMPtr.h>
#include <nsIDOMEventListener.h>
+#include <nsIDOMContextMenuListener.h>
#include <nsIDOMEventTarget.h>
#include <nsIWebNavigation.h>
#include <nsISHistory.h>
@@ -84,12 +85,32 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
};
+class EphyContextMenuListener : public nsIDOMContextMenuListener
+{
+public:
+ NS_DECL_ISUPPORTS
+
+ EphyContextMenuListener();
+ virtual ~EphyContextMenuListener();
+
+ nsresult Init(EphyBrowser *aOwner);
+
+ // nsIDOMContextMenuListener
+
+ NS_IMETHOD ContextMenu(nsIDOMEvent *aEvent);
+ NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
+
+protected:
+ EphyBrowser *mOwner;
+};
+
class EphyBrowser
{
friend class EphyEventListener;
friend class EphyFaviconEventListener;
friend class EphyPopupBlockEventListener;
friend class EphyModalAlertEventListener;
+friend class EphyContextMenuListener;
public:
EphyBrowser();
~EphyBrowser();
@@ -159,6 +180,7 @@ private:
EphyFaviconEventListener *mFaviconEventListener;
EphyPopupBlockEventListener *mPopupBlockEventListener;
EphyModalAlertEventListener *mModalAlertListener;
+ EphyContextMenuListener *mContextMenuListener;
PRBool mInitialized;
#ifdef HAVE_MOZILLA_PSM
nsCOMPtr<nsISecureBrowserUI> mSecurityInfo;
diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp
index 5b5db0638..2001cfc0f 100644
--- a/embed/mozilla/EventContext.cpp
+++ b/embed/mozilla/EventContext.cpp
@@ -572,38 +572,81 @@ nsresult EventContext::GetCSSBackground (nsIDOMNode *node, nsAString& url)
return NS_OK;
}
+nsresult EventContext::GetTargetCoords (nsIDOMEventTarget *aTarget, PRInt32 *aX, PRInt32 *aY)
+{
+ /* Calculate the node coordinates relative to the widget origin */
+ nsCOMPtr<nsIDOMNSHTMLElement> elem (do_QueryInterface(aTarget));
+
+ PRInt32 x = 0, y = 0;
+ while (elem)
+ {
+ PRInt32 val;
+ elem->GetOffsetTop(&val); y += val;
+ elem->GetScrollTop(&val); y -= val;
+ elem->GetOffsetLeft(&val); x += val;
+ elem->GetScrollLeft(&val); x -= val;
+
+ nsCOMPtr<nsIDOMElement> parent;
+ elem->GetOffsetParent (getter_AddRefs (parent));
+ elem = do_QueryInterface(parent);
+ }
+
+ *aX = x;
+ *aY = y;
+
+ return NS_OK;
+}
+
nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, MozillaEmbedEvent *info)
{
/* FIXME: casting 32-bit guint* to PRUint16* below will break on big-endian */
- PRUint16 btn;
+ PRUint16 btn = 1729;
aMouseEvent->GetButton (&btn);
switch (btn)
{
+ /* mozilla's button counting is one-off from gtk+'s */
case 0:
- info->type = EPHY_EMBED_EVENT_MOUSE_BUTTON1;
- break;
+ info->button = 1;
+ break;
case 1:
- info->type = EPHY_EMBED_EVENT_MOUSE_BUTTON2;
- break;
+ info->button = 2;
+ break;
case 2:
- info->type = EPHY_EMBED_EVENT_MOUSE_BUTTON3;
- break;
+ info->button = 3;
+ break;
+
+#ifdef MOZ_BROKEN_CTX_MENU_EVENT
+ case 1729:
+ /* This only appears to happen when getting a mouse context menu
+ * signal, so map it to button 3 (right mouse button)
+ * http://bugzilla.mozilla.org/show_bug.cgi?id=258193 */
+ info->button = 3;
+ break;
+#endif
case (PRUint16) -1:
/* when the user submits a form with Return, mozilla synthesises
* a _mouse_ click event with btn=65535 (-1).
*/
- info->type = EPHY_EMBED_EVENT_KEY;
+ default:
+ info->button = 0;
break;
+ }
- default:
- g_warning ("Unknown mouse button");
+ if (info->button != 0)
+ {
+ /* OTOH, casting only between (un)signedness is safe */
+ aMouseEvent->GetScreenX ((PRInt32*)&info->x);
+ aMouseEvent->GetScreenY ((PRInt32*)&info->y);
}
+ else /* this is really a keyboard event */
+ {
+ nsCOMPtr<nsIDOMEventTarget> eventTarget;
+ aMouseEvent->GetTarget (getter_AddRefs (eventTarget));
- /* OTOH, casting only between (un)signedness is safe */
- aMouseEvent->GetScreenX ((PRInt32*)&info->x);
- aMouseEvent->GetScreenY ((PRInt32*)&info->y);
+ GetTargetCoords (eventTarget, (PRInt32*)&info->x, (PRInt32*)&info->y);
+ }
/* be sure we are not clicking on the scroolbars */
@@ -661,10 +704,9 @@ nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, Mozilla
nsresult EventContext::GetKeyEventInfo (nsIDOMKeyEvent *aKeyEvent, MozillaEmbedEvent *info)
{
- nsresult rv;
-
- info->type = EPHY_EMBED_EVENT_KEY;
+ info->button = 0;
+ nsresult rv;
PRUint32 keyCode;
rv = aKeyEvent->GetKeyCode(&keyCode);
if (NS_FAILED(rv)) return rv;
@@ -674,25 +716,7 @@ nsresult EventContext::GetKeyEventInfo (nsIDOMKeyEvent *aKeyEvent, MozillaEmbedE
rv = aKeyEvent->GetTarget(getter_AddRefs(target));
if (NS_FAILED(rv) || !target) return NS_ERROR_FAILURE;
- /* Calculate the node coordinates relative to the widget origin */
- nsCOMPtr<nsIDOMNSHTMLElement> elem = do_QueryInterface(target, &rv);
- if (NS_FAILED(rv)) return rv;
-
- PRInt32 x = 0, y = 0;
- while (elem)
- {
- PRInt32 val;
- elem->GetOffsetTop(&val); y += val;
- elem->GetScrollTop(&val); y -= val;
- elem->GetOffsetLeft(&val); x += val;
- elem->GetScrollLeft(&val); x -= val;
-
- nsCOMPtr<nsIDOMElement> parent;
- elem->GetOffsetParent(getter_AddRefs(parent));
- elem = do_QueryInterface(parent, &rv);
- }
- info->x = x;
- info->y = y;
+ GetTargetCoords (target, (PRInt32*)&info->x, (PRInt32*)&info->y);
/* Context */
rv = GetEventContext (target, info);
diff --git a/embed/mozilla/EventContext.h b/embed/mozilla/EventContext.h
index 5a2564e3f..36d3faedb 100644
--- a/embed/mozilla/EventContext.h
+++ b/embed/mozilla/EventContext.h
@@ -26,6 +26,7 @@
#include "ephy-embed.h"
#include "mozilla-embed-event.h"
+#include <nsIDOMEventTarget.h>
#include <nsIDOMMouseEvent.h>
#include <nsIDOMKeyEvent.h>
#include <nsIDOMEvent.h>
@@ -51,6 +52,7 @@ private:
MozillaEmbedEvent *mEmbedEvent;
nsCOMPtr<nsIDOMDocument> mDOMDocument;
+ nsresult GetTargetCoords (nsIDOMEventTarget *aTarget, PRInt32 *aX, PRInt32 *aY);
nsresult GatherTextUnder (nsIDOMNode* aNode, nsAString& aResult);
nsresult ResolveBaseURL (const nsAString &relurl, nsACString &url);
nsresult Unescape (const nsACString &aEscaped, nsACString &aUnescaped);
diff --git a/embed/mozilla/mozilla-embed-event.cpp b/embed/mozilla/mozilla-embed-event.cpp
index 6e37313d4..685fa6f6a 100644
--- a/embed/mozilla/mozilla-embed-event.cpp
+++ b/embed/mozilla/mozilla-embed-event.cpp
@@ -35,9 +35,9 @@
#define MOZILLA_EMBED_EVENT_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_EVENT, MozillaEmbedEventPrivate))
-struct MozillaEmbedEventPrivate
+struct _MozillaEmbedEventPrivate
{
- nsCOMPtr<nsIDOMEvent> dom_event;
+ nsIDOMEvent* dom_event;
GHashTable *props;
};
@@ -94,6 +94,7 @@ mozilla_embed_event_new (gpointer dom_event)
event = MOZILLA_EMBED_EVENT (g_object_new (MOZILLA_TYPE_EMBED_EVENT, NULL));
event->priv->dom_event = static_cast<nsIDOMEvent*>(dom_event);
+ NS_IF_ADDREF (event->priv->dom_event);
return event;
}
@@ -112,12 +113,6 @@ mozilla_embed_event_set_property (MozillaEmbedEvent *event,
value);
}
-static EphyEmbedEventType
-impl_get_type (EphyEmbedEvent *event)
-{
- return ((MozillaEmbedEvent *) event)->type;
-}
-
static EphyEmbedEventContext
impl_get_context (EphyEmbedEvent *event)
{
@@ -125,6 +120,12 @@ impl_get_context (EphyEmbedEvent *event)
}
static guint
+impl_get_button (EphyEmbedEvent *event)
+{
+ return ((MozillaEmbedEvent *) event)->button;
+}
+
+static guint
impl_get_modifier (EphyEmbedEvent *event)
{
return ((MozillaEmbedEvent *) event)->modifier;
@@ -190,6 +191,7 @@ mozilla_embed_event_finalize (GObject *object)
g_hash_table_destroy (event->priv->props);
+ NS_IF_RELEASE (event->priv->dom_event);
event->priv->dom_event = nsnull;
LOG ("MozillaEmbedEvent %p finalised", object)
@@ -200,8 +202,8 @@ mozilla_embed_event_finalize (GObject *object)
static void
ephy_embed_event_iface_init (EphyEmbedEventIface *iface)
{
- iface->get_type = impl_get_type;
iface->get_context = impl_get_context;
+ iface->get_button = impl_get_button;
iface->get_modifier = impl_get_modifier;
iface->get_coordinates = impl_get_coordinates;
iface->get_property = impl_get_property;
diff --git a/embed/mozilla/mozilla-embed-event.h b/embed/mozilla/mozilla-embed-event.h
index b3be2a557..79499e215 100644
--- a/embed/mozilla/mozilla-embed-event.h
+++ b/embed/mozilla/mozilla-embed-event.h
@@ -36,16 +36,16 @@ G_BEGIN_DECLS
#define MOZILLA_IS_EMBED_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MOZILLA_TYPE_EMBED_EVENT))
#define MOZILLA_EMBED_EVENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MOZILLA_TYPE_EMBED_EVENT, MozillaEmbedEventClass))
-typedef struct MozillaEmbedEventClass MozillaEmbedEventClass;
-typedef struct MozillaEmbedEvent MozillaEmbedEvent;
-typedef struct MozillaEmbedEventPrivate MozillaEmbedEventPrivate;
+typedef struct _MozillaEmbedEventClass MozillaEmbedEventClass;
+typedef struct _MozillaEmbedEvent MozillaEmbedEvent;
+typedef struct _MozillaEmbedEventPrivate MozillaEmbedEventPrivate;
-struct MozillaEmbedEventClass
+struct _MozillaEmbedEventClass
{
GObjectClass parent_class;
};
-struct MozillaEmbedEvent
+struct _MozillaEmbedEvent
{
GObject parent;
@@ -53,7 +53,7 @@ struct MozillaEmbedEvent
MozillaEmbedEventPrivate *priv;
/*< private >*/ /* public to the embed implementation */
- EphyEmbedEventType type;
+ guint button;
guint context;
guint modifier;
guint x;
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 7d6681fb4..41c6ac6ac 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -57,9 +57,6 @@ static void mozilla_embed_net_state_all_cb (GtkMozEmbed *embed,
gint state,
guint status,
MozillaEmbed *membed);
-static gint mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed,
- gpointer dom_event,
- MozillaEmbed *membed);
static gint mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed,
gpointer dom_event,
MozillaEmbed *membed);
@@ -279,9 +276,6 @@ mozilla_embed_init (MozillaEmbed *embed)
g_signal_connect_object (G_OBJECT (embed), "security_change",
G_CALLBACK (mozilla_embed_security_change_cb),
embed, (GConnectFlags) 0);
- g_signal_connect_object (G_OBJECT (embed), "dom_key_down",
- G_CALLBACK (mozilla_embed_dom_key_down_cb),
- embed, (GConnectFlags) 0);
}
gpointer
@@ -871,71 +865,6 @@ mozilla_embed_net_state_all_cb (GtkMozEmbed *embed, const char *aURI,
}
static gint
-mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed, gpointer dom_event,
- MozillaEmbed *membed)
-{
- MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
-
- if (dom_event == NULL)
- {
- g_warning ("mozilla_embed_dom_key_down_cb: domevent NULL");
- return FALSE;
- }
-
- nsCOMPtr<nsIDOMKeyEvent> ev = static_cast<nsIDOMKeyEvent*>(dom_event);
- NS_ENSURE_TRUE (ev, FALSE);
- nsCOMPtr<nsIDOMEvent> dev = do_QueryInterface (ev);
- NS_ENSURE_TRUE (dev, FALSE);
-
- MozillaEmbedEvent *info;
- info = mozilla_embed_event_new (NS_STATIC_CAST (gpointer, dev));
-
- gboolean ret = FALSE;
-
- nsresult rv;
- EventContext ctx;
- ctx.Init (mpriv->browser);
- rv = ctx.GetKeyEventInfo (ev, info);
- if (NS_FAILED (rv)) return ret;
-
- if ((info->keycode == nsIDOMKeyEvent::DOM_VK_F10 &&
- (info->modifier == GDK_SHIFT_MASK ||
- info->modifier == GDK_CONTROL_MASK))
- || (info->keycode == nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU &&
- !info->modifier)
- )
- {
- /* 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);
- info->x += x + 6;
- info->y += y + 6;
-
- if (info->modifier == GDK_CONTROL_MASK)
- {
- info->context = EPHY_EMBED_CONTEXT_DOCUMENT;
- }
-
- nsCOMPtr<nsIDOMDocument> doc;
- rv = ctx.GetTargetDocument (getter_AddRefs(doc));
- if (NS_SUCCEEDED(rv))
- {
- rv = mpriv->browser->PushTargetDocument (doc);
- if (NS_SUCCEEDED(rv))
- {
- g_signal_emit_by_name (membed, "ge_context_menu", info, &ret);
- mpriv->browser->PopTargetDocument ();
- }
- }
- }
-
- g_object_unref (info);
- return ret;
-}
-
-static gint
mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event,
MozillaEmbed *membed)
{
@@ -991,7 +920,6 @@ mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event,
EventContext event_context;
gint return_value = FALSE;
nsresult rv;
- EphyEmbedEventType type;
MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
if (dom_event == NULL)
@@ -1011,28 +939,16 @@ mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event,
rv = event_context.GetMouseEventInfo (ev, MOZILLA_EMBED_EVENT (info));
if (NS_FAILED (rv)) return FALSE;
- type = ephy_embed_event_get_event_type ((EphyEmbedEvent *) info);
-
nsCOMPtr<nsIDOMDocument> domDoc;
rv = event_context.GetTargetDocument (getter_AddRefs(domDoc));
if (NS_SUCCEEDED (rv))
{
- rv = mpriv->browser->PushTargetDocument (domDoc);
+ mpriv->browser->PushTargetDocument (domDoc);
- if (NS_SUCCEEDED (rv))
- {
- g_signal_emit_by_name (membed, "ge_dom_mouse_down",
- info, &return_value);
+ g_signal_emit_by_name (membed, "ge_dom_mouse_down",
+ info, &return_value);
- if (return_value == FALSE &&
- type == EPHY_EMBED_EVENT_MOUSE_BUTTON3)
- {
- g_signal_emit_by_name (membed, "ge_context_menu",
- info, &return_value);
- }
-
- mpriv->browser->PopTargetDocument ();
- }
+ mpriv->browser->PopTargetDocument ();
}
g_object_unref (info);
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 4b297e5b1..11ec9168a 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -1521,9 +1521,8 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
EphyEmbedEvent *event,
EphyTab *tab)
{
- EphyEmbedEventType type;
EphyEmbedEventContext context;
- guint modifier;
+ guint button, modifier;
gboolean handled = TRUE;
gboolean with_control, with_shift, is_left_click, is_middle_click;
gboolean is_link, is_image, is_middle_clickable;
@@ -1532,17 +1531,17 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
g_return_val_if_fail (EPHY_IS_EMBED_EVENT(event), FALSE);
- type = ephy_embed_event_get_event_type (event);
+ button = ephy_embed_event_get_button (event);
context = ephy_embed_event_get_context (event);
modifier = ephy_embed_event_get_modifier (event);
- LOG ("ephy_tab_dom_mouse_click_cb: type %d, context %x, modifier %x",
- type, context, modifier)
+ LOG ("ephy_tab_dom_mouse_click_cb: button %d, context %x, modifier %x",
+ button, context, modifier)
with_control = (modifier & GDK_CONTROL_MASK) != 0;
with_shift = (modifier & GDK_SHIFT_MASK) != 0;
- is_left_click = (type == EPHY_EMBED_EVENT_MOUSE_BUTTON1);
- is_middle_click = (type == EPHY_EMBED_EVENT_MOUSE_BUTTON2);
+ is_left_click = (button == 1);
+ is_middle_click = (button == 2);
middle_click_opens =
eel_gconf_get_boolean (CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL) &&
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 2760e59fb..bd97d29e2 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1715,7 +1715,7 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
const GValue *value;
gboolean framed, has_background, can_open_in_new;
GtkWidget *widget;
- EphyEmbedEventType type;
+ guint button;
/* Do not show the menu in print preview mode */
if (window->priv->ppv_mode)
@@ -1796,8 +1796,8 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
g_signal_connect (widget, "hide",
G_CALLBACK (hide_embed_popup_cb), window);
- type = ephy_embed_event_get_event_type (event);
- if (type == EPHY_EMBED_EVENT_KEY)
+ button = ephy_embed_event_get_button (event);
+ if (button == 0)
{
gtk_menu_popup (GTK_MENU (widget), NULL, NULL,
popup_menu_at_coords, window, 0,
@@ -1807,7 +1807,7 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
else
{
gtk_menu_popup (GTK_MENU (widget), NULL, NULL,
- NULL, NULL, 2,
+ NULL, NULL, button,
gtk_get_current_event_time ());
}
}
@@ -1819,17 +1819,13 @@ tab_context_menu_cb (EphyEmbed *embed,
{
EphyTab *tab;
- g_return_val_if_fail (EPHY_IS_WINDOW (window), FALSE);
- g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE);
- g_return_val_if_fail (EPHY_IS_EMBED_EVENT(event), FALSE);
-
tab = ephy_tab_for_embed (embed);
g_return_val_if_fail (EPHY_IS_TAB (tab), FALSE);
g_return_val_if_fail (window->priv->active_tab == tab, FALSE);
show_embed_popup (window, tab, event);
- return FALSE;
+ return TRUE;
}
static void
@@ -1963,7 +1959,7 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
embed = ephy_tab_get_embed (new_tab);
g_signal_connect_object (embed, "ge_context_menu",
G_CALLBACK (tab_context_menu_cb),
- window, 0);
+ window, G_CONNECT_AFTER);
action = GTK_TOGGLE_ACTION (ephy_tab_get_action (new_tab));
gtk_toggle_action_set_active (action, TRUE);