kattrali / webkitten

A command-driven web browser toolkit inspired by luakit and Vim.

Home Page:https://webkitten.delisa.me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow customization of cmd click link behavior

keith opened this issue · comments

We discussed this a little bit but I wanted to create an issue so we don't forget.

It would be nice to be able to hook into the cmd+click action on links in order to do things like open the link in the background instead of the foreground, and also be able to decide on the ordering. For example if you cmd+click multiple URLs and they come to the foreground, you may want the later ones to be just a single buffer in front of the website you were opening them from, instead of at the end.

I think this could mostly be achieved by adding a new config option such as new-frame.opens-in-background. This could then be used for all parts of this function:

https://github.com/kylef/webkitten/blob/e3a822e852d2faf3f0fb92f236dc1300bea69e18/src/lib.rs#L60-L66

Which would either refocus, the window, or webview that was focused at the time after opening the new URL.

I'm happy to take a stab at this if everyone is on board with the approach!

I think the config option in the right track, though you may have to touch some dirty internals in window.rs to prevent showing a newly-added webview. Getting started should be as simple as adding a focus argument to open_webview though.