--- rxvt-unicode/src/init.C 2005/02/19 04:16:49 1.113 +++ rxvt-unicode/src/init.C 2005/08/10 15:10:06 1.118 @@ -187,10 +187,13 @@ "WM_DELETE_WINDOW", "CLIPBOARD", #if ENABLE_FRILLS - "_NET_WM_PID", "_MOTIF_WM_HINTS", +#endif +#if ENABLE_EWMH + "_NET_WM_PID", "_NET_WM_NAME", "_NET_WM_ICON_NAME", + "_NET_WM_PING", #endif #if USE_XIM "WM_LOCALE_NAME", @@ -205,6 +208,7 @@ #endif #if ENABLE_XEMBED "_XEMBED", + "_XEMBED_INFO", #endif }; @@ -342,19 +346,7 @@ get_options (r_argc, r_argv); -#ifdef LOCAL_X_IS_UNIX - if (rs[Rs_display_name][0] == ':') - { - val = rxvt_malloc (5 + strlen (rs[Rs_display_name])); - strcpy (val, "unix"); - strcat (val, rs[Rs_display_name]); - display = displays.get (val); - free (val); - } -#endif - - if (!display - && ! (display = displays.get (rs[Rs_display_name]))) + if (!(display = displays.get (rs[Rs_display_name]))) rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); extract_resources (); @@ -770,7 +762,8 @@ #ifdef KEEP_SCROLLCOLOR if (display->depth <= 2) - { /* Monochrome */ + { + /* Monochrome */ pix_colors[Color_scroll] = pix_colors[Color_fg]; pix_colors[Color_topShadow] = pix_colors[Color_bg]; pix_colors[Color_bottomShadow] = pix_colors[Color_bg]; @@ -931,7 +924,7 @@ long vt_emask; XSetWindowAttributes attributes; XWindowAttributes gattr; - Window top; + Window top, parent; dDisp; #ifdef USING_W11LIB @@ -968,9 +961,7 @@ } } else - { - mwmhints.flags = 0; - } + mwmhints.flags = 0; #endif /* grab colors before netscape does */ @@ -979,59 +970,44 @@ if (!set_fonts ()) rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); + parent = DefaultRootWindow (disp); + #if ENABLE_XEMBED if (rs[Rs_embed]) { XWindowAttributes wattr; - top = strtol (rs[Rs_embed], 0, 0); + parent = strtol (rs[Rs_embed], 0, 0); - if (!XGetWindowAttributes (disp, top, &wattr)) + if (!XGetWindowAttributes (disp, parent, &wattr)) rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); window_calc (wattr.width, wattr.height); - -#if 0 - if (wattr.map_state == IsViewable) - { - TermWin.mapped = 1; - refresh_type = FAST_REFRESH; - XClearWindow (disp, top); - // TODO: make XMapNotify-event-code a function and call it - // TODO: how can I detect visibility without unmap/map? - // TODO: focusin etc. - } -#else - // it's easiest just to unmap/map to get all state correctly set-up - XUnmapWindow (disp, top); -#endif } - else + #endif - { - window_calc (0, 0); + window_calc (0, 0); - /* sub-window placement & size in rxvt_resize_subwindows () */ + /* sub-window placement & size in rxvt_resize_subwindows () */ #ifdef PREFER_24BIT - attributes.background_pixel = pix_colors_focused[Color_border]; - attributes.border_pixel = pix_colors_focused[Color_border]; - attributes.colormap = display->cmap; - top = XCreateWindow (disp, DefaultRootWindow (disp), - szHint.x, szHint.y, - szHint.width, szHint.height, - TermWin.ext_bwidth, - display->depth, InputOutput, - display->visual, - CWColormap | CWBackPixel | CWBorderPixel, &attributes); + attributes.background_pixel = pix_colors_focused[Color_border]; + attributes.border_pixel = pix_colors_focused[Color_border]; + attributes.colormap = display->cmap; + top = XCreateWindow (disp, parent, + szHint.x, szHint.y, + szHint.width, szHint.height, + TermWin.ext_bwidth, + display->depth, InputOutput, + display->visual, + CWColormap | CWBackPixel | CWBorderPixel, &attributes); #else - top = XCreateSimpleWindow (disp, DefaultRootWindow (disp), - szHint.x, szHint.y, - szHint.width, szHint.height, - TermWin.ext_bwidth, - pix_colors_focused[Color_border], - pix_colors_focused[Color_border]); + top = XCreateSimpleWindow (disp, parent, + szHint.x, szHint.y, + szHint.width, szHint.height, + TermWin.ext_bwidth, + pix_colors_focused[Color_border], + pix_colors_focused[Color_border]); #endif - } TermWin.parent[0] = top; @@ -1049,18 +1025,26 @@ wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; wmHint.window_group = top; - XSetWMProperties (disp, top, NULL, NULL, - (char **)argv, argc, &szHint, &wmHint, &classHint); + XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, + &szHint, &wmHint, &classHint); + + Atom protocols[] = { + xa[XA_WM_DELETE_WINDOW], +#if ENABLE_EWMH + xa[XA_NET_WM_PING], +#endif + }; - /* Enable delete window protocol */ - XSetWMProtocols (disp, top, &xa[XA_WM_DELETE_WINDOW], 1); + XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); -#if ENABLE_FRILLS +#if ENABLE_EWMH long pid = getpid (); XChangeProperty (disp, top, xa[XA_NET_WM_PID], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); + + // _NET_WM_WINDOW_TYPE is NORMAL, which is the default #endif XSelectInput (disp, top, @@ -1187,8 +1171,13 @@ scr_recolour (); #if ENABLE_XEMBED - // why this is necessary, I don't know, race condition?? - XMoveWindow (disp, TermWin.vt, window_vt_x, window_vt_y); + if (rs[Rs_embed]) + { + long info[2] = { 0, XEMBED_MAPPED }; + + XChangeProperty (disp, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], + 32, PropModeReplace, (unsigned char *)&info, 2); + } #endif }