Skip to content
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

Fixed Window dark mode issue for Windows 10 users! #449

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TBar09
Copy link

@TBar09 TBar09 commented Nov 20, 2024

-Added a fix for Windows 10 users where they would have to unfocus and refocus the application to set the window to dark mode.
-Added setWindowBorderColor, which can set the window header (and/or border) to any color.

Comment on lines +113 to +116
#if windows
flixel.FlxG.stage.window.borderless = true;
flixel.FlxG.stage.window.borderless = false;
#end
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to do this without toggling borderless? Can't you do UpdateWindow(window);


UpdateWindow(window);
')
public static function setWindowBorderColor(title:String, color:Array<Int>, setHeader:Bool = true, setBorder:Bool = false) {}
Copy link
Member

Choose a reason for hiding this comment

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

Tbh i would rather want setWindowBorderColor setWindowTitleColor

Copy link
Member

Choose a reason for hiding this comment

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

DWM Attributes

DWMWA_BORDER_COLOR (34)

Use with DwmSetWindowAttribute. Specifies the color of the window border. The pvAttribute parameter points to a value of type COLORREF. The app is responsible for changing the border color according to state changes, such as a change in window activation.

  • DWMWA_COLOR_NONE (0xFFFFFFFE): Suppresses the drawing of the window border, allowing for a rounded window with no border.
  • DWMWA_COLOR_DEFAULT (0xFFFFFFFF): Resets the window back to using the system's default behavior for the border color.

Supported: Starting with Windows 11 Build 22000.


DWMWA_CAPTION_COLOR (35)

Use with DwmSetWindowAttribute. Specifies the color of the caption. The pvAttribute parameter points to a value of type COLORREF.

  • DWMWA_COLOR_DEFAULT (0xFFFFFFFF): Resets the window back to using the system's default behavior for the caption color.

Supported: Starting with Windows 11 Build 22000.


DWMWA_TEXT_COLOR (36)

Use with DwmSetWindowAttribute. Specifies the color of the caption text. The pvAttribute parameter points to a value of type COLORREF.

  • DWMWA_COLOR_DEFAULT (0xFFFFFFFF): Resets the window back to using the system's default behavior for the caption text color.

Supported: Starting with Windows 11 Build 22000.

please do mention about the 0xFFFFFFFF/-1 being default color and that 0xFFFFFFFE/-2 is none color for the border, right now your code only does 0x00FFFFFF so theres no way for it to return to default color

/**
* Switch the window's color to any color. This is exclusive to windows 11 users, unfortunately.
*/
public static function setWindowBorderColor(title:String, color:Array<Int>, setHeader:Bool = true, setBorder:Bool = false) {
Copy link
Member

Choose a reason for hiding this comment

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

Please use flxcolor here

@@ -156,6 +156,9 @@ class Main extends Sprite
FlxG.signals.postStateSwitch.add(onStateSwitchPost);

FlxG.mouse.useSystemCursor = true;
#if DARK_MODE_WINDOW
if(funkin.backend.utils.NativeAPI.hasVersion("10")) funkin.backend.utils.NativeAPI.redrawWindowHeader();
Copy link
Member

Choose a reason for hiding this comment

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

What about windows 11 or other platforms that have the text 10

Comment on lines +144 to +155
@:functionCode('
int darkMode = enable ? 1 : 0;

HWND window = FindWindowA(NULL, title.c_str());
// Look for child windows if top level aint found
if (window == NULL) window = FindWindowExA(GetActiveWindow(), NULL, NULL, title.c_str());

if (window != NULL && S_OK != DwmSetWindowAttribute(window, 19, &darkMode, sizeof(darkMode))) {
DwmSetWindowAttribute(window, 20, &darkMode, sizeof(darkMode));
}
')
public static function setDarkMode(title:String, color:Array<Int>) {}
Copy link
Member

Choose a reason for hiding this comment

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

Please remove duplicate function

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