/* -------------------------------------------------------------------------
* 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);
+
+ socket->m_functions->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;
- _GSocket_Detected_Write(socket);
+ socket->m_functions->Detected_Write(socket);
+}
+
+int _GSocket_GUI_Init(void)
+{
+ return 1;
}
-int _GSocket_GUI_Init(GSocket *socket)
+void _GSocket_GUI_Cleanup(void)
+{
+}
+
+int _GSocket_GUI_Init_Socket(GSocket *socket)
{
int *m_id;
return TRUE;
}
-void _GSocket_GUI_Destroy(GSocket *socket)
+void _GSocket_GUI_Destroy_Socket(GSocket *socket)
{
free(socket->m_gui_dependent);
}
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;
}