Commit Graph

2836 Commits

Author SHA1 Message Date
Camilla Löwy 74a8ba26c3 Simplify parsing of default gamepad mappings
The outer glfwUpdateGamepadMappings function is now bypassed when
parsing the default gamepad mappings.  The data in mappings.h does not
contain any comments or line breaks.  Also this is done before joystick
support has been initialized, so there is no need to look for matching
devices.

Finally, the array of default mappings is pre-allocated.  This has no
measurable performance impact but does generate a lot of calls, which
won't be nice for a user provided custom allocator to deal with.

(cherry picked from commit 201400b974)
2021-08-27 17:13:12 +02:00
Camilla Löwy 929286ca47 Update gamepad mappings from upstream
(cherry picked from commit afa78b4270)
2021-08-27 17:13:01 +02:00
Camilla Löwy d3317b4937 Add gamepad mapping filtering by backend
This fixes gamepad mappings being included in GLFW binaries that would
then never use them because they were for a different platform.

(cherry picked from commit 0c90e1a33f)
2021-08-03 16:01:03 +02:00
Camilla Löwy b3b82cdd78 Add custom target for updating gamepad mappings
(cherry picked from commit 01778329ec)
2021-08-03 16:00:30 +02:00
Camilla Löwy 20a7962a9b Improve error description for invalid scancodes
(cherry picked from commit 56092814f3)
2021-08-03 15:59:59 +02:00
Stephen Gowen 1e98fc325d 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.

(cherry picked from commit 1d88a2e3d6)
2021-08-03 15:43:16 +02:00
Camilla Löwy 545b6c7970 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.

(cherry picked from commit 076bfd55be)
2021-08-03 15:43:03 +02:00
Camilla Löwy a7202e2341 Cocoa: Remove calls to -update on nil
These calls have no effect unless the context was created with NSGL.

(cherry picked from commit 836e709503)
2021-08-03 15:41:57 +02:00
Camilla Löwy 8f0198e82e 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.

(cherry picked from commit 6876cf8d7e)
2021-08-03 14:04:01 +02:00
Camilla Löwy d61f7225d1 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.

(cherry picked from commit a89fcd20d8)
2021-08-03 14:03:01 +02:00
Camilla Löwy 163fa83fac 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.

(cherry picked from commit 114776a246)
2021-06-15 18:07:38 +02:00
Camilla Löwy 6769ffcd0f 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.

(cherry picked from commit fd79b02840)
2021-06-15 18:07:28 +02:00
Camilla Löwy 07c29d1c1c 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.

(cherry picked from commit 184377b493)
2021-06-15 18:06:46 +02:00
Camilla Löwy 508e24c01c Add tracking of single-/double-buffering
This adds the state part of 04f21abb52
(Make GLFW_DOUBLEBUFFER a window attribute), but without the associated
API change, because this is needed by later bug fixes that will go into
the stable branch.
2021-06-15 18:04:05 +02:00
Camilla Löwy e756ae1d85 Make monitor and joystick names static strings
Related to #478.

(cherry picked from commit da236ba807)
2021-06-09 18:37:31 +02:00
Camilla Löwy 728aaccbbb Win32: Always define UNICODE and _UNICODE
(cherry picked from commit 9a3a8bc267)
2021-06-09 18:32:24 +02:00
Camilla Löwy 52b2775c2e Win32: Fix macros being enabled for other backends
_UNICODE should not be defined for other backends even when built on
Windows.

(cherry picked from commit a646f51bca)
2021-06-09 18:32:10 +02:00
Konstantin Podsvirov 9ef9b1361a Fix hardcoded runtime destination in CMake install
Closes #1883.
Closes #1884.

(cherry picked from commit e3f916808d)
2021-06-09 18:31:56 +02:00
Camilla Löwy 5dd6716ee9 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.

(cherry picked from commit 061a0263a9)
2021-06-09 18:31:39 +02:00
Camilla Löwy 3cded29c2f Replace GL_ARB_debug_output in comments
(cherry picked from commit 85bce8a8ea)
2021-06-09 18:26:39 +02:00
Camilla Löwy b39c02b118 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.

(cherry picked from commit 52ba8c7f07)
2021-03-21 23:23:17 +01:00
Camilla Löwy 0f46d089e8 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

(cherry picked from commit 4afa227a05)
2021-03-19 16:18:12 +01:00
Camilla Löwy 0c22ebac36 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.

(cherry picked from commit b925a54ef1)
2021-02-17 21:15:51 +01:00
Camilla Löwy 900dda7e89 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.

(cherry picked from commit 729c9988d0)
2021-02-17 21:15:32 +01:00
Camilla Löwy 56230ca173 Win32: Fix full screen windows affected by scaling
Per-monitor DPI scaling should not affect full screen windows.

Fixes #1582.

(cherry picked from commit 410890aa80)
2021-02-17 21:14:47 +01:00
Camilla Löwy c6fa2c8cfb Cocoa: Fix console apps getting a dock icon
Regression introduced by @elmindreda in
8b11867464.

Adapted to 3.3-stable from 6de084000b.
2021-02-10 18:17:16 +01:00
Laurent Aphecetche 5a15d8a784 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.

(cherry picked from commit 384ff74a46)
2021-02-10 17:14:46 +01:00
Camilla Löwy 8270081334 Simplify references in CMake if-statements
Adapted to 3.3-stable from f8d6801a50.
2021-02-10 17:14:46 +01:00
Camilla Löwy 15b0c43e2d Cocoa: Unify CG display to NS screen mapping
This moves the matching of CG displays to NS screens to monitor
enumeration time.

(cherry picked from commit 3959ee8949)
2021-02-10 17:14:46 +01:00
Nevyn Bengtsson 8746f68d61 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.

(cherry picked from commit 2bc52ca82e)
2021-02-10 17:14:45 +01:00
Camilla Löwy 14921d1e24 Cocoa: Fix duplicate monitor connection events
(cherry picked from commit 5aff72aa00)
2021-02-10 17:14:45 +01:00
Camilla Löwy eda12dd949 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.

