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 "this creates/frees an XID" to the XML and use that for better generated API #589

Open
psychon opened this issue Jan 10, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed P5 Priority Nice-to-have question Further information is requested stable API Things that might require API changes

Comments

@psychon
Copy link
Owner

psychon commented Jan 10, 2021

Related: #369 and #516

We could do something like the following:

diff --git a/xcb-proto-1.14-1-g2b3559c/src/xproto.xml b/xcb-proto-1.14-1-g2b3559c/src/xproto.xml
index dea48df..7281c5a 100644
--- a/xcb-proto-1.14-1-g2b3559c/src/xproto.xml
+++ b/xcb-proto-1.14-1-g2b3559c/src/xproto.xml
@@ -3748,7 +3748,7 @@ The maximum number of fonts to be returned.
 
   <request name="CreatePixmap" opcode="53">
     <field type="CARD8" name="depth" />
-    <field type="PIXMAP" name="pid" />
+    <field type="PIXMAP" name="pid" xid="create" />
     <field type="DRAWABLE" name="drawable" />
     <field type="CARD16" name="width" />
     <field type="CARD16" name="height" />
@@ -3789,7 +3789,7 @@ The X server could not allocate the requested resources (no memory?).
 
   <request name="FreePixmap" opcode="54">
     <pad bytes="1" />
-    <field type="PIXMAP" name="pixmap" />
+    <field type="PIXMAP" name="pixmap" xid="free" />
     <doc>
       <brief>Destroys a pixmap</brief>
       <description><![CDATA[

No idea what to do with the free annotation, but the create would allow to provide a more Xlib-y API where the new XID is returned instead of provided by the caller. That would then remove the need for generate_id() and thus fix #516.
(Another option would be to add new XML <free name="pid" /> and <create name="pid" /> that is only allowed inside of <request>. More bikeshedding options...)

My preferred approach for how to tackle this would be to first propose a WIP patch upstream to xcb-proto and get through the bikeshedding on how to call this and how to integrate that with XSD rules. After the "how" is done, one could go through all the extension and figure out where to add the annotations. Hopefully, the result would then be mergable upstream.

Open questions include:

CC @not-a-seagull just FYI. Feel free to just ignore this, but I thought you might be interested in this. Right now, it looks like you have e.g. a hand-written wrapper for create_pixmap that already returns the XID.

@psychon psychon added enhancement New feature or request help wanted Extra attention is needed question Further information is requested stable API Things that might require API changes P5 Priority Nice-to-have labels Jan 10, 2021
@notgull
Copy link
Collaborator

notgull commented Jan 10, 2021

I probably wouldn’t use it (the manual design of breadx is an intentional decision), but I would support it. Scratch that I would 100% use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed P5 Priority Nice-to-have question Further information is requested stable API Things that might require API changes
Projects
None yet
Development

No branches or pull requests

2 participants