From afa764321471fd4ccb424c0afc0b11f38b1bae36 Mon Sep 17 00:00:00 2001 From: Carlos Alberto Cortez Date: Mon, 19 Apr 2010 10:51:38 +0000 Subject: [PATCH] * NotifyIcon.cs: Make BalloonWindow expose the owner's Handle. * Theme.cs: * ThemeWin32Classic.cs: Add a HideBalloonWindow method to force to close an active balloon window. * XplatUIX11.cs: When removing from the system tray try to close the balloon window. This is important when we hide a NotifyIcon and thus need to close its related balloon window as well. Fixes bits of #590093. 2010-04-19 Carlos Alberto Cortez svn path=/trunk/mcs/; revision=155713 --- .../System.Windows.Forms/ChangeLog | 11 +++++++++++ .../System.Windows.Forms/NotifyIcon.cs | 6 ++++++ .../System.Windows.Forms/Theme.cs | 1 + .../System.Windows.Forms/ThemeWin32Classic.cs | 10 ++++++++++ .../System.Windows.Forms/XplatUIX11.cs | 4 ++++ 5 files changed, 32 insertions(+) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 3d090eaaf82..eb9969ba4f2 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,14 @@ +2010-04-19 Carlos Alberto Cortez + + * NotifyIcon.cs: Make BalloonWindow expose the owner's Handle. + * Theme.cs: + * ThemeWin32Classic.cs: Add a HideBalloonWindow method to force to + close an active balloon window. + * XplatUIX11.cs: When removing from the system tray try to close + the balloon window. This is important when we hide a NotifyIcon and + thus need to close its related balloon window as well. + Fixes bits of #590093. + 2010-04-19 Carlos Alberto Cortez * XplatUIX11.cs: When adding a NotifyIcon to the system tray, mark its diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs index b45922574f1..0a71465d762 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NotifyIcon.cs @@ -263,6 +263,12 @@ namespace System.Windows.Forms { timer.Enabled = false; timer.Tick += new EventHandler (HandleTimer); } + + public IntPtr OwnerHandle { + get { + return owner; + } + } protected override void Dispose (bool disposing) { diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs index 599ae0f33b2..e4154e726f1 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs @@ -984,6 +984,7 @@ namespace System.Windows.Forms #region BalloonWindow #if NET_2_0 public abstract void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon); + public abstract void HideBalloonWindow (IntPtr handle); public abstract void DrawBalloonWindow (Graphics dc, Rectangle clip, NotifyIcon.BalloonWindow control); public abstract Rectangle BalloonWindowRect (NotifyIcon.BalloonWindow control); #endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs index 0bd84de71b0..42a533043ed 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs @@ -5529,6 +5529,16 @@ namespace System.Windows.Forms balloon_window.Show (); } + public override void HideBalloonWindow (IntPtr handle) + { + if (balloon_window == null || balloon_window.OwnerHandle != handle) + return; + + balloon_window.Close (); + balloon_window.Dispose (); + balloon_window = null; + } + private const int balloon_iconsize = 16; private const int balloon_bordersize = 8; diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs index 9db43870771..582e660bde5 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs @@ -6086,6 +6086,10 @@ namespace System.Windows.Forms { tt.Dispose(); tt = null; } +#if NET_2_0 + // Close any balloon window *we* fired. + ThemeEngine.Current.HideBalloonWindow (handle); +#endif } #if NET_2_0 -- 2.25.1