Replace linkhover() with mousetargetchanged()
The “linkhover” can now be more than a simple link (image, video, etc.). As we can't anymore perform a hit test when we want, we have to keep the last known hit test to be able to know where the mouse is on the next click event.
This commit is contained in:
parent
b9530ad5d1
commit
42c6c90366
1 changed files with 23 additions and 12 deletions
35
surf.c
35
surf.c
|
@ -59,7 +59,8 @@ typedef struct Client {
|
||||||
Window xid;
|
Window xid;
|
||||||
WebKitWebView *view;
|
WebKitWebView *view;
|
||||||
WebKitWebInspector *inspector;
|
WebKitWebInspector *inspector;
|
||||||
const char *title, *linkhover;
|
WebKitHitTestResult *mousepos;
|
||||||
|
const char *title, *targeturi;
|
||||||
const char *needle;
|
const char *needle;
|
||||||
gint progress;
|
gint progress;
|
||||||
struct Client *next;
|
struct Client *next;
|
||||||
|
@ -151,8 +152,8 @@ static void inspector_finished(WebKitWebInspector *i, Client *c);
|
||||||
|
|
||||||
static gboolean keypress(GtkAccelGroup *group, GObject *obj, guint key,
|
static gboolean keypress(GtkAccelGroup *group, GObject *obj, guint key,
|
||||||
GdkModifierType mods, Client *c);
|
GdkModifierType mods, Client *c);
|
||||||
static void linkhover(WebKitWebView *v, const char* t, const char* l,
|
static void mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h,
|
||||||
Client *c);
|
guint modifiers, Client *c);
|
||||||
static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec,
|
static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec,
|
||||||
Client *c);
|
Client *c);
|
||||||
static void loaduri(Client *c, const Arg *arg);
|
static void loaduri(Client *c, const Arg *arg);
|
||||||
|
@ -691,14 +692,24 @@ keypress(GtkAccelGroup *group, GObject *obj, guint key, GdkModifierType mods,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
linkhover(WebKitWebView *v, const char* t, const char* l, Client *c)
|
mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers,
|
||||||
|
Client *c)
|
||||||
{
|
{
|
||||||
if (l) {
|
WebKitHitTestResultContext hc;
|
||||||
c->linkhover = copystr(&c->linkhover, l);
|
|
||||||
} else if (c->linkhover) {
|
/* Keep the hit test to know where is the pointer on the next click */
|
||||||
free(c->linkhover);
|
c->mousepos = h;
|
||||||
c->linkhover = NULL;
|
|
||||||
}
|
hc = webkit_hit_test_result_get_context(h);
|
||||||
|
|
||||||
|
if (hc & OnLink)
|
||||||
|
c->targeturi = webkit_hit_test_result_get_link_uri(h);
|
||||||
|
else if (hc & OnImg)
|
||||||
|
c->targeturi = webkit_hit_test_result_get_image_uri(h);
|
||||||
|
else if (hc & OnMedia)
|
||||||
|
c->targeturi = webkit_hit_test_result_get_media_uri(h);
|
||||||
|
else
|
||||||
|
c->targeturi = NULL;
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,8 +880,8 @@ newview(Client *c, WebKitWebView *rv)
|
||||||
"notify::title",
|
"notify::title",
|
||||||
G_CALLBACK(titlechanged), c);
|
G_CALLBACK(titlechanged), c);
|
||||||
g_signal_connect(G_OBJECT(v),
|
g_signal_connect(G_OBJECT(v),
|
||||||
"hovering-over-link",
|
"mouse-target-changed",
|
||||||
G_CALLBACK(linkhover), c);
|
G_CALLBACK(mousetargetchanged), c);
|
||||||
g_signal_connect(G_OBJECT(v),
|
g_signal_connect(G_OBJECT(v),
|
||||||
"geolocation-policy-decision-requested",
|
"geolocation-policy-decision-requested",
|
||||||
G_CALLBACK(geopolicyrequested), c);
|
G_CALLBACK(geopolicyrequested), c);
|
||||||
|
|
Loading…
Reference in a new issue