Add support for kwin (wayland) (#1393)
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

This commit is contained in:
Arimil
2025-06-21 13:51:25 -04:00
committed by GitHub
parent 456a9c04c7
commit f2c7b532d9
4 changed files with 232 additions and 2 deletions

View File

@@ -32,6 +32,7 @@
#endif
#include <fstream>
#include <sstream>
#include "kwin-helpers.h"
namespace advss {
@@ -44,6 +45,10 @@ static XScreenSaverAllocInfoFunc allocSSFunc = nullptr;
static XScreenSaverQueryInfoFunc querySSFunc = nullptr;
bool canGetIdleTime = false;
static bool KWin = false;
static FocusNotifier notifier;
static QString KWinScriptObjectPath;
static QLibrary *libprocps = nullptr;
#ifdef PROCPS_AVAILABLE
typedef PROCTAB *(*openproc_func)(int flags);
@@ -275,6 +280,11 @@ int getActiveWindow(Window *&window)
void GetCurrentWindowTitle(std::string &title)
{
if (KWin) {
title = FocusNotifier::getActiveWindowTitle();
return;
}
Window *data = 0;
if (getActiveWindow(data) != Success || !data) {
return;
@@ -286,6 +296,7 @@ void GetCurrentWindowTitle(std::string &title)
auto name = getWindowName(data[0]);
XFree(data);
if (name.empty()) {
return;
}
@@ -412,6 +423,10 @@ void GetProcessList(QStringList &processes)
long getForegroundProcessPid()
{
if (KWin) {
return FocusNotifier::getActiveWindowPID();
}
Window *window;
if (getActiveWindow(window) != Success || !window || !*window) {
return -1;
@@ -437,6 +452,7 @@ long getForegroundProcessPid()
pid = *((long *)prop);
XFree(prop);
return pid;
}
@@ -562,6 +578,17 @@ void PlatformInit()
return;
}
KWin = isKWinAvailable();
if (!(KWin && startKWinScript(KWinScriptObjectPath) &&
registerKWinDBusListener(&notifier))) {
// something bad happened while trying to initialize
// the KWin script/dbus so disable it
KWin = false;
blog(LOG_INFO, "not using KWin compat");
} else {
blog(LOG_INFO, "using KWin compat");
}
initXss();
initProcps();
initProc2();
@@ -583,6 +610,8 @@ void PlatformCleanup()
cleanupHelper(libproc2);
cleanupDisplay();
XSetErrorHandler(NULL);
if (KWin && !KWinScriptObjectPath.isEmpty())
stopKWinScript(KWinScriptObjectPath);
}
} // namespace advss