*** empty log message ***
authorroot <root>
Fri, 4 Feb 2005 11:41:23 +0000 (11:41 +0000)
committerroot <root>
Fri, 4 Feb 2005 11:41:23 +0000 (11:41 +0000)
src/command.C
src/init.C
src/main.C
src/menubar.C
src/rxvt.h
src/rxvtlib.h.in
src/screen.C
src/scrollbar-next.C
src/scrollbar-rxvt.C
src/xpm.C

index 1e61d26..4c5d324 100644 (file)
@@ -1184,6 +1184,8 @@ rxvt_W11_process_x_event (XEvent *ev)
 void
 rxvt_term::x_cb (XEvent &ev)
 {
 void
 rxvt_term::x_cb (XEvent &ev)
 {
+  dDisp;
+
   SET_R (this);
   SET_LOCALE (locale);
 
   SET_R (this);
   SET_LOCALE (locale);
 
@@ -1324,17 +1326,17 @@ rxvt_term::x_cb (XEvent &ev)
             unsigned char *data;
             unsigned long Size, RemainingBytes;
 
             unsigned char *data;
             unsigned long Size, RemainingBytes;
 
-            XGetWindowProperty (display->display, display->root,
-                               xa[XA_DNDSELECTION],
-                               0L, 1000000L,
-                               False, AnyPropertyType,
-                               &ActualType, &ActualFormat,
-                               &Size, &RemainingBytes,
-                               &data);
+            XGetWindowProperty (disp, display->root,
+                                xa[XA_DNDSELECTION],
+                                0L, 1000000L,
+                                False, AnyPropertyType,
+                                &ActualType, &ActualFormat,
+                                &Size, &RemainingBytes,
+                                &data);
             set_string_property (XA_CUT_BUFFER0, data);
             XFree (data);
             selection_paste (display->root, XA_CUT_BUFFER0, true);
             set_string_property (XA_CUT_BUFFER0, data);
             XFree (data);
             selection_paste (display->root, XA_CUT_BUFFER0, true);
-            XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime);
+            XSetInputFocus (disp, display->root, RevertToNone, CurrentTime);
           }
 #endif                         /* OFFIX_DND */
         break;
           }
 #endif                         /* OFFIX_DND */
         break;
@@ -1437,7 +1439,7 @@ rxvt_term::x_cb (XEvent &ev)
                 height = ev.xconfigure.height;
                 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
               }
                 height = ev.xconfigure.height;
                 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
               }
-            while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev));
+            while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev));
 
             if (szHint.width != width || szHint.height != height)
               {
 
             if (szHint.width != width || szHint.height != height)
               {
@@ -1499,11 +1501,11 @@ rxvt_term::x_cb (XEvent &ev)
             do
               scr_expose (ev.xexpose.x, ev.xexpose.y,
                           ev.xexpose.width, ev.xexpose.height, False);
             do
               scr_expose (ev.xexpose.x, ev.xexpose.y,
                           ev.xexpose.width, ev.xexpose.height, False);
-            while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev));
+            while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev));
 
             ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
 
 
             ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
 
-            while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev))
+            while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev))
               scr_expose (ev.xexpose.x, ev.xexpose.y,
                           ev.xexpose.width, ev.xexpose.height, False);
 
               scr_expose (ev.xexpose.x, ev.xexpose.y,
                           ev.xexpose.width, ev.xexpose.height, False);
 
@@ -1513,9 +1515,9 @@ rxvt_term::x_cb (XEvent &ev)
           {
             XEvent unused_event;
 
           {
             XEvent unused_event;
 
-            while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event))
+            while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event))
               ;
               ;
-            while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event))
+            while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event))
               ;
 
             if (isScrollbarWindow (ev.xany.window))
               ;
 
             if (isScrollbarWindow (ev.xany.window))
@@ -1530,7 +1532,7 @@ rxvt_term::x_cb (XEvent &ev)
 
 #ifdef TRANSPARENT
             if (am_transparent && ev.xany.window == TermWin.parent[0])
 
 #ifdef TRANSPARENT
             if (am_transparent && ev.xany.window == TermWin.parent[0])
-              XClearWindow (display->display, ev.xany.window);
+              XClearWindow (disp, ev.xany.window);
 #endif
           }
         break;
 #endif
           }
         break;
@@ -1554,10 +1556,10 @@ rxvt_term::x_cb (XEvent &ev)
           {
             if (ev.xbutton.state & (Button1Mask | Button3Mask))
               {
           {
             if (ev.xbutton.state & (Button1Mask | Button3Mask))
               {
-                while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev))
+                while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev))
                   ;
 
                   ;
 
-                XQueryPointer (display->display, TermWin.vt,
+                XQueryPointer (disp, TermWin.vt,
                                &unused_root, &unused_child,
                                &unused_root_x, &unused_root_y,
                                &ev.xbutton.x, &ev.xbutton.y,
                                &unused_root, &unused_child,
                                &unused_root_x, &unused_root_y,
                                &ev.xbutton.x, &ev.xbutton.y,
@@ -1631,11 +1633,11 @@ rxvt_term::x_cb (XEvent &ev)
           }
         else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
           {
           }
         else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
           {
-            while (XCheckTypedWindowEvent (display->display, scrollBar.win,
+            while (XCheckTypedWindowEvent (disp, scrollBar.win,
                                            MotionNotify, &ev))
               ;
 
                                            MotionNotify, &ev))
               ;
 
-            XQueryPointer (display->display, scrollBar.win,
+            XQueryPointer (disp, scrollBar.win,
                           &unused_root, &unused_child,
                           &unused_root_x, &unused_root_y,
                           &ev.xbutton.x, &ev.xbutton.y,
                           &unused_root, &unused_child,
                           &unused_root_x, &unused_root_y,
                           &ev.xbutton.x, &ev.xbutton.y,
@@ -2083,7 +2085,7 @@ void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int
   unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
   int i;
 
   unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
   int i;
 
-  Visualvisual = display->visual;
+  Visual *visual = display->visual;
 
   if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
 
 
   if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
 
@@ -2314,23 +2316,24 @@ rxvt_term::check_our_parents ()
   Window root, oldp, *list;
   Pixmap rootpixmap = None;
   XWindowAttributes wattr, wrootattr;
   Window root, oldp, *list;
   Pixmap rootpixmap = None;
   XWindowAttributes wattr, wrootattr;
+  dDisp;
 
   pchanged = 0;
 
   if (!(options & Opt_transparent))
     return pchanged;   /* Don't try any more */
 
 
   pchanged = 0;
 
   if (!(options & Opt_transparent))
     return pchanged;   /* Don't try any more */
 
-  XGetWindowAttributes (display->display, display->root, &wrootattr);
+  XGetWindowAttributes (disp, display->root, &wrootattr);
   rootdepth = wrootattr.depth;
 
   rootdepth = wrootattr.depth;
 
-  XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
+  XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
 
   if (rootdepth != wattr.depth)
     {
       if (am_transparent)
         {
           pchanged = 1;
 
   if (rootdepth != wattr.depth)
     {
       if (am_transparent)
         {
           pchanged = 1;
-          XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]);
+          XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]);
           am_transparent = am_pixmap_trans = 0;
         }
 
           am_transparent = am_pixmap_trans = 0;
         }
 
@@ -2338,7 +2341,7 @@ rxvt_term::check_our_parents ()
     }
 
   /* Get all X ops out of the queue so that our information is up-to-date. */
     }
 
   /* Get all X ops out of the queue so that our information is up-to-date. */
-  XSync (display->display, False);
+  XSync (disp, False);
 
   /*
    * Make the frame window set by the window manager have
 
   /*
    * Make the frame window set by the window manager have
@@ -2346,13 +2349,13 @@ rxvt_term::check_our_parents ()
    * windows for each client, so we have to take care about that.
    */
   i = (xa[XA_XROOTPMAP_ID]
    * windows for each client, so we have to take care about that.
    */
   i = (xa[XA_XROOTPMAP_ID]
-       && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID],
+       && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID],
                               0L, 1L, False, XA_PIXMAP, &atype, &aformat,
                               &nitems, &bytes_after, &prop) == Success);
 
   if (!i || prop == NULL)
      i = (xa[XA_ESETROOT_PMAP_ID]
                               0L, 1L, False, XA_PIXMAP, &atype, &aformat,
                               &nitems, &bytes_after, &prop) == Success);
 
   if (!i || prop == NULL)
      i = (xa[XA_ESETROOT_PMAP_ID]
-          && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID],
+          && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID],
                                  0L, 1L, False, XA_PIXMAP, &atype, &aformat,
                                  &nitems, &bytes_after, &prop) == Success);
 
                                  0L, 1L, False, XA_PIXMAP, &atype, &aformat,
                                  &nitems, &bytes_after, &prop) == Success);
 
@@ -2381,7 +2384,7 @@ rxvt_term::check_our_parents ()
       GC gc;
       XGCValues gcvalue;
 
       GC gc;
       XGCValues gcvalue;
 
-      XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
+      XTranslateCoordinates (disp, TermWin.parent[0], display->root,
                              0, 0, &sx, &sy, &cr);
       nw = (unsigned int)szHint.width;
       nh = (unsigned int)szHint.height;
                              0, 0, &sx, &sy, &cr);
       nw = (unsigned int)szHint.width;
       nh = (unsigned int)szHint.height;
@@ -2404,9 +2407,9 @@ rxvt_term::check_our_parents ()
       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 (display->display, False);
+      XSync (disp, False);
       allowedxerror = -1;
       allowedxerror = -1;
-      image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
+      image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
 
       /* XXX: handle BadMatch - usually because we're outside the pixmap */
       /* XXX: may need a delay here? */
 
       /* XXX: handle BadMatch - usually because we're outside the pixmap */
       /* XXX: may need a delay here? */
@@ -2419,7 +2422,7 @@ rxvt_term::check_our_parents ()
               pchanged = 1;
               if (TermWin.pixmap != None)
                 {
               pchanged = 1;
               if (TermWin.pixmap != None)
                 {
-                  XFreePixmap (display->display, TermWin.pixmap);
+                  XFreePixmap (disp, TermWin.pixmap);
                   TermWin.pixmap = None;
                 }
             }
                   TermWin.pixmap = None;
                 }
             }
@@ -2429,7 +2432,7 @@ rxvt_term::check_our_parents ()
       else
         {
           if (TermWin.pixmap != None)
       else
         {
           if (TermWin.pixmap != None)
-            XFreePixmap (display->display, TermWin.pixmap);
+            XFreePixmap (disp, TermWin.pixmap);
 
 #if TINTING
           if (ISSET_PIXCOLOR (Color_tint))
 
 #if TINTING
           if (ISSET_PIXCOLOR (Color_tint))
@@ -2443,15 +2446,15 @@ rxvt_term::check_our_parents ()
             }
 #endif
 
             }
 #endif
 
-          TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
+          TermWin.pixmap = XCreatePixmap (disp, TermWin.vt,
                                           szHint.width, szHint.height, image->depth);
                                           szHint.width, szHint.height, image->depth);
-          gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue);
-          XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0,
+          gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue);
+          XPutImage (disp, TermWin.pixmap, gc, image, 0, 0,
                      nx, ny, image->width, image->height);
                      nx, ny, image->width, image->height);
-          XFreeGC (display->display, gc);
+          XFreeGC (disp, gc);
           XDestroyImage (image);
           XDestroyImage (image);
-          XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap);
-          XClearWindow (display->display, TermWin.parent[0]);
+          XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap);
+          XClearWindow (disp, TermWin.parent[0]);
 
           if (!am_transparent || !am_pixmap_trans)
             pchanged = 1;
 
           if (!am_transparent || !am_pixmap_trans)
             pchanged = 1;
@@ -2461,7 +2464,7 @@ rxvt_term::check_our_parents ()
     }
 
   if (am_pixmap_trans)
     }
 
   if (am_pixmap_trans)
-    XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
+    XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative);
   else
     {
       unsigned int n;
   else
     {
       unsigned int n;
@@ -2471,7 +2474,7 @@ rxvt_term::check_our_parents ()
       for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
         {
           oldp = TermWin.parent[i];
       for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
         {
           oldp = TermWin.parent[i];
-          XQueryTree (display->display, TermWin.parent[i - 1], &root,
+          XQueryTree (disp, TermWin.parent[i - 1], &root,
                       &TermWin.parent[i], &list, &n);
           XFree (list);
 
                       &TermWin.parent[i], &list, &n);
           XFree (list);
 
@@ -2493,7 +2496,7 @@ rxvt_term::check_our_parents ()
         {
           for (; n < (unsigned int)i; n++)
             {
         {
           for (; n < (unsigned int)i; n++)
             {
-              XGetWindowAttributes (display->display, TermWin.parent[n], &wattr);
+              XGetWindowAttributes (disp, TermWin.parent[n], &wattr);
               if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
                 {
                   n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
               if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
                 {
                   n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
@@ -2504,8 +2507,8 @@ rxvt_term::check_our_parents ()
 
       if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
         {
 
       if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
         {
-          XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]);
-          XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]);
+          XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]);
+          XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]);
           am_transparent = 0;
           /* XXX: also turn off Opt_transparent? */
         }
           am_transparent = 0;
           /* XXX: also turn off Opt_transparent? */
         }
@@ -2518,11 +2521,11 @@ rxvt_term::check_our_parents ()
 #endif
           for (n = 0; n < (unsigned int)i; n++)
             {
 #endif
           for (n = 0; n < (unsigned int)i; n++)
             {
-              XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative);
-              XClearWindow (display->display, TermWin.parent[n]);
+              XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative);
+              XClearWindow (disp, TermWin.parent[n]);
             }
 
             }
 
-          XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
+          XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative);
           am_transparent = 1;
         }
 
           am_transparent = 1;
         }
 
@@ -2532,7 +2535,7 @@ rxvt_term::check_our_parents ()
 
   if (scrollBar.win)
     {
 
   if (scrollBar.win)
     {
-      XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
+      XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative);
       scrollBar.setIdle ();
       scrollbar_show (0);
     }
       scrollBar.setIdle ();
       scrollbar_show (0);
     }
@@ -3415,6 +3418,7 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
   int x, y;
   XWindowAttributes wattr;
   Window wdummy;
   int x, y;
   XWindowAttributes wattr;
   Window wdummy;
+  dDisp;
 
   if (nargs == 0)
     return;
 
   if (nargs == 0)
     return;
@@ -3425,23 +3429,22 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
        * commands
        */
       case 1:                  /* deiconify window */
        * commands
        */
       case 1:                  /* deiconify window */
-        XMapWindow (display->display, TermWin.parent[0]);
+        XMapWindow (disp, TermWin.parent[0]);
         break;
       case 2:                  /* iconify window */
         break;
       case 2:                  /* iconify window */
-        XIconifyWindow (display->display, TermWin.parent[0],
-                       DefaultScreen (display->display));
+        XIconifyWindow (disp, TermWin.parent[0], display->screen);
         break;
       case 3:                  /* set position (pixels) */
         break;
       case 3:                  /* set position (pixels) */
-        XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]);
+        XMoveWindow (disp, TermWin.parent[0], args[1], args[2]);
         break;
       case 4:                  /* set size (pixels) */
         set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
         break;
       case 5:                  /* raise window */
         break;
       case 4:                  /* set size (pixels) */
         set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
         break;
       case 5:                  /* raise window */
-        XRaiseWindow (display->display, TermWin.parent[0]);
+        XRaiseWindow (disp, TermWin.parent[0]);
         break;
       case 6:                  /* lower window */
         break;
       case 6:                  /* lower window */
-        XLowerWindow (display->display, TermWin.parent[0]);
+        XLowerWindow (disp, TermWin.parent[0]);
         break;
       case 7:                  /* refresh window */
         scr_touch (true);
         break;
       case 7:                  /* refresh window */
         scr_touch (true);
@@ -3463,18 +3466,18 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
        * reports - some output format copied from XTerm
        */
       case 11:                 /* report window state */
        * reports - some output format copied from XTerm
        */
       case 11:                 /* report window state */
-        XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
+        XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
         tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
         break;
       case 13:                 /* report window position */
         tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
         break;
       case 13:                 /* report window position */
-        XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
-        XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root,
+        XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
+        XTranslateCoordinates (disp, TermWin.parent[0], wattr.root,
                                -wattr.border_width, -wattr.border_width,
                                &x, &y, &wdummy);
         tt_printf ("\033[3;%d;%dt", x, y);
         break;
       case 14:                 /* report window size (pixels) */
                                -wattr.border_width, -wattr.border_width,
                                &x, &y, &wdummy);
         tt_printf ("\033[3;%d;%dt", x, y);
         break;
       case 14:                 /* report window size (pixels) */
-        XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
+        XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
         tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
         break;
       case 18:                 /* report text area size (chars) */
         tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
         break;
       case 18:                 /* report text area size (chars) */
@@ -3486,7 +3489,7 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
       case 20:                 /* report icon label */
         {
           char *s;
       case 20:                 /* report icon label */
         {
           char *s;
-          XGetIconName (display->display, TermWin.parent[0], &s);
+          XGetIconName (disp, TermWin.parent[0], &s);
           tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : "");     /* 8bit ST */
           XFree (s);
         }
           tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : "");     /* 8bit ST */
           XFree (s);
         }
@@ -3494,7 +3497,7 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
       case 21:                 /* report window title */
         {
           char *s;
       case 21:                 /* report window title */
         {
           char *s;
-          XFetchName (display->display, TermWin.parent[0], &s);
+          XFetchName (disp, TermWin.parent[0], &s);
           tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : "");     /* 8bit ST */
           XFree (s);
         }
           tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : "");     /* 8bit ST */
           XFree (s);
         }
@@ -3646,6 +3649,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
   char *buf, *name;
   bool query = str[0] == '?' && !str[1];
   int saveop = op;
   char *buf, *name;
   bool query = str[0] == '?' && !str[1];
   int saveop = op;
+  dDisp;
 
   assert (str != NULL);
   switch (op)
 
   assert (str != NULL);
   switch (op)
@@ -3671,7 +3675,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
             const char *str = "";
 
             if (prop
             const char *str = "";
 
             if (prop
-                && XGetWindowProperty (display->display, TermWin.parent[0],
+                && XGetWindowProperty (disp, TermWin.parent[0],
                                        prop, 0, 1<<16, 0, AnyPropertyType,
                                        &actual_type, &actual_format,
                                        &nitems, &bytes_after, &value) == Success
                                        prop, 0, 1<<16, 0, AnyPropertyType,
                                        &actual_type, &actual_format,
                                        &nitems, &bytes_after, &value) == Success
@@ -3693,7 +3697,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
                 set_utf8_property (display->atom (str), eq + 1);
               }
             else
                 set_utf8_property (display->atom (str), eq + 1);
               }
             else
-              XDeleteProperty (display->display, TermWin.parent[0],
+              XDeleteProperty (disp, TermWin.parent[0],
                                display->atom (str));
           }
         break;
                                display->atom (str));
           }
         break;
index 1b45ec7..031955a 100644 (file)
@@ -339,7 +339,6 @@ rxvt_term::init_resources (int argc, const char *const *argv)
     rs[Rs_display_name] = ":0";
 
   get_options (r_argc, r_argv);
     rs[Rs_display_name] = ":0";
 
   get_options (r_argc, r_argv);
-  free (r_argv);
 
 #ifdef LOCAL_X_IS_UNIX
   if (rs[Rs_display_name][0] == ':')
 
 #ifdef LOCAL_X_IS_UNIX
   if (rs[Rs_display_name][0] == ':')
@@ -356,7 +355,8 @@ rxvt_term::init_resources (int argc, const char *const *argv)
       && ! (display = displays.get (rs[Rs_display_name])))
     rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
 
       && ! (display = displays.get (rs[Rs_display_name])))
     rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
 
-  extract_resources (display->display, rs[Rs_name]);
+  extract_resources ();
+  free (r_argv);
 
   /*
    * set any defaults not already set
 
   /*
    * set any defaults not already set
@@ -832,11 +832,11 @@ rxvt_term::color_aliases (int idx)
 void
 rxvt_term::get_ourmods ()
 {
 void
 rxvt_term::get_ourmods ()
 {
-  int             i, j, k;
-  int             requestedmeta, realmeta, realalt;
-  const char     *cm, *rsmod;
+  int i, j, k;
+  int requestedmeta, realmeta, realalt;
+  const char *cm, *rsmod;
   XModifierKeymap *map;
   XModifierKeymap *map;
-  KeyCode        *kc;
+  KeyCode *kc;
   const unsigned int modmasks[] =
     {
       Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
   const unsigned int modmasks[] =
     {
       Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
@@ -928,25 +928,26 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   long vt_emask;
   XSetWindowAttributes attributes;
   XWindowAttributes gattr;
   long vt_emask;
   XSetWindowAttributes attributes;
   XWindowAttributes gattr;
+  dDisp;
 
 #ifdef USING_W11LIB
   /* enable W11 callbacks */
 
 #ifdef USING_W11LIB
   /* enable W11 callbacks */
-  W11AddEventHandler (display->display, rxvt_W11_process_x_event);
+  W11AddEventHandler (disp, rxvt_W11_process_x_event);
 #endif
 
   assert (sizeof (xa_names) / sizeof (char *) == NUM_XA);
 #endif
 
   assert (sizeof (xa_names) / sizeof (char *) == NUM_XA);
-  XInternAtoms (display->display, (char **)xa_names, NUM_XA, False, xa);
+  XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa);
 
   if (options & Opt_transparent)
     {
 
   if (options & Opt_transparent)
     {
-      XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr);
+      XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr);
       display->depth = gattr.depth; // doh //TODO, per-term not per-display?
     }
 
 #if ENABLE_FRILLS
   if (options & Opt_borderLess)
     {
       display->depth = gattr.depth; // doh //TODO, per-term not per-display?
     }
 
 #if ENABLE_FRILLS
   if (options & Opt_borderLess)
     {
-      prop = XInternAtom(display->display, "_MOTIF_WM_INFO", True);
+      prop = XInternAtom(disp, "_MOTIF_WM_INFO", True);
 
       if (prop == None)
         {
 
       if (prop == None)
         {
@@ -984,7 +985,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   attributes.background_pixel = pix_colors_focused[Color_border];
   attributes.border_pixel = pix_colors_focused[Color_border];
   attributes.colormap = display->cmap;
   attributes.background_pixel = pix_colors_focused[Color_border];
   attributes.border_pixel = pix_colors_focused[Color_border];
   attributes.colormap = display->cmap;
-  TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display),
+  TermWin.parent[0] = XCreateWindow (disp, DefaultRootWindow (disp),
                                      szHint.x, szHint.y,
                                      szHint.width, szHint.height,
                                      TermWin.ext_bwidth,
                                      szHint.x, szHint.y,
                                      szHint.width, szHint.height,
                                      TermWin.ext_bwidth,
@@ -992,7 +993,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
                                      display->visual,
                                      CWColormap | CWBackPixel | CWBorderPixel, &attributes);
 #else
                                      display->visual,
                                      CWColormap | CWBackPixel | CWBorderPixel, &attributes);
 #else
-  TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display),
+  TermWin.parent[0] = XCreateSimpleWindow (disp, DefaultRootWindow (disp),
                                            szHint.x, szHint.y,
                                            szHint.width, szHint.height,
                                            TermWin.ext_bwidth,
                                            szHint.x, szHint.y,
                                            szHint.width, szHint.height,
                                            TermWin.ext_bwidth,
@@ -1011,22 +1012,22 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState;
   wmHint.window_group = TermWin.parent[0];
 
   wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState;
   wmHint.window_group = TermWin.parent[0];
 
-  XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL,
+  XSetWMProperties (disp, TermWin.parent[0], NULL, NULL,
                     (char **)argv, argc, &szHint, &wmHint, &classHint);
 
   /* Enable delete window protocol */
                     (char **)argv, argc, &szHint, &wmHint, &classHint);
 
   /* Enable delete window protocol */
-  XSetWMProtocols (display->display, TermWin.parent[0],
+  XSetWMProtocols (disp, TermWin.parent[0],
                    &xa[XA_WMDELETEWINDOW], 1);
 
 #if ENABLE_FRILLS
   long pid = getpid ();
 
                    &xa[XA_WMDELETEWINDOW], 1);
 
 #if ENABLE_FRILLS
   long pid = getpid ();
 
-  XChangeProperty (display->display, TermWin.parent[0],
+  XChangeProperty (disp, TermWin.parent[0],
                    xa[XA_NET_WM_PID], XA_CARDINAL, 32,
                    PropModeReplace, (unsigned char *)&pid, 1);
 #endif
 
                    xa[XA_NET_WM_PID], XA_CARDINAL, 32,
                    PropModeReplace, (unsigned char *)&pid, 1);
 #endif
 
-  XSelectInput (display->display, TermWin.parent[0],
+  XSelectInput (disp, TermWin.parent[0],
                 KeyPressMask
 #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755
                 | KeyReleaseMask
                 KeyPressMask
 #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755
                 | KeyReleaseMask
@@ -1038,33 +1039,33 @@ rxvt_term::create_windows (int argc, const char *const *argv)
 
 #if ENABLE_FRILLS
   if (mwmhints.flags)
 
 #if ENABLE_FRILLS
   if (mwmhints.flags)
-    XChangeProperty (display->display, TermWin.parent[0], xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,
+    XChangeProperty (disp, 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 */
                      PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS);
 #endif
 
   /* vt cursor: Black-on-White is standard, but this is more popular */
-  TermWin_cursor = XCreateFontCursor (display->display, XC_xterm);
+  TermWin_cursor = XCreateFontCursor (disp, XC_xterm);
 
 #if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
   /* cursor (menuBar/scrollBar): Black-on-White */
 
 #if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
   /* cursor (menuBar/scrollBar): Black-on-White */
-  leftptr_cursor = XCreateFontCursor (display->display, XC_left_ptr);
+  leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr);
 #endif
 
   /* the vt window */
 #endif
 
   /* the vt window */
-  TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0],
-                                   window_vt_x,
-                                   window_vt_y,
-                                   TermWin_TotalWidth (),
-                                   TermWin_TotalHeight (),
-                                   0,
-                                   pix_colors_focused[Color_fg],
-                                   pix_colors_focused[Color_bg]);
+  TermWin.vt = XCreateSimpleWindow (disp, TermWin.parent[0],
+                                    window_vt_x,
+                                    window_vt_y,
+                                    TermWin_TotalWidth (),
+                                    TermWin_TotalHeight (),
+                                    0,
+                                    pix_colors_focused[Color_fg],
+                                    pix_colors_focused[Color_bg]);
 #ifdef DEBUG_X
 #ifdef DEBUG_X
-  XStoreName (display->display, TermWin.vt, "vt window");
+  XStoreName (disp, TermWin.vt, "vt window");
 #endif
 
   attributes.bit_gravity = NorthWestGravity;
 #endif
 
   attributes.bit_gravity = NorthWestGravity;
-  XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes);
+  XChangeWindowAttributes (disp, TermWin.vt, CWBitGravity, &attributes);
 
   vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask;
 
 
   vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask;
 
@@ -1077,13 +1078,13 @@ rxvt_term::create_windows (int argc, const char *const *argv)
 #endif
     vt_emask |= Button1MotionMask | Button3MotionMask;
 
 #endif
     vt_emask |= Button1MotionMask | Button3MotionMask;
 
-  XSelectInput (display->display, TermWin.vt, vt_emask);
+  XSelectInput (disp, TermWin.vt, vt_emask);
   vt_ev.start (display, TermWin.vt);
 
 #if defined(MENUBAR) && (MENUBAR_MAX > 1)
   if (menuBar_height ())
     {
   vt_ev.start (display, TermWin.vt);
 
 #if defined(MENUBAR) && (MENUBAR_MAX > 1)
   if (menuBar_height ())
     {
-      menuBar.win = XCreateSimpleWindow (display->display, TermWin.parent[0],
+      menuBar.win = XCreateSimpleWindow (disp, TermWin.parent[0],
                                          window_vt_x, 0,
                                          TermWin_TotalWidth (),
                                          menuBar_TotalHeight (),
                                          window_vt_x, 0,
                                          TermWin_TotalWidth (),
                                          menuBar_TotalHeight (),
@@ -1092,17 +1093,16 @@ rxvt_term::create_windows (int argc, const char *const *argv)
                                          pix_colors_focused[Color_scroll]);
 
 #ifdef DEBUG_X
                                          pix_colors_focused[Color_scroll]);
 
 #ifdef DEBUG_X
-      XStoreName (display->display, menuBar.win, "menubar");
+      XStoreName (disp, menuBar.win, "menubar");
 #endif
 
       menuBar.drawable = new rxvt_drawable (display, menuBar.win);
 
 #endif
 
       menuBar.drawable = new rxvt_drawable (display, menuBar.win);
 
-      XDefineCursor (display->display, menuBar.win,
-                     XCreateFontCursor (display->display, XC_left_ptr));
+      XDefineCursor (disp, menuBar.win,
+                     XCreateFontCursor (disp, XC_left_ptr));
 
 
-      XSelectInput (display->display, menuBar.win,
-                   (ExposureMask | ButtonPressMask | ButtonReleaseMask
-                    | Button1MotionMask));
+      XSelectInput (disp, menuBar.win,
+                    (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask));
       menubar_ev.start (display, menuBar.win);
     }
 #endif
       menubar_ev.start (display, menuBar.win);
     }
 #endif
