]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/threadgui.inc
Listctrl updates
[wxWidgets.git] / src / gtk1 / 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{
38 wxThread* ptr;
39
40 if (fid != p_thrd_pipe[0])
41 return;
42 if (read(fid, &ptr, sizeof(ptr)) == sizeof(ptr)) {
43 //fprintf(stderr, "calling OnExit %p\n", ptr);
44 ptr->OnExit();
45 } else {
46 //fprintf(stderr, "this should never happen\n");
47 }
48}
49
50// Global initialization
b89156b5 51static void wxThreadGuiInit()
7c351dad
GL
52{
53 pipe(p_thrd_pipe);
54 p_thrd_inid = gdk_input_add(p_thrd_pipe[0], GDK_INPUT_READ,
55 ThreadExitProc, 0);
56}
57
58// Global cleanup
b89156b5 59static void wxThreadGuiExit()
7c351dad
GL
60{
61 gdk_input_remove(p_thrd_inid);
62 close(p_thrd_pipe[0]);
63 close(p_thrd_pipe[1]);
64}
75ed1d15
GL
65
66#ifdef NO_DEFINE_GDK_1_1
67
68void wxMutexGuiEnter()
69{
70 gdk_mutex_enter();
71}
72
73void wxMutexGuiLeave()
74{
75 gdk_mutex_leave();
76}
77
78#else
79
80void wxMutexGuiEnter()
81{
6773ae19 82 wxMainMutex->Lock();
75ed1d15
GL
83}
84
85void wxMutexGuiLeave()
86{
6773ae19 87 wxMainMutex->Unlock();
75ed1d15
GL
88}
89
90#endif