mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 13:05:38 +02:00
force foreground window when switching virtual desktop
This commit is contained in:
parent
af7add873f
commit
3472349519
3 changed files with 21 additions and 4 deletions
|
@ -26,12 +26,14 @@ namespace PersistentWindows.Common
|
|||
public class VirtualDesktop
|
||||
{
|
||||
private IVirtualDesktopManager _manager = null;
|
||||
private static IVirtualDesktopManager _static_manager = null;
|
||||
|
||||
public VirtualDesktop()
|
||||
{
|
||||
try
|
||||
{
|
||||
_manager = (IVirtualDesktopManager)new CVirtualDesktopManager();
|
||||
_static_manager = _manager;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -44,9 +46,13 @@ namespace PersistentWindows.Common
|
|||
return _manager != null;
|
||||
}
|
||||
|
||||
public bool IsWindowOnCurrentVirtualDesktop(IntPtr TopLevelWindow)
|
||||
public static bool IsWindowOnCurrentVirtualDesktop(IntPtr TopLevelWindow)
|
||||
{
|
||||
int hr = _manager.IsWindowOnCurrentVirtualDesktop(TopLevelWindow, out int result);
|
||||
if (_static_manager == null)
|
||||
return true;
|
||||
|
||||
int result = 1;
|
||||
int hr = _static_manager.IsWindowOnCurrentVirtualDesktop(TopLevelWindow, out result);
|
||||
if (hr != 0)
|
||||
{
|
||||
//Marshal.ThrowExceptionForHR(hr);
|
||||
|
@ -70,6 +76,9 @@ namespace PersistentWindows.Common
|
|||
|
||||
public void MoveWindowToDesktop(IntPtr TopLevelWindow, Guid CurrentDesktop)
|
||||
{
|
||||
if (!Enabled())
|
||||
return;
|
||||
|
||||
int hr = _manager.MoveWindowToDesktop(TopLevelWindow, CurrentDesktop);
|
||||
if (hr != 0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue