From e25492a3a36f7e1fde6e3c3014620525a712a64a Mon Sep 17 00:00:00 2001 From: rs189 <35667100+rs189@users.noreply.github.com> Date: Sat, 12 Oct 2024 18:19:02 +0200 Subject: [PATCH] [client] x11/wayland: add application id --- AUTHORS | 1 + .../displayservers/Wayland/desktops/libdecor/libdecor.c | 4 ++-- client/displayservers/Wayland/desktops/xdg/xdg.c | 4 ++-- client/displayservers/Wayland/interface/desktop.h | 2 +- client/displayservers/Wayland/wayland.c | 2 +- client/displayservers/Wayland/wayland.h | 2 +- client/displayservers/Wayland/window.c | 4 ++-- client/displayservers/X11/x11.c | 2 +- client/include/interface/displayserver.h | 1 + client/src/config.c | 8 ++++++++ client/src/main.c | 1 + client/src/main.h | 1 + 12 files changed, 22 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index bb022f92..f1e205ab 100644 --- a/AUTHORS +++ b/AUTHORS @@ -70,3 +70,4 @@ Zenithal (ZenithalHourlyRate) Kamplom <6284968128@protonmail.ch> (kamplom) Jacob McNamee (jacobmcnamee) Marco Antonio J. Costa (majcosta) +rs189 <35667100+rs189@users.noreply.github.com> (rs189) \ No newline at end of file diff --git a/client/displayservers/Wayland/desktops/libdecor/libdecor.c b/client/displayservers/Wayland/desktops/libdecor/libdecor.c index 25fca91e..f0aab68e 100644 --- a/client/displayservers/Wayland/desktops/libdecor/libdecor.c +++ b/client/displayservers/Wayland/desktops/libdecor/libdecor.c @@ -130,14 +130,14 @@ static void libdecorCallback(uint32_t events, void * opaque) static bool libdecor_shellInit( struct wl_display * display, struct wl_surface * surface, - const char * title, bool fullscreen, + const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable) { state.libdecor = libdecor_new(display, &libdecorListener); state.libdecorFrame = libdecor_decorate(state.libdecor, surface, &libdecorFrameListener, NULL); - libdecor_frame_set_app_id(state.libdecorFrame, "looking-glass-client"); + libdecor_frame_set_app_id(state.libdecorFrame, appId); libdecor_frame_set_title(state.libdecorFrame, title); libdecor_frame_map(state.libdecorFrame); diff --git a/client/displayservers/Wayland/desktops/xdg/xdg.c b/client/displayservers/Wayland/desktops/xdg/xdg.c index 26bd16ac..e333218a 100644 --- a/client/displayservers/Wayland/desktops/xdg/xdg.c +++ b/client/displayservers/Wayland/desktops/xdg/xdg.c @@ -130,7 +130,7 @@ static const struct xdg_toplevel_listener xdgToplevelListener = { }; bool xdg_shellInit(struct wl_display * display, struct wl_surface * surface, - const char * title, bool fullscreen, bool maximize, bool borderless, + const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable) { if (!state.wmBase) @@ -147,7 +147,7 @@ bool xdg_shellInit(struct wl_display * display, struct wl_surface * surface, state.toplevel = xdg_surface_get_toplevel(state.surface); xdg_toplevel_add_listener(state.toplevel, &xdgToplevelListener, NULL); xdg_toplevel_set_title(state.toplevel, title); - xdg_toplevel_set_app_id(state.toplevel, "looking-glass-client"); + xdg_toplevel_set_app_id(state.toplevel, appId); if (fullscreen) xdg_toplevel_set_fullscreen(state.toplevel, NULL); diff --git a/client/displayservers/Wayland/interface/desktop.h b/client/displayservers/Wayland/interface/desktop.h index 8248231b..831c4788 100644 --- a/client/displayservers/Wayland/interface/desktop.h +++ b/client/displayservers/Wayland/interface/desktop.h @@ -34,7 +34,7 @@ typedef struct WL_DesktopOps bool (*shellInit)( struct wl_display * display, struct wl_surface * surface, - const char * title, bool fullscreen, bool maximize, + const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable); void (*shellAckConfigureIfNeeded)(void); diff --git a/client/displayservers/Wayland/wayland.c b/client/displayservers/Wayland/wayland.c index 33d21889..8f43fef8 100644 --- a/client/displayservers/Wayland/wayland.c +++ b/client/displayservers/Wayland/wayland.c @@ -159,7 +159,7 @@ static bool waylandInit(const LG_DSInitParams params) return false; wlWm.desktop->setSize(params.w, params.h); - if (!waylandWindowInit(params.title, params.fullscreen, params.maximize, + if (!waylandWindowInit(params.title, params.appId, params.fullscreen, params.maximize, params.borderless, params.resizable)) return false; diff --git a/client/displayservers/Wayland/wayland.h b/client/displayservers/Wayland/wayland.h index 92a8efcc..4c2e521c 100644 --- a/client/displayservers/Wayland/wayland.h +++ b/client/displayservers/Wayland/wayland.h @@ -301,7 +301,7 @@ bool waylandRegistryInit(void); void waylandRegistryFree(void); // window module -bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool borderless, bool resizable); +bool waylandWindowInit(const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable); void waylandWindowFree(void); void waylandWindowUpdateScale(void); void waylandSetWindowSize(int x, int y); diff --git a/client/displayservers/Wayland/window.c b/client/displayservers/Wayland/window.c index 1a277886..140c3eb4 100644 --- a/client/displayservers/Wayland/window.c +++ b/client/displayservers/Wayland/window.c @@ -85,7 +85,7 @@ static const struct wl_surface_listener wlSurfaceListener = { .leave = wlSurfaceLeaveHandler, }; -bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool borderless, bool resizable) +bool waylandWindowInit(const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable) { wlWm.scale = wl_fixed_from_int(1); @@ -113,7 +113,7 @@ bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool wl_surface_add_listener(wlWm.surface, &wlSurfaceListener, NULL); if (!wlWm.desktop->shellInit(wlWm.display, wlWm.surface, - title, fullscreen, maximize, borderless, resizable)) + title, appId, fullscreen, maximize, borderless, resizable)) return false; wl_surface_commit(wlWm.surface); diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index bfa4c307..b84526f2 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -343,7 +343,7 @@ static bool x11Init(const LG_DSInitParams params) XClassHint hint = { .res_name = strdup(params.title), - .res_class = strdup("looking-glass-client") + .res_class = strdup(params.appId) }; XSetClassHint(x11.display, x11.window, &hint); free(hint.res_name); diff --git a/client/include/interface/displayserver.h b/client/include/interface/displayserver.h index ee30fc5d..53b700fe 100644 --- a/client/include/interface/displayserver.h +++ b/client/include/interface/displayserver.h @@ -84,6 +84,7 @@ LG_DSPointer; typedef struct LG_DSInitParams { const char * title; + const char * appId; int x, y, w, h; bool center; bool fullscreen; diff --git a/client/src/config.c b/client/src/config.c index a868a7a8..f941e5fe 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -112,6 +112,13 @@ static struct Option options[] = .type = OPTION_TYPE_STRING, .value.x_string = "Looking Glass (client)" }, + { + .module = "win", + .name = "appId", + .description = "The application Id", + .type = OPTION_TYPE_STRING, + .value.x_string = "looking-glass-client" + }, { .module = "win", .name = "position", @@ -649,6 +656,7 @@ bool config_load(int argc, char * argv[]) g_params.allowDMA = option_get_bool ("app" , "allowDMA" ); g_params.windowTitle = option_get_string("win", "title" ); + g_params.appId = option_get_string("win", "appId" ); g_params.autoResize = option_get_bool ("win", "autoResize" ); g_params.allowResize = option_get_bool ("win", "allowResize" ); g_params.keepAspect = option_get_bool ("win", "keepAspect" ); diff --git a/client/src/main.c b/client/src/main.c index 0108c1db..e2df89b8 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1350,6 +1350,7 @@ static int lg_run(void) const LG_DSInitParams params = { .title = g_params.windowTitle, + .appId = g_params.appId, .x = g_params.x, .y = g_params.y, .w = g_params.w, diff --git a/client/src/main.h b/client/src/main.h index 8214c546..a51b5b3f 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -211,6 +211,7 @@ struct AppParams unsigned int forceRendererIndex; const char * windowTitle; + const char * appId; bool mouseRedraw; int mouseSens; bool mouseSmoothing;