qt-bugs@ issue : none
bugs.kde.org number : 83974
applied: no
author: Lubos Lunak <l.lunak@kde.org>

An ugly hack to get real transparency in Konsole working somehow, with Qt not having
any support for the ARGB visual. QApplication has one ctor that allows passing
any X connection and X visual, but that has some side effects, so this patch
adds a magic flag to turn the side effects off.


--- src/kernel/qapplication.cpp.sav	2007-02-23 14:01:19.000000000 +0100
+++ src/kernel/qapplication.cpp	2007-05-29 15:42:39.000000000 +0200
@@ -317,6 +317,7 @@ void qt_init( int *, char **, QApplicati
 void qt_cleanup();
 #if defined(Q_WS_X11)
 void qt_init( Display* dpy, Qt::HANDLE, Qt::HANDLE );
+void qt_init( int *, char **, Display* dpy, Qt::HANDLE, Qt::HANDLE );
 #endif
 Q_EXPORT bool qt_tryModalHelper( QWidget *widget, QWidget **rettop );
 
@@ -905,7 +906,7 @@ QApplication::QApplication(Display *dpy,
 
 	qt_init( &argc, argv, GuiClient );
     } else {
-	qt_init(dpy, visual, colormap);
+	qt_init( &argc, argv, dpy, visual, colormap);
     }
 
     process_cmdline( &argc, argv );
--- src/kernel/qapplication_x11.cpp.sav	2007-05-25 18:56:23.000000000 +0200
+++ src/kernel/qapplication_x11.cpp	2007-05-29 16:24:58.000000000 +0200
@@ -196,6 +196,7 @@ static bool	noxim		= FALSE;	// connect t
 static Display *appDpy		= 0;		// X11 application display
 static char    *appDpyName	= 0;		// X11 display name
 static bool	appForeignDpy	= FALSE;        // we didn't create display
+Q_EXPORT bool qt_no_foreign_hack = false;
 static bool	appSync		= FALSE;	// X11 synchronization
 #if defined(QT_DEBUG)
 static bool	appNoGrab	= FALSE;	// X11 grabbing enabled
@@ -1541,7 +1542,7 @@ void qt_init_internal( int *argcptr, cha
     setlocale( LC_ALL, "" );		// use correct char set mapping
     setlocale( LC_NUMERIC, "C" );	// make sprintf()/scanf() work
 
-    if ( display ) {
+    if ( display && !qt_no_foreign_hack ) {
 	// Qt part of other application
 
 	appForeignDpy = TRUE;
@@ -1698,7 +1699,9 @@ void qt_init_internal( int *argcptr, cha
 	// Connect to X server
 
 	if( qt_is_gui_used ) {
-	    if ( ( appDpy = XOpenDisplay(appDpyName) ) == 0 ) {
+            if( display != NULL && qt_no_foreign_hack )
+                appDpy = display;
+	    else if ( ( appDpy = XOpenDisplay(appDpyName) ) == 0 ) {
 		qWarning( "%s: cannot connect to X server %s", appName,
 			  XDisplayName(appDpyName) );
 		qApp = 0;
@@ -2345,6 +2348,10 @@ void qt_init( Display *display, Qt::HAND
     qt_init_internal( 0, 0, display, visual, colormap );
 }
 
+void qt_init( int *argcptr, char **argv, Display *display, Qt::HANDLE visual, Qt::HANDLE colormap )
+{
+    qt_init_internal( argcptr, argv, display, visual, colormap );
+}
 
 /*****************************************************************************
   qt_cleanup() - cleans up when the application is finished
