X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83df96d63a52ebb08b9e32549dc255354b4a18d0..68a2e005a51a87df6cc445345f27443e57ab3608:/src/x11/gsockx11.c diff --git a/src/x11/gsockx11.c b/src/x11/gsockx11.c index 1297cecdee..ae23842347 100644 --- a/src/x11/gsockx11.c +++ b/src/x11/gsockx11.c @@ -1,7 +1,8 @@ /* ------------------------------------------------------------------------- * Project: GSocket (Generic Socket) for WX * Name: gsockmot.c - * Purpose: GSocket: Motif part + * Purpose: GSocket: X11 part + * Licence: The wxWindows licence * CVSID: $Id$ * ------------------------------------------------------------------------- */ @@ -10,29 +11,47 @@ #if wxUSE_SOCKETS #include -#include #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; @@ -45,7 +64,7 @@ int _GSocket_GUI_Init(GSocket *socket) return TRUE; } -void _GSocket_GUI_Destroy(GSocket *socket) +void _GSocket_GUI_Destroy_Socket(GSocket *socket) { free(socket->m_gui_dependent); } @@ -67,22 +86,24 @@ void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event) 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); } } @@ -101,7 +122,12 @@ void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event) } 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; }