Compare commits

...

158 Commits

Author SHA1 Message Date
Jan Schürkamp
da1061760b
Merge 940b7a8668 into b35641f4a3 2024-06-12 17:58:27 +00:00
GamesTrap
940b7a8668
Merge branch 'glfw:master' into taskbar-progress 2024-06-12 19:57:51 +02:00
Camilla Löwy
b35641f4a3 Wayland: Cleanup 2024-04-12 18:27:53 +02:00
Camilla Löwy
64906f8e64 Wayland: Cleanup 2024-04-12 18:25:06 +02:00
Camilla Löwy
51b6434ac4 Wayland: Fix possible segfault on drag enter
Found with Clang static analysis.
2024-04-11 19:12:17 +02:00
Camilla Löwy
dfebad786d Update macOS OpenGL compatibility notes 2024-04-07 20:56:18 +02:00
Camilla Löwy
97892c6037 Cocoa: Add QuartzCore as a link-time dependency 2024-04-07 20:55:30 +02:00
Camilla Löwy
8b574030a8 Cocoa: Remove support for OS X 10.10 Yosemite
Fixes #2506
2024-04-07 20:43:48 +02:00
Camilla Löwy
228e58262e EGL: Allow native access with defaults on Wayland
The intent of enforcing GLFW_EGL_CONTEXT_API for EGL native access
functions was to ensure that the application had requested the same
context creation API at window creation time that it then attempted
native access for.

With the 3.4 ABI this both isn't true anymore, as a single binary may
have multiple meanings of GLFW_NATIVE_CONTEXT_API, and is no longer
necessary, since glfwGetPlatform provides enough information to
disambiguate even without knowing what GLFW_PLATFORM was set to.

This all leaves the requirement that the context creation API be
GLFW_EGL_CONTEXT_API as just an unnecessary annoyance.

Fixes #2518
2024-03-29 13:18:31 +01:00
Camilla Löwy
3573c5a890 Wayland: Fix segfault when there is no seat
Bug encountered running on a headless instance of Weston.

Fixes #2517
2024-03-29 13:17:06 +01:00
Camilla Löwy
072f660d93 Allow C99 booleans 2024-03-28 16:53:04 +01:00
Camilla Löwy
68dcea0d7f Place assertions for handles after init check
This lets automated testing check that GLFW_NOT_INITIALIZED is emitted
for every public function.
2024-03-28 16:53:04 +01:00
Camilla Löwy
38ec7abd3b Fix missing assertions for native access functions 2024-03-28 16:53:04 +01:00
Camilla Löwy
738dd6ff1d Null: Add limited EGL context creation on Mesa
This provides very limited support for context creation via EGL on the
Null platform.  It supports Unix-like systems with a version of Mesa
that provides EGL_MESA_platform_surfaceless.

Even then, the actual framebuffer provided is not resized along with the
'window'.  That will hopefully change once context and framebuffer
creation are separated, but this commit should at least allow more
applications than before to run on the Null platform.
2024-03-28 16:53:04 +01:00
Camilla Löwy
860c8ef38f Null: Add Vulkan 'window' surface creation
This adds support for Vulkan 'window' surface creation on the Null
platform via the VK_EXT_headless_surface extension, where available.

Tested with MoltenVK.
2024-03-28 16:53:04 +01:00
Camilla Löwy
42dc1ffaee Wayland: Fix leak of surface scaling objects 2024-03-28 16:53:04 +01:00
Grzesiek11
bf945f1213 Unlimited mouse button input mode
This adds the GLFW_UNLIMITED_MOUSE_BUTTONS input mode which permits
mouse buttons over GLFW_MOUSE_BUTTON_LAST to be reported to the mouse
button callback.

Closes #2423
2024-03-12 16:24:01 +00:00
Camilla Löwy
dc557ecf38 Fix minimum CMake version in README 2024-02-29 15:44:01 +01:00
Camilla Löwy
d24ee9953f Start 3.5 2024-02-29 15:42:28 +01:00
Camilla Löwy
7b6aead9fb Documentation updates for 3.4 release 2024-02-23 12:45:31 +01:00
Camilla Löwy
e14e72a2e7 De-emphasize FAQ
Until it can be properly rewritten.
2024-02-22 22:35:05 +01:00
Camilla Löwy
523d1d61ca Remove outline of Doxygen 1.9.8 menu links 2024-02-22 22:35:05 +01:00
Camilla Löwy
4d9557aefe Update README for 3.3.10 release 2024-02-22 20:20:50 +01:00
Camilla Löwy
415df7e3ba Wayland: Explain what to do when the build fails
That would be a helpful thing to do.
2024-02-21 15:42:44 +01:00
Camilla Löwy
fb9c23fbf2 Build has been tested with CMake 3.28 2024-02-21 15:34:36 +01:00
Camilla Löwy
d45cbc82c9 Fix error return value for glfwGetVideoMode
The function returned a pointer to a zeroed video mode instead of NULL
on error because errors were not propagated up from the platform.

Fixes #1292
2024-02-21 01:01:20 +01:00
Camilla Löwy
d7e7b164bc Add credit
Related to #2359
2024-02-21 00:17:32 +01:00
Camilla Löwy
421dc66afb Remove reference to stale Coverity result 2024-02-20 23:38:16 +01:00
Camilla Löwy
b864e4baeb Improved build guide slightly 2024-02-20 21:28:42 +01:00
Camilla Löwy
f6f7ee2284 Add new symbol to list 2024-02-20 20:23:19 +01:00
Camilla Löwy
961e45bded Include declarations from native access header 2024-02-20 16:29:41 +01:00
Camilla Löwy
e28397bda0 Cocoa: Fix glfwGetCocoaWindow error return value 2024-02-20 16:29:41 +01:00
Camilla Löwy
8f2f766f0d NSGL: ANGLE exists 2024-02-20 16:27:51 +01:00
Camilla Löwy
f6360eadee NSGL: Fix missing check for OpenGL profile
macOS only provides the core profile for OpenGL 3.2 and later.
2024-02-20 15:55:24 +01:00
Doug Binks
1fb7f0e120 Cocoa: Added glfwGetCocoaView native access function
Resolves #2235

Co-authored-by: mightgoyardstill <mightgoyardstill@users.noreply.github.com>
2024-02-20 13:20:30 +00:00
Camilla Löwy
0bb605cd79 Wayland related documentation work 2024-02-19 15:08:51 +01:00
Camilla Löwy
559bd3adb9 Add credit
Related to #2035
2024-02-19 14:44:02 +01:00
Florian Hülsmann
65102e2005 Prefer Wayland over X11
When GLFW_ANY_PLATFORM is used (which is the default), X11 would be
selected on a Wayland system with XWayland and where XDG_SESSION_TYPE
was not set.

Closes #2035
2024-02-19 14:39:50 +01:00
Camilla Löwy
dbf7cfc4dc Update credit
Related to #2204
2024-02-19 14:21:55 +01:00
Camilla Löwy
42afd127a9 Documentation work 2024-02-19 14:21:55 +01:00
Camilla Löwy
7bdcdf435a Cleanup 2024-02-19 14:21:48 +01:00
Camilla Löwy
c8372cda08 Documentation work 2024-02-19 14:20:52 +01:00
Camilla Löwy
1ce41b358b Null: Remove unused struct member 2024-02-19 14:20:52 +01:00
Camilla Löwy
af5d250553 Wayland: Remove separate window title copy 2024-02-19 14:20:52 +01:00
Doug Binks
95d464bb4b Add glfwGetWindowTitle
This adds a function for querying the current title of a window.  This
currently returns a copy of the last title set via GLFW.

Fixes #1448
Closes #1909
Closes #2482
2024-02-19 14:20:52 +01:00
Camilla Löwy
bafece4cf7 Update Wayland remarks for glfwCreateWindow
The backend has improved somewhat and support among compositors for some
protocols have improved to the point that they can be relied upon.
2024-02-19 14:19:36 +01:00
Camilla Löwy
64b4f0f30c Null: Fix missing damage event 2024-02-16 12:36:15 +01:00
Camilla Löwy
a53ce7e8b8 Null: Fix window/framebuffer size event order 2024-02-16 12:36:15 +01:00
Camilla Löwy
f0ec791386 X11: Cleanup
The actual reported bug was fixed at some point during the refactoring
of the Wayland backend.  This is only a bit of tidying.  Updating the
cache before emitting events is always a nice thing to do.

Closes #2046
2024-02-16 12:34:03 +01:00
Camilla Löwy
14e653358b Add support for XDG_SESSION_TYPE env variable
Related to #2439
2024-02-16 00:18:44 +01:00
Camilla Löwy
690a15f929 Wayland: Implement GLFW_RESIZABLE for XDG toplevel
This implements GLFW_RESIZABLE for all paths where we manage our own
xdg_toplevel, namely XDG decorations and fallback decorations.

Fixes #2203
2024-02-16 00:13:33 +01:00
Camilla Löwy
b61f3fc479 Wayland: Fix invalid size protocol error
This could happen when resizing a window with fallback decorations.

Fixes #2204
2024-02-16 00:13:32 +01:00
Camilla Löwy
a650c69cff Wayland: Decide final window size in one place 2024-02-16 00:12:50 +01:00
Camilla Löwy
2b3f919b60 Wayland: Add support for fractional scaling
This adds basic support for fractional-scale-v1.

Note that this introduces a potential discrepancy between window and
monitor content scales.
2024-02-14 22:35:46 +01:00
Camilla Löwy
a9cc7c7260 Add GLFW_SCALE_FRAMEBUFFER window hint
This adds the GLFW_SCALE_FRAMEBUFFER window hint, enabling control of
framebuffer scaling across Wayland and macOS.  On macOS, this window
hint is a new name for GLFW_COCOA_RETINA_FRAMEBUFFER, and both hint
names will modify the same hint.

This is now a more symmetric counterpart to GLFW_SCALE_TO_MONITOR and,
weirdly, they each apply neatly to half of the supported platforms.

This commit is mostly documentation updates to better integrate and
contrast these two scaling mechanisms.
2024-02-14 22:35:46 +01:00
Camilla Löwy
63397fb0d5 Convert some external links to reference links 2024-02-14 22:35:46 +01:00
Camilla Löwy
532bd66e7f Convert Doxygen tables of contents to Markdown 2024-02-14 22:35:46 +01:00
Camilla Löwy
244852a93a Convert Doxygen paragraphs to Markdown 2024-02-14 22:35:46 +01:00
Camilla Löwy
973a3c0b31 Fix Markdown syntax for link 2024-02-14 22:35:46 +01:00
Camilla Löwy
1a0bae7fa8 Convert Doxygen code sections to Markdown 2024-02-14 22:35:45 +01:00
Camilla Löwy
611099f745 Convert Doxygen headings to Markdown 2024-02-14 22:35:45 +01:00
Camilla Löwy
3e73a5c76c Rename Doxygen files to Markdown 2024-02-14 22:35:45 +01:00
Camilla Löwy
e3e41ba339 Move to Doxygen 1.9.8 and later 2024-02-14 22:35:32 +01:00
Camilla Löwy
fb10e95f78 Add language tags for C code sections 2024-02-13 21:28:24 +01:00
Camilla Löwy
d93868bcf3 Win32: Fix handling of local absolute raw motion
The implementation for how to handle absolute raw motion remotely is
just how to handle absolute raw motion, period.
2024-02-13 19:12:05 +01:00
Camilla Löwy
275b92f887 Win32: Clean up RDP hidden cursor workaround 2024-02-13 18:13:01 +01:00
Camilla Löwy
6c1e3fd84c Win32: Use existing cursor creation path 2024-02-13 17:36:35 +01:00
Camilla Löwy
efffd492dd Wayland: Check all xkbcommon entry points 2024-02-13 17:36:35 +01:00
Camilla Löwy
77ced84e9c Use C99 instead of hard-coded indices 2024-02-13 17:36:35 +01:00
Camilla Löwy
8946f5314d Win32: Add GLFW_WIN32_SHOWDEFAULT
Fixes #2359
2024-02-13 17:36:35 +01:00
Camilla Löwy
2afd57bf9b Expand documentation for custom allocator
Fixes #2298
2024-02-13 17:35:59 +01:00
Camilla Löwy
a12311e596 Document GLFW_FLOATING not supported on Wayland 2024-02-12 22:50:25 +01:00
Camilla Löwy
bb951b4b71 Use C99 fminf and fmaxf 2024-02-12 22:50:25 +01:00
Camilla Löwy
5a0ab56ed7 Fix spelling 2024-02-12 22:50:25 +01:00
Camilla Löwy
30127690a2 Add credit
Related to #2445
2024-02-12 15:59:11 +01:00
Camilla Löwy
6f1ddf51a1 Wayland: Remove unused struct member 2024-02-12 13:06:59 +01:00
Camilla Löwy
6565c0cc04 Update changelog and add credit
Related to #2446
2024-02-12 13:06:59 +01:00
Victor Chernyakin
edd38207a6 Linux: Set O_CLOEXEC on evdev fd
Closes #2446
2024-02-12 13:06:59 +01:00
Camilla Löwy
9953f7ead1 Wayland: Cache framebuffer size
The calculation of framebuffer size is about to get more complicated
with the introduction of fractional-scale-v1, so only do it in one
place.

This is also a tiny preparation for eventually behaving better towards
wl_egl_window_resize.
2024-02-12 13:06:59 +01:00
Camilla Löwy
1be7bc546b Wayland: Clean up data types related to scales 2024-02-12 13:06:59 +01:00
Camilla Löwy
4c283e4a3c Wayland: Be more specific about scales
We are about to introduce another scaling method (fractional-scale-v1),
so it will become more important to be specific about what scales are
used where and what their units are.

This removes 'content scale' from window and monitor structs.  A monitor
(output) now has just a 'scale', which becomes a 'buffer scale' when
applied to a window.  A window now has a list of 'output scales' to
select its buffer scale from.  Content scales are calculated from the
respective monitor or window when queried, even if the calculation right
now is to just return the same value as before.
2024-02-12 13:06:59 +01:00
Camilla Löwy
e25c1cc74f Wayland: Make fallback concepts more distinct 2024-02-12 13:06:59 +01:00
Camilla Löwy
72164e6921 Wayland: Remove fallback decoration edge enum 2024-02-12 13:06:32 +01:00
Camilla Löwy
a268b4b3a4 Wayland: Cleanup 2024-02-11 12:32:46 +01:00
Camilla Löwy
4baeadbd66 Wayland: Put fallback decorations behind a boolean 2024-02-11 12:32:27 +01:00
Camilla Löwy
6ac0835ad2 Wayland: Cleanup 2024-02-09 14:33:13 +01:00
Camilla Löwy
ea6dd72c71 Wayland: Fix GLFW_HOVERED for fallback decorations
When using the fallback decorations, GLFW_HOVERED was true also when the
cursor was over one of the window decorations.

This also disentangles the GLFW_HOVERED state from the fallback
decorations.  Because GLFW_HOVERED should have had the same behavior as
GLFW_MAIN_WINDOW, the latter has been removed.
2024-02-09 14:33:01 +01:00
Camilla Löwy
5e97447dd5 Wayland: Clarify fallback decoration struct name
We now have three window decoration paths in the Wayland backend:
libdecor decorations, XDG decorations and fallback decorations.

This makes it clearer when code relates to the fallback decoration path,
which should increasingly (hopefully) not get used.
2024-02-09 14:22:23 +01:00
Camilla Löwy
d3a7362430 Wayland: Separate window and framebuffer resizing 2024-02-09 14:01:57 +01:00
Camilla Löwy
1fe98a0d53 Fix missing list entry dash in README 2024-02-09 14:00:02 +01:00
Camilla Löwy
a360198f8f Wayland: Implement glfwFocusWindow
This implements window focus requests via the xdg-activation-v1
protocol.  These requests will likely only work when another window of
the same application already has input focus, but that isn't unlike the
behavior of other platforms.

The GLFW_FEATURE_UNAVAILABLE error has been removed from this function
for now.

Related to #2284
Related to #2306
Related to #2439
2024-02-09 13:52:54 +01:00
Camilla Löwy
eeb403135d Add minor features and updates to window test
- Button label reflects window mode
- Window attention request button
- Slightly less bad button layout possibly
- Applicable button labels list expected delay
- Less telegraphic message for positions being unsupported
- Window size more likely to fit contents
2024-02-09 13:45:48 +01:00
Camilla Löwy
00e86d4b73 WGL: Fix pixel format count in a Parallels VM
In a Parallels VM wglGetPixelFormatAttribivARB returns fewer pixel
formats than DescribePixelFormat.  This broke context creation on
Windows in Parallels since the changes in
2c0f34b60f.  The previous version of the
code worked accidentally.

This adds a workaround by iterating through the minimum of both counts.
It should have no effect when running on conforming implementations.

Tested on Parallels by @ dougbinks.

Closes #2191
Fixes #2406
Fixes #2467
2024-01-30 20:22:10 +01:00
Camilla Löwy
86d7bcb124 Fix missing checks for platform mismatch
The native access functions for monitor objects did not check whether
the correct platform was initialized and would return invalid handles if
it was not.
2024-01-30 20:20:42 +01:00
Camilla Löwy
d7aeb1eae8 Fix function return value when uninitialized 2024-01-30 20:20:42 +01:00
Camilla Löwy
f74ff2aa10 Fix function return value when uninitialized 2024-01-30 20:20:42 +01:00
Camilla Löwy
c47894a9a3 Update compilation-related parts of README 2024-01-30 20:20:42 +01:00
Camilla Löwy
42afff41fe Remove reminders to use C99 from more source files 2024-01-30 20:20:42 +01:00
Camilla Löwy
23962c9dc7 Remove further traces of IRC channel 2024-01-30 20:20:42 +01:00
Camilla Löwy
ad264f5061 Update URL for xdg-activation-v1 protocol docs 2024-01-30 20:20:42 +01:00
Camilla Löwy
94310c5281 Wayland: Move listener to correct section 2024-01-30 20:20:42 +01:00
Camilla Löwy
bdedec9932 Wayland: Fix formatting of attention request 2024-01-30 20:20:42 +01:00
Jan Schürkamp
9317970243 Wayland: Implement glfwRequestWindowAttention
This implements window attention requests via the xdg-activation-v1
protocol.

This was updated by @ elmindreda to work with recent Wayland related
 changes to the main branch:
 - Switched to current way of handling Wayland protocol files
 - Added the xdg-activation-v1.xml protocol file to deps/wayland
 - Added missing macros to rename protocol interface globals

The protocol file was copied from wayland-protocols 1.33.

Closes #2287
2024-01-30 20:20:42 +01:00
Camilla Löwy
2590d4cdd4 Wayland: Enable platform by default
This changes the default platform for Unix-like systems (other than
macOS) from only X11 to Wayland and X11.  It also removes the backward
compatibility with the older GLFW_USE_WAYLAND CMake option.

If a bisect took you here because your build broke, hello, sorry, set
the GLFW_BUILD_WAYLAND or GLFW_BUILD_X11 CMake option to disable the
associated platform.

This can be done when configuring GLFW with CMake, from a higher-level
CMakeLists.txt if GLFW is part of your project, or at any point after
configuration by updating the CMake cache with the command-line tool or
the GUI.

The next step is to make Wayland the run-time default when enabled, but
that will hopefully not break any builds.

Related to #2439
2024-01-30 20:20:42 +01:00
Camilla Löwy
51920ede68 Wayland: Fix compilation on FreeBSD
The list of compile-time dependencies on FreeBSD lacked evdev-proto.

Unlike on Linux, the input-event-codes.h header file was not implicitly
included on FreeBSD.

Fixes #2445
2024-01-30 20:20:42 +01:00
Camilla Löwy
291f4d89cd OSMesa: Fix headers included before shared header
The shared header, internal.h, must be the first header included in
every compilation unit of GLFW.
2024-01-30 20:20:41 +01:00
Camilla Löwy
bc95384f4c Remove platform-specific logic from shared header
The public header already defines APIENTRY, which is functionally
identical to EGLAPIENTRY.
2024-01-30 20:20:41 +01:00
Bruce Mitchener
becf1dc14b Update to actions/checkout@v4 from v3
This mainly updates the version of NodeJS used internally to keep
up with what's going on at GitHub Actions.

Closes #2447
2024-01-30 20:20:41 +01:00
Camilla Löwy
86bf5698ec Fix glfwGetKeyName incorrectly emitting error
glfwGetKeyName emitted GLFW_INVALID_VALUE when passed GLFW_KEY_UNKNOWN
and any scancode not associated with a key token on that platform.

This causes physical keys with no associated key token to emit
GLFW_INVALID_VALUE when the key and scancode are passed directly from
the key event to glfwGetKeyName.  This breaks the promise made in the
reference documentation for glfwGetKeyName.

This commit removes that error for the whole range of valid scancodes.

Fixes #1785
2024-01-30 20:14:57 +01:00
Camilla Löwy
7e2470d343 Use designated initializers for platform structs
This should make platform struct initializers slightly more resistant to
merge mistakes.
2024-01-29 21:09:10 +01:00
Camilla Löwy
bbf661ca38 Replace comments with designated initializers
We can finally have the compiler verify that the values go to the
correct struct member.

With this commit GLFW no longer compiles with Visual Studio 2012 or
earlier.  If you must compile GLFW on Windows XP, check out MinGW-w64.

Fixes #2465
2024-01-29 21:09:10 +01:00
Camilla Löwy
d81fcb93f1 Clarify event test reporting of keys
Reshuffled line to group key-related items together.  Omitted key code
output for unknown keys to put focus on the (lack of) name.
2024-01-29 21:09:10 +01:00
Camilla Löwy
c339dfc63d Update changelog for 3.4 release
This adds some missing entries and splits them all into what has already
been released and what hasn't.
2024-01-29 21:09:10 +01:00
Camilla Löwy
9afbcb442b Wayland: Clean up pointer axis handler 2024-01-29 21:05:35 +01:00
Jan Schürkamp
f6722ab492
Merge branch 'glfw:master' into taskbar-progress 2023-12-20 00:19:32 +01:00
Jan Schürkamp
439546caae
Merge branch 'glfw:master' into taskbar-progress 2023-12-08 20:54:19 +01:00
Jan Schürkamp
125b1a2506
Merge branch 'master' into taskbar-progress 2023-11-22 09:38:27 +01:00
Jan Schürkamp
a8e3e5dbe6
Merge branch 'glfw:master' into taskbar-progress 2023-11-18 11:54:13 +01:00
Jan Schürkamp
e597552e75
Merge branch 'glfw:master' into taskbar-progress 2023-08-11 19:58:59 +02:00
GamesTrap
8f1ddbb908
Fixed DBus crash because of illegal characters in executable name 2023-04-12 00:54:47 +02:00
GamesTrap
5842644e2e
Improved DBus repetition 2023-04-12 00:10:39 +02:00
GamesTrap
59514c4bb5
DBus made bus and signal paths unique 2023-04-12 00:02:35 +02:00
GamesTrap
1824da004f
Added caching of desktop file path 2023-04-10 14:16:08 +02:00
GamesTrap
dacb814e8b
Merge upstream/master into origin/taskbar-progress 2023-04-05 19:57:47 +02:00
GamesTrap
589e6b78d9
Added DBus pointer checks 2023-03-08 14:47:40 +01:00
Andreas
ef4d722b76
Merge(#3): Finalized progress API 2023-03-08 14:10:00 +01:00
GamesTrap
9f17a69a67
glfwSetWindowTaskbarProgress Polishing 2023-03-03 16:18:16 +01:00
Jan Schürkamp
d173bf1fed
Merge(#1): Add Cocoa Dock icon progress bar implemenetation 2023-03-03 16:07:15 +01:00
Andreas
14333117c4
Update window.dox
Fix typo in window.dox
2023-03-03 16:04:18 +01:00
Andreas
df8349b747
Delete remaining unintentionally added build files 2023-03-03 15:49:26 +01:00
ws909
8618927ef9 Delete unintentionally added build files 2023-03-03 15:48:33 +01:00
ws909
5301a924c4 Enclose [indicator setControlSize] in availability check 2023-03-03 15:20:11 +01:00
ws909
2244051453 Per-window progress indicator states and values for the MacOS Dock icon 2023-03-02 18:43:27 +01:00
ws909
a9b36d48d7 Simplify _glfwSetWindowTaskbarProgressCocoa
Fix merge issues
Rename taskbarState to progressState
Remove const qualifier from progressState parameter
2023-03-02 15:51:10 +01:00
ws909
0173252ee1 Merge remote-tracking branch 'refs/remotes/GamesTrap/taskbar-progress'
Conflicts:
	src/cocoa_window.m
	tests/window.c
2023-03-02 14:08:25 +01:00
GamesTrap
0f142e3a1a
glfwSetWindowTaskbarProgress Changed value type from int to double 2023-03-02 13:55:42 +01:00
ws909
78e4f9bd67 Make progress bar slider in window test program responsive 2023-03-02 05:20:32 +01:00
ws909
34ee36c088 Initial shared overridable Dock progress bar for all windows in Cocoa 2023-03-02 05:20:05 +01:00
GamesTrap
e387ef3fdf
Added changelog entry to readme 2023-03-01 22:28:48 +01:00
GamesTrap
a480de9b1d
glfwSetWindowTaskbarProgress Renamed parameter completed to value 2023-03-01 22:27:52 +01:00
GamesTrap
3e7b016a00
Renamed GLFW_TASKBAR_PROGRESS_NOPROGRESS to GLFW_TASKBAR_PROGRESS_DISABLED 2023-03-01 22:22:01 +01:00
GamesTrap
1071cf1950
win32_platform.h Removed ShObjIdl_core.h include dependency 2023-03-01 17:25:58 +01:00
GamesTrap
4a66bf3b60
Added documentation to window.dox 2023-02-05 04:19:15 +01:00
GamesTrap
74dac5cfb4
Win32: glfwSetWindowTaskbarProgress now emits GLFW_FEATURE_UNAVAILABLE on Windows Vista and older 2023-02-05 03:03:54 +01:00
GamesTrap
f590075121
Removed taskbar-progress from branch local GH Actions workflow 2023-02-05 02:53:47 +01:00
GamesTrap
19f9247a68
Added documentation 2023-02-05 02:50:53 +01:00
GamesTrap
c8fd71c7e7
Added credit 2023-02-03 23:38:45 +01:00
GamesTrap
fb6826c934
Fixed Cocoa linker error 2023-02-03 23:35:29 +01:00
GamesTrap
efac372213
Fixed Wayland linker error 2023-02-03 23:31:02 +01:00
GamesTrap
8b1b11c3c4
Fixed GitHub Action errors 2023-02-03 23:27:45 +01:00
GamesTrap
48818fc7a9
Unified X11/Wayland code path using _glfwUpdateTaskbarProgressDBusPOSIX() 2023-02-03 23:23:25 +01:00
GamesTrap
7d5bb13b88
Enabled GitHub Action for the taskbar-progress branch 2023-02-03 22:48:47 +01:00
Jan Schürkamp
48e08616d9
Merge branch 'glfw:master' into taskbar-progress 2023-02-01 00:28:58 +01:00
GamesTrap
11ddcdde9f
Merge remote-tracking branch 'upstream/master' into taskbar-progress 2022-10-14 18:05:48 +02:00
Jan Schürkamp
ec524797cc
Merge branch 'glfw:master' into taskbar-progress 2022-09-02 03:15:13 +02:00
GamesTrap
827cf79f63
Linux Added support for taskbar progress (KDE & Unity) 2022-09-02 02:49:53 +02:00
Jan Schürkamp
fb4c22ed9c
Merge branch 'glfw:master' into taskbar-progress 2022-08-06 16:38:09 +02:00
GamesTrap
8acb72b9a1
Win32 Added support for taskbar progress 2022-07-23 21:28:35 +02:00
97 changed files with 4849 additions and 3131 deletions

View File

@ -28,7 +28,7 @@ indent_size = 4
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
[*.{dox,md}] [*.{md}]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
trim_trailing_whitespace = false trim_trailing_whitespace = false

View File

@ -17,7 +17,7 @@ jobs:
CC: clang CC: clang
CFLAGS: -Werror CFLAGS: -Werror
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt update sudo apt update
@ -54,10 +54,10 @@ jobs:
timeout-minutes: 4 timeout-minutes: 4
env: env:
CFLAGS: -Werror CFLAGS: -Werror
MACOSX_DEPLOYMENT_TARGET: 10.8 MACOSX_DEPLOYMENT_TARGET: 10.11
CMAKE_OSX_ARCHITECTURES: x86_64;arm64 CMAKE_OSX_ARCHITECTURES: x86_64;arm64
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Configure Null shared library - name: Configure Null shared library
run: cmake -B build-null-shared -D GLFW_BUILD_COCOA=OFF -D BUILD_SHARED_LIBS=ON run: cmake -B build-null-shared -D GLFW_BUILD_COCOA=OFF -D BUILD_SHARED_LIBS=ON
@ -81,7 +81,7 @@ jobs:
env: env:
CFLAGS: /WX CFLAGS: /WX
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Configure Win32 shared x86 library - name: Configure Win32 shared x86 library
run: cmake -B build-win32-shared-x86 -G "Visual Studio 17 2022" -A Win32 -D BUILD_SHARED_LIBS=ON run: cmake -B build-win32-shared-x86 -G "Visual Studio 17 2022" -A Win32 -D BUILD_SHARED_LIBS=ON

4
.gitignore vendored
View File

@ -57,11 +57,11 @@ src/glfw3ConfigVersion.cmake
# Compiled binaries # Compiled binaries
src/libglfw.so src/libglfw.so
src/libglfw.so.3 src/libglfw.so.3
src/libglfw.so.3.4 src/libglfw.so.3.5
src/libglfw.dylib src/libglfw.dylib
src/libglfw.dylib src/libglfw.dylib
src/libglfw.3.dylib src/libglfw.3.dylib
src/libglfw.3.4.dylib src/libglfw.3.5.dylib
src/libglfw3.a src/libglfw3.a
src/glfw3.lib src/glfw3.lib
src/glfw3.dll src/glfw3.dll

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR) cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR)
project(GLFW VERSION 3.4.0 LANGUAGES C) project(GLFW VERSION 3.5.0 LANGUAGES C)
if (POLICY CMP0069) if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW) cmake_policy(SET CMP0069 NEW)
@ -27,11 +27,15 @@ if (GLFW_USE_OSMESA)
message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint") message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint")
endif() endif()
if (DEFINED GLFW_USE_WAYLAND AND UNIX AND NOT APPLE)
message(FATAL_ERROR
"GLFW_USE_WAYLAND has been removed; delete the CMake cache and set GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 instead")
endif()
cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF) cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF)
cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF) cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF)
cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF) cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF)
cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" ON "UNIX;NOT APPLE" OFF)
"${GLFW_USE_WAYLAND}" "UNIX;NOT APPLE" OFF)
cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
"WIN32" OFF) "WIN32" OFF)
@ -55,11 +59,6 @@ list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if (GLFW_BUILD_DOCS)
set(DOXYGEN_SKIP_DOT TRUE)
find_package(Doxygen)
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Report backend selection # Report backend selection
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@ -130,7 +129,7 @@ if (GLFW_BUILD_TESTS)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS) if (GLFW_BUILD_DOCS)
add_subdirectory(docs) add_subdirectory(docs)
endif() endif()
@ -152,11 +151,6 @@ if (GLFW_INSTALL)
install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
DESTINATION "${CMAKE_INSTALL_DOCDIR}")
endif()
# Only generate this target if no higher-level project already has # Only generate this target if no higher-level project already has
if (NOT TARGET uninstall) if (NOT TARGET uninstall)
configure_file(CMake/cmake_uninstall.cmake.in configure_file(CMake/cmake_uninstall.cmake.in

View File

@ -15,6 +15,7 @@ video tutorials.
- Keith Bauer - Keith Bauer
- John Bartholomew - John Bartholomew
- Coşku Baş - Coşku Baş
- Bayemite
- Niklas Behrens - Niklas Behrens
- Andrew Belt - Andrew Belt
- Nevyn Bengtsson - Nevyn Bengtsson
@ -32,7 +33,9 @@ video tutorials.
- Nicolas Caramelli - Nicolas Caramelli
- David Carlier - David Carlier
- Arturo Castro - Arturo Castro
- Jose Luis Cercós Pita
- Chi-kwan Chan - Chi-kwan Chan
- Victor Chernyakin
- TheChocolateOre - TheChocolateOre
- Ali Chraghi - Ali Chraghi
- Joseph Chua - Joseph Chua
@ -46,7 +49,9 @@ video tutorials.
- Andrew Corrigan - Andrew Corrigan
- Bailey Cosier - Bailey Cosier
- Noel Cower - Noel Cower
- James Cowgill
- CuriouserThing - CuriouserThing
- Bill Currie
- Jason Daly - Jason Daly
- danhambleton - danhambleton
- Jarrod Davis - Jarrod Davis
@ -98,11 +103,13 @@ video tutorials.
- Warren Hu - Warren Hu
- Charles Huber - Charles Huber
- Brent Huisman - Brent Huisman
- Florian Hülsmann
- illustris - illustris
- InKryption - InKryption
- IntellectualKitty - IntellectualKitty
- Aaron Jacobs - Aaron Jacobs
- JannikGM - JannikGM
- Andreas O. Jansen
- Erik S. V. Jansson - Erik S. V. Jansson
- jjYBdx4IL - jjYBdx4IL
- Peter Johnson - Peter Johnson
@ -150,6 +157,7 @@ video tutorials.
- Jonathan Mercier - Jonathan Mercier
- Marcel Metz - Marcel Metz
- Liam Middlebrook - Liam Middlebrook
- mightgoyardstill
- Ave Milia - Ave Milia
- Icyllis Milica - Icyllis Milica
- Jonathan Miller - Jonathan Miller
@ -166,11 +174,15 @@ video tutorials.
- Pascal Muetschard - Pascal Muetschard
- James Murphy - James Murphy
- Julian Møller - Julian Møller
- Julius Häger
- Nat!
- NateIsStalling
- ndogxj - ndogxj
- F. Nedelec - F. Nedelec
- n3rdopolis - n3rdopolis
- Kristian Nielsen - Kristian Nielsen
- Joel Niemelä - Joel Niemelä
- Victor Nova
- Kamil Nowakowski - Kamil Nowakowski
- onox - onox
- Denis Ovod - Denis Ovod
@ -216,7 +228,9 @@ video tutorials.
- Yoshinori Sano - Yoshinori Sano
- Brandon Schaefer - Brandon Schaefer
- Sebastian Schuberth - Sebastian Schuberth
- Jan Schuerkamp
- Scr3amer - Scr3amer
- Jan Schuerkamp
- Christian Sdunek - Christian Sdunek
- Matt Sealey - Matt Sealey
- Steve Sexton - Steve Sexton
@ -246,6 +260,7 @@ video tutorials.
- Paul Sultana - Paul Sultana
- Nathan Sweet - Nathan Sweet
- TTK-Bandit - TTK-Bandit
- Nuno Teixeira
- Jared Tiala - Jared Tiala
- Sergey Tikhomirov - Sergey Tikhomirov
- Arthur Tombs - Arthur Tombs

344
README.md
View File

@ -2,7 +2,6 @@
[![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions) [![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions)
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw) [![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
## Introduction ## Introduction
@ -11,15 +10,15 @@ application development. It provides a simple, platform-independent API for
creating windows, contexts and surfaces, reading input, handling events, etc. creating windows, contexts and surfaces, reading input, handling events, etc.
GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On
Linux both X11 and Wayland are supported. Linux both Wayland and X11 are supported.
GLFW is licensed under the [zlib/libpng GLFW is licensed under the [zlib/libpng
license](https://www.glfw.org/license.html). license](https://www.glfw.org/license.html).
You can [download](https://www.glfw.org/download.html) the latest stable release You can [download](https://www.glfw.org/download.html) the latest stable release
as source or Windows binaries, or fetch the `latest` branch from GitHub. Each as source or Windows binaries. Each release starting with 3.0 also has
release starting with 3.0 also has a corresponding [annotated a corresponding [annotated tag](https://github.com/glfw/glfw/releases) with
tag](https://github.com/glfw/glfw/releases) with source and binary archives. source and binary archives.
The [documentation](https://www.glfw.org/docs/latest/) is available online and is The [documentation](https://www.glfw.org/docs/latest/) is available online and is
included in all source and binary archives. See the [release included in all source and binary archives. See the [release
@ -47,18 +46,19 @@ features or fixing bugs.
## Compiling GLFW ## Compiling GLFW
GLFW itself requires only the headers and libraries for your OS and window GLFW is written primarily in C99, with parts of macOS support being written in
system. It does not need the headers for any context creation API (WGL, GLX, Objective-C. GLFW itself requires only the headers and libraries for your OS
EGL, NSGL, OSMesa) or rendering API (OpenGL, OpenGL ES, Vulkan) to enable and window system. It does not need any additional headers for context creation
support for them. APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan)
to enable support for them.
GLFW supports compilation on Windows with Visual C++ 2010 and later, MinGW and GLFW supports compilation on Windows with Visual C++ 2013 and later, MinGW and
MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
and Clang. It will likely compile in other environments as well, but this is and Clang. It will likely compile in other environments as well, but this is
not regularly tested. not regularly tested.
There are [pre-compiled Windows binaries](https://www.glfw.org/download.html) There are [pre-compiled binaries](https://www.glfw.org/download.html) available
available for all supported compilers. for all supported compilers on Windows and macOS.
See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for
more information about how to compile GLFW yourself. more information about how to compile GLFW yourself.
@ -79,9 +79,7 @@ more information.
## System requirements ## System requirements
GLFW is written in C99 and does not support Visual Studio 2012 or earlier. GLFW supports Windows XP and later and macOS 10.11 and later. Linux and other
GLFW supports Windows XP and later and macOS 10.8 and later. Linux and other
Unix-like systems running the X Window System are supported even without Unix-like systems running the X Window System are supported even without
a desktop environment or modern extensions, although some features require a desktop environment or modern extensions, although some features require
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3. a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
@ -92,7 +90,7 @@ in the documentation for more information.
## Dependencies ## Dependencies
GLFW itself needs only CMake 3.1 or later and the headers and libraries for your GLFW itself needs only CMake 3.4 or later and the headers and libraries for your
OS and window system. OS and window system.
The examples and test programs depend on a number of tiny libraries. These are The examples and test programs depend on a number of tiny libraries. These are
@ -121,303 +119,20 @@ guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
information on what to include when reporting a bug. information on what to include when reporting a bug.
## Changelog ## Changelog since 3.4
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) - Added `glfwSetWindowProgressIndicator` for displaying progress on the dock or taskbar (#2286,#1183)
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to the limit of the mouse button tokens to be reported (#2423)
specify the desired platform (#1958) - [Cocoa] Added `QuartzCore` framework as link-time dependency
- Added `glfwGetPlatform` function to query what platform was selected (#1655,#1958) - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
- Added `glfwPlatformSupported` function to query if a platform is supported - [Wayland] Bugfix: The fractional scaling related objects were not destroyed
(#1655,#1958) - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517)
- Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947) - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault
- Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
`GLFWdeallocatefun` types (#544,#1628,#1947) - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
- Added `glfwInitVulkanLoader` for using a non-default Vulkan loader (#1374,#1890) - [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
- Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`, `GLFW_NATIVE_CONTEXT_API` (#2518)
`GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
- Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
- Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427)
- Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
- Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
through the window (#1236,#1568)
- Added `GLFW_CURSOR_CAPTURED` cursor mode to confine the cursor to the window
content area (#58)
- Added `GLFW_POSITION_X` and `GLFW_POSITION_Y` window hints for initial position
(#1603,#1747)
- Added `GLFW_ANY_POSITION` hint value for letting the window manager choose (#1603,#1747)
- Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958)
- Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
- Added `GLFW_WAYLAND_APP_ID` window hint string for Wayland app\_id selection
(#2121,#2122)
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
values to select ANGLE backend (#1380)
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
surface extension (#1793)
- Added `GLFW_NATIVE_INCLUDE_NONE` for disabling inclusion of native headers (#1348)
- Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958)
- Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa support (#1958)
- Added `GLFW_BUILD_X11` CMake option for enabling X11 support (#1958)
- Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type
(#279,#1307,#1497,#1574,#1928)
- Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake
variables exposing pkg-config dependencies (#1307)
- Made joystick subsystem initialize at first use (#1284,#1646)
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1
- Updated gamepad mappings from upstream
- Disabled tests and examples by default when built as a CMake subdirectory
- Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958)
- Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958)
- Removed CMake generated configuration header
- Bugfix: The CMake config-file package used an absolute path and was not
relocatable (#1470)
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
- Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
- Bugfix: Some extension loader headers did not prevent default OpenGL header
inclusion (#1695)
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
incompatible controllers sharing hardware ID (#1763)
- Bugfix: Native access functions for context handles did not check that the API matched
- Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization
- Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization
- Bugfix: `glfwGetJoystickUserPointer` returned `NULL` during disconnection (#2092)
- Bugfix: `glfwGetKeyScancode` returned `0` on error when initialized instead of `-1`
- Bugfix: Failure to make a newly created context current could cause segfault (#2327)
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
to the window menu
- [Win32] Added a version info resource to the GLFW DLL
- [Win32] Made hidden helper window use its own window class
- [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are
opaque (#1512)
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
symbol redefinition (#1524)
- [Win32] Bugfix: The cursor position event was emitted before its cursor enter
event (#1490)
- [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the
window (#1499)
- [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions
- [Win32] Bugfix: Super key was not released after Win+V hotkey (#1622)
- [Win32] Bugfix: `glfwGetKeyName` could access out of bounds and return an
invalid pointer
- [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN`
(#1623)
- [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
- [Win32] Bugfix: Monitor functions could return invalid values after
configuration change (#1761)
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
- [Win32] Bugfix: Duplicate size events were not filtered (#1610)
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
(#1582)
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
Windows 10 version 1703 (#1511)
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
later (#1783,#1796)
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
- [Win32] Bugfix: Content scale queries could fail silently (#1615)
- [Win32] Bugfix: Content scales could have garbage values if monitor was recently
disconnected (#1615)
- [Win32] Bugfix: A window created maximized and undecorated would cover the whole
monitor (#1806)
- [Win32] Bugfix: The default restored window position was lost when creating a maximized
window
- [Win32] Bugfix: `glfwMaximizeWindow` would make a hidden window visible
- [Win32] Bugfix: `Alt+PrtSc` would emit `GLFW_KEY_UNKNOWN` and a different
scancode than `PrtSc` (#1993)
- [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not
match event scancode (#1993)
- [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395)
- [Win32] Bugfix: The OSMesa library was not unloaded on termination
- [Win32] Bugfix: Right shift emitted `GLFW_KEY_UNKNOWN` when using a CJK IME (#2050)
- [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408)
- [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420)
- [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291)
- [Win32] Bugfix: Rapid clipboard calls could fail due to Clipboard History
- [Win32] Bugfix: Disabled cursor mode doesn't work right when connected over RDP (#1276,#1279,#2431)
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
- [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency
(#1786)
- [Cocoa] Disabled macOS fullscreen when `GLFW_RESIZABLE` is false
- [Cocoa] Removed dependency on the CoreVideo framework
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
(#1412)
- [Cocoa] Bugfix: Event processing before window creation would assert (#1543)
- [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
- [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
would abort (#1649)
- [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
(#1635)
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
could leak memory
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
- [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830)
- [Cocoa] Bugfix: Menu bar was not clickable on macOS 10.15+ until it lost and
regained focus (#1648,#1802)
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
related events were emitted
- [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for
a fraction of a second (#1962)
- [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980)
- [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003)
- [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791)
- [Cocoa] Bugfix: The EGL and OSMesa libraries were not unloaded on termination
- [Cocoa] Bugfix: `GLFW_MAXIMIZED` was always true when `GLFW_RESIZABLE` was false
- [Cocoa] Bugfix: Changing `GLFW_DECORATED` in macOS fullscreen would abort
application (#1886)
- [Cocoa] Bugfix: Setting a monitor from macOS fullscreen would abort
application (#2110)
- [Cocoa] Bugfix: The Vulkan loader was not loaded from the `Frameworks` bundle
subdirectory (#2113,#2120)
- [Cocoa] Bugfix: Compilation failed on OS X 10.8 due to unconditional use of 10.9+
symbols (#2161)
- [Cocoa] Bugfix: Querying joystick elements could reportedly segfault on macOS
13 Ventura (#2320)
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528)
- [X11] Bugfix: Decorations could not be enabled after window creation (#1566)
- [X11] Bugfix: Content scale fallback value could be inconsistent (#1578)
- [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows
- [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read
- [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail
- [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows
- [X11] Bugfix: Monitor physical dimensions could be reported as zero mm
- [X11] Bugfix: Window position events were not emitted during resizing (#1613)
- [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM
- [X11] Bugfix: Querying a disconnected monitor could segfault (#1602)
- [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
- [X11] Bugfix: Termination would segfault if the IM had been destroyed
- [X11] Bugfix: Any IM started after initialization would not be detected
- [X11] Bugfix: Xlib errors caused by other parts of the application could be
reported as GLFW errors
- [X11] Bugfix: A handle race condition could cause a `BadWindow` error (#1633)
- [X11] Bugfix: XKB path used keysyms instead of physical locations for
non-printable keys (#1598)
- [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
combinations (#1598)
- [X11] Bugfix: Keys pressed simultaneously with others were not always
reported (#1112,#1415,#1472,#1616)
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
(#1863)
- [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory
- [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on
undefined behavior (#1986)
- [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences
- [X11] Bugfix: Waiting for events would fail if file descriptor was too large
(#2024)
- [X11] Bugfix: Joystick events could lead to busy-waiting (#1872)
- [X11] Bugfix: `glfwWaitEvents*` did not continue for joystick events
- [X11] Bugfix: `glfwPostEmptyEvent` could be ignored due to race condition
(#379,#1281,#1285,#2033)
- [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences
- [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951)
- [X11] Bugfix: The OSMesa libray was not unloaded on termination
- [X11] Bugfix: A malformed response during selection transfer could cause a segfault
- [X11] Bugfix: Some calls would reset Xlib to the default error handler (#2108)
- [Wayland] Added improved fallback window decorations via libdecor (#1639,#1693)
- [Wayland] Added dynamic loading of all Wayland libraries
- [Wayland] Added support for key names via xkbcommon
- [Wayland] Added support for file path drop events (#2040)
- [Wayland] Added support for more human-readable monitor names where available
- [Wayland] Disabled alpha channel for opaque windows on systems lacking
`EGL_EXT_present_opaque` (#1895)
- [Wayland] Removed support for `wl_shell` (#1443)
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
- [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704)
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
(#1463)
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong order
(#1798)
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
- [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908)
- [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899)
- [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD
- [Wayland] Bugfix: Key repeat could lead to a race condition (#1710)
- [Wayland] Bugfix: Activating a window would emit two input focus events
- [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus
- [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731)
- [Wayland] Bugfix: A key being repeated was not released when window lost focus
- [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event
- [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE`
- [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN`
- [Wayland] Bugfix: Text input did not repeat along with key repeat
- [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521)
- [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of
`glfwGetClipboardString`
- [Wayland] Bugfix: Data source creation error would cause double free at termination
- [Wayland] Bugfix: Partial writes of clipboard string would cause beginning to repeat
- [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang
- [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string
- [Wayland] Bugfix: MIME type matching was not performed for clipboard string
- [Wayland] Bugfix: The OSMesa library was not unloaded on termination
- [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_FEATURE_UNAVAILABLE`
- [Wayland] Bugfix: Lock key modifier bits were only set when lock keys were pressed
- [Wayland] Bugfix: A window leaving full screen mode would be iconified (#1995)
- [Wayland] Bugfix: A window leaving full screen mode ignored its desired size
- [Wayland] Bugfix: `glfwSetWindowMonitor` did not update windowed mode size
- [Wayland] Bugfix: `glfwRestoreWindow` would make a full screen window windowed
- [Wayland] Bugfix: A window maximized or restored by the user would enter an
inconsistent state
- [Wayland] Bugfix: Window maximization events were not emitted
- [Wayland] Bugfix: `glfwRestoreWindow` assumed it was always in windowed mode
- [Wayland] Bugfix: `glfwSetWindowSize` would resize a full screen window
- [Wayland] Bugfix: A window content scale event would be emitted every time
the window resized
- [Wayland] Bugfix: If `glfwInit` failed it would close stdin
- [Wayland] Bugfix: Manual resizing with fallback decorations behaved erratically
(#1991,#2115,#2127)
- [Wayland] Bugfix: Size limits included frame size for fallback decorations
- [Wayland] Bugfix: Updating `GLFW_DECORATED` had no effect on server-side
decorations
- [Wayland] Bugfix: A monitor would be reported as connected again if its scale
changed
- [Wayland] Bugfix: `glfwTerminate` would segfault if any monitor had changed
scale
- [Wayland] Bugfix: Window content scale events were not emitted when monitor
scale changed
- [Wayland] Bugfix: `glfwSetWindowAspectRatio` reported an error instead of
applying the specified ratio
- [Wayland] Bugfix: `GLFW_MAXIMIZED` window hint had no effect
- [Wayland] Bugfix: `glfwRestoreWindow` had no effect before first show
- [Wayland] Bugfix: Hiding and then showing a window caused program abort on
wlroots compositors (#1268)
- [Wayland] Bugfix: `GLFW_DECORATED` was ignored when showing a window with XDG
decorations
- [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450)
- [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198)
- [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors
- [POSIX] Removed use of deprecated function `gettimeofday`
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043)
- [Linux] Bugfix: A small amount of memory could leak if initialization failed (#2229)
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
macOS versions (#1442)
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
- [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused
a duplicate definition warning (#1840)
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
(#442)
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
(#1380)
- [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
- [EGL] Bugfix: Setting `GLFW_CONTEXT_DEBUG` caused creation to fail (#2348)
- [GLX] Added loading of glvnd `libGLX.so.0` where available
- [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library
## Contact ## Contact
@ -426,13 +141,12 @@ On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as
well as news, documentation and other information about the project. well as news, documentation and other information about the project.
If you have questions related to the use of GLFW, we have a If you have questions related to the use of GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on [forum](https://discourse.glfw.org/).
[Libera.Chat](https://libera.chat/).
If you have a bug to report, a patch to submit or a feature you'd like to If you have a bug to report, a patch to submit or a feature you'd like to
request, please file it in the request, please file it in the
[issue tracker](https://github.com/glfw/glfw/issues) on GitHub. [issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
Finally, if you're interested in helping out with the development of GLFW or Finally, if you're interested in helping out with the development of GLFW or
porting it to your favorite platform, join us on the forum, GitHub or IRC. porting it to your favorite platform, join us on the forum or GitHub.

102
deps/wayland/fractional-scale-v1.xml vendored Normal file
View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="fractional_scale_v1">
<copyright>
Copyright © 2022 Kenny Levinsen
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="Protocol for requesting fractional surface scales">
This protocol allows a compositor to suggest for surfaces to render at
fractional scales.
A client can submit scaled content by utilizing wp_viewport. This is done by
creating a wp_viewport object for the surface and setting the destination
rectangle to the surface size before the scale factor is applied.
The buffer size is calculated by multiplying the surface size by the
intended scale.
The wl_surface buffer scale should remain set to 1.
If a surface has a surface-local size of 100 px by 50 px and wishes to
submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should
be used and the wp_viewport destination rectangle should be 100 px by 50 px.
For toplevel surfaces, the size is rounded halfway away from zero. The
rounding algorithm for subsurface position and size is not defined.
</description>
<interface name="wp_fractional_scale_manager_v1" version="1">
<description summary="fractional surface scale information">
A global interface for requesting surfaces to use fractional scales.
</description>
<request name="destroy" type="destructor">
<description summary="unbind the fractional surface scale interface">
Informs the server that the client will not be using this protocol
object anymore. This does not affect any other objects,
wp_fractional_scale_v1 objects included.
</description>
</request>
<enum name="error">
<entry name="fractional_scale_exists" value="0"
summary="the surface already has a fractional_scale object associated"/>
</enum>
<request name="get_fractional_scale">
<description summary="extend surface interface for scale information">
Create an add-on object for the the wl_surface to let the compositor
request fractional scales. If the given wl_surface already has a
wp_fractional_scale_v1 object associated, the fractional_scale_exists
protocol error is raised.
</description>
<arg name="id" type="new_id" interface="wp_fractional_scale_v1"
summary="the new surface scale info interface id"/>
<arg name="surface" type="object" interface="wl_surface"
summary="the surface"/>
</request>
</interface>
<interface name="wp_fractional_scale_v1" version="1">
<description summary="fractional scale interface to a wl_surface">
An additional interface to a wl_surface object which allows the compositor
to inform the client of the preferred scale.
</description>
<request name="destroy" type="destructor">
<description summary="remove surface scale information for surface">
Destroy the fractional scale object. When this object is destroyed,
preferred_scale events will no longer be sent.
</description>
</request>
<event name="preferred_scale">
<description summary="notify of new preferred scale">
Notification of a new preferred scale for this surface that the
compositor suggests that the client should use.
The sent scale is the numerator of a fraction with a denominator of 120.
</description>
<arg name="scale" type="uint" summary="the new preferred scale"/>
</event>
</interface>
</protocol>

200
deps/wayland/xdg-activation-v1.xml vendored Normal file
View File

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xdg_activation_v1">
<copyright>
Copyright © 2020 Aleix Pol Gonzalez &lt;aleixpol@kde.org&gt;
Copyright © 2020 Carlos Garnacho &lt;carlosg@gnome.org&gt;
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="Protocol for requesting activation of surfaces">
The way for a client to pass focus to another toplevel is as follows.
The client that intends to activate another toplevel uses the
xdg_activation_v1.get_activation_token request to get an activation token.
This token is then forwarded to the client, which is supposed to activate
one of its surfaces, through a separate band of communication.
One established way of doing this is through the XDG_ACTIVATION_TOKEN
environment variable of a newly launched child process. The child process
should unset the environment variable again right after reading it out in
order to avoid propagating it to other child processes.
Another established way exists for Applications implementing the D-Bus
interface org.freedesktop.Application, which should get their token under
activation-token on their platform_data.
In general activation tokens may be transferred across clients through
means not described in this protocol.
The client to be activated will then pass the token
it received to the xdg_activation_v1.activate request. The compositor can
then use this token to decide how to react to the activation request.
The token the activating client gets may be ineffective either already at
the time it receives it, for example if it was not focused, for focus
stealing prevention. The activating client will have no way to discover
the validity of the token, and may still forward it to the to be activated
client.
The created activation token may optionally get information attached to it
that can be used by the compositor to identify the application that we
intend to activate. This can for example be used to display a visual hint
about what application is being started.
Warning! The protocol described in this file is currently in the testing
phase. Backward compatible changes may be added together with the
corresponding interface version bump. Backward incompatible changes can
only be done by creating a new major version of the extension.
</description>
<interface name="xdg_activation_v1" version="1">
<description summary="interface for activating surfaces">
A global interface used for informing the compositor about applications
being activated or started, or for applications to request to be
activated.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the xdg_activation object">
Notify the compositor that the xdg_activation object will no longer be
used.
The child objects created via this interface are unaffected and should
be destroyed separately.
</description>
</request>
<request name="get_activation_token">
<description summary="requests a token">
Creates an xdg_activation_token_v1 object that will provide
the initiating client with a unique token for this activation. This
token should be offered to the clients to be activated.
</description>
<arg name="id" type="new_id" interface="xdg_activation_token_v1"/>
</request>
<request name="activate">
<description summary="notify new interaction being available">
Requests surface activation. It's up to the compositor to display
this information as desired, for example by placing the surface above
the rest.
The compositor may know who requested this by checking the activation
token and might decide not to follow through with the activation if it's
considered unwanted.
Compositors can ignore unknown activation tokens when an invalid
token is passed.
</description>
<arg name="token" type="string" summary="the activation token of the initiating client"/>
<arg name="surface" type="object" interface="wl_surface"
summary="the wl_surface to activate"/>
</request>
</interface>
<interface name="xdg_activation_token_v1" version="1">
<description summary="an exported activation handle">
An object for setting up a token and receiving a token handle that can
be passed as an activation token to another client.
The object is created using the xdg_activation_v1.get_activation_token
request. This object should then be populated with the app_id, surface
and serial information and committed. The compositor shall then issue a
done event with the token. In case the request's parameters are invalid,
the compositor will provide an invalid token.
</description>
<enum name="error">
<entry name="already_used" value="0"
summary="The token has already been used previously"/>
</enum>
<request name="set_serial">
<description summary="specifies the seat and serial of the activating event">
Provides information about the seat and serial event that requested the
token.
The serial can come from an input or focus event. For instance, if a
click triggers the launch of a third-party client, the launcher client
should send a set_serial request with the serial and seat from the
wl_pointer.button event.
Some compositors might refuse to activate toplevels when the token
doesn't have a valid and recent enough event serial.
Must be sent before commit. This information is optional.
</description>
<arg name="serial" type="uint"
summary="the serial of the event that triggered the activation"/>
<arg name="seat" type="object" interface="wl_seat"
summary="the wl_seat of the event"/>
</request>
<request name="set_app_id">
<description summary="specifies the application being activated">
The requesting client can specify an app_id to associate the token
being created with it.
Must be sent before commit. This information is optional.
</description>
<arg name="app_id" type="string"
summary="the application id of the client being activated."/>
</request>
<request name="set_surface">
<description summary="specifies the surface requesting activation">
This request sets the surface requesting the activation. Note, this is
different from the surface that will be activated.
Some compositors might refuse to activate toplevels when the token
doesn't have a requesting surface.
Must be sent before commit. This information is optional.
</description>
<arg name="surface" type="object" interface="wl_surface"
summary="the requesting surface"/>
</request>
<request name="commit">
<description summary="issues the token request">
Requests an activation token based on the different parameters that
have been offered through set_serial, set_surface and set_app_id.
</description>
</request>
<event name="done">
<description summary="the exported activation token">
The 'done' event contains the unique token of this activation request
and notifies that the provider is done.
</description>
<arg name="token" type="string" summary="the exported activation token"/>
</event>
<request name="destroy" type="destructor">
<description summary="destroy the xdg_activation_token_v1 object">
Notify the compositor that the xdg_activation_token_v1 object will no
longer be used. The received token stays valid.
</description>
</request>
</interface>
</protocol>

View File

@ -2,20 +2,20 @@
# NOTE: The order of this list determines the order of items in the Guides # NOTE: The order of this list determines the order of items in the Guides
# (i.e. Pages) list in the generated documentation # (i.e. Pages) list in the generated documentation
set(source_files set(source_files
main.dox main.md
news.dox news.md
quick.dox quick.md
moving.dox moving.md
compile.dox compile.md
build.dox build.md
intro.dox intro.md
context.dox context.md
monitor.dox monitor.md
window.dox window.md
input.dox input.md
vulkan.dox vulkan.md
compat.dox compat.md
internal.dox) internal.md)
set(extra_files DoxygenLayout.xml header.html footer.html extra.css spaces.svg) set(extra_files DoxygenLayout.xml header.html footer.html extra.css spaces.svg)
@ -31,16 +31,27 @@ foreach(file IN LISTS source_files)
string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${CMAKE_CURRENT_SOURCE_DIR}/${file}\"") string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${CMAKE_CURRENT_SOURCE_DIR}/${file}\"")
endforeach() endforeach()
configure_file(Doxyfile.in Doxyfile @ONLY) set(DOXYGEN_SKIP_DOT TRUE)
find_package(Doxygen)
add_custom_command(OUTPUT "html/index.html" if (NOT DOXYGEN_FOUND OR DOXYGEN_VERSION VERSION_LESS "1.9.8")
COMMAND "${DOXYGEN_EXECUTABLE}" message(STATUS "Documentation generation requires Doxygen 1.9.8 or later")
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" else()
MAIN_DEPENDENCY Doxyfile configure_file(Doxyfile.in Doxyfile @ONLY)
DEPENDS ${header_paths} ${source_files} ${extra_files} add_custom_command(OUTPUT "html/index.html"
COMMENT "Generating HTML documentation" COMMAND "${DOXYGEN_EXECUTABLE}"
VERBATIM) WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
MAIN_DEPENDENCY Doxyfile
DEPENDS ${header_paths} ${source_files} ${extra_files}
COMMENT "Generating HTML documentation"
VERBATIM)
add_custom_target(docs ALL SOURCES "html/index.html") add_custom_target(docs ALL SOURCES "html/index.html")
set_target_properties(docs PROPERTIES FOLDER "GLFW3") set_target_properties(docs PROPERTIES FOLDER "GLFW3")
if (GLFW_INSTALL)
install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
DESTINATION "${CMAKE_INSTALL_DOCDIR}")
endif()
endif()

View File

@ -23,13 +23,12 @@ Questions about how to use GLFW should be asked either in the [support
section](https://discourse.glfw.org/c/support) of the forum, under the [Stack section](https://discourse.glfw.org/c/support) of the forum, under the [Stack
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
Stack Exchange or in the IRC channel `#glfw` on Stack Exchange.
[Libera.Chat](https://libera.chat/).
Questions about the design or implementation of GLFW or about future plans Questions about the design or implementation of GLFW or about future plans
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
forum or in the IRC channel. Please don't open a GitHub issue to discuss design forum. Please don't open a GitHub issue to discuss design questions without
questions without first checking with a maintainer. first checking with a maintainer.
## Reporting a bug ## Reporting a bug
@ -358,7 +357,7 @@ feature.
In addition to the code, a complete feature includes: In addition to the code, a complete feature includes:
- Change log entry in `README.md`, listing all new symbols - Change log entry in `README.md`, listing all new symbols
- News page entry in `docs/news.dox`, briefly describing the feature - News page entry in `docs/news.md`, briefly describing the feature
- Guide documentation, with minimal examples, in the relevant guide in the `docs` folder - Guide documentation, with minimal examples, in the relevant guide in the `docs` folder
- Reference documentation, with all applicable tags - Reference documentation, with all applicable tags
- Cross-references and mentions in appropriate places - Cross-references and mentions in appropriate places
@ -374,7 +373,7 @@ If it adds a new monitor property, support for it must be added to
If it adds a new OpenGL, OpenGL ES or Vulkan option or extension, support If it adds a new OpenGL, OpenGL ES or Vulkan option or extension, support
for it must be added to `tests/glfwinfo.c` and the behavior of the library when for it must be added to `tests/glfwinfo.c` and the behavior of the library when
the extension is missing documented in `docs/compat.dox`. the extension is missing documented in `docs/compat.md`.
If you haven't already, read the excellent article [How to Write a Git Commit If you haven't already, read the excellent article [How to Write a Git Commit
Message](https://chris.beams.io/posts/git-commit/). Message](https://chris.beams.io/posts/git-commit/).

View File

@ -5,7 +5,7 @@
<tab type="mainpage" visible="yes" title="Introduction"/> <tab type="mainpage" visible="yes" title="Introduction"/>
<tab type="user" url="quick_guide.html" title="Tutorial"/> <tab type="user" url="quick_guide.html" title="Tutorial"/>
<tab type="pages" visible="yes" title="Guides" intro=""/> <tab type="pages" visible="yes" title="Guides" intro=""/>
<tab type="modules" visible="yes" title="Reference" intro=""/> <tab type="topics" visible="yes" title="Reference" intro=""/>
<tab type="filelist" visible="yes" title="Files"/> <tab type="filelist" visible="yes" title="Files"/>
</navindex> </navindex>

View File

@ -4,8 +4,7 @@ See the [latest documentation](https://www.glfw.org/docs/latest/) for tutorials,
guides and the API reference. guides and the API reference.
If you have questions about using GLFW, we have a If you have questions about using GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on [forum](https://discourse.glfw.org/).
[Libera.Chat](https://libera.chat/).
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues). Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
Please check the [contribution Please check the [contribution

View File

@ -1,8 +1,6 @@
/*! # Building applications {#build_guide}
@page build_guide Building applications [TOC]
@tableofcontents
This is about compiling and linking applications that use GLFW. For information on This is about compiling and linking applications that use GLFW. For information on
how to write such applications, start with the how to write such applications, start with the
@ -16,14 +14,14 @@ and linking process should be explained in your C programming material and in
the documentation for your development environment. the documentation for your development environment.
@section build_include Including the GLFW header file ## Including the GLFW header file {#build_include}
You should include the GLFW header in the source files where you use OpenGL or You should include the GLFW header in the source files where you use OpenGL or
GLFW. GLFW.
@code ```c
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
This header defines all the constants and declares all the types and function This header defines all the constants and declares all the types and function
prototypes of the GLFW API. By default, it also includes the OpenGL header from prototypes of the GLFW API. By default, it also includes the OpenGL header from
@ -43,17 +41,18 @@ In other words:
- Do not include window system headers unless you will use those APIs directly - Do not include window system headers unless you will use those APIs directly
- If you do need such headers, include them before the GLFW header - If you do need such headers, include them before the GLFW header
If you are using an OpenGL extension loading library such as If you are using an OpenGL extension loading library such as [glad][], the
[glad](https://github.com/Dav1dde/glad), the extension loader header should extension loader header should be included before the GLFW one. GLFW attempts
be included before the GLFW one. GLFW attempts to detect any OpenGL or OpenGL to detect any OpenGL or OpenGL ES header or extension loader header included
ES header or extension loader header included before it and will then disable before it and will then disable the inclusion of the default OpenGL header.
the inclusion of the default OpenGL header. Most extension loaders also define Most extension loaders also define macros that disable similar headers below it.
macros that disable similar headers below it.
@code [glad]: https://github.com/Dav1dde/glad
```c
#include <glad/gl.h> #include <glad/gl.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
Both of these mechanisms depend on the extension loader header defining a known Both of these mechanisms depend on the extension loader header defining a known
macro. If yours doesn't or you don't know which one your users will pick, the macro. If yours doesn't or you don't know which one your users will pick, the
@ -61,14 +60,14 @@ macro. If yours doesn't or you don't know which one your users will pick, the
including the OpenGL header. This will also allow you to include the two including the OpenGL header. This will also allow you to include the two
headers in any order. headers in any order.
@code ```c
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <glad/gl.h> #include <glad/gl.h>
@endcode ```
@subsection build_macros GLFW header option macros ### GLFW header option macros {#build_macros}
These macros may be defined before the inclusion of the GLFW header and affect These macros may be defined before the inclusion of the GLFW header and affect
its behavior. its behavior.
@ -82,8 +81,9 @@ Only one of these may be defined at a time.
@note GLFW does not provide any of the API headers mentioned below. They are @note GLFW does not provide any of the API headers mentioned below. They are
provided by your development environment or your OpenGL, OpenGL ES or Vulkan provided by your development environment or your OpenGL, OpenGL ES or Vulkan
SDK, and most of them can be downloaded from the SDK, and most of them can be downloaded from the [Khronos Registry][registry].
[Khronos Registry](https://www.khronos.org/registry/).
[registry]: https://www.khronos.org/registry/
@anchor GLFW_INCLUDE_GLCOREARB @anchor GLFW_INCLUDE_GLCOREARB
__GLFW_INCLUDE_GLCOREARB__ makes the GLFW header include the modern __GLFW_INCLUDE_GLCOREARB__ makes the GLFW header include the modern
@ -142,7 +142,7 @@ If your build includes GLFW and you define any these in your build files, make
sure they are not applied to the GLFW sources. sure they are not applied to the GLFW sources.
@section build_link Link with the right libraries ## Link with the right libraries {#build_link}
GLFW is essentially a wrapper of various platform-specific APIs and therefore GLFW is essentially a wrapper of various platform-specific APIs and therefore
needs to link against many different system libraries. If you are using GLFW as needs to link against many different system libraries. If you are using GLFW as
@ -155,28 +155,104 @@ hard-coded into your build environment. See the section for your development
environment below. On Linux and other Unix-like operating systems, the list environment below. On Linux and other Unix-like operating systems, the list
varies but can be retrieved in various ways as described below. varies but can be retrieved in various ways as described below.
A good general introduction to linking is A good general introduction to linking is [Beginner's Guide to
[Beginner's Guide to Linkers](https://www.lurklurk.org/linkers/linkers.html) by Linkers][linker_guide] by David Drysdale.
David Drysdale.
[linker_guide]: https://www.lurklurk.org/linkers/linkers.html
@subsection build_link_win32 With MinGW or Visual C++ on Windows ### With Visual C++ and GLFW binaries {#build_link_win32}
The static version of the GLFW library is named `glfw3`. When using this If you are using a downloaded [binary
version, it is also necessary to link with some libraries that GLFW uses. archive](https://www.glfw.org/download.html), first make sure you have the
archive matching the architecture you are building for (32-bit or 64-bit), or
you will get link errors. Also make sure you are using the binaries for your
version of Visual C++ or you may get other link errors.
When using MinGW to link an application with the static version of GLFW, you There are two version of the static GLFW library in the binary archive, because
must also explicitly link with `gdi32`. Other toolchains including MinGW-w64 it needs to use the same base run-time library variant as the rest of your
include it in the set of default libraries along with other dependencies like executable.
`user32` and `kernel32`.
The link library for the GLFW DLL is named `glfw3dll`. When compiling an One is named `glfw3.lib` and is for projects with the _Runtime Library_ project
application that uses the DLL version of GLFW, you need to define the @ref option set to _Multi-threaded DLL_ or _Multi-threaded Debug DLL_. The other is
GLFW_DLL macro _before_ any inclusion of the GLFW header. This can be done named `glfw3_mt.lib` and is for projects with _Runtime Library_ set to
either with a compiler switch or by defining it in your source code. _Multi-threaded_ or _Multi-threaded Debug_. To use the static GLFW library you
will need to add `path/to/glfw3.lib` or `path/to/glfw3_mt.lib` to the
_Additional Dependencies_ project option.
If you compiled a GLFW static library yourself then there will only be one,
named `glfw3.lib`, and you have to make sure the run-time library variant
matches.
The DLL version of the GLFW library is named `glfw3.dll`, but you will be
linking against the `glfw3dll.lib` link library. To use the DLL you will need
to add `path/to/glfw3dll.lib` to the _Additional Dependencies_ project option.
All of its dependencies are already listed there by default, but when building
with the DLL version of GLFW, you also need to define the @ref GLFW_DLL. This
can be done either in the _Preprocessor Definitions_ project option or by
defining it in your source code before including the GLFW header.
```c
#define GLFW_DLL
#include <GLFW/glfw3.h>
```
All link-time dependencies for GLFW are already listed in the _Additional
Dependencies_ option by default.
@subsection build_link_cmake_source With CMake and GLFW source ### With MinGW-w64 and GLFW binaries {#build_link_mingw}
This is intended for building a program from the command-line or by writing
a makefile, on Windows with [MinGW-w64][] and GLFW binaries. These can be from
a downloaded and extracted [binary archive](https://www.glfw.org/download.html)
or by compiling GLFW yourself. The paths below assume a binary archive is used.
If you are using a downloaded binary archive, first make sure you have the
archive matching the architecture you are building for (32-bit or 64-bit) or you
will get link errors.
Note that the order of source files and libraries matter for GCC. Dependencies
must be listed after the files that depend on them. Any source files that
depend on GLFW must be listed before the GLFW library. GLFW in turn depends on
`gdi32` and must be listed before it.
[MinGW-w64]: https://www.mingw-w64.org/
If you are using the static version of the GLFW library, which is named
`libglfw3.a`, do:
```sh
gcc -o myprog myprog.c -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3.a -lgdi32
```
If you are using the DLL version of the GLFW library, which is named
`glfw3.dll`, you will need to use the `libglfw3dll.a` link library.
```sh
gcc -o myprog myprog.c -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3dll.a -lgdi32
```
The resulting executable will need to find `glfw3.dll` to run, typically by
keeping both files in the same directory.
When you are building with the DLL version of GLFW, you will also need to define
the @ref GLFW_DLL macro. This can be done in your source files, as long as it
done before including the GLFW header:
```c
#define GLFW_DLL
#include <GLFW/glfw3.h>
```
It can also be done on the command-line:
```sh
gcc -o myprog myprog.c -D GLFW_DLL -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3dll.a -lgdi32
```
### With CMake and GLFW source {#build_link_cmake_source}
This section is about using CMake to compile and link GLFW along with your This section is about using CMake to compile and link GLFW along with your
application. If you want to use an installed binary instead, see @ref application. If you want to use an installed binary instead, see @ref
@ -188,18 +264,18 @@ built along with your application.
Add the root directory of the GLFW source tree to your project. This will add Add the root directory of the GLFW source tree to your project. This will add
the `glfw` target to your project. the `glfw` target to your project.
@code{.cmake} ```cmake
add_subdirectory(path/to/glfw) add_subdirectory(path/to/glfw)
@endcode ```
Once GLFW has been added, link your application against the `glfw` target. Once GLFW has been added, link your application against the `glfw` target.
This adds the GLFW library and its link-time dependencies as it is currently This adds the GLFW library and its link-time dependencies as it is currently
configured, the include directory for the GLFW header and, when applicable, the configured, the include directory for the GLFW header and, when applicable, the
@ref GLFW_DLL macro. @ref GLFW_DLL macro.
@code{.cmake} ```cmake
target_link_libraries(myapp glfw) target_link_libraries(myapp glfw)
@endcode ```
Note that the `glfw` target does not depend on OpenGL, as GLFW loads any OpenGL, Note that the `glfw` target does not depend on OpenGL, as GLFW loads any OpenGL,
OpenGL ES or Vulkan libraries it needs at runtime. If your application calls OpenGL ES or Vulkan libraries it needs at runtime. If your application calls
@ -207,22 +283,24 @@ OpenGL directly, instead of using a modern
[extension loader library](@ref context_glext_auto), use the OpenGL CMake [extension loader library](@ref context_glext_auto), use the OpenGL CMake
package. package.
@code{.cmake} ```cmake
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
@endcode ```
If OpenGL is found, the `OpenGL::GL` target is added to your project, containing If OpenGL is found, the `OpenGL::GL` target is added to your project, containing
library and include directory paths. Link against this like any other library. library and include directory paths. Link against this like any other library.
@code{.cmake} ```cmake
target_link_libraries(myapp OpenGL::GL) target_link_libraries(myapp OpenGL::GL)
@endcode ```
For a minimal example of a program and GLFW sources built with CMake, see the For a minimal example of a program and GLFW sources built with CMake, see the
[GLFW CMake Starter](https://github.com/juliettef/GLFW-CMake-starter) on GitHub. [GLFW CMake Starter][cmake_starter] on GitHub.
[cmake_starter]: https://github.com/juliettef/GLFW-CMake-starter
@subsection build_link_cmake_package With CMake and installed GLFW binaries ### With CMake and installed GLFW binaries {#build_link_cmake_package}
This section is about using CMake to link GLFW after it has been built and This section is about using CMake to link GLFW after it has been built and
installed. If you want to build it along with your application instead, see installed. If you want to build it along with your application instead, see
@ -231,17 +309,17 @@ installed. If you want to build it along with your application instead, see
With a few changes to your `CMakeLists.txt` you can locate the package and With a few changes to your `CMakeLists.txt` you can locate the package and
target files generated when GLFW is installed. target files generated when GLFW is installed.
@code{.cmake} ```cmake
find_package(glfw3 3.4 REQUIRED) find_package(glfw3 3.5 REQUIRED)
@endcode ```
Once GLFW has been added to the project, link against it with the `glfw` target. Once GLFW has been added to the project, link against it with the `glfw` target.
This adds the GLFW library and its link-time dependencies, the include directory This adds the GLFW library and its link-time dependencies, the include directory
for the GLFW header and, when applicable, the @ref GLFW_DLL macro. for the GLFW header and, when applicable, the @ref GLFW_DLL macro.
@code{.cmake} ```cmake
target_link_libraries(myapp glfw) target_link_libraries(myapp glfw)
@endcode ```
Note that the `glfw` target does not depend on OpenGL, as GLFW loads any OpenGL, Note that the `glfw` target does not depend on OpenGL, as GLFW loads any OpenGL,
OpenGL ES or Vulkan libraries it needs at runtime. If your application calls OpenGL ES or Vulkan libraries it needs at runtime. If your application calls
@ -249,47 +327,51 @@ OpenGL directly, instead of using a modern
[extension loader library](@ref context_glext_auto), use the OpenGL CMake [extension loader library](@ref context_glext_auto), use the OpenGL CMake
package. package.
@code{.cmake} ```cmake
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
@endcode ```
If OpenGL is found, the `OpenGL::GL` target is added to your project, containing If OpenGL is found, the `OpenGL::GL` target is added to your project, containing
library and include directory paths. Link against this like any other library. library and include directory paths. Link against this like any other library.
@code{.cmake} ```cmake
target_link_libraries(myapp OpenGL::GL) target_link_libraries(myapp OpenGL::GL)
@endcode ```
@subsection build_link_pkgconfig With makefiles and pkg-config on Unix ### With pkg-config and GLFW binaries on Unix {#build_link_pkgconfig}
GLFW supports [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/), This is intended for building a program from the command-line or by writing
and the `glfw3.pc` pkg-config file is generated when the GLFW library is built a makefile, on macOS or any Unix-like system like Linux, FreeBSD and Cygwin.
and is installed along with it. A pkg-config file describes all necessary
compile-time and link-time flags and dependencies needed to use a library. When GLFW supports [pkg-config][], and the `glfw3.pc` pkg-config file is generated
they are updated or if they differ between systems, you will get the correct when the GLFW library is built and is installed along with it. A pkg-config
ones automatically. file describes all necessary compile-time and link-time flags and dependencies
needed to use a library. When they are updated or if they differ between
systems, you will get the correct ones automatically.
[pkg-config]: https://www.freedesktop.org/wiki/Software/pkg-config/
A typical compile and link command-line when using the static version of the A typical compile and link command-line when using the static version of the
GLFW library may look like this: GLFW library may look like this:
@code{.sh} ```sh
cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --static --libs glfw3) cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --static --libs glfw3)
@endcode ```
If you are using the shared version of the GLFW library, omit the `--static` If you are using the shared version of the GLFW library, omit the `--static`
flag. flag.
@code{.sh} ```sh
cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3) cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3)
@endcode ```
You can also use the `glfw3.pc` file without installing it first, by using the You can also use the `glfw3.pc` file without installing it first, by using the
`PKG_CONFIG_PATH` environment variable. `PKG_CONFIG_PATH` environment variable.
@code{.sh} ```sh
env PKG_CONFIG_PATH=path/to/glfw/src cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3) env PKG_CONFIG_PATH=path/to/glfw/src cc $(pkg-config --cflags glfw3) -o myprog myprog.c $(pkg-config --libs glfw3)
@endcode ```
The dependencies do not include OpenGL, as GLFW loads any OpenGL, OpenGL ES or The dependencies do not include OpenGL, as GLFW loads any OpenGL, OpenGL ES or
Vulkan libraries it needs at runtime. If your application calls OpenGL Vulkan libraries it needs at runtime. If your application calls OpenGL
@ -297,34 +379,34 @@ directly, instead of using a modern
[extension loader library](@ref context_glext_auto), you should add the `gl` [extension loader library](@ref context_glext_auto), you should add the `gl`
pkg-config package. pkg-config package.
@code{.sh} ```sh
cc $(pkg-config --cflags glfw3 gl) -o myprog myprog.c $(pkg-config --libs glfw3 gl) cc $(pkg-config --cflags glfw3 gl) -o myprog myprog.c $(pkg-config --libs glfw3 gl)
@endcode ```
@subsection build_link_xcode With Xcode on macOS ### With Xcode on macOS {#build_link_xcode}
If you are using the dynamic library version of GLFW, add it to the project If you are using the dynamic library version of GLFW, add it to the project
dependencies. dependencies.
If you are using the static library version of GLFW, add it and the Cocoa, If you are using the static library version of GLFW, add it and the Cocoa,
OpenGL and IOKit frameworks to the project as dependencies. They can all be OpenGL, IOKit and QuartzCore frameworks to the project as dependencies. They
found in `/System/Library/Frameworks`. can all be found in `/System/Library/Frameworks`.
@subsection build_link_osx With command-line on macOS ### With command-line or makefile on macOS {#build_link_osx}
It is recommended that you use [pkg-config](@ref build_link_pkgconfig) when It is recommended that you use [pkg-config](@ref build_link_pkgconfig) when
building from the command line on macOS. That way you will get any new using installed GLFW binaries from the command line on macOS. That way you will
dependencies added automatically. If you still wish to build manually, you need get any new dependencies added automatically. If you still wish to build
to add the required frameworks and libraries to your command-line yourself using manually, you need to add the required frameworks and libraries to your
the `-l` and `-framework` switches. command-line yourself using the `-l` and `-framework` switches.
If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do: If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do:
@code{.sh} ```sh
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework QuartzCore
@endcode ```
If you are using the static library, named `libglfw3.a`, substitute `-lglfw3` If you are using the static library, named `libglfw3.a`, substitute `-lglfw3`
for `-lglfw`. for `-lglfw`.
@ -335,4 +417,3 @@ against it from the command-line.
@note Your machine may have `libGL.*.dylib` style OpenGL library, but that is @note Your machine may have `libGL.*.dylib` style OpenGL library, but that is
for the X Window System and will not work with the macOS native version of GLFW. for the X Window System and will not work with the macOS native version of GLFW.
*/

View File

@ -1,8 +1,6 @@
/*! # Standards conformance {#compat_guide}
@page compat_guide Standards conformance [TOC]
@tableofcontents
This guide describes the various API extensions used by this version of GLFW. This guide describes the various API extensions used by this version of GLFW.
It lists what are essentially implementation details, but which are nonetheless It lists what are essentially implementation details, but which are nonetheless
@ -15,18 +13,18 @@ part of this information may change in future versions of GLFW and that will not
be considered a breaking API change. be considered a breaking API change.
@section compat_x11 X11 extensions, protocols and IPC standards ## X11 extensions, protocols and IPC standards {#compat_x11}
As GLFW uses Xlib directly, without any intervening toolkit As GLFW uses Xlib directly, without any intervening toolkit library, it has sole
library, it has sole responsibility for interacting well with the many and responsibility for interacting well with the many and varied window managers in
varied window managers in use on Unix-like systems. In order for applications use on Unix-like systems. In order for applications and window managers to work
and window managers to work well together, a number of standards and well together, a number of standards and conventions have been developed that
conventions have been developed that regulate behavior outside the scope of the regulate behavior outside the scope of the X11 API; most importantly the
X11 API; most importantly the [Inter-Client Communication Conventions Manual][ICCCM] (ICCCM) and [Extended
[Inter-Client Communication Conventions Manual](https://www.tronche.com/gui/x/icccm/) Window Manager Hints][EWMH] (EWMH) standards.
(ICCCM) and
[Extended Window Manager Hints](https://standards.freedesktop.org/wm-spec/wm-spec-latest.html) [ICCCM]: https://www.tronche.com/gui/x/icccm/
(EWMH) standards. [EWMH]: https://standards.freedesktop.org/wm-spec/wm-spec-latest.html
GLFW uses the `_MOTIF_WM_HINTS` window property to support borderless windows. GLFW uses the `_MOTIF_WM_HINTS` window property to support borderless windows.
If the running window manager does not support this property, the If the running window manager does not support this property, the
@ -52,16 +50,18 @@ compositing window manager to un-redirect full screen GLFW windows. If the
running window manager uses compositing but does not support this property then running window manager uses compositing but does not support this property then
additional copying may be performed for each buffer swap of full screen windows. additional copying may be performed for each buffer swap of full screen windows.
GLFW uses the GLFW uses the [clipboard manager protocol][ClipboardManager] to push a clipboard
[clipboard manager protocol](https://www.freedesktop.org/wiki/ClipboardManager/) string (i.e. selection) owned by a GLFW window about to be destroyed to the
to push a clipboard string (i.e. selection) owned by a GLFW window about to be clipboard manager. If there is no running clipboard manager, the clipboard
destroyed to the clipboard manager. If there is no running clipboard manager, string will be unavailable once the window has been destroyed.
the clipboard string will be unavailable once the window has been destroyed.
GLFW uses the [clipboardManager]: https://www.freedesktop.org/wiki/ClipboardManager/
[X drag-and-drop protocol](https://www.freedesktop.org/wiki/Specifications/XDND/)
to provide file drop events. If the application originating the drag does not GLFW uses the [X drag-and-drop protocol][XDND] to provide file drop events. If
support this protocol, drag and drop will not work. the application originating the drag does not support this protocol, drag and
drop will not work.
[XDND]: https://www.freedesktop.org/wiki/Specifications/XDND/
GLFW uses the XRandR 1.3 extension to provide multi-monitor support. If the GLFW uses the XRandR 1.3 extension to provide multi-monitor support. If the
running X server does not support this version of this extension, multi-monitor running X server does not support this version of this extension, multi-monitor
@ -93,7 +93,7 @@ conventions, the `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR` and
legacy images. legacy images.
@section compat_wayland Wayland protocols and IPC standards ## Wayland protocols and IPC standards {#compat_wayland}
As GLFW uses libwayland directly, without any intervening toolkit library, it As GLFW uses libwayland directly, without any intervening toolkit library, it
has sole responsibility for interacting well with every compositor in use on has sole responsibility for interacting well with every compositor in use on
@ -106,42 +106,60 @@ Wayland protocols to implement certain features if the compositor supports them.
GLFW uses xkbcommon 0.5.0 to provide key and text input support. Earlier GLFW uses xkbcommon 0.5.0 to provide key and text input support. Earlier
versions are not supported. versions are not supported.
GLFW uses the [xdg-shell protocol](https://wayland.app/protocols/xdg-shell) GLFW uses the [xdg-shell][] protocol to provide better window management. This
to provide better window management. This protocol is mandatory for GLFW to protocol is mandatory for GLFW to display a window.
display a window.
GLFW uses the [xdg-shell]: https://wayland.app/protocols/xdg-shell
[relative pointer protocol](https://wayland.app/protocols/relative-pointer-unstable-v1)
alongside the
[pointer constraints protocol](https://wayland.app/protocols/pointer-constraints-unstable-v1)
to implement disabled cursor. If the running compositor does not support both
of these protocols, disabling the cursor will have no effect.
GLFW uses the GLFW uses the [relative-pointer-unstable-v1][] protocol alongside the
[idle inhibit protocol](https://wayland.app/protocols/idle-inhibit-unstable-v1) [pointer-constraints-unstable-v1][] protocol to implement disabled cursor. If
to prohibit the screensaver from starting. If the running compositor does not the running compositor does not support both of these protocols, disabling the
support this protocol, the screensaver may start even for full screen windows. cursor will have no effect.
GLFW uses the [relative-pointer-unstable-v1]: https://wayland.app/protocols/relative-pointer-unstable-v1
[libdecor library](https://gitlab.freedesktop.org/libdecor/libdecor) for window [pointer-constraints-unstable-v1]: https://wayland.app/protocols/pointer-constraints-unstable-v1
decorations, where available. This in turn provides good quality client-side
decorations (drawn by the application) on desktop systems that do not support
server-side decorations (drawn by the window manager). On systems that do not
provide either libdecor or xdg-decoration, very basic window decorations are
provided. These do not include the window title or any caption buttons.
GLFW uses the GLFW uses the [idle-inhibit-unstable-v1][] protocol to prohibit the screensaver
[xdg-decoration protocol](https://wayland.app/protocols/xdg-decoration-unstable-v1) from starting. If the running compositor does not support this protocol, the
to request decorations to be drawn around its windows. This protocol is part screensaver may start even for full screen windows.
of wayland-protocols 1.15, and mandatory at build time. If the running
compositor does not support this protocol, a very simple frame will be drawn by [idle-inhibit-unstable-v1]: https://wayland.app/protocols/idle-inhibit-unstable-v1
GLFW itself, using the
[viewporter protocol](https://wayland.app/protocols/viewporter) GLFW uses the [libdecor][] library for window decorations, where available.
alongside subsurfaces. If the running compositor does not support these This in turn provides good quality client-side decorations (drawn by the
protocols either, no decorations will be drawn around windows. application) on desktop systems that do not support server-side decorations
(drawn by the window manager). On systems that do not provide either libdecor
or xdg-decoration, very basic window decorations are provided. These do not
include the window title or any caption buttons.
[libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor
GLFW uses the [xdg-decoration-unstable-v1][] protocol to request decorations to
be drawn around its windows. This protocol is part of wayland-protocols 1.15,
and mandatory at build time. If the running compositor does not support this
protocol, a very simple frame will be drawn by GLFW itself, using the
[viewporter][] protocol alongside subsurfaces. If the running compositor does
not support these protocols either, no decorations will be drawn around windows.
[xdg-decoration-unstable-v1]: https://wayland.app/protocols/xdg-decoration-unstable-v1
[viewporter]: https://wayland.app/protocols/viewporter
GLFW uses the [xdg-activation-v1][] protocol to implement window focus and
attention requests. If the running compositor does not support this protocol,
window focus and attention requests do nothing.
[xdg-activation-v1]: https://wayland.app/protocols/xdg-activation-v1
GLFW uses the [fractional-scale-v1][] protocol to implement fine-grained
framebuffer scaling. If the running compositor does not support this protocol,
the @ref GLFW_SCALE_FRAMEBUFFER window hint will only be able to scale the
framebuffer by integer scales. This will typically be the smallest integer not
less than the actual scale.
[fractional-scale-v1]: https://wayland.app/protocols/fractional-scale-v1
@section compat_glx GLX extensions ## GLX extensions {#compat_glx}
The GLX API is the default API used to create OpenGL contexts on Unix-like The GLX API is the default API used to create OpenGL contexts on Unix-like
systems using the X Window System. systems using the X Window System.
@ -181,7 +199,7 @@ extensions to provide support for sRGB framebuffers. Where both of these
extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect.
@section compat_wgl WGL extensions ## WGL extensions {#compat_wgl}
The WGL API is used to create OpenGL contexts on Microsoft Windows and other The WGL API is used to create OpenGL contexts on Microsoft Windows and other
implementations of the Win32 API, such as Wine. implementations of the Win32 API, such as Wine.
@ -222,29 +240,32 @@ extensions to provide support for sRGB framebuffers. When both of these
extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect.
@section compat_osx OpenGL on macOS ## OpenGL on macOS {#compat_osx}
Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then macOS (as of version 14) still provides OpenGL but it has been deprecated by
only forward-compatible, core profile contexts are supported. Support for Apple. While the API is still available, it is poorly maintained and frequently
OpenGL 4.1 was introduced with OS X 10.9, also limited to forward-compatible, develops new issues. On modern systems, OpenGL is implemented on top of Metal
core profile contexts. There is also still no mechanism for requesting debug and is not fully thread-safe.
contexts or no-error contexts. Versions of Mac OS X earlier than 10.7 support
at most OpenGL version 2.1.
Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and macOS does not support OpenGL stereo rendering. If the `GLFW_STEREO` hint is
`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if set to true, OpenGL context creation will always fail.
given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to
`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The
`GLFW_CONTEXT_DEBUG` and `GLFW_CONTEXT_NO_ERROR` hints are ignored.
Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and macOS only supports OpenGL core profile contexts that are forward-compatible,
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, but the `GLFW_OPENGL_FORWARD_COMPAT` hint is ignored since GLFW 3.4. Even if
setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to this hint is set to false (the default), a forward-compatible context will be
a non-default value will cause @ref glfwCreateWindow to fail and the returned if available.
`GLFW_CONTEXT_DEBUG` hint is ignored.
macOS does not support OpenGL debug contexts, no-error contexts or robustness.
The `GLFW_CONTEXT_DEBUG`, `GLFW_CONTEXT_NO_ERROR` and `GLFW_CONTEXT_ROBUSTNESS`
hints will be ignored and a context without these features will be returned.
macOS does not flush OpenGL contexts when they are made non-current. The
`GLFW_CONTEXT_RELEASE_BEHAVIOR` hint is ignored and the release behavior will
always be the equivalent of `GLFW_RELEASE_BEHAVIOR_NONE`. If you need a context
to be flushed, call `glFlush` before making it non-current.
@section compat_vulkan Vulkan loader and API ## Vulkan loader and API {#compat_vulkan}
By default, GLFW uses the standard system-wide Vulkan loader to access the By default, GLFW uses the standard system-wide Vulkan loader to access the
Vulkan API on all platforms except macOS. This is installed by both graphics Vulkan API on all platforms except macOS. This is installed by both graphics
@ -254,7 +275,7 @@ all other Vulkan-related functions will fail with an @ref GLFW_API_UNAVAILABLE
error. error.
@section compat_wsi Vulkan WSI extensions ## Vulkan WSI extensions {#compat_wsi}
The Vulkan WSI extensions are used to create Vulkan surfaces for GLFW windows on The Vulkan WSI extensions are used to create Vulkan surfaces for GLFW windows on
all supported platforms. all supported platforms.
@ -280,4 +301,3 @@ surfaces on Wayland. If any of these extensions are not available, @ref
glfwGetRequiredInstanceExtensions will return an empty list and window surface glfwGetRequiredInstanceExtensions will return an empty list and window surface
creation will fail. creation will fail.
*/

View File

@ -1,8 +1,6 @@
/*! # Compiling GLFW {#compile_guide}
@page compile_guide Compiling GLFW [TOC]
@tableofcontents
This is about compiling the GLFW library itself. For information on how to This is about compiling the GLFW library itself. For information on how to
build applications that use GLFW, see @ref build_guide. build applications that use GLFW, see @ref build_guide.
@ -10,7 +8,7 @@ build applications that use GLFW, see @ref build_guide.
GLFW uses some C99 features and does not support Visual Studio 2012 and earlier. GLFW uses some C99 features and does not support Visual Studio 2012 and earlier.
@section compile_cmake Using CMake ## Using CMake {#compile_cmake}
GLFW behaves like most other libraries that use CMake so this guide mostly GLFW behaves like most other libraries that use CMake so this guide mostly
describes the standard configure, generate and compile sequence. If you are already describes the standard configure, generate and compile sequence. If you are already
@ -21,8 +19,8 @@ GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles
for your chosen development environment. To compile GLFW, first generate these for your chosen development environment. To compile GLFW, first generate these
files with CMake and then use them to compile the GLFW library. files with CMake and then use them to compile the GLFW library.
If you are on Windows and macOS you can If you are on Windows and macOS you can [download
[download CMake](https://cmake.org/download/) from their site. CMake](https://cmake.org/download/) from their site.
If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have
a package system like Fink, MacPorts or Homebrew, you can install its CMake a package system like Fink, MacPorts or Homebrew, you can install its CMake
@ -30,89 +28,65 @@ package.
CMake is a complex tool and this guide will only show a few of the possible ways CMake is a complex tool and this guide will only show a few of the possible ways
to set up and compile GLFW. The CMake project has their own much more detailed to set up and compile GLFW. The CMake project has their own much more detailed
[CMake user guide](https://cmake.org/cmake/help/latest/guide/user-interaction/) [CMake user guide][cmake-guide] that includes everything in this guide not
that includes everything in this guide not specific to GLFW. It may be a useful specific to GLFW. It may be a useful companion to this one.
companion to this one.
[cmake-guide]: https://cmake.org/cmake/help/latest/guide/user-interaction/
@subsection compile_deps Installing dependencies ### Installing dependencies {#compile_deps}
The C/C++ development environments in Visual Studio, Xcode and MinGW come with The C/C++ development environments in Visual Studio, Xcode and MinGW come with
all necessary dependencies for compiling GLFW, but on Unix-like systems like all necessary dependencies for compiling GLFW, but on Unix-like systems like
Linux and FreeBSD you will need a few extra packages. Linux and FreeBSD you will need a few extra packages.
@subsubsection compile_deps_x11 Dependencies for X11 #### Dependencies for Wayland and X11 {#compile_deps_wayland}
To compile GLFW for X11, you need to have the X11 development packages By default, both the Wayland and X11 backends are enabled on Linux and other Unix-like
installed. They are not needed to build or run programs that use GLFW. systems (except macOS). To disable one or both of these, set the @ref GLFW_BUILD_WAYLAND
or @ref GLFW_BUILD_X11 CMake options in the next step when generating build files.
On Debian and derivatives like Ubuntu and Linux Mint the `xorg-dev` meta-package
pulls in the development packages for all of X11.
@code{.sh}
sudo apt install xorg-dev
@endcode
On Fedora and derivatives like Red Hat the X11 extension packages
`libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libXrandr-devel`
required by GLFW pull in all its other dependencies.
@code{.sh}
sudo dnf install libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
@endcode
On FreeBSD the X11 headers are installed along the end-user X11 packages, so if
you have an X server running you should have the headers as well. If not,
install the `xorgproto` package.
@code{.sh}
pkg install xorgproto
@endcode
On Cygwin the `libXcursor-devel`, `libXi-devel`, `libXinerama-devel`,
`libXrandr-devel` and `libXrender-devel` packages in the Libs section of the GUI
installer will install all the headers and other development related files GLFW
requires for X11.
Once you have the required dependencies, move on to @ref compile_generate.
@subsubsection compile_deps_wayland Dependencies for Wayland and X11
To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon
development packages installed. They are not needed to build or run programs that use development packages installed. On some systems a few other packages are also required.
GLFW. You will also need to set the @ref GLFW_BUILD_WAYLAND CMake option in the next None of the development packages above are needed to build or run programs that use an
step when generating build files. already compiled GLFW library.
On Debian and derivatives like Ubuntu and Linux Mint you will need the `libwayland-dev` On Debian and derivatives like Ubuntu and Linux Mint you will need the `libwayland-dev`
and `libxkbcommon-dev` packages and the `xorg-dev` meta-package. These will pull in all and `libxkbcommon-dev` packages to compile for Wayland and the `xorg-dev` meta-package to
other dependencies. compile for X11. These will pull in all other dependencies.
@code{.sh} ```sh
sudo apt install libwayland-dev libxkbcommon-dev xorg-dev sudo apt install libwayland-dev libxkbcommon-dev xorg-dev
@endcode ```
On Fedora and derivatives like Red Hat you will need the `wayland-devel`, On Fedora and derivatives like Red Hat you will need the `wayland-devel` and
`libxkbcommon-devel`, `libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libxkbcommon-devel` packages to compile for Wayland and the `libXcursor-devel`,
`libXrandr-devel` packages. These will pull in all other dependencies. `libXi-devel`, `libXinerama-devel` and `libXrandr-devel` packages to compile for X11.
These will pull in all other dependencies.
@code{.sh} ```sh
sudo dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel sudo dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
@endcode ```
On FreeBSD you will need the `wayland` and `libxkbcommon` packages. The X11 headers are On FreeBSD you will need the `wayland`, `libxkbcommon` and `evdev-proto` packages to
installed along the end-user X11 packages, so if you have an X server running you should compile for Wayland. The X11 headers are installed along the end-user X11 packages, so if
have the headers as well. If not, install the `xorgproto` package. you have an X server running you should have the headers as well. If not, install the
`xorgproto` package to compile for X11.
@code{.sh} ```sh
pkg install wayland libxkbcommon xorgproto pkg install wayland libxkbcommon evdev-proto xorgproto
@endcode ```
On Cygwin Wayland is not supported but you will need the `libXcursor-devel`,
`libXi-devel`, `libXinerama-devel`, `libXrandr-devel` and `libXrender-devel` packages to
compile for X11. These can be found in the Libs section of the GUI installer and will
pull in all other dependencies.
Once you have the required dependencies, move on to @ref compile_generate. Once you have the required dependencies, move on to @ref compile_generate.
@subsection compile_generate Generating build files with CMake ### Generating build files with CMake {#compile_generate}
Once you have all necessary dependencies it is time to generate the project Once you have all necessary dependencies it is time to generate the project
files or makefiles for your development environment. CMake needs two paths for files or makefiles for your development environment. CMake needs two paths for
@ -134,7 +108,7 @@ A common pattern when building a single configuration is to have a build
directory named `build` in the root of the source tree. directory named `build` in the root of the source tree.
@subsubsection compile_generate_gui Generating with the CMake GUI #### Generating with the CMake GUI {#compile_generate_gui}
Start the CMake GUI and set the paths to the source and build directories Start the CMake GUI and set the paths to the source and build directories
described above. Then press _Configure_ and _Generate_. described above. Then press _Configure_ and _Generate_.
@ -143,53 +117,54 @@ If you wish change any CMake variables in the list, press _Configure_ and then
_Generate_ to have the new values take effect. The variable list will be _Generate_ to have the new values take effect. The variable list will be
populated after the first configure step. populated after the first configure step.
By default, GLFW will use X11 on Linux and other Unix-like systems other than macOS. To By default, GLFW will use Wayland and X11 on Linux and other Unix-like systems other than
include support for Wayland as well, set the @ref GLFW_BUILD_WAYLAND option in the GLFW macOS. To disable support for one or both of these, set the @ref GLFW_BUILD_WAYLAND
section of the variable list, then apply the new value as described above. and/or @ref GLFW_BUILD_X11 option in the GLFW section of the variable list, then apply the
new value as described above.
Once you have generated the project files or makefiles for your chosen Once you have generated the project files or makefiles for your chosen
development environment, move on to @ref compile_compile. development environment, move on to @ref compile_compile.
@subsubsection compile_generate_cli Generating with command-line CMake #### Generating with command-line CMake {#compile_generate_cli}
To make a build directory, pass the source and build directories to the `cmake` To make a build directory, pass the source and build directories to the `cmake`
command. These can be relative or absolute paths. The build directory is command. These can be relative or absolute paths. The build directory is
created if it doesn't already exist. created if it doesn't already exist.
@code{.sh} ```sh
cmake -S path/to/glfw -B path/to/build cmake -S path/to/glfw -B path/to/build
@endcode ```
It is common to name the build directory `build` and place it in the root of the It is common to name the build directory `build` and place it in the root of the
source tree when only planning to build a single configuration. source tree when only planning to build a single configuration.
@code{.sh} ```sh
cd path/to/glfw cd path/to/glfw
cmake -S . -B build cmake -S . -B build
@endcode ```
Without other flags these will generate Visual Studio project files on Windows Without other flags these will generate Visual Studio project files on Windows
and makefiles on other platforms. You can choose other targets using the `-G` and makefiles on other platforms. You can choose other targets using the `-G`
flag. flag.
@code{.sh} ```sh
cmake -S path/to/glfw -B path/to/build -G Xcode cmake -S path/to/glfw -B path/to/build -G Xcode
@endcode ```
By default, GLFW will use X11 on Linux and other Unix-like systems other By default, GLFW will use Wayland and X11 on Linux and other Unix-like systems other than
than macOS. To also include support for Wayland, set the @ref GLFW_BUILD_WAYLAND CMake macOS. To disable support for one or both of these, set the @ref GLFW_BUILD_WAYLAND
option. and/or @ref GLFW_BUILD_X11 CMake option.
@code{.sh} ```sh
cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_WAYLAND=1 cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_X11=0
@endcode ```
Once you have generated the project files or makefiles for your chosen Once you have generated the project files or makefiles for your chosen
development environment, move on to @ref compile_compile. development environment, move on to @ref compile_compile.
@subsection compile_compile Compiling the library ### Compiling the library {#compile_compile}
You should now have all required dependencies and the project files or makefiles You should now have all required dependencies and the project files or makefiles
necessary to compile GLFW. Go ahead and compile the actual GLFW library with necessary to compile GLFW. Go ahead and compile the actual GLFW library with
@ -200,24 +175,24 @@ With Visual Studio open `GLFW.sln` and use the Build menu. With Xcode open
With Linux, macOS and other forms of Unix, run `make`. With Linux, macOS and other forms of Unix, run `make`.
@code{.sh} ```sh
cd path/to/build cd path/to/build
make make
@endcode ```
With MinGW, it is `mingw32-make`. With MinGW, it is `mingw32-make`.
@code{.sh} ```sh
cd path/to/build cd path/to/build
mingw32-make mingw32-make
@endcode ```
Any CMake build directory can also be built with the `cmake` command and the Any CMake build directory can also be built with the `cmake` command and the
`--build` flag. `--build` flag.
@code{.sh} ```sh
cmake --build path/to/build cmake --build path/to/build
@endcode ```
This will run the platform specific build tool the directory was generated for. This will run the platform specific build tool the directory was generated for.
@ -225,7 +200,7 @@ Once the GLFW library is compiled you are ready to build your application,
linking it to the GLFW library. See @ref build_guide for more information. linking it to the GLFW library. See @ref build_guide for more information.
@section compile_options CMake options ## CMake options {#compile_options}
The CMake files for GLFW provide a number of options, although not all are The CMake files for GLFW provide a number of options, although not all are
available on all supported platforms. Some of these are de facto standards available on all supported platforms. Some of these are de facto standards
@ -240,12 +215,12 @@ distributions based on Debian GNU/Linux have this tool in a separate
Finally, if you don't want to use any GUI, you can set options from the `cmake` Finally, if you don't want to use any GUI, you can set options from the `cmake`
command-line with the `-D` flag. command-line with the `-D` flag.
@code{.sh} ```sh
cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON
@endcode ```
@subsection compile_options_shared Shared CMake options ### Shared CMake options {#compile_options_shared}
@anchor BUILD_SHARED_LIBS @anchor BUILD_SHARED_LIBS
__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static library or as __BUILD_SHARED_LIBS__ determines whether GLFW is built as a static library or as
@ -277,7 +252,7 @@ with the library. This is enabled by default if
[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration. [Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
@subsection compile_options_win32 Win32 specific CMake options ### Win32 specific CMake options {#compile_options_win32}
@anchor GLFW_BUILD_WIN32 @anchor GLFW_BUILD_WIN32
__GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the __GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the
@ -289,10 +264,11 @@ __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or th
static library version of the Visual C++ runtime library. When enabled, the static library version of the Visual C++ runtime library. When enabled, the
DLL version of the Visual C++ library is used. This is enabled by default. DLL version of the Visual C++ library is used. This is enabled by default.
On CMake 3.15 and later you can set the standard CMake On CMake 3.15 and later you can set the standard CMake [CMAKE_MSVC_RUNTIME_LIBRARY][]
[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)
variable instead of this GLFW-specific option. variable instead of this GLFW-specific option.
[CMAKE_MSVC_RUNTIME_LIBRARY]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html
@anchor GLFW_USE_HYBRID_HPG @anchor GLFW_USE_HYBRID_HPG
__GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and __GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the `AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
@ -302,7 +278,7 @@ will not work if GLFW is built as a DLL. This is disabled by default, letting
the operating system and driver decide. the operating system and driver decide.
@subsection compile_options_macos macOS specific CMake options ### macOS specific CMake options {#compile_options_macos}
@anchor GLFW_BUILD_COCOA @anchor GLFW_BUILD_COCOA
__GLFW_BUILD_COCOA__ determines whether to include support for Cocoa when compiling the __GLFW_BUILD_COCOA__ determines whether to include support for Cocoa when compiling the
@ -310,12 +286,12 @@ library. This option is only available when compiling for macOS. This is enabl
default. default.
@subsection compile_options_unix Unix-like system specific CMake options ### Unix-like system specific CMake options {#compile_options_unix}
@anchor GLFW_BUILD_WAYLAND @anchor GLFW_BUILD_WAYLAND
__GLFW_BUILD_WAYLAND__ determines whether to include support for Wayland when compiling __GLFW_BUILD_WAYLAND__ determines whether to include support for Wayland when compiling
the library. This option is only available when compiling for Linux and other Unix-like the library. This option is only available when compiling for Linux and other Unix-like
systems other than macOS. This is disabled by default. systems other than macOS. This is enabled by default.
@anchor GLFW_BUILD_X11 @anchor GLFW_BUILD_X11
__GLFW_BUILD_X11__ determines whether to include support for X11 when compiling the __GLFW_BUILD_X11__ determines whether to include support for X11 when compiling the
@ -323,7 +299,7 @@ library. This option is only available when compiling for Linux and other Unix-
systems other than macOS. This is enabled by default. systems other than macOS. This is enabled by default.
@section compile_mingw_cross Cross-compilation with CMake and MinGW ## Cross-compilation with CMake and MinGW {#compile_mingw_cross}
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
@ -335,9 +311,9 @@ cross-compilation of Windows binaries. To use these files you set the
`CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when `CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when
configuring and generating the build files. configuring and generating the build files.
@code{.sh} ```sh
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
@endcode ```
The exact toolchain file to use depends on the prefix used by the MinGW or The exact toolchain file to use depends on the prefix used by the MinGW or
MinGW-w64 binaries on your system. You can usually see this in the /usr MinGW-w64 binaries on your system. You can usually see this in the /usr
@ -345,18 +321,19 @@ directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have
`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
would be: would be:
@code{.sh} ```sh
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake
@endcode ```
The path to the toolchain file is relative to the path to the GLFW source tree The path to the toolchain file is relative to the path to the GLFW source tree
passed to the `-S` flag, not to the current directory. passed to the `-S` flag, not to the current directory.
For more details see the For more details see the [CMake toolchain guide][cmake-toolchains].
[CMake toolchain guide](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html).
[cmake-toolchains]: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
@section compile_manual Compiling GLFW manually ## Compiling GLFW manually {#compile_manual}
If you wish to compile GLFW without its CMake build environment then you will have to do If you wish to compile GLFW without its CMake build environment then you will have to do
at least some platform-detection yourself. There are preprocessor macros for at least some platform-detection yourself. There are preprocessor macros for
@ -373,8 +350,8 @@ clipboard. The options are:
- @b _GLFW_COCOA to use the Cocoa frameworks - @b _GLFW_COCOA to use the Cocoa frameworks
- @b _GLFW_WIN32 to use the Win32 API - @b _GLFW_WIN32 to use the Win32 API
- @b _GLFW_WAYLAND to use the Wayland protocol
- @b _GLFW_X11 to use the X Window System - @b _GLFW_X11 to use the X Window System
- @b _GLFW_WAYLAND to use the Wayland API (incomplete)
The @b _GLFW_WAYLAND and @b _GLFW_X11 macros may be combined and produces a library that The @b _GLFW_WAYLAND and @b _GLFW_X11 macros may be combined and produces a library that
attempts to detect the appropriate platform at initialization. attempts to detect the appropriate platform at initialization.
@ -392,4 +369,3 @@ _GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names.
GLFW. If you define any of these in your build files, make sure they are not GLFW. If you define any of these in your build files, make sure they are not
applied to the GLFW sources. applied to the GLFW sources.
*/

View File

@ -1,8 +1,6 @@
/*! # Context guide {#context_guide}
@page context_guide Context guide [TOC]
@tableofcontents
This guide introduces the OpenGL and OpenGL ES context related functions of This guide introduces the OpenGL and OpenGL ES context related functions of
GLFW. For details on a specific function in this category, see the @ref GLFW. For details on a specific function in this category, see the @ref
@ -15,7 +13,7 @@ context. There are also guides for the other areas of the GLFW API.
- @ref input_guide - @ref input_guide
@section context_object Context objects ## Context objects {#context_object}
A window object encapsulates both a top-level window and an OpenGL or OpenGL ES A window object encapsulates both a top-level window and an OpenGL or OpenGL ES
context. It is created with @ref glfwCreateWindow and destroyed with @ref context. It is created with @ref glfwCreateWindow and destroyed with @ref
@ -34,22 +32,22 @@ context creation by setting the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint)
hint to `GLFW_NO_API`. For more information, see the @ref vulkan_guide. hint to `GLFW_NO_API`. For more information, see the @ref vulkan_guide.
@subsection context_hints Context creation hints ### Context creation hints {#context_hints}
There are a number of hints, specified using @ref glfwWindowHint, related to There are a number of hints, specified using @ref glfwWindowHint, related to
what kind of context is created. See what kind of context is created. See
[context related hints](@ref window_hints_ctx) in the window guide. [context related hints](@ref window_hints_ctx) in the window guide.
@subsection context_sharing Context object sharing ### Context object sharing {#context_sharing}
When creating a window and its OpenGL or OpenGL ES context with @ref When creating a window and its OpenGL or OpenGL ES context with @ref
glfwCreateWindow, you can specify another window whose context the new one glfwCreateWindow, you can specify another window whose context the new one
should share its objects (textures, vertex and element buffers, etc.) with. should share its objects (textures, vertex and element buffers, etc.) with.
@code ```c
GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window); GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window);
@endcode ```
Object sharing is implemented by the operating system and graphics driver. On Object sharing is implemented by the operating system and graphics driver. On
platforms where it is possible to choose which types of objects are shared, GLFW platforms where it is possible to choose which types of objects are shared, GLFW
@ -64,17 +62,17 @@ Contexts_.
GLFW comes with a bare-bones object sharing example program called `sharing`. GLFW comes with a bare-bones object sharing example program called `sharing`.
@subsection context_offscreen Offscreen contexts ### Offscreen contexts {#context_offscreen}
GLFW doesn't support creating contexts without an associated window. However, GLFW doesn't support creating contexts without an associated window. However,
contexts with hidden windows can be created with the contexts with hidden windows can be created with the
[GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint. [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint.
@code ```c
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL); GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL);
@endcode ```
The window never needs to be shown and its context can be used as a plain The window never needs to be shown and its context can be used as a plain
offscreen context. Depending on the window manager, the size of a hidden offscreen context. Depending on the window manager, the size of a hidden
@ -85,7 +83,7 @@ You should still [process events](@ref events) as long as you have at least one
window, even if none of them are visible. window, even if none of them are visible.
@subsection context_less Windows without contexts ### Windows without contexts {#context_less}
You can disable context creation by setting the You can disable context creation by setting the
[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`. [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`.
@ -94,7 +92,7 @@ Windows without contexts should not be passed to @ref glfwMakeContextCurrent or
@ref glfwSwapBuffers. Doing this generates a @ref GLFW_NO_WINDOW_CONTEXT error. @ref glfwSwapBuffers. Doing this generates a @ref GLFW_NO_WINDOW_CONTEXT error.
@section context_current Current context ## Current context {#context_current}
Before you can make OpenGL or OpenGL ES calls, you need to have a current Before you can make OpenGL or OpenGL ES calls, you need to have a current
context of the correct type. A context can only be current for a single thread context of the correct type. A context can only be current for a single thread
@ -105,15 +103,15 @@ thread before making it current on the new one.
The context of a window is made current with @ref glfwMakeContextCurrent. The context of a window is made current with @ref glfwMakeContextCurrent.
@code ```c
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
@endcode ```
The window of the current context is returned by @ref glfwGetCurrentContext. The window of the current context is returned by @ref glfwGetCurrentContext.
@code ```c
GLFWwindow* window = glfwGetCurrentContext(); GLFWwindow* window = glfwGetCurrentContext();
@endcode ```
The following GLFW functions require a context to be current. Calling any these The following GLFW functions require a context to be current. Calling any these
functions without a current context will generate a @ref GLFW_NO_CURRENT_CONTEXT functions without a current context will generate a @ref GLFW_NO_CURRENT_CONTEXT
@ -124,12 +122,12 @@ error.
- @ref glfwGetProcAddress - @ref glfwGetProcAddress
@section context_swap Buffer swapping ## Buffer swapping {#context_swap}
See @ref buffer_swap in the window guide. See @ref buffer_swap in the window guide.
@section context_glext OpenGL and OpenGL ES extensions ## OpenGL and OpenGL ES extensions {#context_glext}
One of the benefits of OpenGL and OpenGL ES is their extensibility. One of the benefits of OpenGL and OpenGL ES is their extensibility.
Hardware vendors may include extensions in their implementations that extend the Hardware vendors may include extensions in their implementations that extend the
@ -152,7 +150,7 @@ their specifications, can be found at the
[OpenGL ES Registry](https://www.khronos.org/registry/gles/). [OpenGL ES Registry](https://www.khronos.org/registry/gles/).
@subsection context_glext_auto Loading extension with a loader library ### Loading extension with a loader library {#context_glext_auto}
An extension loader library is the easiest and best way to access both OpenGL and An extension loader library is the easiest and best way to access both OpenGL and
OpenGL ES extensions and modern versions of the core OpenGL or OpenGL ES APIs. OpenGL ES extensions and modern versions of the core OpenGL or OpenGL ES APIs.
@ -169,9 +167,9 @@ both GLFW and glad, but loaders for OpenGL ES, as well as loaders for specific
API versions and extension sets can be generated. The generated files are API versions and extension sets can be generated. The generated files are
written to the `output` directory. written to the `output` directory.
@code{.sh} ```sh
python main.py --generator c --no-loader --out-path output python main.py --generator c --no-loader --out-path output
@endcode ```
The `--no-loader` option is added because GLFW already provides a function for The `--no-loader` option is added because GLFW already provides a function for
loading OpenGL and OpenGL ES function pointers, one that automatically uses the loading OpenGL and OpenGL ES function pointers, one that automatically uses the
@ -185,14 +183,14 @@ include the glad header file, which will replace the OpenGL header of your
development environment. By including the glad header before the GLFW header, development environment. By including the glad header before the GLFW header,
it suppresses the development environment's OpenGL or OpenGL ES header. it suppresses the development environment's OpenGL or OpenGL ES header.
@code ```c
#include <glad/glad.h> #include <glad/glad.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
Finally, you need to initialize glad once you have a suitable current context. Finally, you need to initialize glad once you have a suitable current context.
@code ```c
window = glfwCreateWindow(640, 480, "My Window", NULL, NULL); window = glfwCreateWindow(640, 480, "My Window", NULL, NULL);
if (!window) if (!window)
{ {
@ -202,7 +200,7 @@ if (!window)
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
@endcode ```
Once glad has been loaded, you have access to all OpenGL core and extension Once glad has been loaded, you have access to all OpenGL core and extension
functions supported by both the context you created and the glad loader you functions supported by both the context you created and the glad loader you
@ -215,25 +213,25 @@ check the actual OpenGL or OpenGL ES version with
a specific version is supported by the current context with the a specific version is supported by the current context with the
`GLAD_GL_VERSION_x_x` booleans. `GLAD_GL_VERSION_x_x` booleans.
@code ```c
if (GLAD_GL_VERSION_3_2) if (GLAD_GL_VERSION_3_2)
{ {
// Call OpenGL 3.2+ specific code // Call OpenGL 3.2+ specific code
} }
@endcode ```
To check whether a specific extension is supported, use the `GLAD_GL_xxx` To check whether a specific extension is supported, use the `GLAD_GL_xxx`
booleans. booleans.
@code ```c
if (GLAD_GL_ARB_gl_spirv) if (GLAD_GL_ARB_gl_spirv)
{ {
// Use GL_ARB_gl_spirv // Use GL_ARB_gl_spirv
} }
@endcode ```
@subsection context_glext_manual Loading extensions manually ### Loading extensions manually {#context_glext_manual}
__Do not use this technique__ unless it is absolutely necessary. An __Do not use this technique__ unless it is absolutely necessary. An
[extension loader library](@ref context_glext_auto) will save you a ton of [extension loader library](@ref context_glext_auto) will save you a ton of
@ -248,7 +246,7 @@ This section will demonstrate manual loading of OpenGL extensions. The loading
of OpenGL ES extensions is identical except for the name of the extension header. of OpenGL ES extensions is identical except for the name of the extension header.
@subsubsection context_glext_header The glext.h header #### The glext.h header {#context_glext_header}
The `glext.h` extension header is a continually updated file that defines the The `glext.h` extension header is a continually updated file that defines the
interfaces for all OpenGL extensions. The latest version of this can always be interfaces for all OpenGL extensions. The latest version of this can always be
@ -267,41 +265,41 @@ to function) and `PROC` (procedure) are added to the ends.
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
the GLFW header. the GLFW header.
@code ```c
#define GLFW_INCLUDE_GLEXT #define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
@subsubsection context_glext_string Checking for extensions #### Checking for extensions {#context_glext_string}
A given machine may not actually support the extension (it may have older A given machine may not actually support the extension (it may have older
drivers or a graphics card that lacks the necessary hardware features), so it drivers or a graphics card that lacks the necessary hardware features), so it
is necessary to check at run-time whether the context supports the extension. is necessary to check at run-time whether the context supports the extension.
This is done with @ref glfwExtensionSupported. This is done with @ref glfwExtensionSupported.
@code ```c
if (glfwExtensionSupported("GL_ARB_gl_spirv")) if (glfwExtensionSupported("GL_ARB_gl_spirv"))
{ {
// The extension is supported by the current context // The extension is supported by the current context
} }
@endcode ```
The argument is a null terminated ASCII string with the extension name. If the The argument is a null terminated ASCII string with the extension name. If the
extension is supported, @ref glfwExtensionSupported returns `GLFW_TRUE`, extension is supported, @ref glfwExtensionSupported returns `GLFW_TRUE`,
otherwise it returns `GLFW_FALSE`. otherwise it returns `GLFW_FALSE`.
@subsubsection context_glext_proc Fetching function pointers #### Fetching function pointers {#context_glext_proc}
Many extensions, though not all, require the use of new OpenGL functions. Many extensions, though not all, require the use of new OpenGL functions.
These functions often do not have entry points in the client API libraries of These functions often do not have entry points in the client API libraries of
your operating system, making it necessary to fetch them at run time. You can your operating system, making it necessary to fetch them at run time. You can
retrieve pointers to these functions with @ref glfwGetProcAddress. retrieve pointers to these functions with @ref glfwGetProcAddress.
@code ```c
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB"); PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB");
@endcode ```
In general, you should avoid giving the function pointer variables the (exact) In general, you should avoid giving the function pointer variables the (exact)
same name as the function, as this may confuse your linker. Instead, you can same name as the function, as this may confuse your linker. Instead, you can
@ -310,7 +308,7 @@ use a different prefix, like above, or some other naming scheme.
Now that all the pieces have been introduced, here is what they might look like Now that all the pieces have been introduced, here is what they might look like
when used together. when used together.
@code ```c
#define GLFW_INCLUDE_GLEXT #define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@ -338,6 +336,5 @@ void some_function(void)
glSpecializeShaderARB(...); glSpecializeShaderARB(...);
} }
} }
@endcode ```
*/

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AA8EA,2GAA4G,CAC3G,UAAU,CAAC,IAAI,CACf,WAAW,CAAC,IAAI,CAGjB,wBAAyB,CACxB,YAAY,CAAC,2CAAsD,CAGpE,4HAA6H,CAC5H,YAAY,CAAC,wCAAuD,CAGrE,wIAAyI,CACxI,YAAY,CAAC,wCAAuD,CAGrE,kBAAmB,CAClB,UAAU,CA9EgB,IAAa,CA+EvC,WAAW,CAAC,IAAI,CAGjB,sBAAuB,CACtB,KAAK,CAzFe,OAAa,CA0FjC,WAAW,CAAC,IAAI,CAGjB,4UAA6U,CAC5U,UAAU,CAAC,IAAI,CAGhB,kJAAmJ,CAClJ,MAAM,CAAC,IAAI,CAGZ,wHAAyH,CACxH,WAAW,CAAC,IAAI,CAGjB,qBAAsB,CACrB,UAAU,CAAC,IAAI,CAGhB,2LAA4L,CAC3L,OAAO,CAAC,CAAC,CAGV,wCAAyC,CACxC,OAAO,CAAC,IAAI,CAGb,iMAAkM,CACjM,UAAU,CApGW,OAA+B,CAuGrD,IAAK,CACJ,KAAK,CA1He,OAAa,CA6HlC,SAAU,CACN,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,aAAa,CAGzB,qDAAsD,CACrD,KAAK,CApHU,OAAa,CAqH5B,aAAa,CAAC,IAAI,CAGnB,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,WAAY,CACX,SAAS,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CACf,SAAS,CAAC,KAAK,CACf,OAAO,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,CAEb,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,SAAU,CACT,WAAW,CAAC,IAAI,CAChB,aAAa,CAAC,IAAI,CAClB,KAAK,CApKqB,IAAa,CAqKvC,SAAS,CAAC,KAAK,CACf,UAAU,CAAC,yDAAyD,CAGrE,WAAY,CACX,eAAe,CAAC,IAAI,CACpB,MAAM,CAAC,UAAU,CACjB,KAAK,CAAC,KAAK,CAGZ,wBAAyB,CACxB,KAAK,CAAC,IAAI,CAGX,mCAAoC,CACnC,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,GAAG,CACf,OAAO,CAAC,KAAK,CACb,KAAK,CAvLqB,IAAa,CA0LxC,WAAY,CACX,YAAY,CAAE,CAAC,CAGhB,6CAA8C,CAC7C,UAAU,CAAC,SAAS,CAGrB,kBAAmB,CAClB,KAAK,CAnMqB,IAAa,CAsMxC,cAAe,CACd,UAAU,CAAC,MAAM,CACjB,OAAO,CAAC,GAAG,CACX,UAAU,CAAC,GAAG,CAGf,IAAK,CACJ,UAAU,CA7MgB,IAAa,CAgNxC,SAAU,CACT,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,UAAW,CACV,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,SAAU,CACT,OAAO,CAAC,IAAI,CAGb,kBAAmB,CAClB,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,IAAI,CAGjB,UAAW,CACV,UAAU,CAAC,IAAI,CACf,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,kEAAmE,CAClE,KAAK,CApOgB,OAA+B,CAuOrD,+BAAgC,CAC/B,KAAK,CA1Pe,OAAa,CA6PlC,qCAAsC,CACrC,KAAK,CA1NoB,IAAsB,CA6NhD,wBAA2B,CAC1B,MAAM,CAAE,UAAU,CAGnB,SAAU,CACT,UAAU,CAAC,KAAK,CAGjB,uBAAwB,CACvB,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,OAAO,CAAC,MAAM,CACd,UAAU,CAAC,SAA8B,CAG1C,sDAAuD,CACtD,UAAU,CAAC,iDAAoF,CAC/F,UAAU,CAAC,mBAAuC,CAClD,WAAW,CAAC,kBAAgD,CAC5D,UAAU,CAAC,IAAI,CACf,KAAK,CAlPa,IAAe,CAqPlC,kBAAmB,CAClB,KAAK,CArPoB,IAAsB,CAsP/C,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG,CACjB,gBAAgB,CAAC,OAAiC,CAGnD,OAAQ,CACP,KAAK,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAGV,oCAAoC,CACnC,OAAQ,CACP,KAAK,CAAC,IAAI,CACV,KAAK,CAAC,OAAO,CACb,MAAM,CAAC,CAAC,EAIV,UAAW,CACV,SAAS,CAAC,MAAM,CAGjB,UAAW,CACV,YAAY,CAAC,KAAK,CAGnB,UAAW,CACV,SAAS,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CACd,eAAe,CAAC,IAAI,CAIjB,mCAAqB,CACjB,WAAW,CAAC,KAAK,CAIzB,mCAAoC,CACnC,UAAU,CAAC,oDAAgF,CAC3F,UAAU,CAAC,sBAAqC,CAChD,WAAW,CAAC,cAA8C,CAC1D,KAAK,CArTU,OAAa,CAsT5B,MAAM,CAAC,iBAAgC,CACvC,aAAa,CAAC,GAAG,CAGlB,UAAW,CACV,KAAK,CA9RkB,OAAgC,CAiSxD,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,sBAAsB,CAAC,GAAG,CAC1B,uBAAuB,CAAC,GAAG,CAC3B,aAAa,CAAC,IAAI,CAGnB,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,0BAA0B,CAAC,GAAG,CAC9B,yBAAyB,CAAC,GAAG,CAC7B,UAAU,CAAC,IAAI,CAGhB,kCAAmC,CAClC,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,+HAAgI,CAC/H,KAAK,CA/ToB,IAAsB,CAgU/C,eAAe,CAAC,IAAI,CAGrB,aAAc,CACb,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,gBAAiB,CAChB,MAAM,CAAC,GAAG,CACV,UAAU,CAAC,gEAAiH,CAG7H,mCAAoC,CAvTnC,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAwT3D,uBAAwB,CA3TvB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CA4T3D,oBAAqB,CA/TpB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAgU3D,eAAgB,CAnUf,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAoU3D,gGAAiG,CAChG,aAAa,CAAC,GAAG,CACjB,OAAO,CAAC,GAAG,CACX,WAAW,CAAC,cAAwB,CACpC,MAAM,CAAC,KAAK,CAGb,iRAAkR,CACjR,KAAK,CAAC,OAAO,CAGd,QAAS,CACR,WAAW,CAAC,OAAO,CAGpB,yBAA0B,CACzB,UAAU,CAAC,OAAa,CACxB,aAAa,CAAC,GAAG,CACjB,MAAM,CAAC,IAAI,CACX,OAAO,CAAC,GAAG,CACX,QAAQ,CAAC,IAAI,CACb,WAAW,CAAC,cAAuB,CACnC,MAAM,CAAC,KAAK,CAGb,8CAA+C,CAC9C,KAAK,CA7Ze,OAAa,CAgalC,8BAA+B,CAC9B,KAAK,CAAC,OAAiB,CAGxB,qBAAsB,CACrB,KAAK,CAAC,OAAgB,CAGvB,8CAA+C,CAC9C,KAAK,CAAC,OAA+B,CACrC,WAAW,CAAC,IAAI,CAGjB,kBAAmB,CAClB,KAAK,CAAC,OAAiB,CAGxB,IAAK,CACJ,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG", "mappings": "AA8EA,2GAA4G,CAC3G,UAAU,CAAC,IAAI,CACf,WAAW,CAAC,IAAI,CAGjB,wBAAyB,CACxB,YAAY,CAAC,2CAAsD,CAGpE,4HAA6H,CAC5H,YAAY,CAAC,wCAAuD,CAGrE,wIAAyI,CACxI,YAAY,CAAC,wCAAuD,CAGrE,kBAAmB,CAClB,UAAU,CA9EgB,IAAa,CA+EvC,WAAW,CAAC,IAAI,CAGjB,sBAAuB,CACtB,KAAK,CAzFe,OAAa,CA0FjC,WAAW,CAAC,IAAI,CAGjB,4UAA6U,CAC5U,UAAU,CAAC,IAAI,CAGhB,kJAAmJ,CAClJ,MAAM,CAAC,IAAI,CAGZ,wHAAyH,CACxH,WAAW,CAAC,IAAI,CAGjB,qBAAsB,CACrB,UAAU,CAAC,IAAI,CAGhB,2LAA4L,CAC3L,OAAO,CAAC,CAAC,CAGV,wCAAyC,CACxC,OAAO,CAAC,IAAI,CAGb,iMAAkM,CACjM,UAAU,CApGW,OAA+B,CAuGrD,IAAK,CACJ,KAAK,CA1He,OAAa,CA6HlC,SAAU,CACN,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,aAAa,CAGzB,qDAAsD,CACrD,KAAK,CApHU,OAAa,CAqH5B,aAAa,CAAC,IAAI,CAGnB,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,WAAY,CACX,SAAS,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CACf,SAAS,CAAC,KAAK,CACf,OAAO,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,CAEb,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,SAAU,CACT,WAAW,CAAC,IAAI,CAChB,aAAa,CAAC,IAAI,CAClB,KAAK,CApKqB,IAAa,CAqKvC,SAAS,CAAC,KAAK,CACf,UAAU,CAAC,yDAAyD,CAGrE,WAAY,CACX,eAAe,CAAC,IAAI,CACpB,MAAM,CAAC,UAAU,CACjB,KAAK,CAAC,KAAK,CAGZ,wBAAyB,CACxB,KAAK,CAAC,IAAI,CAGX,mCAAoC,CACnC,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,GAAG,CACf,OAAO,CAAC,KAAK,CACb,KAAK,CAvLqB,IAAa,CA0LxC,WAAY,CACX,YAAY,CAAE,CAAC,CAGhB,6CAA8C,CAC7C,UAAU,CAAC,SAAS,CAGrB,kBAAmB,CAClB,KAAK,CAnMqB,IAAa,CAsMxC,cAAe,CACd,UAAU,CAAC,MAAM,CACjB,OAAO,CAAC,GAAG,CACX,UAAU,CAAC,GAAG,CAGf,IAAK,CACJ,UAAU,CA7MgB,IAAa,CAgNxC,SAAU,CACT,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,UAAW,CACV,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,SAAU,CACT,OAAO,CAAC,IAAI,CAGb,kBAAmB,CAClB,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,IAAI,CAGjB,UAAW,CACV,UAAU,CAAC,IAAI,CACf,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,kBAAmB,CACf,aAAa,CAAE,IAAI,CAGvB,kEAAmE,CAClE,KAAK,CAxOgB,OAA+B,CA2OrD,+BAAgC,CAC/B,KAAK,CA9Pe,OAAa,CAiQlC,qCAAsC,CACrC,KAAK,CA9NoB,IAAsB,CAiOhD,wBAA2B,CAC1B,MAAM,CAAE,UAAU,CAGnB,SAAU,CACT,UAAU,CAAC,KAAK,CAGjB,uBAAwB,CACvB,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,OAAO,CAAC,MAAM,CACd,UAAU,CAAC,SAA8B,CAG1C,sDAAuD,CACtD,UAAU,CAAC,iDAAoF,CAC/F,UAAU,CAAC,mBAAuC,CAClD,WAAW,CAAC,kBAAgD,CAC5D,UAAU,CAAC,IAAI,CACf,KAAK,CAtPa,IAAe,CAyPlC,kBAAmB,CAClB,KAAK,CAzPoB,IAAsB,CA0P/C,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG,CACjB,gBAAgB,CAAC,OAAiC,CAGnD,OAAQ,CACP,KAAK,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAGV,oCAAoC,CACnC,OAAQ,CACP,KAAK,CAAC,IAAI,CACV,KAAK,CAAC,OAAO,CACb,MAAM,CAAC,CAAC,EAIV,UAAW,CACV,SAAS,CAAC,MAAM,CAGjB,UAAW,CACV,YAAY,CAAC,KAAK,CAGnB,UAAW,CACV,SAAS,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CACd,eAAe,CAAC,IAAI,CAIjB,mCAAqB,CACjB,WAAW,CAAC,KAAK,CAIzB,mCAAoC,CACnC,UAAU,CAAC,oDAAgF,CAC3F,UAAU,CAAC,sBAAqC,CAChD,WAAW,CAAC,cAA8C,CAC1D,KAAK,CAzTU,OAAa,CA0T5B,MAAM,CAAC,iBAAgC,CACvC,aAAa,CAAC,GAAG,CAGlB,UAAW,CACV,KAAK,CAlSkB,OAAgC,CAqSxD,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,sBAAsB,CAAC,GAAG,CAC1B,uBAAuB,CAAC,GAAG,CAC3B,aAAa,CAAC,IAAI,CAGnB,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,0BAA0B,CAAC,GAAG,CAC9B,yBAAyB,CAAC,GAAG,CAC7B,UAAU,CAAC,IAAI,CAGhB,kCAAmC,CAClC,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,+HAAgI,CAC/H,KAAK,CAnUoB,IAAsB,CAoU/C,eAAe,CAAC,IAAI,CAGrB,aAAc,CACb,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,gBAAiB,CAChB,MAAM,CAAC,GAAG,CACV,UAAU,CAAC,gEAAiH,CAG7H,mCAAoC,CA3TnC,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CA4T3D,uBAAwB,CA/TvB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAgU3D,oBAAqB,CAnUpB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAoU3D,eAAgB,CAvUf,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAwU3D,gGAAiG,CAChG,aAAa,CAAC,GAAG,CACjB,OAAO,CAAC,GAAG,CACX,WAAW,CAAC,cAAwB,CACpC,MAAM,CAAC,KAAK,CAGb,iRAAkR,CACjR,KAAK,CAAC,OAAO,CAGd,QAAS,CACR,WAAW,CAAC,OAAO,CAGpB,yBAA0B,CACzB,UAAU,CAAC,OAAa,CACxB,aAAa,CAAC,GAAG,CACjB,MAAM,CAAC,IAAI,CACX,OAAO,CAAC,GAAG,CACX,QAAQ,CAAC,IAAI,CACb,WAAW,CAAC,cAAuB,CACnC,MAAM,CAAC,KAAK,CAGb,8CAA+C,CAC9C,KAAK,CAjae,OAAa,CAoalC,8BAA+B,CAC9B,KAAK,CAAC,OAAiB,CAGxB,qBAAsB,CACrB,KAAK,CAAC,OAAgB,CAGvB,8CAA+C,CAC9C,KAAK,CAAC,OAA+B,CACrC,WAAW,CAAC,IAAI,CAGjB,kBAAmB,CAClB,KAAK,CAAC,OAAiB,CAGxB,IAAK,CACJ,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG",
"sources": ["extra.scss"], "sources": ["extra.scss"],
"names": [], "names": [],
"file": "extra.css" "file": "extra.css"

View File

@ -255,6 +255,10 @@ address.footer {
align-content: stretch; align-content: stretch;
} }
#main-menu a:focus {
outline-style: none;
}
#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li { #main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li {
color:$navbar-link-color; color:$navbar-link-color;
} }

View File

@ -1,8 +1,6 @@
/*! # Input guide {#input_guide}
@page input_guide Input guide [TOC]
@tableofcontents
This guide introduces the input related functions of GLFW. For details on This guide introduces the input related functions of GLFW. For details on
a specific function in this category, see the @ref input. There are also guides a specific function in this category, see the @ref input. There are also guides
@ -29,7 +27,7 @@ out all arguments provided for every event, along with time and sequence
information. information.
@section events Event processing ## Event processing {#events}
GLFW needs to poll the window system for events both to provide input to the GLFW needs to poll the window system for events both to provide input to the
application and to prove to the window system that the application hasn't locked application and to prove to the window system that the application hasn't locked
@ -42,18 +40,18 @@ There are three functions for processing pending events. @ref glfwPollEvents,
processes only those events that have already been received and then returns processes only those events that have already been received and then returns
immediately. immediately.
@code ```c
glfwPollEvents(); glfwPollEvents();
@endcode ```
This is the best choice when rendering continuously, like most games do. This is the best choice when rendering continuously, like most games do.
If you only need to update the contents of the window when you receive new If you only need to update the contents of the window when you receive new
input, @ref glfwWaitEvents is a better choice. input, @ref glfwWaitEvents is a better choice.
@code ```c
glfwWaitEvents(); glfwWaitEvents();
@endcode ```
It puts the thread to sleep until at least one event has been received and then It puts the thread to sleep until at least one event has been received and then
processes all received events. This saves a great deal of CPU cycles and is processes all received events. This saves a great deal of CPU cycles and is
@ -62,9 +60,9 @@ useful for, for example, editing tools.
If you want to wait for events but have UI elements or other tasks that need If you want to wait for events but have UI elements or other tasks that need
periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout. periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout.
@code ```c
glfwWaitEventsTimeout(0.7); glfwWaitEventsTimeout(0.7);
@endcode ```
It puts the thread to sleep until at least one event has been received, or until It puts the thread to sleep until at least one event has been received, or until
the specified number of seconds have elapsed. It then processes any received the specified number of seconds have elapsed. It then processes any received
@ -74,9 +72,9 @@ If the main thread is sleeping in @ref glfwWaitEvents, you can wake it from
another thread by posting an empty event to the event queue with @ref another thread by posting an empty event to the event queue with @ref
glfwPostEmptyEvent. glfwPostEmptyEvent.
@code ```c
glfwPostEmptyEvent(); glfwPostEmptyEvent();
@endcode ```
Do not assume that callbacks will _only_ be called in response to the above Do not assume that callbacks will _only_ be called in response to the above
functions. While it is necessary to process events in one or more of the ways functions. While it is necessary to process events in one or more of the ways
@ -91,7 +89,7 @@ a [window size callback](@ref window_size) GLFW will call it in turn with the
new size before everything returns back out of the @ref glfwSetWindowSize call. new size before everything returns back out of the @ref glfwSetWindowSize call.
@section input_keyboard Keyboard input ## Keyboard input {#input_keyboard}
GLFW divides keyboard input into two categories; key events and character GLFW divides keyboard input into two categories; key events and character
events. Key events relate to actual physical keyboard keys, whereas character events. Key events relate to actual physical keyboard keys, whereas character
@ -103,25 +101,25 @@ may not be the case on your machine, but your users are likely not all using the
same keyboard layout, input method or even operating system as you. same keyboard layout, input method or even operating system as you.
@subsection input_key Key input ### Key input {#input_key}
If you wish to be notified when a physical key is pressed or released or when it If you wish to be notified when a physical key is pressed or released or when it
repeats, set a key callback. repeats, set a key callback.
@code ```c
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(window, key_callback);
@endcode ```
The callback function receives the [keyboard key](@ref keys), platform-specific The callback function receives the [keyboard key](@ref keys), platform-specific
scancode, key action and [modifier bits](@ref mods). scancode, key action and [modifier bits](@ref mods).
@code ```c
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{ {
if (key == GLFW_KEY_E && action == GLFW_PRESS) if (key == GLFW_KEY_E && action == GLFW_PRESS)
activate_airship(); activate_airship();
} }
@endcode ```
The action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`. Events with The action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`. Events with
`GLFW_PRESS` and `GLFW_RELEASE` actions are emitted for every key press. Most `GLFW_PRESS` and `GLFW_RELEASE` actions are emitted for every key press. Most
@ -149,21 +147,21 @@ different scancodes depending on the platform but they are safe to save to disk.
You can query the scancode for any [key token](@ref keys) supported on the You can query the scancode for any [key token](@ref keys) supported on the
current platform with @ref glfwGetKeyScancode. current platform with @ref glfwGetKeyScancode.
@code ```c
const int scancode = glfwGetKeyScancode(GLFW_KEY_X); const int scancode = glfwGetKeyScancode(GLFW_KEY_X);
set_key_mapping(scancode, swap_weapons); set_key_mapping(scancode, swap_weapons);
@endcode ```
The last reported state for every physical key with a [key token](@ref keys) is The last reported state for every physical key with a [key token](@ref keys) is
also saved in per-window state arrays that can be polled with @ref glfwGetKey. also saved in per-window state arrays that can be polled with @ref glfwGetKey.
@code ```c
int state = glfwGetKey(window, GLFW_KEY_E); int state = glfwGetKey(window, GLFW_KEY_E);
if (state == GLFW_PRESS) if (state == GLFW_PRESS)
{ {
activate_airship(); activate_airship();
} }
@endcode ```
The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`. The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`.
@ -177,9 +175,9 @@ If a pressed key is released again before you poll its state, you will have
missed the key press. The recommended solution for this is to use a missed the key press. The recommended solution for this is to use a
key callback, but there is also the `GLFW_STICKY_KEYS` input mode. key callback, but there is also the `GLFW_STICKY_KEYS` input mode.
@code ```c
glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE); glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE);
@endcode ```
When sticky keys mode is enabled, the pollable state of a key will remain When sticky keys mode is enabled, the pollable state of a key will remain
`GLFW_PRESS` until the state of that key is polled with @ref glfwGetKey. Once `GLFW_PRESS` until the state of that key is polled with @ref glfwGetKey. Once
@ -190,9 +188,9 @@ the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`.
If you wish to know what the state of the Caps Lock and Num Lock keys was when If you wish to know what the state of the Caps Lock and Num Lock keys was when
input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode. input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode.
@code ```c
glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE); glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE);
@endcode ```
When this input mode is enabled, any callback that receives When this input mode is enabled, any callback that receives
[modifier bits](@ref mods) will have the @ref GLFW_MOD_CAPS_LOCK bit set if Caps [modifier bits](@ref mods) will have the @ref GLFW_MOD_CAPS_LOCK bit set if Caps
@ -203,7 +201,7 @@ The `GLFW_KEY_LAST` constant holds the highest value of any
[key token](@ref keys). [key token](@ref keys).
@subsection input_char Text input ### Text input {#input_char}
GLFW supports text input in the form of a stream of GLFW supports text input in the form of a stream of
[Unicode code points](https://en.wikipedia.org/wiki/Unicode), as produced by the [Unicode code points](https://en.wikipedia.org/wiki/Unicode), as produced by the
@ -217,30 +215,30 @@ you can treat the code point argument as native endian UTF-32.
If you wish to offer regular text input, set a character callback. If you wish to offer regular text input, set a character callback.
@code ```c
glfwSetCharCallback(window, character_callback); glfwSetCharCallback(window, character_callback);
@endcode ```
The callback function receives Unicode code points for key events that would The callback function receives Unicode code points for key events that would
have led to regular text input and generally behaves as a standard text field on have led to regular text input and generally behaves as a standard text field on
that platform. that platform.
@code ```c
void character_callback(GLFWwindow* window, unsigned int codepoint) void character_callback(GLFWwindow* window, unsigned int codepoint)
{ {
} }
@endcode ```
@subsection input_key_name Key names ### Key names {#input_key_name}
If you wish to refer to keys by name, you can query the keyboard layout If you wish to refer to keys by name, you can query the keyboard layout
dependent name of printable keys with @ref glfwGetKeyName. dependent name of printable keys with @ref glfwGetKeyName.
@code ```c
const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0); const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0);
show_tutorial_hint("Press %s to move forward", key_name); show_tutorial_hint("Press %s to move forward", key_name);
@endcode ```
This function can handle both [keys and scancodes](@ref input_key). If the This function can handle both [keys and scancodes](@ref input_key). If the
specified key is `GLFW_KEY_UNKNOWN` then the scancode is used, otherwise it is specified key is `GLFW_KEY_UNKNOWN` then the scancode is used, otherwise it is
@ -248,42 +246,42 @@ ignored. This matches the behavior of the key callback, meaning the callback
arguments can always be passed unmodified to this function. arguments can always be passed unmodified to this function.
@section input_mouse Mouse input ## Mouse input {#input_mouse}
Mouse input comes in many forms, including mouse motion, button presses and Mouse input comes in many forms, including mouse motion, button presses and
scrolling offsets. The cursor appearance can also be changed, either to scrolling offsets. The cursor appearance can also be changed, either to
a custom image or a standard cursor shape from the system theme. a custom image or a standard cursor shape from the system theme.
@subsection cursor_pos Cursor position ### Cursor position {#cursor_pos}
If you wish to be notified when the cursor moves over the window, set a cursor If you wish to be notified when the cursor moves over the window, set a cursor
position callback. position callback.
@code ```c
glfwSetCursorPosCallback(window, cursor_position_callback); glfwSetCursorPosCallback(window, cursor_position_callback);
@endcode ```
The callback functions receives the cursor position, measured in screen The callback functions receives the cursor position, measured in screen
coordinates but relative to the top-left corner of the window content area. On coordinates but relative to the top-left corner of the window content area. On
platforms that provide it, the full sub-pixel cursor position is passed on. platforms that provide it, the full sub-pixel cursor position is passed on.
@code ```c
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
{ {
} }
@endcode ```
The cursor position is also saved per-window and can be polled with @ref The cursor position is also saved per-window and can be polled with @ref
glfwGetCursorPos. glfwGetCursorPos.
@code ```c
double xpos, ypos; double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos); glfwGetCursorPos(window, &xpos, &ypos);
@endcode ```
@subsection cursor_mode Cursor mode ### Cursor mode {#cursor_mode}
@anchor GLFW_CURSOR @anchor GLFW_CURSOR
The `GLFW_CURSOR` input mode provides several cursor modes for special forms of The `GLFW_CURSOR` input mode provides several cursor modes for special forms of
@ -295,9 +293,9 @@ If you wish to implement mouse motion based camera controls or other input
schemes that require unlimited mouse movement, set the cursor mode to schemes that require unlimited mouse movement, set the cursor mode to
`GLFW_CURSOR_DISABLED`. `GLFW_CURSOR_DISABLED`.
@code ```c
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
@endcode ```
This will hide the cursor and lock it to the specified window. GLFW will then This will hide the cursor and lock it to the specified window. GLFW will then
take care of all the details of cursor re-centering and offset calculation and take care of all the details of cursor re-centering and offset calculation and
@ -311,18 +309,18 @@ other features of GLFW. It is not supported and will not work as robustly as
If you only wish the cursor to become hidden when it is over a window but still If you only wish the cursor to become hidden when it is over a window but still
want it to behave normally, set the cursor mode to `GLFW_CURSOR_HIDDEN`. want it to behave normally, set the cursor mode to `GLFW_CURSOR_HIDDEN`.
@code ```c
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
@endcode ```
This mode puts no limit on the motion of the cursor. This mode puts no limit on the motion of the cursor.
If you wish the cursor to be visible but confined to the content area of the If you wish the cursor to be visible but confined to the content area of the
window, set the cursor mode to `GLFW_CURSOR_CAPTURED`. window, set the cursor mode to `GLFW_CURSOR_CAPTURED`.
@code ```c
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
@endcode ```
The cursor will behave normally inside the content area but will not be able to The cursor will behave normally inside the content area but will not be able to
leave unless the window loses focus. leave unless the window loses focus.
@ -330,15 +328,15 @@ leave unless the window loses focus.
To exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL` To exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL`
cursor mode. cursor mode.
@code ```c
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
@endcode ```
If the cursor was disabled, this will move it back to its last visible position. If the cursor was disabled, this will move it back to its last visible position.
@anchor GLFW_RAW_MOUSE_MOTION @anchor GLFW_RAW_MOUSE_MOTION
@subsection raw_mouse_motion Raw mouse motion ### Raw mouse motion {#raw_mouse_motion}
When the cursor is disabled, raw (unscaled and unaccelerated) mouse motion can When the cursor is disabled, raw (unscaled and unaccelerated) mouse motion can
be enabled if available. be enabled if available.
@ -353,16 +351,16 @@ Call @ref glfwRawMouseMotionSupported to check if the current machine provides
raw motion and set the `GLFW_RAW_MOUSE_MOTION` input mode to enable it. It is raw motion and set the `GLFW_RAW_MOUSE_MOTION` input mode to enable it. It is
disabled by default. disabled by default.
@code ```c
if (glfwRawMouseMotionSupported()) if (glfwRawMouseMotionSupported())
glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE); glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
@endcode ```
If supported, raw mouse motion can be enabled or disabled per-window and at any If supported, raw mouse motion can be enabled or disabled per-window and at any
time but it will only be provided when the cursor is disabled. time but it will only be provided when the cursor is disabled.
@subsection cursor_object Cursor objects ### Cursor objects {#cursor_object}
GLFW supports creating both custom and system theme cursor images, encapsulated GLFW supports creating both custom and system theme cursor images, encapsulated
as @ref GLFWcursor objects. They are created with @ref glfwCreateCursor or @ref as @ref GLFWcursor objects. They are created with @ref glfwCreateCursor or @ref
@ -370,13 +368,13 @@ glfwCreateStandardCursor and destroyed with @ref glfwDestroyCursor, or @ref
glfwTerminate, if any remain. glfwTerminate, if any remain.
@subsubsection cursor_custom Custom cursor creation #### Custom cursor creation {#cursor_custom}
A custom cursor is created with @ref glfwCreateCursor, which returns a handle to A custom cursor is created with @ref glfwCreateCursor, which returns a handle to
the created cursor object. For example, this creates a 16x16 white square the created cursor object. For example, this creates a 16x16 white square
cursor with the hot-spot in the upper-left corner: cursor with the hot-spot in the upper-left corner:
@code ```c
unsigned char pixels[16 * 16 * 4]; unsigned char pixels[16 * 16 * 4];
memset(pixels, 0xff, sizeof(pixels)); memset(pixels, 0xff, sizeof(pixels));
@ -386,7 +384,7 @@ image.height = 16;
image.pixels = pixels; image.pixels = pixels;
GLFWcursor* cursor = glfwCreateCursor(&image, 0, 0); GLFWcursor* cursor = glfwCreateCursor(&image, 0, 0);
@endcode ```
If cursor creation fails, `NULL` will be returned, so it is necessary to check If cursor creation fails, `NULL` will be returned, so it is necessary to check
the return value. the return value.
@ -396,14 +394,14 @@ per channel with the red channel first. The pixels are arranged canonically as
sequential rows, starting from the top-left corner. sequential rows, starting from the top-left corner.
@subsubsection cursor_standard Standard cursor creation #### Standard cursor creation {#cursor_standard}
A cursor with a [standard shape](@ref shapes) from the current system cursor A cursor with a [standard shape](@ref shapes) from the current system cursor
theme can be created with @ref glfwCreateStandardCursor. theme can be created with @ref glfwCreateStandardCursor.
@code ```c
GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR); GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR);
@endcode ```
These cursor objects behave in the exact same way as those created with @ref These cursor objects behave in the exact same way as those created with @ref
glfwCreateCursor except that the system cursor theme provides the actual image. glfwCreateCursor except that the system cursor theme provides the actual image.
@ -412,26 +410,26 @@ A few of these shapes are not available everywhere. If a shape is unavailable,
`NULL` is returned. See @ref glfwCreateStandardCursor for details. `NULL` is returned. See @ref glfwCreateStandardCursor for details.
@subsubsection cursor_destruction Cursor destruction #### Cursor destruction {#cursor_destruction}
When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor. When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor.
@code ```c
glfwDestroyCursor(cursor); glfwDestroyCursor(cursor);
@endcode ```
Cursor destruction always succeeds. If the cursor is current for any window, Cursor destruction always succeeds. If the cursor is current for any window,
that window will revert to the default cursor. This does not affect the cursor that window will revert to the default cursor. This does not affect the cursor
mode. All remaining cursors are destroyed when @ref glfwTerminate is called. mode. All remaining cursors are destroyed when @ref glfwTerminate is called.
@subsubsection cursor_set Cursor setting #### Cursor setting {#cursor_set}
A cursor can be set as current for a window with @ref glfwSetCursor. A cursor can be set as current for a window with @ref glfwSetCursor.
@code ```c
glfwSetCursor(window, cursor); glfwSetCursor(window, cursor);
@endcode ```
Once set, the cursor image will be used as long as the system cursor is over the Once set, the cursor image will be used as long as the system cursor is over the
content area of the window and the [cursor mode](@ref cursor_mode) is set content area of the window and the [cursor mode](@ref cursor_mode) is set
@ -441,26 +439,26 @@ A single cursor may be set for any number of windows.
To revert to the default cursor, set the cursor of that window to `NULL`. To revert to the default cursor, set the cursor of that window to `NULL`.
@code ```c
glfwSetCursor(window, NULL); glfwSetCursor(window, NULL);
@endcode ```
When a cursor is destroyed, any window that has it set will revert to the When a cursor is destroyed, any window that has it set will revert to the
default cursor. This does not affect the cursor mode. default cursor. This does not affect the cursor mode.
@subsection cursor_enter Cursor enter/leave events ### Cursor enter/leave events {#cursor_enter}
If you wish to be notified when the cursor enters or leaves the content area of If you wish to be notified when the cursor enters or leaves the content area of
a window, set a cursor enter/leave callback. a window, set a cursor enter/leave callback.
@code ```c
glfwSetCursorEnterCallback(window, cursor_enter_callback); glfwSetCursorEnterCallback(window, cursor_enter_callback);
@endcode ```
The callback function receives the new classification of the cursor. The callback function receives the new classification of the cursor.
@code ```c
void cursor_enter_callback(GLFWwindow* window, int entered) void cursor_enter_callback(GLFWwindow* window, int entered)
{ {
if (entered) if (entered)
@ -472,52 +470,71 @@ void cursor_enter_callback(GLFWwindow* window, int entered)
// The cursor left the content area of the window // The cursor left the content area of the window
} }
} }
@endcode ```
You can query whether the cursor is currently inside the content area of the You can query whether the cursor is currently inside the content area of the
window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute. window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute.
@code ```c
if (glfwGetWindowAttrib(window, GLFW_HOVERED)) if (glfwGetWindowAttrib(window, GLFW_HOVERED))
{ {
highlight_interface(); highlight_interface();
} }
@endcode ```
@subsection input_mouse_button Mouse button input ### Mouse button input {#input_mouse_button}
If you wish to be notified when a mouse button is pressed or released, set If you wish to be notified when a mouse button is pressed or released, set
a mouse button callback. a mouse button callback.
@code ```c
glfwSetMouseButtonCallback(window, mouse_button_callback); glfwSetMouseButtonCallback(window, mouse_button_callback);
@endcode ```
@anchor GLFW_UNLIMITED_MOUSE_BUTTONS
To handle all mouse buttons in the callback, instead of only ones with associated
[button tokens](@ref buttons), set the @ref GLFW_UNLIMITED_MOUSE_BUTTONS
input mode.
```c
glfwSetInputMode(window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE);
```
When this input mode is enabled, GLFW doesn't limit the reported mouse buttons
to only those that have an associated button token, for compatibility with
earlier versions of GLFW, which never reported any buttons over
@ref GLFW_MOUSE_BUTTON_LAST, on which users could have relied on.
The callback function receives the [mouse button](@ref buttons), button action The callback function receives the [mouse button](@ref buttons), button action
and [modifier bits](@ref mods). and [modifier bits](@ref mods).
@code ```c
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{ {
if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS)
popup_menu(); popup_menu();
} }
@endcode ```
The mouse button is an integer that can be one of the
[mouse button tokens](@ref buttons) or, if the
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set, any other positive value.
The action is one of `GLFW_PRESS` or `GLFW_RELEASE`. The action is one of `GLFW_PRESS` or `GLFW_RELEASE`.
The last reported state for every [supported mouse button](@ref buttons) is also The last reported state for every [mouse button token](@ref buttons) is also
saved in per-window state arrays that can be polled with @ref saved in per-window state arrays that can be polled with @ref
glfwGetMouseButton. glfwGetMouseButton. This is not effected by the @ref GLFW_UNLIMITED_MOUSE_BUTTONS
input mode.
@code ```c
int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT); int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT);
if (state == GLFW_PRESS) if (state == GLFW_PRESS)
{ {
upgrade_cow(); upgrade_cow();
} }
@endcode ```
The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`. The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`.
@ -531,9 +548,9 @@ missed the button press. The recommended solution for this is to use a
mouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS` mouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS`
input mode. input mode.
@code ```c
glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GLFW_TRUE); glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GLFW_TRUE);
@endcode ```
When sticky mouse buttons mode is enabled, the pollable state of a mouse button When sticky mouse buttons mode is enabled, the pollable state of a mouse button
will remain `GLFW_PRESS` until the state of that button is polled with @ref will remain `GLFW_PRESS` until the state of that button is polled with @ref
@ -542,30 +559,30 @@ had been processed in the meantime, the state will reset to `GLFW_RELEASE`,
otherwise it will remain `GLFW_PRESS`. otherwise it will remain `GLFW_PRESS`.
The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any
[supported mouse button](@ref buttons). [mouse button token](@ref buttons).
@subsection scrolling Scroll input ### Scroll input {#scrolling}
If you wish to be notified when the user scrolls, whether with a mouse wheel or If you wish to be notified when the user scrolls, whether with a mouse wheel or
touchpad gesture, set a scroll callback. touchpad gesture, set a scroll callback.
@code ```c
glfwSetScrollCallback(window, scroll_callback); glfwSetScrollCallback(window, scroll_callback);
@endcode ```
The callback function receives two-dimensional scroll offsets. The callback function receives two-dimensional scroll offsets.
@code ```c
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{ {
} }
@endcode ```
A normal mouse wheel, being vertical, provides offsets along the Y-axis. A normal mouse wheel, being vertical, provides offsets along the Y-axis.
@section joystick Joystick input ## Joystick input {#joystick}
The joystick functions expose connected joysticks and controllers, with both The joystick functions expose connected joysticks and controllers, with both
referred to as joysticks. It supports up to sixteen joysticks, ranging from referred to as joysticks. It supports up to sixteen joysticks, ranging from
@ -573,9 +590,9 @@ referred to as joysticks. It supports up to sixteen joysticks, ranging from
`GLFW_JOYSTICK_LAST`. You can test whether a [joystick](@ref joysticks) is `GLFW_JOYSTICK_LAST`. You can test whether a [joystick](@ref joysticks) is
present with @ref glfwJoystickPresent. present with @ref glfwJoystickPresent.
@code ```c
int present = glfwJoystickPresent(GLFW_JOYSTICK_1); int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
@endcode ```
Each joystick has zero or more axes, zero or more buttons, zero or more hats, Each joystick has zero or more axes, zero or more buttons, zero or more hats,
a human-readable name, a user pointer and an SDL compatible GUID. a human-readable name, a user pointer and an SDL compatible GUID.
@ -595,30 +612,30 @@ To see all the properties of all connected joysticks in real-time, run the
`joysticks` test program. `joysticks` test program.
@subsection joystick_axis Joystick axis states ### Joystick axis states {#joystick_axis}
The positions of all axes of a joystick are returned by @ref The positions of all axes of a joystick are returned by @ref
glfwGetJoystickAxes. See the reference documentation for the lifetime of the glfwGetJoystickAxes. See the reference documentation for the lifetime of the
returned array. returned array.
@code ```c
int count; int count;
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count); const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count);
@endcode ```
Each element in the returned array is a value between -1.0 and 1.0. Each element in the returned array is a value between -1.0 and 1.0.
@subsection joystick_button Joystick button states ### Joystick button states {#joystick_button}
The states of all buttons of a joystick are returned by @ref The states of all buttons of a joystick are returned by @ref
glfwGetJoystickButtons. See the reference documentation for the lifetime of the glfwGetJoystickButtons. See the reference documentation for the lifetime of the
returned array. returned array.
@code ```c
int count; int count;
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_3, &count); const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_3, &count);
@endcode ```
Each element in the returned array is either `GLFW_PRESS` or `GLFW_RELEASE`. Each element in the returned array is either `GLFW_PRESS` or `GLFW_RELEASE`.
@ -627,15 +644,15 @@ glfwGetJoystickHats, the button array by default also includes all hats. See
the reference documentation for @ref glfwGetJoystickButtons for details. the reference documentation for @ref glfwGetJoystickButtons for details.
@subsection joystick_hat Joystick hat states ### Joystick hat states {#joystick_hat}
The states of all hats are returned by @ref glfwGetJoystickHats. See the The states of all hats are returned by @ref glfwGetJoystickHats. See the
reference documentation for the lifetime of the returned array. reference documentation for the lifetime of the returned array.
@code ```c
int count; int count;
const unsigned char* hats = glfwGetJoystickHats(GLFW_JOYSTICK_7, &count); const unsigned char* hats = glfwGetJoystickHats(GLFW_JOYSTICK_7, &count);
@endcode ```
Each element in the returned array is one of the following: Each element in the returned array is one of the following:
@ -655,34 +672,34 @@ The diagonal directions are bitwise combinations of the primary (up, right, down
and left) directions and you can test for these individually by ANDing it with and left) directions and you can test for these individually by ANDing it with
the corresponding direction. the corresponding direction.
@code ```c
if (hats[2] & GLFW_HAT_RIGHT) if (hats[2] & GLFW_HAT_RIGHT)
{ {
// State of hat 2 could be right-up, right or right-down // State of hat 2 could be right-up, right or right-down
} }
@endcode ```
For backward compatibility with earlier versions that did not have @ref For backward compatibility with earlier versions that did not have @ref
glfwGetJoystickHats, all hats are by default also included in the button array. glfwGetJoystickHats, all hats are by default also included in the button array.
See the reference documentation for @ref glfwGetJoystickButtons for details. See the reference documentation for @ref glfwGetJoystickButtons for details.
@subsection joystick_name Joystick name ### Joystick name {#joystick_name}
The human-readable, UTF-8 encoded name of a joystick is returned by @ref The human-readable, UTF-8 encoded name of a joystick is returned by @ref
glfwGetJoystickName. See the reference documentation for the lifetime of the glfwGetJoystickName. See the reference documentation for the lifetime of the
returned string. returned string.
@code ```c
const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4); const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4);
@endcode ```
Joystick names are not guaranteed to be unique. Two joysticks of the same model Joystick names are not guaranteed to be unique. Two joysticks of the same model
and make may have the same name. Only the [joystick ID](@ref joysticks) is and make may have the same name. Only the [joystick ID](@ref joysticks) is
guaranteed to be unique, and only until that joystick is disconnected. guaranteed to be unique, and only until that joystick is disconnected.
@subsection joystick_userptr Joystick user pointer ### Joystick user pointer {#joystick_userptr}
Each joystick has a user pointer that can be set with @ref Each joystick has a user pointer that can be set with @ref
glfwSetJoystickUserPointer and queried with @ref glfwGetJoystickUserPointer. glfwSetJoystickUserPointer and queried with @ref glfwGetJoystickUserPointer.
@ -693,19 +710,19 @@ terminated.
The initial value of the pointer is `NULL`. The initial value of the pointer is `NULL`.
@subsection joystick_event Joystick configuration changes ### Joystick configuration changes {#joystick_event}
If you wish to be notified when a joystick is connected or disconnected, set If you wish to be notified when a joystick is connected or disconnected, set
a joystick callback. a joystick callback.
@code ```c
glfwSetJoystickCallback(joystick_callback); glfwSetJoystickCallback(joystick_callback);
@endcode ```
The callback function receives the ID of the joystick that has been connected The callback function receives the ID of the joystick that has been connected
and disconnected and the event that occurred. and disconnected and the event that occurred.
@code ```c
void joystick_callback(int jid, int event) void joystick_callback(int jid, int event)
{ {
if (event == GLFW_CONNECTED) if (event == GLFW_CONNECTED)
@ -717,7 +734,7 @@ void joystick_callback(int jid, int event)
// The joystick was disconnected // The joystick was disconnected
} }
} }
@endcode ```
For joystick connection and disconnection events to be delivered on all For joystick connection and disconnection events to be delivered on all
platforms, you need to call one of the [event processing](@ref events) platforms, you need to call one of the [event processing](@ref events)
@ -730,15 +747,17 @@ useful values for a disconnected joystick and only before the monitor callback
returns. returns.
@subsection gamepad Gamepad input ### Gamepad input {#gamepad}
The joystick functions provide unlabeled axes, buttons and hats, with no The joystick functions provide unlabeled axes, buttons and hats, with no
indication of where they are located on the device. Their order may also vary indication of where they are located on the device. Their order may also vary
between platforms even with the same device. between platforms even with the same device.
To solve this problem the SDL community crowdsourced the To solve this problem the SDL community crowdsourced the
[SDL_GameControllerDB](https://github.com/gabomdq/SDL_GameControllerDB) project, [SDL_GameControllerDB][] project, a database of mappings from many different
a database of mappings from many different devices to an Xbox-like gamepad. devices to an Xbox-like gamepad.
[SDL_GameControllerDB]: https://github.com/gabomdq/SDL_GameControllerDB
GLFW supports this mapping format and contains a copy of the mappings GLFW supports this mapping format and contains a copy of the mappings
available at the time of release. See @ref gamepad_mapping for how to update available at the time of release. See @ref gamepad_mapping for how to update
@ -748,12 +767,12 @@ a joystick is connected or the mappings are updated.
You can check whether a joystick is both present and has a gamepad mapping with You can check whether a joystick is both present and has a gamepad mapping with
@ref glfwJoystickIsGamepad. @ref glfwJoystickIsGamepad.
@code ```c
if (glfwJoystickIsGamepad(GLFW_JOYSTICK_2)) if (glfwJoystickIsGamepad(GLFW_JOYSTICK_2))
{ {
// Use as gamepad // Use as gamepad
} }
@endcode ```
If you are only interested in gamepad input you can use this function instead of If you are only interested in gamepad input you can use this function instead of
@ref glfwJoystickPresent. @ref glfwJoystickPresent.
@ -762,13 +781,13 @@ You can query the human-readable name provided by the gamepad mapping with @ref
glfwGetGamepadName. This may or may not be the same as the glfwGetGamepadName. This may or may not be the same as the
[joystick name](@ref joystick_name). [joystick name](@ref joystick_name).
@code ```c
const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7); const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7);
@endcode ```
To retrieve the gamepad state of a joystick, call @ref glfwGetGamepadState. To retrieve the gamepad state of a joystick, call @ref glfwGetGamepadState.
@code ```c
GLFWgamepadstate state; GLFWgamepadstate state;
if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state)) if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state))
@ -780,7 +799,7 @@ if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state))
input_speed(state.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER]); input_speed(state.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER]);
} }
@endcode ```
The @ref GLFWgamepadstate struct has two arrays; one for button states and one The @ref GLFWgamepadstate struct has two arrays; one for button states and one
for axis states. The values for each button and axis are the same as for the for axis states. The values for each button and axis are the same as for the
@ -811,18 +830,17 @@ The `GLFW_GAMEPAD_BUTTON_LAST` and `GLFW_GAMEPAD_AXIS_LAST` constants equal
the largest available index for each array. the largest available index for each array.
@subsection gamepad_mapping Gamepad mappings ### Gamepad mappings {#gamepad_mapping}
GLFW contains a copy of the mappings available in GLFW contains a copy of the mappings available in [SDL_GameControllerDB][] at
[SDL_GameControllerDB](https://github.com/gabomdq/SDL_GameControllerDB) at the the time of release. Newer ones can be added at runtime with @ref
time of release. Newer ones can be added at runtime with @ref
glfwUpdateGamepadMappings. glfwUpdateGamepadMappings.
@code ```c
const char* mappings = load_file_contents("game/data/gamecontrollerdb.txt"); const char* mappings = load_file_contents("game/data/gamecontrollerdb.txt");
glfwUpdateGamepadMappings(mappings); glfwUpdateGamepadMappings(mappings);
@endcode ```
This function supports everything from single lines up to and including the This function supports everything from single lines up to and including the
unmodified contents of the whole `gamecontrollerdb.txt` file. unmodified contents of the whole `gamecontrollerdb.txt` file.
@ -882,25 +900,25 @@ one built into GLFW for Xbox controllers accessed via the XInput API on Windows.
This example has been broken into several lines to fit on the page, but real This example has been broken into several lines to fit on the page, but real
gamepad mappings must be a single line. gamepad mappings must be a single line.
@code{.unparsed} ```
78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0, 78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,
b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8, b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,
rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4, rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,
righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8, righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,
@endcode ```
@note GLFW does not yet support the output range and modifiers `+` and `-` that @note GLFW does not yet support the output range and modifiers `+` and `-` that
were recently added to SDL. The input modifiers `+`, `-` and `~` are supported were recently added to SDL. The input modifiers `+`, `-` and `~` are supported
and described above. and described above.
@section time Time input ## Time input {#time}
GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime. GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime.
@code ```c
double seconds = glfwGetTime(); double seconds = glfwGetTime();
@endcode ```
It returns the number of seconds since the library was initialized with @ref It returns the number of seconds since the library was initialized with @ref
glfwInit. The platform-specific time sources used typically have micro- or glfwInit. The platform-specific time sources used typically have micro- or
@ -908,9 +926,9 @@ nanosecond resolution.
You can modify the base time with @ref glfwSetTime. You can modify the base time with @ref glfwSetTime.
@code ```c
glfwSetTime(4.0); glfwSetTime(4.0);
@endcode ```
This sets the time to the specified time, in seconds, and it continues to count This sets the time to the specified time, in seconds, and it continues to count
from there. from there.
@ -918,32 +936,32 @@ from there.
You can also access the raw timer used to implement the functions above, You can also access the raw timer used to implement the functions above,
with @ref glfwGetTimerValue. with @ref glfwGetTimerValue.
@code ```c
uint64_t value = glfwGetTimerValue(); uint64_t value = glfwGetTimerValue();
@endcode ```
This value is in 1&nbsp;/&nbsp;frequency seconds. The frequency of the raw This value is in 1&nbsp;/&nbsp;frequency seconds. The frequency of the raw
timer varies depending on the operating system and hardware. You can query the timer varies depending on the operating system and hardware. You can query the
frequency, in Hz, with @ref glfwGetTimerFrequency. frequency, in Hz, with @ref glfwGetTimerFrequency.
@code ```c
uint64_t frequency = glfwGetTimerFrequency(); uint64_t frequency = glfwGetTimerFrequency();
@endcode ```
@section clipboard Clipboard input and output ## Clipboard input and output {#clipboard}
If the system clipboard contains a UTF-8 encoded string or if it can be If the system clipboard contains a UTF-8 encoded string or if it can be
converted to one, you can retrieve it with @ref glfwGetClipboardString. See the converted to one, you can retrieve it with @ref glfwGetClipboardString. See the
reference documentation for the lifetime of the returned string. reference documentation for the lifetime of the returned string.
@code ```c
const char* text = glfwGetClipboardString(NULL); const char* text = glfwGetClipboardString(NULL);
if (text) if (text)
{ {
insert_text(text); insert_text(text);
} }
@endcode ```
If the clipboard is empty or if its contents could not be converted, `NULL` is If the clipboard is empty or if its contents could not be converted, `NULL` is
returned. returned.
@ -951,33 +969,32 @@ returned.
The contents of the system clipboard can be set to a UTF-8 encoded string with The contents of the system clipboard can be set to a UTF-8 encoded string with
@ref glfwSetClipboardString. @ref glfwSetClipboardString.
@code ```c
glfwSetClipboardString(NULL, "A string with words in it"); glfwSetClipboardString(NULL, "A string with words in it");
@endcode ```
@section path_drop Path drop input ## Path drop input {#path_drop}
If you wish to receive the paths of files and/or directories dropped on If you wish to receive the paths of files and/or directories dropped on
a window, set a file drop callback. a window, set a file drop callback.
@code ```c
glfwSetDropCallback(window, drop_callback); glfwSetDropCallback(window, drop_callback);
@endcode ```
The callback function receives an array of paths encoded as UTF-8. The callback function receives an array of paths encoded as UTF-8.
@code ```c
void drop_callback(GLFWwindow* window, int count, const char** paths) void drop_callback(GLFWwindow* window, int count, const char** paths)
{ {
int i; int i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
handle_dropped_file(paths[i]); handle_dropped_file(paths[i]);
} }
@endcode ```
The path array and its strings are only valid until the file drop callback The path array and its strings are only valid until the file drop callback
returns, as they may have been generated specifically for that event. You need returns, as they may have been generated specifically for that event. You need
to make a deep copy of the array if you want to keep the paths. to make a deep copy of the array if you want to keep the paths.
*/

View File

@ -1,14 +1,12 @@
/*! # Internal structure {#internals_guide}
@page internals_guide Internal structure [TOC]
@tableofcontents
There are several interfaces inside GLFW. Each interface has its own area of There are several interfaces inside GLFW. Each interface has its own area of
responsibility and its own naming conventions. responsibility and its own naming conventions.
@section internals_public Public interface ## Public interface {#internals_public}
The most well-known is the public interface, described in the glfw3.h header The most well-known is the public interface, described in the glfw3.h header
file. This is implemented in source files shared by all platforms and these file. This is implemented in source files shared by all platforms and these
@ -22,7 +20,7 @@ it use headless camel case.
Examples: `glfwCreateWindow`, `GLFWwindow`, `GLFW_RED_BITS` Examples: `glfwCreateWindow`, `GLFWwindow`, `GLFW_RED_BITS`
@section internals_native Native interface ## Native interface {#internals_native}
The [native interface](@ref native) is a small set of publicly available The [native interface](@ref native) is a small set of publicly available
but platform-specific functions, described in the glfw3native.h header file and but platform-specific functions, described in the glfw3native.h header file and
@ -36,7 +34,7 @@ from.
Examples: `glfwGetX11Window`, `glfwGetWGLContext` Examples: `glfwGetX11Window`, `glfwGetWGLContext`
@section internals_internal Internal interface ## Internal interface {#internals_internal}
The internal interface consists of utility functions used by all other The internal interface consists of utility functions used by all other
interfaces. It is shared code implemented in the same shared source files as interfaces. It is shared code implemented in the same shared source files as
@ -52,7 +50,7 @@ global names have a leading underscore.
Examples: `_glfwIsValidContextConfig`, `_GLFWwindow`, `_glfw.monitorCount` Examples: `_glfwIsValidContextConfig`, `_GLFWwindow`, `_glfw.monitorCount`
@section internals_platform Platform interface ## Platform interface {#internals_platform}
The platform interface implements all platform-specific operations as a service The platform interface implements all platform-specific operations as a service
to the public interface. This includes event processing. The platform to the public interface. This includes event processing. The platform
@ -90,7 +88,7 @@ prevents shared code from accidentally using these members.
Examples: `window->win32.handle`, `_glfw.x11.display` Examples: `window->win32.handle`, `_glfw.x11.display`
@section internals_event Event interface ## Event interface {#internals_event}
The event interface is implemented in the same shared source files as the public The event interface is implemented in the same shared source files as the public
interface and is responsible for delivering the events it receives to the interface and is responsible for delivering the events it receives to the
@ -102,7 +100,7 @@ ObjectEvent pattern.
Examples: `_glfwInputWindowFocus`, `_glfwInputCursorPos` Examples: `_glfwInputWindowFocus`, `_glfwInputCursorPos`
@section internals_static Static functions ## Static functions {#internals_static}
Static functions may be used by any interface and have no prefixes or suffixes. Static functions may be used by any interface and have no prefixes or suffixes.
These use headless camel case. These use headless camel case.
@ -110,7 +108,7 @@ These use headless camel case.
Examples: `isValidElementForJoystick` Examples: `isValidElementForJoystick`
@section internals_config Configuration macros ## Configuration macros {#internals_config}
GLFW uses a number of configuration macros to select at compile time which GLFW uses a number of configuration macros to select at compile time which
interfaces and code paths to use. They are defined in the GLFW CMake target. interfaces and code paths to use. They are defined in the GLFW CMake target.
@ -120,4 +118,3 @@ with a leading underscore.
Examples: `_GLFW_WIN32`, `_GLFW_BUILD_DLL` Examples: `_GLFW_WIN32`, `_GLFW_BUILD_DLL`
*/

View File

@ -1,8 +1,6 @@
/*! # Introduction to the API {#intro_guide}
@page intro_guide Introduction to the API [TOC]
@tableofcontents
This guide introduces the basic concepts of GLFW and describes initialization, This guide introduces the basic concepts of GLFW and describes initialization,
error handling and API guarantees and limitations. For a broad but shallow error handling and API guarantees and limitations. For a broad but shallow
@ -18,7 +16,7 @@ There are also guides for the other areas of GLFW.
- @ref input_guide - @ref input_guide
@section intro_init Initialization and termination ## Initialization and termination {#intro_init}
Before most GLFW functions may be called, the library must be initialized. Before most GLFW functions may be called, the library must be initialized.
This initialization checks what features are available on the machine, This initialization checks what features are available on the machine,
@ -43,17 +41,17 @@ Calling any other function before successful initialization will cause a @ref
GLFW_NOT_INITIALIZED error. GLFW_NOT_INITIALIZED error.
@subsection intro_init_init Initializing GLFW ### Initializing GLFW {#intro_init_init}
The library is initialized with @ref glfwInit, which returns `GLFW_FALSE` if an The library is initialized with @ref glfwInit, which returns `GLFW_FALSE` if an
error occurred. error occurred.
@code ```c
if (!glfwInit()) if (!glfwInit())
{ {
// Handle initialization failure // Handle initialization failure
} }
@endcode ```
If any part of initialization fails, any parts that succeeded are terminated as If any part of initialization fails, any parts that succeeded are terminated as
if @ref glfwTerminate had been called. The library only needs to be initialized if @ref glfwTerminate had been called. The library only needs to be initialized
@ -71,14 +69,14 @@ main menu and dock icon can be disabled with the @ref GLFW_COCOA_MENUBAR init
hint. hint.
@subsection init_hints Initialization hints ### Initialization hints {#init_hints}
Initialization hints are set before @ref glfwInit and affect how the library Initialization hints are set before @ref glfwInit and affect how the library
behaves until termination. Hints are set with @ref glfwInitHint. behaves until termination. Hints are set with @ref glfwInitHint.
@code ```c
glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE); glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);
@endcode ```
The values you set hints to are never reset by GLFW, but they only take effect The values you set hints to are never reset by GLFW, but they only take effect
during initialization. Once GLFW has been initialized, any values you set will during initialization. Once GLFW has been initialized, any values you set will
@ -89,12 +87,12 @@ will only affect their specific platform. Other platforms will ignore them.
Setting these hints requires no platform specific headers or functions. Setting these hints requires no platform specific headers or functions.
@subsubsection init_hints_shared Shared init hints #### Shared init hints {#init_hints_shared}
@anchor GLFW_PLATFORM @anchor GLFW_PLATFORM
__GLFW_PLATFORM__ specifies the platform to use for windowing and input. __GLFW_PLATFORM__ specifies the platform to use for windowing and input.
Possible values are `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, Possible values are `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`,
`GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` and `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and
`GLFW_PLATFORM_NULL`. The default value is `GLFW_ANY_PLATFORM`, which will `GLFW_PLATFORM_NULL`. The default value is `GLFW_ANY_PLATFORM`, which will
choose any platform the library includes support for except for the Null choose any platform the library includes support for except for the Null
backend. backend.
@ -107,20 +105,21 @@ glfwGetJoystickHats. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@anchor GLFW_ANGLE_PLATFORM_TYPE_hint @anchor GLFW_ANGLE_PLATFORM_TYPE_hint
__GLFW_ANGLE_PLATFORM_TYPE__ specifies the platform type (rendering backend) to __GLFW_ANGLE_PLATFORM_TYPE__ specifies the platform type (rendering backend) to
request when using OpenGL ES and EGL via request when using OpenGL ES and EGL via [ANGLE][]. If the requested platform
[ANGLE](https://chromium.googlesource.com/angle/angle/). If the requested type is unavailable, ANGLE will use its default. Possible values are one of
platform type is unavailable, ANGLE will use its default. Possible values are `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`,
one of `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`,
`GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`,
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and
`GLFW_ANGLE_PLATFORM_TYPE_METAL`. `GLFW_ANGLE_PLATFORM_TYPE_METAL`.
[ANGLE]: https://chromium.googlesource.com/angle/angle/
The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle` The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle`
extension. This extension is not used if this hint is extension. This extension is not used if this hint is
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value. `GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value.
@subsubsection init_hints_osx macOS specific init hints #### macOS specific init hints {#init_hints_osx}
@anchor GLFW_COCOA_CHDIR_RESOURCES_hint @anchor GLFW_COCOA_CHDIR_RESOURCES_hint
__GLFW_COCOA_CHDIR_RESOURCES__ specifies whether to set the current directory to __GLFW_COCOA_CHDIR_RESOURCES__ specifies whether to set the current directory to
@ -135,7 +134,17 @@ a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
This is ignored on other platforms. This is ignored on other platforms.
@subsubsection init_hints_x11 X11 specific init hints #### Wayland specific init hints {#init_hints_wayland}
@anchor GLFW_WAYLAND_LIBDECOR_hint
__GLFW_WAYLAND_LIBDECOR__ specifies whether to use [libdecor][] for window
decorations where available. Possible values are `GLFW_WAYLAND_PREFER_LIBDECOR`
and `GLFW_WAYLAND_DISABLE_LIBDECOR`. This is ignored on other platforms.
[libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor
#### X11 specific init hints {#init_hints_x11}
@anchor GLFW_X11_XCB_VULKAN_SURFACE_hint @anchor GLFW_X11_XCB_VULKAN_SURFACE_hint
__GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the __GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the
@ -144,76 +153,67 @@ the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
`GLFW_FALSE`. This is ignored on other platforms. `GLFW_FALSE`. This is ignored on other platforms.
@subsubsection init_hints_wayland Wayland specific init hints #### Supported and default values {#init_hints_values}
@anchor GLFW_WAYLAND_LIBDECOR_hint
__GLFW_WAYLAND_LIBDECOR__ specifies whether to use
[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor) for window
decorations where available. Possible values are `GLFW_WAYLAND_PREFER_LIBDECOR`
and `GLFW_WAYLAND_DISABLE_LIBDECOR`. This is ignored on other platforms.
@subsubsection init_hints_values Supported and default values
Initialization hint | Default value | Supported values Initialization hint | Default value | Supported values
-------------------------------- | ------------------------------- | ---------------- -------------------------------- | ------------------------------- | ----------------
@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` or `GLFW_PLATFORM_NULL` @ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL` @ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_WAYLAND_LIBDECOR | `GLFW_WAYLAND_PREFER_LIBDECOR` | `GLFW_WAYLAND_PREFER_LIBDECOR` or `GLFW_WAYLAND_DISABLE_LIBDECOR` @ref GLFW_WAYLAND_LIBDECOR | `GLFW_WAYLAND_PREFER_LIBDECOR` | `GLFW_WAYLAND_PREFER_LIBDECOR` or `GLFW_WAYLAND_DISABLE_LIBDECOR`
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@subsection platform Runtime platform selection ### Runtime platform selection {#platform}
GLFW can be compiled for more than one platform (window system) at once. This lets GLFW can be compiled for more than one platform (window system) at once. This lets
a single library binary support both X11 and Wayland on Linux and other Unix-like systems. a single library binary support both Wayland and X11 on Linux and other Unix-like systems.
You can control platform selection via the @ref GLFW_PLATFORM initialization hint. By You can control platform selection via the @ref GLFW_PLATFORM initialization hint. By
default, this is set to @ref GLFW_ANY_PLATFORM, which will look for supported window default, this is set to @ref GLFW_ANY_PLATFORM, which will look for supported window
systems in order of priority and select the first one it finds. It can also be set to any systems in order of priority and select the first one it finds. It can also be set to any
specific platform to have GLFW only look for that one. specific platform to have GLFW only look for that one.
@code ```c
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11); glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11);
@endcode ```
This mechanism also provides the Null platform, which is always supported but needs to be This mechanism also provides the Null platform, which is always supported but needs to be
explicitly requested. This platform is effectively a stub, emulating a window system on explicitly requested. This platform is effectively a stub, emulating a window system on
a single 1080p monitor, but will not interact with any actual window system. a single 1080p monitor, but will not interact with any actual window system.
@code ```c
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL); glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL);
@endcode ```
You can test whether a library binary was compiled with support for a specific platform You can test whether a library binary was compiled with support for a specific platform
with @ref glfwPlatformSupported. with @ref glfwPlatformSupported.
@code ```c
if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND))
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND); glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
@endcode ```
Once GLFW has been initialized, you can query which platform was selected with @ref Once GLFW has been initialized, you can query which platform was selected with @ref
glfwGetPlatform. glfwGetPlatform.
@code ```c
int platform = glfwGetPlatform(); int platform = glfwGetPlatform();
@endcode ```
If you are using any [native access functions](@ref native), especially on Linux and other If you are using any [native access functions](@ref native), especially on Linux and other
Unix-like systems, then you may need to check that you are calling the ones matching the Unix-like systems, then you may need to check that you are calling the ones matching the
selected platform. selected platform.
@subsection init_allocator Custom heap memory allocator ### Custom heap memory allocator {#init_allocator}
The heap memory allocator can be customized before initialization with @ref The heap memory allocator can be customized before initialization with @ref
glfwInitAllocator. glfwInitAllocator.
@code ```c
GLFWallocator allocator; GLFWallocator allocator;
allocator.allocate = my_malloc; allocator.allocate = my_malloc;
allocator.reallocate = my_realloc; allocator.reallocate = my_realloc;
@ -221,11 +221,11 @@ allocator.deallocate = my_free;
allocator.user = NULL; allocator.user = NULL;
glfwInitAllocator(&allocator); glfwInitAllocator(&allocator);
@endcode ```
The allocator will be picked up at the beginning of initialization and will be The allocator will be made active at the beginning of initialization and will be used by
used until GLFW has been fully terminated. Any allocator set after GLFW until the library has been fully terminated. Any allocator set after initialization
initialization will be picked up only at the next initialization. will be picked up only at the next initialization.
The allocator will only be used for allocations that would have been made with The allocator will only be used for allocations that would have been made with
the C standard library. Memory allocations that must be made with platform the C standard library. Memory allocations that must be made with platform
@ -235,45 +235,54 @@ The allocation function must have a signature matching @ref GLFWallocatefun. It
the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and
returns the address to the allocated memory block. returns the address to the allocated memory block.
@code ```c
void* my_malloc(size_t size, void* user) void* my_malloc(size_t size, void* user)
{ {
... ...
} }
@endcode ```
The documentation for @ref GLFWallocatefun also lists the requirements and limitations for
an allocation function. If the active one does not meet all of these, GLFW may fail.
The reallocation function must have a function signature matching @ref GLFWreallocatefun. The reallocation function must have a function signature matching @ref GLFWreallocatefun.
It receives the memory block to be reallocated, the new desired size, in bytes, and the user It receives the memory block to be reallocated, the new desired size, in bytes, and the user
pointer passed to @ref glfwInitAllocator and returns the address to the resized memory pointer passed to @ref glfwInitAllocator and returns the address to the resized memory
block. block.
@code ```c
void* my_realloc(void* block, size_t size, void* user) void* my_realloc(void* block, size_t size, void* user)
{ {
... ...
} }
@endcode ```
The documentation for @ref GLFWreallocatefun also lists the requirements and limitations
for a reallocation function. If the active one does not meet all of these, GLFW may fail.
The deallocation function must have a function signature matching @ref GLFWdeallocatefun. The deallocation function must have a function signature matching @ref GLFWdeallocatefun.
It receives the memory block to be deallocated and the user pointer passed to @ref It receives the memory block to be deallocated and the user pointer passed to @ref
glfwInitAllocator. glfwInitAllocator.
@code ```c
void my_free(void* block, void* user) void my_free(void* block, void* user)
{ {
... ...
} }
@endcode ```
The documentation for @ref GLFWdeallocatefun also lists the requirements and limitations
for a deallocation function. If the active one does not meet all of these, GLFW may fail.
@subsection intro_init_terminate Terminating GLFW ### Terminating GLFW {#intro_init_terminate}
Before your application exits, you should terminate the GLFW library if it has Before your application exits, you should terminate the GLFW library if it has
been initialized. This is done with @ref glfwTerminate. been initialized. This is done with @ref glfwTerminate.
@code ```c
glfwTerminate(); glfwTerminate();
@endcode ```
This will destroy any remaining window, monitor and cursor objects, restore any This will destroy any remaining window, monitor and cursor objects, restore any
modified gamma ramps, re-enable the screensaver if it had been disabled and free modified gamma ramps, re-enable the screensaver if it had been disabled and free
@ -285,7 +294,7 @@ library was not initialized or had already been terminated, it returns
immediately. immediately.
@section error_handling Error handling ## Error handling {#error_handling}
Some GLFW functions have return values that indicate an error, but this is often Some GLFW functions have return values that indicate an error, but this is often
not very helpful when trying to figure out what happened or why it occurred. not very helpful when trying to figure out what happened or why it occurred.
@ -296,12 +305,12 @@ values.
The last [error code](@ref errors) for the calling thread can be queried at any The last [error code](@ref errors) for the calling thread can be queried at any
time with @ref glfwGetError. time with @ref glfwGetError.
@code ```c
int code = glfwGetError(NULL); int code = glfwGetError(NULL);
if (code != GLFW_NO_ERROR) if (code != GLFW_NO_ERROR)
handle_error(code); handle_error(code);
@endcode ```
If no error has occurred since the last call, @ref GLFW_NO_ERROR (zero) is If no error has occurred since the last call, @ref GLFW_NO_ERROR (zero) is
returned. The error is cleared before the function returns. returned. The error is cleared before the function returns.
@ -315,13 +324,13 @@ can retrieve a UTF-8 encoded human-readable description along with the error
code. If no error has occurred since the last call, the description is set to code. If no error has occurred since the last call, the description is set to
`NULL`. `NULL`.
@code ```c
const char* description; const char* description;
int code = glfwGetError(&description); int code = glfwGetError(&description);
if (description) if (description)
display_error_message(code, description); display_error_message(code, description);
@endcode ```
The retrieved description string is only valid until the next error occurs. The retrieved description string is only valid until the next error occurs.
This means you must make a copy of it if you want to keep it. This means you must make a copy of it if you want to keep it.
@ -329,19 +338,19 @@ This means you must make a copy of it if you want to keep it.
You can also set an error callback, which will be called each time an error You can also set an error callback, which will be called each time an error
occurs. It is set with @ref glfwSetErrorCallback. occurs. It is set with @ref glfwSetErrorCallback.
@code ```c
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
@endcode ```
The error callback receives the same error code and human-readable description The error callback receives the same error code and human-readable description
returned by @ref glfwGetError. returned by @ref glfwGetError.
@code ```c
void error_callback(int code, const char* description) void error_callback(int code, const char* description)
{ {
display_error_message(code, description); display_error_message(code, description);
} }
@endcode ```
The error callback is called after the error is stored, so calling @ref The error callback is called after the error is stored, so calling @ref
glfwGetError from within the error callback returns the same values as the glfwGetError from within the error callback returns the same values as the
@ -360,7 +369,7 @@ Do not rely on a currently invalid call to generate a specific error, as in the
future that same call may generate a different error or become valid. future that same call may generate a different error or become valid.
@section coordinate_systems Coordinate systems ## Coordinate systems {#coordinate_systems}
GLFW has two primary coordinate systems: the _virtual screen_ and the window GLFW has two primary coordinate systems: the _virtual screen_ and the window
_content area_ or _content area_. Both use the same unit: _virtual screen _content area_ or _content area_. Both use the same unit: _virtual screen
@ -397,7 +406,7 @@ between screen coordinates and pixels may also change at run-time depending on
which monitor the window is currently considered to be on. which monitor the window is currently considered to be on.
@section guarantees_limitations Guarantees and limitations ## Guarantees and limitations {#guarantees_limitations}
This section describes the conditions under which GLFW can be expected to This section describes the conditions under which GLFW can be expected to
function, barring bugs in the operating system or drivers. Use of GLFW outside function, barring bugs in the operating system or drivers. Use of GLFW outside
@ -406,7 +415,7 @@ time, or on some versions of GLFW, but it may break at any time and this will
not be considered a bug. not be considered a bug.
@subsection lifetime Pointer lifetimes ### Pointer lifetimes {#lifetime}
GLFW will never free any pointer you provide to it, and you must never free any GLFW will never free any pointer you provide to it, and you must never free any
pointer it provides to you. pointer it provides to you.
@ -426,7 +435,7 @@ Pointer lifetimes are guaranteed not to be shortened in future minor or patch
releases. releases.
@subsection reentrancy Reentrancy ### Reentrancy {#reentrancy}
GLFW event processing and object destruction are not reentrant. This means that GLFW event processing and object destruction are not reentrant. This means that
the following functions must not be called from any callback function: the following functions must not be called from any callback function:
@ -442,7 +451,7 @@ These functions may be made reentrant in future minor or patch releases, but
functions not on this list will not be made non-reentrant. functions not on this list will not be made non-reentrant.
@subsection thread_safety Thread safety ### Thread safety {#thread_safety}
Most GLFW functions must only be called from the main thread (the thread that Most GLFW functions must only be called from the main thread (the thread that
calls main), but some may be called from any thread once the library has been calls main), but some may be called from any thread once the library has been
@ -523,7 +532,7 @@ but functions that are currently limited to the main thread may be updated to
allow calls from any thread in future releases. allow calls from any thread in future releases.
@subsection compatibility Version compatibility ### Version compatibility {#compatibility}
GLFW uses [Semantic Versioning](https://semver.org/). This guarantees source GLFW uses [Semantic Versioning](https://semver.org/). This guarantees source
and binary backward compatibility with earlier minor versions of the API. This and binary backward compatibility with earlier minor versions of the API. This
@ -543,14 +552,14 @@ fixed in the next release. The reference documentation will also take
precedence over anything stated in a guide. precedence over anything stated in a guide.
@subsection event_order Event order ### Event order {#event_order}
The order of arrival of related events is not guaranteed to be consistent The order of arrival of related events is not guaranteed to be consistent
across platforms. The exception is synthetic key and mouse button release across platforms. The exception is synthetic key and mouse button release
events, which are always delivered after the window defocus event. events, which are always delivered after the window defocus event.
@section intro_version Version management ## Version management {#intro_version}
GLFW provides mechanisms for identifying what version of GLFW your application GLFW provides mechanisms for identifying what version of GLFW your application
was compiled against as well as what version it is currently running against. was compiled against as well as what version it is currently running against.
@ -558,33 +567,33 @@ If you are loading GLFW dynamically (not just linking dynamically), you can use
this to verify that the library binary is compatible with your application. this to verify that the library binary is compatible with your application.
@subsection intro_version_compile Compile-time version ### Compile-time version {#intro_version_compile}
The compile-time version of GLFW is provided by the GLFW header with the The compile-time version of GLFW is provided by the GLFW header with the
`GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros. `GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros.
@code ```c
printf("Compiled against GLFW %i.%i.%i\n", printf("Compiled against GLFW %i.%i.%i\n",
GLFW_VERSION_MAJOR, GLFW_VERSION_MAJOR,
GLFW_VERSION_MINOR, GLFW_VERSION_MINOR,
GLFW_VERSION_REVISION); GLFW_VERSION_REVISION);
@endcode ```
@subsection intro_version_runtime Run-time version ### Run-time version {#intro_version_runtime}
The run-time version can be retrieved with @ref glfwGetVersion, a function that The run-time version can be retrieved with @ref glfwGetVersion, a function that
may be called regardless of whether GLFW is initialized. may be called regardless of whether GLFW is initialized.
@code ```c
int major, minor, revision; int major, minor, revision;
glfwGetVersion(&major, &minor, &revision); glfwGetVersion(&major, &minor, &revision);
printf("Running against GLFW %i.%i.%i\n", major, minor, revision); printf("Running against GLFW %i.%i.%i\n", major, minor, revision);
@endcode ```
@subsection intro_version_string Version string ### Version string {#intro_version_string}
GLFW 3 also provides a compile-time generated version string that describes the GLFW 3 also provides a compile-time generated version string that describes the
version, platform, compiler and any platform-specific compile-time options. version, platform, compiler and any platform-specific compile-time options.
@ -612,18 +621,17 @@ The format of the string is as follows:
- The names of the always supported context creation APIs EGL and OSMesa - The names of the always supported context creation APIs EGL and OSMesa
- Any additional compile-time options, APIs and (on Windows) what compiler was used - Any additional compile-time options, APIs and (on Windows) what compiler was used
For example, compiling GLFW 3.4 with MinGW as a DLL for Windows, may result in a version string For example, compiling GLFW 3.5 with MinGW as a DLL for Windows, may result in a version string
like this: like this:
@code ```c
3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL 3.5.0 Win32 WGL Null EGL OSMesa MinGW DLL
@endcode ```
Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may
result in a version string like this: result in a version string like this:
@code ```c
3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic 3.5.0 Wayland X11 GLX Null EGL OSMesa monotonic
@endcode ```
*/

View File

@ -1,14 +1,10 @@
/*! # Introduction {#mainpage}
@mainpage notitle
@section main_intro Introduction
GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and
Vulkan application development. It provides a simple, platform-independent API Vulkan application development. It provides a simple, platform-independent API
for creating windows, contexts and surfaces, reading input, handling events, etc. for creating windows, contexts and surfaces, reading input, handling events, etc.
@ref news_34 list new features, caveats and deprecations. @ref news list new features, caveats and deprecations.
@ref quick_guide is a guide for users new to GLFW. It takes you through how to @ref quick_guide is a guide for users new to GLFW. It takes you through how to
write a small but complete program. write a small but complete program.
@ -33,9 +29,6 @@ use the new API.
There is a section on @ref guarantees_limitations for pointer lifetimes, There is a section on @ref guarantees_limitations for pointer lifetimes,
reentrancy, thread safety, event order and backward and forward compatibility. reentrancy, thread safety, event order and backward and forward compatibility.
The [FAQ](https://www.glfw.org/faq.html) answers many common questions about the
design, implementation and use of GLFW.
Finally, @ref compat_guide explains what APIs, standards and protocols GLFW uses Finally, @ref compat_guide explains what APIs, standards and protocols GLFW uses
and what happens when they are not present on a given machine. and what happens when they are not present on a given machine.
@ -43,4 +36,3 @@ This documentation was generated with Doxygen. The sources for it are available
in both the [source distribution](https://www.glfw.org/download.html) and in both the [source distribution](https://www.glfw.org/download.html) and
[GitHub repository](https://github.com/glfw/glfw). [GitHub repository](https://github.com/glfw/glfw).
*/

View File

@ -1,8 +1,6 @@
/*! # Monitor guide {#monitor_guide}
@page monitor_guide Monitor guide [TOC]
@tableofcontents
This guide introduces the monitor related functions of GLFW. For details on This guide introduces the monitor related functions of GLFW. For details on
a specific function in this category, see the @ref monitor. There are also a specific function in this category, see the @ref monitor. There are also
@ -15,7 +13,7 @@ guides for the other areas of GLFW.
- @ref input_guide - @ref input_guide
@section monitor_object Monitor objects ## Monitor objects {#monitor_object}
A monitor object represents a currently connected monitor and is represented as A monitor object represents a currently connected monitor and is represented as
a pointer to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type a pointer to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type
@ -36,42 +34,42 @@ To see how GLFW views your monitor setup and its available video modes, run the
`monitors` test program. `monitors` test program.
@subsection monitor_monitors Retrieving monitors ### Retrieving monitors {#monitor_monitors}
The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's
preferred monitor and is usually the one with global UI elements like task bar preferred monitor and is usually the one with global UI elements like task bar
or menu bar. or menu bar.
@code ```c
GLFWmonitor* primary = glfwGetPrimaryMonitor(); GLFWmonitor* primary = glfwGetPrimaryMonitor();
@endcode ```
You can retrieve all currently connected monitors with @ref glfwGetMonitors. You can retrieve all currently connected monitors with @ref glfwGetMonitors.
See the reference documentation for the lifetime of the returned array. See the reference documentation for the lifetime of the returned array.
@code ```c
int count; int count;
GLFWmonitor** monitors = glfwGetMonitors(&count); GLFWmonitor** monitors = glfwGetMonitors(&count);
@endcode ```
The primary monitor is always the first monitor in the returned array, but other The primary monitor is always the first monitor in the returned array, but other
monitors may be moved to a different index when a monitor is connected or monitors may be moved to a different index when a monitor is connected or
disconnected. disconnected.
@subsection monitor_event Monitor configuration changes ### Monitor configuration changes {#monitor_event}
If you wish to be notified when a monitor is connected or disconnected, set If you wish to be notified when a monitor is connected or disconnected, set
a monitor callback. a monitor callback.
@code ```c
glfwSetMonitorCallback(monitor_callback); glfwSetMonitorCallback(monitor_callback);
@endcode ```
The callback function receives the handle for the monitor that has been The callback function receives the handle for the monitor that has been
connected or disconnected and the event that occurred. connected or disconnected and the event that occurred.
@code ```c
void monitor_callback(GLFWmonitor* monitor, int event) void monitor_callback(GLFWmonitor* monitor, int event)
{ {
if (event == GLFW_CONNECTED) if (event == GLFW_CONNECTED)
@ -83,7 +81,7 @@ void monitor_callback(GLFWmonitor* monitor, int event)
// The monitor was disconnected // The monitor was disconnected
} }
} }
@endcode ```
If a monitor is disconnected, all windows that are full screen on it will be If a monitor is disconnected, all windows that are full screen on it will be
switched to windowed mode before the callback is called. Only @ref switched to windowed mode before the callback is called. Only @ref
@ -91,14 +89,14 @@ glfwGetMonitorName and @ref glfwGetMonitorUserPointer will return useful values
for a disconnected monitor and only before the monitor callback returns. for a disconnected monitor and only before the monitor callback returns.
@section monitor_properties Monitor properties ## Monitor properties {#monitor_properties}
Each monitor has a current video mode, a list of supported video modes, Each monitor has a current video mode, a list of supported video modes,
a virtual position, a content scale, a human-readable name, a user pointer, an a virtual position, a content scale, a human-readable name, a user pointer, an
estimated physical size and a gamma ramp. estimated physical size and a gamma ramp.
@subsection monitor_modes Video modes ### Video modes {#monitor_modes}
GLFW generally does a good job selecting a suitable video mode when you create GLFW generally does a good job selecting a suitable video mode when you create
a full screen window, change its video mode or make a windowed one full a full screen window, change its video mode or make a windowed one full
@ -109,101 +107,93 @@ Video modes are represented as @ref GLFWvidmode structures. You can get an
array of the video modes supported by a monitor with @ref glfwGetVideoModes. array of the video modes supported by a monitor with @ref glfwGetVideoModes.
See the reference documentation for the lifetime of the returned array. See the reference documentation for the lifetime of the returned array.
@code ```c
int count; int count;
GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
@endcode ```
To get the current video mode of a monitor call @ref glfwGetVideoMode. See the To get the current video mode of a monitor call @ref glfwGetVideoMode. See the
reference documentation for the lifetime of the returned pointer. reference documentation for the lifetime of the returned pointer.
@code ```c
const GLFWvidmode* mode = glfwGetVideoMode(monitor); const GLFWvidmode* mode = glfwGetVideoMode(monitor);
@endcode ```
The resolution of a video mode is specified in The resolution of a video mode is specified in
[screen coordinates](@ref coordinate_systems), not pixels. [screen coordinates](@ref coordinate_systems), not pixels.
@subsection monitor_size Physical size ### Physical size {#monitor_size}
The physical size of a monitor in millimetres, or an estimation of it, can be The physical size of a monitor in millimetres, or an estimation of it, can be
retrieved with @ref glfwGetMonitorPhysicalSize. This has no relation to its retrieved with @ref glfwGetMonitorPhysicalSize. This has no relation to its
current _resolution_, i.e. the width and height of its current current _resolution_, i.e. the width and height of its current
[video mode](@ref monitor_modes). [video mode](@ref monitor_modes).
@code ```c
int width_mm, height_mm; int width_mm, height_mm;
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm); glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
@endcode ```
While this can be used to calculate the raw DPI of a monitor, this is often not While this can be used to calculate the raw DPI of a monitor, this is often not
useful. Instead, use the [monitor content scale](@ref monitor_scale) and useful. Instead, use the [monitor content scale](@ref monitor_scale) and
[window content scale](@ref window_scale) to scale your content. [window content scale](@ref window_scale) to scale your content.
@subsection monitor_scale Content scale ### Content scale {#monitor_scale}
The content scale for a monitor can be retrieved with @ref The content scale for a monitor can be retrieved with @ref
glfwGetMonitorContentScale. glfwGetMonitorContentScale.
@code ```c
float xscale, yscale; float xscale, yscale;
glfwGetMonitorContentScale(monitor, &xscale, &yscale); glfwGetMonitorContentScale(monitor, &xscale, &yscale);
@endcode ```
The content scale is the ratio between the current DPI and the platform's For more information on what the content scale is and how to use it, see
default DPI. This is especially important for text and any UI elements. If the [window content scale](@ref window_scale).
pixel dimensions of your UI scaled by this look appropriate on your machine then
it should appear at a reasonable size on other machines regardless of their DPI
and scaling settings. This relies on the system DPI and scaling settings being
somewhat correct.
The content scale may depend on both the monitor resolution and pixel density
and on user settings. It may be very different from the raw DPI calculated from
the physical size and current resolution.
@subsection monitor_pos Virtual position ### Virtual position {#monitor_pos}
The position of the monitor on the virtual desktop, in The position of the monitor on the virtual desktop, in
[screen coordinates](@ref coordinate_systems), can be retrieved with @ref [screen coordinates](@ref coordinate_systems), can be retrieved with @ref
glfwGetMonitorPos. glfwGetMonitorPos.
@code ```c
int xpos, ypos; int xpos, ypos;
glfwGetMonitorPos(monitor, &xpos, &ypos); glfwGetMonitorPos(monitor, &xpos, &ypos);
@endcode ```
@subsection monitor_workarea Work area ### Work area {#monitor_workarea}
The area of a monitor not occupied by global task bars or menu bars is the work The area of a monitor not occupied by global task bars or menu bars is the work
area. This is specified in [screen coordinates](@ref coordinate_systems) and area. This is specified in [screen coordinates](@ref coordinate_systems) and
can be retrieved with @ref glfwGetMonitorWorkarea. can be retrieved with @ref glfwGetMonitorWorkarea.
@code ```c
int xpos, ypos, width, height; int xpos, ypos, width, height;
glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height); glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height);
@endcode ```
@subsection monitor_name Human-readable name ### Human-readable name {#monitor_name}
The human-readable, UTF-8 encoded name of a monitor is returned by @ref The human-readable, UTF-8 encoded name of a monitor is returned by @ref
glfwGetMonitorName. See the reference documentation for the lifetime of the glfwGetMonitorName. See the reference documentation for the lifetime of the
returned string. returned string.
@code ```c
const char* name = glfwGetMonitorName(monitor); const char* name = glfwGetMonitorName(monitor);
@endcode ```
Monitor names are not guaranteed to be unique. Two monitors of the same model Monitor names are not guaranteed to be unique. Two monitors of the same model
and make may have the same name. Only the monitor handle is guaranteed to be and make may have the same name. Only the monitor handle is guaranteed to be
unique, and only until that monitor is disconnected. unique, and only until that monitor is disconnected.
@subsection monitor_userptr User pointer ### User pointer {#monitor_userptr}
Each monitor has a user pointer that can be set with @ref Each monitor has a user pointer that can be set with @ref
glfwSetMonitorUserPointer and queried with @ref glfwGetMonitorUserPointer. This glfwSetMonitorUserPointer and queried with @ref glfwGetMonitorUserPointer. This
@ -214,12 +204,12 @@ terminated.
The initial value of the pointer is `NULL`. The initial value of the pointer is `NULL`.
@subsection monitor_gamma Gamma ramp ### Gamma ramp {#monitor_gamma}
The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts
a monitor handle and a pointer to a @ref GLFWgammaramp structure. a monitor handle and a pointer to a @ref GLFWgammaramp structure.
@code ```c
GLFWgammaramp ramp; GLFWgammaramp ramp;
unsigned short red[256], green[256], blue[256]; unsigned short red[256], green[256], blue[256];
@ -234,7 +224,7 @@ for (i = 0; i < ramp.size; i++)
} }
glfwSetGammaRamp(monitor, &ramp); glfwSetGammaRamp(monitor, &ramp);
@endcode ```
The gamma ramp data is copied before the function returns, so there is no need The gamma ramp data is copied before the function returns, so there is no need
to keep it around once the ramp has been set. to keep it around once the ramp has been set.
@ -245,17 +235,17 @@ ramp for that monitor.
The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. See The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. See
the reference documentation for the lifetime of the returned structure. the reference documentation for the lifetime of the returned structure.
@code ```c
const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor); const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor);
@endcode ```
If you wish to set a regular gamma ramp, you can have GLFW calculate it for you If you wish to set a regular gamma ramp, you can have GLFW calculate it for you
from the desired exponent with @ref glfwSetGamma, which in turn calls @ref from the desired exponent with @ref glfwSetGamma, which in turn calls @ref
glfwSetGammaRamp with the resulting ramp. glfwSetGammaRamp with the resulting ramp.
@code ```c
glfwSetGamma(monitor, 1.0); glfwSetGamma(monitor, 1.0);
@endcode ```
To experiment with gamma correction via the @ref glfwSetGamma function, run the To experiment with gamma correction via the @ref glfwSetGamma function, run the
`gamma` test program. `gamma` test program.
@ -265,4 +255,3 @@ hardware gamma correction, which today is typically an approximation of sRGB
gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will
produce the default (usually sRGB-like) behavior. produce the default (usually sRGB-like) behavior.
*/

View File

@ -1,8 +1,6 @@
/*! # Moving from GLFW 2 to 3 {#moving_guide}
@page moving_guide Moving from GLFW 2 to 3 [TOC]
@tableofcontents
This is a transition guide for moving from GLFW 2 to 3. It describes what has This is a transition guide for moving from GLFW 2 to 3. It describes what has
changed or been removed, but does _not_ include changed or been removed, but does _not_ include
@ -11,61 +9,64 @@ base onto the new API. For example, the new multi-monitor functions are
required to create full screen windows with GLFW 3. required to create full screen windows with GLFW 3.
@section moving_removed Changed and removed features ## Changed and removed features {#moving_removed}
@subsection moving_renamed_files Renamed library and header file ### Renamed library and header file {#moving_renamed_files}
The GLFW 3 header is named @ref glfw3.h and moved to the `GLFW` directory, to The GLFW 3 header is named @ref glfw3.h and moved to the `GLFW` directory, to
avoid collisions with the headers of other major versions. Similarly, the GLFW avoid collisions with the headers of other major versions. Similarly, the GLFW
3 library is named `glfw3,` except when it's installed as a shared library on 3 library is named `glfw3,` except when it's installed as a shared library on
Unix-like systems, where it uses the Unix-like systems, where it uses the [soname][] `libglfw.so.3`.
[soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`.
@par Old syntax [soname]: https://en.wikipedia.org/wiki/soname
@code
__Old syntax__
```c
#include <GL/glfw.h> #include <GL/glfw.h>
@endcode ```
@par New syntax __New syntax__
@code ```c
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
@subsection moving_threads Removal of threading functions ### Removal of threading functions {#moving_threads}
The threading functions have been removed, including the per-thread sleep The threading functions have been removed, including the per-thread sleep
function. They were fairly primitive, under-used, poorly integrated and took function. They were fairly primitive, under-used, poorly integrated and took
time away from the focus of GLFW (i.e. context, input and window). There are time away from the focus of GLFW (i.e. context, input and window). There are
better threading libraries available and native threading support is available better threading libraries available and native threading support is available
in both [C++11](https://en.cppreference.com/w/cpp/thread) and in both [C++11][] and [C11][], both of which are gaining traction.
[C11](https://en.cppreference.com/w/c/thread), both of which are gaining
traction. [C++11]: https://en.cppreference.com/w/cpp/thread
[C11]: https://en.cppreference.com/w/c/thread
If you wish to use the C++11 or C11 facilities but your compiler doesn't yet If you wish to use the C++11 or C11 facilities but your compiler doesn't yet
support them, see the support them, see the [TinyThread++][] and [TinyCThread][] projects created by
[TinyThread++](https://gitorious.org/tinythread/tinythreadpp) and
[TinyCThread](https://github.com/tinycthread/tinycthread) projects created by
the original author of GLFW. These libraries implement a usable subset of the the original author of GLFW. These libraries implement a usable subset of the
threading APIs in C++11 and C11, and in fact some GLFW 3 test programs use threading APIs in C++11 and C11, and in fact some GLFW 3 test programs use
TinyCThread. TinyCThread.
[TinyThread++]: https://gitorious.org/tinythread/tinythreadpp
[TinyCThread]: https://github.com/tinycthread/tinycthread
However, GLFW 3 has better support for _use from multiple threads_ than GLFW However, GLFW 3 has better support for _use from multiple threads_ than GLFW
2 had. Contexts can be made current on any thread, although only a single 2 had. Contexts can be made current on any thread, although only a single
thread at a time, and the documentation explicitly states which functions may be thread at a time, and the documentation explicitly states which functions may be
used from any thread and which must only be used from the main thread. used from any thread and which must only be used from the main thread.
@par Removed functions __Removed functions__
`glfwSleep`, `glfwCreateThread`, `glfwDestroyThread`, `glfwWaitThread`, > `glfwSleep`, `glfwCreateThread`, `glfwDestroyThread`, `glfwWaitThread`,
`glfwGetThreadID`, `glfwCreateMutex`, `glfwDestroyMutex`, `glfwLockMutex`, > `glfwGetThreadID`, `glfwCreateMutex`, `glfwDestroyMutex`, `glfwLockMutex`,
`glfwUnlockMutex`, `glfwCreateCond`, `glfwDestroyCond`, `glfwWaitCond`, > `glfwUnlockMutex`, `glfwCreateCond`, `glfwDestroyCond`, `glfwWaitCond`,
`glfwSignalCond`, `glfwBroadcastCond` and `glfwGetNumberOfProcessors`. > `glfwSignalCond`, `glfwBroadcastCond` and `glfwGetNumberOfProcessors`.
@par Removed types __Removed types__
`GLFWthreadfun` > `GLFWthreadfun`
@subsection moving_image Removal of image and texture loading ### Removal of image and texture loading {#moving_image}
The image and texture loading functions have been removed. They only supported The image and texture loading functions have been removed. They only supported
the Targa image format, making them mostly useful for beginner level examples. the Targa image format, making them mostly useful for beginner level examples.
@ -79,94 +80,97 @@ As there already are libraries doing this, it is unnecessary both to duplicate
the work and to tie the duplicate to GLFW. The resulting library would also be the work and to tie the duplicate to GLFW. The resulting library would also be
platform-independent, as both OpenGL and stdio are available wherever GLFW is. platform-independent, as both OpenGL and stdio are available wherever GLFW is.
@par Removed functions __Removed functions__
`glfwReadImage`, `glfwReadMemoryImage`, `glfwFreeImage`, `glfwLoadTexture2D`, > `glfwReadImage`, `glfwReadMemoryImage`, `glfwFreeImage`, `glfwLoadTexture2D`,
`glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`. > `glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`.
@subsection moving_stdcall Removal of GLFWCALL macro ### Removal of GLFWCALL macro {#moving_stdcall}
The `GLFWCALL` macro, which made callback functions use The `GLFWCALL` macro, which made callback functions use [\_\_stdcall][stdcall]
[__stdcall](https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows, on Windows, has been removed. GLFW is written in C, not Pascal. Removing this
has been removed. GLFW is written in C, not Pascal. Removing this macro means macro means there's one less thing for application programmers to remember, i.e.
there's one less thing for application programmers to remember, i.e. the the requirement to mark all callback functions with `GLFWCALL`. It also
requirement to mark all callback functions with `GLFWCALL`. It also simplifies simplifies the creation of DLLs and DLL link libraries, as there's no need to
the creation of DLLs and DLL link libraries, as there's no need to explicitly explicitly disable `@n` entry point suffixes.
disable `@n` entry point suffixes.
@par Old syntax [stdcall]: https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx
@code
__Old syntax__
```c
void GLFWCALL callback_function(...); void GLFWCALL callback_function(...);
@endcode ```
@par New syntax __New syntax__
@code ```c
void callback_function(...); void callback_function(...);
@endcode ```
@subsection moving_window_handles Window handle parameters ### Window handle parameters {#moving_window_handles}
Because GLFW 3 supports multiple windows, window handle parameters have been Because GLFW 3 supports multiple windows, window handle parameters have been
added to all window-related GLFW functions and callbacks. The handle of added to all window-related GLFW functions and callbacks. The handle of
a newly created window is returned by @ref glfwCreateWindow (formerly a newly created window is returned by @ref glfwCreateWindow (formerly
`glfwOpenWindow`). Window handles are pointers to the `glfwOpenWindow`). Window handles are pointers to the
[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow. [opaque][opaque-type] type @ref GLFWwindow.
@par Old syntax [opaque-type]: https://en.wikipedia.org/wiki/Opaque_data_type
@code
__Old syntax__
```c
glfwSetWindowTitle("New Window Title"); glfwSetWindowTitle("New Window Title");
@endcode ```
@par New syntax __New syntax__
@code ```c
glfwSetWindowTitle(window, "New Window Title"); glfwSetWindowTitle(window, "New Window Title");
@endcode ```
@subsection moving_monitor Explicit monitor selection ### Explicit monitor selection {#moving_monitor}
GLFW 3 provides support for multiple monitors. To request a full screen mode window, GLFW 3 provides support for multiple monitors. To request a full screen mode window,
instead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the instead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the
window to use. The @ref glfwGetPrimaryMonitor function returns the monitor that window to use. The @ref glfwGetPrimaryMonitor function returns the monitor that
GLFW 2 would have selected, but there are many other GLFW 2 would have selected, but there are many other
[monitor functions](@ref monitor_guide). Monitor handles are pointers to the [monitor functions](@ref monitor_guide). Monitor handles are pointers to the
[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor. [opaque][opaque-type] type @ref GLFWmonitor.
@par Old basic full screen __Old basic full screen__
@code ```c
glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN); glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN);
@endcode ```
@par New basic full screen __New basic full screen__
@code ```c
window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL); window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL);
@endcode ```
@note The framebuffer bit depth parameters of `glfwOpenWindow` have been turned @note The framebuffer bit depth parameters of `glfwOpenWindow` have been turned
into [window hints](@ref window_hints), but as they have been given into [window hints](@ref window_hints), but as they have been given
[sane defaults](@ref window_hints_values) you rarely need to set these hints. [sane defaults](@ref window_hints_values) you rarely need to set these hints.
@subsection moving_autopoll Removal of automatic event polling ### Removal of automatic event polling {#moving_autopoll}
GLFW 3 does not automatically poll for events in @ref glfwSwapBuffers, meaning GLFW 3 does not automatically poll for events in @ref glfwSwapBuffers, meaning
you need to call @ref glfwPollEvents or @ref glfwWaitEvents yourself. Unlike you need to call @ref glfwPollEvents or @ref glfwWaitEvents yourself. Unlike
buffer swap, which acts on a single window, the event processing functions act buffer swap, which acts on a single window, the event processing functions act
on all windows at once. on all windows at once.
@par Old basic main loop __Old basic main loop__
@code ```c
while (...) while (...)
{ {
// Process input // Process input
// Render output // Render output
glfwSwapBuffers(); glfwSwapBuffers();
} }
@endcode ```
@par New basic main loop __New basic main loop__
@code ```c
while (...) while (...)
{ {
// Process input // Process input
@ -174,10 +178,10 @@ while (...)
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }
@endcode ```
@subsection moving_context Explicit context management ### Explicit context management {#moving_context}
Each GLFW 3 window has its own OpenGL context and only you, the application Each GLFW 3 window has its own OpenGL context and only you, the application
programmer, can know which context should be current on which thread at any programmer, can know which context should be current on which thread at any
@ -187,7 +191,7 @@ This means that you need to call @ref glfwMakeContextCurrent after creating
a window before you can call any OpenGL functions. a window before you can call any OpenGL functions.
@subsection moving_hidpi Separation of window and framebuffer sizes ### Separation of window and framebuffer sizes {#moving_hidpi}
Window positions and sizes now use screen coordinates, which may not be the same Window positions and sizes now use screen coordinates, which may not be the same
as pixels on machines with high-DPI monitors. This is important as OpenGL uses as pixels on machines with high-DPI monitors. This is important as OpenGL uses
@ -197,20 +201,20 @@ been added. You can retrieve the size of the framebuffer of a window with @ref
glfwGetFramebufferSize function. A framebuffer size callback has also been glfwGetFramebufferSize function. A framebuffer size callback has also been
added, which can be set with @ref glfwSetFramebufferSizeCallback. added, which can be set with @ref glfwSetFramebufferSizeCallback.
@par Old basic viewport setup __Old basic viewport setup__
@code ```c
glfwGetWindowSize(&width, &height); glfwGetWindowSize(&width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@endcode ```
@par New basic viewport setup __New basic viewport setup__
@code ```c
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@endcode ```
@subsection moving_window_close Window closing changes ### Window closing changes {#moving_window_close}
The `GLFW_OPENED` window parameter has been removed. As long as the window has The `GLFW_OPENED` window parameter has been removed. As long as the window has
not been destroyed, whether through @ref glfwDestroyWindow or @ref not been destroyed, whether through @ref glfwDestroyWindow or @ref
@ -226,43 +230,43 @@ the window, take some other action or ignore the request.
You can query the close flag at any time with @ref glfwWindowShouldClose and set You can query the close flag at any time with @ref glfwWindowShouldClose and set
it at any time with @ref glfwSetWindowShouldClose. it at any time with @ref glfwSetWindowShouldClose.
@par Old basic main loop __Old basic main loop__
@code ```c
while (glfwGetWindowParam(GLFW_OPENED)) while (glfwGetWindowParam(GLFW_OPENED))
{ {
... ...
} }
@endcode ```
@par New basic main loop __New basic main loop__
@code ```c
while (!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window))
{ {
... ...
} }
@endcode ```
The close callback no longer returns a value. Instead, it is called after the The close callback no longer returns a value. Instead, it is called after the
close flag has been set, so it can optionally override its value, before close flag has been set, so it can optionally override its value, before
event processing completes. You may however not call @ref glfwDestroyWindow event processing completes. You may however not call @ref glfwDestroyWindow
from the close callback (or any other window related callback). from the close callback (or any other window related callback).
@par Old syntax __Old syntax__
@code ```c
int GLFWCALL window_close_callback(void); int GLFWCALL window_close_callback(void);
@endcode ```
@par New syntax __New syntax__
@code ```c
void window_close_callback(GLFWwindow* window); void window_close_callback(GLFWwindow* window);
@endcode ```
@note GLFW never clears the close flag to `GLFW_FALSE`, meaning you can use it @note GLFW never clears the close flag to `GLFW_FALSE`, meaning you can use it
for other reasons to close the window as well, for example the user choosing for other reasons to close the window as well, for example the user choosing
Quit from an in-game menu. Quit from an in-game menu.
@subsection moving_hints Persistent window hints ### Persistent window hints {#moving_hints}
The `glfwOpenWindowHint` function has been renamed to @ref glfwWindowHint. The `glfwOpenWindowHint` function has been renamed to @ref glfwWindowHint.
@ -271,7 +275,7 @@ instead retain their values until modified by @ref glfwWindowHint or @ref
glfwDefaultWindowHints, or until the library is terminated and re-initialized. glfwDefaultWindowHints, or until the library is terminated and re-initialized.
@subsection moving_video_modes Video mode enumeration ### Video mode enumeration {#moving_video_modes}
Video mode enumeration is now per-monitor. The @ref glfwGetVideoModes function Video mode enumeration is now per-monitor. The @ref glfwGetVideoModes function
now returns all available modes for a specific monitor instead of requiring you now returns all available modes for a specific monitor instead of requiring you
@ -280,7 +284,7 @@ had poorly defined behavior, has been replaced by @ref glfwGetVideoMode, which
returns the current mode of a monitor. returns the current mode of a monitor.
@subsection moving_char_up Removal of character actions ### Removal of character actions {#moving_char_up}
The action parameter of the [character callback](@ref GLFWcharfun) has been The action parameter of the [character callback](@ref GLFWcharfun) has been
removed. This was an artefact of the origin of GLFW, i.e. being developed in removed. This was an artefact of the origin of GLFW, i.e. being developed in
@ -288,18 +292,18 @@ English by a Swede. However, many keyboard layouts require more than one key to
produce characters with diacritical marks. Even the Swedish keyboard layout produce characters with diacritical marks. Even the Swedish keyboard layout
requires this for uncommon cases like ü. requires this for uncommon cases like ü.
@par Old syntax __Old syntax__
@code ```c
void GLFWCALL character_callback(int character, int action); void GLFWCALL character_callback(int character, int action);
@endcode ```
@par New syntax __New syntax__
@code ```c
void character_callback(GLFWwindow* window, int character); void character_callback(GLFWwindow* window, int character);
@endcode ```
@subsection moving_cursorpos Cursor position changes ### Cursor position changes {#moving_cursorpos}
The `glfwGetMousePos` function has been renamed to @ref glfwGetCursorPos, The `glfwGetMousePos` function has been renamed to @ref glfwGetCursorPos,
`glfwSetMousePos` to @ref glfwSetCursorPos and `glfwSetMousePosCallback` to @ref `glfwSetMousePos` to @ref glfwSetCursorPos and `glfwSetMousePosCallback` to @ref
@ -315,7 +319,7 @@ glfwSetCursorPos (formerly `glfwSetMousePos`) when that window is active.
Unless the window is active, the function fails silently. Unless the window is active, the function fails silently.
@subsection moving_wheel Wheel position replaced by scroll offsets ### Wheel position replaced by scroll offsets {#moving_wheel}
The `glfwGetMouseWheel` function has been removed. Scrolling is the input of The `glfwGetMouseWheel` function has been removed. Scrolling is the input of
offsets and has no absolute position. The mouse wheel callback has been offsets and has no absolute position. The mouse wheel callback has been
@ -323,21 +327,21 @@ replaced by a [scroll callback](@ref GLFWscrollfun) that receives
two-dimensional floating point scroll offsets. This allows you to receive two-dimensional floating point scroll offsets. This allows you to receive
precise scroll data from for example modern touchpads. precise scroll data from for example modern touchpads.
@par Old syntax __Old syntax__
@code ```c
void GLFWCALL mouse_wheel_callback(int position); void GLFWCALL mouse_wheel_callback(int position);
@endcode ```
@par New syntax __New syntax__
@code ```c
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
@endcode ```
@par Removed functions __Removed functions__
`glfwGetMouseWheel` > `glfwGetMouseWheel`
@subsection moving_repeat Key repeat action ### Key repeat action {#moving_repeat}
The `GLFW_KEY_REPEAT` enable has been removed and key repeat is always enabled The `GLFW_KEY_REPEAT` enable has been removed and key repeat is always enabled
for both keys and characters. A new key action, `GLFW_REPEAT`, has been added for both keys and characters. A new key action, `GLFW_REPEAT`, has been added
@ -346,7 +350,7 @@ from a repeat. Note that @ref glfwGetKey still returns only `GLFW_PRESS` or
`GLFW_RELEASE`. `GLFW_RELEASE`.
@subsection moving_keys Physical key input ### Physical key input {#moving_keys}
GLFW 3 key tokens map to physical keys, unlike in GLFW 2 where they mapped to GLFW 3 key tokens map to physical keys, unlike in GLFW 2 where they mapped to
the values generated by the current keyboard layout. The tokens are named the values generated by the current keyboard layout. The tokens are named
@ -366,7 +370,7 @@ having to remember whether to check for `a` or `A`, you now check for
@ref GLFW_KEY_A. @ref GLFW_KEY_A.
@subsection moving_joystick Joystick function changes ### Joystick function changes {#moving_joystick}
The `glfwGetJoystickPos` function has been renamed to @ref glfwGetJoystickAxes. The `glfwGetJoystickPos` function has been renamed to @ref glfwGetJoystickAxes.
@ -376,18 +380,19 @@ function as well as axis and button counts returned by the @ref
glfwGetJoystickAxes and @ref glfwGetJoystickButtons functions. glfwGetJoystickAxes and @ref glfwGetJoystickButtons functions.
@subsection moving_mbcs Win32 MBCS support ### Win32 MBCS support {#moving_mbcs}
The Win32 port of GLFW 3 will not compile in The Win32 port of GLFW 3 will not compile in [MBCS mode][MBCS]. However,
[MBCS mode](https://msdn.microsoft.com/en-us/library/5z097dxa.aspx). because the use of the Unicode version of the Win32 API doesn't affect the
However, because the use of the Unicode version of the Win32 API doesn't affect process as a whole, but only those windows created using it, it's perfectly
the process as a whole, but only those windows created using it, it's perfectly
possible to call MBCS functions from other parts of the same application. possible to call MBCS functions from other parts of the same application.
Therefore, even if an application using GLFW has MBCS mode code, there's no need Therefore, even if an application using GLFW has MBCS mode code, there's no need
for GLFW itself to support it. for GLFW itself to support it.
[MBCS]: https://msdn.microsoft.com/en-us/library/5z097dxa.aspx
@subsection moving_windows Support for versions of Windows older than XP
### Support for versions of Windows older than XP {#moving_windows}
All explicit support for version of Windows older than XP has been removed. All explicit support for version of Windows older than XP has been removed.
There is no code that actively prevents GLFW 3 from running on these earlier There is no code that actively prevents GLFW 3 from running on these earlier
@ -407,7 +412,7 @@ runtime checking for a number of functions that are present only on modern
version of Windows. version of Windows.
@subsection moving_syskeys Capture of system-wide hotkeys ### Capture of system-wide hotkeys {#moving_syskeys}
The ability to disable and capture system-wide hotkeys like Alt+Tab has been The ability to disable and capture system-wide hotkeys like Alt+Tab has been
removed. Modern applications, whether they're games, scientific visualisations removed. Modern applications, whether they're games, scientific visualisations
@ -415,7 +420,7 @@ or something else, are nowadays expected to be good desktop citizens and allow
these hotkeys to function even when running in full screen mode. these hotkeys to function even when running in full screen mode.
@subsection moving_terminate Automatic termination ### Automatic termination {#moving_terminate}
GLFW 3 does not register @ref glfwTerminate with `atexit` at initialization, GLFW 3 does not register @ref glfwTerminate with `atexit` at initialization,
because `exit` calls registered functions from the calling thread and while it because `exit` calls registered functions from the calling thread and while it
@ -428,37 +433,41 @@ destroys all windows not already destroyed with @ref glfwDestroyWindow,
invalidating any window handles you may still have. invalidating any window handles you may still have.
@subsection moving_glu GLU header inclusion ### GLU header inclusion {#moving_glu}
GLFW 3 does not by default include the GLU header and GLU itself has been GLFW 3 does not by default include the GLU header and GLU itself has been
deprecated by [Khronos](https://en.wikipedia.org/wiki/Khronos_Group). __New deprecated by [Khronos][]. __New projects should not use GLU__, but if you need
projects should not use GLU__, but if you need it for legacy code that it for legacy code that has been moved to GLFW 3, you can request that the GLFW
has been moved to GLFW 3, you can request that the GLFW header includes it by header includes it by defining @ref GLFW_INCLUDE_GLU before the inclusion of the
defining @ref GLFW_INCLUDE_GLU before the inclusion of the GLFW header. GLFW header.
@par Old syntax [Khronos]: https://en.wikipedia.org/wiki/Khronos_Group
@code
__Old syntax__
```c
#include <GL/glfw.h> #include <GL/glfw.h>
@endcode ```
@par New syntax __New syntax__
@code ```c
#define GLFW_INCLUDE_GLU #define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
There are many libraries that offer replacements for the functionality offered There are many libraries that offer replacements for the functionality offered
by GLU. For the matrix helper functions, see math libraries like by GLU. For the matrix helper functions, see math libraries like [GLM][] (for
[GLM](https://github.com/g-truc/glm) (for C++), C++), [linmath.h][] (for C) and others. For the tessellation functions, see for
[linmath.h](https://github.com/datenwolf/linmath.h) (for C) and others. For the example [libtess2][].
tessellation functions, see for example
[libtess2](https://github.com/memononen/libtess2). [GLM]: https://github.com/g-truc/glm
[linmath.h]: https://github.com/datenwolf/linmath.h
[libtess2]: https://github.com/memononen/libtess2
@section moving_tables Name change tables ## Name change tables {#moving_tables}
@subsection moving_renamed_functions Renamed functions ### Renamed functions {#moving_renamed_functions}
| GLFW 2 | GLFW 3 | Notes | | GLFW 2 | GLFW 3 | Notes |
| --------------------------- | ----------------------------- | ----- | | --------------------------- | ----------------------------- | ----- |
@ -478,7 +487,7 @@ tessellation functions, see for example
| `glfwGetJoystickParam` | @ref glfwJoystickPresent | The axis and button counts are provided by @ref glfwGetJoystickAxes and @ref glfwGetJoystickButtons | | `glfwGetJoystickParam` | @ref glfwJoystickPresent | The axis and button counts are provided by @ref glfwGetJoystickAxes and @ref glfwGetJoystickButtons |
@subsection moving_renamed_types Renamed types ### Renamed types {#moving_renamed_types}
| GLFW 2 | GLFW 3 | Notes | | GLFW 2 | GLFW 3 | Notes |
| ------------------- | --------------------- | | | ------------------- | --------------------- | |
@ -486,7 +495,7 @@ tessellation functions, see for example
| `GLFWmouseposfun` | @ref GLFWcursorposfun | | | `GLFWmouseposfun` | @ref GLFWcursorposfun | |
@subsection moving_renamed_tokens Renamed tokens ### Renamed tokens {#moving_renamed_tokens}
| GLFW 2 | GLFW 3 | Notes | | GLFW 2 | GLFW 3 | Notes |
| --------------------------- | ---------------------------- | ----- | | --------------------------- | ---------------------------- | ----- |
@ -510,4 +519,3 @@ tessellation functions, see for example
| `GLFW_KEY_RALT` | `GLFW_KEY_RIGHT_ALT` | | | `GLFW_KEY_RALT` | `GLFW_KEY_RIGHT_ALT` | |
| `GLFW_KEY_RSUPER` | `GLFW_KEY_RIGHT_SUPER` | | | `GLFW_KEY_RSUPER` | `GLFW_KEY_RIGHT_SUPER` | |
*/

View File

@ -1,293 +0,0 @@
/*!
@page news Release notes
@tableofcontents
@section news_34 Release notes for version 3.4
@subsection features_34 New features in version 3.4
@subsubsection runtime_platform_34 Runtime platform selection
GLFW now supports being compiled for multiple backends and selecting between
them at runtime with the @ref GLFW_PLATFORM init hint. After initialization the
selected platform can be queried with @ref glfwGetPlatform. You can check if
support for a given platform is compiled in with @ref glfwPlatformSupported.
@subsubsection standard_cursors_34 More standard cursors
GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and
@ref GLFW_RESIZE_NESW_CURSOR for diagonal resizing, @ref GLFW_RESIZE_ALL_CURSOR
for omnidirectional resizing and @ref GLFW_NOT_ALLOWED_CURSOR for showing an
action is not allowed.
Unlike the original set, these shapes may not be available everywhere and
creation will then fail with the new @ref GLFW_CURSOR_UNAVAILABLE error.
The cursors for horizontal and vertical resizing are now referred to as @ref
GLFW_RESIZE_EW_CURSOR and @ref GLFW_RESIZE_NS_CURSOR, and the pointing hand
cursor is now referred to as @ref GLFW_POINTING_HAND_CURSOR. The older names
are still available.
For more information see @ref cursor_standard.
@subsubsection mouse_passthrough_34 Mouse event passthrough
GLFW now provides the [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint)
window hint for making a window transparent to mouse input, lettings events pass
to whatever window is behind it. This can also be changed after window
creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
@subsubsection wayland_libdecor_34 Wayland libdecor decorations
GLFW now supports improved fallback window decorations via
[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor).
Support for libdecor can be toggled before GLFW is initialized with the
[GLFW_WAYLAND_LIBDECOR](@ref GLFW_WAYLAND_LIBDECOR_hint) init hint. It is
enabled by default.
@subsubsection wayland_app_id_34 Wayland app_id specification
GLFW now supports specifying the app_id for a Wayland window using the
[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string.
@subsubsection features_34_angle_backend Support for ANGLE rendering backend selection
GLFW now provides the
[GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for
requesting a specific rendering backend when using
[ANGLE](https://chromium.googlesource.com/angle/angle/) to create OpenGL ES
contexts.
@subsubsection captured_cursor_34 Captured cursor mode
GLFW now supports confining the cursor to the window content area with the @ref
GLFW_CURSOR_CAPTURED cursor mode.
For more information see @ref cursor_mode.
@subsubsection features_34_init_allocator Support for custom memory allocator
GLFW now supports plugging a custom memory allocator at initialization with @ref
glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator with
function pointers corresponding to the standard library functions `malloc`,
`realloc` and `free`.
For more information see @ref init_allocator.
@subsubsection features_34_position_hint Window hints for initial position
GLFW now provides the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints for
specifying the initial position of the window. This removes the need to create a hidden
window, move it and then show it. The default value of these hints is
`GLFW_ANY_POSITION`, which selects the previous behavior.
@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu
GLFW now provides the
[GLFW_WIN32_KEYBOARD_MENU](@ref GLFW_WIN32_KEYBOARD_MENU_hint) window hint for
enabling keyboard access to the window menu via the Alt+Space and
Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented
applications.
@subsection caveats Caveats for version 3.4
@subsubsection native_34 Multiple sets of native access functions
Because GLFW now supports runtime selection of platform (window system), a library binary
may export native access functions for multiple platforms. Starting with version 3.4 you
must not assume that GLFW is running on a platform just because it exports native access
functions for it. After initialization, you can query the selected platform with @ref
glfwGetPlatform.
@subsubsection version_string_34 Version string format has been changed
Because GLFW now supports runtime selection of platform (window system), the version
string returned by @ref glfwGetVersionString has been expanded. It now contains the names
of all APIs for all the platforms that the library binary supports.
@subsubsection joysticks_34 Joystick support is initialized on demand
The joystick part of GLFW is now initialized when first used, primarily to work
around faulty Windows drivers that cause DirectInput to take up to several
seconds to enumerate devices.
This change will usually not be observable. However, if your application waits
for events without having first called any joystick function or created any
visible windows, the wait may never unblock as GLFW may not yet have subscribed
to joystick related OS events.
To work around this, call any joystick function before waiting for events, for
example by setting a [joystick callback](@ref joystick_event).
@subsubsection wayland_alpha_34 Frambuffer may lack alpha channel on older Wayland systems
On Wayland, when creating an EGL context on a machine lacking the new
`EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be
ignored and the framebuffer will have no alpha channel. This is because some
Wayland compositors treat any buffer with an alpha channel as per-pixel
transparent.
If you want a per-pixel transparent window, see the
[GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) window
hint.
@subsubsection standalone_34 Tests and examples are disabled when built as a subproject
GLFW now does not build the tests and examples when it is added as
a subdirectory of another CMake project. To enable these, set the @ref
GLFW_BUILD_TESTS and @ref GLFW_BUILD_EXAMPLES cache variables before adding the
GLFW subdirectory.
@code{.cmake}
set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
add_subdirectory(path/to/glfw)
@endcode
@subsubsection initmenu_34 macOS main menu now created at initialization
GLFW now creates the main menu and completes the initialization of NSApplication
during initialization. Programs that do not want a main menu can disable it
with the [GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint) init hint.
@subsubsection corevideo_34 CoreVideo dependency has been removed
GLFW no longer depends on the CoreVideo framework on macOS and it no longer
needs to be specified during compilation or linking.
@subsubsection caveat_fbtransparency_34 Framebuffer transparency requires DWM transparency
GLFW no longer supports framebuffer transparency enabled via @ref
GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off
(the Transparency setting under Personalization > Window Color).
@subsubsection emptyevents_34 Empty events on X11 no longer round-trip to server
Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe
instead of sending an X11 client event to the helper window.
@subsection deprecations_34 Deprecations in version 3.4
@subsection removals_34 Removals in 3.4
@subsubsection vulkan_static_34 GLFW_VULKAN_STATIC CMake option has been removed
This option was used to compile GLFW directly linked with the Vulkan loader, instead of
using dynamic loading to get hold of `vkGetInstanceProcAddr` at initialization. This is
now done by calling the @ref glfwInitVulkanLoader function before initialization.
If you need backward compatibility, this macro can still be defined for GLFW 3.4 and will
have no effect. The call to @ref glfwInitVulkanLoader can be conditionally enabled in
your code by checking the @ref GLFW_VERSION_MAJOR and @ref GLFW_VERSION_MINOR macros.
@subsubsection osmesa_option_34 GLFW_USE_OSMESA CMake option has been removed
This option was used to compile GLFW for the Null platform. The Null platform is now
always supported. To produce a library binary that only supports this platform, the way
this CMake option used to do, you will instead need to disable the default platform for
the target OS. This means setting the @ref GLFW_BUILD_WIN32, @ref GLFW_BUILD_COCOA or
@ref GLFW_BUILD_X11 CMake option to false.
You can set all of them to false and the ones that don't apply for the target OS will be
ignored.
@subsubsection wl_shell_34 Support for the wl_shell protocol has been removed
Support for the wl_shell protocol has been removed and GLFW now only supports
the XDG-Shell protocol. If your Wayland compositor does not support XDG-Shell
then GLFW will fail to initialize.
@subsection symbols_34 New symbols in version 3.4
@subsubsection functions_34 New functions in version 3.4
- @ref glfwInitAllocator
- @ref glfwGetPlatform
- @ref glfwPlatformSupported
- @ref glfwInitVulkanLoader
@subsubsection types_34 New types in version 3.4
- @ref GLFWallocator
- @ref GLFWallocatefun
- @ref GLFWreallocatefun
- @ref GLFWdeallocatefun
@subsubsection constants_34 New constants in version 3.4
- @ref GLFW_PLATFORM
- @ref GLFW_ANY_PLATFORM
- @ref GLFW_PLATFORM_WIN32
- @ref GLFW_PLATFORM_COCOA
- @ref GLFW_PLATFORM_WAYLAND
- @ref GLFW_PLATFORM_X11
- @ref GLFW_PLATFORM_NULL
- @ref GLFW_PLATFORM_UNAVAILABLE
- @ref GLFW_POINTING_HAND_CURSOR
- @ref GLFW_RESIZE_EW_CURSOR
- @ref GLFW_RESIZE_NS_CURSOR
- @ref GLFW_RESIZE_NWSE_CURSOR
- @ref GLFW_RESIZE_NESW_CURSOR
- @ref GLFW_RESIZE_ALL_CURSOR
- @ref GLFW_MOUSE_PASSTHROUGH
- @ref GLFW_NOT_ALLOWED_CURSOR
- @ref GLFW_CURSOR_UNAVAILABLE
- @ref GLFW_WIN32_KEYBOARD_MENU
- @ref GLFW_CONTEXT_DEBUG
- @ref GLFW_FEATURE_UNAVAILABLE
- @ref GLFW_FEATURE_UNIMPLEMENTED
- @ref GLFW_ANGLE_PLATFORM_TYPE
- @ref GLFW_ANGLE_PLATFORM_TYPE_NONE
- @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGL
- @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGLES
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D9
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
- @ref GLFW_X11_XCB_VULKAN_SURFACE
- @ref GLFW_CURSOR_CAPTURED
- @ref GLFW_POSITION_X
- @ref GLFW_POSITION_Y
- @ref GLFW_ANY_POSITION
- @ref GLFW_WAYLAND_APP_ID
- @ref GLFW_WAYLAND_LIBDECOR
- @ref GLFW_WAYLAND_PREFER_LIBDECOR
- @ref GLFW_WAYLAND_DISABLE_LIBDECOR
@section news_archive Release notes for earlier versions
- [Release notes for 3.3](https://www.glfw.org/docs/3.3/news.html)
- [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html)
- [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html)
- [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html)
*/

40
docs/news.md Normal file
View File

@ -0,0 +1,40 @@
# Release notes for version 3.5 {#news}
[TOC]
## New features {#features}
### Unlimited mouse buttons {#unlimited_mouse_buttons}
GLFW now has an input mode which allows an unlimited number of mouse buttons to
be reported by the mouse buttton callback, rather than just the associated
[mouse button tokens](@ref buttons). This allows using mouse buttons with
values over 8. For compatibility with older versions, the
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
this.
## Caveats {#caveats}
## Deprecations {#deprecations}
## Removals {#removals}
## New symbols {#new_symbols}
### New functions {#new_functions}
### New types {#new_types}
### New constants {#new_constants}
- @ref GLFW_UNLIMITED_MOUSE_BUTTONS
## Release notes for earlier versions {#news_archive}
- [Release notes for 3.4](https://www.glfw.org/docs/3.4/news.html)
- [Release notes for 3.3](https://www.glfw.org/docs/3.3/news.html)
- [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html)
- [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html)
- [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html)

View File

@ -1,8 +1,6 @@
/*! # Getting started {#quick_guide}
@page quick_guide Getting started [TOC]
@tableofcontents
This guide takes you through writing a small application using GLFW 3. The This guide takes you through writing a small application using GLFW 3. The
application will create a window and OpenGL context, render a rotating triangle application will create a window and OpenGL context, render a rotating triangle
@ -14,16 +12,16 @@ have used GLFW 2 in the past, read @ref moving_guide, as some functions
behave differently in GLFW 3. behave differently in GLFW 3.
@section quick_steps Step by step ## Step by step {#quick_steps}
@subsection quick_include Including the GLFW header ### Including the GLFW header {#quick_include}
In the source files of your application where you use GLFW, you need to include In the source files of your application where you use GLFW, you need to include
its header file. its header file.
@code ```c
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
This header provides all the constants, types and function prototypes of the This header provides all the constants, types and function prototypes of the
GLFW API. GLFW API.
@ -38,51 +36,51 @@ This example uses files generated by [glad](https://gen.glad.sh/). The GLFW
header can detect most such headers if they are included first and will then not header can detect most such headers if they are included first and will then not
include the one from your development environment. include the one from your development environment.
@code ```c
#include <glad/gl.h> #include <glad/gl.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
To make sure there will be no header conflicts, you can define @ref To make sure there will be no header conflicts, you can define @ref
GLFW_INCLUDE_NONE before the GLFW header to explicitly disable inclusion of the GLFW_INCLUDE_NONE before the GLFW header to explicitly disable inclusion of the
development environment header. This also allows the two headers to be included development environment header. This also allows the two headers to be included
in any order. in any order.
@code ```c
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <glad/gl.h> #include <glad/gl.h>
@endcode ```
@subsection quick_init_term Initializing and terminating GLFW ### Initializing and terminating GLFW {#quick_init_term}
Before you can use most GLFW functions, the library must be initialized. On Before you can use most GLFW functions, the library must be initialized. On
successful initialization, `GLFW_TRUE` is returned. If an error occurred, successful initialization, `GLFW_TRUE` is returned. If an error occurred,
`GLFW_FALSE` is returned. `GLFW_FALSE` is returned.
@code ```c
if (!glfwInit()) if (!glfwInit())
{ {
// Initialization failed // Initialization failed
} }
@endcode ```
Note that `GLFW_TRUE` and `GLFW_FALSE` are and will always be one and zero. Note that `GLFW_TRUE` and `GLFW_FALSE` are and will always be one and zero.
When you are done using GLFW, typically just before the application exits, you When you are done using GLFW, typically just before the application exits, you
need to terminate GLFW. need to terminate GLFW.
@code ```c
glfwTerminate(); glfwTerminate();
@endcode ```
This destroys any remaining windows and releases any other resources allocated by This destroys any remaining windows and releases any other resources allocated by
GLFW. After this call, you must initialize GLFW again before using any GLFW GLFW. After this call, you must initialize GLFW again before using any GLFW
functions that require it. functions that require it.
@subsection quick_capture_error Setting an error callback ### Setting an error callback {#quick_capture_error}
Most events are reported through callbacks, whether it's a key being pressed, Most events are reported through callbacks, whether it's a key being pressed,
a GLFW window being moved, or an error occurring. Callbacks are C functions (or a GLFW window being moved, or an error occurring. Callbacks are C functions (or
@ -92,36 +90,36 @@ In case a GLFW function fails, an error is reported to the GLFW error callback.
You can receive these reports with an error callback. This function must have You can receive these reports with an error callback. This function must have
the signature below but may do anything permitted in other callbacks. the signature below but may do anything permitted in other callbacks.
@code ```c
void error_callback(int error, const char* description) void error_callback(int error, const char* description)
{ {
fprintf(stderr, "Error: %s\n", description); fprintf(stderr, "Error: %s\n", description);
} }
@endcode ```
Callback functions must be set, so GLFW knows to call them. The function to set Callback functions must be set, so GLFW knows to call them. The function to set
the error callback is one of the few GLFW functions that may be called before the error callback is one of the few GLFW functions that may be called before
initialization, which lets you be notified of errors both during and after initialization, which lets you be notified of errors both during and after
initialization. initialization.
@code ```c
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
@endcode ```
@subsection quick_create_window Creating a window and context ### Creating a window and context {#quick_create_window}
The window and its OpenGL context are created with a single call to @ref The window and its OpenGL context are created with a single call to @ref
glfwCreateWindow, which returns a handle to the created combined window and glfwCreateWindow, which returns a handle to the created combined window and
context object context object
@code ```c
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
if (!window) if (!window)
{ {
// Window or OpenGL context creation failed // Window or OpenGL context creation failed
} }
@endcode ```
This creates a 640 by 480 windowed mode window with an OpenGL context. If This creates a 640 by 480 windowed mode window with an OpenGL context. If
window or OpenGL context creation fails, `NULL` will be returned. You should window or OpenGL context creation fails, `NULL` will be returned. You should
@ -138,7 +136,7 @@ You can select the OpenGL profile by setting the `GLFW_OPENGL_PROFILE` hint.
This program uses the core profile as that is the only profile macOS supports This program uses the core profile as that is the only profile macOS supports
for OpenGL 3.x and 4.x. for OpenGL 3.x and 4.x.
@code ```c
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
@ -147,25 +145,25 @@ if (!window)
{ {
// Window or context creation failed // Window or context creation failed
} }
@endcode ```
When a window and context is no longer needed, destroy it. When a window and context is no longer needed, destroy it.
@code ```c
glfwDestroyWindow(window); glfwDestroyWindow(window);
@endcode ```
Once this function is called, no more events will be delivered for that window Once this function is called, no more events will be delivered for that window
and its handle becomes invalid. and its handle becomes invalid.
@subsection quick_context_current Making the OpenGL context current ### Making the OpenGL context current {#quick_context_current}
Before you can use the OpenGL API, you must have a current OpenGL context. Before you can use the OpenGL API, you must have a current OpenGL context.
@code ```c
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
@endcode ```
The context will remain current until you make another context current or until The context will remain current until you make another context current or until
the window owning the current context is destroyed. the window owning the current context is destroyed.
@ -176,12 +174,12 @@ a current context to load from. This example uses
[glad](https://github.com/Dav1dde/glad), but the same rule applies to all such [glad](https://github.com/Dav1dde/glad), but the same rule applies to all such
libraries. libraries.
@code ```c
gladLoadGL(glfwGetProcAddress); gladLoadGL(glfwGetProcAddress);
@endcode ```
@subsection quick_window_close Checking the window close flag ### Checking the window close flag {#quick_window_close}
Each window has a flag indicating whether the window should be closed. Each window has a flag indicating whether the window should be closed.
@ -191,12 +189,12 @@ Note that __the window isn't actually closed__, so you are expected to monitor
this flag and either destroy the window or give some kind of feedback to the this flag and either destroy the window or give some kind of feedback to the
user. user.
@code ```c
while (!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window))
{ {
// Keep running // Keep running
} }
@endcode ```
You can be notified when the user is attempting to close the window by setting You can be notified when the user is attempting to close the window by setting
a close callback with @ref glfwSetWindowCloseCallback. The callback will be a close callback with @ref glfwSetWindowCloseCallback. The callback will be
@ -207,41 +205,41 @@ useful if you want to interpret other kinds of input as closing the window, like
for example pressing the _Escape_ key. for example pressing the _Escape_ key.
@subsection quick_key_input Receiving input events ### Receiving input events {#quick_key_input}
Each window has a large number of callbacks that can be set to receive all the Each window has a large number of callbacks that can be set to receive all the
various kinds of events. To receive key press and release events, create a key various kinds of events. To receive key press and release events, create a key
callback function. callback function.
@code ```c
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{ {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GLFW_TRUE); glfwSetWindowShouldClose(window, GLFW_TRUE);
} }
@endcode ```
The key callback, like other window related callbacks, are set per-window. The key callback, like other window related callbacks, are set per-window.
@code ```c
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(window, key_callback);
@endcode ```
In order for event callbacks to be called when events occur, you need to process In order for event callbacks to be called when events occur, you need to process
events as described below. events as described below.
@subsection quick_render Rendering with OpenGL ### Rendering with OpenGL {#quick_render}
Once you have a current OpenGL context, you can use OpenGL normally. In this Once you have a current OpenGL context, you can use OpenGL normally. In this
tutorial, a multicolored rotating triangle will be rendered. The framebuffer tutorial, a multicolored rotating triangle will be rendered. The framebuffer
size needs to be retrieved for `glViewport`. size needs to be retrieved for `glViewport`.
@code ```c
int width, height; int width, height;
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@endcode ```
You can also set a framebuffer size callback using @ref You can also set a framebuffer size callback using @ref
glfwSetFramebufferSizeCallback and be notified when the size changes. glfwSetFramebufferSizeCallback and be notified when the size changes.
@ -258,19 +256,19 @@ These all happen to use GLFW, but OpenGL itself works the same whatever API you
use to create the window and context. use to create the window and context.
@subsection quick_timer Reading the timer ### Reading the timer {#quick_timer}
To create smooth animation, a time source is needed. GLFW provides a timer that To create smooth animation, a time source is needed. GLFW provides a timer that
returns the number of seconds since initialization. The time source used is the returns the number of seconds since initialization. The time source used is the
most accurate on each platform and generally has micro- or nanosecond most accurate on each platform and generally has micro- or nanosecond
resolution. resolution.
@code ```c
double time = glfwGetTime(); double time = glfwGetTime();
@endcode ```
@subsection quick_swap_buffers Swapping buffers ### Swapping buffers {#quick_swap_buffers}
GLFW windows by default use double buffering. That means that each window has GLFW windows by default use double buffering. That means that each window has
two rendering buffers; a front buffer and a back buffer. The front buffer is two rendering buffers; a front buffer and a back buffer. The front buffer is
@ -279,9 +277,9 @@ the one being displayed and the back buffer the one you render to.
When the entire frame has been rendered, the buffers need to be swapped with one When the entire frame has been rendered, the buffers need to be swapped with one
another, so the back buffer becomes the front buffer and vice versa. another, so the back buffer becomes the front buffer and vice versa.
@code ```c
glfwSwapBuffers(window); glfwSwapBuffers(window);
@endcode ```
The swap interval indicates how many frames to wait until swapping the buffers, The swap interval indicates how many frames to wait until swapping the buffers,
commonly known as _vsync_. By default, the swap interval is zero, meaning commonly known as _vsync_. By default, the swap interval is zero, meaning
@ -296,15 +294,15 @@ For these reasons, applications will typically want to set the swap interval to
one. It can be set to higher values, but this is usually not recommended, one. It can be set to higher values, but this is usually not recommended,
because of the input latency it leads to. because of the input latency it leads to.
@code ```c
glfwSwapInterval(1); glfwSwapInterval(1);
@endcode ```
This function acts on the current context and will fail unless a context is This function acts on the current context and will fail unless a context is
current. current.
@subsection quick_process_events Processing events ### Processing events {#quick_process_events}
GLFW needs to communicate regularly with the window system both in order to GLFW needs to communicate regularly with the window system both in order to
receive events and to show that the application hasn't locked up. Event receive events and to show that the application hasn't locked up. Event
@ -315,9 +313,9 @@ There are two methods for processing pending events; polling and waiting. This
example will use event polling, which processes only those events that have example will use event polling, which processes only those events that have
already been received and then returns immediately. already been received and then returns immediately.
@code ```c
glfwPollEvents(); glfwPollEvents();
@endcode ```
This is the best choice when rendering continually, like most games do. If This is the best choice when rendering continually, like most games do. If
instead you only need to update your rendering once you have received new input, instead you only need to update your rendering once you have received new input,
@ -327,7 +325,7 @@ all received events. This saves a great deal of CPU cycles and is useful for,
for example, many kinds of editing tools. for example, many kinds of editing tools.
@section quick_example Putting it together ## Putting it together {#quick_example}
Now that you know how to initialize GLFW, create a window and poll for Now that you know how to initialize GLFW, create a window and poll for
keyboard input, it's possible to create a small program. keyboard input, it's possible to create a small program.
@ -338,13 +336,14 @@ presses _Escape_ or closes the window.
@snippet triangle-opengl.c code @snippet triangle-opengl.c code
The program above can be found in the The program above can be found in the [source package][download] as
[source package](https://www.glfw.org/download.html) as
`examples/triangle-opengl.c` and is compiled along with all other examples when `examples/triangle-opengl.c` and is compiled along with all other examples when
you build GLFW. If you built GLFW from the source package then you already have you build GLFW. If you built GLFW from the source package then you already have
this as `triangle-opengl.exe` on Windows, `triangle-opengl` on Linux or this as `triangle-opengl.exe` on Windows, `triangle-opengl` on Linux or
`triangle-opengl.app` on macOS. `triangle-opengl.app` on macOS.
[download]: https://www.glfw.org/download.html
This tutorial used only a few of the many functions GLFW provides. There are This tutorial used only a few of the many functions GLFW provides. There are
guides for each of the areas covered by GLFW. Each guide will introduce all the guides for each of the areas covered by GLFW. Each guide will introduce all the
functions for that category. functions for that category.
@ -364,4 +363,3 @@ environment you are using and is best explained by the documentation for that
environment. To learn about the details that are specific to GLFW, see environment. To learn about the details that are specific to GLFW, see
@ref build_guide. @ref build_guide.
*/

View File

@ -1,8 +1,6 @@
/*! # Vulkan guide {#vulkan_guide}
@page vulkan_guide Vulkan guide [TOC]
@tableofcontents
This guide is intended to fill the gaps between the official [Vulkan This guide is intended to fill the gaps between the official [Vulkan
resources](https://www.khronos.org/vulkan/) and the rest of the GLFW resources](https://www.khronos.org/vulkan/) and the rest of the GLFW
@ -29,7 +27,7 @@ are also guides for the other areas of the GLFW API.
- @ref input_guide - @ref input_guide
@section vulkan_loader Finding the Vulkan loader ## Finding the Vulkan loader {#vulkan_loader}
GLFW itself does not ever need to be linked against the Vulkan loader. GLFW itself does not ever need to be linked against the Vulkan loader.
@ -45,32 +43,32 @@ you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr
glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan
entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader. entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader.
@code ```c
glfwInitVulkanLoader(vkGetInstanceProcAddr); glfwInitVulkanLoader(vkGetInstanceProcAddr);
@endcode ```
@macos To make your application be redistributable you will need to set up the application @macos To make your application be redistributable you will need to set up the application
bundle according to the LunarG SDK documentation. This is explained in more detail in the bundle according to the LunarG SDK documentation. This is explained in more detail in the
[SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html). [SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html).
@section vulkan_include Including the Vulkan header file ## Including the Vulkan header file {#vulkan_include}
To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including
the GLFW header. the GLFW header.
@code ```c
#define GLFW_INCLUDE_VULKAN #define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
If you instead want to include the Vulkan header from a custom location or use If you instead want to include the Vulkan header from a custom location or use
your own custom Vulkan header then do this before the GLFW header. your own custom Vulkan header then do this before the GLFW header.
@code ```c
#include <path/to/vulkan.h> #include <path/to/vulkan.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode ```
Unless a Vulkan header is included, either by the GLFW header or above it, the following Unless a Vulkan header is included, either by the GLFW header or above it, the following
GLFW functions will not be declared, as depend on Vulkan types. GLFW functions will not be declared, as depend on Vulkan types.
@ -84,7 +82,7 @@ The `VK_USE_PLATFORM_*_KHR` macros do not need to be defined for the Vulkan part
of GLFW to work. Define them only if you are using these extensions directly. of GLFW to work. Define them only if you are using these extensions directly.
@section vulkan_support Querying for Vulkan support ## Querying for Vulkan support {#vulkan_support}
If you are linking directly against the Vulkan loader then you can skip this If you are linking directly against the Vulkan loader then you can skip this
section. The canonical desktop loader library exports all Vulkan core and section. The canonical desktop loader library exports all Vulkan core and
@ -94,12 +92,12 @@ If you are loading the Vulkan loader dynamically instead of linking directly
against it, you can check for the availability of a loader and ICD with @ref against it, you can check for the availability of a loader and ICD with @ref
glfwVulkanSupported. glfwVulkanSupported.
@code ```c
if (glfwVulkanSupported()) if (glfwVulkanSupported())
{ {
// Vulkan is available, at least for compute // Vulkan is available, at least for compute
} }
@endcode ```
This function returns `GLFW_TRUE` if the Vulkan loader and any minimally This function returns `GLFW_TRUE` if the Vulkan loader and any minimally
functional ICD was found. functional ICD was found.
@ -108,24 +106,24 @@ If one or both were not found, calling any other Vulkan related GLFW function
will generate a @ref GLFW_API_UNAVAILABLE error. will generate a @ref GLFW_API_UNAVAILABLE error.
@subsection vulkan_proc Querying Vulkan function pointers ### Querying Vulkan function pointers {#vulkan_proc}
To load any Vulkan core or extension function from the found loader, call @ref To load any Vulkan core or extension function from the found loader, call @ref
glfwGetInstanceProcAddress. To load functions needed for instance creation, glfwGetInstanceProcAddress. To load functions needed for instance creation,
pass `NULL` as the instance. pass `NULL` as the instance.
@code ```c
PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance) PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance)
glfwGetInstanceProcAddress(NULL, "vkCreateInstance"); glfwGetInstanceProcAddress(NULL, "vkCreateInstance");
@endcode ```
Once you have created an instance, you can load from it all other Vulkan core Once you have created an instance, you can load from it all other Vulkan core
functions and functions from any instance extensions you enabled. functions and functions from any instance extensions you enabled.
@code ```c
PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice) PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice)
glfwGetInstanceProcAddress(instance, "vkCreateDevice"); glfwGetInstanceProcAddress(instance, "vkCreateDevice");
@endcode ```
This function in turn calls `vkGetInstanceProcAddr`. If that fails, the This function in turn calls `vkGetInstanceProcAddr`. If that fails, the
function falls back to a platform-specific query of the Vulkan loader (i.e. function falls back to a platform-specific query of the Vulkan loader (i.e.
@ -137,17 +135,17 @@ Vulkan also provides `vkGetDeviceProcAddr` for loading device-specific versions
of Vulkan function. This function can be retrieved from an instance with @ref of Vulkan function. This function can be retrieved from an instance with @ref
glfwGetInstanceProcAddress. glfwGetInstanceProcAddress.
@code ```c
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)
glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr"); glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr");
@endcode ```
Device-specific functions may execute a little faster, due to not having to Device-specific functions may execute a little faster, due to not having to
dispatch internally based on the device passed to them. For more information dispatch internally based on the device passed to them. For more information
about `vkGetDeviceProcAddr`, see the Vulkan documentation. about `vkGetDeviceProcAddr`, see the Vulkan documentation.
@section vulkan_ext Querying required Vulkan extensions ## Querying required Vulkan extensions {#vulkan_ext}
To do anything useful with Vulkan you need to create an instance. If you want To do anything useful with Vulkan you need to create an instance. If you want
to use Vulkan to render to a window, you must enable the instance extensions to use Vulkan to render to a window, you must enable the instance extensions
@ -156,10 +154,10 @@ GLFW requires to create Vulkan surfaces.
To query the instance extensions required, call @ref To query the instance extensions required, call @ref
glfwGetRequiredInstanceExtensions. glfwGetRequiredInstanceExtensions.
@code ```c
uint32_t count; uint32_t count;
const char** extensions = glfwGetRequiredInstanceExtensions(&count); const char** extensions = glfwGetRequiredInstanceExtensions(&count);
@endcode ```
These extensions must all be enabled when creating instances that are going to These extensions must all be enabled when creating instances that are going to
be passed to @ref glfwGetPhysicalDevicePresentationSupport and @ref be passed to @ref glfwGetPhysicalDevicePresentationSupport and @ref
@ -174,14 +172,14 @@ If successful the returned array will always include `VK_KHR_surface`, so if
you don't require any additional extensions you can pass this list directly to you don't require any additional extensions you can pass this list directly to
the `VkInstanceCreateInfo` struct. the `VkInstanceCreateInfo` struct.
@code ```c
VkInstanceCreateInfo ici; VkInstanceCreateInfo ici;
memset(&ici, 0, sizeof(ici)); memset(&ici, 0, sizeof(ici));
ici.enabledExtensionCount = count; ici.enabledExtensionCount = count;
ici.ppEnabledExtensionNames = extensions; ici.ppEnabledExtensionNames = extensions;
... ...
@endcode ```
Additional extensions may be required by future versions of GLFW. You should Additional extensions may be required by future versions of GLFW. You should
check whether any extensions you wish to enable are already in the returned check whether any extensions you wish to enable are already in the returned
@ -196,52 +194,52 @@ info flags for MoltenVK to show up in the list of physical devices. For more
information, see the Vulkan and MoltenVK documentation. information, see the Vulkan and MoltenVK documentation.
@section vulkan_present Querying for Vulkan presentation support ## Querying for Vulkan presentation support {#vulkan_present}
Not every queue family of every Vulkan device can present images to surfaces. Not every queue family of every Vulkan device can present images to surfaces.
To check whether a specific queue family of a physical device supports image To check whether a specific queue family of a physical device supports image
presentation without first having to create a window and surface, call @ref presentation without first having to create a window and surface, call @ref
glfwGetPhysicalDevicePresentationSupport. glfwGetPhysicalDevicePresentationSupport.
@code ```c
if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index)) if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index))
{ {
// Queue family supports image presentation // Queue family supports image presentation
} }
@endcode ```
The `VK_KHR_surface` extension additionally provides the The `VK_KHR_surface` extension additionally provides the
`vkGetPhysicalDeviceSurfaceSupportKHR` function, which performs the same test on `vkGetPhysicalDeviceSurfaceSupportKHR` function, which performs the same test on
an existing Vulkan surface. an existing Vulkan surface.
@section vulkan_window Creating the window ## Creating the window {#vulkan_window}
Unless you will be using OpenGL or OpenGL ES with the same window as Vulkan, Unless you will be using OpenGL or OpenGL ES with the same window as Vulkan,
there is no need to create a context. You can disable context creation with the there is no need to create a context. You can disable context creation with the
[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint. [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint.
@code ```c
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL);
@endcode ```
See @ref context_less for more information. See @ref context_less for more information.
@section vulkan_surface Creating a Vulkan window surface ## Creating a Vulkan window surface {#vulkan_surface}
You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension) You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension)
for a GLFW window with @ref glfwCreateWindowSurface. for a GLFW window with @ref glfwCreateWindowSurface.
@code ```c
VkSurfaceKHR surface; VkSurfaceKHR surface;
VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface); VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface);
if (err) if (err)
{ {
// Window surface creation failed // Window surface creation failed
} }
@endcode ```
If an OpenGL or OpenGL ES context was created on the window, the context has If an OpenGL or OpenGL ES context was created on the window, the context has
ownership of the presentation on the window and a Vulkan surface cannot be ownership of the presentation on the window and a Vulkan surface cannot be
@ -250,4 +248,3 @@ created.
It is your responsibility to destroy the surface. GLFW does not destroy it for It is your responsibility to destroy the surface. GLFW does not destroy it for
you. Call `vkDestroySurfaceKHR` function from the same extension to destroy it. you. Call `vkDestroySurfaceKHR` function from the same extension to destroy it.
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/************************************************************************* /*************************************************************************
* GLFW 3.4 - www.glfw.org * GLFW 3.5 - www.glfw.org
* A library for OpenGL, window and input * A library for OpenGL, window and input
*------------------------------------------------------------------------ *------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard * Copyright (c) 2002-2006 Marcus Geelnard
@ -291,7 +291,7 @@ extern "C" {
* features are added to the API but it remains backward-compatible. * features are added to the API but it remains backward-compatible.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_MINOR 4 #define GLFW_VERSION_MINOR 5
/*! @brief The revision number of the GLFW header. /*! @brief The revision number of the GLFW header.
* *
* The revision number of the GLFW header. This is incremented when a bug fix * The revision number of the GLFW header. This is incremented when a bug fix
@ -1098,8 +1098,15 @@ extern "C" {
* [window hint](@ref GLFW_SCALE_TO_MONITOR). * [window hint](@ref GLFW_SCALE_TO_MONITOR).
*/ */
#define GLFW_SCALE_TO_MONITOR 0x0002200C #define GLFW_SCALE_TO_MONITOR 0x0002200C
/*! @brief macOS specific /*! @brief Window framebuffer scaling
* [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint). * [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint).
*/
#define GLFW_SCALE_FRAMEBUFFER 0x0002200D
/*! @brief Legacy name for compatibility.
*
* This is an alias for the
* [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for
* compatibility with earlier versions.
*/ */
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001 #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
/*! @brief macOS specific /*! @brief macOS specific
@ -1119,6 +1126,9 @@ extern "C" {
*/ */
#define GLFW_X11_INSTANCE_NAME 0x00024002 #define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 #define GLFW_WIN32_KEYBOARD_MENU 0x00025001
/*! @brief Win32 specific [window hint](@ref GLFW_WIN32_SHOWDEFAULT_hint).
*/
#define GLFW_WIN32_SHOWDEFAULT 0x00025002
/*! @brief Wayland specific /*! @brief Wayland specific
* [window hint](@ref GLFW_WAYLAND_APP_ID_hint). * [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
* *
@ -1139,11 +1149,12 @@ extern "C" {
#define GLFW_OPENGL_CORE_PROFILE 0x00032001 #define GLFW_OPENGL_CORE_PROFILE 0x00032001
#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002 #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
#define GLFW_CURSOR 0x00033001 #define GLFW_CURSOR 0x00033001
#define GLFW_STICKY_KEYS 0x00033002 #define GLFW_STICKY_KEYS 0x00033002
#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
#define GLFW_LOCK_KEY_MODS 0x00033004 #define GLFW_LOCK_KEY_MODS 0x00033004
#define GLFW_RAW_MOUSE_MOTION 0x00033005 #define GLFW_RAW_MOUSE_MOTION 0x00033005
#define GLFW_UNLIMITED_MOUSE_BUTTONS 0x00033006
#define GLFW_CURSOR_NORMAL 0x00034001 #define GLFW_CURSOR_NORMAL 0x00034001
#define GLFW_CURSOR_HIDDEN 0x00034002 #define GLFW_CURSOR_HIDDEN 0x00034002
@ -1220,11 +1231,11 @@ extern "C" {
* @note @macos This shape is provided by a private system API and may fail * @note @macos This shape is provided by a private system API and may fail
* with @ref GLFW_CURSOR_UNAVAILABLE in the future. * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
* *
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*
* @note @wayland This shape is provided by a newer standard not supported by * @note @wayland This shape is provided by a newer standard not supported by
* all cursor themes. * all cursor themes.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*/ */
#define GLFW_RESIZE_NWSE_CURSOR 0x00036007 #define GLFW_RESIZE_NWSE_CURSOR 0x00036007
/*! @brief The top-right to bottom-left diagonal resize/move arrow shape. /*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
@ -1235,11 +1246,11 @@ extern "C" {
* @note @macos This shape is provided by a private system API and may fail * @note @macos This shape is provided by a private system API and may fail
* with @ref GLFW_CURSOR_UNAVAILABLE in the future. * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
* *
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*
* @note @wayland This shape is provided by a newer standard not supported by * @note @wayland This shape is provided by a newer standard not supported by
* all cursor themes. * all cursor themes.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*/ */
#define GLFW_RESIZE_NESW_CURSOR 0x00036008 #define GLFW_RESIZE_NESW_CURSOR 0x00036008
/*! @brief The omni-directional resize/move cursor shape. /*! @brief The omni-directional resize/move cursor shape.
@ -1253,11 +1264,11 @@ extern "C" {
* The operation-not-allowed shape. This is usually a circle with a diagonal * The operation-not-allowed shape. This is usually a circle with a diagonal
* line through it. * line through it.
* *
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*
* @note @wayland This shape is provided by a newer standard not supported by * @note @wayland This shape is provided by a newer standard not supported by
* all cursor themes. * all cursor themes.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*/ */
#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A #define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
/*! @brief Legacy name for compatibility. /*! @brief Legacy name for compatibility.
@ -1277,6 +1288,59 @@ extern "C" {
#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR #define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR
/*! @} */ /*! @} */
/*! @addtogroup window
* @{ */
/*! @brief Disable the progress bar.
*
* Disable the progress bar.
*
* Used by @ref window_progress_indicator.
*/
#define GLFW_PROGRESS_INDICATOR_DISABLED 0
/*! @brief Display the progress bar in an indeterminate state.
*
* Display the progress bar in an indeterminate state.
*
* @remark @win32 This displays the progress bar animation cycling repeatedly.
*
* @remark @x11 @wayland This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
*
* @remark @macos This displays a standard indeterminate `NSProgressIndicator`.
*
* Used by @ref window_progress_indicator.
*/
#define GLFW_PROGRESS_INDICATOR_INDETERMINATE 1
/*! @brief Display the normal progress bar.
*
* Display the normal progress bar.
*
* Used by @ref window_progress_indicator.
*/
#define GLFW_PROGRESS_INDICATOR_NORMAL 2
/*! @brief Display the progress bar in an error state.
*
* Display the progress bar in an error state.
*
* @remark @win32 This displays a red progress bar.
*
* @remark @x11 @wayland @macos This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
*
* Used by @ref window_progress_indicator.
*/
#define GLFW_PROGRESS_INDICATOR_ERROR 3
/*! @brief Display the progress bar in a paused state.
*
* Display the progress bar in a paused state.
*
* @remark @win32 This displays a yellow progress bar.
*
* @remark @x11 @wayland @macos This behaves like @ref GLFW_PROGRESS_INDICATOR_NORMAL.
*
* Used by @ref window_progress_indicator.
*/
#define GLFW_PROGRESS_INDICATOR_PAUSED 4
/*! @} */
#define GLFW_CONNECTED 0x00040001 #define GLFW_CONNECTED 0x00040001
#define GLFW_DISCONNECTED 0x00040002 #define GLFW_DISCONNECTED 0x00040002
@ -1416,16 +1480,25 @@ typedef struct GLFWcursor GLFWcursor;
* or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation * or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
* failures gracefully yet. * failures gracefully yet.
* *
* This function may be called during @ref glfwInit but before the library is * This function must support being called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the * flagged as initialized, as well as during @ref glfwTerminate after the library is no
* library is no longer flagged as initialized. * longer flagged as initialized.
* *
* Any memory allocated by this function will be deallocated during library * Any memory allocated via this function will be deallocated via the same allocator
* termination or earlier. * during library termination or earlier.
*
* Any memory allocated via this function must be suitably aligned for any object type.
* If you are using C99 or earlier, this alignment is platform-dependent but will be the
* same as what `malloc` provides. If you are using C11 or later, this is the value of
* `alignof(max_align_t)`.
* *
* The size will always be greater than zero. Allocations of size zero are filtered out * The size will always be greater than zero. Allocations of size zero are filtered out
* before reaching the custom allocator. * before reaching the custom allocator.
* *
* If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
*
* This function must not call any GLFW function.
*
* @param[in] size The minimum size, in bytes, of the memory block. * @param[in] size The minimum size, in bytes, of the memory block.
* @param[in] user The user-defined pointer from the allocator. * @param[in] user The user-defined pointer from the allocator.
* @return The address of the newly allocated memory block, or `NULL` if an * @return The address of the newly allocated memory block, or `NULL` if an
@ -1436,7 +1509,8 @@ typedef struct GLFWcursor GLFWcursor;
* *
* @reentrancy This function should not call any GLFW function. * @reentrancy This function should not call any GLFW function.
* *
* @thread_safety This function may be called from any thread that calls GLFW functions. * @thread_safety This function must support being called from any thread that calls GLFW
* functions.
* *
* @sa @ref init_allocator * @sa @ref init_allocator
* @sa @ref GLFWallocator * @sa @ref GLFWallocator
@ -1459,16 +1533,26 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user);
* `NULL` if allocation failed. Note that not all parts of GLFW handle allocation * `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
* failures gracefully yet. * failures gracefully yet.
* *
* This function may be called during @ref glfwInit but before the library is * This function must support being called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the * flagged as initialized, as well as during @ref glfwTerminate after the library is no
* library is no longer flagged as initialized. * longer flagged as initialized.
* *
* Any memory allocated by this function will be deallocated during library * Any memory allocated via this function will be deallocated via the same allocator
* termination or earlier. * during library termination or earlier.
*
* Any memory allocated via this function must be suitably aligned for any object type.
* If you are using C99 or earlier, this alignment is platform-dependent but will be the
* same as what `realloc` provides. If you are using C11 or later, this is the value of
* `alignof(max_align_t)`.
* *
* The block address will never be `NULL` and the size will always be greater than zero. * The block address will never be `NULL` and the size will always be greater than zero.
* Reallocations of a block to size zero are converted into deallocations. Reallocations * Reallocations of a block to size zero are converted into deallocations before reaching
* of `NULL` to a non-zero size are converted into regular allocations. * the custom allocator. Reallocations of `NULL` to a non-zero size are converted into
* regular allocations before reaching the custom allocator.
*
* If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
*
* This function must not call any GLFW function.
* *
* @param[in] block The address of the memory block to reallocate. * @param[in] block The address of the memory block to reallocate.
* @param[in] size The new minimum size, in bytes, of the memory block. * @param[in] size The new minimum size, in bytes, of the memory block.
@ -1481,7 +1565,8 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user);
* *
* @reentrancy This function should not call any GLFW function. * @reentrancy This function should not call any GLFW function.
* *
* @thread_safety This function may be called from any thread that calls GLFW functions. * @thread_safety This function must support being called from any thread that calls GLFW
* functions.
* *
* @sa @ref init_allocator * @sa @ref init_allocator
* @sa @ref GLFWallocator * @sa @ref GLFWallocator
@ -1503,13 +1588,17 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
* This function may deallocate the specified memory block. This memory block * This function may deallocate the specified memory block. This memory block
* will have been allocated with the same allocator. * will have been allocated with the same allocator.
* *
* This function may be called during @ref glfwInit but before the library is * This function must support being called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the * flagged as initialized, as well as during @ref glfwTerminate after the library is no
* library is no longer flagged as initialized. * longer flagged as initialized.
* *
* The block address will never be `NULL`. Deallocations of `NULL` are filtered out * The block address will never be `NULL`. Deallocations of `NULL` are filtered out
* before reaching the custom allocator. * before reaching the custom allocator.
* *
* If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
*
* This function must not call any GLFW function.
*
* @param[in] block The address of the memory block to deallocate. * @param[in] block The address of the memory block to deallocate.
* @param[in] user The user-defined pointer from the allocator. * @param[in] user The user-defined pointer from the allocator.
* *
@ -1518,7 +1607,8 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
* *
* @reentrancy This function should not call any GLFW function. * @reentrancy This function should not call any GLFW function.
* *
* @thread_safety This function may be called from any thread that calls GLFW functions. * @thread_safety This function must support being called from any thread that calls GLFW
* functions.
* *
* @sa @ref init_allocator * @sa @ref init_allocator
* @sa @ref GLFWallocator * @sa @ref GLFWallocator
@ -2086,7 +2176,10 @@ typedef struct GLFWgamepadstate
float axes[6]; float axes[6];
} GLFWgamepadstate; } GLFWgamepadstate;
/*! @brief /*! @brief Custom heap memory allocator.
*
* This describes a custom heap memory allocator for GLFW. To set an allocator, pass it
* to @ref glfwInitAllocator before initializing the library.
* *
* @sa @ref init_allocator * @sa @ref init_allocator
* @sa @ref glfwInitAllocator * @sa @ref glfwInitAllocator
@ -2097,9 +2190,21 @@ typedef struct GLFWgamepadstate
*/ */
typedef struct GLFWallocator typedef struct GLFWallocator
{ {
/*! The memory allocation function. See @ref GLFWallocatefun for details about
* allocation function.
*/
GLFWallocatefun allocate; GLFWallocatefun allocate;
/*! The memory reallocation function. See @ref GLFWreallocatefun for details about
* reallocation function.
*/
GLFWreallocatefun reallocate; GLFWreallocatefun reallocate;
/*! The memory deallocation function. See @ref GLFWdeallocatefun for details about
* deallocation function.
*/
GLFWdeallocatefun deallocate; GLFWdeallocatefun deallocate;
/*! The user pointer for this custom allocator. This value will be passed to the
* allocator functions.
*/
void* user; void* user;
} GLFWallocator; } GLFWallocator;
@ -2144,6 +2249,13 @@ typedef struct GLFWallocator
* and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init * and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
* hint. * hint.
* *
* @remark __Wayland, X11:__ If the library was compiled with support for both
* Wayland and X11, and the @ref GLFW_PLATFORM init hint is set to
* `GLFW_ANY_PLATFORM`, the `XDG_SESSION_TYPE` environment variable affects
* which platform is picked. If the environment variable is not set, or is set
* to something other than `wayland` or `x11`, the regular detection mechanism
* will be used instead.
*
* @remark @x11 This function will set the `LC_CTYPE` category of the * @remark @x11 This function will set the `LC_CTYPE` category of the
* application locale according to the current environment if that category is * application locale according to the current environment if that category is
* still "C". This is because the "C" locale breaks Unicode text input. * still "C". This is because the "C" locale breaks Unicode text input.
@ -2232,8 +2344,12 @@ GLFWAPI void glfwInitHint(int hint, int value);
* To use the default allocator, call this function with a `NULL` argument. * To use the default allocator, call this function with a `NULL` argument.
* *
* If you specify an allocator struct, every member must be a valid function * If you specify an allocator struct, every member must be a valid function
* pointer. If any member is `NULL`, this function emits @ref * pointer. If any member is `NULL`, this function will emit @ref
* GLFW_INVALID_VALUE and the init allocator is unchanged. * GLFW_INVALID_VALUE and the init allocator will be unchanged.
*
* The functions in the allocator must fulfil a number of requirements. See the
* documentation for @ref GLFWallocatefun, @ref GLFWreallocatefun and @ref
* GLFWdeallocatefun for details.
* *
* @param[in] allocator The allocator to use at the next initialization, or * @param[in] allocator The allocator to use at the next initialization, or
* `NULL` to use the default one. * `NULL` to use the default one.
@ -2600,9 +2716,10 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
* specified monitor. * specified monitor.
* *
* Some platforms do not provide accurate monitor size information, either * Some platforms do not provide accurate monitor size information, either
* because the monitor * because the monitor [EDID][] data is incorrect or because the driver does
* [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data) * not report it accurately.
* data is incorrect or because the driver does not report it accurately. *
* [EDID]: https://en.wikipedia.org/wiki/Extended_display_identification_data
* *
* Any or all of the size arguments may be `NULL`. If an error occurs, all * Any or all of the size arguments may be `NULL`. If an error occurs, all
* non-`NULL` size arguments will be set to zero. * non-`NULL` size arguments will be set to zero.
@ -2649,6 +2766,9 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland Fractional scaling information is not yet available for
* monitors, so this function only returns integer content scales.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref monitor_scale * @sa @ref monitor_scale
@ -3112,23 +3232,35 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
* @remark @macos The GLFW window has no icon, as it is not a document * @remark @macos The GLFW window has no icon, as it is not a document
* window, but the dock icon will be the same as the application bundle's icon. * window, but the dock icon will be the same as the application bundle's icon.
* For more information on bundles, see the * For more information on bundles, see the
* [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
* in the Mac Developer Library.
* *
* @remark @macos On OS X 10.10 and later the window frame will not be rendered * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
* at full resolution on Retina displays unless the *
* [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) * @remark @macos The window frame will not be rendered at full resolution on
* Retina displays unless the
* [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint)
* hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
* application bundle's `Info.plist`. For more information, see * application bundle's `Info.plist`. For more information, see
* [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) * [High Resolution Guidelines for OS X][hidpi-guide] in the Mac Developer
* in the Mac Developer Library. The GLFW test and example programs use * Library. The GLFW test and example programs use a custom `Info.plist`
* a custom `Info.plist` template for this, which can be found as * template for this, which can be found as `CMake/Info.plist.in` in the source
* `CMake/Info.plist.in` in the source tree. * tree.
*
* [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
* *
* @remark @macos When activating frame autosaving with * @remark @macos When activating frame autosaving with
* [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
* window size and position may be overridden by previously saved values. * window size and position may be overridden by previously saved values.
* *
* @remark @wayland GLFW uses [libdecor][] where available to create its window
* decorations. This in turn uses server-side XDG decorations where available
* and provides high quality client-side decorations on compositors like GNOME.
* If both XDG decorations and libdecor are unavailable, GLFW falls back to
* a very simple set of window decorations that only support moving, resizing
* and the window manager's right-click menu.
*
* [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor
*
* @remark @x11 Some window managers will not respect the placement of * @remark @x11 Some window managers will not respect the placement of
* initially hidden windows. * initially hidden windows.
* *
@ -3145,20 +3277,6 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
* [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
* override this. * override this.
* *
* @remark @wayland Compositors should implement the xdg-decoration protocol
* for GLFW to decorate the window properly. If this protocol isn't
* supported, or if the compositor prefers client-side decorations, a very
* simple fallback frame will be drawn using the wp_viewporter protocol. A
* compositor can still emit close, maximize or fullscreen events, using for
* instance a keybind mechanism. If neither of these protocols is supported,
* the window won't be decorated.
*
* @remark @wayland A full screen window will not attempt to change the mode,
* no matter what the requested size or refresh rate.
*
* @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
* to be implemented in the user's compositor.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_creation * @sa @ref window_creation
@ -3241,6 +3359,38 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
*/ */
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
/*! @brief Returns the title of the specified window.
*
* This function returns the window title, encoded as UTF-8, of the specified
* window. This is the title set previously by @ref glfwCreateWindow
* or @ref glfwSetWindowTitle.
*
* @param[in] window The window to query.
* @return The UTF-8 encoded window title, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @remark The returned title is currently a copy of the title last set by @ref
* glfwCreateWindow or @ref glfwSetWindowTitle. It does not include any
* additional text which may be appended by the platform or another program.
*
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the next call to @ref
* glfwGetWindowTitle or @ref glfwSetWindowTitle, or until the library is
* terminated.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_title
* @sa @ref glfwSetWindowTitle
*
* @since Added in version 3.4.
*
* @ingroup window
*/
GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window);
/*! @brief Sets the title of the specified window. /*! @brief Sets the title of the specified window.
* *
* This function sets the window title, encoded as UTF-8, of the specified * This function sets the window title, encoded as UTF-8, of the specified
@ -3258,6 +3408,7 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_title * @sa @ref window_title
* @sa @ref glfwGetWindowTitle
* *
* @since Added in version 1.0. * @since Added in version 1.0.
* @glfw3 Added window handle parameter. * @glfw3 Added window handle parameter.
@ -3297,8 +3448,9 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
* @remark @macos Regular windows do not have icons on macOS. This function * @remark @macos Regular windows do not have icons on macOS. This function
* will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
* the application bundle's icon. For more information on bundles, see the * the application bundle's icon. For more information on bundles, see the
* [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
* in the Mac Developer Library. *
* [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
* *
* @remark @wayland There is no existing protocol to change an icon, the * @remark @wayland There is no existing protocol to change an icon, the
* window will thus inherit the one defined in the application's desktop file. * window will thus inherit the one defined in the application's desktop file.
@ -3314,6 +3466,46 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
*/ */
GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images); GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
/*! @brief Sets the dock or taskbar progress indicator for the specified window.
*
* This function sets the dock or taskbar progress indicator of the specified window.
*
* @param[in] window The window whose progress to set.
* @param[in] progressState The state of the progress to be displayed in the dock
* or taskbar. Valid values are: @ref GLFW_PROGRESS_INDICATOR_DISABLED,
* @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_NORMAL,
* @ref GLFW_PROGRESS_INDICATOR_ERROR and @ref GLFW_PROGRESS_INDICATOR_PAUSED.
* @param[in] value The amount of completed progress to set. Valid range is 0.0 to 1.0.
* This is ignored if progressState is set to @ref GLFW_PROGRESS_INDICATOR_DISABLED.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR,
* @ref GLFW_FEATURE_UNIMPLEMENTED and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
*
* @remark @win32 On Windows Vista and earlier, this function will emit
* @ref GLFW_FEATURE_UNAVAILABLE.
*
* @remark @macos There exists only one Dock icon progress bar, and this
* displays the combined values of all the windows.
*
* @remark @x11 @wayland Requires a valid application desktop file with the same name
* as the compiled executable. Due to limitations in the Unity Launcher API
* @ref GLFW_PROGRESS_INDICATOR_INDETERMINATE, @ref GLFW_PROGRESS_INDICATOR_ERROR
* and @ref GLFW_PROGRESS_INDICATOR_PAUSED have the same behaviour as
* @ref GLFW_PROGRESS_INDICATOR_NORMAL. The Unity Launcher API is only known
* to be supported on the Unity and KDE desktop environments; on other desktop
* environments this function may do nothing.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_progress_indicator
*
* @since Added in version 3.4.
*
* @ingroup window
*/
GLFWAPI void glfwSetWindowProgressIndicator(GLFWwindow* window, int progressState, double value);
/*! @brief Retrieves the position of the content area of the specified window. /*! @brief Retrieves the position of the content area of the specified window.
* *
* This function retrieves the position, in screen coordinates, of the * This function retrieves the position, in screen coordinates, of the
@ -3522,9 +3714,6 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland A full screen window will not attempt to change the mode,
* no matter what the requested size.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_size * @sa @ref window_size
@ -3856,11 +4045,11 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window);
* *
* @param[in] window The window to give input focus. * @param[in] window The window to give input focus.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland It is not possible for an application to set the input * @remark @wayland The compositor will likely ignore focus requests unless
* focus. This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * another window created by the same application already has input focus.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@ -3965,9 +4154,6 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
* @remark @wayland The desired window position is ignored, as there is no way * @remark @wayland The desired window position is ignored, as there is no way
* for an application to set this property. * for an application to set this property.
* *
* @remark @wayland Setting the window to full screen will not attempt to
* change the mode, no matter what the requested size or refresh rate.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_monitor * @sa @ref window_monitor
@ -4041,11 +4227,14 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
* GLFW_FEATURE_UNAVAILABLE. * GLFW_FEATURE_UNAVAILABLE (see remarks).
* *
* @remark Calling @ref glfwGetWindowAttrib will always return the latest * @remark Calling @ref glfwGetWindowAttrib will always return the latest
* value, even if that value is ignored by the current mode of the window. * value, even if that value is ignored by the current mode of the window.
* *
* @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is
* not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_attribs * @sa @ref window_attribs
@ -4581,8 +4770,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
* *
* This function sets an input mode option for the specified window. The mode * This function sets an input mode option for the specified window. The mode
* must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS, * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
* @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS
* @ref GLFW_RAW_MOUSE_MOTION. * @ref GLFW_RAW_MOUSE_MOTION, or @ref GLFW_UNLIMITED_MOUSE_BUTTONS.
* *
* If the mode is `GLFW_CURSOR`, the value must be one of the following cursor * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
* modes: * modes:
@ -4622,6 +4811,11 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
* attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
* glfwRawMouseMotionSupported to check for support. * glfwRawMouseMotionSupported to check for support.
* *
* If the mode is `GLFW_UNLIMITED_MOUSE_BUTTONS`, the value must be either
* `GLFW_TRUE` to disable the mouse button limit when calling the mouse button
* callback, or `GLFW_FALSE` to limit the mouse buttons sent to the callback
* to the mouse button token values up to `GLFW_MOUSE_BUTTON_LAST`.
*
* @param[in] window The window whose input mode to set. * @param[in] window The window whose input mode to set.
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`, * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
* `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
@ -4816,8 +5010,11 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
* returns `GLFW_PRESS` the first time you call it for a mouse button that was * returns `GLFW_PRESS` the first time you call it for a mouse button that was
* pressed, even if that mouse button has already been released. * pressed, even if that mouse button has already been released.
* *
* The @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode does not effect the
* limit on buttons which can be polled with this function.
*
* @param[in] window The desired window. * @param[in] window The desired window.
* @param[in] button The desired [mouse button](@ref buttons). * @param[in] button The desired [mouse button token](@ref buttons).
* @return One of `GLFW_PRESS` or `GLFW_RELEASE`. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
@ -5193,10 +5390,15 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods
* is called when a mouse button is pressed or released. * is called when a mouse button is pressed or released.
* *
* When a window loses input focus, it will generate synthetic mouse button * When a window loses input focus, it will generate synthetic mouse button
* release events for all pressed mouse buttons. You can tell these events * release events for all pressed mouse buttons with associated button tokens.
* from user-generated events by the fact that the synthetic ones are generated * You can tell these events from user-generated events by the fact that the
* after the focus loss event has been processed, i.e. after the * synthetic ones are generated after the focus loss event has been processed,
* [window focus callback](@ref glfwSetWindowFocusCallback) has been called. * i.e. after the [window focus callback](@ref glfwSetWindowFocusCallback) has
* been called.
*
* The reported `button` value can be higher than `GLFW_MOUSE_BUTTON_LAST` if
* the button does not have an associated [button token](@ref buttons) and the
* @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set.
* *
* @param[in] window The window whose callback to set. * @param[in] window The window whose callback to set.
* @param[in] callback The new callback, or `NULL` to remove the currently set * @param[in] callback The new callback, or `NULL` to remove the currently set
@ -5346,8 +5548,6 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun ca
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* *
* @remark @wayland File drop is currently unimplemented.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref path_drop * @sa @ref path_drop

View File

@ -1,5 +1,5 @@
/************************************************************************* /*************************************************************************
* GLFW 3.4 - www.glfw.org * GLFW 3.5 - www.glfw.org
* A library for OpenGL, window and input * A library for OpenGL, window and input
*------------------------------------------------------------------------ *------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard * Copyright (c) 2002-2006 Marcus Geelnard
@ -286,6 +286,23 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
* @ingroup native * @ingroup native
*/ */
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
/*! @brief Returns the `NSView` of the specified window.
*
* @return The `NSView` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.4.
*
* @ingroup native
*/
GLFWAPI id glfwGetCocoaView(GLFWwindow* window);
#endif #endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL) #if defined(GLFW_EXPOSE_NATIVE_NSGL)

View File

@ -17,7 +17,8 @@ elseif (WIN32)
win32_time.c win32_thread.c) win32_time.c win32_thread.c)
else() else()
target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c
posix_time.c posix_thread.c) posix_time.c posix_thread.c posix_dbus.h
posix_dbus.c)
endif() endif()
add_custom_target(update_mappings add_custom_target(update_mappings
@ -101,6 +102,8 @@ if (GLFW_BUILD_WAYLAND)
generate_wayland_protocol("idle-inhibit-unstable-v1.xml") generate_wayland_protocol("idle-inhibit-unstable-v1.xml")
generate_wayland_protocol("pointer-constraints-unstable-v1.xml") generate_wayland_protocol("pointer-constraints-unstable-v1.xml")
generate_wayland_protocol("relative-pointer-unstable-v1.xml") generate_wayland_protocol("relative-pointer-unstable-v1.xml")
generate_wayland_protocol("fractional-scale-v1.xml")
generate_wayland_protocol("xdg-activation-v1.xml")
generate_wayland_protocol("xdg-decoration-unstable-v1.xml") generate_wayland_protocol("xdg-decoration-unstable-v1.xml")
endif() endif()
@ -149,10 +152,11 @@ endif()
if (GLFW_BUILD_COCOA) if (GLFW_BUILD_COCOA)
target_link_libraries(glfw PRIVATE "-framework Cocoa" target_link_libraries(glfw PRIVATE "-framework Cocoa"
"-framework IOKit" "-framework IOKit"
"-framework CoreFoundation") "-framework CoreFoundation"
"-framework QuartzCore")
set(glfw_PKG_DEPS "") set(glfw_PKG_DEPS "")
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework QuartzCore")
endif() endif()
if (GLFW_BUILD_WAYLAND) if (GLFW_BUILD_WAYLAND)

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 macOS - www.glfw.org // GLFW 3.5 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@ -23,8 +23,6 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@ -495,78 +493,79 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
{ {
const _GLFWplatform cocoa = const _GLFWplatform cocoa =
{ {
GLFW_PLATFORM_COCOA, .platformID = GLFW_PLATFORM_COCOA,
_glfwInitCocoa, .init = _glfwInitCocoa,
_glfwTerminateCocoa, .terminate = _glfwTerminateCocoa,
_glfwGetCursorPosCocoa, .getCursorPos = _glfwGetCursorPosCocoa,
_glfwSetCursorPosCocoa, .setCursorPos = _glfwSetCursorPosCocoa,
_glfwSetCursorModeCocoa, .setCursorMode = _glfwSetCursorModeCocoa,
_glfwSetRawMouseMotionCocoa, .setRawMouseMotion = _glfwSetRawMouseMotionCocoa,
_glfwRawMouseMotionSupportedCocoa, .rawMouseMotionSupported = _glfwRawMouseMotionSupportedCocoa,
_glfwCreateCursorCocoa, .createCursor = _glfwCreateCursorCocoa,
_glfwCreateStandardCursorCocoa, .createStandardCursor = _glfwCreateStandardCursorCocoa,
_glfwDestroyCursorCocoa, .destroyCursor = _glfwDestroyCursorCocoa,
_glfwSetCursorCocoa, .setCursor = _glfwSetCursorCocoa,
_glfwGetScancodeNameCocoa, .getScancodeName = _glfwGetScancodeNameCocoa,
_glfwGetKeyScancodeCocoa, .getKeyScancode = _glfwGetKeyScancodeCocoa,
_glfwSetClipboardStringCocoa, .setClipboardString = _glfwSetClipboardStringCocoa,
_glfwGetClipboardStringCocoa, .getClipboardString = _glfwGetClipboardStringCocoa,
_glfwInitJoysticksCocoa, .initJoysticks = _glfwInitJoysticksCocoa,
_glfwTerminateJoysticksCocoa, .terminateJoysticks = _glfwTerminateJoysticksCocoa,
_glfwPollJoystickCocoa, .pollJoystick = _glfwPollJoystickCocoa,
_glfwGetMappingNameCocoa, .getMappingName = _glfwGetMappingNameCocoa,
_glfwUpdateGamepadGUIDCocoa, .updateGamepadGUID = _glfwUpdateGamepadGUIDCocoa,
_glfwFreeMonitorCocoa, .freeMonitor = _glfwFreeMonitorCocoa,
_glfwGetMonitorPosCocoa, .getMonitorPos = _glfwGetMonitorPosCocoa,
_glfwGetMonitorContentScaleCocoa, .getMonitorContentScale = _glfwGetMonitorContentScaleCocoa,
_glfwGetMonitorWorkareaCocoa, .getMonitorWorkarea = _glfwGetMonitorWorkareaCocoa,
_glfwGetVideoModesCocoa, .getVideoModes = _glfwGetVideoModesCocoa,
_glfwGetVideoModeCocoa, .getVideoMode = _glfwGetVideoModeCocoa,
_glfwGetGammaRampCocoa, .getGammaRamp = _glfwGetGammaRampCocoa,
_glfwSetGammaRampCocoa, .setGammaRamp = _glfwSetGammaRampCocoa,
_glfwCreateWindowCocoa, .createWindow = _glfwCreateWindowCocoa,
_glfwDestroyWindowCocoa, .destroyWindow = _glfwDestroyWindowCocoa,
_glfwSetWindowTitleCocoa, .setWindowTitle = _glfwSetWindowTitleCocoa,
_glfwSetWindowIconCocoa, .setWindowIcon = _glfwSetWindowIconCocoa,
_glfwGetWindowPosCocoa, .setWindowProgressIndicator = _glfwSetWindowProgressIndicatorCocoa,
_glfwSetWindowPosCocoa, .getWindowPos = _glfwGetWindowPosCocoa,
_glfwGetWindowSizeCocoa, .setWindowPos = _glfwSetWindowPosCocoa,
_glfwSetWindowSizeCocoa, .getWindowSize = _glfwGetWindowSizeCocoa,
_glfwSetWindowSizeLimitsCocoa, .setWindowSize = _glfwSetWindowSizeCocoa,
_glfwSetWindowAspectRatioCocoa, .setWindowSizeLimits = _glfwSetWindowSizeLimitsCocoa,
_glfwGetFramebufferSizeCocoa, .setWindowAspectRatio = _glfwSetWindowAspectRatioCocoa,
_glfwGetWindowFrameSizeCocoa, .getFramebufferSize = _glfwGetFramebufferSizeCocoa,
_glfwGetWindowContentScaleCocoa, .getWindowFrameSize = _glfwGetWindowFrameSizeCocoa,
_glfwIconifyWindowCocoa, .getWindowContentScale = _glfwGetWindowContentScaleCocoa,
_glfwRestoreWindowCocoa, .iconifyWindow = _glfwIconifyWindowCocoa,
_glfwMaximizeWindowCocoa, .restoreWindow = _glfwRestoreWindowCocoa,
_glfwShowWindowCocoa, .maximizeWindow = _glfwMaximizeWindowCocoa,
_glfwHideWindowCocoa, .showWindow = _glfwShowWindowCocoa,
_glfwRequestWindowAttentionCocoa, .hideWindow = _glfwHideWindowCocoa,
_glfwFocusWindowCocoa, .requestWindowAttention = _glfwRequestWindowAttentionCocoa,
_glfwSetWindowMonitorCocoa, .focusWindow = _glfwFocusWindowCocoa,
_glfwWindowFocusedCocoa, .setWindowMonitor = _glfwSetWindowMonitorCocoa,
_glfwWindowIconifiedCocoa, .windowFocused = _glfwWindowFocusedCocoa,
_glfwWindowVisibleCocoa, .windowIconified = _glfwWindowIconifiedCocoa,
_glfwWindowMaximizedCocoa, .windowVisible = _glfwWindowVisibleCocoa,
_glfwWindowHoveredCocoa, .windowMaximized = _glfwWindowMaximizedCocoa,
_glfwFramebufferTransparentCocoa, .windowHovered = _glfwWindowHoveredCocoa,
_glfwGetWindowOpacityCocoa, .framebufferTransparent = _glfwFramebufferTransparentCocoa,
_glfwSetWindowResizableCocoa, .getWindowOpacity = _glfwGetWindowOpacityCocoa,
_glfwSetWindowDecoratedCocoa, .setWindowResizable = _glfwSetWindowResizableCocoa,
_glfwSetWindowFloatingCocoa, .setWindowDecorated = _glfwSetWindowDecoratedCocoa,
_glfwSetWindowOpacityCocoa, .setWindowFloating = _glfwSetWindowFloatingCocoa,
_glfwSetWindowMousePassthroughCocoa, .setWindowOpacity = _glfwSetWindowOpacityCocoa,
_glfwPollEventsCocoa, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughCocoa,
_glfwWaitEventsCocoa, .pollEvents = _glfwPollEventsCocoa,
_glfwWaitEventsTimeoutCocoa, .waitEvents = _glfwWaitEventsCocoa,
_glfwPostEmptyEventCocoa, .waitEventsTimeout = _glfwWaitEventsTimeoutCocoa,
_glfwGetEGLPlatformCocoa, .postEmptyEvent = _glfwPostEmptyEventCocoa,
_glfwGetEGLNativeDisplayCocoa, .getEGLPlatform = _glfwGetEGLPlatformCocoa,
_glfwGetEGLNativeWindowCocoa, .getEGLNativeDisplay = _glfwGetEGLNativeDisplayCocoa,
_glfwGetRequiredInstanceExtensionsCocoa, .getEGLNativeWindow = _glfwGetEGLNativeWindowCocoa,
_glfwGetPhysicalDevicePresentationSupportCocoa, .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsCocoa,
_glfwCreateWindowSurfaceCocoa, .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportCocoa,
.createWindowSurface = _glfwCreateWindowSurfaceCocoa
}; };
*platform = cocoa; *platform = cocoa;
@ -649,6 +648,12 @@ void _glfwTerminateCocoa(void)
{ {
@autoreleasepool { @autoreleasepool {
if (_glfw.ns.dockProgressIndicator.view != nil)
{
[_glfw.ns.dockProgressIndicator.view removeFromSuperview];
[_glfw.ns.dockProgressIndicator.view release];
}
if (_glfw.ns.inputSource) if (_glfw.ns.inputSource)
{ {
CFRelease(_glfw.ns.inputSource); CFRelease(_glfw.ns.inputSource);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Cocoa - www.glfw.org // GLFW 3.5 Cocoa - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Cocoa - www.glfw.org // GLFW 3.5 Cocoa - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net> // Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
@ -24,8 +24,6 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 macOS - www.glfw.org // GLFW 3.5 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -24,8 +24,6 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@ -34,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <assert.h>
#include <IOKit/graphics/IOGraphicsLib.h> #include <IOKit/graphics/IOGraphicsLib.h>
#include <ApplicationServices/ApplicationServices.h> #include <ApplicationServices/ApplicationServices.h>
@ -138,7 +137,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode)
if (flags & kDisplayModeStretchedFlag) if (flags & kDisplayModeStretchedFlag)
return GLFW_FALSE; return GLFW_FALSE;
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 #if MAC_OS_X_VERSION_MAX_ALLOWED == 101100
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode); CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) && if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0)) CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
@ -165,7 +164,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
if (result.refreshRate == 0) if (result.refreshRate == 0)
result.refreshRate = (int) round(fallbackRefreshRate); result.refreshRate = (int) round(fallbackRefreshRate);
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 #if MAC_OS_X_VERSION_MAX_ALLOWED == 101100
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode); CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0) if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
{ {
@ -181,7 +180,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
result.blueBits = 8; result.blueBits = 8;
} }
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 #if MAC_OS_X_VERSION_MAX_ALLOWED == 101100
CFRelease(format); CFRelease(format);
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ #endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
return result; return result;
@ -551,13 +550,20 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
} // autoreleasepool } // autoreleasepool
} }
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode) GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
{ {
@autoreleasepool { @autoreleasepool {
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID); CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
if (!native)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to query display mode");
return GLFW_FALSE;
}
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate); *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
CGDisplayModeRelease(native); CGDisplayModeRelease(native);
return GLFW_TRUE;
} // autoreleasepool } // autoreleasepool
} }
@ -622,8 +628,17 @@ void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay); _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Cocoa: Platform not initialized");
return kCGNullDirectDisplay;
}
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
return monitor->ns.displayID; return monitor->ns.displayID;
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 macOS - www.glfw.org // GLFW 3.5 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@ -145,7 +145,7 @@ typedef struct _GLFWwindowNS
GLFWbool maximized; GLFWbool maximized;
GLFWbool occluded; GLFWbool occluded;
GLFWbool retina; GLFWbool scaleFramebuffer;
// Cached window properties to filter out duplicate events // Cached window properties to filter out duplicate events
int width, height; int width, height;
@ -156,6 +156,11 @@ typedef struct _GLFWwindowNS
// since the last cursor motion event was processed // since the last cursor motion event was processed
// This is kept to counteract Cocoa doing the same internally // This is kept to counteract Cocoa doing the same internally
double cursorWarpDeltaX, cursorWarpDeltaY; double cursorWarpDeltaX, cursorWarpDeltaY;
struct {
int state;
double value;
} dockProgressIndicator;
} _GLFWwindowNS; } _GLFWwindowNS;
// Cocoa-specific global data // Cocoa-specific global data
@ -189,6 +194,13 @@ typedef struct _GLFWlibraryNS
PFN_LMGetKbdType GetKbdType; PFN_LMGetKbdType GetKbdType;
CFStringRef kPropertyUnicodeKeyLayoutData; CFStringRef kPropertyUnicodeKeyLayoutData;
} tis; } tis;
struct {
id view;
int windowCount;
int indeterminateCount;
double totalValue;
} dockProgressIndicator;
} _GLFWlibraryNS; } _GLFWlibraryNS;
// Cocoa-specific per-monitor data // Cocoa-specific per-monitor data
@ -218,6 +230,7 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndco
void _glfwDestroyWindowCocoa(_GLFWwindow* window); void _glfwDestroyWindowCocoa(_GLFWwindow* window);
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowProgressIndicatorCocoa(_GLFWwindow* window, int progressState, double value);
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos); void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos);
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height); void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height);
@ -281,7 +294,7 @@ void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count); GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp); GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 macOS - www.glfw.org // GLFW 3.5 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 macOS - www.glfw.org // GLFW 3.5 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2021 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2021 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 macOS - www.glfw.org // GLFW 3.5 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@ -23,15 +23,16 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
#if defined(_GLFW_COCOA) #if defined(_GLFW_COCOA)
#import <QuartzCore/CAMetalLayer.h>
#include <float.h> #include <float.h>
#include <string.h> #include <string.h>
#include <assert.h>
// HACK: This enum value is missing from framework headers on OS X 10.11 despite // HACK: This enum value is missing from framework headers on OS X 10.11 despite
// having been (according to documentation) added in Mac OS X 10.7 // having been (according to documentation) added in Mac OS X 10.7
@ -197,6 +198,83 @@ static NSUInteger translateKeyToModifierFlag(int key)
// //
static const NSRange kEmptyRange = { NSNotFound, 0 }; static const NSRange kEmptyRange = { NSNotFound, 0 };
static NSProgressIndicator* createProgressIndicator(const NSDockTile* dockTile)
{
NSView* contentView = [dockTile contentView];
NSProgressIndicator* indicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, contentView.frame.size.width, 15.0f)];
[indicator setStyle:NSProgressIndicatorStyleBar];
if (@available(macOS 11.0, *))
{
[indicator setControlSize:NSControlSizeLarge];
}
[indicator setMinValue:0.0f];
[indicator setMaxValue:1.0f];
[indicator sizeToFit];
[contentView addSubview:indicator];
_glfw.ns.dockProgressIndicator.view = indicator;
return indicator;
}
static void setDockProgressIndicator(int progressState, double value)
{
NSProgressIndicator* indicator = _glfw.ns.dockProgressIndicator.view;
NSDockTile* dockTile = [[NSApplication sharedApplication] dockTile];
if (indicator == nil)
{
if ([dockTile contentView] == nil)
{
NSImageView *iconView = [[NSImageView alloc] init];
[iconView setImage:[[NSApplication sharedApplication] applicationIconImage]];
[dockTile setContentView:iconView];
[iconView release];
}
indicator = createProgressIndicator(dockTile);
}
// ### Switching from INDETERMINATE to NORMAL, PAUSED or ERROR requires 2 invocations in different frames.
// In MacOS 12 (and probably other versions), an indeterminate progress bar is rendered as a normal bar
// with 0.0 progress. So when calling [progressIndicator setIndeterminate:YES], the indicator actually
// sets its doubleValue to 0.0.
// The bug is caused by NSProgressIndicator not immediately updating its value when it's increasing.
// This code illustrates the exact same problem, but this time from NORMAL, PAUSED and ERROR to INDETERMINATE:
//
// if (progressState == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
// [progressIndicator setDoubleValue:0.75];
// else
// [progressIndicator setDoubleValue:0.25];
//
// This is likely a bug in Cocoa.
//
// ### Progress increments are delayed
// What this also means, is that each time the progress increments, the bar's progress will be 1 frame delayed,
// and only updated once a higher or similar value is again set the next frame.
// Workaround for the aforementioned issues. If there's any versions of MacOS where
// this issue is not present, this should be ommitted in those versions.
if ([indicator isIndeterminate] || [indicator doubleValue] < value)
{
[indicator removeFromSuperview];
[indicator release];
indicator = createProgressIndicator(dockTile);
}
[indicator setIndeterminate:progressState == GLFW_PROGRESS_INDICATOR_INDETERMINATE];
[indicator setHidden:progressState == GLFW_PROGRESS_INDICATOR_DISABLED];
[indicator setDoubleValue:value];
[dockTile display];
}
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Delegate for window related notifications // Delegate for window related notifications
@ -311,7 +389,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidChangeOcclusionState:(NSNotification* )notification - (void)windowDidChangeOcclusionState:(NSNotification* )notification
{ {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
if ([window->ns.object respondsToSelector:@selector(occlusionState)]) if ([window->ns.object respondsToSelector:@selector(occlusionState)])
{ {
if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
@ -319,7 +396,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
else else
window->ns.occluded = GLFW_TRUE; window->ns.occluded = GLFW_TRUE;
} }
#endif
} }
@end @end
@ -515,7 +591,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
if (xscale != window->ns.xscale || yscale != window->ns.yscale) if (xscale != window->ns.xscale || yscale != window->ns.yscale)
{ {
if (window->ns.retina && window->ns.layer) if (window->ns.scaleFramebuffer && window->ns.layer)
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
window->ns.xscale = xscale; window->ns.xscale = xscale;
@ -874,7 +950,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
[window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)]; [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)];
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
window->ns.retina = wndconfig->ns.retina; window->ns.scaleFramebuffer = wndconfig->scaleFramebuffer;
if (fbconfig->transparent) if (fbconfig->transparent)
{ {
@ -992,6 +1068,8 @@ void _glfwDestroyWindowCocoa(_GLFWwindow* window)
{ {
@autoreleasepool { @autoreleasepool {
_glfwSetWindowProgressIndicatorCocoa(window, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
_glfw.ns.disabledCursorWindow = NULL; _glfw.ns.disabledCursorWindow = NULL;
@ -1037,6 +1115,62 @@ void _glfwSetWindowIconCocoa(_GLFWwindow* window,
"Cocoa: Regular windows do not have icons on macOS"); "Cocoa: Regular windows do not have icons on macOS");
} }
void _glfwSetWindowProgressIndicatorCocoa(_GLFWwindow* window, int progressState, double value)
{
if (progressState == GLFW_PROGRESS_INDICATOR_ERROR || progressState == GLFW_PROGRESS_INDICATOR_PAUSED)
progressState = GLFW_PROGRESS_INDICATOR_NORMAL;
const int oldState = window->ns.dockProgressIndicator.state;
const int state = progressState;
const double oldValue = window->ns.dockProgressIndicator.value;
if (oldState == state)
{
if (state == GLFW_PROGRESS_INDICATOR_DISABLED ||
state == GLFW_PROGRESS_INDICATOR_INDETERMINATE ||
oldValue == value)
return;
}
if (oldState != state)
{
// Reset
if (oldState == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
--_glfw.ns.dockProgressIndicator.indeterminateCount;
if (oldState != GLFW_PROGRESS_INDICATOR_DISABLED)
{
--_glfw.ns.dockProgressIndicator.windowCount;
_glfw.ns.dockProgressIndicator.totalValue -= oldValue;
}
// Set
if (state == GLFW_PROGRESS_INDICATOR_INDETERMINATE)
++_glfw.ns.dockProgressIndicator.indeterminateCount;
if (state != GLFW_PROGRESS_INDICATOR_DISABLED)
{
++_glfw.ns.dockProgressIndicator.windowCount;
_glfw.ns.dockProgressIndicator.totalValue += value;
}
}
else if (state != GLFW_PROGRESS_INDICATOR_DISABLED)
_glfw.ns.dockProgressIndicator.totalValue += (value - oldValue);
if (_glfw.ns.dockProgressIndicator.windowCount > _glfw.ns.dockProgressIndicator.indeterminateCount)
{
const double finalValue = _glfw.ns.dockProgressIndicator.totalValue / _glfw.ns.dockProgressIndicator.windowCount;
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_NORMAL, finalValue);
}
else if (_glfw.ns.dockProgressIndicator.indeterminateCount > 0)
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_INDETERMINATE, 0.0f);
else
setDockProgressIndicator(GLFW_PROGRESS_INDICATOR_DISABLED, 0.0f);
window->ns.dockProgressIndicator.state = state;
window->ns.dockProgressIndicator.value = value;
}
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos) void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos)
{ {
@autoreleasepool { @autoreleasepool {
@ -1659,14 +1793,15 @@ const char* _glfwGetScancodeNameCocoa(int scancode)
{ {
@autoreleasepool { @autoreleasepool {
if (scancode < 0 || scancode > 0xff || if (scancode < 0 || scancode > 0xff)
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL; return NULL;
} }
const int key = _glfw.ns.keycodes[scancode]; const int key = _glfw.ns.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
UInt32 deadKeyState = 0; UInt32 deadKeyState = 0;
UniChar characters[4]; UniChar characters[4];
@ -1950,19 +2085,8 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
{ {
@autoreleasepool { @autoreleasepool {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
// HACK: Dynamically load Core Animation to avoid adding an extra
// dependency for the majority who don't use MoltenVK
NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
if (!bundle)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to find QuartzCore.framework");
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
// NOTE: Create the layer here as makeBackingLayer should not return nil // NOTE: Create the layer here as makeBackingLayer should not return nil
window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer]; window->ns.layer = [CAMetalLayer layer];
if (!window->ns.layer) if (!window->ns.layer)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
@ -1970,7 +2094,7 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
return VK_ERROR_EXTENSION_NOT_PRESENT; return VK_ERROR_EXTENSION_NOT_PRESENT;
} }
if (window->ns.retina) if (window->ns.scaleFramebuffer)
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
[window->ns.view setLayer:window->ns.layer]; [window->ns.view setLayer:window->ns.layer];
@ -2027,9 +2151,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
} }
return err; return err;
#else
return VK_ERROR_EXTENSION_NOT_PRESENT;
#endif
} // autoreleasepool } // autoreleasepool
} }
@ -2041,18 +2162,37 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(nil); _GLFW_REQUIRE_INIT_OR_RETURN(nil);
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
{ {
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
"Cocoa: Platform not initialized"); "Cocoa: Platform not initialized");
return NULL; return nil;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
return window->ns.object; return window->ns.object;
} }
GLFWAPI id glfwGetCocoaView(GLFWwindow* handle)
{
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
"Cocoa: Platform not initialized");
return nil;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
return window->ns.view;
}
#endif // _GLFW_COCOA #endif // _GLFW_COCOA

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
@ -615,11 +615,11 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
_GLFWwindow* previous; _GLFWwindow* previous;
_GLFW_REQUIRE_INIT();
previous = _glfwPlatformGetTls(&_glfw.contextSlot); previous = _glfwPlatformGetTls(&_glfw.contextSlot);
if (window && window->context.client == GLFW_NO_API) if (window && window->context.client == GLFW_NO_API)
@ -647,11 +647,11 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
GLFWAPI void glfwSwapBuffers(GLFWwindow* handle) GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (window->context.client == GLFW_NO_API) if (window->context.client == GLFW_NO_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, _glfwInputError(GLFW_NO_WINDOW_CONTEXT,

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 EGL - www.glfw.org // GLFW 3.5 EGL - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -92,7 +92,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
EGLConfig* nativeConfigs; EGLConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs; _GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest; const _GLFWfbconfig* closest;
int i, nativeCount, usableCount, apiBit; int i, nativeCount, usableCount, apiBit, surfaceTypeBit;
GLFWbool wrongApiAvailable = GLFW_FALSE; GLFWbool wrongApiAvailable = GLFW_FALSE;
if (ctxconfig->client == GLFW_OPENGL_ES_API) if (ctxconfig->client == GLFW_OPENGL_ES_API)
@ -105,6 +105,11 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
else else
apiBit = EGL_OPENGL_BIT; apiBit = EGL_OPENGL_BIT;
if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA)
surfaceTypeBit = EGL_PBUFFER_BIT;
else
surfaceTypeBit = EGL_WINDOW_BIT;
if (fbconfig->stereo) if (fbconfig->stereo)
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Stereo rendering not supported"); _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Stereo rendering not supported");
@ -133,8 +138,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER) if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
continue; continue;
// Only consider window EGLConfigs if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & surfaceTypeBit))
if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
continue; continue;
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
@ -420,6 +424,8 @@ GLFWbool _glfwInitEGL(void)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext"); _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext");
_glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface) _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface"); _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface");
_glfw.egl.CreatePbufferSurface = (PFN_eglCreatePbufferSurface)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreatePbufferSurface");
_glfw.egl.MakeCurrent = (PFN_eglMakeCurrent) _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent"); _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent");
_glfw.egl.SwapBuffers = (PFN_eglSwapBuffers) _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
@ -442,6 +448,7 @@ GLFWbool _glfwInitEGL(void)
!_glfw.egl.DestroySurface || !_glfw.egl.DestroySurface ||
!_glfw.egl.DestroyContext || !_glfw.egl.DestroyContext ||
!_glfw.egl.CreateWindowSurface || !_glfw.egl.CreateWindowSurface ||
!_glfw.egl.CreatePbufferSurface ||
!_glfw.egl.MakeCurrent || !_glfw.egl.MakeCurrent ||
!_glfw.egl.SwapBuffers || !_glfw.egl.SwapBuffers ||
!_glfw.egl.SwapInterval || !_glfw.egl.SwapInterval ||
@ -477,6 +484,8 @@ GLFWbool _glfwInitEGL(void)
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions); _glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
_glfw.egl.ANGLE_platform_angle_metal = _glfw.egl.ANGLE_platform_angle_metal =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions); _glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
_glfw.egl.MESA_platform_surfaceless =
_glfwStringInExtensionString("EGL_MESA_platform_surfaceless", extensions);
} }
if (_glfw.egl.EXT_platform_base) if (_glfw.egl.EXT_platform_base)
@ -708,20 +717,36 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
} }
if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA)
{
int width, height;
_glfw.platform.getFramebufferSize(window, &width, &height);
SET_ATTRIB(EGL_WIDTH, width);
SET_ATTRIB(EGL_HEIGHT, height);
}
SET_ATTRIB(EGL_NONE, EGL_NONE); SET_ATTRIB(EGL_NONE, EGL_NONE);
native = _glfw.platform.getEGLNativeWindow(window); native = _glfw.platform.getEGLNativeWindow(window);
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT if (!_glfw.egl.platform || _glfw.egl.platform == EGL_PLATFORM_ANGLE_ANGLE)
// despite reporting EGL_EXT_platform_base
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
{ {
// HACK: Also use non-platform function for ANGLE, as it does not
// implement eglCreatePlatformWindowSurfaceEXT despite reporting
// support for EGL_EXT_platform_base
window->context.egl.surface = window->context.egl.surface =
eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs); eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
}
else if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA)
{
// HACK: Use a pbuffer surface as the default framebuffer
window->context.egl.surface =
eglCreatePbufferSurface(_glfw.egl.display, config, attribs);
} }
else else
{ {
window->context.egl.surface = window->context.egl.surface =
eglCreateWindowSurface(_glfw.egl.display, config, native, attribs); eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
} }
if (window->context.egl.surface == EGL_NO_SURFACE) if (window->context.egl.surface == EGL_NO_SURFACE)
@ -883,13 +908,19 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_EGL_CONTEXT_API) if (window->context.source != GLFW_EGL_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND ||
return EGL_NO_CONTEXT; window->context.source != GLFW_NATIVE_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return EGL_NO_CONTEXT;
}
} }
return window->context.egl.handle; return window->context.egl.handle;
@ -897,13 +928,19 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_EGL_CONTEXT_API) if (window->context.source != GLFW_EGL_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND ||
return EGL_NO_SURFACE; window->context.source != GLFW_NATIVE_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return EGL_NO_CONTEXT;
}
} }
return window->context.egl.surface; return window->context.egl.surface;

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 GLX - www.glfw.org // GLFW 3.5 GLX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -677,7 +677,6 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11) if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
@ -686,6 +685,9 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
return NULL; return NULL;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_NATIVE_CONTEXT_API) if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
@ -697,7 +699,6 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None); _GLFW_REQUIRE_INIT_OR_RETURN(None);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11) if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
@ -706,6 +707,9 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
return None; return None;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_NATIVE_CONTEXT_API) if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
@ -49,19 +49,22 @@ static GLFWerrorfun _glfwErrorCallback;
static GLFWallocator _glfwInitAllocator; static GLFWallocator _glfwInitAllocator;
static _GLFWinitconfig _glfwInitHints = static _GLFWinitconfig _glfwInitHints =
{ {
GLFW_TRUE, // hat buttons .hatButtons = GLFW_TRUE,
GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend .angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE,
GLFW_ANY_PLATFORM, // preferred platform .platformID = GLFW_ANY_PLATFORM,
NULL, // vkGetInstanceProcAddr function .vulkanLoader = NULL,
.ns =
{ {
GLFW_TRUE, // macOS menu bar .menubar = GLFW_TRUE,
GLFW_TRUE // macOS bundle chdir .chdir = GLFW_TRUE
}, },
.x11 =
{ {
GLFW_TRUE, // X11 XCB Vulkan surface .xcbVulkanSurface = GLFW_TRUE,
}, },
.wl =
{ {
GLFW_WAYLAND_PREFER_LIBDECOR // Wayland libdecor mode .libdecorMode = GLFW_WAYLAND_PREFER_LIBDECOR
}, },
}; };
@ -243,30 +246,6 @@ int _glfw_max(int a, int b)
return a > b ? a : b; return a > b ? a : b;
} }
float _glfw_fminf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a < b)
return a;
else
return b;
}
float _glfw_fmaxf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a > b)
return a;
else
return b;
}
void* _glfw_calloc(size_t count, size_t size) void* _glfw_calloc(size_t count, size_t size)
{ {
if (count && size) if (count && size)

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -348,20 +348,22 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
{ {
assert(window != NULL); assert(window != NULL);
assert(button >= 0); assert(button >= 0);
assert(button <= GLFW_MOUSE_BUTTON_LAST);
assert(action == GLFW_PRESS || action == GLFW_RELEASE); assert(action == GLFW_PRESS || action == GLFW_RELEASE);
assert(mods == (mods & GLFW_MOD_MASK)); assert(mods == (mods & GLFW_MOD_MASK));
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) if (button < 0 || (!window->disableMouseButtonLimit && button > GLFW_MOUSE_BUTTON_LAST))
return; return;
if (!window->lockKeyMods) if (!window->lockKeyMods)
mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK); mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
if (action == GLFW_RELEASE && window->stickyMouseButtons) if (button <= GLFW_MOUSE_BUTTON_LAST)
window->mouseButtons[button] = _GLFW_STICK; {
else if (action == GLFW_RELEASE && window->stickyMouseButtons)
window->mouseButtons[button] = (char) action; window->mouseButtons[button] = _GLFW_STICK;
else
window->mouseButtons[button] = (char) action;
}
if (window->callbacks.mouseButton) if (window->callbacks.mouseButton)
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods); window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
@ -559,11 +561,11 @@ void _glfwCenterCursorInContentArea(_GLFWwindow* window)
GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode) GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(0);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(0);
switch (mode) switch (mode)
{ {
case GLFW_CURSOR: case GLFW_CURSOR:
@ -576,6 +578,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
return window->lockKeyMods; return window->lockKeyMods;
case GLFW_RAW_MOUSE_MOTION: case GLFW_RAW_MOUSE_MOTION:
return window->rawMouseMotion; return window->rawMouseMotion;
case GLFW_UNLIMITED_MOUSE_BUTTONS:
return window->disableMouseButtonLimit;
} }
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
@ -584,11 +588,11 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
switch (mode) switch (mode)
{ {
case GLFW_CURSOR: case GLFW_CURSOR:
@ -683,6 +687,12 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
_glfw.platform.setRawMouseMotion(window, value); _glfw.platform.setRawMouseMotion(window, value);
return; return;
} }
case GLFW_UNLIMITED_MOUSE_BUTTONS:
{
window->disableMouseButtonLimit = value ? GLFW_TRUE : GLFW_FALSE;
return;
}
} }
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
@ -721,7 +731,7 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
GLFWAPI int glfwGetKeyScancode(int key) GLFWAPI int glfwGetKeyScancode(int key)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(-1); _GLFW_REQUIRE_INIT_OR_RETURN(0);
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST) if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{ {
@ -734,11 +744,11 @@ GLFWAPI int glfwGetKeyScancode(int key)
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key) GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST) if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key); _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
@ -757,11 +767,11 @@ GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button) GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST) if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button); _glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button);
@ -780,9 +790,6 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos) GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (xpos) if (xpos)
*xpos = 0; *xpos = 0;
if (ypos) if (ypos)
@ -790,6 +797,9 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->cursorMode == GLFW_CURSOR_DISABLED) if (window->cursorMode == GLFW_CURSOR_DISABLED)
{ {
if (xpos) if (xpos)
@ -803,11 +813,11 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos) GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX || if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX ||
ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX) ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX)
{ {
@ -897,10 +907,10 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
GLFWAPI void glfwDestroyCursor(GLFWcursor* handle) GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
{ {
_GLFWcursor* cursor = (_GLFWcursor*) handle;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWcursor* cursor = (_GLFWcursor*) handle;
if (cursor == NULL) if (cursor == NULL)
return; return;
@ -932,12 +942,12 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle) GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) windowHandle; _GLFWwindow* window = (_GLFWwindow*) windowHandle;
_GLFWcursor* cursor = (_GLFWcursor*) cursorHandle; _GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
window->cursor = cursor; window->cursor = cursor;
_glfw.platform.setCursor(window, cursor); _glfw.platform.setCursor(window, cursor);
@ -945,30 +955,33 @@ GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun) GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun); _GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun);
return cbfun; return cbfun;
} }
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun) GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun); _GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun);
return cbfun; return cbfun;
} }
GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun) GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun); _GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun);
return cbfun; return cbfun;
} }
@ -976,10 +989,11 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmods
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle, GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
GLFWmousebuttonfun cbfun) GLFWmousebuttonfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun); _GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun);
return cbfun; return cbfun;
} }
@ -987,10 +1001,11 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle, GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
GLFWcursorposfun cbfun) GLFWcursorposfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun); _GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun);
return cbfun; return cbfun;
} }
@ -998,10 +1013,11 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle, GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
GLFWcursorenterfun cbfun) GLFWcursorenterfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun); _GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun);
return cbfun; return cbfun;
} }
@ -1009,20 +1025,22 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle, GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
GLFWscrollfun cbfun) GLFWscrollfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun); _GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun);
return cbfun; return cbfun;
} }
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun) GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun); _GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun);
return cbfun; return cbfun;
} }
@ -1438,7 +1456,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
if (e->type == _GLFW_JOYSTICK_AXIS) if (e->type == _GLFW_JOYSTICK_AXIS)
{ {
const float value = js->axes[e->index] * e->axisScale + e->axisOffset; const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f); state->axes[i] = fminf(fmaxf(value, -1.f), 1.f);
} }
else if (e->type == _GLFW_JOYSTICK_HATBIT) else if (e->type == _GLFW_JOYSTICK_HATBIT)
{ {

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -48,6 +48,8 @@
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include "../include/GLFW/glfw3.h" #include "../include/GLFW/glfw3.h"
#include <stdbool.h>
#define _GLFW_INSERT_FIRST 0 #define _GLFW_INSERT_FIRST 0
#define _GLFW_INSERT_LAST 1 #define _GLFW_INSERT_LAST 1
@ -108,12 +110,6 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
#if defined(_GLFW_WIN32)
#define EGLAPIENTRY __stdcall
#else
#define EGLAPIENTRY
#endif
#define EGL_SUCCESS 0x3000 #define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001 #define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002 #define EGL_BAD_ACCESS 0x3002
@ -156,6 +152,9 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
#define EGL_NO_DISPLAY ((EGLDisplay) 0) #define EGL_NO_DISPLAY ((EGLDisplay) 0)
#define EGL_NO_CONTEXT ((EGLContext) 0) #define EGL_NO_CONTEXT ((EGLContext) 0)
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
#define EGL_PBUFFER_BIT 0x0001
#define EGL_WIDTH 0x3057
#define EGL_HEIGHT 0x3056
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
@ -187,6 +186,7 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 #define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489 #define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f #define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
#define EGL_PLATFORM_SURFACELESS_MESA 0x31dd
typedef int EGLint; typedef int EGLint;
typedef unsigned int EGLBoolean; typedef unsigned int EGLBoolean;
@ -200,22 +200,23 @@ typedef void* EGLNativeDisplayType;
typedef void* EGLNativeWindowType; typedef void* EGLNativeWindowType;
// EGL function pointer typedefs // EGL function pointer typedefs
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); typedef EGLBoolean (APIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); typedef EGLBoolean (APIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); typedef EGLDisplay (APIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void); typedef EGLint (APIENTRY * PFN_eglGetError)(void);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); typedef EGLBoolean (APIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay); typedef EGLBoolean (APIENTRY * PFN_eglTerminate)(EGLDisplay);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum); typedef EGLBoolean (APIENTRY * PFN_eglBindAPI)(EGLenum);
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); typedef EGLContext (APIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); typedef EGLBoolean (APIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); typedef EGLBoolean (APIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); typedef EGLSurface (APIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); typedef EGLSurface (APIENTRY * PFN_eglCreatePbufferSurface)(EGLDisplay,EGLContext,const EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); typedef EGLBoolean (APIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); typedef EGLBoolean (APIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); typedef EGLBoolean (APIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); typedef const char* (APIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
typedef GLFWglproc (APIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
#define eglGetConfigs _glfw.egl.GetConfigs #define eglGetConfigs _glfw.egl.GetConfigs
#define eglGetDisplay _glfw.egl.GetDisplay #define eglGetDisplay _glfw.egl.GetDisplay
@ -227,14 +228,15 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglDestroySurface _glfw.egl.DestroySurface #define eglDestroySurface _glfw.egl.DestroySurface
#define eglDestroyContext _glfw.egl.DestroyContext #define eglDestroyContext _glfw.egl.DestroyContext
#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface #define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
#define eglCreatePbufferSurface _glfw.egl.CreatePbufferSurface
#define eglMakeCurrent _glfw.egl.MakeCurrent #define eglMakeCurrent _glfw.egl.MakeCurrent
#define eglSwapBuffers _glfw.egl.SwapBuffers #define eglSwapBuffers _glfw.egl.SwapBuffers
#define eglSwapInterval _glfw.egl.SwapInterval #define eglSwapInterval _glfw.egl.SwapInterval
#define eglQueryString _glfw.egl.QueryString #define eglQueryString _glfw.egl.QueryString
#define eglGetProcAddress _glfw.egl.GetProcAddress #define eglGetProcAddress _glfw.egl.GetProcAddress
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); typedef EGLDisplay (APIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); typedef EGLSurface (APIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT #define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT #define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
@ -283,6 +285,7 @@ typedef enum VkStructureType
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000,
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkStructureType; } VkStructureType;
@ -330,6 +333,9 @@ typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const c
#include "platform.h" #include "platform.h"
#define GLFW_NATIVE_INCLUDE_NONE
#include "../include/GLFW/glfw3native.h"
// Checks for whether the library has been initialized // Checks for whether the library has been initialized
#define _GLFW_REQUIRE_INIT() \ #define _GLFW_REQUIRE_INIT() \
if (!_glfw.initialized) \ if (!_glfw.initialized) \
@ -408,8 +414,8 @@ struct _GLFWwndconfig
GLFWbool focusOnShow; GLFWbool focusOnShow;
GLFWbool mousePassthrough; GLFWbool mousePassthrough;
GLFWbool scaleToMonitor; GLFWbool scaleToMonitor;
GLFWbool scaleFramebuffer;
struct { struct {
GLFWbool retina;
char frameName[256]; char frameName[256];
} ns; } ns;
struct { struct {
@ -418,6 +424,7 @@ struct _GLFWwndconfig
} x11; } x11;
struct { struct {
GLFWbool keymenu; GLFWbool keymenu;
GLFWbool showDefault;
} win32; } win32;
struct { struct {
char appId[256]; char appId[256];
@ -537,6 +544,7 @@ struct _GLFWwindow
GLFWvidmode videoMode; GLFWvidmode videoMode;
_GLFWmonitor* monitor; _GLFWmonitor* monitor;
_GLFWcursor* cursor; _GLFWcursor* cursor;
char* title;
int minwidth, minheight; int minwidth, minheight;
int maxwidth, maxheight; int maxwidth, maxheight;
@ -545,6 +553,7 @@ struct _GLFWwindow
GLFWbool stickyKeys; GLFWbool stickyKeys;
GLFWbool stickyMouseButtons; GLFWbool stickyMouseButtons;
GLFWbool lockKeyMods; GLFWbool lockKeyMods;
GLFWbool disableMouseButtonLimit;
int cursorMode; int cursorMode;
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
char keys[GLFW_KEY_LAST + 1]; char keys[GLFW_KEY_LAST + 1];
@ -701,7 +710,7 @@ struct _GLFWplatform
void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*); void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*);
void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*); void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*);
GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*); GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*);
void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); GLFWbool (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*);
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*); GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
// window // window
@ -709,6 +718,7 @@ struct _GLFWplatform
void (*destroyWindow)(_GLFWwindow*); void (*destroyWindow)(_GLFWwindow*);
void (*setWindowTitle)(_GLFWwindow*,const char*); void (*setWindowTitle)(_GLFWwindow*,const char*);
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
void (*setWindowProgressIndicator)(_GLFWwindow*,const int,double);
void (*getWindowPos)(_GLFWwindow*,int*,int*); void (*getWindowPos)(_GLFWwindow*,int*,int*);
void (*setWindowPos)(_GLFWwindow*,int,int); void (*setWindowPos)(_GLFWwindow*,int,int);
void (*getWindowSize)(_GLFWwindow*,int*,int*); void (*getWindowSize)(_GLFWwindow*,int*,int*);
@ -812,6 +822,7 @@ struct _GLFWlibrary
GLFWbool ANGLE_platform_angle_d3d; GLFWbool ANGLE_platform_angle_d3d;
GLFWbool ANGLE_platform_angle_vulkan; GLFWbool ANGLE_platform_angle_vulkan;
GLFWbool ANGLE_platform_angle_metal; GLFWbool ANGLE_platform_angle_metal;
GLFWbool MESA_platform_surfaceless;
void* handle; void* handle;
@ -826,6 +837,7 @@ struct _GLFWlibrary
PFN_eglDestroySurface DestroySurface; PFN_eglDestroySurface DestroySurface;
PFN_eglDestroyContext DestroyContext; PFN_eglDestroyContext DestroyContext;
PFN_eglCreateWindowSurface CreateWindowSurface; PFN_eglCreateWindowSurface CreateWindowSurface;
PFN_eglCreatePbufferSurface CreatePbufferSurface;
PFN_eglMakeCurrent MakeCurrent; PFN_eglMakeCurrent MakeCurrent;
PFN_eglSwapBuffers SwapBuffers; PFN_eglSwapBuffers SwapBuffers;
PFN_eglSwapInterval SwapInterval; PFN_eglSwapInterval SwapInterval;
@ -861,6 +873,7 @@ struct _GLFWlibrary
GLFWbool KHR_xlib_surface; GLFWbool KHR_xlib_surface;
GLFWbool KHR_xcb_surface; GLFWbool KHR_xcb_surface;
GLFWbool KHR_wayland_surface; GLFWbool KHR_wayland_surface;
GLFWbool EXT_headless_surface;
} vk; } vk;
struct { struct {
@ -872,6 +885,7 @@ struct _GLFWlibrary
GLFW_PLATFORM_LIBRARY_WINDOW_STATE GLFW_PLATFORM_LIBRARY_WINDOW_STATE
GLFW_PLATFORM_LIBRARY_CONTEXT_STATE GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
GLFW_PLATFORM_LIBRARY_DBUS_STATE
}; };
// Global state shared between compilation units of GLFW // Global state shared between compilation units of GLFW
@ -1003,8 +1017,6 @@ char** _glfwParseUriList(char* text, int* count);
char* _glfw_strdup(const char* source); char* _glfw_strdup(const char* source);
int _glfw_min(int a, int b); int _glfw_min(int a, int b);
int _glfw_max(int a, int b); int _glfw_max(int a, int b);
float _glfw_fminf(float a, float b);
float _glfw_fmaxf(float a, float b);
void* _glfw_calloc(size_t count, size_t size); void* _glfw_calloc(size_t count, size_t size);
void* _glfw_realloc(void* pointer, size_t size); void* _glfw_realloc(void* pointer, size_t size);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Linux - www.glfw.org // GLFW 3.5 Linux - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@ -135,7 +135,7 @@ static GLFWbool openJoystickDevice(const char* path)
} }
_GLFWjoystickLinux linjs = {0}; _GLFWjoystickLinux linjs = {0};
linjs.fd = open(path, O_RDONLY | O_NONBLOCK); linjs.fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (linjs.fd == -1) if (linjs.fd == -1)
return GLFW_FALSE; return GLFW_FALSE;

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Linux - www.glfw.org // GLFW 3.5 Linux - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -325,9 +325,6 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos) GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (xpos) if (xpos)
*xpos = 0; *xpos = 0;
if (ypos) if (ypos)
@ -335,6 +332,9 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_glfw.platform.getMonitorPos(monitor, xpos, ypos); _glfw.platform.getMonitorPos(monitor, xpos, ypos);
} }
@ -342,9 +342,6 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
int* xpos, int* ypos, int* xpos, int* ypos,
int* width, int* height) int* width, int* height)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (xpos) if (xpos)
*xpos = 0; *xpos = 0;
if (ypos) if (ypos)
@ -356,14 +353,14 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height); _glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height);
} }
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM) GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (widthMM) if (widthMM)
*widthMM = 0; *widthMM = 0;
if (heightMM) if (heightMM)
@ -371,6 +368,9 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int*
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (widthMM) if (widthMM)
*widthMM = monitor->widthMM; *widthMM = monitor->widthMM;
if (heightMM) if (heightMM)
@ -380,42 +380,46 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int*
GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle, GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
float* xscale, float* yscale) float* xscale, float* yscale)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (xscale) if (xscale)
*xscale = 0.f; *xscale = 0.f;
if (yscale) if (yscale)
*yscale = 0.f; *yscale = 0.f;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_glfw.platform.getMonitorContentScale(monitor, xscale, yscale); _glfw.platform.getMonitorContentScale(monitor, xscale, yscale);
} }
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle) GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL); assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->name; return monitor->name;
} }
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer) GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
{ {
_GLFW_REQUIRE_INIT();
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL); assert(monitor != NULL);
_GLFW_REQUIRE_INIT();
monitor->userPointer = pointer; monitor->userPointer = pointer;
} }
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle) GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL); assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->userPointer; return monitor->userPointer;
} }
@ -428,14 +432,15 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count) GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
assert(count != NULL); assert(count != NULL);
*count = 0; *count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (!refreshVideoModes(monitor)) if (!refreshVideoModes(monitor))
return NULL; return NULL;
@ -445,12 +450,14 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle) GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL); assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (!_glfw.platform.getVideoMode(monitor, &monitor->currentMode))
return NULL;
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
return &monitor->currentMode; return &monitor->currentMode;
} }
@ -460,12 +467,13 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
unsigned short* values; unsigned short* values;
GLFWgammaramp ramp; GLFWgammaramp ramp;
const GLFWgammaramp* original; const GLFWgammaramp* original;
assert(handle != NULL);
assert(gamma > 0.f); assert(gamma > 0.f);
assert(gamma <= FLT_MAX); assert(gamma <= FLT_MAX);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
assert(handle != NULL);
if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX) if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma); _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
@ -487,7 +495,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
// Apply gamma curve // Apply gamma curve
value = powf(value, 1.f / gamma) * 65535.f + 0.5f; value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
// Clamp to value range // Clamp to value range
value = _glfw_fminf(value, 65535.f); value = fminf(value, 65535.f);
values[i] = (unsigned short) value; values[i] = (unsigned short) value;
} }
@ -503,11 +511,11 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle) GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL); assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_glfwFreeGammaArrays(&monitor->currentRamp); _glfwFreeGammaArrays(&monitor->currentRamp);
if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp)) if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp))
return NULL; return NULL;
@ -517,8 +525,6 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
assert(ramp != NULL); assert(ramp != NULL);
assert(ramp->size > 0); assert(ramp->size > 0);
assert(ramp->red != NULL); assert(ramp->red != NULL);
@ -527,6 +533,9 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (ramp->size <= 0) if (ramp->size <= 0)
{ {
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 macOS - www.glfw.org // GLFW 3.5 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@ -23,8 +23,6 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@ -32,6 +30,7 @@
#include <unistd.h> #include <unistd.h>
#include <math.h> #include <math.h>
#include <assert.h>
static void makeContextCurrentNSGL(_GLFWwindow* window) static void makeContextCurrentNSGL(_GLFWwindow* window)
{ {
@ -163,7 +162,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
if (ctxconfig->client == GLFW_OPENGL_ES_API) if (ctxconfig->client == GLFW_OPENGL_ES_API)
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: OpenGL ES is not available on macOS"); "NSGL: OpenGL ES is not available via NSGL");
return GLFW_FALSE; return GLFW_FALSE;
} }
@ -177,16 +176,23 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
} }
} }
// Context robustness modes (GL_KHR_robustness) are not yet supported by if (ctxconfig->major >= 3 && ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The compatibility profile is not available on macOS");
return GLFW_FALSE;
}
// Context robustness modes (GL_KHR_robustness) are not supported by
// macOS but are not a hard constraint, so ignore and continue // macOS but are not a hard constraint, so ignore and continue
// Context release behaviors (GL_KHR_context_flush_control) are not yet // Context release behaviors (GL_KHR_context_flush_control) are not
// supported by macOS but are not a hard constraint, so ignore and continue // supported by macOS but are not a hard constraint, so ignore and continue
// Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not // Debug contexts (GL_KHR_debug) are not supported by macOS but are not
// a hard constraint, so ignore and continue // a hard constraint, so ignore and continue
// No-error contexts (GL_KHR_no_error) are not yet supported by macOS but // No-error contexts (GL_KHR_no_error) are not supported by macOS but
// are not a hard constraint, so ignore and continue // are not a hard constraint, so ignore and continue
#define ADD_ATTRIB(a) \ #define ADD_ATTRIB(a) \
@ -212,14 +218,11 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching); ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching);
} }
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
if (ctxconfig->major >= 4) if (ctxconfig->major >= 4)
{ {
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core); SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
} }
else else if (ctxconfig->major >= 3)
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
if (ctxconfig->major >= 3)
{ {
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core); SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
} }
@ -335,7 +338,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
forParameter:NSOpenGLContextParameterSurfaceOpacity]; forParameter:NSOpenGLContextParameterSurfaceOpacity];
} }
[window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina]; [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.scaleFramebuffer];
[window->context.nsgl.object setView:window->ns.view]; [window->context.nsgl.object setView:window->ns.view];
@ -356,7 +359,6 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(nil); _GLFW_REQUIRE_INIT_OR_RETURN(nil);
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
@ -366,6 +368,9 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
return nil; return nil;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_NATIVE_CONTEXT_API) if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
@ -39,78 +39,79 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
{ {
const _GLFWplatform null = const _GLFWplatform null =
{ {
GLFW_PLATFORM_NULL, .platformID = GLFW_PLATFORM_NULL,
_glfwInitNull, .init = _glfwInitNull,
_glfwTerminateNull, .terminate = _glfwTerminateNull,
_glfwGetCursorPosNull, .getCursorPos = _glfwGetCursorPosNull,
_glfwSetCursorPosNull, .setCursorPos = _glfwSetCursorPosNull,
_glfwSetCursorModeNull, .setCursorMode = _glfwSetCursorModeNull,
_glfwSetRawMouseMotionNull, .setRawMouseMotion = _glfwSetRawMouseMotionNull,
_glfwRawMouseMotionSupportedNull, .rawMouseMotionSupported = _glfwRawMouseMotionSupportedNull,
_glfwCreateCursorNull, .createCursor = _glfwCreateCursorNull,
_glfwCreateStandardCursorNull, .createStandardCursor = _glfwCreateStandardCursorNull,
_glfwDestroyCursorNull, .destroyCursor = _glfwDestroyCursorNull,
_glfwSetCursorNull, .setCursor = _glfwSetCursorNull,
_glfwGetScancodeNameNull, .getScancodeName = _glfwGetScancodeNameNull,
_glfwGetKeyScancodeNull, .getKeyScancode = _glfwGetKeyScancodeNull,
_glfwSetClipboardStringNull, .setClipboardString = _glfwSetClipboardStringNull,
_glfwGetClipboardStringNull, .getClipboardString = _glfwGetClipboardStringNull,
_glfwInitJoysticksNull, .initJoysticks = _glfwInitJoysticksNull,
_glfwTerminateJoysticksNull, .terminateJoysticks = _glfwTerminateJoysticksNull,
_glfwPollJoystickNull, .pollJoystick = _glfwPollJoystickNull,
_glfwGetMappingNameNull, .getMappingName = _glfwGetMappingNameNull,
_glfwUpdateGamepadGUIDNull, .updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
_glfwFreeMonitorNull, .freeMonitor = _glfwFreeMonitorNull,
_glfwGetMonitorPosNull, .getMonitorPos = _glfwGetMonitorPosNull,
_glfwGetMonitorContentScaleNull, .getMonitorContentScale = _glfwGetMonitorContentScaleNull,
_glfwGetMonitorWorkareaNull, .getMonitorWorkarea = _glfwGetMonitorWorkareaNull,
_glfwGetVideoModesNull, .getVideoModes = _glfwGetVideoModesNull,
_glfwGetVideoModeNull, .getVideoMode = _glfwGetVideoModeNull,
_glfwGetGammaRampNull, .getGammaRamp = _glfwGetGammaRampNull,
_glfwSetGammaRampNull, .setGammaRamp = _glfwSetGammaRampNull,
_glfwCreateWindowNull, .createWindow = _glfwCreateWindowNull,
_glfwDestroyWindowNull, .destroyWindow = _glfwDestroyWindowNull,
_glfwSetWindowTitleNull, .setWindowTitle = _glfwSetWindowTitleNull,
_glfwSetWindowIconNull, .setWindowIcon = _glfwSetWindowIconNull,
_glfwGetWindowPosNull, .setWindowProgressIndicator = _glfwSetWindowProgressIndicatorNull,
_glfwSetWindowPosNull, .getWindowPos = _glfwGetWindowPosNull,
_glfwGetWindowSizeNull, .setWindowPos = _glfwSetWindowPosNull,
_glfwSetWindowSizeNull, .getWindowSize = _glfwGetWindowSizeNull,
_glfwSetWindowSizeLimitsNull, .setWindowSize = _glfwSetWindowSizeNull,
_glfwSetWindowAspectRatioNull, .setWindowSizeLimits = _glfwSetWindowSizeLimitsNull,
_glfwGetFramebufferSizeNull, .setWindowAspectRatio = _glfwSetWindowAspectRatioNull,
_glfwGetWindowFrameSizeNull, .getFramebufferSize = _glfwGetFramebufferSizeNull,
_glfwGetWindowContentScaleNull, .getWindowFrameSize = _glfwGetWindowFrameSizeNull,
_glfwIconifyWindowNull, .getWindowContentScale = _glfwGetWindowContentScaleNull,
_glfwRestoreWindowNull, .iconifyWindow = _glfwIconifyWindowNull,
_glfwMaximizeWindowNull, .restoreWindow = _glfwRestoreWindowNull,
_glfwShowWindowNull, .maximizeWindow = _glfwMaximizeWindowNull,
_glfwHideWindowNull, .showWindow = _glfwShowWindowNull,
_glfwRequestWindowAttentionNull, .hideWindow = _glfwHideWindowNull,
_glfwFocusWindowNull, .requestWindowAttention = _glfwRequestWindowAttentionNull,
_glfwSetWindowMonitorNull, .focusWindow = _glfwFocusWindowNull,
_glfwWindowFocusedNull, .setWindowMonitor = _glfwSetWindowMonitorNull,
_glfwWindowIconifiedNull, .windowFocused = _glfwWindowFocusedNull,
_glfwWindowVisibleNull, .windowIconified = _glfwWindowIconifiedNull,
_glfwWindowMaximizedNull, .windowVisible = _glfwWindowVisibleNull,
_glfwWindowHoveredNull, .windowMaximized = _glfwWindowMaximizedNull,
_glfwFramebufferTransparentNull, .windowHovered = _glfwWindowHoveredNull,
_glfwGetWindowOpacityNull, .framebufferTransparent = _glfwFramebufferTransparentNull,
_glfwSetWindowResizableNull, .getWindowOpacity = _glfwGetWindowOpacityNull,
_glfwSetWindowDecoratedNull, .setWindowResizable = _glfwSetWindowResizableNull,
_glfwSetWindowFloatingNull, .setWindowDecorated = _glfwSetWindowDecoratedNull,
_glfwSetWindowOpacityNull, .setWindowFloating = _glfwSetWindowFloatingNull,
_glfwSetWindowMousePassthroughNull, .setWindowOpacity = _glfwSetWindowOpacityNull,
_glfwPollEventsNull, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughNull,
_glfwWaitEventsNull, .pollEvents = _glfwPollEventsNull,
_glfwWaitEventsTimeoutNull, .waitEvents = _glfwWaitEventsNull,
_glfwPostEmptyEventNull, .waitEventsTimeout = _glfwWaitEventsTimeoutNull,
_glfwGetEGLPlatformNull, .postEmptyEvent = _glfwPostEmptyEventNull,
_glfwGetEGLNativeDisplayNull, .getEGLPlatform = _glfwGetEGLPlatformNull,
_glfwGetEGLNativeWindowNull, .getEGLNativeDisplay = _glfwGetEGLNativeDisplayNull,
_glfwGetRequiredInstanceExtensionsNull, .getEGLNativeWindow = _glfwGetEGLNativeWindowNull,
_glfwGetPhysicalDevicePresentationSupportNull, .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsNull,
_glfwCreateWindowSurfaceNull, .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportNull,
.createWindowSurface = _glfwCreateWindowSurfaceNull
}; };
*platform = null; *platform = null;

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
@ -109,9 +109,10 @@ GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
return mode; return mode;
} }
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
*mode = getVideoMode(); *mode = getVideoMode();
return GLFW_TRUE;
} }
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -128,7 +129,7 @@ GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
float value; float value;
value = i / (float) (monitor->null.ramp.size - 1); value = i / (float) (monitor->null.ramp.size - 1);
value = powf(value, 1.f / gamma) * 65535.f + 0.5f; value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
value = _glfw_fminf(value, 65535.f); value = fminf(value, 65535.f);
monitor->null.ramp.red[i] = (unsigned short) value; monitor->null.ramp.red[i] = (unsigned short) value;
monitor->null.ramp.green[i] = (unsigned short) value; monitor->null.ramp.green[i] = (unsigned short) value;

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
@ -156,6 +156,17 @@
#define GLFW_NULL_SC_MENU 120 #define GLFW_NULL_SC_MENU 120
#define GLFW_NULL_SC_LAST GLFW_NULL_SC_MENU #define GLFW_NULL_SC_LAST GLFW_NULL_SC_MENU
typedef VkFlags VkHeadlessSurfaceCreateFlagsEXT;
typedef struct VkHeadlessSurfaceCreateInfoEXT
{
VkStructureType sType;
const void* pNext;
VkHeadlessSurfaceCreateFlagsEXT flags;
} VkHeadlessSurfaceCreateInfoEXT;
typedef VkResult (APIENTRY *PFN_vkCreateHeadlessSurfaceEXT)(VkInstance,const VkHeadlessSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
// Null-specific per-window data // Null-specific per-window data
// //
typedef struct _GLFWwindowNull typedef struct _GLFWwindowNull
@ -164,7 +175,6 @@ typedef struct _GLFWwindowNull
int ypos; int ypos;
int width; int width;
int height; int height;
char* title;
GLFWbool visible; GLFWbool visible;
GLFWbool iconified; GLFWbool iconified;
GLFWbool maximized; GLFWbool maximized;
@ -205,7 +215,7 @@ void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found); GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp); GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
@ -213,6 +223,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndcon
void _glfwDestroyWindowNull(_GLFWwindow* window); void _glfwDestroyWindowNull(_GLFWwindow* window);
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowProgressIndicatorNull(_GLFWwindow* window, int progressState, double value);
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos); void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
@ -28,6 +28,7 @@
#include "internal.h" #include "internal.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
static void applySizeLimits(_GLFWwindow* window, int* width, int* height) static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
{ {
@ -185,6 +186,10 @@ void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* ima
{ {
} }
void _glfwSetWindowProgressIndicatorNull(_GLFWwindow* window, int progressState, double value)
{
}
void _glfwSetWindowMonitorNull(_GLFWwindow* window, void _glfwSetWindowMonitorNull(_GLFWwindow* window,
_GLFWmonitor* monitor, _GLFWmonitor* monitor,
int xpos, int ypos, int xpos, int ypos,
@ -258,8 +263,9 @@ void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height)
{ {
window->null.width = width; window->null.width = width;
window->null.height = height; window->null.height = height;
_glfwInputWindowSize(window, width, height);
_glfwInputFramebufferSize(window, width, height); _glfwInputFramebufferSize(window, width, height);
_glfwInputWindowDamage(window);
_glfwInputWindowSize(window, width, height);
} }
} }
@ -551,12 +557,15 @@ const char* _glfwGetClipboardStringNull(void)
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs) EGLenum _glfwGetEGLPlatformNull(EGLint** attribs)
{ {
return 0; if (_glfw.egl.EXT_platform_base && _glfw.egl.MESA_platform_surfaceless)
return EGL_PLATFORM_SURFACELESS_MESA;
else
return 0;
} }
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void) EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void)
{ {
return 0; return EGL_DEFAULT_DISPLAY;
} }
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window) EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
@ -698,13 +707,18 @@ int _glfwGetKeyScancodeNull(int key)
void _glfwGetRequiredInstanceExtensionsNull(char** extensions) void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
{ {
if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_headless_surface)
return;
extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_EXT_headless_surface";
} }
GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
VkPhysicalDevice device, VkPhysicalDevice device,
uint32_t queuefamily) uint32_t queuefamily)
{ {
return GLFW_FALSE; return GLFW_TRUE;
} }
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
@ -712,7 +726,28 @@ VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
const VkAllocationCallbacks* allocator, const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface) VkSurfaceKHR* surface)
{ {
// This seems like the most appropriate error to return here PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT =
return VK_ERROR_EXTENSION_NOT_PRESENT; (PFN_vkCreateHeadlessSurfaceEXT)
vkGetInstanceProcAddr(instance, "vkCreateHeadlessSurfaceEXT");
if (!vkCreateHeadlessSurfaceEXT)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Null: Vulkan instance missing VK_EXT_headless_surface extension");
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
VkHeadlessSurfaceCreateInfoEXT sci;
memset(&sci, 0, sizeof(sci));
sci.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT;
const VkResult err = vkCreateHeadlessSurfaceEXT(instance, &sci, allocator, surface);
if (err)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Null: Failed to create Vulkan surface: %s",
_glfwGetVulkanResultString(err));
}
return err;
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 OSMesa - www.glfw.org // GLFW 3.5 OSMesa - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
@ -25,13 +25,12 @@
// //
//======================================================================== //========================================================================
#include "internal.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include "internal.h"
static void makeContextCurrentOSMesa(_GLFWwindow* window) static void makeContextCurrentOSMesa(_GLFWwindow* window)
{ {
if (window) if (window)
@ -297,11 +296,12 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
{ {
void* mesaBuffer; void* mesaBuffer;
GLint mesaWidth, mesaHeight, mesaFormat; GLint mesaWidth, mesaHeight, mesaFormat;
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_OSMESA_CONTEXT_API) if (window->context.source != GLFW_OSMESA_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
@ -336,11 +336,12 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
{ {
void* mesaBuffer; void* mesaBuffer;
GLint mesaWidth, mesaHeight, mesaBytes; GLint mesaWidth, mesaHeight, mesaBytes;
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_OSMESA_CONTEXT_API) if (window->context.source != GLFW_OSMESA_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
@ -370,9 +371,11 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_OSMESA_CONTEXT_API) if (window->context.source != GLFW_OSMESA_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
@ -27,6 +27,9 @@
#include "internal.h" #include "internal.h"
#include <string.h>
#include <stdlib.h>
// These construct a string literal from individual numeric constants // These construct a string literal from individual numeric constants
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r #define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r) #define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
@ -47,12 +50,12 @@ static const struct
#if defined(_GLFW_COCOA) #if defined(_GLFW_COCOA)
{ GLFW_PLATFORM_COCOA, _glfwConnectCocoa }, { GLFW_PLATFORM_COCOA, _glfwConnectCocoa },
#endif #endif
#if defined(_GLFW_X11)
{ GLFW_PLATFORM_X11, _glfwConnectX11 },
#endif
#if defined(_GLFW_WAYLAND) #if defined(_GLFW_WAYLAND)
{ GLFW_PLATFORM_WAYLAND, _glfwConnectWayland }, { GLFW_PLATFORM_WAYLAND, _glfwConnectWayland },
#endif #endif
#if defined(_GLFW_X11)
{ GLFW_PLATFORM_X11, _glfwConnectX11 },
#endif
}; };
GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
@ -80,6 +83,22 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
return GLFW_FALSE; return GLFW_FALSE;
} }
#if defined(_GLFW_WAYLAND) && defined(_GLFW_X11)
if (desiredID == GLFW_ANY_PLATFORM)
{
const char* const session = getenv("XDG_SESSION_TYPE");
if (session)
{
// Only follow XDG_SESSION_TYPE if it is set correctly and the
// environment looks plausble; otherwise fall back to detection
if (strcmp(session, "wayland") == 0 && getenv("WAYLAND_DISPLAY"))
desiredID = GLFW_PLATFORM_WAYLAND;
else if (strcmp(session, "x11") == 0 && getenv("DISPLAY"))
desiredID = GLFW_PLATFORM_X11;
}
}
#endif
if (desiredID == GLFW_ANY_PLATFORM) if (desiredID == GLFW_ANY_PLATFORM)
{ {
// If there is exactly one platform available for auto-selection, let it emit the // If there is exactly one platform available for auto-selection, let it emit the

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
@ -38,9 +38,13 @@
#endif #endif
#include "null_platform.h" #include "null_platform.h"
#define GLFW_EXPOSE_NATIVE_EGL
#define GLFW_EXPOSE_NATIVE_OSMESA
#if defined(_GLFW_WIN32) #if defined(_GLFW_WIN32)
#include "win32_platform.h" #include "win32_platform.h"
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#else #else
#define GLFW_WIN32_WINDOW_STATE #define GLFW_WIN32_WINDOW_STATE
#define GLFW_WIN32_MONITOR_STATE #define GLFW_WIN32_MONITOR_STATE
@ -52,6 +56,8 @@
#if defined(_GLFW_COCOA) #if defined(_GLFW_COCOA)
#include "cocoa_platform.h" #include "cocoa_platform.h"
#define GLFW_EXPOSE_NATIVE_COCOA
#define GLFW_EXPOSE_NATIVE_NSGL
#else #else
#define GLFW_COCOA_WINDOW_STATE #define GLFW_COCOA_WINDOW_STATE
#define GLFW_COCOA_MONITOR_STATE #define GLFW_COCOA_MONITOR_STATE
@ -63,6 +69,7 @@
#if defined(_GLFW_WAYLAND) #if defined(_GLFW_WAYLAND)
#include "wl_platform.h" #include "wl_platform.h"
#define GLFW_EXPOSE_NATIVE_WAYLAND
#else #else
#define GLFW_WAYLAND_WINDOW_STATE #define GLFW_WAYLAND_WINDOW_STATE
#define GLFW_WAYLAND_MONITOR_STATE #define GLFW_WAYLAND_MONITOR_STATE
@ -72,6 +79,8 @@
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
#include "x11_platform.h" #include "x11_platform.h"
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
#else #else
#define GLFW_X11_WINDOW_STATE #define GLFW_X11_WINDOW_STATE
#define GLFW_X11_MONITOR_STATE #define GLFW_X11_MONITOR_STATE
@ -178,6 +187,7 @@
#define GLFW_BUILD_COCOA_TIMER #define GLFW_BUILD_COCOA_TIMER
#else #else
#define GLFW_BUILD_POSIX_TIMER #define GLFW_BUILD_POSIX_TIMER
#define GLFW_BUILD_POSIX_DBUS
#endif #endif
#if defined(GLFW_BUILD_WIN32_TIMER) #if defined(GLFW_BUILD_WIN32_TIMER)
@ -191,6 +201,13 @@
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
#endif #endif
#if defined(GLFW_BUILD_POSIX_DBUS)
#include "posix_dbus.h"
#define GLFW_PLATFORM_LIBRARY_DBUS_STATE GLFW_POSIX_LIBRARY_DBUS_STATE
#else
#define GLFW_PLATFORM_LIBRARY_DBUS_STATE
#endif
#if defined(_WIN32) #if defined(_WIN32)
#define GLFW_BUILD_WIN32_MODULE #define GLFW_BUILD_WIN32_MODULE
#else #else

473
src/posix_dbus.c Normal file
View File

@ -0,0 +1,473 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2023 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#define _GNU_SOURCE
#include "internal.h"
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
void _glfwInitDBusPOSIX(void)
{
//Initialize DBus library functions
_glfw.dbus.handle = NULL;
_glfw.dbus.connection = NULL;
_glfw.dbus.handle = _glfwPlatformLoadModule("libdbus-1.so.3");
if (!_glfw.dbus.handle)
return;
_glfw.dbus.error_init = (PFN_dbus_error_init)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_init");
_glfw.dbus.error_is_set = (PFN_dbus_error_is_set)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_is_set");
_glfw.dbus.error_free = (PFN_dbus_error_free)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_free");
_glfw.dbus.connection_unref = (PFN_dbus_connection_unref)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_unref");
_glfw.dbus.connection_send = (PFN_dbus_connection_send)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_send");
_glfw.dbus.connection_flush = (PFN_dbus_connection_flush)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_connection_flush");
_glfw.dbus.bus_request_name = (PFN_dbus_bus_request_name)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_bus_request_name");
_glfw.dbus.bus_get = (PFN_dbus_bus_get)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_bus_get");
_glfw.dbus.message_unref = (PFN_dbus_message_unref)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_unref");
_glfw.dbus.message_new_signal = (PFN_dbus_message_new_signal)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_new_signal");
_glfw.dbus.message_iter_init_append = (PFN_dbus_message_iter_init_append)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_init_append");
_glfw.dbus.message_iter_append_basic = (PFN_dbus_message_iter_append_basic)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_append_basic");
_glfw.dbus.message_iter_open_container = (PFN_dbus_message_iter_open_container)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_open_container");
_glfw.dbus.message_iter_close_container = (PFN_dbus_message_iter_close_container)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_close_container");
if (!_glfw.dbus.error_init ||
!_glfw.dbus.error_is_set ||
!_glfw.dbus.error_free ||
!_glfw.dbus.connection_unref ||
!_glfw.dbus.connection_send ||
!_glfw.dbus.connection_flush ||
!_glfw.dbus.bus_request_name ||
!_glfw.dbus.bus_get ||
!_glfw.dbus.message_unref ||
!_glfw.dbus.message_new_signal ||
!_glfw.dbus.message_iter_init_append ||
!_glfw.dbus.message_iter_append_basic ||
!_glfw.dbus.message_iter_open_container ||
!_glfw.dbus.message_iter_close_container)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"POSIX: Failed to load DBus entry points");
return;
}
//Initialize DBus connection
dbus_error_init(&_glfw.dbus.error);
_glfw.dbus.connection = dbus_bus_get(DBUS_BUS_SESSION, &_glfw.dbus.error);
//Check for errors
if(dbus_error_is_set(&_glfw.dbus.error) || !_glfw.dbus.connection)
{
if(dbus_error_is_set(&_glfw.dbus.error))
dbus_error_free(&_glfw.dbus.error);
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to connect to DBus");
dbus_connection_unref(_glfw.dbus.connection);
_glfw.dbus.connection = NULL;
return;
}
else
{
//Request name
_glfwCacheLegalExecutableNameDBusPOSIX();
if(!_glfw.dbus.legalExecutableName)
return;
//"org.glfw.<exe_name>_<pid>"
char* busName = _glfw_calloc(21 + strlen(_glfw.dbus.legalExecutableName), sizeof(char));
if(!busName)
{
_glfwInputError(GLFW_OUT_OF_MEMORY, "Failed to allocate memory for bus name");
return;
}
memset(busName, '\0', (21 + strlen(_glfw.dbus.legalExecutableName)) * sizeof(char));
const pid_t pid = getpid();
sprintf(busName, "org.glfw.%s_%d", _glfw.dbus.legalExecutableName, pid);
const int res = dbus_bus_request_name(_glfw.dbus.connection, busName, DBUS_NAME_FLAG_REPLACE_EXISTING, &_glfw.dbus.error);
_glfw_free(busName);
//Check for errors
if(dbus_error_is_set(&_glfw.dbus.error) || res != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
{
if(dbus_error_is_set(&_glfw.dbus.error))
dbus_error_free(&_glfw.dbus.error);
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to request DBus name");
dbus_connection_unref(_glfw.dbus.connection);
_glfw.dbus.connection = NULL;
}
}
_glfwCacheFullExecutableNameDBusPOSIX();
_glfwCacheDesktopFilePathDBusPOSIX();
_glfwCacheSignalNameDBusPOSIX();
}
void _glfwCacheSignalNameDBusPOSIX(void)
{
if(!_glfw.dbus.legalExecutableName)
return;
//"/org/glfw/<exe_name>_<pid>"
char* signalName = _glfw_calloc(22 + strlen(_glfw.dbus.legalExecutableName), sizeof(char));
if(!signalName)
{
_glfwInputError(GLFW_OUT_OF_MEMORY, "Failed to allocate memory for signal name");
return;
}
memset(signalName, '\0', (22 + strlen(_glfw.dbus.legalExecutableName)) * sizeof(char));
const pid_t pid = getpid();
if(sprintf(signalName, "/org/glfw/%s_%d", _glfw.dbus.legalExecutableName, pid) < 0)
{
_glfwInputError(GLFW_PLATFORM, "Failed to create signal name");
_glfw_free(signalName);
return;
}
_glfw.dbus.signalName = signalName;
}
void _glfwCacheFullExecutableNameDBusPOSIX(void)
{
char exeName[PATH_MAX];
memset(exeName, 0, sizeof(char) * PATH_MAX);
if(readlink("/proc/self/exe", exeName, PATH_MAX) == -1)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to get name of the running executable");
return;
}
char* exeNameEnd = strchr(exeName, '\0');
char* lastFound = strrchr(exeName, '/');
if(!lastFound || !exeNameEnd)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to get name of the running executable");
return;
}
unsigned int exeNameLength = (exeNameEnd - lastFound) - 1;
char* exeNameFinal = _glfw_calloc(exeNameLength + 1, sizeof(char));
if(!exeNameFinal)
{
_glfwInputError(GLFW_OUT_OF_MEMORY, "Failed to allocate memory for executable name");
return;
}
memset(exeNameFinal, 0, sizeof(char) * (exeNameLength + 1));
memcpy(exeNameFinal, (lastFound + 1), exeNameLength);
_glfw.dbus.fullExecutableName = exeNameFinal;
}
void _glfwCacheLegalExecutableNameDBusPOSIX(void)
{
//The executable name is stripped of any illegal characters
//according to the DBus specification
int i = 0;
int validExeNameLength = 0;
int output = 0;
char exeName[PATH_MAX];
memset(exeName, 0, sizeof(char) * PATH_MAX);
if(readlink("/proc/self/exe", exeName, PATH_MAX) == -1)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to get name of the running executable");
return;
}
char* exeNameEnd = strchr(exeName, '\0');
char* lastFound = strrchr(exeName, '/');
if(!lastFound || !exeNameEnd)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to get name of the running executable");
return;
}
unsigned int exeNameLength = (exeNameEnd - lastFound) - 1;
for(i = 0; i < exeNameLength; ++i)
{
if(isalnum(*(lastFound + 1 + i)))
validExeNameLength++;
}
char* exeNameFinal = _glfw_calloc(validExeNameLength + 1, sizeof(char));
if(!exeNameFinal)
{
_glfwInputError(GLFW_OUT_OF_MEMORY, "Failed to allocate memory for executable name");
return;
}
memset(exeNameFinal, 0, sizeof(char) * (validExeNameLength + 1));
for(i = 0; i < exeNameLength; ++i)
{
if(isalnum(*(lastFound + 1 + i)))
exeNameFinal[output++] = *(lastFound + 1 + i);
}
_glfw.dbus.legalExecutableName = exeNameFinal;
}
void _glfwCacheDesktopFilePathDBusPOSIX(void)
{
if(!_glfw.dbus.fullExecutableName)
return;
//Cache path of .desktop file
//Create our final desktop file uri
//"application://<exe_name>.desktop"
unsigned int desktopFileLength = strlen("application://") + strlen(_glfw.dbus.fullExecutableName) + strlen(".desktop") + 1;
_glfw.dbus.desktopFilePath = _glfw_calloc(desktopFileLength, sizeof(char));
if(!_glfw.dbus.desktopFilePath)
{
_glfwInputError(GLFW_OUT_OF_MEMORY, "Failed to allocate memory for .desktop file path");
return;
}
memset(_glfw.dbus.desktopFilePath, 0, sizeof(char) * desktopFileLength);
strcpy(_glfw.dbus.desktopFilePath, "application://");
memcpy(_glfw.dbus.desktopFilePath + strlen("application://"), _glfw.dbus.fullExecutableName, strlen(_glfw.dbus.fullExecutableName));
strcpy(_glfw.dbus.desktopFilePath + strlen("application://") + strlen(_glfw.dbus.fullExecutableName), ".desktop");
_glfw.dbus.desktopFilePath[desktopFileLength - 1] = '\0';
}
void _glfwTerminateDBusPOSIX(void)
{
if(_glfw.dbus.signalName)
_glfw_free(_glfw.dbus.signalName);
if(_glfw.dbus.legalExecutableName)
_glfw_free(_glfw.dbus.legalExecutableName);
if(_glfw.dbus.fullExecutableName)
_glfw_free(_glfw.dbus.fullExecutableName);
if(_glfw.dbus.desktopFilePath)
_glfw_free(_glfw.dbus.desktopFilePath);
if (_glfw.dbus.connection)
{
dbus_connection_unref(_glfw.dbus.connection);
_glfw.dbus.connection = NULL;
}
if (_glfw.dbus.handle)
{
_glfwPlatformFreeModule(_glfw.dbus.handle);
_glfw.dbus.handle = NULL;
}
}
void _glfwUpdateTaskbarProgressDBusPOSIX(dbus_bool_t progressVisible, double progressValue)
{
struct DBusMessage* msg = NULL;
if(!_glfw.dbus.handle || !_glfw.dbus.connection || !_glfw.dbus.desktopFilePath || !_glfw.dbus.signalName)
return;
//Signal signature:
//signal com.canonical.Unity.LauncherEntry.Update (in s app_uri, in a{sv} properties)
struct DBusMessageIter args;
memset(&args, 0, sizeof(args));
if(!_glfwNewMessageSignalDBusPOSIX(_glfw.dbus.signalName, "com.canonical.Unity.LauncherEntry", "Update", &msg))
return;
dbus_message_iter_init_append(msg, &args);
//Setup app_uri parameter
_glfwAppendDataDBusPOSIX(&args, DBUS_TYPE_STRING, &_glfw.dbus.desktopFilePath);
//Set properties parameter
struct DBusMessageIter sub1;
memset(&sub1, 0, sizeof(sub1));
_glfwOpenContainerDBusPOSIX(&args, DBUS_TYPE_ARRAY, "{sv}", &sub1);
//Set progress visible property
const char* progressVisibleStr = "progress-visible";
_glfwAppendDictDataDBusPOSIX(&sub1, DBUS_TYPE_STRING, &progressVisibleStr, DBUS_TYPE_BOOLEAN, &progressVisible);
//Set progress value property
const char* progressStr = "progress";
_glfwAppendDictDataDBusPOSIX(&sub1, DBUS_TYPE_STRING, &progressStr, DBUS_TYPE_DOUBLE, &progressValue);
_glfwCloseContainerDBusPOSIX(&args, &sub1);
_glfwSendMessageDBusPOSIX(msg);
//Free the message
dbus_message_unref(msg);
}
dbus_bool_t _glfwNewMessageSignalDBusPOSIX(const char* objectPath, const char* interfaceName, const char* signalName, struct DBusMessage** outMessage)
{
if(!outMessage)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to create new DBus message, output message pointer is NULL");
return GLFW_FALSE;
}
*outMessage = dbus_message_new_signal(objectPath, interfaceName, signalName);
if(!(*outMessage))
{
*outMessage = NULL;
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to create new DBus message");
return GLFW_FALSE;
}
return GLFW_TRUE;
}
dbus_bool_t _glfwOpenContainerDBusPOSIX(struct DBusMessageIter* iterator, int DBusType, const char* signature, struct DBusMessageIter* subIterator)
{
if(DBusType != DBUS_TYPE_ARRAY && DBusType != DBUS_TYPE_STRUCT_OPEN &&
DBusType != DBUS_TYPE_STRUCT_CLOSE && DBusType != DBUS_TYPE_VARIANT &&
DBusType != DBUS_TYPE_DICT_ENTRY)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Invalid DBUS container type provided");
return GLFW_FALSE;
}
if(!iterator || !subIterator)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "DBus message iterator is NULL");
return GLFW_FALSE;
}
return dbus_message_iter_open_container(iterator, DBusType, signature, subIterator);
}
dbus_bool_t _glfwCloseContainerDBusPOSIX(struct DBusMessageIter* iterator, struct DBusMessageIter* subIterator)
{
if(!iterator || !subIterator)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "DBus message iterator is NULL");
return GLFW_FALSE;
}
return dbus_message_iter_close_container(iterator, subIterator);
}
dbus_bool_t _glfwAppendDataDBusPOSIX(struct DBusMessageIter* iterator, int DBusType, const void* data)
{
if(DBusType == DBUS_TYPE_ARRAY || DBusType == DBUS_TYPE_VARIANT || DBusType == DBUS_TYPE_DICT_ENTRY || DBusType == DBUS_TYPE_STRUCT_OPEN || DBusType == DBUS_TYPE_STRUCT_CLOSE)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Invalid DBus type provided");
return GLFW_FALSE;
}
if(!iterator)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "DBus message iterator is NULL");
return GLFW_FALSE;
}
if(!data)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "DBus data to append is NULL");
return GLFW_FALSE;
}
return dbus_message_iter_append_basic(iterator, DBusType, data);
}
dbus_bool_t _glfwAppendDictDataDBusPOSIX(struct DBusMessageIter* iterator, int keyType, const void* keyData, int valueType, const void* valueData)
{
struct DBusMessageIter keyIterator;
struct DBusMessageIter valueIterator;
memset(&keyIterator, 0, sizeof(keyIterator));
memset(&valueIterator, 0, sizeof(valueIterator));
if(!_glfwOpenContainerDBusPOSIX(iterator, DBUS_TYPE_DICT_ENTRY, NULL, &keyIterator))
return GLFW_FALSE;
//Append key data
if(!_glfwAppendDataDBusPOSIX(&keyIterator, keyType, keyData))
return GLFW_FALSE;
if(!_glfwOpenContainerDBusPOSIX(&keyIterator, DBUS_TYPE_VARIANT, (const char*)&valueType, &valueIterator))
return GLFW_FALSE;
//Append value data
if(!_glfwAppendDataDBusPOSIX(&valueIterator, valueType, valueData))
return GLFW_FALSE;
if(!_glfwCloseContainerDBusPOSIX(&keyIterator, &valueIterator))
return GLFW_FALSE;
if(!_glfwCloseContainerDBusPOSIX(iterator, &keyIterator))
return GLFW_FALSE;
return GLFW_TRUE;
}
dbus_bool_t _glfwSendMessageDBusPOSIX(struct DBusMessage* message)
{
if(!message)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "DBus message is NULL");
return GLFW_FALSE;
}
unsigned int serial = 0;
if(!dbus_connection_send(_glfw.dbus.connection, message, &serial))
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to send DBus message");
return GLFW_FALSE;
}
dbus_connection_flush(_glfw.dbus.connection);
return GLFW_TRUE;
}

158
src/posix_dbus.h Normal file
View File

@ -0,0 +1,158 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2023 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
//Taken from DBus docs (https://dbus.freedesktop.org/doc/api/html/index.html)
typedef struct DBusConnection DBusConnection;
typedef struct DBusMessage DBusMessage;
typedef unsigned int dbus_bool_t;
typedef unsigned int dbus_uint32_t;
enum DBusBusType
{
DBUS_BUS_SESSION,
DBUS_BUS_SYSTEM,
DBUS_BUS_STARTER
};
struct DBusError
{
const char* name;
const char* message;
unsigned int dummy1 : 1;
unsigned int dummy2 : 1;
unsigned int dummy3 : 1;
unsigned int dummy4 : 1;
unsigned int dummy5 : 1;
void* padding1;
};
struct DBusMessageIter
{
void* dummy1;
void* dummy2;
dbus_uint32_t dummy3;
int dummy4, dummy5, dummy6, dummy7, dummy8, dummy9, dummy10, dummy11;
int pad1;
void* pad2;
void* pad3;
};
#define DBUS_NAME_FLAG_REPLACE_EXISTING 0x2
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
#define DBUS_TYPE_STRING (unsigned int)'s'
#define DBUS_TYPE_ARRAY (unsigned int)'a'
#define DBUS_TYPE_DICT_ENTRY (unsigned int)'e'
#define DBUS_TYPE_VARIANT (unsigned int)'v'
#define DBUS_TYPE_BOOLEAN (unsigned int)'b'
#define DBUS_TYPE_DOUBLE (unsigned int)'d'
#define DBUS_TYPE_INT16 (unsigned int)'n'
#define DBUS_TYPE_UINT16 (unsigned int)'q'
#define DBUS_TYPE_INT32 (unsigned int)'i'
#define DBUS_TYPE_UINT32 (unsigned int)'u'
#define DBUS_TYPE_INT64 (unsigned int)'x'
#define DBUS_TYPE_UINT64 (unsigned int)'t'
#define DBUS_TYPE_STRUCT_OPEN (unsigned int)'('
#define DBUS_TYPE_STRUCT_CLOSE (unsigned int)')'
#define DBUS_TYPE_BYTE (unsigned int)'y'
#define DBUS_TYPE_OBJECT_PATH (unsigned int)'o'
#define DBUS_TYPE_SIGNATURE (unsigned int)'g'
typedef void (* PFN_dbus_error_init)(struct DBusError*);
typedef dbus_bool_t (* PFN_dbus_error_is_set)(const struct DBusError*);
typedef void (* PFN_dbus_error_free)(struct DBusError*);
typedef void (* PFN_dbus_connection_unref)(DBusConnection*);
typedef dbus_bool_t (* PFN_dbus_connection_send)(DBusConnection*, DBusMessage*, dbus_uint32_t*);
typedef void (* PFN_dbus_connection_flush)(DBusConnection*);
typedef int (* PFN_dbus_bus_request_name)(DBusConnection*, const char*, unsigned int, struct DBusError*);
typedef DBusConnection* (* PFN_dbus_bus_get)(enum DBusBusType, struct DBusError*);
typedef void (* PFN_dbus_message_unref)(DBusMessage*);
typedef DBusMessage* (* PFN_dbus_message_new_signal)(const char*, const char*, const char*);
typedef void (* PFN_dbus_message_iter_init_append)(DBusMessage*, struct DBusMessageIter*);
typedef dbus_bool_t (* PFN_dbus_message_iter_append_basic)(struct DBusMessageIter*, int, const void*);
typedef dbus_bool_t (* PFN_dbus_message_iter_open_container)(struct DBusMessageIter*, int, const char*, struct DBusMessageIter*);
typedef dbus_bool_t (* PFN_dbus_message_iter_close_container)(struct DBusMessageIter*, struct DBusMessageIter*);
#define dbus_error_init _glfw.dbus.error_init
#define dbus_error_is_set _glfw.dbus.error_is_set
#define dbus_error_free _glfw.dbus.error_free
#define dbus_connection_unref _glfw.dbus.connection_unref
#define dbus_connection_send _glfw.dbus.connection_send
#define dbus_connection_flush _glfw.dbus.connection_flush
#define dbus_bus_request_name _glfw.dbus.bus_request_name
#define dbus_bus_get _glfw.dbus.bus_get
#define dbus_message_unref _glfw.dbus.message_unref
#define dbus_message_new_signal _glfw.dbus.message_new_signal
#define dbus_message_iter_init_append _glfw.dbus.message_iter_init_append
#define dbus_message_iter_append_basic _glfw.dbus.message_iter_append_basic
#define dbus_message_iter_open_container _glfw.dbus.message_iter_open_container
#define dbus_message_iter_close_container _glfw.dbus.message_iter_close_container
#define GLFW_POSIX_LIBRARY_DBUS_STATE _GLFWDBusPOSIX dbus;
// POSIX-specific dbus data
//
typedef struct _GLFWDBusPOSIX
{
void* handle;
PFN_dbus_error_init error_init;
PFN_dbus_error_is_set error_is_set;
PFN_dbus_error_free error_free;
PFN_dbus_connection_unref connection_unref;
PFN_dbus_connection_send connection_send;
PFN_dbus_connection_flush connection_flush;
PFN_dbus_bus_request_name bus_request_name;
PFN_dbus_bus_get bus_get;
PFN_dbus_message_unref message_unref;
PFN_dbus_message_new_signal message_new_signal;
PFN_dbus_message_iter_init_append message_iter_init_append;
PFN_dbus_message_iter_append_basic message_iter_append_basic;
PFN_dbus_message_iter_open_container message_iter_open_container;
PFN_dbus_message_iter_close_container message_iter_close_container;
DBusConnection* connection;
struct DBusError error;
char* desktopFilePath;
char* fullExecutableName;
char* legalExecutableName;
char* signalName;
} _GLFWDBusPOSIX;
void _glfwInitDBusPOSIX(void);
void _glfwCacheSignalNameDBusPOSIX(void);
void _glfwCacheFullExecutableNameDBusPOSIX(void);
void _glfwCacheLegalExecutableNameDBusPOSIX(void);
void _glfwCacheDesktopFilePathDBusPOSIX(void);
void _glfwTerminateDBusPOSIX(void);
void _glfwUpdateTaskbarProgressDBusPOSIX(dbus_bool_t progressVisible, double progressValue);
dbus_bool_t _glfwNewMessageSignalDBusPOSIX(const char* objectPath, const char* interfaceName, const char* signalName, struct DBusMessage** outMessage);
dbus_bool_t _glfwOpenContainerDBusPOSIX(struct DBusMessageIter* iterator, int DBusType, const char* signature, struct DBusMessageIter* subIterator);
dbus_bool_t _glfwCloseContainerDBusPOSIX(struct DBusMessageIter* iterator, struct DBusMessageIter* subIterator);
dbus_bool_t _glfwAppendDataDBusPOSIX(struct DBusMessageIter* iterator, int DBusType, const void* data);
dbus_bool_t _glfwAppendDictDataDBusPOSIX(struct DBusMessageIter* iterator, int keyType, const void* keyData, int valueType, const void* valueData);
dbus_bool_t _glfwSendMessageDBusPOSIX(struct DBusMessage* message);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.5 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.5 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.5 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.5 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.5 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.5 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 POSIX - www.glfw.org // GLFW 3.5 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
@ -142,6 +142,8 @@ GLFWbool _glfwInitVulkan(int mode)
_glfw.vk.KHR_xcb_surface = GLFW_TRUE; _glfw.vk.KHR_xcb_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0) else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
_glfw.vk.KHR_wayland_surface = GLFW_TRUE; _glfw.vk.KHR_wayland_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_EXT_headless_surface") == 0)
_glfw.vk.EXT_headless_surface = GLFW_TRUE;
} }
_glfw_free(ep); _glfw_free(ep);
@ -272,11 +274,11 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
VkPhysicalDevice device, VkPhysicalDevice device,
uint32_t queuefamily) uint32_t queuefamily)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
assert(instance != VK_NULL_HANDLE); assert(instance != VK_NULL_HANDLE);
assert(device != VK_NULL_HANDLE); assert(device != VK_NULL_HANDLE);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER)) if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
return GLFW_FALSE; return GLFW_FALSE;
@ -297,15 +299,16 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
const VkAllocationCallbacks* allocator, const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface) VkSurfaceKHR* surface)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(instance != VK_NULL_HANDLE);
assert(window != NULL);
assert(surface != NULL); assert(surface != NULL);
*surface = VK_NULL_HANDLE; *surface = VK_NULL_HANDLE;
_GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED); _GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED);
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(instance != VK_NULL_HANDLE);
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER)) if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
return VK_ERROR_INITIALIZATION_FAILED; return VK_ERROR_INITIALIZATION_FAILED;

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 WGL - www.glfw.org // GLFW 3.5 WGL - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -115,6 +115,23 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
if (_glfw.wgl.EXT_colorspace) if (_glfw.wgl.EXT_colorspace)
ADD_ATTRIB(WGL_COLORSPACE_EXT); ADD_ATTRIB(WGL_COLORSPACE_EXT);
} }
// NOTE: In a Parallels VM WGL_ARB_pixel_format returns fewer pixel formats than
// DescribePixelFormat, violating the guarantees of the extension spec
// HACK: Iterate through the minimum of both counts
const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
int extensionCount;
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
1, 0, 1, &attrib, &extensionCount))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve pixel format attribute");
return 0;
}
nativeCount = _glfw_min(nativeCount, extensionCount);
} }
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
@ -758,7 +775,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
@ -768,6 +784,9 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
return NULL; return NULL;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (window->context.source != GLFW_NATIVE_CONTEXT_API) if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -430,46 +430,6 @@ static GLFWbool createHelperWindow(void)
return GLFW_TRUE; return GLFW_TRUE;
} }
// Creates the blank cursor
//
static void createBlankCursor(void)
{
// HACK: Create a transparent cursor as using the NULL cursor breaks
// using SetCursorPos when connected over RDP
int cursorWidth = GetSystemMetrics(SM_CXCURSOR);
int cursorHeight = GetSystemMetrics(SM_CYCURSOR);
unsigned char* andMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char));
unsigned char* xorMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char));
if (andMask != NULL && xorMask != NULL) {
memset(andMask, 0xFF, (size_t)(cursorWidth * cursorHeight / 8));
// Cursor creation might fail, but that's fine as we get NULL in that case,
// which serves as an acceptable fallback blank cursor (other than on RDP)
_glfw.win32.blankCursor = CreateCursor(NULL, 0, 0, cursorWidth, cursorHeight, andMask, xorMask);
_glfw_free(andMask);
_glfw_free(xorMask);
}
}
// Initialize for remote sessions
//
static void initRemoteSession(void)
{
//Check if the current progress was started with Remote Desktop.
_glfw.win32.isRemoteSession = GetSystemMetrics(SM_REMOTESESSION) > 0;
// With Remote desktop, we need to create a blank cursor because of the cursor is Set to NULL
// if cannot be moved to center in capture mode. If not Remote Desktop win32.blankCursor stays NULL
// and will perform has before (normal).
if (_glfw.win32.isRemoteSession)
{
createBlankCursor();
}
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW internal API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -642,78 +602,79 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
{ {
const _GLFWplatform win32 = const _GLFWplatform win32 =
{ {
GLFW_PLATFORM_WIN32, .platformID = GLFW_PLATFORM_WIN32,
_glfwInitWin32, .init = _glfwInitWin32,
_glfwTerminateWin32, .terminate = _glfwTerminateWin32,
_glfwGetCursorPosWin32, .getCursorPos = _glfwGetCursorPosWin32,
_glfwSetCursorPosWin32, .setCursorPos = _glfwSetCursorPosWin32,
_glfwSetCursorModeWin32, .setCursorMode = _glfwSetCursorModeWin32,
_glfwSetRawMouseMotionWin32, .setRawMouseMotion = _glfwSetRawMouseMotionWin32,
_glfwRawMouseMotionSupportedWin32, .rawMouseMotionSupported = _glfwRawMouseMotionSupportedWin32,
_glfwCreateCursorWin32, .createCursor = _glfwCreateCursorWin32,
_glfwCreateStandardCursorWin32, .createStandardCursor = _glfwCreateStandardCursorWin32,
_glfwDestroyCursorWin32, .destroyCursor = _glfwDestroyCursorWin32,
_glfwSetCursorWin32, .setCursor = _glfwSetCursorWin32,
_glfwGetScancodeNameWin32, .getScancodeName = _glfwGetScancodeNameWin32,
_glfwGetKeyScancodeWin32, .getKeyScancode = _glfwGetKeyScancodeWin32,
_glfwSetClipboardStringWin32, .setClipboardString = _glfwSetClipboardStringWin32,
_glfwGetClipboardStringWin32, .getClipboardString = _glfwGetClipboardStringWin32,
_glfwInitJoysticksWin32, .initJoysticks = _glfwInitJoysticksWin32,
_glfwTerminateJoysticksWin32, .terminateJoysticks = _glfwTerminateJoysticksWin32,
_glfwPollJoystickWin32, .pollJoystick = _glfwPollJoystickWin32,
_glfwGetMappingNameWin32, .getMappingName = _glfwGetMappingNameWin32,
_glfwUpdateGamepadGUIDWin32, .updateGamepadGUID = _glfwUpdateGamepadGUIDWin32,
_glfwFreeMonitorWin32, .freeMonitor = _glfwFreeMonitorWin32,
_glfwGetMonitorPosWin32, .getMonitorPos = _glfwGetMonitorPosWin32,
_glfwGetMonitorContentScaleWin32, .getMonitorContentScale = _glfwGetMonitorContentScaleWin32,
_glfwGetMonitorWorkareaWin32, .getMonitorWorkarea = _glfwGetMonitorWorkareaWin32,
_glfwGetVideoModesWin32, .getVideoModes = _glfwGetVideoModesWin32,
_glfwGetVideoModeWin32, .getVideoMode = _glfwGetVideoModeWin32,
_glfwGetGammaRampWin32, .getGammaRamp = _glfwGetGammaRampWin32,
_glfwSetGammaRampWin32, .setGammaRamp = _glfwSetGammaRampWin32,
_glfwCreateWindowWin32, .createWindow = _glfwCreateWindowWin32,
_glfwDestroyWindowWin32, .destroyWindow = _glfwDestroyWindowWin32,
_glfwSetWindowTitleWin32, .setWindowTitle = _glfwSetWindowTitleWin32,
_glfwSetWindowIconWin32, .setWindowIcon = _glfwSetWindowIconWin32,
_glfwGetWindowPosWin32, .setWindowProgressIndicator = _glfwSetWindowProgressIndicatorWin32,
_glfwSetWindowPosWin32, .getWindowPos = _glfwGetWindowPosWin32,
_glfwGetWindowSizeWin32, .setWindowPos = _glfwSetWindowPosWin32,
_glfwSetWindowSizeWin32, .getWindowSize = _glfwGetWindowSizeWin32,
_glfwSetWindowSizeLimitsWin32, .setWindowSize = _glfwSetWindowSizeWin32,
_glfwSetWindowAspectRatioWin32, .setWindowSizeLimits = _glfwSetWindowSizeLimitsWin32,
_glfwGetFramebufferSizeWin32, .setWindowAspectRatio = _glfwSetWindowAspectRatioWin32,
_glfwGetWindowFrameSizeWin32, .getFramebufferSize = _glfwGetFramebufferSizeWin32,
_glfwGetWindowContentScaleWin32, .getWindowFrameSize = _glfwGetWindowFrameSizeWin32,
_glfwIconifyWindowWin32, .getWindowContentScale = _glfwGetWindowContentScaleWin32,
_glfwRestoreWindowWin32, .iconifyWindow = _glfwIconifyWindowWin32,
_glfwMaximizeWindowWin32, .restoreWindow = _glfwRestoreWindowWin32,
_glfwShowWindowWin32, .maximizeWindow = _glfwMaximizeWindowWin32,
_glfwHideWindowWin32, .showWindow = _glfwShowWindowWin32,
_glfwRequestWindowAttentionWin32, .hideWindow = _glfwHideWindowWin32,
_glfwFocusWindowWin32, .requestWindowAttention = _glfwRequestWindowAttentionWin32,
_glfwSetWindowMonitorWin32, .focusWindow = _glfwFocusWindowWin32,
_glfwWindowFocusedWin32, .setWindowMonitor = _glfwSetWindowMonitorWin32,
_glfwWindowIconifiedWin32, .windowFocused = _glfwWindowFocusedWin32,
_glfwWindowVisibleWin32, .windowIconified = _glfwWindowIconifiedWin32,
_glfwWindowMaximizedWin32, .windowVisible = _glfwWindowVisibleWin32,
_glfwWindowHoveredWin32, .windowMaximized = _glfwWindowMaximizedWin32,
_glfwFramebufferTransparentWin32, .windowHovered = _glfwWindowHoveredWin32,
_glfwGetWindowOpacityWin32, .framebufferTransparent = _glfwFramebufferTransparentWin32,
_glfwSetWindowResizableWin32, .getWindowOpacity = _glfwGetWindowOpacityWin32,
_glfwSetWindowDecoratedWin32, .setWindowResizable = _glfwSetWindowResizableWin32,
_glfwSetWindowFloatingWin32, .setWindowDecorated = _glfwSetWindowDecoratedWin32,
_glfwSetWindowOpacityWin32, .setWindowFloating = _glfwSetWindowFloatingWin32,
_glfwSetWindowMousePassthroughWin32, .setWindowOpacity = _glfwSetWindowOpacityWin32,
_glfwPollEventsWin32, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWin32,
_glfwWaitEventsWin32, .pollEvents = _glfwPollEventsWin32,
_glfwWaitEventsTimeoutWin32, .waitEvents = _glfwWaitEventsWin32,
_glfwPostEmptyEventWin32, .waitEventsTimeout = _glfwWaitEventsTimeoutWin32,
_glfwGetEGLPlatformWin32, .postEmptyEvent = _glfwPostEmptyEventWin32,
_glfwGetEGLNativeDisplayWin32, .getEGLPlatform = _glfwGetEGLPlatformWin32,
_glfwGetEGLNativeWindowWin32, .getEGLNativeDisplay = _glfwGetEGLNativeDisplayWin32,
_glfwGetRequiredInstanceExtensionsWin32, .getEGLNativeWindow = _glfwGetEGLNativeWindowWin32,
_glfwGetPhysicalDevicePresentationSupportWin32, .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWin32,
_glfwCreateWindowSurfaceWin32, .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWin32,
.createWindowSurface = _glfwCreateWindowSurfaceWin32
}; };
*platform = win32; *platform = win32;
@ -738,15 +699,6 @@ int _glfwInitWin32(void)
if (!createHelperWindow()) if (!createHelperWindow())
return GLFW_FALSE; return GLFW_FALSE;
//Some hacks are needed to support Remote Desktop...
initRemoteSession();
if (_glfw.win32.isRemoteSession && _glfw.win32.blankCursor == NULL )
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to create blank cursor for remote session.");
return GLFW_FALSE;
}
_glfwPollMonitorsWin32(); _glfwPollMonitorsWin32();
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -754,7 +706,7 @@ int _glfwInitWin32(void)
void _glfwTerminateWin32(void) void _glfwTerminateWin32(void)
{ {
if (_glfw.win32.blankCursor) if (_glfw.win32.blankCursor)
DestroyCursor(_glfw.win32.blankCursor); DestroyIcon((HICON) _glfw.win32.blankCursor);
if (_glfw.win32.deviceNotificationHandle) if (_glfw.win32.deviceNotificationHandle)
UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle); UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
// //

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -33,6 +33,7 @@
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#include <wchar.h> #include <wchar.h>
#include <assert.h>
// Callback for EnumDisplayMonitors in createMonitor // Callback for EnumDisplayMonitors in createMonitor
@ -470,13 +471,17 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
return result; return result;
} }
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
DEVMODEW dm; DEVMODEW dm;
ZeroMemory(&dm, sizeof(dm)); ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(dm); dm.dmSize = sizeof(dm);
EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm); if (!EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm))
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query display settings");
return GLFW_FALSE;
}
mode->width = dm.dmPelsWidth; mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight; mode->height = dm.dmPelsHeight;
@ -485,6 +490,8 @@ void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
&mode->redBits, &mode->redBits,
&mode->greenBits, &mode->greenBits,
&mode->blueBits); &mode->blueBits);
return GLFW_TRUE;
} }
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -533,15 +540,33 @@ void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle) GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized");
return NULL;
}
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
return monitor->win32.publicAdapterName; return monitor->win32.publicAdapterName;
} }
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized");
return NULL;
}
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
return monitor->win32.publicDisplayName; return monitor->win32.publicDisplayName;
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -366,6 +366,79 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(
#define GLFW_WGL_CONTEXT_STATE _GLFWcontextWGL wgl; #define GLFW_WGL_CONTEXT_STATE _GLFWcontextWGL wgl;
#define GLFW_WGL_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl; #define GLFW_WGL_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl;
typedef enum
{
TBPF_NOPROGRESS = 0x0,
TBPF_INDETERMINATE = 0x1,
TBPF_NORMAL = 0x2,
TBPF_ERROR = 0x4,
TBPF_PAUSED = 0x8
} TBPFLAG;
static const IID IID_ITaskbarList3 = { 0xea1afb91, 0x9e28, 0x4b86, {0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf} };
static const IID CLSID_TaskbarList = { 0x56fdf344, 0xfd6d, 0x11d0, {0x95, 0x8a, 0x00, 0x60, 0x97, 0xc9, 0xa0, 0x90} };
typedef enum THUMBBUTTONMASK
{
THB_BITMAP = 0x1,
THB_ICON = 0x2,
THB_TOOLTIP = 0x4,
THB_FLAGS = 0x8
} THUMBBUTTONMASK;
typedef enum THUMBBUTTONFLAGS
{
THBF_ENABLED = 0,
THBF_DISABLED = 0x1,
THBF_DISMISSONCLICK = 0x2,
THBF_NOBACKGROUND = 0x4,
THBF_HIDDEN = 0x8,
THBF_NONINTERACTIVE = 0x10
} THUMBBUTTONFLAGS;
typedef struct THUMBBUTTON {
THUMBBUTTONMASK dwMask;
UINT iId;
UINT iBitmap;
HICON hIcon;
WCHAR szTip[260];
THUMBBUTTONFLAGS dwFlags;
} THUMBBUTTON, *LPTHUMBBUTTON;
struct _IMAGELIST;
typedef struct _IMAGELIST* HIMAGELIST;
typedef struct ITaskbarList3 ITaskbarList3;
typedef struct ITaskbarList3Vtbl
{
HRESULT(WINAPI* QueryInterface)(struct ITaskbarList3*, const IID* const, void**);
ULONG(WINAPI* AddRef)(struct ITaskbarList3*);
ULONG(WINAPI* Release)(struct ITaskbarList3*);
HRESULT(WINAPI* HrInit)(struct ITaskbarList3*);
HRESULT(WINAPI* AddTab)(struct ITaskbarList3*, HWND);
HRESULT(WINAPI* DeleteTab)(struct ITaskbarList3*, HWND);
HRESULT(WINAPI* ActivateTab)(struct ITaskbarList3*, HWND);
HRESULT(WINAPI* SetActiveAlt)(struct ITaskbarList3*, HWND);
HRESULT(WINAPI* MarkFullscreenWindow)(struct ITaskbarList3*, HWND, BOOL);
HRESULT(WINAPI* SetProgressValue)(struct ITaskbarList3*, HWND, ULONGLONG, ULONGLONG);
HRESULT(WINAPI* SetProgressState)(struct ITaskbarList3*, HWND, TBPFLAG);
HRESULT(WINAPI* RegisterTab)(struct ITaskbarList3*, HWND, HWND);
HRESULT(WINAPI* UnregisterTab)(struct ITaskbarList3*, HWND);
HRESULT(WINAPI* SetTabOrder)(struct ITaskbarList3*, HWND, HWND);
HRESULT(WINAPI* SetTabActive)(struct ITaskbarList3*, HWND, HWND, DWORD);
HRESULT(WINAPI* ThumbBarAddButtons)(struct ITaskbarList3*, HWND, UINT, LPTHUMBBUTTON);
HRESULT(WINAPI* ThumbBarUpdateButtons)(struct ITaskbarList3*, HWND, UINT, LPTHUMBBUTTON);
HRESULT(WINAPI* ThumbBarSetImageList)(struct ITaskbarList3*, HWND, HIMAGELIST);
HRESULT(WINAPI* SetOverlayIcon)(struct ITaskbarList3*, HWND, HICON, LPCWSTR);
HRESULT(WINAPI* SetThumbnailTooltip)(struct ITaskbarList3*, HWND, LPCWSTR);
HRESULT(WINAPI* SetThumbnailClip)(struct ITaskbarList3*, HWND, RECT*);
} ITaskbarList3Vtbl;
struct ITaskbarList3
{
struct ITaskbarList3Vtbl* lpVtbl;
};
// WGL-specific per-context data // WGL-specific per-context data
// //
@ -424,6 +497,7 @@ typedef struct _GLFWwindowWin32
GLFWbool transparent; GLFWbool transparent;
GLFWbool scaleToMonitor; GLFWbool scaleToMonitor;
GLFWbool keymenu; GLFWbool keymenu;
GLFWbool showDefault;
// Cached size used to filter out duplicate events // Cached size used to filter out duplicate events
int width, height; int width, height;
@ -432,6 +506,9 @@ typedef struct _GLFWwindowWin32
int lastCursorPosX, lastCursorPosY; int lastCursorPosX, lastCursorPosY;
// The last received high surrogate when decoding pairs of UTF-16 messages // The last received high surrogate when decoding pairs of UTF-16 messages
WCHAR highSurrogate; WCHAR highSurrogate;
ITaskbarList3* taskbarList;
UINT taskbarListMsgID;
} _GLFWwindowWin32; } _GLFWwindowWin32;
// Win32-specific global data // Win32-specific global data
@ -457,9 +534,7 @@ typedef struct _GLFWlibraryWin32
RAWINPUT* rawInput; RAWINPUT* rawInput;
int rawInputSize; int rawInputSize;
UINT mouseTrailSize; UINT mouseTrailSize;
// Indicate if the process was started behind Remote Destop // The cursor handle to use to hide the cursor (NULL or a transparent cursor)
BOOL isRemoteSession;
// An invisible cursor, needed for special cases (see WM_INPUT handler)
HCURSOR blankCursor; HCURSOR blankCursor;
struct { struct {
@ -526,7 +601,6 @@ typedef struct _GLFWcursorWin32
HCURSOR handle; HCURSOR handle;
} _GLFWcursorWin32; } _GLFWcursorWin32;
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform); GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform);
int _glfwInitWin32(void); int _glfwInitWin32(void);
void _glfwTerminateWin32(void); void _glfwTerminateWin32(void);
@ -547,6 +621,7 @@ GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndco
void _glfwDestroyWindowWin32(_GLFWwindow* window); void _glfwDestroyWindowWin32(_GLFWwindow* window);
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowProgressIndicatorWin32(_GLFWwindow* window, int progressState, double value);
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos); void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height); void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height);
@ -610,7 +685,7 @@ void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count); GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp); GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Win32 - www.glfw.org // GLFW 3.5 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -32,6 +32,7 @@
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <windowsx.h> #include <windowsx.h>
#include <shellapi.h> #include <shellapi.h>
@ -232,10 +233,12 @@ static void updateCursorImage(_GLFWwindow* window)
SetCursor(LoadCursorW(NULL, IDC_ARROW)); SetCursor(LoadCursorW(NULL, IDC_ARROW));
} }
else else
//Connected via Remote Desktop, NULL cursor will present SetCursorPos the move the cursor. {
//using a blank cursor fix that. // NOTE: Via Remote Desktop, setting the cursor to NULL does not hide it.
//When not via Remote Desktop, win32.blankCursor should be NULL // HACK: When running locally, it is set to NULL, but when connected via Remote
// Desktop, this is a transparent cursor.
SetCursor(_glfw.win32.blankCursor); SetCursor(_glfw.win32.blankCursor);
}
} }
// Sets the cursor clip rect to the window content area // Sets the cursor clip rect to the window content area
@ -900,8 +903,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
HRAWINPUT ri = (HRAWINPUT) lParam; HRAWINPUT ri = (HRAWINPUT) lParam;
RAWINPUT* data = NULL; RAWINPUT* data = NULL;
int dx, dy; int dx, dy;
int width, height;
POINT pos;
if (_glfw.win32.disabledCursorWindow != window) if (_glfw.win32.disabledCursorWindow != window)
break; break;
@ -929,28 +930,28 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
data = _glfw.win32.rawInput; data = _glfw.win32.rawInput;
if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
{ {
if (_glfw.win32.isRemoteSession) POINT pos = {0};
int width, height;
if (data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP)
{ {
//Remote Desktop Mode... pos.x += GetSystemMetrics(SM_XVIRTUALSCREEN);
// As per https://github.com/Microsoft/DirectXTK/commit/ef56b63f3739381e451f7a5a5bd2c9779d2a7555 pos.y += GetSystemMetrics(SM_YVIRTUALSCREEN);
// MOUSE_MOVE_ABSOLUTE is a range from 0 through 65535, based on the screen size. width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// As far as I can tell, absolute mode only occurs over RDP though. height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
width = GetSystemMetrics((data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) ? SM_CXVIRTUALSCREEN : SM_CXSCREEN);
height = GetSystemMetrics((data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) ? SM_CYVIRTUALSCREEN : SM_CYSCREEN);
pos.x = (int)((data->data.mouse.lLastX / 65535.0f) * width);
pos.y = (int)((data->data.mouse.lLastY / 65535.0f) * height);
ScreenToClient(window->win32.handle, &pos);
dx = pos.x - window->win32.lastCursorPosX;
dy = pos.y - window->win32.lastCursorPosY;
} }
else else
{ {
//Normal mode... We should have the right absolute coords in data.mouse width = GetSystemMetrics(SM_CXSCREEN);
dx = data->data.mouse.lLastX - window->win32.lastCursorPosX; height = GetSystemMetrics(SM_CYSCREEN);
dy = data->data.mouse.lLastY - window->win32.lastCursorPosY;
} }
pos.x += (int) ((data->data.mouse.lLastX / 65535.f) * width);
pos.y += (int) ((data->data.mouse.lLastY / 65535.f) * height);
ScreenToClient(window->win32.handle, &pos);
dx = pos.x - window->win32.lastCursorPosX;
dy = pos.y - window->win32.lastCursorPosY;
} }
else else
{ {
@ -1267,6 +1268,18 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
} }
} }
if(uMsg == window->win32.taskbarListMsgID)
{
HRESULT res = CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, (LPVOID*)&window->win32.taskbarList);
if (res != S_OK && window->win32.taskbarList)
window->win32.taskbarList->lpVtbl->Release(window->win32.taskbarList);
else
{
window->win32.taskbarList->lpVtbl->AddRef(window->win32.taskbarList);
window->win32.taskbarList->lpVtbl->HrInit(window->win32.taskbarList);
}
}
return DefWindowProcW(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
@ -1314,6 +1327,34 @@ static int createNativeWindow(_GLFWwindow* window,
} }
} }
if (GetSystemMetrics(SM_REMOTESESSION))
{
// NOTE: On Remote Desktop, setting the cursor to NULL does not hide it
// HACK: Create a transparent cursor and always set that instead of NULL
// When not on Remote Desktop, this handle is NULL and normal hiding is used
if (!_glfw.win32.blankCursor)
{
const int cursorWidth = GetSystemMetrics(SM_CXCURSOR);
const int cursorHeight = GetSystemMetrics(SM_CYCURSOR);
unsigned char* cursorPixels = _glfw_calloc(cursorWidth * cursorHeight, 4);
if (!cursorPixels)
return GLFW_FALSE;
// NOTE: Windows checks whether the image is fully transparent and if so
// just ignores the alpha channel and makes the whole cursor opaque
// HACK: Make one pixel slightly less transparent
cursorPixels[3] = 1;
const GLFWimage cursorImage = { cursorWidth, cursorHeight, cursorPixels };
_glfw.win32.blankCursor = createIcon(&cursorImage, 0, 0, FALSE);
_glfw_free(cursorPixels);
if (!_glfw.win32.blankCursor)
return GLFW_FALSE;
}
}
if (window->monitor) if (window->monitor)
{ {
MONITORINFO mi = { sizeof(mi) }; MONITORINFO mi = { sizeof(mi) };
@ -1386,10 +1427,15 @@ static int createNativeWindow(_GLFWwindow* window,
WM_COPYDATA, MSGFLT_ALLOW, NULL); WM_COPYDATA, MSGFLT_ALLOW, NULL);
ChangeWindowMessageFilterEx(window->win32.handle, ChangeWindowMessageFilterEx(window->win32.handle,
WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL); WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
window->win32.taskbarListMsgID = RegisterWindowMessageW(L"TaskbarButtonCreated");
if (window->win32.taskbarListMsgID)
ChangeWindowMessageFilterEx(window->win32.handle, window->win32.taskbarListMsgID, MSGFLT_ALLOW, NULL);
} }
window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
window->win32.keymenu = wndconfig->win32.keymenu; window->win32.keymenu = wndconfig->win32.keymenu;
window->win32.showDefault = wndconfig->win32.showDefault;
if (!window->monitor) if (!window->monitor)
{ {
@ -1538,6 +1584,9 @@ void _glfwDestroyWindowWin32(_GLFWwindow* window)
if (_glfw.win32.capturedCursorWindow == window) if (_glfw.win32.capturedCursorWindow == window)
releaseCursor(); releaseCursor();
if (window->win32.taskbarList)
window->win32.taskbarList->lpVtbl->Release(window->win32.taskbarList);
if (window->win32.handle) if (window->win32.handle)
{ {
RemovePropW(window->win32.handle, L"GLFW"); RemovePropW(window->win32.handle, L"GLFW");
@ -1600,6 +1649,53 @@ void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* im
} }
} }
void _glfwSetWindowProgressIndicatorWin32(_GLFWwindow* window, int progressState, double value)
{
HRESULT res = S_OK;
int winProgressState = 0;
int progressValue = (int)(value * 100.0);
if(!IsWindows7OrGreater())
{
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Win32: Taskbar progress is only supported on Windows 7 or newer");
return;
}
if(!window->win32.taskbarList)
return;
res = window->win32.taskbarList->lpVtbl->SetProgressValue(window->win32.taskbarList, window->win32.handle, progressValue, 100);
if(res != S_OK)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar progress value");
return;
}
switch(progressState)
{
case GLFW_PROGRESS_INDICATOR_INDETERMINATE:
winProgressState = TBPF_INDETERMINATE;
break;
case GLFW_PROGRESS_INDICATOR_NORMAL:
winProgressState = TBPF_NORMAL;
break;
case GLFW_PROGRESS_INDICATOR_ERROR:
winProgressState = TBPF_ERROR;
break;
case GLFW_PROGRESS_INDICATOR_PAUSED:
winProgressState = TBPF_PAUSED;
break;
default:
winProgressState = TBPF_NOPROGRESS;
break;
}
res = window->win32.taskbarList->lpVtbl->SetProgressState(window->win32.taskbarList, window->win32.handle, winProgressState);
if (res != S_OK)
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to set taskbar progress state");
}
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos) void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos)
{ {
POINT pos = { 0, 0 }; POINT pos = { 0, 0 };
@ -1772,7 +1868,23 @@ void _glfwMaximizeWindowWin32(_GLFWwindow* window)
void _glfwShowWindowWin32(_GLFWwindow* window) void _glfwShowWindowWin32(_GLFWwindow* window)
{ {
ShowWindow(window->win32.handle, SW_SHOWNA); int showCommand = SW_SHOWNA;
if (window->win32.showDefault)
{
// NOTE: GLFW windows currently do not seem to match the Windows 10 definition of
// a main window, so even SW_SHOWDEFAULT does nothing
// This definition is undocumented and can change (source: Raymond Chen)
// HACK: Apply the STARTUPINFO show command manually if available
STARTUPINFOW si = { sizeof(si) };
GetStartupInfoW(&si);
if (si.dwFlags & STARTF_USESHOWWINDOW)
showCommand = si.wShowWindow;
window->win32.showDefault = GLFW_FALSE;
}
ShowWindow(window->win32.handle, showCommand);
} }
void _glfwHideWindowWin32(_GLFWwindow* window) void _glfwHideWindowWin32(_GLFWwindow* window)
@ -2223,14 +2335,17 @@ void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode)
const char* _glfwGetScancodeNameWin32(int scancode) const char* _glfwGetScancodeNameWin32(int scancode)
{ {
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) || if (scancode < 0 || scancode > (KF_EXTENDED | 0xff))
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL; return NULL;
} }
return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]]; const int key = _glfw.win32.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
return _glfw.win32.keynames[key];
} }
int _glfwGetKeyScancodeWin32(int key) int _glfwGetKeyScancodeWin32(int key)
@ -2528,7 +2643,6 @@ VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance,
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
@ -2538,6 +2652,9 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
return NULL; return NULL;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
return window->win32.handle; return window->win32.handle;
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 - www.glfw.org // GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -242,6 +242,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->maxheight = GLFW_DONT_CARE; window->maxheight = GLFW_DONT_CARE;
window->numer = GLFW_DONT_CARE; window->numer = GLFW_DONT_CARE;
window->denom = GLFW_DONT_CARE; window->denom = GLFW_DONT_CARE;
window->title = _glfw_strdup(title);
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig)) if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
{ {
@ -274,6 +275,7 @@ void glfwDefaultWindowHints(void)
_glfw.hints.window.focusOnShow = GLFW_TRUE; _glfw.hints.window.focusOnShow = GLFW_TRUE;
_glfw.hints.window.xpos = GLFW_ANY_POSITION; _glfw.hints.window.xpos = GLFW_ANY_POSITION;
_glfw.hints.window.ypos = GLFW_ANY_POSITION; _glfw.hints.window.ypos = GLFW_ANY_POSITION;
_glfw.hints.window.scaleFramebuffer = GLFW_TRUE;
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
// double buffered // double buffered
@ -288,9 +290,6 @@ void glfwDefaultWindowHints(void)
// The default is to select the highest available refresh rate // The default is to select the highest available refresh rate
_glfw.hints.refreshRate = GLFW_DONT_CARE; _glfw.hints.refreshRate = GLFW_DONT_CARE;
// The default is to use full Retina resolution framebuffers
_glfw.hints.window.ns.retina = GLFW_TRUE;
} }
GLFWAPI void glfwWindowHint(int hint, int value) GLFWAPI void glfwWindowHint(int hint, int value)
@ -374,18 +373,22 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_POSITION_Y: case GLFW_POSITION_Y:
_glfw.hints.window.ypos = value; _glfw.hints.window.ypos = value;
return; return;
case GLFW_COCOA_RETINA_FRAMEBUFFER:
_glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_WIN32_KEYBOARD_MENU: case GLFW_WIN32_KEYBOARD_MENU:
_glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_WIN32_SHOWDEFAULT:
_glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_COCOA_GRAPHICS_SWITCHING: case GLFW_COCOA_GRAPHICS_SWITCHING:
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_SCALE_TO_MONITOR: case GLFW_SCALE_TO_MONITOR:
_glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_SCALE_FRAMEBUFFER:
case GLFW_COCOA_RETINA_FRAMEBUFFER:
_glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_CENTER_CURSOR: case GLFW_CENTER_CURSOR:
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
@ -464,10 +467,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
GLFWAPI void glfwDestroyWindow(GLFWwindow* handle) GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
// Allow closing of NULL (to match the behavior of free) // Allow closing of NULL (to match the behavior of free)
if (window == NULL) if (window == NULL)
return; return;
@ -492,49 +495,69 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
*prev = window->next; *prev = window->next;
} }
_glfw_free(window->title);
_glfw_free(window); _glfw_free(window);
} }
GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle) GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(0);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(0);
return window->shouldClose; return window->shouldClose;
} }
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value) GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
window->shouldClose = value; window->shouldClose = value;
} }
GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* handle)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
return window->title;
}
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(title != NULL); assert(title != NULL);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
char* prev = window->title;
window->title = _glfw_strdup(title);
_glfw.platform.setWindowTitle(window, title); _glfw.platform.setWindowTitle(window, title);
_glfw_free(prev);
} }
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
int count, const GLFWimage* images) int count, const GLFWimage* images)
{ {
int i; int i;
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(count >= 0); assert(count >= 0);
assert(count == 0 || images != NULL); assert(count == 0 || images != NULL);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (count < 0) if (count < 0)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon"); _glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon");
@ -556,27 +579,53 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
_glfw.platform.setWindowIcon(window, count, images); _glfw.platform.setWindowIcon(window, count, images);
} }
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos) GLFWAPI void glfwSetWindowProgressIndicator(GLFWwindow* handle, int progressState, double value)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (value < 0.0 || value > 1.0)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid progress amount for window progress indicator");
return;
}
if (progressState != GLFW_PROGRESS_INDICATOR_DISABLED && progressState != GLFW_PROGRESS_INDICATOR_INDETERMINATE &&
progressState != GLFW_PROGRESS_INDICATOR_NORMAL && progressState != GLFW_PROGRESS_INDICATOR_ERROR &&
progressState != GLFW_PROGRESS_INDICATOR_PAUSED)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid progress state 0x%08X", progressState);
return;
}
_glfw.platform.setWindowProgressIndicator(window, progressState, value);
}
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
{
if (xpos) if (xpos)
*xpos = 0; *xpos = 0;
if (ypos) if (ypos)
*ypos = 0; *ypos = 0;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_glfw.platform.getWindowPos(window, xpos, ypos); _glfw.platform.getWindowPos(window, xpos, ypos);
} }
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (window->monitor) if (window->monitor)
return; return;
@ -585,27 +634,29 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height) GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (width) if (width)
*width = 0; *width = 0;
if (height) if (height)
*height = 0; *height = 0;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_glfw.platform.getWindowSize(window, width, height); _glfw.platform.getWindowSize(window, width, height);
} }
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height) GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(width >= 0); assert(width >= 0);
assert(height >= 0); assert(height >= 0);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
window->videoMode.width = width; window->videoMode.width = width;
window->videoMode.height = height; window->videoMode.height = height;
@ -616,11 +667,11 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
int minwidth, int minheight, int minwidth, int minheight,
int maxwidth, int maxheight) int maxwidth, int maxheight)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE) if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE)
{ {
if (minwidth < 0 || minheight < 0) if (minwidth < 0 || minheight < 0)
@ -659,13 +710,14 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom) GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(numer != 0); assert(numer != 0);
assert(denom != 0); assert(denom != 0);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE) if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
{ {
if (numer <= 0 || denom <= 0) if (numer <= 0 || denom <= 0)
@ -688,15 +740,16 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height) GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (width) if (width)
*width = 0; *width = 0;
if (height) if (height)
*height = 0; *height = 0;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_glfw.platform.getFramebufferSize(window, width, height); _glfw.platform.getFramebufferSize(window, width, height);
} }
@ -704,9 +757,6 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
int* left, int* top, int* left, int* top,
int* right, int* bottom) int* right, int* bottom)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (left) if (left)
*left = 0; *left = 0;
if (top) if (top)
@ -717,43 +767,50 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
*bottom = 0; *bottom = 0;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_glfw.platform.getWindowFrameSize(window, left, top, right, bottom); _glfw.platform.getWindowFrameSize(window, left, top, right, bottom);
} }
GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle, GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
float* xscale, float* yscale) float* xscale, float* yscale)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (xscale) if (xscale)
*xscale = 0.f; *xscale = 0.f;
if (yscale) if (yscale)
*yscale = 0.f; *yscale = 0.f;
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_glfw.platform.getWindowContentScale(window, xscale, yscale); _glfw.platform.getWindowContentScale(window, xscale, yscale);
} }
GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle) GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(0.f);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
return _glfw.platform.getWindowOpacity(window); return _glfw.platform.getWindowOpacity(window);
} }
GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity) GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
assert(opacity == opacity); assert(opacity == opacity);
assert(opacity >= 0.f); assert(opacity >= 0.f);
assert(opacity <= 1.f); assert(opacity <= 1.f);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
if (opacity != opacity || opacity < 0.f || opacity > 1.f) if (opacity != opacity || opacity < 0.f || opacity > 1.f)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity); _glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity);
@ -765,29 +822,31 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle) GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
_glfw.platform.iconifyWindow(window); _glfw.platform.iconifyWindow(window);
} }
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle) GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
_glfw.platform.restoreWindow(window); _glfw.platform.restoreWindow(window);
} }
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle) GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (window->monitor) if (window->monitor)
return; return;
@ -796,11 +855,11 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
GLFWAPI void glfwShowWindow(GLFWwindow* handle) GLFWAPI void glfwShowWindow(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (window->monitor) if (window->monitor)
return; return;
@ -812,21 +871,21 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle)
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle) GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
_glfw.platform.requestWindowAttention(window); _glfw.platform.requestWindowAttention(window);
} }
GLFWAPI void glfwHideWindow(GLFWwindow* handle) GLFWAPI void glfwHideWindow(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (window->monitor) if (window->monitor)
return; return;
@ -835,21 +894,21 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle)
GLFWAPI void glfwFocusWindow(GLFWwindow* handle) GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
_glfw.platform.focusWindow(window); _glfw.platform.focusWindow(window);
} }
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(0);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(0);
switch (attrib) switch (attrib)
{ {
case GLFW_FOCUSED: case GLFW_FOCUSED:
@ -908,11 +967,11 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
value = value ? GLFW_TRUE : GLFW_FALSE; value = value ? GLFW_TRUE : GLFW_FALSE;
switch (attrib) switch (attrib)
@ -954,10 +1013,11 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle) GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return (GLFWmonitor*) window->monitor; return (GLFWmonitor*) window->monitor;
} }
@ -967,14 +1027,15 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
int width, int height, int width, int height,
int refreshRate) int refreshRate)
{ {
_GLFWwindow* window = (_GLFWwindow*) wh;
_GLFWmonitor* monitor = (_GLFWmonitor*) mh;
assert(window != NULL);
assert(width >= 0); assert(width >= 0);
assert(height >= 0); assert(height >= 0);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) wh;
_GLFWmonitor* monitor = (_GLFWmonitor*) mh;
assert(window != NULL);
if (width <= 0 || height <= 0) if (width <= 0 || height <= 0)
{ {
_glfwInputError(GLFW_INVALID_VALUE, _glfwInputError(GLFW_INVALID_VALUE,
@ -1002,29 +1063,32 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer) GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
{ {
_GLFW_REQUIRE_INIT();
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT();
window->userPointer = pointer; window->userPointer = pointer;
} }
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle) GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->userPointer; return window->userPointer;
} }
GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle, GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
GLFWwindowposfun cbfun) GLFWwindowposfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun); _GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun);
return cbfun; return cbfun;
} }
@ -1032,10 +1096,11 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle, GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
GLFWwindowsizefun cbfun) GLFWwindowsizefun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun); _GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun);
return cbfun; return cbfun;
} }
@ -1043,10 +1108,11 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle, GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
GLFWwindowclosefun cbfun) GLFWwindowclosefun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun); _GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun);
return cbfun; return cbfun;
} }
@ -1054,10 +1120,11 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle, GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
GLFWwindowrefreshfun cbfun) GLFWwindowrefreshfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun); _GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun);
return cbfun; return cbfun;
} }
@ -1065,10 +1132,11 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle, GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
GLFWwindowfocusfun cbfun) GLFWwindowfocusfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun); _GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun);
return cbfun; return cbfun;
} }
@ -1076,10 +1144,11 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle, GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
GLFWwindowiconifyfun cbfun) GLFWwindowiconifyfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun); _GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun);
return cbfun; return cbfun;
} }
@ -1087,10 +1156,11 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle, GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
GLFWwindowmaximizefun cbfun) GLFWwindowmaximizefun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun); _GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun);
return cbfun; return cbfun;
} }
@ -1098,10 +1168,11 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle, GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
GLFWframebuffersizefun cbfun) GLFWframebuffersizefun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun); _GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun);
return cbfun; return cbfun;
} }
@ -1109,10 +1180,11 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle
GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle, GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle,
GLFWwindowcontentscalefun cbfun) GLFWwindowcontentscalefun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun); _GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun);
return cbfun; return cbfun;
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Wayland - www.glfw.org // GLFW 3.5 Wayland - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
@ -46,6 +46,8 @@
#include "viewporter-client-protocol.h" #include "viewporter-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h" #include "relative-pointer-unstable-v1-client-protocol.h"
#include "pointer-constraints-unstable-v1-client-protocol.h" #include "pointer-constraints-unstable-v1-client-protocol.h"
#include "fractional-scale-v1-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h" #include "idle-inhibit-unstable-v1-client-protocol.h"
// NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of // NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of
@ -77,6 +79,14 @@
#include "pointer-constraints-unstable-v1-client-protocol-code.h" #include "pointer-constraints-unstable-v1-client-protocol-code.h"
#undef types #undef types
#define types _glfw_fractional_scale_types
#include "fractional-scale-v1-client-protocol-code.h"
#undef types
#define types _glfw_xdg_activation_types
#include "xdg-activation-v1-client-protocol-code.h"
#undef types
#define types _glfw_idle_inhibit_types #define types _glfw_idle_inhibit_types
#include "idle-inhibit-unstable-v1-client-protocol-code.h" #include "idle-inhibit-unstable-v1-client-protocol-code.h"
#undef types #undef types
@ -127,6 +137,13 @@ static void registryHandleGlobal(void* userData,
wl_registry_bind(registry, name, &wl_seat_interface, wl_registry_bind(registry, name, &wl_seat_interface,
_glfw_min(4, version)); _glfw_min(4, version));
_glfwAddSeatListenerWayland(_glfw.wl.seat); _glfwAddSeatListenerWayland(_glfw.wl.seat);
if (wl_seat_get_version(_glfw.wl.seat) >=
WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
{
_glfw.wl.keyRepeatTimerfd =
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
}
} }
} }
else if (strcmp(interface, "wl_data_device_manager") == 0) else if (strcmp(interface, "wl_data_device_manager") == 0)
@ -177,6 +194,20 @@ static void registryHandleGlobal(void* userData,
&zwp_idle_inhibit_manager_v1_interface, &zwp_idle_inhibit_manager_v1_interface,
1); 1);
} }
else if (strcmp(interface, "xdg_activation_v1") == 0)
{
_glfw.wl.activationManager =
wl_registry_bind(registry, name,
&xdg_activation_v1_interface,
1);
}
else if (strcmp(interface, "wp_fractional_scale_manager_v1") == 0)
{
_glfw.wl.fractionalScaleManager =
wl_registry_bind(registry, name,
&wp_fractional_scale_manager_v1_interface,
1);
}
} }
static void registryHandleGlobalRemove(void* userData, static void registryHandleGlobalRemove(void* userData,
@ -405,86 +436,87 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
{ {
const _GLFWplatform wayland = const _GLFWplatform wayland =
{ {
GLFW_PLATFORM_WAYLAND, .platformID = GLFW_PLATFORM_WAYLAND,
_glfwInitWayland, .init = _glfwInitWayland,
_glfwTerminateWayland, .terminate = _glfwTerminateWayland,
_glfwGetCursorPosWayland, .getCursorPos = _glfwGetCursorPosWayland,
_glfwSetCursorPosWayland, .setCursorPos = _glfwSetCursorPosWayland,
_glfwSetCursorModeWayland, .setCursorMode = _glfwSetCursorModeWayland,
_glfwSetRawMouseMotionWayland, .setRawMouseMotion = _glfwSetRawMouseMotionWayland,
_glfwRawMouseMotionSupportedWayland, .rawMouseMotionSupported = _glfwRawMouseMotionSupportedWayland,
_glfwCreateCursorWayland, .createCursor = _glfwCreateCursorWayland,
_glfwCreateStandardCursorWayland, .createStandardCursor = _glfwCreateStandardCursorWayland,
_glfwDestroyCursorWayland, .destroyCursor = _glfwDestroyCursorWayland,
_glfwSetCursorWayland, .setCursor = _glfwSetCursorWayland,
_glfwGetScancodeNameWayland, .getScancodeName = _glfwGetScancodeNameWayland,
_glfwGetKeyScancodeWayland, .getKeyScancode = _glfwGetKeyScancodeWayland,
_glfwSetClipboardStringWayland, .setClipboardString = _glfwSetClipboardStringWayland,
_glfwGetClipboardStringWayland, .getClipboardString = _glfwGetClipboardStringWayland,
#if defined(GLFW_BUILD_LINUX_JOYSTICK) #if defined(GLFW_BUILD_LINUX_JOYSTICK)
_glfwInitJoysticksLinux, .initJoysticks = _glfwInitJoysticksLinux,
_glfwTerminateJoysticksLinux, .terminateJoysticks = _glfwTerminateJoysticksLinux,
_glfwPollJoystickLinux, .pollJoystick = _glfwPollJoystickLinux,
_glfwGetMappingNameLinux, .getMappingName = _glfwGetMappingNameLinux,
_glfwUpdateGamepadGUIDLinux, .updateGamepadGUID = _glfwUpdateGamepadGUIDLinux,
#else #else
_glfwInitJoysticksNull, .initJoysticks = _glfwInitJoysticksNull,
_glfwTerminateJoysticksNull, .terminateJoysticks = _glfwTerminateJoysticksNull,
_glfwPollJoystickNull, .pollJoystick = _glfwPollJoystickNull,
_glfwGetMappingNameNull, .getMappingName = _glfwGetMappingNameNull,
_glfwUpdateGamepadGUIDNull, .updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
#endif #endif
_glfwFreeMonitorWayland, .freeMonitor = _glfwFreeMonitorWayland,
_glfwGetMonitorPosWayland, .getMonitorPos = _glfwGetMonitorPosWayland,
_glfwGetMonitorContentScaleWayland, .getMonitorContentScale = _glfwGetMonitorContentScaleWayland,
_glfwGetMonitorWorkareaWayland, .getMonitorWorkarea = _glfwGetMonitorWorkareaWayland,
_glfwGetVideoModesWayland, .getVideoModes = _glfwGetVideoModesWayland,
_glfwGetVideoModeWayland, .getVideoMode = _glfwGetVideoModeWayland,
_glfwGetGammaRampWayland, .getGammaRamp = _glfwGetGammaRampWayland,
_glfwSetGammaRampWayland, .setGammaRamp = _glfwSetGammaRampWayland,
_glfwCreateWindowWayland, .createWindow = _glfwCreateWindowWayland,
_glfwDestroyWindowWayland, .destroyWindow = _glfwDestroyWindowWayland,
_glfwSetWindowTitleWayland, .setWindowTitle = _glfwSetWindowTitleWayland,
_glfwSetWindowIconWayland, .setWindowIcon = _glfwSetWindowIconWayland,
_glfwGetWindowPosWayland, .setWindowProgressIndicator = _glfwSetWindowProgressIndicatorWayland,
_glfwSetWindowPosWayland, .getWindowPos = _glfwGetWindowPosWayland,
_glfwGetWindowSizeWayland, .setWindowPos = _glfwSetWindowPosWayland,
_glfwSetWindowSizeWayland, .getWindowSize = _glfwGetWindowSizeWayland,
_glfwSetWindowSizeLimitsWayland, .setWindowSize = _glfwSetWindowSizeWayland,
_glfwSetWindowAspectRatioWayland, .setWindowSizeLimits = _glfwSetWindowSizeLimitsWayland,
_glfwGetFramebufferSizeWayland, .setWindowAspectRatio = _glfwSetWindowAspectRatioWayland,
_glfwGetWindowFrameSizeWayland, .getFramebufferSize = _glfwGetFramebufferSizeWayland,
_glfwGetWindowContentScaleWayland, .getWindowFrameSize = _glfwGetWindowFrameSizeWayland,
_glfwIconifyWindowWayland, .getWindowContentScale = _glfwGetWindowContentScaleWayland,
_glfwRestoreWindowWayland, .iconifyWindow = _glfwIconifyWindowWayland,
_glfwMaximizeWindowWayland, .restoreWindow = _glfwRestoreWindowWayland,
_glfwShowWindowWayland, .maximizeWindow = _glfwMaximizeWindowWayland,
_glfwHideWindowWayland, .showWindow = _glfwShowWindowWayland,
_glfwRequestWindowAttentionWayland, .hideWindow = _glfwHideWindowWayland,
_glfwFocusWindowWayland, .requestWindowAttention = _glfwRequestWindowAttentionWayland,
_glfwSetWindowMonitorWayland, .focusWindow = _glfwFocusWindowWayland,
_glfwWindowFocusedWayland, .setWindowMonitor = _glfwSetWindowMonitorWayland,
_glfwWindowIconifiedWayland, .windowFocused = _glfwWindowFocusedWayland,
_glfwWindowVisibleWayland, .windowIconified = _glfwWindowIconifiedWayland,
_glfwWindowMaximizedWayland, .windowVisible = _glfwWindowVisibleWayland,
_glfwWindowHoveredWayland, .windowMaximized = _glfwWindowMaximizedWayland,
_glfwFramebufferTransparentWayland, .windowHovered = _glfwWindowHoveredWayland,
_glfwGetWindowOpacityWayland, .framebufferTransparent = _glfwFramebufferTransparentWayland,
_glfwSetWindowResizableWayland, .getWindowOpacity = _glfwGetWindowOpacityWayland,
_glfwSetWindowDecoratedWayland, .setWindowResizable = _glfwSetWindowResizableWayland,
_glfwSetWindowFloatingWayland, .setWindowDecorated = _glfwSetWindowDecoratedWayland,
_glfwSetWindowOpacityWayland, .setWindowFloating = _glfwSetWindowFloatingWayland,
_glfwSetWindowMousePassthroughWayland, .setWindowOpacity = _glfwSetWindowOpacityWayland,
_glfwPollEventsWayland, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWayland,
_glfwWaitEventsWayland, .pollEvents = _glfwPollEventsWayland,
_glfwWaitEventsTimeoutWayland, .waitEvents = _glfwWaitEventsWayland,
_glfwPostEmptyEventWayland, .waitEventsTimeout = _glfwWaitEventsTimeoutWayland,
_glfwGetEGLPlatformWayland, .postEmptyEvent = _glfwPostEmptyEventWayland,
_glfwGetEGLNativeDisplayWayland, .getEGLPlatform = _glfwGetEGLPlatformWayland,
_glfwGetEGLNativeWindowWayland, .getEGLNativeDisplay = _glfwGetEGLNativeDisplayWayland,
_glfwGetRequiredInstanceExtensionsWayland, .getEGLNativeWindow = _glfwGetEGLNativeWindowWayland,
_glfwGetPhysicalDevicePresentationSupportWayland, .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWayland,
_glfwCreateWindowSurfaceWayland, .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWayland,
.createWindowSurface = _glfwCreateWindowSurfaceWayland
}; };
void* module = _glfwPlatformLoadModule("libwayland-client.so.0"); void* module = _glfwPlatformLoadModule("libwayland-client.so.0");
@ -532,6 +564,8 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
int _glfwInitWayland(void) int _glfwInitWayland(void)
{ {
_glfwInitDBusPOSIX();
// These must be set before any failure checks // These must be set before any failure checks
_glfw.wl.keyRepeatTimerfd = -1; _glfw.wl.keyRepeatTimerfd = -1;
_glfw.wl.cursorTimerfd = -1; _glfw.wl.cursorTimerfd = -1;
@ -681,6 +715,32 @@ int _glfwInitWayland(void)
_glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym) _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
if (!_glfw.wl.xkb.context_new ||
!_glfw.wl.xkb.context_unref ||
!_glfw.wl.xkb.keymap_new_from_string ||
!_glfw.wl.xkb.keymap_unref ||
!_glfw.wl.xkb.keymap_mod_get_index ||
!_glfw.wl.xkb.keymap_key_repeats ||
!_glfw.wl.xkb.keymap_key_get_syms_by_level ||
!_glfw.wl.xkb.state_new ||
!_glfw.wl.xkb.state_unref ||
!_glfw.wl.xkb.state_key_get_syms ||
!_glfw.wl.xkb.state_update_mask ||
!_glfw.wl.xkb.state_key_get_layout ||
!_glfw.wl.xkb.state_mod_index_is_active ||
!_glfw.wl.xkb.compose_table_new_from_locale ||
!_glfw.wl.xkb.compose_table_unref ||
!_glfw.wl.xkb.compose_state_new ||
!_glfw.wl.xkb.compose_state_unref ||
!_glfw.wl.xkb.compose_state_feed ||
!_glfw.wl.xkb.compose_state_get_status ||
!_glfw.wl.xkb.compose_state_get_one_sym)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Failed to load all entry points from libxkbcommon");
return GLFW_FALSE;
}
if (_glfw.hints.init.wl.libdecorMode == GLFW_WAYLAND_PREFER_LIBDECOR) if (_glfw.hints.init.wl.libdecorMode == GLFW_WAYLAND_PREFER_LIBDECOR)
_glfw.wl.libdecor.handle = _glfwPlatformLoadModule("libdecor-0.so.0"); _glfw.wl.libdecor.handle = _glfwPlatformLoadModule("libdecor-0.so.0");
@ -803,12 +863,6 @@ int _glfwInitWayland(void)
} }
} }
if (wl_seat_get_version(_glfw.wl.seat) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
{
_glfw.wl.keyRepeatTimerfd =
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
}
if (!_glfw.wl.wmBase) if (!_glfw.wl.wmBase)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
@ -929,6 +983,10 @@ void _glfwTerminateWayland(void)
zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints); zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
if (_glfw.wl.idleInhibitManager) if (_glfw.wl.idleInhibitManager)
zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager); zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
if (_glfw.wl.activationManager)
xdg_activation_v1_destroy(_glfw.wl.activationManager);
if (_glfw.wl.fractionalScaleManager)
wp_fractional_scale_manager_v1_destroy(_glfw.wl.fractionalScaleManager);
if (_glfw.wl.registry) if (_glfw.wl.registry)
wl_registry_destroy(_glfw.wl.registry); wl_registry_destroy(_glfw.wl.registry);
if (_glfw.wl.display) if (_glfw.wl.display)
@ -943,6 +1001,8 @@ void _glfwTerminateWayland(void)
close(_glfw.wl.cursorTimerfd); close(_glfw.wl.cursorTimerfd);
_glfw_free(_glfw.wl.clipboardString); _glfw_free(_glfw.wl.clipboardString);
_glfwTerminateDBusPOSIX();
} }
#endif // _GLFW_WAYLAND #endif // _GLFW_WAYLAND

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Wayland - www.glfw.org // GLFW 3.5 Wayland - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
@ -33,6 +33,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <math.h> #include <math.h>
#include <assert.h>
#include "wayland-client-protocol.h" #include "wayland-client-protocol.h"
@ -112,16 +113,16 @@ static void outputHandleScale(void* userData,
{ {
struct _GLFWmonitor* monitor = userData; struct _GLFWmonitor* monitor = userData;
monitor->wl.contentScale = factor; monitor->wl.scale = factor;
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
{ {
for (int i = 0; i < window->wl.scaleCount; i++) for (size_t i = 0; i < window->wl.outputScaleCount; i++)
{ {
if (window->wl.scales[i].output == monitor->wl.output) if (window->wl.outputScales[i].output == monitor->wl.output)
{ {
window->wl.scales[i].factor = monitor->wl.contentScale; window->wl.outputScales[i].factor = monitor->wl.scale;
_glfwUpdateContentScaleWayland(window); _glfwUpdateBufferScaleFromOutputsWayland(window);
break; break;
} }
} }
@ -176,7 +177,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
// The actual name of this output will be set in the geometry handler // The actual name of this output will be set in the geometry handler
_GLFWmonitor* monitor = _glfwAllocMonitor("", 0, 0); _GLFWmonitor* monitor = _glfwAllocMonitor("", 0, 0);
monitor->wl.contentScale = 1; monitor->wl.scale = 1;
monitor->wl.output = output; monitor->wl.output = output;
monitor->wl.name = name; monitor->wl.name = name;
@ -207,9 +208,9 @@ void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor,
float* xscale, float* yscale) float* xscale, float* yscale)
{ {
if (xscale) if (xscale)
*xscale = (float) monitor->wl.contentScale; *xscale = (float) monitor->wl.scale;
if (yscale) if (yscale)
*yscale = (float) monitor->wl.contentScale; *yscale = (float) monitor->wl.scale;
} }
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor,
@ -232,9 +233,10 @@ GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found)
return monitor->modes; return monitor->modes;
} }
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
*mode = monitor->modes[monitor->wl.currentMode]; *mode = monitor->modes[monitor->wl.currentMode];
return GLFW_TRUE;
} }
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -257,8 +259,17 @@ void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Wayland: Platform not initialized");
return NULL;
}
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
return monitor->wl.output; return monitor->wl.output;
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Wayland - www.glfw.org // GLFW 3.5 Wayland - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
@ -28,8 +28,6 @@
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h> #include <xkbcommon/xkbcommon-compose.h>
#include <stdbool.h>
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
typedef struct VkWaylandSurfaceCreateInfoKHR typedef struct VkWaylandSurfaceCreateInfoKHR
@ -129,6 +127,10 @@ struct wl_output;
#define xdg_surface_interface _glfw_xdg_surface_interface #define xdg_surface_interface _glfw_xdg_surface_interface
#define xdg_toplevel_interface _glfw_xdg_toplevel_interface #define xdg_toplevel_interface _glfw_xdg_toplevel_interface
#define xdg_wm_base_interface _glfw_xdg_wm_base_interface #define xdg_wm_base_interface _glfw_xdg_wm_base_interface
#define xdg_activation_v1_interface _glfw_xdg_activation_v1_interface
#define xdg_activation_token_v1_interface _glfw_xdg_activation_token_v1_interface
#define wl_surface_interface _glfw_wl_surface_interface
#define wp_fractional_scale_v1_interface _glfw_wp_fractional_scale_v1_interface
#define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl; #define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl;
#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl; #define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl;
@ -321,21 +323,12 @@ typedef void (* PFN_libdecor_state_free)(struct libdecor_state*);
#define libdecor_state_new _glfw.wl.libdecor.libdecor_state_new_ #define libdecor_state_new _glfw.wl.libdecor.libdecor_state_new_
#define libdecor_state_free _glfw.wl.libdecor.libdecor_state_free_ #define libdecor_state_free _glfw.wl.libdecor.libdecor_state_free_
typedef enum _GLFWdecorationSideWayland typedef struct _GLFWfallbackEdgeWayland
{
GLFW_MAIN_WINDOW,
GLFW_TOP_DECORATION,
GLFW_LEFT_DECORATION,
GLFW_RIGHT_DECORATION,
GLFW_BOTTOM_DECORATION
} _GLFWdecorationSideWayland;
typedef struct _GLFWdecorationWayland
{ {
struct wl_surface* surface; struct wl_surface* surface;
struct wl_subsurface* subsurface; struct wl_subsurface* subsurface;
struct wp_viewport* viewport; struct wp_viewport* viewport;
} _GLFWdecorationWayland; } _GLFWfallbackEdgeWayland;
typedef struct _GLFWofferWayland typedef struct _GLFWofferWayland
{ {
@ -347,7 +340,7 @@ typedef struct _GLFWofferWayland
typedef struct _GLFWscaleWayland typedef struct _GLFWscaleWayland
{ {
struct wl_output* output; struct wl_output* output;
int factor; int32_t factor;
} _GLFWscaleWayland; } _GLFWscaleWayland;
// Wayland-specific per-window data // Wayland-specific per-window data
@ -355,12 +348,14 @@ typedef struct _GLFWscaleWayland
typedef struct _GLFWwindowWayland typedef struct _GLFWwindowWayland
{ {
int width, height; int width, height;
int fbWidth, fbHeight;
GLFWbool visible; GLFWbool visible;
GLFWbool maximized; GLFWbool maximized;
GLFWbool activated; GLFWbool activated;
GLFWbool fullscreen; GLFWbool fullscreen;
GLFWbool hovered; GLFWbool hovered;
GLFWbool transparent; GLFWbool transparent;
GLFWbool scaleFramebuffer;
struct wl_surface* surface; struct wl_surface* surface;
struct wl_callback* callback; struct wl_callback* callback;
@ -385,33 +380,37 @@ typedef struct _GLFWwindowWayland
struct { struct {
struct libdecor_frame* frame; struct libdecor_frame* frame;
int mode;
} libdecor; } libdecor;
_GLFWcursor* currentCursor; _GLFWcursor* currentCursor;
double cursorPosX, cursorPosY; double cursorPosX, cursorPosY;
char* title;
char* appId; char* appId;
// We need to track the monitors the window spans on to calculate the // We need to track the monitors the window spans on to calculate the
// optimal scaling factor. // optimal scaling factor.
int contentScale; int32_t bufferScale;
_GLFWscaleWayland* scales; _GLFWscaleWayland* outputScales;
int scaleCount; size_t outputScaleCount;
int scaleSize; size_t outputScaleSize;
struct wp_viewport* scalingViewport;
uint32_t scalingNumerator;
struct wp_fractional_scale_v1* fractionalScale;
struct zwp_relative_pointer_v1* relativePointer; struct zwp_relative_pointer_v1* relativePointer;
struct zwp_locked_pointer_v1* lockedPointer; struct zwp_locked_pointer_v1* lockedPointer;
struct zwp_confined_pointer_v1* confinedPointer; struct zwp_confined_pointer_v1* confinedPointer;
struct zwp_idle_inhibitor_v1* idleInhibitor; struct zwp_idle_inhibitor_v1* idleInhibitor;
struct xdg_activation_token_v1* activationToken;
struct { struct {
struct wl_buffer* buffer; GLFWbool decorations;
_GLFWdecorationWayland top, left, right, bottom; struct wl_buffer* buffer;
_GLFWdecorationSideWayland focus; _GLFWfallbackEdgeWayland top, left, right, bottom;
} decorations; struct wl_surface* focus;
} fallback;
} _GLFWwindowWayland; } _GLFWwindowWayland;
// Wayland-specific global data // Wayland-specific global data
@ -434,6 +433,8 @@ typedef struct _GLFWlibraryWayland
struct zwp_relative_pointer_manager_v1* relativePointerManager; struct zwp_relative_pointer_manager_v1* relativePointerManager;
struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_pointer_constraints_v1* pointerConstraints;
struct zwp_idle_inhibit_manager_v1* idleInhibitManager; struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
struct xdg_activation_v1* activationManager;
struct wp_fractional_scale_manager_v1* fractionalScaleManager;
_GLFWofferWayland* offers; _GLFWofferWayland* offers;
unsigned int offerCount; unsigned int offerCount;
@ -590,7 +591,7 @@ typedef struct _GLFWmonitorWayland
int x; int x;
int y; int y;
int contentScale; int32_t scale;
} _GLFWmonitorWayland; } _GLFWmonitorWayland;
// Wayland-specific per-cursor data // Wayland-specific per-cursor data
@ -613,6 +614,7 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wnd
void _glfwDestroyWindowWayland(_GLFWwindow* window); void _glfwDestroyWindowWayland(_GLFWwindow* window);
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowProgressIndicatorWayland(_GLFWwindow* window, int progressState, double value);
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos); void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos);
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height); void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height);
@ -676,12 +678,12 @@ void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count); GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp); GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
void _glfwAddOutputWayland(uint32_t name, uint32_t version); void _glfwAddOutputWayland(uint32_t name, uint32_t version);
void _glfwUpdateContentScaleWayland(_GLFWwindow* window); void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window);
void _glfwAddSeatListenerWayland(struct wl_seat* seat); void _glfwAddSeatListenerWayland(struct wl_seat* seat);
void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device); void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device);

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 X11 - www.glfw.org // GLFW 3.5 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -1166,86 +1166,87 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
{ {
const _GLFWplatform x11 = const _GLFWplatform x11 =
{ {
GLFW_PLATFORM_X11, .platformID = GLFW_PLATFORM_X11,
_glfwInitX11, .init = _glfwInitX11,
_glfwTerminateX11, .terminate = _glfwTerminateX11,
_glfwGetCursorPosX11, .getCursorPos = _glfwGetCursorPosX11,
_glfwSetCursorPosX11, .setCursorPos = _glfwSetCursorPosX11,
_glfwSetCursorModeX11, .setCursorMode = _glfwSetCursorModeX11,
_glfwSetRawMouseMotionX11, .setRawMouseMotion = _glfwSetRawMouseMotionX11,
_glfwRawMouseMotionSupportedX11, .rawMouseMotionSupported = _glfwRawMouseMotionSupportedX11,
_glfwCreateCursorX11, .createCursor = _glfwCreateCursorX11,
_glfwCreateStandardCursorX11, .createStandardCursor = _glfwCreateStandardCursorX11,
_glfwDestroyCursorX11, .destroyCursor = _glfwDestroyCursorX11,
_glfwSetCursorX11, .setCursor = _glfwSetCursorX11,
_glfwGetScancodeNameX11, .getScancodeName = _glfwGetScancodeNameX11,
_glfwGetKeyScancodeX11, .getKeyScancode = _glfwGetKeyScancodeX11,
_glfwSetClipboardStringX11, .setClipboardString = _glfwSetClipboardStringX11,
_glfwGetClipboardStringX11, .getClipboardString = _glfwGetClipboardStringX11,
#if defined(GLFW_BUILD_LINUX_JOYSTICK) #if defined(GLFW_BUILD_LINUX_JOYSTICK)
_glfwInitJoysticksLinux, .initJoysticks = _glfwInitJoysticksLinux,
_glfwTerminateJoysticksLinux, .terminateJoysticks = _glfwTerminateJoysticksLinux,
_glfwPollJoystickLinux, .pollJoystick = _glfwPollJoystickLinux,
_glfwGetMappingNameLinux, .getMappingName = _glfwGetMappingNameLinux,
_glfwUpdateGamepadGUIDLinux, .updateGamepadGUID = _glfwUpdateGamepadGUIDLinux,
#else #else
_glfwInitJoysticksNull, .initJoysticks = _glfwInitJoysticksNull,
_glfwTerminateJoysticksNull, .terminateJoysticks = _glfwTerminateJoysticksNull,
_glfwPollJoystickNull, .pollJoystick = _glfwPollJoystickNull,
_glfwGetMappingNameNull, .getMappingName = _glfwGetMappingNameNull,
_glfwUpdateGamepadGUIDNull, .updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
#endif #endif
_glfwFreeMonitorX11, .freeMonitor = _glfwFreeMonitorX11,
_glfwGetMonitorPosX11, .getMonitorPos = _glfwGetMonitorPosX11,
_glfwGetMonitorContentScaleX11, .getMonitorContentScale = _glfwGetMonitorContentScaleX11,
_glfwGetMonitorWorkareaX11, .getMonitorWorkarea = _glfwGetMonitorWorkareaX11,
_glfwGetVideoModesX11, .getVideoModes = _glfwGetVideoModesX11,
_glfwGetVideoModeX11, .getVideoMode = _glfwGetVideoModeX11,
_glfwGetGammaRampX11, .getGammaRamp = _glfwGetGammaRampX11,
_glfwSetGammaRampX11, .setGammaRamp = _glfwSetGammaRampX11,
_glfwCreateWindowX11, .createWindow = _glfwCreateWindowX11,
_glfwDestroyWindowX11, .destroyWindow = _glfwDestroyWindowX11,
_glfwSetWindowTitleX11, .setWindowTitle = _glfwSetWindowTitleX11,
_glfwSetWindowIconX11, .setWindowIcon = _glfwSetWindowIconX11,
_glfwGetWindowPosX11, .setWindowProgressIndicator = _glfwSetWindowProgressIndicatorX11,
_glfwSetWindowPosX11, .getWindowPos = _glfwGetWindowPosX11,
_glfwGetWindowSizeX11, .setWindowPos = _glfwSetWindowPosX11,
_glfwSetWindowSizeX11, .getWindowSize = _glfwGetWindowSizeX11,
_glfwSetWindowSizeLimitsX11, .setWindowSize = _glfwSetWindowSizeX11,
_glfwSetWindowAspectRatioX11, .setWindowSizeLimits = _glfwSetWindowSizeLimitsX11,
_glfwGetFramebufferSizeX11, .setWindowAspectRatio = _glfwSetWindowAspectRatioX11,
_glfwGetWindowFrameSizeX11, .getFramebufferSize = _glfwGetFramebufferSizeX11,
_glfwGetWindowContentScaleX11, .getWindowFrameSize = _glfwGetWindowFrameSizeX11,
_glfwIconifyWindowX11, .getWindowContentScale = _glfwGetWindowContentScaleX11,
_glfwRestoreWindowX11, .iconifyWindow = _glfwIconifyWindowX11,
_glfwMaximizeWindowX11, .restoreWindow = _glfwRestoreWindowX11,
_glfwShowWindowX11, .maximizeWindow = _glfwMaximizeWindowX11,
_glfwHideWindowX11, .showWindow = _glfwShowWindowX11,
_glfwRequestWindowAttentionX11, .hideWindow = _glfwHideWindowX11,
_glfwFocusWindowX11, .requestWindowAttention = _glfwRequestWindowAttentionX11,
_glfwSetWindowMonitorX11, .focusWindow = _glfwFocusWindowX11,
_glfwWindowFocusedX11, .setWindowMonitor = _glfwSetWindowMonitorX11,
_glfwWindowIconifiedX11, .windowFocused = _glfwWindowFocusedX11,
_glfwWindowVisibleX11, .windowIconified = _glfwWindowIconifiedX11,
_glfwWindowMaximizedX11, .windowVisible = _glfwWindowVisibleX11,
_glfwWindowHoveredX11, .windowMaximized = _glfwWindowMaximizedX11,
_glfwFramebufferTransparentX11, .windowHovered = _glfwWindowHoveredX11,
_glfwGetWindowOpacityX11, .framebufferTransparent = _glfwFramebufferTransparentX11,
_glfwSetWindowResizableX11, .getWindowOpacity = _glfwGetWindowOpacityX11,
_glfwSetWindowDecoratedX11, .setWindowResizable = _glfwSetWindowResizableX11,
_glfwSetWindowFloatingX11, .setWindowDecorated = _glfwSetWindowDecoratedX11,
_glfwSetWindowOpacityX11, .setWindowFloating = _glfwSetWindowFloatingX11,
_glfwSetWindowMousePassthroughX11, .setWindowOpacity = _glfwSetWindowOpacityX11,
_glfwPollEventsX11, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11,
_glfwWaitEventsX11, .pollEvents = _glfwPollEventsX11,
_glfwWaitEventsTimeoutX11, .waitEvents = _glfwWaitEventsX11,
_glfwPostEmptyEventX11, .waitEventsTimeout = _glfwWaitEventsTimeoutX11,
_glfwGetEGLPlatformX11, .postEmptyEvent = _glfwPostEmptyEventX11,
_glfwGetEGLNativeDisplayX11, .getEGLPlatform = _glfwGetEGLPlatformX11,
_glfwGetEGLNativeWindowX11, .getEGLNativeDisplay = _glfwGetEGLNativeDisplayX11,
_glfwGetRequiredInstanceExtensionsX11, .getEGLNativeWindow = _glfwGetEGLNativeWindowX11,
_glfwGetPhysicalDevicePresentationSupportX11, .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsX11,
_glfwCreateWindowSurfaceX11, .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportX11,
.createWindowSurface = _glfwCreateWindowSurfaceX11
}; };
// HACK: If the application has left the locale as "C" then both wide // HACK: If the application has left the locale as "C" then both wide
@ -1319,6 +1320,8 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
int _glfwInitX11(void) int _glfwInitX11(void)
{ {
_glfwInitDBusPOSIX();
_glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint) _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint)
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocClassHint"); _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocClassHint");
_glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints) _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints)
@ -1650,6 +1653,8 @@ void _glfwTerminateX11(void)
close(_glfw.x11.emptyEventPipe[0]); close(_glfw.x11.emptyEventPipe[0]);
close(_glfw.x11.emptyEventPipe[1]); close(_glfw.x11.emptyEventPipe[1]);
} }
_glfwTerminateDBusPOSIX();
} }
#endif // _GLFW_X11 #endif // _GLFW_X11

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 X11 - www.glfw.org // GLFW 3.5 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -33,6 +33,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <assert.h>
// Check whether the display mode should be included in enumeration // Check whether the display mode should be included in enumeration
@ -491,24 +492,31 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
return result; return result;
} }
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr = XRRScreenResources* sr =
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); const XRRModeInfo* mi = NULL;
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
if (ci) if (ci)
{ {
const XRRModeInfo* mi = getModeInfo(sr, ci->mode); mi = getModeInfo(sr, ci->mode);
if (mi) // mi can be NULL if the monitor has been disconnected if (mi)
*mode = vidmodeFromModeInfo(mi, ci); *mode = vidmodeFromModeInfo(mi, ci);
XRRFreeCrtcInfo(ci); XRRFreeCrtcInfo(ci);
} }
XRRFreeScreenResources(sr); XRRFreeScreenResources(sr);
if (!mi)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to query video mode");
return GLFW_FALSE;
}
} }
else else
{ {
@ -519,6 +527,8 @@ void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
_glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen), _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
&mode->redBits, &mode->greenBits, &mode->blueBits); &mode->redBits, &mode->greenBits, &mode->blueBits);
} }
return GLFW_TRUE;
} }
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -602,15 +612,33 @@ void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None); _GLFW_REQUIRE_INIT_OR_RETURN(None);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
return None;
}
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
return monitor->x11.crtc; return monitor->x11.crtc;
} }
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None); _GLFW_REQUIRE_INIT_OR_RETURN(None);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
return None;
}
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
return monitor->x11.output; return monitor->x11.output;
} }

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 X11 - www.glfw.org // GLFW 3.5 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -905,6 +905,7 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconf
void _glfwDestroyWindowX11(_GLFWwindow* window); void _glfwDestroyWindowX11(_GLFWwindow* window);
void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title); void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images); void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value);
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos); void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos); void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos);
void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height); void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height);
@ -968,7 +969,7 @@ void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count); GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp); GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 X11 - www.glfw.org // GLFW 3.5 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@ -79,24 +79,25 @@ static GLFWbool waitForX11Event(double* timeout)
// //
static GLFWbool waitForAnyEvent(double* timeout) static GLFWbool waitForAnyEvent(double* timeout)
{ {
nfds_t count = 2; enum { XLIB_FD, PIPE_FD, INOTIFY_FD };
struct pollfd fds[3] = struct pollfd fds[] =
{ {
{ ConnectionNumber(_glfw.x11.display), POLLIN }, [XLIB_FD] = { ConnectionNumber(_glfw.x11.display), POLLIN },
{ _glfw.x11.emptyEventPipe[0], POLLIN } [PIPE_FD] = { _glfw.x11.emptyEventPipe[0], POLLIN },
[INOTIFY_FD] = { -1, POLLIN }
}; };
#if defined(GLFW_BUILD_LINUX_JOYSTICK) #if defined(GLFW_BUILD_LINUX_JOYSTICK)
if (_glfw.joysticksInitialized) if (_glfw.joysticksInitialized)
fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN }; fds[INOTIFY_FD].fd = _glfw.linjs.inotify;
#endif #endif
while (!XPending(_glfw.x11.display)) while (!XPending(_glfw.x11.display))
{ {
if (!_glfwPollPOSIX(fds, count, timeout)) if (!_glfwPollPOSIX(fds, sizeof(fds) / sizeof(fds[0]), timeout))
return GLFW_FALSE; return GLFW_FALSE;
for (int i = 1; i < count; i++) for (int i = 1; i < sizeof(fds) / sizeof(fds[0]); i++)
{ {
if (fds[i].revents & POLLIN) if (fds[i].revents & POLLIN)
return GLFW_TRUE; return GLFW_TRUE;
@ -1487,6 +1488,9 @@ static void processEvent(XEvent *event)
if (event->xconfigure.width != window->x11.width || if (event->xconfigure.width != window->x11.width ||
event->xconfigure.height != window->x11.height) event->xconfigure.height != window->x11.height)
{ {
window->x11.width = event->xconfigure.width;
window->x11.height = event->xconfigure.height;
_glfwInputFramebufferSize(window, _glfwInputFramebufferSize(window,
event->xconfigure.width, event->xconfigure.width,
event->xconfigure.height); event->xconfigure.height);
@ -1494,9 +1498,6 @@ static void processEvent(XEvent *event)
_glfwInputWindowSize(window, _glfwInputWindowSize(window,
event->xconfigure.width, event->xconfigure.width,
event->xconfigure.height); event->xconfigure.height);
window->x11.width = event->xconfigure.width;
window->x11.height = event->xconfigure.height;
} }
int xpos = event->xconfigure.x; int xpos = event->xconfigure.x;
@ -1524,9 +1525,10 @@ static void processEvent(XEvent *event)
if (xpos != window->x11.xpos || ypos != window->x11.ypos) if (xpos != window->x11.xpos || ypos != window->x11.ypos)
{ {
_glfwInputWindowPos(window, xpos, ypos);
window->x11.xpos = xpos; window->x11.xpos = xpos;
window->x11.ypos = ypos; window->x11.ypos = ypos;
_glfwInputWindowPos(window, xpos, ypos);
} }
return; return;
@ -2038,6 +2040,14 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window,
} }
} }
//Reset progress state as it gets saved between application runs
if(_glfw.dbus.connection)
{
//Window NULL is safe here because it won't get
//used inside the SetWindowTaskbarProgress function
_glfwSetWindowProgressIndicatorX11(NULL, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
}
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -2150,6 +2160,15 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);
} }
void _glfwSetWindowProgressIndicatorX11(_GLFWwindow* window, int progressState, double value)
{
(void)window;
const dbus_bool_t progressVisible = (progressState != GLFW_PROGRESS_INDICATOR_DISABLED);
_glfwUpdateTaskbarProgressDBusPOSIX(progressVisible, value);
}
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos) void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos)
{ {
Window dummy; Window dummy;
@ -2901,14 +2920,16 @@ const char* _glfwGetScancodeNameX11(int scancode)
if (!_glfw.x11.xkb.available) if (!_glfw.x11.xkb.available)
return NULL; return NULL;
if (scancode < 0 || scancode > 0xff || if (scancode < 0 || scancode > 0xff)
_glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL; return NULL;
} }
const int key = _glfw.x11.keycodes[scancode]; const int key = _glfw.x11.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
scancode, _glfw.x11.xkb.group, 0); scancode, _glfw.x11.xkb.group, 0);
if (keysym == NoSymbol) if (keysym == NoSymbol)
@ -3298,7 +3319,6 @@ GLFWAPI Display* glfwGetX11Display(void)
GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None); _GLFW_REQUIRE_INIT_OR_RETURN(None);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11) if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
@ -3307,11 +3327,16 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
return None; return None;
} }
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
return window->x11.handle; return window->x11.handle;
} }
GLFWAPI void glfwSetX11SelectionString(const char* string) GLFWAPI void glfwSetX11SelectionString(const char* string)
{ {
assert(string != NULL);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
if (_glfw.platform.platformID != GLFW_PLATFORM_X11) if (_glfw.platform.platformID != GLFW_PLATFORM_X11)

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 X11 - www.glfw.org // GLFW 3.5 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>

View File

@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.4 Linux - www.glfw.org // GLFW 3.5 Linux - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //

View File

@ -400,24 +400,34 @@ static void scroll_callback(GLFWwindow* window, double x, double y)
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{ {
Slot* slot = glfwGetWindowUserPointer(window); Slot* slot = glfwGetWindowUserPointer(window);
const char* name = glfwGetKeyName(key, scancode);
if (name) if (key == GLFW_KEY_UNKNOWN)
{ {
printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n", printf("%08x to %i at %0.3f: Key (%s) Scancode 0x%04x (with%s) was %s\n",
counter++, slot->number, glfwGetTime(), key, scancode, counter++, slot->number, glfwGetTime(),
get_key_name(key), get_key_name(key), scancode,
name, get_mods_name(mods),
get_mods_name(mods), get_action_name(action));
get_action_name(action));
} }
else else
{ {
printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n", const char* name = glfwGetKeyName(key, scancode);
counter++, slot->number, glfwGetTime(), key, scancode, if (name)
get_key_name(key), {
get_mods_name(mods), printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x Name %s (with%s) was %s\n",
get_action_name(action)); counter++, slot->number, glfwGetTime(),
key, get_key_name(key), scancode, name,
get_mods_name(mods),
get_action_name(action));
}
else
{
printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x (with%s) was %s\n",
counter++, slot->number, glfwGetTime(),
key, get_key_name(key), scancode,
get_mods_name(mods),
get_action_name(action));
}
} }
if (action != GLFW_PRESS) if (action != GLFW_PRESS)
@ -620,6 +630,7 @@ int main(int argc, char** argv)
glfwTerminate(); glfwTerminate();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetInputMode(slots[i].window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE);
glfwSetWindowUserPointer(slots[i].window, slots + i); glfwSetWindowUserPointer(slots[i].window, slots + i);

View File

@ -62,6 +62,7 @@ int main(int argc, char** argv)
char min_width_buffer[12] = "", min_height_buffer[12] = ""; char min_width_buffer[12] = "", min_height_buffer[12] = "";
char max_width_buffer[12] = "", max_height_buffer[12] = ""; char max_width_buffer[12] = "", max_height_buffer[12] = "";
int may_close = true; int may_close = true;
char window_title[64] = "";
if (!glfwInit()) if (!glfwInit())
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -71,12 +72,13 @@ int main(int argc, char** argv)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
GLFWwindow* window = glfwCreateWindow(600, 600, "Window Features", NULL, NULL); GLFWwindow* window = glfwCreateWindow(600, 700, "Window Features", NULL, NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetInputMode(window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE);
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress); gladLoadGL(glfwGetProcAddress);
@ -109,6 +111,8 @@ int main(int argc, char** argv)
nk_glfw3_font_stash_begin(&atlas); nk_glfw3_font_stash_begin(&atlas);
nk_glfw3_font_stash_end(); nk_glfw3_font_stash_end();
strncpy(window_title, glfwGetWindowTitle(window), sizeof(window_title));
while (!(may_close && glfwWindowShouldClose(window))) while (!(may_close && glfwWindowShouldClose(window)))
{ {
int width, height; int width, height;
@ -121,17 +125,20 @@ int main(int argc, char** argv)
nk_glfw3_new_frame(); nk_glfw3_new_frame();
if (nk_begin(nk, "main", area, 0)) if (nk_begin(nk, "main", area, 0))
{ {
nk_layout_row_dynamic(nk, 30, 5); nk_layout_row_dynamic(nk, 30, 4);
if (nk_button_label(nk, "Toggle Fullscreen")) if (glfwGetWindowMonitor(window))
{ {
if (glfwGetWindowMonitor(window)) if (nk_button_label(nk, "Make Windowed"))
{ {
glfwSetWindowMonitor(window, NULL, glfwSetWindowMonitor(window, NULL,
windowed_x, windowed_y, windowed_x, windowed_y,
windowed_width, windowed_height, 0); windowed_width, windowed_height, 0);
} }
else }
else
{
if (nk_button_label(nk, "Make Fullscreen"))
{ {
GLFWmonitor* monitor = glfwGetPrimaryMonitor(); GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor); const GLFWvidmode* mode = glfwGetVideoMode(monitor);
@ -149,7 +156,10 @@ int main(int argc, char** argv)
glfwIconifyWindow(window); glfwIconifyWindow(window);
if (nk_button_label(nk, "Restore")) if (nk_button_label(nk, "Restore"))
glfwRestoreWindow(window); glfwRestoreWindow(window);
if (nk_button_label(nk, "Hide (briefly)"))
nk_layout_row_dynamic(nk, 30, 2);
if (nk_button_label(nk, "Hide (for 3s)"))
{ {
glfwHideWindow(window); glfwHideWindow(window);
@ -159,6 +169,16 @@ int main(int argc, char** argv)
glfwShowWindow(window); glfwShowWindow(window);
} }
if (nk_button_label(nk, "Request Attention (after 3s)"))
{
glfwIconifyWindow(window);
const double time = glfwGetTime() + 3.0;
while (glfwGetTime() < time)
glfwWaitEventsTimeout(1.0);
glfwRequestWindowAttention(window);
}
nk_layout_row_dynamic(nk, 30, 1); nk_layout_row_dynamic(nk, 30, 1);
@ -177,6 +197,16 @@ int main(int argc, char** argv)
NK_EDIT_SIG_ENTER | NK_EDIT_SIG_ENTER |
NK_EDIT_GOTO_END_ON_ACTIVATE; NK_EDIT_GOTO_END_ON_ACTIVATE;
nk_layout_row_begin(nk, NK_DYNAMIC, 30, 2);
nk_layout_row_push(nk, 1.f / 3.f);
nk_label(nk, "Title", NK_TEXT_LEFT);
nk_layout_row_push(nk, 2.f / 3.f);
events = nk_edit_string_zero_terminated(nk, flags, window_title,
sizeof(window_title), NULL);
if (events & NK_EDIT_COMMITED)
glfwSetWindowTitle(window, window_title);
nk_layout_row_end(nk);
if (position_supported) if (position_supported)
{ {
int xpos, ypos; int xpos, ypos;
@ -211,7 +241,7 @@ int main(int argc, char** argv)
last_ypos = ypos; last_ypos = ypos;
} }
else else
nk_label(nk, "Position not supported", NK_TEXT_LEFT); nk_label(nk, "Platform does not support window position", NK_TEXT_LEFT);
nk_layout_row_dynamic(nk, 30, 3); nk_layout_row_dynamic(nk, 30, 3);
nk_label(nk, "Size", NK_TEXT_LEFT); nk_label(nk, "Size", NK_TEXT_LEFT);
@ -411,6 +441,29 @@ int main(int argc, char** argv)
nk_value_bool(nk, "Visible", glfwGetWindowAttrib(window, GLFW_VISIBLE)); nk_value_bool(nk, "Visible", glfwGetWindowAttrib(window, GLFW_VISIBLE));
nk_value_bool(nk, "Iconified", glfwGetWindowAttrib(window, GLFW_ICONIFIED)); nk_value_bool(nk, "Iconified", glfwGetWindowAttrib(window, GLFW_ICONIFIED));
nk_value_bool(nk, "Maximized", glfwGetWindowAttrib(window, GLFW_MAXIMIZED)); nk_value_bool(nk, "Maximized", glfwGetWindowAttrib(window, GLFW_MAXIMIZED));
nk_layout_row_dynamic(nk, 30, 1);
nk_label(nk, "Window Progress indicator", NK_TEXT_CENTERED);
nk_layout_row_dynamic(nk, 30, 5);
static int state = GLFW_PROGRESS_INDICATOR_DISABLED;
static float progress = 0;
if(nk_button_label(nk, "No progress"))
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_DISABLED, (double) progress);
if (nk_button_label(nk, "Indeterminate"))
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_INDETERMINATE, (double) progress);
if (nk_button_label(nk, "Normal"))
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_NORMAL, (double) progress);
if (nk_button_label(nk, "Error"))
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_ERROR, (double) progress);
if (nk_button_label(nk, "Paused"))
glfwSetWindowProgressIndicator(window, state = GLFW_PROGRESS_INDICATOR_PAUSED, (double) progress);
nk_label(nk, "Progress: ", NK_TEXT_ALIGN_LEFT);
if (nk_slider_float(nk, 0.0f, &progress, 1.0f, 0.05f))
glfwSetWindowProgressIndicator(window, state, (double) progress);
} }
nk_end(nk); nk_end(nk);