Update GLFW to 3.4 (#3827)

* Update GLFW to 3.4 (draft)

* Add _glfwConnectNull() function to rglfw.c

* Update rglfw.c

* Update Makefile

* Makefile: Replace USE_WAYLAND_DISPLAY with DISABLE_WAYLAND

* Revert "Makefile: Replace USE_WAYLAND_DISPLAY with DISABLE_WAYLAND"

This reverts commit 9e79abde78.

* GlfwImport.cmake: Replace GLFW_USE_WAYLAND with GLFW_BUILD_WAYLAND

* Update rglfw.c

* Output platform selected by GLFW to TRACELOG

* GLFW has removed Mir support
This commit is contained in:
Alexandre Almeida 2024-02-29 14:29:32 -03:00 committed by GitHub
parent 53221eb799
commit 6589311a0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
76 changed files with 9460 additions and 2957 deletions

View File

@ -16,7 +16,7 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
set(GLFW_USE_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE)
set(GLFW_BUILD_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE)
set(GLFW_LIBRARY_TYPE "OBJECT" CACHE STRING "" FORCE)

View File

@ -411,8 +411,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
CFLAGS += -D_GLFW_WAYLAND
LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
WL_PROTOCOLS_DIR := $(shell pkg-config wayland-protocols --variable=pkgdatadir)
WL_CLIENT_DIR := $(shell pkg-config wayland-client --variable=pkgdatadir)
WL_PROTOCOLS_DIR := external/glfw/deps/wayland
wl_generate = \
$(eval protocol=$(1)) \
@ -420,13 +419,15 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
$(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \
$(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.h)
$(call wl_generate, $(WL_CLIENT_DIR)/wayland.xml, wayland-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/stable/xdg-shell/xdg-shell.xml, wayland-xdg-shell-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml, wayland-xdg-decoration-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/stable/viewporter/viewporter.xml, wayland-viewporter-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/relative-pointer/relative-pointer-unstable-v1.xml, wayland-relative-pointer-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml, wayland-pointer-constraints-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml, wayland-idle-inhibit-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/wayland.xml, wayland-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/viewporter.xml, viewporter-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/fractional-scale-v1.xml, fractional-scale-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-activation-v1.xml, xdg-activation-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/idle-inhibit-unstable-v1.xml, idle-inhibit-unstable-v1-client-protocol)
endif
endif
endif
@ -805,7 +806,7 @@ clean: clean_shell_$(PLATFORM_SHELL)
@echo "removed all generated files!"
clean_shell_sh:
rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c
rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h
ifeq ($(PLATFORM),PLATFORM_ANDROID)
rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
endif

View File

@ -8,6 +8,6 @@ Description: A multi-platform library for OpenGL, window and input
Version: @GLFW_VERSION@
URL: https://www.glfw.org/
Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@
Libs: -L${libdir} -l@GLFW_LIB_NAME@
Libs: -L${libdir} -l@GLFW_LIB_NAME@@GLFW_LIB_NAME_SUFFIX@
Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@
Cflags: -I${includedir}

View File

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

View File

@ -8,12 +8,14 @@ video tutorials.
- Bobyshev Alexander
- Laurent Aphecetche
- Matt Arsenault
- Takuro Ashie
- ashishgamedev
- David Avedissian
- Luca Bacci
- Keith Bauer
- John Bartholomew
- Coşku Baş
- Bayemite
- Niklas Behrens
- Andrew Belt
- Nevyn Bengtsson
@ -32,7 +34,9 @@ video tutorials.
- David Carlier
- Arturo Castro
- Chi-kwan Chan
- Victor Chernyakin
- TheChocolateOre
- Ali Chraghi
- Joseph Chua
- Ian Clarkson
- Michał Cichoń
@ -45,6 +49,7 @@ video tutorials.
- Bailey Cosier
- Noel Cower
- CuriouserThing
- Bill Currie
- Jason Daly
- danhambleton
- Jarrod Davis
@ -64,11 +69,13 @@ video tutorials.
- Nikita Fediuchin
- Felipe Ferreira
- Michael Fogleman
- forworldm
- Jason Francis
- Gerald Franz
- Mário Freitas
- GeO4d
- Marcus Geelnard
- Gegy
- ghuser404
- Charles Giessen
- Ryan C. Gordon
@ -76,11 +83,14 @@ video tutorials.
- Kovid Goyal
- Kevin Grandemange
- Eloi Marín Gratacós
- Grzesiek11
- Stefan Gustavson
- Andrew Gutekanst
- Stephen Gutekanst
- Jonathan Hale
- Daniel Hauser
- hdf89shfdfs
- Moritz Heinemann
- Sylvain Hellegouarch
- Björn Hempel
- Matthew Henry
@ -91,6 +101,7 @@ video tutorials.
- Warren Hu
- Charles Huber
- Brent Huisman
- Florian Hülsmann
- illustris
- InKryption
- IntellectualKitty
@ -98,6 +109,7 @@ video tutorials.
- JannikGM
- Erik S. V. Jansson
- jjYBdx4IL
- Peter Johnson
- Toni Jovanoski
- Arseny Kapoulkine
- Cem Karan
@ -112,6 +124,7 @@ video tutorials.
- Rokas Kupstys
- Konstantin Käfer
- Eric Larson
- Guillaume Lebrun
- Francis Lecavalier
- Jong Won Lee
- Robin Leffmann
@ -120,12 +133,16 @@ video tutorials.
- Anders Lindqvist
- Leon Linhart
- Marco Lizza
- lo-v-ol
- Eyal Lotem
- Aaron Loucks
- Ned Loynd
- Luflosi
- lukect
- Tristam MacDonald
- Jean-Luc Mackail
- Hans Mackowiak
- Ramiro Magno
- Дмитри Малышев
- Zbigniew Mandziejewicz
- Adam Marcus
@ -137,7 +154,9 @@ video tutorials.
- Jonathan Mercier
- Marcel Metz
- Liam Middlebrook
- mightgoyardstill
- Ave Milia
- Icyllis Milica
- Jonathan Miller
- Kenneth Miller
- Bruce Mitchener
@ -152,11 +171,15 @@ video tutorials.
- Pascal Muetschard
- James Murphy
- Julian Møller
- Julius Häger
- Nat!
- NateIsStalling
- ndogxj
- F. Nedelec
- n3rdopolis
- Kristian Nielsen
- Joel Niemelä
- Victor Nova
- Kamil Nowakowski
- onox
- Denis Ovod
@ -179,12 +202,14 @@ video tutorials.
- Stanislav Podgorskiy
- Konstantin Podsvirov
- Nathan Poirier
- Pokechu22
- Alexandre Pretyman
- Pablo Prietz
- przemekmirek
- pthom
- Martin Pulec
- Guillaume Racicot
- Juan Ramos
- Christian Rauch
- Philip Rideout
- Eddie Ringle
@ -197,17 +222,23 @@ video tutorials.
- Aleksey Rybalkin
- Mikko Rytkönen
- Riku Salminen
- Yoshinori Sano
- Brandon Schaefer
- Sebastian Schuberth
- Scr3amer
- Jan Schuerkamp
- Christian Sdunek
- Matt Sealey
- Steve Sexton
- Arkady Shapkin
- Mingjie Shen
- Ali Sherief
- Yoshiki Shibukawa
- Dmitri Shuralyov
- Joao da Silva
- Daniel Sieger
- Daljit Singh
- Michael Skec
- Daniel Skorupski
- Slemmie
- Anthony Smith
@ -225,6 +256,7 @@ video tutorials.
- Paul Sultana
- Nathan Sweet
- TTK-Bandit
- Nuno Teixeira
- Jared Tiala
- Sergey Tikhomirov
- Arthur Tombs
@ -238,11 +270,14 @@ video tutorials.
- Jari Vetoniemi
- Ricardo Vieira
- Nicholas Vitovitch
- Vladimír Vondruš
- Simon Voordouw
- Corentin Wallez
- Torsten Walluhn
- Patrick Walton
- Jim Wang
- Xo Wang
- Andre Weissflog
- Jay Weisskopf
- Frank Wille
- Andy Williams

View File

@ -2,7 +2,6 @@
[![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions)
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
## Introduction
@ -11,15 +10,15 @@ application development. It provides a simple, platform-independent API for
creating windows, contexts and surfaces, reading input, handling events, etc.
GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On
Linux both X11 and Wayland are supported.
Linux both Wayland and X11 are supported.
GLFW is licensed under the [zlib/libpng
license](https://www.glfw.org/license.html).
You can [download](https://www.glfw.org/download.html) the latest stable release
as source or Windows binaries, or fetch the `latest` branch from GitHub. Each
release starting with 3.0 also has a corresponding [annotated
tag](https://github.com/glfw/glfw/releases) with source and binary archives.
as source or Windows binaries. Each release starting with 3.0 also has
a corresponding [annotated tag](https://github.com/glfw/glfw/releases) with
source and binary archives.
The [documentation](https://www.glfw.org/docs/latest/) is available online and is
included in all source and binary archives. See the [release
@ -47,18 +46,19 @@ features or fixing bugs.
## Compiling GLFW
GLFW itself requires only the headers and libraries for your OS and window
system. It does not need the headers for any context creation API (WGL, GLX,
EGL, NSGL, OSMesa) or rendering API (OpenGL, OpenGL ES, Vulkan) to enable
support for them.
GLFW is written primarily in C99, with parts of macOS support being written in
Objective-C. GLFW itself requires only the headers and libraries for your OS
and window system. It does not need any additional headers for context creation
APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan)
to enable support for them.
GLFW supports compilation on Windows with Visual C++ 2010 and later, MinGW and
GLFW supports compilation on Windows with Visual C++ 2013 and later, MinGW and
MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
and Clang. It will likely compile in other environments as well, but this is
not regularly tested.
There are [pre-compiled Windows binaries](https://www.glfw.org/download.html)
available for all supported compilers.
There are [pre-compiled binaries](https://www.glfw.org/download.html) available
for all supported compilers on Windows and macOS.
See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for
more information about how to compile GLFW yourself.
@ -119,7 +119,7 @@ guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
information on what to include when reporting a bug.
## Changelog
## Changelog since 3.3.10
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
@ -131,6 +131,7 @@ information on what to include when reporting a bug.
- Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947)
- Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and
`GLFWdeallocatefun` types (#544,#1628,#1947)
- Added `glfwGetWindowTitle` function for querying window title (#1448,#1909,#2482)
- Added `glfwInitVulkanLoader` for using a non-default Vulkan loader (#1374,#1890)
- Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
`GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
@ -143,6 +144,7 @@ information on what to include when reporting a bug.
content area (#58)
- Added `GLFW_POSITION_X` and `GLFW_POSITION_Y` window hints for initial position
(#1603,#1747)
- Added `GLFW_SCALE_FRAMEBUFFER` window hint for Wayland and macOS scaling (#2457)
- Added `GLFW_ANY_POSITION` hint value for letting the window manager choose (#1603,#1747)
- Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958)
- Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
@ -153,22 +155,63 @@ information on what to include when reporting a bug.
values to select ANGLE backend (#1380)
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
surface extension (#1793)
- Added `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu
- Added `GLFW_WIN32_SHOWDEFAULT` window hint for applying the parent process
show command (#2359)
- Added `GLFW_NATIVE_INCLUDE_NONE` for disabling inclusion of native headers (#1348)
- Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958)
- Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa support (#1958)
- Added `GLFW_BUILD_X11` CMake option for enabling X11 support (#1958)
- Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type
(#279,#1307,#1497,#1574,#1928)
- Added support for `XDG_SESSION_TYPE` environment variable
- Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake
variables exposing pkg-config dependencies (#1307)
- Made joystick subsystem initialize at first use (#1284,#1646)
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1
- Made Wayland the preferred platform over X11 if both are available (#2035)
- Updated the minimum required CMake version to 3.4
- Updated gamepad mappings from upstream
- Disabled tests and examples by default when built as a CMake subdirectory
- Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958)
- Disabled tests and examples by default when built as a CMake subdirectory
- Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958)
- Removed CMake generated configuration header
- Bugfix: `glfwGetVideoMode` returned an invalid mode on error (#1292)
- [Win32] Added a version info resource to the GLFW DLL
- [Win32] Made hidden helper window use its own window class
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
- [Cocoa] Added `glfwGetCocoaView` native access function (#2235)
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
would abort (#1649)
- [Wayland] Added support for `glfwRequestWindowAttention` (#2287)
- [Wayland] Added support for `glfwFocusWindow`
- [Wayland] Added support for `GLFW_RESIZABLE` (#2203)
- [Wayland] Added support for fractional scaling of window contents
- [Wayland] Added dynamic loading of all Wayland libraries
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
- [Wayland] Bugfix: `GLFW_HOVERED` was true when the cursor was over any
fallback window decoration
- [Wayland] Bugfix: Fallback decorations allowed resizing to invalid size
(#2204)
- [X11] Bugfix: Termination would segfault if the IM had been destroyed
- [X11] Bugfix: Any IM started after initialization would not be detected
- [Linux] Bugfix: Joystick evdev fds remained open in forks (#2446)
- [POSIX] Removed use of deprecated function `gettimeofday`
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [NSGL] Bugfix: A core profile OpenGL context was returned if 3.2+
compatibility profile was requested
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
(#442)
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
(#1380)
## Changelog since 3.3
- Added `GLFW_WAYLAND_LIBDECOR` init hint for disabling libdecor support (#1639,#1693)
- Bugfix: The CMake config-file package used an absolute path and was not
relocatable (#1470)
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
@ -183,10 +226,8 @@ information on what to include when reporting a bug.
- 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
to the window menu
- [Win32] Added a version info resource to the GLFW DLL
- [Win32] Made hidden helper window use its own window class
- Bugfix: `glfwGetKeyScancode` returned `0` on error when initialized instead of `-1`
- Bugfix: Failure to make a newly created context current could cause segfault (#2327)
- [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are
opaque (#1512)
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
@ -213,7 +254,6 @@ information on what to include when reporting a bug.
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
later (#1783,#1796)
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
- [Win32] Bugfix: Content scale queries could fail silently (#1615)
- [Win32] Bugfix: Content scales could have garbage values if monitor was recently
disconnected (#1615)
@ -229,9 +269,13 @@ information on what to include when reporting a bug.
- [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395)
- [Win32] Bugfix: The OSMesa library was not unloaded on termination
- [Win32] Bugfix: Right shift emitted `GLFW_KEY_UNKNOWN` when using a CJK IME (#2050)
- [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408)
- [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420)
- [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291)
- [Win32] Bugfix: Rapid clipboard calls could fail due to Clipboard History
- [Win32] Bugfix: Disabled cursor mode doesn't work right when connected over RDP (#1276,#1279,#2431)
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
- [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency
(#1786)
@ -242,8 +286,6 @@ information on what to include when reporting a bug.
(#1412)
- [Cocoa] Bugfix: Event processing before window creation would assert (#1543)
- [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
- [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
would abort (#1649)
- [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
(#1635)
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
@ -269,6 +311,10 @@ information on what to include when reporting a bug.
application (#2110)
- [Cocoa] Bugfix: The Vulkan loader was not loaded from the `Frameworks` bundle
subdirectory (#2113,#2120)
- [Cocoa] Bugfix: Compilation failed on OS X 10.8 due to unconditional use of 10.9+
symbols (#2161)
- [Cocoa] Bugfix: Querying joystick elements could reportedly segfault on macOS
13 Ventura (#2320)
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528)
@ -283,8 +329,6 @@ information on what to include when reporting a bug.
- [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM
- [X11] Bugfix: Querying a disconnected monitor could segfault (#1602)
- [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
- [X11] Bugfix: Termination would segfault if the IM had been destroyed
- [X11] Bugfix: Any IM started after initialization would not be detected
- [X11] Bugfix: Xlib errors caused by other parts of the application could be
reported as GLFW errors
- [X11] Bugfix: A handle race condition could cause a `BadWindow` error (#1633)
@ -311,7 +355,7 @@ information on what to include when reporting a bug.
- [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 improved fallback window decorations via libdecor (#1639,#1693)
- [Wayland] Added support for key names via xkbcommon
- [Wayland] Added support for file path drop events (#2040)
- [Wayland] Added support for more human-readable monitor names where available
@ -319,7 +363,6 @@ information on what to include when reporting a bug.
`EGL_EXT_present_opaque` (#1895)
- [Wayland] Removed support for `wl_shell` (#1443)
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
- [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704)
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
@ -382,22 +425,18 @@ information on what to include when reporting a bug.
- [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] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198)
- [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors
- [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043)
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [Linux] Bugfix: A small amount of memory could leak if initialization failed (#2229)
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
macOS versions (#1442)
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
- [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused
a duplicate definition warning (#1840)
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
(#442)
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
(#1380)
[EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL
- [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
- [EGL] Bugfix: Setting `GLFW_CONTEXT_DEBUG` caused creation to fail (#2348)
- [GLX] Added loading of glvnd `libGLX.so.0` where available
- [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library
@ -408,13 +447,12 @@ On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as
well as news, documentation and other information about the project.
If you have questions related to the use of GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
[Libera.Chat](https://libera.chat/).
[forum](https://discourse.glfw.org/).
If you have a bug to report, a patch to submit or a feature you'd like to
request, please file it in the
[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
Finally, if you're interested in helping out with the development of GLFW or
porting it to your favorite platform, join us on the forum, GitHub or IRC.
porting it to your favorite platform, join us on the forum or GitHub.

View File

@ -1,247 +0,0 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#ifdef __cplusplus
extern "C" {
#endif
# include <wchar.h>
#ifdef __cplusplus
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 signed int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]

View File

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

View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="idle_inhibit_unstable_v1">
<copyright>
Copyright © 2015 Samsung Electronics Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zwp_idle_inhibit_manager_v1" version="1">
<description summary="control behavior when display idles">
This interface permits inhibiting the idle behavior such as screen
blanking, locking, and screensaving. The client binds the idle manager
globally, then creates idle-inhibitor objects for each surface.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the idle inhibitor object">
Destroy the inhibit manager.
</description>
</request>
<request name="create_inhibitor">
<description summary="create a new inhibitor object">
Create a new inhibitor object associated with the given surface.
</description>
<arg name="id" type="new_id" interface="zwp_idle_inhibitor_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="the surface that inhibits the idle behavior"/>
</request>
</interface>
<interface name="zwp_idle_inhibitor_v1" version="1">
<description summary="context object for inhibiting idle behavior">
An idle inhibitor prevents the output that the associated surface is
visible on from being set to a state where it is not visually usable due
to lack of user interaction (e.g. blanked, dimmed, locked, set to power
save, etc.) Any screensaver processes are also blocked from displaying.
If the surface is destroyed, unmapped, becomes occluded, loses
visibility, or otherwise becomes not visually relevant for the user, the
idle inhibitor will not be honored by the compositor; if the surface
subsequently regains visibility the inhibitor takes effect once again.
Likewise, the inhibitor isn't honored if the system was already idled at
the time the inhibitor was established, although if the system later
de-idles and re-idles the inhibitor will take effect.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the idle inhibitor object">
Remove the inhibitor effect from the associated wl_surface.
</description>
</request>
</interface>
</protocol>

View File

@ -0,0 +1,339 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="pointer_constraints_unstable_v1">
<copyright>
Copyright © 2014 Jonas Ådahl
Copyright © 2015 Red Hat Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="protocol for constraining pointer motions">
This protocol specifies a set of interfaces used for adding constraints to
the motion of a pointer. Possible constraints include confining pointer
motions to a given region, or locking it to its current position.
In order to constrain the pointer, a client must first bind the global
interface "wp_pointer_constraints" which, if a compositor supports pointer
constraints, is exposed by the registry. Using the bound global object, the
client uses the request that corresponds to the type of constraint it wants
to make. See wp_pointer_constraints for more details.
Warning! The protocol described in this file is experimental and backward
incompatible changes may be made. Backward compatible changes may be added
together with the corresponding interface version bump. Backward
incompatible changes are done by bumping the version number in the protocol
and interface names and resetting the interface version. Once the protocol
is to be declared stable, the 'z' prefix and the version number in the
protocol and interface names are removed and the interface version number is
reset.
</description>
<interface name="zwp_pointer_constraints_v1" version="1">
<description summary="constrain the movement of a pointer">
The global interface exposing pointer constraining functionality. It
exposes two requests: lock_pointer for locking the pointer to its
position, and confine_pointer for locking the pointer to a region.
The lock_pointer and confine_pointer requests create the objects
wp_locked_pointer and wp_confined_pointer respectively, and the client can
use these objects to interact with the lock.
For any surface, only one lock or confinement may be active across all
wl_pointer objects of the same seat. If a lock or confinement is requested
when another lock or confinement is active or requested on the same surface
and with any of the wl_pointer objects of the same seat, an
'already_constrained' error will be raised.
</description>
<enum name="error">
<description summary="wp_pointer_constraints error values">
These errors can be emitted in response to wp_pointer_constraints
requests.
</description>
<entry name="already_constrained" value="1"
summary="pointer constraint already requested on that surface"/>
</enum>
<enum name="lifetime">
<description summary="constraint lifetime">
These values represent different lifetime semantics. They are passed
as arguments to the factory requests to specify how the constraint
lifetimes should be managed.
</description>
<entry name="oneshot" value="1">
<description summary="the pointer constraint is defunct once deactivated">
A oneshot pointer constraint will never reactivate once it has been
deactivated. See the corresponding deactivation event
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
details.
</description>
</entry>
<entry name="persistent" value="2">
<description summary="the pointer constraint may reactivate">
A persistent pointer constraint may again reactivate once it has
been deactivated. See the corresponding deactivation event
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
details.
</description>
</entry>
</enum>
<request name="destroy" type="destructor">
<description summary="destroy the pointer constraints manager object">
Used by the client to notify the server that it will no longer use this
pointer constraints object.
</description>
</request>
<request name="lock_pointer">
<description summary="lock pointer to a position">
The lock_pointer request lets the client request to disable movements of
the virtual pointer (i.e. the cursor), effectively locking the pointer
to a position. This request may not take effect immediately; in the
future, when the compositor deems implementation-specific constraints
are satisfied, the pointer lock will be activated and the compositor
sends a locked event.
The protocol provides no guarantee that the constraints are ever
satisfied, and does not require the compositor to send an error if the
constraints cannot ever be satisfied. It is thus possible to request a
lock that will never activate.
There may not be another pointer constraint of any kind requested or
active on the surface for any of the wl_pointer objects of the seat of
the passed pointer when requesting a lock. If there is, an error will be
raised. See general pointer lock documentation for more details.
The intersection of the region passed with this request and the input
region of the surface is used to determine where the pointer must be
in order for the lock to activate. It is up to the compositor whether to
warp the pointer or require some kind of user interaction for the lock
to activate. If the region is null the surface input region is used.
A surface may receive pointer focus without the lock being activated.
The request creates a new object wp_locked_pointer which is used to
interact with the lock as well as receive updates about its state. See
the the description of wp_locked_pointer for further information.
Note that while a pointer is locked, the wl_pointer objects of the
corresponding seat will not emit any wl_pointer.motion events, but
relative motion events will still be emitted via wp_relative_pointer
objects of the same seat. wl_pointer.axis and wl_pointer.button events
are unaffected.
</description>
<arg name="id" type="new_id" interface="zwp_locked_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
<arg name="pointer" type="object" interface="wl_pointer"
summary="the pointer that should be locked"/>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
<arg name="lifetime" type="uint" enum="lifetime" summary="lock lifetime"/>
</request>
<request name="confine_pointer">
<description summary="confine pointer to a region">
The confine_pointer request lets the client request to confine the
pointer cursor to a given region. This request may not take effect
immediately; in the future, when the compositor deems implementation-
specific constraints are satisfied, the pointer confinement will be
activated and the compositor sends a confined event.
The intersection of the region passed with this request and the input
region of the surface is used to determine where the pointer must be
in order for the confinement to activate. It is up to the compositor
whether to warp the pointer or require some kind of user interaction for
the confinement to activate. If the region is null the surface input
region is used.
The request will create a new object wp_confined_pointer which is used
to interact with the confinement as well as receive updates about its
state. See the the description of wp_confined_pointer for further
information.
</description>
<arg name="id" type="new_id" interface="zwp_confined_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
<arg name="pointer" type="object" interface="wl_pointer"
summary="the pointer that should be confined"/>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
<arg name="lifetime" type="uint" enum="lifetime" summary="confinement lifetime"/>
</request>
</interface>
<interface name="zwp_locked_pointer_v1" version="1">
<description summary="receive relative pointer motion events">
The wp_locked_pointer interface represents a locked pointer state.
While the lock of this object is active, the wl_pointer objects of the
associated seat will not emit any wl_pointer.motion events.
This object will send the event 'locked' when the lock is activated.
Whenever the lock is activated, it is guaranteed that the locked surface
will already have received pointer focus and that the pointer will be
within the region passed to the request creating this object.
To unlock the pointer, send the destroy request. This will also destroy
the wp_locked_pointer object.
If the compositor decides to unlock the pointer the unlocked event is
sent. See wp_locked_pointer.unlock for details.
When unlocking, the compositor may warp the cursor position to the set
cursor position hint. If it does, it will not result in any relative
motion events emitted via wp_relative_pointer.
If the surface the lock was requested on is destroyed and the lock is not
yet activated, the wp_locked_pointer object is now defunct and must be
destroyed.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the locked pointer object">
Destroy the locked pointer object. If applicable, the compositor will
unlock the pointer.
</description>
</request>
<request name="set_cursor_position_hint">
<description summary="set the pointer cursor position hint">
Set the cursor position hint relative to the top left corner of the
surface.
If the client is drawing its own cursor, it should update the position
hint to the position of its own cursor. A compositor may use this
information to warp the pointer upon unlock in order to avoid pointer
jumps.
The cursor position hint is double buffered. The new hint will only take
effect when the associated surface gets it pending state applied. See
wl_surface.commit for details.
</description>
<arg name="surface_x" type="fixed"
summary="surface-local x coordinate"/>
<arg name="surface_y" type="fixed"
summary="surface-local y coordinate"/>
</request>
<request name="set_region">
<description summary="set a new lock region">
Set a new region used to lock the pointer.
The new lock region is double-buffered. The new lock region will
only take effect when the associated surface gets its pending state
applied. See wl_surface.commit for details.
For details about the lock region, see wp_locked_pointer.
</description>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
<event name="locked">
<description summary="lock activation event">
Notification that the pointer lock of the seat's pointer is activated.
</description>
</event>
<event name="unlocked">
<description summary="lock deactivation event">
Notification that the pointer lock of the seat's pointer is no longer
active. If this is a oneshot pointer lock (see
wp_pointer_constraints.lifetime) this object is now defunct and should
be destroyed. If this is a persistent pointer lock (see
wp_pointer_constraints.lifetime) this pointer lock may again
reactivate in the future.
</description>
</event>
</interface>
<interface name="zwp_confined_pointer_v1" version="1">
<description summary="confined pointer object">
The wp_confined_pointer interface represents a confined pointer state.
This object will send the event 'confined' when the confinement is
activated. Whenever the confinement is activated, it is guaranteed that
the surface the pointer is confined to will already have received pointer
focus and that the pointer will be within the region passed to the request
creating this object. It is up to the compositor to decide whether this
requires some user interaction and if the pointer will warp to within the
passed region if outside.
To unconfine the pointer, send the destroy request. This will also destroy
the wp_confined_pointer object.
If the compositor decides to unconfine the pointer the unconfined event is
sent. The wp_confined_pointer object is at this point defunct and should
be destroyed.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the confined pointer object">
Destroy the confined pointer object. If applicable, the compositor will
unconfine the pointer.
</description>
</request>
<request name="set_region">
<description summary="set a new confine region">
Set a new region used to confine the pointer.
The new confine region is double-buffered. The new confine region will
only take effect when the associated surface gets its pending state
applied. See wl_surface.commit for details.
If the confinement is active when the new confinement region is applied
and the pointer ends up outside of newly applied region, the pointer may
warped to a position within the new confinement region. If warped, a
wl_pointer.motion event will be emitted, but no
wp_relative_pointer.relative_motion event.
The compositor may also, instead of using the new region, unconfine the
pointer.
For details about the confine region, see wp_confined_pointer.
</description>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
<event name="confined">
<description summary="pointer confined">
Notification that the pointer confinement of the seat's pointer is
activated.
</description>
</event>
<event name="unconfined">
<description summary="pointer unconfined">
Notification that the pointer confinement of the seat's pointer is no
longer active. If this is a oneshot pointer confinement (see
wp_pointer_constraints.lifetime) this object is now defunct and should
be destroyed. If this is a persistent pointer confinement (see
wp_pointer_constraints.lifetime) this pointer confinement may again
reactivate in the future.
</description>
</event>
</interface>
</protocol>

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="relative_pointer_unstable_v1">
<copyright>
Copyright © 2014 Jonas Ådahl
Copyright © 2015 Red Hat Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="protocol for relative pointer motion events">
This protocol specifies a set of interfaces used for making clients able to
receive relative pointer events not obstructed by barriers (such as the
monitor edge or other pointer barriers).
To start receiving relative pointer events, a client must first bind the
global interface "wp_relative_pointer_manager" which, if a compositor
supports relative pointer motion events, is exposed by the registry. After
having created the relative pointer manager proxy object, the client uses
it to create the actual relative pointer object using the
"get_relative_pointer" request given a wl_pointer. The relative pointer
motion events will then, when applicable, be transmitted via the proxy of
the newly created relative pointer object. See the documentation of the
relative pointer interface for more details.
Warning! The protocol described in this file is experimental and backward
incompatible changes may be made. Backward compatible changes may be added
together with the corresponding interface version bump. Backward
incompatible changes are done by bumping the version number in the protocol
and interface names and resetting the interface version. Once the protocol
is to be declared stable, the 'z' prefix and the version number in the
protocol and interface names are removed and the interface version number is
reset.
</description>
<interface name="zwp_relative_pointer_manager_v1" version="1">
<description summary="get relative pointer objects">
A global interface used for getting the relative pointer object for a
given pointer.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the relative pointer manager object">
Used by the client to notify the server that it will no longer use this
relative pointer manager object.
</description>
</request>
<request name="get_relative_pointer">
<description summary="get a relative pointer object">
Create a relative pointer interface given a wl_pointer object. See the
wp_relative_pointer interface for more details.
</description>
<arg name="id" type="new_id" interface="zwp_relative_pointer_v1"/>
<arg name="pointer" type="object" interface="wl_pointer"/>
</request>
</interface>
<interface name="zwp_relative_pointer_v1" version="1">
<description summary="relative pointer object">
A wp_relative_pointer object is an extension to the wl_pointer interface
used for emitting relative pointer events. It shares the same focus as
wl_pointer objects of the same seat and will only emit events when it has
focus.
</description>
<request name="destroy" type="destructor">
<description summary="release the relative pointer object"/>
</request>
<event name="relative_motion">
<description summary="relative pointer motion">
Relative x/y pointer motion from the pointer of the seat associated with
this object.
A relative motion is in the same dimension as regular wl_pointer motion
events, except they do not represent an absolute position. For example,
moving a pointer from (x, y) to (x', y') would have the equivalent
relative motion (x' - x, y' - y). If a pointer motion caused the
absolute pointer position to be clipped by for example the edge of the
monitor, the relative motion is unaffected by the clipping and will
represent the unclipped motion.
This event also contains non-accelerated motion deltas. The
non-accelerated delta is, when applicable, the regular pointer motion
delta as it was before having applied motion acceleration and other
transformations such as normalization.
Note that the non-accelerated delta does not represent 'raw' events as
they were read from some device. Pointer motion acceleration is device-
and configuration-specific and non-accelerated deltas and accelerated
deltas may have the same value on some devices.
Relative motions are not coupled to wl_pointer.motion events, and can be
sent in combination with such events, but also independently. There may
also be scenarios where wl_pointer.motion is sent, but there is no
relative motion. The order of an absolute and relative motion event
originating from the same physical motion is not guaranteed.
If the client needs button events or focus state, it can receive them
from a wl_pointer object of the same seat that the wp_relative_pointer
object is associated with.
</description>
<arg name="utime_hi" type="uint"
summary="high 32 bits of a 64 bit timestamp with microsecond granularity"/>
<arg name="utime_lo" type="uint"
summary="low 32 bits of a 64 bit timestamp with microsecond granularity"/>
<arg name="dx" type="fixed"
summary="the x component of the motion vector"/>
<arg name="dy" type="fixed"
summary="the y component of the motion vector"/>
<arg name="dx_unaccel" type="fixed"
summary="the x component of the unaccelerated motion vector"/>
<arg name="dy_unaccel" type="fixed"
summary="the y component of the unaccelerated motion vector"/>
</event>
</interface>
</protocol>

View File

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="viewporter">
<copyright>
Copyright © 2013-2016 Collabora, Ltd.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="wp_viewporter" version="1">
<description summary="surface cropping and scaling">
The global interface exposing surface cropping and scaling
capabilities is used to instantiate an interface extension for a
wl_surface object. This extended interface will then allow
cropping and scaling the surface contents, effectively
disconnecting the direct relationship between the buffer and the
surface size.
</description>
<request name="destroy" type="destructor">
<description summary="unbind from the cropping and scaling interface">
Informs the server that the client will not be using this
protocol object anymore. This does not affect any other objects,
wp_viewport objects included.
</description>
</request>
<enum name="error">
<entry name="viewport_exists" value="0"
summary="the surface already has a viewport object associated"/>
</enum>
<request name="get_viewport">
<description summary="extend surface interface for crop and scale">
Instantiate an interface extension for the given wl_surface to
crop and scale its content. If the given wl_surface already has
a wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>
<arg name="id" type="new_id" interface="wp_viewport"
summary="the new viewport interface id"/>
<arg name="surface" type="object" interface="wl_surface"
summary="the surface"/>
</request>
</interface>
<interface name="wp_viewport" version="1">
<description summary="crop and scale interface to a wl_surface">
An additional interface to a wl_surface object, which allows the
client to specify the cropping and scaling of the surface
contents.
This interface works with two concepts: the source rectangle (src_x,
src_y, src_width, src_height), and the destination size (dst_width,
dst_height). The contents of the source rectangle are scaled to the
destination size, and content outside the source rectangle is ignored.
This state is double-buffered, and is applied on the next
wl_surface.commit.
The two parts of crop and scale state are independent: the source
rectangle, and the destination size. Initially both are unset, that
is, no scaling is applied. The whole of the current wl_buffer is
used as the source, and the surface size is as defined in
wl_surface.attach.
If the destination size is set, it causes the surface size to become
dst_width, dst_height. The source (rectangle) is scaled to exactly
this size. This overrides whatever the attached wl_buffer size is,
unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
has no content and therefore no size. Otherwise, the size is always
at least 1x1 in surface local coordinates.
If the source rectangle is set, it defines what area of the wl_buffer is
taken as the source. If the source rectangle is set and the destination
size is not set, then src_width and src_height must be integers, and the
surface size becomes the source rectangle size. This results in cropping
without scaling. If src_width or src_height are not integers and
destination size is not set, the bad_size protocol error is raised when
the surface state is applied.
The coordinate transformations from buffer pixel coordinates up to
the surface-local coordinates happen in the following order:
1. buffer_transform (wl_surface.set_buffer_transform)
2. buffer_scale (wl_surface.set_buffer_scale)
3. crop and scale (wp_viewport.set*)
This means, that the source rectangle coordinates of crop and scale
are given in the coordinates after the buffer transform and scale,
i.e. in the coordinates that would be the surface-local coordinates
if the crop and scale was not applied.
If src_x or src_y are negative, the bad_value protocol error is raised.
Otherwise, if the source rectangle is partially or completely outside of
the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
when the surface state is applied. A NULL wl_buffer does not raise the
out_of_buffer error.
If the wl_surface associated with the wp_viewport is destroyed,
all wp_viewport requests except 'destroy' raise the protocol error
no_surface.
If the wp_viewport object is destroyed, the crop and scale
state is removed from the wl_surface. The change will be applied
on the next wl_surface.commit.
</description>
<request name="destroy" type="destructor">
<description summary="remove scaling and cropping from the surface">
The associated wl_surface's crop and scale state is removed.
The change is applied on the next wl_surface.commit.
</description>
</request>
<enum name="error">
<entry name="bad_value" value="0"
summary="negative or zero values in width or height"/>
<entry name="bad_size" value="1"
summary="destination size is not integer"/>
<entry name="out_of_buffer" value="2"
summary="source rectangle extends outside of the content area"/>
<entry name="no_surface" value="3"
summary="the wl_surface was destroyed"/>
</enum>
<request name="set_source">
<description summary="set the source rectangle for cropping">
Set the source rectangle of the associated wl_surface. See
wp_viewport for the description, and relation to the wl_buffer
size.
If all of x, y, width and height are -1.0, the source rectangle is
unset instead. Any other set of values where width or height are zero
or negative, or x or y are negative, raise the bad_value protocol
error.
The crop and scale state is double-buffered state, and will be
applied on the next wl_surface.commit.
</description>
<arg name="x" type="fixed" summary="source rectangle x"/>
<arg name="y" type="fixed" summary="source rectangle y"/>
<arg name="width" type="fixed" summary="source rectangle width"/>
<arg name="height" type="fixed" summary="source rectangle height"/>
</request>
<request name="set_destination">
<description summary="set the surface size for scaling">
Set the destination size of the associated wl_surface. See
wp_viewport for the description, and relation to the wl_buffer
size.
If width is -1 and height is -1, the destination size is unset
instead. Any other pair of values for width and height that
contains zero or negative values raises the bad_value protocol
error.
The crop and scale state is double-buffered state, and will be
applied on the next wl_surface.commit.
</description>
<arg name="width" type="int" summary="surface width"/>
<arg name="height" type="int" summary="surface height"/>
</request>
</interface>
</protocol>

3151
src/external/glfw/deps/wayland/wayland.xml vendored Normal file

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xdg_decoration_unstable_v1">
<copyright>
Copyright © 2018 Simon Ser
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zxdg_decoration_manager_v1" version="1">
<description summary="window decoration manager">
This interface allows a compositor to announce support for server-side
decorations.
A window decoration is a set of window controls as deemed appropriate by
the party managing them, such as user interface components used to move,
resize and change a window's state.
A client can use this protocol to request being decorated by a supporting
compositor.
If compositor and client do not negotiate the use of a server-side
decoration using this protocol, clients continue to self-decorate as they
see fit.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the decoration manager object">
Destroy the decoration manager. This doesn't destroy objects created
with the manager.
</description>
</request>
<request name="get_toplevel_decoration">
<description summary="create a new toplevel decoration object">
Create a new decoration object associated with the given toplevel.
Creating an xdg_toplevel_decoration from an xdg_toplevel which has a
buffer attached or committed is a client error, and any attempts by a
client to attach or manipulate a buffer prior to the first
xdg_toplevel_decoration.configure event must also be treated as
errors.
</description>
<arg name="id" type="new_id" interface="zxdg_toplevel_decoration_v1"/>
<arg name="toplevel" type="object" interface="xdg_toplevel"/>
</request>
</interface>
<interface name="zxdg_toplevel_decoration_v1" version="1">
<description summary="decoration object for a toplevel surface">
The decoration object allows the compositor to toggle server-side window
decorations for a toplevel surface. The client can request to switch to
another mode.
The xdg_toplevel_decoration object must be destroyed before its
xdg_toplevel.
</description>
<enum name="error">
<entry name="unconfigured_buffer" value="0"
summary="xdg_toplevel has a buffer attached before configure"/>
<entry name="already_constructed" value="1"
summary="xdg_toplevel already has a decoration object"/>
<entry name="orphaned" value="2"
summary="xdg_toplevel destroyed before the decoration object"/>
</enum>
<request name="destroy" type="destructor">
<description summary="destroy the decoration object">
Switch back to a mode without any server-side decorations at the next
commit.
</description>
</request>
<enum name="mode">
<description summary="window decoration modes">
These values describe window decoration modes.
</description>
<entry name="client_side" value="1"
summary="no server-side window decoration"/>
<entry name="server_side" value="2"
summary="server-side window decoration"/>
</enum>
<request name="set_mode">
<description summary="set the decoration mode">
Set the toplevel surface decoration mode. This informs the compositor
that the client prefers the provided decoration mode.
After requesting a decoration mode, the compositor will respond by
emitting an xdg_surface.configure event. The client should then update
its content, drawing it without decorations if the received mode is
server-side decorations. The client must also acknowledge the configure
when committing the new content (see xdg_surface.ack_configure).
The compositor can decide not to use the client's mode and enforce a
different mode instead.
Clients whose decoration mode depend on the xdg_toplevel state may send
a set_mode request in response to an xdg_surface.configure event and wait
for the next xdg_surface.configure event to prevent unwanted state.
Such clients are responsible for preventing configure loops and must
make sure not to send multiple successive set_mode requests with the
same decoration mode.
</description>
<arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
</request>
<request name="unset_mode">
<description summary="unset the decoration mode">
Unset the toplevel surface decoration mode. This informs the compositor
that the client doesn't prefer a particular decoration mode.
This request has the same semantics as set_mode.
</description>
</request>
<event name="configure">
<description summary="suggest a surface change">
The configure event asks the client to change its decoration mode. The
configured state should not be applied immediately. Clients must send an
ack_configure in response to this event. See xdg_surface.configure and
xdg_surface.ack_configure for details.
A configure event can be sent at any time. The specified mode must be
obeyed by the client.
</description>
<arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
</event>
</interface>
</protocol>

File diff suppressed because it is too large Load Diff

View File

@ -361,10 +361,15 @@ extern "C" {
#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
/*! @ingroup input
*/
#define GLFW_KEY_UNKNOWN -1
/*! @} */
/*! @defgroup keys Keyboard keys
* @brief Keyboard key IDs.
/*! @defgroup keys Keyboard key tokens
* @brief Keyboard key tokens.
*
* See [key input](@ref input_key) for how these are used.
*
@ -387,9 +392,6 @@ extern "C" {
* @{
*/
/* The unknown key */
#define GLFW_KEY_UNKNOWN -1
/* Printable keys */
#define GLFW_KEY_SPACE 32
#define GLFW_KEY_APOSTROPHE 39 /* ' */
@ -825,11 +827,11 @@ extern "C" {
#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
/*! @brief Platform unavailable or no matching platform was found.
*
* If emitted during initialization, no matching platform was found. If @ref
* GLFW_PLATFORM is set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of the
* platforms supported by this library binary, except for the Null platform. If set to
* a specific platform, it is either not supported by this library binary or GLFW was not
* able to detect it.
* If emitted during initialization, no matching platform was found. If the @ref
* GLFW_PLATFORM init hint was set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of
* the platforms supported by this library binary, except for the Null platform. If the
* init hint was set to a specific platform, it is either not supported by this library
* binary or GLFW was not able to detect it.
*
* If emitted by a native access function, GLFW was initialized for a different platform
* than the function is for.
@ -1096,8 +1098,15 @@ extern "C" {
* [window hint](@ref GLFW_SCALE_TO_MONITOR).
*/
#define GLFW_SCALE_TO_MONITOR 0x0002200C
/*! @brief macOS specific
* [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint).
/*! @brief Window framebuffer scaling
* [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint).
*/
#define GLFW_SCALE_FRAMEBUFFER 0x0002200D
/*! @brief Legacy name for compatibility.
*
* This is an alias for the
* [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for
* compatibility with earlier versions.
*/
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
/*! @brief macOS specific
@ -1117,6 +1126,9 @@ extern "C" {
*/
#define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WIN32_KEYBOARD_MENU 0x00025001
/*! @brief Win32 specific [window hint](@ref GLFW_WIN32_SHOWDEFAULT_hint).
*/
#define GLFW_WIN32_SHOWDEFAULT 0x00025002
/*! @brief Wayland specific
* [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
*
@ -1164,6 +1176,9 @@ extern "C" {
#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007
#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008
#define GLFW_WAYLAND_PREFER_LIBDECOR 0x00038001
#define GLFW_WAYLAND_DISABLE_LIBDECOR 0x00038002
#define GLFW_ANY_POSITION 0x80000000
/*! @defgroup shapes Standard cursor shapes
@ -1215,11 +1230,11 @@ extern "C" {
* @note @macos This shape is provided by a private system API and may fail
* with @ref GLFW_CURSOR_UNAVAILABLE in the future.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*
* @note @wayland This shape is provided by a newer standard not supported by
* all cursor themes.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*/
#define GLFW_RESIZE_NWSE_CURSOR 0x00036007
/*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
@ -1230,11 +1245,11 @@ extern "C" {
* @note @macos This shape is provided by a private system API and may fail
* with @ref GLFW_CURSOR_UNAVAILABLE in the future.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*
* @note @wayland This shape is provided by a newer standard not supported by
* all cursor themes.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*/
#define GLFW_RESIZE_NESW_CURSOR 0x00036008
/*! @brief The omni-directional resize/move cursor shape.
@ -1248,11 +1263,11 @@ extern "C" {
* The operation-not-allowed shape. This is usually a circle with a diagonal
* line through it.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*
* @note @wayland This shape is provided by a newer standard not supported by
* all cursor themes.
*
* @note @x11 This shape is provided by a newer standard not supported by all
* cursor themes.
*/
#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
/*! @brief Legacy name for compatibility.
@ -1307,6 +1322,11 @@ extern "C" {
* X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
*/
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
/*! @brief Wayland specific init hint.
*
* Wayland specific [init hint](@ref GLFW_WAYLAND_LIBDECOR_hint).
*/
#define GLFW_WAYLAND_LIBDECOR 0x00053001
/*! @} */
/*! @addtogroup init
@ -1406,16 +1426,25 @@ typedef struct GLFWcursor GLFWcursor;
* or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
* failures gracefully yet.
*
* This function may be called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the
* library is no longer flagged as initialized.
* This function must support being called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the library is no
* longer flagged as initialized.
*
* Any memory allocated by this function will be deallocated during library
* termination or earlier.
* Any memory allocated via this function will be deallocated via the same allocator
* during library termination or earlier.
*
* Any memory allocated via this function must be suitably aligned for any object type.
* If you are using C99 or earlier, this alignment is platform-dependent but will be the
* same as what `malloc` provides. If you are using C11 or later, this is the value of
* `alignof(max_align_t)`.
*
* The size will always be greater than zero. Allocations of size zero are filtered out
* before reaching the custom allocator.
*
* If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
*
* This function must not call any GLFW function.
*
* @param[in] size The minimum size, in bytes, of the memory block.
* @param[in] user The user-defined pointer from the allocator.
* @return The address of the newly allocated memory block, or `NULL` if an
@ -1426,7 +1455,8 @@ typedef struct GLFWcursor GLFWcursor;
*
* @reentrancy This function should not call any GLFW function.
*
* @thread_safety This function may be called from any thread that calls GLFW functions.
* @thread_safety This function must support being called from any thread that calls GLFW
* functions.
*
* @sa @ref init_allocator
* @sa @ref GLFWallocator
@ -1449,16 +1479,26 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user);
* `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
* failures gracefully yet.
*
* This function may be called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the
* library is no longer flagged as initialized.
* This function must support being called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the library is no
* longer flagged as initialized.
*
* Any memory allocated by this function will be deallocated during library
* termination or earlier.
* Any memory allocated via this function will be deallocated via the same allocator
* during library termination or earlier.
*
* Any memory allocated via this function must be suitably aligned for any object type.
* If you are using C99 or earlier, this alignment is platform-dependent but will be the
* same as what `realloc` provides. If you are using C11 or later, this is the value of
* `alignof(max_align_t)`.
*
* The block address will never be `NULL` and the size will always be greater than zero.
* Reallocations of a block to size zero are converted into deallocations. Reallocations
* of `NULL` to a non-zero size are converted into regular allocations.
* Reallocations of a block to size zero are converted into deallocations before reaching
* the custom allocator. Reallocations of `NULL` to a non-zero size are converted into
* regular allocations before reaching the custom allocator.
*
* If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
*
* This function must not call any GLFW function.
*
* @param[in] block The address of the memory block to reallocate.
* @param[in] size The new minimum size, in bytes, of the memory block.
@ -1471,7 +1511,8 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user);
*
* @reentrancy This function should not call any GLFW function.
*
* @thread_safety This function may be called from any thread that calls GLFW functions.
* @thread_safety This function must support being called from any thread that calls GLFW
* functions.
*
* @sa @ref init_allocator
* @sa @ref GLFWallocator
@ -1493,13 +1534,17 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
* This function may deallocate the specified memory block. This memory block
* will have been allocated with the same allocator.
*
* This function may be called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the
* library is no longer flagged as initialized.
* This function must support being called during @ref glfwInit but before the library is
* flagged as initialized, as well as during @ref glfwTerminate after the library is no
* longer flagged as initialized.
*
* The block address will never be `NULL`. Deallocations of `NULL` are filtered out
* before reaching the custom allocator.
*
* If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
*
* This function must not call any GLFW function.
*
* @param[in] block The address of the memory block to deallocate.
* @param[in] user The user-defined pointer from the allocator.
*
@ -1508,7 +1553,8 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
*
* @reentrancy This function should not call any GLFW function.
*
* @thread_safety This function may be called from any thread that calls GLFW functions.
* @thread_safety This function must support being called from any thread that calls GLFW
* functions.
*
* @sa @ref init_allocator
* @sa @ref GLFWallocator
@ -2076,7 +2122,10 @@ typedef struct GLFWgamepadstate
float axes[6];
} GLFWgamepadstate;
/*! @brief
/*! @brief Custom heap memory allocator.
*
* This describes a custom heap memory allocator for GLFW. To set an allocator, pass it
* to @ref glfwInitAllocator before initializing the library.
*
* @sa @ref init_allocator
* @sa @ref glfwInitAllocator
@ -2087,9 +2136,21 @@ typedef struct GLFWgamepadstate
*/
typedef struct GLFWallocator
{
/*! The memory allocation function. See @ref GLFWallocatefun for details about
* allocation function.
*/
GLFWallocatefun allocate;
/*! The memory reallocation function. See @ref GLFWreallocatefun for details about
* reallocation function.
*/
GLFWreallocatefun reallocate;
/*! The memory deallocation function. See @ref GLFWdeallocatefun for details about
* deallocation function.
*/
GLFWdeallocatefun deallocate;
/*! The user pointer for this custom allocator. This value will be passed to the
* allocator functions.
*/
void* user;
} GLFWallocator;
@ -2134,6 +2195,13 @@ typedef struct GLFWallocator
* and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
* hint.
*
* @remark __Wayland, X11:__ If the library was compiled with support for both
* Wayland and X11, and the @ref GLFW_PLATFORM init hint is set to
* `GLFW_ANY_PLATFORM`, the `XDG_SESSION_TYPE` environment variable affects
* which platform is picked. If the environment variable is not set, or is set
* to something other than `wayland` or `x11`, the regular detection mechanism
* will be used instead.
*
* @remark @x11 This function will set the `LC_CTYPE` category of the
* application locale according to the current environment if that category is
* still "C". This is because the "C" locale breaks Unicode text input.
@ -2222,8 +2290,12 @@ GLFWAPI void glfwInitHint(int hint, int value);
* To use the default allocator, call this function with a `NULL` argument.
*
* If you specify an allocator struct, every member must be a valid function
* pointer. If any member is `NULL`, this function emits @ref
* GLFW_INVALID_VALUE and the init allocator is unchanged.
* pointer. If any member is `NULL`, this function will emit @ref
* GLFW_INVALID_VALUE and the init allocator will be unchanged.
*
* The functions in the allocator must fulfil a number of requirements. See the
* documentation for @ref GLFWallocatefun, @ref GLFWreallocatefun and @ref
* GLFWdeallocatefun for details.
*
* @param[in] allocator The allocator to use at the next initialization, or
* `NULL` to use the default one.
@ -2590,9 +2662,10 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
* specified monitor.
*
* Some platforms do not provide accurate monitor size information, either
* because the monitor
* [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
* data is incorrect or because the driver does not report it accurately.
* because the monitor [EDID][] data is incorrect or because the driver does
* not report it accurately.
*
* [EDID]: https://en.wikipedia.org/wiki/Extended_display_identification_data
*
* Any or all of the size arguments may be `NULL`. If an error occurs, all
* non-`NULL` size arguments will be set to zero.
@ -2639,6 +2712,9 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
*
* @remark @wayland Fractional scaling information is not yet available for
* monitors, so this function only returns integer content scales.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref monitor_scale
@ -2835,11 +2911,11 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
* @param[in] monitor The monitor whose gamma ramp to set.
* @param[in] gamma The desired exponent.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
* @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
*
* @remark @wayland Gamma handling is a privileged protocol, this function
* will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
*
* @thread_safety This function must only be called from the main thread.
*
@ -2859,11 +2935,11 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
* @return The current gamma ramp, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
* and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
*
* @remark @wayland Gamma handling is a privileged protocol, this function
* will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
* returning `NULL`.
*
* @pointer_lifetime The returned structure and its arrays are allocated and
@ -2898,8 +2974,8 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
* @param[in] monitor The monitor whose gamma ramp to set.
* @param[in] ramp The gamma ramp to use.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
* and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
*
* @remark The size of the specified gamma ramp should match the size of the
* current ramp for that monitor.
@ -2907,7 +2983,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
* @remark @win32 The gamma ramp size must be 256.
*
* @remark @wayland Gamma handling is a privileged protocol, this function
* will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
*
* @pointer_lifetime The specified gamma ramp is copied before this function
* returns.
@ -3079,8 +3155,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
* GLFW_PLATFORM_ERROR.
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
*
* @remark @win32 Window creation will fail if the Microsoft GDI software
* OpenGL implementation is the only one available.
@ -3102,23 +3178,35 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
* @remark @macos The GLFW window has no icon, as it is not a document
* window, but the dock icon will be the same as the application bundle's icon.
* For more information on bundles, see the
* [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
* in the Mac Developer Library.
* [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
*
* [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
*
* @remark @macos On OS X 10.10 and later the window frame will not be rendered
* at full resolution on Retina displays unless the
* [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
* [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint)
* hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
* application bundle's `Info.plist`. For more information, see
* [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
* in the Mac Developer Library. The GLFW test and example programs use
* a custom `Info.plist` template for this, which can be found as
* `CMake/Info.plist.in` in the source tree.
* [High Resolution Guidelines for OS X][hidpi-guide] in the Mac Developer
* Library. The GLFW test and example programs use a custom `Info.plist`
* template for this, which can be found as `CMake/Info.plist.in` in the source
* tree.
*
* [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
*
* @remark @macos When activating frame autosaving with
* [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
* window size and position may be overridden by previously saved values.
*
* @remark @wayland GLFW uses [libdecor][] where available to create its window
* decorations. This in turn uses server-side XDG decorations where available
* and provides high quality client-side decorations on compositors like GNOME.
* If both XDG decorations and libdecor are unavailable, GLFW falls back to
* a very simple set of window decorations that only support moving, resizing
* and the window manager's right-click menu.
*
* [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor
*
* @remark @x11 Some window managers will not respect the placement of
* initially hidden windows.
*
@ -3135,20 +3223,6 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
* [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
* override this.
*
* @remark @wayland Compositors should implement the xdg-decoration protocol
* for GLFW to decorate the window properly. If this protocol isn't
* supported, or if the compositor prefers client-side decorations, a very
* simple fallback frame will be drawn using the wp_viewporter protocol. A
* compositor can still emit close, maximize or fullscreen events, using for
* instance a keybind mechanism. If neither of these protocols is supported,
* the window won't be decorated.
*
* @remark @wayland A full screen window will not attempt to change the mode,
* no matter what the requested size or refresh rate.
*
* @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
* to be implemented in the user's compositor.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_creation
@ -3231,6 +3305,38 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
*/
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
/*! @brief Returns the title of the specified window.
*
* This function returns the window title, encoded as UTF-8, of the specified
* window. This is the title set previously by @ref glfwCreateWindow
* or @ref glfwSetWindowTitle.
*
* @param[in] window The window to query.
* @return The UTF-8 encoded window title, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @remark The returned title is currently a copy of the title last set by @ref
* glfwCreateWindow or @ref glfwSetWindowTitle. It does not include any
* additional text which may be appended by the platform or another program.
*
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the next call to @ref
* glfwGetWindowTitle or @ref glfwSetWindowTitle, or until the library is
* terminated.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_title
* @sa @ref glfwSetWindowTitle
*
* @since Added in version 3.4.
*
* @ingroup window
*/
GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window);
/*! @brief Sets the title of the specified window.
*
* This function sets the window title, encoded as UTF-8, of the specified
@ -3248,6 +3354,7 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_title
* @sa @ref glfwGetWindowTitle
*
* @since Added in version 1.0.
* @glfw3 Added window handle parameter.
@ -3287,8 +3394,9 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
* @remark @macos Regular windows do not have icons on macOS. This function
* will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
* the application bundle's icon. For more information on bundles, see the
* [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
* in the Mac Developer Library.
* [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
*
* [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
*
* @remark @wayland There is no existing protocol to change an icon, the
* window will thus inherit the one defined in the application's desktop file.
@ -3512,9 +3620,6 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
*
* @remark @wayland A full screen window will not attempt to change the mode,
* no matter what the requested size.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_size
@ -3846,11 +3951,11 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window);
*
* @param[in] window The window to give input focus.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
*
* @remark @wayland It is not possible for an application to set the input
* focus. This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
* @remark @wayland The compositor will likely ignore focus requests unless
* another window created by the same application already has input focus.
*
* @thread_safety This function must only be called from the main thread.
*
@ -3955,9 +4060,6 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
* @remark @wayland The desired window position is ignored, as there is no way
* for an application to set this property.
*
* @remark @wayland Setting the window to full screen will not attempt to
* change the mode, no matter what the requested size or refresh rate.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_monitor
@ -4030,11 +4132,15 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
* @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
* GLFW_FEATURE_UNAVAILABLE (see remarks).
*
* @remark Calling @ref glfwGetWindowAttrib will always return the latest
* value, even if that value is ignored by the current mode of the window.
*
* @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is
* not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_attribs
@ -4709,8 +4815,8 @@ GLFWAPI int glfwRawMouseMotionSupported(void);
* @param[in] scancode The scancode of the key to query.
* @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
*
* @remark The contents of the returned string may change when a keyboard
* layout change event is received.
@ -4732,15 +4838,18 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode);
*
* This function returns the platform-specific scancode of the specified key.
*
* If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
* method will return `-1`.
* If the specified [key token](@ref keys) corresponds to a physical key not
* supported on the current platform then this method will return `-1`.
* Calling this function with anything other than a key token will return `-1`
* and generate a @ref GLFW_INVALID_ENUM error.
*
* @param[in] key Any [named key](@ref keys).
* @return The platform-specific scancode for the key, or `-1` if an
* [error](@ref error_handling) occurred.
* @param[in] key Any [key token](@ref keys).
* @return The platform-specific scancode for the key, or `-1` if the key is
* not supported on the current platform or an [error](@ref error_handling)
* occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_INVALID_ENUM.
*
* @thread_safety This function may be called from any thread.
*
@ -4881,11 +4990,11 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
* @param[in] ypos The desired y-coordinate, relative to the top edge of the
* content area.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
*
* @remark @wayland This function will only work when the cursor mode is
* `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
* `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE.
*
* @thread_safety This function must only be called from the main thread.
*
@ -5049,9 +5158,9 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
* [character callback](@ref glfwSetCharCallback) instead.
*
* When a window loses input focus, it will generate synthetic key release
* events for all pressed keys. You can tell these events from user-generated
* events by the fact that the synthetic ones are generated after the focus
* loss event has been processed, i.e. after the
* events for all pressed keys with associated key tokens. You can tell these
* events from user-generated events by the fact that the synthetic ones are
* generated after the focus loss event has been processed, i.e. after the
* [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
*
* The scancode of a key is specific to that platform or sometimes even to that
@ -5332,8 +5441,6 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun ca
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @remark @wayland File drop is currently unimplemented.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref path_drop
@ -5800,6 +5907,11 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
*
* @remark @win32 The clipboard on Windows has a single global lock for reading and
* writing. GLFW tries to acquire it a few times, which is almost always enough. If it
* cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
* It is safe to try this multiple times.
*
* @pointer_lifetime The specified string is copied before this function
* returns.
*
@ -5828,6 +5940,11 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
*
* @remark @win32 The clipboard on Windows has a single global lock for reading and
* writing. GLFW tries to acquire it a few times, which is almost always enough. If it
* cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
* It is safe to try this multiple times.
*
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the next call to @ref
* glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
@ -5950,12 +6067,15 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void);
* thread.
*
* This function makes the OpenGL or OpenGL ES context of the specified window
* current on the calling thread. A context must only be made current on
* a single thread at a time and each thread can have only a single current
* context at a time.
* current on the calling thread. It can also detach the current context from
* the calling thread without making a new one current by passing in `NULL`.
*
* When moving a context between threads, you must make it non-current on the
* old thread before making it current on the new one.
* A context must only be made current on a single thread at a time and each
* thread can have only a single current context at a time. Making a context
* current detaches any previously current context on the calling thread.
*
* When moving a context between threads, you must detach it (make it
* non-current) on the old thread before making it current on the new one.
*
* By default, making a context non-current implicitly forces a pipeline flush.
* On machines that support `GL_KHR_context_flush_control`, you can control
@ -5970,6 +6090,10 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void);
* @param[in] window The window whose context to make current, or `NULL` to
* detach the current context.
*
* @remarks If the previously current context was created via a different
* context creation API than the one passed to this function, GLFW will still
* detach the previous one from its API before making the new one current.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
*

View File

@ -169,7 +169,8 @@ extern "C" {
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
* occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -186,7 +187,8 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -202,7 +204,8 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
* @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
@ -228,8 +231,8 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
* @return The `HGLRC` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
*
* @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
@ -255,7 +258,8 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
* @return The `CGDirectDisplayID` of the specified monitor, or
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -271,7 +275,8 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
* @return The `NSWindow` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -281,6 +286,23 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
* @ingroup native
*/
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
/*! @brief Returns the `NSView` of the specified window.
*
* @return The `NSView` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.4.
*
* @ingroup native
*/
GLFWAPI id glfwGetCocoaView(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
@ -289,8 +311,8 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -308,7 +330,8 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
* @return The `Display` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -324,7 +347,8 @@ GLFWAPI Display* glfwGetX11Display(void);
* @return The `RRCrtc` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -340,7 +364,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
* @return The `RROutput` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -356,7 +381,8 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
* @return The `Window` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -371,8 +397,8 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
*
* @param[in] string A UTF-8 encoded string.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
*
* @pointer_lifetime The specified string is copied before this function
* returns.
@ -397,8 +423,8 @@ GLFWAPI void glfwSetX11SelectionString(const char* string);
* @return The contents of the selection as a UTF-8 encoded string, or `NULL`
* if an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
*
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the next call to @ref
@ -424,8 +450,8 @@ GLFWAPI const char* glfwGetX11SelectionString(void);
* @return The `GLXContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -441,8 +467,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
* @return The `GLXWindow` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -460,7 +486,8 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -476,7 +503,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -492,7 +520,8 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
* an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_UNAVAILABLE.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -529,8 +558,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_NO_WINDOW_CONTEXT.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -546,8 +575,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_NO_WINDOW_CONTEXT.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -572,8 +601,8 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_NO_WINDOW_CONTEXT.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -596,8 +625,8 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_NO_WINDOW_CONTEXT.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
@ -613,8 +642,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height
* @return The `OSMesaContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_NO_WINDOW_CONTEXT.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.

View File

@ -72,47 +72,38 @@ if (GLFW_BUILD_WAYLAND)
endif()
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
if (NOT WAYLAND_SCANNER_EXECUTABLE)
message(FATAL_ERROR "Failed to find wayland-scanner")
endif()
include(FindPkgConfig)
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
pkg_get_variable(WAYLAND_CLIENT_PKGDATADIR wayland-client pkgdatadir)
macro(generate_wayland_protocol protocol_file)
set(protocol_path "${GLFW_SOURCE_DIR}/deps/wayland/${protocol_file}")
macro(wayland_generate protocol_file output_file)
add_custom_command(OUTPUT "${output_file}.h"
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h"
DEPENDS "${protocol_file}"
string(REGEX REPLACE "\\.xml$" "-client-protocol.h" header_file ${protocol_file})
string(REGEX REPLACE "\\.xml$" "-client-protocol-code.h" code_file ${protocol_file})
add_custom_command(OUTPUT ${header_file}
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_path}" ${header_file}
DEPENDS "${protocol_path}"
VERBATIM)
add_custom_command(OUTPUT "${output_file}-code.h"
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}-code.h"
DEPENDS "${protocol_file}"
add_custom_command(OUTPUT ${code_file}
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_path}" ${code_file}
DEPENDS "${protocol_path}"
VERBATIM)
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}-code.h")
target_sources(glfw PRIVATE ${header_file} ${code_file})
endmacro()
wayland_generate(
"${WAYLAND_CLIENT_PKGDATADIR}/wayland.xml"
"${GLFW_BINARY_DIR}/src/wayland-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml"
"${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
generate_wayland_protocol("wayland.xml")
generate_wayland_protocol("viewporter.xml")
generate_wayland_protocol("xdg-shell.xml")
generate_wayland_protocol("idle-inhibit-unstable-v1.xml")
generate_wayland_protocol("pointer-constraints-unstable-v1.xml")
generate_wayland_protocol("relative-pointer-unstable-v1.xml")
generate_wayland_protocol("fractional-scale-v1.xml")
generate_wayland_protocol("xdg-activation-v1.xml")
generate_wayland_protocol("xdg-decoration-unstable-v1.xml")
endif()
if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
@ -126,6 +117,7 @@ if (UNIX AND GLFW_BUILD_SHARED_LIBRARY)
else()
set(GLFW_LIB_NAME glfw3)
endif()
set(GLFW_LIB_NAME_SUFFIX "")
set_target_properties(glfw PROPERTIES
OUTPUT_NAME ${GLFW_LIB_NAME}
@ -166,6 +158,8 @@ if (GLFW_BUILD_COCOA)
endif()
if (GLFW_BUILD_WAYLAND)
include(FindPkgConfig)
pkg_check_modules(Wayland REQUIRED
wayland-client>=0.2.7
wayland-cursor>=0.2.7
@ -245,17 +239,6 @@ if (UNIX AND NOT APPLE)
endif()
endif()
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
# source files that VS will build (Clang ignores this because we set -std=c99)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(context.c init.c input.c monitor.c platform.c vulkan.c
window.c null_init.c null_joystick.c null_monitor.c
null_window.c win32_init.c win32_joystick.c win32_module.c
win32_monitor.c win32_time.c win32_thread.c win32_window.c
wgl_context.c egl_context.c osmesa_context.c PROPERTIES
COMPILE_FLAGS -Wdeclaration-after-statement)
endif()
if (WIN32)
if (GLFW_USE_HYBRID_HPG)
target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG)
@ -300,25 +283,9 @@ if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
# Workaround for VS 2008 not shipping with stdint.h
if (MSVC90)
target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/deps/vs2008")
endif()
# Check for the DirectX 9 SDK as it is not included with VS 2008
if (MSVC90)
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND)
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
endif()
endif()
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
endif()
if (GLFW_BUILD_SHARED_LIBRARY)
@ -337,6 +304,7 @@ if (GLFW_BUILD_SHARED_LIBRARY)
# Add a suffix to the import library to avoid naming conflicts
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
endif()
set (GLFW_LIB_NAME_SUFFIX "dll")
target_compile_definitions(glfw INTERFACE GLFW_DLL)
endif()

View File

@ -23,10 +23,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_COCOA)
#include <sys/param.h> // For MAXPATHLEN
// Needed for _NSGetProgname
@ -492,78 +493,78 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform cocoa =
{
GLFW_PLATFORM_COCOA,
_glfwInitCocoa,
_glfwTerminateCocoa,
_glfwGetCursorPosCocoa,
_glfwSetCursorPosCocoa,
_glfwSetCursorModeCocoa,
_glfwSetRawMouseMotionCocoa,
_glfwRawMouseMotionSupportedCocoa,
_glfwCreateCursorCocoa,
_glfwCreateStandardCursorCocoa,
_glfwDestroyCursorCocoa,
_glfwSetCursorCocoa,
_glfwGetScancodeNameCocoa,
_glfwGetKeyScancodeCocoa,
_glfwSetClipboardStringCocoa,
_glfwGetClipboardStringCocoa,
_glfwInitJoysticksCocoa,
_glfwTerminateJoysticksCocoa,
_glfwPollJoystickCocoa,
_glfwGetMappingNameCocoa,
_glfwUpdateGamepadGUIDCocoa,
_glfwFreeMonitorCocoa,
_glfwGetMonitorPosCocoa,
_glfwGetMonitorContentScaleCocoa,
_glfwGetMonitorWorkareaCocoa,
_glfwGetVideoModesCocoa,
_glfwGetVideoModeCocoa,
_glfwGetGammaRampCocoa,
_glfwSetGammaRampCocoa,
_glfwCreateWindowCocoa,
_glfwDestroyWindowCocoa,
_glfwSetWindowTitleCocoa,
_glfwSetWindowIconCocoa,
_glfwGetWindowPosCocoa,
_glfwSetWindowPosCocoa,
_glfwGetWindowSizeCocoa,
_glfwSetWindowSizeCocoa,
_glfwSetWindowSizeLimitsCocoa,
_glfwSetWindowAspectRatioCocoa,
_glfwGetFramebufferSizeCocoa,
_glfwGetWindowFrameSizeCocoa,
_glfwGetWindowContentScaleCocoa,
_glfwIconifyWindowCocoa,
_glfwRestoreWindowCocoa,
_glfwMaximizeWindowCocoa,
_glfwShowWindowCocoa,
_glfwHideWindowCocoa,
_glfwRequestWindowAttentionCocoa,
_glfwFocusWindowCocoa,
_glfwSetWindowMonitorCocoa,
_glfwWindowFocusedCocoa,
_glfwWindowIconifiedCocoa,
_glfwWindowVisibleCocoa,
_glfwWindowMaximizedCocoa,
_glfwWindowHoveredCocoa,
_glfwFramebufferTransparentCocoa,
_glfwGetWindowOpacityCocoa,
_glfwSetWindowResizableCocoa,
_glfwSetWindowDecoratedCocoa,
_glfwSetWindowFloatingCocoa,
_glfwSetWindowOpacityCocoa,
_glfwSetWindowMousePassthroughCocoa,
_glfwPollEventsCocoa,
_glfwWaitEventsCocoa,
_glfwWaitEventsTimeoutCocoa,
_glfwPostEmptyEventCocoa,
_glfwGetEGLPlatformCocoa,
_glfwGetEGLNativeDisplayCocoa,
_glfwGetEGLNativeWindowCocoa,
_glfwGetRequiredInstanceExtensionsCocoa,
_glfwGetPhysicalDevicePresentationSupportCocoa,
_glfwCreateWindowSurfaceCocoa,
.platformID = GLFW_PLATFORM_COCOA,
.init = _glfwInitCocoa,
.terminate = _glfwTerminateCocoa,
.getCursorPos = _glfwGetCursorPosCocoa,
.setCursorPos = _glfwSetCursorPosCocoa,
.setCursorMode = _glfwSetCursorModeCocoa,
.setRawMouseMotion = _glfwSetRawMouseMotionCocoa,
.rawMouseMotionSupported = _glfwRawMouseMotionSupportedCocoa,
.createCursor = _glfwCreateCursorCocoa,
.createStandardCursor = _glfwCreateStandardCursorCocoa,
.destroyCursor = _glfwDestroyCursorCocoa,
.setCursor = _glfwSetCursorCocoa,
.getScancodeName = _glfwGetScancodeNameCocoa,
.getKeyScancode = _glfwGetKeyScancodeCocoa,
.setClipboardString = _glfwSetClipboardStringCocoa,
.getClipboardString = _glfwGetClipboardStringCocoa,
.initJoysticks = _glfwInitJoysticksCocoa,
.terminateJoysticks = _glfwTerminateJoysticksCocoa,
.pollJoystick = _glfwPollJoystickCocoa,
.getMappingName = _glfwGetMappingNameCocoa,
.updateGamepadGUID = _glfwUpdateGamepadGUIDCocoa,
.freeMonitor = _glfwFreeMonitorCocoa,
.getMonitorPos = _glfwGetMonitorPosCocoa,
.getMonitorContentScale = _glfwGetMonitorContentScaleCocoa,
.getMonitorWorkarea = _glfwGetMonitorWorkareaCocoa,
.getVideoModes = _glfwGetVideoModesCocoa,
.getVideoMode = _glfwGetVideoModeCocoa,
.getGammaRamp = _glfwGetGammaRampCocoa,
.setGammaRamp = _glfwSetGammaRampCocoa,
.createWindow = _glfwCreateWindowCocoa,
.destroyWindow = _glfwDestroyWindowCocoa,
.setWindowTitle = _glfwSetWindowTitleCocoa,
.setWindowIcon = _glfwSetWindowIconCocoa,
.getWindowPos = _glfwGetWindowPosCocoa,
.setWindowPos = _glfwSetWindowPosCocoa,
.getWindowSize = _glfwGetWindowSizeCocoa,
.setWindowSize = _glfwSetWindowSizeCocoa,
.setWindowSizeLimits = _glfwSetWindowSizeLimitsCocoa,
.setWindowAspectRatio = _glfwSetWindowAspectRatioCocoa,
.getFramebufferSize = _glfwGetFramebufferSizeCocoa,
.getWindowFrameSize = _glfwGetWindowFrameSizeCocoa,
.getWindowContentScale = _glfwGetWindowContentScaleCocoa,
.iconifyWindow = _glfwIconifyWindowCocoa,
.restoreWindow = _glfwRestoreWindowCocoa,
.maximizeWindow = _glfwMaximizeWindowCocoa,
.showWindow = _glfwShowWindowCocoa,
.hideWindow = _glfwHideWindowCocoa,
.requestWindowAttention = _glfwRequestWindowAttentionCocoa,
.focusWindow = _glfwFocusWindowCocoa,
.setWindowMonitor = _glfwSetWindowMonitorCocoa,
.windowFocused = _glfwWindowFocusedCocoa,
.windowIconified = _glfwWindowIconifiedCocoa,
.windowVisible = _glfwWindowVisibleCocoa,
.windowMaximized = _glfwWindowMaximizedCocoa,
.windowHovered = _glfwWindowHoveredCocoa,
.framebufferTransparent = _glfwFramebufferTransparentCocoa,
.getWindowOpacity = _glfwGetWindowOpacityCocoa,
.setWindowResizable = _glfwSetWindowResizableCocoa,
.setWindowDecorated = _glfwSetWindowDecoratedCocoa,
.setWindowFloating = _glfwSetWindowFloatingCocoa,
.setWindowOpacity = _glfwSetWindowOpacityCocoa,
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughCocoa,
.pollEvents = _glfwPollEventsCocoa,
.waitEvents = _glfwWaitEventsCocoa,
.waitEventsTimeout = _glfwWaitEventsTimeoutCocoa,
.postEmptyEvent = _glfwPostEmptyEventCocoa,
.getEGLPlatform = _glfwGetEGLPlatformCocoa,
.getEGLNativeDisplay = _glfwGetEGLNativeDisplayCocoa,
.getEGLNativeWindow = _glfwGetEGLNativeWindowCocoa,
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsCocoa,
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportCocoa,
.createWindowSurface = _glfwCreateWindowSurfaceCocoa
};
*platform = cocoa;
@ -690,3 +691,5 @@ void _glfwTerminateCocoa(void)
} // autoreleasepool
}
#endif // _GLFW_COCOA

View File

@ -31,8 +31,6 @@
#define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns;
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
#define GLFW_BUILD_COCOA_MAPPINGS
// Cocoa-specific per-joystick data
//
typedef struct _GLFWjoystickNS

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_COCOA)
#include <unistd.h>
#include <ctype.h>
#include <string.h>
@ -134,6 +134,14 @@ static void matchCallback(void* context,
return;
}
CFArrayRef elements =
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
// It is reportedly possible for this to fail on macOS 13 Ventura
// if the application does not have input monitoring permissions
if (!elements)
return;
axes = CFArrayCreateMutable(NULL, 0, NULL);
buttons = CFArrayCreateMutable(NULL, 0, NULL);
hats = CFArrayCreateMutable(NULL, 0, NULL);
@ -177,9 +185,6 @@ static void matchCallback(void* context,
name[8], name[9], name[10]);
}
CFArrayRef elements =
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
for (CFIndex i = 0; i < CFArrayGetCount(elements); i++)
{
IOHIDElementRef native = (IOHIDElementRef)
@ -476,3 +481,5 @@ void _glfwUpdateGamepadGUIDCocoa(char* guid)
}
}
#endif // _GLFW_COCOA

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_COCOA)
#include <stdlib.h>
#include <limits.h>
#include <math.h>
@ -549,13 +549,20 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
} // autoreleasepool
}
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
{
@autoreleasepool {
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
if (!native)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to query display mode");
return GLFW_FALSE;
}
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
CGDisplayModeRelease(native);
return GLFW_TRUE;
} // autoreleasepool
}
@ -622,6 +629,15 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Cocoa: Platform not initialized");
return kCGNullDirectDisplay;
}
return monitor->ns.displayID;
}
#endif // _GLFW_COCOA

View File

@ -145,7 +145,7 @@ typedef struct _GLFWwindowNS
GLFWbool maximized;
GLFWbool occluded;
GLFWbool retina;
GLFWbool scaleFramebuffer;
// Cached window properties to filter out duplicate events
int width, height;
@ -281,7 +281,7 @@ void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);

View File

@ -23,11 +23,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_COCOA_TIMER)
#include <mach/mach_time.h>
@ -53,3 +53,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void)
return _glfw.timer.ns.frequency;
}
#endif // GLFW_BUILD_COCOA_TIMER

View File

@ -23,11 +23,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_COCOA)
#include <float.h>
#include <string.h>
@ -309,10 +309,15 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidChangeOcclusionState:(NSNotification* )notification
{
if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
window->ns.occluded = GLFW_FALSE;
else
window->ns.occluded = GLFW_TRUE;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
if ([window->ns.object respondsToSelector:@selector(occlusionState)])
{
if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
window->ns.occluded = GLFW_FALSE;
else
window->ns.occluded = GLFW_TRUE;
}
#endif
}
@end
@ -508,7 +513,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
{
if (window->ns.retina && window->ns.layer)
if (window->ns.scaleFramebuffer && window->ns.layer)
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
window->ns.xscale = xscale;
@ -867,7 +872,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
[window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)];
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
window->ns.retina = wndconfig->ns.retina;
window->ns.scaleFramebuffer = wndconfig->scaleFramebuffer;
if (fbconfig->transparent)
{
@ -1277,7 +1282,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
if (window->monitor)
{
styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable);
styleMask &= ~(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable);
styleMask |= NSWindowStyleMaskBorderless;
}
else
@ -1652,14 +1657,15 @@ const char* _glfwGetScancodeNameCocoa(int scancode)
{
@autoreleasepool {
if (scancode < 0 || scancode > 0xff ||
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 0xff)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
const int key = _glfw.ns.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
UInt32 deadKeyState = 0;
UniChar characters[4];
@ -1963,7 +1969,7 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
if (window->ns.retina)
if (window->ns.scaleFramebuffer)
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
[window->ns.view setLayer:window->ns.layer];
@ -2041,9 +2047,26 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
"Cocoa: Platform not initialized");
return NULL;
return nil;
}
return window->ns.object;
}
GLFWAPI id glfwGetCocoaView(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
"Cocoa: Platform not initialized");
return nil;
}
return window->ns.view;
}
#endif // _GLFW_COCOA

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
@ -363,6 +361,8 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
glfwMakeContextCurrent((GLFWwindow*) window);
if (_glfwPlatformGetTls(&_glfw.contextSlot) != window)
return GLFW_FALSE;
window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
window->context.getProcAddress("glGetIntegerv");

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
@ -88,13 +86,30 @@ static int getEGLConfigAttrib(EGLConfig config, int attrib)
// Return the EGLConfig most closely matching the specified hints
//
static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* desired,
const _GLFWfbconfig* fbconfig,
EGLConfig* result)
{
EGLConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest;
int i, nativeCount, usableCount;
int i, nativeCount, usableCount, apiBit;
GLFWbool wrongApiAvailable = GLFW_FALSE;
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (ctxconfig->major == 1)
apiBit = EGL_OPENGL_ES_BIT;
else
apiBit = EGL_OPENGL_ES2_BIT;
}
else
apiBit = EGL_OPENGL_BIT;
if (fbconfig->stereo)
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Stereo rendering not supported");
return GLFW_FALSE;
}
eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);
if (!nativeCount)
@ -132,7 +147,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
if (!vi.visualid)
continue;
if (desired->transparent)
if (fbconfig->transparent)
{
int count;
XVisualInfo* vis =
@ -146,23 +161,10 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
}
#endif // _GLFW_X11
if (ctxconfig->client == GLFW_OPENGL_ES_API)
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & apiBit))
{
if (ctxconfig->major == 1)
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
continue;
}
else
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
continue;
}
}
else if (ctxconfig->client == GLFW_OPENGL_API)
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
continue;
wrongApiAvailable = GLFW_TRUE;
continue;
}
u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
@ -182,22 +184,51 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
// with an alpha channel to ensure the buffer is opaque
if (!_glfw.egl.EXT_present_opaque)
{
if (!desired->transparent && u->alphaBits > 0)
if (!fbconfig->transparent && u->alphaBits > 0)
continue;
}
}
#endif // _GLFW_WAYLAND
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = desired->doublebuffer;
u->doublebuffer = fbconfig->doublebuffer;
u->handle = (uintptr_t) n;
usableCount++;
}
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
closest = _glfwChooseFBConfig(fbconfig, usableConfigs, usableCount);
if (closest)
*result = (EGLConfig) closest->handle;
else
{
if (wrongApiAvailable)
{
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (ctxconfig->major == 1)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to find support for OpenGL ES 1.x");
}
else
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to find support for OpenGL ES 2 or later");
}
}
else
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to find support for OpenGL");
}
}
else
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
}
}
_glfw_free(nativeConfigs);
_glfw_free(usableConfigs);
@ -278,6 +309,7 @@ static int extensionSupportedEGL(const char* extension)
static GLFWglproc getProcAddressEGL(const char* procname)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
assert(window != NULL);
if (window->context.egl.client)
{
@ -550,11 +582,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
share = ctxconfig->share->context.egl.handle;
if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
return GLFW_FALSE;
}
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
@ -611,18 +639,18 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
}
if (ctxconfig->noerror)
{
if (_glfw.egl.KHR_create_context_no_error)
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
}
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
SET_ATTRIB(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
SET_ATTRIB(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
}
if (ctxconfig->noerror)
{
if (_glfw.egl.KHR_create_context_no_error)
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
}
if (mask)
SET_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
@ -674,8 +702,11 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
if (!fbconfig->doublebuffer)
SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
if (_glfw.egl.EXT_present_opaque)
SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
{
if (_glfw.egl.EXT_present_opaque)
SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
}
SET_ATTRIB(EGL_NONE, EGL_NONE);
@ -815,11 +846,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
const long vimask = VisualScreenMask | VisualIDMask;
if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
return GLFW_FALSE;
}
eglGetConfigAttrib(_glfw.egl.display, native,
EGL_NATIVE_VISUAL_ID, &visualID);

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_X11)
#include <string.h>
#include <stdlib.h>
#include <assert.h>
@ -190,6 +190,7 @@ static void swapBuffersGLX(_GLFWwindow* window)
static void swapIntervalGLX(int interval)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
assert(window != NULL);
if (_glfw.glx.EXT_swap_control)
{
@ -714,3 +715,5 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
return window->context.glx.window;
}
#endif // _GLFW_X11

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
@ -51,16 +49,22 @@ static GLFWerrorfun _glfwErrorCallback;
static GLFWallocator _glfwInitAllocator;
static _GLFWinitconfig _glfwInitHints =
{
GLFW_TRUE, // hat buttons
GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend
GLFW_ANY_PLATFORM, // preferred platform
NULL, // vkGetInstanceProcAddr function
.hatButtons = GLFW_TRUE,
.angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE,
.platformID = GLFW_ANY_PLATFORM,
.vulkanLoader = NULL,
.ns =
{
GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir
.menubar = GLFW_TRUE,
.chdir = GLFW_TRUE
},
.x11 =
{
GLFW_TRUE, // X11 XCB Vulkan surface
.xcbVulkanSurface = GLFW_TRUE,
},
.wl =
{
.libdecorMode = GLFW_WAYLAND_PREFER_LIBDECOR
},
};
@ -242,30 +246,6 @@ int _glfw_max(int a, int b)
return a > b ? a : b;
}
float _glfw_fminf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a < b)
return a;
else
return b;
}
float _glfw_fmaxf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a > b)
return a;
else
return b;
}
void* _glfw_calloc(size_t count, size_t size)
{
if (count && size)
@ -479,6 +459,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
case GLFW_X11_XCB_VULKAN_SURFACE:
_glfwInitHints.x11.xcbVulkanSurface = value;
return;
case GLFW_WAYLAND_LIBDECOR:
_glfwInitHints.wl.libdecorMode = value;
return;
}
_glfwInputError(GLFW_INVALID_ENUM,

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include "mappings.h"
@ -462,10 +460,11 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
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
// Valid hat values only use the least significant nibble
assert((value & 0xf0) == 0);
assert((value & ((value << 2) | (value >> 2))) == 0);
// Valid hat values do not have both bits of an axis set
assert((value & GLFW_HAT_LEFT) == 0 || (value & GLFW_HAT_RIGHT) == 0);
assert((value & GLFW_HAT_UP) == 0 || (value & GLFW_HAT_DOWN) == 0);
base = js->buttonCount + hat * 4;
@ -701,6 +700,12 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
if (key != GLFW_KEY_UNKNOWN)
{
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
return NULL;
}
if (key != GLFW_KEY_KP_EQUAL &&
(key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) &&
(key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2))
@ -716,12 +721,12 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
GLFWAPI int glfwGetKeyScancode(int key)
{
_GLFW_REQUIRE_INIT_OR_RETURN(-1);
_GLFW_REQUIRE_INIT_OR_RETURN(0);
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
return GLFW_RELEASE;
return -1;
}
return _glfw.platform.getKeyScancode(key);
@ -1433,7 +1438,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
if (e->type == _GLFW_JOYSTICK_AXIS)
{
const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f);
state->axes[i] = fminf(fmaxf(value, -1.f), 1.f);
}
else if (e->type == _GLFW_JOYSTICK_HATBIT)
{

View File

@ -108,12 +108,6 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
#if defined(_GLFW_WIN32)
#define EGLAPIENTRY __stdcall
#else
#define EGLAPIENTRY
#endif
#define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002
@ -200,22 +194,22 @@ typedef void* EGLNativeDisplayType;
typedef void* EGLNativeWindowType;
// EGL function pointer typedefs
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
typedef EGLBoolean (APIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
typedef EGLBoolean (APIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
typedef EGLDisplay (APIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
typedef EGLint (APIENTRY * PFN_eglGetError)(void);
typedef EGLBoolean (APIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
typedef EGLBoolean (APIENTRY * PFN_eglTerminate)(EGLDisplay);
typedef EGLBoolean (APIENTRY * PFN_eglBindAPI)(EGLenum);
typedef EGLContext (APIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
typedef EGLBoolean (APIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
typedef EGLBoolean (APIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
typedef EGLSurface (APIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
typedef EGLBoolean (APIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
typedef EGLBoolean (APIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
typedef EGLBoolean (APIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
typedef const char* (APIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
typedef GLFWglproc (APIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
#define eglGetConfigs _glfw.egl.GetConfigs
#define eglGetDisplay _glfw.egl.GetDisplay
@ -233,8 +227,8 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglQueryString _glfw.egl.QueryString
#define eglGetProcAddress _glfw.egl.GetProcAddress
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
typedef EGLDisplay (APIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
typedef EGLSurface (APIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
@ -330,12 +324,8 @@ typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const c
#include "platform.h"
// Constructs a version number string from the public header macros
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
#define _GLFW_VERSION_NUMBER _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR, \
GLFW_VERSION_MINOR, \
GLFW_VERSION_REVISION)
#define GLFW_NATIVE_INCLUDE_NONE
#include "../include/GLFW/glfw3native.h"
// Checks for whether the library has been initialized
#define _GLFW_REQUIRE_INIT() \
@ -386,6 +376,9 @@ struct _GLFWinitconfig
struct {
GLFWbool xcbVulkanSurface;
} x11;
struct {
int libdecorMode;
} wl;
};
// Window configuration
@ -412,8 +405,8 @@ struct _GLFWwndconfig
GLFWbool focusOnShow;
GLFWbool mousePassthrough;
GLFWbool scaleToMonitor;
GLFWbool scaleFramebuffer;
struct {
GLFWbool retina;
char frameName[256];
} ns;
struct {
@ -422,6 +415,7 @@ struct _GLFWwndconfig
} x11;
struct {
GLFWbool keymenu;
GLFWbool showDefault;
} win32;
struct {
char appId[256];
@ -541,6 +535,7 @@ struct _GLFWwindow
GLFWvidmode videoMode;
_GLFWmonitor* monitor;
_GLFWcursor* cursor;
char* title;
int minwidth, minheight;
int maxwidth, maxheight;
@ -705,7 +700,7 @@ struct _GLFWplatform
void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*);
void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*);
GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*);
void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*);
GLFWbool (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*);
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
// window
@ -1007,8 +1002,6 @@ char** _glfwParseUriList(char* text, int* count);
char* _glfw_strdup(const char* source);
int _glfw_min(int a, int b);
int _glfw_max(int a, int b);
float _glfw_fminf(float a, float b);
float _glfw_fmaxf(float a, float b);
void* _glfw_calloc(size_t count, size_t size);
void* _glfw_realloc(void* pointer, size_t size);

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/inotify.h>
@ -135,7 +135,7 @@ static GLFWbool openJoystickDevice(const char* path)
}
_GLFWjoystickLinux linjs = {0};
linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
linjs.fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (linjs.fd == -1)
return GLFW_FALSE;
@ -324,7 +324,8 @@ GLFWbool _glfwInitJoysticksLinux(void)
// Continue without device connection notifications if inotify fails
if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
_glfw.linjs.regexCompiled = (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) == 0);
if (!_glfw.linjs.regexCompiled)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
return GLFW_FALSE;
@ -376,8 +377,10 @@ void _glfwTerminateJoysticksLinux(void)
inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
close(_glfw.linjs.inotify);
regfree(&_glfw.linjs.regex);
}
if (_glfw.linjs.regexCompiled)
regfree(&_glfw.linjs.regex);
}
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
@ -429,3 +432,5 @@ void _glfwUpdateGamepadGUIDLinux(char* guid)
{
}
#endif // GLFW_BUILD_LINUX_JOYSTICK

View File

@ -31,8 +31,6 @@
#define GLFW_LINUX_JOYSTICK_STATE _GLFWjoystickLinux linjs;
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs;
#define GLFW_BUILD_LINUX_MAPPINGS
// Linux-specific joystick data
//
typedef struct _GLFWjoystickLinux
@ -52,6 +50,7 @@ typedef struct _GLFWlibraryLinux
int inotify;
int watch;
regex_t regex;
GLFWbool regexCompiled;
GLFWbool dropped;
} _GLFWlibraryLinux;

File diff suppressed because it is too large Load Diff

View File

@ -60,7 +60,7 @@
const char* _glfwDefaultMappings[] =
{
#if defined(GLFW_BUILD_WIN32_MAPPINGS)
#if defined(_GLFW_WIN32)
@GLFW_WIN32_MAPPINGS@
"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
@ -69,14 +69,14 @@ const char* _glfwDefaultMappings[] =
"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
#endif // GLFW_BUILD_WIN32_MAPPINGS
#endif // _GLFW_WIN32
#if defined(GLFW_BUILD_COCOA_MAPPINGS)
#if defined(_GLFW_COCOA)
@GLFW_COCOA_MAPPINGS@
#endif // GLFW_BUILD_COCOA_MAPPINGS
#endif // _GLFW_COCOA
#if defined(GLFW_BUILD_LINUX_MAPPINGS)
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
@GLFW_LINUX_MAPPINGS@
#endif // GLFW_BUILD_LINUX_MAPPINGS
#endif // GLFW_BUILD_LINUX_JOYSTICK
};

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
@ -452,7 +450,9 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
if (!_glfw.platform.getVideoMode(monitor, &monitor->currentMode))
return NULL;
return &monitor->currentMode;
}
@ -489,7 +489,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
// Apply gamma curve
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
// Clamp to value range
value = _glfw_fminf(value, 65535.f);
value = fminf(value, 65535.f);
values[i] = (unsigned short) value;
}

View File

@ -23,11 +23,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_COCOA)
#include <unistd.h>
#include <math.h>
@ -81,11 +81,10 @@ static void swapIntervalNSGL(int interval)
@autoreleasepool {
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (window)
{
[window->context.nsgl.object setValues:&interval
forParameter:NSOpenGLContextParameterSwapInterval];
}
assert(window != NULL);
[window->context.nsgl.object setValues:&interval
forParameter:NSOpenGLContextParameterSwapInterval];
} // autoreleasepool
}
@ -162,7 +161,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: OpenGL ES is not available on macOS");
"NSGL: OpenGL ES is not available via NSGL");
return GLFW_FALSE;
}
@ -176,6 +175,13 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
}
}
if (ctxconfig->major >= 3 && ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The compatibility profile is not available on macOS");
return GLFW_FALSE;
}
// Context robustness modes (GL_KHR_robustness) are not yet supported by
// macOS but are not a hard constraint, so ignore and continue
@ -334,7 +340,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
forParameter:NSOpenGLContextParameterSurfaceOpacity];
}
[window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina];
[window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.scaleFramebuffer];
[window->context.nsgl.object setView:window->ns.view];
@ -374,3 +380,5 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
return window->context.nsgl.object;
}
#endif // _GLFW_COCOA

View File

@ -24,12 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <stdlib.h>
#include <string.h>
//////////////////////////////////////////////////////////////////////////
@ -40,78 +39,78 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform null =
{
GLFW_PLATFORM_NULL,
_glfwInitNull,
_glfwTerminateNull,
_glfwGetCursorPosNull,
_glfwSetCursorPosNull,
_glfwSetCursorModeNull,
_glfwSetRawMouseMotionNull,
_glfwRawMouseMotionSupportedNull,
_glfwCreateCursorNull,
_glfwCreateStandardCursorNull,
_glfwDestroyCursorNull,
_glfwSetCursorNull,
_glfwGetScancodeNameNull,
_glfwGetKeyScancodeNull,
_glfwSetClipboardStringNull,
_glfwGetClipboardStringNull,
_glfwInitJoysticksNull,
_glfwTerminateJoysticksNull,
_glfwPollJoystickNull,
_glfwGetMappingNameNull,
_glfwUpdateGamepadGUIDNull,
_glfwFreeMonitorNull,
_glfwGetMonitorPosNull,
_glfwGetMonitorContentScaleNull,
_glfwGetMonitorWorkareaNull,
_glfwGetVideoModesNull,
_glfwGetVideoModeNull,
_glfwGetGammaRampNull,
_glfwSetGammaRampNull,
_glfwCreateWindowNull,
_glfwDestroyWindowNull,
_glfwSetWindowTitleNull,
_glfwSetWindowIconNull,
_glfwGetWindowPosNull,
_glfwSetWindowPosNull,
_glfwGetWindowSizeNull,
_glfwSetWindowSizeNull,
_glfwSetWindowSizeLimitsNull,
_glfwSetWindowAspectRatioNull,
_glfwGetFramebufferSizeNull,
_glfwGetWindowFrameSizeNull,
_glfwGetWindowContentScaleNull,
_glfwIconifyWindowNull,
_glfwRestoreWindowNull,
_glfwMaximizeWindowNull,
_glfwShowWindowNull,
_glfwHideWindowNull,
_glfwRequestWindowAttentionNull,
_glfwFocusWindowNull,
_glfwSetWindowMonitorNull,
_glfwWindowFocusedNull,
_glfwWindowIconifiedNull,
_glfwWindowVisibleNull,
_glfwWindowMaximizedNull,
_glfwWindowHoveredNull,
_glfwFramebufferTransparentNull,
_glfwGetWindowOpacityNull,
_glfwSetWindowResizableNull,
_glfwSetWindowDecoratedNull,
_glfwSetWindowFloatingNull,
_glfwSetWindowOpacityNull,
_glfwSetWindowMousePassthroughNull,
_glfwPollEventsNull,
_glfwWaitEventsNull,
_glfwWaitEventsTimeoutNull,
_glfwPostEmptyEventNull,
_glfwGetEGLPlatformNull,
_glfwGetEGLNativeDisplayNull,
_glfwGetEGLNativeWindowNull,
_glfwGetRequiredInstanceExtensionsNull,
_glfwGetPhysicalDevicePresentationSupportNull,
_glfwCreateWindowSurfaceNull,
.platformID = GLFW_PLATFORM_NULL,
.init = _glfwInitNull,
.terminate = _glfwTerminateNull,
.getCursorPos = _glfwGetCursorPosNull,
.setCursorPos = _glfwSetCursorPosNull,
.setCursorMode = _glfwSetCursorModeNull,
.setRawMouseMotion = _glfwSetRawMouseMotionNull,
.rawMouseMotionSupported = _glfwRawMouseMotionSupportedNull,
.createCursor = _glfwCreateCursorNull,
.createStandardCursor = _glfwCreateStandardCursorNull,
.destroyCursor = _glfwDestroyCursorNull,
.setCursor = _glfwSetCursorNull,
.getScancodeName = _glfwGetScancodeNameNull,
.getKeyScancode = _glfwGetKeyScancodeNull,
.setClipboardString = _glfwSetClipboardStringNull,
.getClipboardString = _glfwGetClipboardStringNull,
.initJoysticks = _glfwInitJoysticksNull,
.terminateJoysticks = _glfwTerminateJoysticksNull,
.pollJoystick = _glfwPollJoystickNull,
.getMappingName = _glfwGetMappingNameNull,
.updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
.freeMonitor = _glfwFreeMonitorNull,
.getMonitorPos = _glfwGetMonitorPosNull,
.getMonitorContentScale = _glfwGetMonitorContentScaleNull,
.getMonitorWorkarea = _glfwGetMonitorWorkareaNull,
.getVideoModes = _glfwGetVideoModesNull,
.getVideoMode = _glfwGetVideoModeNull,
.getGammaRamp = _glfwGetGammaRampNull,
.setGammaRamp = _glfwSetGammaRampNull,
.createWindow = _glfwCreateWindowNull,
.destroyWindow = _glfwDestroyWindowNull,
.setWindowTitle = _glfwSetWindowTitleNull,
.setWindowIcon = _glfwSetWindowIconNull,
.getWindowPos = _glfwGetWindowPosNull,
.setWindowPos = _glfwSetWindowPosNull,
.getWindowSize = _glfwGetWindowSizeNull,
.setWindowSize = _glfwSetWindowSizeNull,
.setWindowSizeLimits = _glfwSetWindowSizeLimitsNull,
.setWindowAspectRatio = _glfwSetWindowAspectRatioNull,
.getFramebufferSize = _glfwGetFramebufferSizeNull,
.getWindowFrameSize = _glfwGetWindowFrameSizeNull,
.getWindowContentScale = _glfwGetWindowContentScaleNull,
.iconifyWindow = _glfwIconifyWindowNull,
.restoreWindow = _glfwRestoreWindowNull,
.maximizeWindow = _glfwMaximizeWindowNull,
.showWindow = _glfwShowWindowNull,
.hideWindow = _glfwHideWindowNull,
.requestWindowAttention = _glfwRequestWindowAttentionNull,
.focusWindow = _glfwFocusWindowNull,
.setWindowMonitor = _glfwSetWindowMonitorNull,
.windowFocused = _glfwWindowFocusedNull,
.windowIconified = _glfwWindowIconifiedNull,
.windowVisible = _glfwWindowVisibleNull,
.windowMaximized = _glfwWindowMaximizedNull,
.windowHovered = _glfwWindowHoveredNull,
.framebufferTransparent = _glfwFramebufferTransparentNull,
.getWindowOpacity = _glfwGetWindowOpacityNull,
.setWindowResizable = _glfwSetWindowResizableNull,
.setWindowDecorated = _glfwSetWindowDecoratedNull,
.setWindowFloating = _glfwSetWindowFloatingNull,
.setWindowOpacity = _glfwSetWindowOpacityNull,
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughNull,
.pollEvents = _glfwPollEventsNull,
.waitEvents = _glfwWaitEventsNull,
.waitEventsTimeout = _glfwWaitEventsTimeoutNull,
.postEmptyEvent = _glfwPostEmptyEventNull,
.getEGLPlatform = _glfwGetEGLPlatformNull,
.getEGLNativeDisplay = _glfwGetEGLNativeDisplayNull,
.getEGLNativeWindow = _glfwGetEGLNativeWindowNull,
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsNull,
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportNull,
.createWindowSurface = _glfwCreateWindowSurfaceNull
};
*platform = null;
@ -120,6 +119,138 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
int _glfwInitNull(void)
{
int scancode;
memset(_glfw.null.keycodes, -1, sizeof(_glfw.null.keycodes));
memset(_glfw.null.scancodes, -1, sizeof(_glfw.null.scancodes));
_glfw.null.keycodes[GLFW_NULL_SC_SPACE] = GLFW_KEY_SPACE;
_glfw.null.keycodes[GLFW_NULL_SC_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
_glfw.null.keycodes[GLFW_NULL_SC_COMMA] = GLFW_KEY_COMMA;
_glfw.null.keycodes[GLFW_NULL_SC_MINUS] = GLFW_KEY_MINUS;
_glfw.null.keycodes[GLFW_NULL_SC_PERIOD] = GLFW_KEY_PERIOD;
_glfw.null.keycodes[GLFW_NULL_SC_SLASH] = GLFW_KEY_SLASH;
_glfw.null.keycodes[GLFW_NULL_SC_0] = GLFW_KEY_0;
_glfw.null.keycodes[GLFW_NULL_SC_1] = GLFW_KEY_1;
_glfw.null.keycodes[GLFW_NULL_SC_2] = GLFW_KEY_2;
_glfw.null.keycodes[GLFW_NULL_SC_3] = GLFW_KEY_3;
_glfw.null.keycodes[GLFW_NULL_SC_4] = GLFW_KEY_4;
_glfw.null.keycodes[GLFW_NULL_SC_5] = GLFW_KEY_5;
_glfw.null.keycodes[GLFW_NULL_SC_6] = GLFW_KEY_6;
_glfw.null.keycodes[GLFW_NULL_SC_7] = GLFW_KEY_7;
_glfw.null.keycodes[GLFW_NULL_SC_8] = GLFW_KEY_8;
_glfw.null.keycodes[GLFW_NULL_SC_9] = GLFW_KEY_9;
_glfw.null.keycodes[GLFW_NULL_SC_SEMICOLON] = GLFW_KEY_SEMICOLON;
_glfw.null.keycodes[GLFW_NULL_SC_EQUAL] = GLFW_KEY_EQUAL;
_glfw.null.keycodes[GLFW_NULL_SC_A] = GLFW_KEY_A;
_glfw.null.keycodes[GLFW_NULL_SC_B] = GLFW_KEY_B;
_glfw.null.keycodes[GLFW_NULL_SC_C] = GLFW_KEY_C;
_glfw.null.keycodes[GLFW_NULL_SC_D] = GLFW_KEY_D;
_glfw.null.keycodes[GLFW_NULL_SC_E] = GLFW_KEY_E;
_glfw.null.keycodes[GLFW_NULL_SC_F] = GLFW_KEY_F;
_glfw.null.keycodes[GLFW_NULL_SC_G] = GLFW_KEY_G;
_glfw.null.keycodes[GLFW_NULL_SC_H] = GLFW_KEY_H;
_glfw.null.keycodes[GLFW_NULL_SC_I] = GLFW_KEY_I;
_glfw.null.keycodes[GLFW_NULL_SC_J] = GLFW_KEY_J;
_glfw.null.keycodes[GLFW_NULL_SC_K] = GLFW_KEY_K;
_glfw.null.keycodes[GLFW_NULL_SC_L] = GLFW_KEY_L;
_glfw.null.keycodes[GLFW_NULL_SC_M] = GLFW_KEY_M;
_glfw.null.keycodes[GLFW_NULL_SC_N] = GLFW_KEY_N;
_glfw.null.keycodes[GLFW_NULL_SC_O] = GLFW_KEY_O;
_glfw.null.keycodes[GLFW_NULL_SC_P] = GLFW_KEY_P;
_glfw.null.keycodes[GLFW_NULL_SC_Q] = GLFW_KEY_Q;
_glfw.null.keycodes[GLFW_NULL_SC_R] = GLFW_KEY_R;
_glfw.null.keycodes[GLFW_NULL_SC_S] = GLFW_KEY_S;
_glfw.null.keycodes[GLFW_NULL_SC_T] = GLFW_KEY_T;
_glfw.null.keycodes[GLFW_NULL_SC_U] = GLFW_KEY_U;
_glfw.null.keycodes[GLFW_NULL_SC_V] = GLFW_KEY_V;
_glfw.null.keycodes[GLFW_NULL_SC_W] = GLFW_KEY_W;
_glfw.null.keycodes[GLFW_NULL_SC_X] = GLFW_KEY_X;
_glfw.null.keycodes[GLFW_NULL_SC_Y] = GLFW_KEY_Y;
_glfw.null.keycodes[GLFW_NULL_SC_Z] = GLFW_KEY_Z;
_glfw.null.keycodes[GLFW_NULL_SC_LEFT_BRACKET] = GLFW_KEY_LEFT_BRACKET;
_glfw.null.keycodes[GLFW_NULL_SC_BACKSLASH] = GLFW_KEY_BACKSLASH;
_glfw.null.keycodes[GLFW_NULL_SC_RIGHT_BRACKET] = GLFW_KEY_RIGHT_BRACKET;
_glfw.null.keycodes[GLFW_NULL_SC_GRAVE_ACCENT] = GLFW_KEY_GRAVE_ACCENT;
_glfw.null.keycodes[GLFW_NULL_SC_WORLD_1] = GLFW_KEY_WORLD_1;
_glfw.null.keycodes[GLFW_NULL_SC_WORLD_2] = GLFW_KEY_WORLD_2;
_glfw.null.keycodes[GLFW_NULL_SC_ESCAPE] = GLFW_KEY_ESCAPE;
_glfw.null.keycodes[GLFW_NULL_SC_ENTER] = GLFW_KEY_ENTER;
_glfw.null.keycodes[GLFW_NULL_SC_TAB] = GLFW_KEY_TAB;
_glfw.null.keycodes[GLFW_NULL_SC_BACKSPACE] = GLFW_KEY_BACKSPACE;
_glfw.null.keycodes[GLFW_NULL_SC_INSERT] = GLFW_KEY_INSERT;
_glfw.null.keycodes[GLFW_NULL_SC_DELETE] = GLFW_KEY_DELETE;
_glfw.null.keycodes[GLFW_NULL_SC_RIGHT] = GLFW_KEY_RIGHT;
_glfw.null.keycodes[GLFW_NULL_SC_LEFT] = GLFW_KEY_LEFT;
_glfw.null.keycodes[GLFW_NULL_SC_DOWN] = GLFW_KEY_DOWN;
_glfw.null.keycodes[GLFW_NULL_SC_UP] = GLFW_KEY_UP;
_glfw.null.keycodes[GLFW_NULL_SC_PAGE_UP] = GLFW_KEY_PAGE_UP;
_glfw.null.keycodes[GLFW_NULL_SC_PAGE_DOWN] = GLFW_KEY_PAGE_DOWN;
_glfw.null.keycodes[GLFW_NULL_SC_HOME] = GLFW_KEY_HOME;
_glfw.null.keycodes[GLFW_NULL_SC_END] = GLFW_KEY_END;
_glfw.null.keycodes[GLFW_NULL_SC_CAPS_LOCK] = GLFW_KEY_CAPS_LOCK;
_glfw.null.keycodes[GLFW_NULL_SC_SCROLL_LOCK] = GLFW_KEY_SCROLL_LOCK;
_glfw.null.keycodes[GLFW_NULL_SC_NUM_LOCK] = GLFW_KEY_NUM_LOCK;
_glfw.null.keycodes[GLFW_NULL_SC_PRINT_SCREEN] = GLFW_KEY_PRINT_SCREEN;
_glfw.null.keycodes[GLFW_NULL_SC_PAUSE] = GLFW_KEY_PAUSE;
_glfw.null.keycodes[GLFW_NULL_SC_F1] = GLFW_KEY_F1;
_glfw.null.keycodes[GLFW_NULL_SC_F2] = GLFW_KEY_F2;
_glfw.null.keycodes[GLFW_NULL_SC_F3] = GLFW_KEY_F3;
_glfw.null.keycodes[GLFW_NULL_SC_F4] = GLFW_KEY_F4;
_glfw.null.keycodes[GLFW_NULL_SC_F5] = GLFW_KEY_F5;
_glfw.null.keycodes[GLFW_NULL_SC_F6] = GLFW_KEY_F6;
_glfw.null.keycodes[GLFW_NULL_SC_F7] = GLFW_KEY_F7;
_glfw.null.keycodes[GLFW_NULL_SC_F8] = GLFW_KEY_F8;
_glfw.null.keycodes[GLFW_NULL_SC_F9] = GLFW_KEY_F9;
_glfw.null.keycodes[GLFW_NULL_SC_F10] = GLFW_KEY_F10;
_glfw.null.keycodes[GLFW_NULL_SC_F11] = GLFW_KEY_F11;
_glfw.null.keycodes[GLFW_NULL_SC_F12] = GLFW_KEY_F12;
_glfw.null.keycodes[GLFW_NULL_SC_F13] = GLFW_KEY_F13;
_glfw.null.keycodes[GLFW_NULL_SC_F14] = GLFW_KEY_F14;
_glfw.null.keycodes[GLFW_NULL_SC_F15] = GLFW_KEY_F15;
_glfw.null.keycodes[GLFW_NULL_SC_F16] = GLFW_KEY_F16;
_glfw.null.keycodes[GLFW_NULL_SC_F17] = GLFW_KEY_F17;
_glfw.null.keycodes[GLFW_NULL_SC_F18] = GLFW_KEY_F18;
_glfw.null.keycodes[GLFW_NULL_SC_F19] = GLFW_KEY_F19;
_glfw.null.keycodes[GLFW_NULL_SC_F20] = GLFW_KEY_F20;
_glfw.null.keycodes[GLFW_NULL_SC_F21] = GLFW_KEY_F21;
_glfw.null.keycodes[GLFW_NULL_SC_F22] = GLFW_KEY_F22;
_glfw.null.keycodes[GLFW_NULL_SC_F23] = GLFW_KEY_F23;
_glfw.null.keycodes[GLFW_NULL_SC_F24] = GLFW_KEY_F24;
_glfw.null.keycodes[GLFW_NULL_SC_F25] = GLFW_KEY_F25;
_glfw.null.keycodes[GLFW_NULL_SC_KP_0] = GLFW_KEY_KP_0;
_glfw.null.keycodes[GLFW_NULL_SC_KP_1] = GLFW_KEY_KP_1;
_glfw.null.keycodes[GLFW_NULL_SC_KP_2] = GLFW_KEY_KP_2;
_glfw.null.keycodes[GLFW_NULL_SC_KP_3] = GLFW_KEY_KP_3;
_glfw.null.keycodes[GLFW_NULL_SC_KP_4] = GLFW_KEY_KP_4;
_glfw.null.keycodes[GLFW_NULL_SC_KP_5] = GLFW_KEY_KP_5;
_glfw.null.keycodes[GLFW_NULL_SC_KP_6] = GLFW_KEY_KP_6;
_glfw.null.keycodes[GLFW_NULL_SC_KP_7] = GLFW_KEY_KP_7;
_glfw.null.keycodes[GLFW_NULL_SC_KP_8] = GLFW_KEY_KP_8;
_glfw.null.keycodes[GLFW_NULL_SC_KP_9] = GLFW_KEY_KP_9;
_glfw.null.keycodes[GLFW_NULL_SC_KP_DECIMAL] = GLFW_KEY_KP_DECIMAL;
_glfw.null.keycodes[GLFW_NULL_SC_KP_DIVIDE] = GLFW_KEY_KP_DIVIDE;
_glfw.null.keycodes[GLFW_NULL_SC_KP_MULTIPLY] = GLFW_KEY_KP_MULTIPLY;
_glfw.null.keycodes[GLFW_NULL_SC_KP_SUBTRACT] = GLFW_KEY_KP_SUBTRACT;
_glfw.null.keycodes[GLFW_NULL_SC_KP_ADD] = GLFW_KEY_KP_ADD;
_glfw.null.keycodes[GLFW_NULL_SC_KP_ENTER] = GLFW_KEY_KP_ENTER;
_glfw.null.keycodes[GLFW_NULL_SC_KP_EQUAL] = GLFW_KEY_KP_EQUAL;
_glfw.null.keycodes[GLFW_NULL_SC_LEFT_SHIFT] = GLFW_KEY_LEFT_SHIFT;
_glfw.null.keycodes[GLFW_NULL_SC_LEFT_CONTROL] = GLFW_KEY_LEFT_CONTROL;
_glfw.null.keycodes[GLFW_NULL_SC_LEFT_ALT] = GLFW_KEY_LEFT_ALT;
_glfw.null.keycodes[GLFW_NULL_SC_LEFT_SUPER] = GLFW_KEY_LEFT_SUPER;
_glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SHIFT] = GLFW_KEY_RIGHT_SHIFT;
_glfw.null.keycodes[GLFW_NULL_SC_RIGHT_CONTROL] = GLFW_KEY_RIGHT_CONTROL;
_glfw.null.keycodes[GLFW_NULL_SC_RIGHT_ALT] = GLFW_KEY_RIGHT_ALT;
_glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SUPER] = GLFW_KEY_RIGHT_SUPER;
_glfw.null.keycodes[GLFW_NULL_SC_MENU] = GLFW_KEY_MENU;
for (scancode = GLFW_NULL_SC_FIRST; scancode < GLFW_NULL_SC_LAST; scancode++)
{
if (_glfw.null.keycodes[scancode] > 0)
_glfw.null.scancodes[_glfw.null.keycodes[scancode]] = scancode;
}
_glfwPollMonitorsNull();
return GLFW_TRUE;
}

View File

@ -23,8 +23,6 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
@ -111,9 +109,10 @@ GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
return mode;
}
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
{
*mode = getVideoMode();
return GLFW_TRUE;
}
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -130,7 +129,7 @@ GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
float value;
value = i / (float) (monitor->null.ramp.size - 1);
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
value = _glfw_fminf(value, 65535.f);
value = fminf(value, 65535.f);
monitor->null.ramp.red[i] = (unsigned short) value;
monitor->null.ramp.green[i] = (unsigned short) value;

View File

@ -33,6 +33,128 @@
#define GLFW_NULL_CURSOR_STATE
#define GLFW_NULL_LIBRARY_CONTEXT_STATE
#define GLFW_NULL_SC_FIRST GLFW_NULL_SC_SPACE
#define GLFW_NULL_SC_SPACE 1
#define GLFW_NULL_SC_APOSTROPHE 2
#define GLFW_NULL_SC_COMMA 3
#define GLFW_NULL_SC_MINUS 4
#define GLFW_NULL_SC_PERIOD 5
#define GLFW_NULL_SC_SLASH 6
#define GLFW_NULL_SC_0 7
#define GLFW_NULL_SC_1 8
#define GLFW_NULL_SC_2 9
#define GLFW_NULL_SC_3 10
#define GLFW_NULL_SC_4 11
#define GLFW_NULL_SC_5 12
#define GLFW_NULL_SC_6 13
#define GLFW_NULL_SC_7 14
#define GLFW_NULL_SC_8 15
#define GLFW_NULL_SC_9 16
#define GLFW_NULL_SC_SEMICOLON 17
#define GLFW_NULL_SC_EQUAL 18
#define GLFW_NULL_SC_LEFT_BRACKET 19
#define GLFW_NULL_SC_BACKSLASH 20
#define GLFW_NULL_SC_RIGHT_BRACKET 21
#define GLFW_NULL_SC_GRAVE_ACCENT 22
#define GLFW_NULL_SC_WORLD_1 23
#define GLFW_NULL_SC_WORLD_2 24
#define GLFW_NULL_SC_ESCAPE 25
#define GLFW_NULL_SC_ENTER 26
#define GLFW_NULL_SC_TAB 27
#define GLFW_NULL_SC_BACKSPACE 28
#define GLFW_NULL_SC_INSERT 29
#define GLFW_NULL_SC_DELETE 30
#define GLFW_NULL_SC_RIGHT 31
#define GLFW_NULL_SC_LEFT 32
#define GLFW_NULL_SC_DOWN 33
#define GLFW_NULL_SC_UP 34
#define GLFW_NULL_SC_PAGE_UP 35
#define GLFW_NULL_SC_PAGE_DOWN 36
#define GLFW_NULL_SC_HOME 37
#define GLFW_NULL_SC_END 38
#define GLFW_NULL_SC_CAPS_LOCK 39
#define GLFW_NULL_SC_SCROLL_LOCK 40
#define GLFW_NULL_SC_NUM_LOCK 41
#define GLFW_NULL_SC_PRINT_SCREEN 42
#define GLFW_NULL_SC_PAUSE 43
#define GLFW_NULL_SC_A 44
#define GLFW_NULL_SC_B 45
#define GLFW_NULL_SC_C 46
#define GLFW_NULL_SC_D 47
#define GLFW_NULL_SC_E 48
#define GLFW_NULL_SC_F 49
#define GLFW_NULL_SC_G 50
#define GLFW_NULL_SC_H 51
#define GLFW_NULL_SC_I 52
#define GLFW_NULL_SC_J 53
#define GLFW_NULL_SC_K 54
#define GLFW_NULL_SC_L 55
#define GLFW_NULL_SC_M 56
#define GLFW_NULL_SC_N 57
#define GLFW_NULL_SC_O 58
#define GLFW_NULL_SC_P 59
#define GLFW_NULL_SC_Q 60
#define GLFW_NULL_SC_R 61
#define GLFW_NULL_SC_S 62
#define GLFW_NULL_SC_T 63
#define GLFW_NULL_SC_U 64
#define GLFW_NULL_SC_V 65
#define GLFW_NULL_SC_W 66
#define GLFW_NULL_SC_X 67
#define GLFW_NULL_SC_Y 68
#define GLFW_NULL_SC_Z 69
#define GLFW_NULL_SC_F1 70
#define GLFW_NULL_SC_F2 71
#define GLFW_NULL_SC_F3 72
#define GLFW_NULL_SC_F4 73
#define GLFW_NULL_SC_F5 74
#define GLFW_NULL_SC_F6 75
#define GLFW_NULL_SC_F7 76
#define GLFW_NULL_SC_F8 77
#define GLFW_NULL_SC_F9 78
#define GLFW_NULL_SC_F10 79
#define GLFW_NULL_SC_F11 80
#define GLFW_NULL_SC_F12 81
#define GLFW_NULL_SC_F13 82
#define GLFW_NULL_SC_F14 83
#define GLFW_NULL_SC_F15 84
#define GLFW_NULL_SC_F16 85
#define GLFW_NULL_SC_F17 86
#define GLFW_NULL_SC_F18 87
#define GLFW_NULL_SC_F19 88
#define GLFW_NULL_SC_F20 89
#define GLFW_NULL_SC_F21 90
#define GLFW_NULL_SC_F22 91
#define GLFW_NULL_SC_F23 92
#define GLFW_NULL_SC_F24 93
#define GLFW_NULL_SC_F25 94
#define GLFW_NULL_SC_KP_0 95
#define GLFW_NULL_SC_KP_1 96
#define GLFW_NULL_SC_KP_2 97
#define GLFW_NULL_SC_KP_3 98
#define GLFW_NULL_SC_KP_4 99
#define GLFW_NULL_SC_KP_5 100
#define GLFW_NULL_SC_KP_6 101
#define GLFW_NULL_SC_KP_7 102
#define GLFW_NULL_SC_KP_8 103
#define GLFW_NULL_SC_KP_9 104
#define GLFW_NULL_SC_KP_DECIMAL 105
#define GLFW_NULL_SC_KP_DIVIDE 106
#define GLFW_NULL_SC_KP_MULTIPLY 107
#define GLFW_NULL_SC_KP_SUBTRACT 108
#define GLFW_NULL_SC_KP_ADD 109
#define GLFW_NULL_SC_KP_ENTER 110
#define GLFW_NULL_SC_KP_EQUAL 111
#define GLFW_NULL_SC_LEFT_SHIFT 112
#define GLFW_NULL_SC_LEFT_CONTROL 113
#define GLFW_NULL_SC_LEFT_ALT 114
#define GLFW_NULL_SC_LEFT_SUPER 115
#define GLFW_NULL_SC_RIGHT_SHIFT 116
#define GLFW_NULL_SC_RIGHT_CONTROL 117
#define GLFW_NULL_SC_RIGHT_ALT 118
#define GLFW_NULL_SC_RIGHT_SUPER 119
#define GLFW_NULL_SC_MENU 120
#define GLFW_NULL_SC_LAST GLFW_NULL_SC_MENU
// Null-specific per-window data
//
@ -42,7 +164,6 @@ typedef struct _GLFWwindowNull
int ypos;
int width;
int height;
char* title;
GLFWbool visible;
GLFWbool iconified;
GLFWbool maximized;
@ -68,6 +189,8 @@ typedef struct _GLFWlibraryNull
int ycursor;
char* clipboardString;
_GLFWwindow* focusedWindow;
uint16_t keycodes[GLFW_NULL_SC_LAST + 1];
uint8_t scancodes[GLFW_KEY_LAST + 1];
} _GLFWlibraryNull;
void _glfwPollMonitorsNull(void);
@ -81,7 +204,7 @@ void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
@ -115,7 +238,6 @@ void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled);
GLFWbool _glfwRawMouseMotionSupportedNull(void);
void _glfwShowWindowNull(_GLFWwindow* window);
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
void _glfwHideWindowNull(_GLFWwindow* window);
void _glfwFocusWindowNull(_GLFWwindow* window);
GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window);

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
@ -260,8 +258,9 @@ void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height)
{
window->null.width = width;
window->null.height = height;
_glfwInputWindowSize(window, width, height);
_glfwInputFramebufferSize(window, width, height);
_glfwInputWindowDamage(window);
_glfwInputWindowSize(window, width, height);
}
}
@ -568,7 +567,7 @@ EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
const char* _glfwGetScancodeNameNull(int scancode)
{
if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)
if (scancode < GLFW_NULL_SC_FIRST || scancode > GLFW_NULL_SC_LAST)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
@ -576,117 +575,117 @@ const char* _glfwGetScancodeNameNull(int scancode)
switch (scancode)
{
case GLFW_KEY_APOSTROPHE:
case GLFW_NULL_SC_APOSTROPHE:
return "'";
case GLFW_KEY_COMMA:
case GLFW_NULL_SC_COMMA:
return ",";
case GLFW_KEY_MINUS:
case GLFW_KEY_KP_SUBTRACT:
case GLFW_NULL_SC_MINUS:
case GLFW_NULL_SC_KP_SUBTRACT:
return "-";
case GLFW_KEY_PERIOD:
case GLFW_KEY_KP_DECIMAL:
case GLFW_NULL_SC_PERIOD:
case GLFW_NULL_SC_KP_DECIMAL:
return ".";
case GLFW_KEY_SLASH:
case GLFW_KEY_KP_DIVIDE:
case GLFW_NULL_SC_SLASH:
case GLFW_NULL_SC_KP_DIVIDE:
return "/";
case GLFW_KEY_SEMICOLON:
case GLFW_NULL_SC_SEMICOLON:
return ";";
case GLFW_KEY_EQUAL:
case GLFW_KEY_KP_EQUAL:
case GLFW_NULL_SC_EQUAL:
case GLFW_NULL_SC_KP_EQUAL:
return "=";
case GLFW_KEY_LEFT_BRACKET:
case GLFW_NULL_SC_LEFT_BRACKET:
return "[";
case GLFW_KEY_RIGHT_BRACKET:
case GLFW_NULL_SC_RIGHT_BRACKET:
return "]";
case GLFW_KEY_KP_MULTIPLY:
case GLFW_NULL_SC_KP_MULTIPLY:
return "*";
case GLFW_KEY_KP_ADD:
case GLFW_NULL_SC_KP_ADD:
return "+";
case GLFW_KEY_BACKSLASH:
case GLFW_KEY_WORLD_1:
case GLFW_KEY_WORLD_2:
case GLFW_NULL_SC_BACKSLASH:
case GLFW_NULL_SC_WORLD_1:
case GLFW_NULL_SC_WORLD_2:
return "\\";
case GLFW_KEY_0:
case GLFW_KEY_KP_0:
case GLFW_NULL_SC_0:
case GLFW_NULL_SC_KP_0:
return "0";
case GLFW_KEY_1:
case GLFW_KEY_KP_1:
case GLFW_NULL_SC_1:
case GLFW_NULL_SC_KP_1:
return "1";
case GLFW_KEY_2:
case GLFW_KEY_KP_2:
case GLFW_NULL_SC_2:
case GLFW_NULL_SC_KP_2:
return "2";
case GLFW_KEY_3:
case GLFW_KEY_KP_3:
case GLFW_NULL_SC_3:
case GLFW_NULL_SC_KP_3:
return "3";
case GLFW_KEY_4:
case GLFW_KEY_KP_4:
case GLFW_NULL_SC_4:
case GLFW_NULL_SC_KP_4:
return "4";
case GLFW_KEY_5:
case GLFW_KEY_KP_5:
case GLFW_NULL_SC_5:
case GLFW_NULL_SC_KP_5:
return "5";
case GLFW_KEY_6:
case GLFW_KEY_KP_6:
case GLFW_NULL_SC_6:
case GLFW_NULL_SC_KP_6:
return "6";
case GLFW_KEY_7:
case GLFW_KEY_KP_7:
case GLFW_NULL_SC_7:
case GLFW_NULL_SC_KP_7:
return "7";
case GLFW_KEY_8:
case GLFW_KEY_KP_8:
case GLFW_NULL_SC_8:
case GLFW_NULL_SC_KP_8:
return "8";
case GLFW_KEY_9:
case GLFW_KEY_KP_9:
case GLFW_NULL_SC_9:
case GLFW_NULL_SC_KP_9:
return "9";
case GLFW_KEY_A:
case GLFW_NULL_SC_A:
return "a";
case GLFW_KEY_B:
case GLFW_NULL_SC_B:
return "b";
case GLFW_KEY_C:
case GLFW_NULL_SC_C:
return "c";
case GLFW_KEY_D:
case GLFW_NULL_SC_D:
return "d";
case GLFW_KEY_E:
case GLFW_NULL_SC_E:
return "e";
case GLFW_KEY_F:
case GLFW_NULL_SC_F:
return "f";
case GLFW_KEY_G:
case GLFW_NULL_SC_G:
return "g";
case GLFW_KEY_H:
case GLFW_NULL_SC_H:
return "h";
case GLFW_KEY_I:
case GLFW_NULL_SC_I:
return "i";
case GLFW_KEY_J:
case GLFW_NULL_SC_J:
return "j";
case GLFW_KEY_K:
case GLFW_NULL_SC_K:
return "k";
case GLFW_KEY_L:
case GLFW_NULL_SC_L:
return "l";
case GLFW_KEY_M:
case GLFW_NULL_SC_M:
return "m";
case GLFW_KEY_N:
case GLFW_NULL_SC_N:
return "n";
case GLFW_KEY_O:
case GLFW_NULL_SC_O:
return "o";
case GLFW_KEY_P:
case GLFW_NULL_SC_P:
return "p";
case GLFW_KEY_Q:
case GLFW_NULL_SC_Q:
return "q";
case GLFW_KEY_R:
case GLFW_NULL_SC_R:
return "r";
case GLFW_KEY_S:
case GLFW_NULL_SC_S:
return "s";
case GLFW_KEY_T:
case GLFW_NULL_SC_T:
return "t";
case GLFW_KEY_U:
case GLFW_NULL_SC_U:
return "u";
case GLFW_KEY_V:
case GLFW_NULL_SC_V:
return "v";
case GLFW_KEY_W:
case GLFW_NULL_SC_W:
return "w";
case GLFW_KEY_X:
case GLFW_NULL_SC_X:
return "x";
case GLFW_KEY_Y:
case GLFW_NULL_SC_Y:
return "y";
case GLFW_KEY_Z:
case GLFW_NULL_SC_Z:
return "z";
}
@ -695,7 +694,7 @@ const char* _glfwGetScancodeNameNull(int scancode)
int _glfwGetKeyScancodeNull(int key)
{
return key;
return _glfw.null.scancodes[key];
}
void _glfwGetRequiredInstanceExtensionsNull(char** extensions)

View File

@ -24,16 +24,13 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "internal.h"
static void makeContextCurrentOSMesa(_GLFWwindow* window)
{
if (window)

View File

@ -24,11 +24,16 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <string.h>
#include <stdlib.h>
// These construct a string literal from individual numeric constants
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
@ -45,12 +50,12 @@ static const struct
#if defined(_GLFW_COCOA)
{ GLFW_PLATFORM_COCOA, _glfwConnectCocoa },
#endif
#if defined(_GLFW_X11)
{ GLFW_PLATFORM_X11, _glfwConnectX11 },
#endif
#if defined(_GLFW_WAYLAND)
{ GLFW_PLATFORM_WAYLAND, _glfwConnectWayland },
#endif
#if defined(_GLFW_X11)
{ GLFW_PLATFORM_X11, _glfwConnectX11 },
#endif
};
GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
@ -71,13 +76,29 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
// Only allow the Null platform if specifically requested
if (desiredID == GLFW_PLATFORM_NULL)
return GLFW_FALSE; //_glfwConnectNull(desiredID, platform); // @raysan5
return _glfwConnectNull(desiredID, platform);
else if (count == 0)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform");
return GLFW_FALSE;
}
#if defined(_GLFW_WAYLAND) && defined(_GLFW_X11)
if (desiredID == GLFW_ANY_PLATFORM)
{
const char* const session = getenv("XDG_SESSION_TYPE");
if (session)
{
// Only follow XDG_SESSION_TYPE if it is set correctly and the
// environment looks plausble; otherwise fall back to detection
if (strcmp(session, "wayland") == 0 && getenv("WAYLAND_DISPLAY"))
desiredID = GLFW_PLATFORM_WAYLAND;
else if (strcmp(session, "x11") == 0 && getenv("DISPLAY"))
desiredID = GLFW_PLATFORM_X11;
}
}
#endif
if (desiredID == GLFW_ANY_PLATFORM)
{
// If there is exactly one platform available for auto-selection, let it emit the
@ -146,7 +167,9 @@ GLFWAPI int glfwPlatformSupported(int platformID)
GLFWAPI const char* glfwGetVersionString(void)
{
return _GLFW_VERSION_NUMBER
return _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR,
GLFW_VERSION_MINOR,
GLFW_VERSION_REVISION)
#if defined(_GLFW_WIN32)
" Win32 WGL"
#endif

View File

@ -25,10 +25,26 @@
//
//========================================================================
#if defined(GLFW_BUILD_WIN32_TIMER) || \
defined(GLFW_BUILD_WIN32_MODULE) || \
defined(GLFW_BUILD_WIN32_THREAD) || \
defined(GLFW_BUILD_COCOA_TIMER) || \
defined(GLFW_BUILD_POSIX_TIMER) || \
defined(GLFW_BUILD_POSIX_MODULE) || \
defined(GLFW_BUILD_POSIX_THREAD) || \
defined(GLFW_BUILD_POSIX_POLL) || \
defined(GLFW_BUILD_LINUX_JOYSTICK)
#error "You must not define these; define zero or more _GLFW_<platform> macros instead"
#endif
#include "null_platform.h"
#define GLFW_EXPOSE_NATIVE_EGL
#define GLFW_EXPOSE_NATIVE_OSMESA
#if defined(_GLFW_WIN32)
#include "win32_platform.h"
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#else
#define GLFW_WIN32_WINDOW_STATE
#define GLFW_WIN32_MONITOR_STATE
@ -40,6 +56,8 @@
#if defined(_GLFW_COCOA)
#include "cocoa_platform.h"
#define GLFW_EXPOSE_NATIVE_COCOA
#define GLFW_EXPOSE_NATIVE_NSGL
#else
#define GLFW_COCOA_WINDOW_STATE
#define GLFW_COCOA_MONITOR_STATE
@ -51,6 +69,7 @@
#if defined(_GLFW_WAYLAND)
#include "wl_platform.h"
#define GLFW_EXPOSE_NATIVE_WAYLAND
#else
#define GLFW_WAYLAND_WINDOW_STATE
#define GLFW_WAYLAND_MONITOR_STATE
@ -60,6 +79,8 @@
#if defined(_GLFW_X11)
#include "x11_platform.h"
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
#else
#define GLFW_X11_WINDOW_STATE
#define GLFW_X11_MONITOR_STATE
@ -86,6 +107,10 @@
#endif
#if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__)
#define GLFW_BUILD_LINUX_JOYSTICK
#endif
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
#include "linux_joystick.h"
#else
#define GLFW_LINUX_JOYSTICK_STATE
@ -141,23 +166,47 @@
GLFW_GLX_LIBRARY_CONTEXT_STATE
#if defined(_WIN32)
#define GLFW_BUILD_WIN32_THREAD
#else
#define GLFW_BUILD_POSIX_THREAD
#endif
#if defined(GLFW_BUILD_WIN32_THREAD)
#include "win32_thread.h"
#define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE
#define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE
#else
#elif defined(GLFW_BUILD_POSIX_THREAD)
#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)
#define GLFW_BUILD_WIN32_TIMER
#elif defined(__APPLE__)
#define GLFW_BUILD_COCOA_TIMER
#else
#define GLFW_BUILD_POSIX_TIMER
#endif
#if defined(GLFW_BUILD_WIN32_TIMER)
#include "win32_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE
#elif defined(__APPLE__)
#elif defined(GLFW_BUILD_COCOA_TIMER)
#include "cocoa_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE
#else
#elif defined(GLFW_BUILD_POSIX_TIMER)
#include "posix_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
#endif
#if defined(_WIN32)
#define GLFW_BUILD_WIN32_MODULE
#else
#define GLFW_BUILD_POSIX_MODULE
#endif
#if defined(_GLFW_WAYLAND) || defined(_GLFW_X11)
#define GLFW_BUILD_POSIX_POLL
#endif

View File

@ -23,11 +23,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_POSIX_MODULE)
#include <dlfcn.h>
//////////////////////////////////////////////////////////////////////////
@ -49,3 +49,5 @@ GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
return dlsym(module, name);
}
#endif // GLFW_BUILD_POSIX_MODULE

View File

@ -23,13 +23,13 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#define _GNU_SOURCE
#include "internal.h"
#if defined(GLFW_BUILD_POSIX_POLL)
#include <signal.h>
#include <time.h>
#include <errno.h>
@ -79,3 +79,5 @@ GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout)
}
}
#endif // GLFW_BUILD_POSIX_POLL

View File

@ -23,8 +23,6 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include <poll.h>

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_POSIX_THREAD)
#include <assert.h>
#include <string.h>
@ -103,3 +103,5 @@ void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
pthread_mutex_unlock(&mutex->posix.handle);
}
#endif // GLFW_BUILD_POSIX_THREAD

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_POSIX_TIMER)
#include <unistd.h>
#include <sys/time.h>
@ -61,3 +61,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void)
return _glfw.timer.posix.frequency;
}
#endif // GLFW_BUILD_POSIX_TIMER

View File

@ -24,8 +24,6 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(_GLFW_WIN32)
#include <stdlib.h>
#include <assert.h>
@ -115,6 +115,23 @@ static int choosePixelFormatWGL(_GLFWwindow* window,
if (_glfw.wgl.EXT_colorspace)
ADD_ATTRIB(WGL_COLORSPACE_EXT);
}
// NOTE: In a Parallels VM WGL_ARB_pixel_format returns fewer pixel formats than
// DescribePixelFormat, violating the guarantees of the extension spec
// HACK: Iterate through the minimum of both counts
const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
int extensionCount;
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
1, 0, 1, &attrib, &extensionCount))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve pixel format attribute");
return 0;
}
nativeCount = _glfw_min(nativeCount, extensionCount);
}
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
@ -330,6 +347,7 @@ static void swapBuffersWGL(_GLFWwindow* window)
static void swapIntervalWGL(int interval)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
assert(window != NULL);
window->context.wgl.interval = interval;
@ -776,3 +794,5 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
return window->context.wgl.handle;
}
#endif // _GLFW_WIN32

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(_GLFW_WIN32)
#include <stdlib.h>
static const GUID _glfw_GUID_DEVINTERFACE_HID =
@ -382,7 +382,7 @@ static GLFWbool createHelperWindow(void)
if (!_glfw.win32.helperWindowClass)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WIn32: Failed to register helper window class");
"Win32: Failed to register helper window class");
return GLFW_FALSE;
}
@ -430,7 +430,6 @@ static GLFWbool createHelperWindow(void)
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
@ -603,78 +602,78 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform win32 =
{
GLFW_PLATFORM_WIN32,
_glfwInitWin32,
_glfwTerminateWin32,
_glfwGetCursorPosWin32,
_glfwSetCursorPosWin32,
_glfwSetCursorModeWin32,
_glfwSetRawMouseMotionWin32,
_glfwRawMouseMotionSupportedWin32,
_glfwCreateCursorWin32,
_glfwCreateStandardCursorWin32,
_glfwDestroyCursorWin32,
_glfwSetCursorWin32,
_glfwGetScancodeNameWin32,
_glfwGetKeyScancodeWin32,
_glfwSetClipboardStringWin32,
_glfwGetClipboardStringWin32,
_glfwInitJoysticksWin32,
_glfwTerminateJoysticksWin32,
_glfwPollJoystickWin32,
_glfwGetMappingNameWin32,
_glfwUpdateGamepadGUIDWin32,
_glfwFreeMonitorWin32,
_glfwGetMonitorPosWin32,
_glfwGetMonitorContentScaleWin32,
_glfwGetMonitorWorkareaWin32,
_glfwGetVideoModesWin32,
_glfwGetVideoModeWin32,
_glfwGetGammaRampWin32,
_glfwSetGammaRampWin32,
_glfwCreateWindowWin32,
_glfwDestroyWindowWin32,
_glfwSetWindowTitleWin32,
_glfwSetWindowIconWin32,
_glfwGetWindowPosWin32,
_glfwSetWindowPosWin32,
_glfwGetWindowSizeWin32,
_glfwSetWindowSizeWin32,
_glfwSetWindowSizeLimitsWin32,
_glfwSetWindowAspectRatioWin32,
_glfwGetFramebufferSizeWin32,
_glfwGetWindowFrameSizeWin32,
_glfwGetWindowContentScaleWin32,
_glfwIconifyWindowWin32,
_glfwRestoreWindowWin32,
_glfwMaximizeWindowWin32,
_glfwShowWindowWin32,
_glfwHideWindowWin32,
_glfwRequestWindowAttentionWin32,
_glfwFocusWindowWin32,
_glfwSetWindowMonitorWin32,
_glfwWindowFocusedWin32,
_glfwWindowIconifiedWin32,
_glfwWindowVisibleWin32,
_glfwWindowMaximizedWin32,
_glfwWindowHoveredWin32,
_glfwFramebufferTransparentWin32,
_glfwGetWindowOpacityWin32,
_glfwSetWindowResizableWin32,
_glfwSetWindowDecoratedWin32,
_glfwSetWindowFloatingWin32,
_glfwSetWindowOpacityWin32,
_glfwSetWindowMousePassthroughWin32,
_glfwPollEventsWin32,
_glfwWaitEventsWin32,
_glfwWaitEventsTimeoutWin32,
_glfwPostEmptyEventWin32,
_glfwGetEGLPlatformWin32,
_glfwGetEGLNativeDisplayWin32,
_glfwGetEGLNativeWindowWin32,
_glfwGetRequiredInstanceExtensionsWin32,
_glfwGetPhysicalDevicePresentationSupportWin32,
_glfwCreateWindowSurfaceWin32,
.platformID = GLFW_PLATFORM_WIN32,
.init = _glfwInitWin32,
.terminate = _glfwTerminateWin32,
.getCursorPos = _glfwGetCursorPosWin32,
.setCursorPos = _glfwSetCursorPosWin32,
.setCursorMode = _glfwSetCursorModeWin32,
.setRawMouseMotion = _glfwSetRawMouseMotionWin32,
.rawMouseMotionSupported = _glfwRawMouseMotionSupportedWin32,
.createCursor = _glfwCreateCursorWin32,
.createStandardCursor = _glfwCreateStandardCursorWin32,
.destroyCursor = _glfwDestroyCursorWin32,
.setCursor = _glfwSetCursorWin32,
.getScancodeName = _glfwGetScancodeNameWin32,
.getKeyScancode = _glfwGetKeyScancodeWin32,
.setClipboardString = _glfwSetClipboardStringWin32,
.getClipboardString = _glfwGetClipboardStringWin32,
.initJoysticks = _glfwInitJoysticksWin32,
.terminateJoysticks = _glfwTerminateJoysticksWin32,
.pollJoystick = _glfwPollJoystickWin32,
.getMappingName = _glfwGetMappingNameWin32,
.updateGamepadGUID = _glfwUpdateGamepadGUIDWin32,
.freeMonitor = _glfwFreeMonitorWin32,
.getMonitorPos = _glfwGetMonitorPosWin32,
.getMonitorContentScale = _glfwGetMonitorContentScaleWin32,
.getMonitorWorkarea = _glfwGetMonitorWorkareaWin32,
.getVideoModes = _glfwGetVideoModesWin32,
.getVideoMode = _glfwGetVideoModeWin32,
.getGammaRamp = _glfwGetGammaRampWin32,
.setGammaRamp = _glfwSetGammaRampWin32,
.createWindow = _glfwCreateWindowWin32,
.destroyWindow = _glfwDestroyWindowWin32,
.setWindowTitle = _glfwSetWindowTitleWin32,
.setWindowIcon = _glfwSetWindowIconWin32,
.getWindowPos = _glfwGetWindowPosWin32,
.setWindowPos = _glfwSetWindowPosWin32,
.getWindowSize = _glfwGetWindowSizeWin32,
.setWindowSize = _glfwSetWindowSizeWin32,
.setWindowSizeLimits = _glfwSetWindowSizeLimitsWin32,
.setWindowAspectRatio = _glfwSetWindowAspectRatioWin32,
.getFramebufferSize = _glfwGetFramebufferSizeWin32,
.getWindowFrameSize = _glfwGetWindowFrameSizeWin32,
.getWindowContentScale = _glfwGetWindowContentScaleWin32,
.iconifyWindow = _glfwIconifyWindowWin32,
.restoreWindow = _glfwRestoreWindowWin32,
.maximizeWindow = _glfwMaximizeWindowWin32,
.showWindow = _glfwShowWindowWin32,
.hideWindow = _glfwHideWindowWin32,
.requestWindowAttention = _glfwRequestWindowAttentionWin32,
.focusWindow = _glfwFocusWindowWin32,
.setWindowMonitor = _glfwSetWindowMonitorWin32,
.windowFocused = _glfwWindowFocusedWin32,
.windowIconified = _glfwWindowIconifiedWin32,
.windowVisible = _glfwWindowVisibleWin32,
.windowMaximized = _glfwWindowMaximizedWin32,
.windowHovered = _glfwWindowHoveredWin32,
.framebufferTransparent = _glfwFramebufferTransparentWin32,
.getWindowOpacity = _glfwGetWindowOpacityWin32,
.setWindowResizable = _glfwSetWindowResizableWin32,
.setWindowDecorated = _glfwSetWindowDecoratedWin32,
.setWindowFloating = _glfwSetWindowFloatingWin32,
.setWindowOpacity = _glfwSetWindowOpacityWin32,
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughWin32,
.pollEvents = _glfwPollEventsWin32,
.waitEvents = _glfwWaitEventsWin32,
.waitEventsTimeout = _glfwWaitEventsTimeoutWin32,
.postEmptyEvent = _glfwPostEmptyEventWin32,
.getEGLPlatform = _glfwGetEGLPlatformWin32,
.getEGLNativeDisplay = _glfwGetEGLNativeDisplayWin32,
.getEGLNativeWindow = _glfwGetEGLNativeWindowWin32,
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWin32,
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWin32,
.createWindowSurface = _glfwCreateWindowSurfaceWin32
};
*platform = win32;
@ -705,6 +704,9 @@ int _glfwInitWin32(void)
void _glfwTerminateWin32(void)
{
if (_glfw.win32.blankCursor)
DestroyIcon((HICON) _glfw.win32.blankCursor);
if (_glfw.win32.deviceNotificationHandle)
UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
@ -725,3 +727,5 @@ void _glfwTerminateWin32(void)
freeLibraries();
}
#endif // _GLFW_WIN32

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(_GLFW_WIN32)
#include <stdio.h>
#include <math.h>
@ -734,6 +734,13 @@ GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
dpad |= GLFW_HAT_LEFT;
// Treat invalid combinations as neither being pressed
// while preserving what data can be preserved
if ((dpad & GLFW_HAT_RIGHT) && (dpad & GLFW_HAT_LEFT))
dpad &= ~(GLFW_HAT_RIGHT | GLFW_HAT_LEFT);
if ((dpad & GLFW_HAT_UP) && (dpad & GLFW_HAT_DOWN))
dpad &= ~(GLFW_HAT_UP | GLFW_HAT_DOWN);
_glfwInputJoystickHat(js, 0, dpad);
}
@ -756,3 +763,5 @@ void _glfwUpdateGamepadGUIDWin32(char* guid)
}
}
#endif // _GLFW_WIN32

View File

@ -27,8 +27,6 @@
#define GLFW_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32;
#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
#define GLFW_BUILD_WIN32_MAPPINGS
// Joystick element (axis, button or slider)
//
typedef struct _GLFWjoyobjectWin32

View File

@ -23,11 +23,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_WIN32_MODULE)
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
@ -47,3 +47,5 @@ GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
return (GLFWproc) GetProcAddress((HMODULE) module, name);
}
#endif // GLFW_BUILD_WIN32_MODULE

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(_GLFW_WIN32)
#include <stdlib.h>
#include <string.h>
#include <limits.h>
@ -470,13 +470,17 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
return result;
}
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
{
DEVMODEW dm;
ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(dm);
EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm);
if (!EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm))
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query display settings");
return GLFW_FALSE;
}
mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight;
@ -485,6 +489,8 @@ void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
&mode->redBits,
&mode->greenBits,
&mode->blueBits);
return GLFW_TRUE;
}
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -535,6 +541,13 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized");
return NULL;
}
return monitor->win32.publicAdapterName;
}
@ -542,6 +555,15 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized");
return NULL;
}
return monitor->win32.publicDisplayName;
}
#endif // _GLFW_WIN32

View File

@ -424,6 +424,7 @@ typedef struct _GLFWwindowWin32
GLFWbool transparent;
GLFWbool scaleToMonitor;
GLFWbool keymenu;
GLFWbool showDefault;
// Cached size used to filter out duplicate events
int width, height;
@ -457,6 +458,8 @@ typedef struct _GLFWlibraryWin32
RAWINPUT* rawInput;
int rawInputSize;
UINT mouseTrailSize;
// The cursor handle to use to hide the cursor (NULL or a transparent cursor)
HCURSOR blankCursor;
struct {
HINSTANCE instance;
@ -606,7 +609,7 @@ void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_WIN32_THREAD)
#include <assert.h>
@ -96,3 +96,5 @@ void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
LeaveCriticalSection(&mutex->win32.section);
}
#endif // GLFW_BUILD_WIN32_THREAD

View File

@ -25,6 +25,11 @@
//
//========================================================================
// 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
#undef APIENTRY
#include <windows.h>
#define GLFW_WIN32_TLS_STATE _GLFWtlsWin32 win32;

View File

@ -24,11 +24,10 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_WIN32_TIMER)
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
@ -51,3 +50,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void)
return _glfw.timer.win32.frequency;
}
#endif // GLFW_BUILD_WIN32_TIMER

View File

