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
+3
View File
@@ -421,6 +421,9 @@ struct _GLFWwndconfig
struct {
GLFWbool keymenu;
} win32;
struct {
char appId[256];
} wl;
};
// Context configuration
+4
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);
+1
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.
+5
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);
}