mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 13:23:45 -07:00
fix: show/hide cursors properly (#1829)
This commit is contained in:
parent
6c30d7a435
commit
2f96e28135
7 changed files with 47 additions and 47 deletions
|
@ -352,12 +352,21 @@ static void gfx_dxgi_set_fullscreen_changed_callback(void (*on_fullscreen_change
|
|||
dxgi.on_fullscreen_changed = on_fullscreen_changed;
|
||||
}
|
||||
|
||||
static void gfx_dxgi_show_cursor(bool hide) {
|
||||
/**
|
||||
* @bug When menubar is open in windowed mode and you toggle fullscreen
|
||||
* ShowCursor no longer responds. Debugging shows the bool to be correct.
|
||||
**/
|
||||
ShowCursor(hide);
|
||||
static void gfx_dxgi_set_cursor_visibility(bool visible) {
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showcursor
|
||||
// https://devblogs.microsoft.com/oldnewthing/20091217-00/?p=15643
|
||||
// ShowCursor uses a counter, not a boolean value, and increments or decrements that value when called
|
||||
// This means we need to keep calling it until we get the value we want
|
||||
int cursorVisibilityCounter;
|
||||
if (visible) {
|
||||
do {
|
||||
cursorVisibilityCounter = ShowCursor(true);
|
||||
} while (cursorVisibilityCounter < 0);
|
||||
} else {
|
||||
do {
|
||||
cursorVisibilityCounter = ShowCursor(false);
|
||||
} while (cursorVisibilityCounter >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_dxgi_set_fullscreen(bool enable) {
|
||||
|
@ -730,7 +739,7 @@ extern "C" struct GfxWindowManagerAPI gfx_dxgi_api = {
|
|||
gfx_dxgi_set_keyboard_callbacks,
|
||||
gfx_dxgi_set_fullscreen_changed_callback,
|
||||
gfx_dxgi_set_fullscreen,
|
||||
gfx_dxgi_show_cursor,
|
||||
gfx_dxgi_set_cursor_visibility,
|
||||
gfx_dxgi_main_loop,
|
||||
gfx_dxgi_get_dimensions,
|
||||
gfx_dxgi_handle_events,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue