-// -------------------------------------------------------------------------
-// Project: GSocket (Generic Socket) for WX
-// Name: gsockmot.cpp
-// Purpose: GSocket: Motif part
-// CVSID: $Id$
-// Log: $Log$
-// Log: Revision 1.1 1999/07/23 17:24:24 GL
-// Log: Added GSocket motif (it compiles but I didn't tested it)
-// Log: Changed wxSockFlags type (switched to int)
-// Log:
-// -------------------------------------------------------------------------
-#include <stdlib.h>
-#include <X11/Intrinsic.h>
-#include <wx/gsocket.h>
-#include <wx/app.h>
-#include "../unix/gsockunx.h"
-
-#define wxAPP_CONTEXT ((XtAppContext)wxTheApp->GetAppContext())
-
-static void _GSocket_Motif_Input(XtPointer data, int *fid,
- XtInputId *id)
-{
- GSocket *socket = (GSocket *)data;
-
- _GSocket_Detected_Read(socket);
-}
-
-static void _GSocket_Motif_Output(XtPointer data, int *fid,
- XtInputId *id)
+///////////////////////////////////////////////////////////////////////////////
+// Name: motif/gsockmot.cpp
+// Purpose: implementation of wxMotif-specific socket event handling
+// Author: Guilhem Lavaux, Vadim Zeitlin
+// Created: 1999
+// RCS-ID: $Id$
+// Copyright: (c) 1999, 2007 wxWidgets dev team
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if wxUSE_SOCKETS
+
+#include <X11/Intrinsic.h> // XtAppAdd/RemoveInput()
+#include "wx/motif/private.h" // wxGetAppContext()
+#include "wx/gsocket.h"
+#include "wx/apptrait.h"
+
+extern "C" {
+
+static void _GSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid),
+ XtInputId *WXUNUSED(id))