gcollazo / BrowserRefresh-Sublime

This plugin will switch from ST2 and ST3 to Google Chrome, Google Chrome Canary, Safari, Firefox or Opera and reload the active tab
http://gcollazo.github.com/BrowserRefresh-Sublime
565 stars 61 forks source link

Linux Bug fix and improvements #84

Closed Kwaadpepper closed 4 years ago

Kwaadpepper commented 9 years ago

fixes #83 Fix the deadlock issue caused by --sync (removed --sync since it is useless) Fix the Chromebased since it needs focus before send input Fix Firefox bug with xdotool since invisible window is returned by xdotool --visible-only Added Opera support for linux Added Chromium support

gcollazo commented 8 years ago

@Kwaadpepper I don't have a proper linux testing environment. Can you share what kind of testing you did and what's the environment like?

Kwaadpepper commented 8 years ago

@gcollazo Hey i'll try to explain what i did here. I have first noticed --sync should not be used since this plugin does not actually launch browsers so it makes ST freeze.

I have then noticed a bug with Firefox using xdotool where --only-visible would not work as expected, so using wmctrl to detect browser with window name and a regex is a pretty good work around since all browsers have their name in the window title (except epiphany).

I have noticed xdotool actually handles multiple desktop and it sometimes explode at your face if you don't actually specify the desktop XGetWindowProperty[_NET_WM_DESKTOP] failed (code=1).

There is a well know bug where chromebased navigators aren't listening to keys that are 'synthetic', this means the input system on linux (xorg input i would say) make a difference between real input send and program keys send, plus any window can choose to just ignore stuff.

So there are 3 methods added in the code for all these cases. I also tested on Kubuntu 15.04 and 15.10 all available browsers in this PR to make sure everything is working and good handling of any exceptions.

SendKeyToAllWindows is the normal method SendKeysToAllNamedWindows is using window name SendKeyToAllWebkitBasedNavigators force windowactivate with xdotool and refocus sublimetext if the option activate is on false print_error is refactored getDesktop provides the actual desktop for xdotool

firefoxdev is firefox in linux whereas nightly is nightly, i just added support for nightly to Linux since i don't own mac or window stuff. I believe chromium support could be added to windows so as nightly.

To conclude, i just noticed another bug : you actually have to run the plugin twice to make its first refresh (eg use the shortcut twice).

If any question there is anwser will follow. I spend lot of time to make this happening.

PS: https://github.com/gcollazo/BrowserRefresh-Sublime/pull/56 should be close as the PR has invalid workaround.