/* -------------------------------------------------------------------------
* Project: GSocket (Generic Socket) for WX
* Name: gsockmot.c
- * Purpose: GSocket: Motif part
+ * Purpose: GSocket: X11 part
+ * Licence: The wxWindows licence
* CVSID: $Id$
* ------------------------------------------------------------------------- */
#if wxUSE_SOCKETS
#include <stdlib.h>
-#include <X11/Intrinsic.h>
#include "wx/gsocket.h"
#include "wx/unix/gsockunx.h"
-extern XtAppContext wxGetAppContext();
+/*
+ * FIXME: have these in a common header instead of being repeated
+ * in evtloop.cpp and gsockx11.c
+ */
-static void _GSocket_Motif_Input(XtPointer data, int *fid,
- XtInputId *id)
+typedef void (*wxSocketCallback) (int fd, void* data);
+
+typedef enum
+{ wxSocketTableInput, wxSocketTableOutput } wxSocketTableType ;
+
+void wxRegisterSocketCallback(int fd, wxSocketTableType socketType, wxSocketCallback cback, void* data);
+void wxUnregisterSocketCallback(int fd, wxSocketTableType socketType);
+
+
+static void _GSocket_X11_Input(int *fid, void* data)
{
GSocket *socket = (GSocket *)data;
-
+
_GSocket_Detected_Read(socket);
}
-static void _GSocket_Motif_Output(XtPointer data, int *fid,
- XtInputId *id)
+static void _GSocket_X11_Output(int *fid, void* data)
{
GSocket *socket = (GSocket *)data;
default: return;
}
+#if 0
if (m_id[c] != -1)
- XtRemoveInput(m_id[c]);
+ XtRemoveInput(m_id[c]);
+#endif /* 0 */
if (c == 0)
{
- m_id[0] = XtAppAddInput(wxGetAppContext(), socket->m_fd,
- (XtPointer *)XtInputReadMask,
- (XtInputCallbackProc) _GSocket_Motif_Input,
- (XtPointer) socket);
+ m_id[0] = socket->m_fd;
+
+ wxRegisterSocketCallback(socket->m_fd, wxSocketTableInput,
+ (wxSocketCallback) _GSocket_X11_Input, (void*) socket);
}
else
{
- m_id[1] = XtAppAddInput(wxGetAppContext(), socket->m_fd,
- (XtPointer *)XtInputWriteMask,
- (XtInputCallbackProc) _GSocket_Motif_Output,
- (XtPointer) socket);
+ m_id[1] = socket->m_fd;
+
+ wxRegisterSocketCallback(socket->m_fd, wxSocketTableOutput,
+ (wxSocketCallback) _GSocket_X11_Output, (void*) socket);
}
}
}
if (m_id[c] != -1)
- XtRemoveInput(m_id[c]);
+ {
+ if (c == 0)
+ wxUnregisterSocketCallback(m_id[c], wxSocketTableInput);
+ else
+ wxUnregisterSocketCallback(m_id[c], wxSocketTableOutput);
+ }
m_id[c] = -1;
}