-
Notifications
You must be signed in to change notification settings - Fork 26
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 context managers for pixmaps and graphic contexts #109
Comments
I'm more interested in accepting a patch for it than implementing it myself :-)
…On Mon, Aug 31, 2020, at 4:40 PM, m-col wrote:
Context managers for these would mean we don't need try-finally blocks to free them after use, which makes it neater and easier to correctly handle exceptions. Would you be interested in implementing this?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#109>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAF7VVZ6TR3JJKWIKNOVH7LSDQRFHANCNFSM4QRAMCNA>.
|
I suspected that would be your response so I have been digging into the code :) From what I can tell, the context managers would need to be added to the generated xproto.py, because the init.py can't see the xproto stuff. Implementing this in Python would be a piece of cake, but this seems like it would be a Haskell patch. Am I heading in the right direction? Perhaps I can give my Haskell-loving pal a hard poke. |
Can you give an example usage of what you're thinking here? I'm not sure I quite understand what it would look like. Might be a haskell patch and the haskell is... not pretty. It started out really pretty, but xcb is very inconsistent, and slowly more and more state monads, etc. had to be added :( |
This would let us change this:
into this:
|
I think we've traditionally wrapped this type of thing in libqtile's xcbq; you could just write a little pixmap class there that would do this type of thing. However, it does seem useful more generally, so if you still want to hack on this here's some thoughts. IMO, doing Another option would be to do something like Given that you have to create this list manually, maybe it's time to add an |
Yeah that all sounds much clearer. What else would you move from xcbq.py into xcffib.wrappers? |
Anything that looks reasonable :). This seems good for a start, but if you see other stuff that looks obvious, that's fine too. |
Context managers for these would mean we don't need try-finally blocks to free them after use, which makes it neater and easier to correctly handle exceptions. Would you be interested in implementing this?
The text was updated successfully, but these errors were encountered: