Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmd5 committed Feb 20, 2024
1 parent 77383d7 commit 76d8040
Show file tree
Hide file tree
Showing 15 changed files with 823 additions and 804 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added .github/.DS_Store
Binary file not shown.
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: publish Borderless Gaming

on: [push, pull_request]
#on:
# push:
# tags:
# - "*.*.*"

on:
push:
tags:
- "*.*.*"

jobs:
publish:
Expand All @@ -25,7 +25,7 @@ jobs:

- name: Install bebopc
shell: pwsh
run: irm https://bebop.sh | iex
run: $version = '2.7.4'; $script = irm "https://bebop.sh"; & ([scriptblock]::Create($script)) -bebopcVersion $version

- name: Build release
shell: pwsh
Expand Down
Binary file added BorderlessGaming/.DS_Store
Binary file not shown.
7 changes: 4 additions & 3 deletions BorderlessGaming/BorderlessGaming.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<SelfContained>true</SelfContained>
<AssemblyVersion>9.5.6</AssemblyVersion>
<FileVersion>9.5.6</FileVersion>
<Version>9.5.6</Version>
<AssemblyVersion>10.0.0</AssemblyVersion>
<FileVersion>10.0.0</FileVersion>
<Version>10.0.0</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>BorderlessGaming_new.ico</ApplicationIcon>
Expand Down
Binary file added BorderlessGaming/Logic/.DS_Store
Binary file not shown.
32 changes: 28 additions & 4 deletions BorderlessGaming/Logic/Extensions/ProcessExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,53 @@ namespace BorderlessGaming.Logic.Extensions
{
internal static class ProcessExtensions
{

#nullable enable
public static Process? GetProcessById(int id)
{
try
{
return Process.GetProcessById(id);
}
catch
{
return null;
}
}
#nullable disable

private static string FindIndexedProcessName(int pid)
{
var processName = Process.GetProcessById(pid).ProcessName;
using var process = GetProcessById(pid);
if (process is null)
{
return string.Empty;
}
var processName = process.ProcessName;
var processesByName = Process.GetProcessesByName(processName);
string processIndexdName = null;

for (var index = 0; index < processesByName.Length; index++)
{
processIndexdName = index == 0 ? processName : processName + "#" + index;
var processId = new PerformanceCounter("Process", "ID Process", processIndexdName);
if ((int) processId.NextValue() == pid)
if ((int)processId.NextValue() == pid)
{
return processIndexdName;
}
}

return processIndexdName;
}

private static Process FindPidFromIndexedProcessName(string indexedProcessName)
{
if (string.IsNullOrEmpty(indexedProcessName))
{
return null;
}
var parentId = new PerformanceCounter("Process", "Creating Process ID", indexedProcessName);
return Process.GetProcessById((int) parentId.NextValue());
return Process.GetProcessById((int)parentId.NextValue());
}

public static Process Parent(this Process process)
Expand Down
1,529 changes: 755 additions & 774 deletions BorderlessGaming/Logic/Models/Models.g.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public partial class UserPreferences
"iw4 console",
"steam",
"origin",
"uplay"
"uplay",
"msedge"

// Let them hide the rest manually
};
Expand Down
2 changes: 1 addition & 1 deletion BorderlessGaming/Logic/Steam/SteamAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void Init()
IsLoaded = true;
}
catch (Exception ex)
{
{
Console.WriteLine("Failed to load Steam.");
ExceptionHandler.LogException(ex);
}
Expand Down
24 changes: 15 additions & 9 deletions BorderlessGaming/Logic/Windows/ForegroundManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using BorderlessGaming.Logic.Extensions;
using BorderlessGaming.Logic.Models;

namespace BorderlessGaming.Logic.Windows
Expand All @@ -17,13 +18,13 @@ public static class ForegroundManager
public static void Subscribe()
{
_dele = WinEventProc;
_mHhook = Native.SetWinEventHook(EventSystemForeground, EventSystemForeground, IntPtr.Zero, _dele, 0, 0, WineventOutofcontext);
_mHhook = Native.SetWinEventHook(EventSystemForeground, EventSystemForeground, IntPtr.Zero, _dele, 0, 0, WineventOutofcontext);
}

private const uint WineventOutofcontext = 0;
private const uint EventSystemForeground = 3;


public static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
{
if (UserPreferences.Instance.Favorites is not null)
Expand All @@ -32,15 +33,20 @@ public static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwn
{
var handle = Native.GetForegroundWindow();
Native.GetWindowThreadProcessId(handle, out uint processId);
var details = new ProcessDetails(Process.GetProcessById((int)processId), handle);
var process = ProcessExtensions.GetProcessById((int)processId);
if (process is null)
{
return;
}
var details = new ProcessDetails(process, handle);
foreach (var fav in UserPreferences.Instance.Favorites.Where(favorite => favorite.IsRunning && favorite.MuteInBackground))
{

if (fav.Matches(details))
{
if (Native.IsMuted((int) processId))
if (Native.IsMuted((int)processId))
{
Native.UnMuteProcess((int) processId);
Native.UnMuteProcess((int)processId);
}
}
else
Expand All @@ -51,14 +57,14 @@ public static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwn
}
}
}

}
catch (Exception)
{
//
//
}
}

}
}
}
12 changes: 9 additions & 3 deletions BorderlessGaming/Logic/Windows/Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using BorderlessGaming.Logic.Extensions;
using BorderlessGaming.Logic.Models;

namespace BorderlessGaming.Logic.Windows
Expand Down Expand Up @@ -31,7 +32,7 @@ bool Del(IntPtr hwnd, uint lParam)
{
if (Native.GetWindowRect(ptr, out Native.Rect rect))
{
if (((Rectangle) rect).IsEmpty)
if (((Rectangle)rect).IsEmpty)
{
continue;
}
Expand All @@ -43,7 +44,12 @@ bool Del(IntPtr hwnd, uint lParam)
}
uint processId;
Native.GetWindowThreadProcessId(ptr, out processId);
callback(new ProcessDetails(Process.GetProcessById((int) processId), ptr)
var process = ProcessExtensions.GetProcessById((int)processId);
if (process is null)
{
continue;
}
callback(new ProcessDetails(process, ptr)
{
Manageable = true
});
Expand Down Expand Up @@ -77,7 +83,7 @@ private static bool GetMainWindowForProcess_EnumWindows(List<IntPtr> ptrList, In
case 1:
if (Native.IsWindowVisible(hWndEnumerated))
{
if ((uint) styleCurrentWindowStandard != 0)
if ((uint)styleCurrentWindowStandard != 0)
{
ptrList.Add(hWndEnumerated);
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ or if you're suffering from crashes or bugs submit information [here](https://gi
## Contact info

* **Twitter:** [@AndrewMD5](https://twitter.com/andrewmd5)
* **Blog:** [blog.andrew.im](http://blog.andrew.im)
* **Website:** [andrew.im](https://andrew.im)

# Join our Steam Group!
[Borderless Gaming on Steam](https://steamcommunity.com/app/388080/discussions/)
2 changes: 1 addition & 1 deletion scripts/build-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ $projectXml.Save($csproj)

& bebopc
& dotnet restore "$cjproj"
& dotnet publish "$csproj"
& dotnet publish "$csproj" -c Release -r win-x64
& iscc "$root\Installers\BorderlessGaming_Standalone_Admin.iss"
2 changes: 1 addition & 1 deletion version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<borderlessgaming>
<version>9.5.6</version>
<version>10.0.0</version>
<url>https://github.com/Codeusa/Borderless-Gaming/releases/latest</url>
</borderlessgaming>

0 comments on commit 76d8040

Please sign in to comment.