$OpenBSD: patch-src_kernel_qapplication_x11_cpp,v 1.1 2003/01/19 17:36:51 espie Exp $
--- src/kernel/qapplication_x11.cpp.orig	Mon Dec  9 10:40:39 2002
+++ src/kernel/qapplication_x11.cpp	Sun Jan 19 16:07:04 2003
@@ -360,8 +360,8 @@ static bool qt_x11EventFilter( XEvent* e
 #if !defined(QT_NO_XIM)
 XIM		qt_xim			= 0;
 XIMStyle	qt_xim_style		= 0;
-// static XIMStyle	xim_preferred_style	= XIMPreeditPosition | XIMStatusNothing;
-static XIMStyle	xim_preferred_style	= XIMPreeditCallbacks | XIMStatusNothing;
+static XIMStyle xim_default_style      = XIMPreeditCallbacks | XIMStatusNothing;
+static XIMStyle        xim_preferred_style     = 0;
 #endif
 
 static int composingKeycode=0;
@@ -988,6 +988,32 @@ bool QApplication::x11_apply_settings()
     qt_use_rtl_extensions =
     	settings.readBoolEntry("/qt/useRtlExtensions", FALSE);
 
+#ifndef QT_NO_XFTFREETYPE
+    // defined in qfont_x11.cpp
+    extern bool qt_has_xft;
+    extern bool qt_use_antialiasing;
+
+    qt_has_xft = FALSE;
+    qt_use_antialiasing = FALSE;
+    if (qt_use_xrender &&
+       XftInit(0) && XftInitFtLibrary()) {
+       qt_has_xft = settings.readBoolEntry( "/qt/enableXft", TRUE );
+       qt_use_antialiasing = settings.readBoolEntry( "/qt/useXft", TRUE );
+    }
+#endif // QT_NO_XFTFREETYPE
+
+    QString ximInputStyle =
+       settings.readEntry( "/qt/XIMInputStyle",
+                           QObject::trUtf8( "On The Spot" ) ).lower();
+    if ( ximInputStyle == "on the spot" )
+       xim_preferred_style = XIMPreeditCallbacks | XIMStatusNothing;
+    else if ( ximInputStyle == "over the spot" )
+       xim_preferred_style = XIMPreeditPosition | XIMStatusNothing;
+    else if ( ximInputStyle == "off the spot" )
+       xim_preferred_style = XIMPreeditArea | XIMStatusArea;
+    else if ( ximInputStyle == "root" )
+       xim_preferred_style = XIMPreeditNothing | XIMStatusNothing;
+
     if (update_timestamp) {
 	QBuffer stamp;
 	QDataStream s(stamp.buffer(), IO_WriteOnly);
@@ -1452,25 +1478,7 @@ void qt_init_internal( int *argcptr, cha
 	p = strrchr( argv[0], '/' );
 	appName = p ? p + 1 : argv[0];
 
-	// Read global settings file
-#if !defined(QT_NO_XIM)
-	if ( QApplication::desktopSettingsAware() ) {
-	    QString ximInputStyle =
-		QSettings().readEntry( "/qt/XIMInputStyle",
-				       QObject::trUtf8( "On The Spot" ) ).lower();
-	    if ( ximInputStyle == "on the spot" )
-		xim_preferred_style = XIMPreeditCallbacks | XIMStatusNothing;
-	    else if ( ximInputStyle == "over the spot" )
-		xim_preferred_style = XIMPreeditPosition | XIMStatusNothing;
-	    else if ( ximInputStyle == "off the spot" )
-		xim_preferred_style = XIMPreeditArea | XIMStatusArea;
-	    else if ( ximInputStyle == "root" )
-		xim_preferred_style = XIMPreeditNothing | XIMStatusNothing;
-	}
-#endif
-
 	// Get command line params
-
 	j = 1;
 	for ( int i=1; i<argc; i++ ) {
 	    if ( argv[i] && *argv[i] != '-' ) {
@@ -1974,8 +1982,28 @@ void qt_init_internal( int *argcptr, cha
     setlocale( LC_NUMERIC, "C" );	// make sprintf()/scanf() work
 
     if ( qt_is_gui_used ) {
+       qt_set_input_encoding();
+
+       // be smart about the size of the default font. most X servers have helvetica
+       // 12 point available at 2 resolutions:
+       //     75dpi (12 pixels) and 100dpi (17 pixels).
+       // At 95 DPI, a 12 point font should be 16 pixels tall - in which case a 17
+       // pixel font is a closer match than a 12 pixel font
+       int ptsz =
+           (int) ( ( ( QPaintDevice::x11AppDpiY() >= 95 ? 17. : 12. ) *
+                     72. / (float) QPaintDevice::x11AppDpiY() ) + 0.5 );
+
+       if ( !qt_app_has_font ) {
+           QFont f( "Helvetica", ptsz );
+           QApplication::setFont( f );
+       }
+
+       qt_set_x11_resources( appFont, appFGCol, appBGCol, appBTNCol);
 
 #ifndef QT_NO_XIM
+       if ( ! xim_preferred_style ) // no configured input style, use the default
+           xim_preferred_style = xim_default_style;
+
 	qt_xim = 0;
 	QString ximServerName(ximServer);
 	if (ximServer)
@@ -2001,24 +2029,6 @@ void qt_init_internal( int *argcptr, cha
 #endif // USE_X11R6_XIM
 #endif // QT_NO_XIM
 
-	qt_set_input_encoding();
-
-	// be smart about the size of the default font. most X servers have helvetica
-	// 12 point available at 2 resolutions:
-	//     75dpi (12 pixels) and 100dpi (17 pixels).
-	// At 95 DPI, a 12 point font should be 16 pixels tall - in which case a 17
-	// pixel font is a closer match than a 12 pixel font
-	int ptsz =
-	    (int) ( ( ( QPaintDevice::x11AppDpiY() >= 95 ? 17. : 12. ) *
-		      72. / (float) QPaintDevice::x11AppDpiY() ) + 0.5 );
-
-	if ( !qt_app_has_font ) {
-	    QFont f( "Helvetica", ptsz );
-	    QApplication::setFont( f );
-	}
-
-	qt_set_x11_resources( appFont, appFGCol, appBGCol, appBTNCol);
-
 #if defined (QT_TABLET_SUPPORT)
 	int ndev,
 	    i,
@@ -2573,7 +2583,7 @@ void QApplication::setMainWidget( QWidge
   QApplication cursor stack
  *****************************************************************************/
 
-extern void qt_x11_enforce_cursor( QWidget * w, bool unset );
+extern void qt_x11_enforce_cursor( QWidget * w );
 
 typedef QPtrList<QCursor> QCursorList;
 
@@ -2638,7 +2648,8 @@ void QApplication::setOverrideCursor( co
     QWidgetIntDictIt it( *((QWidgetIntDict*)QWidget::mapper) );
     register QWidget *w;
     while ( (w=it.current()) ) {		// for all widgets that have
-	qt_x11_enforce_cursor( w, FALSE );
+	if ( w->testWState( WState_OwnCursor ) )
+	    qt_x11_enforce_cursor( w );
 	++it;
     }
     XFlush( appDpy );				// make X execute it NOW
@@ -2665,7 +2676,8 @@ void QApplication::restoreOverrideCursor
 	QWidgetIntDictIt it( *((QWidgetIntDict*)QWidget::mapper) );
 	register QWidget *w;
 	while ( (w=it.current()) ) {		// set back to original cursors
-	    qt_x11_enforce_cursor( w, FALSE );
+	    if ( w->testWState( WState_OwnCursor ) )
+		qt_x11_enforce_cursor( w );
 	    ++it;
 	}
 	XFlush( appDpy );
