*** empty log message ***
authorroot <root>
Sat, 18 Feb 2006 14:14:43 +0000 (14:14 +0000)
committerroot <root>
Sat, 18 Feb 2006 14:14:43 +0000 (14:14 +0000)
Changes
src/main.C
src/rxvtfont.C
src/rxvtfont.h
src/rxvttoolkit.C
src/rxvttoolkit.h

diff --git a/Changes b/Changes
index 1fd55da646e3da74d0d35d49f7527f26c2ae08e6..2c6b01d731a3e81d81f43ce7941302051c11b2b1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -26,6 +26,7 @@ DUMB: support tex fonts
           in empts spaces, but thats not true when reversing (e.g. selection),
           so also check for matching fg colours. This fixes the problem where
           selecting newly scrolled-in lines would exhibit wrong colours.
+        - fix a race resulting in a crash on exiting.
 
 7.6  Fri Feb 10 08:52:36 CET 2006
        - changed interpretation of [alpha] colour prefix.
index 148e4f06ecdaa0535b2d2f1b380ce969251d32f3..09cdf6a128d845b13c58d43d2c744191f973320d 100644 (file)
@@ -200,6 +200,7 @@ void rxvt_term::emergency_cleanup ()
   if (cmd_pid)
     kill (-cmd_pid, SIGHUP);
 
+  pty_ev.stop ();
   delete pty; pty = 0;
 }
 
index 13b4785862388954058c4578768fd0fe81e1b374..75fc571d426740159aae427176cda5c8412f6b62 100644 (file)
@@ -165,24 +165,6 @@ static uint16_t extent_test_chars[] = {
 
 /////////////////////////////////////////////////////////////////////////////
 
-#if XFT
-rxvt_drawable::~rxvt_drawable ()
-{
-  if (xftdrawable)
-    XftDrawDestroy (xftdrawable);
-}
-
-rxvt_drawable::operator XftDraw *()
-{
-  if (!xftdrawable)
-    xftdrawable = XftDrawCreate (screen->dpy, drawable, screen->visual, screen->cmap);
-
-  return xftdrawable;
-}
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-
 static const char *
 enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero)
 {
@@ -1284,8 +1266,6 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
                      const text_t *text, int len,
                      int fg, int bg)
 {
-  clear_rect (d, x, y, term->fwidth * len, term->fheight, bg);
-
   XGlyphInfo extents;
   XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec));
   XftGlyphSpec *ep = enc;
@@ -1293,10 +1273,18 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
   dTermDisplay;
   dTermGC;
 
+  int w = term->fwidth * len;
+  int h = term->fheight;
+
+  bool buffered = false;
+
   // cut trailing spaces
   while (len && text [len - 1] == ' ')
     len--;
 
+  int x_ = buffered ? 0 : x;
+  int y_ = buffered ? 0 : y;
+
   while (len)
     {
       int cwidth = term->fwidth;
@@ -1311,21 +1299,39 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
           XftGlyphExtents (disp, f, &glyph, 1, &extents);
 
           ep->glyph = glyph;
-          ep->x = x + (cwidth - extents.xOff >> 1);
-          ep->y = y + ascent;
+          ep->x = x_ + (cwidth - extents.xOff >> 1);
+          ep->y = y_ + ascent;
 
           if (extents.xOff == 0)
-            ep->x = x + cwidth;
+            ep->x = x_ + cwidth;
 
           ep++;
         }
 
-      x += cwidth;
+      x_ += cwidth;
     }
 
-  if (ep != enc)
-    XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc);
+  if (buffered)
+    {
+      if (ep != enc)
+        {
+          rxvt_drawable &d2 = d.screen->scratch_drawable (w, h);
+
+          XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h);
+
+          XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc);
+          XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y);
+        }
+      else
+        clear_rect (d, x, y, w, h, bg);
+    }
+  else
+    {
+      clear_rect (d, x, y, w, h, bg);
+      XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc);
+    }
 }
+
 #endif
 
 /////////////////////////////////////////////////////////////////////////////
index 6eb296f1f0a36539157539498fb1a2101491dc19..a70ead45e8495be98ca6923bb9ef977eac149422 100644 (file)
@@ -38,29 +38,6 @@ struct rxvt_fontprop {
   int weight, slant;
 };
 
-struct rxvt_drawable {
-  rxvt_screen *screen;
-#if XFT
-  XftDraw *xftdrawable;
-  operator XftDraw *();
-#endif
-  Drawable drawable;
-
-  rxvt_drawable (rxvt_screen *screen, Drawable drawable)
-  : screen(screen),
-#if XFT
-    xftdrawable(0),
-#endif
-    drawable(drawable)
-  { }
-
-#if XFT
-  ~rxvt_drawable ();
-#endif
-
-  operator Drawable() { return drawable; }
-};
-
 struct rxvt_font {
   // managed by the fontset
   rxvt_term *term;
index 42d2080cbcd83a940432db7105d67300fdf25a97..711b99fe464636c0a4f0b63e3c19dad525e6b35f 100644 (file)
@@ -203,6 +203,56 @@ rxvt_xim::~rxvt_xim ()
 
 /////////////////////////////////////////////////////////////////////////////
 
+#if XFT
+rxvt_drawable::~rxvt_drawable ()
+{
+  if (xftdrawable)
+    XftDrawDestroy (xftdrawable);
+}
+
+rxvt_drawable::operator XftDraw *()
+{
+  if (!xftdrawable)
+    xftdrawable = XftDrawCreate (screen->dpy, drawable, screen->visual, screen->cmap);
+
+  return xftdrawable;
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+
+#if XFT
+
+// not strictly necessary as it is only used with superclass of zero_initialised
+rxvt_screen::rxvt_screen ()
+: scratch_area (0)
+{
+}
+
+rxvt_drawable &rxvt_screen::scratch_drawable (int w, int h)
+{
+  // it's actually faster to re-allocate every time. don't ask me
+  // why, but its likely no big deal there are no roundtrips
+  // (I think/hope).
+  if (!scratch_area || w > scratch_w || h > scratch_h || 1/*D*/)
+    {
+      if (scratch_area)
+        {
+          XFreePixmap (dpy, scratch_area->drawable);
+          delete scratch_area;
+        }
+
+      Pixmap pm = XCreatePixmap (dpy, RootWindowOfScreen (ScreenOfDisplay (dpy, display->screen)),
+                                 scratch_w = w, scratch_h = h, depth);
+
+      scratch_area = new rxvt_drawable (this, pm);
+    }
+
+  return *scratch_area;
+}
+
+#endif
+
 void
 rxvt_screen::set (rxvt_display *disp)
 {
@@ -236,6 +286,14 @@ rxvt_screen::set (rxvt_display *disp, int bitdepth)
 void
 rxvt_screen::clear ()
 {
+#if XFT
+  if (scratch_area)
+    {
+      XFreePixmap (dpy, scratch_area->drawable);
+      delete scratch_area;
+    }
+#endif
+
   if (cmap != DefaultColormapOfScreen (ScreenOfDisplay (dpy, display->screen)))
     XFreeColormap (dpy, cmap);
 }
index 4314289cfa3c5624d500b11715e6bf2e27eecc7a..06491d304d596b45265fa3ced54eeeb97cbb58e4 100644 (file)
@@ -107,6 +107,33 @@ struct refcache : vector<T *> {
 
 /////////////////////////////////////////////////////////////////////////////
 
+struct rxvt_screen;
+
+struct rxvt_drawable {
+  rxvt_screen *screen;
+  Drawable drawable;
+  operator Drawable() { return drawable; }
+
+#if XFT
+  XftDraw *xftdrawable;
+  operator XftDraw *();
+#endif
+
+  rxvt_drawable (rxvt_screen *screen, Drawable drawable)
+  : screen(screen),
+#if XFT
+    xftdrawable(0),
+#endif
+    drawable(drawable)
+  { }
+
+#if XFT
+  ~rxvt_drawable ();
+#endif
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
 #ifdef USE_XIM
 struct rxvt_xim : refcounted {
   void destroy ();
@@ -128,6 +155,16 @@ struct rxvt_screen {
   Visual *visual;
   Colormap cmap;
 
+#if XFT
+  // scratch pixmap
+  rxvt_drawable *scratch_area;
+  int scratch_w, scratch_h;
+
+  rxvt_drawable &scratch_drawable (int w, int h);
+
+  rxvt_screen ();
+#endif
+
   void set (rxvt_display *disp);
   void set (rxvt_display *disp, int bitdepth);
   void clear ();