Skip to content

Commit

Permalink
Detect WSLg
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusDierheimer committed Jun 18, 2022
1 parent 9176797 commit 26d1725
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/detection/displayserver/wmde.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>

static const char* parseEnv()
{
Expand Down Expand Up @@ -42,6 +43,11 @@ static const char* parseEnv()
if(getenv("TDE_FULL_SESSION") != NULL)
return "Trinity";

if(
getenv("WAYLAND_DISPLAY") != NULL &&
ffFileExists("/mnt/wslg/", S_IFDIR)
) return "WSLg";

return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/detection/displayserver/xcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void* xcbGetProperty(XcbPropertyData* data, xcb_connection_t* connection,

static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connection, xcb_window_t rootWindow, FFDisplayServerResult* result)
{
if(result->wmProcessName.length > 0)
if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND) == 0)
return;

xcb_window_t* wmWindow = (xcb_window_t*) xcbGetProperty(data, connection, rootWindow, "_NET_SUPPORTING_WM_CHECK");
Expand Down
2 changes: 1 addition & 1 deletion src/detection/displayserver/xlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static unsigned char* x11GetProperty(X11PropertyData* data, Display* display, Wi

static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDisplayServerResult* result)
{
if(result->wmProcessName.length > 0)
if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND) == 0)
return;

Window* wmWindow = (Window*) x11GetProperty(data, display, DefaultRootWindow(display), "_NET_SUPPORTING_WM_CHECK");
Expand Down
6 changes: 6 additions & 0 deletions src/modules/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ void ffPrintCursor(FFinstance* instance)

const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);

if(ffStrbufCompS(&wmde->wmPrettyName, "WSLg") == 0)
{
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "WSLg uses native windows cursor");
return;
}

if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
{
ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursor, "Cursor isn't supported in TTY");
Expand Down

0 comments on commit 26d1725

Please sign in to comment.