@@ -1128,7 +1128,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   gcvalue.foreground = pix_colors[Color_fg];
   gcvalue.background = pix_colors[Color_bg];
   gcvalue.graphics_exposures = 1;
   gcvalue.foreground = pix_colors[Color_fg];
   gcvalue.background = pix_colors[Color_bg];
   gcvalue.graphics_exposures = 1;
-  TermWin.gc = XCreateGC (display->display, TermWin.vt,
+  TermWin.gc = XCreateGC (disp, TermWin.vt,
                           GCForeground | GCBackground | GCGraphicsExposures,
                           &gcvalue);
 
                           GCForeground | GCBackground | GCGraphicsExposures,
                           &gcvalue);
 
@@ -1136,11 +1136,11 @@ rxvt_term::create_windows (int argc, const char *const *argv)
 
 #if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
   gcvalue.foreground = pix_colors[Color_topShadow];
 
 #if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
   gcvalue.foreground = pix_colors[Color_topShadow];
-  topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
+  topShadowGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue);
   gcvalue.foreground = pix_colors[Color_bottomShadow];
   gcvalue.foreground = pix_colors[Color_bottomShadow];
-  botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
+  botShadowGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue);
   gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)];
   gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)];
-  scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
+  scrollbarGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue);
 #endif
 
 #ifdef OFF_FOCUS_FADING
 #endif
 
 #ifdef OFF_FOCUS_FADING
index 994b781..04e13d9 100644 (file)
@@ -183,10 +183,10 @@ rxvt_term::rxvt_term ()
 #endif
 }
 
 #endif
 }
 
-rxvt_term::~rxvt_term ()
+// clean up the most important stuff, do *not* call x or free mem etc.
+// for use before an emergency exit
+void rxvt_term::emergency_cleanup ()
 {
 {
-  termlist.erase (find (termlist.begin (), termlist.end(), this));
-
   if (cmd_pid)
     kill (-cmd_pid, SIGHUP);
 
   if (cmd_pid)
     kill (-cmd_pid, SIGHUP);
 
@@ -195,6 +195,13 @@ rxvt_term::~rxvt_term ()
 #endif
 
   pty.put ();
 #endif
 
   pty.put ();
+}
+
+rxvt_term::~rxvt_term ()
+{
+  termlist.erase (find (termlist.begin (), termlist.end(), this));
+
+  emergency_cleanup ();
 
 #if ENABLE_STYLES
   for (int i = RS_styleCount; --i; )
 
 #if ENABLE_STYLES
   for (int i = RS_styleCount; --i; )
@@ -205,49 +212,51 @@ rxvt_term::~rxvt_term ()
 
   if (display)
     {
 
   if (display)
     {
+      dDisp;
+
       selection_clear ();
 
 #ifdef USE_XIM
       im_destroy ();
 #endif
 #ifdef MENUBAR
       selection_clear ();
 
 #ifdef USE_XIM
       im_destroy ();
 #endif
 #ifdef MENUBAR
-      if (menubarGC)    XFreeGC (display->display, menubarGC);
+      if (menubarGC)    XFreeGC (disp, menubarGC);
 #endif
 #ifdef XTERM_SCROLLBAR
 #endif
 #ifdef XTERM_SCROLLBAR
-      if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC);
-      if (ShadowGC)     XFreeGC (display->display, ShadowGC);
+      if (xscrollbarGC) XFreeGC (disp, xscrollbarGC);
+      if (ShadowGC)     XFreeGC (disp, ShadowGC);
 #endif
 #ifdef PLAIN_SCROLLBAR
 #endif
 #ifdef PLAIN_SCROLLBAR
-      if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC);
+      if (pscrollbarGC) XFreeGC (disp, pscrollbarGC);
 #endif
 #ifdef NEXT_SCROLLBAR
 #endif
 #ifdef NEXT_SCROLLBAR
-      if (blackGC)      XFreeGC (display->display, blackGC);
-      if (whiteGC)      XFreeGC (display->display, whiteGC);
-      if (grayGC)       XFreeGC (display->display, grayGC);
-      if (darkGC)       XFreeGC (display->display, darkGC);
-      if (stippleGC)    XFreeGC (display->display, stippleGC);
-      if (dimple)       XFreePixmap (display->display, dimple);
-      if (upArrow)      XFreePixmap (display->display, upArrow);
-      if (downArrow)    XFreePixmap (display->display, downArrow);
-      if (upArrowHi)    XFreePixmap (display->display, upArrowHi);
-      if (downArrowHi)  XFreePixmap (display->display, downArrowHi);
+      if (blackGC)      XFreeGC (disp, blackGC);
+      if (whiteGC)      XFreeGC (disp, whiteGC);
+      if (grayGC)       XFreeGC (disp, grayGC);
+      if (darkGC)       XFreeGC (disp, darkGC);
+      if (stippleGC)    XFreeGC (disp, stippleGC);
+      if (dimple)       XFreePixmap (disp, dimple);
+      if (upArrow)      XFreePixmap (disp, upArrow);
+      if (downArrow)    XFreePixmap (disp, downArrow);
+      if (upArrowHi)    XFreePixmap (disp, upArrowHi);
+      if (downArrowHi)  XFreePixmap (disp, downArrowHi);
 #endif
 #if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
 #endif
 #if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
-      if (topShadowGC)  XFreeGC (display->display, topShadowGC);
-      if (botShadowGC)  XFreeGC (display->display, botShadowGC);
-      if (scrollbarGC)  XFreeGC (display->display, scrollbarGC);
+      if (topShadowGC)  XFreeGC (disp, topShadowGC);
+      if (botShadowGC)  XFreeGC (disp, botShadowGC);
+      if (scrollbarGC)  XFreeGC (disp, scrollbarGC);
 #endif
 #endif
-      if (TermWin.gc)   XFreeGC (display->display, TermWin.gc);
+      if (TermWin.gc)   XFreeGC (disp, TermWin.gc);
 
 #if defined(MENUBAR) && (MENUBAR_MAX > 1)
       delete menuBar.drawable;
       //if (menuBar.win)
 
 #if defined(MENUBAR) && (MENUBAR_MAX > 1)
       delete menuBar.drawable;
       //if (menuBar.win)
-      //  XDestroyWindow (display->display, menuBar.win);
+      //  XDestroyWindow (disp, menuBar.win);
 #endif
       delete TermWin.drawable;
       // destroy all windows
       if (TermWin.parent[0])
 #endif
       delete TermWin.drawable;
       // destroy all windows
       if (TermWin.parent[0])
-        XDestroyWindow (display->display, TermWin.parent[0]);
+        XDestroyWindow (disp, TermWin.parent[0]);
     }
 
   // TODO: free pixcolours, colours should become part of rxvt_display
     }
 
   // TODO: free pixcolours, colours should become part of rxvt_display
@@ -263,7 +272,7 @@ rxvt_term::~rxvt_term ()
 
   /* clear all resources */
   for (int i = 0; i < allocated.size (); i++)
 
   /* clear all resources */
   for (int i = 0; i < allocated.size (); i++)
-    free (allocated[i]);
+    free (allocated [i]);
 
   free (selection.text);
   // TODO: manage env vars in child only(!)
 
   free (selection.text);
   // TODO: manage env vars in child only(!)
@@ -279,7 +288,7 @@ rxvt_term::~rxvt_term ()
   delete argv;
 
 #ifdef KEYSYM_RESOURCE
   delete argv;
 
 #ifdef KEYSYM_RESOURCE
-   delete keyboard;
+  delete keyboard;
 #endif
 }
 
 #endif
 }
 
@@ -342,6 +351,59 @@ rxvt_term::destroy_cb (time_watcher &w)
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
+/*
+ * Exit gracefully, clearing the utmp entry and restoring tty attributes
+ * TODO: if debugging, this should free up any known resources if we can
+ */
+static XErrorHandler old_xerror_handler;
+
+static void
+rxvt_emergency_cleanup ()
+{
+  for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
+    (*t)->emergency_cleanup ();
+}
+
+int
+rxvt_xerror_handler (Display *display, XErrorEvent *event)
+{
+  if (GET_R->allowedxerror == -1)
+    GET_R->allowedxerror = event->error_code;
+  else
+    {
+      //TODO: GET_R is most likely not the terminal which caused the error
+      //TODO: maybe just output the error and continue?
+      old_xerror_handler (display, event);
+      GET_R->destroy ();
+    }
+
+  return 0;
+}
+
+int
+rxvt_xioerror_handler (Display *display)
+{
+  rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n",
+             DisplayString (display));
+  rxvt_emergency_cleanup ();
+  _exit (EXIT_FAILURE);
+}
+
+/*
+ * Catch a fatal signal and tidy up before quitting
+ */
+void
+rxvt_term::sig_term (sig_watcher &w)
+{
+#ifdef DEBUG_CMD
+  rxvt_warn ("caught signal %d, exiting.\n", w.signum);
+#endif
+  rxvt_emergency_cleanup ();
+  signal (w.signum, SIG_DFL);
+  kill (getpid (), w.signum);
+}
+
+/*----------------------------------------------------------------------*/
 /* rxvt_init () */
 bool
 rxvt_term::init (int argc, const char *const *argv)
 /* rxvt_init () */
 bool
 rxvt_term::init (int argc, const char *const *argv)
@@ -371,12 +433,14 @@ rxvt_term::init (int argc, const char *const *argv)
 
   create_windows (argc, argv);
 
 
   create_windows (argc, argv);
 
+  dDisp;
+
   init_xlocale ();
 
   scr_reset ();         /* initialize screen */
 
 #if 0
   init_xlocale ();
 
   scr_reset ();         /* initialize screen */
 
 #if 0
-  XSynchronize (display->display, True);
+  XSynchronize (disp, True);
 #endif
 
 #ifdef HAVE_SCROLLBARS
 #endif
 
 #ifdef HAVE_SCROLLBARS
@@ -385,19 +449,19 @@ rxvt_term::init (int argc, const char *const *argv)
 #endif
 #if (MENUBAR_MAX)
   if (menubar_visible ())
 #endif
 #if (MENUBAR_MAX)
   if (menubar_visible ())
-    XMapWindow (display->display, menuBar.win);
+    XMapWindow (disp, menuBar.win);
 #endif
 #ifdef TRANSPARENT
   if (options & Opt_transparent)
     {
 #endif
 #ifdef TRANSPARENT
   if (options & Opt_transparent)
     {
-      XSelectInput (display->display, display->root, PropertyChangeMask);
+      XSelectInput (disp, display->root, PropertyChangeMask);
       check_our_parents ();
       rootwin_ev.start (display, display->root);
     }
 #endif
 
       check_our_parents ();
       rootwin_ev.start (display, display->root);
     }
 #endif
 
-  XMapWindow (display->display, TermWin.vt);
-  XMapWindow (display->display, TermWin.parent[0]);
+  XMapWindow (disp, TermWin.vt);
+  XMapWindow (disp, TermWin.parent[0]);
 
   set_colorfgbg ();
 
 
   set_colorfgbg ();
 
@@ -412,8 +476,6 @@ rxvt_term::init (int argc, const char *const *argv)
   return true;
 }
 
   return true;
 }
 
-static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
-
 void
 rxvt_init ()
 {
 void
 rxvt_init ()
 {
@@ -435,7 +497,7 @@ rxvt_init ()
 
   old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
   // TODO: handle this with exceptions and tolerate the memory loss
 
   old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
   // TODO: handle this with exceptions and tolerate the memory loss
-  //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
+  XSetIOErrorHandler (rxvt_xioerror_handler);
 }
 
 /* ------------------------------------------------------------------------- *
 }
 
 /* ------------------------------------------------------------------------- *
@@ -460,48 +522,6 @@ rxvt_term::sig_chld (sig_watcher &w)
         }
 }
 
         }
 }
 
-/*----------------------------------------------------------------------*/
-/*
- * Exit gracefully, clearing the utmp entry and restoring tty attributes
- * TODO: if debugging, this should free up any known resources if we can
- */
-void
-rxvt_destroy_all ()
-{
-  // TODO: rxvtd should clean up all ressources
-  for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
-    (*t)->destroy ();
-}
-
-/*
- * Catch a fatal signal and tidy up before quitting
- */
-void
-rxvt_term::sig_term (sig_watcher &w)
-{
-#ifdef DEBUG_CMD
-  rxvt_warn ("caught signal %d, exiting.\n", w.signum);
-#endif
-  rxvt_destroy_all ();
-  signal (w.signum, SIG_DFL);
-  kill (getpid (), w.signum);
-}
-
-/* INTPROTO */
-int
-rxvt_xerror_handler (Display *display, XErrorEvent *event)
-{
-  if (GET_R->allowedxerror == -1)
-    GET_R->allowedxerror = event->error_code;
-  else
-    {
-      old_xerror_handler (display, event);
-      GET_R->destroy ();
-    }
-
-  return 0;
-}
-
 /* ------------------------------------------------------------------------- *
  *                         MEMORY ALLOCATION WRAPPERS                        *
  * ------------------------------------------------------------------------- */
 /* ------------------------------------------------------------------------- *
  *                         MEMORY ALLOCATION WRAPPERS                        *
  * ------------------------------------------------------------------------- */
@@ -622,10 +642,11 @@ rxvt_term::privileged_utmp (rxvt_privaction action)
 void
 rxvt_term::window_calc (unsigned int width, unsigned int height)
 {
 void
 rxvt_term::window_calc (unsigned int width, unsigned int height)
 {
-  short           recalc_x, recalc_y;
-  int             x, y, sb_w, mb_h, flags;
-  unsigned int    w, h;
-  unsigned int    max_width, max_height;
+  short recalc_x, recalc_y;
+  int x, y, sb_w, mb_h, flags;
+  unsigned int w, h;
+  unsigned int max_width, max_height;
+  dDisp;
 
   D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
           TermWin.ncol, TermWin.nrow, szHint.width,
 
   D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
           TermWin.ncol, TermWin.nrow, szHint.width,
@@ -733,10 +754,10 @@ rxvt_term::window_calc (unsigned int width, unsigned int height)
     window_sb_x = szHint.width - sb_w;
 
   if (recalc_x)
     window_sb_x = szHint.width - sb_w;
 
   if (recalc_x)
-    szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display))
+    szHint.x += (DisplayWidth (disp, display->screen)
                  - szHint.width - 2 * TermWin.ext_bwidth);
   if (recalc_y)
                  - szHint.width - 2 * TermWin.ext_bwidth);
   if (recalc_y)
-    szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display))
+    szHint.y += (DisplayHeight (disp, display->screen)
                  - szHint.height - 2 * TermWin.ext_bwidth);
 
   TermWin.ncol = TermWin.width / TermWin.fwidth;
                  - szHint.height - 2 * TermWin.ext_bwidth);
 
   TermWin.ncol = TermWin.width / TermWin.fwidth;
@@ -911,6 +932,7 @@ rxvt_term::set_window_color (int idx, const char *color)
   if (isdigit (*color))
     {
       i = atoi (color);
   if (isdigit (*color))
     {
       i = atoi (color);
+
       if (i >= 8 && i <= 15)
         {        /* bright colors */
           i -= 8;
       if (i >= 8 && i <= 15)
         {        /* bright colors */
           i -= 8;
@@ -919,8 +941,8 @@ rxvt_term::set_window_color (int idx, const char *color)
           SET_PIXCOLOR (idx);
           goto Done;
 # endif
           SET_PIXCOLOR (idx);
           goto Done;
 # endif
-
         }
         }
+
       if (i >= 0 && i <= 7)
         { /* normal colors */
           pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
       if (i >= 0 && i <= 7)
         { /* normal colors */
           pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
@@ -929,7 +951,7 @@ rxvt_term::set_window_color (int idx, const char *color)
         }
     }
 
         }
     }
 
-  if (!rXParseAllocColor (& xcol, color))
+  if (!rXParseAllocColor (&xcol, color))
     return;
 
   /* XStoreColor (display->display, display->cmap, XColor*); */
     return;
 
   /* XStoreColor (display->display, display->cmap, XColor*); */
@@ -1042,13 +1064,13 @@ void
 rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
 {
   int fix_screen;
 rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
 {
   int fix_screen;
-
 #ifdef SMART_RESIZE
   int old_width = szHint.width, old_height = szHint.height;
 #endif
 #ifdef SMART_RESIZE
   int old_width = szHint.width, old_height = szHint.height;
 #endif
+  dDisp;
 
   window_calc (width, height);
 
   window_calc (width, height);
-  XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
+  XSetWMNormalHints (disp, TermWin.parent[0], &szHint);
 
   if (!ignoreparent)
     {
 
   if (!ignoreparent)
     {
@@ -1062,9 +1084,9 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
       unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
       Window unused_cr;
 
       unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
       Window unused_cr;
 
-      XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
+      XTranslateCoordinates (disp, TermWin.parent[0], display->root,
                              0, 0, &x, &y, &unused_cr);
                              0, 0, &x, &y, &unused_cr);
-      XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1,
+      XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1,
                     &unused_w1, &unused_h1, &unused_b1, &unused_d1);
       /*
        * if display->root isn't the parent window, a WM will probably have offset
                     &unused_w1, &unused_h1, &unused_b1, &unused_d1);
       /*
        * if display->root isn't the parent window, a WM will probably have offset
@@ -1076,8 +1098,8 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
           y -= y1;
         }
 
           y -= y1;
         }
 
-      x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2;
-      y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2;
+      x1 = (DisplayWidth (disp, display->screen) - old_width) / 2;
+      y1 = (DisplayHeight (disp, display->screen) - old_height) / 2;
       dx = old_width - szHint.width;
       dy = old_height - szHint.height;
 
       dx = old_width - szHint.width;
       dy = old_height - szHint.height;
 
@@ -1091,10 +1113,10 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
       else if (y == y1)       /* exact center */
         dy /= 2;
 
       else if (y == y1)       /* exact center */
         dy /= 2;
 
-      XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy,
+      XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy,
                          szHint.width, szHint.height);
 #else
                          szHint.width, szHint.height);
 #else
-      XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height);
+      XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height);
 #endif
     }
 
 #endif
     }
 
@@ -1104,18 +1126,18 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno
     {
       if (scrollbar_visible ())
         {
     {
       if (scrollbar_visible ())
         {
-          XMoveResizeWindow (display->display, scrollBar.win,
+          XMoveResizeWindow (disp, scrollBar.win,
                              window_sb_x, 0,
                              scrollbar_TotalWidth (), szHint.height);
           resize_scrollbar ();
         }
 
       if (menubar_visible ())
                              window_sb_x, 0,
                              scrollbar_TotalWidth (), szHint.height);
           resize_scrollbar ();
         }
 
       if (menubar_visible ())
-        XMoveResizeWindow (display->display, menuBar.win,
+        XMoveResizeWindow (disp, menuBar.win,
                            window_vt_x, 0,
                            TermWin_TotalWidth (), menuBar_TotalHeight ());
 
                            window_vt_x, 0,
                            TermWin_TotalWidth (), menuBar_TotalHeight ());
 
-      XMoveResizeWindow (display->display, TermWin.vt,
+      XMoveResizeWindow (disp, TermWin.vt,
                          window_vt_x, window_vt_y,
                          TermWin_TotalWidth (), TermWin_TotalHeight ());
 
                          window_vt_x, window_vt_y,
                          TermWin_TotalWidth (), TermWin_TotalHeight ());
 
index 5bcf408..3e066ee 100644 (file)
@@ -957,11 +957,11 @@ rxvt_term::menu_show ()
   if (ActiveMenu->win == None)
     {
       ActiveMenu->win = XCreateSimpleWindow (display->display, TermWin.vt,
   if (ActiveMenu->win == None)
     {
       ActiveMenu->win = XCreateSimpleWindow (display->display, TermWin.vt,
-                                            x, ActiveMenu->y,
-                                            ActiveMenu->w, ActiveMenu->h,
-                                            0,
-                                            pix_colors[Color_fg],
-                                            pix_colors[Color_scroll]);
+                                             x, ActiveMenu->y,
+                                             ActiveMenu->w, ActiveMenu->h,
+                                             0,
+                                             pix_colors[Color_fg],
+                                             pix_colors[Color_scroll]);
       ActiveMenu->drawable = new rxvt_drawable (display, ActiveMenu->win);
       XMapWindow (display->display, ActiveMenu->win);
     }
       ActiveMenu->drawable = new rxvt_drawable (display, ActiveMenu->win);
       XMapWindow (display->display, ActiveMenu->win);
     }
@@ -984,9 +984,9 @@ rxvt_term::menu_show ()
       if (isSeparator (item->name))
         {
           rxvt_Draw_Shadow (display->display, ActiveMenu->win,
       if (isSeparator (item->name))
         {
           rxvt_Draw_Shadow (display->display, ActiveMenu->win,
-                           topShadowGC, botShadowGC,
-                           SHADOW, y + SHADOW + 1,
-                           ActiveMenu->w - 2 * SHADOW, 0);
+                            topShadowGC, botShadowGC,
+                            SHADOW, y + SHADOW + 1,
+                            ActiveMenu->w - 2 * SHADOW, 0);
           h = HEIGHT_SEPARATOR;
         }
       else
           h = HEIGHT_SEPARATOR;
         }
       else
@@ -2017,7 +2017,7 @@ rxvt_term::draw_Arrows (int name, int state)
 
       if (!name || name == Arrows[i].name)
         rxvt_Draw_Triangle (display->display, menuBar.win, top, bot, x, y, w,
 
       if (!name || name == Arrows[i].name)
         rxvt_Draw_Triangle (display->display, menuBar.win, top, bot, x, y, w,
-                           Arrows[i].name);
+                            Arrows[i].name);
     }
   XFlush (display->display);
 }
     }
   XFlush (display->display);
 }
index c2188f6..b58d976 100644 (file)
@@ -761,6 +761,8 @@ enum {
 #define strchr(x, y)            strchr((const char *)(x), (int)(y))
 #define strrchr(x, y)           strrchr((const char *)(x), (int)(y))
 
 #define strchr(x, y)            strchr((const char *)(x), (int)(y))
 #define strrchr(x, y)           strrchr((const char *)(x), (int)(y))
 
+#define dDisp                  Display *disp = display->display
+
 /* convert pixel dimensions to row/column values.  Everything as int32_t */
 #define Pixel2Col(x)            Pixel2Width((int32_t)(x))
 #define Pixel2Row(y)            Pixel2Height((int32_t)(y))
 /* convert pixel dimensions to row/column values.  Everything as int32_t */
 #define Pixel2Col(x)            Pixel2Width((int32_t)(x))
 #define Pixel2Row(y)            Pixel2Height((int32_t)(y))
@@ -868,13 +870,6 @@ enum {
 # define XPMClearArea(a, b, c, d, e, f, g)
 #endif
 
 # define XPMClearArea(a, b, c, d, e, f, g)
 #endif
 
-#ifndef STRICT_FONT_CHECKING
-# define rxvt_get_fontwidest(font)      ((font)->max_bounds.width)
-#endif
-
-#define rxvt_Gr_ButtonPress(x,y)        rxvt_Gr_ButtonReport (R, 'P',(x),(y))
-#define rxvt_Gr_ButtonRelease(x,y)      rxvt_Gr_ButtonReport (R, 'R',(x),(y))
-
 #ifdef UTMP_SUPPORT
 # if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX)
 #  undef HAVE_UTMPX_H
 #ifdef UTMP_SUPPORT
 # if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX)
 #  undef HAVE_UTMPX_H
@@ -1285,6 +1280,7 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   rxvt_term ();
   ~rxvt_term ();
   void destroy ();
   rxvt_term ();
   ~rxvt_term ();
   void destroy ();
+  void emergency_cleanup ();
 
   bool init (int argc, const char *const *argv);
   bool init_vars ();
 
   bool init (int argc, const char *const *argv);
   bool init_vars ();
@@ -1518,7 +1514,7 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   void get_options (int argc, const char *const *argv);
   int parse_keysym (const char *str, const char *arg);
   void get_xdefaults (FILE *stream, const char *name);
   void get_options (int argc, const char *const *argv);
   int parse_keysym (const char *str, const char *arg);
   void get_xdefaults (FILE *stream, const char *name);
-  void extract_resources (Display *display, const char *name);
+  void extract_resources ();
   // xpm.C
   int scale_pixmap (const char *geom);
   void resize_pixmap ();
   // xpm.C
   int scale_pixmap (const char *geom);
   void resize_pixmap ();
index 2cefa2f..f288b56 100644 (file)
@@ -56,8 +56,8 @@ typedef struct rxvt_term *rxvt_t;
 
 extern rxvt_t rxvt_current_term;
 
 
 extern rxvt_t rxvt_current_term;
 
-# define SET_R(r) rxvt_current_term = (r)
-# define GET_R rxvt_current_term
+#define SET_R(r) rxvt_current_term = (r)
+#define GET_R rxvt_current_term
 
 #define scrollbar_visible()    scrollBar.state
 #define menubar_visible()      menuBar.state
 
 #define scrollbar_visible()    scrollBar.state
 #define menubar_visible()      menuBar.state
index f8b79af..418603c 100644 (file)
@@ -3537,6 +3537,7 @@ void
 rxvt_term::selection_send (const XSelectionRequestEvent &rq)
 {
   XSelectionEvent ev;
 rxvt_term::selection_send (const XSelectionRequestEvent &rq)
 {
   XSelectionEvent ev;
+  dDisp;
 
   ev.type = SelectionNotify;
   ev.property = None;
 
   ev.type = SelectionNotify;
   ev.property = None;
@@ -3560,7 +3561,7 @@ rxvt_term::selection_send (const XSelectionRequestEvent &rq)
       *target++ = xa[XA_UTF8_STRING];
 #endif
 
       *target++ = xa[XA_UTF8_STRING];
 #endif
 
-      XChangeProperty (display->display, rq.requestor, rq.property, XA_ATOM,
+      XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM,
                        32, PropModeReplace,
                        (unsigned char *)target_list, target - target_list);
       ev.property = rq.property;
                        32, PropModeReplace,
                        (unsigned char *)target_list, target - target_list);
       ev.property = rq.property;
@@ -3573,7 +3574,7 @@ rxvt_term::selection_send (const XSelectionRequestEvent &rq)
 #endif
   else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
     {
 #endif
   else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
     {
-      XChangeProperty (display->display, rq.requestor, rq.property, rq.target,
+      XChangeProperty (disp, rq.requestor, rq.property, rq.target,
                        32, PropModeReplace, (unsigned char *)&selection_time, 1);
       ev.property = rq.property;
     }
                        32, PropModeReplace, (unsigned char *)&selection_time, 1);
       ev.property = rq.property;
     }
@@ -3641,7 +3642,7 @@ rxvt_term::selection_send (const XSelectionRequestEvent &rq)
         }
       else
 #endif
         }
       else
 #endif
-      if (XwcTextListToTextProperty (display->display, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0)
+      if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0)
         freect = 1;
       else
         {
         freect = 1;
       else
         {
@@ -3651,7 +3652,7 @@ rxvt_term::selection_send (const XSelectionRequestEvent &rq)
           ct.encoding = target;
         }
 
           ct.encoding = target;
         }
 
-      XChangeProperty (display->display, rq.requestor, rq.property,
+      XChangeProperty (disp, rq.requestor, rq.property,
                        ct.encoding, 8, PropModeReplace,
                        ct.value, (int)ct.nitems);
       ev.property = rq.property;
                        ct.encoding, 8, PropModeReplace,
                        ct.value, (int)ct.nitems);
       ev.property = rq.property;
@@ -3660,7 +3661,7 @@ rxvt_term::selection_send (const XSelectionRequestEvent &rq)
         XFree (ct.value);
     }
 
         XFree (ct.value);
     }
 
