diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index d56e321e..ba26e163 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -25,6 +25,23 @@ namespace TweetDuck.Core{ sealed partial class FormBrowser : Form{ private static UserConfig Config => Program.UserConfig; + public bool IsWaiting{ + set{ + if (value){ + browser.Enabled = false; + Cursor = Cursors.WaitCursor; + } + else{ + browser.Enabled = true; + Cursor = Cursors.Default; + + if (Focused){ // re-focus browser only if the window or a child is activated + browser.Focus(); + } + } + } + } + public string UpdateInstallerPath { get; private set; } private readonly ChromiumWebBrowser browser; @@ -225,6 +242,10 @@ private void FormBrowser_Activated(object sender, EventArgs e){ if (!isLoaded)return; trayIcon.HasNotifications = false; + + if (!browser.Enabled){ // when taking a screenshot, the window is unfocused and + browser.Enabled = true; // the browser is disabled; if the user clicks back into + } // the window, enable the browser again } private void FormBrowser_LocationChanged(object sender, EventArgs e){ diff --git a/Core/Notification/Screenshot/TweetScreenshotManager.cs b/Core/Notification/Screenshot/TweetScreenshotManager.cs index ddae302a..f6d6aafd 100644 --- a/Core/Notification/Screenshot/TweetScreenshotManager.cs +++ b/Core/Notification/Screenshot/TweetScreenshotManager.cs @@ -8,14 +8,14 @@ namespace TweetDuck.Core.Notification.Screenshot{ sealed class TweetScreenshotManager : IDisposable{ - private readonly Form owner; + private readonly FormBrowser owner; private readonly PluginManager plugins; private readonly Timer timeout; private readonly Timer disposer; private FormNotificationScreenshotable screenshot; - public TweetScreenshotManager(Form owner, PluginManager pluginManager){ + public TweetScreenshotManager(FormBrowser owner, PluginManager pluginManager){ this.owner = owner; this.plugins = pluginManager; @@ -28,8 +28,7 @@ public TweetScreenshotManager(Form owner, PluginManager pluginManager){ private void timeout_Tick(object sender, EventArgs e){ timeout.Stop(); - screenshot.Location = ControlExtensions.InvisibleLocation; - disposer.Start(); + OnFinished(); } private void disposer_Tick(object sender, EventArgs e){ @@ -50,6 +49,10 @@ public void Trigger(string html, int width, int height){ screenshot.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, 0, string.Empty, string.Empty), width, height); screenshot.Show(); timeout.Start(); + + #if !(DEBUG && NO_HIDE_SCREENSHOTS) + owner.IsWaiting = true; + #endif } private void Callback(){ @@ -61,14 +64,19 @@ private void Callback(){ screenshot.TakeScreenshot(); #if !(DEBUG && NO_HIDE_SCREENSHOTS) - screenshot.Location = ControlExtensions.InvisibleLocation; - disposer.Start(); + OnFinished(); #else screenshot.MoveToVisibleLocation(); screenshot.FormClosed += (sender, args) => disposer.Start(); #endif } + private void OnFinished(){ + screenshot.Location = ControlExtensions.InvisibleLocation; + owner.IsWaiting = false; + disposer.Start(); + } + public void Dispose(){ timeout.Dispose(); disposer.Dispose();