mirror of
https://github.com/glfw/glfw.git
synced 2025-06-08 00:34:56 +00:00
Merge branch 'glfw:master' into master
This commit is contained in:
commit
7a275dbec8
0
docs/CODEOWNERS → .github/CODEOWNERS
vendored
0
docs/CODEOWNERS → .github/CODEOWNERS
vendored
@ -19,11 +19,13 @@ video tutorials.
|
|||||||
- Nevyn Bengtsson
|
- Nevyn Bengtsson
|
||||||
- Niklas Bergström
|
- Niklas Bergström
|
||||||
- Denis Bernard
|
- Denis Bernard
|
||||||
|
- BiBi
|
||||||
- Doug Binks
|
- Doug Binks
|
||||||
- blanco
|
- blanco
|
||||||
- Waris Boonyasiriwat
|
- Waris Boonyasiriwat
|
||||||
- Kyle Brenneman
|
- Kyle Brenneman
|
||||||
- Rok Breulj
|
- Rok Breulj
|
||||||
|
- TheBrokenRail
|
||||||
- Kai Burjack
|
- Kai Burjack
|
||||||
- Martin Capitanio
|
- Martin Capitanio
|
||||||
- Nicolas Caramelli
|
- Nicolas Caramelli
|
||||||
@ -44,6 +46,7 @@ video tutorials.
|
|||||||
- Noel Cower
|
- Noel Cower
|
||||||
- CuriouserThing
|
- CuriouserThing
|
||||||
- Jason Daly
|
- Jason Daly
|
||||||
|
- danhambleton
|
||||||
- Jarrod Davis
|
- Jarrod Davis
|
||||||
- Olivier Delannoy
|
- Olivier Delannoy
|
||||||
- Paul R. Deppe
|
- Paul R. Deppe
|
||||||
@ -58,6 +61,7 @@ video tutorials.
|
|||||||
- Jan Ekström
|
- Jan Ekström
|
||||||
- Siavash Eliasi
|
- Siavash Eliasi
|
||||||
- Ahmad Fatoum
|
- Ahmad Fatoum
|
||||||
|
- Nikita Fediuchin
|
||||||
- Felipe Ferreira
|
- Felipe Ferreira
|
||||||
- Michael Fogleman
|
- Michael Fogleman
|
||||||
- Jason Francis
|
- Jason Francis
|
||||||
@ -78,10 +82,12 @@ video tutorials.
|
|||||||
- Jonathan Hale
|
- Jonathan Hale
|
||||||
- hdf89shfdfs
|
- hdf89shfdfs
|
||||||
- Sylvain Hellegouarch
|
- Sylvain Hellegouarch
|
||||||
|
- Björn Hempel
|
||||||
- Matthew Henry
|
- Matthew Henry
|
||||||
- heromyth
|
- heromyth
|
||||||
- Lucas Hinderberger
|
- Lucas Hinderberger
|
||||||
- Paul Holden
|
- Paul Holden
|
||||||
|
- Hajime Hoshi
|
||||||
- Warren Hu
|
- Warren Hu
|
||||||
- Charles Huber
|
- Charles Huber
|
||||||
- Brent Huisman
|
- Brent Huisman
|
||||||
@ -136,6 +142,7 @@ video tutorials.
|
|||||||
- Kenneth Miller
|
- Kenneth Miller
|
||||||
- Bruce Mitchener
|
- Bruce Mitchener
|
||||||
- Jack Moffitt
|
- Jack Moffitt
|
||||||
|
- Ravi Mohan
|
||||||
- Jeff Molofee
|
- Jeff Molofee
|
||||||
- Alexander Monakov
|
- Alexander Monakov
|
||||||
- Pierre Morel
|
- Pierre Morel
|
||||||
@ -143,10 +150,13 @@ video tutorials.
|
|||||||
- Pierre Moulon
|
- Pierre Moulon
|
||||||
- Martins Mozeiko
|
- Martins Mozeiko
|
||||||
- Pascal Muetschard
|
- Pascal Muetschard
|
||||||
|
- James Murphy
|
||||||
- Julian Møller
|
- Julian Møller
|
||||||
- ndogxj
|
- ndogxj
|
||||||
|
- F. Nedelec
|
||||||
- n3rdopolis
|
- n3rdopolis
|
||||||
- Kristian Nielsen
|
- Kristian Nielsen
|
||||||
|
- Joel Niemelä
|
||||||
- Kamil Nowakowski
|
- Kamil Nowakowski
|
||||||
- onox
|
- onox
|
||||||
- Denis Ovod
|
- Denis Ovod
|
||||||
@ -156,8 +166,10 @@ video tutorials.
|
|||||||
- Peoro
|
- Peoro
|
||||||
- Braden Pellett
|
- Braden Pellett
|
||||||
- Christopher Pelloux
|
- Christopher Pelloux
|
||||||
|
- Michael Pennington
|
||||||
- Arturo J. Pérez
|
- Arturo J. Pérez
|
||||||
- Vladimir Perminov
|
- Vladimir Perminov
|
||||||
|
- Olivier Perret
|
||||||
- Anthony Pesch
|
- Anthony Pesch
|
||||||
- Orson Peters
|
- Orson Peters
|
||||||
- Emmanuel Gil Peyrot
|
- Emmanuel Gil Peyrot
|
||||||
@ -171,10 +183,12 @@ video tutorials.
|
|||||||
- Pablo Prietz
|
- Pablo Prietz
|
||||||
- przemekmirek
|
- przemekmirek
|
||||||
- pthom
|
- pthom
|
||||||
|
- Martin Pulec
|
||||||
- Guillaume Racicot
|
- Guillaume Racicot
|
||||||
- Philip Rideout
|
- Philip Rideout
|
||||||
- Eddie Ringle
|
- Eddie Ringle
|
||||||
- Max Risuhin
|
- Max Risuhin
|
||||||
|
- Joe Roback
|
||||||
- Jorge Rodriguez
|
- Jorge Rodriguez
|
||||||
- Jari Ronkainen
|
- Jari Ronkainen
|
||||||
- Luca Rood
|
- Luca Rood
|
||||||
|
60
README.md
60
README.md
@ -139,13 +139,18 @@ information on what to include when reporting a bug.
|
|||||||
- Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
|
- Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
|
||||||
- Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
|
- Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
|
||||||
through the window (#1236,#1568)
|
through the window (#1236,#1568)
|
||||||
|
- Added `GLFW_CURSOR_CAPTURED` cursor mode to confine the cursor to the window
|
||||||
|
content area (#58)
|
||||||
- Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958)
|
- Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958)
|
||||||
- Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
|
- Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
|
||||||
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#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_*`
|
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
||||||
values to select ANGLE backend (#1380)
|
values to select ANGLE backend (#1380)
|
||||||
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
|
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
|
||||||
surface extension (#1793)
|
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_WIN32` CMake option for enabling Win32 support (#1958)
|
||||||
- Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa 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_BUILD_X11` CMake option for enabling X11 support (#1958)
|
||||||
@ -172,9 +177,13 @@ information on what to include when reporting a bug.
|
|||||||
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
|
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
|
||||||
incompatible controllers sharing hardware ID (#1763)
|
incompatible controllers sharing hardware ID (#1763)
|
||||||
- Bugfix: Native access functions for context handles did not check that the API matched
|
- 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)
|
||||||
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
||||||
to the window menu
|
to the window menu
|
||||||
- [Win32] Added a version info resource to the GLFW DLL
|
- [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
|
- [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are
|
||||||
opaque (#1512)
|
opaque (#1512)
|
||||||
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
|
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
|
||||||
@ -215,12 +224,15 @@ information on what to include when reporting a bug.
|
|||||||
- [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not
|
- [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not
|
||||||
match event scancode (#1993)
|
match event scancode (#1993)
|
||||||
- [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395)
|
- [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)
|
||||||
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
|
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
|
||||||
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
|
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
|
||||||
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
|
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
|
||||||
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
|
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
|
||||||
- [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency
|
- [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency
|
||||||
(#1786)
|
(#1786)
|
||||||
|
- [Cocoa] Disabled macOS fullscreen when `GLFW_RESIZABLE` is false
|
||||||
- [Cocoa] Removed dependency on the CoreVideo framework
|
- [Cocoa] Removed dependency on the CoreVideo framework
|
||||||
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
|
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
|
||||||
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
|
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
|
||||||
@ -246,6 +258,14 @@ information on what to include when reporting a bug.
|
|||||||
- [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980)
|
- [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980)
|
||||||
- [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003)
|
- [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003)
|
||||||
- [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791)
|
- [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)
|
||||||
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
- [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
|
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
||||||
(#1462,#1528)
|
(#1462,#1528)
|
||||||
@ -285,9 +305,13 @@ information on what to include when reporting a bug.
|
|||||||
(#379,#1281,#1285,#2033)
|
(#379,#1281,#1285,#2033)
|
||||||
- [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences
|
- [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: 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 dynamic loading of all Wayland libraries
|
- [Wayland] Added dynamic loading of all Wayland libraries
|
||||||
- [Wayland] Added support for key names via xkbcommon
|
- [Wayland] Added support for key names via xkbcommon
|
||||||
- [Wayland] Added support for file path drop events (#2040)
|
- [Wayland] Added support for file path drop events (#2040)
|
||||||
|
- [Wayland] Added support for more human-readable monitor names where available
|
||||||
- [Wayland] Removed support for `wl_shell` (#1443)
|
- [Wayland] Removed support for `wl_shell` (#1443)
|
||||||
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
||||||
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
||||||
@ -318,8 +342,44 @@ information on what to include when reporting a bug.
|
|||||||
- [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang
|
- [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang
|
||||||
- [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string
|
- [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string
|
||||||
- [Wayland] Bugfix: MIME type matching was not performed for 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)
|
||||||
- [POSIX] Removed use of deprecated function `gettimeofday`
|
- [POSIX] Removed use of deprecated function `gettimeofday`
|
||||||
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
||||||
|
- [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043)
|
||||||
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
|
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
|
||||||
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
|
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
|
||||||
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
||||||
|
2488
deps/glad/vulkan.h
vendored
2488
deps/glad/vulkan.h
vendored
File diff suppressed because it is too large
Load Diff
930
deps/stb_image_write.h
vendored
930
deps/stb_image_write.h
vendored
File diff suppressed because it is too large
Load Diff
@ -351,8 +351,8 @@ __Note:__ If you haven't already implemented the feature, check first if there
|
|||||||
already is an open issue for it and if it's already being developed in an
|
already is an open issue for it and if it's already being developed in an
|
||||||
[experimental branch](https://github.com/glfw/glfw/branches/all).
|
[experimental branch](https://github.com/glfw/glfw/branches/all).
|
||||||
|
|
||||||
__There is no preferred patch size__. A one character change is just as welcome
|
__There is no preferred patch size__. A one-character change is just as welcome
|
||||||
as one adding a thousand line one, if that is the appropriate size for the
|
as one adding a thousand lines, if that is the appropriate size for the
|
||||||
feature.
|
feature.
|
||||||
|
|
||||||
In addition to the code, a complete feature includes:
|
In addition to the code, a complete feature includes:
|
||||||
|
@ -57,7 +57,7 @@ macros that disable similar headers below it.
|
|||||||
|
|
||||||
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
|
||||||
@ref GLFW_INCLUDE_NONE macro will explicitly to prevent the GLFW header from
|
@ref GLFW_INCLUDE_NONE macro will explicitly prevent the GLFW header from
|
||||||
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.
|
||||||
|
|
||||||
|
@ -123,9 +123,21 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
The action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`. The key
|
The action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`. Events with
|
||||||
will be `GLFW_KEY_UNKNOWN` if GLFW lacks a key token for it, for example
|
`GLFW_PRESS` and `GLFW_RELEASE` actions are emitted for every key press. Most
|
||||||
_E-mail_ and _Play_ keys.
|
keys will also emit events with `GLFW_REPEAT` actions while a key is held down.
|
||||||
|
|
||||||
|
Key events with `GLFW_REPEAT` actions are intended for text input. They are
|
||||||
|
emitted at the rate set in the user's keyboard settings. At most one key is
|
||||||
|
repeated even if several keys are held down. `GLFW_REPEAT` actions should not
|
||||||
|
be relied on to know which keys are being held down or to drive animation.
|
||||||
|
Instead you should either save the state of relevant keys based on `GLFW_PRESS`
|
||||||
|
and `GLFW_RELEASE` actions, or call @ref glfwGetKey, which provides basic cached
|
||||||
|
key state.
|
||||||
|
|
||||||
|
The key will be one of the existing [key tokens](@ref keys), or
|
||||||
|
`GLFW_KEY_UNKNOWN` if GLFW lacks a token for it, for example _E-mail_ and _Play_
|
||||||
|
keys.
|
||||||
|
|
||||||
The scancode is unique for every key, regardless of whether it has a key token.
|
The scancode is unique for every key, regardless of whether it has a key token.
|
||||||
Scancodes are platform-specific but consistent over time, so keys will have
|
Scancodes are platform-specific but consistent over time, so keys will have
|
||||||
@ -300,6 +312,16 @@ glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
|||||||
|
|
||||||
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
|
||||||
|
window, set the cursor mode to `GLFW_CURSOR_CAPTURED`.
|
||||||
|
|
||||||
|
@code
|
||||||
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The cursor will behave normally inside the content area but will not be able to
|
||||||
|
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.
|
||||||
|
|
||||||
@ -307,6 +329,8 @@ cursor mode.
|
|||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
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
|
@subsection raw_mouse_motion Raw mouse motion
|
||||||
|
@ -43,6 +43,12 @@ to whatever window is behind it. This can also be changed after window
|
|||||||
creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
|
creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
@subsubsection features_34_angle_backend Support for ANGLE rendering backend selection
|
||||||
|
|
||||||
GLFW now provides the
|
GLFW now provides the
|
||||||
@ -52,6 +58,14 @@ requesting a specific rendering backend when using
|
|||||||
contexts.
|
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
|
@subsubsection features_34_init_allocator Support for custom memory allocator
|
||||||
|
|
||||||
GLFW now supports plugging a custom memory allocator at initialization with @ref
|
GLFW now supports plugging a custom memory allocator at initialization with @ref
|
||||||
@ -228,6 +242,7 @@ then GLFW will fail to initialize.
|
|||||||
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
|
||||||
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
|
||||||
- @ref GLFW_X11_XCB_VULKAN_SURFACE
|
- @ref GLFW_X11_XCB_VULKAN_SURFACE
|
||||||
|
- @ref GLFW_CURSOR_CAPTURED
|
||||||
|
|
||||||
|
|
||||||
@section news_archive Release notes for earlier versions
|
@section news_archive Release notes for earlier versions
|
||||||
|
@ -37,8 +37,8 @@ By default, GLFW will load the Vulkan loader dynamically at runtime via its stan
|
|||||||
`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other Unix-like systems and
|
`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other Unix-like systems and
|
||||||
`libvulkan.1.dylib` on macOS.
|
`libvulkan.1.dylib` on macOS.
|
||||||
|
|
||||||
@macos GLFW will also look up and search the executable subdirectory of your application
|
@macos GLFW will also look up and search the `Frameworks` subdirectory of your
|
||||||
bundle.
|
application bundle.
|
||||||
|
|
||||||
If your code is using a Vulkan loader with a different name or in a non-standard location
|
If your code is using a Vulkan loader with a different name or in a non-standard location
|
||||||
you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr` to @ref
|
you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr` to @ref
|
||||||
@ -188,6 +188,13 @@ check whether any extensions you wish to enable are already in the returned
|
|||||||
array, as it is an error to specify an extension more than once in the
|
array, as it is an error to specify an extension more than once in the
|
||||||
`VkInstanceCreateInfo` struct.
|
`VkInstanceCreateInfo` struct.
|
||||||
|
|
||||||
|
@macos MoltenVK is (as of July 2022) not yet a fully conformant implementation
|
||||||
|
of Vulkan. As of Vulkan SDK 1.3.216.0, this means you must also enable the
|
||||||
|
`VK_KHR_portability_enumeration` instance extension and set the
|
||||||
|
`VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` bit in the instance creation
|
||||||
|
info flags for MoltenVK to show up in the list of physical devices. For more
|
||||||
|
information, see the Vulkan and MoltenVK documentation.
|
||||||
|
|
||||||
|
|
||||||
@section vulkan_present Querying for Vulkan presentation support
|
@section vulkan_present Querying for Vulkan presentation support
|
||||||
|
|
||||||
|
@ -492,6 +492,13 @@ __GLFW_X11_CLASS_NAME__ and __GLFW_X11_INSTANCE_NAME__ specifies the desired
|
|||||||
ASCII encoded class and instance parts of the ICCCM `WM_CLASS` window property.
|
ASCII encoded class and instance parts of the ICCCM `WM_CLASS` window property.
|
||||||
These are set with @ref glfwWindowHintString.
|
These are set with @ref glfwWindowHintString.
|
||||||
|
|
||||||
|
@subsubsection window_hints_wayland Wayland specific window hints
|
||||||
|
|
||||||
|
@anchor GLFW_WAYLAND_APP_ID_hint
|
||||||
|
__GLFW_WAYLAND_APP_ID__ specifies the Wayland app_id for a window, used
|
||||||
|
by window managers to identify types of windows. This is set with
|
||||||
|
@ref glfwWindowHintString.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection window_hints_values Supported and default values
|
@subsubsection window_hints_values Supported and default values
|
||||||
|
|
||||||
@ -540,6 +547,7 @@ GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded fr
|
|||||||
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name
|
GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name
|
||||||
GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded `WM_CLASS` instance name
|
GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded `WM_CLASS` instance name
|
||||||
|
GLFW_WAYLAND_APP_ID | `""` | An ASCII encoded Wayland `app_id` name
|
||||||
|
|
||||||
|
|
||||||
@section window_events Window event processing
|
@section window_events Window event processing
|
||||||
|
@ -50,11 +50,6 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
|||||||
C_STANDARD 99
|
C_STANDARD 99
|
||||||
FOLDER "GLFW3/Examples")
|
FOLDER "GLFW3/Examples")
|
||||||
|
|
||||||
if (GLFW_USE_OSMESA)
|
|
||||||
find_package(OSMesa REQUIRED)
|
|
||||||
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Tell MSVC to use main instead of WinMain
|
# Tell MSVC to use main instead of WinMain
|
||||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
|
@ -28,11 +28,6 @@
|
|||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#if USE_NATIVE_OSMESA
|
|
||||||
#define GLFW_EXPOSE_NATIVE_OSMESA
|
|
||||||
#include <GLFW/glfw3native.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "linmath.h"
|
#include "linmath.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -151,12 +146,8 @@ int main(void)
|
|||||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
#if USE_NATIVE_OSMESA
|
|
||||||
glfwGetOSMesaColorBuffer(window, &width, &height, NULL, (void**) &buffer);
|
|
||||||
#else
|
|
||||||
buffer = calloc(4, width * height);
|
buffer = calloc(4, width * height);
|
||||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Write image Y-flipped because OpenGL
|
// Write image Y-flipped because OpenGL
|
||||||
stbi_write_png("offscreen.png",
|
stbi_write_png("offscreen.png",
|
||||||
@ -164,11 +155,7 @@ int main(void)
|
|||||||
buffer + (width * 4 * (height - 1)),
|
buffer + (width * 4 * (height - 1)),
|
||||||
-width * 4);
|
-width * 4);
|
||||||
|
|
||||||
#if USE_NATIVE_OSMESA
|
|
||||||
// Here is where there's nothing
|
|
||||||
#else
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
#endif
|
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
|
|
||||||
|
@ -262,13 +262,12 @@ extern "C" {
|
|||||||
/* We are building GLFW as a Win32 DLL */
|
/* We are building GLFW as a Win32 DLL */
|
||||||
#define GLFWAPI __declspec(dllexport)
|
#define GLFWAPI __declspec(dllexport)
|
||||||
#elif defined(_WIN32) && defined(GLFW_DLL)
|
#elif defined(_WIN32) && defined(GLFW_DLL)
|
||||||
/* We are calling GLFW as a Win32 DLL */
|
/* We are calling a GLFW Win32 DLL */
|
||||||
#define GLFWAPI __declspec(dllimport)
|
#define GLFWAPI __declspec(dllimport)
|
||||||
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
|
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
|
||||||
/* We are building GLFW as a shared / dynamic library */
|
/* We are building GLFW as a Unix shared library */
|
||||||
#define GLFWAPI __attribute__((visibility("default")))
|
#define GLFWAPI __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
/* We are building or calling GLFW as a static library */
|
|
||||||
#define GLFWAPI
|
#define GLFWAPI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1106,6 +1105,12 @@ 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 Wayland specific
|
||||||
|
* [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
|
||||||
|
*
|
||||||
|
* Allows specification of the Wayland app_id.
|
||||||
|
*/
|
||||||
|
#define GLFW_WAYLAND_APP_ID 0x00026001
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
#define GLFW_NO_API 0
|
#define GLFW_NO_API 0
|
||||||
@ -1129,6 +1134,7 @@ extern "C" {
|
|||||||
#define GLFW_CURSOR_NORMAL 0x00034001
|
#define GLFW_CURSOR_NORMAL 0x00034001
|
||||||
#define GLFW_CURSOR_HIDDEN 0x00034002
|
#define GLFW_CURSOR_HIDDEN 0x00034002
|
||||||
#define GLFW_CURSOR_DISABLED 0x00034003
|
#define GLFW_CURSOR_DISABLED 0x00034003
|
||||||
|
#define GLFW_CURSOR_CAPTURED 0x00034004
|
||||||
|
|
||||||
#define GLFW_ANY_RELEASE_BEHAVIOR 0
|
#define GLFW_ANY_RELEASE_BEHAVIOR 0
|
||||||
#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
|
#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
|
||||||
@ -3672,8 +3678,9 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
|
|||||||
* previously restored. If the window is already iconified, this function does
|
* previously restored. If the window is already iconified, this function does
|
||||||
* nothing.
|
* nothing.
|
||||||
*
|
*
|
||||||
* If the specified window is a full screen window, the original monitor
|
* If the specified window is a full screen window, GLFW restores the original
|
||||||
* resolution is restored until the window is restored.
|
* video mode of the monitor. The window's desired video mode is set again
|
||||||
|
* when the window is restored.
|
||||||
*
|
*
|
||||||
* @param[in] window The window to iconify.
|
* @param[in] window The window to iconify.
|
||||||
*
|
*
|
||||||
@ -3703,8 +3710,8 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
|
|||||||
* (minimized) or maximized. If the window is already restored, this function
|
* (minimized) or maximized. If the window is already restored, this function
|
||||||
* does nothing.
|
* does nothing.
|
||||||
*
|
*
|
||||||
* If the specified window is a full screen window, the resolution chosen for
|
* If the specified window is an iconified full screen window, its desired
|
||||||
* the window is restored on the selected monitor.
|
* video mode is set again for its monitor when the window is restored.
|
||||||
*
|
*
|
||||||
* @param[in] window The window to restore.
|
* @param[in] window The window to restore.
|
||||||
*
|
*
|
||||||
@ -3972,6 +3979,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int
|
|||||||
* errors. However, this function should not fail as long as it is passed
|
* errors. However, this function should not fail as long as it is passed
|
||||||
* valid arguments and the library has been [initialized](@ref intro_init).
|
* valid arguments and the library has been [initialized](@ref intro_init).
|
||||||
*
|
*
|
||||||
|
* @remark @wayland The Wayland protocol provides no way to check whether a
|
||||||
|
* window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`.
|
||||||
|
*
|
||||||
* @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
|
||||||
@ -4557,6 +4567,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
|||||||
* - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
|
* - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
|
||||||
* and unlimited cursor movement. This is useful for implementing for
|
* and unlimited cursor movement. This is useful for implementing for
|
||||||
* example 3D camera controls.
|
* example 3D camera controls.
|
||||||
|
* - `GLFW_CURSOR_CAPTURED` makes the cursor visible and confines it to the
|
||||||
|
* content area of the window.
|
||||||
*
|
*
|
||||||
* If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
|
* If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
|
||||||
* enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
|
* enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
|
||||||
@ -4731,8 +4743,7 @@ GLFWAPI int glfwGetKeyScancode(int key);
|
|||||||
*
|
*
|
||||||
* This function returns the last state reported for the specified key to the
|
* This function returns the last state reported for the specified key to the
|
||||||
* specified window. The returned state is one of `GLFW_PRESS` or
|
* specified window. The returned state is one of `GLFW_PRESS` or
|
||||||
* `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
|
* `GLFW_RELEASE`. The action `GLFW_REPEAT` is only reported to the key callback.
|
||||||
* the key callback.
|
|
||||||
*
|
*
|
||||||
* If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
|
* If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
|
||||||
* `GLFW_PRESS` the first time you call it for a key that was pressed, even if
|
* `GLFW_PRESS` the first time you call it for a key that was pressed, even if
|
||||||
@ -6384,6 +6395,7 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
|
|||||||
*/
|
*/
|
||||||
#ifndef GLAPIENTRY
|
#ifndef GLAPIENTRY
|
||||||
#define GLAPIENTRY APIENTRY
|
#define GLAPIENTRY APIENTRY
|
||||||
|
#define GLFW_GLAPIENTRY_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
|
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
|
||||||
|
@ -74,6 +74,16 @@ extern "C" {
|
|||||||
* and which platform-specific headers to include. It is then up your (by
|
* and which platform-specific headers to include. It is then up your (by
|
||||||
* definition platform-specific) code to handle which of these should be
|
* definition platform-specific) code to handle which of these should be
|
||||||
* defined.
|
* defined.
|
||||||
|
*
|
||||||
|
* If you do not want the platform-specific headers to be included, define
|
||||||
|
* `GLFW_NATIVE_INCLUDE_NONE` before including the @ref glfw3native.h header.
|
||||||
|
*
|
||||||
|
* @code
|
||||||
|
* #define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
|
* #define GLFW_EXPOSE_NATIVE_WGL
|
||||||
|
* #define GLFW_NATIVE_INCLUDE_NONE
|
||||||
|
* #include <GLFW/glfw3native.h>
|
||||||
|
* @endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -81,55 +91,65 @@ extern "C" {
|
|||||||
* System headers and types
|
* System headers and types
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
#if !defined(GLFW_NATIVE_INCLUDE_NONE)
|
||||||
/* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
|
||||||
* example to allow applications to correctly declare a GL_KHR_debug callback)
|
|
||||||
* but windows.h assumes no one will define APIENTRY before it does
|
|
||||||
*/
|
|
||||||
#if defined(GLFW_APIENTRY_DEFINED)
|
|
||||||
#undef APIENTRY
|
|
||||||
#undef GLFW_APIENTRY_DEFINED
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
|
|
||||||
#if defined(__OBJC__)
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#else
|
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
|
||||||
typedef void* id;
|
|
||||||
#endif
|
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/extensions/Xrandr.h>
|
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
|
||||||
#include <wayland-client.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
/* WGL is declared by windows.h */
|
/* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||||
#endif
|
* example to allow applications to correctly declare a GL_KHR_debug callback)
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
* but windows.h assumes no one will define APIENTRY before it does
|
||||||
/* NSGL is declared by Cocoa.h */
|
*/
|
||||||
#endif
|
#if defined(GLFW_APIENTRY_DEFINED)
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
#undef APIENTRY
|
||||||
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
#undef GLFW_APIENTRY_DEFINED
|
||||||
* default it also acts as an OpenGL header
|
#endif
|
||||||
* However, glx.h will include gl.h, which will define it unconditionally
|
#include <windows.h>
|
||||||
*/
|
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
#undef GLAPIENTRY
|
#if defined(__OBJC__)
|
||||||
#include <GL/glx.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#endif
|
#else
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#include <EGL/egl.h>
|
#include <objc/objc.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||||
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
#include <X11/Xlib.h>
|
||||||
* default it also acts as an OpenGL header
|
#include <X11/extensions/Xrandr.h>
|
||||||
* However, osmesa.h will include gl.h, which will define it unconditionally
|
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
||||||
*/
|
#include <wayland-client.h>
|
||||||
#undef GLAPIENTRY
|
#endif
|
||||||
#include <GL/osmesa.h>
|
|
||||||
#endif
|
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
|
/* WGL is declared by windows.h */
|
||||||
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
|
/* NSGL is declared by Cocoa.h */
|
||||||
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||||
|
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
||||||
|
* default it also acts as an OpenGL header
|
||||||
|
* However, glx.h will include gl.h, which will define it unconditionally
|
||||||
|
*/
|
||||||
|
#if defined(GLFW_GLAPIENTRY_DEFINED)
|
||||||
|
#undef GLAPIENTRY
|
||||||
|
#undef GLFW_GLAPIENTRY_DEFINED
|
||||||
|
#endif
|
||||||
|
#include <GL/glx.h>
|
||||||
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||||
|
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
||||||
|
* default it also acts as an OpenGL header
|
||||||
|
* However, osmesa.h will include gl.h, which will define it unconditionally
|
||||||
|
*/
|
||||||
|
#if defined(GLFW_GLAPIENTRY_DEFINED)
|
||||||
|
#undef GLAPIENTRY
|
||||||
|
#undef GLFW_GLAPIENTRY_DEFINED
|
||||||
|
#endif
|
||||||
|
#include <GL/osmesa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*GLFW_NATIVE_INCLUDE_NONE*/
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@ -486,6 +506,9 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
|
|||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
*
|
*
|
||||||
|
* @remark Because EGL is initialized on demand, this function will return
|
||||||
|
* `EGL_NO_DISPLAY` until the first context has been created via EGL.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
|
@ -460,18 +460,26 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
|||||||
if (!bundle)
|
if (!bundle)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
CFURLRef url =
|
CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle);
|
||||||
CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib"));
|
if (!frameworksUrl)
|
||||||
if (!url)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent(
|
||||||
|
kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false);
|
||||||
|
if (!loaderUrl)
|
||||||
|
{
|
||||||
|
CFRelease(frameworksUrl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
void* handle = NULL;
|
void* handle = NULL;
|
||||||
|
|
||||||
if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
|
if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1))
|
||||||
handle = _glfwPlatformLoadModule(path);
|
handle = _glfwPlatformLoadModule(path);
|
||||||
|
|
||||||
CFRelease(url);
|
CFRelease(loaderUrl);
|
||||||
|
CFRelease(frameworksUrl);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,6 +684,8 @@ void _glfwTerminateCocoa(void)
|
|||||||
_glfw_free(_glfw.ns.clipboardString);
|
_glfw_free(_glfw.ns.clipboardString);
|
||||||
|
|
||||||
_glfwTerminateNSGL();
|
_glfwTerminateNSGL();
|
||||||
|
_glfwTerminateEGL();
|
||||||
|
_glfwTerminateOSMesa();
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ typedef struct _GLFWjoystickNS
|
|||||||
|
|
||||||
GLFWbool _glfwInitJoysticksCocoa(void);
|
GLFWbool _glfwInitJoysticksCocoa(void);
|
||||||
void _glfwTerminateJoysticksCocoa(void);
|
void _glfwTerminateJoysticksCocoa(void);
|
||||||
int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode);
|
GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode);
|
||||||
const char* _glfwGetMappingNameCocoa(void);
|
const char* _glfwGetMappingNameCocoa(void);
|
||||||
void _glfwUpdateGamepadGUIDCocoa(char* guid);
|
void _glfwUpdateGamepadGUIDCocoa(char* guid);
|
||||||
|
|
||||||
|
@ -96,8 +96,7 @@ static CFComparisonResult compareElements(const void* fp,
|
|||||||
//
|
//
|
||||||
static void closeJoystick(_GLFWjoystick* js)
|
static void closeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
if (!js->present)
|
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||||
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
|
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
|
||||||
@ -112,7 +111,6 @@ static void closeJoystick(_GLFWjoystick* js)
|
|||||||
CFRelease(js->ns.hats);
|
CFRelease(js->ns.hats);
|
||||||
|
|
||||||
_glfwFreeJoystick(js);
|
_glfwFreeJoystick(js);
|
||||||
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback for user-initiated joystick addition
|
// Callback for user-initiated joystick addition
|
||||||
@ -289,9 +287,9 @@ static void removeCallback(void* context,
|
|||||||
{
|
{
|
||||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
if (_glfw.joysticks[jid].ns.device == device)
|
if (_glfw.joysticks[jid].connected && _glfw.joysticks[jid].ns.device == device)
|
||||||
{
|
{
|
||||||
closeJoystick(_glfw.joysticks + jid);
|
closeJoystick(&_glfw.joysticks[jid]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -382,7 +380,10 @@ GLFWbool _glfwInitJoysticksCocoa(void)
|
|||||||
void _glfwTerminateJoysticksCocoa(void)
|
void _glfwTerminateJoysticksCocoa(void)
|
||||||
{
|
{
|
||||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
closeJoystick(_glfw.joysticks + jid);
|
{
|
||||||
|
if (_glfw.joysticks[jid].connected)
|
||||||
|
closeJoystick(&_glfw.joysticks[jid]);
|
||||||
|
}
|
||||||
|
|
||||||
if (_glfw.ns.hidManager)
|
if (_glfw.ns.hidManager)
|
||||||
{
|
{
|
||||||
@ -392,7 +393,7 @@ void _glfwTerminateJoysticksCocoa(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
if (mode & _GLFW_POLL_AXES)
|
if (mode & _GLFW_POLL_AXES)
|
||||||
{
|
{
|
||||||
@ -455,7 +456,7 @@ int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return js->present;
|
return js->connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwGetMappingNameCocoa(void)
|
const char* _glfwGetMappingNameCocoa(void)
|
||||||
|
@ -214,7 +214,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform);
|
|||||||
int _glfwInitCocoa(void);
|
int _glfwInitCocoa(void);
|
||||||
void _glfwTerminateCocoa(void);
|
void _glfwTerminateCocoa(void);
|
||||||
|
|
||||||
int _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
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);
|
||||||
@ -235,12 +235,12 @@ void _glfwHideWindowCocoa(_GLFWwindow* window);
|
|||||||
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowCocoa(_GLFWwindow* window);
|
void _glfwFocusWindowCocoa(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
int _glfwWindowFocusedCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window);
|
||||||
int _glfwWindowIconifiedCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window);
|
||||||
int _glfwWindowVisibleCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window);
|
||||||
int _glfwWindowMaximizedCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow* window);
|
||||||
int _glfwWindowHoveredCocoa(_GLFWwindow* window);
|
GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window);
|
||||||
int _glfwFramebufferTransparentCocoa(_GLFWwindow* window);
|
GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window);
|
||||||
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||||
@ -261,8 +261,8 @@ void _glfwSetCursorPosCocoa(_GLFWwindow* window, double xpos, double ypos);
|
|||||||
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode);
|
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode);
|
||||||
const char* _glfwGetScancodeNameCocoa(int scancode);
|
const char* _glfwGetScancodeNameCocoa(int scancode);
|
||||||
int _glfwGetKeyScancodeCocoa(int key);
|
int _glfwGetKeyScancodeCocoa(int key);
|
||||||
int _glfwCreateCursorCocoa(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
GLFWbool _glfwCreateCursorCocoa(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape);
|
GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape);
|
||||||
void _glfwDestroyCursorCocoa(_GLFWcursor* cursor);
|
void _glfwDestroyCursorCocoa(_GLFWcursor* cursor);
|
||||||
void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor);
|
void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
void _glfwSetClipboardStringCocoa(const char* string);
|
void _glfwSetClipboardStringCocoa(const char* string);
|
||||||
@ -273,7 +273,7 @@ EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void);
|
|||||||
EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window);
|
EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions);
|
void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions);
|
||||||
int _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
|
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
|
||||||
|
@ -31,25 +31,9 @@
|
|||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// Returns the style mask corresponding to the window settings
|
// 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
|
||||||
static NSUInteger getStyleMask(_GLFWwindow* window)
|
#define NSWindowCollectionBehaviorFullScreenNone (1 << 9)
|
||||||
{
|
|
||||||
NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;
|
|
||||||
|
|
||||||
if (window->monitor || !window->decorated)
|
|
||||||
styleMask |= NSWindowStyleMaskBorderless;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
styleMask |= NSWindowStyleMaskTitled |
|
|
||||||
NSWindowStyleMaskClosable;
|
|
||||||
|
|
||||||
if (window->resizable)
|
|
||||||
styleMask |= NSWindowStyleMaskResizable;
|
|
||||||
}
|
|
||||||
|
|
||||||
return styleMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns whether the cursor is in the content area of the specified window
|
// Returns whether the cursor is in the content area of the specified window
|
||||||
//
|
//
|
||||||
@ -809,9 +793,21 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
|
contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
|
||||||
|
|
||||||
|
NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;
|
||||||
|
|
||||||
|
if (window->monitor || !window->decorated)
|
||||||
|
styleMask |= NSWindowStyleMaskBorderless;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
|
||||||
|
|
||||||
|
if (window->resizable)
|
||||||
|
styleMask |= NSWindowStyleMaskResizable;
|
||||||
|
}
|
||||||
|
|
||||||
window->ns.object = [[GLFWWindow alloc]
|
window->ns.object = [[GLFWWindow alloc]
|
||||||
initWithContentRect:contentRect
|
initWithContentRect:contentRect
|
||||||
styleMask:getStyleMask(window)
|
styleMask:styleMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:NO];
|
defer:NO];
|
||||||
|
|
||||||
@ -837,6 +833,12 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
NSWindowCollectionBehaviorManaged;
|
NSWindowCollectionBehaviorManaged;
|
||||||
[window->ns.object setCollectionBehavior:behavior];
|
[window->ns.object setCollectionBehavior:behavior];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const NSWindowCollectionBehavior behavior =
|
||||||
|
NSWindowCollectionBehaviorFullScreenNone;
|
||||||
|
[window->ns.object setCollectionBehavior:behavior];
|
||||||
|
}
|
||||||
|
|
||||||
if (wndconfig->floating)
|
if (wndconfig->floating)
|
||||||
[window->ns.object setLevel:NSFloatingWindowLevel];
|
[window->ns.object setLevel:NSFloatingWindowLevel];
|
||||||
@ -893,10 +895,10 @@ float _glfwTransformYCocoa(float y)
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwCreateWindowCocoa(_GLFWwindow* window,
|
GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -931,13 +933,31 @@ int _glfwCreateWindowCocoa(_GLFWwindow* window,
|
|||||||
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughCocoa(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
_glfwShowWindowCocoa(window);
|
_glfwShowWindowCocoa(window);
|
||||||
_glfwFocusWindowCocoa(window);
|
_glfwFocusWindowCocoa(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
|
||||||
|
if (wndconfig->centerCursor)
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->visible)
|
||||||
|
{
|
||||||
|
_glfwShowWindowCocoa(window);
|
||||||
|
if (wndconfig->focused)
|
||||||
|
_glfwFocusWindowCocoa(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -1217,9 +1237,10 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
const NSRect contentRect =
|
const NSRect contentRect =
|
||||||
NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height);
|
NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height);
|
||||||
|
const NSUInteger styleMask = [window->ns.object styleMask];
|
||||||
const NSRect frameRect =
|
const NSRect frameRect =
|
||||||
[window->ns.object frameRectForContentRect:contentRect
|
[window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:getStyleMask(window)];
|
styleMask:styleMask];
|
||||||
|
|
||||||
[window->ns.object setFrame:frameRect display:YES];
|
[window->ns.object setFrame:frameRect display:YES];
|
||||||
}
|
}
|
||||||
@ -1236,7 +1257,27 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
|||||||
// TODO: Solve this in a less terrible way
|
// TODO: Solve this in a less terrible way
|
||||||
_glfwPollEventsCocoa();
|
_glfwPollEventsCocoa();
|
||||||
|
|
||||||
const NSUInteger styleMask = getStyleMask(window);
|
NSUInteger styleMask = [window->ns.object styleMask];
|
||||||
|
|
||||||
|
if (window->monitor)
|
||||||
|
{
|
||||||
|
styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
|
||||||
|
styleMask |= NSWindowStyleMaskBorderless;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (window->decorated)
|
||||||
|
{
|
||||||
|
styleMask &= ~NSWindowStyleMaskBorderless;
|
||||||
|
styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->resizable)
|
||||||
|
styleMask |= NSWindowStyleMaskResizable;
|
||||||
|
else
|
||||||
|
styleMask &= ~NSWindowStyleMaskResizable;
|
||||||
|
}
|
||||||
|
|
||||||
[window->ns.object setStyleMask:styleMask];
|
[window->ns.object setStyleMask:styleMask];
|
||||||
// HACK: Changing the style mask can cause the first responder to be cleared
|
// HACK: Changing the style mask can cause the first responder to be cleared
|
||||||
[window->ns.object makeFirstResponder:window->ns.view];
|
[window->ns.object makeFirstResponder:window->ns.view];
|
||||||
@ -1282,6 +1323,20 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
[window->ns.object setLevel:NSNormalWindowLevel];
|
[window->ns.object setLevel:NSNormalWindowLevel];
|
||||||
|
|
||||||
|
if (window->resizable)
|
||||||
|
{
|
||||||
|
const NSWindowCollectionBehavior behavior =
|
||||||
|
NSWindowCollectionBehaviorFullScreenPrimary |
|
||||||
|
NSWindowCollectionBehaviorManaged;
|
||||||
|
[window->ns.object setCollectionBehavior:behavior];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const NSWindowCollectionBehavior behavior =
|
||||||
|
NSWindowCollectionBehaviorFullScreenNone;
|
||||||
|
[window->ns.object setCollectionBehavior:behavior];
|
||||||
|
}
|
||||||
|
|
||||||
[window->ns.object setHasShadow:YES];
|
[window->ns.object setHasShadow:YES];
|
||||||
// HACK: Clearing NSWindowStyleMaskTitled resets and disables the window
|
// HACK: Clearing NSWindowStyleMaskTitled resets and disables the window
|
||||||
// title property but the miniwindow title property is unaffected
|
// title property but the miniwindow title property is unaffected
|
||||||
@ -1291,35 +1346,40 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowFocusedCocoa(_GLFWwindow* window)
|
GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isKeyWindow];
|
return [window->ns.object isKeyWindow];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowIconifiedCocoa(_GLFWwindow* window)
|
GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isMiniaturized];
|
return [window->ns.object isMiniaturized];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowVisibleCocoa(_GLFWwindow* window)
|
GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isVisible];
|
return [window->ns.object isVisible];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowMaximizedCocoa(_GLFWwindow* window)
|
GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isZoomed];
|
|
||||||
|
if (window->resizable)
|
||||||
|
return [window->ns.object isZoomed];
|
||||||
|
else
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowHoveredCocoa(_GLFWwindow* window)
|
GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1337,7 +1397,7 @@ int _glfwWindowHoveredCocoa(_GLFWwindow* window)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwFramebufferTransparentCocoa(_GLFWwindow* window)
|
GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
|
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
|
||||||
@ -1347,15 +1407,46 @@ int _glfwFramebufferTransparentCocoa(_GLFWwindow* window)
|
|||||||
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object setStyleMask:getStyleMask(window)];
|
|
||||||
|
const NSUInteger styleMask = [window->ns.object styleMask];
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
[window->ns.object setStyleMask:(styleMask | NSWindowStyleMaskResizable)];
|
||||||
|
const NSWindowCollectionBehavior behavior =
|
||||||
|
NSWindowCollectionBehaviorFullScreenPrimary |
|
||||||
|
NSWindowCollectionBehaviorManaged;
|
||||||
|
[window->ns.object setCollectionBehavior:behavior];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[window->ns.object setStyleMask:(styleMask & ~NSWindowStyleMaskResizable)];
|
||||||
|
const NSWindowCollectionBehavior behavior =
|
||||||
|
NSWindowCollectionBehaviorFullScreenNone;
|
||||||
|
[window->ns.object setCollectionBehavior:behavior];
|
||||||
|
}
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object setStyleMask:getStyleMask(window)];
|
|
||||||
|
NSUInteger styleMask = [window->ns.object styleMask];
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
styleMask |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
|
||||||
|
styleMask &= ~NSWindowStyleMaskBorderless;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
styleMask |= NSWindowStyleMaskBorderless;
|
||||||
|
styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
|
||||||
|
}
|
||||||
|
|
||||||
|
[window->ns.object setStyleMask:styleMask];
|
||||||
[window->ns.object makeFirstResponder:window->ns.view];
|
[window->ns.object makeFirstResponder:window->ns.view];
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1528,8 +1619,16 @@ void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y)
|
|||||||
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode)
|
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
if (mode == GLFW_CURSOR_CAPTURED)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
|
||||||
|
"Cocoa: Captured cursor mode not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
if (_glfwWindowFocusedCocoa(window))
|
if (_glfwWindowFocusedCocoa(window))
|
||||||
updateCursorMode(window);
|
updateCursorMode(window);
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1587,9 +1686,9 @@ int _glfwGetKeyScancodeCocoa(int key)
|
|||||||
return _glfw.ns.scancodes[key];
|
return _glfw.ns.scancodes[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateCursorCocoa(_GLFWcursor* cursor,
|
GLFWbool _glfwCreateCursorCocoa(_GLFWcursor* cursor,
|
||||||
const GLFWimage* image,
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1631,7 +1730,7 @@ int _glfwCreateCursorCocoa(_GLFWcursor* cursor,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape)
|
GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1814,9 +1913,9 @@ void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance,
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance,
|
||||||
VkPhysicalDevice device,
|
VkPhysicalDevice device,
|
||||||
uint32_t queuefamily)
|
uint32_t queuefamily)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -609,10 +609,12 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
|
|||||||
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
_GLFWwindow* previous;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
|
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||||
|
|
||||||
if (window && window->context.client == GLFW_NO_API)
|
if (window && window->context.client == GLFW_NO_API)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
|
||||||
|
105
src/input.c
105
src/input.c
@ -44,6 +44,13 @@
|
|||||||
#define _GLFW_JOYSTICK_BUTTON 2
|
#define _GLFW_JOYSTICK_BUTTON 2
|
||||||
#define _GLFW_JOYSTICK_HATBIT 3
|
#define _GLFW_JOYSTICK_HATBIT 3
|
||||||
|
|
||||||
|
#define GLFW_MOD_MASK (GLFW_MOD_SHIFT | \
|
||||||
|
GLFW_MOD_CONTROL | \
|
||||||
|
GLFW_MOD_ALT | \
|
||||||
|
GLFW_MOD_SUPER | \
|
||||||
|
GLFW_MOD_CAPS_LOCK | \
|
||||||
|
GLFW_MOD_NUM_LOCK)
|
||||||
|
|
||||||
// Initializes the platform joystick API if it has not been already
|
// Initializes the platform joystick API if it has not been already
|
||||||
//
|
//
|
||||||
static GLFWbool initJoysticks(void)
|
static GLFWbool initJoysticks(void)
|
||||||
@ -266,6 +273,12 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
|||||||
//
|
//
|
||||||
void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
|
void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(key >= 0 || key == GLFW_KEY_UNKNOWN);
|
||||||
|
assert(key <= GLFW_KEY_LAST);
|
||||||
|
assert(action == GLFW_PRESS || action == GLFW_RELEASE);
|
||||||
|
assert(mods == (mods & GLFW_MOD_MASK));
|
||||||
|
|
||||||
if (key >= 0 && key <= GLFW_KEY_LAST)
|
if (key >= 0 && key <= GLFW_KEY_LAST)
|
||||||
{
|
{
|
||||||
GLFWbool repeated = GLFW_FALSE;
|
GLFWbool repeated = GLFW_FALSE;
|
||||||
@ -297,6 +310,10 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
|||||||
//
|
//
|
||||||
void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool plain)
|
void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool plain)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(mods == (mods & GLFW_MOD_MASK));
|
||||||
|
assert(plain == GLFW_TRUE || plain == GLFW_FALSE);
|
||||||
|
|
||||||
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -317,6 +334,12 @@ void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool
|
|||||||
//
|
//
|
||||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(xoffset > -FLT_MAX);
|
||||||
|
assert(xoffset < FLT_MAX);
|
||||||
|
assert(yoffset > -FLT_MAX);
|
||||||
|
assert(yoffset < FLT_MAX);
|
||||||
|
|
||||||
if (window->callbacks.scroll)
|
if (window->callbacks.scroll)
|
||||||
window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
|
window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
|
||||||
}
|
}
|
||||||
@ -325,6 +348,12 @@ void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
|||||||
//
|
//
|
||||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(button >= 0);
|
||||||
|
assert(button <= GLFW_MOUSE_BUTTON_LAST);
|
||||||
|
assert(action == GLFW_PRESS || action == GLFW_RELEASE);
|
||||||
|
assert(mods == (mods & GLFW_MOD_MASK));
|
||||||
|
|
||||||
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -345,6 +374,12 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
|||||||
//
|
//
|
||||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(xpos > -FLT_MAX);
|
||||||
|
assert(xpos < FLT_MAX);
|
||||||
|
assert(ypos > -FLT_MAX);
|
||||||
|
assert(ypos < FLT_MAX);
|
||||||
|
|
||||||
if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
|
if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -359,6 +394,9 @@ void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
|||||||
//
|
//
|
||||||
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
|
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(entered == GLFW_TRUE || entered == GLFW_FALSE);
|
||||||
|
|
||||||
if (window->callbacks.cursorEnter)
|
if (window->callbacks.cursorEnter)
|
||||||
window->callbacks.cursorEnter((GLFWwindow*) window, entered);
|
window->callbacks.cursorEnter((GLFWwindow*) window, entered);
|
||||||
}
|
}
|
||||||
@ -367,6 +405,10 @@ void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
|
|||||||
//
|
//
|
||||||
void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
|
void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(count > 0);
|
||||||
|
assert(paths != NULL);
|
||||||
|
|
||||||
if (window->callbacks.drop)
|
if (window->callbacks.drop)
|
||||||
window->callbacks.drop((GLFWwindow*) window, count, paths);
|
window->callbacks.drop((GLFWwindow*) window, count, paths);
|
||||||
}
|
}
|
||||||
@ -375,16 +417,26 @@ void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
|
|||||||
//
|
//
|
||||||
void _glfwInputJoystick(_GLFWjoystick* js, int event)
|
void _glfwInputJoystick(_GLFWjoystick* js, int event)
|
||||||
{
|
{
|
||||||
const int jid = (int) (js - _glfw.joysticks);
|
assert(js != NULL);
|
||||||
|
assert(event == GLFW_CONNECTED || event == GLFW_DISCONNECTED);
|
||||||
|
|
||||||
|
if (event == GLFW_CONNECTED)
|
||||||
|
js->connected = GLFW_TRUE;
|
||||||
|
else if (event == GLFW_DISCONNECTED)
|
||||||
|
js->connected = GLFW_FALSE;
|
||||||
|
|
||||||
if (_glfw.callbacks.joystick)
|
if (_glfw.callbacks.joystick)
|
||||||
_glfw.callbacks.joystick(jid, event);
|
_glfw.callbacks.joystick((int) (js - _glfw.joysticks), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notifies shared code of the new value of a joystick axis
|
// Notifies shared code of the new value of a joystick axis
|
||||||
//
|
//
|
||||||
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
|
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
|
||||||
{
|
{
|
||||||
|
assert(js != NULL);
|
||||||
|
assert(axis >= 0);
|
||||||
|
assert(axis < js->axisCount);
|
||||||
|
|
||||||
js->axes[axis] = value;
|
js->axes[axis] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,6 +444,11 @@ void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
|
|||||||
//
|
//
|
||||||
void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
|
void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
|
||||||
{
|
{
|
||||||
|
assert(js != NULL);
|
||||||
|
assert(button >= 0);
|
||||||
|
assert(button < js->buttonCount);
|
||||||
|
assert(value == GLFW_PRESS || value == GLFW_RELEASE);
|
||||||
|
|
||||||
js->buttons[button] = value;
|
js->buttons[button] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +456,18 @@ void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
|
|||||||
//
|
//
|
||||||
void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
|
void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
|
||||||
{
|
{
|
||||||
const int base = js->buttonCount + hat * 4;
|
int base;
|
||||||
|
|
||||||
|
assert(js != NULL);
|
||||||
|
assert(hat >= 0);
|
||||||
|
assert(hat < js->hatCount);
|
||||||
|
|
||||||
|
// Valid hat values only use the least significant nibble and have at most two bits
|
||||||
|
// set, which can be considered adjacent plus an arbitrary rotation within the nibble
|
||||||
|
assert((value & 0xf0) == 0);
|
||||||
|
assert((value & ((value << 2) | (value >> 2))) == 0);
|
||||||
|
|
||||||
|
base = js->buttonCount + hat * 4;
|
||||||
|
|
||||||
js->buttons[base + 0] = (value & 0x01) ? GLFW_PRESS : GLFW_RELEASE;
|
js->buttons[base + 0] = (value & 0x01) ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
|
js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
@ -442,7 +510,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
if (!_glfw.joysticks[jid].present)
|
if (!_glfw.joysticks[jid].allocated)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +518,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
js->present = GLFW_TRUE;
|
js->allocated = GLFW_TRUE;
|
||||||
js->axes = _glfw_calloc(axisCount, sizeof(float));
|
js->axes = _glfw_calloc(axisCount, sizeof(float));
|
||||||
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
|
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
|
||||||
js->hats = _glfw_calloc(hatCount, 1);
|
js->hats = _glfw_calloc(hatCount, 1);
|
||||||
@ -528,7 +596,8 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
{
|
{
|
||||||
if (value != GLFW_CURSOR_NORMAL &&
|
if (value != GLFW_CURSOR_NORMAL &&
|
||||||
value != GLFW_CURSOR_HIDDEN &&
|
value != GLFW_CURSOR_HIDDEN &&
|
||||||
value != GLFW_CURSOR_DISABLED)
|
value != GLFW_CURSOR_DISABLED &&
|
||||||
|
value != GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
_glfwInputError(GLFW_INVALID_ENUM,
|
||||||
"Invalid cursor mode 0x%08X",
|
"Invalid cursor mode 0x%08X",
|
||||||
@ -972,7 +1041,7 @@ GLFWAPI int glfwJoystickPresent(int jid)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
return _glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE);
|
return _glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE);
|
||||||
@ -1000,7 +1069,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_AXES))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_AXES))
|
||||||
@ -1032,7 +1101,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||||
@ -1068,7 +1137,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||||
@ -1097,7 +1166,7 @@ GLFWAPI const char* glfwGetJoystickName(int jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
@ -1125,7 +1194,7 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
@ -1144,7 +1213,7 @@ GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
|
|||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->allocated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
js->userPointer = pointer;
|
js->userPointer = pointer;
|
||||||
@ -1160,7 +1229,7 @@ GLFWAPI void* glfwGetJoystickUserPointer(int jid)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->allocated)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return js->userPointer;
|
return js->userPointer;
|
||||||
@ -1230,7 +1299,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
|
|||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->connected)
|
||||||
js->mapping = findValidMapping(js);
|
js->mapping = findValidMapping(js);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1256,7 +1325,7 @@ GLFWAPI int glfwJoystickIsGamepad(int jid)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
@ -1284,7 +1353,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
@ -1319,7 +1388,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->connected)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_ALL))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_ALL))
|
||||||
|
@ -421,6 +421,9 @@ struct _GLFWwndconfig
|
|||||||
struct {
|
struct {
|
||||||
GLFWbool keymenu;
|
GLFWbool keymenu;
|
||||||
} win32;
|
} win32;
|
||||||
|
struct {
|
||||||
|
char appId[256];
|
||||||
|
} wl;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Context configuration
|
// Context configuration
|
||||||
@ -634,7 +637,8 @@ struct _GLFWmapping
|
|||||||
//
|
//
|
||||||
struct _GLFWjoystick
|
struct _GLFWjoystick
|
||||||
{
|
{
|
||||||
GLFWbool present;
|
GLFWbool allocated;
|
||||||
|
GLFWbool connected;
|
||||||
float* axes;
|
float* axes;
|
||||||
int axisCount;
|
int axisCount;
|
||||||
unsigned char* buttons;
|
unsigned char* buttons;
|
||||||
@ -680,8 +684,8 @@ struct _GLFWplatform
|
|||||||
void (*setCursorMode)(_GLFWwindow*,int);
|
void (*setCursorMode)(_GLFWwindow*,int);
|
||||||
void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool);
|
void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool);
|
||||||
GLFWbool (*rawMouseMotionSupported)(void);
|
GLFWbool (*rawMouseMotionSupported)(void);
|
||||||
int (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int);
|
GLFWbool (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int);
|
||||||
int (*createStandardCursor)(_GLFWcursor*,int);
|
GLFWbool (*createStandardCursor)(_GLFWcursor*,int);
|
||||||
void (*destroyCursor)(_GLFWcursor*);
|
void (*destroyCursor)(_GLFWcursor*);
|
||||||
void (*setCursor)(_GLFWwindow*,_GLFWcursor*);
|
void (*setCursor)(_GLFWwindow*,_GLFWcursor*);
|
||||||
const char* (*getScancodeName)(int);
|
const char* (*getScancodeName)(int);
|
||||||
@ -690,7 +694,7 @@ struct _GLFWplatform
|
|||||||
const char* (*getClipboardString)(void);
|
const char* (*getClipboardString)(void);
|
||||||
GLFWbool (*initJoysticks)(void);
|
GLFWbool (*initJoysticks)(void);
|
||||||
void (*terminateJoysticks)(void);
|
void (*terminateJoysticks)(void);
|
||||||
int (*pollJoystick)(_GLFWjoystick*,int);
|
GLFWbool (*pollJoystick)(_GLFWjoystick*,int);
|
||||||
const char* (*getMappingName)(void);
|
const char* (*getMappingName)(void);
|
||||||
void (*updateGamepadGUID)(char*);
|
void (*updateGamepadGUID)(char*);
|
||||||
// monitor
|
// monitor
|
||||||
@ -703,7 +707,7 @@ struct _GLFWplatform
|
|||||||
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
|
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
|
||||||
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
|
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
|
||||||
// window
|
// window
|
||||||
int (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
|
GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
|
||||||
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*);
|
||||||
@ -724,12 +728,12 @@ struct _GLFWplatform
|
|||||||
void (*requestWindowAttention)(_GLFWwindow*);
|
void (*requestWindowAttention)(_GLFWwindow*);
|
||||||
void (*focusWindow)(_GLFWwindow*);
|
void (*focusWindow)(_GLFWwindow*);
|
||||||
void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int);
|
void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int);
|
||||||
int (*windowFocused)(_GLFWwindow*);
|
GLFWbool (*windowFocused)(_GLFWwindow*);
|
||||||
int (*windowIconified)(_GLFWwindow*);
|
GLFWbool (*windowIconified)(_GLFWwindow*);
|
||||||
int (*windowVisible)(_GLFWwindow*);
|
GLFWbool (*windowVisible)(_GLFWwindow*);
|
||||||
int (*windowMaximized)(_GLFWwindow*);
|
GLFWbool (*windowMaximized)(_GLFWwindow*);
|
||||||
int (*windowHovered)(_GLFWwindow*);
|
GLFWbool (*windowHovered)(_GLFWwindow*);
|
||||||
int (*framebufferTransparent)(_GLFWwindow*);
|
GLFWbool (*framebufferTransparent)(_GLFWwindow*);
|
||||||
float (*getWindowOpacity)(_GLFWwindow*);
|
float (*getWindowOpacity)(_GLFWwindow*);
|
||||||
void (*setWindowResizable)(_GLFWwindow*,GLFWbool);
|
void (*setWindowResizable)(_GLFWwindow*,GLFWbool);
|
||||||
void (*setWindowDecorated)(_GLFWwindow*,GLFWbool);
|
void (*setWindowDecorated)(_GLFWwindow*,GLFWbool);
|
||||||
@ -746,7 +750,7 @@ struct _GLFWplatform
|
|||||||
EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*);
|
EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*);
|
||||||
// vulkan
|
// vulkan
|
||||||
void (*getRequiredInstanceExtensions)(char**);
|
void (*getRequiredInstanceExtensions)(char**);
|
||||||
int (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
|
GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
|
||||||
VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ static GLFWbool openJoystickDevice(const char* path)
|
|||||||
{
|
{
|
||||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
if (!_glfw.joysticks[jid].present)
|
if (!_glfw.joysticks[jid].connected)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
|
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -157,7 +157,7 @@ static GLFWbool openJoystickDevice(const char* path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure this device supports the events expected of a joystick
|
// Ensure this device supports the events expected of a joystick
|
||||||
if (!isBitSet(EV_KEY, evBits) || !isBitSet(EV_ABS, evBits))
|
if (!isBitSet(EV_ABS, evBits))
|
||||||
{
|
{
|
||||||
close(linjs.fd);
|
close(linjs.fd);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -245,9 +245,9 @@ static GLFWbool openJoystickDevice(const char* path)
|
|||||||
//
|
//
|
||||||
static void closeJoystick(_GLFWjoystick* js)
|
static void closeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
|
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
||||||
close(js->linjs.fd);
|
close(js->linjs.fd);
|
||||||
_glfwFreeJoystick(js);
|
_glfwFreeJoystick(js);
|
||||||
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lexically compare joysticks by name; used by qsort
|
// Lexically compare joysticks by name; used by qsort
|
||||||
@ -366,7 +366,7 @@ void _glfwTerminateJoysticksLinux(void)
|
|||||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->connected)
|
||||||
closeJoystick(js);
|
closeJoystick(js);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ void _glfwTerminateJoysticksLinux(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
// Read all queued events (non-blocking)
|
// Read all queued events (non-blocking)
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -417,7 +417,7 @@ int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
|||||||
handleAbsEvent(js, e.code, e.value);
|
handleAbsEvent(js, e.code, e.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return js->present;
|
return js->connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwGetMappingNameLinux(void)
|
const char* _glfwGetMappingNameLinux(void)
|
||||||
|
@ -59,7 +59,7 @@ void _glfwDetectJoystickConnectionLinux(void);
|
|||||||
|
|
||||||
GLFWbool _glfwInitJoysticksLinux(void);
|
GLFWbool _glfwInitJoysticksLinux(void);
|
||||||
void _glfwTerminateJoysticksLinux(void);
|
void _glfwTerminateJoysticksLinux(void);
|
||||||
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode);
|
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode);
|
||||||
const char* _glfwGetMappingNameLinux(void);
|
const char* _glfwGetMappingNameLinux(void);
|
||||||
void _glfwUpdateGamepadGUIDLinux(char* guid);
|
void _glfwUpdateGamepadGUIDLinux(char* guid);
|
||||||
|
|
||||||
|
@ -96,6 +96,10 @@ static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
|
|||||||
//
|
//
|
||||||
void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
|
void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
|
||||||
{
|
{
|
||||||
|
assert(monitor != NULL);
|
||||||
|
assert(action == GLFW_CONNECTED || action == GLFW_DISCONNECTED);
|
||||||
|
assert(placement == _GLFW_INSERT_FIRST || placement == _GLFW_INSERT_LAST);
|
||||||
|
|
||||||
if (action == GLFW_CONNECTED)
|
if (action == GLFW_CONNECTED)
|
||||||
{
|
{
|
||||||
_glfw.monitorCount++;
|
_glfw.monitorCount++;
|
||||||
@ -155,6 +159,7 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
|
|||||||
//
|
//
|
||||||
void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
|
void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
assert(monitor != NULL);
|
||||||
monitor->window = window;
|
monitor->window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,6 +527,8 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
|||||||
assert(ramp->green != NULL);
|
assert(ramp->green != NULL);
|
||||||
assert(ramp->blue != NULL);
|
assert(ramp->blue != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
if (ramp->size <= 0)
|
if (ramp->size <= 0)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
@ -530,8 +537,6 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
|
||||||
|
|
||||||
if (!monitor->originalRamp.size)
|
if (!monitor->originalRamp.size)
|
||||||
{
|
{
|
||||||
if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp))
|
if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp))
|
||||||
|
@ -42,7 +42,7 @@ void _glfwTerminateJoysticksNull(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPollJoystickNull(_GLFWjoystick* js, int mode)
|
GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
GLFWbool _glfwInitJoysticksNull(void);
|
GLFWbool _glfwInitJoysticksNull(void);
|
||||||
void _glfwTerminateJoysticksNull(void);
|
void _glfwTerminateJoysticksNull(void);
|
||||||
int _glfwPollJoystickNull(_GLFWjoystick* js, int mode);
|
GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode);
|
||||||
const char* _glfwGetMappingNameNull(void);
|
const char* _glfwGetMappingNameNull(void);
|
||||||
void _glfwUpdateGamepadGUIDNull(char* guid);
|
void _glfwUpdateGamepadGUIDNull(char* guid);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ void _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);
|
||||||
|
|
||||||
int _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
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);
|
||||||
@ -102,9 +102,9 @@ void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* y
|
|||||||
void _glfwIconifyWindowNull(_GLFWwindow* window);
|
void _glfwIconifyWindowNull(_GLFWwindow* window);
|
||||||
void _glfwRestoreWindowNull(_GLFWwindow* window);
|
void _glfwRestoreWindowNull(_GLFWwindow* window);
|
||||||
void _glfwMaximizeWindowNull(_GLFWwindow* window);
|
void _glfwMaximizeWindowNull(_GLFWwindow* window);
|
||||||
int _glfwWindowMaximizedNull(_GLFWwindow* window);
|
GLFWbool _glfwWindowMaximizedNull(_GLFWwindow* window);
|
||||||
int _glfwWindowHoveredNull(_GLFWwindow* window);
|
GLFWbool _glfwWindowHoveredNull(_GLFWwindow* window);
|
||||||
int _glfwFramebufferTransparentNull(_GLFWwindow* window);
|
GLFWbool _glfwFramebufferTransparentNull(_GLFWwindow* window);
|
||||||
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
@ -118,9 +118,9 @@ void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
|
|||||||
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
|
||||||
void _glfwHideWindowNull(_GLFWwindow* window);
|
void _glfwHideWindowNull(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowNull(_GLFWwindow* window);
|
void _glfwFocusWindowNull(_GLFWwindow* window);
|
||||||
int _glfwWindowFocusedNull(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window);
|
||||||
int _glfwWindowIconifiedNull(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedNull(_GLFWwindow* window);
|
||||||
int _glfwWindowVisibleNull(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleNull(_GLFWwindow* window);
|
||||||
void _glfwPollEventsNull(void);
|
void _glfwPollEventsNull(void);
|
||||||
void _glfwWaitEventsNull(void);
|
void _glfwWaitEventsNull(void);
|
||||||
void _glfwWaitEventsTimeoutNull(double timeout);
|
void _glfwWaitEventsTimeoutNull(double timeout);
|
||||||
@ -128,8 +128,8 @@ void _glfwPostEmptyEventNull(void);
|
|||||||
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos);
|
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos);
|
||||||
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y);
|
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y);
|
||||||
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode);
|
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode);
|
||||||
int _glfwCreateCursorNull(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
GLFWbool _glfwCreateCursorNull(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape);
|
GLFWbool _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape);
|
||||||
void _glfwDestroyCursorNull(_GLFWcursor* cursor);
|
void _glfwDestroyCursorNull(_GLFWcursor* cursor);
|
||||||
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor);
|
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
void _glfwSetClipboardStringNull(const char* string);
|
void _glfwSetClipboardStringNull(const char* string);
|
||||||
@ -142,7 +142,7 @@ EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void);
|
|||||||
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window);
|
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwGetRequiredInstanceExtensionsNull(char** extensions);
|
void _glfwGetRequiredInstanceExtensionsNull(char** extensions);
|
||||||
int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
void _glfwPollMonitorsNull(void);
|
void _glfwPollMonitorsNull(void);
|
||||||
|
@ -103,10 +103,10 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwCreateWindowNull(_GLFWwindow* window,
|
GLFWbool _glfwCreateWindowNull(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
if (!createNativeWindow(window, wndconfig, fbconfig))
|
if (!createNativeWindow(window, wndconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -128,13 +128,31 @@ int _glfwCreateWindowNull(_GLFWwindow* window,
|
|||||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughNull(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
_glfwShowWindowNull(window);
|
_glfwShowWindowNull(window);
|
||||||
_glfwFocusWindowNull(window);
|
_glfwFocusWindowNull(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
|
||||||
|
if (wndconfig->centerCursor)
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->visible)
|
||||||
|
{
|
||||||
|
_glfwShowWindowNull(window);
|
||||||
|
if (wndconfig->focused)
|
||||||
|
_glfwFocusWindowNull(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -344,12 +362,12 @@ void _glfwMaximizeWindowNull(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowMaximizedNull(_GLFWwindow* window)
|
GLFWbool _glfwWindowMaximizedNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.maximized;
|
return window->null.maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowHoveredNull(_GLFWwindow* window)
|
GLFWbool _glfwWindowHoveredNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return _glfw.null.xcursor >= window->null.xpos &&
|
return _glfw.null.xcursor >= window->null.xpos &&
|
||||||
_glfw.null.ycursor >= window->null.ypos &&
|
_glfw.null.ycursor >= window->null.ypos &&
|
||||||
@ -357,7 +375,7 @@ int _glfwWindowHoveredNull(_GLFWwindow* window)
|
|||||||
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
|
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwFramebufferTransparentNull(_GLFWwindow* window)
|
GLFWbool _glfwFramebufferTransparentNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.transparent;
|
return window->null.transparent;
|
||||||
}
|
}
|
||||||
@ -443,17 +461,17 @@ void _glfwFocusWindowNull(_GLFWwindow* window)
|
|||||||
_glfwInputWindowFocus(window, GLFW_TRUE);
|
_glfwInputWindowFocus(window, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowFocusedNull(_GLFWwindow* window)
|
GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return _glfw.null.focusedWindow == window;
|
return _glfw.null.focusedWindow == window;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowIconifiedNull(_GLFWwindow* window)
|
GLFWbool _glfwWindowIconifiedNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.iconified;
|
return window->null.iconified;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowVisibleNull(_GLFWwindow* window)
|
GLFWbool _glfwWindowVisibleNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.visible;
|
return window->null.visible;
|
||||||
}
|
}
|
||||||
@ -492,14 +510,14 @@ void _glfwSetCursorModeNull(_GLFWwindow* window, int mode)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateCursorNull(_GLFWcursor* cursor,
|
GLFWbool _glfwCreateCursorNull(_GLFWcursor* cursor,
|
||||||
const GLFWimage* image,
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape)
|
GLFWbool _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
@ -675,9 +693,9 @@ void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
|
||||||
VkPhysicalDevice device,
|
VkPhysicalDevice device,
|
||||||
uint32_t queuefamily)
|
uint32_t queuefamily)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -92,30 +92,6 @@
|
|||||||
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#include "win32_thread.h"
|
|
||||||
#define GLFW_POSIX_TLS_STATE
|
|
||||||
#define GLFW_POSIX_MUTEX_STATE
|
|
||||||
#else
|
|
||||||
#include "posix_thread.h"
|
|
||||||
#define GLFW_WIN32_TLS_STATE
|
|
||||||
#define GLFW_WIN32_MUTEX_STATE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#include "win32_time.h"
|
|
||||||
#define GLFW_POSIX_LIBRARY_TIMER_STATE
|
|
||||||
#define GLFW_COCOA_LIBRARY_TIMER_STATE
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include "cocoa_time.h"
|
|
||||||
#define GLFW_WIN32_LIBRARY_TIMER_STATE
|
|
||||||
#define GLFW_POSIX_LIBRARY_TIMER_STATE
|
|
||||||
#else
|
|
||||||
#include "posix_time.h"
|
|
||||||
#define GLFW_WIN32_LIBRARY_TIMER_STATE
|
|
||||||
#define GLFW_COCOA_LIBRARY_TIMER_STATE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GLFW_PLATFORM_WINDOW_STATE \
|
#define GLFW_PLATFORM_WINDOW_STATE \
|
||||||
GLFW_WIN32_WINDOW_STATE \
|
GLFW_WIN32_WINDOW_STATE \
|
||||||
GLFW_COCOA_WINDOW_STATE \
|
GLFW_COCOA_WINDOW_STATE \
|
||||||
@ -142,14 +118,6 @@
|
|||||||
GLFW_COCOA_JOYSTICK_STATE \
|
GLFW_COCOA_JOYSTICK_STATE \
|
||||||
GLFW_LINUX_JOYSTICK_STATE
|
GLFW_LINUX_JOYSTICK_STATE
|
||||||
|
|
||||||
#define GLFW_PLATFORM_TLS_STATE \
|
|
||||||
GLFW_WIN32_TLS_STATE \
|
|
||||||
GLFW_POSIX_TLS_STATE \
|
|
||||||
|
|
||||||
#define GLFW_PLATFORM_MUTEX_STATE \
|
|
||||||
GLFW_WIN32_MUTEX_STATE \
|
|
||||||
GLFW_POSIX_MUTEX_STATE \
|
|
||||||
|
|
||||||
#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
|
#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
|
||||||
GLFW_WIN32_LIBRARY_WINDOW_STATE \
|
GLFW_WIN32_LIBRARY_WINDOW_STATE \
|
||||||
GLFW_COCOA_LIBRARY_WINDOW_STATE \
|
GLFW_COCOA_LIBRARY_WINDOW_STATE \
|
||||||
@ -162,11 +130,6 @@
|
|||||||
GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
|
GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
|
||||||
GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
||||||
|
|
||||||
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE \
|
|
||||||
GLFW_WIN32_LIBRARY_TIMER_STATE \
|
|
||||||
GLFW_COCOA_LIBRARY_TIMER_STATE \
|
|
||||||
GLFW_POSIX_LIBRARY_TIMER_STATE \
|
|
||||||
|
|
||||||
#define GLFW_PLATFORM_CONTEXT_STATE \
|
#define GLFW_PLATFORM_CONTEXT_STATE \
|
||||||
GLFW_WGL_CONTEXT_STATE \
|
GLFW_WGL_CONTEXT_STATE \
|
||||||
GLFW_NSGL_CONTEXT_STATE \
|
GLFW_NSGL_CONTEXT_STATE \
|
||||||
@ -177,3 +140,24 @@
|
|||||||
GLFW_NSGL_LIBRARY_CONTEXT_STATE \
|
GLFW_NSGL_LIBRARY_CONTEXT_STATE \
|
||||||
GLFW_GLX_LIBRARY_CONTEXT_STATE
|
GLFW_GLX_LIBRARY_CONTEXT_STATE
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "win32_thread.h"
|
||||||
|
#define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE
|
||||||
|
#define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE
|
||||||
|
#else
|
||||||
|
#include "posix_thread.h"
|
||||||
|
#define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE
|
||||||
|
#define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "win32_time.h"
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "cocoa_time.h"
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE
|
||||||
|
#else
|
||||||
|
#include "posix_time.h"
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -331,15 +331,64 @@ static void createKeyTables(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Window procedure for the hidden helper window
|
||||||
|
//
|
||||||
|
static LRESULT CALLBACK helperWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (uMsg)
|
||||||
|
{
|
||||||
|
case WM_DISPLAYCHANGE:
|
||||||
|
_glfwPollMonitorsWin32();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DEVICECHANGE:
|
||||||
|
{
|
||||||
|
if (!_glfw.joysticksInitialized)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (wParam == DBT_DEVICEARRIVAL)
|
||||||
|
{
|
||||||
|
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
||||||
|
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||||
|
_glfwDetectJoystickConnectionWin32();
|
||||||
|
}
|
||||||
|
else if (wParam == DBT_DEVICEREMOVECOMPLETE)
|
||||||
|
{
|
||||||
|
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
||||||
|
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||||
|
_glfwDetectJoystickDisconnectionWin32();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a dummy window for behind-the-scenes work
|
// Creates a dummy window for behind-the-scenes work
|
||||||
//
|
//
|
||||||
static GLFWbool createHelperWindow(void)
|
static GLFWbool createHelperWindow(void)
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
WNDCLASSEXW wc = { sizeof(wc) };
|
||||||
|
|
||||||
|
wc.style = CS_OWNDC;
|
||||||
|
wc.lpfnWndProc = (WNDPROC) helperWindowProc;
|
||||||
|
wc.hInstance = _glfw.win32.instance;
|
||||||
|
wc.lpszClassName = L"GLFW3 Helper";
|
||||||
|
|
||||||
|
_glfw.win32.helperWindowClass = RegisterClassExW(&wc);
|
||||||
|
if (!_glfw.win32.helperWindowClass)
|
||||||
|
{
|
||||||
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
|
"WIn32: Failed to register helper window class");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
_glfw.win32.helperWindowHandle =
|
_glfw.win32.helperWindowHandle =
|
||||||
CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
|
CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
|
||||||
_GLFW_WNDCLASSNAME,
|
MAKEINTATOM(_glfw.win32.helperWindowClass),
|
||||||
L"GLFW message window",
|
L"GLFW message window",
|
||||||
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
||||||
0, 0, 1, 1,
|
0, 0, 1, 1,
|
||||||
@ -502,6 +551,8 @@ void _glfwUpdateKeyNamesWin32(void)
|
|||||||
|
|
||||||
if (length == -1)
|
if (length == -1)
|
||||||
{
|
{
|
||||||
|
// This is a dead key, so we need a second simulated key press
|
||||||
|
// to make it output its own character (usually a diacritic)
|
||||||
length = ToUnicode(vk, scancode, state,
|
length = ToUnicode(vk, scancode, state,
|
||||||
chars, sizeof(chars) / sizeof(WCHAR),
|
chars, sizeof(chars) / sizeof(WCHAR),
|
||||||
0);
|
0);
|
||||||
@ -645,9 +696,6 @@ int _glfwInitWin32(void)
|
|||||||
else if (IsWindowsVistaOrGreater())
|
else if (IsWindowsVistaOrGreater())
|
||||||
SetProcessDPIAware();
|
SetProcessDPIAware();
|
||||||
|
|
||||||
if (!_glfwRegisterWindowClassWin32())
|
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (!createHelperWindow())
|
if (!createHelperWindow())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
@ -662,14 +710,17 @@ void _glfwTerminateWin32(void)
|
|||||||
|
|
||||||
if (_glfw.win32.helperWindowHandle)
|
if (_glfw.win32.helperWindowHandle)
|
||||||
DestroyWindow(_glfw.win32.helperWindowHandle);
|
DestroyWindow(_glfw.win32.helperWindowHandle);
|
||||||
|
if (_glfw.win32.helperWindowClass)
|
||||||
_glfwUnregisterWindowClassWin32();
|
UnregisterClassW(MAKEINTATOM(_glfw.win32.helperWindowClass), _glfw.win32.instance);
|
||||||
|
if (_glfw.win32.mainWindowClass)
|
||||||
|
UnregisterClassW(MAKEINTATOM(_glfw.win32.mainWindowClass), _glfw.win32.instance);
|
||||||
|
|
||||||
_glfw_free(_glfw.win32.clipboardString);
|
_glfw_free(_glfw.win32.clipboardString);
|
||||||
_glfw_free(_glfw.win32.rawInput);
|
_glfw_free(_glfw.win32.rawInput);
|
||||||
|
|
||||||
_glfwTerminateWGL();
|
_glfwTerminateWGL();
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
|
_glfwTerminateOSMesa();
|
||||||
|
|
||||||
freeLibraries();
|
freeLibraries();
|
||||||
}
|
}
|
||||||
|
@ -256,6 +256,8 @@ static GLFWbool supportsXInput(const GUID* guid)
|
|||||||
//
|
//
|
||||||
static void closeJoystick(_GLFWjoystick* js)
|
static void closeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
|
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
||||||
|
|
||||||
if (js->win32.device)
|
if (js->win32.device)
|
||||||
{
|
{
|
||||||
IDirectInputDevice8_Unacquire(js->win32.device);
|
IDirectInputDevice8_Unacquire(js->win32.device);
|
||||||
@ -263,9 +265,7 @@ static void closeJoystick(_GLFWjoystick* js)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfw_free(js->win32.objects);
|
_glfw_free(js->win32.objects);
|
||||||
|
|
||||||
_glfwFreeJoystick(js);
|
_glfwFreeJoystick(js);
|
||||||
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DirectInput device object enumeration callback
|
// DirectInput device object enumeration callback
|
||||||
@ -357,7 +357,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
|
|||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->connected)
|
||||||
{
|
{
|
||||||
if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
|
if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
|
||||||
return DIENUM_CONTINUE;
|
return DIENUM_CONTINUE;
|
||||||
@ -508,7 +508,7 @@ void _glfwDetectJoystickConnectionWin32(void)
|
|||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
if (_glfw.joysticks[jid].present &&
|
if (_glfw.joysticks[jid].connected &&
|
||||||
_glfw.joysticks[jid].win32.device == NULL &&
|
_glfw.joysticks[jid].win32.device == NULL &&
|
||||||
_glfw.joysticks[jid].win32.index == index)
|
_glfw.joysticks[jid].win32.index == index)
|
||||||
{
|
{
|
||||||
@ -560,7 +560,7 @@ void _glfwDetectJoystickDisconnectionWin32(void)
|
|||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
{
|
{
|
||||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->connected)
|
||||||
_glfwPollJoystickWin32(js, _GLFW_POLL_PRESENCE);
|
_glfwPollJoystickWin32(js, _GLFW_POLL_PRESENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,13 +601,13 @@ void _glfwTerminateJoysticksWin32(void)
|
|||||||
IDirectInput8_Release(_glfw.win32.dinput8.api);
|
IDirectInput8_Release(_glfw.win32.dinput8.api);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
|
GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
if (js->win32.device)
|
if (js->win32.device)
|
||||||
{
|
{
|
||||||
int i, ai = 0, bi = 0, pi = 0;
|
int i, ai = 0, bi = 0, pi = 0;
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
DIJOYSTATE state;
|
DIJOYSTATE state = {0};
|
||||||
|
|
||||||
IDirectInputDevice8_Poll(js->win32.device);
|
IDirectInputDevice8_Poll(js->win32.device);
|
||||||
result = IDirectInputDevice8_GetDeviceState(js->win32.device,
|
result = IDirectInputDevice8_GetDeviceState(js->win32.device,
|
||||||
|
@ -358,10 +358,6 @@ typedef struct VkWin32SurfaceCreateInfoKHR
|
|||||||
typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||||
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
|
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
|
||||||
|
|
||||||
#if !defined(_GLFW_WNDCLASSNAME)
|
|
||||||
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GLFW_WIN32_WINDOW_STATE _GLFWwindowWin32 win32;
|
#define GLFW_WIN32_WINDOW_STATE _GLFWwindowWin32 win32;
|
||||||
#define GLFW_WIN32_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32;
|
#define GLFW_WIN32_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32;
|
||||||
#define GLFW_WIN32_MONITOR_STATE _GLFWmonitorWin32 win32;
|
#define GLFW_WIN32_MONITOR_STATE _GLFWmonitorWin32 win32;
|
||||||
@ -444,6 +440,8 @@ typedef struct _GLFWlibraryWin32
|
|||||||
{
|
{
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
HWND helperWindowHandle;
|
HWND helperWindowHandle;
|
||||||
|
ATOM helperWindowClass;
|
||||||
|
ATOM mainWindowClass;
|
||||||
HDEVNOTIFY deviceNotificationHandle;
|
HDEVNOTIFY deviceNotificationHandle;
|
||||||
int acquiredMonitorCount;
|
int acquiredMonitorCount;
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
@ -454,6 +452,8 @@ typedef struct _GLFWlibraryWin32
|
|||||||
double restoreCursorPosX, restoreCursorPosY;
|
double restoreCursorPosX, restoreCursorPosY;
|
||||||
// The window whose disabled cursor mode is active
|
// The window whose disabled cursor mode is active
|
||||||
_GLFWwindow* disabledCursorWindow;
|
_GLFWwindow* disabledCursorWindow;
|
||||||
|
// The window the cursor is captured in
|
||||||
|
_GLFWwindow* capturedCursorWindow;
|
||||||
RAWINPUT* rawInput;
|
RAWINPUT* rawInput;
|
||||||
int rawInputSize;
|
int rawInputSize;
|
||||||
UINT mouseTrailSize;
|
UINT mouseTrailSize;
|
||||||
@ -527,9 +527,6 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform);
|
|||||||
int _glfwInitWin32(void);
|
int _glfwInitWin32(void);
|
||||||
void _glfwTerminateWin32(void);
|
void _glfwTerminateWin32(void);
|
||||||
|
|
||||||
GLFWbool _glfwRegisterWindowClassWin32(void);
|
|
||||||
void _glfwUnregisterWindowClassWin32(void);
|
|
||||||
|
|
||||||
WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
|
WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
|
||||||
char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
|
char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
|
||||||
BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
|
BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
|
||||||
@ -542,7 +539,7 @@ void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
|||||||
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
||||||
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
||||||
|
|
||||||
int _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
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);
|
||||||
@ -563,12 +560,12 @@ void _glfwHideWindowWin32(_GLFWwindow* window);
|
|||||||
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowWin32(_GLFWwindow* window);
|
void _glfwFocusWindowWin32(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
int _glfwWindowFocusedWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedWin32(_GLFWwindow* window);
|
||||||
int _glfwWindowIconifiedWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedWin32(_GLFWwindow* window);
|
||||||
int _glfwWindowVisibleWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleWin32(_GLFWwindow* window);
|
||||||
int _glfwWindowMaximizedWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowMaximizedWin32(_GLFWwindow* window);
|
||||||
int _glfwWindowHoveredWin32(_GLFWwindow* window);
|
GLFWbool _glfwWindowHoveredWin32(_GLFWwindow* window);
|
||||||
int _glfwFramebufferTransparentWin32(_GLFWwindow* window);
|
GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window);
|
||||||
void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
@ -589,8 +586,8 @@ void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos);
|
|||||||
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode);
|
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode);
|
||||||
const char* _glfwGetScancodeNameWin32(int scancode);
|
const char* _glfwGetScancodeNameWin32(int scancode);
|
||||||
int _glfwGetKeyScancodeWin32(int key);
|
int _glfwGetKeyScancodeWin32(int key);
|
||||||
int _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
GLFWbool _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
|
GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
|
||||||
void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
|
void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
|
||||||
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
|
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
void _glfwSetClipboardStringWin32(const char* string);
|
void _glfwSetClipboardStringWin32(const char* string);
|
||||||
@ -601,7 +598,7 @@ EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void);
|
|||||||
EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window);
|
EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwGetRequiredInstanceExtensionsWin32(char** extensions);
|
void _glfwGetRequiredInstanceExtensionsWin32(char** extensions);
|
||||||
int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
void _glfwFreeMonitorWin32(_GLFWmonitor* monitor);
|
void _glfwFreeMonitorWin32(_GLFWmonitor* monitor);
|
||||||
@ -615,7 +612,7 @@ void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
|||||||
|
|
||||||
GLFWbool _glfwInitJoysticksWin32(void);
|
GLFWbool _glfwInitJoysticksWin32(void);
|
||||||
void _glfwTerminateJoysticksWin32(void);
|
void _glfwTerminateJoysticksWin32(void);
|
||||||
int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode);
|
GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode);
|
||||||
const char* _glfwGetMappingNameWin32(void);
|
const char* _glfwGetMappingNameWin32(void);
|
||||||
void _glfwUpdateGamepadGUIDWin32(char* guid);
|
void _glfwUpdateGamepadGUIDWin32(char* guid);
|
||||||
|
|
||||||
|
@ -238,7 +238,8 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
|
|||||||
//
|
//
|
||||||
static void updateCursorImage(_GLFWwindow* window)
|
static void updateCursorImage(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
if (window->cursorMode == GLFW_CURSOR_NORMAL ||
|
||||||
|
window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
if (window->cursor)
|
if (window->cursor)
|
||||||
SetCursor(window->cursor->win32.handle);
|
SetCursor(window->cursor->win32.handle);
|
||||||
@ -249,20 +250,24 @@ static void updateCursorImage(_GLFWwindow* window)
|
|||||||
SetCursor(NULL);
|
SetCursor(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the cursor clip rect
|
// Sets the cursor clip rect to the window content area
|
||||||
//
|
//
|
||||||
static void updateClipRect(_GLFWwindow* window)
|
static void captureCursor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window)
|
RECT clipRect;
|
||||||
{
|
GetClientRect(window->win32.handle, &clipRect);
|
||||||
RECT clipRect;
|
ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
|
||||||
GetClientRect(window->win32.handle, &clipRect);
|
ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
|
ClipCursor(&clipRect);
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
|
_glfw.win32.capturedCursorWindow = window;
|
||||||
ClipCursor(&clipRect);
|
}
|
||||||
}
|
|
||||||
else
|
// Disabled clip cursor
|
||||||
ClipCursor(NULL);
|
//
|
||||||
|
static void releaseCursor(void)
|
||||||
|
{
|
||||||
|
ClipCursor(NULL);
|
||||||
|
_glfw.win32.capturedCursorWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enables WM_INPUT messages for the mouse for the specified window
|
// Enables WM_INPUT messages for the mouse for the specified window
|
||||||
@ -301,7 +306,7 @@ static void disableCursor(_GLFWwindow* window)
|
|||||||
&_glfw.win32.restoreCursorPosY);
|
&_glfw.win32.restoreCursorPosY);
|
||||||
updateCursorImage(window);
|
updateCursorImage(window);
|
||||||
_glfwCenterCursorInContentArea(window);
|
_glfwCenterCursorInContentArea(window);
|
||||||
updateClipRect(window);
|
captureCursor(window);
|
||||||
|
|
||||||
if (window->rawMouseMotion)
|
if (window->rawMouseMotion)
|
||||||
enableRawMouseMotion(window);
|
enableRawMouseMotion(window);
|
||||||
@ -315,7 +320,7 @@ static void enableCursor(_GLFWwindow* window)
|
|||||||
disableRawMouseMotion(window);
|
disableRawMouseMotion(window);
|
||||||
|
|
||||||
_glfw.win32.disabledCursorWindow = NULL;
|
_glfw.win32.disabledCursorWindow = NULL;
|
||||||
updateClipRect(NULL);
|
releaseCursor();
|
||||||
_glfwSetCursorPosWin32(window,
|
_glfwSetCursorPosWin32(window,
|
||||||
_glfw.win32.restoreCursorPosX,
|
_glfw.win32.restoreCursorPosX,
|
||||||
_glfw.win32.restoreCursorPosY);
|
_glfw.win32.restoreCursorPosY);
|
||||||
@ -533,59 +538,26 @@ static void maximizeWindowManually(_GLFWwindow* window)
|
|||||||
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window callback function (handles window messages)
|
// Window procedure for user-created windows
|
||||||
//
|
//
|
||||||
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = GetPropW(hWnd, L"GLFW");
|
_GLFWwindow* window = GetPropW(hWnd, L"GLFW");
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
// This is the message handling for the hidden helper window
|
if (uMsg == WM_NCCREATE)
|
||||||
// and for a regular window during its initial creation
|
|
||||||
|
|
||||||
switch (uMsg)
|
|
||||||
{
|
{
|
||||||
case WM_NCCREATE:
|
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||||
{
|
{
|
||||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
|
||||||
{
|
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
|
||||||
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
|
|
||||||
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
|
|
||||||
|
|
||||||
// On per-monitor DPI aware V1 systems, only enable
|
// On per-monitor DPI aware V1 systems, only enable
|
||||||
// non-client scaling for windows that scale the client area
|
// non-client scaling for windows that scale the client area
|
||||||
// We need WM_GETDPISCALEDSIZE from V2 to keep the client
|
// We need WM_GETDPISCALEDSIZE from V2 to keep the client
|
||||||
// area static when the non-client area is scaled
|
// area static when the non-client area is scaled
|
||||||
if (wndconfig && wndconfig->scaleToMonitor)
|
if (wndconfig && wndconfig->scaleToMonitor)
|
||||||
EnableNonClientDpiScaling(hWnd);
|
EnableNonClientDpiScaling(hWnd);
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_DISPLAYCHANGE:
|
|
||||||
_glfwPollMonitorsWin32();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_DEVICECHANGE:
|
|
||||||
{
|
|
||||||
if (!_glfw.joysticksInitialized)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (wParam == DBT_DEVICEARRIVAL)
|
|
||||||
{
|
|
||||||
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
|
||||||
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
|
||||||
_glfwDetectJoystickConnectionWin32();
|
|
||||||
}
|
|
||||||
else if (wParam == DBT_DEVICEREMOVECOMPLETE)
|
|
||||||
{
|
|
||||||
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
|
||||||
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
|
||||||
_glfwDetectJoystickDisconnectionWin32();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,6 +587,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
disableCursor(window);
|
disableCursor(window);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
captureCursor(window);
|
||||||
|
|
||||||
window->win32.frameAction = GLFW_FALSE;
|
window->win32.frameAction = GLFW_FALSE;
|
||||||
}
|
}
|
||||||
@ -633,6 +607,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
disableCursor(window);
|
disableCursor(window);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
captureCursor(window);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -641,6 +617,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
enableCursor(window);
|
enableCursor(window);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
releaseCursor();
|
||||||
|
|
||||||
if (window->monitor && window->autoIconify)
|
if (window->monitor && window->autoIconify)
|
||||||
_glfwIconifyWindowWin32(window);
|
_glfwIconifyWindowWin32(window);
|
||||||
@ -760,6 +738,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
if (scancode == 0x146)
|
if (scancode == 0x146)
|
||||||
scancode = 0x45;
|
scancode = 0x45;
|
||||||
|
|
||||||
|
// HACK: CJK IME sets the extended bit for right Shift
|
||||||
|
if (scancode == 0x136)
|
||||||
|
scancode = 0x36;
|
||||||
|
|
||||||
key = _glfw.win32.keycodes[scancode];
|
key = _glfw.win32.keycodes[scancode];
|
||||||
|
|
||||||
// The Ctrl keys require special handling
|
// The Ctrl keys require special handling
|
||||||
@ -1006,6 +988,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
// resizing the window or using the window menu
|
// resizing the window or using the window menu
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
enableCursor(window);
|
enableCursor(window);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
releaseCursor();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1020,6 +1004,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
// resizing the window or using the menu
|
// resizing the window or using the menu
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
disableCursor(window);
|
disableCursor(window);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
captureCursor(window);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1033,8 +1019,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
(window->win32.maximized &&
|
(window->win32.maximized &&
|
||||||
wParam != SIZE_RESTORED);
|
wParam != SIZE_RESTORED);
|
||||||
|
|
||||||
if (_glfw.win32.disabledCursorWindow == window)
|
if (_glfw.win32.capturedCursorWindow == window)
|
||||||
updateClipRect(window);
|
captureCursor(window);
|
||||||
|
|
||||||
if (window->win32.iconified != iconified)
|
if (window->win32.iconified != iconified)
|
||||||
_glfwInputWindowIconify(window, iconified);
|
_glfwInputWindowIconify(window, iconified);
|
||||||
@ -1069,8 +1055,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
|
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
{
|
{
|
||||||
if (_glfw.win32.disabledCursorWindow == window)
|
if (_glfw.win32.capturedCursorWindow == window)
|
||||||
updateClipRect(window);
|
captureCursor(window);
|
||||||
|
|
||||||
// NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
|
// NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
|
||||||
// those macros do not handle negative window positions correctly
|
// those macros do not handle negative window positions correctly
|
||||||
@ -1282,17 +1268,51 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
DWORD style = getWindowStyle(window);
|
DWORD style = getWindowStyle(window);
|
||||||
DWORD exStyle = getWindowExStyle(window);
|
DWORD exStyle = getWindowExStyle(window);
|
||||||
|
|
||||||
|
if (!_glfw.win32.mainWindowClass)
|
||||||
|
{
|
||||||
|
WNDCLASSEXW wc = { sizeof(wc) };
|
||||||
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||||
|
wc.lpfnWndProc = windowProc;
|
||||||
|
wc.hInstance = _glfw.win32.instance;
|
||||||
|
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
||||||
|
#if defined(_GLFW_WNDCLASSNAME)
|
||||||
|
wc.lpszClassName = _GLFW_WNDCLASSNAME;
|
||||||
|
#else
|
||||||
|
wc.lpszClassName = L"GLFW30";
|
||||||
|
#endif
|
||||||
|
// Load user-provided icon if available
|
||||||
|
wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
|
||||||
|
L"GLFW_ICON", IMAGE_ICON,
|
||||||
|
0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
||||||
|
if (!wc.hIcon)
|
||||||
|
{
|
||||||
|
// No user-provided icon found, load default icon
|
||||||
|
wc.hIcon = LoadImageW(NULL,
|
||||||
|
IDI_APPLICATION, IMAGE_ICON,
|
||||||
|
0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfw.win32.mainWindowClass = RegisterClassExW(&wc);
|
||||||
|
if (!_glfw.win32.mainWindowClass)
|
||||||
|
{
|
||||||
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
|
"Win32: Failed to register window class");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
|
GetMonitorInfoW(window->monitor->win32.handle, &mi);
|
||||||
|
|
||||||
// NOTE: This window placement is temporary and approximate, as the
|
// NOTE: This window placement is temporary and approximate, as the
|
||||||
// correct position and size cannot be known until the monitor
|
// correct position and size cannot be known until the monitor
|
||||||
// video mode has been picked in _glfwSetVideoModeWin32
|
// video mode has been picked in _glfwSetVideoModeWin32
|
||||||
_glfwGetMonitorPosWin32(window->monitor, &xpos, &ypos);
|
xpos = mi.rcMonitor.left;
|
||||||
_glfwGetVideoModeWin32(window->monitor, &mode);
|
ypos = mi.rcMonitor.top;
|
||||||
fullWidth = mode.width;
|
fullWidth = mi.rcMonitor.right - mi.rcMonitor.left;
|
||||||
fullHeight = mode.height;
|
fullHeight = mi.rcMonitor.bottom - mi.rcMonitor.top;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1314,7 +1334,7 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
window->win32.handle = CreateWindowExW(exStyle,
|
window->win32.handle = CreateWindowExW(exStyle,
|
||||||
_GLFW_WNDCLASSNAME,
|
MAKEINTATOM(_glfw.win32.mainWindowClass),
|
||||||
wideTitle,
|
wideTitle,
|
||||||
style,
|
style,
|
||||||
xpos, ypos,
|
xpos, ypos,
|
||||||
@ -1419,53 +1439,10 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers the GLFW window class
|
GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window,
|
||||||
//
|
const _GLFWwndconfig* wndconfig,
|
||||||
GLFWbool _glfwRegisterWindowClassWin32(void)
|
const _GLFWctxconfig* ctxconfig,
|
||||||
{
|
const _GLFWfbconfig* fbconfig)
|
||||||
WNDCLASSEXW wc;
|
|
||||||
|
|
||||||
ZeroMemory(&wc, sizeof(wc));
|
|
||||||
wc.cbSize = sizeof(wc);
|
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
|
||||||
wc.lpfnWndProc = (WNDPROC) windowProc;
|
|
||||||
wc.hInstance = _glfw.win32.instance;
|
|
||||||
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
|
||||||
wc.lpszClassName = _GLFW_WNDCLASSNAME;
|
|
||||||
|
|
||||||
// Load user-provided icon if available
|
|
||||||
wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
|
|
||||||
L"GLFW_ICON", IMAGE_ICON,
|
|
||||||
0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
|
||||||
if (!wc.hIcon)
|
|
||||||
{
|
|
||||||
// No user-provided icon found, load default icon
|
|
||||||
wc.hIcon = LoadImageW(NULL,
|
|
||||||
IDI_APPLICATION, IMAGE_ICON,
|
|
||||||
0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!RegisterClassExW(&wc))
|
|
||||||
{
|
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
|
||||||
"Win32: Failed to register window class");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unregisters the GLFW window class
|
|
||||||
//
|
|
||||||
void _glfwUnregisterWindowClassWin32(void)
|
|
||||||
{
|
|
||||||
UnregisterClassW(_GLFW_WNDCLASSNAME, _glfw.win32.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
int _glfwCreateWindowWin32(_GLFWwindow* window,
|
|
||||||
const _GLFWwndconfig* wndconfig,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig)
|
|
||||||
{
|
{
|
||||||
if (!createNativeWindow(window, wndconfig, fbconfig))
|
if (!createNativeWindow(window, wndconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -1493,14 +1470,32 @@ int _glfwCreateWindowWin32(_GLFWwindow* window,
|
|||||||
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughWin32(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
_glfwShowWindowWin32(window);
|
_glfwShowWindowWin32(window);
|
||||||
_glfwFocusWindowWin32(window);
|
_glfwFocusWindowWin32(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
fitToMonitor(window);
|
fitToMonitor(window);
|
||||||
|
|
||||||
|
if (wndconfig->centerCursor)
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->visible)
|
||||||
|
{
|
||||||
|
_glfwShowWindowWin32(window);
|
||||||
|
if (wndconfig->focused)
|
||||||
|
_glfwFocusWindowWin32(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -1515,7 +1510,10 @@ void _glfwDestroyWindowWin32(_GLFWwindow* window)
|
|||||||
window->context.destroy(window);
|
window->context.destroy(window);
|
||||||
|
|
||||||
if (_glfw.win32.disabledCursorWindow == window)
|
if (_glfw.win32.disabledCursorWindow == window)
|
||||||
_glfw.win32.disabledCursorWindow = NULL;
|
enableCursor(window);
|
||||||
|
|
||||||
|
if (_glfw.win32.capturedCursorWindow == window)
|
||||||
|
releaseCursor();
|
||||||
|
|
||||||
if (window->win32.handle)
|
if (window->win32.handle)
|
||||||
{
|
{
|
||||||
@ -1881,32 +1879,32 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowFocusedWin32(_GLFWwindow* window)
|
GLFWbool _glfwWindowFocusedWin32(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->win32.handle == GetActiveWindow();
|
return window->win32.handle == GetActiveWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowIconifiedWin32(_GLFWwindow* window)
|
GLFWbool _glfwWindowIconifiedWin32(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return IsIconic(window->win32.handle);
|
return IsIconic(window->win32.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowVisibleWin32(_GLFWwindow* window)
|
GLFWbool _glfwWindowVisibleWin32(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return IsWindowVisible(window->win32.handle);
|
return IsWindowVisible(window->win32.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowMaximizedWin32(_GLFWwindow* window)
|
GLFWbool _glfwWindowMaximizedWin32(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return IsZoomed(window->win32.handle);
|
return IsZoomed(window->win32.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowHoveredWin32(_GLFWwindow* window)
|
GLFWbool _glfwWindowHoveredWin32(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return cursorInContentArea(window);
|
return cursorInContentArea(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwFramebufferTransparentWin32(_GLFWwindow* window)
|
GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
BOOL composition, opaque;
|
BOOL composition, opaque;
|
||||||
DWORD color;
|
DWORD color;
|
||||||
@ -2162,14 +2160,40 @@ void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos)
|
|||||||
|
|
||||||
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode)
|
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode)
|
||||||
{
|
{
|
||||||
if (mode == GLFW_CURSOR_DISABLED)
|
if (_glfwWindowFocusedWin32(window))
|
||||||
{
|
{
|
||||||
if (_glfwWindowFocusedWin32(window))
|
if (mode == GLFW_CURSOR_DISABLED)
|
||||||
disableCursor(window);
|
{
|
||||||
|
_glfwGetCursorPosWin32(window,
|
||||||
|
&_glfw.win32.restoreCursorPosX,
|
||||||
|
&_glfw.win32.restoreCursorPosY);
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
if (window->rawMouseMotion)
|
||||||
|
enableRawMouseMotion(window);
|
||||||
|
}
|
||||||
|
else if (_glfw.win32.disabledCursorWindow == window)
|
||||||
|
{
|
||||||
|
if (window->rawMouseMotion)
|
||||||
|
disableRawMouseMotion(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == GLFW_CURSOR_DISABLED || mode == GLFW_CURSOR_CAPTURED)
|
||||||
|
captureCursor(window);
|
||||||
|
else
|
||||||
|
releaseCursor();
|
||||||
|
|
||||||
|
if (mode == GLFW_CURSOR_DISABLED)
|
||||||
|
_glfw.win32.disabledCursorWindow = window;
|
||||||
|
else if (_glfw.win32.disabledCursorWindow == window)
|
||||||
|
{
|
||||||
|
_glfw.win32.disabledCursorWindow = NULL;
|
||||||
|
_glfwSetCursorPosWin32(window,
|
||||||
|
_glfw.win32.restoreCursorPosX,
|
||||||
|
_glfw.win32.restoreCursorPosY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (_glfw.win32.disabledCursorWindow == window)
|
|
||||||
enableCursor(window);
|
if (cursorInContentArea(window))
|
||||||
else if (cursorInContentArea(window))
|
|
||||||
updateCursorImage(window);
|
updateCursorImage(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2190,9 +2214,9 @@ int _glfwGetKeyScancodeWin32(int key)
|
|||||||
return _glfw.win32.scancodes[key];
|
return _glfw.win32.scancodes[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateCursorWin32(_GLFWcursor* cursor,
|
GLFWbool _glfwCreateCursorWin32(_GLFWcursor* cursor,
|
||||||
const GLFWimage* image,
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
|
cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
|
||||||
if (!cursor->win32.handle)
|
if (!cursor->win32.handle)
|
||||||
@ -2201,7 +2225,7 @@ int _glfwCreateCursorWin32(_GLFWcursor* cursor,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape)
|
GLFWbool _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
@ -2409,9 +2433,9 @@ void _glfwGetRequiredInstanceExtensionsWin32(char** extensions)
|
|||||||
extensions[1] = "VK_KHR_win32_surface";
|
extensions[1] = "VK_KHR_win32_surface";
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance,
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance,
|
||||||
VkPhysicalDevice device,
|
VkPhysicalDevice device,
|
||||||
uint32_t queuefamily)
|
uint32_t queuefamily)
|
||||||
{
|
{
|
||||||
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
|
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
|
||||||
vkGetPhysicalDeviceWin32PresentationSupportKHR =
|
vkGetPhysicalDeviceWin32PresentationSupportKHR =
|
||||||
|
62
src/window.c
62
src/window.c
@ -44,6 +44,9 @@
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(focused == GLFW_TRUE || focused == GLFW_FALSE);
|
||||||
|
|
||||||
if (window->callbacks.focus)
|
if (window->callbacks.focus)
|
||||||
window->callbacks.focus((GLFWwindow*) window, focused);
|
window->callbacks.focus((GLFWwindow*) window, focused);
|
||||||
|
|
||||||
@ -73,6 +76,8 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
if (window->callbacks.pos)
|
if (window->callbacks.pos)
|
||||||
window->callbacks.pos((GLFWwindow*) window, x, y);
|
window->callbacks.pos((GLFWwindow*) window, x, y);
|
||||||
}
|
}
|
||||||
@ -82,6 +87,10 @@ void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
|
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(width >= 0);
|
||||||
|
assert(height >= 0);
|
||||||
|
|
||||||
if (window->callbacks.size)
|
if (window->callbacks.size)
|
||||||
window->callbacks.size((GLFWwindow*) window, width, height);
|
window->callbacks.size((GLFWwindow*) window, width, height);
|
||||||
}
|
}
|
||||||
@ -90,6 +99,9 @@ void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
|
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(iconified == GLFW_TRUE || iconified == GLFW_FALSE);
|
||||||
|
|
||||||
if (window->callbacks.iconify)
|
if (window->callbacks.iconify)
|
||||||
window->callbacks.iconify((GLFWwindow*) window, iconified);
|
window->callbacks.iconify((GLFWwindow*) window, iconified);
|
||||||
}
|
}
|
||||||
@ -98,6 +110,9 @@ void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
|
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(maximized == GLFW_TRUE || maximized == GLFW_FALSE);
|
||||||
|
|
||||||
if (window->callbacks.maximize)
|
if (window->callbacks.maximize)
|
||||||
window->callbacks.maximize((GLFWwindow*) window, maximized);
|
window->callbacks.maximize((GLFWwindow*) window, maximized);
|
||||||
}
|
}
|
||||||
@ -107,6 +122,10 @@ void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
|
|||||||
//
|
//
|
||||||
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(width >= 0);
|
||||||
|
assert(height >= 0);
|
||||||
|
|
||||||
if (window->callbacks.fbsize)
|
if (window->callbacks.fbsize)
|
||||||
window->callbacks.fbsize((GLFWwindow*) window, width, height);
|
window->callbacks.fbsize((GLFWwindow*) window, width, height);
|
||||||
}
|
}
|
||||||
@ -116,6 +135,12 @@ void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
|
void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
assert(xscale > 0.f);
|
||||||
|
assert(xscale < FLT_MAX);
|
||||||
|
assert(yscale > 0.f);
|
||||||
|
assert(yscale < FLT_MAX);
|
||||||
|
|
||||||
if (window->callbacks.scale)
|
if (window->callbacks.scale)
|
||||||
window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
|
window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
|
||||||
}
|
}
|
||||||
@ -124,6 +149,8 @@ void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscal
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowDamage(_GLFWwindow* window)
|
void _glfwInputWindowDamage(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
if (window->callbacks.refresh)
|
if (window->callbacks.refresh)
|
||||||
window->callbacks.refresh((GLFWwindow*) window);
|
window->callbacks.refresh((GLFWwindow*) window);
|
||||||
}
|
}
|
||||||
@ -132,6 +159,8 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
window->shouldClose = GLFW_TRUE;
|
window->shouldClose = GLFW_TRUE;
|
||||||
|
|
||||||
if (window->callbacks.close)
|
if (window->callbacks.close)
|
||||||
@ -142,6 +171,7 @@ void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
|
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
|
assert(window != NULL);
|
||||||
window->monitor = monitor;
|
window->monitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,40 +245,12 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
window->numer = GLFW_DONT_CARE;
|
window->numer = GLFW_DONT_CARE;
|
||||||
window->denom = GLFW_DONT_CARE;
|
window->denom = GLFW_DONT_CARE;
|
||||||
|
|
||||||
// Open the actual window and create its context
|
|
||||||
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig.client != GLFW_NO_API)
|
|
||||||
{
|
|
||||||
if (!_glfwRefreshContextAttribs(window, &ctxconfig))
|
|
||||||
{
|
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wndconfig.mousePassthrough)
|
|
||||||
_glfw.platform.setWindowMousePassthrough(window, GLFW_TRUE);
|
|
||||||
|
|
||||||
if (window->monitor)
|
|
||||||
{
|
|
||||||
if (wndconfig.centerCursor)
|
|
||||||
_glfwCenterCursorInContentArea(window);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (wndconfig.visible)
|
|
||||||
{
|
|
||||||
_glfw.platform.showWindow(window);
|
|
||||||
if (wndconfig.focused)
|
|
||||||
_glfw.platform.focusWindow(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (GLFWwindow*) window;
|
return (GLFWwindow*) window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,6 +447,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
|
|||||||
strncpy(_glfw.hints.window.x11.instanceName, value,
|
strncpy(_glfw.hints.window.x11.instanceName, value,
|
||||||
sizeof(_glfw.hints.window.x11.instanceName) - 1);
|
sizeof(_glfw.hints.window.x11.instanceName) - 1);
|
||||||
return;
|
return;
|
||||||
|
case GLFW_WAYLAND_APP_ID:
|
||||||
|
strncpy(_glfw.hints.window.wl.appId, value,
|
||||||
|
sizeof(_glfw.hints.window.wl.appId) - 1);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
|
||||||
|
121
src/wl_init.c
121
src/wl_init.c
@ -47,13 +47,38 @@
|
|||||||
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
||||||
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
|
// NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of
|
||||||
|
// wl_interface pointers 'types', making it impossible to combine several unmodified
|
||||||
|
// private-code files into a single compilation unit
|
||||||
|
// HACK: We override this name with a macro for each file, allowing them to coexist
|
||||||
|
|
||||||
|
#define types _glfw_wayland_types
|
||||||
#include "wayland-client-protocol-code.h"
|
#include "wayland-client-protocol-code.h"
|
||||||
|
#undef types
|
||||||
|
|
||||||
|
#define types _glfw_xdg_shell_types
|
||||||
#include "wayland-xdg-shell-client-protocol-code.h"
|
#include "wayland-xdg-shell-client-protocol-code.h"
|
||||||
|
#undef types
|
||||||
|
|
||||||
|
#define types _glfw_xdg_decoration_types
|
||||||
#include "wayland-xdg-decoration-client-protocol-code.h"
|
#include "wayland-xdg-decoration-client-protocol-code.h"
|
||||||
|
#undef types
|
||||||
|
|
||||||
|
#define types _glfw_viewporter_types
|
||||||
#include "wayland-viewporter-client-protocol-code.h"
|
#include "wayland-viewporter-client-protocol-code.h"
|
||||||
|
#undef types
|
||||||
|
|
||||||
|
#define types _glfw_relative_pointer_types
|
||||||
#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h"
|
#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h"
|
||||||
|
#undef types
|
||||||
|
|
||||||
|
#define types _glfw_pointer_constraints_types
|
||||||
#include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h"
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h"
|
||||||
|
#undef types
|
||||||
|
|
||||||
|
#define types _glfw_idle_inhibit_types
|
||||||
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
|
||||||
|
#undef types
|
||||||
|
|
||||||
static void wmBaseHandlePing(void* userData,
|
static void wmBaseHandlePing(void* userData,
|
||||||
struct xdg_wm_base* wmBase,
|
struct xdg_wm_base* wmBase,
|
||||||
@ -159,11 +184,9 @@ static void registryHandleGlobalRemove(void* userData,
|
|||||||
struct wl_registry* registry,
|
struct wl_registry* registry,
|
||||||
uint32_t name)
|
uint32_t name)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor;
|
|
||||||
|
|
||||||
for (int i = 0; i < _glfw.monitorCount; ++i)
|
for (int i = 0; i < _glfw.monitorCount; ++i)
|
||||||
{
|
{
|
||||||
monitor = _glfw.monitors[i];
|
_GLFWmonitor* monitor = _glfw.monitors[i];
|
||||||
if (monitor->wl.name == name)
|
if (monitor->wl.name == name)
|
||||||
{
|
{
|
||||||
_glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0);
|
_glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0);
|
||||||
@ -312,6 +335,38 @@ static void createKeyTables(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLFWbool loadCursorTheme(void)
|
||||||
|
{
|
||||||
|
int cursorSize = 32;
|
||||||
|
|
||||||
|
const char* sizeString = getenv("XCURSOR_SIZE");
|
||||||
|
if (sizeString)
|
||||||
|
{
|
||||||
|
errno = 0;
|
||||||
|
const long cursorSizeLong = strtol(sizeString, NULL, 10);
|
||||||
|
if (errno == 0 && cursorSizeLong > 0 && cursorSizeLong < INT_MAX)
|
||||||
|
cursorSize = (int) cursorSizeLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* themeName = getenv("XCURSOR_THEME");
|
||||||
|
|
||||||
|
_glfw.wl.cursorTheme = wl_cursor_theme_load(themeName, cursorSize, _glfw.wl.shm);
|
||||||
|
if (!_glfw.wl.cursorTheme)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Wayland: Failed to load default cursor theme");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this happens to be NULL, we just fallback to the scale=1 version.
|
||||||
|
_glfw.wl.cursorThemeHiDPI =
|
||||||
|
wl_cursor_theme_load(themeName, cursorSize * 2, _glfw.wl.shm);
|
||||||
|
|
||||||
|
_glfw.wl.cursorSurface = wl_compositor_create_surface(_glfw.wl.compositor);
|
||||||
|
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
@ -448,11 +503,9 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
|
|||||||
|
|
||||||
int _glfwInitWayland(void)
|
int _glfwInitWayland(void)
|
||||||
{
|
{
|
||||||
const char* cursorTheme;
|
// These must be set before any failure checks
|
||||||
const char* cursorSizeStr;
|
_glfw.wl.keyRepeatTimerfd = -1;
|
||||||
char* cursorSizeEnd;
|
_glfw.wl.cursorTimerfd = -1;
|
||||||
long cursorSizeLong;
|
|
||||||
int cursorSize;
|
|
||||||
|
|
||||||
_glfw.wl.client.display_flush = (PFN_wl_display_flush)
|
_glfw.wl.client.display_flush = (PFN_wl_display_flush)
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush");
|
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush");
|
||||||
@ -572,10 +625,10 @@ int _glfwInitWayland(void)
|
|||||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
|
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
|
||||||
_glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
|
_glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_update_mask");
|
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_update_mask");
|
||||||
_glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
|
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
|
|
||||||
_glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout)
|
_glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout)
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_layout");
|
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_layout");
|
||||||
|
_glfw.wl.xkb.state_mod_index_is_active = (PFN_xkb_state_mod_index_is_active)
|
||||||
|
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_mod_index_is_active");
|
||||||
_glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
|
_glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
|
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
|
||||||
_glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
|
_glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
|
||||||
@ -610,9 +663,13 @@ int _glfwInitWayland(void)
|
|||||||
// Sync so we got all initial output events
|
// Sync so we got all initial output events
|
||||||
wl_display_roundtrip(_glfw.wl.display);
|
wl_display_roundtrip(_glfw.wl.display);
|
||||||
|
|
||||||
_glfw.wl.timerfd = -1;
|
#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
|
||||||
if (_glfw.wl.seatVersion >= 4)
|
if (_glfw.wl.seatVersion >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
|
||||||
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
{
|
||||||
|
_glfw.wl.keyRepeatTimerfd =
|
||||||
|
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!_glfw.wl.wmBase)
|
if (!_glfw.wl.wmBase)
|
||||||
{
|
{
|
||||||
@ -621,34 +678,16 @@ int _glfwInitWayland(void)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.wl.pointer && _glfw.wl.shm)
|
if (!_glfw.wl.shm)
|
||||||
{
|
{
|
||||||
cursorTheme = getenv("XCURSOR_THEME");
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
cursorSizeStr = getenv("XCURSOR_SIZE");
|
"Wayland: Failed to find wl_shm in your compositor");
|
||||||
cursorSize = 32;
|
return GLFW_FALSE;
|
||||||
if (cursorSizeStr)
|
|
||||||
{
|
|
||||||
errno = 0;
|
|
||||||
cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10);
|
|
||||||
if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX)
|
|
||||||
cursorSize = (int)cursorSizeLong;
|
|
||||||
}
|
|
||||||
_glfw.wl.cursorTheme =
|
|
||||||
wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm);
|
|
||||||
if (!_glfw.wl.cursorTheme)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Wayland: Failed to load default cursor theme");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
// If this happens to be NULL, we just fallback to the scale=1 version.
|
|
||||||
_glfw.wl.cursorThemeHiDPI =
|
|
||||||
wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
|
|
||||||
_glfw.wl.cursorSurface =
|
|
||||||
wl_compositor_create_surface(_glfw.wl.compositor);
|
|
||||||
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!loadCursorTheme())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
|
if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
|
||||||
{
|
{
|
||||||
_glfw.wl.dataDevice =
|
_glfw.wl.dataDevice =
|
||||||
@ -663,6 +702,8 @@ int _glfwInitWayland(void)
|
|||||||
void _glfwTerminateWayland(void)
|
void _glfwTerminateWayland(void)
|
||||||
{
|
{
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
|
_glfwTerminateOSMesa();
|
||||||
|
|
||||||
if (_glfw.wl.egl.handle)
|
if (_glfw.wl.egl.handle)
|
||||||
{
|
{
|
||||||
_glfwPlatformFreeModule(_glfw.wl.egl.handle);
|
_glfwPlatformFreeModule(_glfw.wl.egl.handle);
|
||||||
@ -742,8 +783,8 @@ void _glfwTerminateWayland(void)
|
|||||||
wl_display_disconnect(_glfw.wl.display);
|
wl_display_disconnect(_glfw.wl.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.wl.timerfd >= 0)
|
if (_glfw.wl.keyRepeatTimerfd >= 0)
|
||||||
close(_glfw.wl.timerfd);
|
close(_glfw.wl.keyRepeatTimerfd);
|
||||||
if (_glfw.wl.cursorTimerfd >= 0)
|
if (_glfw.wl.cursorTimerfd >= 0)
|
||||||
close(_glfw.wl.cursorTimerfd);
|
close(_glfw.wl.cursorTimerfd);
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ static void outputHandleGeometry(void* userData,
|
|||||||
monitor->widthMM = physicalWidth;
|
monitor->widthMM = physicalWidth;
|
||||||
monitor->heightMM = physicalHeight;
|
monitor->heightMM = physicalHeight;
|
||||||
|
|
||||||
snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
|
if (strlen(monitor->name) == 0)
|
||||||
|
snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void outputHandleMode(void* userData,
|
static void outputHandleMode(void* userData,
|
||||||
@ -96,6 +97,12 @@ static void outputHandleDone(void* userData, struct wl_output* output)
|
|||||||
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
|
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _glfw.monitorCount; i++)
|
||||||
|
{
|
||||||
|
if (_glfw.monitors[i] == monitor)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,14 +113,47 @@ static void outputHandleScale(void* userData,
|
|||||||
struct _GLFWmonitor* monitor = userData;
|
struct _GLFWmonitor* monitor = userData;
|
||||||
|
|
||||||
monitor->wl.scale = factor;
|
monitor->wl.scale = factor;
|
||||||
|
|
||||||
|
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < window->wl.monitorsCount; i++)
|
||||||
|
{
|
||||||
|
if (window->wl.monitors[i] == monitor)
|
||||||
|
{
|
||||||
|
_glfwUpdateContentScaleWayland(window);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
||||||
|
|
||||||
|
void outputHandleName(void* userData, struct wl_output* wl_output, const char* name)
|
||||||
|
{
|
||||||
|
struct _GLFWmonitor* monitor = userData;
|
||||||
|
|
||||||
|
strncpy(monitor->name, name, sizeof(monitor->name) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void outputHandleDescription(void* userData,
|
||||||
|
struct wl_output* wl_output,
|
||||||
|
const char* description)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // WL_OUTPUT_NAME_SINCE_VERSION
|
||||||
|
|
||||||
static const struct wl_output_listener outputListener =
|
static const struct wl_output_listener outputListener =
|
||||||
{
|
{
|
||||||
outputHandleGeometry,
|
outputHandleGeometry,
|
||||||
outputHandleMode,
|
outputHandleMode,
|
||||||
outputHandleDone,
|
outputHandleDone,
|
||||||
outputHandleScale,
|
outputHandleScale,
|
||||||
|
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
||||||
|
outputHandleName,
|
||||||
|
outputHandleDescription,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -123,9 +163,6 @@ static const struct wl_output_listener outputListener =
|
|||||||
|
|
||||||
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor;
|
|
||||||
struct wl_output* output;
|
|
||||||
|
|
||||||
if (version < 2)
|
if (version < 2)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
@ -133,19 +170,21 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The actual name of this output will be set in the geometry handler.
|
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
||||||
monitor = _glfwAllocMonitor("", 0, 0);
|
version = _glfw_min(version, WL_OUTPUT_NAME_SINCE_VERSION);
|
||||||
|
#else
|
||||||
|
version = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
output = wl_registry_bind(_glfw.wl.registry,
|
struct wl_output* output = wl_registry_bind(_glfw.wl.registry,
|
||||||
name,
|
name,
|
||||||
&wl_output_interface,
|
&wl_output_interface,
|
||||||
2);
|
version);
|
||||||
if (!output)
|
if (!output)
|
||||||
{
|
|
||||||
_glfwFreeMonitor(monitor);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
// The actual name of this output will be set in the geometry handler
|
||||||
|
_GLFWmonitor* monitor = _glfwAllocMonitor("", 0, 0);
|
||||||
monitor->wl.scale = 1;
|
monitor->wl.scale = 1;
|
||||||
monitor->wl.output = output;
|
monitor->wl.output = output;
|
||||||
monitor->wl.name = name;
|
monitor->wl.name = name;
|
||||||
|
@ -167,8 +167,8 @@ typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
|
|||||||
typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
|
typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
|
||||||
typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
|
typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
|
||||||
typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
|
typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
|
||||||
typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
|
|
||||||
typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t);
|
typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t);
|
||||||
|
typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_index_t,enum xkb_state_component);
|
||||||
#define xkb_context_new _glfw.wl.xkb.context_new
|
#define xkb_context_new _glfw.wl.xkb.context_new
|
||||||
#define xkb_context_unref _glfw.wl.xkb.context_unref
|
#define xkb_context_unref _glfw.wl.xkb.context_unref
|
||||||
#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
|
#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
|
||||||
@ -180,8 +180,8 @@ typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xk
|
|||||||
#define xkb_state_unref _glfw.wl.xkb.state_unref
|
#define xkb_state_unref _glfw.wl.xkb.state_unref
|
||||||
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
|
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
|
||||||
#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
|
#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
|
||||||
#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
|
|
||||||
#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout
|
#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout
|
||||||
|
#define xkb_state_mod_index_is_active _glfw.wl.xkb.state_mod_index_is_active
|
||||||
|
|
||||||
typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
|
typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
|
||||||
typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
|
typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
|
||||||
@ -198,11 +198,6 @@ typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_st
|
|||||||
#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
|
#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
|
||||||
#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
|
#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
|
||||||
|
|
||||||
#define _GLFW_DECORATION_WIDTH 4
|
|
||||||
#define _GLFW_DECORATION_TOP 24
|
|
||||||
#define _GLFW_DECORATION_VERTICAL (_GLFW_DECORATION_TOP + _GLFW_DECORATION_WIDTH)
|
|
||||||
#define _GLFW_DECORATION_HORIZONTAL (2 * _GLFW_DECORATION_WIDTH)
|
|
||||||
|
|
||||||
typedef enum _GLFWdecorationSideWayland
|
typedef enum _GLFWdecorationSideWayland
|
||||||
{
|
{
|
||||||
mainWindow,
|
mainWindow,
|
||||||
@ -233,22 +228,37 @@ typedef struct _GLFWwindowWayland
|
|||||||
int width, height;
|
int width, height;
|
||||||
GLFWbool visible;
|
GLFWbool visible;
|
||||||
GLFWbool maximized;
|
GLFWbool maximized;
|
||||||
|
GLFWbool activated;
|
||||||
|
GLFWbool fullscreen;
|
||||||
GLFWbool hovered;
|
GLFWbool hovered;
|
||||||
GLFWbool transparent;
|
GLFWbool transparent;
|
||||||
struct wl_surface* surface;
|
struct wl_surface* surface;
|
||||||
struct wl_egl_window* native;
|
|
||||||
struct wl_callback* callback;
|
struct wl_callback* callback;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct wl_egl_window* window;
|
||||||
|
} egl;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int width, height;
|
||||||
|
GLFWbool maximized;
|
||||||
|
GLFWbool iconified;
|
||||||
|
GLFWbool activated;
|
||||||
|
GLFWbool fullscreen;
|
||||||
|
} pending;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct xdg_surface* surface;
|
struct xdg_surface* surface;
|
||||||
struct xdg_toplevel* toplevel;
|
struct xdg_toplevel* toplevel;
|
||||||
struct zxdg_toplevel_decoration_v1* decoration;
|
struct zxdg_toplevel_decoration_v1* decoration;
|
||||||
|
uint32_t decorationMode;
|
||||||
} xdg;
|
} xdg;
|
||||||
|
|
||||||
_GLFWcursor* currentCursor;
|
_GLFWcursor* currentCursor;
|
||||||
double cursorPosX, cursorPosY;
|
double cursorPosX, cursorPosY;
|
||||||
|
|
||||||
char* title;
|
char* title;
|
||||||
|
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.
|
||||||
@ -257,20 +267,16 @@ typedef struct _GLFWwindowWayland
|
|||||||
int monitorsCount;
|
int monitorsCount;
|
||||||
int monitorsSize;
|
int monitorsSize;
|
||||||
|
|
||||||
struct {
|
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;
|
||||||
} pointerLock;
|
|
||||||
|
|
||||||
struct zwp_idle_inhibitor_v1* idleInhibitor;
|
struct zwp_idle_inhibitor_v1* idleInhibitor;
|
||||||
|
|
||||||
GLFWbool wasFullscreen;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GLFWbool serverSide;
|
|
||||||
struct wl_buffer* buffer;
|
struct wl_buffer* buffer;
|
||||||
_GLFWdecorationWayland top, left, right, bottom;
|
_GLFWdecorationWayland top, left, right, bottom;
|
||||||
int focus;
|
_GLFWdecorationSideWayland focus;
|
||||||
} decorations;
|
} decorations;
|
||||||
} _GLFWwindowWayland;
|
} _GLFWwindowWayland;
|
||||||
|
|
||||||
@ -316,12 +322,12 @@ typedef struct _GLFWlibraryWayland
|
|||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
uint32_t pointerEnterSerial;
|
uint32_t pointerEnterSerial;
|
||||||
|
|
||||||
int32_t keyboardRepeatRate;
|
int keyRepeatTimerfd;
|
||||||
int32_t keyboardRepeatDelay;
|
int32_t keyRepeatRate;
|
||||||
int keyboardLastKey;
|
int32_t keyRepeatDelay;
|
||||||
int keyboardLastScancode;
|
int keyRepeatScancode;
|
||||||
|
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
int timerfd;
|
|
||||||
short int keycodes[256];
|
short int keycodes[256];
|
||||||
short int scancodes[GLFW_KEY_LAST + 1];
|
short int scancodes[GLFW_KEY_LAST + 1];
|
||||||
char keynames[GLFW_KEY_LAST + 1][5];
|
char keynames[GLFW_KEY_LAST + 1][5];
|
||||||
@ -334,12 +340,12 @@ typedef struct _GLFWlibraryWayland
|
|||||||
|
|
||||||
struct xkb_compose_state* composeState;
|
struct xkb_compose_state* composeState;
|
||||||
|
|
||||||
xkb_mod_mask_t controlMask;
|
xkb_mod_index_t controlIndex;
|
||||||
xkb_mod_mask_t altMask;
|
xkb_mod_index_t altIndex;
|
||||||
xkb_mod_mask_t shiftMask;
|
xkb_mod_index_t shiftIndex;
|
||||||
xkb_mod_mask_t superMask;
|
xkb_mod_index_t superIndex;
|
||||||
xkb_mod_mask_t capsLockMask;
|
xkb_mod_index_t capsLockIndex;
|
||||||
xkb_mod_mask_t numLockMask;
|
xkb_mod_index_t numLockIndex;
|
||||||
unsigned int modifiers;
|
unsigned int modifiers;
|
||||||
|
|
||||||
PFN_xkb_context_new context_new;
|
PFN_xkb_context_new context_new;
|
||||||
@ -353,8 +359,8 @@ typedef struct _GLFWlibraryWayland
|
|||||||
PFN_xkb_state_unref state_unref;
|
PFN_xkb_state_unref state_unref;
|
||||||
PFN_xkb_state_key_get_syms state_key_get_syms;
|
PFN_xkb_state_key_get_syms state_key_get_syms;
|
||||||
PFN_xkb_state_update_mask state_update_mask;
|
PFN_xkb_state_update_mask state_update_mask;
|
||||||
PFN_xkb_state_serialize_mods state_serialize_mods;
|
|
||||||
PFN_xkb_state_key_get_layout state_key_get_layout;
|
PFN_xkb_state_key_get_layout state_key_get_layout;
|
||||||
|
PFN_xkb_state_mod_index_is_active state_mod_index_is_active;
|
||||||
|
|
||||||
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
|
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
|
||||||
PFN_xkb_compose_table_unref compose_table_unref;
|
PFN_xkb_compose_table_unref compose_table_unref;
|
||||||
@ -436,7 +442,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform);
|
|||||||
int _glfwInitWayland(void);
|
int _glfwInitWayland(void);
|
||||||
void _glfwTerminateWayland(void);
|
void _glfwTerminateWayland(void);
|
||||||
|
|
||||||
int _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
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);
|
||||||
@ -457,12 +463,12 @@ void _glfwHideWindowWayland(_GLFWwindow* window);
|
|||||||
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowWayland(_GLFWwindow* window);
|
void _glfwFocusWindowWayland(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
int _glfwWindowFocusedWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedWayland(_GLFWwindow* window);
|
||||||
int _glfwWindowIconifiedWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedWayland(_GLFWwindow* window);
|
||||||
int _glfwWindowVisibleWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleWayland(_GLFWwindow* window);
|
||||||
int _glfwWindowMaximizedWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowMaximizedWayland(_GLFWwindow* window);
|
||||||
int _glfwWindowHoveredWayland(_GLFWwindow* window);
|
GLFWbool _glfwWindowHoveredWayland(_GLFWwindow* window);
|
||||||
int _glfwFramebufferTransparentWayland(_GLFWwindow* window);
|
GLFWbool _glfwFramebufferTransparentWayland(_GLFWwindow* window);
|
||||||
void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
@ -483,8 +489,8 @@ void _glfwSetCursorPosWayland(_GLFWwindow* window, double xpos, double ypos);
|
|||||||
void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode);
|
void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode);
|
||||||
const char* _glfwGetScancodeNameWayland(int scancode);
|
const char* _glfwGetScancodeNameWayland(int scancode);
|
||||||
int _glfwGetKeyScancodeWayland(int key);
|
int _glfwGetKeyScancodeWayland(int key);
|
||||||
int _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
GLFWbool _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
int _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape);
|
GLFWbool _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape);
|
||||||
void _glfwDestroyCursorWayland(_GLFWcursor* cursor);
|
void _glfwDestroyCursorWayland(_GLFWcursor* cursor);
|
||||||
void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor);
|
void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
void _glfwSetClipboardStringWayland(const char* string);
|
void _glfwSetClipboardStringWayland(const char* string);
|
||||||
@ -495,7 +501,7 @@ EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void);
|
|||||||
EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window);
|
EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwGetRequiredInstanceExtensionsWayland(char** extensions);
|
void _glfwGetRequiredInstanceExtensionsWayland(char** extensions);
|
||||||
int _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
void _glfwFreeMonitorWayland(_GLFWmonitor* monitor);
|
void _glfwFreeMonitorWayland(_GLFWmonitor* monitor);
|
||||||
@ -508,7 +514,7 @@ 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);
|
||||||
GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode);
|
void _glfwUpdateContentScaleWayland(_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);
|
||||||
|
1062
src/wl_window.c
1062
src/wl_window.c
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
// Translate the X11 KeySyms for a key to a GLFW key code
|
// Translate the X11 KeySyms for a key to a GLFW key code
|
||||||
@ -1095,8 +1096,9 @@ static int errorHandler(Display *display, XErrorEvent* event)
|
|||||||
//
|
//
|
||||||
void _glfwGrabErrorHandlerX11(void)
|
void _glfwGrabErrorHandlerX11(void)
|
||||||
{
|
{
|
||||||
|
assert(_glfw.x11.errorHandler == NULL);
|
||||||
_glfw.x11.errorCode = Success;
|
_glfw.x11.errorCode = Success;
|
||||||
XSetErrorHandler(errorHandler);
|
_glfw.x11.errorHandler = XSetErrorHandler(errorHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears the X error handler callback
|
// Clears the X error handler callback
|
||||||
@ -1105,7 +1107,8 @@ void _glfwReleaseErrorHandlerX11(void)
|
|||||||
{
|
{
|
||||||
// Synchronize to make sure all commands are processed
|
// Synchronize to make sure all commands are processed
|
||||||
XSync(_glfw.x11.display, False);
|
XSync(_glfw.x11.display, False);
|
||||||
XSetErrorHandler(NULL);
|
XSetErrorHandler(_glfw.x11.errorHandler);
|
||||||
|
_glfw.x11.errorHandler = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reports the specified error, appending information about the last X error
|
// Reports the specified error, appending information about the last X error
|
||||||
@ -1630,6 +1633,7 @@ void _glfwTerminateX11(void)
|
|||||||
_glfw.x11.xi.handle = NULL;
|
_glfw.x11.xi.handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfwTerminateOSMesa();
|
||||||
// NOTE: These need to be unloaded after XCloseDisplay, as they register
|
// NOTE: These need to be unloaded after XCloseDisplay, as they register
|
||||||
// cleanup callbacks that get called by that function
|
// cleanup callbacks that get called by that function
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
|
@ -567,6 +567,8 @@ typedef struct _GLFWlibraryX11
|
|||||||
XContext context;
|
XContext context;
|
||||||
// XIM input method
|
// XIM input method
|
||||||
XIM im;
|
XIM im;
|
||||||
|
// The previous X error handler, to be restored later
|
||||||
|
XErrorHandler errorHandler;
|
||||||
// Most recent error code received by X error handler
|
// Most recent error code received by X error handler
|
||||||
int errorCode;
|
int errorCode;
|
||||||
// Primary selection string (while the primary selection is owned)
|
// Primary selection string (while the primary selection is owned)
|
||||||
@ -900,7 +902,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform);
|
|||||||
int _glfwInitX11(void);
|
int _glfwInitX11(void);
|
||||||
void _glfwTerminateX11(void);
|
void _glfwTerminateX11(void);
|
||||||
|
|
||||||
int _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
GLFWbool _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
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);
|
||||||
@ -921,12 +923,12 @@ void _glfwHideWindowX11(_GLFWwindow* window);
|
|||||||
void _glfwRequestWindowAttentionX11(_GLFWwindow* window);
|
void _glfwRequestWindowAttentionX11(_GLFWwindow* window);
|
||||||
void _glfwFocusWindowX11(_GLFWwindow* window);
|
void _glfwFocusWindowX11(_GLFWwindow* window);
|
||||||
void _glfwSetWindowMonitorX11(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwSetWindowMonitorX11(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
int _glfwWindowFocusedX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowFocusedX11(_GLFWwindow* window);
|
||||||
int _glfwWindowIconifiedX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowIconifiedX11(_GLFWwindow* window);
|
||||||
int _glfwWindowVisibleX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowVisibleX11(_GLFWwindow* window);
|
||||||
int _glfwWindowMaximizedX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowMaximizedX11(_GLFWwindow* window);
|
||||||
int _glfwWindowHoveredX11(_GLFWwindow* window);
|
GLFWbool _glfwWindowHoveredX11(_GLFWwindow* window);
|
||||||
int _glfwFramebufferTransparentX11(_GLFWwindow* window);
|
GLFWbool _glfwFramebufferTransparentX11(_GLFWwindow* window);
|
||||||
void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled);
|
||||||
void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled);
|
||||||
@ -947,8 +949,8 @@ void _glfwSetCursorPosX11(_GLFWwindow* window, double xpos, double ypos);
|
|||||||
void _glfwSetCursorModeX11(_GLFWwindow* window, int mode);
|
void _glfwSetCursorModeX11(_GLFWwindow* window, int mode);
|
||||||
const char* _glfwGetScancodeNameX11(int scancode);
|
const char* _glfwGetScancodeNameX11(int scancode);
|
||||||
int _glfwGetKeyScancodeX11(int key);
|
int _glfwGetKeyScancodeX11(int key);
|
||||||
int _glfwCreateCursorX11(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
GLFWbool _glfwCreateCursorX11(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
int _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape);
|
GLFWbool _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape);
|
||||||
void _glfwDestroyCursorX11(_GLFWcursor* cursor);
|
void _glfwDestroyCursorX11(_GLFWcursor* cursor);
|
||||||
void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor);
|
void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
void _glfwSetClipboardStringX11(const char* string);
|
void _glfwSetClipboardStringX11(const char* string);
|
||||||
@ -959,7 +961,7 @@ EGLNativeDisplayType _glfwGetEGLNativeDisplayX11(void);
|
|||||||
EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window);
|
EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwGetRequiredInstanceExtensionsX11(char** extensions);
|
void _glfwGetRequiredInstanceExtensionsX11(char** extensions);
|
||||||
int _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
void _glfwFreeMonitorX11(_GLFWmonitor* monitor);
|
void _glfwFreeMonitorX11(_GLFWmonitor* monitor);
|
||||||
|
170
src/x11_window.c
170
src/x11_window.c
@ -453,7 +453,8 @@ static char* convertLatin1toUTF8(const char* source)
|
|||||||
//
|
//
|
||||||
static void updateCursorImage(_GLFWwindow* window)
|
static void updateCursorImage(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
if (window->cursorMode == GLFW_CURSOR_NORMAL ||
|
||||||
|
window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
if (window->cursor)
|
if (window->cursor)
|
||||||
{
|
{
|
||||||
@ -470,6 +471,25 @@ static void updateCursorImage(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grabs the cursor and confines it to the window
|
||||||
|
//
|
||||||
|
static void captureCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
XGrabPointer(_glfw.x11.display, window->x11.handle, True,
|
||||||
|
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
|
||||||
|
GrabModeAsync, GrabModeAsync,
|
||||||
|
window->x11.handle,
|
||||||
|
None,
|
||||||
|
CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ungrabs the cursor
|
||||||
|
//
|
||||||
|
static void releaseCursor(void)
|
||||||
|
{
|
||||||
|
XUngrabPointer(_glfw.x11.display, CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
// Enable XI2 raw mouse motion events
|
// Enable XI2 raw mouse motion events
|
||||||
//
|
//
|
||||||
static void enableRawMouseMotion(_GLFWwindow* window)
|
static void enableRawMouseMotion(_GLFWwindow* window)
|
||||||
@ -512,12 +532,7 @@ static void disableCursor(_GLFWwindow* window)
|
|||||||
&_glfw.x11.restoreCursorPosY);
|
&_glfw.x11.restoreCursorPosY);
|
||||||
updateCursorImage(window);
|
updateCursorImage(window);
|
||||||
_glfwCenterCursorInContentArea(window);
|
_glfwCenterCursorInContentArea(window);
|
||||||
XGrabPointer(_glfw.x11.display, window->x11.handle, True,
|
captureCursor(window);
|
||||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
|
|
||||||
GrabModeAsync, GrabModeAsync,
|
|
||||||
window->x11.handle,
|
|
||||||
_glfw.x11.hiddenCursorHandle,
|
|
||||||
CurrentTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit disabled cursor mode for the specified window
|
// Exit disabled cursor mode for the specified window
|
||||||
@ -528,7 +543,7 @@ static void enableCursor(_GLFWwindow* window)
|
|||||||
disableRawMouseMotion(window);
|
disableRawMouseMotion(window);
|
||||||
|
|
||||||
_glfw.x11.disabledCursorWindow = NULL;
|
_glfw.x11.disabledCursorWindow = NULL;
|
||||||
XUngrabPointer(_glfw.x11.display, CurrentTime);
|
releaseCursor();
|
||||||
_glfwSetCursorPosX11(window,
|
_glfwSetCursorPosX11(window,
|
||||||
_glfw.x11.restoreCursorPosX,
|
_glfw.x11.restoreCursorPosX,
|
||||||
_glfw.x11.restoreCursorPosY);
|
_glfw.x11.restoreCursorPosY);
|
||||||
@ -865,20 +880,6 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleSelectionClear(XEvent* event)
|
|
||||||
{
|
|
||||||
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
|
||||||
{
|
|
||||||
_glfw_free(_glfw.x11.primarySelectionString);
|
|
||||||
_glfw.x11.primarySelectionString = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_glfw_free(_glfw.x11.clipboardString);
|
|
||||||
_glfw.x11.clipboardString = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handleSelectionRequest(XEvent* event)
|
static void handleSelectionRequest(XEvent* event)
|
||||||
{
|
{
|
||||||
const XSelectionRequestEvent* request = &event->xselectionrequest;
|
const XSelectionRequestEvent* request = &event->xselectionrequest;
|
||||||
@ -999,13 +1000,16 @@ static const char* getSelectionString(Atom selection)
|
|||||||
|
|
||||||
if (!itemCount)
|
if (!itemCount)
|
||||||
{
|
{
|
||||||
if (targets[i] == XA_STRING)
|
if (string)
|
||||||
{
|
{
|
||||||
*selectionString = convertLatin1toUTF8(string);
|
if (targets[i] == XA_STRING)
|
||||||
_glfw_free(string);
|
{
|
||||||
|
*selectionString = convertLatin1toUTF8(string);
|
||||||
|
_glfw_free(string);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*selectionString = string;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
*selectionString = string;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1171,12 +1175,7 @@ static void processEvent(XEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->type == SelectionClear)
|
if (event->type == SelectionRequest)
|
||||||
{
|
|
||||||
handleSelectionClear(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (event->type == SelectionRequest)
|
|
||||||
{
|
{
|
||||||
handleSelectionRequest(event);
|
handleSelectionRequest(event);
|
||||||
return;
|
return;
|
||||||
@ -1707,6 +1706,8 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
disableCursor(window);
|
disableCursor(window);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
captureCursor(window);
|
||||||
|
|
||||||
if (window->x11.ic)
|
if (window->x11.ic)
|
||||||
XSetICFocus(window->x11.ic);
|
XSetICFocus(window->x11.ic);
|
||||||
@ -1727,6 +1728,8 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
enableCursor(window);
|
enableCursor(window);
|
||||||
|
else if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
releaseCursor();
|
||||||
|
|
||||||
if (window->x11.ic)
|
if (window->x11.ic)
|
||||||
XUnsetICFocus(window->x11.ic);
|
XUnsetICFocus(window->x11.ic);
|
||||||
@ -1853,10 +1856,6 @@ void _glfwPushSelectionToManagerX11(void)
|
|||||||
handleSelectionRequest(&event);
|
handleSelectionRequest(&event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionClear:
|
|
||||||
handleSelectionClear(&event);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SelectionNotify:
|
case SelectionNotify:
|
||||||
{
|
{
|
||||||
if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
|
if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
|
||||||
@ -1915,10 +1914,10 @@ void _glfwCreateInputContextX11(_GLFWwindow* window)
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwCreateWindowX11(_GLFWwindow* window,
|
GLFWbool _glfwCreateWindowX11(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
Visual* visual = NULL;
|
Visual* visual = NULL;
|
||||||
int depth;
|
int depth;
|
||||||
@ -1972,13 +1971,31 @@ int _glfwCreateWindowX11(_GLFWwindow* window,
|
|||||||
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughX11(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
_glfwShowWindowX11(window);
|
_glfwShowWindowX11(window);
|
||||||
updateWindowMode(window);
|
updateWindowMode(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
|
||||||
|
if (wndconfig->centerCursor)
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->visible)
|
||||||
|
{
|
||||||
|
_glfwShowWindowX11(window);
|
||||||
|
if (wndconfig->focused)
|
||||||
|
_glfwFocusWindowX11(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
@ -1988,7 +2005,7 @@ int _glfwCreateWindowX11(_GLFWwindow* window,
|
|||||||
void _glfwDestroyWindowX11(_GLFWwindow* window)
|
void _glfwDestroyWindowX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.disabledCursorWindow == window)
|
if (_glfw.x11.disabledCursorWindow == window)
|
||||||
_glfw.x11.disabledCursorWindow = NULL;
|
enableCursor(window);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
releaseMonitor(window);
|
releaseMonitor(window);
|
||||||
@ -2464,7 +2481,7 @@ void _glfwSetWindowMonitorX11(_GLFWwindow* window,
|
|||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowFocusedX11(_GLFWwindow* window)
|
GLFWbool _glfwWindowFocusedX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
Window focused;
|
Window focused;
|
||||||
int state;
|
int state;
|
||||||
@ -2473,19 +2490,19 @@ int _glfwWindowFocusedX11(_GLFWwindow* window)
|
|||||||
return window->x11.handle == focused;
|
return window->x11.handle == focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowIconifiedX11(_GLFWwindow* window)
|
GLFWbool _glfwWindowIconifiedX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return getWindowState(window) == IconicState;
|
return getWindowState(window) == IconicState;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowVisibleX11(_GLFWwindow* window)
|
GLFWbool _glfwWindowVisibleX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);
|
XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);
|
||||||
return wa.map_state == IsViewable;
|
return wa.map_state == IsViewable;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowMaximizedX11(_GLFWwindow* window)
|
GLFWbool _glfwWindowMaximizedX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
Atom* states;
|
Atom* states;
|
||||||
GLFWbool maximized = GLFW_FALSE;
|
GLFWbool maximized = GLFW_FALSE;
|
||||||
@ -2519,7 +2536,7 @@ int _glfwWindowMaximizedX11(_GLFWwindow* window)
|
|||||||
return maximized;
|
return maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwWindowHoveredX11(_GLFWwindow* window)
|
GLFWbool _glfwWindowHoveredX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
Window w = _glfw.x11.root;
|
Window w = _glfw.x11.root;
|
||||||
while (w)
|
while (w)
|
||||||
@ -2547,7 +2564,7 @@ int _glfwWindowHoveredX11(_GLFWwindow* window)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwFramebufferTransparentX11(_GLFWwindow* window)
|
GLFWbool _glfwFramebufferTransparentX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (!window->x11.transparent)
|
if (!window->x11.transparent)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -2802,16 +2819,40 @@ void _glfwSetCursorPosX11(_GLFWwindow* window, double x, double y)
|
|||||||
|
|
||||||
void _glfwSetCursorModeX11(_GLFWwindow* window, int mode)
|
void _glfwSetCursorModeX11(_GLFWwindow* window, int mode)
|
||||||
{
|
{
|
||||||
if (mode == GLFW_CURSOR_DISABLED)
|
if (_glfwWindowFocusedX11(window))
|
||||||
{
|
{
|
||||||
if (_glfwWindowFocusedX11(window))
|
if (mode == GLFW_CURSOR_DISABLED)
|
||||||
disableCursor(window);
|
{
|
||||||
}
|
_glfwGetCursorPosX11(window,
|
||||||
else if (_glfw.x11.disabledCursorWindow == window)
|
&_glfw.x11.restoreCursorPosX,
|
||||||
enableCursor(window);
|
&_glfw.x11.restoreCursorPosY);
|
||||||
else
|
_glfwCenterCursorInContentArea(window);
|
||||||
updateCursorImage(window);
|
if (window->rawMouseMotion)
|
||||||
|
enableRawMouseMotion(window);
|
||||||
|
}
|
||||||
|
else if (_glfw.x11.disabledCursorWindow == window)
|
||||||
|
{
|
||||||
|
if (window->rawMouseMotion)
|
||||||
|
disableRawMouseMotion(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == GLFW_CURSOR_DISABLED || mode == GLFW_CURSOR_CAPTURED)
|
||||||
|
captureCursor(window);
|
||||||
|
else
|
||||||
|
releaseCursor();
|
||||||
|
|
||||||
|
if (mode == GLFW_CURSOR_DISABLED)
|
||||||
|
_glfw.x11.disabledCursorWindow = window;
|
||||||
|
else if (_glfw.x11.disabledCursorWindow == window)
|
||||||
|
{
|
||||||
|
_glfw.x11.disabledCursorWindow = NULL;
|
||||||
|
_glfwSetCursorPosX11(window,
|
||||||
|
_glfw.x11.restoreCursorPosX,
|
||||||
|
_glfw.x11.restoreCursorPosY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCursorImage(window);
|
||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2850,9 +2891,9 @@ int _glfwGetKeyScancodeX11(int key)
|
|||||||
return _glfw.x11.scancodes[key];
|
return _glfw.x11.scancodes[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateCursorX11(_GLFWcursor* cursor,
|
GLFWbool _glfwCreateCursorX11(_GLFWcursor* cursor,
|
||||||
const GLFWimage* image,
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
cursor->x11.handle = _glfwCreateNativeCursorX11(image, xhot, yhot);
|
cursor->x11.handle = _glfwCreateNativeCursorX11(image, xhot, yhot);
|
||||||
if (!cursor->x11.handle)
|
if (!cursor->x11.handle)
|
||||||
@ -2861,7 +2902,7 @@ int _glfwCreateCursorX11(_GLFWcursor* cursor,
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape)
|
GLFWbool _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.xcursor.handle)
|
if (_glfw.x11.xcursor.handle)
|
||||||
{
|
{
|
||||||
@ -2967,7 +3008,8 @@ void _glfwDestroyCursorX11(_GLFWcursor* cursor)
|
|||||||
|
|
||||||
void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor)
|
void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
if (window->cursorMode == GLFW_CURSOR_NORMAL ||
|
||||||
|
window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
updateCursorImage(window);
|
updateCursorImage(window);
|
||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
@ -3068,9 +3110,9 @@ void _glfwGetRequiredInstanceExtensionsX11(char** extensions)
|
|||||||
extensions[1] = "VK_KHR_xlib_surface";
|
extensions[1] = "VK_KHR_xlib_surface";
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance,
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance,
|
||||||
VkPhysicalDevice device,
|
VkPhysicalDevice device,
|
||||||
uint32_t queuefamily)
|
uint32_t queuefamily)
|
||||||
{
|
{
|
||||||
VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
|
VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
|
||||||
_glfw.x11.screen));
|
_glfw.x11.screen));
|
||||||
|
@ -172,7 +172,8 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
|
|
||||||
case GLFW_KEY_ESCAPE:
|
case GLFW_KEY_ESCAPE:
|
||||||
{
|
{
|
||||||
if (glfwGetInputMode(window, GLFW_CURSOR) != GLFW_CURSOR_DISABLED)
|
const int mode = glfwGetInputMode(window, GLFW_CURSOR);
|
||||||
|
if (mode != GLFW_CURSOR_DISABLED && mode != GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
break;
|
break;
|
||||||
@ -197,6 +198,11 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
printf("(( cursor is hidden ))\n");
|
printf("(( cursor is hidden ))\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GLFW_KEY_C:
|
||||||
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
|
||||||
|
printf("(( cursor is captured ))\n");
|
||||||
|
break;
|
||||||
|
|
||||||
case GLFW_KEY_R:
|
case GLFW_KEY_R:
|
||||||
if (!glfwRawMouseMotionSupported())
|
if (!glfwRawMouseMotionSupported())
|
||||||
break;
|
break;
|
||||||
|
@ -642,7 +642,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
glfwMakeContextCurrent(slots[i].window);
|
glfwMakeContextCurrent(slots[i].window);
|
||||||
gladLoadGL(glfwGetProcAddress);
|
gladLoadGL(glfwGetProcAddress);
|
||||||
glfwSwapInterval(1);
|
glfwSwapBuffers(slots[i].window);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Main loop starting\n");
|
printf("Main loop starting\n");
|
||||||
|
130
tests/glfwinfo.c
130
tests/glfwinfo.c
@ -255,21 +255,6 @@ static void list_context_extensions(int client, int major, int minor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void list_vulkan_instance_extensions(void)
|
|
||||||
{
|
|
||||||
printf("Vulkan instance extensions:\n");
|
|
||||||
|
|
||||||
uint32_t ep_count;
|
|
||||||
vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL);
|
|
||||||
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
|
|
||||||
vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < ep_count; i++)
|
|
||||||
printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion);
|
|
||||||
|
|
||||||
free(ep);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void list_vulkan_instance_layers(void)
|
static void list_vulkan_instance_layers(void)
|
||||||
{
|
{
|
||||||
printf("Vulkan instance layers:\n");
|
printf("Vulkan instance layers:\n");
|
||||||
@ -290,21 +275,6 @@ static void list_vulkan_instance_layers(void)
|
|||||||
free(lp);
|
free(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice device)
|
|
||||||
{
|
|
||||||
printf("Vulkan device extensions:\n");
|
|
||||||
|
|
||||||
uint32_t ep_count;
|
|
||||||
vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL);
|
|
||||||
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
|
|
||||||
vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < ep_count; i++)
|
|
||||||
printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion);
|
|
||||||
|
|
||||||
free(ep);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice device)
|
static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice device)
|
||||||
{
|
{
|
||||||
printf("Vulkan device layers:\n");
|
printf("Vulkan device layers:\n");
|
||||||
@ -953,20 +923,51 @@ int main(int argc, char** argv)
|
|||||||
VK_VERSION_MAJOR(loader_version),
|
VK_VERSION_MAJOR(loader_version),
|
||||||
VK_VERSION_MINOR(loader_version));
|
VK_VERSION_MINOR(loader_version));
|
||||||
|
|
||||||
uint32_t re_count;
|
uint32_t glfw_re_count;
|
||||||
const char** re = glfwGetRequiredInstanceExtensions(&re_count);
|
const char** glfw_re = glfwGetRequiredInstanceExtensions(&glfw_re_count);
|
||||||
|
|
||||||
if (re)
|
uint32_t re_count = glfw_re_count;
|
||||||
|
const char** re = calloc(glfw_re_count, sizeof(char*));
|
||||||
|
|
||||||
|
if (glfw_re)
|
||||||
{
|
{
|
||||||
printf("Vulkan window surface required instance extensions:\n");
|
printf("Vulkan window surface required instance extensions:\n");
|
||||||
for (uint32_t i = 0; i < re_count; i++)
|
for (uint32_t i = 0; i < glfw_re_count; i++)
|
||||||
printf(" %s\n", re[i]);
|
{
|
||||||
|
printf(" %s\n", glfw_re[i]);
|
||||||
|
re[i] = glfw_re[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("Vulkan window surface extensions missing\n");
|
printf("Vulkan window surface extensions missing\n");
|
||||||
|
|
||||||
|
uint32_t ep_count;
|
||||||
|
vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL);
|
||||||
|
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
|
||||||
|
vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep);
|
||||||
|
|
||||||
if (list_extensions)
|
if (list_extensions)
|
||||||
list_vulkan_instance_extensions();
|
{
|
||||||
|
printf("Vulkan instance extensions:\n");
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < ep_count; i++)
|
||||||
|
printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool portability_enumeration = false;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < ep_count; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(ep[i].extensionName, "VK_KHR_portability_enumeration") != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
re_count++;
|
||||||
|
re = realloc((void*) re, sizeof(char*) * re_count);
|
||||||
|
re[re_count - 1] = "VK_KHR_portability_enumeration";
|
||||||
|
portability_enumeration = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(ep);
|
||||||
|
|
||||||
if (list_layers)
|
if (list_layers)
|
||||||
list_vulkan_instance_layers();
|
list_vulkan_instance_layers();
|
||||||
@ -987,6 +988,9 @@ int main(int argc, char** argv)
|
|||||||
ici.enabledExtensionCount = re_count;
|
ici.enabledExtensionCount = re_count;
|
||||||
ici.ppEnabledExtensionNames = re;
|
ici.ppEnabledExtensionNames = re;
|
||||||
|
|
||||||
|
if (portability_enumeration)
|
||||||
|
ici.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
||||||
|
|
||||||
VkInstance instance = VK_NULL_HANDLE;
|
VkInstance instance = VK_NULL_HANDLE;
|
||||||
|
|
||||||
if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS)
|
if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS)
|
||||||
@ -995,9 +999,11 @@ int main(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free((void*) re);
|
||||||
|
|
||||||
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, instance);
|
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, instance);
|
||||||
|
|
||||||
if (re)
|
if (glfw_re_count)
|
||||||
{
|
{
|
||||||
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||||
|
|
||||||
@ -1020,16 +1026,44 @@ int main(int argc, char** argv)
|
|||||||
VkPhysicalDeviceProperties pdp;
|
VkPhysicalDeviceProperties pdp;
|
||||||
vkGetPhysicalDeviceProperties(pd[i], &pdp);
|
vkGetPhysicalDeviceProperties(pd[i], &pdp);
|
||||||
|
|
||||||
printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
|
|
||||||
get_device_type_name(pdp.deviceType),
|
|
||||||
pdp.deviceName,
|
|
||||||
VK_VERSION_MAJOR(pdp.apiVersion),
|
|
||||||
VK_VERSION_MINOR(pdp.apiVersion));
|
|
||||||
|
|
||||||
uint32_t qfp_count;
|
uint32_t qfp_count;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL);
|
vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL);
|
||||||
|
|
||||||
if (re)
|
uint32_t ep_count;
|
||||||
|
vkEnumerateDeviceExtensionProperties(pd[i], NULL, &ep_count, NULL);
|
||||||
|
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
|
||||||
|
vkEnumerateDeviceExtensionProperties(pd[i], NULL, &ep_count, ep);
|
||||||
|
|
||||||
|
if (portability_enumeration)
|
||||||
|
{
|
||||||
|
bool conformant = true;
|
||||||
|
|
||||||
|
for (uint32_t j = 0; j < ep_count; j++)
|
||||||
|
{
|
||||||
|
if (strcmp(ep[j].extensionName, "VK_KHR_portability_subset") == 0)
|
||||||
|
{
|
||||||
|
conformant = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Vulkan %s %s device: \"%s\" (API version %i.%i)\n",
|
||||||
|
conformant ? "conformant" : "non-conformant",
|
||||||
|
get_device_type_name(pdp.deviceType),
|
||||||
|
pdp.deviceName,
|
||||||
|
VK_VERSION_MAJOR(pdp.apiVersion),
|
||||||
|
VK_VERSION_MINOR(pdp.apiVersion));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
|
||||||
|
get_device_type_name(pdp.deviceType),
|
||||||
|
pdp.deviceName,
|
||||||
|
VK_VERSION_MAJOR(pdp.apiVersion),
|
||||||
|
VK_VERSION_MINOR(pdp.apiVersion));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfw_re_count)
|
||||||
{
|
{
|
||||||
printf("Vulkan device queue family presentation support:\n");
|
printf("Vulkan device queue family presentation support:\n");
|
||||||
for (uint32_t j = 0; j < qfp_count; j++)
|
for (uint32_t j = 0; j < qfp_count; j++)
|
||||||
@ -1043,7 +1077,13 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (list_extensions)
|
if (list_extensions)
|
||||||
list_vulkan_device_extensions(instance, pd[i]);
|
{
|
||||||
|
printf("Vulkan device extensions:\n");
|
||||||
|
for (uint32_t j = 0; j < ep_count; j++)
|
||||||
|
printf(" %s (spec version %u)\n", ep[j].extensionName, ep[j].specVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(ep);
|
||||||
|
|
||||||
if (list_layers)
|
if (list_layers)
|
||||||
list_vulkan_device_layers(instance, pd[i]);
|
list_vulkan_device_layers(instance, pd[i]);
|
||||||
|
@ -1561,6 +1561,7 @@ static VkBool32 demo_check_layers(uint32_t check_count, const char **check_names
|
|||||||
|
|
||||||
static void demo_init_vk(struct demo *demo) {
|
static void demo_init_vk(struct demo *demo) {
|
||||||
VkResult err;
|
VkResult err;
|
||||||
|
VkBool32 portability_enumeration = VK_FALSE;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint32_t required_extension_count = 0;
|
uint32_t required_extension_count = 0;
|
||||||
uint32_t instance_extension_count = 0;
|
uint32_t instance_extension_count = 0;
|
||||||
@ -1668,6 +1669,13 @@ static void demo_init_vk(struct demo *demo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(demo->enabled_extension_count < 64);
|
assert(demo->enabled_extension_count < 64);
|
||||||
|
if (!strcmp(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME,
|
||||||
|
instance_extensions[i].extensionName)) {
|
||||||
|
demo->extension_names[demo->enabled_extension_count++] =
|
||||||
|
VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME;
|
||||||
|
portability_enumeration = VK_TRUE;
|
||||||
|
}
|
||||||
|
assert(demo->enabled_extension_count < 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(instance_extensions);
|
free(instance_extensions);
|
||||||
@ -1692,6 +1700,9 @@ static void demo_init_vk(struct demo *demo) {
|
|||||||
.ppEnabledExtensionNames = (const char *const *)demo->extension_names,
|
.ppEnabledExtensionNames = (const char *const *)demo->extension_names,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (portability_enumeration)
|
||||||
|
inst_info.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
||||||
|
|
||||||
uint32_t gpu_count;
|
uint32_t gpu_count;
|
||||||
|
|
||||||
err = vkCreateInstance(&inst_info, NULL, &demo->inst);
|
err = vkCreateInstance(&inst_info, NULL, &demo->inst);
|
||||||
|
Loading…
Reference in New Issue
Block a user