]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/sockgtk.cpp
Add missing WXK constants for the control keys
[wxWidgets.git] / src / gtk1 / sockgtk.cpp
CommitLineData
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
6// RCS-ID: $Id$
7// Copyright: (c) 1999, 2007 wxWidgets dev team
6bcc1145 8// (c) 2009 Vadim Zeitlin
2804f77d
VZ
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
9b5f1895 12// For compilers that support precompilation, includes "wx.h".
eec4d3f5 13
5223261d 14#if defined( __VMS ) && defined( __ia64 )
eec4d3f5
JJ
15// Work around for a bug in the C++ compiler on OpenVMS IA64
16# include <time.h>
17#endif
18
9b5f1895 19#include "wx/wxprec.h"
180f9714
DE
20
21#if wxUSE_SOCKETS
22
180f9714
DE
23#include <gdk/gdk.h>
24#include <glib.h>
25
2804f77d 26#include "wx/apptrait.h"
6bcc1145 27#include "wx/private/fdiomanager.h"
180f9714 28
865bb325
VZ
29extern "C" {
30static
51fe4b60 31void wxSocket_GDK_Input(gpointer data,
89954433 32 gint WXUNUSED(source),
180f9714
DE
33 GdkInputCondition condition)
34{
6bcc1145 35 wxFDIOHandler * const handler = static_cast<wxFDIOHandler *>(data);
180f9714 36
a9d859df 37 if ( condition & GDK_INPUT_READ )
ee0995b0 38 {
a9d859df 39 handler->OnReadWaiting();
ee0995b0
VZ
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
251e98cb 44 if ( !handler->IsOk() )
ee0995b0
VZ
45 return;
46 }
47
a9d859df
VZ
48 if ( condition & GDK_INPUT_WRITE )
49 handler->OnWriteWaiting();
180f9714 50}
865bb325 51}
180f9714 52
6bcc1145 53class GTKFDIOManager : public wxFDIOManager
180f9714 54{
2804f77d 55public:
6bcc1145 56 virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d)
2804f77d
VZ
57 {
58 return gdk_input_add
59 (
a9d859df 60 fd,
6bcc1145 61 d == OUTPUT ? GDK_INPUT_WRITE : GDK_INPUT_READ,
51fe4b60 62 wxSocket_GDK_Input,
a9d859df 63 handler
2804f77d
VZ
64 );
65 }
66
6bcc1145
VZ
67 virtual void
68 RemoveInput(wxFDIOHandler* WXUNUSED(handler), int fd, Direction WXUNUSED(d))
2804f77d
VZ
69 {
70 gdk_input_remove(fd);
71 }
72};
73
6bcc1145 74wxFDIOManager *wxGUIAppTraits::GetFDIOManager()
180f9714 75{
6bcc1145 76 static GTKFDIOManager s_manager;
2804f77d 77 return &s_manager;
180f9714
DE
78}
79
2804f77d 80#endif // wxUSE_SOCKETS