Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/antimicro.pro b/antimicro.pro
- index f46cd0d..10973a8 100644
- --- a/antimicro.pro
- +++ b/antimicro.pro
- @@ -9,7 +9,7 @@ isEmpty(INSTALL_PREFIX) {
- }
- -QT += core gui
- +QT += core gui widgets
- target.path = $$INSTALL_PREFIX/bin
- @@ -28,6 +28,7 @@ SOURCES += main.cpp\
- joybuttonwidget.cpp \
- joystick.cpp \
- joybutton.cpp \
- + x11info.cpp \
- event.cpp \
- inputdaemon.cpp \
- buttoneditdialog.cpp \
- @@ -57,6 +58,7 @@ HEADERS += mainwindow.h \
- joybuttonwidget.h \
- joystick.h \
- joybutton.h \
- + x11info.h \
- event.h \
- inputdaemon.h \
- buttoneditdialog.h \
- @@ -102,3 +104,5 @@ INSTALLS += target desktop deskicon
- OTHER_FILES += \
- gpl.txt \
- other/antimicro.desktop
- +
- +DEFINES += HAVE_QT5
- diff --git a/event.cpp b/event.cpp
- index afe2f62..1974b1b 100644
- --- a/event.cpp
- +++ b/event.cpp
- @@ -1,9 +1,9 @@
- -#include <QX11Info>
- #include <QDebug>
- #include <QMutex>
- #include <X11/extensions/XTest.h>
- #include "event.h"
- +#include "x11info.h"
- QMutex mutex;
- Display* display;
- @@ -11,7 +11,7 @@ Display* display;
- //actually creates an XWindows event :)
- void sendevent( int code, bool pressed, JoyButtonSlot::JoySlotInputAction device) {
- //mutex.lock();
- - display = QX11Info::display();
- + display = X11Info::display();
- XLockDisplay (display);
- @@ -35,7 +35,7 @@ void sendevent( int code, bool pressed, JoyButtonSlot::JoySlotInputAction device
- void sendevent(int code1, int code2)
- {
- - display = QX11Info::display();
- + display = X11Info::display();
- XLockDisplay (display);
- @@ -48,7 +48,7 @@ void sendevent(int code1, int code2)
- int keyToKeycode (QString key)
- {
- int tempcode = -1;
- - Display* display = QX11Info::display();
- + Display* display = X11Info::display();
- if (key.length() > 0)
- {
- tempcode = XKeysymToKeycode(display, XStringToKeysym(key.toUtf8().data()));
- @@ -58,7 +58,7 @@ int keyToKeycode (QString key)
- QString keycodeToKey(int keycode)
- {
- - display = QX11Info::display();
- + display = X11Info::display();
- QString newkey;
- if (keycode <= 0)
- {
- diff --git a/main.cpp b/main.cpp
- index ff6a543..1d330cc 100644
- --- a/main.cpp
- +++ b/main.cpp
- @@ -1,10 +1,8 @@
- -#include <QtGui/QApplication>
- +#include <QApplication>
- #include <QDebug>
- #include <QThread>
- #include <QDir>
- -#include <X11/Xlib.h>
- -
- #include "mainwindow.h"
- #include "joystick.h"
- #include "inputdaemon.h"
- @@ -12,6 +10,8 @@
- #include "xmlconfigwriter.h"
- #include "common.h"
- +#include <X11/Xlib.h>
- +
- int main(int argc, char *argv[])
- {
- qRegisterMetaType<JoyButtonSlot*>();
- diff --git a/mainwindow.cpp b/mainwindow.cpp
- index c361f73..d3e0cf0 100644
- --- a/mainwindow.cpp
- +++ b/mainwindow.cpp
- @@ -2,7 +2,7 @@
- #include <SDL/SDL.h>
- #include <typeinfo>
- #include <QFile>
- -#include <QtGui/QApplication>
- +#include <QApplication>
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
- diff --git a/x11info.cpp b/x11info.cpp
- new file mode 100644
- index 0000000..302cf6a
- --- /dev/null
- +++ b/x11info.cpp
- @@ -0,0 +1,34 @@
- +#include "x11info.h"
- +
- +#ifdef HAVE_QT5
- +# include <QtGlobal>
- +# include <X11/Xlib.h>
- +#else
- +# include <QX11Info>
- +#endif
- +
- +
- +Display* X11Info::display()
- +{
- +#ifdef HAVE_QT5
- + if (!_display) {
- + _display = XOpenDisplay(NULL);
- + }
- + return _display;
- +#else
- + return QX11Info::display();
- +#endif
- +}
- +
- +unsigned long X11Info::appRootWindow(int screen)
- +{
- +#ifdef HAVE_QT5
- + return screen == -1?
- + XDefaultRootWindow(display()) :
- + XRootWindowOfScreen(XScreenOfDisplay(display(), screen));
- +#else
- + return QX11Info::appRootWindow(screen);
- +#endif
- +}
- +
- +Display* X11Info::_display = 0;
- diff --git a/x11info.h b/x11info.h
- new file mode 100644
- index 0000000..9a5aa95
- --- /dev/null
- +++ b/x11info.h
- @@ -0,0 +1,14 @@
- +#ifndef X11INFO_H
- +#define X11INFO_H
- +
- +typedef struct _XDisplay Display;
- +
- +class X11Info
- +{
- + static Display *_display;
- +public:
- + static Display* display();
- + static unsigned long appRootWindow(int screen = -1);
- +};
- +
- +#endif // X11INFO_H
- --
- 1.8.2.2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement