8000 feat: Set XIVLauncher AppID by KazWolfe · Pull Request #2230 · goatcorp/Dalamud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Set XIVLauncher AppID #2230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Dalamud/Interface/Internal/InterfaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

using CheapLoc;

using Dalamud.Common;
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.ClientState.GamePad;
Expand Down Expand Up @@ -503,6 +504,22 @@
sizeof(int))).ThrowOnError();
}

/// <summary>
/// Set the AppUserModelID for FFXIV for taskbar grouping.
/// </summary>
internal void SetAppUserModelId(string appId)

Check warning on line 510 in Dalamud/Interface/Internal/InterfaceManager.cs

View workflow job for this annotation

GitHub Actions / Build on Windows

{
if (Service<Dalamud>.Get().StartInfo.LoadMethod != LoadMethod.Entrypoint) return;

if (this.GameWindowHandle != 0)
{
Log.Warning("Game window was already created! AppID can't be set.");
return;
}

NativeFunctions.SetCurrentProcessExplicitAppUserModelID(appId);
}

private static InterfaceManager WhenFontsReady()
{
var im = Service<InterfaceManager>.GetNullable();
Expand Down Expand Up @@ -820,6 +837,9 @@
};
}

// Set app ID before the game UI is created.
this.SetAppUserModelId("com.squirrel.XIVLauncher.XIVLauncher");

// This will wait for scene on its own. We just wait for this.dalamudAtlas.BuildTask in this.InitScene.
_ = this.dalamudAtlas.BuildFontsAsync();

Expand Down
33 changes: 23 additions & 10 deletions Dalamud/NativeFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ public enum AccessibilityParameter
SPI_GETCLIENTAREAANIMATION = 0x1042,
#pragma warning restore SA1602
}

/// <summary>
/// Retrieves or sets the value of one of the system-wide parameters. This function can also update the user profile while setting a parameter.
/// </summary>
Expand Down Expand Up @@ -1428,18 +1428,18 @@ public enum HeapOptions
/// created with this option cannot be locked.
/// </summary>
NoSerialize = 0x00000001,

/// <summary>
/// The system raises an exception to indicate failure (for example, an out-of-memory condition) for calls to
/// HeapAlloc and HeapReAlloc instead of returning NULL.
/// </summary>
GenerateExceptions = 0x00000004,

/// <summary>
/// The allocated memory will be initialized to zero. Otherwise, the memory is not initialized to zero.
/// </summary>
ZeroMemory = 0x00000008,

/// <summary>
/// All memory blocks that are allocated from this heap allow code execution, if the hardware enforces data
/// execution prevention. Use this flag heap in applications that run code from the heap. If
Expand Down Expand Up @@ -1701,7 +1701,7 @@ public static extern bool ReadProcessMemory(
///
/// This value determines the initial amount of memory that is committed for the heap.
/// The value is rounded up to a multiple of the system page size. The value must be smaller than dwMaximumSize.
///
///
/// If this parameter is 0, the function commits one page. To determine the size of a page on the host computer,
/// use the GetSystemInfo function.
/// </param>
Expand All @@ -1710,25 +1710,25 @@ public static extern bool ReadProcessMemory(
/// system page size and then reserves a block of that size in the process's virtual address space for the heap.
/// If allocation requests made by the HeapAlloc or HeapReAlloc functions exceed the size specified by
/// dwInitialSize, the system commits additional pages of memory for the heap, up to the heap's maximum size.
///
///
/// If dwMaximumSize is not zero, the heap size is fixed and cannot grow beyond the maximum size. Also, the largest
/// memory block that can be allocated from the heap is slightly less than 512 KB for a 32-bit process and slightly
/// less than 1,024 KB for a 64-bit process. Requests to allocate larger blocks fail, even if the maximum size of
/// the heap is large enough to contain the block.
///
///
/// If dwMaximumSize is 0, the heap can grow in size. The heap's size is limited only by the available memory.
/// Requests to allocate memory blocks larger than the limit for a fixed-size heap do not automatically fail;
/// instead, the system calls the VirtualAlloc function to obtain the memory that is needed for large blocks.
/// Applications that need to allocate large memory blocks should set dwMaximumSize to 0.
/// </param>
/// <returns>
/// If the function succeeds, the return value is a handle to the newly created heap.
///
///
/// If the function fails, the return value is NULL. To get extended error information, call GetLastError.
/// </returns>
[DllImport("kernel32.dll", SetLastError = true)]
public static extern nint HeapCreate(HeapOptions flOptions, nuint dwInitialSize, nuint dwMaximumSize);

/// <summary>
/// Allocates a block of memory from a heap. The allocated memory is not movable.
/// </summary>
Expand Down Expand Up @@ -1756,7 +1756,7 @@ public static extern bool ReadProcessMemory(
/// </returns>
[DllImport("kernel32.dll", SetLastError=false)]
public static extern nint HeapAlloc(nint hHeap, HeapOptions dwFlags, nuint dwBytes);

/// <summary>
/// See https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc.
/// Reserves, commits, or changes the state of a region of pages in the virtual address space of the calling process.
Expand Down Expand Up @@ -2111,3 +2111,16 @@ public enum DWMWINDOWATTRIBUTE : int
[DllImport("dwmapi.dll", PreserveSig = true)]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE attr, ref int attrValue, int attrSize);
}

/// <summary>
/// shell32 native functions
/// </summary>
internal static partial class NativeFunctions
{
/// <summary>
/// Sets the value of the AppUserModelID for the current process.
/// </summary>
/// <param name="appId">The AppID to set.</param>
[DllImport("shell32.dll", SetLastError=true)]
public static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string appId);
}
Loading
0