From 08af9dd21911161841d86bea0f862cd8dc4263bf Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 12 Aug 2010 20:16:55 +0000 Subject: [PATCH] More Qt3/Qt4 fixes git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/dependencies/tqtinterface@1162835 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- qtinterface/private/tqucomextra_p.h | 4 +-- qtinterface/tqpaintdevice.cpp | 56 +++++++++++++++++++++++++++++ qtinterface/tqt.h | 4 ++- qtinterface/tqt4/Qt/qpaintdevice.h | 1 + 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/qtinterface/private/tqucomextra_p.h b/qtinterface/private/tqucomextra_p.h index 5f9b7de..b062baf 100644 --- a/qtinterface/private/tqucomextra_p.h +++ b/qtinterface/private/tqucomextra_p.h @@ -29,7 +29,7 @@ Boston, MA 02110-1301, USA. // Reimplement the QUComExtra_P class // For Qt3, no changes are needed -#include +#include #endif // USE_QT3 @@ -45,4 +45,4 @@ public: #endif // USE_QT4 -#endif /* TQUCOMEXTRA_P_H */ \ No newline at end of file +#endif /* TQUCOMEXTRA_P_H */ diff --git a/qtinterface/tqpaintdevice.cpp b/qtinterface/tqpaintdevice.cpp index dd11fbf..20f41cc 100644 --- a/qtinterface/tqpaintdevice.cpp +++ b/qtinterface/tqpaintdevice.cpp @@ -40,4 +40,60 @@ Qt::HANDLE QPaintDevice::x11RenderHandle() const // #endif // QT_NO_XFTFREETYPE } +static GC* app_gc_tmp = 0; // temporary GC +static GC* app_gc_tmp_m = 0; // temporary GC (monochrome) + +static GC create_gc( int scrn, bool monochrome ) +{ + GC gc; + if ( monochrome ) { + Pixmap pm = XCreatePixmap( appDpy, RootWindow( appDpy, scrn ), 8, 8, 1 ); + gc = XCreateGC( appDpy, pm, 0, 0 ); + XFreePixmap( appDpy, pm ); + } else { + if ( QPaintDevice::x11AppDefaultVisual( scrn ) ) { + gc = XCreateGC( appDpy, RootWindow( appDpy, scrn ), 0, 0 ); + } else { + Window w; + XSetWindowAttributes a; + a.background_pixel = Qt::black.pixel( scrn ); + a.border_pixel = Qt::black.pixel( scrn ); + a.colormap = QPaintDevice::x11AppColormap( scrn ); + w = XCreateWindow( appDpy, RootWindow( appDpy, scrn ), 0, 0, 100, 100, + 0, QPaintDevice::x11AppDepth( scrn ), InputOutput, + (Visual*)QPaintDevice::x11AppVisual( scrn ), + CWBackPixel|CWBorderPixel|CWColormap, &a ); + gc = XCreateGC( appDpy, w, 0, 0 ); + XDestroyWindow( appDpy, w ); + } + } + XSetGraphicsExposures( appDpy, gc, False ); + return gc; +} + +GC qt_xget_temp_gc( int scrn, bool monochrome ) // get temporary GC +{ + int appScreenCount = QApplication::desktop()->numScreens(); + if ( scrn < 0 || scrn >= appScreenCount ) { + qDebug("invalid screen (tmp) %d %d", scrn, appScreenCount ); + QWidget* bla = 0; + bla->setName("hello"); + } + GC gc; + if ( monochrome ) { + if ( !app_gc_tmp_m ) // create GC for bitmap + memset( (app_gc_tmp_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); + if ( !app_gc_tmp_m[scrn] ) + app_gc_tmp_m[scrn] = create_gc( scrn, TRUE ); + gc = app_gc_tmp_m[scrn]; + } else { // create standard GC + if ( !app_gc_tmp ) + memset( (app_gc_tmp = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); + if ( !app_gc_tmp[scrn] ) + app_gc_tmp[scrn] = create_gc( scrn, FALSE ); + gc = app_gc_tmp[scrn]; + } + return gc; +} + #endif // USE_QT4 \ No newline at end of file diff --git a/qtinterface/tqt.h b/qtinterface/tqt.h index ca00704..03c8a7c 100644 --- a/qtinterface/tqt.h +++ b/qtinterface/tqt.h @@ -673,8 +673,10 @@ class QUObject; #define TQNoBrush Qt::NoBrush #define QMetaData QMetaMethod -#define qt_xdisplay QX11Info::display +#define qt_xdisplay QPaintDevice::x11Display #define qt_xrootwin QPaintDevice::x11AppRootWindow +#define qt_xscreen QPaintDevice::x11Screen +#define qt_xget_temp_gc QPaintDevice::qt_xget_temp_gc #define TickSetting TickPosition #define ButtonState Qt::ButtonState diff --git a/qtinterface/tqt4/Qt/qpaintdevice.h b/qtinterface/tqt4/Qt/qpaintdevice.h index d6e378b..41a58c6 100644 --- a/qtinterface/tqt4/Qt/qpaintdevice.h +++ b/qtinterface/tqt4/Qt/qpaintdevice.h @@ -95,6 +95,7 @@ public: #elif defined(Q_WS_X11) virtual Qt::HANDLE handle() const; virtual Qt::HANDLE x11RenderHandle() const; + GC qt_xget_temp_gc( int scrn, bool monochrome ); #elif defined(Q_WS_MAC) virtual Qt::HANDLE handle() const; #elif defined(Q_WS_QWS)