Skip to content

Commit d96f635

Browse files
SiegeLordExSiegeLord
authored andcommitted
Fix the drawable area mouse hiding state being out of sync.
We do this by tracking this state next to the usual one and properly resetting it when needed. Fixes #1388
1 parent 4a20785 commit d96f635

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

include/allegro5/platform/aintwin.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ struct ALLEGRO_DISPLAY_WIN
6565
HWND window;
6666
HCURSOR mouse_selected_hcursor;
6767
bool mouse_cursor_shown;
68+
/*
69+
* We want to show the cursor when the user moves the mouse to the
70+
* title-bar (to, e.g. close the window). This variable tracks
71+
* whether or not we should re-hide the cursor when we enter the
72+
* drawable area.
73+
*
74+
* This is almost always false, unless we actually programmatically
75+
* hid the cursor inside wwindow.c.
76+
*/
77+
bool hide_mouse_on_move;
6878

6979
UINT adapter;
7080

src/win/d3d_disp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,7 @@ static ALLEGRO_DISPLAY *d3d_create_display_locked(int w, int h)
18171817

18181818
win_display->mouse_selected_hcursor = 0;
18191819
win_display->mouse_cursor_shown = false;
1820+
win_display->hide_mouse_on_move = false;
18201821
win_display->can_acknowledge = false;
18211822

18221823
SetForegroundWindow(win_display->window);

src/win/wgl_disp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,7 @@ static bool create_display_internals(ALLEGRO_DISPLAY_WGL *wgl_disp)
998998

999999
win_disp->mouse_selected_hcursor = 0;
10001000
win_disp->mouse_cursor_shown = false;
1001+
win_disp->hide_mouse_on_move = false;
10011002
win_disp->can_acknowledge = false;
10021003

10031004
_al_win_grab_input(win_disp);

src/win/wmcursor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ bool _al_win_show_mouse_cursor(ALLEGRO_DISPLAY *display)
261261

262262
tmp_cursor.hcursor = win_display->mouse_selected_hcursor;
263263
win_display->mouse_cursor_shown = true;
264+
win_display->hide_mouse_on_move = false;
264265
_al_win_set_mouse_cursor(display, (ALLEGRO_MOUSE_CURSOR *)tmp_cursor_ptr);
265266

266267
return true;

src/win/wwindow.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ ALLEGRO_DEBUG_CHANNEL("wwindow")
5050
static WNDCLASS window_class;
5151

5252
static bool resize_postponed = false;
53-
static bool we_hid_the_mouse = false;
5453

5554

5655
UINT _al_win_msg_call_proc = 0;
@@ -610,8 +609,8 @@ static LRESULT CALLBACK window_callback(HWND hWnd, UINT message,
610609
int mx = GET_X_LPARAM(lParam);
611610
int my = GET_Y_LPARAM(lParam);
612611

613-
if (win_display->mouse_cursor_shown && we_hid_the_mouse) {
614-
we_hid_the_mouse = false;
612+
if (win_display->mouse_cursor_shown && win_display->hide_mouse_on_move) {
613+
win_display->hide_mouse_on_move = false;
615614
win_display->display.vt->hide_mouse_cursor((void*)win_display);
616615
}
617616

@@ -705,8 +704,8 @@ static LRESULT CALLBACK window_callback(HWND hWnd, UINT message,
705704
}
706705
case WM_NCMOUSEMOVE: {
707706
if (!win_display->mouse_cursor_shown) {
708-
we_hid_the_mouse = true;
709707
win_display->display.vt->show_mouse_cursor((void*)win_display);
708+
win_display->hide_mouse_on_move = true;
710709
}
711710
break;
712711
}

0 commit comments

Comments
 (0)