]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/gsockmot.c
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: Motif part
6 * ------------------------------------------------------------------------- */
13 #include <X11/Intrinsic.h>
14 #include "wx/gsocket.h"
15 #include "wx/unix/gsockunx.h"
17 extern XtAppContext
wxGetAppContext();
19 static void _GSocket_Motif_Input(XtPointer data
, int *fid
,
22 GSocket
*socket
= (GSocket
*)data
;
24 _GSocket_Detected_Read(socket
);
27 static void _GSocket_Motif_Output(XtPointer data
, int *fid
,
30 GSocket
*socket
= (GSocket
*)data
;
32 _GSocket_Detected_Write(socket
);
35 int _GSocket_GUI_Init(GSocket
*socket
)
39 socket
->m_gui_dependent
= (char *)malloc(sizeof(int)*2);
40 m_id
= (int *)(socket
->m_gui_dependent
);
48 void _GSocket_GUI_Destroy(GSocket
*socket
)
50 free(socket
->m_gui_dependent
);
53 void _GSocket_Install_Callback(GSocket
*socket
, GSocketEvent event
)
55 int *m_id
= (int *)(socket
->m_gui_dependent
);
58 if (socket
->m_fd
== -1)
63 case GSOCK_LOST
: /* fall-through */
64 case GSOCK_INPUT
: c
= 0; break;
65 case GSOCK_OUTPUT
: c
= 1; break;
66 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
71 XtRemoveInput(m_id
[c
]);
75 m_id
[0] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
76 (XtPointer
*)XtInputReadMask
,
77 (XtInputCallbackProc
) _GSocket_Motif_Input
,
82 m_id
[1] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
83 (XtPointer
*)XtInputWriteMask
,
84 (XtInputCallbackProc
) _GSocket_Motif_Output
,
89 void _GSocket_Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
91 int *m_id
= (int *)(socket
->m_gui_dependent
);
96 case GSOCK_LOST
: /* fall-through */
97 case GSOCK_INPUT
: c
= 0; break;
98 case GSOCK_OUTPUT
: c
= 1; break;
99 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
104 XtRemoveInput(m_id
[c
]);
109 void _GSocket_Enable_Events(GSocket
*socket
)
111 _GSocket_Install_Callback(socket
, GSOCK_INPUT
);
112 _GSocket_Install_Callback(socket
, GSOCK_OUTPUT
);
115 void _GSocket_Disable_Events(GSocket
*socket
)
117 _GSocket_Uninstall_Callback(socket
, GSOCK_INPUT
);
118 _GSocket_Uninstall_Callback(socket
, GSOCK_OUTPUT
);
121 #else /* !wxUSE_SOCKETS */
123 /* some compilers don't like having empty source files */
124 static int wxDummyGsockVar
= 0;
126 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */