Add ability to set wayland app_id through a window hint

This commit is contained in:
Michael Pennington 2022-05-26 20:33:28 -04:00
parent 62e175ef9f
commit 7ac7e9bab9
5 changed files with 18 additions and 0 deletions

View File

@ -1104,6 +1104,11 @@ extern "C" {
* [window hint](@ref GLFW_X11_CLASS_NAME_hint). * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
*/ */
#define GLFW_X11_INSTANCE_NAME 0x00024002 #define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WAYLAND_APP_ID 0x00026001
/*! @brief Wayland specific
* [window hint](@ref GLDW_WAYLAND_CLASS_NAME_hint).
*/
#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 #define GLFW_WIN32_KEYBOARD_MENU 0x00025001
/*! @} */ /*! @} */

View File

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

View File

@ -417,6 +417,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value)
strncpy(_glfw.hints.window.x11.instanceName, value, strncpy(_glfw.hints.window.x11.instanceName, value,
sizeof(_glfw.hints.window.x11.instanceName) - 1); sizeof(_glfw.hints.window.x11.instanceName) - 1);
return; 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); _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);

View File

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

View File

@ -579,6 +579,9 @@ static GLFWbool createXdgSurface(_GLFWwindow* window)
&xdgToplevelListener, &xdgToplevelListener,
window); window);
if (strlen(window->wl.appId))
xdg_toplevel_set_app_id(window->wl.xdg.toplevel, window->wl.appId);
if (window->wl.title) if (window->wl.title)
xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title); xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
@ -637,6 +640,8 @@ static GLFWbool createSurface(_GLFWwindow* window,
window->wl.height = wndconfig->height; window->wl.height = wndconfig->height;
window->wl.scale = 1; window->wl.scale = 1;
window->wl.title = _glfw_strdup(wndconfig->title); window->wl.title = _glfw_strdup(wndconfig->title);
if (strlen(wndconfig->wl.appId))
window->wl.appId = _glfw_strdup(wndconfig->wl.appId);
window->wl.transparent = fbconfig->transparent; window->wl.transparent = fbconfig->transparent;
if (!window->wl.transparent) if (!window->wl.transparent)