diff --git a/include/QF/console.h b/include/QF/console.h index f2be4a4c6..4ab342581 100644 --- a/include/QF/console.h +++ b/include/QF/console.h @@ -69,7 +69,7 @@ void Con_DrawConsole (void); void Con_Printf (const char *fmt, ...) __attribute__((format(PRINTF, 1, 2))); void Con_Print (const char *fmt, va_list args) __attribute__((format(PRINTF, 1, 0))); -void Con_SetState (con_state_t state); +void Con_SetState (con_state_t state, bool hide_mouse); struct inputline_s; // wrapper function to attempt to either complete the command line diff --git a/include/QF/plugin/console.h b/include/QF/plugin/console.h index b5f1ab536..b2bc420bf 100644 --- a/include/QF/plugin/console.h +++ b/include/QF/plugin/console.h @@ -39,7 +39,7 @@ typedef struct console_funcs_s { void (*process_input) (void); void (*draw_console) (void); void (*new_map) (void); - void (*set_state) (con_state_t state); + void (*set_state) (con_state_t state, bool hide_mouse); } console_funcs_t; typedef struct console_data_s { diff --git a/libs/client/cl_input.c b/libs/client/cl_input.c index 1f288b6bd..09f8156e3 100644 --- a/libs/client/cl_input.c +++ b/libs/client/cl_input.c @@ -581,7 +581,7 @@ static int cl_key_event (const IE_event_t *ie_event) { if (ie_event->key.code == QFK_ESCAPE) { - Con_SetState (con_menu); + Con_SetState (con_menu, true); return 1; } return 0; diff --git a/libs/console/client.c b/libs/console/client.c index 446912ab6..ad0175f56 100644 --- a/libs/console/client.c +++ b/libs/console/client.c @@ -155,6 +155,7 @@ static uint32_t canvas_base; static uint32_t view_base; static con_state_t con_state; +static bool con_hide_mouse; static int con_event_id; static int con_saved_focos; @@ -332,15 +333,18 @@ ClearNotify (void) } static void -C_SetState (con_state_t state) +C_SetState (con_state_t state, bool hide_mouse) { con_state_t old_state = con_state; con_state = state; + con_hide_mouse = hide_mouse; if (con_state == con_inactive) { IE_Set_Focus (con_saved_focos); + VID_SetCursor (!con_hide_mouse); } else if (old_state == con_inactive) { con_saved_focos = IE_Get_Focus (); IE_Set_Focus (con_event_id); + VID_SetCursor (true); } if (state == con_message) { @@ -369,10 +373,10 @@ ToggleConsole_f (void) case con_message: return; case con_inactive: - C_SetState (con_active); + C_SetState (con_active, con_hide_mouse); break; case con_active: - C_SetState (con_inactive); + C_SetState (con_inactive, con_hide_mouse); break; case con_fullscreen: break; @@ -413,7 +417,7 @@ static void con_end_message (inputline_t *line) { Con_ClearTyping (line, 1); - C_SetState (con_inactive); + C_SetState (con_inactive, con_hide_mouse); } static void @@ -979,7 +983,7 @@ MessageMode_f (void) if (con_state != con_inactive) return; chat_team = false; - C_SetState (con_message); + C_SetState (con_message, con_hide_mouse); } static void @@ -988,7 +992,7 @@ MessageMode2_f (void) if (con_state != con_inactive) return; chat_team = true; - C_SetState (con_message); + C_SetState (con_message, con_hide_mouse); } static void diff --git a/libs/console/console.c b/libs/console/console.c index 9c3fc8140..7c2c4cec1 100644 --- a/libs/console/console.c +++ b/libs/console/console.c @@ -175,10 +175,10 @@ Con_Print (const char *fmt, va_list args) } VISIBLE void -Con_SetState (con_state_t state) +Con_SetState (con_state_t state, bool hide_mouse) { if (con_module) { - con_module->functions->console->set_state (state); + con_module->functions->console->set_state (state, hide_mouse); } } diff --git a/libs/console/menu.c b/libs/console/menu.c index af64b90ba..ef8be2bc9 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -378,7 +378,7 @@ bi_Menu_SelectMenu (progs_t *pr, void *data) if (name && *name) menu = Hash_Find (menu_hash, name); if (menu) { - Con_SetState (con_menu); + Con_SetState (con_menu, true); if (menu->enter_hook) { run_menu_pre (); PR_ExecuteProgram (&menu_pr_state, menu->enter_hook); @@ -387,7 +387,7 @@ bi_Menu_SelectMenu (progs_t *pr, void *data) } else { if (name && *name) Sys_Printf ("no menu \"%s\"\n", name); - Con_SetState (con_inactive); + Con_SetState (con_inactive, true); } } @@ -472,7 +472,7 @@ bi_Menu_Leave (progs_t *pr, void *data) } menu = menu->parent; if (!menu) { - Con_SetState (con_inactive); + Con_SetState (con_inactive, true); } } } @@ -851,14 +851,14 @@ void Menu_Enter () { if (!top_menu) { - Con_SetState (con_active); + Con_SetState (con_active, true); return; } if (!menu) { menu = Hash_Find (menu_hash, top_menu); } if (menu) { - Con_SetState (con_menu); + Con_SetState (con_menu, true); if (menu->enter_hook) { run_menu_pre (); PR_ExecuteProgram (&menu_pr_state, menu->enter_hook); @@ -878,7 +878,7 @@ Menu_Leave () } menu = menu->parent; if (!menu) { - Con_SetState (con_inactive); + Con_SetState (con_inactive, true); } } } diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index a1b7d4462..464fdd6dd 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -591,7 +591,8 @@ CL_SetState (cactive_t state) CL_UpdateScreen (&cl.viewstate); } host_in_game = 0; - Con_SetState (state == ca_active ? con_inactive : con_fullscreen); + Con_SetState (state == ca_active ? con_inactive : con_fullscreen, + state == ca_active && !cls.demoplayback); if (state != old_state && state == ca_active) { CL_Input_Activate (host_in_game = !cls.demoplayback); } diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 1461cd5fe..6d0bd89bc 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1406,7 +1406,8 @@ CL_SetState (cactive_t state) } Sbar_SetActive (state == ca_active); } - Con_SetState (state == ca_active ? con_inactive : con_fullscreen); + Con_SetState (state == ca_active ? con_inactive : con_fullscreen, + state == ca_active && !cls.demoplayback); if (state != old_state && state == ca_active) { CL_Input_Activate (!cls.demoplayback); } diff --git a/ruamoko/qwaq/builtins/graphics.c b/ruamoko/qwaq/builtins/graphics.c index 3a9fb24cd..719805e4b 100644 --- a/ruamoko/qwaq/builtins/graphics.c +++ b/ruamoko/qwaq/builtins/graphics.c @@ -161,7 +161,7 @@ event_handler (const IE_event_t *ie_event, void *_pr) { // FIXME rethink event handling for qwaq if (ie_event->type == ie_key && ie_event->key.code == QFK_ESCAPE) { - Con_SetState (con_active); + Con_SetState (con_active, false); return 1; } return IN_Binding_HandleEvent (ie_event);