GThread usage in the panel

Benedikt Meurer benedikt.meurer at
Sat Jul 24 19:35:31 CEST 2004

Jasper Huijsmans wrote:
> Hey all, especially plugin writers,
> Yesterday, I committed a patch from Brian that adds thread 
> initialization and locking to the panel.
> I had hoped that this would not affect anything that wasn't using 
> threads, but it seems this is not the case: idle or timeout functions 
> need to use gdk_thread_enter (); ...; gdk_thread_leave(); to make sure 
> there is no conflict with other threads accessing gtk.
> Since there are currently no plugins using threads, this problem won't 
> show up yet, but it will when e.g. the menu plugin starts using threads.
> If you implement this you can depend on the panel version 4.1.7.

To easy the transition, I added some magic to the XFCE_PANEL_PLUGIN m4 
macro. It now tests if the panel is threaded and if so, it defines 
XFCE_PANEL_THREADED=1 and sets XFCE_PANEL_LOCK to gdk_threads_enter and 
XFCE_PANEL_UNLOCK to gdk_threads_leave. If the panel isn't threaded, 
XFCE_PANEL_THREADED won't be defined and XFCE_PANEL_(UN)LOCK will be no-ops.

So, for panel plugin writers:

1) get the latest depends.m4 from Xfce CVS (I've already updated the 
depends.m4 files in berlios CVS, so if your plugin is hosted at the 
xfce-goodies project, you don't need this step)

2) Locate idle/timeout functions and place XFCE_PANEL_LOCK() at the 
beginning of the function and XFCE_PANEL_UNLOCK() at the end of the 
function (_before_ the return of course :-).

>     Jasper


More information about the Xfce4-dev mailing list