floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
7.12k stars 501 forks source link

[sokol_app] Status of clipboard support on X11? #995

Closed Dvad closed 2 months ago

Dvad commented 9 months ago

The X11 clipboard getter is left non implemented currently :

SOKOL_API_IMPL const char* sapp_get_clipboard_string(void) {
    if (!_sapp.clipboard.enabled) {
        return "";
    }
    #if defined(_SAPP_MACOS)
        return _sapp_macos_get_clipboard_string();
    #elif defined(_SAPP_EMSCRIPTEN)
        return _sapp.clipboard.buffer;
    #elif defined(_SAPP_WIN32)
        return _sapp_win32_get_clipboard_string();
    #else
        /* not implemented */
        return _sapp.clipboard.buffer;
    #endif
}

I wonder if there is a reason to that and if you would be open to have an implementation added. If so, I am happy to submit a PR.

Thank you for this really great library!

floooh commented 9 months ago

Hmm, as far as I can see there's currently no clipboard support at all in the sokol_app.h X11 backend. I don't know how "terrible" an implementation via Xlib would be, but if you want to give it a shot and provide a PR I won't stop you ;) (a good starting point and inspiration would be GLFW).

Dvad commented 9 months ago

I have a version of this function locally already, indeed inspired from glfw. I found X11 api is quite cryptic on the clipboard side so I am not super confident it is not terrible :). I will submit a PR!

floooh commented 2 months ago

I ended up merging the 'extended' PR here which is based on your PR: https://github.com/floooh/sokol/pull/1108