@ -25,6 +25,11 @@
//
//========================================================================
// 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
#undef APIENTRY
#include <windows.h>
#define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32;

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#if defined(_GLFW_WIN32)
#include <limits.h>
#include <stdlib.h>
#include <string.h>
@ -184,53 +184,38 @@ static HICON createIcon(const GLFWimage* image, int xhot, int yhot, GLFWbool ico
return handle;
}
// Translate content area size to full window size according to styles and DPI
//
static void getFullWindowSize(DWORD style, DWORD exStyle,
int contentWidth, int contentHeight,
int* fullWidth, int* fullHeight,
UINT dpi)
{
RECT rect = { 0, 0, contentWidth, contentHeight };
if (_glfwIsWindows10Version1607OrGreaterWin32())
AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
else
AdjustWindowRectEx(&rect, style, FALSE, exStyle);
*fullWidth = rect.right - rect.left;
*fullHeight = rect.bottom - rect.top;
}
// Enforce the content area aspect ratio based on which edge is being dragged
//
static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
{
int xoff, yoff;
UINT dpi = USER_DEFAULT_SCREEN_DPI;
RECT frame = {0};
const float ratio = (float) window->numer / (float) window->denom;
const DWORD style = getWindowStyle(window);
const DWORD exStyle = getWindowExStyle(window);
if (_glfwIsWindows10Version1607OrGreaterWin32())
dpi = GetDpiForWindow(window->win32.handle);
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
0, 0, &xoff, &yoff, dpi);
{
AdjustWindowRectExForDpi(&frame, style, FALSE, exStyle,
GetDpiForWindow(window->win32.handle));
}
else
AdjustWindowRectEx(&frame, style, FALSE, exStyle);
if (edge == WMSZ_LEFT || edge == WMSZ_BOTTOMLEFT ||
edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
{
area->bottom = area->top + yoff +
(int) ((area->right - area->left - xoff) / ratio);
area->bottom = area->top + (frame.bottom - frame.top) +
(int) (((area->right - area->left) - (frame.right - frame.left)) / ratio);
}
else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
{
area->top = area->bottom - yoff -
(int) ((area->right - area->left - xoff) / ratio);
area->top = area->bottom - (frame.bottom - frame.top) -
(int) (((area->right - area->left) - (frame.right - frame.left)) / ratio);
}
else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
{
area->right = area->left + xoff +
(int) ((area->bottom - area->top - yoff) * ratio);
area->right = area->left + (frame.right - frame.left) +
(int) (((area->bottom - area->top) - (frame.bottom - frame.top)) * ratio);
}
}
@ -247,7 +232,12 @@ static void updateCursorImage(_GLFWwindow* window)
SetCursor(LoadCursorW(NULL, IDC_ARROW));
}
else
SetCursor(NULL);
{
// NOTE: Via Remote Desktop, setting the cursor to NULL does not hide it.
// HACK: When running locally, it is set to NULL, but when connected via Remote
// Desktop, this is a transparent cursor.
SetCursor(_glfw.win32.blankCursor);
}
}
// Sets the cursor clip rect to the window content area
@ -939,8 +929,28 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
data = _glfw.win32.rawInput;
if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
{
dx = data->data.mouse.lLastX - window->win32.lastCursorPosX;
dy = data->data.mouse.lLastY - window->win32.lastCursorPosY;
POINT pos = {0};
int width, height;
if (data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP)
{
pos.x += GetSystemMetrics(SM_XVIRTUALSCREEN);
pos.y += GetSystemMetrics(SM_YVIRTUALSCREEN);
width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
}
else
{
width = GetSystemMetrics(SM_CXSCREEN);
height = GetSystemMetrics(SM_CYSCREEN);
}
pos.x += (int) ((data->data.mouse.lLastX / 65535.f) * width);
pos.y += (int) ((data->data.mouse.lLastY / 65535.f) * height);
ScreenToClient(window->win32.handle, &pos);
dx = pos.x - window->win32.lastCursorPosX;
dy = pos.y - window->win32.lastCursorPosY;
}
else
{
@ -1080,31 +1090,34 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
case WM_GETMINMAXINFO:
{
int xoff, yoff;
UINT dpi = USER_DEFAULT_SCREEN_DPI;
RECT frame = {0};
MINMAXINFO* mmi = (MINMAXINFO*) lParam;
const DWORD style = getWindowStyle(window);
const DWORD exStyle = getWindowExStyle(window);
if (window->monitor)
break;
if (_glfwIsWindows10Version1607OrGreaterWin32())
dpi = GetDpiForWindow(window->win32.handle);
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
0, 0, &xoff, &yoff, dpi);
{
AdjustWindowRectExForDpi(&frame, style, FALSE, exStyle,
GetDpiForWindow(window->win32.handle));
}
else
AdjustWindowRectEx(&frame, style, FALSE, exStyle);
if (window->minwidth != GLFW_DONT_CARE &&
window->minheight != GLFW_DONT_CARE)
{
mmi->ptMinTrackSize.x = window->minwidth + xoff;
mmi->ptMinTrackSize.y = window->minheight + yoff;
mmi->ptMinTrackSize.x = window->minwidth + frame.right - frame.left;
mmi->ptMinTrackSize.y = window->minheight + frame.bottom - frame.top;
}
if (window->maxwidth != GLFW_DONT_CARE &&
window->maxheight != GLFW_DONT_CARE)
{
mmi->ptMaxTrackSize.x = window->maxwidth + xoff;
mmi->ptMaxTrackSize.y = window->maxheight + yoff;
mmi->ptMaxTrackSize.x = window->maxwidth + frame.right - frame.left;
mmi->ptMaxTrackSize.y = window->maxheight + frame.bottom - frame.top;
}
if (!window->decorated)
@ -1263,7 +1276,7 @@ static int createNativeWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig)
{
int xpos, ypos, fullWidth, fullHeight;
int frameX, frameY, frameWidth, frameHeight;
WCHAR* wideTitle;
DWORD style = getWindowStyle(window);
DWORD exStyle = getWindowExStyle(window);
@ -1301,6 +1314,34 @@ static int createNativeWindow(_GLFWwindow* window,
}
}
if (GetSystemMetrics(SM_REMOTESESSION))
{
// NOTE: On Remote Desktop, setting the cursor to NULL does not hide it
// HACK: Create a transparent cursor and always set that instead of NULL
// When not on Remote Desktop, this handle is NULL and normal hiding is used
if (!_glfw.win32.blankCursor)
{
const int cursorWidth = GetSystemMetrics(SM_CXCURSOR);
const int cursorHeight = GetSystemMetrics(SM_CYCURSOR);
unsigned char* cursorPixels = _glfw_calloc(cursorWidth * cursorHeight, 4);
if (!cursorPixels)
return GLFW_FALSE;
// NOTE: Windows checks whether the image is fully transparent and if so
// just ignores the alpha channel and makes the whole cursor opaque
// HACK: Make one pixel slightly less transparent
cursorPixels[3] = 1;
const GLFWimage cursorImage = { cursorWidth, cursorHeight, cursorPixels };
_glfw.win32.blankCursor = createIcon(&cursorImage, 0, 0, FALSE);
_glfw_free(cursorPixels);
if (!_glfw.win32.blankCursor)
return GLFW_FALSE;
}
}
if (window->monitor)
{
MONITORINFO mi = { sizeof(mi) };
@ -1309,10 +1350,10 @@ static int createNativeWindow(_GLFWwindow* window,
// NOTE: This window placement is temporary and approximate, as the
// correct position and size cannot be known until the monitor
// video mode has been picked in _glfwSetVideoModeWin32
xpos = mi.rcMonitor.left;
ypos = mi.rcMonitor.top;
fullWidth = mi.rcMonitor.right - mi.rcMonitor.left;
fullHeight = mi.rcMonitor.bottom - mi.rcMonitor.top;
frameX = mi.rcMonitor.left;
frameY = mi.rcMonitor.top;
frameWidth = mi.rcMonitor.right - mi.rcMonitor.left;
frameHeight = mi.rcMonitor.bottom - mi.rcMonitor.top;
}
else
{
@ -1326,17 +1367,17 @@ static int createNativeWindow(_GLFWwindow* window,
if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
{
xpos = CW_USEDEFAULT;
ypos = CW_USEDEFAULT;
frameX = CW_USEDEFAULT;
frameY = CW_USEDEFAULT;
}
else
{
xpos = wndconfig->xpos + rect.left;
ypos = wndconfig->ypos + rect.top;
frameX = wndconfig->xpos + rect.left;
frameY = wndconfig->ypos + rect.top;
}
fullWidth = rect.right - rect.left;
fullHeight = rect.bottom - rect.top;
frameWidth = rect.right - rect.left;
frameHeight = rect.bottom - rect.top;
}
wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
@ -1347,8 +1388,8 @@ static int createNativeWindow(_GLFWwindow* window,
MAKEINTATOM(_glfw.win32.mainWindowClass),
wideTitle,
style,
xpos, ypos,
fullWidth, fullHeight,
frameX, frameY,
frameWidth, frameHeight,
NULL, // No parent window
NULL, // No window menu
_glfw.win32.instance,
@ -1377,6 +1418,7 @@ static int createNativeWindow(_GLFWwindow* window,
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
window->win32.keymenu = wndconfig->win32.keymenu;
window->win32.showDefault = wndconfig->win32.showDefault;
if (!window->monitor)
{
@ -1759,7 +1801,23 @@ void _glfwMaximizeWindowWin32(_GLFWwindow* window)
void _glfwShowWindowWin32(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_SHOWNA);
int showCommand = SW_SHOWNA;
if (window->win32.showDefault)
{
// NOTE: GLFW windows currently do not seem to match the Windows 10 definition of
// a main window, so even SW_SHOWDEFAULT does nothing
// This definition is undocumented and can change (source: Raymond Chen)
// HACK: Apply the STARTUPINFO show command manually if available
STARTUPINFOW si = { sizeof(si) };
GetStartupInfoW(&si);
if (si.dwFlags & STARTF_USESHOWWINDOW)
showCommand = si.wShowWindow;
window->win32.showDefault = GLFW_FALSE;
}
ShowWindow(window->win32.handle, showCommand);
}
void _glfwHideWindowWin32(_GLFWwindow* window)
@ -2114,6 +2172,7 @@ void _glfwPollEventsWin32(void)
// NOTE: Re-center the cursor only if it has moved since the last call,
// to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
// The re-center is required in order to prevent the mouse cursor stopping at the edges of the screen.
if (window->win32.lastCursorPosX != width / 2 ||
window->win32.lastCursorPosY != height / 2)
{
@ -2131,7 +2190,7 @@ void _glfwWaitEventsWin32(void)
void _glfwWaitEventsTimeoutWin32(double timeout)
{
MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLINPUT);
_glfwPollEventsWin32();
}
@ -2209,14 +2268,17 @@ void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode)
const char* _glfwGetScancodeNameWin32(int scancode)
{
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff))
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
const int key = _glfw.win32.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
return _glfw.win32.keynames[key];
}
int _glfwGetKeyScancodeWin32(int key)
@ -2303,7 +2365,7 @@ void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor)
void _glfwSetClipboardStringWin32(const char* string)
{
int characterCount;
int characterCount, tries = 0;
HANDLE object;
WCHAR* buffer;
@ -2331,12 +2393,20 @@ void _glfwSetClipboardStringWin32(const char* string)
MultiByteToWideChar(CP_UTF8, 0, string, -1, buffer, characterCount);
GlobalUnlock(object);
if (!OpenClipboard(_glfw.win32.helperWindowHandle))
// NOTE: Retry clipboard opening a few times as some other application may have it
// open and also the Windows Clipboard History reads it after each update
while (!OpenClipboard(_glfw.win32.helperWindowHandle))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to open clipboard");
GlobalFree(object);
return;
Sleep(1);
tries++;
if (tries == 3)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to open clipboard");
GlobalFree(object);
return;
}
}
EmptyClipboard();
@ -2348,12 +2418,21 @@ const char* _glfwGetClipboardStringWin32(void)
{
HANDLE object;
WCHAR* buffer;
int tries = 0;
if (!OpenClipboard(_glfw.win32.helperWindowHandle))
// NOTE: Retry clipboard opening a few times as some other application may have it
// open and also the Windows Clipboard History reads it after each update
while (!OpenClipboard(_glfw.win32.helperWindowHandle))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to open clipboard");
return NULL;
Sleep(1);
tries++;
if (tries == 3)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to open clipboard");
return NULL;
}
}
object = GetClipboardData(CF_UNICODETEXT);
@ -2510,3 +2589,5 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
return window->win32.handle;
}
#endif // _GLFW_WIN32

