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

Temporarily move notification with Alt and restore by middle-clicking title bar

Closes 
This commit is contained in:
chylex 2017-10-31 23:40:56 +01:00
parent 97da0b79e4
commit 8c9168a4bf
2 changed files with 31 additions and 1 deletions

View File

@ -25,7 +25,7 @@ protected static int FontSizeLevel{
}
}
protected Point PrimaryLocation{
protected virtual Point PrimaryLocation{
get{
UserConfig config = Program.UserConfig;
Screen screen;

View File

@ -10,10 +10,24 @@ sealed partial class FormNotificationTweet : FormNotificationMain{
private const int NonIntrusiveIdleLimit = 30;
private const int TrimMinimum = 32;
protected override Point PrimaryLocation => hasTemporarilyMoved && IsNotificationVisible ? Location : base.PrimaryLocation;
private bool IsCursorOverNotificationArea => new Rectangle(PrimaryLocation, Size).Contains(Cursor.Position);
protected override bool CanDragWindow{
get{
if (ModifierKeys.HasFlag(Keys.Alt)){
hasTemporarilyMoved = true;
return true;
}
else{
return false;
}
}
}
private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
private bool needsTrim;
private bool hasTemporarilyMoved;
public FormNotificationTweet(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, true){
InitializeComponent();
@ -26,6 +40,20 @@ public FormNotificationTweet(FormBrowser owner, PluginManager pluginManager) : b
}
}
protected override void WndProc(ref Message m){
if (m.Msg == 0x00A7){ // WM_NCMBUTTONDOWN
int hitTest = m.WParam.ToInt32();
if (hitTest == 2 || hitTest == 20){ // HTCAPTION, HTCLOSE
hasTemporarilyMoved = false;
MoveToVisibleLocation();
return;
}
}
base.WndProc(ref m);
}
// event handlers
private void Config_MuteToggled(object sender, EventArgs e){
@ -75,6 +103,8 @@ public override void HideNotification(){
tweetQueue.TrimExcess();
needsTrim = false;
}
hasTemporarilyMoved = false;
}
public override void FinishCurrentNotification(){