Adapted to 3.3-stable from 8b11867464.
2021-02-10 17:14:45 +01:00
Philip Rideout 078e8fcf55 Cocoa: Fix duplicate video mode detection
Closes #1830.

(cherry picked from commit f5af421a6b)
2021-02-09 21:49:17 +01:00
ashishgamedev cdd5ee8d36 Fix indentation in internal.h
Closes #1818.

(cherry picked from commit 761f97d6b6)
2021-02-09 21:49:17 +01:00
Leonard König b31d7ddc8c 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.

(cherry picked from commit 0dc1005c85)
2021-02-09 21:49:16 +01:00
Camilla Löwy baf26a6ea7 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.

(cherry picked from commit 3327050ca6)
2021-02-09 21:49:16 +01:00
Camilla Löwy 395ab660d5 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.

(cherry picked from commit 0bccc3852b)
2021-02-09 21:49:16 +01:00
Camilla Löwy 7dee4e05f9 Win32: Fix clang-cl interpreting -Wall as /Wall
Unlike -Wall, VS /Wall really means all warnings.

Closes #1780.

(cherry picked from commit ac627706ef)
2021-02-09 21:49:16 +01:00
Camilla Löwy e0b3361683 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.

(cherry picked from commit 6b78419c9a)
2021-02-09 21:49:16 +01:00
Camilla Löwy 0b56adb721 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.

(cherry picked from commit 9b140d08d7)
2020-12-14 22:50:33 +01:00
Vladimir Perminov 41ad058ce3 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.

(cherry picked from commit e1d71cfa4701250a44a6c02d1bbb43309ac8a46c)
2020-09-30 16:11:14 +02:00
Doug Binks c3250be690 Win32: Update all monitor handles on config change
Closes #1761.

(cherry picked from commit fecd711e0bc9779c379f00e63c1ab7a5081e1954)
2020-09-30 16:10:17 +02:00
Camilla Löwy 0ab31db9c0 Formatting
(cherry picked from commit 7765451d0f)
2020-09-02 22:29:30 +02:00
Camilla Löwy 8363179eee 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.

(cherry picked from commit 05dd2fa298)
2020-09-02 22:27:45 +02:00
Camilla Löwy b8a6254a26 Cocoa: Fix potential leak of CFNumber object
Spotted by Clang static analysis.

(cherry picked from commit a2674a9034)
2020-09-02 22:12:40 +02:00
Camilla Löwy 114704262c Wayland: Fix scroll offsets being inverted
Scrolling offsets were inverted compared to X11 and Win32.

Fixes #1463.

(cherry picked from commit f760b124ca)
2020-07-16 13:34:28 +02:00
Camilla Löwy bd2fb9ebaf Wayland: Fix partial framebuffer size retrieval
(cherry picked from commit 5f60c22cfa)
2020-07-16 13:33:58 +02:00
Camilla Löwy 85a169ff50 X11: Fix cursor hover query retry behavior
XQueryPointer returns zero on BadWindow so the retry did not happen.

Related to ceb20c7f97.

(cherry picked from commit 49dbcfcb8c)
2020-07-16 13:32:11 +02:00
Camilla Löwy 539f4bdca2 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.

(cherry picked from commit ceb20c7f97)
2020-07-16 13:32:04 +02:00
Camilla Löwy 606c0fc03e 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.

(cherry picked from commit 9a3664b4a9)
2020-07-16 13:30:39 +02:00
Camilla Löwy d858e48860 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.

(cherry picked from commit 6ce2070392)
2020-06-30 17:21:24 +02:00
Camilla Löwy e6646c8508 Cocoa: Fix regression in private use area check
This fixes a regression introduced by
ad9eb768c9.

(cherry picked from commit e47832ffcf)
2020-06-30 17:14:24 +02:00
Camilla Löwy 9cae95faa3 Cocoa: Fix non-BMP Unicode codepoint input
Supplimentary Plane codepoints were reported as UTF-16 surrogate pairs.

Fixes #1635.

(cherry picked from commit ad9eb768c9)
2020-06-30 17:14:13 +02:00
Luflosi 1730184971 Fix typos
(cherry picked from commit b66f105f3e)
2020-06-30 17:09:55 +02:00
Camilla Löwy 5dbca2e2c9 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.

(cherry picked from commit c72da994ba)
2020-06-30 17:04:04 +02:00
ben1 37a86f24f0 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.

(cherry picked from commit a84a30ab63)
2020-06-02 19:01:15 +02:00
Luflosi 11e5102d83 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.

(cherry picked from commit 250b94cd03)
2020-06-02 19:01:09 +02:00
Luflosi a8e5c530ee 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.

(cherry picked from commit d4f5074535)
2020-06-02 19:01:05 +02:00
Corentin Wallez 8b63ca53de 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.

(cherry picked from commit 91eebe922d)
2020-06-02 19:00:53 +02:00
Camilla Löwy ca2cd2f796 X11: Clarify function name and comment
(cherry picked from commit 5f9dfe3d83)
2020-05-22 16:29:54 +02:00
Camilla Löwy 0a7c24e48c X11: Clarify code flow for Clang static analysis
(cherry picked from commit ef5220d6b1)
2020-05-22 16:27:33 +02:00
Camilla Löwy 48bc089e9e X11: Fix XKB events being passed on to core path
(cherry picked from commit a17a1b2011)
2020-05-22 16:27:22 +02:00
Camilla Löwy 3df4ebeaac 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.

(cherry picked from commit e07925c404)
2020-05-22 16:27:16 +02:00
Camilla Löwy dff64496d6 X11: Remove duplicate XKB group initialization
The XKB group is already set to zero during initialization.

(cherry picked from commit cf3a03a85d)
2020-05-22 16:27:10 +02:00
Camilla Löwy 117f7694b2 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.

(cherry picked from commit 0c403c8ca6)
2020-05-22 16:27:02 +02:00
Camilla Löwy 6e01359e36 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.

