]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/gsockmot.cpp
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket: Motif part
6 * Licence: The wxWindows licence
7 * ------------------------------------------------------------------------- */
14 #include <X11/Intrinsic.h>
15 #include "wx/gsocket.h"
16 #include "wx/unix/gsockunx.h"
18 extern "C" XtAppContext
wxGetAppContext();
20 static void _GSocket_Motif_Input(XtPointer data
, int *fid
,
23 GSocket
*socket
= (GSocket
*)data
;
25 socket
->Detected_Read();
28 static void _GSocket_Motif_Output(XtPointer data
, int *fid
,
31 GSocket
*socket
= (GSocket
*)data
;
33 socket
->Detected_Write();
36 bool GSocketGUIFunctionsTableConcrete::CanUseEventLoop()
39 bool GSocketGUIFunctionsTableConcrete::OnInit(void)
44 void GSocketGUIFunctionsTableConcrete::OnExit(void)
48 bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket
*socket
)
52 socket
->m_gui_dependent
= (char *)malloc(sizeof(int)*2);
53 m_id
= (int *)(socket
->m_gui_dependent
);
61 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket
*socket
)
63 free(socket
->m_gui_dependent
);
66 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket
*socket
, GSocketEvent event
)
68 int *m_id
= (int *)(socket
->m_gui_dependent
);
71 if (socket
->m_fd
== -1)
76 case GSOCK_LOST
: /* fall-through */
77 case GSOCK_INPUT
: c
= 0; break;
78 case GSOCK_OUTPUT
: c
= 1; break;
79 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
84 XtRemoveInput(m_id
[c
]);
88 m_id
[0] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
89 (XtPointer
*)XtInputReadMask
,
90 (XtInputCallbackProc
) _GSocket_Motif_Input
,
95 m_id
[1] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
96 (XtPointer
*)XtInputWriteMask
,
97 (XtInputCallbackProc
) _GSocket_Motif_Output
,
102 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
104 int *m_id
= (int *)(socket
->m_gui_dependent
);
109 case GSOCK_LOST
: /* fall-through */
110 case GSOCK_INPUT
: c
= 0; break;
111 case GSOCK_OUTPUT
: c
= 1; break;
112 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
117 XtRemoveInput(m_id
[c
]);
122 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket
*socket
)
124 Install_Callback(socket
, GSOCK_INPUT
);
125 Install_Callback(socket
, GSOCK_OUTPUT
);
128 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket
*socket
)
130 Uninstall_Callback(socket
, GSOCK_INPUT
);
131 Uninstall_Callback(socket
, GSOCK_OUTPUT
);
134 #else /* !wxUSE_SOCKETS */
136 /* some compilers don't like having empty source files */
137 static int wxDummyGsockVar
= 0;
139 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */