update ooo310-m15
[ooovba.git] / applied_patches / 0550-kde4-plugin-detection.diff
blob7b71fb8543727f38bfac28936c7627e456dbdb25
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
14 +enum {
15 + DESKTOP_NONE = 0,
16 + DESKTOP_UNKNOWN,
17 + DESKTOP_GNOME,
18 + DESKTOP_KDE,
19 + DESKTOP_KDE4,
20 + DESKTOP_CDE
21 +};
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 )
35 - OUString aRet;
36 + int nRet = 0;
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 );
44 + if( nFullSession )
46 - XLIB_Window aCheckWin = None;
47 + if( !nKDEVersion )
48 + return 3;
50 Atom aRealType = None;
51 int nFormat = 8;
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 ),
57 - nWmCheck,
58 + nKDEVersion,
59 0, 1,
60 False,
61 - XA_WINDOW,
62 + AnyPropertyType,
63 &aRealType,
64 &nFormat,
65 &nItems,
66 &nBytesLeft,
67 &pProperty );
68 - if( aRealType == XA_WINDOW && nFormat == 32 && nItems != 0 )
69 - aCheckWin = *(XLIB_Window*)pProperty;
70 + if( !WasXError() && nItems != 0 && pProperty )
71 + {
72 + nRet = *reinterpret_cast< sal_Int32* >( pProperty );
73 + }
74 if( pProperty )
76 XFree( pProperty );
77 pProperty = NULL;
80 - // see if that window really exists and has the check property set
81 - if( aCheckWin != None )
82 - {
83 - // clear error flag
84 - WasXError();
85 - // get the property
86 - XGetWindowProperty( pDisplay,
87 - aCheckWin,
88 - nWmCheck,
89 - 0, 1,
90 - False,
91 - XA_WINDOW,
92 - &aRealType,
93 - &nFormat,
94 - &nItems,
95 - &nBytesLeft,
96 - &pProperty );
97 - if( ! WasXError() && aRealType == XA_WINDOW && nFormat == 32 && nItems != 0 && pProperty )
98 - {
99 - if( aCheckWin == *(XLIB_Window*)pProperty )
101 - XFree( pProperty );
102 - pProperty = NULL;
103 - XGetWindowProperty( pDisplay,
104 - aCheckWin,
105 - nWmName,
106 - 0, 256,
107 - False,
108 - AnyPropertyType,
109 - &aRealType,
110 - &nFormat,
111 - &nItems,
112 - &nBytesLeft,
113 - &pProperty );
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 );
120 - else
121 - aRet = rtl::OStringToOUString( rtl::OString( (sal_Char*)pProperty ), RTL_TEXTENCODING_UTF8 );
125 - if( pProperty )
127 - XFree( pProperty );
128 - pProperty = NULL;
132 - return aRet;
133 + return nRet;
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 ) )
149 + return true;
153 + if ( KDEVersion( pDisplay ) == 3 )
154 return true;
156 - // check for kwin
157 - rtl::OUString aWM = getNetWMName( pDisplay );
158 - if( aWM.equalsIgnoreAsciiCaseAscii( "KWin" ) )
160 + return false;
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 ) )
171 + return true;
174 + if ( KDEVersion( pDisplay ) == 4 )
175 return true;
178 return false;
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()
202 pRet = "gtk";
203 else if( desktop == desktop_strings[DESKTOP_KDE] )
204 pRet = "kde";
205 + else if( desktop == desktop_strings[DESKTOP_KDE4] )
206 + pRet = "kde4";
207 else
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)
221 SHL5STDLIBS+=\
222 $(VCLLIB) \
223 @@ -404,6 +404,35 @@ SHL5STDLIBS+= $(XRANDR_LIBS)
225 .ENDIF # "$(ENABLE_KDE)" != ""
227 +# KDE4 plugin
228 +.IF "$(ENABLE_KDE4)" != ""
229 +.IF "$(KDE4_ROOT)"!=""
230 +EXTRALIBPATHS+=-L$(KDE4_ROOT)$/lib
231 +.ENDIF
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)
241 +SHL6STDLIBS+=\
242 + $(VCLLIB) \
243 + $(PSPLIB) \
244 + $(TOOLSLIB) \
245 + $(VOSLIB) \
246 + $(SALLIB)
248 +.IF "$(ENABLE_RANDR)" != ""
249 +.IF "$(XRANDR_DLOPEN)" == "FALSE"
250 +SHL6STDLIBS+= $(XRANDR_LIBS)
251 +.ENDIF
252 +.ENDIF
254 +.ENDIF # "$(ENABLE_KDE4)" != ""
256 .ENDIF # UNX
258 # --- Allgemein ----------------------------------------------------------