-  XSendEvent (display->display, rq.requestor, False, 0L, (XEvent *)&ev);
+  XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev);
 }
 \f
 /* ------------------------------------------------------------------------- *
 }
 \f
 /* ------------------------------------------------------------------------- *
index 3f747b8..57ec56e 100644 (file)
@@ -137,6 +137,7 @@ rxvt_term::renderPixmap (const char *const *data, int width, int height)
             pointcolour = darkGC;
           else         /* if (a == '#' || a == 'b' || a) */
             pointcolour = blackGC;
             pointcolour = darkGC;
           else         /* if (a == '#' || a == 'b' || a) */
             pointcolour = blackGC;
+
           XDrawPoint (display->display, d, pointcolour, x, y);
         }
     }
           XDrawPoint (display->display, d, pointcolour, x, y);
         }
     }
@@ -150,15 +151,16 @@ rxvt_term::init_scrollbar_stuff ()
   XColor          xcol;
   Pixmap          stipple;
   unsigned long   light, dark;
   XColor          xcol;
   Pixmap          stipple;
   unsigned long   light, dark;
+  dDisp;
 
   gcvalue.graphics_exposures = False;
 
   gcvalue.foreground = pix_colors_focused[Color_Black];
 
   gcvalue.graphics_exposures = False;
 
   gcvalue.foreground = pix_colors_focused[Color_Black];
-  blackGC = XCreateGC (display->display, scrollBar.win,
+  blackGC = XCreateGC (disp, scrollBar.win,
                       GCForeground | GCGraphicsExposures, &gcvalue);
 
   gcvalue.foreground = pix_colors_focused[Color_White];
                       GCForeground | GCGraphicsExposures, &gcvalue);
 
   gcvalue.foreground = pix_colors_focused[Color_White];
-  whiteGC = XCreateGC (display->display, scrollBar.win,
+  whiteGC = XCreateGC (disp, scrollBar.win,
                       GCForeground | GCGraphicsExposures, &gcvalue);
 
   xcol.red = 0xaeba;
                       GCForeground | GCGraphicsExposures, &gcvalue);
 
   xcol.red = 0xaeba;
@@ -167,7 +169,7 @@ rxvt_term::init_scrollbar_stuff ()
   //if (!rXAllocColor (&xcol, "light gray"))//TODO//D//
   xcol.pixel = pix_colors_focused[Color_AntiqueWhite];
   light = gcvalue.foreground = xcol.pixel;
   //if (!rXAllocColor (&xcol, "light gray"))//TODO//D//
   xcol.pixel = pix_colors_focused[Color_AntiqueWhite];
   light = gcvalue.foreground = xcol.pixel;
-  grayGC = XCreateGC (display->display, scrollBar.win,
+  grayGC = XCreateGC (disp, scrollBar.win,
                      GCForeground | GCGraphicsExposures, &gcvalue);
 
   xcol.red = 0x51aa;
                      GCForeground | GCGraphicsExposures, &gcvalue);
 
   xcol.red = 0x51aa;
@@ -176,10 +178,10 @@ rxvt_term::init_scrollbar_stuff ()
   //if (!rXAllocColor (&xcol, "dark gray"))//TODO//D//
   xcol.pixel = pix_colors_focused[Color_Grey25];
   dark = gcvalue.foreground = xcol.pixel;
   //if (!rXAllocColor (&xcol, "dark gray"))//TODO//D//
   xcol.pixel = pix_colors_focused[Color_Grey25];
   dark = gcvalue.foreground = xcol.pixel;
-  darkGC = XCreateGC (display->display, scrollBar.win,
+  darkGC = XCreateGC (disp, scrollBar.win,
                      GCForeground | GCGraphicsExposures, &gcvalue);
 
                      GCForeground | GCGraphicsExposures, &gcvalue);
 
-  stipple = XCreateBitmapFromData (display->display, scrollBar.win,
+  stipple = XCreateBitmapFromData (disp, scrollBar.win,
                                   (char *)n_stp_bits, n_stp_width,
                                   n_stp_height);
 
                                   (char *)n_stp_bits, n_stp_width,
                                   n_stp_height);
 
@@ -188,9 +190,9 @@ rxvt_term::init_scrollbar_stuff ()
   gcvalue.fill_style = FillOpaqueStippled;
   gcvalue.stipple = stipple;
 
   gcvalue.fill_style = FillOpaqueStippled;
   gcvalue.stipple = stipple;
 
-  /*    XSetWindowBackground (display->display, scrollBar.win, pix_colors_focused[Color_Red]); */
+  /*    XSetWindowBackground (disp, scrollBar.win, pix_colors_focused[Color_Red]); */
 
 
-  stippleGC = XCreateGC (display->display, scrollBar.win,
+  stippleGC = XCreateGC (disp, scrollBar.win,
                         GCForeground | GCBackground | GCStipple
                         | GCFillStyle | GCGraphicsExposures, &gcvalue);
 
                         GCForeground | GCBackground | GCStipple
                         | GCFillStyle | GCGraphicsExposures, &gcvalue);
 
@@ -211,20 +213,21 @@ rxvt_term::init_scrollbar_stuff ()
 void
 rxvt_term::drawBevel (Drawable d, int x1, int y1, int w, int h)
 {
 void
 rxvt_term::drawBevel (Drawable d, int x1, int y1, int w, int h)
 {
-  int             x2, y2;
+  int x2, y2;
+  dDisp;
 
   x2 = x1 + w - 1;             /* right  point */
   y2 = y1 + h - 1;             /* bottom point */
   /* white top and left */
 
   x2 = x1 + w - 1;             /* right  point */
   y2 = y1 + h - 1;             /* bottom point */
   /* white top and left */
-  XDrawLine (display->display, d, whiteGC, x1, y1, x2, y1);
-  XDrawLine (display->display, d, whiteGC, x1, y1, x1, y2);
+  XDrawLine (disp, d, whiteGC, x1, y1, x2, y1);
+  XDrawLine (disp, d, whiteGC, x1, y1, x1, y2);
   /* black bottom and right */
   /* black bottom and right */
-  XDrawLine (display->display, d, blackGC, x1, y2, x2, y2);
-  XDrawLine (display->display, d, blackGC, x2, y1, x2, y2);
+  XDrawLine (disp, d, blackGC, x1, y2, x2, y2);
+  XDrawLine (disp, d, blackGC, x2, y1, x2, y2);
   /* dark inside bottom and right */
   x1++, y1++, x2--, y2--;      /* move in one point */
   /* dark inside bottom and right */
   x1++, y1++, x2--, y2--;      /* move in one point */
-  XDrawLine (display->display, d, darkGC, x1, y2, x2, y2);
-  XDrawLine (display->display, d, darkGC, x2, y1, x2, y2);
+  XDrawLine (disp, d, darkGC, x1, y2, x2, y2);
+  XDrawLine (disp, d, darkGC, x2, y1, x2, y2);
 }
 
 int
 }
 
 int
@@ -232,6 +235,7 @@ rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scro
 {
   int height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING;
   Drawable s;
 {
   int height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING;
   Drawable s;
+  dDisp;
 
   if ((scrollBar.init & R_SB_NEXT) == 0)
     {
 
   if ((scrollBar.init & R_SB_NEXT) == 0)
     {
@@ -241,32 +245,32 @@ rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scro
 
   if (TermWin.nscrolled == 0 || !update)
     {
 
   if (TermWin.nscrolled == 0 || !update)
     {
-      XFillRectangle (display->display, scrollBar.win, grayGC, 0, 0,
+      XFillRectangle (disp, scrollBar.win, grayGC, 0, 0,
                      SB_WIDTH_NEXT + 1, height);
                      SB_WIDTH_NEXT + 1, height);
-      XDrawRectangle (display->display, scrollBar.win, blackGC, 0,
+      XDrawRectangle (disp, scrollBar.win, blackGC, 0,
                      -SB_BORDER_WIDTH, SB_WIDTH_NEXT,
                      height + SB_BORDER_WIDTH);
                      -SB_BORDER_WIDTH, SB_WIDTH_NEXT,
                      height + SB_BORDER_WIDTH);
-      XFillRectangle (display->display, scrollBar.win, stippleGC,
+      XFillRectangle (disp, scrollBar.win, stippleGC,
                      SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height);
     }
 
   if (TermWin.nscrolled)
     {
       if (last_top < scrollBar.top || !update)
                      SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height);
     }
 
   if (TermWin.nscrolled)
     {
       if (last_top < scrollBar.top || !update)
-        XFillRectangle (display->display, scrollBar.win, stippleGC,
+        XFillRectangle (disp, scrollBar.win, stippleGC,
                        SB_LEFT_PADDING, SB_PADDING + last_top,
                        SB_BUTTON_WIDTH, scrollBar.top - last_top);
 
       if (scrollBar.bot < last_bot || !update)
                        SB_LEFT_PADDING, SB_PADDING + last_top,
                        SB_BUTTON_WIDTH, scrollBar.top - last_top);
 
       if (scrollBar.bot < last_bot || !update)
-        XFillRectangle (display->display, scrollBar.win, stippleGC,
+        XFillRectangle (disp, scrollBar.win, stippleGC,
                        SB_LEFT_PADDING, scrollBar.bot + SB_PADDING,
                        SB_BUTTON_WIDTH, (last_bot - scrollBar.bot));
 
                        SB_LEFT_PADDING, scrollBar.bot + SB_PADDING,
                        SB_BUTTON_WIDTH, (last_bot - scrollBar.bot));
 
-      XFillRectangle (display->display, scrollBar.win, grayGC,
+      XFillRectangle (disp, scrollBar.win, grayGC,
                      SB_LEFT_PADDING, scrollBar.top + SB_PADDING,
                      SB_BUTTON_WIDTH, scrollbar_len);
 
                      SB_LEFT_PADDING, scrollBar.top + SB_PADDING,
                      SB_BUTTON_WIDTH, scrollbar_len);
 
-      XCopyArea (display->display, dimple, scrollBar.win, whiteGC, 0, 0,
+      XCopyArea (disp, dimple, scrollBar.win, whiteGC, 0, 0,
                 SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT,
                 (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2,
                 scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT +
                 SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT,
                 (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2,
                 scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT +
@@ -283,12 +287,12 @@ rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scro
                  SB_BUTTON_HEIGHT);
 
       s = (scrollbar_isUp ()) ? upArrowHi : upArrow;
                  SB_BUTTON_HEIGHT);
 
       s = (scrollbar_isUp ()) ? upArrowHi : upArrow;
-      XCopyArea (display->display, s, scrollBar.win, whiteGC, 0, 0,
+      XCopyArea (disp, s, scrollBar.win, whiteGC, 0, 0,
                 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
                 height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
 
       s = (scrollbar_isDn ()) ? downArrowHi : downArrow;
                 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
                 height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
 
       s = (scrollbar_isDn ()) ? downArrowHi : downArrow;
-      XCopyArea (display->display, s, scrollBar.win, whiteGC, 0, 0,
+      XCopyArea (disp, s, scrollBar.win, whiteGC, 0, 0,
                 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
                 height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
     }
                 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
                 height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
     }
index 3bf4183..94f5499 100644 (file)
@@ -83,6 +83,7 @@ rxvt_term::Draw_button (int x, int y, int state, int dirn)
 #if (SHADOW > 1)
   /* doubled */
   pt[0].x++;
 #if (SHADOW > 1)
   /* doubled */
   pt[0].x++;
+
   if (dirn == UP)
     {
       pt[0].y--;
   if (dirn == UP)
     {
       pt[0].y--;
@@ -93,6 +94,7 @@ rxvt_term::Draw_button (int x, int y, int state, int dirn)
       pt[0].y++;
       pt[1].y--;
     }
       pt[0].y++;
       pt[1].y--;
     }
+
   XDrawLine (display->display, scrollBar.win, top,
              pt[0].x, pt[0].y, pt[1].x, pt[1].y);
 #endif
   XDrawLine (display->display, scrollBar.win, top,
              pt[0].x, pt[0].y, pt[1].x, pt[1].y);
 #endif
@@ -103,6 +105,7 @@ rxvt_term::Draw_button (int x, int y, int state, int dirn)
   pt[2].y = y + (dirn == UP ? 0 : sz - 1);
   XDrawLine (display->display, scrollBar.win, bot,
              pt[2].x, pt[2].y, pt[1].x, pt[1].y);
   pt[2].y = y + (dirn == UP ? 0 : sz - 1);
   XDrawLine (display->display, scrollBar.win, bot,
              pt[2].x, pt[2].y, pt[1].x, pt[1].y);
+
 #if (SHADOW > 1)
   /* doubled */
   pt[1].x--;
 #if (SHADOW > 1)
   /* doubled */
   pt[1].x--;
index 7ffff56..02ee79b 100644 (file)
--- a/src/xpm.C
+++ b/src/xpm.C
@@ -163,23 +163,24 @@ rxvt_term::resize_pixmap ()
   GC              gc;
   unsigned int    width = TermWin_TotalWidth ();
   unsigned int    height = TermWin_TotalHeight ();
   GC              gc;
   unsigned int    width = TermWin_TotalWidth ();
   unsigned int    height = TermWin_TotalHeight ();
+  dDisp;
 
   if (TermWin.pixmap != None)
 
   if (TermWin.pixmap != None)
-    XFreePixmap (display->display, TermWin.pixmap);
+    XFreePixmap (disp, TermWin.pixmap);
 
   if (bgPixmap.pixmap == None)
     { /* So be it: I'm not using pixmaps */
       TermWin.pixmap = None;
 
       if (!(options & Opt_transparent) || !am_transparent)
 
   if (bgPixmap.pixmap == None)
     { /* So be it: I'm not using pixmaps */
       TermWin.pixmap = None;
 
       if (!(options & Opt_transparent) || !am_transparent)
-        XSetWindowBackground (display->display, TermWin.vt,
+        XSetWindowBackground (disp, TermWin.vt,
                               pix_colors[Color_bg]);
 
       return;
     }
 
   gcvalue.foreground = pix_colors[Color_bg];
                               pix_colors[Color_bg]);
 
       return;
     }
 
   gcvalue.foreground = pix_colors[Color_bg];
-  gc = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
+  gc = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue);
 
   if (bgPixmap.pixmap != None)
     {  /* we have a specified pixmap */
 
   if (bgPixmap.pixmap != None)
     {  /* we have a specified pixmap */
@@ -200,10 +201,10 @@ rxvt_term::resize_pixmap ()
       if (w == 0)
         {
           /* basic X tiling - let the X server do it */
       if (w == 0)
         {
           /* basic X tiling - let the X server do it */
-          TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
+          TermWin.pixmap = XCreatePixmap (disp, TermWin.vt,
                                          xpmw, xpmh,
                                          (unsigned int)display->depth);
                                          xpmw, xpmh,
                                          (unsigned int)display->depth);
-          XCopyArea (display->display, bgPixmap.pixmap, TermWin.pixmap, gc,
+          XCopyArea (disp, bgPixmap.pixmap, TermWin.pixmap, gc,
                     0, 0, xpmw, xpmh, 0, 0);
         }
       else
                     0, 0, xpmw, xpmh, 0, 0);
         }
       else
@@ -211,7 +212,7 @@ rxvt_term::resize_pixmap ()
           float           incr, p;
           Pixmap          tmp;
 
           float           incr, p;
           Pixmap          tmp;
 
-          TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
+          TermWin.pixmap = XCreatePixmap (disp, TermWin.vt,
                                          width, height,
                                          (unsigned int)display->depth);
           /*
                                          width, height,
                                          (unsigned int)display->depth);
           /*
@@ -219,9 +220,9 @@ rxvt_term::resize_pixmap ()
            */
           rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw);
 
            */
           rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw);
 
-          tmp = XCreatePixmap (display->display, TermWin.vt,
+          tmp = XCreatePixmap (disp, TermWin.vt,
                               width, xpmh, (unsigned int)display->depth);
                               width, xpmh, (unsigned int)display->depth);
-          XFillRectangle (display->display, tmp, gc, 0, 0, width,
+          XFillRectangle (disp, tmp, gc, 0, 0, width,
                          xpmh);
 
           for ( /*nil */ ; x < w; x++, p += incr)
                          xpmh);
 
           for ( /*nil */ ; x < w; x++, p += incr)
@@ -229,7 +230,7 @@ rxvt_term::resize_pixmap ()
               if (p >= xpmw)
                 p = 0;
               /* copy one column from the original pixmap to the tmp pixmap */
               if (p >= xpmw)
                 p = 0;
               /* copy one column from the original pixmap to the tmp pixmap */
-              XCopyArea (display->display, bgPixmap.pixmap, tmp, gc,
+              XCopyArea (disp, bgPixmap.pixmap, tmp, gc,
                         (int)p, 0, 1, xpmh, (int)x, 0);
             }
 
                         (int)p, 0, 1, xpmh, (int)x, 0);
             }
 
@@ -239,10 +240,10 @@ rxvt_term::resize_pixmap ()
           rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh);
 
           if (y > 0)
           rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh);
 
           if (y > 0)
-            XFillRectangle (display->display, TermWin.pixmap, gc, 0, 0, width, y);
+            XFillRectangle (disp, TermWin.pixmap, gc, 0, 0, width, y);
 
           if (h < height)
 
           if (h < height)
-            XFillRectangle (display->display, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1);
+            XFillRectangle (disp, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1);
 
           for ( /*nil */ ; y < h; y++, p += incr)
             {
 
           for ( /*nil */ ; y < h; y++, p += incr)
             {
@@ -250,16 +251,16 @@ rxvt_term::resize_pixmap ()
                 p = 0;
 
               /* copy one row from the tmp pixmap to the main pixmap */
                 p = 0;
 
               /* copy one row from the tmp pixmap to the main pixmap */
-              XCopyArea (display->display, tmp, TermWin.pixmap, gc,
+              XCopyArea (disp, tmp, TermWin.pixmap, gc,
                         0, (int)p, width, 1, 0, (int)y);
             }
 
                         0, (int)p, width, 1, 0, (int)y);
             }
 
-          XFreePixmap (display->display, tmp);
+          XFreePixmap (disp, tmp);
         }
     }
 
         }
     }
 
-  XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap);
-  XFreeGC (display->display, gc);
+  XSetWindowBackgroundPixmap (disp, TermWin.vt, TermWin.pixmap);
+  XFreeGC (disp, gc);
   am_transparent = 0;
 }
 
   am_transparent = 0;
 }
 
@@ -343,7 +344,7 @@ rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, uns
 Pixmap
 rxvt_term::set_bgPixmap (const char *file)
 {
 Pixmap
 rxvt_term::set_bgPixmap (const char *file)
 {
-  char           *f;
+  char *f;
 
   assert (file != NULL);
 
 
   assert (file != NULL);