dotnet8 work, source unification work
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
@@ -110,8 +111,11 @@ namespace EveOPreview.Services
|
||||
public void SetActive(KeyValuePair<IntPtr, IThumbnailView> newClient)
|
||||
{
|
||||
this.GetActiveClient()?.ClearBorder();
|
||||
|
||||
#if LINUX
|
||||
this._windowManager.ActivateWindow(newClient.Key, newClient.Value.Title);
|
||||
#else
|
||||
this._windowManager.ActivateWindow(newClient.Key, this._configuration.WindowsAnimationStyle);
|
||||
#endif
|
||||
this.SwitchActiveClient(newClient.Key, newClient.Value.Title);
|
||||
|
||||
newClient.Value.SetHighlight();
|
||||
@@ -596,7 +600,11 @@ namespace EveOPreview.Services
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
#if LINUX
|
||||
this._windowManager.ActivateWindow(view.Id, view.Title);
|
||||
#else
|
||||
this._windowManager.ActivateWindow(view.Id, this._configuration.WindowsAnimationStyle);
|
||||
#endif
|
||||
})
|
||||
.ContinueWith((task) =>
|
||||
{
|
||||
@@ -611,7 +619,11 @@ namespace EveOPreview.Services
|
||||
{
|
||||
if (switchOut)
|
||||
{
|
||||
#if LINUX
|
||||
this._windowManager.ActivateWindow(this._externalApplication, null);
|
||||
#else
|
||||
this._windowManager.ActivateWindow(this._externalApplication, this._configuration.WindowsAnimationStyle);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using EveOPreview.Configuration;
|
||||
using EveOPreview.Services.Interop;
|
||||
@@ -13,8 +14,16 @@ namespace EveOPreview.Services.Implementation
|
||||
private const int NO_ANIMATION = 0;
|
||||
#endregion
|
||||
|
||||
public WindowManager()
|
||||
#region Private fields
|
||||
private readonly bool _enableWineCompatabilityMode;
|
||||
#endregion
|
||||
|
||||
|
||||
public WindowManager(IThumbnailConfiguration configuration)
|
||||
{
|
||||
#if LINUX
|
||||
this._enableWineCompatabilityMode = configuration.EnableWineCompatibilityMode;
|
||||
#endif
|
||||
// Composition is always enabled for Windows 8+
|
||||
this.IsCompositionEnabled =
|
||||
((Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor >= 2)) // Win 8 and Win 8.1
|
||||
@@ -61,7 +70,76 @@ namespace EveOPreview.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
// if building for LINUX the window handling is slightly different
|
||||
#if LINUX
|
||||
private void WindowsActivateWindow(IntPtr handle)
|
||||
{
|
||||
User32NativeMethods.SetForegroundWindow(handle);
|
||||
User32NativeMethods.SetFocus(handle);
|
||||
|
||||
int style = User32NativeMethods.GetWindowLong(handle, InteropConstants.GWL_STYLE);
|
||||
|
||||
if ((style & InteropConstants.WS_MINIMIZE) == InteropConstants.WS_MINIMIZE)
|
||||
{
|
||||
User32NativeMethods.ShowWindowAsync(handle, InteropConstants.SW_RESTORE);
|
||||
}
|
||||
}
|
||||
|
||||
private void WineActivateWindow(string windowName)
|
||||
{
|
||||
// On Wine it is not possible to manipulate windows directly.
|
||||
// They are managed by native Window Manager
|
||||
// So a separate command-line utility is used
|
||||
if (string.IsNullOrEmpty(windowName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string? cmd = null;
|
||||
// If we are in a flatpak, then use flatpak-spawn to run wmctrl outside the sandbox
|
||||
if (Environment.GetEnvironmentVariable("container") == "flatpak")
|
||||
{
|
||||
cmd = "-c \"flatpak-spawn --host wmctrl -a \"\"" + windowName + "\"\"\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = "-c \"wmctrl -a \"\"" + windowName + "\"\"\"";
|
||||
}
|
||||
|
||||
System.Diagnostics.Process.Start("/bin/bash", cmd);
|
||||
}
|
||||
|
||||
public void ActivateWindow(IntPtr handle, string windowName)
|
||||
{
|
||||
if (this._enableWineCompatabilityMode)
|
||||
{
|
||||
this.WineActivateWindow(windowName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WindowsActivateWindow(handle);
|
||||
}
|
||||
}
|
||||
|
||||
public void MinimizeWindow(IntPtr handle, bool enableAnimation)
|
||||
{
|
||||
if (enableAnimation)
|
||||
{
|
||||
User32NativeMethods.SendMessage(handle, InteropConstants.WM_SYSCOMMAND, InteropConstants.SC_MINIMIZE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
WINDOWPLACEMENT param = new WINDOWPLACEMENT();
|
||||
param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
|
||||
User32NativeMethods.GetWindowPlacement(handle, ref param);
|
||||
param.showCmd = WINDOWPLACEMENT.SW_MINIMIZE;
|
||||
User32NativeMethods.SetWindowPlacement(handle, ref param);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if WINDOWS
|
||||
public void ActivateWindow(IntPtr handle, AnimationStyle animation)
|
||||
{
|
||||
User32NativeMethods.SetForegroundWindow(handle);
|
||||
@@ -120,6 +198,7 @@ namespace EveOPreview.Services.Implementation
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public void MoveWindow(IntPtr handle, int left, int top, int width, int height)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user