Skip to content

Conversation

@roeseth
Copy link

@roeseth roeseth commented Dec 15, 2025

Add a mod to center taskbar and system tray as a single unit to provide better usability in ultrawide screen.
Also offer an offset only mode to just offset the system tray.

@m417z
Copy link
Member

m417z commented Dec 15, 2025

Thanks for the submission. Here's how it looks on my computer with the default settings, I assume the edges shouldn't look like this:

image

Also, you're using XAML Diagnostics (InitializeXamlDiagnosticsEx), which makes the mod incompatible with other mods or customization tools that use it. Specifically, it makes the mod incompatible with Windows 11 Taskbar Styler.

You can keep it as is, in which case I think it'd be a good idea to add a notice about it in the readme. Alternatively, you might want to update the implementation such that XAML Diagnostics API isn't used. There are several mod examples which can serve as an example, for example Start button always on the left:

XamlRoot xamlRoot = nullptr;
if (_wcsicmp(szClassName, L"Shell_TrayWnd") == 0) {
xamlRoot = GetTaskbarXamlRoot(hWnd);
} else if (_wcsicmp(szClassName, L"Shell_SecondaryTrayWnd") == 0) {
xamlRoot = GetSecondaryTaskbarXamlRoot(hWnd);
} else {
return TRUE;
}
if (!xamlRoot) {
Wh_Log(L"Getting XamlRoot failed");
return TRUE;
}
if (!ApplyStyle(xamlRoot)) {
Wh_Log(L"ApplyStyles failed");
return TRUE;
}

@roeseth
Copy link
Author

roeseth commented Dec 15, 2025

thank you, yea I'll take a look at other examples. I want to minimize the conflict with other mods, but I'm pretty new to the modding here, do you mind helping me understand some other potential conflicts or preferred method that I should look into?

@m417z
Copy link
Member

m417z commented Dec 15, 2025

XAML Diagnostics API is a unique conflict, as only one consumer can use it due to the way it works. The API was designed for debugging, and has several shortcomings. No other conflicts are expected unless you do something specific.

preferred method that I should look into?

A good starting point is to take a mod which uses GetTaskbarXamlRoot, strip all the pieces that are specific to that mod, and see if what's left works for you, e.g. a function that is called to apply/undo taskbar customizations.

I provided taskbar-start-button-position as an example. Perhaps taskbar-multirow is a better example since it's a smaller mod.

@roeseth
Copy link
Author

roeseth commented Dec 22, 2025

Updated to use GetTaskbarXamlRoot instead of InitializeXamlDiagnosticsEx

{
try
{
taskbarFrame.LayoutUpdated(g_layoutUpdatedToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be run from the taskbar (UI) thread.

Something like:

HWND hTaskbarWnd = FindCurrentProcessTaskbarWnd();
if (hTaskbarWnd)
{
    RunFromWindowThread(
        hTaskbarWnd, [](void *pParam)
        { /* cleanup code here */ }, 0);
}

Also generally, I suggest to at least print errors instead of having empty catch blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants