FluentAvalonia icon indicating copy to clipboard operation
FluentAvalonia copied to clipboard

White outline

Open VeyDlin opened this issue 2 years ago • 7 comments

After launching the application, until the window loses focus for the first time or the user changes its size, a white outline on a black theme is visible. Acrylic also behaves strangely.

Immediately after launch: 1

If you remove the window from focus and select again: 2

This problem can also be reproduced in FluentAvaloniaSamples. To do this, you need:

  1. Launch the application and do not change its focus.
  2. Go to Settings
  3. Choose a dark theme

2022-05-26_11-54-34

2022-05-26_11-54-51

  • OS Windows 10
  • FluentAvalonia Version 1.3.5
  • Avalonia Version 0.10.14

VeyDlin avatar May 26 '22 08:05 VeyDlin

The white outline is the system window border (Win32 windows are always light mode by default hence the white). There is an API to force the window into dark mode (CoreWindow handles that automatically - which is why it works after you unfocus then reactivate the window), but it seems to fail to apply on first launch. Unfortunately that falls into the 'undocumented' APIs of Windows which makes things hard to diagnose. I thought I had fixed this, but that seems to have already regressed. Will take another look...

amwx avatar May 27 '22 01:05 amwx

Note there is still a little red (accent color i think) line at the very top of the window. I personally don't like this, that's a reason I don't use core window

timunie avatar Jun 27 '22 13:06 timunie

Note there is still a little red (accent color i think) line at the very top of the window. I personally don't like this, that's a reason I don't use core window

Unfortunately there's not much I can do about that, there's a bug within the OS in Windows 10 when the WS_EX_NOREDIRECTIONBITMAP flag is set (WinUI Composition) with Extended frames where the top border of the window isn't drawn - so I draw it manually. But I assume the system accent color for the border, but if the rest of the frame is white it means the "Show accent color on Titlebars and borders" is turned off in Windows settings. Unfortunately there's no API for reading that setting, and I don't want to rely on the registry to check it. The only other way to fix it is to do what Windows Terminal does (and UWP internally) but that would require completely rewriting the Win32 window and I don't think that's possible outside of the Avalonia source. Trust me, it bothers me too, but at least right now, it is what it is

amwx avatar Jun 28 '22 01:06 amwx

I don't mind that there is a border drawn, but I would like to change the color to whatever color I prefer. If that was possible to define, it would be great I think. Maybe one could even tell the border to be transparent.

Just to be clear, I like this lib and also I know how much effort you do to deliver it. So if it's not easily possible to do, let's keep what we have so far.

Happy coding Tim

timunie avatar Jun 28 '22 06:06 timunie

Hello there, I got the same problem from days and I found a work around today. To remove the white outline, you need to force Win32 theme before initializing your main window.

var thm = AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>();
thm?.ForceWin32WindowToTheme(this);
[...]
InitializeComponent();

Hope this will help you.

zlnimda avatar Jul 06 '22 16:07 zlnimda

Hello there, I got the same problem from days and I found a work around today. To remove the white outline, you need to force Win32 theme before initializing your main window.

var thm = AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>();
thm?.ForceWin32WindowToTheme(this);
[...]
InitializeComponent();

Hope this will help you.

Oh, it worked for me, but only if I do it after initializing If I call the code before initializing then it doesn't work This is strange Here is my code

...
    public partial class MainWindow : CoreWindow {
        public MainWindow() {
            InitializeComponent();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
                var thm = AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>();
                thm?.ForceWin32WindowToTheme(this);
            }
...

VeyDlin avatar Jul 09 '22 12:07 VeyDlin

This solution worked before/after InitializeComponent() call. The blue outline at the top is still visible, but this was only 25% of the problem :yum: so good catch...

alex6dj avatar Jul 09 '22 13:07 alex6dj

solved? (#222)

danielmayost avatar Nov 06 '22 05:11 danielmayost

Forgot to link the issue. Yes, this should now be solved with AppWindow

amwx avatar Nov 06 '22 23:11 amwx