Fixed none working open hints in new window (#74).
authorDaniel Carl <danielcarl@gmx.de>
Wed, 2 Apr 2014 07:45:39 +0000 (09:45 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 2 Apr 2014 07:45:39 +0000 (09:45 +0200)
There is already a hack to allow the hinting JavaScript to open a page also in
a new window without user interaction (hinting in no user interaction in the
manner of webkit). To allow to open hints into new window the webkit setting
'javascript-can-open-windows-automatically' is enabled. After fireing a hint,
this is set back to it's initial value. But this seemed to be to early, what
means we potentially disabled to open page in new window right before the new
window was created.
This patch moved the resetting of the option into the clear function, that
should be late enough.

src/hints.c

index 4bfc51c..31f995d 100644 (file)
@@ -108,6 +108,14 @@ void hints_clear(void)
         call_hints_function("clear", 0, NULL);
 
         g_signal_emit_by_name(vb.gui.webview, "hovering-over-link", NULL, NULL);
+
+#if WEBKIT_CHECK_VERSION(2, 0, 0)
+        /* if open window was not allowed for JavaScript, restore this */
+        if (!hints.allow_open_win) {
+            WebKitWebSettings *setting = webkit_web_view_get_settings(vb.gui.webview);
+            g_object_set(G_OBJECT(setting), "javascript-can-open-windows-automatically", hints.allow_open_win, NULL);
+        }
+#endif
     }
 }
 
@@ -333,13 +341,5 @@ static gboolean call_hints_function(const char *func, int count, JSValueRef para
         }
     }
     g_free(value);
-
-#if WEBKIT_CHECK_VERSION(2, 0, 0)
-    /* if open window was not allowed for JavaScript, restore this */
-    if (!hints.allow_open_win) {
-        WebKitWebSettings *setting = webkit_web_view_get_settings(vb.gui.webview);
-        g_object_set(G_OBJECT(setting), "javascript-can-open-windows-automatically", hints.allow_open_win, NULL);
-    }
-#endif
     return true;
 }