]>
Commit | Line | Data |
---|---|---|
2804f77d | 1 | /////////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: src/gtk1/sockgtk.cpp |
2804f77d VZ |
3 | // Purpose: implementation of wxGTK-specific socket event handling |
4 | // Author: Guilhem Lavaux, Vadim Zeitlin | |
5 | // Created: 1999 | |
2804f77d | 6 | // Copyright: (c) 1999, 2007 wxWidgets dev team |
6bcc1145 | 7 | // (c) 2009 Vadim Zeitlin |
2804f77d VZ |
8 | // Licence: wxWindows licence |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
9b5f1895 | 11 | // For compilers that support precompilation, includes "wx.h". |
eec4d3f5 | 12 | |
5223261d | 13 | #if defined( __VMS ) && defined( __ia64 ) |
eec4d3f5 JJ |
14 | // Work around for a bug in the C++ compiler on OpenVMS IA64 |
15 | # include <time.h> | |
16 | #endif | |
17 | ||
9b5f1895 | 18 | #include "wx/wxprec.h" |
180f9714 DE |
19 | |
20 | #if wxUSE_SOCKETS | |
21 | ||
180f9714 DE |
22 | #include <gdk/gdk.h> |
23 | #include <glib.h> | |
24 | ||
2804f77d | 25 | #include "wx/apptrait.h" |
6bcc1145 | 26 | #include "wx/private/fdiomanager.h" |
180f9714 | 27 | |
865bb325 VZ |
28 | extern "C" { |
29 | static | |
51fe4b60 | 30 | void wxSocket_GDK_Input(gpointer data, |
89954433 | 31 | gint WXUNUSED(source), |
180f9714 DE |
32 | GdkInputCondition condition) |
33 | { | |
6bcc1145 | 34 | wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data); |
180f9714 | 35 | |
a9d859df | 36 | if ( condition & GDK_INPUT_READ ) |
ee0995b0 | 37 | { |
a9d859df | 38 | handler->OnReadWaiting(); |
ee0995b0 VZ |
39 | |
40 | // we could have lost connection while reading in which case we | |
41 | // shouldn't call OnWriteWaiting() as the socket is now closed and it | |
42 | // would assert | |
251e98cb | 43 | if ( !handler->IsOk() ) |
ee0995b0 VZ |
44 | return; |
45 | } | |
46 | ||
a9d859df VZ |
47 | if ( condition & GDK_INPUT_WRITE ) |
48 | handler->OnWriteWaiting(); | |
180f9714 | 49 | } |
865bb325 | 50 | } |
180f9714 | 51 | |
6bcc1145 | 52 | class GTKFDIOManager : public wxFDIOManager |
180f9714 | 53 | { |
2804f77d | 54 | public: |
6bcc1145 | 55 | virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d) |
2804f77d VZ |
56 | { |
57 | return gdk_input_add | |
58 | ( | |
a9d859df | 59 | fd, |
6bcc1145 | 60 | d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ, |
51fe4b60 | 61 | wxSocket_GDK_Input, |
a9d859df | 62 | handler |
2804f77d VZ |
63 | ); |
64 | } | |
65 | ||
6bcc1145 VZ |
66 | virtual void |
67 | RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d)) | |
2804f77d VZ |
68 | { |
69 | gdk_input_remove(fd); | |
70 | } | |
71 | }; | |
72 | ||
6bcc1145 | 73 | wxFDIOManager *wxGUIAppTraits::GetFDIOManager() |
180f9714 | 74 | { |
6bcc1145 | 75 | static GTKFDIOManager s_manager; |
2804f77d | 76 | return &s_manager; |
180f9714 DE |
77 | } |
78 | ||
2804f77d | 79 | #endif // wxUSE_SOCKETS |