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