mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-24 14:58:19 -05:00
Use existing Qt functionality to get cursor position
Might resolve issues with cursor position detection on non-X windows on Linux
This commit is contained in:
parent
cc3ce3f0e0
commit
05fce566f4
|
|
@ -251,29 +251,6 @@ void GetCurrentWindowTitle(std::string &title)
|
|||
title = name;
|
||||
}
|
||||
|
||||
std::pair<int, int> getCursorPos()
|
||||
{
|
||||
std::pair<int, int> pos(0, 0);
|
||||
Display *dpy;
|
||||
Window root;
|
||||
Window ret_root;
|
||||
Window ret_child;
|
||||
int root_x;
|
||||
int root_y;
|
||||
int win_x;
|
||||
int win_y;
|
||||
unsigned int mask;
|
||||
|
||||
dpy = disp();
|
||||
root = XDefaultRootWindow(dpy);
|
||||
|
||||
if (XQueryPointer(dpy, root, &ret_root, &ret_child, &root_x, &root_y,
|
||||
&win_x, &win_y, &mask)) {
|
||||
pos = std::pair<int, int>(root_x, root_y);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool isMaximized(const std::string &title)
|
||||
{
|
||||
if (!ewmhIsSupported()) {
|
||||
|
|
|
|||
|
|
@ -99,17 +99,6 @@ void GetCurrentWindowTitle(std::string &title)
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<int, int> getCursorPos()
|
||||
{
|
||||
std::pair<int, int> pos(0, 0);
|
||||
CGEventRef event = CGEventCreate(NULL);
|
||||
CGPoint cursorPos = CGEventGetLocation(event);
|
||||
CFRelease(event);
|
||||
pos.first = cursorPos.x;
|
||||
pos.second = cursorPos.y;
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool isWindowOriginOnScreen(NSDictionary *app, NSScreen *screen,
|
||||
bool fullscreen = false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ void GetWindowList(QStringList &windows);
|
|||
void GetCurrentWindowTitle(std::string &title);
|
||||
bool isFullscreen(const std::string &title);
|
||||
bool isMaximized(const std::string &title);
|
||||
std::pair<int, int> getCursorPos();
|
||||
int secondsSinceLastInput();
|
||||
void GetProcessList(QStringList &processes);
|
||||
void GetForegroundProcessName(std::string &name);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QGuiApplication>
|
||||
#include <QCursor>
|
||||
#include <unordered_map>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
|
|
@ -980,3 +981,9 @@ int findIdxInRagne(QComboBox *list, int start, int stop,
|
|||
}
|
||||
return foundIdx;
|
||||
}
|
||||
|
||||
std::pair<int, int> getCursorPos()
|
||||
{
|
||||
auto cursorPos = QCursor::pos();
|
||||
return {cursorPos.x(), cursorPos.y()};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,3 +88,4 @@ void addSelectionGroup(QComboBox *selection, const QStringList &group,
|
|||
bool addSeparator = true);
|
||||
int findIdxInRagne(QComboBox *list, int start, int stop,
|
||||
const std::string &value);
|
||||
std::pair<int, int> getCursorPos();
|
||||
|
|
|
|||
|
|
@ -124,17 +124,6 @@ void GetCurrentWindowTitle(std::string &title)
|
|||
GetWindowTitle(window, title);
|
||||
}
|
||||
|
||||
std::pair<int, int> getCursorPos()
|
||||
{
|
||||
std::pair<int, int> pos(0, 0);
|
||||
POINT cursorPos;
|
||||
if (GetPhysicalCursorPos(&cursorPos)) {
|
||||
pos.first = cursorPos.x;
|
||||
pos.second = cursorPos.y;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
HWND getHWNDfromTitle(std::string title)
|
||||
{
|
||||
HWND hwnd = NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user