Commit Graph

2844 Commits

Author SHA1 Message Date
Camilla Löwy
01778329ec Add custom target for updating gamepad mappings 2021-08-01 20:16:17 +02:00
Camilla Löwy
56092814f3 Improve error description for invalid scancodes 2021-07-29 21:50:24 +02:00
Stephen Gowen
1d88a2e3d6 Cocoa: Fix macro redefinition warning
This avoids generating a macro redefinition warning when the
GL_SILENCE_DEPRECATION macro has been defined for the whole of a larger
project.

Closes #1840.
2021-07-29 21:21:45 +02:00
Camilla Löwy
076bfd55be Cocoa: Fix MoltenVK layer scale out of sync
The contents scale of the hosted CAMetalLayer created for MoltenVK was
updated only after the GLFW content scale and framebuffer size events
were emitted, causing the layer to get out of sync with the monitor the
window was on.
2021-07-16 20:10:19 +02:00
Camilla Löwy
836e709503 Cocoa: Remove calls to -update on nil
These calls have no effect unless the context was created with NSGL.
2021-07-16 19:54:21 +02:00
Camilla Löwy
6876cf8d7e Remove errors for gamepad element mismatch
Because there are controllers in the wild using the same hardware ID
despite having different numbers of buttons and axes, an error message
was triggered that was only expected for a corrupted mapping database.

This removes the error for now, in preparation for better error handling
for gamepad mappings overall.

Fixes #1763.
2021-06-25 20:19:40 +02:00
Camilla Löwy
a89fcd20d8 Wayland: Fix missing constant on FreeBSD
On FreeBSD O_CLOEXEC is only available when _POSIX_C_SOURCE >= 200809.
O_CLOEXEC is in turn required by the epollshim header.

Issue reported on IRC.
2021-06-22 00:30:39 +02:00
Camilla Löwy
114776a246 EGL: Fix creation of single-buffered windows
The EGL backend ignored the state of GLFW_DOUBLEBUFFER and always
created a double-buffered EGL window.

This sets the EGL_RENDER_BUFFER attribute at EGL window creation
appropriately.

Fixes #1843.
2021-05-14 19:02:25 +02:00
Camilla Löwy
fd79b02840 Move single/double-buffer filtering to backends
There is no need to enumerate framebuffer configs that will just be
filtered out later by the GLFW_DOUBLEBUFFER hard constraint.
2021-05-14 19:02:25 +02:00
Camilla Löwy
184377b493 Skip initial buffer swap when single-buffered
This skips the buffer swap after the initial glClear performed during
window creation, if the window is single-buffered.  This call confused
apitrace into thinking the window was double-buffered.

Fixes #1873.
2021-05-14 19:02:25 +02:00
Camilla Löwy
04f21abb52 Make GLFW_DOUBLEBUFFER a window attribute 2021-05-14 19:02:25 +02:00
Camilla Löwy
da236ba807 Make monitor and joystick names static strings
Related to #478.
2021-05-14 19:02:08 +02:00
Camilla Löwy
9a3a8bc267 Win32: Always define UNICODE and _UNICODE 2021-04-23 14:46:47 +02:00
Camilla Löwy
a646f51bca Win32: Fix macros being enabled for other backends
_UNICODE should not be defined for other backends even when built on
Windows.
2021-04-23 14:46:47 +02:00
Konstantin Podsvirov
e3f916808d Fix hardcoded runtime destination in CMake install
Closes #1883.
Closes #1884.
2021-04-22 22:47:16 +02:00
Camilla Löwy
061a0263a9 Win32: Fix compilation with standalone LLVM
The /clang: suffix passed to Clang-CL was accidentally also passed to
the regular standalone Clang, which caused compilation to fail.  We now
pass /W3 to Clang-CL, which it interprets as -Wall.

The _CRT_SECURE_NO_WARNINGS macro is now defined for both Clang and
Clang-CL.

The /entry: flag passed to link.exe is now also passed to lld-link,
letting the windows subsystem tests and examples link.

Fixes #1807.
Closes #1824.
Closes #1874.
2021-04-22 22:37:37 +02:00
Camilla Löwy
85bce8a8ea Replace GL_ARB_debug_output in comments 2021-04-22 22:37:37 +02:00
Nicolas Caramelli
84f95a7d7f Add GLFW_X11_XCB_VULKAN_SURFACE init hint
This hint controls whether GLFW will try to use VK_KHR_xcb_surface
before falling back to VK_KHR_xlib_surface.

Closes #1793.
2021-04-14 23:38:22 +02:00
Camilla Löwy
52ba8c7f07 Win32: Add warning when option will have no effect
The GPU driver only looks in the executable for the symbol requesting
the high-performance GPU, so enabling them when buidling GLFW as a DLL
will have no effect.
2021-03-15 00:48:48 +01:00
Camilla Löwy
17ae300d96 Ignore cached state when setting window attributes
This filtering prevented valid changes if the native window state was
changed externally.
2021-03-14 23:16:17 +01:00
Camilla Löwy
1f34295a74 Win32: Add MinGW-w64 detection to version string 2021-03-09 23:36:05 +01:00
Camilla Löwy
4afa227a05 X11: Fix attribs not applied on leaving fullscreen
If the GLFW_DECORATED and/or GLFW_FLOATING window attributes were
changed while in fullscreen mode, the changes did not take effect when
the window entered windowed mode.

Bug reported on the GLFW forum.
https://discourse.glfw.org/t/turning-on-off-window-decorations-while-in-full-screen-wont-work-properly/1780
2021-03-08 21:55:26 +01:00
Camilla Löwy
b925a54ef1 Wayland: Move DPI fallback work to output done
This removes the dependency on the (unspecified) ordering of geometry
and mode events in wl_output.

Based on feedback from @linkmauve and @caramelli.

Related to #1792.
2021-02-10 20:43:11 +01:00
Camilla Löwy
729c9988d0 Win32: Fix content area rescaling on older systems
GLFW_SCALE_TO_MONITOR had no effect on Windows 8.1 up to and including
Windows 10 version 1607 (Anniversary Update), despite those having
support for per-monitor DPI.

That done was to avoid handling systems that have non-client scaling,
introduced in Windows 10 version 1607, without reliable overriding of
the new window size, introduced in Windows 10 version 1703 (Creators
Update).  Both are needed to keep the content area at a fixed size for
windows that have GLFW_SCALE_TO_MONITOR disabled.

This change enables window rescaling on Windows 8.1 and all later
versions but disables non-client scaling for unscaled windows on Windows
10 version 1607.  Versions after 1607 are unaffected.

Fixes #1511.
2021-02-10 20:41:40 +01:00
Camilla Löwy
410890aa80 Win32: Fix full screen windows affected by scaling
Per-monitor DPI scaling should not affect full screen windows.

Fixes #1582.
2021-02-10 20:28:54 +01:00
Camilla Löwy
6de084000b Cocoa: Fix console apps getting a dock icon
Regression introduced by @elmindreda in
8b11867464.
2021-02-10 18:14:32 +01:00
Laurent Aphecetche
384ff74a46 Cocoa: Fix install name for installed dylib
The install name was incorrectly set to a relative path.

This change leaves the install name of the installed dylib as
@rpath/soname.  Those who wish to override this can set the
CMAKE_INSTALL_NAME_DIR variable.

Closes #1504.
2021-01-18 23:52:27 +01:00
Camilla Löwy
f8d6801a50 Simplify references in CMake if-statements 2021-01-18 23:52:27 +01:00
Camilla Löwy
3959ee8949 Cocoa: Unify CG display to NS screen mapping
This moves the matching of CG displays to NS screens to monitor
enumeration time.
2021-01-18 23:52:27 +01:00
Nevyn Bengtsson
2bc52ca82e Cocoa: Use modern API to get display name
On Apple Silicon, IOKit is deprecated and there will be no
matching io_service that we can query for name. Luckilly,
NSScreen got an API to fetch the display name in 10.15.

This is a blocker to get glfw running on Apple Silicon.

Fixes #1809.
Closes #1833.
2021-01-18 23:52:27 +01:00
Camilla Löwy
5aff72aa00 Cocoa: Fix duplicate monitor connection events 2021-01-18 23:52:27 +01:00
Camilla Löwy
8b11867464 Cocoa: Fix menubar for unbundled apps on 10.15
NSApp setActivationPolicy: was being called too soon when the app was
not bundled and launched from the command line.

This fix is based on #1802 by @richardwilkes.

Fixes #1648.
Closes #1802.
2021-01-18 23:52:27 +01:00
Philip Rideout
f5af421a6b Cocoa: Fix duplicate video mode detection
Closes #1830.
2021-01-18 23:52:27 +01:00
ashishgamedev
761f97d6b6 Fix indentation in internal.h
Closes #1818.
2020-12-15 02:12:20 +01:00
Nicolas Caramelli
1adfbde4d7 Wayland: Move 96 DPI default to outputHandleMode
Closes #1792.
2020-12-09 19:11:40 +01:00
Luflosi
08e5a17063 Use switch statement instead of if-else-chain for cursor shapes
Closes #1739.
2020-12-08 15:45:14 +01:00
Leonard König
0dc1005c85 Wayland: Fix destroying CSDs in the correct order
On Wayland we implement Client-Side Decorations if the compositors do not
implement SSDs.  In that case, the destructors of the surfaces were called
in the wrong order, leading to a dereference of an already freed object.
We need to first destroy the subsurface before destroying the parent surface.

Related PR on kitty: https://github.com/kovidgoyal/kitty/pull/3066
Related issue on kitty: https://github.com/kovidgoyal/kitty/issues/3051

Closes #1798.
2020-11-19 02:47:30 +01:00
Camilla Löwy
3327050ca6 Cocoa: Fix ObjC being built as C with CMake 3.19
CMake 3.19 adds -xc when the LANGUAGE file property is C, breaking our
workaround for CMake 3.15 and earlier not understanding the .m suffix.

Fixes #1787.
2020-11-18 00:11:13 +01:00
Camilla Löwy
2f76f70c76 Wayland: Simplify adding of protocol sources 2020-11-11 19:11:38 +01:00
Camilla Löwy
420b165bff Wayland: Fix indentation 2020-11-11 19:11:38 +01:00
Camilla Löwy
a62a6c5019 Wayland: Scanner tool has input and output args 2020-11-11 19:11:38 +01:00
Camilla Löwy
d5f32dfb3b Wayland: Ensure paths are passed on in quoted form 2020-11-11 19:11:38 +01:00
Camilla Löwy
a6f8cc9d44 Fix unquoted paths with variable references
Whitespace is a field separator in CMake.
2020-11-11 19:11:38 +01:00
Joel Winarske
af8f9713dd Wayland: Fix CMake binary dir when built as subdir
Regression introduced by 2747e47393.

Related to #1782.
2020-11-11 19:10:19 +01: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
Camilla Löwy
ac627706ef Win32: Fix clang-cl interpreting -Wall as /Wall
Unlike -Wall, VS /Wall really means all warnings.

Closes #1780.
2020-11-11 19:10:05 +01:00
Camilla Löwy
6b78419c9a Win32: Enable /W3 on VS for library sources
/W3 is the default for new VS projects and the library builds cleanly
with it on VS 2010-2019 so let's try to keep it that way.
2020-11-11 19:09:10 +01:00
Camilla Löwy
9b140d08d7 Remove ignored Clang compiler flag
Clang ignores this when C99 is enabled, while GCC does not.  Removing
the checks for Clang to hopefully avoid a false sense of security.
2020-11-11 19:07:26 +01:00
Andy Williams
c940695eb0 Fix macOS Print Screen
Many years ago this value was changed from F13 to Print Screen with
1ae9ce1e0a.  However, this was later
reverted to F13 with 5759d0fdf2.

This changes it back to Print Screen for consistency with other
platforms.

Closes #1786.
2020-10-20 19:59:16 +02:00
Nicolas Caramelli
0ef149c8f2 Wayland: Assume 96 DPI if physical size is <= 0 2020-10-14 12:04:28 +02: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
Doug Binks
166611cef5 Win32: Update all monitor handles on config change
Closes #1761.
2020-10-05 23:24:12 +02:00
Emmanuel Gil Peyrot
2e6fb7fe22 Wayland: Remove extra trailing whitespace 2020-09-30 17:02:32 +02:00
Joel Winarske
2747e47393 Wayland: Remove extra-cmake-modules dependency
Fixes #1774.
2020-09-30 17:02:26 +02:00
Camilla Löwy
7765451d0f Formatting 2020-08-23 18:33:57 +02:00
Camilla Löwy
cd0dc76c7c Null: Fix out parameters not being set
It turns out platform functions are sometimes called directly instead of
going through the public wrapper.
2020-08-19 19:31:55 +02:00
Luflosi
b488c3f87f
Make _glfwPlatformInitJoysticks() return the correct type in null_joystick
This code was introduced in 782e6b6cef.

Closes #1745.
2020-08-08 22:51:50 +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
a2674a9034 Cocoa: Fix potential leak of CFNumber object
Spotted by Clang static analysis.
2020-07-23 22:27:40 +02:00
Luflosi
0cc13ceafc Return NULL instead of GLFW_FALSE where appropriate
Related to 782e6b6cef.

Closes #1738.
2020-07-23 22:13:11 +02:00
Camilla Löwy
c01acc267a X11: Fix joystick detection before joystick init
Spotted by @Luflosi.
2020-07-23 21:14:36 +02:00
Camilla Löwy
f771d41292 Cleanup
Moving functions to their respective sections.  Related to delayed
joystick Initialization.
2020-07-21 17:54:07 +02:00
Camilla Löwy
782e6b6cef Make joystick platform code init on demand
This makes joystick support initialize the first time a joystick
function is called, including those gamepad functions that are layered
on top of joystick functions.

Related to #1284.
Related to #1646.
2020-07-21 17:38:56 +02:00
Camilla Löwy
f760b124ca Wayland: Fix scroll offsets being inverted
Scrolling offsets were inverted compared to X11 and Win32.

Fixes #1463.
2020-07-15 23:16:01 +02:00
Camilla Löwy
5f60c22cfa Wayland: Fix partial framebuffer size retrieval 2020-07-15 21:56:52 +02:00
Camilla Löwy
dfeacee000 Move mouse passthrough before window showing
Related to #1568.
2020-07-15 18:02:38 +02:00
Camilla Löwy
1095a43708 Remove no-op call at window creation
Related to #1568.
2020-07-15 18:02:38 +02:00
Camilla Löwy
6d2003d07a Move management of shared state to shared code
Platform code may not modify shared state.

Related to #1568.
2020-07-15 18:02:38 +02:00
Camilla Löwy
7da3e52c86 Win32: Fix GLFW_MOUSE_PASSTHROUGH dropping events
Returning HTTRANSPARENT from WM_NCHITTEST does cause the window to be
transparent for some hit-testing APIs but does not make it pass mouse
input through to whatever window is below it.

For that to work on modern Windows, the window needs to be both layered
and extended-window-style-transparent.

Additional logic changes to ensure mouse input passthrough, framebuffer
transparency and window opacity are mindful of one another when
modifying WS_EX_LAYERED.

Related to #1568.
2020-07-15 18:00:43 +02:00
Camilla Löwy
68e4261d73 X11: Include X Shape extension headers
Related to #1568.
2020-07-15 18:00:00 +02:00
Camilla Löwy
e81d381256 X11: Fix disabling of GLFW_MOUSE_PASSTHROUGH
The client clip region was left in place when mouse passthrough was
disabled, leading to missing mouse input if the window grew beyond it.

Related to #1568.
2020-07-15 18:00:00 +02:00
Rokas Kupstys
d285a9fdeb Add support for mouse input transparency
This adds the GLFW_MOUSE_PASSTHROUGH window hint and attribute for
controlling whether mouse input passes through the window to whatever
window is behind it.

Fixes #1236.
Closes #1568.
2020-07-15 17:59:55 +02:00
Camilla Löwy
6c031af245 Null: Fix typos in workarea retrieval 2020-07-13 19:43:13 +02:00
Camilla Löwy
49dbcfcb8c X11: Fix cursor hover query retry behavior
XQueryPointer returns zero on BadWindow so the retry did not happen.

Related to ceb20c7f97.
2020-07-10 00:05:09 +02:00
Camilla Löwy
ceb20c7f97 X11: Fix race in window hovered query
The window decoration window can go away between calls to XQueryPointer,
for example if the GLFW_DECORATED window attribute was just cleared.
2020-07-09 22:36:59 +02:00
Camilla Löwy
4ae93e0547 X11: Remove non-UTF-8 fallback paths
It seems it has not been possible to compile GLFW on systems without the
UTF-8 extensions to Xlib since a0a5cc57df
was merged five months ago.  The UTF-8 extension functions were
introduced with XFree86 4.0.2 in December 2000 and are likely widely
available at this point.

This removes the locale-dependent fallback paths and uses the UTF-8
extension functions where available.
2020-07-02 21:38:40 +02:00
Camilla Löwy
9a3664b4a9 X11: Fix detection of key events duplicated by XIM
Background: The IM will filter out key events, instead sending exact
duplicate events that are not filtered.  It does not send these for
every event, however, so the duplicate events cannot be relied on for
key input.  Instead we need to identify and discard them.  Since they
are identical, they have the same timestamp as the originals.

The previous duplicate event detection would consume unrelated key
events if the keys were pressed simultaneously, as it only tracked
a single timestamp.

This fixes that issue for any combination of keys, at the expense of
a 1 KB array per GLFW window.

This fix is a stopgap until explicit IME support is done.

Based on #1472 by @LucaRood.

Fixes #1112.
Fixes #1415.
Fixes #1616.
Fixes #1663.
Closes #1472.
2020-07-02 21:38:03 +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
e47832ffcf Cocoa: Fix regression in private use area check
This fixes a regression introduced by
ad9eb768c9.
2020-06-29 23:23:26 +02:00
Camilla Löwy
ad9eb768c9 Cocoa: Fix non-BMP Unicode codepoint input
Supplimentary Plane codepoints were reported as UTF-16 surrogate pairs.

Fixes #1635.
2020-06-29 23:03:24 +02:00
Camilla Löwy
0dea8a4441 EGL: Add support for EGL_ANGLE_platform_angle
This adds basic support for selecting the platform type (rendering
backend) when running on ANGLE.

Related to #1380.
2020-06-29 00:02:22 +02:00
Camilla Löwy
b420ca7404 Add GLFW_CONTEXT_DEBUG window hint alias
This adds GLFW_CONTEXT_DEBUG as a preferred alias for
the GLFW_OPENGL_DEBUG_CONTEXT window hint, as debug contexts are
defined for both OpenGL and OpenGL ES.

Related to #1720.
2020-06-28 19:27:48 +02:00
Camilla Löwy
2539d03747 Win32: Use helper window DC as EGL native display
Closes #1717.
2020-06-24 00:51:19 +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
aec9fae8f3 EGL: Add support for EGL_EXT_platform_base
This adds support for EGL_EXT_platform_base and its associated X11 and
Wayland extensions, allowing us to explicitly tell EGL which window
system we are using.

This is based on work by @linkmauve in #1691.

Closes #1691.
2020-06-24 00:49:55 +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
Luflosi
b66f105f3e
Fix typos 2020-06-23 16:41:37 +02:00
Camilla Löwy
c1f60ab5dc Make compiler specific workarounds more consistent 2020-06-08 01:07:35 +02:00
Camilla Löwy
e47705d8fb Move more compiler workarounds to library setup
These are details of the glfw CMake target and belong in the creation of
that target.
2020-06-08 01:07:34 +02:00
Camilla Löwy
e0c77f71f9 Null: Make platform more conformant
This makes the null platform behave more like an actual stub.  More
queryable state is tracked and there is even a fake monitor with one
whole fake video mode.
2020-06-02 22:40:09 +02:00
Camilla Löwy
c72da994ba Wayland: Fix repeated keys reported to NULL window
This fixes a race between the key repeat logic and the surface leave
event handler, which could result in repeated keys being reported with
a window of NULL.

Fixes #1704.
2020-06-02 19:54:30 +02:00
Camilla Löwy
9a87c2a4b4 Add feature available/implemented errors
This adds two new error codes: GLFW_FEATURE_UNAVAILABLE for when
a GLFW feature cannot be reasonably implemented on that platform, and
GLFW_FEATURE_UNIMPLEMENTED for when it can be but has not been yet.

This replaces the current situation where the Wayland code emitted
GLFW_PLATFORM_ERROR in both cases while the macOS code silently did
nothing.

If your application exits on any GLFW error, these error codes should at
least be easy to filter out from that behavior.

Ideally, GLFW_FEATURE_UNAVAILABLE should be rare and
GLFW_FEATURE_UNIMPLEMENTED should never be emitted at all.

Fixes #1692.
2020-06-02 17:18:18 +02:00
ben1
a84a30ab63 Win32: Fix VS /W4 compile warnings
These are harmless errors but the code was worth fixing just to reduce
confusion and be more explicit.  E.g. using a different variable name
for a new variable of a different type in win32_joystick.c.

Closes #1700.
2020-05-26 21:37:20 +02:00
Luflosi
250b94cd03 Use the correct type in a for loop
The `atomCount` variable has the type `unsigned long`,
so the `for` loop iterating over it should use the same type.

Closes #1701.
2020-05-26 20:19:14 +02:00
Luflosi
d4f5074535 Replace %m conversion specifier with %s and strerror()
When compiling with `-Wall` and `-pedantic-errors`, gcc complains with
```
warning: ISO C does not support the '%m' gnu_printf format [-Wformat=]
```
because the `%m` conversion specifier is a GNU extension.

Closes #1702.
2020-05-25 16:05:49 +02:00
Corentin Wallez
91eebe922d Use CALayer instead of NSView for EGLNativeWindowType
The only two EGL implementations on macOS are Swiftshader and ANGLE.
While Swiftshader supports both `NSView` and `CALayer` as
`EGLNativeWindowType`, ANGLE supports only `CALayer`. Furthermore
Swiftshader's OpenGL ES frontend is deprecated in favor of using ANGLE's
Vulkan backend on top of Swiftshader's Vulkan frontend.

This means that on macOS `EGLNativeWindowType` should be a `CALayer` for
compatibility with ANGLE.

