mamedev / mame

MAME
https://www.mamedev.org/
Other
8.33k stars 2.03k forks source link

On Windows, non-d3d video options (bgfx, opengl) locks the screen to topmost (can't alt-tab). #2997

Open stargoonman opened 6 years ago

stargoonman commented 6 years ago

If the mame runs a machine on non-d3d video settings, the screen will stay topmost, even though the window is deselected.

If you alt-tab, it will select other window, but the mame window will stay topmost regardless. This may look like mame is ignoring inputs to the uninitiated.

u-man74 commented 6 years ago

You dont use alt-tab combo. You use alt-enter. :)

stargoonman commented 6 years ago

I'm aware of the workaround, but it is not a fix to the issue.

cuavas commented 6 years ago

It's a legitimate bug - bgfx uses an floating, borderless window rather than exclusive fullscreen mode, and this should be hidden when MAME loses focus.

Robbbert commented 3 years ago

Is this still a problem? It works correctly for me.

Robbbert commented 3 years ago

Nothing heard; closing.

happppp commented 3 years ago

Can still repro it: mame64 ridgerac -nowindow -video opengl

Alt-tab to a different program. Ridge Racer is still visible in fullscreen but inputs are unfocused and MAME will seem unresponsive.

antonioginer commented 3 years ago

This serves as a workaround:

index ca62d750f50..ba4d268f270 100644
--- a/src/osd/windows/window.cpp
+++ b/src/osd/windows/window.cpp
@@ -1346,6 +1346,11 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
        }
        return DefWindowProc(wnd, message, wparam, lparam);

+   case WM_ACTIVATE:
+       if (window->has_renderer() && window->fullscreen() && (LOWORD(wparam) == WA_INACTIVE) && !is_mame_window(HWND(lparam)))
+           if (osd_common_t::s_window_list.size()) winwindow_toggle_full_screen();
+       break;
+
    // close: cause MAME to exit
    case WM_CLOSE:
        window->machine().schedule_exit();

It just toggles windowed mode when focus is lost.

cuavas commented 3 years ago

It would be better to hide the fullscreen window though, to be consistent with other platforms.

cuavas commented 3 years ago

7cfe419ca809eb8572f5a0c1e85e8170342c028e should address this. It seems to mostly work, but with multiple screens by repeatedly alt-tab’ing in and out I could sometimes get it to minimise one window but not the other. It corrects itself if you alt-tab in and out a couple of times though. If someone else wants to work out what’s going on there, feel free to.

antonioginer commented 3 years ago

but with multiple screens by repeatedly alt-tab’ing in and out I could sometimes get it to minimise one window but not the other.

I've been playing with this, it looks like setting the first window as foreground after SW_RESTORE fixes it.

    if ((wparam == WA_ACTIVE) || (wparam == WA_CLICKACTIVE))
    {
        for (const auto &w : osd_common_t::s_window_list)
            ShowWindow(std::static_pointer_cast<win_window_info>(w)->platform_window(), SW_RESTORE);

        SetForegroundWindow(std::static_pointer_cast<win_window_info>(osd_common_t::s_window_list.front())->platform_window());
    }