From fa7ab97783083a58b5f641cd1835f647dcc21cf5 Mon Sep 17 00:00:00 2001 From: kreatordxx <> Date: Fri, 5 Feb 2010 14:05:57 +0000 Subject: [PATCH] Send EVENT_WINDOW_DEACTIVATE before EVENT_WINDOW_ACTIVATE, ensuring cursor remains shown when appropriate --- CHANGELOG.txt | 1 + arch/sdl/window.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2668e4b4f..c3ee5245d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D1X-Rebirth Changelog -------- main/game.c, main/gameseq.c, main/newdemo.c: Use palette_save and palette_restore for all windows displayed over Game_wind, not just for do_option main/gameseq.c, main/newmenu.c: No showing the main menu background between loading a level and playing it (syncing with D2X) +main/window.c: Send EVENT_WINDOW_DEACTIVATE before EVENT_WINDOW_ACTIVATE, ensuring cursor remains shown when appropriate 20100202 -------- diff --git a/arch/sdl/window.c b/arch/sdl/window.c index c767d077f..24734c49d 100644 --- a/arch/sdl/window.c +++ b/arch/sdl/window.c @@ -30,7 +30,7 @@ window *window_create(grs_canvas *src, int x, int y, int w, int h, int (*event_c { window *wind; window *prev = window_get_front(); - d_event event = { EVENT_WINDOW_ACTIVATED }; + d_event event; wind = d_malloc(sizeof(window)); if (wind == NULL) @@ -50,14 +50,15 @@ window *window_create(grs_canvas *src, int x, int y, int w, int h, int (*event_c FrontWindow->next = wind; wind->next = NULL; FrontWindow = wind; - window_send_event(wind, &event); - if (prev) { event.type = EVENT_WINDOW_DEACTIVATED; window_send_event(prev, &event); } + event.type = EVENT_WINDOW_ACTIVATED; + window_send_event(wind, &event); + return wind; } @@ -124,7 +125,7 @@ window *window_get_next(window *wind) void window_select(window *wind) { window *prev = window_get_front(); - d_event event = { EVENT_WINDOW_ACTIVATED }; + d_event event; Assert (wind != NULL); @@ -143,29 +144,31 @@ void window_select(window *wind) if (window_is_visible(wind)) { - window_send_event(wind, &event); event.type = EVENT_WINDOW_DEACTIVATED; if (prev) window_send_event(prev, &event); + event.type = EVENT_WINDOW_ACTIVATED; + window_send_event(wind, &event); } } void window_set_visible(window *wind, int visible) { window *prev = window_get_front(); - d_event event = { EVENT_WINDOW_ACTIVATED }; + d_event event; wind->w_visible = visible; wind = window_get_front(); // get the new front window if (wind == prev) return; - - if (wind) - window_send_event(wind, &event); event.type = EVENT_WINDOW_DEACTIVATED; if (prev) window_send_event(prev, &event); + + event.type = EVENT_WINDOW_ACTIVATED; + if (wind) + window_send_event(wind, &event); } int window_is_visible(window *wind)