a-ba / squint

Duplicate an X11 monitor into a window
GNU General Public License v3.0
17 stars 2 forks source link

Passive mode #4

Closed br0xpl closed 1 year ago

br0xpl commented 1 year ago

Hi there @a-ba,

Nice project!

I'm using i3wm and when working in windowed mode squint "steals" the focus from source monitor because i3wm by default changes focus to the window requiring attention.

Added quiet mode so that squint works well without dropping focus of the source monitor.

Let me know what you think about this.

a-ba commented 1 year ago

Several notes here:

  1. Quiet mode may not be the most appropriate term for describing the feature. The window will not go blank, it will still display the content of other monitor. I think passive mode would be more relevant (i.e. it mirrors the other monitor but without tracking user inputs and reacting to them). I am renaming the PR Passive mode.

  2. Squint never takes the focus.

    • gdk_window_raise()/gdk_window_hide() only moves the window to the top or bottom of the stack, which should be a no-op on tiling window managers.
    • Acquiring the focus is a separate action which is initiated by the window manager: WM sends WM_TAKE_FOCUS, client receives it and if it wishes to take the focus then it explicitely calls XSetInputFocus to receive the focus.
    • The squint window is configured with gdk_window_set_accept_focus == FALSE, this prevents gdk from calling XSetInputFocus when it receives WM_TAKE_FOCUS.
    • My best guess here it that i3wm does not fully comply with ICCCM. I tried with spectrwm which is another tiling window manager and it does not seem to have the issue.
  3. In the submitted code, the passive mode has no effects in fullscreen. It should be made clear that both options cannot be used together: selecting fullscreen mode should disable passive mode and vice versa. It could be interesting to support it in fullscreen mode too, but this would at least require to add an overlay button to let the user close the window in last resort (in case it is misconfigured).

While I believe this is a WM bug, i am inclined to add such a feature. They may be other cases where it could be useful.

br0xpl commented 1 year ago

Hi @a-ba, Yes I agree fully, specific replies:

  1. Yeeees indeed passive sounds really nice, I was thinking several minutes and I couldn't go with anything better than quiet (I was thinking, no raise etc.). Passive is good.
  2. Yes, that is exactly what I've seen as well, this is done by i3wm, it can be changed though with "focus_on_window_activation" option in i3wm. So actually I had a workaround but I thing raising window can also be not wanted thus I decided for the PR here. My setup marks attention windows with red border, so everytime I moved the mouse to the mirrored screen the border was turning red which was also disturbing me a little bit.
  3. Yes it has no meaning in fullscreen but please be aware that the fullscreen mode can be toggled on and off during runtime of squint - thus the passive mode is nicely preserved. Maybe it is enough to just state in the description of passive mode that this has no effect while in fullscreen?

How do we proceed? Will you take over from here? Or do you want me to continue the fix?

Kind regards!

a-ba commented 1 year ago

I did a few fixes and optimisations in br0xpl/squint#1. Please test it and tell me if it looks fine for you.

br0xpl commented 1 year ago

@a-ba it works good!

Just one remark: I'm not sure if -p should imply -w... as I wrote previously I see a usecase like this:

  1. I run in fullscreen but in passive mode (which has no effect in fullscreen but "is remembered")
  2. I then switch between fullscreen and windowed mode, and the "passive" is kept "on".

You can leave it as it is but the above scenario will not work in such implementation.

a-ba commented 1 year ago

That makes sense. I reverted this change.

I opted for another solution : disable the Passive menu item when running in fullscreen mode. This way is even less confusing that the mutual exclusion.

br0xpl commented 1 year ago

Hi @a-ba, great, thank you! I've tested this and merged it on my side.