@@ -392,7 +392,7 @@ void mon_timer_fn()
392
392
if (!win.borderless ) // remove borders
393
393
{
394
394
MONITORINFO mi = {sizeof (mi)};
395
- GetMonitorInfoW (MonitorFromWindow ( win.hwnd , MONITOR_DEFAULTTOPRIMARY) , &mi);
395
+ GetMonitorInfoW (win.monitor , &mi);
396
396
SetWindowLongPtr (win.hwnd , GWL_STYLE, (monwin.second .style & ~(WS_CAPTION|WS_THICKFRAME)) | WS_POPUP);
397
397
SetWindowPos (win.hwnd , HWND_TOP, mi.rcMonitor .left , mi.rcMonitor .top , mi.rcMonitor .right - mi.rcMonitor .left ,
398
398
mi.rcMonitor .bottom - mi.rcMonitor .top , SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
@@ -401,10 +401,15 @@ void mon_timer_fn()
401
401
HWND fghwnd = GetForegroundWindow ();
402
402
if (monwin.second .active )
403
403
{
404
- if (fghwnd != win.hwnd )
404
+ if (fghwnd != win.hwnd && win. monitor == MonitorFromWindow (fghwnd, MONITOR_DEFAULTTOPRIMARY) )
405
405
{
406
- monwin.second .active = false ;
407
- PostMessage (win.hwnd , WM_SYSCOMMAND, SC_MINIMIZE, 0 );
406
+ string fgclassname (1024 , ' \0 ' );
407
+ fgclassname.resize (GetClassNameA (fghwnd, &fgclassname.front (), fgclassname.size ()));
408
+ if (fgclassname != " TaskSwitcherWnd" )
409
+ {
410
+ monwin.second .active = false ;
411
+ PostMessage (win.hwnd , WM_SYSCOMMAND, SC_MINIMIZE, 0 );
412
+ }
408
413
}
409
414
}
410
415
else if (fghwnd == win.hwnd ) monwin.second .active = true ;
@@ -499,6 +504,7 @@ void enum_windows()
499
504
filepath procpath (procname);
500
505
win.procnamew = procpath.fullnamew ();
501
506
win.hwnd = hwnd;
507
+ win.monitor = MonitorFromWindow (hwnd, MONITOR_DEFAULTTOPRIMARY);
502
508
win.captionw = caption;
503
509
if (!(style & (WS_CAPTION|WS_THICKFRAME))) win.borderless = true ;
504
510
windows[procpath.fullname ()] = win;
@@ -590,4 +596,4 @@ void SaveSettings()
590
596
ini.WriteString (s, " p" , monwin.first );
591
597
ini.WriteInt (s, " s" , monwin.second .style );
592
598
}
593
- }
599
+ }
0 commit comments