summaryrefslogtreecommitdiffstats
path: root/qtinterface/tqpaintdevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtinterface/tqpaintdevice.cpp')
-rw-r--r--qtinterface/tqpaintdevice.cpp56
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