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

Use black border color in borderless fullscreen mode on Windows #88734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Feb 23, 2024

This makes the border much less noticeable, or even completely invisible on OLED displays.

The gray border is still visible for a split second after starting a project configured to run in fullscreen (while the splash screen is still displayed). Any ideas on how to make it black as soon as possible? cc @bruvzg

Preview

Example on the edges of an OLED display (LG C2 42"):

Before

20240223_194005

After

20240223_194011

@Calinou Calinou requested a review from a team as a code owner February 23, 2024 19:59
@Calinou Calinou changed the title windows borderless fullscreen use black border Use black border color in borderless fullscreen mode on Windows Feb 23, 2024
@Calinou Calinou added this to the 4.x milestone Feb 23, 2024
@bruvzg
Copy link
Member

bruvzg commented Feb 23, 2024

The gray border is still visible for a split second after starting a project configured to run in fullscreen (while the splash screen is still displayed). Any ideas on how to make it black as soon as possible?

Probably related to the early BG erase:

case WM_ERASEBKGND: {
Color early_color;
if (!_get_window_early_clear_override(early_color)) {
break;
}
bool must_recreate_brush = !window_bkg_brush || window_bkg_brush_color != early_color.to_argb32();
if (must_recreate_brush) {
if (window_bkg_brush) {
DeleteObject(window_bkg_brush);
}
window_bkg_brush = CreateSolidBrush(RGB(early_color.get_r8(), early_color.get_g8(), early_color.get_b8()));
}
HDC hdc = (HDC)wParam;
RECT rect = {};
if (GetUpdateRect(hWnd, &rect, true)) {
FillRect(hdc, &rect, window_bkg_brush);
}
return 1;
} break;

Maybe RedrawWindow should be called with RDW_FRAME flag when splash is displayed (not sure where exactly is the most appropriate place to do it) to force redraw the border. Or WM_ERASEBKGND should draw back border and fill only the client area if it's in full-screen.

@bruvzg
Copy link
Member

bruvzg commented Feb 23, 2024

This looks better, but I feel like we might still want to add another option for FS (see #63500 (comment)), in a non compatibility breaking manner, maybe something like:

  • MODE_FULLSCREEN → (WS_OVERLAPPED | WS_BORDER + screen size), with black border.
  • MODE_EXCLUSIVE_FULLSCREEN and BORDERLESS flag is not set → (WS_POPUP + screen size), always "exclusive".
  • MODE_EXCLUSIVE_FULLSCREEN and BORDERLESS flag is set → (WS_OVERLAPPED + screen size), w/o border, might be "borderless" or "exclusive" depending on GPU.

@Calinou
Copy link
Member Author

Calinou commented Feb 23, 2024

This looks better, but I feel like we might still want to add another option for FS (see #63500 (comment)), in a non compatibility breaking manner, maybe something like:

I agree it's good to have both modes available (as in, "best-effort borderless fullscreen" and "forced borderless fullscreen"). The proposed API should work well with existing projects as I'm not aware of any projects that enable both exclusive fullscreen and borderless at the same time currently.

@bruvzg
Copy link
Member

bruvzg commented Feb 23, 2024

but I feel like we might still want to add another option for FS

#88735

Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

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

There's also mention of clear color in the WINDOW_MODE_FULLSCREEN documentation, which should be changed as well.

This makes the border much less noticeable, or even completely invisible
on OLED displays.
@Calinou Calinou force-pushed the windows-borderless-fullscreen-use-black-border branch from 9063dab to aa5f7b8 Compare February 27, 2024 22:18
@Calinou Calinou requested a review from a team as a code owner February 27, 2024 22:18
@Calinou Calinou requested a review from bruvzg May 21, 2024 23:58
@alvinhochun
Copy link
Contributor

  • MODE_FULLSCREEN → (WS_OVERLAPPED | WS_BORDER + screen size), with black border.

If this is intended for the editor and to allow popup windows and menus to show properly, may I suggest an alternative? Don't use WS_BORDER. Instead make the window 1px taller, then subtract 1px from the viewport (leaving the bottom row of pixel unused), which should prevent drivers from forcing exclusive fullscreen but still having the window content match the screen size.

@bruvzg
Copy link
Member

bruvzg commented Jul 13, 2024

If this is intended for the editor and to allow popup windows and menus to show properly, may I suggest an alternative? Don't use WS_BORDER. Instead make the window 1px taller, then subtract 1px from the viewport (leaving the bottom row of pixel unused), which should prevent drivers from forcing exclusive fullscreen but still having the window content match the screen size.

That's what #88852 do (and the extra pixel is made transparent as well). But it should be tested on different vendor GPUs to make sure it's not affecting performance.

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

Successfully merging this pull request may close these issues.

3 participants