Compare commits

...

4 Commits

Author SHA1 Message Date
JakobDev
fa0220d762
Merge adcb0bda78 into d11cb3779b 2025-07-12 18:58:52 +08:00
Camilla Löwy
d11cb3779b Win32: Remove support for Windows XP and Vista
It's increasingly difficult to maintain a safe testing environment for
Windows XP, and so increasingly a burden on contributors to maintain
support for it.

Windows XP has been out of of support since 2014 and should not be used
as a desktop OS.

Fixes #2505
2025-07-11 16:49:23 +02:00
JakobDev
adcb0bda78
Fix 2025-01-28 17:36:59 +01:00
JakobDev
69cc9fe0a8
Wayland: Implement cursor-shape-v1 protocol 2025-01-28 17:24:05 +01:00
12 changed files with 1450 additions and 79 deletions

View File

@ -79,7 +79,7 @@ more information.
## System requirements ## System requirements
GLFW supports Windows XP and later and macOS 10.11 and later. Linux and other GLFW supports Windows 7 and later and macOS 10.11 and later. Linux and other
Unix-like systems running the X Window System are supported even without Unix-like systems running the X Window System are supported even without
a desktop environment or modern extensions, although some features require a desktop environment or modern extensions, although some features require
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3. a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
@ -125,6 +125,7 @@ information on what to include when reporting a bug.
the limit of the mouse button tokens to be reported (#2423) the limit of the mouse button tokens to be reported (#2423)
- Updated minimum CMake version to 3.16 (#2541) - Updated minimum CMake version to 3.16 (#2541)
- Removed support for building with original MinGW (#2540) - Removed support for building with original MinGW (#2540)
- [Win32] Removed support for Windows XP and Vista (#2505)
- [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Added `QuartzCore` framework as link-time dependency
- [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: The fractional scaling related objects were not destroyed

152
deps/wayland/cursor-shape-v1.xml vendored Normal file
View File

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="cursor_shape_v1">
<copyright>
Copyright 2018 The Chromium Authors
Copyright 2023 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="wp_cursor_shape_manager_v1" version="1">
<description summary="cursor shape manager">
This global offers an alternative, optional way to set cursor images. This
new way uses enumerated cursors instead of a wl_surface like
wl_pointer.set_cursor does.
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>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
Destroy the cursor shape manager.
</description>
</request>
<request name="get_pointer">
<description summary="manage the cursor shape of a pointer device">
Obtain a wp_cursor_shape_device_v1 for a wl_pointer object.
When the pointer capability is removed from the wl_seat, the
wp_cursor_shape_device_v1 object becomes inert.
</description>
<arg name="cursor_shape_device" type="new_id" interface="wp_cursor_shape_device_v1"/>
<arg name="pointer" type="object" interface="wl_pointer"/>
</request>
<request name="get_tablet_tool_v2">
<description summary="manage the cursor shape of a tablet tool device">
Obtain a wp_cursor_shape_device_v1 for a zwp_tablet_tool_v2 object.
When the zwp_tablet_tool_v2 is removed, the wp_cursor_shape_device_v1
object becomes inert.
</description>
<arg name="cursor_shape_device" type="new_id" interface="wp_cursor_shape_device_v1"/>
<arg name="tablet_tool" type="object" interface="zwp_tablet_tool_v2"/>
</request>
</interface>
<interface name="wp_cursor_shape_device_v1" version="1">
<description summary="cursor shape for a device">
This interface allows clients to set the cursor shape.
</description>
<enum name="shape">
<description summary="cursor shapes">
This enum describes cursor shapes.
The names are taken from the CSS W3C specification:
https://w3c.github.io/csswg-drafts/css-ui/#cursor
</description>
<entry name="default" value="1" summary="default cursor"/>
<entry name="context_menu" value="2" summary="a context menu is available for the object under the cursor"/>
<entry name="help" value="3" summary="help is available for the object under the cursor"/>
<entry name="pointer" value="4" summary="pointer that indicates a link or another interactive element"/>
<entry name="progress" value="5" summary="progress indicator"/>
<entry name="wait" value="6" summary="program is busy, user should wait"/>
<entry name="cell" value="7" summary="a cell or set of cells may be selected"/>
<entry name="crosshair" value="8" summary="simple crosshair"/>
<entry name="text" value="9" summary="text may be selected"/>
<entry name="vertical_text" value="10" summary="vertical text may be selected"/>
<entry name="alias" value="11" summary="drag-and-drop: alias of/shortcut to something is to be created"/>
<entry name="copy" value="12" summary="drag-and-drop: something is to be copied"/>
<entry name="move" value="13" summary="drag-and-drop: something is to be moved"/>
<entry name="no_drop" value="14" summary="drag-and-drop: the dragged item cannot be dropped at the current cursor location"/>
<entry name="not_allowed" value="15" summary="drag-and-drop: the requested action will not be carried out"/>
<entry name="grab" value="16" summary="drag-and-drop: something can be grabbed"/>
<entry name="grabbing" value="17" summary="drag-and-drop: something is being grabbed"/>
<entry name="e_resize" value="18" summary="resizing: the east border is to be moved"/>
<entry name="n_resize" value="19" summary="resizing: the north border is to be moved"/>
<entry name="ne_resize" value="20" summary="resizing: the north-east corner is to be moved"/>
<entry name="nw_resize" value="21" summary="resizing: the north-west corner is to be moved"/>
<entry name="s_resize" value="22" summary="resizing: the south border is to be moved"/>
<entry name="se_resize" value="23" summary="resizing: the south-east corner is to be moved"/>
<entry name="sw_resize" value="24" summary="resizing: the south-west corner is to be moved"/>
<entry name="w_resize" value="25" summary="resizing: the west border is to be moved"/>
<entry name="ew_resize" value="26" summary="resizing: the east and west borders are to be moved"/>
<entry name="ns_resize" value="27" summary="resizing: the north and south borders are to be moved"/>
<entry name="nesw_resize" value="28" summary="resizing: the north-east and south-west corners are to be moved"/>
<entry name="nwse_resize" value="29" summary="resizing: the north-west and south-east corners are to be moved"/>
<entry name="col_resize" value="30" summary="resizing: that the item/column can be resized horizontally"/>
<entry name="row_resize" value="31" summary="resizing: that the item/row can be resized vertically"/>
<entry name="all_scroll" value="32" summary="something can be scrolled in any direction"/>
<entry name="zoom_in" value="33" summary="something can be zoomed in"/>
<entry name="zoom_out" value="34" summary="something can be zoomed out"/>
</enum>
<enum name="error">
<entry name="invalid_shape" value="1"
summary="the specified shape value is invalid"/>
</enum>
<request name="destroy" type="destructor">
<description summary="destroy the cursor shape device">
Destroy the cursor shape device.
The device cursor shape remains unchanged.
</description>
</request>
<request name="set_shape">
<description summary="set device cursor to the shape">
Sets the device cursor to the specified shape. The compositor will
change the cursor image based on the specified shape.
The cursor actually changes only if the input device focus is one of
the requesting client's surfaces. If any, the previous cursor image
(surface or shape) is replaced.
The "shape" argument must be a valid enum entry, otherwise the
invalid_shape protocol error is raised.
This is similar to the wl_pointer.set_cursor and
zwp_tablet_tool_v2.set_cursor requests, but this request accepts a
shape instead of contents in the form of a surface. Clients can mix
set_cursor and set_shape requests.
The serial parameter must match the latest wl_pointer.enter or
zwp_tablet_tool_v2.proximity_in serial number sent to the client.
Otherwise the request will be ignored.
</description>
<arg name="serial" type="uint" summary="serial number of the enter event"/>
<arg name="shape" type="uint" enum="shape"/>
</request>
</interface>
</protocol>

1182
deps/wayland/tablet-unstable-v2.xml vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,12 @@ this.
## Removals {#removals} ## Removals {#removals}
### Windows XP and Vista support has been removed {#winxp_vista}
Support for Windows XP and Vista has been removed. Windows XP has been out of extended
support since 2014.
### Original MinGW support has been removed {#original_mingw} ### Original MinGW support has been removed {#original_mingw}
Support for the now unmaintained original MinGW distribution has been removed. Support for the now unmaintained original MinGW distribution has been removed.

View File

@ -105,6 +105,8 @@ if (GLFW_BUILD_WAYLAND)
generate_wayland_protocol("fractional-scale-v1.xml") generate_wayland_protocol("fractional-scale-v1.xml")
generate_wayland_protocol("xdg-activation-v1.xml") generate_wayland_protocol("xdg-activation-v1.xml")
generate_wayland_protocol("xdg-decoration-unstable-v1.xml") generate_wayland_protocol("xdg-decoration-unstable-v1.xml")
generate_wayland_protocol("tablet-unstable-v2.xml")
generate_wayland_protocol("cursor-shape-v1.xml")
endif() endif()
if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY) if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)

View File

@ -327,8 +327,8 @@ static void swapBuffersWGL(_GLFWwindow* window)
{ {
if (!window->monitor) if (!window->monitor)
{ {
// HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7 // HACK: Use DwmFlush when desktop composition is enabled on Windows 7
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) if (!IsWindows8OrGreater())
{ {
BOOL enabled = FALSE; BOOL enabled = FALSE;
@ -353,9 +353,9 @@ static void swapIntervalWGL(int interval)
if (!window->monitor) if (!window->monitor)
{ {
// HACK: Disable WGL swap interval when desktop composition is enabled on Windows // HACK: Disable WGL swap interval when desktop composition is enabled on
// Vista and 7 to avoid interfering with DWM vsync // Windows 7 to avoid interfering with DWM vsync
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) if (!IsWindows8OrGreater())
{ {
BOOL enabled = FALSE; BOOL enabled = FALSE;

View File

@ -89,10 +89,6 @@ static GLFWbool loadLibraries(void)
return GLFW_FALSE; return GLFW_FALSE;
} }
_glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware");
_glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling) _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext) _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
@ -692,7 +688,7 @@ int _glfwInitWin32(void)
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
else if (IsWindows8Point1OrGreater()) else if (IsWindows8Point1OrGreater())
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
else if (IsWindowsVistaOrGreater()) else
SetProcessDPIAware(); SetProcessDPIAware();
if (!createHelperWindow()) if (!createHelperWindow())

View File

@ -48,14 +48,14 @@
#define UNICODE #define UNICODE
#endif #endif
// GLFW requires Windows XP or later // GLFW requires Windows 7 or later
#if WINVER < 0x0501 #if WINVER < 0x0601
#undef WINVER #undef WINVER
#define WINVER 0x0501 #define WINVER 0x0601
#endif #endif
#if _WIN32_WINNT < 0x0501 #if _WIN32_WINNT < 0x0601
#undef _WIN32_WINNT #undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 #define _WIN32_WINNT 0x0601
#endif #endif
// GLFW uses DirectInput8 interfaces // GLFW uses DirectInput8 interfaces
@ -66,20 +66,12 @@
#include <wctype.h> #include <wctype.h>
#include <windows.h> #include <windows.h>
#include <dwmapi.h>
#include <dinput.h> #include <dinput.h>
#include <xinput.h> #include <xinput.h>
#include <dbt.h> #include <dbt.h>
// HACK: Define macros that some windows.h variants don't // HACK: Define macros that some windows.h variants don't
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
#endif
#ifndef WM_DWMCOMPOSITIONCHANGED
#define WM_DWMCOMPOSITIONCHANGED 0x031E
#endif
#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
#define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
#endif
#ifndef WM_COPYGLOBALDATA #ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDATA 0x0049 #define WM_COPYGLOBALDATA 0x0049
#endif #endif
@ -102,31 +94,6 @@
#define USER_DEFAULT_SCREEN_DPI 96 #define USER_DEFAULT_SCREEN_DPI 96
#endif #endif
#if WINVER < 0x0601
typedef struct
{
DWORD cbSize;
DWORD ExtStatus;
} CHANGEFILTERSTRUCT;
#ifndef MSGFLT_ALLOW
#define MSGFLT_ALLOW 1
#endif
#endif /*Windows 7*/
#if WINVER < 0x0600
#define DWM_BB_ENABLE 0x00000001
#define DWM_BB_BLURREGION 0x00000002
typedef struct
{
DWORD dwFlags;
BOOL fEnable;
HRGN hRgnBlur;
BOOL fTransitionOnMaximized;
} DWM_BLURBEHIND;
#else
#include <dwmapi.h>
#endif /*Windows Vista*/
#ifndef DPI_ENUMS_DECLARED #ifndef DPI_ENUMS_DECLARED
typedef enum typedef enum
{ {
@ -150,12 +117,6 @@ typedef enum
// Replacement for versionhelpers.h macros, as we cannot rely on the // Replacement for versionhelpers.h macros, as we cannot rely on the
// application having a correct embedded manifest // application having a correct embedded manifest
// //
#define IsWindowsVistaOrGreater() \
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
LOBYTE(_WIN32_WINNT_VISTA), 0)
#define IsWindows7OrGreater() \
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \
LOBYTE(_WIN32_WINNT_WIN7), 0)
#define IsWindows8OrGreater() \ #define IsWindows8OrGreater() \
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \
LOBYTE(_WIN32_WINNT_WIN8), 0) LOBYTE(_WIN32_WINNT_WIN8), 0)
@ -266,15 +227,11 @@ typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*
#define DirectInput8Create _glfw.win32.dinput8.Create #define DirectInput8Create _glfw.win32.dinput8.Create
// user32.dll function pointer typedefs // user32.dll function pointer typedefs
typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND); typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE); typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND); typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT); typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT); typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_ #define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_ #define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_ #define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
@ -460,8 +417,6 @@ typedef struct _GLFWlibraryWin32
struct { struct {
HINSTANCE instance; HINSTANCE instance;
PFN_SetProcessDPIAware SetProcessDPIAware_;
PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_; PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_;
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_; PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
PFN_GetDpiForWindow GetDpiForWindow_; PFN_GetDpiForWindow GetDpiForWindow_;

View File

@ -374,9 +374,6 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
BOOL composition, opaque; BOOL composition, opaque;
DWORD color; DWORD color;
if (!IsWindowsVistaOrGreater())
return;
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
return; return;
@ -983,7 +980,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
case WM_MOUSEHWHEEL: case WM_MOUSEHWHEEL:
{ {
// This message is only sent on Windows Vista and later
// NOTE: The X-axis is inverted for consistency with macOS and X11 // NOTE: The X-axis is inverted for consistency with macOS and X11
_glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0); _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
return 0; return 0;
@ -1407,15 +1403,9 @@ static int createNativeWindow(_GLFWwindow* window,
SetPropW(window->win32.handle, L"GLFW", window); SetPropW(window->win32.handle, L"GLFW", window);
if (IsWindows7OrGreater()) ChangeWindowMessageFilterEx(window->win32.handle, WM_DROPFILES, MSGFLT_ALLOW, NULL);
{ ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYDATA, MSGFLT_ALLOW, NULL);
ChangeWindowMessageFilterEx(window->win32.handle, ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
WM_DROPFILES, MSGFLT_ALLOW, NULL);
ChangeWindowMessageFilterEx(window->win32.handle,
WM_COPYDATA, MSGFLT_ALLOW, NULL);
ChangeWindowMessageFilterEx(window->win32.handle,
WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
}
window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
window->win32.keymenu = wndconfig->win32.keymenu; window->win32.keymenu = wndconfig->win32.keymenu;
@ -1981,9 +1971,6 @@ GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window)
if (!window->win32.transparent) if (!window->win32.transparent)
return GLFW_FALSE; return GLFW_FALSE;
if (!IsWindowsVistaOrGreater())
return GLFW_FALSE;
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
return GLFW_FALSE; return GLFW_FALSE;

View File

@ -49,6 +49,8 @@
#include "fractional-scale-v1-client-protocol.h" #include "fractional-scale-v1-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h" #include "xdg-activation-v1-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h" #include "idle-inhibit-unstable-v1-client-protocol.h"
#include "tablet-unstable-v2-client-protocol.h"
#include "cursor-shape-v1-client-protocol.h"
// NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of // NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of
// wl_interface pointers 'types', making it impossible to combine several unmodified // wl_interface pointers 'types', making it impossible to combine several unmodified
@ -91,6 +93,14 @@
#include "idle-inhibit-unstable-v1-client-protocol-code.h" #include "idle-inhibit-unstable-v1-client-protocol-code.h"
#undef types #undef types
#define types _glfw_tablet_types
#include "tablet-unstable-v2-client-protocol-code.h"
#undef types
#define types _glfw_cursor_shape_types
#include "cursor-shape-v1-client-protocol-code.h"
#undef types
static void wmBaseHandlePing(void* userData, static void wmBaseHandlePing(void* userData,
struct xdg_wm_base* wmBase, struct xdg_wm_base* wmBase,
uint32_t serial) uint32_t serial)
@ -208,6 +218,13 @@ static void registryHandleGlobal(void* userData,
&wp_fractional_scale_manager_v1_interface, &wp_fractional_scale_manager_v1_interface,
1); 1);
} }
else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0)
{
_glfw.wl.cursorShapeManager =
wl_registry_bind(registry, name,
&wp_cursor_shape_manager_v1_interface,
1);
}
} }
static void registryHandleGlobalRemove(void* userData, static void registryHandleGlobalRemove(void* userData,
@ -988,6 +1005,10 @@ void _glfwTerminateWayland(void)
xdg_activation_v1_destroy(_glfw.wl.activationManager); xdg_activation_v1_destroy(_glfw.wl.activationManager);
if (_glfw.wl.fractionalScaleManager) if (_glfw.wl.fractionalScaleManager)
wp_fractional_scale_manager_v1_destroy(_glfw.wl.fractionalScaleManager); wp_fractional_scale_manager_v1_destroy(_glfw.wl.fractionalScaleManager);
if (_glfw.wl.cursorShapeManager)
wp_cursor_shape_manager_v1_destroy(_glfw.wl.cursorShapeManager);
if (_glfw.wl.cursorShapeDevice)
wp_cursor_shape_device_v1_destroy(_glfw.wl.cursorShapeDevice);
if (_glfw.wl.registry) if (_glfw.wl.registry)
wl_registry_destroy(_glfw.wl.registry); wl_registry_destroy(_glfw.wl.registry);
if (_glfw.wl.display) if (_glfw.wl.display)

View File

@ -438,6 +438,8 @@ typedef struct _GLFWlibraryWayland
struct zwp_idle_inhibit_manager_v1* idleInhibitManager; struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
struct xdg_activation_v1* activationManager; struct xdg_activation_v1* activationManager;
struct wp_fractional_scale_manager_v1* fractionalScaleManager; struct wp_fractional_scale_manager_v1* fractionalScaleManager;
struct wp_cursor_shape_manager_v1* cursorShapeManager;
struct wp_cursor_shape_device_v1* cursorShapeDevice;
_GLFWofferWayland* offers; _GLFWofferWayland* offers;
unsigned int offerCount; unsigned int offerCount;
@ -609,6 +611,7 @@ typedef struct _GLFWcursorWayland
int width, height; int width, height;
int xhot, yhot; int xhot, yhot;
int currentImage; int currentImage;
int shape;
} _GLFWcursorWayland; } _GLFWcursorWayland;
GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform); GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform);

View File

@ -51,6 +51,7 @@
#include "xdg-activation-v1-client-protocol.h" #include "xdg-activation-v1-client-protocol.h"
#include "idle-inhibit-unstable-v1-client-protocol.h" #include "idle-inhibit-unstable-v1-client-protocol.h"
#include "fractional-scale-v1-client-protocol.h" #include "fractional-scale-v1-client-protocol.h"
#include "cursor-shape-v1-client-protocol.h"
#define GLFW_BORDER_SIZE 4 #define GLFW_BORDER_SIZE 4
#define GLFW_CAPTION_HEIGHT 24 #define GLFW_CAPTION_HEIGHT 24
@ -1075,9 +1076,67 @@ static GLFWbool createNativeSurface(_GLFWwindow* window,
return GLFW_TRUE; return GLFW_TRUE;
} }
GLFWbool setCursorShape(int shape) {
int xdgShape = -1;
switch (shape)
{
case GLFW_ARROW_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT;
break;
case GLFW_IBEAM_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT;
break;
case GLFW_CROSSHAIR_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR;
break;
case GLFW_POINTING_HAND_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER;
break;
case GLFW_RESIZE_EW_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_EW_RESIZE;
break;
case GLFW_RESIZE_NS_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NS_RESIZE;
break;
case GLFW_RESIZE_NWSE_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NWSE_RESIZE;
break;
case GLFW_RESIZE_NESW_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NESW_RESIZE;
break;
case GLFW_RESIZE_ALL_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_SCROLL;
break;
case GLFW_NOT_ALLOWED_CURSOR:
xdgShape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NOT_ALLOWED;
break;
}
if (xdgShape == -1)
{
return GLFW_FALSE;
}
wp_cursor_shape_device_v1_set_shape(_glfw.wl.cursorShapeDevice,
_glfw.wl.pointerEnterSerial,
xdgShape);
return GLFW_TRUE;
}
static void setCursorImage(_GLFWwindow* window, static void setCursorImage(_GLFWwindow* window,
_GLFWcursorWayland* cursorWayland) _GLFWcursorWayland* cursorWayland)
{ {
if (_glfw.wl.cursorShapeDevice && cursorWayland->shape != 0)
{
GLFWbool ok = setCursorShape(cursorWayland->shape);
if (ok == GLFW_TRUE)
{
return;
}
}
struct itimerspec timer = {0}; struct itimerspec timer = {0};
struct wl_cursor* wlCursor = cursorWayland->cursor; struct wl_cursor* wlCursor = cursorWayland->cursor;
struct wl_cursor_image* image; struct wl_cursor_image* image;
@ -1889,6 +1948,10 @@ static void seatHandleCapabilities(void* userData,
{ {
_glfw.wl.pointer = wl_seat_get_pointer(seat); _glfw.wl.pointer = wl_seat_get_pointer(seat);
wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL); wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);
if (_glfw.wl.cursorShapeManager)
{
_glfw.wl.cursorShapeDevice = wp_cursor_shape_manager_v1_get_pointer(_glfw.wl.cursorShapeManager, _glfw.wl.pointer);
}
} }
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer) else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
{ {
@ -2767,6 +2830,8 @@ GLFWbool _glfwCreateCursorWayland(_GLFWcursor* cursor,
GLFWbool _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape) GLFWbool _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape)
{ {
cursor->wl.shape = shape;
const char* name = NULL; const char* name = NULL;
// Try the XDG names first // Try the XDG names first
@ -3068,7 +3133,8 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
NULL, NULL,
0, 0, 0, 0,
0, 0, 0, 0,
0 0,
GLFW_ARROW_CURSOR
}; };
setCursorImage(window, &cursorWayland); setCursorImage(window, &cursorWayland);