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

New (non-embedded) window transparency glitching based on focus if window is size is equal to monitor resolution #76551

Open
KMouratidis opened this issue Apr 28, 2023 · 4 comments

Comments

@KMouratidis
Copy link

KMouratidis commented Apr 28, 2023

Godot version

4.0.2 + 4.0.3 + 4.1

System information

Windows 11, Forward+, Intel i7-13700k, Nvidia RTX 4070ti

Also replicated on: Windows 10, Forward+, Intel i7-11850H, Nvidia MX450
Also replicated on: Windows 11, Forward+, AMD Ryzen 7 6800 HS, Nvidia 3060M (both discrete & integrated graphics)
But on: Ubuntu 22.04, AMD Ryzen 7 6800 HS, Nvidia 3060M:

  • It works as expected on all renderers for (a) integrated graphics, (b) on dedicated graphics + X11 (nouveau), and (c) on Wayland (all combinations I tried)
  • The window gets opened but doesn't show at all (no pink rect) with the proprietary 530 driver if using Forward+ or Mobile but it does show if using Compatibility

Not affected by monitor or number of monitors.

Issue description

When creating a new window with Window.new(), add_child() etc, I'm trying to make it transparent. I've enabled Display > Window > Size > Transparent, Display > Window > Per Pixel Transparency > Allowed and Rendering > Viewport > Transparent Background and I've set all flags that seem relevant:

window.size = DisplayServer.screen_get_size()
window.always_on_top = true
window.transparent = true
window.borderless = true
window.set_transparent_background(true)

But the window turns completely completely black (minus the ColorRect which show fine, as soon as OBS catches up):

Edit: The recording show the transitions as taking some time but they actually happen instantly. Not sure what the issue with the recording is :/

WindowTransparency.mp4

However when I change the size:

window.size = DisplayServer.screen_get_size() - Vector2i(1, 1)

Everything works fine:

WindowTransparency2.mp4

Steps to reproduce

  1. Open provided project and run it
  2. Double click inside the main window to trigger opening of a new window
  3. New window is black despite best efforts to have it transparent
  4. Focusing on any other window (e.g. click or alt-tab), be it Godot or otherwise, fixes the transparency
  5. Re-focusing on the new window causes it to go black again

Minimal reproduction project

WindowTransparency.zip

@Calinou
Copy link
Member

Calinou commented Jun 9, 2023

This is due to Windows making those windows use exclusive fullscreen if they match the screen size. As a workaround, make their width or height 1 pixel smaller than the screen's width/height.

@KMouratidis
Copy link
Author

iirc, I replicated it on Ubuntu 22 + Nvidia (proprietary) + X11 as well, but all other combinations on Ubuntu worked fine.

@bruvzg
Copy link
Member

bruvzg commented Jun 9, 2023

Instead of setting window to borderless and setting window size manually (which is equivalent to WINDOW_MODE_EXCLUSIVE_FULLSCREEN), try using WINDOW_MODE_FULLSCREEN, it should prevent OS from disabling compositor when in full screen and allow transparency to work.

@KMouratidis
Copy link
Author

@bruvzg sorry for the late reply. I don't think I understand. I tried various combinations of these but nothing worked:

var window := Window.new()
window.position = Vector2(0.0, 0.0)
# window.size = DisplayServer.screen_get_size()  # <--- commented out, or not
window.always_on_top = true
window.transparent = true
# window.borderless = true  #  <--- commented out, or not
window.mode = Window.MODE_FULLSCREEN # or Window.MODE_EXCLUSIVE_FULLSCREEN, or commented out
window.set_transparent_background(true)

MODE_FULLSCREEN with borderless still has the same issue, and without it, it has borders.

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

No branches or pull requests

3 participants