From 5c0cc7b6682380a17926a6228384e2abf58712c3 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sat, 22 Dec 2012 03:45:06 +0100 Subject: [PATCH] Dispatch click event over the document the hints belongs. --- src/command.c | 4 ++-- src/hints.c | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/command.c b/src/command.c index e1b6342..b159c6c 100644 --- a/src/command.c +++ b/src/command.c @@ -64,8 +64,8 @@ static CommandInfo cmd_list[] = { {"complete", command_complete, {0}, VP_MODE_COMMAND | VP_MODE_COMPLETE}, {"complete-back", command_complete, {1}, VP_MODE_COMMAND | VP_MODE_COMPLETE}, {"inspect", command_inspect, {0}, VP_MODE_NORMAL}, - {"hint-link", command_hints, {HINTS_TYPE_LINK, "."}, VP_MODE_HINTING}, - {"hint-link-new", command_hints, {HINTS_TYPE_LINK | HINTS_TARGET_BLANK, ","}, VP_MODE_HINTING}, + {"hint-link", command_hints, {HINTS_TYPE_LINK, ". "}, VP_MODE_HINTING}, + {"hint-link-new", command_hints, {HINTS_TYPE_LINK | HINTS_TARGET_BLANK, ", "}, VP_MODE_HINTING}, {"hint-input-open", command_hints, {HINTS_TYPE_LINK | HINTS_PROCESS | HINTS_PROCESS_INPUT, ";o"}, VP_MODE_HINTING}, {"hint-input-tabopen", command_hints, {HINTS_TYPE_LINK | HINTS_TARGET_BLANK | HINTS_PROCESS | HINTS_PROCESS_INPUT, ";t"}, VP_MODE_HINTING}, {"hint-focus-next", command_hints_focus, {0}, VP_MODE_HINTING}, diff --git a/src/hints.c b/src/hints.c index 5bc3dbb..cb5da69 100644 --- a/src/hints.c +++ b/src/hints.c @@ -310,13 +310,14 @@ static void hints_create_for_window(const gchar* input, Window* win) static void hints_focus(const gulong num) { - /* TODO use the document the hinted element belongs to */ - Document* doc = webkit_web_view_get_dom_document(vp.gui.webview); + Document* doc = NULL; + Hint* hint = hints_get_hint_by_number(currentFocusNum); if (hint) { /* reset previous focused element */ dom_element_style_set_property(hint->elem, "background-color", ELEM_BACKGROUND); + doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(hint->elem)); dom_dispatch_mouse_event(doc, hint->elem, "mouseout", 0); } @@ -325,6 +326,7 @@ static void hints_focus(const gulong num) /* mark new hint as focused */ dom_element_style_set_property(hint->elem, "background-color", ELEM_BACKGROUND_FOCUS); + doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(hint->elem)); dom_dispatch_mouse_event(doc, hint->elem, "mouseover", 0); webkit_dom_element_blur(hint->elem); } @@ -359,10 +361,6 @@ static void hints_fire(const gulong num) */ static void hints_click_fired_hint(guint mode, Element* elem) { - /* TODO I don't get the mouse click event dispatched here to - * invoke the gtk events for button press wich might be the better - * way hanlding to open new windows than setting temporary target - * attribute here */ gchar* target = webkit_dom_element_get_attribute(elem, "target"); if (mode & HINTS_TARGET_BLANK) { /* open in new window */ webkit_dom_element_set_attribute(elem, "target", "_blank", NULL); @@ -371,9 +369,7 @@ static void hints_click_fired_hint(guint mode, Element* elem) } /* dispatch click event */ - /* TODO use document of the hint an not the default one, but this is only - * required if we hint also into frames and iframes */ - Document* doc = webkit_web_view_get_dom_document(vp.gui.webview); + Document* doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(elem)); dom_dispatch_mouse_event(doc, elem, "click", 0); /* reset previous target attribute */ -- 2.20.1