MCPcopy Create free account
hub / github.com/NetHack/NetHack / x_event

Function x_event

win/X11/winmap.c:1943–2034  ·  view source on GitHub ↗

* Main X event loop. Here we accept and dispatch X events. We only exit * under certain circumstances. */

Source from the content-addressed store, hash-verified

1941 * under certain circumstances.
1942 */
1943int
1944x_event(int exit_condition)
1945{
1946 XEvent event;
1947 int retval = 0;
1948 boolean keep_going = TRUE;
1949
1950 /* Hold globals so function is re-entrant */
1951 boolean hold_exit_x_event = exit_x_event;
1952
1953 click_button = NO_CLICK; /* reset click exit condition */
1954 exit_x_event = FALSE; /* reset callback exit condition */
1955
1956 /*
1957 * Loop until we get a sent event, callback exit, or are accepting key
1958 * press and button press events and we receive one.
1959 */
1960 if ((exit_condition == EXIT_ON_KEY_PRESS
1961 || exit_condition == EXIT_ON_KEY_OR_BUTTON_PRESS) && incount)
1962 goto try_test;
1963
1964 do {
1965 XtAppNextEvent(app_context, &event);
1966 XtDispatchEvent(&event);
1967
1968 /* See if we can exit. */
1969 try_test:
1970 switch (exit_condition) {
1971 case EXIT_ON_SENT_EVENT: {
1972 XAnyEvent *any = (XAnyEvent *) &event;
1973
1974 if (any->send_event) {
1975 retval = 0;
1976 keep_going = FALSE;
1977 }
1978 break;
1979 }
1980 case EXIT_ON_EXIT:
1981 if (exit_x_event) {
1982 incount = 0;
1983 retval = 0;
1984 keep_going = FALSE;
1985 }
1986 break;
1987 case EXIT_ON_KEY_PRESS:
1988 if (incount != 0) {
1989 /* get first pressed key */
1990 --incount;
1991 retval = inbuf[inptr];
1992 inptr = (inptr + 1) % INBUF_SIZE;
1993 /* pkey(retval); */
1994 keep_going = FALSE;
1995#if defined(HANGUPHANDLING)
1996 } else if (program_state.done_hup) {
1997 retval = '\033';
1998 inptr = (inptr + 1) % INBUF_SIZE;
1999 keep_going = FALSE;
2000#endif

Callers 10

X11_display_nhwindowFunction · 0.85
X11_delay_outputFunction · 0.85
X11_asknameFunction · 0.85
X11_getlinFunction · 0.85
X11_yn_function_coreFunction · 0.85
input_eventFunction · 0.85
X11_select_menuFunction · 0.85
display_text_windowFunction · 0.85
winmisc.cFile · 0.85
X11_get_ext_cmdFunction · 0.85

Calls 1

panicFunction · 0.50

Tested by

no test coverage detected