]> git.saurik.com Git - wxWidgets.git/blame - src/motif/gsockmot.cpp
//... => /* ... */
[wxWidgets.git] / src / motif / gsockmot.cpp
CommitLineData
dbd300df
GL
1// -------------------------------------------------------------------------
2// Project: GSocket (Generic Socket) for WX
3// Name: gsockmot.cpp
4// Purpose: GSocket: Motif part
5// CVSID: $Id$
dbd300df 6// -------------------------------------------------------------------------
813c20a6
VZ
7
8#include "wx/setup.h"
9
10#if wxUSE_SOCKETS
11
dbd300df
GL
12#include <stdlib.h>
13#include <X11/Intrinsic.h>
14#include <wx/gsocket.h>
15#include <wx/app.h>
2ef1f50a 16#include <wx/unix/gsockunx.h>
dbd300df
GL
17
18#define wxAPP_CONTEXT ((XtAppContext)wxTheApp->GetAppContext())
19
20static void _GSocket_Motif_Input(XtPointer data, int *fid,
21 XtInputId *id)
22{
23 GSocket *socket = (GSocket *)data;
24
25 _GSocket_Detected_Read(socket);
26}
27
28static void _GSocket_Motif_Output(XtPointer data, int *fid,
29 XtInputId *id)
30{
31 GSocket *socket = (GSocket *)data;
32
33 _GSocket_Detected_Write(socket);
34}
35
36void _GSocket_GUI_Init(GSocket *socket)
37{
38 int i;
39 int *m_id;
40
41 socket->m_gui_dependent = (char *)malloc(sizeof(int)*3);
42 m_id = (int *)(socket->m_gui_dependent);
43
44 for (i=0;i<3;i++)
45 m_id[i] = -1;
46}
47
48void _GSocket_GUI_Destroy(GSocket *socket)
49{
50 int i;
51 int *m_id;
52
53 m_id = (int *)(socket->m_gui_dependent);
54
55 for (i=0;i<3;i++)
56 if (m_id[i] == -1)
57 XtRemoveInput(m_id[i]);
58
59 free(socket->m_gui_dependent);
60}
61
39b91eca 62void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
dbd300df
GL
63{
64 int *m_id;
65
66 m_id = (int *)(socket->m_gui_dependent);
67
68 switch (event) {
69 case GSOCK_CONNECTION:
70 case GSOCK_LOST:
71 case GSOCK_INPUT:
72 if (m_id[0] != -1)
73 XtRemoveInput(m_id[0]);
74 m_id[0] = XtAppAddInput(wxAPP_CONTEXT, socket->m_fd,
75 (XtPointer *)XtInputReadMask,
76 (XtInputCallbackProc) _GSocket_Motif_Input,
77 (XtPointer) socket);
78 break;
79 case GSOCK_OUTPUT:
80 if (m_id[1] != -1)
81 XtRemoveInput(m_id[1]);
82 m_id[1] = XtAppAddInput(wxAPP_CONTEXT, socket->m_fd,
83 (XtPointer *)XtInputWriteMask,
84 (XtInputCallbackProc) _GSocket_Motif_Output,
85 (XtPointer) socket);
86 break;
87 default: return;
88 }
89}
90
39b91eca 91void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
dbd300df
GL
92{
93 int c;
94 int *m_id;
95
96 m_id = (int *)(socket->m_gui_dependent);
97
98 switch (event) {
99 case GSOCK_CONNECTION:
100 case GSOCK_LOST:
101 case GSOCK_INPUT: c = 0; break;
102 case GSOCK_OUTPUT: c = 1; break;
103 break;
104 default: return;
105 }
106
107 if (m_id[c] != -1)
108 XtRemoveInput(m_id[c]);
109
110 m_id[c] = -1;
111}
112
113unsigned long GSocket_GetEventID(GSocket *socket)
114{
115 return 0;
116}
117
118void GSocket_DoEvent(unsigned long evt_id)
119{
120}
813c20a6
VZ
121
122#endif // wxUSE_SOCKETS