1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-22 18:28:52 -05:00

Wayland: Add GLFW_WAYLAND_APP_ID window hint

This adds a window hint string for the xdg_toplevel::app_id, which is
used by desktop environments to connect windows with application icons
and other information.  This is similar to the WM_CLASS property on X11.

A few very minor fixes were done by @elmindreda during merge.

Fixes #2121
Closes #2122
This commit is contained in:
Michael Pennington 2022-05-26 20:33:28 -04:00 committed by Camilla Löwy
parent 26b85215c0
commit b9ed25d2e9
9 changed files with 36 additions and 0 deletions

View File

@ -166,6 +166,7 @@ video tutorials.
- Peoro
- Braden Pellett
- Christopher Pelloux
- Michael Pennington
- Arturo J. Pérez
- Vladimir Perminov
- Olivier Perret

View File

@ -142,6 +142,8 @@ information on what to include when reporting a bug.
- Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958)
- Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
- Added `GLFW_WAYLAND_APP_ID` window hint string for Wayland app\_id selection
(#2121,#2122)
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
values to select ANGLE backend (#1380)
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan

View File

@ -43,6 +43,12 @@ to whatever window is behind it. This can also be changed after window
creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
@subsubsection wayland_app_id_34 Wayland app_id specification
GLFW now supports specifying the app_id for a Wayland window using the
[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string.
@subsubsection features_34_angle_backend Support for ANGLE rendering backend selection
GLFW now provides the

View File

@ -492,6 +492,13 @@ __GLFW_X11_CLASS_NAME__ and __GLFW_X11_INSTANCE_NAME__ specifies the desired
ASCII encoded class and instance parts of the ICCCM `WM_CLASS` window property.
These are set with @ref glfwWindowHintString.
@subsubsection window_hints_wayland Wayland specific window hints
@anchor GLFW_WAYLAND_APP_ID_hint
__GLFW_WAYLAND_APP_ID__ specifies the Wayland app_id for a window, used
by window managers to identify types of windows. This is set with
@ref glfwWindowHintString.
@subsubsection window_hints_values Supported and default values
@ -540,6 +547,7 @@ GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded fr
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name
GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded `WM_CLASS` instance name
GLFW_WAYLAND_APP_ID | `""` | An ASCII encoded Wayland `app_id` name
@section window_events Window event processing

View File

@ -1105,6 +1105,12 @@ extern "C" {
*/
#define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WIN32_KEYBOARD_MENU 0x00025001
/*! @brief Wayland specific
* [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
*
* Allows specification of the Wayland app_id.
*/
#define GLFW_WAYLAND_APP_ID 0x00026001
/*! @} */
#define GLFW_NO_API 0

View File

@ -421,6 +421,9 @@ struct _GLFWwndconfig
struct {
GLFWbool keymenu;
} win32;
struct {
char appId[256];
} wl;
};
// Context configuration

View File

@ -447,6 +447,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
strncpy(_glfw.hints.window.x11.instanceName, value,
sizeof(_glfw.hints.window.x11.instanceName) - 1);
return;
case GLFW_WAYLAND_APP_ID:
strncpy(_glfw.hints.window.wl.appId, value,
sizeof(_glfw.hints.window.wl.appId) - 1);
return;
}
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);

View File

@ -258,6 +258,7 @@ typedef struct _GLFWwindowWayland
double cursorPosX, cursorPosY;
char* title;
char* appId;
// We need to track the monitors the window spans on to calculate the
// optimal scaling factor.

View File

@ -614,6 +614,9 @@ static GLFWbool createShellObjects(_GLFWwindow* window)
xdg_toplevel_add_listener(window->wl.xdg.toplevel, &xdgToplevelListener, window);
if (window->wl.appId)
xdg_toplevel_set_app_id(window->wl.xdg.toplevel, window->wl.appId);
if (window->wl.title)
xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
@ -728,6 +731,7 @@ static GLFWbool createNativeSurface(_GLFWwindow* window,
window->wl.height = wndconfig->height;
window->wl.scale = 1;
window->wl.title = _glfw_strdup(wndconfig->title);
window->wl.appId = _glfw_strdup(wndconfig->wl.appId);
window->wl.maximized = wndconfig->maximized;
@ -1865,6 +1869,7 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
wl_surface_destroy(window->wl.surface);
_glfw_free(window->wl.title);
_glfw_free(window->wl.appId);
_glfw_free(window->wl.monitors);
}