View File

@ -25,8 +25,6 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
@ -244,6 +242,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->maxheight = GLFW_DONT_CARE;
window->numer = GLFW_DONT_CARE;
window->denom = GLFW_DONT_CARE;
window->title = _glfw_strdup(title);
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
{
@ -276,6 +275,7 @@ void glfwDefaultWindowHints(void)
_glfw.hints.window.focusOnShow = GLFW_TRUE;
_glfw.hints.window.xpos = GLFW_ANY_POSITION;
_glfw.hints.window.ypos = GLFW_ANY_POSITION;
_glfw.hints.window.scaleFramebuffer = GLFW_TRUE;
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
// double buffered
@ -290,9 +290,6 @@ void glfwDefaultWindowHints(void)
// The default is to select the highest available refresh rate
_glfw.hints.refreshRate = GLFW_DONT_CARE;
// The default is to use full Retina resolution framebuffers
_glfw.hints.window.ns.retina = GLFW_TRUE;
}
GLFWAPI void glfwWindowHint(int hint, int value)
@ -376,18 +373,22 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_POSITION_Y:
_glfw.hints.window.ypos = value;
return;
case GLFW_COCOA_RETINA_FRAMEBUFFER:
_glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_WIN32_KEYBOARD_MENU:
_glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_WIN32_SHOWDEFAULT:
_glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_COCOA_GRAPHICS_SWITCHING:
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_SCALE_TO_MONITOR:
_glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_SCALE_FRAMEBUFFER:
case GLFW_COCOA_RETINA_FRAMEBUFFER:
_glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_CENTER_CURSOR:
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
return;
@ -494,6 +495,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
*prev = window->next;
}
_glfw_free(window->title);
_glfw_free(window);
}
@ -515,6 +517,16 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
window->shouldClose = value;
}
GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->title;
}
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
@ -522,7 +534,12 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
assert(title != NULL);
_GLFW_REQUIRE_INIT();
char* prev = window->title;
window->title = _glfw_strdup(title);
_glfw.platform.setWindowTitle(window, title);
_glfw_free(prev);
}
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
@ -742,7 +759,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
_GLFW_REQUIRE_INIT_OR_RETURN(0.f);
return _glfw.platform.getWindowOpacity(window);
}

View File

@ -23,11 +23,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_WAYLAND)
#include <errno.h>
#include <limits.h>
#include <linux/input.h>
@ -38,14 +38,17 @@
#include <sys/timerfd.h>
#include <unistd.h>
#include <time.h>
#include <assert.h>
#include "wayland-client-protocol.h"
#include "wayland-xdg-shell-client-protocol.h"
#include "wayland-xdg-decoration-client-protocol.h"
#include "wayland-viewporter-client-protocol.h"
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
#include "xdg-shell-client-protocol.h"
#include "xdg-decoration-unstable-v1-client-protocol.h"
#include "viewporter-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "fractional-scale-v1-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h"
// 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
@ -57,27 +60,35 @@
#undef types
#define types _glfw_xdg_shell_types
#include "wayland-xdg-shell-client-protocol-code.h"
#include "xdg-shell-client-protocol-code.h"
#undef types
#define types _glfw_xdg_decoration_types
#include "wayland-xdg-decoration-client-protocol-code.h"
#include "xdg-decoration-unstable-v1-client-protocol-code.h"
#undef types
#define types _glfw_viewporter_types
#include "wayland-viewporter-client-protocol-code.h"
#include "viewporter-client-protocol-code.h"
#undef types
#define types _glfw_relative_pointer_types
#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h"
#include "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 "pointer-constraints-unstable-v1-client-protocol-code.h"
#undef types
#define types _glfw_fractional_scale_types
#include "fractional-scale-v1-client-protocol-code.h"
#undef types
#define types _glfw_xdg_activation_types
#include "xdg-activation-v1-client-protocol-code.h"
#undef types
#define types _glfw_idle_inhibit_types
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
#include "idle-inhibit-unstable-v1-client-protocol-code.h"
#undef types
static void wmBaseHandlePing(void* userData,
@ -100,10 +111,9 @@ static void registryHandleGlobal(void* userData,
{
if (strcmp(interface, "wl_compositor") == 0)
{
_glfw.wl.compositorVersion = _glfw_min(3, version);
_glfw.wl.compositor =
wl_registry_bind(registry, name, &wl_compositor_interface,
_glfw.wl.compositorVersion);
_glfw_min(3, version));
}
else if (strcmp(interface, "wl_subcompositor") == 0)
{
@ -123,10 +133,9 @@ static void registryHandleGlobal(void* userData,
{
if (!_glfw.wl.seat)
{
_glfw.wl.seatVersion = _glfw_min(4, version);
_glfw.wl.seat =
wl_registry_bind(registry, name, &wl_seat_interface,
_glfw.wl.seatVersion);
_glfw_min(4, version));
_glfwAddSeatListenerWayland(_glfw.wl.seat);
}
}
@ -178,6 +187,20 @@ static void registryHandleGlobal(void* userData,
&zwp_idle_inhibit_manager_v1_interface,
1);
}
else if (strcmp(interface, "xdg_activation_v1") == 0)
{
_glfw.wl.activationManager =
wl_registry_bind(registry, name,
&xdg_activation_v1_interface,
1);
}
else if (strcmp(interface, "wp_fractional_scale_manager_v1") == 0)
{
_glfw.wl.fractionalScaleManager =
wl_registry_bind(registry, name,
&wp_fractional_scale_manager_v1_interface,
1);
}
}
static void registryHandleGlobalRemove(void* userData,
@ -202,6 +225,36 @@ static const struct wl_registry_listener registryListener =
registryHandleGlobalRemove
};
void libdecorHandleError(struct libdecor* context,
enum libdecor_error error,
const char* message)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: libdecor error %u: %s",
error, message);
}
static const struct libdecor_interface libdecorInterface =
{
libdecorHandleError
};
static void libdecorReadyCallback(void* userData,
struct wl_callback* callback,
uint32_t time)
{
_glfw.wl.libdecor.ready = GLFW_TRUE;
assert(_glfw.wl.libdecor.callback == callback);
wl_callback_destroy(_glfw.wl.libdecor.callback);
_glfw.wl.libdecor.callback = NULL;
}
static const struct wl_callback_listener libdecorReadyListener =
{
libdecorReadyCallback
};
// Create key code translation tables
//
static void createKeyTables(void)
@ -337,7 +390,7 @@ static void createKeyTables(void)
static GLFWbool loadCursorTheme(void)
{
int cursorSize = 32;
int cursorSize = 16;
const char* sizeString = getenv("XCURSOR_SIZE");
if (sizeString)
@ -376,86 +429,86 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform wayland =
{
GLFW_PLATFORM_WAYLAND,
_glfwInitWayland,
_glfwTerminateWayland,
_glfwGetCursorPosWayland,
_glfwSetCursorPosWayland,
_glfwSetCursorModeWayland,
_glfwSetRawMouseMotionWayland,
_glfwRawMouseMotionSupportedWayland,
_glfwCreateCursorWayland,
_glfwCreateStandardCursorWayland,
_glfwDestroyCursorWayland,
_glfwSetCursorWayland,
_glfwGetScancodeNameWayland,
_glfwGetKeyScancodeWayland,
_glfwSetClipboardStringWayland,
_glfwGetClipboardStringWayland,
#if defined(__linux__)
_glfwInitJoysticksLinux,
_glfwTerminateJoysticksLinux,
_glfwPollJoystickLinux,
_glfwGetMappingNameLinux,
_glfwUpdateGamepadGUIDLinux,
.platformID = GLFW_PLATFORM_WAYLAND,
.init = _glfwInitWayland,
.terminate = _glfwTerminateWayland,
.getCursorPos = _glfwGetCursorPosWayland,
.setCursorPos = _glfwSetCursorPosWayland,
.setCursorMode = _glfwSetCursorModeWayland,
.setRawMouseMotion = _glfwSetRawMouseMotionWayland,
.rawMouseMotionSupported = _glfwRawMouseMotionSupportedWayland,
.createCursor = _glfwCreateCursorWayland,
.createStandardCursor = _glfwCreateStandardCursorWayland,
.destroyCursor = _glfwDestroyCursorWayland,
.setCursor = _glfwSetCursorWayland,
.getScancodeName = _glfwGetScancodeNameWayland,
.getKeyScancode = _glfwGetKeyScancodeWayland,
.setClipboardString = _glfwSetClipboardStringWayland,
.getClipboardString = _glfwGetClipboardStringWayland,
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
.initJoysticks = _glfwInitJoysticksLinux,
.terminateJoysticks = _glfwTerminateJoysticksLinux,
.pollJoystick = _glfwPollJoystickLinux,
.getMappingName = _glfwGetMappingNameLinux,
.updateGamepadGUID = _glfwUpdateGamepadGUIDLinux,
#else
_glfwInitJoysticksNull,
_glfwTerminateJoysticksNull,
_glfwPollJoystickNull,
_glfwGetMappingNameNull,
_glfwUpdateGamepadGUIDNull,
.initJoysticks = _glfwInitJoysticksNull,
.terminateJoysticks = _glfwTerminateJoysticksNull,
.pollJoystick = _glfwPollJoystickNull,
.getMappingName = _glfwGetMappingNameNull,
.updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
#endif
_glfwFreeMonitorWayland,
_glfwGetMonitorPosWayland,
_glfwGetMonitorContentScaleWayland,
_glfwGetMonitorWorkareaWayland,
_glfwGetVideoModesWayland,
_glfwGetVideoModeWayland,
_glfwGetGammaRampWayland,
_glfwSetGammaRampWayland,
_glfwCreateWindowWayland,
_glfwDestroyWindowWayland,
_glfwSetWindowTitleWayland,
_glfwSetWindowIconWayland,
_glfwGetWindowPosWayland,
_glfwSetWindowPosWayland,
_glfwGetWindowSizeWayland,
_glfwSetWindowSizeWayland,
_glfwSetWindowSizeLimitsWayland,
_glfwSetWindowAspectRatioWayland,
_glfwGetFramebufferSizeWayland,
_glfwGetWindowFrameSizeWayland,
_glfwGetWindowContentScaleWayland,
_glfwIconifyWindowWayland,
_glfwRestoreWindowWayland,
_glfwMaximizeWindowWayland,
_glfwShowWindowWayland,
_glfwHideWindowWayland,
_glfwRequestWindowAttentionWayland,
_glfwFocusWindowWayland,
_glfwSetWindowMonitorWayland,
_glfwWindowFocusedWayland,
_glfwWindowIconifiedWayland,
_glfwWindowVisibleWayland,
_glfwWindowMaximizedWayland,
_glfwWindowHoveredWayland,
_glfwFramebufferTransparentWayland,
_glfwGetWindowOpacityWayland,
_glfwSetWindowResizableWayland,
_glfwSetWindowDecoratedWayland,
_glfwSetWindowFloatingWayland,
_glfwSetWindowOpacityWayland,
_glfwSetWindowMousePassthroughWayland,
_glfwPollEventsWayland,
_glfwWaitEventsWayland,
_glfwWaitEventsTimeoutWayland,
_glfwPostEmptyEventWayland,
_glfwGetEGLPlatformWayland,
_glfwGetEGLNativeDisplayWayland,
_glfwGetEGLNativeWindowWayland,
_glfwGetRequiredInstanceExtensionsWayland,
_glfwGetPhysicalDevicePresentationSupportWayland,
_glfwCreateWindowSurfaceWayland,
.freeMonitor = _glfwFreeMonitorWayland,
.getMonitorPos = _glfwGetMonitorPosWayland,
.getMonitorContentScale = _glfwGetMonitorContentScaleWayland,
.getMonitorWorkarea = _glfwGetMonitorWorkareaWayland,
.getVideoModes = _glfwGetVideoModesWayland,
.getVideoMode = _glfwGetVideoModeWayland,
.getGammaRamp = _glfwGetGammaRampWayland,
.setGammaRamp = _glfwSetGammaRampWayland,
.createWindow = _glfwCreateWindowWayland,
.destroyWindow = _glfwDestroyWindowWayland,
.setWindowTitle = _glfwSetWindowTitleWayland,
.setWindowIcon = _glfwSetWindowIconWayland,
.getWindowPos = _glfwGetWindowPosWayland,
.setWindowPos = _glfwSetWindowPosWayland,
.getWindowSize = _glfwGetWindowSizeWayland,
.setWindowSize = _glfwSetWindowSizeWayland,
.setWindowSizeLimits = _glfwSetWindowSizeLimitsWayland,
.setWindowAspectRatio = _glfwSetWindowAspectRatioWayland,
.getFramebufferSize = _glfwGetFramebufferSizeWayland,
.getWindowFrameSize = _glfwGetWindowFrameSizeWayland,
.getWindowContentScale = _glfwGetWindowContentScaleWayland,
.iconifyWindow = _glfwIconifyWindowWayland,
.restoreWindow = _glfwRestoreWindowWayland,
.maximizeWindow = _glfwMaximizeWindowWayland,
.showWindow = _glfwShowWindowWayland,
.hideWindow = _glfwHideWindowWayland,
.requestWindowAttention = _glfwRequestWindowAttentionWayland,
.focusWindow = _glfwFocusWindowWayland,
.setWindowMonitor = _glfwSetWindowMonitorWayland,
.windowFocused = _glfwWindowFocusedWayland,
.windowIconified = _glfwWindowIconifiedWayland,
.windowVisible = _glfwWindowVisibleWayland,
.windowMaximized = _glfwWindowMaximizedWayland,
.windowHovered = _glfwWindowHoveredWayland,
.framebufferTransparent = _glfwFramebufferTransparentWayland,
.getWindowOpacity = _glfwGetWindowOpacityWayland,
.setWindowResizable = _glfwSetWindowResizableWayland,
.setWindowDecorated = _glfwSetWindowDecoratedWayland,
.setWindowFloating = _glfwSetWindowFloatingWayland,
.setWindowOpacity = _glfwSetWindowOpacityWayland,
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughWayland,
.pollEvents = _glfwPollEventsWayland,
.waitEvents = _glfwWaitEventsWayland,
.waitEventsTimeout = _glfwWaitEventsTimeoutWayland,
.postEmptyEvent = _glfwPostEmptyEventWayland,
.getEGLPlatform = _glfwGetEGLPlatformWayland,
.getEGLNativeDisplay = _glfwGetEGLNativeDisplayWayland,
.getEGLNativeWindow = _glfwGetEGLNativeWindowWayland,
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWayland,
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWayland,
.createWindowSurface = _glfwCreateWindowSurfaceWayland
};
void* module = _glfwPlatformLoadModule("libwayland-client.so.0");
@ -507,6 +560,8 @@ int _glfwInitWayland(void)
_glfw.wl.keyRepeatTimerfd = -1;
_glfw.wl.cursorTimerfd = -1;
_glfw.wl.tag = glfwGetVersionString();
_glfw.wl.client.display_flush = (PFN_wl_display_flush)
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush");
_glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read)
@ -537,6 +592,10 @@ int _glfwInitWayland(void)
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_user_data");
_glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data)
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_user_data");
_glfw.wl.client.proxy_get_tag = (PFN_wl_proxy_get_tag)
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_tag");
_glfw.wl.client.proxy_set_tag = (PFN_wl_proxy_set_tag)
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_tag");
_glfw.wl.client.proxy_get_version = (PFN_wl_proxy_get_version)
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_version");
_glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags)
@ -556,7 +615,9 @@ int _glfwInitWayland(void)
!_glfw.wl.client.proxy_marshal_constructor ||
!_glfw.wl.client.proxy_marshal_constructor_versioned ||
!_glfw.wl.client.proxy_get_user_data ||
!_glfw.wl.client.proxy_set_user_data)
!_glfw.wl.client.proxy_set_user_data ||
!_glfw.wl.client.proxy_get_tag ||
!_glfw.wl.client.proxy_set_tag)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Failed to load libwayland-client entry point");
@ -644,6 +705,119 @@ int _glfwInitWayland(void)
_glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
if (!_glfw.wl.xkb.context_new ||
!_glfw.wl.xkb.context_unref ||
!_glfw.wl.xkb.keymap_new_from_string ||
!_glfw.wl.xkb.keymap_unref ||
!_glfw.wl.xkb.keymap_mod_get_index ||
!_glfw.wl.xkb.keymap_key_repeats ||
!_glfw.wl.xkb.keymap_key_get_syms_by_level ||
!_glfw.wl.xkb.state_new ||
!_glfw.wl.xkb.state_unref ||
!_glfw.wl.xkb.state_key_get_syms ||
!_glfw.wl.xkb.state_update_mask ||
!_glfw.wl.xkb.state_key_get_layout ||
!_glfw.wl.xkb.state_mod_index_is_active ||
!_glfw.wl.xkb.compose_table_new_from_locale ||
!_glfw.wl.xkb.compose_table_unref ||
!_glfw.wl.xkb.compose_state_new ||
!_glfw.wl.xkb.compose_state_unref ||
!_glfw.wl.xkb.compose_state_feed ||
!_glfw.wl.xkb.compose_state_get_status ||
!_glfw.wl.xkb.compose_state_get_one_sym)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Failed to load all entry points from libxkbcommon");
return GLFW_FALSE;
}
if (_glfw.hints.init.wl.libdecorMode == GLFW_WAYLAND_PREFER_LIBDECOR)
_glfw.wl.libdecor.handle = _glfwPlatformLoadModule("libdecor-0.so.0");
if (_glfw.wl.libdecor.handle)
{
_glfw.wl.libdecor.libdecor_new_ = (PFN_libdecor_new)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_new");
_glfw.wl.libdecor.libdecor_unref_ = (PFN_libdecor_unref)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_unref");
_glfw.wl.libdecor.libdecor_get_fd_ = (PFN_libdecor_get_fd)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_get_fd");
_glfw.wl.libdecor.libdecor_dispatch_ = (PFN_libdecor_dispatch)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_dispatch");
_glfw.wl.libdecor.libdecor_decorate_ = (PFN_libdecor_decorate)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_decorate");
_glfw.wl.libdecor.libdecor_frame_unref_ = (PFN_libdecor_frame_unref)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unref");
_glfw.wl.libdecor.libdecor_frame_set_app_id_ = (PFN_libdecor_frame_set_app_id)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_app_id");
_glfw.wl.libdecor.libdecor_frame_set_title_ = (PFN_libdecor_frame_set_title)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_title");
_glfw.wl.libdecor.libdecor_frame_set_minimized_ = (PFN_libdecor_frame_set_minimized)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_minimized");
_glfw.wl.libdecor.libdecor_frame_set_fullscreen_ = (PFN_libdecor_frame_set_fullscreen)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_fullscreen");
_glfw.wl.libdecor.libdecor_frame_unset_fullscreen_ = (PFN_libdecor_frame_unset_fullscreen)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unset_fullscreen");
_glfw.wl.libdecor.libdecor_frame_map_ = (PFN_libdecor_frame_map)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_map");
_glfw.wl.libdecor.libdecor_frame_commit_ = (PFN_libdecor_frame_commit)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_commit");
_glfw.wl.libdecor.libdecor_frame_set_min_content_size_ = (PFN_libdecor_frame_set_min_content_size)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_min_content_size");
_glfw.wl.libdecor.libdecor_frame_set_max_content_size_ = (PFN_libdecor_frame_set_max_content_size)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_max_content_size");
_glfw.wl.libdecor.libdecor_frame_set_maximized_ = (PFN_libdecor_frame_set_maximized)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_maximized");
_glfw.wl.libdecor.libdecor_frame_unset_maximized_ = (PFN_libdecor_frame_unset_maximized)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unset_maximized");
_glfw.wl.libdecor.libdecor_frame_set_capabilities_ = (PFN_libdecor_frame_set_capabilities)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_capabilities");
_glfw.wl.libdecor.libdecor_frame_unset_capabilities_ = (PFN_libdecor_frame_unset_capabilities)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unset_capabilities");
_glfw.wl.libdecor.libdecor_frame_set_visibility_ = (PFN_libdecor_frame_set_visibility)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_visibility");
_glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ = (PFN_libdecor_frame_get_xdg_toplevel)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_get_xdg_toplevel");
_glfw.wl.libdecor.libdecor_configuration_get_content_size_ = (PFN_libdecor_configuration_get_content_size)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_configuration_get_content_size");
_glfw.wl.libdecor.libdecor_configuration_get_window_state_ = (PFN_libdecor_configuration_get_window_state)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_configuration_get_window_state");
_glfw.wl.libdecor.libdecor_state_new_ = (PFN_libdecor_state_new)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_state_new");
_glfw.wl.libdecor.libdecor_state_free_ = (PFN_libdecor_state_free)
_glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_state_free");
if (!_glfw.wl.libdecor.libdecor_new_ ||
!_glfw.wl.libdecor.libdecor_unref_ ||
!_glfw.wl.libdecor.libdecor_get_fd_ ||
!_glfw.wl.libdecor.libdecor_dispatch_ ||
!_glfw.wl.libdecor.libdecor_decorate_ ||
!_glfw.wl.libdecor.libdecor_frame_unref_ ||
!_glfw.wl.libdecor.libdecor_frame_set_app_id_ ||
!_glfw.wl.libdecor.libdecor_frame_set_title_ ||
!_glfw.wl.libdecor.libdecor_frame_set_minimized_ ||
!_glfw.wl.libdecor.libdecor_frame_set_fullscreen_ ||
!_glfw.wl.libdecor.libdecor_frame_unset_fullscreen_ ||
!_glfw.wl.libdecor.libdecor_frame_map_ ||
!_glfw.wl.libdecor.libdecor_frame_commit_ ||
!_glfw.wl.libdecor.libdecor_frame_set_min_content_size_ ||
!_glfw.wl.libdecor.libdecor_frame_set_max_content_size_ ||
!_glfw.wl.libdecor.libdecor_frame_set_maximized_ ||
!_glfw.wl.libdecor.libdecor_frame_unset_maximized_ ||
!_glfw.wl.libdecor.libdecor_frame_set_capabilities_ ||
!_glfw.wl.libdecor.libdecor_frame_unset_capabilities_ ||
!_glfw.wl.libdecor.libdecor_frame_set_visibility_ ||
!_glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ ||
!_glfw.wl.libdecor.libdecor_configuration_get_content_size_ ||
!_glfw.wl.libdecor.libdecor_configuration_get_window_state_ ||
!_glfw.wl.libdecor.libdecor_state_new_ ||
!_glfw.wl.libdecor.libdecor_state_free_)
{
_glfwPlatformFreeModule(_glfw.wl.libdecor.handle);
memset(&_glfw.wl.libdecor, 0, sizeof(_glfw.wl.libdecor));
}
}
_glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);
@ -663,13 +837,27 @@ int _glfwInitWayland(void)
// Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display);
#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
if (_glfw.wl.seatVersion >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
if (_glfw.wl.libdecor.handle)
{
_glfw.wl.libdecor.context = libdecor_new(_glfw.wl.display, &libdecorInterface);
if (_glfw.wl.libdecor.context)
{
// Perform an initial dispatch and flush to get the init started
libdecor_dispatch(_glfw.wl.libdecor.context, 0);
// Create sync point to "know" when libdecor is ready for use
_glfw.wl.libdecor.callback = wl_display_sync(_glfw.wl.display);
wl_callback_add_listener(_glfw.wl.libdecor.callback,
&libdecorReadyListener,
NULL);
}
}
if (wl_seat_get_version(_glfw.wl.seat) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
{
_glfw.wl.keyRepeatTimerfd =
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
}
#endif
if (!_glfw.wl.wmBase)
{
@ -704,6 +892,22 @@ void _glfwTerminateWayland(void)
_glfwTerminateEGL();
_glfwTerminateOSMesa();
if (_glfw.wl.libdecor.context)
{
// Allow libdecor to finish receiving all its requested globals
// and ensure the associated sync callback object is destroyed
while (!_glfw.wl.libdecor.ready)
_glfwWaitEventsWayland();
libdecor_unref(_glfw.wl.libdecor.context);
}
if (_glfw.wl.libdecor.handle)
{
_glfwPlatformFreeModule(_glfw.wl.libdecor.handle);
_glfw.wl.libdecor.handle = NULL;
}
if (_glfw.wl.egl.handle)
{
_glfwPlatformFreeModule(_glfw.wl.egl.handle);
@ -775,6 +979,10 @@ void _glfwTerminateWayland(void)
zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
if (_glfw.wl.idleInhibitManager)
zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
if (_glfw.wl.activationManager)
xdg_activation_v1_destroy(_glfw.wl.activationManager);
if (_glfw.wl.fractionalScaleManager)
wp_fractional_scale_manager_v1_destroy(_glfw.wl.fractionalScaleManager);
if (_glfw.wl.registry)
wl_registry_destroy(_glfw.wl.registry);
if (_glfw.wl.display)
@ -791,3 +999,5 @@ void _glfwTerminateWayland(void)
_glfw_free(_glfw.wl.clipboardString);
}
#endif // _GLFW_WAYLAND

View File

@ -23,11 +23,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_WAYLAND)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -116,19 +116,18 @@ static void outputHandleScale(void* userData,
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
{
for (int i = 0; i < window->wl.monitorsCount; i++)
for (size_t i = 0; i < window->wl.outputScaleCount; i++)
{
if (window->wl.monitors[i] == monitor)
if (window->wl.outputScales[i].output == monitor->wl.output)
{
_glfwUpdateContentScaleWayland(window);
window->wl.outputScales[i].factor = monitor->wl.scale;
_glfwUpdateBufferScaleFromOutputsWayland(window);
break;
}
}
}
}
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
void outputHandleName(void* userData, struct wl_output* wl_output, const char* name)
{
struct _GLFWmonitor* monitor = userData;
@ -142,18 +141,14 @@ void outputHandleDescription(void* userData,
{
}
#endif // WL_OUTPUT_NAME_SINCE_VERSION
static const struct wl_output_listener outputListener =
{
outputHandleGeometry,
outputHandleMode,
outputHandleDone,
outputHandleScale,
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
outputHandleName,
outputHandleDescription,
#endif
};
@ -170,11 +165,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
return;
}
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
version = _glfw_min(version, WL_OUTPUT_NAME_SINCE_VERSION);
#else
version = 2;
#endif
struct wl_output* output = wl_registry_bind(_glfw.wl.registry,
name,
@ -189,6 +180,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
monitor->wl.output = output;
monitor->wl.name = name;
wl_proxy_set_tag((struct wl_proxy*) output, &_glfw.wl.tag);
wl_output_add_listener(output, &outputListener, monitor);
}
@ -240,9 +232,10 @@ GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found)
return monitor->modes;
}
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode)
GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode)
{
*mode = monitor->modes[monitor->wl.currentMode];
return GLFW_TRUE;
}
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -267,6 +260,15 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Wayland: Platform not initialized");
return NULL;
}
return monitor->wl.output;
}
#endif // _GLFW_WAYLAND

