diff options
author | Christian Dywan <christian@twotoasts.de> | 2018-09-11 23:42:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-11 23:42:25 +0200 |
commit | 498ec5054aa4300f56f9b95869a4100fd2e9d517 (patch) | |
tree | 5d22d8f4cd192d81ce6694d3c7f4921e9e680fc8 | |
parent | cc50b965145eb068328469a68b16fa9e039e9a53 (diff) | |
download | midori-git-498ec5054aa4300f56f9b95869a4100fd2e9d517.tar.gz |
Employ timeout with focussing/ loading tab (#26)
When switching tabs, the new tab gets focus which causes it to load if it'd been delayed before. A timeout of 500ms prevents switching from triggering all tabs in-between.
-rw-r--r-- | core/browser.vala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/browser.vala b/core/browser.vala index 6d04c4a2..07acf920 100644 --- a/core/browser.vala +++ b/core/browser.vala @@ -73,6 +73,7 @@ namespace Midori { Gtk.SearchEntry search_entry; List<Binding> bindings; + uint focus_timeout = 0; construct { overlay.add_events (Gdk.EventMask.ENTER_NOTIFY_MASK); @@ -185,7 +186,15 @@ namespace Midori { bindings.append (tab.bind_property ("link-uri", statusbar, "label")); bindings.append (tab.bind_property ("display-uri", navigationbar.urlbar, "uri")); bindings.append (tab.bind_property ("pinned", navigationbar, "visible", BindingFlags.INVERT_BOOLEAN)); - tab.grab_focus (); + if (focus_timeout > 0) { + Source.remove (focus_timeout); + focus_timeout = 0; + } + focus_timeout = Timeout.add (500, () => { + tab.grab_focus (); + goto_activated (); + return Source.REMOVE; + }, Priority.LOW); } else { var previous_tab = tabs.get_children ().nth_data (0); if (previous_tab == null) |