wake = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
wake.Connect(listen.LocalEndPoint);
+
+ // Make this non-blocking, so it doesn't
+ // deadlock if too many wakes are sent
+ // before the wake_receive end is polled
+ wake.Blocking = false;
+
wake_receive = listen.Accept();
#if __MonoCS__
}
void WakeupMain () {
- wake.Send (new byte [] { 0xFF });
+ try {
+ wake.Send (new byte [] { 0xFF });
+ } catch (SocketException ex) {
+ if (ex.SocketErrorCode != SocketError.WouldBlock) {
+ throw;
+ }
+ }
}
XEventQueue ThreadQueue(Thread thread) {
if (((long)nitems > 0) && (prop != IntPtr.Zero)) {
active = (IntPtr)Marshal.ReadInt32(prop);
XFree(prop);
+ } else {
+ // The window manager does not support _NET_ACTIVE_WINDOW. Fall back to XGetInputFocus.
+ IntPtr revert_to = IntPtr.Zero;
+ XGetInputFocus(DisplayHandle, out active, out revert_to);
}
if (active != IntPtr.Zero) {
tt.Dispose();
tt = null;
}
-#if NET_2_0
// Close any balloon window *we* fired.
ThemeEngine.Current.HideBalloonWindow (handle);
-#endif
}
-#if NET_2_0
internal override void SystrayBalloon(IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
{
ThemeEngine.Current.ShowBalloonWindow (handle, timeout, title, text, icon);
SendMessage(handle, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONSHOW);
}
-#endif
internal override bool Text(IntPtr handle, string text)
{
[DllImport ("libX11", EntryPoint="XIfEvent")]
internal extern static void XIfEvent (IntPtr display, ref XEvent xevent, Delegate event_predicate, IntPtr arg);
+
+ [DllImport ("libX11", EntryPoint="XGetInputFocus")]
+ internal extern static void XGetInputFocus (IntPtr display, out IntPtr focus, out IntPtr revert_to);
#endregion
#endif
}