Win32: Fix using executable instance and not ours

Operations that take an instance handle should be passed the handle of
whatever module we are inside instead of blindly passing the handle of
the executable.

This commit makes GLFW retrieve its own instance on initialization.

This makes the most difference for window classes, which are
per-instance.  Using the executable instance led to name conflicts if
there were several copies of GLFW in a single process.

Note that having this is still a bad idea unless you know what things to
avoid, and those things are mostly platform-specific.  This is partly
because the library wasn't designed for it and partly because it needs
to save, update and restore various per-process and per-session settings
like current context and video mode.

However, multiple simultaneous copies of GLFW in a single Win32 process
should now at least initialize, like is already the case on other
platforms.

Fixes #469
Fixes #1296
Fixes #1395
Related to #927
Related to #1885
This commit is contained in:
Camilla Löwy
2022-03-17 23:54:39 +01:00
parent 66a4882eb1
commit 07a5518c3e
6 changed files with 20 additions and 6 deletions

View File

@@ -442,6 +442,7 @@ typedef struct _GLFWwindowWin32
//
typedef struct _GLFWlibraryWin32
{
HINSTANCE instance;
HWND helperWindowHandle;
HDEVNOTIFY deviceNotificationHandle;
int acquiredMonitorCount;