(cherry picked from commit 949275bbed)
2020-05-19 14:33:15 +02:00
Camilla Löwy 404c28df3d 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.

(cherry picked from commit cab41529da)
2020-05-05 00:18:59 +02:00
Camilla Löwy b0c79896a3 X11: Add additional XKB key names for Right Alt
(cherry picked from commit 318e08d914)
2020-05-05 00:18:54 +02:00
Camilla Löwy 4aaf8ba1d2 X11: Use XKB key name MENU for Menu key
(cherry picked from commit 560304e0f4)
2020-05-05 00:18:51 +02:00
Camilla Löwy cf87e6549c X11: Check XKB key aliases in addition to names
(cherry picked from commit 9ecacf1d7f)
2020-05-05 00:18:48 +02:00
Camilla Löwy 27d7fc098d 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.

(cherry picked from commit ee45b58647)
2020-05-05 00:18:16 +02:00
Ali Sherief b25ee390c1 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.

(cherry picked from commit a41a58a95e)
2020-05-05 00:14:18 +02:00
Camilla Löwy a6d022c257 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.

(cherry picked from commit e65de2941c)
2020-04-03 17:03:29 +02:00
Camilla Löwy 2d4c4b7949 X11: Filter out Xlib errors from other connections
(cherry picked from commit 2c8e0512dd)
2020-04-03 17:02:51 +02:00
Camilla Löwy 0ac013381b X11: Fix CJK IME input when locale CTYPE is "C"
Fixes #1587.
Fixes #1636.

(cherry picked from commit 4381b86b6b)
2020-02-13 22:03:51 +01:00
Camilla Löwy d99249337e WGL: Remove unused constants
(cherry picked from commit 27d19d06ca)
2020-02-13 22:02:23 +01:00
Camilla Löwy 1d711057a1 X11: Fix setting the clipboard string to itself
(cherry picked from commit 0c27ed1d0e)
2020-02-13 22:02:15 +01:00
Kovid Goyal 835dc3d327 X11: Fix queries crashing if monitor disconnected
Merged from downstream kovidgoyal/glfw.  First of many.

Related to #1602.

(cherry picked from commit a5e5b782c7)
2020-01-17 15:48:05 +01:00
Camilla Löwy 6a9fd2e13f Win32: Add matching comment
(cherry picked from commit 190673e779)
2020-01-17 15:47:03 +01:00
Camilla Löwy e53538010a 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.

(cherry picked from commit 789a2bcb39)
2020-01-17 15:46:40 +01:00
Camilla Löwy ec28696994 Check scancode before use in glfwGetKeyName
(cherry picked from commit 5f1631cb0e)
2020-01-17 15:46:18 +01:00
Camilla Löwy 0af3bf3b36 Win32: Use non-async key state for modifier hack
The synchronous key state seems to make more sense in context.

(cherry picked from commit a491b0698c)
2020-01-17 15:45:32 +01:00
Camilla Löwy 8552152f80 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.

(cherry picked from commit 562c17d131)
2020-01-17 15:44:45 +01:00
Camilla Löwy 85172703db 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.

(cherry picked from commit 7da87aaae7)
2020-01-17 15:42:39 +01:00
Camilla Löwy d33084447d Cocoa: Select Vulkan surface extension at runtime
This mostly just follows the pattern established by X11.

Related to #1619.

(cherry picked from commit 15d91801b7)
2020-01-17 15:40:48 +01:00
ByunghoonKim 50f3979dfd Cocoa: Add support for VK_EXT_metal_surface
This adds optional support for the VK_EXT_metal_surface instance
extension.

Closes #1619.

(cherry picked from commit c5cb4a253a)
2020-01-17 15:38:54 +01:00
Camilla Löwy fbe8ae993c 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.

(cherry picked from commit 9372ba95fa)
2020-01-14 21:28:58 +01:00
Camilla Löwy 487e0419a7 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.

(cherry picked from commit aa5e313561)
2020-01-12 17:54:49 +01:00
Camilla Löwy ecda86fa4f 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.

(cherry picked from commit fe57e3c292)
2020-01-01 17:24:44 +01:00
Camilla Löwy e8d4cc327d X11: Fix IC event mask not being added to our window
(cherry picked from commit a3d28ef52c)
2019-12-31 23:10:54 +01:00
Camilla Löwy 7f775302ae X11: Cleanup
We can use C99 now and also we will need the event mask below.

(cherry picked from commit 8149a5fc00)
2019-12-31 23:10:46 +01:00
Luflosi cb49e1821b 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.

(cherry picked from commit 74a46dfa0c)
2019-12-31 23:10:29 +01:00
Camilla Löwy 9fc5fd1375 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.

(cherry picked from commit 4ec7daf3e9)
2019-12-31 23:10:11 +01:00
Camilla Löwy bb8ed627bf NSGL: Simulate vsync for occluded windows
This only supports a swap interval of zero or one, as that is all NSGL
supports.

(cherry picked from commit c3ca88055f)
2019-12-31 23:08:11 +01:00
Camilla Löwy ccb54c3e05 NSGL: Remove problematic swap interval workaround
Fixes #1483.

(cherry picked from commit 54e8e0b092)
2019-12-31 23:08:05 +01:00
Camilla Löwy 7c9d0081e3 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.

(cherry picked from commit b4a8eb9b19)
2019-12-31 23:07:35 +01:00
Camilla Löwy c3b8afc5d6 X11: Cleanup
This is technically valid but misleading and may inspire future bugs
like the one fixed by 0b652a44d2.

(cherry picked from commit 73a8ebb691)
2019-12-19 06:57:30 +01:00
Camilla Löwy 4df0a2b38e X11: Cleanup
The window state action is not an atom.

