1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-08 02:34:06 +02:00

Add a HORRIBLE HACK to unfocus example notification in Settings

This commit is contained in:
chylex 2017-01-02 15:44:18 +01:00
parent 7ad927bdaf
commit b26a6098eb

View File

@ -1,12 +1,15 @@
using System;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
using TweetDck.Core.Controls;
using TweetDck.Core.Notification;
using TweetDck.Core.Utils;
namespace TweetDck.Core.Other.Settings{
partial class TabSettingsNotifications : BaseTabSettings{
private readonly FormNotification notification;
private readonly Point initCursorPosition;
public TabSettingsNotifications(FormNotification notification){
InitializeComponent();
@ -24,8 +27,11 @@ public TabSettingsNotifications(FormNotification notification){
this.InvokeSafe(() => this.notification.ShowNotificationForSettings(true));
};
this.notification.Activated += notification_Activated;
this.notification.Show(this);
initCursorPosition = Cursor.Position;
switch(Config.NotificationPosition){
case TweetNotification.Position.TopLeft: radioLocTL.Checked = true; break;
case TweetNotification.Position.TopRight: radioLocTR.Checked = true; break;
@ -71,6 +77,21 @@ private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
}
}
private void notification_Activated(object sender, EventArgs e){
if (Cursor.Position == initCursorPosition){
Timer delay = WindowsUtils.CreateSingleTickTimer(1);
delay.Tick += (sender2, args2) => { // here you can see a disgusting hack to force the freshly opened notification window out of focus
NativeMethods.SimulateMouseClick(NativeMethods.MouseButton.Left); // because for some reason, the stupid thing keeps stealing it
delay.Dispose(); // even after using ShowWithoutActivation, the CreateParams bullshit, and about a million different combinations
}; // of trying to force the original form back into focus in various events, so you will have to fucking deal with it, alright
delay.Start();
}
notification.Activated -= notification_Activated;
}
private void radioLoc_CheckedChanged(object sender, EventArgs e){
if (!Ready)return;