forked from Grabacr07/VirtualDesktop
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for 22449 & correct naming
- Loading branch information
Showing
17 changed files
with
300 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
source/VirtualDesktop/Interop/(interfaces)/22449/IVirtualDesktop.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace WindowsDesktop.Interop | ||
{ | ||
[ComImport] | ||
[Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface IVirtualDesktop | ||
{ | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
bool IsViewVisible(IApplicationView pView); | ||
|
||
Guid GetID(); | ||
|
||
IntPtr Unknown1(); | ||
|
||
[return: MarshalAs(UnmanagedType.HString)] | ||
string GetName(); | ||
|
||
[return: MarshalAs(UnmanagedType.HString)] | ||
string GetWallpaperPath(); | ||
} | ||
|
||
// see also: | ||
// https://github.com/MScholtes/VirtualDesktop/blob/f7c0018069f5500bce3b170a53fb71edee44ebec/VirtualDesktop.cs#L156-L173 | ||
|
||
public class VirtualDesktopCacheImpl : IVirtualDesktopCache | ||
{ | ||
private readonly ConcurrentDictionary<Guid, VirtualDesktop> _wrappers = new ConcurrentDictionary<Guid, VirtualDesktop>(); | ||
|
||
public Func<Guid, object, VirtualDesktop> Factory { get; set; } | ||
|
||
public VirtualDesktop GetOrCreate(object comObject) | ||
{ | ||
if (comObject is IVirtualDesktop) | ||
{ | ||
return this._wrappers.GetOrAdd(((IVirtualDesktop)comObject).GetID(), id => this.Factory(id, comObject)); | ||
} | ||
|
||
throw new ArgumentException(); | ||
} | ||
|
||
public void Clear() | ||
{ | ||
this._wrappers.Clear(); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
source/VirtualDesktop/Interop/(interfaces)/22449/IVirtualDesktopManagerInternal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace WindowsDesktop.Interop | ||
{ | ||
[ComImport] | ||
[Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
internal interface IVirtualDesktopManagerInternal | ||
{ | ||
int GetCount(IntPtr hWndOrMon); | ||
|
||
void MoveViewToDesktop(IApplicationView pView, IVirtualDesktop pDesktop); | ||
|
||
[return: MarshalAs(UnmanagedType.Bool)] | ||
bool CanViewMoveDesktops(IApplicationView pView); | ||
|
||
IVirtualDesktop GetCurrentDesktop(IntPtr hWndOrMon); | ||
|
||
IObjectArray GetAllCurrentDesktops();//7 | ||
|
||
IObjectArray GetDesktops(IntPtr hWndOrMon); | ||
|
||
IVirtualDesktop GetAdjacentDesktop(IVirtualDesktop pDesktopReference, AdjacentDesktop uDirection); | ||
|
||
void SwitchDesktop(IntPtr hWndOrMon, IVirtualDesktop pDesktop); | ||
|
||
IVirtualDesktop CreateDesktopW(IntPtr hWndOrMon); | ||
|
||
IVirtualDesktop MoveDesktop(IVirtualDesktop pDesktopReference, IntPtr hWndOrMon, int nIndex); | ||
|
||
void RemoveDesktop(IVirtualDesktop pRemove, IVirtualDesktop pFallbackDesktop); | ||
|
||
IVirtualDesktop FindDesktop([In, MarshalAs(UnmanagedType.LPStruct)] Guid desktopId); | ||
|
||
void GetDesktopSwitchIncludeExcludeViews(IVirtualDesktop desktop, out IObjectArray unknown1, out IObjectArray unknown2);//15 | ||
|
||
void SetDesktopName(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string chName); | ||
|
||
void SetDesktopWallpaper(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string chPath); | ||
|
||
void UpdateWallpaperPathForAllDesktops([MarshalAs(UnmanagedType.HString)] string wallpaper);//18 | ||
|
||
void CopyDesktopState(IApplicationView pView0, IApplicationView pView1);//19 | ||
|
||
int GetDesktopIsPerMonitor();//20 | ||
|
||
void GetDesktopIsPerMonitor(int state);//21 | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
source/VirtualDesktop/Interop/(interfaces)/22449/IVirtualDesktopNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace WindowsDesktop.Interop | ||
{ | ||
[ComImport] | ||
[Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface IVirtualDesktopNotification | ||
{ | ||
void VirtualDesktopCreated(IVirtualDesktop pDesktop); | ||
|
||
void VirtualDesktopDestroyBegin(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback); | ||
|
||
void VirtualDesktopDestroyFailed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback); | ||
|
||
void VirtualDesktopDestroyed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback); | ||
|
||
void Unknown1(int nNumber); | ||
|
||
void VirtualDesktopMoved(IVirtualDesktop pDesktop, int nFromIndex, int nToIndex); | ||
|
||
void VirtualDesktopRenamed(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string chName); | ||
|
||
void ViewVirtualDesktopChanged(IApplicationView pView); | ||
|
||
void CurrentVirtualDesktopChanged(IVirtualDesktop pDesktopOld, IVirtualDesktop pDesktopNew); | ||
|
||
void VirtualDesktopWallpaperChanged(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string chPath); | ||
} | ||
|
||
public class VirtualDesktopNotificationListener : VirtualDesktopNotification, IVirtualDesktopNotification | ||
{ | ||
public void VirtualDesktopCreated(IVirtualDesktop pDesktop) | ||
{ | ||
this.VirtualDesktopCreatedCore(pDesktop); | ||
} | ||
|
||
public void VirtualDesktopDestroyBegin(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback) | ||
{ | ||
this.VirtualDesktopDestroyBeginCore(pDesktopDestroyed, pDesktopFallback); | ||
} | ||
|
||
public void VirtualDesktopDestroyFailed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback) | ||
{ | ||
this.VirtualDesktopDestroyFailedCore(pDesktopDestroyed, pDesktopFallback); | ||
} | ||
|
||
public void VirtualDesktopDestroyed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback) | ||
{ | ||
this.VirtualDesktopDestroyedCore(pDesktopDestroyed, pDesktopFallback); | ||
} | ||
|
||
public void Unknown1(int nNumber) | ||
{ | ||
} | ||
|
||
public void VirtualDesktopMoved(IVirtualDesktop pDesktop, int nFromIndex, int nToIndex) | ||
{ | ||
this.VirtualDesktopMovedCore(pDesktop, nFromIndex, nToIndex); | ||
} | ||
|
||
public void VirtualDesktopRenamed(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string chName) | ||
{ | ||
this.VirtualDesktopRenamedCore(pDesktop, chName); | ||
} | ||
|
||
public void ViewVirtualDesktopChanged(IApplicationView pView) | ||
{ | ||
this.ViewVirtualDesktopChangedCore(pView); | ||
} | ||
|
||
public void CurrentVirtualDesktopChanged(IVirtualDesktop pDesktopOld, IVirtualDesktop pDesktopNew) | ||
{ | ||
this.CurrentVirtualDesktopChangedCore(pDesktopOld, pDesktopNew); | ||
} | ||
|
||
public void VirtualDesktopWallpaperChanged(IVirtualDesktop pDesktop, [MarshalAs(UnmanagedType.HString)] string chName) | ||
{ | ||
this.VirtualDesktopWallpaperChangedCore(pDesktop, chName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
source/VirtualDesktop/Interop/(wrappers)/VirtualDesktopManagerInternal22449.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace WindowsDesktop.Interop | ||
{ | ||
[ComInterfaceWrapper("IVirtualDesktopManagerInternal", 22449)] | ||
internal sealed class VirtualDesktopManagerInternal22449 : VirtualDesktopManagerInternal | ||
{ | ||
public VirtualDesktopManagerInternal22449(ComInterfaceAssembly assembly) | ||
: base(assembly) | ||
{ | ||
} | ||
|
||
public override void MoveViewToDesktop(ApplicationView pView, VirtualDesktop desktop) | ||
{ | ||
this.Invoke(Args(pView.ComObject, desktop.ComObject)); | ||
} | ||
|
||
public override VirtualDesktop GetCurrentDesktop() | ||
{ | ||
return this.GetDesktop(Args(IntPtr.Zero)); | ||
} | ||
|
||
public override IEnumerable<VirtualDesktop> GetDesktops() | ||
{ | ||
var array = this.Invoke<IObjectArray>(Args(IntPtr.Zero)); | ||
var count = array.GetCount(); | ||
var vdType = this.ComInterfaceAssembly.GetType("IVirtualDesktop"); | ||
|
||
for (var i = 0u; i < count; i++) | ||
{ | ||
array.GetAt(i, vdType.GUID, out var ppvObject); | ||
yield return VirtualDesktopCache.GetOrCreate(ppvObject); | ||
} | ||
} | ||
|
||
public override VirtualDesktop GetAdjacentDesktop(VirtualDesktop pDesktopReference, AdjacentDesktop uDirection) | ||
{ | ||
return this.GetDesktop(Args(pDesktopReference.ComObject, uDirection)); | ||
} | ||
|
||
public override void SwitchDesktop(VirtualDesktop desktop) | ||
{ | ||
this.Invoke(Args(IntPtr.Zero, desktop.ComObject)); | ||
} | ||
|
||
public override VirtualDesktop CreateDesktopW() | ||
{ | ||
return this.GetDesktop(Args(IntPtr.Zero)); | ||
} | ||
|
||
public override void MoveDesktop(VirtualDesktop desktop, int index) | ||
{ | ||
this.Invoke(Args(desktop.ComObject, IntPtr.Zero, index)); | ||
} | ||
|
||
public override void RemoveDesktop(VirtualDesktop pRemove, VirtualDesktop pFallbackDesktop) | ||
{ | ||
this.Invoke(Args(pRemove.ComObject, pFallbackDesktop.ComObject)); | ||
} | ||
|
||
public override VirtualDesktop FindDesktop(Guid desktopId) | ||
{ | ||
return this.GetDesktop(Args(desktopId)); | ||
} | ||
|
||
private VirtualDesktop GetDesktop(object[] parameters = null, [CallerMemberName] string methodName = "") | ||
=> VirtualDesktopCache.GetOrCreate(this.Invoke<object>(parameters, methodName)); | ||
|
||
public override void SetDesktopName(VirtualDesktop desktop, string name) | ||
{ | ||
this.Invoke(Args(desktop.ComObject, name)); | ||
} | ||
|
||
public override void SetDesktopWallpaper(VirtualDesktop desktop, string path) | ||
{ | ||
this.Invoke(Args(desktop.ComObject, path)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.