Mercurial > dwindows
comparison gtk/dw.c @ 1887:09860ba329a4
Divided thread initialization and deinitialization into separate
exported functions so they can be accessed from language bindings.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 09 Sep 2013 19:18:36 +0000 |
parents | f7d408a47752 |
children | ed377fd16360 |
comparison
equal
deleted
inserted
replaced
1886:f7d408a47752 | 1887:09860ba329a4 |
---|---|
1981 XSetWMNormalHints (GDK_DISPLAY(),GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),&sizehints); | 1981 XSetWMNormalHints (GDK_DISPLAY(),GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),&sizehints); |
1982 gdk_flush (); | 1982 gdk_flush (); |
1983 } | 1983 } |
1984 #endif | 1984 #endif |
1985 | 1985 |
1986 void _init_thread(void) | |
1987 { | |
1988 GdkColor *foreground = malloc(sizeof(GdkColor)); | |
1989 | |
1990 foreground->pixel = foreground->red = foreground->green = foreground->blue = 0; | |
1991 pthread_setspecific(_dw_fg_color_key, foreground); | |
1992 pthread_setspecific(_dw_bg_color_key, NULL); | |
1993 } | |
1994 | |
1995 /* Try to load the mozilla embed shared libary */ | 1986 /* Try to load the mozilla embed shared libary */ |
1996 #ifdef USE_GTKMOZEMBED | 1987 #ifdef USE_GTKMOZEMBED |
1997 #include <ctype.h> | 1988 #include <ctype.h> |
1998 | 1989 |
1999 void init_mozembed(void) | 1990 void init_mozembed(void) |
2175 | 2166 |
2176 pthread_key_create(&_dw_fg_color_key, NULL); | 2167 pthread_key_create(&_dw_fg_color_key, NULL); |
2177 pthread_key_create(&_dw_bg_color_key, NULL); | 2168 pthread_key_create(&_dw_bg_color_key, NULL); |
2178 pthread_key_create(&_dw_mutex_key, NULL); | 2169 pthread_key_create(&_dw_mutex_key, NULL); |
2179 | 2170 |
2180 _init_thread(); | 2171 _dw_init_thread(); |
2181 | 2172 |
2182 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); | 2173 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); |
2183 | 2174 |
2184 #ifdef USE_GTKMOZEMBED | 2175 #ifdef USE_GTKMOZEMBED |
2185 init_mozembed(); | 2176 init_mozembed(); |
10104 */ | 10095 */ |
10105 close(GPOINTER_TO_INT(eve)); | 10096 close(GPOINTER_TO_INT(eve)); |
10106 return DW_ERROR_NONE; | 10097 return DW_ERROR_NONE; |
10107 } | 10098 } |
10108 | 10099 |
10109 /* | 10100 /* |
10110 * Setup thread independent color sets. | 10101 * Generally an internal function called from a newly created |
10111 */ | 10102 * thread to setup the Dynamic Windows environment for the thread. |
10112 void _dwthreadstart(void *data) | 10103 * However it is exported so language bindings can call it when |
10113 { | 10104 * they create threads that require access to Dynamic Windows. |
10114 void (*threadfunc)(void *) = NULL; | 10105 */ |
10115 void **tmp = (void **)data; | 10106 void API _dw_init_thread(void) |
10107 { | |
10108 GdkColor *foreground = malloc(sizeof(GdkColor)); | |
10109 | |
10110 foreground->pixel = foreground->red = foreground->green = foreground->blue = 0; | |
10111 pthread_setspecific(_dw_fg_color_key, foreground); | |
10112 pthread_setspecific(_dw_bg_color_key, NULL); | |
10113 } | |
10114 | |
10115 /* | |
10116 * Generally an internal function called from a terminating | |
10117 * thread to cleanup the Dynamic Windows environment for the thread. | |
10118 * However it is exported so language bindings can call it when | |
10119 * they exit threads that require access to Dynamic Windows. | |
10120 */ | |
10121 void API _dw_deinit_thread(void) | |
10122 { | |
10116 GdkColor *foreground, *background; | 10123 GdkColor *foreground, *background; |
10117 | 10124 |
10118 threadfunc = (void (*)(void *))tmp[0]; | |
10119 | |
10120 /* Initialize colors */ | |
10121 _init_thread(); | |
10122 | |
10123 threadfunc(tmp[1]); | |
10124 free(tmp); | |
10125 | |
10126 /* Free colors */ | |
10127 if((foreground = pthread_getspecific(_dw_fg_color_key))) | 10125 if((foreground = pthread_getspecific(_dw_fg_color_key))) |
10128 free(foreground); | 10126 free(foreground); |
10129 if((background = pthread_getspecific(_dw_bg_color_key))) | 10127 if((background = pthread_getspecific(_dw_bg_color_key))) |
10130 free(background); | 10128 free(background); |
10129 } | |
10130 | |
10131 /* | |
10132 * Setup thread independent color sets. | |
10133 */ | |
10134 void _dwthreadstart(void *data) | |
10135 { | |
10136 void (*threadfunc)(void *) = NULL; | |
10137 void **tmp = (void **)data; | |
10138 | |
10139 threadfunc = (void (*)(void *))tmp[0]; | |
10140 | |
10141 /* Initialize colors */ | |
10142 _dw_init_thread(); | |
10143 | |
10144 threadfunc(tmp[1]); | |
10145 free(tmp); | |
10146 | |
10147 /* Free colors */ | |
10148 _dw_deinit_thread(); | |
10131 } | 10149 } |
10132 | 10150 |
10133 /* | 10151 /* |
10134 * Allocates a shared memory region with a name. | 10152 * Allocates a shared memory region with a name. |
10135 * Parameters: | 10153 * Parameters: |