forked from dnSpy/dnSpy
-
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable WPF hardware acceleration when running dnSpy under Wine
- Loading branch information
1 parent
7ce4d52
commit f20c005
Showing
2 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Windows.Interop; | ||
using System.Windows.Media; | ||
|
||
namespace dnSpy.MainApp { | ||
/// <summary> | ||
/// Applies fixes and compatibility workarounds for running on Wine. | ||
/// </summary> | ||
static class WineFixes { | ||
public static void Initialize() { | ||
if (!IsRunningOnWine()) | ||
return; | ||
|
||
// Disable WPF hardware acceleration on Wine | ||
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; | ||
} | ||
|
||
static bool IsRunningOnWine() { | ||
var ntdll = GetModuleHandle("ntdll.dll"); | ||
if (ntdll == IntPtr.Zero) | ||
return false; | ||
return GetProcAddress(ntdll, "wine_get_version") != IntPtr.Zero; | ||
} | ||
|
||
[DllImport("kernel32", SetLastError = true)] | ||
static extern IntPtr GetModuleHandle(string lpModuleName); | ||
|
||
[DllImport("kernel32", SetLastError = true)] | ||
static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); | ||
} | ||
} |