View File

@ -28,6 +28,8 @@
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
#include <stdbool.h>
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
typedef struct VkWaylandSurfaceCreateInfoKHR
@ -61,6 +63,8 @@ typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor)(struct wl_proxy*,u
typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor_versioned)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,...);
typedef void* (* PFN_wl_proxy_get_user_data)(struct wl_proxy*);
typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*);
typedef void (* PFN_wl_proxy_set_tag)(struct wl_proxy*,const char*const*);
typedef const char* const* (* PFN_wl_proxy_get_tag)(struct wl_proxy*);
typedef uint32_t (* PFN_wl_proxy_get_version)(struct wl_proxy*);
typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,uint32_t,...);
#define wl_display_flush _glfw.wl.client.display_flush
@ -78,10 +82,13 @@ typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_
#define wl_proxy_marshal_constructor_versioned _glfw.wl.client.proxy_marshal_constructor_versioned
#define wl_proxy_get_user_data _glfw.wl.client.proxy_get_user_data
#define wl_proxy_set_user_data _glfw.wl.client.proxy_set_user_data
#define wl_proxy_get_tag _glfw.wl.client.proxy_get_tag
#define wl_proxy_set_tag _glfw.wl.client.proxy_set_tag
#define wl_proxy_get_version _glfw.wl.client.proxy_get_version
#define wl_proxy_marshal_flags _glfw.wl.client.proxy_marshal_flags
struct wl_shm;
struct wl_output;
#define wl_display_interface _glfw_wl_display_interface
#define wl_subcompositor_interface _glfw_wl_subcompositor_interface
@ -122,6 +129,10 @@ struct wl_shm;
#define xdg_surface_interface _glfw_xdg_surface_interface
#define xdg_toplevel_interface _glfw_xdg_toplevel_interface
#define xdg_wm_base_interface _glfw_xdg_wm_base_interface
#define xdg_activation_v1_interface _glfw_xdg_activation_v1_interface
#define xdg_activation_token_v1_interface _glfw_xdg_activation_token_v1_interface
#define wl_surface_interface _glfw_wl_surface_interface
#define wp_fractional_scale_v1_interface _glfw_wp_fractional_scale_v1_interface
#define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl;
#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl;
@ -198,21 +209,128 @@ 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_one_sym _glfw.wl.xkb.compose_state_get_one_sym
typedef enum _GLFWdecorationSideWayland
{
mainWindow,
topDecoration,
leftDecoration,
rightDecoration,
bottomDecoration,
} _GLFWdecorationSideWayland;
struct libdecor;
struct libdecor_frame;
struct libdecor_state;
struct libdecor_configuration;
typedef struct _GLFWdecorationWayland
enum libdecor_error
{
LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,
};
enum libdecor_window_state
{
LIBDECOR_WINDOW_STATE_NONE = 0,
LIBDECOR_WINDOW_STATE_ACTIVE = 1,
LIBDECOR_WINDOW_STATE_MAXIMIZED = 2,
LIBDECOR_WINDOW_STATE_FULLSCREEN = 4,
LIBDECOR_WINDOW_STATE_TILED_LEFT = 8,
LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16,
LIBDECOR_WINDOW_STATE_TILED_TOP = 32,
LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64
};
enum libdecor_capabilities
{
LIBDECOR_ACTION_MOVE = 1,
LIBDECOR_ACTION_RESIZE = 2,
LIBDECOR_ACTION_MINIMIZE = 4,
LIBDECOR_ACTION_FULLSCREEN = 8,
LIBDECOR_ACTION_CLOSE = 16
};
struct libdecor_interface
{
void (* error)(struct libdecor*,enum libdecor_error,const char*);
void (* reserved0)(void);
void (* reserved1)(void);
void (* reserved2)(void);
void (* reserved3)(void);
void (* reserved4)(void);
void (* reserved5)(void);
void (* reserved6)(void);
void (* reserved7)(void);
void (* reserved8)(void);
void (* reserved9)(void);
};
struct libdecor_frame_interface
{
void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*);
void (* close)(struct libdecor_frame*,void*);
void (* commit)(struct libdecor_frame*,void*);
void (* dismiss_popup)(struct libdecor_frame*,const char*,void*);
void (* reserved0)(void);
void (* reserved1)(void);
void (* reserved2)(void);
void (* reserved3)(void);
void (* reserved4)(void);
void (* reserved5)(void);
void (* reserved6)(void);
void (* reserved7)(void);
void (* reserved8)(void);
void (* reserved9)(void);
};
typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*);
typedef void (* PFN_libdecor_unref)(struct libdecor*);
typedef int (* PFN_libdecor_get_fd)(struct libdecor*);
typedef int (* PFN_libdecor_dispatch)(struct libdecor*,int);
typedef struct libdecor_frame* (* PFN_libdecor_decorate)(struct libdecor*,struct wl_surface*,const struct libdecor_frame_interface*,void*);
typedef void (* PFN_libdecor_frame_unref)(struct libdecor_frame*);
typedef void (* PFN_libdecor_frame_set_app_id)(struct libdecor_frame*,const char*);
typedef void (* PFN_libdecor_frame_set_title)(struct libdecor_frame*,const char*);
typedef void (* PFN_libdecor_frame_set_minimized)(struct libdecor_frame*);
typedef void (* PFN_libdecor_frame_set_fullscreen)(struct libdecor_frame*,struct wl_output*);
typedef void (* PFN_libdecor_frame_unset_fullscreen)(struct libdecor_frame*);
typedef void (* PFN_libdecor_frame_map)(struct libdecor_frame*);
typedef void (* PFN_libdecor_frame_commit)(struct libdecor_frame*,struct libdecor_state*,struct libdecor_configuration*);
typedef void (* PFN_libdecor_frame_set_min_content_size)(struct libdecor_frame*,int,int);
typedef void (* PFN_libdecor_frame_set_max_content_size)(struct libdecor_frame*,int,int);
typedef void (* PFN_libdecor_frame_set_maximized)(struct libdecor_frame*);
typedef void (* PFN_libdecor_frame_unset_maximized)(struct libdecor_frame*);
typedef void (* PFN_libdecor_frame_set_capabilities)(struct libdecor_frame*,enum libdecor_capabilities);
typedef void (* PFN_libdecor_frame_unset_capabilities)(struct libdecor_frame*,enum libdecor_capabilities);
typedef void (* PFN_libdecor_frame_set_visibility)(struct libdecor_frame*,bool visible);
typedef struct xdg_toplevel* (* PFN_libdecor_frame_get_xdg_toplevel)(struct libdecor_frame*);
typedef bool (* PFN_libdecor_configuration_get_content_size)(struct libdecor_configuration*,struct libdecor_frame*,int*,int*);
typedef bool (* PFN_libdecor_configuration_get_window_state)(struct libdecor_configuration*,enum libdecor_window_state*);
typedef struct libdecor_state* (* PFN_libdecor_state_new)(int,int);
typedef void (* PFN_libdecor_state_free)(struct libdecor_state*);
#define libdecor_new _glfw.wl.libdecor.libdecor_new_
#define libdecor_unref _glfw.wl.libdecor.libdecor_unref_
#define libdecor_get_fd _glfw.wl.libdecor.libdecor_get_fd_
#define libdecor_dispatch _glfw.wl.libdecor.libdecor_dispatch_
#define libdecor_decorate _glfw.wl.libdecor.libdecor_decorate_
#define libdecor_frame_unref _glfw.wl.libdecor.libdecor_frame_unref_
#define libdecor_frame_set_app_id _glfw.wl.libdecor.libdecor_frame_set_app_id_
#define libdecor_frame_set_title _glfw.wl.libdecor.libdecor_frame_set_title_
#define libdecor_frame_set_minimized _glfw.wl.libdecor.libdecor_frame_set_minimized_
#define libdecor_frame_set_fullscreen _glfw.wl.libdecor.libdecor_frame_set_fullscreen_
#define libdecor_frame_unset_fullscreen _glfw.wl.libdecor.libdecor_frame_unset_fullscreen_
#define libdecor_frame_map _glfw.wl.libdecor.libdecor_frame_map_
#define libdecor_frame_commit _glfw.wl.libdecor.libdecor_frame_commit_
#define libdecor_frame_set_min_content_size _glfw.wl.libdecor.libdecor_frame_set_min_content_size_
#define libdecor_frame_set_max_content_size _glfw.wl.libdecor.libdecor_frame_set_max_content_size_
#define libdecor_frame_set_maximized _glfw.wl.libdecor.libdecor_frame_set_maximized_
#define libdecor_frame_unset_maximized _glfw.wl.libdecor.libdecor_frame_unset_maximized_
#define libdecor_frame_set_capabilities _glfw.wl.libdecor.libdecor_frame_set_capabilities_
#define libdecor_frame_unset_capabilities _glfw.wl.libdecor.libdecor_frame_unset_capabilities_
#define libdecor_frame_set_visibility _glfw.wl.libdecor.libdecor_frame_set_visibility_
#define libdecor_frame_get_xdg_toplevel _glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_
#define libdecor_configuration_get_content_size _glfw.wl.libdecor.libdecor_configuration_get_content_size_
#define libdecor_configuration_get_window_state _glfw.wl.libdecor.libdecor_configuration_get_window_state_
#define libdecor_state_new _glfw.wl.libdecor.libdecor_state_new_
#define libdecor_state_free _glfw.wl.libdecor.libdecor_state_free_
typedef struct _GLFWfallbackEdgeWayland
{
struct wl_surface* surface;
struct wl_subsurface* subsurface;
struct wp_viewport* viewport;
} _GLFWdecorationWayland;
} _GLFWfallbackEdgeWayland;
typedef struct _GLFWofferWayland
{
@ -221,17 +339,25 @@ typedef struct _GLFWofferWayland
GLFWbool text_uri_list;
} _GLFWofferWayland;
typedef struct _GLFWscaleWayland
{
struct wl_output* output;
int32_t factor;
} _GLFWscaleWayland;
// Wayland-specific per-window data
//
typedef struct _GLFWwindowWayland
{
int width, height;
int fbWidth, fbHeight;
GLFWbool visible;
GLFWbool maximized;
GLFWbool activated;
GLFWbool fullscreen;
GLFWbool hovered;
GLFWbool transparent;
GLFWbool scaleFramebuffer;
struct wl_surface* surface;
struct wl_callback* callback;
@ -254,30 +380,39 @@ typedef struct _GLFWwindowWayland
uint32_t decorationMode;
} xdg;
struct {
struct libdecor_frame* frame;
} libdecor;
_GLFWcursor* currentCursor;
double cursorPosX, cursorPosY;
char* title;
char* appId;
// We need to track the monitors the window spans on to calculate the
// optimal scaling factor.
int scale;
_GLFWmonitor** monitors;
int monitorsCount;
int monitorsSize;
int32_t bufferScale;
_GLFWscaleWayland* outputScales;
size_t outputScaleCount;
size_t outputScaleSize;
struct wp_viewport* scalingViewport;
uint32_t scalingNumerator;
struct wp_fractional_scale_v1* fractionalScale;
struct zwp_relative_pointer_v1* relativePointer;
struct zwp_locked_pointer_v1* lockedPointer;
struct zwp_confined_pointer_v1* confinedPointer;
struct zwp_idle_inhibitor_v1* idleInhibitor;
struct zwp_idle_inhibitor_v1* idleInhibitor;
struct xdg_activation_token_v1* activationToken;
struct {
struct wl_buffer* buffer;
_GLFWdecorationWayland top, left, right, bottom;
_GLFWdecorationSideWayland focus;
} decorations;
GLFWbool decorations;
struct wl_buffer* buffer;
_GLFWfallbackEdgeWayland top, left, right, bottom;
struct wl_surface* focus;
} fallback;
} _GLFWwindowWayland;
// Wayland-specific global data
@ -300,6 +435,8 @@ typedef struct _GLFWlibraryWayland
struct zwp_relative_pointer_manager_v1* relativePointerManager;
struct zwp_pointer_constraints_v1* pointerConstraints;
struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
struct xdg_activation_v1* activationManager;
struct wp_fractional_scale_manager_v1* fractionalScaleManager;
_GLFWofferWayland* offers;
unsigned int offerCount;
@ -311,8 +448,7 @@ typedef struct _GLFWlibraryWayland
_GLFWwindow* dragFocus;
uint32_t dragSerial;
int compositorVersion;
int seatVersion;
const char* tag;
struct wl_cursor_theme* cursorTheme;
struct wl_cursor_theme* cursorThemeHiDPI;
@ -391,6 +527,8 @@ typedef struct _GLFWlibraryWayland
PFN_wl_proxy_marshal_constructor_versioned proxy_marshal_constructor_versioned;
PFN_wl_proxy_get_user_data proxy_get_user_data;
PFN_wl_proxy_set_user_data proxy_set_user_data;
PFN_wl_proxy_get_tag proxy_get_tag;
PFN_wl_proxy_set_tag proxy_set_tag;
PFN_wl_proxy_get_version proxy_get_version;
PFN_wl_proxy_marshal_flags proxy_marshal_flags;
} client;
@ -411,6 +549,38 @@ typedef struct _GLFWlibraryWayland
PFN_wl_egl_window_destroy window_destroy;
PFN_wl_egl_window_resize window_resize;
} egl;
struct {
void* handle;
struct libdecor* context;
struct wl_callback* callback;
GLFWbool ready;
PFN_libdecor_new libdecor_new_;
PFN_libdecor_unref libdecor_unref_;
PFN_libdecor_get_fd libdecor_get_fd_;
PFN_libdecor_dispatch libdecor_dispatch_;
PFN_libdecor_decorate libdecor_decorate_;
PFN_libdecor_frame_unref libdecor_frame_unref_;
PFN_libdecor_frame_set_app_id libdecor_frame_set_app_id_;
PFN_libdecor_frame_set_title libdecor_frame_set_title_;
PFN_libdecor_frame_set_minimized libdecor_frame_set_minimized_;
PFN_libdecor_frame_set_fullscreen libdecor_frame_set_fullscreen_;
PFN_libdecor_frame_unset_fullscreen libdecor_frame_unset_fullscreen_;
PFN_libdecor_frame_map libdecor_frame_map_;
PFN_libdecor_frame_commit libdecor_frame_commit_;
PFN_libdecor_frame_set_min_content_size libdecor_frame_set_min_content_size_;
PFN_libdecor_frame_set_max_content_size libdecor_frame_set_max_content_size_;
PFN_libdecor_frame_set_maximized libdecor_frame_set_maximized_;
PFN_libdecor_frame_unset_maximized libdecor_frame_unset_maximized_;
PFN_libdecor_frame_set_capabilities libdecor_frame_set_capabilities_;
PFN_libdecor_frame_unset_capabilities libdecor_frame_unset_capabilities_;
PFN_libdecor_frame_set_visibility libdecor_frame_set_visibility_;
PFN_libdecor_frame_get_xdg_toplevel libdecor_frame_get_xdg_toplevel_;
PFN_libdecor_configuration_get_content_size libdecor_configuration_get_content_size_;
PFN_libdecor_configuration_get_window_state libdecor_configuration_get_window_state_;
PFN_libdecor_state_new libdecor_state_new_;
PFN_libdecor_state_free libdecor_state_free_;
} libdecor;
} _GLFWlibraryWayland;
// Wayland-specific per-monitor data
@ -423,7 +593,7 @@ typedef struct _GLFWmonitorWayland
int x;
int y;
int scale;
int32_t scale;
} _GLFWmonitorWayland;
// Wayland-specific per-cursor data
@ -509,12 +679,12 @@ void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
void _glfwAddOutputWayland(uint32_t name, uint32_t version);
void _glfwUpdateContentScaleWayland(_GLFWwindow* window);
void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window);
void _glfwAddSeatListenerWayland(struct wl_seat* seat);
void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device);

