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