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

When hiding titlebar a few white pixels still show on top #8947

Open
dotMorten opened this issue Jul 21, 2022 · 22 comments
Open

When hiding titlebar a few white pixels still show on top #8947

dotMorten opened this issue Jul 21, 2022 · 22 comments
Labels
area-AppWindow area-Windowing bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team transfer-repo

Comments

@dotMorten
Copy link
Contributor

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: dotMorten/WinUIEx#67

@dotMorten dotMorten changed the title When hiding titlebar a few while pixels still show on top When hiding titlebar a few white pixels still show on top Jul 21, 2022
@btueffers btueffers transferred this issue from microsoft/WindowsAppSDK Jul 21, 2022
@gabbybilka gabbybilka transferred this issue from microsoft/microsoft-ui-xaml Jul 23, 2022
@gabbybilka
Copy link
Member

@mevey can you take a look?

cc: @btueffers

@riverar
Copy link
Contributor

riverar commented Jul 23, 2022

pong @rkarman

@mevey
Copy link

mevey commented Jul 25, 2022

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

@mevey
Copy link

mevey commented Sep 7, 2022

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.

@dotMorten
Copy link
Contributor Author

@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
Copy link
Contributor Author

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

@ArchieCoder
Copy link

Here is my original issue in WinUIEx: dotMorten/WinUIEx#67

Someone has the workaround: dotMorten/WinUIEx#67 (comment)

@dotMorten
Copy link
Contributor Author

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

@ArchieCoder
Copy link

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.

@ACGNnsj
Copy link

ACGNnsj commented May 9, 2023

It seems unchanged in WAS 1.3, so should I consider it a normal behavior? At least, 'ExtendsContentIntoTitleBar' helps eliminate the white space.

@stevenbrix
Copy link
Contributor

we would like to get rid of this little white border as well. we want to have full control over the appearance of the window for our app and this prevents us from doing that

@riverar
Copy link
Contributor

riverar commented Aug 5, 2023

@stevenbrix That's the caption area peeking out there; here's a workaround for now:

var windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(this);
int colorBlack = 0x00_00_00_00;
unsafe
{
    DwmSetWindowAttribute(new HWND(windowHandle),
        DWMWINDOWATTRIBUTE.DWMWA_CAPTION_COLOR, &colorBlack, sizeof(int));
}

Notes:

  • Congrats, you've now signed up to monitor for DWM theme/colorization, high contrast, etc. changes and set this caption color accordingly! This involves a number of events and window messages. Some documented, some not.
  • You'll want to bind that to the user's color preferences.
  • Solid colors only. No fancy art up there or the bar will "reappear".
  • This doesn't work on Windows 10 or Windows 11 before build 22000.

@pratikone
Copy link
Contributor

pratikone commented Aug 7, 2023

I am aware of this issue. Seems like something Windows shell puts and unless it gets patched, it cannot be removed. I suggest not using this api (if rest of appwindow/winui3 custom titlebar apis are not filling the requirements, because they cover a lot cases now including interactive controls within the titlebar), but rolling out a custom titlebar solution using a custom WndProc and using WS_EX_LAYERED and WS_OVERLAPPED styles, but using 1.4 newly introduced InputNonClientPointerSource apis (can find it only in preview2/experimental1 builds for now) for doing the heavy lifting around Non client message handling. Let me know if any of you need a sample, I can put together a solution you can refer.
Adding @tiberiu2 as he is the owner of appwindow titlebar apis as well as these new ones

@riverar
Copy link
Contributor

riverar commented Aug 7, 2023

@pratikone Are you saying OverlappedPresenter.SetBorderAndTitleBar(..., false) is forever broken and that developers will have to handle NC painting/messages manually for no-titlebar scenarios?

@riverar
Copy link
Contributor

riverar commented Aug 8, 2023

@pratikone @tiberiu2 Can either of you answer my question? I was simply asking for clarification of @pratikone's comment above. Thanks!

@pratikone
Copy link
Contributor

pratikone commented Oct 5, 2023

@pratikone Are you saying OverlappedPresenter.SetBorderAndTitleBar(..., false) is forever broken and that developers will have to handle NC painting/messages manually for no-titlebar scenarios?

I am not saying that at all. I am saying that while this issue gets fixed (given the fix has to be in windows shell code) , there exists a immediate workaround which is much simpler than earlier i.e. let InputNonClientPointerSource apis handle NC messages for a vanilla custom solution.

@pratikone pratikone transferred this issue from microsoft/WindowsAppSDK Oct 5, 2023
@riverar
Copy link
Contributor

riverar commented Oct 5, 2023

Sounds like we're in disagreement over "forever", that's fair.

Maybe we can get this documented as a known issue when using this API for future devs?

@pratikone
Copy link
Contributor

Yeah, that seems right. This issue has existed for some time and affects any app which does custom titlebar. If you are quick enough, you can spot it during launch of Visual Studio too. It goes away quickly.

Let me check internally if we can make some progress on fixing this.if not, getting it documented would be a good step too. Thanks for the suggestion

@bpulliam bpulliam added the team-CompInput Issue for IXP (Composition, Input) team label Oct 18, 2023
@duncanmacmichael duncanmacmichael added the bug Something isn't working label Oct 31, 2023
@duncanmacmichael
Copy link
Member

Fixed in 1.4.3, closing issue.

@khoabui1412
Copy link

I just tested in ver 1.4.3 but issue still remains

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Nov 21, 2023
@dotMorten
Copy link
Contributor Author

I see the same thing. @duncanmacmichael Can we're open this?

@ranjeshj ranjeshj reopened this Dec 1, 2023
@LucaCris
Copy link

LucaCris commented Dec 6, 2023

Not fixed, when app is maximized:

Screenshot 2023-12-06 104358

(I assure you, there is an one pixel white line on top, try to open image out of this page).

@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-AppWindow area-Windowing bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team transfer-repo
Projects
None yet
Development

No branches or pull requests