File diff suppressed because it is too large Load Diff

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_X11)
#include <stdlib.h>
#include <string.h>
#include <limits.h>
@ -1166,86 +1166,86 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform x11 =
{
GLFW_PLATFORM_X11,
_glfwInitX11,
_glfwTerminateX11,
_glfwGetCursorPosX11,
_glfwSetCursorPosX11,
_glfwSetCursorModeX11,
_glfwSetRawMouseMotionX11,
_glfwRawMouseMotionSupportedX11,
_glfwCreateCursorX11,
_glfwCreateStandardCursorX11,
_glfwDestroyCursorX11,
_glfwSetCursorX11,
_glfwGetScancodeNameX11,
_glfwGetKeyScancodeX11,
_glfwSetClipboardStringX11,
_glfwGetClipboardStringX11,
#if defined(__linux__)
_glfwInitJoysticksLinux,
_glfwTerminateJoysticksLinux,
_glfwPollJoystickLinux,
_glfwGetMappingNameLinux,
_glfwUpdateGamepadGUIDLinux,
.platformID = GLFW_PLATFORM_X11,
.init = _glfwInitX11,
.terminate = _glfwTerminateX11,
.getCursorPos = _glfwGetCursorPosX11,
.setCursorPos = _glfwSetCursorPosX11,
.setCursorMode = _glfwSetCursorModeX11,
.setRawMouseMotion = _glfwSetRawMouseMotionX11,
.rawMouseMotionSupported = _glfwRawMouseMotionSupportedX11,
.createCursor = _glfwCreateCursorX11,
.createStandardCursor = _glfwCreateStandardCursorX11,
.destroyCursor = _glfwDestroyCursorX11,
.setCursor = _glfwSetCursorX11,
.getScancodeName = _glfwGetScancodeNameX11,
.getKeyScancode = _glfwGetKeyScancodeX11,
.setClipboardString = _glfwSetClipboardStringX11,
.getClipboardString = _glfwGetClipboardStringX11,
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
.initJoysticks = _glfwInitJoysticksLinux,
.terminateJoysticks = _glfwTerminateJoysticksLinux,
.pollJoystick = _glfwPollJoystickLinux,
.getMappingName = _glfwGetMappingNameLinux,
.updateGamepadGUID = _glfwUpdateGamepadGUIDLinux,
#else
_glfwInitJoysticksNull,
_glfwTerminateJoysticksNull,
_glfwPollJoystickNull,
_glfwGetMappingNameNull,
_glfwUpdateGamepadGUIDNull,
.initJoysticks = _glfwInitJoysticksNull,
.terminateJoysticks = _glfwTerminateJoysticksNull,
.pollJoystick = _glfwPollJoystickNull,
.getMappingName = _glfwGetMappingNameNull,
.updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
#endif
_glfwFreeMonitorX11,
_glfwGetMonitorPosX11,
_glfwGetMonitorContentScaleX11,
_glfwGetMonitorWorkareaX11,
_glfwGetVideoModesX11,
_glfwGetVideoModeX11,
_glfwGetGammaRampX11,
_glfwSetGammaRampX11,
_glfwCreateWindowX11,
_glfwDestroyWindowX11,
_glfwSetWindowTitleX11,
_glfwSetWindowIconX11,
_glfwGetWindowPosX11,
_glfwSetWindowPosX11,
_glfwGetWindowSizeX11,
_glfwSetWindowSizeX11,
_glfwSetWindowSizeLimitsX11,
_glfwSetWindowAspectRatioX11,
_glfwGetFramebufferSizeX11,
_glfwGetWindowFrameSizeX11,
_glfwGetWindowContentScaleX11,
_glfwIconifyWindowX11,
_glfwRestoreWindowX11,
_glfwMaximizeWindowX11,
_glfwShowWindowX11,
_glfwHideWindowX11,
_glfwRequestWindowAttentionX11,
_glfwFocusWindowX11,
_glfwSetWindowMonitorX11,
_glfwWindowFocusedX11,
_glfwWindowIconifiedX11,
_glfwWindowVisibleX11,
_glfwWindowMaximizedX11,
_glfwWindowHoveredX11,
_glfwFramebufferTransparentX11,
_glfwGetWindowOpacityX11,
_glfwSetWindowResizableX11,
_glfwSetWindowDecoratedX11,
_glfwSetWindowFloatingX11,
_glfwSetWindowOpacityX11,
_glfwSetWindowMousePassthroughX11,
_glfwPollEventsX11,
_glfwWaitEventsX11,
_glfwWaitEventsTimeoutX11,
_glfwPostEmptyEventX11,
_glfwGetEGLPlatformX11,
_glfwGetEGLNativeDisplayX11,
_glfwGetEGLNativeWindowX11,
_glfwGetRequiredInstanceExtensionsX11,
_glfwGetPhysicalDevicePresentationSupportX11,
_glfwCreateWindowSurfaceX11,
.freeMonitor = _glfwFreeMonitorX11,
.getMonitorPos = _glfwGetMonitorPosX11,
.getMonitorContentScale = _glfwGetMonitorContentScaleX11,
.getMonitorWorkarea = _glfwGetMonitorWorkareaX11,
.getVideoModes = _glfwGetVideoModesX11,
.getVideoMode = _glfwGetVideoModeX11,
.getGammaRamp = _glfwGetGammaRampX11,
.setGammaRamp = _glfwSetGammaRampX11,
.createWindow = _glfwCreateWindowX11,
.destroyWindow = _glfwDestroyWindowX11,
.setWindowTitle = _glfwSetWindowTitleX11,
.setWindowIcon = _glfwSetWindowIconX11,
.getWindowPos = _glfwGetWindowPosX11,
.setWindowPos = _glfwSetWindowPosX11,
.getWindowSize = _glfwGetWindowSizeX11,
.setWindowSize = _glfwSetWindowSizeX11,
.setWindowSizeLimits = _glfwSetWindowSizeLimitsX11,
.setWindowAspectRatio = _glfwSetWindowAspectRatioX11,
.getFramebufferSize = _glfwGetFramebufferSizeX11,
.getWindowFrameSize = _glfwGetWindowFrameSizeX11,
.getWindowContentScale = _glfwGetWindowContentScaleX11,
.iconifyWindow = _glfwIconifyWindowX11,
.restoreWindow = _glfwRestoreWindowX11,
.maximizeWindow = _glfwMaximizeWindowX11,
.showWindow = _glfwShowWindowX11,
.hideWindow = _glfwHideWindowX11,
.requestWindowAttention = _glfwRequestWindowAttentionX11,
.focusWindow = _glfwFocusWindowX11,
.setWindowMonitor = _glfwSetWindowMonitorX11,
.windowFocused = _glfwWindowFocusedX11,
.windowIconified = _glfwWindowIconifiedX11,
.windowVisible = _glfwWindowVisibleX11,
.windowMaximized = _glfwWindowMaximizedX11,
.windowHovered = _glfwWindowHoveredX11,
.framebufferTransparent = _glfwFramebufferTransparentX11,
.getWindowOpacity = _glfwGetWindowOpacityX11,
.setWindowResizable = _glfwSetWindowResizableX11,
.setWindowDecorated = _glfwSetWindowDecoratedX11,
.setWindowFloating = _glfwSetWindowFloatingX11,
.setWindowOpacity = _glfwSetWindowOpacityX11,
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11,
.pollEvents = _glfwPollEventsX11,
.waitEvents = _glfwWaitEventsX11,
.waitEventsTimeout = _glfwWaitEventsTimeoutX11,
.postEmptyEvent = _glfwPostEmptyEventX11,
.getEGLPlatform = _glfwGetEGLPlatformX11,
.getEGLNativeDisplay = _glfwGetEGLNativeDisplayX11,
.getEGLNativeWindow = _glfwGetEGLNativeWindowX11,
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsX11,
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportX11,
.createWindowSurface = _glfwCreateWindowSurfaceX11
};
// HACK: If the application has left the locale as "C" then both wide
@ -1652,3 +1652,5 @@ void _glfwTerminateX11(void)
}
}
#endif // _GLFW_X11

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_X11)
#include <limits.h>
#include <stdlib.h>
#include <string.h>
@ -491,24 +491,31 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
return result;
}
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
{
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{
XRRScreenResources* sr =
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
const XRRModeInfo* mi = NULL;
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
if (ci)
{
const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
if (mi) // mi can be NULL if the monitor has been disconnected
mi = getModeInfo(sr, ci->mode);
if (mi)
*mode = vidmodeFromModeInfo(mi, ci);
XRRFreeCrtcInfo(ci);
}
XRRFreeScreenResources(sr);
if (!mi)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to query video mode");
return GLFW_FALSE;
}
}
else
{
@ -519,6 +526,8 @@ void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
_glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
&mode->redBits, &mode->greenBits, &mode->blueBits);
}
return GLFW_TRUE;
}
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
@ -604,6 +613,13 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
return None;
}
return monitor->x11.crtc;
}
@ -611,6 +627,15 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized");
return None;
}
return monitor->x11.output;
}
#endif // _GLFW_X11

View File

@ -968,7 +968,7 @@ void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);

View File

@ -24,11 +24,11 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_X11)
#include <X11/cursorfont.h>
#include <X11/Xmd.h>
@ -79,24 +79,25 @@ static GLFWbool waitForX11Event(double* timeout)
//
static GLFWbool waitForAnyEvent(double* timeout)
{
nfds_t count = 2;
struct pollfd fds[3] =
enum { XLIB_FD, PIPE_FD, INOTIFY_FD };
struct pollfd fds[] =
{
{ ConnectionNumber(_glfw.x11.display), POLLIN },
{ _glfw.x11.emptyEventPipe[0], POLLIN }
[XLIB_FD] = { ConnectionNumber(_glfw.x11.display), POLLIN },
[PIPE_FD] = { _glfw.x11.emptyEventPipe[0], POLLIN },
[INOTIFY_FD] = { -1, POLLIN }
};
#if defined(__linux__)
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
if (_glfw.joysticksInitialized)
fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN };
fds[INOTIFY_FD].fd = _glfw.linjs.inotify;
#endif
while (!XPending(_glfw.x11.display))
{
if (!_glfwPollPOSIX(fds, count, timeout))
if (!_glfwPollPOSIX(fds, sizeof(fds) / sizeof(fds[0]), timeout))
return GLFW_FALSE;
for (int i = 1; i < count; i++)
for (int i = 1; i < sizeof(fds) / sizeof(fds[0]); i++)
{
if (fds[i].revents & POLLIN)
return GLFW_TRUE;
@ -1487,6 +1488,9 @@ static void processEvent(XEvent *event)
if (event->xconfigure.width != window->x11.width ||
event->xconfigure.height != window->x11.height)
{
window->x11.width = event->xconfigure.width;
window->x11.height = event->xconfigure.height;
_glfwInputFramebufferSize(window,
event->xconfigure.width,
event->xconfigure.height);
@ -1494,9 +1498,6 @@ static void processEvent(XEvent *event)
_glfwInputWindowSize(window,
event->xconfigure.width,
event->xconfigure.height);
window->x11.width = event->xconfigure.width;
window->x11.height = event->xconfigure.height;
}
int xpos = event->xconfigure.x;
@ -1524,9 +1525,10 @@ static void processEvent(XEvent *event)
if (xpos != window->x11.xpos || ypos != window->x11.ypos)
{
_glfwInputWindowPos(window, xpos, ypos);
window->x11.xpos = xpos;
window->x11.ypos = ypos;
_glfwInputWindowPos(window, xpos, ypos);
}
return;
@ -2781,7 +2783,7 @@ void _glfwPollEventsX11(void)
{
drainEmptyEvents();
#if defined(__linux__)
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
if (_glfw.joysticksInitialized)
_glfwDetectJoystickConnectionLinux();
#endif
@ -2901,14 +2903,16 @@ const char* _glfwGetScancodeNameX11(int scancode)
if (!_glfw.x11.xkb.available)
return NULL;
if (scancode < 0 || scancode > 0xff ||
_glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 0xff)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
const int key = _glfw.x11.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
scancode, _glfw.x11.xkb.group, 0);
if (keysym == NoSymbol)
@ -3349,3 +3353,5 @@ GLFWAPI const char* glfwGetX11SelectionString(void)
return getSelectionString(_glfw.x11.PRIMARY);
}
#endif // _GLFW_X11

View File

@ -24,11 +24,10 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND)
/*
* Marcus: This code was originally written by Markus G. Kuhn.
@ -940,3 +939,5 @@ uint32_t _glfwKeySym2Unicode(unsigned int keysym)
return GLFW_INVALID_CODEPOINT;
}
#endif // _GLFW_WAYLAND or _GLFW_X11

View File

@ -74,7 +74,6 @@
//#define GLFW_EXPOSE_NATIVE_X11 // WARNING: Exposing Xlib.h > X.h results in dup symbols for Font type
//#define GLFW_EXPOSE_NATIVE_WAYLAND
//#define GLFW_EXPOSE_NATIVE_MIR
#include "GLFW/glfw3native.h" // Required for: glfwGetX11Window()
#endif
#if defined(__APPLE__)
@ -1570,6 +1569,17 @@ int InitPlatform(void)
CORE.Storage.basePath = GetWorkingDirectory();
//----------------------------------------------------------------------------
char* glfwPlatform = "";
switch (glfwGetPlatform())
{
case GLFW_PLATFORM_WIN32: glfwPlatform = "Win32"; break;
case GLFW_PLATFORM_COCOA: glfwPlatform = "Cocoa"; break;
case GLFW_PLATFORM_WAYLAND: glfwPlatform = "Wayland"; break;
case GLFW_PLATFORM_X11: glfwPlatform = "X11"; break;
case GLFW_PLATFORM_NULL: glfwPlatform = "Null"; break;
}
TRACELOG(LOG_INFO, "GLFW platform: %s", glfwPlatform);
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (GLFW): Initialized successfully");
return 0;

View File

@ -34,8 +34,8 @@
// _GLFW_X11 to use the X Window System
// _GLFW_WAYLAND to use the Wayland API (experimental and incomplete)
// _GLFW_COCOA to use the Cocoa frameworks
// _GLFW_OSMESA to use the OSMesa API (headless and non-interactive)
// _GLFW_MIR experimental, not supported at this moment
//
// Note: GLFW's runtime platform selection is not supported at the moment
//----------------------------------------------------------------------------------
// Feature Test Macros required for this module
@ -69,6 +69,15 @@
#define _WIN32_WINNT_WINXP 0x0501
#endif
#include "external/glfw/src/internal.h"
// We do not use GLFW's "null" platform, but the absence of this function
// causes the build to fail
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
{
return GLFW_TRUE;
}
// Common modules to all platforms
#include "external/glfw/src/init.c"
#include "external/glfw/src/platform.c"