]>
Commit | Line | Data |
---|---|---|
2804f77d | 1 | /////////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: src/motif/sockmot.cpp |
2804f77d VZ |
3 | // Purpose: implementation of wxMotif-specific socket event handling |
4 | // Author: Guilhem Lavaux, Vadim Zeitlin | |
5 | // Created: 1999 | |
2804f77d VZ |
6 | // Copyright: (c) 1999, 2007 wxWidgets dev team |
7 | // Licence: wxWindows licence | |
8 | /////////////////////////////////////////////////////////////////////////////// | |
793ba541 | 9 | |
355b4d3d WS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
793ba541 DE |
12 | |
13 | #if wxUSE_SOCKETS | |
14 | ||
2804f77d VZ |
15 | #include <X11/Intrinsic.h> // XtAppAdd/RemoveInput() |
16 | #include "wx/motif/private.h" // wxGetAppContext() | |
6bcc1145 | 17 | #include "wx/private/fdiomanager.h" |
2804f77d | 18 | #include "wx/apptrait.h" |
793ba541 | 19 | |
2804f77d | 20 | extern "C" { |
793ba541 | 21 | |
51fe4b60 | 22 | static void wxSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid), |
355b4d3d | 23 | XtInputId *WXUNUSED(id)) |
793ba541 | 24 | { |
6bcc1145 | 25 | wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data); |
793ba541 | 26 | |
a9d859df | 27 | handler->OnReadWaiting(); |
793ba541 DE |
28 | } |
29 | ||
51fe4b60 | 30 | static void wxSocket_Motif_Output(XtPointer data, int *WXUNUSED(fid), |
355b4d3d | 31 | XtInputId *WXUNUSED(id)) |
793ba541 | 32 | { |
6bcc1145 | 33 | wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data); |
793ba541 | 34 | |
a9d859df | 35 | handler->OnWriteWaiting(); |
793ba541 DE |
36 | } |
37 | ||
793ba541 DE |
38 | } |
39 | ||
6bcc1145 | 40 | class MotifFDIOManager : public wxFDIOManager |
793ba541 | 41 | { |
2804f77d | 42 | public: |
6bcc1145 | 43 | virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d) |
355b4d3d | 44 | { |
2804f77d VZ |
45 | return XtAppAddInput |
46 | ( | |
47 | wxGetAppContext(), | |
a9d859df | 48 | fd, |
6bcc1145 VZ |
49 | (XtPointer)(d == OUTPUT ? XtInputWriteMask |
50 | : XtInputReadMask), | |
51 | d == OUTPUT ? wxSocket_Motif_Output | |
52 | : wxSocket_Motif_Input, | |
a9d859df | 53 | handler |
2804f77d | 54 | ); |
355b4d3d WS |
55 | } |
56 | ||
6bcc1145 VZ |
57 | virtual void |
58 | RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d)) | |
355b4d3d | 59 | { |
2804f77d | 60 | XtRemoveInput(fd); |
355b4d3d | 61 | } |
2804f77d | 62 | }; |
793ba541 | 63 | |
6bcc1145 | 64 | wxFDIOManager *wxGUIAppTraits::GetFDIOManager() |
793ba541 | 65 | { |
6bcc1145 | 66 | static MotifFDIOManager s_manager; |
2804f77d | 67 | return &s_manager; |
793ba541 DE |
68 | } |
69 | ||
2804f77d | 70 | #endif // wxUSE_SOCKETS |