piroor / aggregate-tabs-to-main-window

Aggregate new tabs to a window which has most many tabs and largest size.
Mozilla Public License 2.0
8 stars 2 forks source link

Add option to ignore child or empty tabs #3

Open ssokolow opened 6 years ago

ssokolow commented 6 years ago

I have a triple-monitor Firefox setup like this...

bitmap

...and it's very irritating when clicking a link in Thunderbird (or any other external application) causes one of my non-primary Firefox windows to change just because I interacted with it in a way which made Firefox think of it as "most recently used". (eg. starting a new YouTube video playing.)

Since my primary window is a bit bigger than the others I tried installing this extension as a way to force externally opened tabs to appear in the primary window. However, I ran into another problem: It's too aggressive.

If I middle-click a tab, this extension overrules Tree Style Tab and forces it to the centre window. If I open a new blank tab, it overrules my choice of which window's "New Tab" button I clicked and forces it to the centre window. If I use a browser-provided menu entry like Addons or Preferences which would normally open in whichever window I used the menu to open it from, it forces it to the centre window.

Would you mind adding an option to only aggregate tabs with no existing window affinity (ie. externally opened tabs) and ignore ones that either certainly or probably have a window affinity (eg. child tabs and tabs opening on about:* addresses like about:newtab or about:addons, which would have been triggered by a menu entry or toolbar button)?

piroor commented 6 years ago

Sadly it is very hard because WebExtensions API doesn't provide ability to know what is the exact trigger of a new tab. By the commit b8b6077 I've added ability to set exceptions for tabs opened from pinned and unpinned tabs, but currently it is impossible to set such exceptions for other detailed cases.

ssokolow commented 6 years ago

Then how does Tree Style Tab tell whether something is a child? I was just proposing this:

  1. Identify and ignore child tabs using whatever mechanism TST uses to arrange them in a tree.
  2. If necessary, defer moving the tab until the initial page being loaded can be determined.
  3. If the initial page being loaded is one of the about:... pages, ignore it, since this is almost certainly something opened by a browser UI element which has a separate copy for each window. (eg. The New Tab button, the Add-ons or Preferences entries in the hamburger menu, etc.)
piroor commented 6 years ago

OK, I've added support for more type exceptions. There is a development build which is triable via "about:debugging": https://piro.sakura.ne.jp/xul/xpi/nightly/aggregate-tabs-to-main-window.xpi

ssokolow commented 6 years ago

I've got it installed (I'm on Developer Edition with extension signing disabled. I just clicked the link, OKed through as normal, and then went through the extra step of manually clicking "Enable".) but it's still behaving the same way as the release version.

How do I enable the new type exceptions?

piroor commented 6 years ago

Exceptions are configurable via the "preferences" page of the addon.

ssokolow commented 6 years ago

I guessed that much, but the only likely candidates are the fields which are revealed when "Debug mode" is selected and they're not intuitive enough for me to know how to change them to get the desired effect without explanatory documentation.

This is what I get, after removing and re-installing the extension to be certain I'm not looking at an old version:

screenshot16

piroor commented 6 years ago

Hmm, sorry it is my fault. The nighly build is not updated as I expected. Anyway, I've released a new version 1.3.0 and you'll see more options in the configuration page. For example, uncheck all checkboxes under "Tabs to be aggregated" except "All other cases" then tabs only from non-existing tab (like tabs from external apps) will be moved automatically.

ssokolow commented 6 years ago

It's closer, but not perfect. If I do as you describe, the "New Tab" button and the Add-ons and Preferences menu entries still get aggregated.

If I do this, the "New Tab" button and Add-ons and Preferences menu entries don't get moved, but neither do the links I open from Thunderbird.

screenshot16

No matter what I try, the tab opened by clicking the "2 reviews" in the addon page still results in the tab being moved.

piroor commented 6 years ago

I've configured this addon exact same to the screenshot, and I got expected results - about:preferences, about:support, and about:addons are opened in a not largest window and stay there. Hmm...

Could you try logging? When the "Debug mode" checkbox is turned on, detailed logs will appear in the debugger's console for this addon. (You'll open the debugger console from about:debugging.)

ssokolow commented 6 years ago

The problem is that, when configured as shown in the screenshot, enabling the "Don't aggregate if it is matched to the regular expression" portion blocks the "Any other case" from working.

Steps to Reproduce:

  1. Configure the extension as shown in the screenshot
  2. Try clicking the "New Tab" button and the Addons and Preferences menu entries in a not-largest window.
  3. Try running firefox http://github.com/ in a terminal window.

Expected:

Actual behaviour:

Today was distracting and It's late now so, if you still need the logging output, I'll get that tomorrow.

piroor commented 4 years ago

Sorry for this 2 years delay...

Today I researched again deeply and I've realized that tabs from external applications are opened with "about:blank" URL at first. Such a tab matches to the regular expression for "don't aggregate" and remained unexpectedly. So I've introduced some changes to detect really requested URLs. With those changes, the case reported at the last comment works as expected for me now.