Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Commit

Permalink
better virtualdesktop management
Browse files Browse the repository at this point in the history
  • Loading branch information
glsorre committed May 30, 2021
1 parent ec75cb1 commit 19f7520
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 21 additions & 12 deletions AmethystWindowsSystray/DesktopWindowManager.Internal/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
Point point = new Point(properties[1].Value.ToObject<int>() + 100, properties[2].Value.ToObject<int>() + 100);
HMONITOR monitor = User32.MonitorFromPoint(point, User32.MonitorFlags.MONITOR_DEFAULTTONEAREST);

int virtualDesktopIndex = VirtualDesktop.SearchDesktop(properties[0].Value.ToString());

virtualDesktop = VirtualDesktop.FromIndex(VirtualDesktop.SearchDesktop(properties[0].Value.ToString()));
hMONITOR = monitor;
layout = (Layout)properties[3].Value.ToObject<int>();
}
if (virtualDesktopIndex != -1)
{
virtualDesktop = VirtualDesktop.FromIndex(virtualDesktopIndex);
hMONITOR = monitor;
layout = (Layout)properties[3].Value.ToObject<int>();

var key = new Pair<VirtualDesktop, HMONITOR>(virtualDesktop, hMONITOR);
list.Add(new KeyValuePair<Pair<VirtualDesktop, HMONITOR>, Layout>(key, layout));
var key = new Pair<VirtualDesktop, HMONITOR>(virtualDesktop, hMONITOR);
list.Add(new KeyValuePair<Pair<VirtualDesktop, HMONITOR>, Layout>(key, layout));
}
}

return list;
}
Expand Down Expand Up @@ -160,13 +164,18 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
Point point = new Point(properties[1].Value.ToObject<int>() + 100, properties[2].Value.ToObject<int>() + 100);
HMONITOR monitor = User32.MonitorFromPoint(point, User32.MonitorFlags.MONITOR_DEFAULTTONEAREST);

virtualDesktop = VirtualDesktop.FromIndex(VirtualDesktop.SearchDesktop(properties[0].Value.ToString()));
hMONITOR = monitor;
factor = properties[3].Value.ToObject<int>();
}
int virtualDesktopIndex = VirtualDesktop.SearchDesktop(properties[0].Value.ToString());

var key = new Pair<VirtualDesktop, HMONITOR>(virtualDesktop, hMONITOR);
list.Add(new KeyValuePair<Pair<VirtualDesktop, HMONITOR>, int>(key, factor));
if (virtualDesktopIndex != -1)
{
virtualDesktop = VirtualDesktop.FromIndex(virtualDesktopIndex);
hMONITOR = monitor;
factor = properties[3].Value.ToObject<int>();

var key = new Pair<VirtualDesktop, HMONITOR>(virtualDesktop, hMONITOR);
list.Add(new KeyValuePair<Pair<VirtualDesktop, HMONITOR>, int>(key, factor));
}
}

return list;
}
Expand Down
2 changes: 1 addition & 1 deletion AmethystWindowsSystray/SystrayContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ private async void App_Refresh()
item.Add(w.value.Window.DangerousGetHandle().ToString());
item.Add(w.value.AppName);
item.Add(w.value.ClassName);
item.Add(w.value.VirtualDesktop.ToString());
item.Add(VirtualDesktop.DesktopNameFromDesktop(w.value.VirtualDesktop));
item.Add(screen.DeviceName.ToString().Remove(0,4));
item.Add(w.value.Info.rcWindow.ToString());
item.Add(w.value.Info.dwStyle.ToString());
Expand Down

0 comments on commit 19f7520

Please sign in to comment.