sbmpost / AutoRaise

AutoRaise (and focus) a window when hovering over it with the mouse
GNU General Public License v3.0
1.48k stars 60 forks source link

Disable for picture in picture window #143

Closed echo-saurav closed 1 year ago

echo-saurav commented 1 year ago

first of all thank you for this awesome app! when i use pip in browser pip window treat as the whole browser window, i know maybe the window have the same id/name so it just raised the whole browser, but is there any option to disable it for pip? or instead of application name to disable , select window with mouse pointer and grub the id for that window to fix it

sbmpost commented 1 year ago

@echo-saurav

Perhaps you can be a bit more specific about the pip. Which browser do you use? And what are the steps so I can test this myself on my own machine?

sbmpost commented 1 year ago

@echo-saurav

I played around with Chrome and Firefox PiP features. It would seem that in Firefox, the PiP window can actually receive keyboard input such as CMD-W to close the window. In theory, the Chrome PiP window may also support keyboard input (if not now, then perhaps in the future). As such we probably don't want to make exceptions for PiP windows. That being said, if you are willing to compile AutoRaise yourself, below are the changes required for disabling PiP auto focus/raise.

 static const NSString * FinderBundleId = @"com.apple.finder";
 static const NSString * AssistiveControl = @"AssistiveControl";
 static const NSString * BartenderBar = @"Bartender Bar";
+static const NSString * ChromePiP = @"Picture in Picture";
+static const NSString * FirefoxPiP = @"Picture-in-Picture";
 static const NSString * XQuartz = @"XQuartz";
 static const NSString * Finder = @"Finder";
 static const NSString * NoTitle = @"";

... Lots of code in between ...

-                if (titleEquals(_mouseWindow, @[BartenderBar])) {
+                if (titleEquals(_mouseWindow, @[BartenderBar, ChromePiP, FirefoxPiP])) {
                     needs_raise = false;
                     if (verbose) { NSLog(@"Excluding window"); }
                 }

P.S. Similar to the IgnoreApps option, it could be useful to introduce something like an IgnoreWindows option. In this way the hardcoded BartenderBar window can also be removed. Something to consider for a future release I suppose.

GNRSN commented 1 year ago

+1 for this issue

The Arc browser (chromium based) uses PiP aggressively for video and autoraise breaks interacting with the PiP-window completely.

sbmpost commented 1 year ago

@GNRSN Does the fix above work for the arc browser? I might consider making it part of master then

GNRSN commented 1 year ago

@sbmpost I'm running AutoRaise though Homebrew at the moment but I will atempt to build it myself as soon as I can find the time for it. The Readme states

To compile AutoRaise yourself, download the master branch from here and use the following commands:

But I assume its ok just to clone the repo as well? If so I can open a PR if I can validate that the fix improves the situation for me 😄

sbmpost commented 1 year ago

@GNRSN Of course cloning (or forking) is also an option. I think for arc/chromium we might consider the fix. For firefox perhaps not. They use slightly different names for their pip windows. Feel free to create a PR.

GNRSN commented 1 year ago

@sbmpost Unfortunately it didn't seem to work for Arc, the issue I'm having is that as soon as I move the cursor over the Arc PiP player with autoraise enabled the window/workspace focus is switched from my current workspace to wherever the Arc window acting as source for the PiP is running, focusing that window.

In combination with the Arc PiP repositioning itself (for some reason?) whenever I traverse workspaces with ctrl+arrows right/left autoraise is often accidentally triggered, taking me back to the workspace where I'm running Arc => super annoying.

When trying out the fix and trying to compare the effects I didn't really get what the issue with the chrome PiP window (the one you get from the official chrome extension I assume?) is. It doesn't seem nearly as bad as the issues I'm having with Arc.

I tried checking for Arc window names using https://github.com/smokris/GetWindowID but they all list as null, I get the chrome PiP to list with its correct name though so I guess the fault is at Arc and I will go raise an issue there about it.

Edit: Possibly there could be a config option for some kind of window min-size as a work around? as most PiP windows are smaller than any window one would normally use.

sbmpost commented 1 year ago

@GNRSN Thanks for the detailed investigation. The window size could be used but then again it doesn't sound ideal. Can I reproduce the unwanted behavior myself by simply downloading arc and run it? Maybe an alternative (temporary) fix can be found. I should mention I am currently on a 1 week holiday so I will only be able to investigate after that.

sbmpost commented 1 year ago

@GNRSN Having played around with ARC myself a bit, I am not able to reproduce the issue. Perhaps this was fixed on their end?

echo-saurav commented 1 year ago

hey, i don't know who fixed it , but i no longer having this issue anymore

echo-saurav commented 1 year ago

hey one thing, i can not click on three dot menu on arc browser (at right top)

GNRSN commented 1 year ago

@sbmpost I need to validate that i'm running the latest version but I still have the same issues, I will check my config and get back with an update.

I have a suspicion though that my issues are actually caused by Yabai but made worse in combination with AutoRaise.

GNRSN commented 1 year ago

Alright, I've upgraded to Autoraise 4.0, I was previously on 3.8(?)

To define the repro I'm testing against, this is what I'm doing With youtube open in Arc, switch to another tab to trigger the PiP, then also switch to an adjacent Space in MacOS

Without Yabai or Autoraise running

With Autoraise running

With Only Yabai running

With Yabai + Autoraise

I think my next step will be to ignore/exclude Arc in both Yabai and Autoraise. At the moment accidental space-switching when moving the cursor over the PiP is what I find most annoying.

GNRSN commented 1 year ago

Here is an update if anyone faces this same issue

Now I can keep using Arc PiP with Yabai and Autoraise running, the only downside is that the main Arc window doesn't trigger Autoraise, this is acceptable for my personal workflow though.

sbmpost commented 1 year ago

@GNRSN

May I suggest to disable raise and focus only? The raise functionality causes the application as a whole to activate whereas merely focusing on hover will only give focus to the pip window. I don't know if you are relying on raise. If not, then the focus only setting may be a good alternative?

GNRSN commented 1 year ago

@GNRSN

May I suggest to disable raise and focus only? The raise functionality causes the application as a whole to activate whereas merely focusing on hover will only give focus to the pip window. I don't know if you are relying on raise. If not, then the focus only setting may be a good alternative?

@sbmpost Would you mind instructing me in how to do so? 😅

What would I add to my config file and do I need to compile with EXPERIMENTAL_FOCUS_FIRST?

sbmpost commented 1 year ago

@GNRSN

The easiest and quickest option would be to simply download the UI version from here: https://github.com/sbmpost/AutoRaise/blob/master/AutoRaise.dmg

If however you would like to compile the non UI version instead you can say:

make clean && make CXXFLAGS="-DOLD_ACTIVATION_METHOD -DEXPERIMENTAL_FOCUS_FIRST" && make install

You'd then update your ~/.AutoRaise config file replacing delay=1 with focusDelay=1

@GNRSN @echo-saurav In addition I have created an experimental branch that should fix the arc issues: https://github.com/sbmpost/AutoRaise/tree/143-pip-arc

Note this is a work in progress but so far seems to work fine.