| 1563 | } |
| 1564 | |
| 1565 | void |
| 1566 | X11_init_nhwindows(int *argcp, char **argv) |
| 1567 | { |
| 1568 | int i; |
| 1569 | Cardinal num_args; |
| 1570 | Arg args[4]; |
| 1571 | uid_t savuid; |
| 1572 | |
| 1573 | /* Init windows to nothing. */ |
| 1574 | for (i = 0; i < MAX_WINDOWS; i++) |
| 1575 | window_list[i].type = NHW_NONE; |
| 1576 | |
| 1577 | /* force high scores display to be shown in a window, and don't allow |
| 1578 | that to be toggled off via 'O' (note: 'nethack -s' won't reach here; |
| 1579 | its output goes to stdout and could be redirected into a file) */ |
| 1580 | iflags.toptenwin = TRUE; |
| 1581 | set_option_mod_status("toptenwin", set_in_config); |
| 1582 | |
| 1583 | /* add another option that can be set */ |
| 1584 | set_wc_option_mod_status(WC_TILED_MAP, set_in_game); |
| 1585 | set_option_mod_status("mouse_support", set_in_game); |
| 1586 | |
| 1587 | load_default_resources(); /* create default_resource_data[] */ |
| 1588 | |
| 1589 | /* |
| 1590 | * setuid hack: make sure that if nethack is setuid, to use real uid |
| 1591 | * when opening X11 connections, in case the user is using xauth, since |
| 1592 | * the "games" or whatever user probably doesn't have permission to open |
| 1593 | * a window on the user's display. This code is harmless if the binary |
| 1594 | * is not installed setuid. |
| 1595 | */ |
| 1596 | savuid = geteuid(); |
| 1597 | (void) seteuid(getuid()); |
| 1598 | |
| 1599 | XSetIOErrorHandler((XIOErrorHandler) X11_io_error_handler); |
| 1600 | |
| 1601 | num_args = 0; |
| 1602 | XtSetArg(args[num_args], XtNallowShellResize, True); num_args++; |
| 1603 | XtSetArg(args[num_args], XtNtitle, "NetHack"); num_args++; |
| 1604 | |
| 1605 | toplevel = XtAppInitialize(&app_context, "NetHack", /* application */ |
| 1606 | (XrmOptionDescList) 0, 0, /* options list */ |
| 1607 | argcp, (String *) argv, /* command line */ |
| 1608 | default_resource_data, /* fallback resources */ |
| 1609 | (ArgList) args, num_args); |
| 1610 | XtOverrideTranslations(toplevel, |
| 1611 | XtParseTranslationTable("<Message>WM_PROTOCOLS: X11_hangup()")); |
| 1612 | |
| 1613 | /* We don't need to realize the top level widget. */ |
| 1614 | |
| 1615 | old_error_handler = XSetErrorHandler(panic_on_error); |
| 1616 | |
| 1617 | /* add new color converter to deal with overused colormaps */ |
| 1618 | XtSetTypeConverter(XtRString, XtRPixel, nhCvtStringToPixel, |
| 1619 | (XtConvertArgList) nhcolorConvertArgs, |
| 1620 | XtNumber(nhcolorConvertArgs), XtCacheByDisplay, |
| 1621 | nhFreePixel); |
| 1622 |
nothing calls this directly
no test coverage detected