Commit Graph

2700 Commits

Author SHA1 Message Date
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