Fixes #1169.
Closes #1680.
2020-05-22 17:37:44 +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
5f9dfe3d83 X11: Clarify function name and comment 2020-05-19 22:36:44 +02:00
Camilla Löwy
ef5220d6b1 X11: Clarify code flow for Clang static analysis 2020-05-19 17:59:18 +02:00
Camilla Löwy
a17a1b2011 X11: Fix XKB events being passed on to core path 2020-05-19 17:55:28 +02:00
Camilla Löwy
e07925c404 X11: Fix XKB state event bits being overwritten
This limits the update to the XKB group state event bit without clearing
all other state event bits.
2020-05-19 17:49:02 +02:00
Camilla Löwy
cf3a03a85d X11: Remove duplicate XKB group initialization
The XKB group is already set to zero during initialization.
2020-05-19 17:47:58 +02:00
Camilla Löwy
0c403c8ca6 X11: Fix XKB group event depending on state query
This fixes XKB group change events not being enabled if the initial
XKB keyboard state query fails.
2020-05-19 17:44:59 +02:00
Camilla Löwy
949275bbed Cocoa: Fix call to NSWindow from non-main threads
glfwSwapBuffers may be called by any thread but NSWindow may not.

Bug introduced by c3ca88055f and reported
by @crujose.
2020-04-30 22:44:54 +02:00
Camilla Löwy
cab41529da X11: Improve non-XKB fallback for key mapping
A regression introduced by b889aa7841
broke the special handling of numpad keys for the non-XKB fallback path.
The non-functional remains were later removed.  This restores the
original behavior.
2020-04-23 22:13:18 +02:00
Camilla Löwy
318e08d914 X11: Add additional XKB key names for Right Alt 2020-04-23 17:42:36 +02:00
Camilla Löwy
560304e0f4 X11: Use XKB key name MENU for Menu key 2020-03-31 17:31:01 +02:00
Camilla Löwy
9ecacf1d7f X11: Check XKB key aliases in addition to names 2020-03-31 17:31:01 +02:00
Camilla Löwy
ee45b58647 X11: Fix X keycode ranges for XKB and core
This replaces the hardcoded keycode ranges and various kludgy range
checks with the actual ranges reported by Xlib and XKB.
2020-03-31 17:31:01 +02:00
Ali Sherief
a41a58a95e X11: Fix function keys mapped to GLFW_KEY_UNKNOWN
This fixes the issue where function keys would be reported as
GLFW_KEY_UNKNOWN if XKB was available and one of the configured keyboard
layouts was Arabic.

This is only part of #1598, because the full patch removed parts of the
fallback path for when XKB is unavailable.

Closes #1598.
2020-03-31 17:03:29 +02:00
Camilla Löwy
e65de2941c X11: Improve window handle race condition
The non-root parent window owned by the WM could be destroyed before we
process the ConfigureNotify event using the cached parent handle.

Bug was found by unmapping a decorated window.

This like all uses of the Xlib error handler is not thread safe and
there is nothing we can do about that short of moving to XCB.

Fixes #1633.
2020-03-31 17:03:29 +02:00
Camilla Löwy
2c8e0512dd X11: Filter out Xlib errors from other connections 2020-03-16 17:15:07 +01:00
Camilla Löwy
44b5d06583 X11: Add support for XIM callbacks
This adds support for the XIM instantiate and destroy callbacks, letting
GLFW detect both when the current input method disappears and when a new
one is started.

Tested with ibus.
2020-03-12 21:05:54 +01:00
Camilla Löwy
72366ac9a9 Cocoa: Finish launching NSApp in glfwInit
This moves the remaining bits of NSApplication initialization into
_glfwPlatformInit.  As a side-effect of this, any command-line program
initializing GLFW will get a menu bar, which is not ideal.

If this has happened to you and a bisect led you here, please see the
GLFW_COCOA_MENUBAR init hint introduced in GLFW 3.3.

If this patch is a terrible idea, please get in touch in the 3.4 release
timeframe.

This is a replacement for 6e6805000a,
which attempts to preserve the existing menu bar creation behavior for
the 3.3-stable branch.

Fixes #1649.
2020-03-12 01:56:35 +01:00
Camilla Löwy
4381b86b6b X11: Fix CJK IME input when locale CTYPE is "C"
Fixes #1587.
Fixes #1636.
2020-02-12 19:01:16 +01:00
Camilla Löwy
27d19d06ca WGL: Remove unused constants 2020-02-10 17:44:57 +01:00
Camilla Löwy
a0a5cc57df X11: Make libX11 dynamically loaded
This completes the dynamic loading of all X11 libraries in preparation
for run-time platform selection.
2020-02-10 17:44:56 +01:00
Camilla Löwy
0c27ed1d0e X11: Fix setting the clipboard string to itself 2020-02-10 17:44:56 +01:00
Camilla Löwy
40c7e471e3 Move more non-source template files to CMake dir 2020-02-08 17:42:53 +01:00
Kovid Goyal
a5e5b782c7 X11: Fix queries crashing if monitor disconnected
Merged from downstream kovidgoyal/glfw.  First of many.

Related to #1602.
2020-01-16 23:52:39 +01:00
Camilla Löwy
190673e779 Win32: Add matching comment 2020-01-16 23:52:38 +01:00
Camilla Löwy
789a2bcb39 Win32: Fix scancode when key message only had VK
Some synthetic key messages come with a scancode of zero, causing them
to be translate to GLFW_KEY_UNKNOWN.  This fills in the missing scancode
by translating the provided virtual key.

Rather than further complicate a single-use function, its body is merged
into the key message handler.

