]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/gsockmot.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/gsockmot.cpp
3 // Project: GSocket (Generic Socket) for WX
4 // Purpose: GSocket: Motif part
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
15 #include <X11/Intrinsic.h>
16 #include "wx/gsocket.h"
17 #include "wx/unix/gsockunx.h"
19 extern "C" XtAppContext
wxGetAppContext();
21 static void _GSocket_Motif_Input(XtPointer data
, int *WXUNUSED(fid
),
22 XtInputId
*WXUNUSED(id
))
24 GSocket
*socket
= (GSocket
*)data
;
26 socket
->Detected_Read();
29 static void _GSocket_Motif_Output(XtPointer data
, int *WXUNUSED(fid
),
30 XtInputId
*WXUNUSED(id
))
32 GSocket
*socket
= (GSocket
*)data
;
34 socket
->Detected_Write();
37 bool GSocketGUIFunctionsTableConcrete::CanUseEventLoop()
42 bool GSocketGUIFunctionsTableConcrete::OnInit(void)
47 void GSocketGUIFunctionsTableConcrete::OnExit(void)
51 bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket
*socket
)
55 socket
->m_gui_dependent
= (char *)malloc(sizeof(int)*2);
56 m_id
= (int *)(socket
->m_gui_dependent
);
64 void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket
*socket
)
66 free(socket
->m_gui_dependent
);
69 void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket
*socket
, GSocketEvent event
)
71 int *m_id
= (int *)(socket
->m_gui_dependent
);
74 if (socket
->m_fd
== -1)
79 case GSOCK_LOST
: /* fall-through */
80 case GSOCK_INPUT
: c
= 0; break;
81 case GSOCK_OUTPUT
: c
= 1; break;
82 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
87 XtRemoveInput(m_id
[c
]);
91 m_id
[0] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
92 (XtPointer
*)XtInputReadMask
,
93 (XtInputCallbackProc
) _GSocket_Motif_Input
,
98 m_id
[1] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
,
99 (XtPointer
*)XtInputWriteMask
,
100 (XtInputCallbackProc
) _GSocket_Motif_Output
,
105 void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket
*socket
, GSocketEvent event
)
107 int *m_id
= (int *)(socket
->m_gui_dependent
);
112 case GSOCK_LOST
: /* fall-through */
113 case GSOCK_INPUT
: c
= 0; break;
114 case GSOCK_OUTPUT
: c
= 1; break;
115 case GSOCK_CONNECTION
: c
= ((socket
->m_server
) ? 0 : 1); break;
120 XtRemoveInput(m_id
[c
]);
125 void GSocketGUIFunctionsTableConcrete::Enable_Events(GSocket
*socket
)
127 Install_Callback(socket
, GSOCK_INPUT
);
128 Install_Callback(socket
, GSOCK_OUTPUT
);
131 void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket
*socket
)
133 Uninstall_Callback(socket
, GSOCK_INPUT
);
134 Uninstall_Callback(socket
, GSOCK_OUTPUT
);
137 #else /* !wxUSE_SOCKETS */
139 /* some compilers don't like having empty source files */
140 static int wxDummyGsockVar
= 0;
142 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */