The data available on the X11 connection may be a reply or an internal
event for an X11 extension. Previously the check for whether an event
was available for us was done outside waitForEvent. This prevented data
available on other file descriptors from breaking the outer wait loop.
This commit moves the check for whether an event is available into the
wait functions, where there is enough knowledge to limit the check to
the X11 connection.
Related to #932
On Linux, the inotify descriptor was included in the set used for
select, but could not break the outer loop, leading to busy waiting
until timeout or the correct X11 event arrived.
This commit adds a new function for waiting just on X11 events.
Fixes#1872
We switched to kUTTypeURL when NSURLPboardType was deprecated, as the
official replacement symbol NSPasteboardTypeURL was not available on
every version of macOS supported by GLFW.
kUTTypeURL has now also been deprecated.
This commit moves to a compile-time choice between NSURLPboardType and
NSPasteboardTypeURL depending on the minimum targeted macOS version.
Fixes#2003
By definition a hidden window on Wayland does not have valid framebuffer
contents.
This adds a window damage (refresh) event when a window is shown, to
request an initial frame for the now visible window.
Platform code should not generate key events with GLFW_REPEAT.
GLFW_PRESS is translated into GLFW_REPEAT by shared code based on the
key state cache.
This confused the automatic key release logic into not generating an
event with GLFW_RELEASE for a key being repeated when the window lost
input focus.
The OpenBSD ports tree assigns its own soname version numbers, so the
hardcoded sonames GLFW uses to load libraries on non-macOS Unices are
often incorrect. Instead OpenBSD recommends that run-time loading
should leave out the version numbers entirely. The OpenBSD ld.so then
finds the correct library.
This upstreams the ports tree fixes for Xcursor and EGL, and adds the
corresponding fix for all other run-time loaded library sonames.
Tested on OpenBSD 7.0.
This issue was initially reported on IRC.
Corrects the protocol violation when creating an xdg_surface from a
wl_surface that already has a buffer due to EGL buffer swaps.
This commit is based on PR #1731 by @ghost, but adapted and altered:
- The XDG surface and role are now only created when a window is shown
to prevent application lists from showing command-line applications
with off-screen-only windows
- The special case of Wayland+EGL buffer swap is now in the EGL code
to mirror how X11 is handled
- Adaption to run-time platform selection and separate credits file
Fixes#1492Closes#1731
The monitor handle could have become invalid just before the call to
GetDpiForMonitor. It was possible for both window and monitor content
scale queries.
This ensures both that an appropriate error is emitted and that the
retrieved values are zero on error.
Fixes#1615
This removes the GLFW_VULKAN_STATIC CMake option and the
_GLFW_VULKAN_STATIC configuration macro and replaces them with the
glfwInitVulkanLoader function, allowing a single library binary to
provide both behaviors.
This is based on the design from PR #1374 by @pmuetschard.
Closes#1374Closes#1890
This hack breaks when switching a window to fullscreen, if the OpenGL
ICD detects this and switches its swapchain to exclusive mode.
This limits the hack to Windows Vista and 7. This hack was added
because of vsync jitter under DWM on Windows 7 and I have been unable
to reproduce it on any later version.
Is this change causing any problems on any version of Windows? Please
open an issue!
Fixes#1072
This adds compile-time support for multiple platforms and runtime
detection of them. Window system related platform functions are now
called from shared code via the function pointer struct _GLFWplatform.
The timer, thread and module loading platform functions are still called
directly by name and the implementation chosen at link-time. These
functions are the same for any backend on a given OS, including the Null
backend.
The platforms are now enabled via CMake dependent options following the
GLFW_BUILD_<platform> pattern instead of a mix of automagic and ad-hoc
option names. There is no longer any option for the Null backend as it
is now always enabled.
Much of the struct stitching work in platform.h was based on an earlier
experimental branch for runtime platform selection by @ronchaine.
Every platform function related to windows, contexts, monitors, input,
event processing and Vulkan have been renamed so that multiple sets of
them can exist without colliding. Calls to these are now routed through
the _glfw.platform struct member. These changes makes up most of this
commit.
For Wayland and X11 the client library loading and display creation is
used to detect a running compositor/server. The XDG_SESSION_TYPE
environment variable is ignored for now, as X11 is still by far the more
complete implementation.
Closes#1655Closes#1958
The native access functions for context handles did not verify that the
context had been created with the same API the function was for.
This makes these functions emit GLFW_NO_WINDOW_CONTEXT on API mismatch.
The Wayland protocol spec[1] states that set_cursor must be called
with the serial number of the enter event. However, GLFW is passing in
the serial number of the latest received event, which does not meet the
protocol spec.
[1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_pointer
As a result, set_cursor calls were simply ignored by the compositor.
This fix complies with the protocol more closely by specifically caching
the enter event serial, and using it for all set_cursor calls.
Fixes#1706Closes#1899
According to the libxkbcommon documentation[1], xkb_keymap_key_repeats
requires keymap and keycode as input:
int xkb_keymap_key_repeats( struct xkb_keymap * keymap,
xkb_keycode_t key)
However, in inputChar in wl_input.c we are passing in xkb_keysym_t,
which was a type mismatch.
This results in some keys not repeating when they should and vice versa.
[1] https://xkbcommon.org/doc/current/group__components.html#ga9d7f998efeca98b3afc7c257bbac90a8Closes#1908.
This adds the glfwInitAllocator function for specifying a custom memory
allocator to use instead of the C runtime library.
The allocator is a struct of type GLFWallocator with fields
corresponding to malloc, realloc and free, while the internal API
corresponds to calloc, realloc and free.
Heap allocation calls are filtered before reaching the user-provided
functions, so deallocation of NULL and allocations of zero bytes are not
passed on, reallocating NULL is transformed into an allocation and
reallocating to size zero is transformed into deallocation.
The clearing of a new block to zero is performed by the internal
calloc-like function.
Closes#544.
Fixes#1628.
Closes#1947.
This will be useful when building GLFW as a CMake object library and
linking it into a larger library that exports pkg-config information.
Partly based on #1307 by @a3f.
Closes#1307.
This adds the GLFW_LIBRARY_TYPE CMake cache variable, which allows users
and higher-level projects to set what type of library GLFW is built as.
When not empty, this value overrides the standard BUILD_SHARED_LIBS
option for GLFW while still allowing it to control the type of other
libraries in a larger project.
This also allows building GLFW as an object library without adding dummy
source files (as required by Xcode) or producing unused library
binaries.
Projects using CMake 3.12 or later can link the resulting GLFW object
library normally using target_link_libraries.
Fixes#279.
Related to #1307.
Closes#1497.
Closes#1574.
Closes#1928.
The insight to use wayland.xml to resolve the difficult-to-redirect
interface symbols was gleaned from SDL.
Instead of compiling the code output of wayland-scanner separately it is
made part of the wl_init compilation unit. This lets us do things like
transparently rename our copies of Wayland globals.
The OS version of wayland-client-protocol.h is no longer used by GLFW,
but it is presumably ABI compatible with the output of wayland-scanner.
Closes#1174.
Closes#1338.
Related to #1655.
Closes#1943.
POSIX.1-2008 deprecated gettimeofday, which we used as a fallback if the
monotonic clock was unavailable.
This replaces that fallback with the non-monotonic real-time clock.
Because of the Gordian knot of feature test macros across Unices, this
also includes the shift from some platform source files defining
_POSIX_C_SOURCE to various values to _DEFAULT_SOURCE being defined for
all source files on Linux. This is because -std=c99 on Linux disables
_DEFAULT_SOURCE (POSIX 2008 and extensions).
Once runtime platform selection comes in, this kind of platform-specific
preprocessor logic can be moved into the platform glue files and won't
need to be replicated by third-party build setups, but for now, sorry.
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.
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.
The old Travis CI .org service has been throttled for a while now and is
said to be shutting down completely next week.
This migrates the Travis CI build jobs to GitHub Actions, with minor
changes.
- The trailing whitespace detection has been removed for now.
- The libegl1-mesa-dev dependency for Wayland has been removed as it
appears to no longer be necessary for building.
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.
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.
This makes USE_MSVC_RUNTIME_LIBRARY_DLL update the directory scope
CMAKE_MSVC_RUNTIME_LIBRARY variable instead of CMAKE_C_FLAGS on CMake
3.15 and later.
Solution proposed by @moritz-h.
Fixes#1783.
Closes#1796.
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.
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.
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/3051Closes#1798.
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.
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.
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.
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.
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.
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.
The documentation claims that any extension loader library header
included before the GLFW one will prevent the inclusion of the
default OpenGL header. In reality this only worked if the loader
defined the canonical desktop OpenGL __gl_h_ inclusion guard and even
then relied on the OpenGL header to detect this.
This is the companion to 105cf32e0b, which
added the preprocessor logic to check for many known OpenGL and OpenGL
ES inclusion guards and not even attempt to include the default header
if any are present.
Some clarification of the language around header inclusion has also been
attempted, including making GLFW_INCLUDE_NONE more prominent.
Fixes#1695.
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.
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.
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.
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.
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.
This removes most references to GLU, replaces the legacy CMake cache
variables for OpenGL with the modern namespaced target and switches to
$() for command substitution.
Fixes#1580.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Replaces `VERSION_GREATER_EQUAL` with `VERSION_EQUAL OR
VERSION_GREATER`. `VERSION_GREATER_EQUAL` was only added in CMake 3.7.
Fixes#1584.
Closes#1585.
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.
When both GLFW_INCLUDE_VULKAN and VK_USE_PLATFORM_WIN32_KHR were
defined, the GLFW header would define replacement versions of APIENTRY
and WINGDIAPI /before/ including the Vulkan header, which would include
windows.h, which (justifiably) defines APIENTRY and WINGDIAPI blindly.
Fixes#1524.
This will let higher-level projects override GLFW CMake options with
normal variables instead of having to use cache variables.
This means with CMake 3.13 and later you can now do:
set(GLFW_BUILD_TESTS ON)
add_subdirectory(path/to/glfw)
Instead of the more verbose:
set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
add_subdirectory(path/to/glfw)