internal override bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
GetSystrayManagerWindow();
if (SystrayMgrWindow != IntPtr.Zero) {
XSizeHints size_hints;
Hwnd hwnd;
hwnd = Hwnd.ObjectFromHandle(handle);
#if DriverDebug
Console.WriteLine("Adding Systray Whole:{0:X}, Client:{1:X}", hwnd.whole_window.ToInt32(), hwnd.client_window.ToInt32());
#endif
// Oh boy.
if (hwnd.client_window != hwnd.whole_window) {
Keyboard.DestroyICForWindow (hwnd.client_window);
XDestroyWindow(DisplayHandle, hwnd.client_window);
hwnd.client_window = hwnd.whole_window;
}
/* by virtue of the way the tests are ordered when determining if it's PAINT
or NCPAINT, client_window == whole_window will always be PAINT. So, if we're
waiting on an nc_expose, drop it and remove the hwnd from the list (unless
there's a pending expose). */
if (hwnd.nc_expose_pending) {
hwnd.nc_expose_pending = false;
if (!hwnd.expose_pending)
hwnd.Queue.Paint.Remove (hwnd);
}
size_hints = new XSizeHints();
size_hints.flags = (IntPtr)(XSizeHintsFlags.PMinSize | XSizeHintsFlags.PMaxSize | XSizeHintsFlags.PBaseSize);
size_hints.min_width = 24;
size_hints.min_height = 24;
size_hints.max_width = 24;
size_hints.max_height = 24;
size_hints.base_width = 24;
size_hints.base_height = 24;
XSetWMNormalHints(DisplayHandle, hwnd.whole_window, ref size_hints);
int[] atoms = new int[2];
atoms [0] = 1; // Version 1
atoms [1] = 1; // we want to be mapped
// This line cost me 3 days...
XChangeProperty(DisplayHandle, hwnd.whole_window, _XEMBED_INFO, _XEMBED_INFO, 32, PropertyMode.Replace, atoms, 2);
// Need to pick some reasonable defaults
tt = new ToolTip();
tt.AutomaticDelay = 350;
tt.InitialDelay = 250;
tt.ReshowDelay = 250;
tt.ShowAlways = true;
if ((tip != null) && (tip != string.Empty)) {
tt.SetToolTip(Control.FromHandle(handle), tip);
tt.Active = true;
} else {
tt.Active = false;
}
SendNetClientMessage(SystrayMgrWindow, _NET_SYSTEM_TRAY_OPCODE, IntPtr.Zero, (IntPtr)SystrayRequest.SYSTEM_TRAY_REQUEST_DOCK, hwnd.whole_window);
return true;
}
tt = null;
return false;
}