X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bc797f4cc8ffe36277ba8b7dd4b57e63a96bfcb5..9a33ef7c3cc827658ba12b553c40af432f10bc3b:/src/x11/gsockx11.c diff --git a/src/x11/gsockx11.c b/src/x11/gsockx11.c index b6199391e6..ae23842347 100644 --- a/src/x11/gsockx11.c +++ b/src/x11/gsockx11.c @@ -2,6 +2,7 @@ * Project: GSocket (Generic Socket) for WX * Name: gsockmot.c * Purpose: GSocket: X11 part + * Licence: The wxWindows licence * CVSID: $Id$ * ------------------------------------------------------------------------- */ @@ -10,32 +11,47 @@ #if wxUSE_SOCKETS #include -// #include #include "wx/gsocket.h" #include "wx/unix/gsockunx.h" -// TODO: Raw X11 version -#if 0 +/* + * FIXME: have these in a common header instead of being repeated + * in evtloop.cpp and gsockx11.c + */ + +typedef void (*wxSocketCallback) (int fd, void* data); + +typedef enum +{ wxSocketTableInput, wxSocketTableOutput } wxSocketTableType ; -extern XtAppContext wxGetAppContext(); +void wxRegisterSocketCallback(int fd, wxSocketTableType socketType, wxSocketCallback cback, void* data); +void wxUnregisterSocketCallback(int fd, wxSocketTableType socketType); -static void _GSocket_Motif_Input(XtPointer data, int *fid, - XtInputId *id) + +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(GSocket *socket) +int _GSocket_GUI_Init(void) +{ + return 1; +} + +void _GSocket_GUI_Cleanup(void) +{ +} + +int _GSocket_GUI_Init_Socket(GSocket *socket) { int *m_id; @@ -48,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); } @@ -70,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); } } @@ -104,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; } @@ -126,7 +149,4 @@ void _GSocket_Disable_Events(GSocket *socket) /* some compilers don't like having empty source files */ static int wxDummyGsockVar = 0; -#endif - // 0 - #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */