--- rxvt-unicode/src/command.C 2006/03/04 22:05:05 1.312 +++ rxvt-unicode/src/command.C 2007/06/09 13:04:27 1.326 @@ -502,6 +502,14 @@ # endif return; } + else if (keysym == XK_BackSpace) + { + iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; +# if ISO_14755 + iso14755_51 (iso14755buf & ISO_14755_MASK); +# endif + return; + } else if ((hv = hex_keyval (ev)) >= 0) { iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) @@ -879,7 +887,7 @@ if (len <= 0) return; /* not mapped */ - if (OPTION (Opt_scrollTtyKeypress)) + if (option (Opt_scrollTtyKeypress)) if (view_start) { view_start = 0; @@ -967,7 +975,7 @@ if (iso14755buf & ISO_14755_51) commit_iso14755 (); #if ISO_14755 - else if (iso14755buf & ISO_14755_STARTED) + else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) { iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair @@ -1234,7 +1242,7 @@ { pty_ev.stop (); - if (!OPTION (Opt_hold)) + if (!option (Opt_hold)) destroy (); } @@ -1265,7 +1273,7 @@ #ifdef POINTER_BLANK hidden_pointer = 0; - if (OPTION (Opt_pointerBlank)) + if (option (Opt_pointerBlank)) pointer_ev.start (NOW + pointerBlankDelay); #endif } @@ -1274,7 +1282,7 @@ void rxvt_term::pointer_blank () { - if (!OPTION (Opt_pointerBlank)) + if (!option (Opt_pointerBlank)) return; XDefineCursor (dpy, vt, display->blank_cursor); @@ -1460,11 +1468,17 @@ break; case FocusIn: - focus_in (); + if (ev.xfocus.detail != NotifyInferior + && ev.xfocus.detail != NotifyPointer + && ev.xfocus.mode != NotifyGrab) + focus_in (); break; case FocusOut: - focus_out (); + if (ev.xfocus.detail != NotifyInferior + && ev.xfocus.detail != NotifyPointer + && ev.xfocus.mode != NotifyGrab) + focus_out (); break; case ConfigureNotify: @@ -1477,12 +1491,19 @@ { seen_resize = 1; resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); +#ifdef XPM_BACKGROUND + if (!option(Opt_transparent) && bgPixmap.auto_resize) + { + resize_pixmap (); + scr_touch (true); + } +#endif } HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); -#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ - if (OPTION (Opt_transparent)) +#ifdef TRANSPARENT + if (option (Opt_transparent)) check_our_parents (); #endif } @@ -1681,7 +1702,7 @@ } #if defined(CURSOR_BLINK) - if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) + if (option (Opt_cursorBlink) && ev.type == KeyPress) { if (hidden_cursor) { @@ -1694,7 +1715,7 @@ #endif #if defined(POINTER_BLANK) - if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) + if (option (Opt_pointerBlank) && pointerBlankDelay > 0) { if (ev.type == MotionNotify || ev.type == ButtonPress @@ -1726,7 +1747,7 @@ } #endif #if CURSOR_BLINK - if (OPTION (Opt_cursorBlink)) + if (option (Opt_cursorBlink)) cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); #endif #if OFF_FOCUS_FADING @@ -1736,6 +1757,19 @@ scr_recolour (); } #endif +#if ENABLE_FRILLS + if (option (Opt_urgentOnBell)) + { + XWMHints *h; + + h = XGetWMHints(dpy, parent[0]); + if (h != NULL) + { + h->flags &= ~XUrgencyHint; + XSetWMHints(dpy, parent[0], h); + } + } +#endif } } @@ -1763,7 +1797,7 @@ XUnsetICFocus (Input_Context); #endif #if CURSOR_BLINK - if (OPTION (Opt_cursorBlink)) + if (option (Opt_cursorBlink)) cursor_blink_ev.stop (); hidden_cursor = 0; #endif @@ -1777,12 +1811,30 @@ } } -#if TRANSPARENT +void +rxvt_term::update_fade_color (unsigned int idx) +{ +#if OFF_FOCUS_FADING + if (rs[Rs_fade]) + { + rgba c; + pix_colors [Color_fade].get (c); + pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); + } +#endif +} + +#if TRANSPARENT || ENABLE_PERL void rxvt_term::rootwin_cb (XEvent &ev) { make_current (); + if (SHOULD_INVOKE (HOOK_ROOT_EVENT) + && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) + return; + +# if TRANSPARENT switch (ev.type) { case PropertyNotify: @@ -1796,10 +1848,11 @@ /* FALLTHROUGH */ case ReparentNotify: - if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) - want_refresh = want_full_refresh = 1; + if (option (Opt_transparent)) + check_our_parents (); break; } +# endif } #endif @@ -2137,7 +2190,7 @@ case Button2: if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? - selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); + selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); break; #ifdef MOUSE_WHEEL @@ -2151,7 +2204,7 @@ if (ev.state & ShiftMask) i = 1; - else if (OPTION (Opt_mouseWheelScrollPage)) + else if (option (Opt_mouseWheelScrollPage)) i = nrow - 1; else i = 5; @@ -2184,7 +2237,7 @@ } #ifdef TRANSPARENT -#if TINTING +#if TINTING && !defined(HAVE_AFTERIMAGE) /* taken from aterm-0.4.2 */ typedef uint32_t RUINT32T; @@ -2422,6 +2475,16 @@ int rxvt_term::check_our_parents () { +#if TRANSPARENT || ENABLE_PERL + check_our_parents_ev.stop (); + check_our_parents_ev.start (NOW + .1); +#endif + return 0; +} + +void +rxvt_term::check_our_parents_cb (time_watcher &w) +{ int i, pchanged, aformat, have_pixmap, rootdepth; unsigned long nitems, bytes_after; Atom atype; @@ -2429,11 +2492,13 @@ Window root, oldp, *list; Pixmap rootpixmap = None; XWindowAttributes wattr, wrootattr; + int sx, sy; + Window cr; pchanged = 0; - if (!OPTION (Opt_transparent)) - return pchanged; /* Don't try any more */ + if (!option (Opt_transparent)) + return /*pchanged*/; /* Don't try any more */ XGetWindowAttributes (dpy, display->root, &wrootattr); rootdepth = wrootattr.depth; @@ -2449,12 +2514,19 @@ am_transparent = am_pixmap_trans = 0; } - return pchanged; /* Don't try any more */ + return /*pchanged*/; /* Don't try any more */ } /* Get all X ops out of the queue so that our information is up-to-date. */ XSync (dpy, False); + XTranslateCoordinates (dpy, parent[0], display->root, + 0, 0, &sx, &sy, &cr); + + /* check if we are outside of the visible part of the virtual screen : */ + if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 + || sx >= wrootattr.width || sy >= wrootattr.height ) + return /* 0 */ ; /* * Make the frame window set by the window manager have * the root background. Some window managers put multiple nested frame @@ -2473,7 +2545,11 @@ if (!i || prop == NULL #if TINTING - || !ISSET_PIXCOLOR (Color_tint) + || (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL +#ifdef HAVE_AFTERIMAGE + && original_asim == NULL && rs[Rs_blurradius] == NULL +#endif + ) #endif ) have_pixmap = 0; @@ -2486,48 +2562,192 @@ if (have_pixmap) { + Bool success = False ; + GC gc; + XGCValues gcvalue; +#ifdef HAVE_AFTERIMAGE + { + Pixmap tmp_pmap = None ; + ShadingInfo shade; + ARGB32 tint ; + unsigned int pmap_w = 0, pmap_h = 0; + + if (get_drawable_size( rootpixmap, &pmap_w, &pmap_h )) + { + int root_x = 0, root_y = 0; + + shade.shading = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; + if (ISSET_PIXCOLOR (Color_tint)) + { + rgba c; + pix_colors_focused [Color_tint].get (c); + shade.tintColor.red = c.r; + shade.tintColor.green = c.g; + shade.tintColor.blue = c.b; + } + else + shade.tintColor.red = shade.tintColor.green = shade.tintColor.blue = 0xFFFF; + tint = shading2tint32( &shade ); + gc = XCreateGC (dpy, vt, 0UL, &gcvalue); + if (GetWinPosition (parent[0], &root_x, &root_y) ) + { + ASImageLayer *layers = create_image_layers( 2 ); + ASImage *merged_im = NULL; + int back_x, back_y, back_w, back_h; + /* merge_layers does good job at tiling background appropriately, + so all we need is to cut out smallest possible piece : */ +#define MAKE_ROOTPMAP_GEOM(xy,wh,widthheight) \ + do{ while( root_##xy < 0 ) root_##xy += (int)wrootattr.widthheight; \ + back_##xy = root_##xy % pmap_##wh; /* that gives us left side of the closest tile : */ \ + if( pmap_##wh >= back_##xy + szHint.widthheight ) \ + back_##wh = szHint.widthheight;/* background is large - limit it by our size */ \ + else \ + { /* small background - need the whole of it for successfull tiling :*/ \ + back_##xy = 0; \ + back_##wh = pmap_##wh; \ + }}while(0) + + MAKE_ROOTPMAP_GEOM(x,w,width); + MAKE_ROOTPMAP_GEOM(y,h,height); + + layers[0].im = pixmap2asimage (display->asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100); + layers[0].clip_x = (back_w == pmap_w)?root_x:0; + layers[0].clip_y = (back_h == pmap_h)?root_y:0; + layers[0].clip_width = szHint.width; + layers[0].clip_height = szHint.height; + layers[0].tint = tint; + if (rs[Rs_blurradius] && layers[0].im) + { + double r = atof(rs[Rs_blurradius]); + ASImage* tmp = blur_asimage_gauss(display->asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT ); + if( tmp ) + { + destroy_asimage( &layers[0].im ); + layers[0].im = tmp; + } + } + if (original_asim != NULL) + { + int fore_w, fore_h; + layers[1].im = original_asim; + if( bgPixmap.auto_resize ) + { + fore_w = szHint.width; + fore_h = szHint.height; + } + else + { + fore_w = bgPixmap.w; + fore_h = bgPixmap.h; + } + if (fore_w != original_asim->width + || fore_h != original_asim->height) + { + layers[1].im = scale_asimage( display->asv, + original_asim, + fore_w, fore_h, + ASA_ASImage, 100, + ASIMAGE_QUALITY_DEFAULT ); + } + + layers[1].clip_width = szHint.width; + layers[1].clip_height = szHint.height; + + if (rs[Rs_blendtype]) + { + layers[1].merge_scanlines = blend_scanlines_name2func(rs[Rs_blendtype]); + if( layers[1].merge_scanlines == NULL ) + layers[1].merge_scanlines = alphablend_scanlines; + } + } + merged_im = merge_layers( display->asv, layers, layers[1].im?2:1, + szHint.width, szHint.height, + ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); + if (layers[1].im != original_asim) + destroy_asimage( &(layers[1].im) ); + destroy_asimage( &(layers[0].im) ); + if (merged_im != NULL) + { + tmp_pmap = asimage2pixmap( display->asv, DefaultRootWindow(dpy), merged_im, gc, True ); + destroy_asimage( &merged_im ); + } + free( layers ); + } + } + if (tmp_pmap != None) + { + success = True; + if (pixmap != None) + XFreePixmap (dpy, pixmap); + pixmap = tmp_pmap; + } + } +#else /* HAVE_AFTERIMAGE */ + { /* * Copy display->root pixmap transparency */ - int sx, sy, nx, ny; - unsigned int nw, nh; - Window cr; - XImage *image; - GC gc; - XGCValues gcvalue; + int nx, ny; + unsigned int nw, nh; + XImage *image; - XTranslateCoordinates (dpy, parent[0], display->root, - 0, 0, &sx, &sy, &cr); - nw = (unsigned int)szHint.width; - nh = (unsigned int)szHint.height; - nx = ny = 0; + nw = (unsigned int)szHint.width; + nh = (unsigned int)szHint.height; + nx = ny = 0; - if (sx < 0) - { - nw += sx; - nx = -sx; - sx = 0; - } + if (sx < 0) + { + nw += sx; + nx = -sx; + sx = 0; + } - if (sy < 0) - { - nh += sy; - ny = -sy; - sy = 0; - } + if (sy < 0) + { + nh += sy; + ny = -sy; + sy = 0; + } + + min_it (nw, (unsigned int) (wrootattr.width - sx)); + min_it (nh, (unsigned int) (wrootattr.height - sy)); - min_it (nw, (unsigned int) (wrootattr.width - sx)); - min_it (nh, (unsigned int) (wrootattr.height - sy)); + XSync (dpy, False); + allowedxerror = -1; + image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); - XSync (dpy, False); - allowedxerror = -1; - image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); + /* XXX: handle BadMatch - usually because we're outside the pixmap */ + /* XXX: may need a delay here? */ + allowedxerror = 0; + if (image != NULL) + { + if (pixmap != None) + XFreePixmap (dpy, pixmap); + +#if TINTING + if (ISSET_PIXCOLOR (Color_tint)) + { + int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; + + rgba c; + pix_colors_focused [Color_tint].get (c); + ShadeXImage (this, image, shade, c.r, c.g, c.b); + } +#endif - /* XXX: handle BadMatch - usually because we're outside the pixmap */ - /* XXX: may need a delay here? */ - allowedxerror = 0; + pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); + gc = XCreateGC (dpy, vt, 0UL, &gcvalue); + XPutImage (dpy, pixmap, gc, image, 0, 0, + nx, ny, image->width, image->height); + XDestroyImage (image); + success = True ; + } + } +#endif /* HAVE_AFTERIMAGE */ + if (gc != NULL) + XFreeGC (dpy, gc); - if (image == NULL) + if (!success) { if (am_transparent && am_pixmap_trans) { @@ -2543,27 +2763,6 @@ } else { - if (pixmap != None) - XFreePixmap (dpy, pixmap); - -#if TINTING - if (ISSET_PIXCOLOR (Color_tint)) - { - int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; - - rgba c; - pix_colors_focused [Color_tint].get (c); - - ShadeXImage (this, image, shade, c.r, c.g, c.b); - } -#endif - - pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); - gc = XCreateGC (dpy, vt, 0UL, &gcvalue); - XPutImage (dpy, pixmap, gc, image, 0, 0, - nx, ny, image->width, image->height); - XFreeGC (dpy, gc); - XDestroyImage (image); XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); XClearWindow (dpy, parent[0]); @@ -2651,7 +2850,7 @@ flush (); } - return pchanged; +// return pchanged; } #endif @@ -2712,7 +2911,7 @@ refresh_count++; - if (!OPTION (Opt_jumpScroll) + if (!option (Opt_jumpScroll) || (refresh_count >= refresh_limit * (nrow - 1))) { refreshnow = true; @@ -2762,7 +2961,7 @@ */ if (refreshnow) { - if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) + if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) refresh_limit++; else { @@ -3438,7 +3637,7 @@ scr_report_position (); break; case 7: /* unofficial extension */ - if (OPTION (Opt_insecure)) + if (option (Opt_insecure)) tt_printf ("%-.250s\012", rs[Rs_display_name]); break; case 8: /* unofficial extension */ @@ -3612,7 +3811,7 @@ { char *s; XGetIconName (dpy, parent[0], &s); - tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ + tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3620,7 +3819,7 @@ { char *s; XFetchName (dpy, parent[0], &s); - tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ + tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3657,6 +3856,8 @@ } else if (ch == C0_BEL || ch == CHAR_ST) break; + else if (ch == C0_SYN) + ch = cmd_get8 (); else if (ch < 0x20) return NULL; /* other control character - exit */ @@ -3666,10 +3867,7 @@ // stop at some sane length return NULL; - if (ch == C0_SYN) - string[n++] = cmd_get8 (); - else - string[n++] = ch; + string[n++] = ch; } string[n++] = '\0'; @@ -3903,6 +4101,11 @@ scr_touch (true); #endif } +#if TRANSPARENT && defined(HAVE_AFTERIMAGE) + if (option(Opt_transparent)) + check_our_parents (); +#endif + } break; @@ -3939,7 +4142,7 @@ #endif if (query) tt_printf ("\33]%d;%-.250s%c", saveop, - OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc + option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc ? fontset[op - URxvt_font]->fontdesc : "", resp); else @@ -3963,7 +4166,7 @@ #if !ENABLE_MINIMAL case URxvt_locale: if (query) - tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); + tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); else { set_locale (str); @@ -4114,7 +4317,7 @@ #endif case 1048: /* alternative cursor save */ case 1049: - if (OPTION (Opt_secondaryScreen)) + if (option (Opt_secondaryScreen)) if (mode == 0) scr_cursor (RESTORE); else if (mode == 1) @@ -4189,14 +4392,14 @@ set_option (Opt_scrollTtyKeypress, state); break; case 1047: /* secondary screen w/ clearing last */ - if (OPTION (Opt_secondaryScreen)) + if (option (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); scr_change_screen (state); break; case 1049: /* secondary screen w/ clearing first */ scr_change_screen (state); - if (OPTION (Opt_secondaryScreen)) + if (option (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); break;