mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-20 00:05:41 -05:00
Add temp vars for window position and size
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -11,11 +11,20 @@ namespace advss {
|
||||
|
||||
enum class HotkeyType;
|
||||
|
||||
struct WindowGeometry {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
EXPORT std::vector<std::string> GetWindowList();
|
||||
EXPORT std::string GetCurrentWindowTitle();
|
||||
EXPORT bool IsFullscreen(const std::string &title);
|
||||
EXPORT bool IsMaximized(const std::string &title);
|
||||
EXPORT std::optional<std::string> GetTextInWindow(const std::string &window);
|
||||
EXPORT std::optional<WindowGeometry>
|
||||
GetWindowGeometry(const std::string &title);
|
||||
EXPORT int SecondsSinceLastInput();
|
||||
EXPORT QStringList GetProcessList();
|
||||
EXPORT std::string GetForegroundProcessName();
|
||||
|
||||
@@ -345,6 +345,26 @@ bool IsFullscreen(const std::string &title)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<WindowGeometry> GetWindowGeometry(const std::string &title)
|
||||
{
|
||||
HWND hwnd = getHWNDfromTitle(title);
|
||||
if (!hwnd) {
|
||||
return {};
|
||||
}
|
||||
|
||||
RECT rect;
|
||||
if (!GetWindowRect(hwnd, &rect)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
WindowGeometry geo;
|
||||
geo.x = rect.left;
|
||||
geo.y = rect.top;
|
||||
geo.width = rect.right - rect.left;
|
||||
geo.height = rect.bottom - rect.top;
|
||||
return geo;
|
||||
}
|
||||
|
||||
QStringList GetProcessList()
|
||||
{
|
||||
QStringList processes;
|
||||
|
||||
Reference in New Issue
Block a user