Skip to content

Commit

Permalink
Upgrade to .NET 9, fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
widavies committed Dec 27, 2024
1 parent 7a6d7a3 commit 51e89fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions WinJump/Core/MouseHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr GetModuleHandle(string lpModuleName);

private static LowLevelMouseProc _proc = HookCallback;
private static readonly LowLevelMouseProc _proc = HookCallback;
private static IntPtr _hookID = IntPtr.Zero;

private static event EventHandler<MouseWheelScrolledEventArgs>? _mouseEvents;
Expand Down Expand Up @@ -52,7 +52,7 @@ private static IntPtr SetHook(LowLevelMouseProc proc) {

private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) {
if(nCode >= 0 && MouseMessages.WM_MOUSEWHEEL == (MouseMessages) wParam) {
MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT) Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
MSLLHOOKSTRUCT hookStruct = Marshal.PtrToStructure<MSLLHOOKSTRUCT>(lParam);
int delta = (short) ((hookStruct.mouseData & 0xFFFF0000) >> 16);

_mouseEvents?.Invoke(null, new MouseWheelScrolledEventArgs {
Expand Down
12 changes: 6 additions & 6 deletions WinJump/Core/WinJumpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ public WinJumpManager(DesktopChanged desktopChanged) {

if(toggleGroup != null) {
_thread?.JumpToNext(toggleGroup.Desktops.Select(x => x - 1).ToArray());

return;
}
};

Expand Down Expand Up @@ -148,15 +146,17 @@ public WinJumpManager(DesktopChanged desktopChanged) {
});

// Create sticky desktops config
var desktopsToCreate = int.Clamp(config.StickyDesktops - _thread.GetDesktopCount(), 0, Config.MAX_STICKY_DESKTOPS);
for (var i = 0; i < desktopsToCreate; i++) {
int desktopsToCreate = int.Clamp(config.StickyDesktops - _thread.GetDesktopCount(), 0, Config.MAX_STICKY_DESKTOPS);
for (int i = 0; i < desktopsToCreate; i++) {
_thread?.CreateDesktop();
}

// This particular event fires immediately on initial register
_explorerMonitor.OnColorSchemeChanged += lightMode => {
_lightMode = lightMode;
desktopChanged.Invoke(lightMode, (uint) _thread.GetCurrentDesktop());
if(_thread != null) {
desktopChanged.Invoke(lightMode, (uint) _thread.GetCurrentDesktop());
}
};

_explorerMonitor.OnExplorerRestarted += () => {
Expand Down Expand Up @@ -263,7 +263,7 @@ public void JumpTo(uint index, uint fallback) {

public void JumpTo(uint index) {

var allowJump = true;
bool allowJump = true;
WrapCall(() => {
// If the desktop is the same as the current one or doesn't exist, don't allow the jump
if(api.GetCurrentDesktop() == index) {
Expand Down
3 changes: 2 additions & 1 deletion WinJump/WinJump.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net9.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<Version>2.0.15</Version>
<AssemblyVersion>2.0.15</AssemblyVersion>
<FileVersion>2.0.15</FileVersion>
<LangVersion>default</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.0",
"version": "9.0.0",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down

0 comments on commit 51e89fc

Please sign in to comment.