Skip to content

Add platform and wayland.libDecor init hints #10

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markjfisher
Copy link

@markjfisher markjfisher commented Jan 15, 2024

I wanted to add platform hints to my code as follows

glfw {
    errorCB = defaultErrorCB

    initHint {
        if (glfw.Platform.Wayland.supported) {
            platform = GLFW_PLATFORM_WAYLAND
            libDecor = GLFW_WAYLAND_PREFER_LIBDECOR
        }
    }

I can do this with the extensions:

var InitHint.platform: Int
    get() = throw Exception("No getting allowed")
    set(value) {
        glfwInitHint(GLFW_PLATFORM, value)
    }

var InitHint.libDecor: Int
    get() = throw Exception("No getting allowed")
    set(value) {
        glfwInitHint(GLFW_WAYLAND_LIBDECOR, value)
    }

but I thought I'd also contribute them to your repository if you're willing to take them!

I've actually put the libDecor in its own "wayland" block within InitHints, so it reads like this for normal usage:

glfw {
    errorCB = defaultErrorCB

    initHint {
        if (glfw.Platform.Wayland.supported) {
            platform = GLFW_PLATFORM_WAYLAND
            wayland {
                libDecor = GLFW_WAYLAND_PREFER_LIBDECOR
            }
        }
    }

I was torn on a name for platform, as it's already a property name. I went with simplicity though as we're already in the InitHints block, but it could also be platformHint.

Additionally, I kept them as properties rather than functions, despite not being able to read the value, as I feel the syntax is nicer, i.e. platform = GLFW_PLATFORM_XXX rather than platform(GLFW_PLATFORM_XXX) as everything else is assigning rather than calling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant