mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-28 23:22:43 +00:00
[qwaq] Separate out mouse (de)init code
This is the simplest fix for the curses/input initialization order issue. The terminal io code should still be moved to its own file, really, but I think it can wait.
This commit is contained in:
parent
72900fd16b
commit
6f71ef6657
5 changed files with 20 additions and 7 deletions
|
@ -1595,6 +1595,8 @@ bi_initialize (progs_t *pr)
|
|||
mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
|
||||
refresh();
|
||||
|
||||
qwaq_input_enable_mouse ();
|
||||
|
||||
res->stdscr.win = stdscr;
|
||||
|
||||
create_thread (qwaq_curses_thread, res);
|
||||
|
@ -1843,6 +1845,7 @@ bi_curses_clear (progs_t *pr, void *data)
|
|||
__auto_type res = (qwaq_resources_t *) data;
|
||||
|
||||
if (res->initialized) {
|
||||
qwaq_input_disable_mouse ();
|
||||
endwin ();
|
||||
}
|
||||
need_endwin = 0;
|
||||
|
|
|
@ -569,13 +569,26 @@ qwaq_input_init (qwaq_input_resources_t *res)
|
|||
action.sa_handler = handle_winch;
|
||||
sigaction (SIGWINCH, &action, &save_winch);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
qwaq_input_enable_mouse (void)
|
||||
{
|
||||
// ncurses takes care of input mode for us, so need only tell xterm
|
||||
// what we need
|
||||
(void) !write(1, MOUSE_MOVES_ON, sizeof (MOUSE_MOVES_ON) - 1);
|
||||
(void) !write(1, SGR_ON, sizeof (SGR_ON) - 1);
|
||||
}
|
||||
|
||||
void
|
||||
qwaq_input_disable_mouse (void)
|
||||
{
|
||||
// ncurses takes care of input mode for us, so need only tell xterm
|
||||
// what we need
|
||||
(void) !write(1, SGR_OFF, sizeof (SGR_OFF) - 1);
|
||||
(void) !write(1, MOUSE_MOVES_OFF, sizeof (MOUSE_MOVES_OFF) - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
qwaq_process_input (qwaq_input_resources_t *res)
|
||||
{
|
||||
|
@ -588,11 +601,6 @@ qwaq_input_shutdown (qwaq_input_resources_t *res)
|
|||
IE_Remove_Handler (res->input_event_handler);
|
||||
IN_DriverData (term_driver_handle, 0);
|
||||
|
||||
// ncurses takes care of input mode for us, so need only tell xterm
|
||||
// what we need
|
||||
(void) !write(1, SGR_OFF, sizeof (SGR_OFF) - 1);
|
||||
(void) !write(1, MOUSE_MOVES_OFF, sizeof (MOUSE_MOVES_OFF) - 1);
|
||||
|
||||
#ifdef HAVE_SIGACTION
|
||||
sigaction (SIGWINCH, &save_winch, 0);
|
||||
#endif
|
||||
|
|
|
@ -42,8 +42,8 @@ arp_end (void)
|
|||
return nil;
|
||||
}
|
||||
|
||||
initialize ();
|
||||
init_input ();
|
||||
initialize ();
|
||||
for (int i = 1; i < 64; i++) {
|
||||
init_pair (i, i & 0x7, i >> 3);
|
||||
color_palette[i] = COLOR_PAIR (i);
|
||||
|
|
|
@ -41,8 +41,8 @@ arp_end (void)
|
|||
return nil;
|
||||
}
|
||||
|
||||
initialize ();
|
||||
init_input ();
|
||||
initialize ();
|
||||
for (int i = 1; i < 64; i++) {
|
||||
init_pair (i, i & 0x7, i >> 3);
|
||||
color_palette[i] = COLOR_PAIR (i);
|
||||
|
|
|
@ -127,6 +127,8 @@ typedef struct qwaq_input_resources_s {
|
|||
} qwaq_input_resources_t;
|
||||
|
||||
int qwaq_add_event (qwaq_input_resources_t *res, qwaq_event_t *event);
|
||||
void qwaq_input_enable_mouse (void);
|
||||
void qwaq_input_disable_mouse (void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue