1 diff --git vcl/unx/source/plugadapt/salplug.cxx vcl/unx/source/plugadapt/salplug.cxx
2 index e33d05d..a3b60ba 100644
3 --- vcl/unx/source/plugadapt/salplug.cxx
4 +++ vcl/unx/source/plugadapt/salplug.cxx
5 @@ -55,13 +55,16 @@ typedef SalInstance*(*salFactoryProc)( oslModule pModule);
7 static oslModule pCloseModule = NULL;
9 -#define DESKTOP_NONE 0
10 -#define DESKTOP_UNKNOWN 1
11 -#define DESKTOP_GNOME 2
12 -#define DESKTOP_KDE 3
13 -#define DESKTOP_CDE 4
23 -static const char * desktop_strings[5] = { "none", "unknown", "GNOME", "KDE", "CDE" };
24 +static const char * desktop_strings[] = { "none", "unknown", "GNOME", "KDE", "KDE4", "CDE" };
26 static SalInstance* tryInstance( const OUString& rModuleBase )
28 @@ -214,15 +217,18 @@ extern "C"
29 typedef int(* XErrorHandler)(Display*,XErrorEvent*);
32 -static OUString getNetWMName( Display* pDisplay )
33 +static int KDEVersion( Display* pDisplay )
38 - Atom nWmCheck = XInternAtom( pDisplay, "_NET_SUPPORTING_WM_CHECK", True );
39 - Atom nWmName = XInternAtom( pDisplay, "_NET_WM_NAME", True );
40 - if( nWmName && nWmCheck )
41 + Atom nFullSession = XInternAtom( pDisplay, "KDE_FULL_SESSION", True );
42 + Atom nKDEVersion = XInternAtom( pDisplay, "KDE_SESSION_VERSION", True );
46 - XLIB_Window aCheckWin = None;
50 Atom aRealType = None;
52 unsigned long nItems = 0;
53 @@ -230,88 +236,65 @@ static OUString getNetWMName( Display* pDisplay )
54 unsigned char* pProperty = NULL;
55 XGetWindowProperty( pDisplay,
56 DefaultRootWindow( pDisplay ),
68 - if( aRealType == XA_WINDOW && nFormat == 32 && nItems != 0 )
69 - aCheckWin = *(XLIB_Window*)pProperty;
70 + if( !WasXError() && nItems != 0 && pProperty )
72 + nRet = *reinterpret_cast< sal_Int32* >( pProperty );
80 - // see if that window really exists and has the check property set
81 - if( aCheckWin != None )
86 - XGetWindowProperty( pDisplay,
97 - if( ! WasXError() && aRealType == XA_WINDOW && nFormat == 32 && nItems != 0 && pProperty )
99 - if( aCheckWin == *(XLIB_Window*)pProperty )
101 - XFree( pProperty );
103 - XGetWindowProperty( pDisplay,
114 - if( !WasXError() && nItems != 0 && pProperty && *pProperty )
116 - if( aRealType == XA_STRING ) // some WM's use this although the should use UTF8_STRING
118 - aRet = rtl::OStringToOUString( rtl::OString( (sal_Char*)pProperty ), RTL_TEXTENCODING_ISO_8859_1 );
121 - aRet = rtl::OStringToOUString( rtl::OString( (sal_Char*)pProperty ), RTL_TEXTENCODING_UTF8 );
127 - XFree( pProperty );
136 static bool is_kde_desktop( Display* pDisplay )
138 if ( NULL != getenv( "KDE_FULL_SESSION" ) )
140 + const char *pVer = getenv( "KDE_SESSION_VERSION" );
141 + if ( !pVer || pVer[0] == '0' )
143 + return true; // does not exist => KDE3
146 + rtl::OUString aVer( RTL_CONSTASCII_USTRINGPARAM( "3" ) );
147 + if ( aVer.equalsIgnoreAsciiCaseAscii( pVer ) )
153 + if ( KDEVersion( pDisplay ) == 3 )
157 - rtl::OUString aWM = getNetWMName( pDisplay );
158 - if( aWM.equalsIgnoreAsciiCaseAscii( "KWin" ) )
163 +static bool is_kde4_desktop( Display* pDisplay )
165 + if ( NULL != getenv( "KDE_FULL_SESSION" ) )
167 + rtl::OUString aVer( RTL_CONSTASCII_USTRINGPARAM( "4" ) );
169 + const char *pVer = getenv( "KDE_SESSION_VERSION" );
170 + if ( pVer && aVer.equalsIgnoreAsciiCaseAscii( pVer ) )
174 + if ( KDEVersion( pDisplay ) == 4 )
181 @@ -344,6 +327,8 @@ static const char * get_desktop_environment()
182 pRet = desktop_strings[DESKTOP_CDE];
183 if ( aOver.equalsIgnoreAsciiCase( "kde" ) )
184 pRet = desktop_strings[DESKTOP_KDE];
185 + if ( aOver.equalsIgnoreAsciiCase( "kde4" ) )
186 + pRet = desktop_strings[DESKTOP_KDE4];
187 if ( aOver.equalsIgnoreAsciiCase( "gnome" ) )
188 pRet = desktop_strings[DESKTOP_GNOME];
189 if ( aOver.equalsIgnoreAsciiCase( "none" ) )
190 @@ -384,7 +369,9 @@ static const char * get_desktop_environment()
192 XErrorHandler pOldHdl = XSetErrorHandler( autodect_error_handler );
194 - if ( is_kde_desktop( pDisplay ) )
195 + if ( is_kde4_desktop( pDisplay ) )
196 + pRet = desktop_strings[DESKTOP_KDE4];
197 + else if ( is_kde_desktop( pDisplay ) )
198 pRet = desktop_strings[DESKTOP_KDE];
199 else if ( is_gnome_desktop( pDisplay ) )
200 pRet = desktop_strings[DESKTOP_GNOME];
201 @@ -417,6 +404,8 @@ static const char* autodetect_plugin()
203 else if( desktop == desktop_strings[DESKTOP_KDE] )
205 + else if( desktop == desktop_strings[DESKTOP_KDE4] )
209 // #i95296# use the much nicer looking gtk plugin
210 diff --git vcl/util/makefile.mk vcl/util/makefile.mk
211 index f41aae8..a842fa9 100644
212 --- vcl/util/makefile.mk
213 +++ vcl/util/makefile.mk
214 @@ -387,7 +387,7 @@ SHL5IMPLIB=ikde_plug_
215 SHL5LIBS=$(LIB5TARGET)
216 SHL5DEPN=$(SHL2TARGETN)
217 # libs for KDE plugin
218 -SHL5STDLIBS=$(KDE_LIBS)
219 +SHL5LINKFLAGS+=$(KDE_LIBS)
220 SHL5STDLIBS+=-l$(SHL2TARGET)
223 @@ -404,6 +404,35 @@ SHL5STDLIBS+= $(XRANDR_LIBS)
225 .ENDIF # "$(ENABLE_KDE)" != ""
228 +.IF "$(ENABLE_KDE4)" != ""
229 +.IF "$(KDE4_ROOT)"!=""
230 +EXTRALIBPATHS+=-L$(KDE4_ROOT)$/lib
232 +LIB6TARGET=$(SLB)$/ikde4_plug_
233 +LIB6FILES=$(SLB)$/kde4plug.lib
234 +SHL6TARGET=vclplug_kde4$(DLLPOSTFIX)
235 +SHL6IMPLIB=ikde4_plug_
236 +SHL6LIBS=$(LIB6TARGET)
237 +SHL6DEPN=$(SHL2TARGETN)
238 +# libs for KDE4 plugin
239 +SHL6LINKFLAGS+=$(KDE4_LIBS)
240 +SHL6STDLIBS+=-l$(SHL2TARGET)
248 +.IF "$(ENABLE_RANDR)" != ""
249 +.IF "$(XRANDR_DLOPEN)" == "FALSE"
250 +SHL6STDLIBS+= $(XRANDR_LIBS)
254 +.ENDIF # "$(ENABLE_KDE4)" != ""
258 # --- Allgemein ----------------------------------------------------------