lv2 / pugl

A minimal portable API for embeddable GUIs
https://gitlab.com/lv2/pugl/
ISC License
179 stars 34 forks source link

X11/KDE: puglSetCursor for arrow/default fails with bad parameter error #81

Closed falkTX closed 2 years ago

falkTX commented 2 years ago

When changing the cursor to something custom and then trying to revert back to the default, puglSetCursor(view, PUGL_CURSOR_ARROW) fails with PUGL_BAD_PARAMETER. To be more precise, it fails because XcursorLibraryLoadImage returns null. Happens at least with X11 with KDE, running Ubuntu/Neon 20.04.

Changing "default" to "left_ptr" makes this work. So it seems to be "just" a matter of picking the correct name.

I did a quick check and passing zero/null as the cursor for XDefineCursor allows the cursor to revert to default. So perhaps an idea would be to simply unset the cursor entirely instead of trying to set the default one?

drobilla commented 2 years ago

It depends on the cursor theme. In my testing, default seemed to be the most universally present one that made sense in every environment I tried (and left_ptr noticeably didn't work with several).

drobilla commented 2 years ago

Please test proposed solutions, preferably in patch form, to the same level. Specifically:

With several cursor themes, in each, using (at least) pugl_cursor_demo.

falkTX commented 2 years ago

what about simply unsettling the cursor?

falkTX commented 2 years ago

sorry I think I misunderstood. I can try the unsetting-cursor on those environments yes

drobilla commented 2 years ago

I dunno. Assuming it always actually changes it to the default, sure, I guess? Point being that this stuff seems wildly inconsistent, so half-baked "works for me" guesses aren't going to cut it and it needs to be well-tested in a bunch of environments. How XCursor themes are this much of a seemingly unstandardized mess is beyond me...

Note that GLFW uses "default", although it also uses things like "ew-resize" which don't work for me with several setups.

Worst case scenario, I suppose it would be possible to try several names, but that would make the code quite a bit more complicated.

falkTX commented 2 years ago

For some reason I no longer have issues regarding this with latest pugl.. Unsetting the cursor to arrow/default is working fine.

drobilla commented 2 years ago

:shrug: I'll assume it's fine until proven otherwise, then.

falkTX commented 2 years ago

Yes, I have not seen the issue come back yet, so we can assume it is fine.