Commit Graph

212 Commits

Author SHA1 Message Date
Camilla Löwy
a465c1c32e Win32: Simplify window class handling
By using window class atoms, we only need to mention each window class
name once, also removing the need to define _GLFW_WNDCLASSNAME.  It can
still be defined by the user as before.
2022-06-09 18:39:37 +02:00
Camilla Löwy
736a88b067 Fix return type of functions returning bool values 2022-06-08 22:14:38 +02:00
Camilla Löwy
07a5518c3e 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
2022-03-18 00:45:04 +01:00
Camilla Löwy
aa803f7de5 Win32: Update rationale for reimplementation
It is true that plain MinGW lacks this header, but that is not the main
reason for reimplementing IsWindowsVersionOrGreater.
2022-03-10 19:35:23 +01:00
Camilla Löwy
34573798f4 Win32: Rename Windows 10 macros for clarity
This switches the Windows 10 version helper macros to include the
version numbers listed in MSDN requirements sections.
2022-03-10 19:32:21 +01:00
Camilla Löwy
723f3eb40d Win32: Fix maximization showing a hidden window
The normal way of maximizing a window also makes it visible.  This
implements window maximization manually for when the window passed to
glfwMaximizeWindow is hidden.

This will very likely not be forward-compatible and should be replaced.
2022-03-10 19:30:20 +01:00
luz paz
0fe96ec202 Fix various typos
Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille`

Closes #1965
2021-10-25 23:39:06 +02:00
Camilla Löwy
56a4cb0a3a Add runtime platform selection
This adds compile-time support for multiple platforms and runtime
detection of them.  Window system related platform functions are now
called from shared code via the function pointer struct _GLFWplatform.

The timer, thread and module loading platform functions are still called
directly by name and the implementation chosen at link-time.  These
functions are the same for any backend on a given OS, including the Null
backend.

The platforms are now enabled via CMake dependent options following the
GLFW_BUILD_<platform> pattern instead of a mix of automagic and ad-hoc
option names.  There is no longer any option for the Null backend as it
is now always enabled.

Much of the struct stitching work in platform.h was based on an earlier
experimental branch for runtime platform selection by @ronchaine.

Every platform function related to windows, contexts, monitors, input,
event processing and Vulkan have been renamed so that multiple sets of
them can exist without colliding.  Calls to these are now routed through
the _glfw.platform struct member.  These changes makes up most of this
commit.

For Wayland and X11 the client library loading and display creation is
used to detect a running compositor/server.  The XDG_SESSION_TYPE
environment variable is ignored for now, as X11 is still by far the more
complete implementation.

Closes #1655
Closes #1958
2021-10-13 21:47:11 +02:00
Camilla Löwy
bdfe6b09af Win32: Make timer functions backend independent
This is work towards allowing the Null backend to build for Windows
using the Win32 timer API, without the Win32 backend being enabled.
2021-10-12 12:54:37 +02:00
Camilla Löwy
b6834bf2a1 Win32: Remove timeGetTime fallback for timer
The performance counter API is guaranteed to succeed on Windows XP and
later so there is no need for a fallback.

This removes our last dependency on winmm.
2021-10-12 12:54:37 +02:00
Camilla Löwy
35f3b58c21 Win32: Make thread functions backend independent
This is work towards allowing the Null backend to build for Windows
using the Win32 threading API, without the Win32 backend being enabled.
2021-10-12 12:54:36 +02:00
Camilla Löwy
f5758d75d0 Remove context creation backend headers
These headers come from when GLFW only supported a single context
creation API at a time, chosen at compile-time.

Since EGL and OSMesa are now always enabled and the platform-specific
APIs are tied to their specific window system, there is no reason to
keep these declarations separate from the internal.h and *_platform.h
header files.
2021-10-12 12:54:36 +02:00
Camilla Löwy
b7d0c6037d Make dynamic module loading part of platform API
This is part of the preparations for runtime platform selection.
2021-10-12 12:54:36 +02:00
Camilla Löwy
e31deedc99 Make timer init part of platform API
This is part of runtime platform selection because the null backend
needs the timer implementation for the current OS.
2021-10-12 12:54:36 +02:00
Camilla Löwy
efe764b492 Remove blank line before the end of some structs 2021-10-12 12:54:35 +02:00
Camilla Löwy
58b48a3a00 Win32: Remove changing the foreground lock timeout
It's rude to ignore the foreground lock timeout, especially by default.

Discussion of this code and its removal:
https://discourse.glfw.org/t/why-is-spi-setforegroundlocktimeout-set-to-zero-on-glfwinit-win32
2021-08-12 20:50:30 +02:00
Camilla Löwy
85bce8a8ea Replace GL_ARB_debug_output in comments 2021-04-22 22:37:37 +02:00
Camilla Löwy
0bccc3852b Win32: Filter out duplicate size events
This mirrors the filtering done on X11 and Cocoa.  Possibly this should
be done by shared code instead.

Fixes #1610.
2020-11-11 19:10:19 +01:00
Vladimir Perminov
53b1396a09 Win32: Fix value for _WIN32_WINNT_WINBLUE
An incorrect value for _WIN32_WINNT_WINBLUE caused GLFW to think Windows
8 was 8.1 or greater.  This led to a crash when attempting to call
SetProcessDpiAwareness.

Closes #1775.
2020-10-05 23:24:12 +02:00
Camilla Löwy
05dd2fa298 Win32: Disable fb transparency when it is broken
On Windows 7, when GLFW framebuffer transparency and the DWM are enabled
but DWM transparency is disabled (i.e. when the Transparency setting is
disabled under Personalization > Color), the contents of the framebuffer
is combined with the last frame using additive blending instead of
replacing the previous contents.

This commit limits GLFW framebuffer transparency on Windows 7 to when
DWM transparency is enabled, removing the previous workaround of setting
a layered window color key that led to rendering artifacts.

Fixes #1512.
2020-07-29 15:21:45 +02:00
Camilla Löwy
6ce2070392 Win32: Fix non-BMP Unicode codepoint input
Supplementary Plane codepoints from WM_CHAR and WM_SYSCHAR messages were
reported as UTF-16 surrogate pairs.

Related to #1635.
2020-06-29 23:50:05 +02:00
Camilla Löwy
bcb8558189 Remove EGL and OSMesa struct member macros
Now that the EGL and OSMesa structs can be used safely by any platform,
the member macros serve no purpose.
2020-06-24 00:50:49 +02:00
Camilla Löwy
d7f7b0e1b5 EGL: Replace native handle macros with functions
This change is in preparation both for EGL_EXT_platform_base and runtime
GLFW platform selection.

Related to #1691.
2020-06-24 00:48:53 +02:00
Camilla Löwy
51a465ee2b Win32: Remove checks for pre-XP Windows
Windows XP is the oldest version supported by GLFW 3.4.
2020-05-20 17:59:10 +02:00
Camilla Löwy
8e288dc94c Win32: Add GLFW_WIN32_KEYBOARD_MENU
This platform specific window hint enables access to the Windows window
menu via the keyboard shortcuts.
2019-11-11 22:37:18 +01:00
Luflosi
2db3b9688d
Replace some tabs with spaces
I found some tabs where there should be spaces for consistency.
Closes #1496.
2019-06-16 16:57:09 +02:00
Camilla Löwy
a337c56848 Start 3.4 2019-04-16 23:08:39 +02:00
Camilla Löwy
ab118b2529 Fix copyright years (somewhat) 2019-04-15 20:50:00 +02:00
Camilla Löwy
93962ec168 Win32: Fix VS 2010 build error 2019-04-15 02:46:07 +02:00
Camilla Löwy
7c3aaf8065 Win32: Fix OCR_HAND macro missing on MinGW
Fixes #1438.
2019-02-24 04:18:11 +01:00
Camilla Löwy
e2fa82ffbb Cleanup
Related to #1431.
2019-02-13 23:21:05 +01:00
Max Risuhin
cf79f06257 Win32: Fix standard cursors not being DPI aware
Closes #1431.
2019-02-11 19:19:06 +01:00
Camilla Löwy
1725d1c4f5 Win32: Fix build on early Windows 10 SDKs
Related to #1320.
2018-10-22 00:51:08 +02:00
Camilla Löwy
eeac43c3f7 Win32: Fix symbol definition detection
Related to #1320.
2018-09-05 22:45:06 +02:00
Camilla Löwy
089ea9af22 Add GLFW_SCALE_TO_MONITOR
This adds the GLFW_SCALE_TO_MONITOR window hint for automatically
resizing the content area of a window to the requested size times the
monitor content scale each time it is placed on a new monitor.  This
only applies to windowed mode windows and includes the initial placement
at window creation.

This hint only has an effect on platforms where screen coordinates and
pixels always map 1:1 such as Windows and X11.  Platforms like macOS
instead change the resolution of the framebuffer independently of the
window size.

Related to #676.
Related to #1115.
2018-09-03 23:12:39 +02:00
Camilla Löwy
5294439595 Win32: Add support for Per-Monitor V2 awareness
This adds basic support for the Per-Monitor V2 level of DPI awareness
in Windows 10, which allows for automatic DPI scaling of window
decorations.

This commit does not include resizing the window content area to match
the new window content scale.

Related to #1115.
Fixes #1294.
2018-09-03 23:12:39 +02:00
Camilla Löwy
a67d8afbd4 Win32: Clean up DWM detection 2018-08-24 15:06:39 +02:00
Camilla Löwy
f82a8f09eb Win32: Disable mouse trails for full screen
When mouse trails are enabled, the cursor becomes invisible when the
OpenGL ICD detects a full screen window and switches to page flipping.

Mouse trails are now disabled as long as any full screen windows are
visible.

Fixes #1263.
2018-08-02 00:01:26 +02:00
Camilla Löwy
15d89bdff6 Win32: Allow compile-time override of class name
To use, define _GLFW_WNDCLASSNAME to any sane wide string.

Fixes #1120.
2018-05-16 17:15:02 +02:00
Camilla Löwy
c443b02472 Cleanup 2018-04-25 21:50:51 +02:00
Andreas Noever
fcc244ea6d Win32: Fix windows build with WINVER >= Vista
In 32e78aeb2 the definition of DWM_BLURBEHIND in win32_platform.h was
moved behind a WINVER < 0x0600 preprocessor check (< Vista). This broke
the build for WINVER >= 0x0600 since DWM_BLURBEHIND is not defined.

Starting with Vista DWM_BLURBEHIND is available in Dwmapi.h.
So we can just include the header directly on Vista and above.

Closes #1253.
2018-04-25 21:50:51 +02:00
Camilla Löwy
1d75b205cb Cleanup
Allow window creation despite video mode setting failure.

Video mode setting failure is ignored the rest of the time and the
desired video mode has never been a hard constraint anyway.
2018-02-07 16:46:58 +01:00
Camilla Löwy
973bf29622 Remove use of non-standard function strdup
Related to #873.
2018-01-17 11:56:35 +01:00
przemekmirek
9f91bd6ea9 Win32: Fix HDEVNOTIFY handle leak
Closes #1170.
2018-01-05 08:12:51 +01:00
Camilla Löwy
638c4b604e Cleanup 2017-12-06 18:01:33 +01:00
Camilla Löwy
98990217bc Cleanup 2017-11-10 02:58:19 +01:00
Camilla Löwy
16bf872117 Add content scale queries
This adds glfwGetWindowContentScale and glfwGetMonitorContentScale for
querying the recommended drawing scale factor for DPI-aware rendering.

Parts of this patch are based on code by @ferreiradaselva.

Fixes #235.
Fixes #439.
Fixes #677.
Fixes #845.
Fixes #898.
2017-10-26 17:26:36 +02:00
Camilla Löwy
32e78aeb2e Add GLFW_TRANSPARENT attribute and documentation
This completes support for window framebuffer transparency on Windows,
macOS and X11.  Note that the hint/attribute may be renamed before
release to clarify its relationship to GLFW_OPACITY.

Fixes #197.
Closes #1079.
Related to #663.
Related to #715.
Related to #723.
Related to #1078.
2017-09-27 21:54:04 +02:00
Christopher Pelloux
51f0cd3b51 Win32: Implement GLFW_TRANSPARENT
This is a squashed extract of several commits, minimally edited to
ensure it compiles.

Related to #197.
Related to #723.
2017-09-27 21:33:03 +02:00
Camilla Löwy
25b7eba4a0 Win32: Clean up dynamic loading and version checks 2017-09-27 21:33:03 +02:00