]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/gsockx11.c
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: X11 part
6 * ------------------------------------------------------------------------- */
13 // #include <X11/Intrinsic.h>
14 #include "wx/gsocket.h"
15 #include "wx/unix/gsockunx.h"
17 // TODO: Raw X11 version
20 extern XtAppContext
wxGetAppContext();
22 static void _GSocket_Motif_Input(XtPointer data
, int *fid
,
25 GSocket
*socket
= (GSocket
*)data
;
27 _GSocket_Detected_Read(socket
);
30 static void _GSocket_Motif_Output(XtPointer data
, int *fid
,
33 GSocket
*socket
= (GSocket
*)data
;
35 _GSocket_Detected_Write(socket
);
38 int _GSocket_GUI_Init(GSocket
*socket
)
42 socket
->m_gui_dependent
= (char *)malloc(sizeof(int)*2);
43 m_id
= (int *)(socket
->m_gui_dependent
);
51 void _GSocket_GUI_Destroy(GSocket
*socket
)
53 free(socket
->m_gui_dependent
);
56 void _GSocket_Install_Callback(GSocket
*socket
, GSocketEvent event
)
58 int *m_id
= (int *)(socket
->m_gui_dependent
);
61 if (socket
->m_fd
== -1)
66 case GSOCK_LOST
: /* fall-through */
67 case GSOCK_INPUT
: c
= 0; break;
68 case GSOCK_OUTPUT
: c
= 1; break;
69 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
74 XtRemoveInput(m_id
[c
]);
78 m_id
[0] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
79 (XtPointer
*)XtInputReadMask
,
80 (XtInputCallbackProc
) _GSocket_Motif_Input
,
85 m_id
[1] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
86 (XtPointer
*)XtInputWriteMask
,
87 (XtInputCallbackProc
) _GSocket_Motif_Output
,
92 void _GSocket_Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
94 int *m_id
= (int *)(socket
->m_gui_dependent
);
99 case GSOCK_LOST
: /* fall-through */
100 case GSOCK_INPUT
: c
= 0; break;
101 case GSOCK_OUTPUT
: c
= 1; break;
102 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
107 XtRemoveInput(m_id
[c
]);
112 void _GSocket_Enable_Events(GSocket
*socket
)
114 _GSocket_Install_Callback(socket
, GSOCK_INPUT
);
115 _GSocket_Install_Callback(socket
, GSOCK_OUTPUT
);
118 void _GSocket_Disable_Events(GSocket
*socket
)
120 _GSocket_Uninstall_Callback(socket
, GSOCK_INPUT
);
121 _GSocket_Uninstall_Callback(socket
, GSOCK_OUTPUT
);
124 #else /* !wxUSE_SOCKETS */
126 /* some compilers don't like having empty source files */
127 static int wxDummyGsockVar
= 0;
132 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */