Add temp vars for window position and size

This commit is contained in:
WarmUpTill
2026-05-17 20:01:04 +02:00
parent 20c276f4ea
commit ee1d0136d9
5 changed files with 101 additions and 0 deletions

View File

@@ -352,6 +352,41 @@ std::optional<std::string> GetTextInWindow(const std::string &)
return {};
}
std::optional<WindowGeometry> GetWindowGeometry(const std::string &title)
{
auto display = disp();
if (!display) {
return {};
}
for (auto window : getTopLevelWindows()) {
if (getWindowName(window) != title) {
continue;
}
XWindowAttributes attrs;
if (!XGetWindowAttributes(display, window, &attrs)) {
return {};
}
int x = 0;
int y = 0;
Window child;
XTranslateCoordinates(display, window,
DefaultRootWindow(display), 0, 0, &x, &y,
&child);
WindowGeometry geo;
geo.x = x;
geo.y = y;
geo.width = attrs.width;
geo.height = attrs.height;
return geo;
}
return {};
}
static void getProcessListProcps(QStringList &processes)
{
#ifdef PROCPS_AVAILABLE