Skip to content

Commit

Permalink
csharpier
Browse files Browse the repository at this point in the history
  • Loading branch information
FaithBeam committed Oct 8, 2024
1 parent dc0ff3b commit cdd61a0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
44 changes: 37 additions & 7 deletions YMouseButtonControl.Linux/Services/CurrentWindowServiceX11.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,47 @@ private static string GetForegroundWindow()
var prop = X11.XInternAtom(display, Marshal.StringToHGlobalAnsi("_NET_ACTIVE_WINDOW"), 0);
var pidProp = X11.XInternAtom(display, Marshal.StringToHGlobalAnsi("_NET_WM_PID"), 1);

if (X11.XGetWindowProperty(display, root, prop, 0, sizeof(ulong), 0, 0,
out _, out _, out _,
out _, out var outProp) != 0 || outProp == nint.Zero)
if (
X11.XGetWindowProperty(
display,
root,
prop,
0,
sizeof(ulong),
0,
0,
out _,
out _,
out _,
out _,
out var outProp
) != 0
|| outProp == nint.Zero
)
{
return null;
}

var activeWindow = *(nint*)outProp;
X11.XFree(outProp);

if (X11.XGetWindowProperty(display, activeWindow, pidProp, 0, sizeof(int), 0, 0, out _, out _, out _, out _,
out var prop2) != 0 || prop2 == nint.Zero)
if (
X11.XGetWindowProperty(
display,
activeWindow,
pidProp,
0,
sizeof(int),
0,
0,
out _,
out _,
out _,
out _,
out var prop2
) != 0
|| prop2 == nint.Zero
)
{
return null;
}
Expand Down Expand Up @@ -95,5 +124,6 @@ internal static partial int XGetWindowProperty(
out int actualFormatReturn,
out ulong nItemsReturn,
out ulong bytesAfterReturn,
out IntPtr propReturn);
}
out IntPtr propReturn
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ private static void RegisterMacOsServices(IServiceCollection services)
.AddScoped<ICurrentWindowService, MacOS.Services.CurrentWindowService>()
.AddScoped<IBackgroundTasksRunner, MacOS.Services.BackgroundTasksRunner>();
}
}
}

0 comments on commit cdd61a0

Please sign in to comment.