(cherry picked from commit 4e70c95aa3)
2019-12-19 06:57:05 +01:00
Camilla Löwy 94bb2a138e X11: Fix updating GLFW_FLOATING on a hidden window
(cherry picked from commit 9db156421f)
2019-12-19 06:56:58 +01:00
Camilla Löwy 85a27e9f74 X11: Fix invalid read when clearing GLFW_FLOATING
(cherry picked from commit 0b652a44d2)
2019-12-19 06:56:27 +01:00
Camilla Löwy 5615c16439 X11: Fix missing checks for EWMH attention atoms
(cherry picked from commit 9b6d68ec70)
2019-12-19 06:56:19 +01:00
Camilla Löwy 8dd40f1c48 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.

(cherry picked from commit 4837b78ffe)
2019-12-19 06:56:14 +01:00
Camilla Löwy 640e3205a9 Win32: Add missing include for wcscmp
(cherry picked from commit da3f20d860)
2019-12-19 06:56:02 +01:00
Camilla Löwy dd00c6dea1 Win32: Enable Unicode mode for all compilers
(cherry picked from commit fb0028c766)
2019-12-19 06:55:55 +01:00
Camilla Löwy e8dab39625 Fix use of CMake 3.13 command target_link_options
(cherry picked from commit a5ed740d9d)
2019-12-19 06:54:14 +01:00
Camilla Löwy 9724f33038 Formatting
(cherry picked from commit 506a6aafde)
2019-12-19 06:50:22 +01:00
Camilla Löwy 8c3d2f769f Cocoa: Fix duplicate conversion of title string
(cherry picked from commit a875a536b7)
2019-12-19 06:50:17 +01:00
Camilla Löwy 03f2cde34e Replace CMake generator expression with variable
Generator expressions are amazing but best used in moderation.

(cherry picked from commit c194193797)
2019-12-19 06:47:14 +01:00
Camilla Löwy cd70e1bbc4 Merge GCC/Clang specific CMake blocks
(cherry picked from commit 9dc365f192)
2019-12-19 06:47:07 +01:00
Camilla Löwy db2ff13d41 Fix source list for Objective-C fix
(cherry picked from commit 197193ac0b)
2019-12-19 06:44:15 +01:00
Camilla Löwy 82bd22ec29 Fix source list for -Wdeclaration-after-statement
The context creation files were not included on platforms other than
Win32.

(cherry picked from commit 9486ec0c02)
2019-12-19 06:43:47 +01:00
Camilla Löwy bcd232e2ae Remove tab character
(cherry picked from commit bc7b19cbd1)
2019-12-19 06:43:17 +01:00
Camilla Löwy f650a898f2 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.

(cherry picked from commit f6d44cedfd)
2019-12-19 06:43:04 +01:00
Camilla Löwy e135210cb3 NSGL: Fix disabling of Retina resolution
It appears the default is now YES.

Fixes #1442.

(cherry picked from commit fa60269245)
2019-12-19 06:38:22 +01:00
Camilla Löwy 2da4adce40 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.

(cherry picked from commit 6e6805000a)
2019-12-19 06:37:23 +01:00
Camilla Löwy 17d727cd35 Cocoa: Update outdated comment
(cherry picked from commit b3544ca43e)
2019-12-19 06:37:12 +01:00
Emmanuel Gil Peyrot 9db0bd45e6 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.

(cherry picked from commit ef6189f348)
2019-12-19 06:35:14 +01:00
Camilla Löwy df4bda44fc Wayland: Fix pointing hand cursor shape
Related to #1432.

(cherry picked from commit 80fde12fda)
2019-12-03 17:19:14 +01:00
Emmanuel Gil Peyrot 50218fbf7e 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.

(cherry picked from commit a80788c17f)
2019-12-03 17:17:36 +01:00
Emmanuel Gil Peyrot 3a2c0aaa27 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.

(cherry picked from commit a9f674e719)
2019-12-03 17:17:33 +01:00
Camilla Löwy 7c33fb22fd 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.

(cherry picked from commit e96dc5d219)
2019-11-14 21:34:04 +01:00
Camilla Löwy 52b77030e4 Cocoa: Fix full screen window iconification
Iconification (miniaturization) of undecorated windows stopped working
unless the window has the NSWindowStyleMaskMiniaturizable style.

(cherry picked from commit 2c519709be)
2019-11-14 21:34:01 +01:00
Camilla Löwy e662492169 Cocoa: Cleanup
Readability fix, does not affect generated code.

(cherry picked from commit bd452016be)
2019-11-14 21:33:56 +01:00
Camilla Löwy b3c2023ebc Cocoa: Fix multiple methods warning
This fixes a warning due to us using bare ids and
NSCollectionLayoutAnchor having a message with the same name.

(cherry picked from commit bac15f9449)
2019-11-14 21:33:52 +01:00
Camilla Löwy 129a5ccb19 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.

(cherry picked from commit c819f27ce3)
2019-11-14 21:33:48 +01:00
Camilla Löwy 25af31528c Cocoa: Add comments for Cocoa symbol macros
(cherry picked from commit 94cb0347ab)
2019-11-14 21:33:43 +01:00
Camilla Löwy 5f7e5cb92b 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.

(cherry picked from commit b69fb99031)
2019-11-14 21:30:07 +01:00
Camilla Löwy c5a870ebd9 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.

(cherry picked from commit c88ee1c9d3)
2019-11-14 21:30:02 +01:00
Camilla Löwy 399c082033 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.

(cherry picked from commit 75294462b3)
2019-11-05 18:03:11 +01:00
Camilla Löwy 1bf892f603 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.

(cherry picked from commit 5fc4c01302)
2019-11-05 18:02:03 +01:00
Camilla Löwy f9a9bb6747 Remove stray characters from hardcoded CFLAGS
The additional '>' characters were appended to the compiler option.

Related to #1576.

(cherry picked from commit 33683ec60e)
2019-11-05 18:01:18 +01:00
Camilla Löwy 91c6a542ff Cleanup
Related to #1585.

(cherry picked from commit 04f7f55f07)
2019-11-05 18:01:05 +01:00
Pablo Prietz 411d4dd51e 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.

(cherry picked from commit 4d0ae4ffa7)
2019-11-05 18:00:50 +01:00
Corentin Wallez afcefcb5f7 Fix -Wextra-semi warnings
Closes #1440.

(cherry picked from commit 3a37a08998)
2019-11-05 17:59:15 +01:00
Luflosi 8c69091c59 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.

(cherry picked from commit 7749aac50d)
2019-11-05 17:59:08 +01:00
Guillaume Racicot 3f0390b827 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.

(cherry picked from commit 8f852e0833)
2019-11-05 17:58:45 +01:00
Luflosi 3facbd2083 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.

(cherry picked from commit d25248343e)
2019-11-05 17:58:10 +01:00
Camilla Löwy 087110aa63 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.

(cherry picked from commit 3d2540c373)
2019-10-04 02:18:48 +02:00
Camilla Löwy e30718e927 Win32: Disable dynamic libgcc for MinGW DLL
(cherry picked from commit 3ec8f4a7f5)
2019-10-04 02:18:46 +02:00
Luflosi 613b169899 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.

(cherry picked from commit 243b1bc292)
2019-10-04 02:18:43 +02:00
luz.paz 13a4e4e810 Fix typos
Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille`

(cherry picked from commit 7105ff2dfd)
2019-09-23 15:27:17 +02:00
Camilla Löwy a1b65e8542 Cocoa: Fix glfwSetWindowSize anchor point
This makes glfwSetWindowSize use the top-left corner as anchor point
instead of the bottom-left corner.

Fixes #1553.

(cherry picked from commit 7f02898264)
2019-09-23 15:27:00 +02:00
httpdigest b2919dca4b 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.

(cherry picked from commit 2777f6a754)
2019-09-23 15:26:37 +02:00
Camilla Löwy 71cfafe2f9 Win32: Fix VS static analysis false positive
This way is perhaps also more readable for humans.

(cherry picked from commit cbf23e5615)
2019-09-23 15:26:28 +02:00
Camilla Löwy 79f4ec6822 Unify key name string handling
This makes key names per-key static strings for all supported platforms.

Fixes #1200.

(cherry picked from commit 56ca0cb3b3)
2019-09-23 15:26:23 +02:00
Camilla Löwy 2032a8f0dc Clarify comment
(cherry picked from commit 4cc5d2e623)
2019-09-23 15:26:17 +02:00
Camilla Löwy 2d3f388158 Win32: Fix initial state of maximized state cache
(cherry picked from commit 2c7ef5b480)
2019-09-23 15:26:08 +02:00
Camilla Löwy 30e67357be Win32: Fix GLFW_MAXIMIZED not maximizing window
The window rect adjustment for content scale broke the initial, correct
maximization performed when creating the window with WS_MAXIMIZE.  This
switches to updating the restored rect instead of the current rect.

Fixes #1499.
Closes #1503.

(cherry picked from commit 711b9694a1)
2019-09-23 15:25:51 +02:00
Ave Milia d25e19b790 CMake: remove -DGLFW_DLL on non-Windows targets
When using GLFW with CMake and installed GLFW binaries, `-DGLFW_DLL` is
passed on Linux, which should not happen.

Closes #1530.

(cherry picked from commit d7fb01750ece465cfaae0493dfe3003da1e5f500)
2019-07-22 23:26:02 +02:00
Camilla Löwy 1daf9de40f Cocoa: Fix internal symbol hiding for dylib
The default symbol visibility was not set to hidden on macOS.

(cherry picked from commit b430bc4935)
2019-07-22 23:25:52 +02:00
Camilla Löwy cfd93597ec Cocoa: Fix file-local function not declared static
(cherry picked from commit 062a1c22b5)
2019-07-22 23:24:56 +02:00
Leon Linhart 9fc035a562 Win32: Fix cursor enter/position event order
This fixes the cursor enter event being emitted after the first cursor
position event on Windows.

Closes #1490.

(cherry picked from commit 4f0b8b0dda)
2019-07-16 14:41:16 +02:00
Camilla Löwy ff2c00091d Cleanup
Related to #1528.

(cherry picked from commit d232bcfcdd)
2019-07-16 14:39:38 +02:00
Denis Bernard b3eb6dd38b X11: Query and keep track of Xkb group index
For users with multiple keyboard layouts configured, glfwGetKeyName
works fine only with the primary layout.  Switching layouts results in
changing the group index.  This commit querries the current group index
when initializing keyboard input and keeps track of any change to it.

As a result the scancode -> keyname mapping may change while the program
is running (needs to be documented).

Fixes #1462.
Closes #1528.

(cherry picked from commit 36f90800d8)
2019-07-16 14:39:34 +02:00
Camilla Löwy 84fa724456 X11: Fix focus events not being filtered
The filter condition had ended up below the action.

(cherry picked from commit c6b95e3b07)
2019-07-16 14:39:28 +02:00
Luflosi 633ba53f2c Fix typo
Closes #1513.

(cherry picked from commit e463e85bba)
2019-07-16 14:39:19 +02:00
Camilla Löwy eb466a0e0b Cocoa: Cleanup
This makes the Cocoa _glfwPlatformSetWindowMonitor consistent with its
X11 and Win32 counterparts.

(cherry picked from commit 3262c29440)
2019-07-16 14:39:05 +02:00
A. Tombs 8542f8dd84 Win32: Cleanup pointer test in win32_window.c
MSVC 2019 complains that the code at line 1744
(`GetMonitorInfo(window->monitor->win32.handle, &mi);`) can potentially
dereference a null pointer. The compiler is wrong in this case (it has
not spotted that `monitor` and `window->monitor` must be equal), but
I think it makes sense for our non-NULL test to be on the variable we
actually use rather than the one it was set from.

Related to #1491.

(cherry picked from commit 1d62157268)
2019-07-16 14:39:02 +02:00
Camilla Löwy 1e12653348 X11: Let the language initialize XEvent structs
(cherry picked from commit 1f508530f0)
2019-07-16 14:38:55 +02:00
Camilla Löwy e276f6731e X11: Clean up EWMH feature detection
The EWMH feature detection atoms are now named and loaded the same way
as other X11 atoms.  Detection is now performed after all
non-conditional atoms have been loaded.  The EWMH detection now has
hopefully more readable comments.

(cherry picked from commit fad9896d38)
2019-07-16 14:38:48 +02:00
Camilla Löwy 66e06b0609 Convert some declarations to C99 style
(cherry picked from commit 0c6b505619)
2019-07-16 14:38:26 +02:00
Luflosi 71a4f2d8a2 Replace some tabs with spaces
I found some tabs where there should be spaces for consistency.
Closes #1496.

(cherry picked from commit 2db3b9688d)
2019-07-16 14:38:14 +02:00
Camilla Löwy b436d8e3e6 Remove pointless comments
(cherry picked from commit 84ec99bb01)
2019-05-27 16:34:23 +02:00
Camilla Löwy ad3e7c7f39 Win32: Fix non-client actions for disabled cursor
Disabled cursor mode interfered with some non-client actions.

(cherry picked from commit d0c3fa900a)
2019-05-27 16:34:17 +02:00
Camilla Löwy 15f078c6ad Win32: Remove stale comment
(cherry picked from commit 267e06a41e)
2019-05-27 16:34:13 +02:00
Camilla Löwy 051424f196 WGL: Add extension function macro aliases
This should have been done when the WGL extension members were moved
from the context struct to the library struct.

(cherry picked from commit 22a6c02a4c)
2019-05-27 16:33:59 +02:00
Camilla Löwy 97393223ee WGL: Fix misplaced block comment
(cherry picked from commit 3fd4e79adb)
2019-05-27 16:33:55 +02:00
Camilla Löwy 04522580ad Add C dialect reminders to each source file
Files built for Win32 must use C89 style declarations for compatibility
with VS 2010 and 2012, which are still supported by GLFW.

(cherry picked from commit 56aad76b16)
2019-05-27 16:33:22 +02:00
Camilla Löwy bc8b567d7c Move to the modern CMake project version option
This replaces the manual ad-hoc version variables we have used since
CMake 2.x (and GLFW 2.x lite).

(cherry picked from commit a255e7ace6)
2019-05-19 18:30:58 +02:00
Konstantin Podsvirov 2e3b4cf898 Fix use of absolute path in INSTALL_INTERFACE
Closes #1470.

(cherry picked from commit 15af302f77)
2019-05-19 18:26:58 +02:00
Camilla Löwy ab118b2529 Fix copyright years (somewhat) 2019-04-15 20:50:00 +02:00
Camilla Löwy 1f91697cd3 Win32: Fix VS static analysis warnings 2019-04-15 15:37:15 +02:00
Camilla Löwy 334a485968 Win32: Fix potential buffer overrun
Found with VS static analysis.
2019-04-15 15:35:19 +02:00
Camilla Löwy 0e74265426 Cocoa: Fix cursor hover test 2019-04-15 14:52:17 +02:00
Camilla Löwy 3c3981a4f0 Cocoa: Fix coordinate transformations
Window relative mouse locations provided via NSWindow and NSEvent are
based at 0,1 while screen relative locations use 0,0.  Incorrect
handling of this had crept into other coordinate transformations.  Note
that most of these errors canceled each other out, so the reported
positions of windows, monitors and work areas are unaffected.  This
corrects the cursor position for glfwGetCursorPos and glfwSetCursorPos.

Fixes #1461.
2019-04-15 14:52:17 +02:00
Camilla Löwy 28f118f4de NSGL: Disable swap interval
Swap interval now uses CVDisplayLink.
2019-04-15 14:36:12 +02:00
Camilla Löwy 93962ec168 Win32: Fix VS 2010 build error 2019-04-15 02:46:07 +02:00
Camilla Löwy 3461d1c2a5 Fix missing context APIs in version strings 2019-04-08 20:51:34 +02:00
Camilla Löwy c585bf010b Fix file flags 2019-04-07 20:44:21 +02:00
Cliff Smolinsky 87458617e0 Win32: Bypass composition check on Windows 8+
DWM composition is always enabled on Windows 8 and later, so there's no
need to call DwmIsCompositionEnabled on those platforms.

Fixes #1452.
Closes #1453.
2019-04-01 18:11:55 +02:00
Camilla Löwy 297999c9e1 Add missing SDL2 attribution 2019-04-01 17:42:27 +02:00
Camilla Löwy 5292914ce1 Win32: Fix message pump filtering during init
Fixes #886.
2019-03-28 23:50:13 +01:00
Camilla Löwy 02874d9c14 Align joystick axis to gamepad button behavior
This is an SDL2 compatibility fix.
2019-03-28 23:01:27 +01:00
Camilla Löwy 0d355379e0 Cocoa: Support some sim page joystick elements
This is an SDL2 compatibility fix.
2019-03-28 22:58:47 +01:00
Camilla Löwy c32dc3a085 Fix half-axis to gamepad button value mapping
Negative half-axes were not negated when mapped onto gamepad buttons.
2019-03-27 20:34:54 +01:00
Camilla Löwy cad22cb2f6 Cocoa: Fix missing check for selector
Fixes #1457.
2019-03-27 20:04:43 +01:00
Camilla Löwy 1fca33b3c1 Cocoa: Remove checks for pre-10.8 SDK
OS X 10.8 is now the minimum required version but these checks were not
removed when that change was made.
2019-03-27 20:03:05 +01:00
Camilla Löwy 9420e6f0d0 Fix invalid ranges for gamepad axis sources
Buttons and hat bits were mapped to [0,1] instead of [-1,1].

Fixes #1293.
2019-03-27 19:35:19 +01:00
Camilla Löwy 980fc9b52f Cocoa: Apply retina window hint to Metal layer
Related to #1340.
2019-03-27 17:14:30 +01:00
Camilla Löwy e108c0de0d Cocoa: Explicitly set layer on surface creation
Implicitly setting the layer doesn't work when there is already a layer.
Our view is now layer-hosting for Vulkan.

Fixes #1340.
2019-03-27 16:28:16 +01:00
Camilla Löwy 056c5d3f90 Cleanup 2019-03-27 01:26:39 +01:00
Camilla Löwy a4fbc6fe91 NSGL: Disable API deprecation warnings 2019-03-26 18:30:17 +01:00
Camilla Löwy 8d7e5cdb49 NSGL: Update current display for display link
This solution of one display link per window is far from ideal but is
still better than no solution.

As a side-effect this fixes swap interval breaking being ignored for
occluded windows on earlier versions of macOS.

Fixes #680.
Fixes #1337.
Related to #1417.
Fixes #1435.
2019-03-05 20:22:00 +01:00
Camilla Löwy f8bcc7e65c NSGL: Fix leak of condition object
Related to #1417.
2019-03-05 20:22:00 +01:00
Camilla Löwy ba761ab06e NSGL: Fix display link leaking and left running
Related to #1417.
2019-03-05 20:22:00 +01:00
Camilla Löwy d0e8d06d95 Cleanup
Related to #1417.
2019-03-05 20:22:00 +01:00
Camilla Löwy 3615d437a7 Formatting
Related to #1417.
2019-03-05 20:22:00 +01:00
amarcu5 82ca58da04 NSGL: Implement swap interval with CVDisplayLink
This fixes OpenGL swap interval (vsync) on macOS 10.14 Mojave by using
CVDisplayLink to synchronise to the monitor refresh rate rather than
setting NSOpenGLContextParameterSwapInterval.

Solution based on advice provided by @rcgordon.

Closes #1417.
2019-03-05 20:21:56 +01:00
Camilla Löwy 4e3204d86d Cocoa: Replace global autorelease pool with blocks
This is another small step towards having GLFW play nice with other
toolkits sharing the same process, including AppKit.

Any macOS platform function that touches Cocoa must now wrap itself in
an autoreleasepool block.

Since GLFW no longer provides an autoreleasepool outside of its
functions, THIS MAY BREAK EXISTING CODE MIXING GLFW AND COCOA.  Sorry!
Please add your own autoreleasepool blocks as needed.

Fixes #1107.
Closes #1114.
2019-03-05 20:11:20 +01:00
Camilla Löwy 9883cb64f0 Cocoa: Disable shadow for transparent framebuffer 2019-03-05 20:03:29 +01:00
Camilla Löwy 4b20fb705b Cocoa: Fix work area using NS screen coordinates
Related to #1322.
2019-03-05 17:41:32 +01:00
Camilla Löwy 3a2a97f15d X11: Fix implementation of work area retrieval
This intersects the global work area from _NET_WORKAREA with the monitor
viewport.  The monitor viewport falls back to the core display
dimensions where working RandR is missing.  The _NET_WORKAREA query is
now checked for success.  The _NET_WORKAREA extent array is now indexed
by _NET_CURRENT_DESKTOP.  The _NET_WORKAREA atom is now checked for
availability.

Related to #1322.
2019-03-05 16:58:45 +01:00
Camilla Löwy 4f14c1e776 X11: Fix copypaste errors
Related to #1322.
2019-03-05 16:58:45 +01:00
Camilla Löwy d82e7b5cb1 Win32: Use cached monitor handle for work area
This facility was added after the original PR was made.

Related to #1322.
2019-03-05 16:58:45 +01:00
Camilla Löwy 0118743333 Formatting
Related to #1322.
2019-03-05 16:58:45 +01:00
Camilla Löwy a726942bfe Cocoa: Unify NSScreen cached lookup for monitors
Related to #1322.
2019-03-05 16:58:45 +01:00
Doug Binks 68fd4e8bb3 Cocoa: Fix work area retrieval on missing screen
Closes #1322.
2019-03-05 16:58:45 +01:00
Doug Binks ba4e78e57f Wayland: Return whole output area as work area
Related to #1322.
2019-03-05 16:10:59 +01:00
Doug Binks 222ac78a44 Cocoa: Add work area NULL checks and fix size
Related to #1322.
2019-03-05 16:10:59 +01:00
Doug Binks bea4818030 X11: Add NULL checks in work area retrieval
Related to #1322.
2019-03-05 16:10:59 +01:00
Doug Binks e6d22346f9 Fix copypaste error in glfwGetMonitorWorkarea
Related to #1322.
2019-03-05 16:10:59 +01:00
Doug Binks f7733c7b4f Win32: Add missing out parameter NULL checks
This fixes _glfwPlatformGetMonitorWorkarea not checking if its out
parameters were NULL.

Related to #1322.
2019-03-05 16:10:59 +01:00
Doug Binks 5c752355cb Win32: Fix and simplify work area retrieval
Related to #1322.
2019-03-05 16:10:59 +01:00
Felipe Ferreira da Silva be295ccbea Add glfwGetMonitorWorkarea
This function retrieves the work area rectangle of the specified
monitor.

Related to #920.
Closes #989.
2019-03-05 16:10:59 +01:00
Camilla Löwy c20754c4a6 Fix Coverity Scan false positive 2019-03-04 18:52:56 +01:00
Camilla Löwy 621ece63c8 Round refresh rate instead of truncating
Fixes #1441.
2019-03-04 17:31:14 +01:00
Camilla Löwy 2fbb560eb7 Cocoa: Fix window creation blocking after re-init
Fixes #1439.
2019-02-25 02:41:05 +01: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 44af6bb936 Wayland: Implement raw mouse motion control
Related to #1400.
Related to #1401.
2019-02-22 14:52:02 +01:00
Camilla Löwy 1155c83013 Rename raw input to raw mouse motion, cleanup
This renames 'raw input' to 'raw mouse motion' as there are other kinds
of raw input.  The update path is restructured to avoid reinitializing
all of disabled cursor mode.  Modification of shared state is moved out
into shared code.  Raw mouse motion is disabled by default for
compatibility.

Related to #1401.
2019-02-22 13:04:11 +01:00
Nathan Poirier 9e29f556fd Add GLFW_RAW_INPUT and glfwRawInputSupported
This adds runtime per-window control of whether accelerated or raw mouse
motion is provided when the cursor is disabled.

Fixes #1400.
Closes #1401.
2019-02-22 13:04:11 +01:00
Emmanuel Gil Peyrot 5f9cbd0ebc Wayland: keyboard repeat rate is given in Hz
It was currently interpreted as ms, which is obviously wrong.

Thanks to https://github.com/Smithay/client-toolkit/pull/62 for making
me notice this issue.
2019-02-20 15:56:04 +01:00
Camilla Löwy ec3784f3d7 WGL: Unify query error handling 2019-02-17 18:34:56 +01:00
Camilla Löwy 782f7fe0c7 WGL: Fix leak on format attrib query failure
This was found by Coverity Scan.
2019-02-17 18:34:56 +01:00
Emmanuel Gil Peyrot 45bd991ea9 Wayland: Fix auto-iconify on kwin_wayland
We now keep track of the fullscreen and activated state and only iconify
if we were previously fullscreen and now we are either not fullscreen or
not activated anymore.

This is the proper way to do it, compared to the previous hack where we
didn’t iconify only if it was the first configure event received.
2019-02-15 18:12:09 +01:00
Emmanuel Gil Peyrot edf0a07174 Wayland: Only auto-iconify fullscreen windows
Thanks to kwin for exposing a bug here!
2019-02-15 17:03:37 +01:00
Greg V 36ce73bbfd Wayland: use SHM_ANON on FreeBSD
This works like memfd on Linux.
2019-02-15 15:45:25 +01:00
Camilla Löwy 1d95acdf56 Cocoa: Fix detection of Clang 2019-02-14 00:19:45 +01:00
schraf 2e70950c0f Fix quoting of CMAKE_C_COMPILER_ID
I was getting an error in this cmake file when using 3.10.2 on linux.
Here was the error message I was getting:

[cmake] CMake Error at external/glfw/src/CMakeLists.txt:82 (if):
[cmake]   if given arguments:
[cmake]
[cmake]     "STREQUAL" "GNU" "OR" "STREQUAL" "Clang"
[cmake]
[cmake]   Unknown arguments specified

Adding the quotes around the cmake variables seems to do the trick. That
was also done with the STREQUAL condition earlier on line 66.

Closes #1411.
2019-02-14 00:19:45 +01:00
Camilla Löwy 2a27eb95e4 X11: Fix system cursor used for GLFW_HAND_CURSOR
Fixes #1432.
2019-02-14 00:04:39 +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 90e22947c6 Cleanup 2019-01-31 01:58:04 +01:00
Camilla Löwy 463ef7eb71 Cocoa: Fix handling of analog joystick buttons
The reported state was not clamped to [0,1], i.e. GLFW_RELEASE and
GLFW_PRESS.

Fixes #1385.
2019-01-31 01:54:49 +01:00
Camilla Löwy 51ca41dd9f Cocoa: Add missing IOHID page and usages
Related to #1385.
2019-01-31 01:53:55 +01:00
Camilla Löwy 530b37f4db Cocoa: Disable automatic tabbing for GLFW windows
Related to #1250.
2019-01-31 00:20:24 +01:00
Camilla Löwy 78e6a0063d X11: Fix EWMH state update for hidden windows
The EWMH window state code assumed the window was mapped.

Fixes #1358.
2019-01-31 00:02:16 +01:00
Camilla Löwy b41cd34143 Cleanup 2019-01-25 12:46:46 +01:00
Camilla Löwy d5ab3e919a Cleanup
Replace client area with content area.
2019-01-25 12:46:46 +01:00
iamCaveLamp a46104ee69 Removed duplicates of centerCursor function 2019-01-22 20:17:35 +01:00
Camilla Löwy 3d748cf530 Cleanup
Related to #1381.
2019-01-17 00:12:59 +01:00
Doug Binks babafc13db WGL: Add array-based call to wglGetPixelFormatAttribivARB
This improves performance of pixel format enumeration and helps the very
poor performance reported on a small number of machines.

Closes #1381.
2019-01-17 00:12:59 +01:00
Camilla Löwy 2053f3ed22 Cleanup 2019-01-17 00:11:17 +01:00
Camilla Löwy 55b1a16f90 Remove window requirement for all event functions
This lets an application wait for non-window events without needing to
create a window.

Fixes #1317.
2019-01-15 19:28:17 +01:00
Camilla Löwy ea7eb2ddab Cocoa: Move app delegate and menu creation to init
The application delegate needs to be set at init to receive monitor
events before window creation.  Menu creation is moved to
applicationWillFinishLaunching: to play nicer with other toolkits in the
same process.

Related to #1317.
2019-01-11 01:05:00 +01:00
Camilla Löwy 9a9568212c Cocoa: Move slightly towards modern Objective-C 2019-01-10 23:20:56 +01:00
Camilla Löwy 72c3908e14 X11: Fix glfwSetWindowMonitor not flushing buffer 2019-01-02 21:55:30 +01:00
Camilla Löwy cde0aaaab1 X11: Fix glfwSetWindowMonitor not updating hints
This makes glfwSetWindowMonitor update the WM_NORMAL_HINTS when resizing
non-user-resizable windowed mode windows.
2019-01-02 21:55:30 +01:00
Camilla Löwy 1635fe2826 Cleanup
Put the non-client painting related message cases with the client ones
so that they can be happy together.

Related to #1383.
2018-12-26 15:22:20 +01:00
Aaron Loucks 9ac9d7b85a Win32: Disable non-client painting if undecorated
Fixes an issue where a small title bar and window caption
buttons were being painted after restoring a minimized
undecorated window.

Closes #1383.
2018-12-26 15:00:39 +01:00