diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 673db319..9c4964c0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -166,6 +166,7 @@ video tutorials. - Peoro - Braden Pellett - Christopher Pelloux + - Michael Pennington - Arturo J. PĂ©rez - Vladimir Perminov - Olivier Perret diff --git a/README.md b/README.md index 5b56b3eb..66af82e5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/news.dox b/docs/news.dox index fbf60319..98daa3a2 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -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 diff --git a/docs/window.dox b/docs/window.dox index 32271e3a..451aca73 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -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 diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index aa6ddc33..8f481790 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -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 diff --git a/src/internal.h b/src/internal.h index 89a18628..8d576d1d 100644 --- a/src/internal.h +++ b/src/internal.h @@ -421,6 +421,9 @@ struct _GLFWwndconfig struct { GLFWbool keymenu; } win32; + struct { + char appId[256]; + } wl; }; // Context configuration diff --git a/src/window.c b/src/window.c index ebbc6dca..f740580a 100644 --- a/src/window.c +++ b/src/window.c @@ -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); diff --git a/src/wl_platform.h b/src/wl_platform.h index f65bcb11..73639de1 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -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. diff --git a/src/wl_window.c b/src/wl_window.c index ef935d33..900c877d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -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); }