canonical / mir

The Mir compositor
GNU General Public License v2.0
627 stars 100 forks source link

Move alt tabbing logic to the scene instead of the `ApplicationSelector` #3235

Open mattkae opened 8 months ago

mattkae commented 6 months ago

Currently downlaoding everything into my :brain: :

mattkae commented 6 months ago

Solution

mattkae commented 6 months ago

And yet another complication! The SurfaceStack holds a std::vector<std::vector<Surface>>. It has a different focus order for each layer essentially. But we would want an overall focus order of all focusable surfaces. This is a bit different. I wonder if we actually need a different focus order for each layer (probably).

mattkae commented 6 months ago

Things that care about the layers:

And that's it. Looks like we can pretty safely implement that method with a flat layer list representing the current focus order. But now I am having second thoughts if that's actually the best thing to do.

mattkae commented 6 months ago

It's the right place IMO. It implements msh::SurfaceStack, which only cares about focus

mattkae commented 6 months ago

AH! And the list generated by scene_elements_for needs to be in stacking order. That's a big reason not to make that switch. But it does mean that we should have a separate list for the focus order. Or perhaps we can do something very clever to avoid the hit of iterating the list too many times.

mattkae commented 6 months ago

Keeping two lists in parallel is a mess though. There must be a better way !

RAOF commented 6 months ago

So, I think you've got there, but rather than augmenting SurfaceStack with additional focus responsibilities, I think we should be paring back SurfaceStack. It is almost (but not quite) our pseudo-scenegraph - its interfaces are “what is the topmost surface under this point”, “get me a list of {buffer, position} pairs in rendering order”, and various manipulations of the stack (add, remove, raise, lower), and then a couple of miscellaneous bits (which maybe we should remove when we get a better abstraction??).

Focus is not the same as stacking order - things like floating regular windows are above, but don't (necessarily) have focus. For a focus-follows-mouse mode focusing a window doesn't even imply raising it.

On the other end, ApplicationSwitcher should be able to cycle through the applications without changing the stacking order until the alt-tab sequence is complete (it's a persistent low-grade annoyance to me that switching between windows with alt-tab messes up the stacking order).

I think we need to keep two separate lists because there are two distinct lists, and also because they're lists of different things. One's a list of surfaces¹, the other's a list of applications. Changing one does not necessarily require a change to the other.

¹: Actually, It's not a list of surfaces; it's a list of windows, which it probably shouldn't be.

mattkae commented 6 months ago

@RAOF: Why shouldn't it be a list of windows? In fact, it also has to be a list of surfaces to handle alt+tick functionality as well (although that would be a list of surfaces within the list of sessions)