-
Notifications
You must be signed in to change notification settings - Fork 15
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 exwm-client-message-functions #51
Add exwm-client-message-functions #51
Conversation
I think this is a good idea in general, but there are still some implementation details to work out. Currently, each function added to This approach is simplest to implement and most flexible, but we do incur the performance cost of repeatedly checking slot-values on the message in each hook function. We should do some performance measurements to see if this is worth optimizing. One simple optimization would be ordering the default value of the hook functions so that the most frequent types of messages are checked for first. Another idea would be to generate hook functions for each type of client message programmatically. Once we figure this out, we should add a similar hook for Thoughts, @minad @Stebalien ? |
9f1b08b
to
18c54df
Compare
I'm not a fan of exposing such a hook to users as EXWM is likely to misbehave if a user mishandles these messages. If the user really needs full control, they can listen to the event themselves and/or advise the function. In terms of a handling fullscreen changes, etc., I'd add a separate hook for that (like the floating hook, manage hook, etc.). I am a fan of breaking this up but I wouldn't use a hook. I'd eitehr:
From my brief look, it appears that we always switch on the "type". |
Isn't that the case for every hook in Emacs? |
Not really. Hooks are user-facing extension points and package authors tend to take care to make sure:
I agree we should have a hook, but it should be higher level. Let the user hook into a specific behavior (EXWM is making a window full-screen) instead of asking the user to hook into the raw X event stream. |
I think any hook can be "too sharp" given that it executes arbitrary code, so it's not a metric I would use to consider whether a hook is worth it or not. All hooks are "caveat utilitor". That's the price of the flexibility.
Do you foresee any compatibility hazards in this case?
I see no reason we can't offer both types of hooks. Lower level for those who wish to hook in there, and higher level for users who want that. |
In this case, there are multiple ways to get a full screen window:
When we encourage users to hook into low-level features, any low-level change can break their code. That's not to say that we should prevent users from hooking into these features, but we shouldn't encourage it by creating hooks. If the user wants to receive client messages, they can listen for them the same way EXWM does. But by hooking into EXWM's event stream (and possibly filtering it), they can easily end up getting EXWM into an inconsistent state. Again, we shouldn't prevent this, but this kind of low-level interception is exactly what advice is designed for. |
656b465
to
b13766c
Compare
We'll have to agree to disagree here. In any case I've amended the patch to use what I think is a fair compromise. |
Well, but the client message handling is already low level, so you are providing a hook for something which shouldn't really be exposed. I tend to agree that hooks should be provided for high level functionality. Also I am on board with refactoring and decompose the client message handler function. |
This sounds like a good compromise. There also shouldn't be a significant performance impact, given that alist-get/assq is fast for short lists. |
I agree, this sounds like a good compromise. |
Tested locally and this appears to work. I'll merge when you mark it ready. |
b13766c
to
2e8b149
Compare
Do not merge yet. |
Huh. You're right. And yet EXWM sitll... mostly seems to work. I expected it to completely break in this case... |
It looks like we need to set it after starting EXWM (or, even better, have a template with the atom symbols that we then evaluate on init to create the runtime mapping). TBH, these atoms should probably be properties of the connection itself... |
08dd5af
to
2b2ee72
Compare
I went with a simple approach for now. |
* exwm.el (exwm--client-message-functions): Alist for dispatching client messages to handlers. (exwm-init): set exwm--client-message-functions once exwmh support enabled. (exwm--on-ClientMessage): delegate via exwm--client-message-functions, decompose body into separate handlers. See: ch11ng/exwm#931
2b2ee72
to
f152df4
Compare
Looks like it's not as big a threat as it seemed. |
(subtle bugs are worse, IMO) |
Ok, tested minimize, full screen, and close by client request. |
(exwm--on-ClientMessage): delegate to said hook, decompose body into separate hook functions
See: ch11ng/exwm#931