]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/sockgtk.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/sockgtk.cpp
3 // Purpose: implementation of wxGTK-specific socket event handling
4 // Author: Guilhem Lavaux, Vadim Zeitlin
6 // Copyright: (c) 1999, 2007 wxWidgets dev team
7 // (c) 2009 Vadim Zeitlin
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #if wxUSE_SOCKETS && defined(__UNIX__)
16 #include "wx/apptrait.h"
17 #include "wx/private/fdiomanager.h"
22 static gboolean
wxSocket_Input(GIOChannel
*, GIOCondition condition
, gpointer data
)
24 wxFDIOHandler
* const handler
= static_cast<wxFDIOHandler
*>(data
);
26 if (condition
& G_IO_IN
)
28 handler
->OnReadWaiting();
30 // we could have lost connection while reading in which case we
31 // shouldn't call OnWriteWaiting() as the socket is now closed and it
33 if ( !handler
->IsOk() )
37 if (condition
& G_IO_OUT
)
38 handler
->OnWriteWaiting();
44 class GTKFDIOManager
: public wxFDIOManager
47 virtual int AddInput(wxFDIOHandler
*handler
, int fd
, Direction d
)
49 return g_io_add_watch(
50 g_io_channel_unix_new(fd
),
51 d
== OUTPUT
? G_IO_OUT
: G_IO_IN
,
57 RemoveInput(wxFDIOHandler
* WXUNUSED(handler
), int fd
, Direction
WXUNUSED(d
))
63 wxFDIOManager
*wxGUIAppTraits::GetFDIOManager()
65 static GTKFDIOManager s_manager
;
69 #endif // wxUSE_SOCKETS && __UNIX__