Merge pull request #537 from madewokherd/ccwmarshal
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms.CarbonInternal / ApplicationHandler.cs
index 77253802991e2893278cd3cddf50e3443379dd76..f8fd95b40c254541a7918682e6d3daa80a1636d0 100644 (file)
@@ -52,13 +52,22 @@ namespace System.Windows.Forms.CarbonInternal {
 
                public bool ProcessEvent (IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg) {
                        switch (kind) {
+                               case kEventAppActivated: {
+                                       foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
+                                               if (!XplatUICarbon.IsWindowVisible (utility_window))
+                                                       XplatUICarbon.ShowWindow (utility_window);
+                                       break;
+                               }
                                case kEventAppDeactivated: {
                                        if (XplatUICarbon.FocusWindow != IntPtr.Zero) {
                                                Driver.SendMessage (XplatUICarbon.FocusWindow, Msg.WM_KILLFOCUS, IntPtr.Zero, IntPtr.Zero);
                                        } 
-                                       if (XplatUICarbon.GrabHwnd != null) {
-                                               Driver.SendMessage (XplatUICarbon.GrabHwnd.Handle, Msg.WM_LBUTTONDOWN, (IntPtr)MsgButtons.MK_LBUTTON, (IntPtr) (Driver.MousePosition.X << 16 | Driver.MousePosition.Y));
+                                       if (XplatUICarbon.Grab.Hwnd != IntPtr.Zero) {
+                                               Driver.SendMessage (Hwnd.ObjectFromHandle (XplatUICarbon.Grab.Hwnd).Handle, Msg.WM_LBUTTONDOWN, (IntPtr)MsgButtons.MK_LBUTTON, (IntPtr) (Driver.MousePosition.X << 16 | Driver.MousePosition.Y));
                                        }
+                                       foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
+                                               if (XplatUICarbon.IsWindowVisible (utility_window))
+                                                       XplatUICarbon.HideWindow (utility_window);
                                        break;
                                }
                        }