Fixes #1623.
2020-01-16 23:52:36 +01:00
Camilla Löwy
5f1631cb0e Check scancode before use in glfwGetKeyName 2020-01-16 23:17:49 +01:00
Camilla Löwy
a491b0698c Win32: Use non-async key state for modifier hack
The synchronous key state seems to make more sense in context.
2020-01-16 23:16:43 +01:00
Camilla Löwy
562c17d131 Win32: Fix no Super key release event after Win+V
The Win+V hotkey brings up a clipboard history IME that consumes the key
release.  This adds left and right Super to the modifier keys manually
polled for undetected release during event processing.

Fixes #1622.
2020-01-16 23:16:41 +01:00
Camilla Löwy
7da87aaae7 Cocoa: Add fully dynamic loading of Vulkan loader
If the application is not linked against the Vulkan loader and relies on
a third-party loader library or glfwGetInstanceProcAddress, then our
call to dlopen will fail without a custom dyld environment variable.

This adds a fallback of looking in the directory of the main executable,
which matches the bundle structure recommended by the Vulkan SDK, making
that finally work out of the box for fully dynamic loading.
2020-01-16 22:15:30 +01:00
Camilla Löwy
15d91801b7 Cocoa: Select Vulkan surface extension at runtime
This mostly just follows the pattern established by X11.

Related to #1619.
2020-01-16 21:53:18 +01:00
ByunghoonKim
c5cb4a253a Cocoa: Add support for VK_EXT_metal_surface
This adds optional support for the VK_EXT_metal_surface instance
extension.

Closes #1619.
2020-01-16 05:28:24 +01:00
Camilla Löwy
9372ba95fa X11: Fix parent window handle initialization
This should have been initialized to the screen root, not None.  This
issue was introduced by fe57e3c292.

Fixes #1620.
2020-01-14 21:26:21 +01:00
Camilla Löwy
aa5e313561 X11: Fix BadMatch focusing a window on non-EWMH WM
When the WM does not support EWMH or there is no WM running, GLFW falls
back to XSetInputFocus, which will emit BadMatch if the window is not
viewable, which will terminate the program.

Bug spotted on IRC.
2020-01-06 22:45:56 +01:00
Camilla Löwy
fe57e3c292 X11: Fix no window position events during resize
A window resize action that also resulting in the window being moved did
not emit any window positions events, as the position of real
ConfigureNotify events was ignored.  The real events use parent
coordinates instead of root coordinates so this adds parent tracking and
conditional translation.

Fixes #1613.
2020-01-01 16:56:32 +01:00
Camilla Löwy
781fbbadb0 Fix Threads package not located by our config file
This fixes a missing dependency error when the imported GLFW target is
a static library.

Thanks to @mosra for reporting the bug.
2019-12-26 16:31:42 +01:00
Camilla Löwy
a3d28ef52c X11: Fix IC event mask not being added to our window 2019-12-26 16:31:42 +01:00
Camilla Löwy
8149a5fc00 X11: Cleanup
We can use C99 now and also we will need the event mask below.
2019-12-26 16:31:41 +01:00
Luflosi
74a46dfa0c Use the correct type in a for loop
The `sizeof()` operator has the type `size_t`, so the `for` loop
iterating over it should use the same type.

Closes #1614.
2019-12-26 16:31:37 +01:00
Camilla Löwy
4ec7daf3e9 Cocoa: Replace display link with IOKit query
This removes the final dependency on CoreVideo, using a display link to
get the refresh rate of monitors where Core Graphics report a refresh
rate of zero.  Instead we now query the I/O registry directly, similarly
to what the display link does at creation.

Thanks to @OneSadCookie for pointers to this solution.
2019-12-25 21:53:04 +01:00
Camilla Löwy
c3ca88055f NSGL: Simulate vsync for occluded windows
This only supports a swap interval of zero or one, as that is all NSGL
supports.
2019-12-20 09:49:55 +01:00
Camilla Löwy
54e8e0b092 NSGL: Remove problematic swap interval workaround
Fixes #1483.
2019-12-20 09:46:48 +01:00
Camilla Löwy
b4a8eb9b19 Cocoa: Only create per-monitor display link once
The display link query is not specific to any particular display mode
and so only needs to be done once.

The next step is to replace the display link altogether by querying
IOKit directly, which is what the display link does.
2019-12-20 09:46:48 +01:00
Camilla Löwy
28773a069e Cocoa: Fix undeclared selector warnings 2019-12-20 09:46:48 +01:00
Camilla Löwy
73a8ebb691 X11: Cleanup
This is technically valid but misleading and may inspire future bugs
like the one fixed by 0b652a44d2.
2019-12-17 02:17:31 +01:00
Camilla Löwy
4e70c95aa3 X11: Cleanup
The window state action is not an atom.
2019-12-17 01:53:48 +01:00
Camilla Löwy
9db156421f X11: Fix updating GLFW_FLOATING on a hidden window 2019-12-17 01:53:40 +01:00
Camilla Löwy
0b652a44d2 X11: Fix invalid read when clearing GLFW_FLOATING 2019-12-17 01:51:35 +01:00
Camilla Löwy
9b6d68ec70 X11: Fix missing checks for EWMH attention atoms 2019-12-16 16:22:22 +01:00
Camilla Löwy
4837b78ffe X11: Fix maximization of hidden windows
This fixes glfwMaximizeWindow having no effect on hidden windows by
manually appending the maximization states to the EWMH state property.
2019-12-16 16:22:15 +01:00
Camilla Löwy
bc3be40f21 Enable strict C99 for non-VS compilers 2019-12-16 12:48:32 +01:00
Camilla Löwy
da3f20d860 Win32: Add missing include for wcscmp 2019-12-15 18:37:57 +01:00
Camilla Löwy
fb0028c766 Win32: Enable Unicode mode for all compilers 2019-12-15 18:37:57 +01:00
Camilla Löwy
994c3b4e48 Cocoa: Remove stale GCC workaround 2019-12-15 18:37:57 +01:00
Camilla Löwy
18307467b4 Gather CMake setup of configuration header 2019-12-15 18:37:57 +01:00
Camilla Löwy
49c5d837b4 Replace CMake threads variable with modern target 2019-12-15 18:37:56 +01:00
Camilla Löwy
8a5fd0c5a4 Replace ad-hoc CMake code with DEFINE_SYMBOL
This target property does what we were doing manually.
2019-12-15 18:37:56 +01:00
Camilla Löwy
a5ed740d9d Fix use of CMake 3.13 command target_link_options 2019-12-15 18:37:56 +01:00
Camilla Löwy
a264d32987 Replace CMake list variables with target_sources 2019-12-15 18:37:56 +01:00
Camilla Löwy
081484ed34 Fix POSIX conformance issues for clock_gettime
CLOCK_MONOTONIC should not be used as a feature macro.  The POSIX
feature macros are provided by unistd.h.  CLOCK_MONOTONIC is provided by
time.h.  CLOCK_MONOTONIC requires _POSIX_C_SOURCE >= 199309L on some
systems.
2019-12-15 18:15:40 +01:00
Camilla Löwy
506a6aafde Formatting 2019-12-11 22:10:00 +01:00
Camilla Löwy
a875a536b7 Cocoa: Fix duplicate conversion of title string 2019-12-11 22:08:56 +01:00
Camilla Löwy
2551829f75 Win32: Add VERSIONINFO resource to GLFW DLL
This will let people see the API version in the Explorer property box.
2019-12-11 21:02:08 +01:00
Camilla Löwy
59055d585f Update minimum required CMake version to 3.1 2019-12-09 23:48:26 +01:00
Camilla Löwy
c194193797 Replace CMake generator expression with variable
Generator expressions are amazing but best used in moderation.
2019-12-09 23:35:51 +01:00
Camilla Löwy
9dc365f192 Merge GCC/Clang specific CMake blocks 2019-12-09 23:35:51 +01:00
Camilla Löwy
197193ac0b Fix source list for Objective-C fix 2019-12-09 23:35:51 +01:00
Camilla Löwy
9486ec0c02 Fix source list for -Wdeclaration-after-statement
The context creation files were not included on platforms other than
Win32.
2019-12-09 23:35:50 +01:00
Camilla Löwy
bc7b19cbd1 Remove tab character 2019-12-09 23:35:50 +01:00
Camilla Löwy
f6d44cedfd Trust CMake to do the right thing for static libs
CMake understands what private library dependencies for a static library
means and handles it correctly.
2019-12-09 23:35:40 +01:00
Camilla Löwy
fa60269245 NSGL: Fix disabling of Retina resolution
It appears the default is now YES.

Fixes #1442.
2019-12-09 22:25:59 +01:00
Camilla Löwy
6e6805000a Cocoa: Fix pre-window-creation event processing
Polling the event queue before NSApp had been allowed to finish
launching, in our case by starting our self-terminating run loop,
triggered an assertion inside NSApplication.

This fix, which makes all event processing functions capable of starting
it, makes that assertion less likely.

A more Cocoa-friendly fix would be to finish launching NSApp during
glfwInit and let people annoyed by the menu bar disabled it with
GLFW_COCOA_MENUBAR.  That may not be suitable for 3.3-stable, though.

Fixes #1543.
2019-12-09 22:25:59 +01:00
Camilla Löwy
b3544ca43e Cocoa: Update outdated comment 2019-12-09 18:46:31 +01:00
Emmanuel Gil Peyrot
ef6189f348 Wayland: Unset the cursor name on border exit
It would previously conserve the last name it had before leaving the
border, sometimes desynchronising with what it should have been.
2019-12-08 21:58:11 +01:00
Camilla Löwy
7dbdd2e6a5 Add more standard cursors
This adds the standard cursors for diagonal and omnidirectional
resize/move and operation-not-allowed.  It also adds new (better?) names
for the horizontal and vertical resize/move and pointing hand cursors.

References:
 - https://developer.apple.com/documentation/appkit/nscursor
 - https://stackoverflow.com/questions/10733228/
 - https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsystemcursor
 - https://freedesktop.org/wiki/Specifications/cursor-spec/
 - https://tronche.com/gui/x/xlib/appendix/b/

Related to #427.
2019-11-28 22:24:00 +01:00
Camilla Löwy
80fde12fda Wayland: Fix pointing hand cursor shape
Related to #1432.
2019-11-25 18:55:50 +01:00
Emmanuel Gil Peyrot
a80788c17f Wayland: Don’t update cursor position in the frame
That way the application only sees the cursor moving when it is inside
of its area, it won’t go back to the top or left side when trying to
resize the window or just hovering the fallback decorations.
2019-11-21 13:53:08 +01:00
Emmanuel Gil Peyrot
a9f674e719 Wayland: Don’t reload the cursor on every pointer motion
Previously, any pointer motion in the window decorations when using the
fallback implementation would obtain the wl_cursor again, and do the
attach danse for no benefit.

This will ultimately allow animated cursors to not reset to the first
frame on motion, once these will be implemented.
2019-11-21 13:52:37 +01:00
Camilla Löwy
e96dc5d219 X11: Assume 96 DPI if RandR monitor size is zero
This falls back to calculating the monitor physical size from the
current resolution and the default X11 DPI when the physical size
returned by RandR is zero.
2019-11-14 19:49:23 +01:00
Camilla Löwy
2c519709be Cocoa: Fix full screen window iconification
Iconification (miniaturization) of undecorated windows stopped working
unless the window has the NSWindowStyleMaskMiniaturizable style.
2019-11-13 14:08:28 +01:00
Camilla Löwy
bd452016be Cocoa: Cleanup
Readability fix, does not affect generated code.
2019-11-11 22:49:00 +01:00
Camilla Löwy
bac15f9449 Cocoa: Fix multiple methods warning
This fixes a warning due to us using bare ids and
NSCollectionLayoutAnchor having a message with the same name.
2019-11-11 22:49:00 +01:00
Camilla Löwy
c819f27ce3 Cocoa: Process events after window destruction
On macOS a destroyed window remained on screen until the next time
events were processed.  This makes the behavior more consistent with
other platforms.

