windows compat
This commit is contained in:
parent
16e1813f95
commit
b009411f55
|
@ -11,7 +11,8 @@ class X11Helper : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static Window InvalidWindow;
|
static const Window InvalidWindow;
|
||||||
|
static const bool IsSupported;
|
||||||
|
|
||||||
explicit X11Helper(QObject* parent = nullptr);
|
explicit X11Helper(QObject* parent = nullptr);
|
||||||
virtual ~X11Helper();
|
virtual ~X11Helper();
|
||||||
|
@ -26,7 +27,9 @@ public slots:
|
||||||
private:
|
private:
|
||||||
Window searchWindows(Window top, const QString& search);
|
Window searchWindows(Window top, const QString& search);
|
||||||
|
|
||||||
|
#ifdef X11SUPPORT
|
||||||
Display* disp;
|
Display* disp;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // X11HELPER_H
|
#endif // X11HELPER_H
|
||||||
|
|
|
@ -70,8 +70,8 @@ SOURCES += \
|
||||||
thirdparty/Log/Log.cpp
|
thirdparty/Log/Log.cpp
|
||||||
|
|
||||||
# platform specific implementations
|
# platform specific implementations
|
||||||
win32:SOURCES += src/clientaccess_windows.cpp
|
win32:SOURCES += src/clientaccess_windows.cpp src/x11helper_other.cpp
|
||||||
unix:SOURCES += src/clientaccess_linux.cpp
|
unix:SOURCES += src/clientaccess_linux.cpp src/x11helper_x11.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
include/arg.h \
|
include/arg.h \
|
||||||
|
|
|
@ -10,10 +10,16 @@
|
||||||
#include "loadingwindow.h"
|
#include "loadingwindow.h"
|
||||||
#include "x11helper.h"
|
#include "x11helper.h"
|
||||||
|
|
||||||
|
#ifdef X11SUPPORT
|
||||||
|
#define INIT_X11HELPER new X11Helper(this)
|
||||||
|
#else
|
||||||
|
#define INIT_X11HELPER nullptr
|
||||||
|
#endif
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui(new Ui::MainWindow), saveTimer(new QTimer(this)), dd(QLocale().name()),
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui(new Ui::MainWindow), saveTimer(new QTimer(this)), dd(QLocale().name()),
|
||||||
lolaa(conf.getConfig(), dd), lwin(new LoadingWindow(nullptr)),
|
lolaa(conf.getConfig(), dd), lwin(new LoadingWindow(nullptr)),
|
||||||
dodgeQuestion(new QMessageBox(QMessageBox::Icon::Warning, MainWindow::tr("Dodge?"), MainWindow::tr("Are you sure you want to dodge?"), QMessageBox::Cancel | QMessageBox::Yes, this)),
|
dodgeQuestion(new QMessageBox(QMessageBox::Icon::Warning, MainWindow::tr("Dodge?"), MainWindow::tr("Are you sure you want to dodge?"), QMessageBox::Cancel | QMessageBox::Yes, this)),
|
||||||
x11Helper(new X11Helper(this)) {
|
x11Helper(INIT_X11HELPER) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
QObject::connect(&dd, &DataDragon::fetchingChamp, lwin, &LoadingWindow::setChampion);
|
QObject::connect(&dd, &DataDragon::fetchingChamp, lwin, &LoadingWindow::setChampion);
|
||||||
|
|
|
@ -1,64 +1,3 @@
|
||||||
#include "x11helper.h"
|
#include "x11helper.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
const Window X11Helper::InvalidWindow = 0;
|
||||||
|
|
||||||
X11Helper::X11Helper(QObject *parent) : QObject(parent), disp(XOpenDisplay(nullptr)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
X11Helper::~X11Helper() {
|
|
||||||
XCloseDisplay(this->disp);
|
|
||||||
}
|
|
||||||
|
|
||||||
Window X11Helper::findWindow(const QString& name) {
|
|
||||||
return searchWindows(DefaultRootWindow(disp), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
Window X11Helper::searchWindows(Window top, const QString& search) {
|
|
||||||
{
|
|
||||||
char* window_name;
|
|
||||||
if (XFetchName(disp, top, &window_name)) {
|
|
||||||
QString winName(window_name);
|
|
||||||
XFree(window_name);
|
|
||||||
if (search == winName) {
|
|
||||||
return top; // dont look for kids
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Window* children = nullptr;
|
|
||||||
Window dummy;
|
|
||||||
unsigned int nchildren;
|
|
||||||
if (!XQueryTree(disp, top, &dummy, &dummy, &children, &nchildren)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nchildren; i++) {
|
|
||||||
Window res = searchWindows(children[i], search);
|
|
||||||
if(res != 0) {
|
|
||||||
XFree((char*) children);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (children) {
|
|
||||||
XFree((char*) children);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void X11Helper::map(Window win) {
|
|
||||||
XMapRaised(disp, win);
|
|
||||||
}
|
|
||||||
|
|
||||||
void X11Helper::unmap(Window win) {
|
|
||||||
XUnmapWindow(disp, win);
|
|
||||||
}
|
|
||||||
|
|
||||||
void X11Helper::setMap(Window win, bool b) {
|
|
||||||
if(b) {
|
|
||||||
map(win);
|
|
||||||
} else {
|
|
||||||
unmap(win);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include "x11helper.h"
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
const bool X11Helper::IsSupported = false;
|
||||||
|
|
||||||
|
X11Helper::X11Helper(QObject *parent) : QObject(parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
X11Helper::~X11Helper() {}
|
||||||
|
|
||||||
|
Window X11Helper::findWindow(const QString& name) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Window X11Helper::searchWindows(Window top, const QString& search) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11Helper::map(Window win) {}
|
||||||
|
|
||||||
|
void X11Helper::unmap(Window win) {}
|
||||||
|
|
||||||
|
void X11Helper::setMap(Window win, bool b) {}
|
|
@ -0,0 +1,66 @@
|
||||||
|
#include "x11helper.h"
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
const bool X11Helper::IsSupported = true;
|
||||||
|
|
||||||
|
X11Helper::X11Helper(QObject *parent) : QObject(parent), disp(XOpenDisplay(nullptr)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
X11Helper::~X11Helper() {
|
||||||
|
XCloseDisplay(this->disp);
|
||||||
|
}
|
||||||
|
|
||||||
|
Window X11Helper::findWindow(const QString& name) {
|
||||||
|
return searchWindows(DefaultRootWindow(disp), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Window X11Helper::searchWindows(Window top, const QString& search) {
|
||||||
|
{
|
||||||
|
char* window_name;
|
||||||
|
if (XFetchName(disp, top, &window_name)) {
|
||||||
|
QString winName(window_name);
|
||||||
|
XFree(window_name);
|
||||||
|
if (search == winName) {
|
||||||
|
return top; // dont look for kids
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window* children = nullptr;
|
||||||
|
Window dummy;
|
||||||
|
unsigned int nchildren;
|
||||||
|
if (!XQueryTree(disp, top, &dummy, &dummy, &children, &nchildren)) {
|
||||||
|
return InvalidWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < nchildren; i++) {
|
||||||
|
Window res = searchWindows(children[i], search);
|
||||||
|
if(res != InvalidWindow) {
|
||||||
|
XFree((char*) children);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (children) {
|
||||||
|
XFree((char*) children);
|
||||||
|
}
|
||||||
|
|
||||||
|
return InvalidWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11Helper::map(Window win) {
|
||||||
|
XMapRaised(disp, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11Helper::unmap(Window win) {
|
||||||
|
XUnmapWindow(disp, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11Helper::setMap(Window win, bool b) {
|
||||||
|
if(b) {
|
||||||
|
map(win);
|
||||||
|
} else {
|
||||||
|
unmap(win);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue