mirror of
https://github.com/glfw/glfw.git
synced 2025-12-21 06:31:58 +00:00
Compare commits
8 Commits
a3f26ba993
...
fb65f1598a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb65f1598a | ||
|
|
161fb1b6f6 | ||
|
|
645a35a38e | ||
|
|
7523b0e6bd | ||
|
|
5190a30d8a | ||
|
|
ddbb8e0f2c | ||
|
|
5245180c56 | ||
|
|
f8e6fca745 |
@ -135,6 +135,9 @@ information on what to include when reporting a bug.
|
|||||||
- [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727)
|
- [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727)
|
||||||
- [Wayland] Bugfix: Memory would leak if reading a data offer failed midway
|
- [Wayland] Bugfix: Memory would leak if reading a data offer failed midway
|
||||||
- [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736)
|
- [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736)
|
||||||
|
- [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over
|
||||||
|
fallback decorations
|
||||||
|
- [Wayland] Bugfix: Fallback decorations would report scroll events
|
||||||
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
|
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
|
||||||
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
|
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
|
||||||
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
|
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
|
||||||
|
|||||||
205
deps/wayland/xdg-toplevel-icon-v1.xml
vendored
Normal file
205
deps/wayland/xdg-toplevel-icon-v1.xml
vendored
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<protocol name="xdg_toplevel_icon_v1">
|
||||||
|
|
||||||
|
<copyright>
|
||||||
|
Copyright © 2023-2024 Matthias Klumpp
|
||||||
|
Copyright © 2024 David Edmundson
|
||||||
|
|
||||||
|
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 to assign icons to toplevels">
|
||||||
|
This protocol allows clients to set icons for their toplevel surfaces
|
||||||
|
either via the XDG icon stock (using an icon name), or from pixel data.
|
||||||
|
|
||||||
|
A toplevel icon represents the individual toplevel (unlike the application
|
||||||
|
or launcher icon, which represents the application as a whole), and may be
|
||||||
|
shown in window switchers, window overviews and taskbars that list
|
||||||
|
individual windows.
|
||||||
|
|
||||||
|
This document adheres to RFC 2119 when using words like "must",
|
||||||
|
"should", "may", etc.
|
||||||
|
|
||||||
|
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_toplevel_icon_manager_v1" version="1">
|
||||||
|
<description summary="interface to manage toplevel icons">
|
||||||
|
This interface allows clients to create toplevel window icons and set
|
||||||
|
them on toplevel windows to be displayed to the user.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor">
|
||||||
|
<description summary="destroy the toplevel icon manager">
|
||||||
|
Destroy the toplevel icon manager.
|
||||||
|
This does not destroy objects created with the manager.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="create_icon">
|
||||||
|
<description summary="create a new icon instance">
|
||||||
|
Creates a new icon object. This icon can then be attached to a
|
||||||
|
xdg_toplevel via the 'set_icon' request.
|
||||||
|
</description>
|
||||||
|
<arg name="id" type="new_id" interface="xdg_toplevel_icon_v1"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="set_icon">
|
||||||
|
<description summary="set an icon on a toplevel window">
|
||||||
|
This request assigns the icon 'icon' to 'toplevel', or clears the
|
||||||
|
toplevel icon if 'icon' was null.
|
||||||
|
This state is double-buffered and is applied on the next
|
||||||
|
wl_surface.commit of the toplevel.
|
||||||
|
|
||||||
|
After making this call, the xdg_toplevel_icon_v1 provided as 'icon'
|
||||||
|
can be destroyed by the client without 'toplevel' losing its icon.
|
||||||
|
The xdg_toplevel_icon_v1 is immutable from this point, and any
|
||||||
|
future attempts to change it must raise the
|
||||||
|
'xdg_toplevel_icon_v1.immutable' protocol error.
|
||||||
|
|
||||||
|
The compositor must set the toplevel icon from either the pixel data
|
||||||
|
the icon provides, or by loading a stock icon using the icon name.
|
||||||
|
See the description of 'xdg_toplevel_icon_v1' for details.
|
||||||
|
|
||||||
|
If 'icon' is set to null, the icon of the respective toplevel is reset
|
||||||
|
to its default icon (usually the icon of the application, derived from
|
||||||
|
its desktop-entry file, or a placeholder icon).
|
||||||
|
If this request is passed an icon with no pixel buffers or icon name
|
||||||
|
assigned, the icon must be reset just like if 'icon' was null.
|
||||||
|
</description>
|
||||||
|
<arg name="toplevel" type="object" interface="xdg_toplevel" summary="the toplevel to act on"/>
|
||||||
|
<arg name="icon" type="object" interface="xdg_toplevel_icon_v1" allow-null="true"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<event name="icon_size">
|
||||||
|
<description summary="describes a supported & preferred icon size">
|
||||||
|
This event indicates an icon size the compositor prefers to be
|
||||||
|
available if the client has scalable icons and can render to any size.
|
||||||
|
|
||||||
|
When the 'xdg_toplevel_icon_manager_v1' object is created, the
|
||||||
|
compositor may send one or more 'icon_size' events to describe the list
|
||||||
|
of preferred icon sizes. If the compositor has no size preference, it
|
||||||
|
may not send any 'icon_size' event, and it is up to the client to
|
||||||
|
decide a suitable icon size.
|
||||||
|
|
||||||
|
A sequence of 'icon_size' events must be finished with a 'done' event.
|
||||||
|
If the compositor has no size preferences, it must still send the
|
||||||
|
'done' event, without any preceding 'icon_size' events.
|
||||||
|
</description>
|
||||||
|
<arg name="size" type="int"
|
||||||
|
summary="the edge size of the square icon in surface-local coordinates, e.g. 64"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="done">
|
||||||
|
<description summary="all information has been sent">
|
||||||
|
This event is sent after all 'icon_size' events have been sent.
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
|
</interface>
|
||||||
|
|
||||||
|
<interface name="xdg_toplevel_icon_v1" version="1">
|
||||||
|
<description summary="a toplevel window icon">
|
||||||
|
This interface defines a toplevel icon.
|
||||||
|
An icon can have a name, and multiple buffers.
|
||||||
|
In order to be applied, the icon must have either a name, or at least
|
||||||
|
one buffer assigned. Applying an empty icon (with no buffer or name) to
|
||||||
|
a toplevel should reset its icon to the default icon.
|
||||||
|
|
||||||
|
It is up to compositor policy whether to prefer using a buffer or loading
|
||||||
|
an icon via its name. See 'set_name' and 'add_buffer' for details.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<enum name="error">
|
||||||
|
<entry name="invalid_buffer"
|
||||||
|
summary="the provided buffer does not satisfy requirements"
|
||||||
|
value="1"/>
|
||||||
|
<entry name="immutable"
|
||||||
|
summary="the icon has already been assigned to a toplevel and must not be changed"
|
||||||
|
value="2"/>
|
||||||
|
<entry name="no_buffer"
|
||||||
|
summary="the provided buffer has been destroyed before the toplevel icon"
|
||||||
|
value="3"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor">
|
||||||
|
<description summary="destroy the icon object">
|
||||||
|
Destroys the 'xdg_toplevel_icon_v1' object.
|
||||||
|
The icon must still remain set on every toplevel it was assigned to,
|
||||||
|
until the toplevel icon is reset explicitly.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="set_name">
|
||||||
|
<description summary="set an icon name">
|
||||||
|
This request assigns an icon name to this icon.
|
||||||
|
Any previously set name is overridden.
|
||||||
|
|
||||||
|
The compositor must resolve 'icon_name' according to the lookup rules
|
||||||
|
described in the XDG icon theme specification[1] using the
|
||||||
|
environment's current icon theme.
|
||||||
|
|
||||||
|
If the compositor does not support icon names or cannot resolve
|
||||||
|
'icon_name' according to the XDG icon theme specification it must
|
||||||
|
fall back to using pixel buffer data instead.
|
||||||
|
|
||||||
|
If this request is made after the icon has been assigned to a toplevel
|
||||||
|
via 'set_icon', a 'immutable' error must be raised.
|
||||||
|
|
||||||
|
[1]: https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
|
||||||
|
</description>
|
||||||
|
<arg name="icon_name" type="string"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="add_buffer">
|
||||||
|
<description summary="add icon data from a pixel buffer">
|
||||||
|
This request adds pixel data supplied as wl_buffer to the icon.
|
||||||
|
|
||||||
|
The client should add pixel data for all icon sizes and scales that
|
||||||
|
it can provide, or which are explicitly requested by the compositor
|
||||||
|
via 'icon_size' events on xdg_toplevel_icon_manager_v1.
|
||||||
|
|
||||||
|
The wl_buffer supplying pixel data as 'buffer' must be backed by wl_shm
|
||||||
|
and must be a square (width and height being equal).
|
||||||
|
If any of these buffer requirements are not fulfilled, a 'invalid_buffer'
|
||||||
|
error must be raised.
|
||||||
|
|
||||||
|
If this icon instance already has a buffer of the same size and scale
|
||||||
|
from a previous 'add_buffer' request, data from the last request
|
||||||
|
overrides the preexisting pixel data.
|
||||||
|
|
||||||
|
The wl_buffer must be kept alive for as long as the xdg_toplevel_icon
|
||||||
|
it is associated with is not destroyed, otherwise a 'no_buffer' error
|
||||||
|
is raised. The buffer contents must not be modified after it was
|
||||||
|
assigned to the icon. As a result, the region of the wl_shm_pool's
|
||||||
|
backing storage used for the wl_buffer must not be modified after this
|
||||||
|
request is sent. The wl_buffer.release event is unused.
|
||||||
|
|
||||||
|
If this request is made after the icon has been assigned to a toplevel
|
||||||
|
via 'set_icon', a 'immutable' error must be raised.
|
||||||
|
</description>
|
||||||
|
<arg name="buffer" type="object" interface="wl_buffer"/>
|
||||||
|
<arg name="scale" type="int"
|
||||||
|
summary="the scaling factor of the icon, e.g. 1"/>
|
||||||
|
</request>
|
||||||
|
</interface>
|
||||||
|
</protocol>
|
||||||
@ -3399,9 +3399,9 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
|
|||||||
*
|
*
|
||||||
* [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
|
* [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
|
||||||
*
|
*
|
||||||
* @remark @wayland There is no existing protocol to change an icon, the
|
* @remark @wayland This only works on compositors implementing the XDG toplevel icon protocol.
|
||||||
* window will thus inherit the one defined in the application's desktop file.
|
* This function will emit @ref GLFW_FEATURE_UNAVAILABLE if this protocol is not available.
|
||||||
* This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
|
* The icon must be square. Otherwise @ref GLFW_INVALID_VALUE will be emited.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -105,6 +105,7 @@ 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("xdg-toplevel-icon-v1.xml")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
|
if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
|
||||||
|
|||||||
@ -49,6 +49,7 @@
|
|||||||
#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 "xdg-toplevel-icon-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 +92,10 @@
|
|||||||
#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_toplevel_icon_types
|
||||||
|
#include "xdg-toplevel-icon-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 +213,13 @@ static void registryHandleGlobal(void* userData,
|
|||||||
&wp_fractional_scale_manager_v1_interface,
|
&wp_fractional_scale_manager_v1_interface,
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(interface, xdg_toplevel_icon_manager_v1_interface.name) == 0)
|
||||||
|
{
|
||||||
|
_glfw.wl.toplevelIconManager =
|
||||||
|
wl_registry_bind(registry, name,
|
||||||
|
&xdg_toplevel_icon_manager_v1_interface,
|
||||||
|
1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void registryHandleGlobalRemove(void* userData,
|
static void registryHandleGlobalRemove(void* userData,
|
||||||
@ -988,6 +1000,8 @@ 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.toplevelIconManager)
|
||||||
|
xdg_toplevel_icon_manager_v1_destroy(_glfw.wl.toplevelIconManager);
|
||||||
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)
|
||||||
|
|||||||
@ -217,62 +217,62 @@ struct libdecor_configuration;
|
|||||||
|
|
||||||
enum libdecor_error
|
enum libdecor_error
|
||||||
{
|
{
|
||||||
LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
|
LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
|
||||||
LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,
|
LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum libdecor_window_state
|
enum libdecor_window_state
|
||||||
{
|
{
|
||||||
LIBDECOR_WINDOW_STATE_NONE = 0,
|
LIBDECOR_WINDOW_STATE_NONE = 0,
|
||||||
LIBDECOR_WINDOW_STATE_ACTIVE = 1,
|
LIBDECOR_WINDOW_STATE_ACTIVE = 1,
|
||||||
LIBDECOR_WINDOW_STATE_MAXIMIZED = 2,
|
LIBDECOR_WINDOW_STATE_MAXIMIZED = 2,
|
||||||
LIBDECOR_WINDOW_STATE_FULLSCREEN = 4,
|
LIBDECOR_WINDOW_STATE_FULLSCREEN = 4,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_LEFT = 8,
|
LIBDECOR_WINDOW_STATE_TILED_LEFT = 8,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16,
|
LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_TOP = 32,
|
LIBDECOR_WINDOW_STATE_TILED_TOP = 32,
|
||||||
LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64
|
LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64
|
||||||
};
|
};
|
||||||
|
|
||||||
enum libdecor_capabilities
|
enum libdecor_capabilities
|
||||||
{
|
{
|
||||||
LIBDECOR_ACTION_MOVE = 1,
|
LIBDECOR_ACTION_MOVE = 1,
|
||||||
LIBDECOR_ACTION_RESIZE = 2,
|
LIBDECOR_ACTION_RESIZE = 2,
|
||||||
LIBDECOR_ACTION_MINIMIZE = 4,
|
LIBDECOR_ACTION_MINIMIZE = 4,
|
||||||
LIBDECOR_ACTION_FULLSCREEN = 8,
|
LIBDECOR_ACTION_FULLSCREEN = 8,
|
||||||
LIBDECOR_ACTION_CLOSE = 16
|
LIBDECOR_ACTION_CLOSE = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libdecor_interface
|
struct libdecor_interface
|
||||||
{
|
{
|
||||||
void (* error)(struct libdecor*,enum libdecor_error,const char*);
|
void (* error)(struct libdecor*,enum libdecor_error,const char*);
|
||||||
void (* reserved0)(void);
|
void (* reserved0)(void);
|
||||||
void (* reserved1)(void);
|
void (* reserved1)(void);
|
||||||
void (* reserved2)(void);
|
void (* reserved2)(void);
|
||||||
void (* reserved3)(void);
|
void (* reserved3)(void);
|
||||||
void (* reserved4)(void);
|
void (* reserved4)(void);
|
||||||
void (* reserved5)(void);
|
void (* reserved5)(void);
|
||||||
void (* reserved6)(void);
|
void (* reserved6)(void);
|
||||||
void (* reserved7)(void);
|
void (* reserved7)(void);
|
||||||
void (* reserved8)(void);
|
void (* reserved8)(void);
|
||||||
void (* reserved9)(void);
|
void (* reserved9)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libdecor_frame_interface
|
struct libdecor_frame_interface
|
||||||
{
|
{
|
||||||
void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*);
|
void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*);
|
||||||
void (* close)(struct libdecor_frame*,void*);
|
void (* close)(struct libdecor_frame*,void*);
|
||||||
void (* commit)(struct libdecor_frame*,void*);
|
void (* commit)(struct libdecor_frame*,void*);
|
||||||
void (* dismiss_popup)(struct libdecor_frame*,const char*,void*);
|
void (* dismiss_popup)(struct libdecor_frame*,const char*,void*);
|
||||||
void (* reserved0)(void);
|
void (* reserved0)(void);
|
||||||
void (* reserved1)(void);
|
void (* reserved1)(void);
|
||||||
void (* reserved2)(void);
|
void (* reserved2)(void);
|
||||||
void (* reserved3)(void);
|
void (* reserved3)(void);
|
||||||
void (* reserved4)(void);
|
void (* reserved4)(void);
|
||||||
void (* reserved5)(void);
|
void (* reserved5)(void);
|
||||||
void (* reserved6)(void);
|
void (* reserved6)(void);
|
||||||
void (* reserved7)(void);
|
void (* reserved7)(void);
|
||||||
void (* reserved8)(void);
|
void (* reserved8)(void);
|
||||||
void (* reserved9)(void);
|
void (* reserved9)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*);
|
typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*);
|
||||||
@ -413,6 +413,8 @@ typedef struct _GLFWwindowWayland
|
|||||||
struct wl_buffer* buffer;
|
struct wl_buffer* buffer;
|
||||||
_GLFWfallbackEdgeWayland top, left, right, bottom;
|
_GLFWfallbackEdgeWayland top, left, right, bottom;
|
||||||
struct wl_surface* focus;
|
struct wl_surface* focus;
|
||||||
|
wl_fixed_t pointerX, pointerY;
|
||||||
|
const char* cursorName;
|
||||||
} fallback;
|
} fallback;
|
||||||
} _GLFWwindowWayland;
|
} _GLFWwindowWayland;
|
||||||
|
|
||||||
@ -438,6 +440,7 @@ 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 xdg_toplevel_icon_manager_v1* toplevelIconManager;
|
||||||
|
|
||||||
_GLFWofferWayland* offers;
|
_GLFWofferWayland* offers;
|
||||||
unsigned int offerCount;
|
unsigned int offerCount;
|
||||||
@ -454,7 +457,6 @@ typedef struct _GLFWlibraryWayland
|
|||||||
struct wl_cursor_theme* cursorTheme;
|
struct wl_cursor_theme* cursorTheme;
|
||||||
struct wl_cursor_theme* cursorThemeHiDPI;
|
struct wl_cursor_theme* cursorThemeHiDPI;
|
||||||
struct wl_surface* cursorSurface;
|
struct wl_surface* cursorSurface;
|
||||||
const char* cursorPreviousName;
|
|
||||||
int cursorTimerfd;
|
int cursorTimerfd;
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
uint32_t pointerEnterSerial;
|
uint32_t pointerEnterSerial;
|
||||||
|
|||||||
362
src/wl_window.c
362
src/wl_window.c
@ -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 "xdg-toplevel-icon-v1-client-protocol.h"
|
||||||
|
|
||||||
#define GLFW_BORDER_SIZE 4
|
#define GLFW_BORDER_SIZE 4
|
||||||
#define GLFW_CAPTION_HEIGHT 24
|
#define GLFW_CAPTION_HEIGHT 24
|
||||||
@ -275,6 +276,146 @@ static void destroyFallbackDecorations(_GLFWwindow* window)
|
|||||||
destroyFallbackEdge(&window->wl.fallback.bottom);
|
destroyFallbackEdge(&window->wl.fallback.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void updateFallbackDecorationCursor(_GLFWwindow* window,
|
||||||
|
wl_fixed_t sx,
|
||||||
|
wl_fixed_t sy)
|
||||||
|
{
|
||||||
|
window->wl.fallback.pointerX = sx;
|
||||||
|
window->wl.fallback.pointerY = sy;
|
||||||
|
|
||||||
|
const double xpos = wl_fixed_to_double(sx);
|
||||||
|
const double ypos = wl_fixed_to_double(sy);
|
||||||
|
const char* cursorName = "left_ptr";
|
||||||
|
|
||||||
|
if (window->resizable)
|
||||||
|
{
|
||||||
|
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "n-resize";
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "nw-resize";
|
||||||
|
else
|
||||||
|
cursorName = "w-resize";
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "ne-resize";
|
||||||
|
else
|
||||||
|
cursorName = "e-resize";
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
||||||
|
{
|
||||||
|
if (xpos < GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "sw-resize";
|
||||||
|
else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
|
||||||
|
cursorName = "se-resize";
|
||||||
|
else
|
||||||
|
cursorName = "s-resize";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->wl.fallback.cursorName != cursorName)
|
||||||
|
{
|
||||||
|
struct wl_surface* surface = _glfw.wl.cursorSurface;
|
||||||
|
struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
|
||||||
|
int scale = 1;
|
||||||
|
|
||||||
|
if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI)
|
||||||
|
{
|
||||||
|
// We only support up to scale=2 for now, since libwayland-cursor
|
||||||
|
// requires us to load a different theme for each size.
|
||||||
|
scale = 2;
|
||||||
|
theme = _glfw.wl.cursorThemeHiDPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName);
|
||||||
|
if (!cursor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO: handle animated cursors too.
|
||||||
|
struct wl_cursor_image* image = cursor->images[0];
|
||||||
|
if (!image)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct wl_buffer* buffer = wl_cursor_image_get_buffer(image);
|
||||||
|
if (!buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
||||||
|
surface,
|
||||||
|
image->hotspot_x / scale,
|
||||||
|
image->hotspot_y / scale);
|
||||||
|
wl_surface_set_buffer_scale(surface, scale);
|
||||||
|
wl_surface_attach(surface, buffer, 0, 0);
|
||||||
|
wl_surface_damage(surface, 0, 0, image->width, image->height);
|
||||||
|
wl_surface_commit(surface);
|
||||||
|
|
||||||
|
window->wl.fallback.cursorName = cursorName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleFallbackDecorationButton(_GLFWwindow* window,
|
||||||
|
uint32_t serial,
|
||||||
|
uint32_t button)
|
||||||
|
{
|
||||||
|
const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX);
|
||||||
|
const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY);
|
||||||
|
|
||||||
|
if (button == BTN_LEFT)
|
||||||
|
{
|
||||||
|
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
||||||
|
|
||||||
|
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
||||||
|
else
|
||||||
|
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
|
||||||
|
else
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
||||||
|
{
|
||||||
|
if (ypos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
|
||||||
|
else
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
||||||
|
}
|
||||||
|
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
||||||
|
{
|
||||||
|
if (xpos < GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
|
||||||
|
else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
|
||||||
|
else
|
||||||
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
|
||||||
|
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, serial, edges);
|
||||||
|
}
|
||||||
|
else if (button == BTN_RIGHT)
|
||||||
|
{
|
||||||
|
if (window->wl.xdg.toplevel)
|
||||||
|
{
|
||||||
|
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
|
||||||
|
_glfw.wl.seat, serial,
|
||||||
|
window->wl.cursorPosX,
|
||||||
|
window->wl.cursorPosY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void xdgDecorationHandleConfigure(void* userData,
|
static void xdgDecorationHandleConfigure(void* userData,
|
||||||
struct zxdg_toplevel_decoration_v1* decoration,
|
struct zxdg_toplevel_decoration_v1* decoration,
|
||||||
uint32_t mode)
|
uint32_t mode)
|
||||||
@ -1417,7 +1558,6 @@ static void pointerHandleLeave(void* userData,
|
|||||||
|
|
||||||
_glfw.wl.serial = serial;
|
_glfw.wl.serial = serial;
|
||||||
_glfw.wl.pointerFocus = NULL;
|
_glfw.wl.pointerFocus = NULL;
|
||||||
_glfw.wl.cursorPreviousName = NULL;
|
|
||||||
|
|
||||||
if (window->wl.hovered)
|
if (window->wl.hovered)
|
||||||
{
|
{
|
||||||
@ -1427,7 +1567,10 @@ static void pointerHandleLeave(void* userData,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (window->wl.fallback.decorations)
|
if (window->wl.fallback.decorations)
|
||||||
|
{
|
||||||
window->wl.fallback.focus = NULL;
|
window->wl.fallback.focus = NULL;
|
||||||
|
window->wl.fallback.cursorName = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1444,92 +1587,16 @@ static void pointerHandleMotion(void* userData,
|
|||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const double xpos = wl_fixed_to_double(sx);
|
|
||||||
const double ypos = wl_fixed_to_double(sy);
|
|
||||||
window->wl.cursorPosX = xpos;
|
|
||||||
window->wl.cursorPosY = ypos;
|
|
||||||
|
|
||||||
if (window->wl.hovered)
|
if (window->wl.hovered)
|
||||||
{
|
{
|
||||||
_glfw.wl.cursorPreviousName = NULL;
|
window->wl.cursorPosX = wl_fixed_to_double(sx);
|
||||||
_glfwInputCursorPos(window, xpos, ypos);
|
window->wl.cursorPosY = wl_fixed_to_double(sy);
|
||||||
return;
|
_glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (window->wl.fallback.decorations)
|
|
||||||
{
|
{
|
||||||
const char* cursorName = "left_ptr";
|
if (window->wl.fallback.decorations)
|
||||||
|
updateFallbackDecorationCursor(window, sx, sy);
|
||||||
if (window->resizable)
|
|
||||||
{
|
|
||||||
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
|
||||||
{
|
|
||||||
if (ypos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "n-resize";
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
|
||||||
{
|
|
||||||
if (ypos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "nw-resize";
|
|
||||||
else
|
|
||||||
cursorName = "w-resize";
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
|
||||||
{
|
|
||||||
if (ypos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "ne-resize";
|
|
||||||
else
|
|
||||||
cursorName = "e-resize";
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
|
||||||
{
|
|
||||||
if (xpos < GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "sw-resize";
|
|
||||||
else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
|
|
||||||
cursorName = "se-resize";
|
|
||||||
else
|
|
||||||
cursorName = "s-resize";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfw.wl.cursorPreviousName != cursorName)
|
|
||||||
{
|
|
||||||
struct wl_surface* surface = _glfw.wl.cursorSurface;
|
|
||||||
struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
|
|
||||||
int scale = 1;
|
|
||||||
|
|
||||||
if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI)
|
|
||||||
{
|
|
||||||
// We only support up to scale=2 for now, since libwayland-cursor
|
|
||||||
// requires us to load a different theme for each size.
|
|
||||||
scale = 2;
|
|
||||||
theme = _glfw.wl.cursorThemeHiDPI;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName);
|
|
||||||
if (!cursor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// TODO: handle animated cursors too.
|
|
||||||
struct wl_cursor_image* image = cursor->images[0];
|
|
||||||
if (!image)
|
|
||||||
return;
|
|
||||||
|
|
||||||
struct wl_buffer* buffer = wl_cursor_image_get_buffer(image);
|
|
||||||
if (!buffer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
|
||||||
surface,
|
|
||||||
image->hotspot_x / scale,
|
|
||||||
image->hotspot_y / scale);
|
|
||||||
wl_surface_set_buffer_scale(surface, scale);
|
|
||||||
wl_surface_attach(surface, buffer, 0, 0);
|
|
||||||
wl_surface_damage(surface, 0, 0, image->width, image->height);
|
|
||||||
wl_surface_commit(surface);
|
|
||||||
|
|
||||||
_glfw.wl.cursorPreviousName = cursorName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1552,62 +1619,11 @@ static void pointerHandleButton(void* userData,
|
|||||||
button - BTN_LEFT,
|
button - BTN_LEFT,
|
||||||
state == WL_POINTER_BUTTON_STATE_PRESSED,
|
state == WL_POINTER_BUTTON_STATE_PRESSED,
|
||||||
_glfw.wl.xkb.modifiers);
|
_glfw.wl.xkb.modifiers);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (window->wl.fallback.decorations)
|
|
||||||
{
|
{
|
||||||
if (button == BTN_LEFT)
|
if (window->wl.fallback.decorations)
|
||||||
{
|
handleFallbackDecorationButton(window, serial, button);
|
||||||
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
|
||||||
|
|
||||||
if (window->wl.fallback.focus == window->wl.fallback.top.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
|
||||||
else
|
|
||||||
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.left.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
|
|
||||||
else
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.right.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosY < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
|
|
||||||
else
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
|
||||||
}
|
|
||||||
else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface)
|
|
||||||
{
|
|
||||||
if (window->wl.cursorPosX < GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
|
|
||||||
else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE)
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
|
|
||||||
else
|
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
|
|
||||||
{
|
|
||||||
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
|
|
||||||
serial, edges);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (button == BTN_RIGHT)
|
|
||||||
{
|
|
||||||
if (window->wl.xdg.toplevel)
|
|
||||||
{
|
|
||||||
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
|
|
||||||
_glfw.wl.seat, serial,
|
|
||||||
window->wl.cursorPosX,
|
|
||||||
window->wl.cursorPosY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1621,11 +1637,14 @@ static void pointerHandleAxis(void* userData,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
|
if (window->wl.hovered)
|
||||||
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
{
|
||||||
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
|
// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
|
||||||
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
||||||
_glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
|
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
|
||||||
|
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
||||||
|
_glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_pointer_listener pointerListener =
|
static const struct wl_pointer_listener pointerListener =
|
||||||
@ -2207,12 +2226,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
|
|||||||
_glfw.wl.pointerFocus = NULL;
|
_glfw.wl.pointerFocus = NULL;
|
||||||
|
|
||||||
if (window == _glfw.wl.keyboardFocus)
|
if (window == _glfw.wl.keyboardFocus)
|
||||||
{
|
{
|
||||||
struct itimerspec timer = {0};
|
struct itimerspec timer = {0};
|
||||||
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
||||||
|
|
||||||
_glfw.wl.keyboardFocus = NULL;
|
_glfw.wl.keyboardFocus = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->wl.fractionalScale)
|
if (window->wl.fractionalScale)
|
||||||
wp_fractional_scale_v1_destroy(window->wl.fractionalScale);
|
wp_fractional_scale_v1_destroy(window->wl.fractionalScale);
|
||||||
@ -2264,8 +2283,55 @@ void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title)
|
|||||||
void _glfwSetWindowIconWayland(_GLFWwindow* window,
|
void _glfwSetWindowIconWayland(_GLFWwindow* window,
|
||||||
int count, const GLFWimage* images)
|
int count, const GLFWimage* images)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
if (!_glfw.wl.toplevelIconManager)
|
||||||
"Wayland: The platform does not support setting the window icon");
|
{
|
||||||
|
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||||
|
"Wayland: The platform does not support setting the window icon");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
{
|
||||||
|
if (window->wl.libdecor.frame)
|
||||||
|
xdg_toplevel_icon_manager_v1_set_icon(_glfw.wl.toplevelIconManager,
|
||||||
|
libdecor_frame_get_xdg_toplevel(window->wl.libdecor.frame),
|
||||||
|
NULL);
|
||||||
|
else if (window->wl.xdg.toplevel)
|
||||||
|
xdg_toplevel_icon_manager_v1_set_icon(_glfw.wl.toplevelIconManager, window->wl.xdg.toplevel, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if (images[i].width != images[i].height)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
|
"Wayland: The icon must be a square");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct xdg_toplevel_icon_v1 *icon = xdg_toplevel_icon_manager_v1_create_icon(_glfw.wl.toplevelIconManager);
|
||||||
|
struct wl_buffer *bufferArr[count];
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
bufferArr[i] = createShmBuffer(&images[i]);
|
||||||
|
xdg_toplevel_icon_v1_add_buffer(icon, bufferArr[i], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->wl.libdecor.frame)
|
||||||
|
xdg_toplevel_icon_manager_v1_set_icon(_glfw.wl.toplevelIconManager,
|
||||||
|
libdecor_frame_get_xdg_toplevel(window->wl.libdecor.frame),
|
||||||
|
icon);
|
||||||
|
else if (window->wl.xdg.toplevel)
|
||||||
|
xdg_toplevel_icon_manager_v1_set_icon(_glfw.wl.toplevelIconManager, window->wl.xdg.toplevel, icon);
|
||||||
|
xdg_toplevel_icon_v1_destroy(icon);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
wl_buffer_destroy(bufferArr[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos)
|
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user