sokol icon indicating copy to clipboard operation
sokol copied to clipboard

[Feature Request] Options for borderless or minimal windows

Open lazalong opened this issue 3 years ago • 5 comments

Hi

On Windows, I was able to make borderless Sokol window by "only" modifying line 6785 of sokol_app.h with one of the following options;

DWORD win_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP | WS_CAPTION | WS_SIZEBOX;
DWORD win_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP | WS_SIZEBOX;
DWORD win_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP ;

The first one will create a window with only the border to resize and the top caption to move the window. The second will have only the resizing border. The third will have none of those.

It would be great to be able to pass a parameter to _sapp_win32_create_window to choose one of those options.

Of course, it means that the programmer must take the responsibility to provide a way to close the window - such as a button or key command. Still this would enable to make application having top bars such as:

Example of borderless top

Btw, I know there are similar or related issues:

  • soft fullscreen mode on macos https://github.com/floooh/sokol/pull/314
  • Borderless Window : https://github.com/floooh/sokol/issues/313

Screenshot of the border less version:

Sokol Borderless

lazalong avatar May 01 '22 03:05 lazalong

Create a PR 660

To test it just modify the sample cube-sapp.c with:

sapp_desc sokol_main(int argc, char* argv[]) {
    (void)argc;
    (void)argv;
    return (sapp_desc){
        .init_cb = init,
        .frame_cb = frame,
        .cleanup_cb = cleanup,
        .event_cb = __dbgui_event,
        .width = 800,
        .height = 600,
        .sample_count = 4,
        .gl_force_gles2 = true,
        .window_title = "Cube (sokol-app)",
        .icon.sokol_default = true,
        .wbs = WBS_BORDERLESS,    // <--------  WBS_FULL or WBS_RESIZE_AND_CAPTION or WBS_RESIZE
    };
}

lazalong avatar May 01 '22 04:05 lazalong

In the (stale) multiwindow branch I had a simple 'no_decoration' flag in sapp_desc:

https://github.com/floooh/sokol/blob/57688eb0c5d09f6149ae6a612c5b53a56e94c328/sokol_app.h#L1401

...would this be enough? Maybe combined with an additional no_resize (although in this case, programmatic control over window movement and sizing must also be added, for instance like thise (I don't particularly like the 'client' naming, but there needs to be a differentiation between what framebuffer pixels (what sapp_width() and sapp_height() report), and window system pixels (for the window movement and sizing):

https://github.com/floooh/sokol/blob/57688eb0c5d09f6149ae6a612c5b53a56e94c328/sokol_app.h#L1488-L1521

I don't want to introduce a too detailed control over window behaviour and look because this might be hard to 'emulate' on different platforms.

floooh avatar May 01 '22 09:05 floooh

Your branch seems good. It should be able to satisfy any requirements I imagined with my proposal. :)

lazalong avatar May 01 '22 10:05 lazalong

Would be fantastic to see you push your branch on in @floooh. Would be very helpful.

ylluminate avatar May 02 '22 03:05 ylluminate

I will only start merging bits and pieces from the multiwindow branch, I've been digging myself into a massive hole with the multiwindow stuff on macOS which required too many changes both to the sokol_app.h internals and sokol_gfx.h that I'm not happy with.

floooh avatar May 02 '22 09:05 floooh