[StrangePan][2.0.76] GUI element at 0,0 receives hover event from opposite edges of the screen

aglaron
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Apr 19, 2026 7:59 pm
Contact:

[StrangePan][2.0.76] GUI element at 0,0 receives hover event from opposite edges of the screen

Post by aglaron »

When a custom LuaGuiElement is placed at location {0,0} it receives mouse hover event if cursor is placed at rightmost or bottommost edge of the screen and then hovers another element.

Steps:
1. Add a mod with the following code

Code: Select all

script.on_event(defines.events.on_player_joined_game, function (event)
    local player = game.get_player(event.player_index)

    local top_left = player.gui.screen.add{
        type = "empty-widget",
        name = "top_left_overlay",
        raise_hover_events = true,
    }
    top_left.style.width = 200
    top_left.style.height = 200

    local bottom_right = player.gui.screen.add{
        type = "empty-widget",
        name = "bottom_right_overlay",
        raise_hover_events = true,
    }
    bottom_right.style.width = 200
    bottom_right.style.height = 200
end)

local function update_hover_overlays_location(player_index)
    local player = game.get_player(player_index)

    local top_left = player.gui.screen["top_left_overlay"]
    top_left.location = { 0, 0 }

    local bottom_right = player.gui.screen["bottom_right_overlay"]
    bottom_right.location = {
        player.display_resolution.width - 200 * player.display_scale,
        player.display_resolution.height - 200 * player.display_scale
    }
end

script.on_event(defines.events.on_player_display_resolution_changed, function(event)
    update_hover_overlays_location(event.player_index)
end)

script.on_event(defines.events.on_player_display_scale_changed, function(event)
    update_hover_overlays_location(event.player_index)
end)

script.on_event(defines.events.on_gui_hover, function(event)
    game.print("on_gui_hover: "..event.element.name)
end)
Note that both elements are small and don't fill up the screen. Especially top_left_overlay.

2. Make sure Factorio is launched in full screen.
3. Start a new Freeplay game.
4. Move cursor to top-left corner. Actual: "on_gui_hover: top_left_overlay" printed in chat. As expected.
5. Move cursor to bottom-right corner of the screen. Actual: "on_gui_hover: bottom_right_overlay" printed in chat. As expected.
6. From initial position at the bottom-right corner, move cursor slightly to the left and slightly to the top. I.e. hover bottom_right_overlay.

Actual: both printed in chat:
on_gui_hover: top_left_overlay
on_gui_hover: bottom_right_overlay
Expected: only "on_gui_hover: bottom_right_overlay" printed in chat.

Notes:
- display_resolution = 2160x3840
- display_scale = 2
- display_density_scale = 3
- Graphics settings -> Full screen = true
- See related bug: viewtopic.php?t=133479 - if it gets fixed, steps here might become outdated/impossible.

UPD:

Another way to reproduce:
7. While game is not paused and cursor is outside top-left element bounds, alt+tab from the game, then alt+tab back into the game. Actual: "on_gui_hover: top_left_overlay" printed in chat.
Attachments
factorio-current.log
(9.3 KiB) Downloaded 15 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 16794
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.76] GUI element at 0,0 receives hover event from opposite edges of the screen

Post by Rseding91 »

I suspect this is related to display scaling and the display area not perfectly scaling to the pixel area. Given I can't reproduce any issues with either of these reports on my system (2560x1440, display_scale of 1, display_density_scale of 1).

If you change both scales to 1 - are you able to reproduce any issues?
If you want to get ahold of me I'm almost always on Discord.
aglaron
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Apr 19, 2026 7:59 pm
Contact:

Re: [2.0.76] GUI element at 0,0 receives hover event from opposite edges of the screen

Post by aglaron »

With display_density_scale = 1 (changed by setting System->Display->Scale in Windows to 100%) and any display_scale (tested with 2, 3, and in between), I can't reproduce the issue with hover not registering, and as consequence cannot reproduce step #6 of this one.

With display_density_scale = 2, both do reproduce.

With any display_density_scale, step #7 still reproduces.
StrangePan
Factorio Staff
Factorio Staff
Posts: 269
Joined: Fri Dec 07, 2018 3:41 pm
Contact:

Re: [2.0.76] GUI element at 0,0 receives hover event from opposite edges of the screen

Post by StrangePan »

Wasn't able to reproduce on Mac, so this might be a Windows-only issue.
Post Reply

Return to “Assigned”