#Screen flickering when resizing window

1 messages · Page 1 of 1 (latest)

narrow gazelle
#

Hi! I'm experiencing a weird screen flickering issue when I resize my window in godot. I've attached a video of the issue. I'm using godot 4.4.1 and I'm on Mac but I've confirmed that the issue is also present on Linux.

I'm not too sure if this is an engine issue or a 'me' issue so I'll explain what I'm doing.

The window starts off 256x256 in the bottom right corner. When the menu button is clicked, I resize the window to 256x768 and then repositioned to the bottom right. I'll attach my code below in case you are curious. I'd love for some help as to why this is occuring and what I can do to fix this. Thank you!

signal close_window


func _handle_open_menu() -> void:
    open_tab(menu_window)


func open_tab(tab: Control) -> void:
    if !current_open_tab:
        current_open_tab = tab
        reposition_window(true)
        current_open_tab.show()
    elif tab != current_open_tab:
        current_open_tab.hide()
        current_open_tab = tab
        reposition_window(true)
        current_open_tab.show()
    elif tab == current_open_tab:
        current_open_tab.hide()
        current_open_tab = null
        reposition_window(false)


func close_tab() -> void:
    if current_open_tab:
        current_open_tab.hide()
        current_open_tab = null
        reposition_window(false)


func _ready() -> void:
    reposition_window(false)
    open_menu.pressed.connect(_handle_open_menu)
    close_window.connect(close_tab)

    shop_window.back_button.pressed.connect(_handle_open_menu)
    inventory_window.back_button.pressed.connect(_handle_open_menu)
    debug_window.back_button.pressed.connect(_handle_open_menu)

    menu_window.close_button.pressed.connect(close_tab)
    menu_window.open_inventory_button.pressed.connect(func(): open_tab(inventory_window))
    menu_window.open_store_button.pressed.connect(func(): open_tab(shop_window))
    menu_window.open_settings_button.pressed.connect(func(): open_tab(debug_window))
    menu_window.open_garden_button.pressed.connect(func(): print("Garden"))





func reposition_window(menu_open: bool) -> void:
    var screen_size: Vector2i = DisplayServer.screen_get_size()

    var new_size = Vector2(256, 256)

    if menu_open:
        new_size = Vector2(256, 256*3)

    if screen_size.y > 1080:
        new_size *= 2

    DisplayServer.window_set_size(new_size)

    var window_size: Vector2i = DisplayServer.window_get_size()

    DisplayServer.window_set_position(
        Vector2i(screen_size.x - window_size.x, screen_size.y - window_size.y)
    )
tulip python
#

What's the undesired behaviour on the video? What is it supposed to look like?

ashen dawn
#

i'm not sure i can see the flickering issue in the video

narrow gazelle
narrow gazelle
tulip python
#

Ahhh, this makes more sense now with the video being slowed down

narrow gazelle
#

I figured this shouldn't flicker because i call reposition_window(true) first and then current_open_tab.show(). I should also mention that I am resizing the window and repositioning it with my function reposition_window. The original window starts out as 256x256 but opening the menu resizes it to 256x768

tulip python
#

hmm

#

You could try using the popup function on the window, instead of setting the size and showing the window separately

#

Also, have you tried showing the window and then setting the size & position? Does the issue happen with that order of events?