WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

When hiding titlebar a few white pixels still show on top

Open dotMorten opened this issue 2 years ago • 9 comments

Describe the bug

When hiding the titlebar using OverlappedPresenter.SetBorderAndTitleBar(true, false) a few pixels of white titlebar still shows.

Steps to reproduce the bug

  1. Create a new WinUI app.
  2. in app.xaml root tag, set RequestedTheme="Dark"
  3. in MainWindow.xaml.cs constructor add this code to hide the titlebar
            var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
            Microsoft.UI.WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
            Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
            var presenter = appWindow.Presenter as Microsoft.UI.Windowing.OverlappedPresenter;
            presenter.SetBorderAndTitleBar(true, false);

Run the app, and observe the white color on top of the window.

Expected behavior

Entire window is black

Screenshots

image

NuGet package version

1.1.3

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 21H2 (22000)

IDE

Visual Studio 2022-preview

Additional context

First reported in WinUIEx: https://github.com/dotMorten/WinUIEx/issues/67

dotMorten avatar Jul 21 '22 17:07 dotMorten

@mevey can you take a look?

cc: @btueffers

gabbybilka avatar Jul 23 '22 00:07 gabbybilka

pong @rkarman

riverar avatar Jul 23 '22 16:07 riverar

I've successfully repro-ed this bug :( and filed it task.ms/40617153

mevey avatar Jul 25 '22 22:07 mevey

Hi @dotMorten, what is the intended goal of hiding the title bar? To draw your own? To have a PIP experience? To have a window that is not movable or resizable perhaps? This is helpful as we try to figure out how to solve this problem.

mevey avatar Sep 07 '22 18:09 mevey

@mevey I'd ask the Windows App SDK team who added that API :-) But a few things come to mind, like splash screens or more custom drawn windows.

dotMorten avatar Sep 07 '22 18:09 dotMorten

Perhaps @ArchieCoder can add details, since he originally logged this bug in WinUIEx

dotMorten avatar Sep 07 '22 20:09 dotMorten

Here is my original issue in WinUIEx: https://github.com/dotMorten/WinUIEx/issues/67

Someone has the workaround: https://github.com/dotMorten/WinUIEx/issues/67#issuecomment-1206649424

ArchieCoder avatar Sep 08 '22 00:09 ArchieCoder

@ArchieCoder thanks but I think they are looking for the ‘why’ you were doing this to justify fixing their API

dotMorten avatar Sep 08 '22 01:09 dotMorten

The original goal was to hide the color of the title bar because it didn't find the rest of the app. If the title bar color can be changed, this is then a non-issue anymore.

ArchieCoder avatar Sep 08 '22 13:09 ArchieCoder