Skip to content

Commit

Permalink
[client] x11/wayland: add application id
Browse files Browse the repository at this point in the history
  • Loading branch information
rs189 authored and gnif committed Oct 15, 2024
1 parent 4e8201d commit e25492a
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ Zenithal <[email protected]> (ZenithalHourlyRate)
Kamplom <[email protected]> (kamplom)
Jacob McNamee <[email protected]> (jacobmcnamee)
Marco Antonio J. Costa <[email protected]> (majcosta)
rs189 <[email protected]> (rs189)
4 changes: 2 additions & 2 deletions client/displayservers/Wayland/desktops/libdecor/libdecor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions client/displayservers/Wayland/desktops/xdg/xdg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion client/displayservers/Wayland/interface/desktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion client/displayservers/Wayland/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion client/displayservers/Wayland/wayland.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions client/displayservers/Wayland/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion client/displayservers/X11/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions client/include/interface/displayserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions client/src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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" );
Expand Down
1 change: 1 addition & 0 deletions client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions client/src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ struct AppParams
unsigned int forceRendererIndex;

const char * windowTitle;
const char * appId;
bool mouseRedraw;
int mouseSens;
bool mouseSmoothing;
Expand Down

0 comments on commit e25492a

Please sign in to comment.