Fixes #1412.
2019-11-11 22:49:00 +01:00
Camilla Löwy
94cb0347ab Cocoa: Add comments for Cocoa symbol macros 2019-11-11 22:49:00 +01: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
Camilla Löwy
b69fb99031 Remove mappings for GUID used by different devices
The SDL2 2.0.5+ controller GUID 03000000790000000600000000000000 matches
many devices with different layouts and element counts but with the same
chipset.  This issue is still being resolved upstream.  In the meantime
this removes those mappings from GLFW to avoid confusion and errors.

SDL upstream issue: https://bugzilla.libsdl.org/show_bug.cgi?id=4545

Related to #1583.
2019-11-11 22:37:18 +01:00
Camilla Löwy
c88ee1c9d3 Win32: Change transparent framebuffer key color
This is a temporary fix while we determine if the color key workaround
should be removed completely.  See issue thread for discussion.

Related to #1512.
2019-11-11 22:37:13 +01:00
Camilla Löwy
75294462b3 X11: Fix content scale fallback value on KDE
KDE sometimes removes the Xft.dpi resource when it would be set to the
X11 default value of 96, causing GLFW to fall back to a value calculated
from the core display sizes in pixels and mm in a desktop environment
that supports Xft.dpi.

This moves to a hardcoded fallback value of 96 on the assumption that
there are more people running KDE with 96 DPI than there are people
running desktop environments that do not support Xft.dpi.

All of this is terrible please send help.

Fixes #1578.
2019-10-29 12:04:47 +01:00
Camilla Löwy
5fc4c01302 X11: Fix decoration enabling after window creation
This fixes the enabling of window decorations after creation.  Instead
of removing the _MOTIF_WM_HINTS property, we now set or unset the
MWM_DECOR_ALL bit of the decorations field.

Fixes #1566.
2019-10-29 12:04:47 +01:00
Camilla Löwy
33683ec60e Remove stray characters from hardcoded CFLAGS
The additional '>' characters were appended to the compiler option.

Related to #1576.
2019-10-29 12:04:47 +01:00
Camilla Löwy
04f7f55f07 Cleanup
Related to #1585.
2019-10-29 12:04:47 +01:00
Pablo Prietz
4d0ae4ffa7 Fix CMake 3.0 - 3.6 support regression
Replaces `VERSION_GREATER_EQUAL` with `VERSION_EQUAL OR
VERSION_GREATER`.  `VERSION_GREATER_EQUAL` was only added in CMake 3.7.

Fixes #1584.
Closes #1585.
2019-10-29 12:04:46 +01:00
Corentin Wallez
3a37a08998 Fix -Wextra-semi warnings
Closes #1440.
2019-10-17 20:09:38 +02:00
Luflosi
7749aac50d
Use the correct type in a for loop
The `monitorCount` member in the `_GLFWlibrary` struct is of type `int`, so the `for` loop iterating over it should also use the type `int`.

Closes #1572.
2019-10-17 13:47:28 +02:00
Guillaume Racicot
8f852e0833 Enable C99 explicitly with CMake where available
This enables compilation as C99 where supported by the compiler.
A workaround with per-compiler hardcoded flags is used for CMake 3.0,
which does not support the C_STANDARD target property.

Fixes #1560.
Closes #1576.
2019-10-16 02:33:12 +02:00
Luflosi
d25248343e Use the correct type for a struct member
The `name` member in the `_GLFWmonitorWayland` struct is used in two places. It is assigned the value from a variable of type `uint32_t` and is compared to another variable of type `uint32_t`, so `name` should also have the same type.

Closes #1569.
2019-10-06 17:36:46 +02:00
Camilla Löwy
3d2540c373 Win32: Cleanup keyboard input flag parsing
This replaces some magic numbers with the corresponding winuser.h
provided macros and unifies how the MSB from Get*KeyState is tested.
2019-10-03 21:05:49 +02:00
Camilla Löwy
3ec8f4a7f5 Win32: Disable dynamic libgcc for MinGW DLL 2019-10-03 21:05:49 +02:00
Luflosi
243b1bc292 Use the correct type in a for loop
The `size` member in the `GLFWgammaramp` struct is of type `unsigned int`, so the `for` loop iterating over it should also use the type `unsigned int`.

Closes #1541.
2019-09-23 13:43:05 +02:00
luz.paz
7105ff2dfd Fix typos
Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille`
2019-09-16 12:30:25 +02:00
Camilla Löwy
7f02898264 Cocoa: Fix glfwSetWindowSize anchor point
This makes glfwSetWindowSize use the top-left corner as anchor point
instead of the bottom-left corner.

Fixes #1553.
2019-09-06 16:57:37 +02:00
httpdigest
2777f6a754 Fix comparison of video modes of equal area
This fixes the bug of video modes being discarded if they had
a different resolution but the same area as another mode.

Fixes #1555.
Closes #1556.
2019-09-01 21:57:06 +02:00
Camilla Löwy
cbf23e5615 Win32: Fix VS static analysis false positive
This way is perhaps also more readable for humans.
2019-08-28 20:59:49 +02:00
Camilla Löwy
56ca0cb3b3 Unify key name string handling
This makes key names per-key static strings for all supported platforms.

Fixes #1200.
2019-08-27 19:29:56 +02:00