]> git.saurik.com Git - wxWidgets.git/blame - include/wx/unix/app.h
Implement monitoring of file descriptors in wxMotif event loop.
[wxWidgets.git] / include / wx / unix / app.h
CommitLineData
b46b1d59
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/unix/app.h
3// Purpose: wxAppConsole implementation for Unix
4// Author: Lukasz Michalski
5// Created: 28/01/2005
6// RCS-ID: $Id$
7// Copyright: (c) Lukasz Michalski
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
eca47740
SN
11//Ensure that sigset_t is being defined
12#include <signal.h>
13
d5ab427f
VZ
14class wxFDIODispatcher;
15class wxFDIOHandler;
16class wxWakeUpPipe;
17
b46b1d59 18// wxApp subclass implementing event processing for console applications
e0954e72 19class WXDLLIMPEXP_BASE wxAppConsole : public wxAppConsoleBase
b46b1d59
VZ
20{
21public:
d5ab427f
VZ
22 wxAppConsole();
23 virtual ~wxAppConsole();
24
b46b1d59
VZ
25 // override base class initialization
26 virtual bool Initialize(int& argc, wxChar** argv);
27
28
29 // Unix-specific: Unix signal handling
30 // -----------------------------------
31
32 // type of the function which can be registered as signal handler: notice
33 // that it isn't really a signal handler, i.e. it's not subject to the
34 // usual signal handlers constraints, because it is called later from
35 // CheckSignal() and not when the signal really occurs
36 typedef void (*SignalHandler)(int);
37
38 // Set signal handler for the given signal, SIG_DFL or SIG_IGN can be used
39 // instead of a function pointer
40 //
41 // Return true if handler was installed, false on error
42 bool SetSignalHandler(int signal, SignalHandler handler);
43
44 // Check if any Unix signals arrived since the last call and execute
45 // handlers for them
46 void CheckSignal();
47
d5ab427f
VZ
48 // Register the signal wake up pipe with the given dispatcher.
49 //
821d856a 50 // This is used by wxExecute(wxEXEC_NOEVENTS) implementation only.
d5ab427f
VZ
51 //
52 // The pointer to the handler used for processing events on this descriptor
53 // is returned so that it can be deleted when we no longer needed it.
54 wxFDIOHandler* RegisterSignalWakeUpPipe(wxFDIODispatcher& dispatcher);
55
b46b1d59
VZ
56private:
57 // signal handler set up by SetSignalHandler() for all signals we handle,
58 // it just adds the signal to m_signalsCaught -- the real processing is
59 // done later, when CheckSignal() is called
60 static void HandleSignal(int signal);
61
62
63 // signals for which HandleSignal() had been called (reset from
64 // CheckSignal())
65 sigset_t m_signalsCaught;
66
67 // the signal handlers
68 WX_DECLARE_HASH_MAP(int, SignalHandler, wxIntegerHash, wxIntegerEqual, SignalHandlerHash);
69 SignalHandlerHash m_signalHandlerHash;
d5ab427f
VZ
70
71 // pipe used for wake up signal handling: if a signal arrives while we're
72 // blocking for input, writing to this pipe triggers a call to our CheckSignal()
73 wxWakeUpPipe *m_signalWakeUpPipe;
b46b1d59 74};