glfw / glfw

A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input
https://www.glfw.org
zlib License
13.02k stars 5.24k forks source link

Borderless Window features #2266

Open sirgru opened 1 year ago

sirgru commented 1 year ago

It would be good if GLFW implemented features on an undecorated window:

  1. Draggability on a custom screen area. Support for standard features like window snapping on Windows.
  2. Resizing.
  3. APIs for minimize/maximize/fullscreen.

These issues are summarized here: https://discourse.glfw.org/t/immovable-resizable-bordeless-window/1586

These features are required because the titlebar is not customizable. Most modern applications will want to reuse the titlebar. Windows supports complete customization of the titlebar in WPF, yet the one drawn with GLFW is old style which doesn't even allow for color customization.

IIRC Electron has this functionality and Flutter does too: https://github.com/bitsdojo/bitsdojo_window

This makes GLFW lag behind modern frameworks. Most of these features seem to be implemented a long time ago for Windows and Linux, and were never merged. It would be good if these features could be merged, because this would significantly modernize the framework for non-games applications.

mdrejhon commented 1 year ago

Ditto.

However, keep support for fullscreen exclusive (e.g. where GLFW siezes exclusive control of the screen on some platforms).

That's required for some applications (e.g. the VSYNC OFF / beamracing ideas posted in #1157).

It also reduces lag/stutter on different-Hz multimonitor systems, since Microsoft Windows is a single-Hz compositor (which means smooth graphics on on screen, stuttery graphics on the other screen) when running in windowed mode or borderless windowed mode on a multiple-Hz system (e.g. 60Hz monitor + 144Hz monitor).

So in a nutshell, all of these need to be support in as cross-platform manner as feasibly possible:

[1] Windowed [2] Boderless full screen window (occasionally-compromised hybrid of windowed and fullscreen) [3] Full screen exclusive (lowest-lag, highest-performance, least-stutter, most control) [4] Offscreen rendering (e.g. #2250)

Both [1] and [2] should be resizeable on the fly or via the OS' standard window-size-set APIs. Although resizeable support of item [2] can vary based on OS to OS. Tons of use cases that only works well with [1], or only with [2], or only with [3], or only with [4], so all use cases needs to exist (#2250 and my comments in #1157 are useful reading to learn about the use cases).

Item [4] is often used for things like streaming or 3D.

The streaming use case (e.g. access to GLFW buffer on headless systems creates a DIY "GeForce NOW" or a DIY "Stadia" or a DIY "Steam Link". Where you use a thin client H.264 device to remotely play a gaming PC.

The 3D/AR/VR/sterescopic use cases that use GLFW workflow seem to use two semi-hacky GLFW instances via item [4] (hacked offscreen contexts) to create the left/right that is sometimes (not always) later merged/multiplexed by a third semi-hacked GLFW instance using item [3] (low latency full screen exclusive) by the 3D developer in the supported 3D format used by the 3D display or VR microdisplay (some use a hidden EDID via things like USB DisplayPort altmode using a special framepacked format) or even pipe to a H.264/H.EVC codec for a 3D VR H.264 stream over WiFi 5/6 (e.g. open source clone of AirLink streaming on Oculus Quest 2 for cordless PCVR removing the HDMI/DisplayPort cable and transmitting the frames over a WiFi H.264/H.EVC stream instead).

With the gradual increase in open source access to VR headsets, keeping GLFW flexibility for [1][2][3][4] is increasingly useful; for developers who want to stay on the GLFW pipeline and workflows;

Especially if Valve releases their merged "Steam Deck" + "Valve Index" standalone headset that competes with Quest 2 (rumor from Discord: ~2025), being the Steam gamestorezilla we love and hate but at least appreciate them being better stewards of Linux than the average game company (FWIW). Their rumored standalone, when it comes out, will undoubtedly be running Linux, and thus benefit huge from GLFW when any of us want to develop VR apps via GLFW, or using GLFW as a porting wrapper from other platforms (e.g. recompile of existing Vulkan-based Oculus Quest apps or PC-based VR apps). And it's also quite possible the same developers may use GLFW to recompile the same software for PCVR (Windows instead of Linux). Making VR porting easier. So prepping the generic API groundwork is key, even if GLFW developers don't have much familiarity with VR (yet).

GLFW also makes recompiling of the same VR application for PCVR and for standalone potentially much easier, with just a few minor changes to GLFW! VR development is so horrendously difficult, so minor changes to GLFW has a overweighted gigantic developer-easing multiplier support if [1][2][3][4] are concurrently offered and centralized into GLFW best-effort.

Many existing game engines (e.g. Unity) are used with GLFW or are used with VR, so making it easier to do both simultaneously is quite golden.

Also item [3] is usually the lowest-latency visible-to-user mode of [1][2][3][4] above, since it bypasses the windows compositor, important for ultra-latency-critical applications such as AR/VR rendering. Interesting side effects such as notification popup windows will work with item [1] and [2] on all platforms but almost never visible on item [3]. (So lowest latency and popup-visibility/ability to Alt+Tab to make an overlay window visible is sometimes diametrically opposed pro/cons).

Most operating system window managers currently supports at least 3 out of the 4 bullet items, and several supports 4 out of 4 bullet items above.

Historically, most of the time this stuff is punted to the end-developer to figure out, but doing best-effort centralizing the crossplatformness of [1][2][3][4] (ideally with success/fail support, or "what-is-supported" discovery built into GLFW for each) is highly favorable, and is right in GLFW's alley because other graphics frameworks are (at least partially) doing it this way -- and now it's kinda high time for GLFW to take the logical baton on this;

So standardizing this into GLFW is definitely hugely favourable... GLFW core developers doesn't necessarily need to know what GLFW users are necessarily doing, or even know VR, or the weird stuff users do, but it would be a gigantic developer-easing to see GLFW movement in this area;

But merely concurrently offering [1][2][3][4] in a reasonably best-effort crossplatform manner, still expands use cases by roughly an order of magnitude, if crossplatform daisychaining GLFW into another GLFW instance is supported (see multiple example of daisychainable combinations in #2250).

dougbinks commented 11 months ago

There is already a preexisting issue open for support for resizing undecorated windows #990

Seneral commented 10 months ago

True, but it's dissappointing to see there has been no action taken on any of the many merge requests. What do you think does it take for glfw to finally merge these? As a developer, I really hate having to scratch together solutions from many merge requests to get working what should long have been merged. Currently, I only have dragging working, snapping on windows doesn't work (but on X11/Wayland), and resizing doesn't work, still haven't gotten around to grab that from any one of the many PRs.

Seriously, we need this for proper desktop application support, please do something about it, there are plenty people willing to work on this but seemingly no commitment by anybody able to merge.

dougbinks commented 10 months ago

@Seneral

True, but it's dissappointing to see there has been no action taken on any of the many merge requests. What do you think does it take for glfw to finally merge these? As a developer, I really hate having to scratch together solutions from many merge requests to get working what should long have been merged.

Seriously, we need this for proper desktop application support, please do something about it, there are plenty people willing to work on this but seemingly no commitment by anybody able to merge.

GLFW isn't a commercial product which owes it's customers a certain level of service. It's primarily maintained by one person for no pay. Indeed on top of the time needed development of GLFW costs money due to the wide range of hardware required. Comments such as yours do not help to motivate the maintainers. PRs are not merged by simply waiving a wand, and there's a huge amount of unseen work which goes into the development of GLFW.

Seneral commented 10 months ago

I didn't know it was one person - maybe it's time to take on more maintainers then. Is there anything I can do to make it easier to vet these merge requests, which people already seem to be using in production? Some of them have been open since 2017, so I really think it's time to do something. If the current process allows merge requests to stay open for 6 1/2 years (which wastes everybodys time), that's not cool. Again, my intent was not to imply we deserve support - in good open source spirit there have been people giving solutions from quite early on, I just see no indication this is taken seriously at all, which leaves me concerned, especially since this is required to support e.g. wayland on gnome, where there are NO ways to drag or resize a glfw window right now (had to disable libdecor integration of glfw because it hard-crashes my application, probably separate issue). Nvm, fixed in 3.3.9! Nice - so this is now at least just for custom CSDs, which I would still want, but at least it's not as pressing anymore. Edit end. I just hate to see that the only real solution for many years now seems to be "make a fork and merge it yourself" - which means tons of duplicate work and wasted time. To be clear, I will do that now, since I don't think this will change anytime soon. Sorry if this offended anyone

dougbinks commented 10 months ago

I didn't know it was one person - maybe it's time to take on more maintainers then.

Taking on maintainers is not easy and doesn't always solve things.

If the current process allows merge requests to stay open for 6 1/2 years (which wastes everybodys time), that's not cool.

There are always multiple different priorities for different people. Simply keeping old features from working is a lot of work: supporting an evolving Wayland, dealing with new OS features which break things, or MacOS' deprecation of older features we rely on. As I mentioned even merging working PRs which cover the entire array of platforms isn't as simple as clicking 'merge'. There is usually a lot of work to do to with any PR.

Seneral commented 9 months ago

For the record, #2152 is, IMO, ready to merge

dougbinks commented 9 months ago

It takes a considerable amount of time for us to review and merge a PR, even one which are ready to merge. Even simple ones with only one OS affected and a very small amount of code take a considerable amount of time to check and merge..

Seneral commented 9 months ago

I didn't write it with the intend to argue - that's what the "for the record" was for. I don't expect anything, don't worry