diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-12 20:16:55 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-08-12 20:16:55 +0000 |
commit | 08af9dd21911161841d86bea0f862cd8dc4263bf (patch) | |
tree | 37cb0fc03d92bcea2509fe4e9de15682720b3f28 /qtinterface/tqpaintdevice.cpp | |
parent | 8bb16c159066215bb8975be57b77885014e00054 (diff) | |
download | tqtinterface-08af9dd21911161841d86bea0f862cd8dc4263bf.tar.gz tqtinterface-08af9dd21911161841d86bea0f862cd8dc4263bf.zip |
More Qt3/Qt4 fixes
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/dependencies/tqtinterface@1162835 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtinterface/tqpaintdevice.cpp')
-rw-r--r-- | qtinterface/tqpaintdevice.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
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 |