]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/threadgui.inc
Some compile warnings removed; file selector prototypes put in each filedlg.h;
[wxWidgets.git] / src / gtk / threadgui.inc
CommitLineData
7c351dad
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: threadgui.inc
3// Purpose: GUI thread manager for GTK
4// Author: Original from Wolfram Gloger/Guilhem Lavaux
5// Modified by:
6// Created: 04/22/98
7// RCS-ID: $Id$
8// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include <stdio.h>
13#include <unistd.h>
14
15// for select()
16#include <sys/time.h>
17#include <sys/types.h>
18#ifdef __sgi
19#include <bstring.h>
20#endif
21
22#include <gdk/gdk.h>
23
7c351dad
GL
24/////////////////////////////////////////////////////////////////////////////
25// Static variables
26/////////////////////////////////////////////////////////////////////////////
27
28static int p_thrd_pipe[2] = { -1, -1 };
29// WorkProc in GTK
30static gint p_thrd_inid;
31
32#define THREAD_SEND_EXIT_MSG(ptr) write(p_thrd_pipe[1], &ptr, sizeof(ptr));
33
34static void
35ThreadExitProc(gpointer WXUNUSED(client), gint fid,
36 GdkInputCondition WXUNUSED(cond))
37{
f3855ef0
RR
38 wxThread* ptr;
39
40 // printf( "thread exit proc.\n" );
41
42 if (fid != p_thrd_pipe[0])
43 return;
44
45 if (read(fid, &ptr, sizeof(ptr)) == sizeof(ptr))
46 {
47 // printf( "calling OnExit %p\n", ptr);
48 ptr->OnExit();
49 }
50 else
51 {
52 // printf( "this should never happen\n" );
53 }
7c351dad
GL
54}
55
56// Global initialization
b89156b5 57static void wxThreadGuiInit()
7c351dad
GL
58{
59 pipe(p_thrd_pipe);
60 p_thrd_inid = gdk_input_add(p_thrd_pipe[0], GDK_INPUT_READ,
61 ThreadExitProc, 0);
62}
63
64// Global cleanup
b89156b5 65static void wxThreadGuiExit()
7c351dad
GL
66{
67 gdk_input_remove(p_thrd_inid);
68 close(p_thrd_pipe[0]);
69 close(p_thrd_pipe[1]);
70}
75ed1d15 71
75ed1d15
GL
72void wxMutexGuiEnter()
73{
015ee844 74 gs_mutexGui->Lock();
75ed1d15
GL
75}
76
77void wxMutexGuiLeave()
78{
015ee844 79 gs_mutexGui->Unlock();
75ed1d15 80}