Wayland: Allow using the --class to set the app id

Fixes #862
This commit is contained in:
Kovid Goyal 2018-09-06 06:54:04 +05:30
parent 3bd45966c6
commit 33f0ac83c1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
9 changed files with 20 additions and 1 deletions

View File

@ -29,6 +29,9 @@ Changelog
- Fix a regression in 0.12.0 that broke resizing of layouts (:iss:`860`)
- Wayland: Allow using the :option:`kitty --class` command line flag
to set the app id (:iss:`862`)
0.12.0 [2018-09-01]
------------------------------

2
glfw/glfw3.h vendored
View File

@ -984,6 +984,8 @@ extern "C" {
#define GLFW_X11_CLASS_NAME 0x00024001
#define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WAYLAND_APP_ID 0x00025001
/*! @} */
#define GLFW_NO_API 0

3
glfw/internal.h vendored
View File

@ -282,6 +282,9 @@ struct _GLFWwndconfig
char className[256];
char instanceName[256];
} x11;
struct {
char appId[256];
} wl;
};
// Context configuration

4
glfw/window.c vendored
View File

@ -460,6 +460,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
glfw/wl_platform.h vendored
View File

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

3
glfw/wl_window.c vendored
View File

@ -693,6 +693,8 @@ static GLFWbool createXdgSurface(_GLFWwindow* window)
{
setIdleInhibitor(window, GLFW_FALSE);
}
if (strlen(window->wl.appId))
xdg_toplevel_set_app_id(window->wl.xdg.toplevel, window->wl.appId);
wl_surface_commit(window->wl.surface);
wl_display_roundtrip(_glfw.wl.display);
@ -769,6 +771,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
{
window->wl.justCreated = GLFW_TRUE;
window->wl.transparent = fbconfig->transparent;
strncpy(window->wl.appId, wndconfig->wl.appId, sizeof(window->wl.appId));
if (!createSurface(window, wndconfig))
return GLFW_FALSE;

View File

@ -464,7 +464,7 @@ def options_spec():
dest=cls
default={appname}
condition=not is_macos
Set the class part of the :italic:`WM_CLASS` window property
Set the class part of the :italic:`WM_CLASS` window property. On Wayland, it sets the app id.
--name

2
kitty/glfw-wrapper.h generated
View File

@ -745,6 +745,8 @@ typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
#define GLFW_X11_CLASS_NAME 0x00024001
#define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WAYLAND_APP_ID 0x00025001
/*! @} */
#define GLFW_NO_API 0

View File

@ -409,6 +409,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
#ifndef __APPLE__
glfwWindowHintString(GLFW_X11_INSTANCE_NAME, wm_class_name);
glfwWindowHintString(GLFW_X11_CLASS_NAME, wm_class_class);
glfwWindowHintString(GLFW_WAYLAND_APP_ID, wm_class_class);
if (OPT(x11_hide_window_decorations)) {
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
}