Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

[release-8.4] Fix information popover flickering #9578

Merged
merged 2 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Timers;
using MonoDevelop.Core;
using MonoDevelop.Ide;
using MonoDevelop.Ide.Tasks;
Expand Down Expand Up @@ -158,9 +159,10 @@ bool WorkaroundNestedDialogFlickering ()

void ShowPopover ()
{
if (popover != null)
popover.Destroy ();
popover = TooltipPopoverWindow.Create (!WorkaroundNestedDialogFlickering ());
if (hideTooltipTimer?.Enabled == true)
hideTooltipTimer.Stop ();
if (popover == null)
popover = TooltipPopoverWindow.Create (!WorkaroundNestedDialogFlickering ());
popover.ShowArrow = true;
if (markup)
popover.Markup = message;
Expand All @@ -172,41 +174,65 @@ void ShowPopover ()

void UpdatePopover ()
{
if (popover != null)
if (popover?.Visible == true)
ShowPopover ();
}

protected override void OnLostFocus (EventArgs args)
{
base.OnLostFocus (args);
DestroyPopover ();
HidePopover ();
}

protected override void OnMouseExited (EventArgs args)
{
base.OnMouseExited (args);
DestroyPopover ();
HidePopover (true);
}

protected override void OnPreferredSizeChanged ()
{
base.OnPreferredSizeChanged ();
if (!Visible)
DestroyPopover ();
HidePopover ();
}

void DestroyPopover ()
Timer hideTooltipTimer;

void HidePopover (bool delayed = false)
{
if (popover != null) {
popover.Destroy ();
popover = null;
if (delayed) {
// we delay hiding using a timer to avoid tooltip flickering in case of focus stealing
// due to weird toolkit behaviour.
if (hideTooltipTimer == null) {
hideTooltipTimer = new Timer (50) {
AutoReset = false,
SynchronizingObject = this,
};
hideTooltipTimer.Elapsed += (sender, e) => {
if (popover?.Visible == true)
popover.Hide ();
};
}
hideTooltipTimer.Start ();
} else {
if (hideTooltipTimer?.Enabled == true)
hideTooltipTimer.Stop ();
if (popover?.Visible == true)
popover.Hide ();
}
}

protected override void Dispose (bool disposing)
{
if (disposing)
DestroyPopover ();
if (disposing) {
hideTooltipTimer?.Dispose ();
if (popover?.Visible == true)
popover.Hide ();
popover?.Dispose ();
}
hideTooltipTimer = null;
popover = null;
base.Dispose (disposing);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ public async Task GoBack (CancellationToken token)

public bool RunWizard ()
{
var dialog = new WizardDialog (this);
return dialog.Run (Xwt.MessageDialog.RootWindow);
using (var dialog = new WizardDialog (this)) {
return dialog.Run (Xwt.MessageDialog.RootWindow);
}
}

public bool RunWizard (Xwt.WindowFrame parentWindow)
{
var dialog = new WizardDialog (this);
return dialog.Run (parentWindow);
using (var dialog = new WizardDialog (this)) {
return dialog.Run (parentWindow);
}
}

public event EventHandler Completed;
Expand Down