--- rxvt-unicode/src/init.C 2004/09/08 17:23:02 1.92 +++ rxvt-unicode/src/init.C 2004/12/15 00:12:58 1.97 @@ -169,7 +169,7 @@ #endif }; -const char *const xa_names[NUM_XA] = +const char *const xa_names[] = { "TEXT", "COMPOUND_TEXT", @@ -180,14 +180,24 @@ "VT_SELECTION", "INCR", "WM_DELETE_WINDOW", + "CLIPBOARD", +#if ENABLE_FRILLS + "_NET_WM_PID", + "_MOTIF_WM_HINTS", + "_NET_WM_NAME", + "_NET_WM_ICON_NAME", +#endif +#if USE_XIM + "WM_LOCALE_NAME", +#endif #ifdef TRANSPARENT "_XROOTPMAP_ID", + "_XSETROOT_ID", #endif #ifdef OFFIX_DND "DndProtocol", "DndSelection", #endif - "CLIPBOARD" }; bool @@ -592,14 +602,15 @@ SET_LOCALE (this->locale); mbstate.reset (); #endif + #if 0 #if HAVE_NL_LANGINFO - free (codeset); - codeset = strdup (nl_langinfo (CODESET)); + char *codeset = strdup (nl_langinfo (CODESET)); enc_utf8 = !strcasecmp (codeset, "UTF-8") || !strcasecmp (codeset, "UTF8"); + free (codeset); #else - enc_utf8 = 1; + enc_utf8 = 0; #endif #endif } @@ -612,12 +623,7 @@ rxvt_warn ("setting locale failed, working without locale support.\n"); else { - Atom wmlocale; - - wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False); - XChangeProperty (display->display, TermWin.parent[0], wmlocale, - XA_STRING, 8, PropModeReplace, - (unsigned char *)locale, strlen (locale)); + set_string_property (xa[XA_WM_LOCALE_NAME], locale); if (!XSupportsLocale ()) { @@ -641,19 +647,6 @@ * Initialize the command connection. * This should be called after the X server connection is established. */ - int i; - - for (i = 0; i < NUM_XA; i++) - xa[i] = XInternAtom (display->display, xa_names[i], False); - - /* Enable delete window protocol */ - XSetWMProtocols (display->display, TermWin.parent[0], - & (xa[XA_WMDELETEWINDOW]), 1); - -#ifdef USING_W11LIB - /* enable W11 callbacks */ - W11AddEventHandler (display->display, rxvt_W11_process_x_event); -#endif #ifdef META8_OPTION meta_char = (options & Opt_meta8 ? 0x80 : C0_ESC); @@ -915,6 +908,14 @@ XSetWindowAttributes attributes; XWindowAttributes gattr; +#ifdef USING_W11LIB + /* enable W11 callbacks */ + W11AddEventHandler (display->display, rxvt_W11_process_x_event); +#endif + + assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); + XInternAtoms (display->display, (char **)xa_names, NUM_XA, False, xa); + if (options & Opt_transparent) { XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); @@ -925,6 +926,7 @@ if (options & Opt_borderLess) { prop = XInternAtom(display->display, "_MOTIF_WM_INFO", True); + if (prop == None) { /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ @@ -949,7 +951,7 @@ Get_Colours (); if (!set_fonts ()) - rxvt_fatal ("unable to load base fontset, please specify one using -fn, aborting.\n"); + rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); window_calc (0, 0); old_width = szHint.width; @@ -991,10 +993,15 @@ XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL, (char **)argv, argc, &szHint, &wmHint, &classHint); + /* Enable delete window protocol */ + XSetWMProtocols (display->display, TermWin.parent[0], + &xa[XA_WMDELETEWINDOW], 1); + #if ENABLE_FRILLS long pid = getpid (); + XChangeProperty (display->display, TermWin.parent[0], - display->atom ("_NET_WM_PID"), XA_CARDINAL, 32, + xa[XA_NET_WM_PID], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); #endif @@ -1010,10 +1017,8 @@ #if ENABLE_FRILLS if (mwmhints.flags) - { - prop = XInternAtom (display->display, "_MOTIF_WM_HINTS", False); - XChangeProperty (display->display, TermWin.parent[0], prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS); - } + XChangeProperty (display->display, TermWin.parent[0], xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, + PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); #endif /* vt cursor: Black-on-White is standard, but this is more popular */