Advertisement
Guest User

antimicro Qt5 build fix

a guest
May 4th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.18 KB | None | 0 0
  1. diff --git a/antimicro.pro b/antimicro.pro
  2. index f46cd0d..10973a8 100644
  3. --- a/antimicro.pro
  4. +++ b/antimicro.pro
  5. @@ -9,7 +9,7 @@ isEmpty(INSTALL_PREFIX) {
  6.  }
  7.  
  8.  
  9. -QT       += core gui
  10. +QT       += core gui widgets
  11.  
  12.  target.path = $$INSTALL_PREFIX/bin
  13.  
  14. @@ -28,6 +28,7 @@ SOURCES += main.cpp\
  15.      joybuttonwidget.cpp \
  16.      joystick.cpp \
  17.      joybutton.cpp \
  18. +    x11info.cpp \
  19.      event.cpp \
  20.      inputdaemon.cpp \
  21.      buttoneditdialog.cpp \
  22. @@ -57,6 +58,7 @@ HEADERS  += mainwindow.h \
  23.      joybuttonwidget.h \
  24.      joystick.h \
  25.      joybutton.h \
  26. +    x11info.h \
  27.      event.h \
  28.      inputdaemon.h \
  29.      buttoneditdialog.h \
  30. @@ -102,3 +104,5 @@ INSTALLS += target desktop deskicon
  31.  OTHER_FILES += \
  32.      gpl.txt \
  33.      other/antimicro.desktop
  34. +
  35. +DEFINES += HAVE_QT5
  36. diff --git a/event.cpp b/event.cpp
  37. index afe2f62..1974b1b 100644
  38. --- a/event.cpp
  39. +++ b/event.cpp
  40. @@ -1,9 +1,9 @@
  41. -#include <QX11Info>
  42.  #include <QDebug>
  43.  #include <QMutex>
  44.  #include <X11/extensions/XTest.h>
  45.  
  46.  #include "event.h"
  47. +#include "x11info.h"
  48.  
  49.  QMutex mutex;
  50.  Display* display;
  51. @@ -11,7 +11,7 @@ Display* display;
  52.  //actually creates an XWindows event  :)
  53.  void sendevent( int code, bool pressed, JoyButtonSlot::JoySlotInputAction device) {
  54.      //mutex.lock();
  55. -    display = QX11Info::display();
  56. +    display = X11Info::display();
  57.  
  58.      XLockDisplay (display);
  59.  
  60. @@ -35,7 +35,7 @@ void sendevent( int code, bool pressed, JoyButtonSlot::JoySlotInputAction device
  61.  
  62.  void sendevent(int code1, int code2)
  63.  {
  64. -    display = QX11Info::display();
  65. +    display = X11Info::display();
  66.  
  67.      XLockDisplay (display);
  68.  
  69. @@ -48,7 +48,7 @@ void sendevent(int code1, int code2)
  70.  int keyToKeycode (QString key)
  71.  {
  72.      int tempcode = -1;
  73. -    Display* display = QX11Info::display();
  74. +    Display* display = X11Info::display();
  75.      if (key.length() > 0)
  76.      {
  77.          tempcode = XKeysymToKeycode(display, XStringToKeysym(key.toUtf8().data()));
  78. @@ -58,7 +58,7 @@ int keyToKeycode (QString key)
  79.  
  80.  QString keycodeToKey(int keycode)
  81.  {
  82. -    display = QX11Info::display();
  83. +    display = X11Info::display();
  84.      QString newkey;
  85.      if (keycode <= 0)
  86.      {
  87. diff --git a/main.cpp b/main.cpp
  88. index ff6a543..1d330cc 100644
  89. --- a/main.cpp
  90. +++ b/main.cpp
  91. @@ -1,10 +1,8 @@
  92. -#include <QtGui/QApplication>
  93. +#include <QApplication>
  94.  #include <QDebug>
  95.  #include <QThread>
  96.  #include <QDir>
  97.  
  98. -#include <X11/Xlib.h>
  99. -
  100.  #include "mainwindow.h"
  101.  #include "joystick.h"
  102.  #include "inputdaemon.h"
  103. @@ -12,6 +10,8 @@
  104.  #include "xmlconfigwriter.h"
  105.  #include "common.h"
  106.  
  107. +#include <X11/Xlib.h>
  108. +
  109.  int main(int argc, char *argv[])
  110.  {
  111.      qRegisterMetaType<JoyButtonSlot*>();
  112. diff --git a/mainwindow.cpp b/mainwindow.cpp
  113. index c361f73..d3e0cf0 100644
  114. --- a/mainwindow.cpp
  115. +++ b/mainwindow.cpp
  116. @@ -2,7 +2,7 @@
  117.  #include <SDL/SDL.h>
  118.  #include <typeinfo>
  119.  #include <QFile>
  120. -#include <QtGui/QApplication>
  121. +#include <QApplication>
  122.  
  123.  #include "mainwindow.h"
  124.  #include "ui_mainwindow.h"
  125. diff --git a/x11info.cpp b/x11info.cpp
  126. new file mode 100644
  127. index 0000000..302cf6a
  128. --- /dev/null
  129. +++ b/x11info.cpp
  130. @@ -0,0 +1,34 @@
  131. +#include "x11info.h"
  132. +
  133. +#ifdef HAVE_QT5
  134. +# include <QtGlobal>
  135. +# include <X11/Xlib.h>
  136. +#else
  137. +# include <QX11Info>
  138. +#endif
  139. +
  140. +
  141. +Display* X11Info::display()
  142. +{
  143. +#ifdef HAVE_QT5
  144. +    if (!_display) {
  145. +        _display = XOpenDisplay(NULL);
  146. +    }
  147. +    return _display;
  148. +#else
  149. +    return QX11Info::display();
  150. +#endif
  151. +}
  152. +
  153. +unsigned long X11Info::appRootWindow(int screen)
  154. +{
  155. +#ifdef HAVE_QT5
  156. +    return screen == -1?
  157. +                XDefaultRootWindow(display()) :
  158. +                XRootWindowOfScreen(XScreenOfDisplay(display(), screen));
  159. +#else
  160. +    return QX11Info::appRootWindow(screen);
  161. +#endif
  162. +}
  163. +
  164. +Display* X11Info::_display = 0;
  165. diff --git a/x11info.h b/x11info.h
  166. new file mode 100644
  167. index 0000000..9a5aa95
  168. --- /dev/null
  169. +++ b/x11info.h
  170. @@ -0,0 +1,14 @@
  171. +#ifndef X11INFO_H
  172. +#define X11INFO_H
  173. +
  174. +typedef struct _XDisplay Display;
  175. +
  176. +class X11Info
  177. +{
  178. +    static Display *_display;
  179. +public:
  180. +    static Display* display();
  181. +    static unsigned long appRootWindow(int screen = -1);
  182. +};
  183. +
  184. +#endif // X11INFO_H
  185. --
  186. 1.8.2.2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement