@@ -17,7 +17,8 @@ typedef enum DEHint
1717 FF_DE_HINT_UNKNOWN = 0 ,
1818 FF_DE_HINT_PLASMA ,
1919 FF_DE_HINT_GNOME ,
20- FF_DE_HINT_CINNAMON
20+ FF_DE_HINT_CINNAMON ,
21+ FF_DE_HINT_XFCE4
2122} DEHint ;
2223
2324typedef struct ProcData
@@ -114,7 +115,7 @@ static bool applyPrettyNameIfWM(FFWMDEResult* result, const FFstrbuf* processNam
114115 }
115116 else if (ffStrbufIgnCaseCompS (processName , "xfwm4" ) == 0 )
116117 {
117- ffStrbufSetS (& result -> wmPrettyName , "XFWM " );
118+ ffStrbufSetS (& result -> wmPrettyName , "Xfwm4 " );
118119 * protocolHint = FF_PROTOCOL_HINT_X11 ;
119120 }
120121 else if (ffStrbufIgnCaseCompS (processName , "gnome-session-binary" ) == 0 )
@@ -139,6 +140,8 @@ static bool applyDEHintIfDE(const FFstrbuf* processName, DEHint* deHint)
139140 * deHint = FF_DE_HINT_GNOME ;
140141 else if (ffStrbufIgnCaseCompS (processName , "cinnamon" ) == 0 )
141142 * deHint = FF_DE_HINT_CINNAMON ;
143+ else if (ffStrbufIgnCaseCompS (processName , "xfce4-session" ) == 0 )
144+ * deHint = FF_DE_HINT_XFCE4 ;
142145
143146 return * deHint != FF_DE_HINT_UNKNOWN ;
144147}
@@ -224,7 +227,30 @@ static void getCinnamon(FFWMDEResult* result)
224227 ffStrbufRecalculateLength (& result -> deVersion );
225228}
226229
227- static inline void getDEFromHint (FFWMDEResult * result , ProcData * procData )
230+ static void getXFCE4 (FFinstance * instance , FFWMDEResult * result )
231+ {
232+ ffStrbufSetS (& result -> deProcessName , "xfce4-session" );
233+ ffStrbufSetS (& result -> dePrettyName , "Xfce4" );
234+
235+ ffParsePropFile ("/usr/share/gtk-doc/html/libxfce4ui/index.html" , "<div><p class=\"releaseinfo\">Version %[^\n]" , result -> deVersion .chars );
236+ ffStrbufRecalculateLength (& result -> deVersion );
237+
238+ if (result -> deVersion .length == 0 && instance -> config .allowSlowOperations )
239+ {
240+ //This is really, really slow. Thank you, XFCE developers
241+ ffProcessAppendStdOut (& result -> deVersion , (char * const []){
242+ "xfce4-session" ,
243+ "--version" ,
244+ NULL
245+ });
246+
247+ ffStrbufSubstrBeforeFirstC (& result -> deVersion , '(' );
248+ ffStrbufSubstrAfterFirstC (& result -> deVersion , ' ' );
249+ ffStrbufTrim (& result -> deVersion , ' ' );
250+ }
251+ }
252+
253+ static inline void getDEFromHint (FFinstance * instance , FFWMDEResult * result , ProcData * procData )
228254{
229255 getFromProcDir (result , procData , false);
230256
@@ -237,9 +263,11 @@ static inline void getDEFromHint(FFWMDEResult* result, ProcData* procData)
237263 getGnome (result );
238264 else if (procData -> deHint == FF_DE_HINT_CINNAMON )
239265 getCinnamon (result );
266+ else if (procData -> deHint == FF_DE_HINT_XFCE4 )
267+ getXFCE4 (instance , result );
240268}
241269
242- static inline void getDE (FFWMDEResult * result , ProcData * procData )
270+ static inline void getDE (FFinstance * instance , FFWMDEResult * result , ProcData * procData )
243271{
244272 // if sessionDesktop is not set or sessionDesktiop == WM, try finding DE via /proc
245273 if (
@@ -248,7 +276,7 @@ static inline void getDE(FFWMDEResult* result, ProcData* procData)
248276 ffStrbufIgnCaseCompS (& result -> wmProcessName , result -> sessionDesktop ) == 0 ||
249277 ffStrbufIgnCaseCompS (& result -> wmPrettyName , result -> sessionDesktop ) == 0
250278 ) {
251- getDEFromHint (result , procData );
279+ getDEFromHint (instance , result , procData );
252280 return ;
253281 }
254282
@@ -258,6 +286,8 @@ static inline void getDE(FFWMDEResult* result, ProcData* procData)
258286 getGnome (result );
259287 else if (strcasecmp (result -> sessionDesktop , "X-Cinnamon" ) == 0 || strcasecmp (result -> sessionDesktop , "Cinnamon" ) == 0 )
260288 getCinnamon (result );
289+ else if (strcasecmp (result -> sessionDesktop , "XFCE" ) == 0 || strcasecmp (result -> sessionDesktop , "X-XFCE" ) == 0 || strcasecmp (result -> sessionDesktop , "XFCE4" ) == 0 || strcasecmp (result -> sessionDesktop , "X-XFCE4" ) == 0 )
290+ getXFCE4 (instance , result );
261291 else
262292 {
263293 ffStrbufSetS (& result -> deProcessName , result -> sessionDesktop );
@@ -304,7 +334,7 @@ static inline void getSessionType(FFWMDEResult* result, ProtocolHint protocolHin
304334 getSessionTypeFallback (result , protocolHint );
305335}
306336
307- static inline void getWMDE (FFWMDEResult * result )
337+ static inline void getWMDE (FFinstance * instance , FFWMDEResult * result )
308338{
309339 ProcData procData ;
310340 procData .proc = opendir ("/proc" );
@@ -314,7 +344,7 @@ static inline void getWMDE(FFWMDEResult* result)
314344
315345 getSessionDesktop (result );
316346 getWM (result , & procData );
317- getDE (result , & procData );
347+ getDE (instance , result , & procData );
318348
319349 if (result -> wmProtocolName .length == 0 && procData .protocolHint != FF_PROTOCOL_HINT_UNKNOWN )
320350 getSessionTypeFallback (result , procData .protocolHint );
@@ -325,8 +355,6 @@ static inline void getWMDE(FFWMDEResult* result)
325355
326356const FFWMDEResult * ffDetectWMDE (FFinstance * instance )
327357{
328- UNUSED (instance );
329-
330358 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER ;
331359 static FFWMDEResult result ;
332360 static bool init = false;
@@ -349,7 +377,7 @@ const FFWMDEResult* ffDetectWMDE(FFinstance* instance)
349377
350378 //Don't run anyting when on TTY. This prevents us to catch process from other users in at least that case.
351379 if (ffStrbufIgnCaseCompS (& result .wmProtocolName , "TTY" ) != 0 )
352- getWMDE (& result );
380+ getWMDE (instance , & result );
353381
354382 pthread_mutex_unlock (& mutex );
355383
0 commit comments