]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/sockgtk.cpp
Ensure that message boxes with only "OK" can be closed with Escape in wxMSW.
[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 #include "wx/wxprec.h"
14
15 #if wxUSE_SOCKETS
16
17 #include <gdk/gdk.h>
18 #include <glib.h>
19
20 #include "wx/apptrait.h"
21 #include "wx/private/fdiomanager.h"
22
23 extern "C" {
24 static
25 void wxSocket_GDK_Input(gpointer data,
26 gint WXUNUSED(source),
27 GdkInputCondition condition)
28 {
29 wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data);
30
31 if ( condition & GDK_INPUT_READ )
32 {
33 handler->OnReadWaiting();
34
35 // we could have lost connection while reading in which case we
36 // shouldn't call OnWriteWaiting() as the socket is now closed and it
37 // would assert
38 if ( !handler->IsOk() )
39 return;
40 }
41
42 if ( condition & GDK_INPUT_WRITE )
43 handler->OnWriteWaiting();
44 }
45 }
46
47 class GTKFDIOManager : public wxFDIOManager
48 {
49 public:
50 virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d)
51 {
52 return gdk_input_add
53 (
54 fd,
55 d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
56 wxSocket_GDK_Input,
57 handler
58 );
59 }
60
61 virtual void
62 RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d))
63 {
64 gdk_input_remove(fd);
65 }
66 };
67
68 wxFDIOManager *wxGUIAppTraits::GetFDIOManager()
69 {
70 static GTKFDIOManager s_manager;
71 return &s_manager;
72 }
73
74 #endif // wxUSE_SOCKETS