Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to override floating rules #4782

Closed
wants to merge 1 commit into from

Conversation

elParaguayo
Copy link
Member

Some float rules (e.g. fixed size/aspect ratio) can be too broad and users may want exceptions to these rules. It is possible to do this with hooks but they can become unwieldy with multiple exceptions.

This PR adds an override_rules argument to the floating layout. Where a window matches one of these rules then window will not be floated.

Question for @tych0 - any idea where the test fails if the windows are added in the other order? i.e. if I open the nofloat window second, the focus remains on the first one so manager.c.window points to the wrong window.

Some float rules (e.g. fixed size/aspect ratio) can be too broad and
users may want exceptions to these rules. It is possible to do this with
hooks but they can become unwieldy with multiple exceptions.

This PR adds an `override_rules` argument to the floating layout. Where
a window matches one of these rules then window will not be floated.
@tych0
Copy link
Member

tych0 commented Apr 28, 2024

I think it's "intentional", i.e. when we add a window underneath a floating window, the floating window remains focused. But,

  •     return matches and not overrides
    

this whole patch seems to be because our Match rules can't express this and not pattern. Can we make it possible for matches to express that instead somehow? Otherwise potentially everywhere we use match will need a patch like this.

@elParaguayo
Copy link
Member Author

Good idea. Let me rework this.

@elParaguayo
Copy link
Member Author

Thinking about it some more, do we need exceptions for other uses of Match? The float rules have some very broad rules which may benefit from some exceptions. But, for other times when users provide Match rules, they're typically very focused already.

@elParaguayo
Copy link
Member Author

The alternative would be to allow a Match object to take a list of Match objects to treat as exceptions to the parent.

@tych0
Copy link
Member

tych0 commented Apr 28, 2024

Thinking about it some more, do we need exceptions for other uses of Match? The float rules have some very broad rules which may benefit from some exceptions. But, for other times when users provide Match rules, they're typically very focused already.

IMO having exceptions for float rules is also weird, but I don't use floating at all, so maybe I don't know. What specifically are the exceptions that people are interested in? Is it because the default rules are too broad?

@elParaguayo
Copy link
Member Author

The float rules are deliberately broad eg they capture all windows requesting a fixed aspect ratio but you may want to carve out some specific apps.

You could do this with a user defined function but then you're asking users to use non documented methods to retrieve properties of windows.

This was just an idea to make it a bit easier for users.

@elParaguayo
Copy link
Member Author

A "fun" way to do it would be to use bitwise operators e.g. (Match(wm_class="notification")) | Match(func=lambda c: c.has_fixed_size())) ~ Match(wm_class="mpv") but that's far less intuitive for users and is probably pretty complicated to code!

@tych0
Copy link
Member

tych0 commented Apr 29, 2024

Honestly, I like it. A DSL for window matching. I guess you mean (Match(wm_class="notification")) | Match(func=lambda c: c.has_fixed_size())) & ~Match(wm_class="mpv") (additional &) in your example?

I think this would be great :)

@elParaguayo
Copy link
Member Author

Yes - missed the & sign.

OK - I might have a play at implementing this.

@elParaguayo
Copy link
Member Author

I've actually managed to get this working. I still need to write some tests and fix the mypy stuff so will upload later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants