From 4912d02bab8dfd17c6afea34f602687931298e42 Mon Sep 17 00:00:00 2001 From: pcg Date: Mon, 9 Feb 2004 07:11:49 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 2 + src/Makefile.in | 4 +- src/command.C | 2 + src/defaultfont.C | 4 +- src/init.C | 165 ++++++++++++++++------------------------ src/iom.h | 4 +- src/main.C | 131 ++++++++++++++++++-------------- src/menubar.C | 56 +++++++------- src/misc.C | 44 +++++------ src/rxvt.h | 36 +++++---- src/rxvtcolor.C | 171 ++++++++++++++++++++++++++++++++++++++---- src/rxvtcolor.h | 84 ++++++++++++++++++--- src/rxvtlib.h.in | 32 +------- src/rxvtstl.h | 3 +- src/screen.C | 114 ++++++++++++++-------------- src/scrollbar-next.C | 48 ++++++------ src/scrollbar-plain.C | 36 ++++----- src/scrollbar-rxvt.C | 30 ++++---- src/scrollbar-xterm.C | 16 ++-- src/scrollbar.C | 25 +++--- src/version.h | 6 +- src/xpm.C | 44 +++++------ 22 files changed, 615 insertions(+), 442 deletions(-) diff --git a/Changes b/Changes index 2ffd7def..41fbc6d2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ 1.9 - fixed bug in plain scrollbar causing x errors in XCreateGC. + - implemented sharing of X connections. will be used to speed + up many x operations considerably. Also saves some memory. 1.8 Mon Feb 2 20:09:18 CET 2004 - almost total conversion to C++. Except for introducing diff --git a/src/Makefile.in b/src/Makefile.in index a428c3fe..3c757701 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.10 2004-01-31 04:12:10 pcg Exp $ +# $Id: Makefile.in,v 1.11 2004-02-09 07:11:49 pcg Exp $ @MCOMMON@ LINT = lint -DNARROWPROTO=1 $(XINC) -chapbxz @@ -71,7 +71,7 @@ INTPROS = command.intpro defaultfont.intpro grkelot.intpro \ scrollbar-rxvt.intpro scrollbar-next.intpro scrollbar-xterm.intpro scrollbar-plain.intpro \ strings.intpro xdefaults.intpro xpm.intpro -DEPS = rxvt.h rxvtlib.h ${basedir}/config.h feature.h .protos +DEPS = rxvt.h rxvtlib.h ${basedir}/config.h feature.h rxvtcolor.h .protos # # Distribution variables diff --git a/src/command.C b/src/command.C index 64c00c3b..a20cead0 100644 --- a/src/command.C +++ b/src/command.C @@ -1550,6 +1550,7 @@ rxvt_term::x_cb (XEvent &ev) } } +#ifdef TRANSPARENT void rxvt_term::rootwin_cb (XEvent &ev) { @@ -1575,6 +1576,7 @@ rxvt_term::rootwin_cb (XEvent &ev) want_full_refresh = 1; } } +#endif void rxvt_term::button_press (const XButtonEvent &ev) diff --git a/src/defaultfont.C b/src/defaultfont.C index 1edcfae8..a49c5489 100644 --- a/src/defaultfont.C +++ b/src/defaultfont.C @@ -25,7 +25,7 @@ #include -#define DISPLAY r->Xdisplay +#define DISPLAY r->display->display #define DRAWABLE r->TermWin.vt #define GC r->TermWin.gc @@ -893,7 +893,7 @@ rxvt_font_xft::draw (int x, int y, int fg, int bg) { if (!d) - d = XftDrawCreate (DISPLAY, DRAWABLE, r->Xvisual, r->Xcmap); + d = XftDrawCreate (DISPLAY, DRAWABLE, r->display->visual, r->display->cmap); if (bg >= 0 && bg != Color_bg) XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); diff --git a/src/init.C b/src/init.C index 7cdbb8d3..fcf156d0 100644 --- a/src/init.C +++ b/src/init.C @@ -374,7 +374,7 @@ rxvt_term::init_vars () Options = DEFAULT_OPTIONS; want_refresh = 1; cmd_pid = -1; - cmd_fd = tty_fd = Xfd = -1; + cmd_fd = tty_fd = -1; PrivateModes = SavedModes = PrivMode_Default; TermWin.focus = 0; TermWin.ncol = 80; @@ -537,19 +537,19 @@ rxvt_term::init_resources (int argc, const char *const *argv) val = rxvt_malloc (5 + STRLEN (rs[Rs_display_name])); STRCPY (val, "unix"); STRCAT (val, rs[Rs_display_name]); - Xdisplay = XOpenDisplay (val); + display = displays.get (val); free (val); } #endif - if (Xdisplay == NULL - && (Xdisplay = XOpenDisplay (rs[Rs_display_name])) == NULL) + if (!display + && !(display = displays.get (rs[Rs_display_name]))) { rxvt_print_error ("can't open display %s", rs[Rs_display_name]); exit (EXIT_FAILURE); } - extract_resources (Xdisplay, rs[Rs_name]); + extract_resources (display->display, rs[Rs_name]); /* * set any defaults not already set @@ -738,7 +738,7 @@ rxvt_term::init_env () if (val == NULL) #endif /* DISPLAY_IS_IP */ - val = XDisplayString(Xdisplay); + val = XDisplayString(display->display); if (rs[Rs_display_name] == NULL) rs[Rs_display_name] = val; /* use broken `:0' value */ @@ -772,7 +772,7 @@ rxvt_term::init_env () putenv ("TERMINFO=" RXVT_TERMINFO); #endif - if (Xdepth <= 2) + if (display->depth <= 2) putenv ("COLORTERM=" COLORTERMENV "-mono"); else putenv ("COLORTERM=" COLORTERMENVFULL); @@ -826,8 +826,8 @@ rxvt_term::init_xlocale () { Atom wmlocale; - wmlocale = XInternAtom (Xdisplay, "WM_LOCALE_NAME", False); - XChangeProperty (Xdisplay, TermWin.parent[0], wmlocale, + wmlocale = XInternAtom (display->display, "WM_LOCALE_NAME", False); + XChangeProperty (display->display, TermWin.parent[0], wmlocale, XA_STRING, 8, PropModeReplace, (unsigned char *)locale, STRLEN(locale)); @@ -838,11 +838,11 @@ rxvt_term::init_xlocale () } /* see if we can connect yet */ - rxvt_IMInstantiateCallback (Xdisplay, NULL, NULL); + rxvt_IMInstantiateCallback (display->display, NULL, NULL); /* To avoid Segmentation Fault in C locale: Solaris only? */ if (STRCMP (locale, "C")) - XRegisterIMInstantiateCallback (Xdisplay, NULL, NULL, NULL, + XRegisterIMInstantiateCallback (display->display, NULL, NULL, NULL, rxvt_IMInstantiateCallback, NULL); } #endif @@ -859,15 +859,15 @@ rxvt_term::init_command(const char *const *argv) int i; for (i = 0; i < NUM_XA; i++) - xa[i] = XInternAtom(Xdisplay, xa_names[i], False); + xa[i] = XInternAtom(display->display, xa_names[i], False); /* Enable delete window protocol */ - XSetWMProtocols (Xdisplay, TermWin.parent[0], + XSetWMProtocols (display->display, TermWin.parent[0], &(xa[XA_WMDELETEWINDOW]), 1); #ifdef USING_W11LIB /* enable W11 callbacks */ - W11AddEventHandler (Xdisplay, rxvt_W11_process_x_event); + W11AddEventHandler (display->display, rxvt_W11_process_x_event); #endif #ifdef META8_OPTION @@ -904,10 +904,7 @@ rxvt_term::init_command(const char *const *argv) greek_init(); #endif - Xfd = XConnectionNumber (Xdisplay); - #ifdef CURSOR_BLINK - if (Options & Opt_cursorBlink) (void)gettimeofday (&lastcursorchange, NULL); #endif @@ -936,9 +933,7 @@ rxvt_term::Get_Colours () { #ifndef XTERM_REVERSE_VIDEO if (i < 2 && (Options & Opt_reverseVideo)) - { - rs[Rs_color + i] = def_colorName[!i]; - } + rs[Rs_color + i] = def_colorName[!i]; else #endif rs[Rs_color + i] = def_colorName[i]; @@ -1004,25 +999,25 @@ rxvt_term::Get_Colours () xcol[1] = PixColors[Color_scroll]; # ifdef PREFER_24BIT - xcol[0].set (this, 65535, 65535, 65535); - /* XFreeColors(Xdisplay, XCMAP, &(xcol[0].pixel), 1, ~0); */ + xcol[0].set (display, 65535, 65535, 65535); + /* XFreeColors(display->display, XCMAP, &(xcol[0].pixel), 1, ~0); */ # else - xcol[0].set (this, WhitePixel (Xdisplay, Xscreen)); + xcol[0].set (display, WhitePixel (display->display, display->screen)); # endif unsigned short pr1, pg1, pb1, pr0, pg0, pb0; - xcol[0].get (this, pr0, pg0, pb0); - xcol[1].get (this, pr1, pg1, pb1); + xcol[0].get (display, pr0, pg0, pb0); + xcol[1].get (display, pr1, pg1, pb1); /* bottomShadowColor */ - if (!xcol[2].set (this, pr1 / 2, pg1 / 2, pb1 / 2)) + if (!xcol[2].set (display, pr1 / 2, pg1 / 2, pb1 / 2)) xcol[2] = PixColors[Color_Black]; PixColors[Color_bottomShadow] = xcol[2]; /* topShadowColor */ - if (!xcol[1].set (this, + if (!xcol[1].set (display, min (pr0, max (pr0 / 5, pr1) * 7 / 5), min (pg0, max (pg0 / 5, pg1) * 7 / 5), min (pb0, max (pb0 / 5, pb1) * 7 / 5))) @@ -1081,7 +1076,7 @@ rxvt_term::get_ourmods () && STRCASECMP(rsmod, "mod1") >= 0 && STRCASECMP(rsmod, "mod5") <= 0) requestedmeta = rsmod[3] - '0'; - map = XGetModifierMapping(Xdisplay); + map = XGetModifierMapping(display->display); kc = map->modifiermap; for (i = 1; i < 6; i++) { @@ -1090,7 +1085,7 @@ rxvt_term::get_ourmods () { if (kc[k] == 0) break; - switch (XKeycodeToKeysym(Xdisplay, kc[k], 0)) + switch (XKeycodeToKeysym(display->display, kc[k], 0)) { case XK_Num_Lock: ModNumLockMask = modmasks[i - 1]; @@ -1140,37 +1135,10 @@ rxvt_term::create_windows (int argc, const char *const *argv) XWindowAttributes gattr; - Xcmap = DefaultColormap (Xdisplay, Xscreen); - Xvisual = DefaultVisual (Xdisplay, Xscreen); - Xscreen = DefaultScreen (Xdisplay); - if (Options & Opt_transparent) { - XGetWindowAttributes (Xdisplay, RootWindow(Xdisplay, Xscreen), &gattr); - Xdepth = gattr.depth; - } - else - { - Xdepth = DefaultDepth(Xdisplay, Xscreen); -#ifdef PREFER_24BIT - /* - * If depth is not 24, look for a 24bit visual. - */ - if (Xdepth != 24) - { - XVisualInfo vinfo; - - if (XMatchVisualInfo(Xdisplay, Xscreen, 24, TrueColor, &vinfo)) - { - Xdepth = 24; - Xvisual = vinfo.visual; - Xcmap = XCreateColormap(Xdisplay, - RootWindow(Xdisplay, Xscreen), - Xvisual, AllocNone); - } - } -#endif - + XGetWindowAttributes (display->display, RootWindow(display->display, display->screen), &gattr); + display->depth = gattr.depth; // doh //TODO, per-term not per-display? } /* grab colors before netscape does */ @@ -1190,17 +1158,16 @@ rxvt_term::create_windows (int argc, const char *const *argv) attributes.background_pixel = PixColors[Color_fg]; attributes.border_pixel = PixColors[Color_border]; - attributes.colormap = Xcmap; - TermWin.parent[0] = XCreateWindow (Xdisplay, DefaultRootWindow (Xdisplay), + attributes.colormap = display->cmap; + TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display), szHint.x, szHint.y, szHint.width, szHint.height, TermWin.ext_bwidth, - Xdepth, InputOutput, - Xvisual, - CWBackPixel | CWBorderPixel - | CWColormap, &attributes); + display->depth, InputOutput, + display->visual, + CWBackPixel | CWBorderPixel | CWColormap, &attributes); #else - TermWin.parent[0] = XCreateSimpleWindow (Xdisplay, DefaultRootWindow (Xdisplay), + TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display), szHint.x, szHint.y, szHint.width, szHint.height, @@ -1221,48 +1188,50 @@ rxvt_term::create_windows (int argc, const char *const *argv) : NormalState); wmHint.window_group = TermWin.parent[0]; - XSetWMProperties(Xdisplay, TermWin.parent[0], NULL, NULL, + XSetWMProperties(display->display, TermWin.parent[0], NULL, NULL, (char **)argv, argc, &szHint, &wmHint, &classHint); - XSelectInput(Xdisplay, TermWin.parent[0], - (KeyPressMask + + XSelectInput(display->display, TermWin.parent[0], + KeyPressMask #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) - | KeyReleaseMask + | KeyReleaseMask #endif - | FocusChangeMask | VisibilityChangeMask - | StructureNotifyMask)); + | FocusChangeMask | VisibilityChangeMask + | StructureNotifyMask); + termwin_ev.start (display, TermWin.parent[0]); /* vt cursor: Black-on-White is standard, but this is more popular */ - TermWin_cursor = XCreateFontCursor(Xdisplay, XC_xterm); + TermWin_cursor = XCreateFontCursor(display->display, XC_xterm); #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) /* cursor (menuBar/scrollBar): Black-on-White */ - leftptr_cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); + leftptr_cursor = XCreateFontCursor(display->display, XC_left_ptr); #endif #ifdef POINTER_BLANK - { XColor blackcolour; blackcolour.red = 0; blackcolour.green = 0; blackcolour.blue = 0; - Font f = XLoadFont (Xdisplay, "fixed"); - blank_cursor = XCreateGlyphCursor (Xdisplay, f, f, ' ', ' ', + Font f = XLoadFont (display->display, "fixed"); + blank_cursor = XCreateGlyphCursor (display->display, f, f, ' ', ' ', &blackcolour, &blackcolour); - XUnloadFont (Xdisplay, f); + XUnloadFont (display->display, f); } #endif /* the vt window */ - TermWin.vt = XCreateSimpleWindow(Xdisplay, TermWin.parent[0], + TermWin.vt = XCreateSimpleWindow(display->display, TermWin.parent[0], window_vt_x, window_vt_y, TermWin_TotalWidth(), TermWin_TotalHeight(), 0, PixColors[Color_fg], PixColors[Color_bg]); + #ifdef DEBUG_X - XStoreName(Xdisplay, TermWin.vt, "vt window"); + XStoreName(display->display, TermWin.vt, "vt window"); #endif vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask @@ -1277,13 +1246,13 @@ rxvt_term::create_windows (int argc, const char *const *argv) #endif vt_emask |= (Button1MotionMask | Button3MotionMask); - XSelectInput(Xdisplay, TermWin.vt, vt_emask); + XSelectInput(display->display, TermWin.vt, vt_emask); + vt_ev.start (display, TermWin.vt); #if defined(MENUBAR) && (MENUBAR_MAX > 1) - if (menuBar_height()) { - menuBar.win = XCreateSimpleWindow(Xdisplay, TermWin.parent[0], + menuBar.win = XCreateSimpleWindow(display->display, TermWin.parent[0], window_vt_x, 0, TermWin_TotalWidth(), menuBar_TotalHeight(), @@ -1291,16 +1260,18 @@ rxvt_term::create_windows (int argc, const char *const *argv) PixColors[Color_fg], PixColors[Color_scroll]); #ifdef DEBUG_X - - XStoreName(Xdisplay, menuBar.win, "menubar"); + XStoreName(display->display, menuBar.win, "menubar"); #endif - XDefineCursor(Xdisplay, menuBar.win, pointer_leftptr); - XSelectInput(Xdisplay, menuBar.win, + XDefineCursor(display->display, menuBar.win, pointer_leftptr); + + XSelectInput(display->display, menuBar.win, (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask)); + menubar_ev.start (display, menuBar.win); } #endif + #ifdef XPM_BACKGROUND if (rs[Rs_backgroundPixmap] != NULL && !(Options & Opt_transparent)) @@ -1321,21 +1292,20 @@ rxvt_term::create_windows (int argc, const char *const *argv) gcvalue.foreground = PixColors[Color_fg]; gcvalue.background = PixColors[Color_bg]; gcvalue.graphics_exposures = 1; - TermWin.gc = XCreateGC(Xdisplay, TermWin.vt, + TermWin.gc = XCreateGC(display->display, TermWin.vt, GCForeground | GCBackground | GCGraphicsExposures, &gcvalue); #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) - gcvalue.foreground = PixColors[Color_topShadow]; - topShadowGC = XCreateGC(Xdisplay, TermWin.vt, + topShadowGC = XCreateGC(display->display, TermWin.vt, GCForeground, &gcvalue); gcvalue.foreground = PixColors[Color_bottomShadow]; - botShadowGC = XCreateGC(Xdisplay, TermWin.vt, + botShadowGC = XCreateGC(display->display, TermWin.vt, GCForeground, &gcvalue); gcvalue.foreground = PixColors[(XDEPTH <= 2 ? Color_fg : Color_scroll)]; - scrollbarGC = XCreateGC(Xdisplay, TermWin.vt, + scrollbarGC = XCreateGC(display->display, TermWin.vt, GCForeground, &gcvalue); #endif } @@ -1358,15 +1328,6 @@ rxvt_term::run_command (const char *const *argv) return -1; } -#ifdef FD_SETSIZE - if (Xfd > FD_SETSIZE || cfd > FD_SETSIZE) - { - rxvt_print_error("fd too high: %d max", FD_SETSIZE); - rxvt_clean_exit(); - exit(EXIT_FAILURE); - } -#endif - fcntl (cfd, F_SETFL, O_NONBLOCK); /* get slave (tty) */ @@ -1404,7 +1365,7 @@ rxvt_term::run_command (const char *const *argv) return -1; case 0: close (cfd); /* only keep tty_fd and STDERR open */ - close (Xfd); + if (rxvt_control_tty (tty_fd, ttydev) < 0) rxvt_print_error ("could not obtain control of tty"); else @@ -1441,7 +1402,7 @@ rxvt_term::run_command (const char *const *argv) #endif } - close (tty_fd); /* keep STDERR_FILENO, cmd_fd, Xfd open */ + close (tty_fd); /* keep STDERR_FILENO, cmd_fd, display->fd () open */ break; } #else /* __QNX__ uses qnxspawn() */ diff --git a/src/iom.h b/src/iom.h index f0b18181..70a5837d 100644 --- a/src/iom.h +++ b/src/iom.h @@ -59,9 +59,7 @@ struct idle_watcher; #endif template -struct io_manager_vec : protected vector { - friend class io_manager; -protected: +struct io_manager_vec : vector { #if IOM_CHECK bool activity; #endif diff --git a/src/main.C b/src/main.C index 7a5899e2..ec98644d 100644 --- a/src/main.C +++ b/src/main.C @@ -74,6 +74,17 @@ rxvt_term::operator delete (void *p, size_t s) rxvt_term::rxvt_term () : +#ifdef TRANSPARENT + rootwin_ev (this, &rxvt_term::rootwin_cb), +#endif + termwin_ev (this, &rxvt_term::x_cb), + vt_ev (this, &rxvt_term::x_cb), +#ifdef HAVE_SCROLLBARS + scrollbar_ev (this, &rxvt_term::x_cb), +#endif +#ifdef MENUBAR + menubar_ev (this, &rxvt_term::x_cb), fixme +#endif #ifdef CURSOR_BLINK cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), #endif @@ -86,7 +97,6 @@ rxvt_term::rxvt_term () check_ev (this, &rxvt_term::check_cb), destroy_ev (this, &rxvt_term::destroy_cb), pty_ev (this, &rxvt_term::pty_cb), - x_ev (this, &rxvt_term::x_cb), incr_ev (this, &rxvt_term::incr_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; @@ -106,28 +116,44 @@ rxvt_term::~rxvt_term () privileged_utmp (RESTORE); #endif #ifdef USE_XIM - if (Input_Context != NULL) + if (Input_Context) { XDestroyIC (Input_Context); Input_Context = NULL; } #endif - if (cmd_fd >= 0) - close (cmd_fd); + if (TermWin.parent[0]) + XDestroyWindow (display->display, TermWin.parent[0]); - if (Xfd >= 0) - XCloseDisplay (Xdisplay); + // TODO: free pixcolours, colours should become part of rxvt_display delete PixColors; + + if (cmd_fd >= 0) + close (cmd_fd); + + if (display) + displays.release (display); } void rxvt_term::destroy () { + if (display) + { + termwin_ev.stop (display); + vt_ev.stop (display); +#ifdef HAVE_SCROLLBARS + scrollbar_ev.stop (display); +#endif +#ifdef MENUBAR + menubar_ev.stop (display); +#endif + } + check_ev.stop (); pty_ev.stop (); - x_ev.stop (); #ifdef CURSOR_BLINK cursor_blink_ev.stop (); #endif @@ -166,6 +192,8 @@ rxvt_init (int argc, const char *const *argv) return GET_R; } +static int (*old_xerror_handler)(Display *dpy, XErrorEvent *event); + void rxvt_init_signals () { @@ -191,7 +219,7 @@ rxvt_init_signals () /* need to trap SIGURG for SVR4 (Unixware) rlogin */ /* signal (SIGURG, SIG_DFL); */ - XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); + old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); } @@ -233,7 +261,7 @@ rxvt_term::init (int argc, const char *const *argv) #if 0 #ifdef DEBUG_X - XSynchronize(Xdisplay, True); + XSynchronize(display->display, True); #endif #endif @@ -243,28 +271,26 @@ rxvt_term::init (int argc, const char *const *argv) #endif #if (MENUBAR_MAX) if (menubar_visible(r)) - XMapWindow (Xdisplay, menuBar.win); + XMapWindow (display->display, menuBar.win); #endif #ifdef TRANSPARENT if (Options & Opt_transparent) { - XSelectInput (Xdisplay, Xroot, PropertyChangeMask); + XSelectInput (display->display, display->root, PropertyChangeMask); + rootwin_ev.start (display, display->root); check_our_parents (); } #endif - XMapWindow (Xdisplay, TermWin.vt); - XMapWindow (Xdisplay, TermWin.parent[0]); + XMapWindow (display->display, TermWin.vt); + XMapWindow (display->display, TermWin.parent[0]); init_env (); init_command (cmd_argv); - x_ev.start (Xfd, EVENT_READ); pty_ev.start (cmd_fd, EVENT_READ); check_ev.start (); - process_x_events (); - return true; } @@ -305,20 +331,15 @@ rxvt_Exit_signal(int sig) kill(getpid(), sig); } -/* ARGSUSED */ -/* EXTPROTO */ +/* INTPROTO */ int -rxvt_xerror_handler(const Display * display - __attribute__ ((unused)), const XErrorEvent * event) +rxvt_xerror_handler (Display *display, XErrorEvent *event) { if (GET_R->allowedxerror == -1) GET_R->allowedxerror = event->error_code; else { - rxvt_print_error("XError: Request: %d . %d, Error: %d", - event->request_code, event->minor_code, - event->error_code); - + old_xerror_handler (display, event); GET_R->destroy (); } @@ -639,10 +660,10 @@ rxvt_term::window_calc (unsigned int width, unsigned int height) window_sb_x = szHint.width - sb_w; if (recalc_x) - szHint.x += (DisplayWidth (Xdisplay, DefaultScreen (Xdisplay)) + szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) - szHint.width - 2 * TermWin.ext_bwidth); if (recalc_y) - szHint.y += (DisplayHeight (Xdisplay, DefaultScreen (Xdisplay)) + szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) - szHint.height - 2 * TermWin.ext_bwidth); TermWin.ncol = TermWin.width / TermWin.fwidth; @@ -704,14 +725,14 @@ void rxvt_term::set_title (const char *str) { #ifndef SMART_WINDOW_TITLE - XStoreName(Xdisplay, TermWin.parent[0], str); + XStoreName(display->display, TermWin.parent[0], str); #else char *name; - if (XFetchName(Xdisplay, TermWin.parent[0], &name) == 0) + if (XFetchName(display->display, TermWin.parent[0], &name) == 0) name = NULL; if (name == NULL || STRCMP(name, str)) - XStoreName(Xdisplay, TermWin.parent[0], str); + XStoreName(display->display, TermWin.parent[0], str); if (name) XFree(name); #endif @@ -721,14 +742,14 @@ void rxvt_term::set_iconName (const char *str) { #ifndef SMART_WINDOW_TITLE - XSetIconName(Xdisplay, TermWin.parent[0], str); + XSetIconName(display->display, TermWin.parent[0], str); #else char *name; - if (XGetIconName(Xdisplay, TermWin.parent[0], &name)) + if (XGetIconName(display->display, TermWin.parent[0], &name)) name = NULL; if (name == NULL || STRCMP(name, str)) - XSetIconName(Xdisplay, TermWin.parent[0], str); + XSetIconName(display->display, TermWin.parent[0], str); if (name) XFree(name); #endif @@ -767,7 +788,7 @@ rxvt_term::set_window_color (int idx, const char *color) } if (!rXParseAllocColor (& xcol, color)) return; - /* XStoreColor (Xdisplay, XCMAP, XColor*); */ + /* XStoreColor (display->display, XCMAP, XColor*); */ /* * FIXME: should free colors here, but no idea how to do it so instead, @@ -780,8 +801,8 @@ rxvt_term::set_window_color (int idx, const char *color) if (i > Color_White) { /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ - XFreeColors(Xdisplay, XCMAP, (PixColors + idx), 1, - DisplayPlanes(Xdisplay, Xscreen)); + XFreeColors(display->display, XCMAP, (PixColors + idx), 1, + DisplayPlanes(display->display, display->screen)); } # endif @@ -792,7 +813,7 @@ rxvt_term::set_window_color (int idx, const char *color) /* Cursor cursor; */ Done: if (idx == Color_bg && !(Options & Opt_transparent)) - XSetWindowBackground(Xdisplay, TermWin.vt, + XSetWindowBackground(display->display, TermWin.vt, PixColors[Color_bg]); /* handle Color_BD, scrollbar background, etc. */ @@ -815,8 +836,8 @@ rxvt_term::recolour_cursor () xcol[0] = PixColors[Color_pointer]; xcol[1] = PixColors[Color_bg]; - XQueryColors (Xdisplay, XCMAP, xcol, 2); - XRecolorCursor (Xdisplay, TermWin_cursor, &(xcol[0]), &(xcol[1])); + XQueryColors (display->display, XCMAP, xcol, 2); + XRecolorCursor (display->display, TermWin_cursor, &(xcol[0]), &(xcol[1])); #endif } @@ -874,7 +895,7 @@ rxvt_term::set_colorfgbg () int rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) { - if (!screen_in_out->set (this, colour)) + if (!screen_in_out->set (display, colour)) { rxvt_print_error("can't allocate colour: %s", colour); return false; @@ -896,7 +917,7 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno #endif window_calc (width, height); - XSetWMNormalHints (Xdisplay, TermWin.parent[0], &szHint); + XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); if (!ignoreparent) { #ifdef SMART_RESIZE @@ -909,12 +930,12 @@ 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; - XTranslateCoordinates (Xdisplay, TermWin.parent[0], Xroot, + XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 0, 0, &x, &y, &unused_cr); - XGetGeometry (Xdisplay, TermWin.parent[0], &unused_cr, &x1, &y1, + XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, &unused_w1, &unused_h1, &unused_b1, &unused_d1); /* - * if Xroot isn't the parent window, a WM will probably have offset + * if display->root isn't the parent window, a WM will probably have offset * our position for handles and decorations. Counter it */ if (x1 != x || y1 != y) @@ -923,8 +944,8 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno y -= y1; } - x1 = (DisplayWidth (Xdisplay, Xscreen) - old_width) / 2; - y1 = (DisplayHeight (Xdisplay, Xscreen) - old_height) / 2; + x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; + y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; dx = old_width - szHint.width; dy = old_height - szHint.height; @@ -938,10 +959,10 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno else if (y == y1) /* exact center */ dy /= 2; - XMoveResizeWindow (Xdisplay, TermWin.parent[0], x + dx, y + dy, + XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, szHint.width, szHint.height); #else - XResizeWindow (Xdisplay, TermWin.parent[0], szHint.width, + XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); #endif @@ -954,16 +975,16 @@ rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int igno { if (scrollbar_visible ()) { - XMoveResizeWindow (Xdisplay, scrollBar.win, window_sb_x, + XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, 0, scrollbar_TotalWidth (), szHint.height); resize_scrollbar (); } if (menubar_visible ()) - XMoveResizeWindow (Xdisplay, menuBar.win, window_vt_x, + XMoveResizeWindow (display->display, menuBar.win, window_vt_x, 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); - XMoveResizeWindow (Xdisplay, TermWin.vt, window_vt_x, + XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, window_vt_y, TermWin_TotalWidth (), TermWin_TotalHeight ()); #ifdef RXVT_GRAPHICS @@ -1020,7 +1041,7 @@ rxvt_term::set_widthheight (unsigned int width, unsigned int height) if (width == 0 || height == 0) { - XGetWindowAttributes(Xdisplay, Xroot, &wattr); + XGetWindowAttributes(display->display, display->root, &wattr); if (width == 0) width = wattr.width - szHint.base_width; if (height == 0) @@ -1071,8 +1092,8 @@ rxvt_term::IMisRunning () if ((p = STRCHR(server + 1, '@')) != NULL) /* first one only */ *p = '\0'; - atom = XInternAtom(Xdisplay, server, False); - win = XGetSelectionOwner(Xdisplay, atom); + atom = XInternAtom(display->display, server, False); + win = XGetSelectionOwner(display->display, atom); if (win != None) return True; } @@ -1137,7 +1158,7 @@ rxvt_IMDestroyCallback(XIM xim __attribute__ ((unused)), XPointer client_data GET_R->Input_Context = NULL; /* To avoid Segmentation Fault in C locale: Solaris only? */ if (STRCMP (GET_R->locale, "C")) - XRegisterIMInstantiateCallback(GET_R->Xdisplay, NULL, NULL, NULL, + XRegisterIMInstantiateCallback(GET_R->display->display, NULL, NULL, NULL, rxvt_IMInstantiateCallback, NULL); } @@ -1160,7 +1181,7 @@ rxvt_term::IM_get_IC () XIMCallback ximcallback; D_MAIN((stderr, "rxvt_IM_get_IC()")); - xim = XOpenIM (Xdisplay, NULL, NULL, NULL); + xim = XOpenIM (display->display, NULL, NULL, NULL); if (xim == NULL) return False; diff --git a/src/menubar.C b/src/menubar.C index 9195453c..efdffc48 100644 --- a/src/menubar.C +++ b/src/menubar.C @@ -748,7 +748,7 @@ rxvt_term::drawbox_menubar (int x, int len, int state) break; /* neutral */ } - rxvt_Draw_Shadow(Xdisplay, menuBar.win, top, bot, + rxvt_Draw_Shadow(display->display, menuBar.win, top, bot, x, 0, len, menuBar_TotalHeight()); } @@ -781,7 +781,7 @@ rxvt_term::drawtriangle (int x, int y, int state) x -= SHADOW + (3 * w / 2); y += SHADOW * 3; - rxvt_Draw_Triangle(Xdisplay, ActiveMenu->win, top, bot, x, y, w, + rxvt_Draw_Triangle(display->display, ActiveMenu->win, top, bot, x, y, w, 'r'); } @@ -808,11 +808,11 @@ rxvt_term::drawbox_menuitem (int y, int state) break; /* neutral */ } - rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, top, bot, + rxvt_Draw_Shadow(display->display, ActiveMenu->win, top, bot, SHADOW + 0, SHADOW + y, ActiveMenu->w - 2 * (SHADOW), HEIGHT_TEXT + 2 * SHADOW); - XFlush(Xdisplay); + XFlush(display->display); } #ifdef DEBUG_MENU_LAYOUT @@ -924,15 +924,15 @@ rxvt_term::menu_show () } if (ActiveMenu->win == None) { - ActiveMenu->win = XCreateSimpleWindow(Xdisplay, TermWin.vt, + ActiveMenu->win = XCreateSimpleWindow(display->display, TermWin.vt, x, ActiveMenu->y, ActiveMenu->w, ActiveMenu->h, 0, PixColors[Color_fg], PixColors[Color_scroll]); - XMapWindow(Xdisplay, ActiveMenu->win); + XMapWindow(display->display, ActiveMenu->win); } - rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, + rxvt_Draw_Shadow(display->display, ActiveMenu->win, topShadowGC, botShadowGC, 0, 0, ActiveMenu->w, ActiveMenu->h); @@ -949,7 +949,7 @@ rxvt_term::menu_show () if (isSeparator(item->name)) { - rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, + rxvt_Draw_Shadow(display->display, ActiveMenu->win, topShadowGC, botShadowGC, SHADOW, y + SHADOW + 1, ActiveMenu->w - 2 * SHADOW, 0); @@ -1008,14 +1008,14 @@ rxvt_term::menu_show () { #ifdef USE_XIM if (TermWin.fontset) - XmbDrawString(Xdisplay, + XmbDrawString(display->display, ActiveMenu->win, TermWin.fontset, gc, xoff, 2 * SHADOW + y + TermWin.font->ascent + 1, name, len); else #endif - XDrawString(Xdisplay, ActiveMenu->win, gc, xoff, + XDrawString(display->display, ActiveMenu->win, gc, xoff, 2 * SHADOW + y + TermWin.font->ascent + 1, name, len); } @@ -1026,7 +1026,7 @@ rxvt_term::menu_show () { #ifdef USE_XIM if (TermWin.fontset) - XmbDrawString(Xdisplay, + XmbDrawString(display->display, ActiveMenu->win, TermWin.fontset, gc, ActiveMenu->w - (xoff + Width2Pixel(xright)), @@ -1034,7 +1034,7 @@ rxvt_term::menu_show () name, len); else #endif - XDrawString(Xdisplay, ActiveMenu->win, gc, + XDrawString(display->display, ActiveMenu->win, gc, ActiveMenu->w - (xoff + Width2Pixel(xright)), 2 * SHADOW + y + TermWin.font->ascent + 1, name, len); @@ -1053,7 +1053,7 @@ rxvt_term::menu_display (void (*update)(rxvt_t *)) if (ActiveMenu == NULL) return; if (ActiveMenu->win != None) - XDestroyWindow(Xdisplay, ActiveMenu->win); + XDestroyWindow(display->display, ActiveMenu->win); ActiveMenu->win = None; ActiveMenu->item = NULL; @@ -2003,10 +2003,10 @@ rxvt_term::draw_Arrows (int name, int state) int x = Arrows_x + (5 * Width2Pixel(i)) / 4; if (!name || name == Arrows[i].name) - rxvt_Draw_Triangle(Xdisplay, menuBar.win, top, bot, x, y, w, + rxvt_Draw_Triangle(display->display, menuBar.win, top, bot, x, y, w, Arrows[i].name); } - XFlush(Xdisplay); + XFlush(display->display); } void @@ -2027,14 +2027,14 @@ rxvt_term::menubar_expose () gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg] : PixColors[Color_Black]); - menubarGC = XCreateGC(Xdisplay, menuBar.win, + menubarGC = XCreateGC(display->display, menuBar.win, GCForeground | GCFont, &gcvalue); } /* make sure the font is correct */ - XSetFont(Xdisplay, menubarGC, TermWin.font->fid); - XSetFont(Xdisplay, botShadowGC, TermWin.font->fid); - XClearWindow(Xdisplay, menuBar.win); + XSetFont(display->display, menubarGC, TermWin.font->fid); + XSetFont(display->display, botShadowGC, TermWin.font->fid); + XClearWindow(display->display, menuBar.win); menu_hide_all (); @@ -2057,14 +2057,14 @@ rxvt_term::menubar_expose () drawbox_menubar (menu->x, len, +1); #ifdef USE_XIM if (TermWin.fontset) - XmbDrawString(Xdisplay, + XmbDrawString(display->display, menuBar.win, TermWin.fontset, menubarGC, (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), menuBar_height() - SHADOW, menu->name, len); else #endif - XDrawString(Xdisplay, menuBar.win, menubarGC, + XDrawString(display->display, menuBar.win, menubarGC, (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), menuBar_height() - SHADOW, menu->name, len); @@ -2130,14 +2130,14 @@ rxvt_term::menubar_expose () { #ifdef USE_XIM if (TermWin.fontset) - XmbDrawString(Xdisplay, + XmbDrawString(display->display, menuBar.win, TermWin.fontset, menubarGC, Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, menuBar_height() - SHADOW, title, len); else #endif - XDrawString(Xdisplay, menuBar.win, menubarGC, + XDrawString(display->display, menuBar.win, menubarGC, Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, menuBar_height() - SHADOW, title, len); } @@ -2154,14 +2154,14 @@ rxvt_term::menubar_mapping (int map) menuBar.state = 1; if (menuBar.win == 0) return 0; - XMapWindow(Xdisplay, menuBar.win); + XMapWindow(display->display, menuBar.win); change = 1; } else if (!map && menubar_visible(r)) { menubar_expose (); menuBar.state = 0; - XUnmapWindow(Xdisplay, menuBar.win); + XUnmapWindow(display->display, menuBar.win); change = 1; } else @@ -2184,7 +2184,7 @@ rxvt_term::menu_select (XButtonEvent *ev) if (ActiveMenu == NULL) return 0; - XQueryPointer(Xdisplay, ActiveMenu->win, + XQueryPointer(display->display, ActiveMenu->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->x), &(ev->y), &unused_mask); @@ -2444,7 +2444,7 @@ rxvt_term::menubar_control (XButtonEvent *ev) break; case MotionNotify: - while (XCheckTypedWindowEvent(Xdisplay, TermWin.parent[0], + while (XCheckTypedWindowEvent(display->display, TermWin.parent[0], MotionNotify, (XEvent *) ev)) ; if (ActiveMenu) @@ -2457,7 +2457,7 @@ rxvt_term::menubar_control (XButtonEvent *ev) int unused_root_x, unused_root_y; unsigned int unused_mask; - XQueryPointer(Xdisplay, menuBar.win, + XQueryPointer(display->display, menuBar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->x), &(ev->y), &unused_mask); diff --git a/src/misc.C b/src/misc.C index ad7d0615..39c78d6c 100644 --- a/src/misc.C +++ b/src/misc.C @@ -366,7 +366,7 @@ rxvt_File_find(const char *file, const char *ext, const char *path) #if defined(RXVT_SCROLLBAR) || defined(MENUBAR) /* EXTPROTO */ void -rxvt_Draw_Shadow(Display *Xdisplay, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h) +rxvt_Draw_Shadow(Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h) { int shadow; @@ -375,10 +375,10 @@ rxvt_Draw_Shadow(Display *Xdisplay, Window win, GC topShadow, GC botShadow, int h += y - 1; for (; shadow-- > 0; x++, y++, w--, h--) { - XDrawLine(Xdisplay, win, topShadow, x, y, w, y); - XDrawLine(Xdisplay, win, topShadow, x, y, x, h); - XDrawLine(Xdisplay, win, botShadow, w, h, w, y + 1); - XDrawLine(Xdisplay, win, botShadow, w, h, x + 1, h); + XDrawLine(display, win, topShadow, x, y, w, y); + XDrawLine(display, win, topShadow, x, y, x, h); + XDrawLine(display, win, botShadow, w, h, w, y + 1); + XDrawLine(display, win, botShadow, w, h, x + 1, h); } } #endif @@ -387,39 +387,39 @@ rxvt_Draw_Shadow(Display *Xdisplay, Window win, GC topShadow, GC botShadow, int #ifdef MENUBAR /* EXTPROTO */ void -rxvt_Draw_Triangle(Display *Xdisplay, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type) +rxvt_Draw_Triangle(Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type) { switch (type) { case 'r': /* right triangle */ - XDrawLine(Xdisplay, win, topShadow, x, y, x, y + w); - XDrawLine(Xdisplay, win, topShadow, x, y, x + w, y + w / 2); - XDrawLine(Xdisplay, win, botShadow, x, y + w, x + w, y + w / 2); + XDrawLine(display, win, topShadow, x, y, x, y + w); + XDrawLine(display, win, topShadow, x, y, x + w, y + w / 2); + XDrawLine(display, win, botShadow, x, y + w, x + w, y + w / 2); break; case 'l': /* left triangle */ - XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w, y); - XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x, y + w / 2); - XDrawLine(Xdisplay, win, topShadow, x, y + w / 2, x + w, y); + XDrawLine(display, win, botShadow, x + w, y + w, x + w, y); + XDrawLine(display, win, botShadow, x + w, y + w, x, y + w / 2); + XDrawLine(display, win, topShadow, x, y + w / 2, x + w, y); break; case 'd': /* down triangle */ - XDrawLine(Xdisplay, win, topShadow, x, y, x + w / 2, y + w); - XDrawLine(Xdisplay, win, topShadow, x, y, x + w, y); - XDrawLine(Xdisplay, win, botShadow, x + w, y, x + w / 2, y + w); + XDrawLine(display, win, topShadow, x, y, x + w / 2, y + w); + XDrawLine(display, win, topShadow, x, y, x + w, y); + XDrawLine(display, win, botShadow, x + w, y, x + w / 2, y + w); break; case 'u': /* up triangle */ - XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w / 2, y); - XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x, y + w); - XDrawLine(Xdisplay, win, topShadow, x, y + w, x + w / 2, y); + XDrawLine(display, win, botShadow, x + w, y + w, x + w / 2, y); + XDrawLine(display, win, botShadow, x + w, y + w, x, y + w); + XDrawLine(display, win, topShadow, x, y + w, x + w / 2, y); break; #if 0 case 's': /* square */ - XDrawLine(Xdisplay, win, topShadow, x + w, y, x, y); - XDrawLine(Xdisplay, win, topShadow, x, y, x, y + w); - XDrawLine(Xdisplay, win, botShadow, x, y + w, x + w, y + w); - XDrawLine(Xdisplay, win, botShadow, x + w, y + w, x + w, y); + XDrawLine(display, win, topShadow, x + w, y, x, y); + XDrawLine(display, win, topShadow, x, y, x, y + w); + XDrawLine(display, win, botShadow, x, y + w, x + w, y + w); + XDrawLine(display, win, botShadow, x + w, y + w, x + w, y); break; #endif diff --git a/src/rxvt.h b/src/rxvt.h index 6d271d92..e028d1d2 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -608,9 +608,9 @@ enum { (PrivMode_Autowrap|PrivMode_aplKP|PrivMode_ShiftKeys|PrivMode_VisibleCursor) #endif -#define XDEPTH Xdepth -#define XCMAP Xcmap -#define XVISUAL Xvisual +#define XDEPTH display->depth +#define XCMAP display->cmap +#define XVISUAL display->visual #define IMBUFSIZ 128 /* input modifier buffer sizes */ #ifndef BUFSIZ @@ -652,8 +652,6 @@ enum { #define TermWin_TotalWidth() ((int32_t)TermWin.width + 2 * (int32_t)TermWin.int_bwidth) #define TermWin_TotalHeight() ((int32_t)TermWin.height + 2 * (int32_t)TermWin.int_bwidth) -#define Xroot DefaultRootWindow(Xdisplay) - /* how to build & extract colors and attributes */ #define GET_BASEFG(x) (((x) & RS_fgMask)) #define GET_BASEBG(x) (((x) & RS_bgMask)>>Color_Bits) @@ -1075,11 +1073,25 @@ struct rxvt_term : rxvt_vars { void flush (); +#ifdef TRANSPARENT + void rootwin_cb (XEvent &xev); + xevent_watcher rootwin_ev; +#endif + + void x_cb (XEvent &xev); + xevent_watcher termwin_ev; + xevent_watcher vt_ev; +#ifdef HAVE_SCROLLBARS + xevent_watcher scrollbar_ev; +#endif +#ifdef MENUBAR + xevent_watcher menubar_ev; +#endif + void check_cb (check_watcher &w); check_watcher check_ev; void destroy_cb (time_watcher &w); time_watcher destroy_ev; void pty_cb (io_watcher &w, short revents); io_watcher pty_ev; - void x_cb (io_watcher &w, short revents); io_watcher x_ev; void incr_cb (time_watcher &w); time_watcher incr_ev; @@ -1111,7 +1123,6 @@ struct rxvt_term : rxvt_vars { uint32_t next_char (); bool pty_fill (); - void process_x_events (); void *operator new (size_t s); void operator delete (void *p, size_t s); @@ -1163,13 +1174,12 @@ struct rxvt_term : rxvt_vars { /* autoconvert */ // command.C - void lookup_key (XKeyEvent *ev); + void lookup_key (XKeyEvent &ev); unsigned int cmd_write (const unsigned char *str, unsigned int count); uint32_t cmd_getc (); - void mouse_report (const XButtonEvent *ev); - void process_x_event (XEvent *ev); - void button_press (XButtonEvent *ev); - void button_release (XButtonEvent *ev); + void mouse_report (const XButtonEvent &ev); + void button_press (const XButtonEvent &ev); + void button_release (const XButtonEvent &ev); int check_our_parents (); #ifdef PRINTPIPE FILE * popen_printer (); @@ -1291,7 +1301,7 @@ struct rxvt_term : rxvt_vars { void selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret); void selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange); void selection_remove_trailing_spaces (); - void selection_send (const XSelectionRequestEvent *rq); + void selection_send (const XSelectionRequestEvent &rq); #if defined(NEXT_SCROLLBAR) // scrollbar-next.C diff --git a/src/rxvtcolor.C b/src/rxvtcolor.C index 217535c0..61331132 100644 --- a/src/rxvtcolor.C +++ b/src/rxvtcolor.C @@ -1,16 +1,146 @@ #include "../config.h" #include +#include -// TODO: free colors again +#include +#include +///////////////////////////////////////////////////////////////////////////// + +rxvt_display::rxvt_display (const char *name) +: x_watcher (this, &rxvt_display::x_event) +{ + this->name = STRDUP (name); +} + +rxvt_display::~rxvt_display () +{ + free (name); +} + +bool rxvt_display::open () +{ + display = XOpenDisplay (name); + + screen = DefaultScreen (display); + root = DefaultRootWindow (display); + visual = DefaultVisual (display, screen); + cmap = DefaultColormap (display, screen); + depth = DefaultDepth (display, screen); + +#ifdef PREFER_24BIT + /* + * If depth is not 24, look for a 24bit visual. + */ + if (depth != 24) + { + XVisualInfo vinfo; + + if (XMatchVisualInfo (display, screen, 24, TrueColor, &vinfo)) + { + depth = 24; + visual = vinfo.visual; + cmap = XCreateColormap (display, + RootWindow (display, screen), + visual, AllocNone); + } + } +#endif + + int fd = XConnectionNumber (display); + x_watcher.start (fd, EVENT_READ); + fcntl (fd, F_SETFL, FD_CLOEXEC); + + return true; +} + +void rxvt_display::close () +{ + x_watcher.stop (); + + XCloseDisplay (display); +} + +void rxvt_display::x_event (io_watcher &w, short revents) +{ + do + { + XEvent xev; + XNextEvent (display, &xev); + + for (int i = xw.size (); i--; ) + { + if (!xw[i]) + xw.erase_unordered (i); + else if (xw[i]->window == xev.xany.window) + xw[i]->call (xev); + } + } + while (XPending (display)); +} + +void rxvt_display::reg (xevent_watcher *w) +{ + xw.push_back (w); + w->active = xw.size (); +} + +void rxvt_display::unreg (xevent_watcher *w) +{ + if (w->active) + xw[w->active - 1] = 0; +} + +///////////////////////////////////////////////////////////////////////////// + +rxvt_displays displays; + +rxvt_display *rxvt_displays::get (const char *name) +{ + for (rxvt_display **i = list.begin (); i < list.end (); ++i) + { + if (!strcmp (name, (*i)->name)) + { + (*i)->referenced++; + return *i; + } + } + + rxvt_display *display = new rxvt_display (name); + + display->referenced = 1; + + if (display && display->open ()) + list.push_back (display); + else + { + delete display; + display = 0; + } + + return display; +} + +void rxvt_displays::release (rxvt_display *display) +{ + if (!--display->referenced) + { + display->close (); + delete display; + list.erase (find (list.begin (), list.end (), display)); + } +} + +///////////////////////////////////////////////////////////////////////////// + bool -rxvt_color::set (rxvt_term *t, Pixel p) +rxvt_color::set (rxvt_display *display, Pixel p) { #if XFT XColor xc; xc.pixel = p; - if (!XQueryColor (t->Xdisplay, t->Xcmap, &xc)) + if (!XQueryColor (display->display, display->cmap, &xc)) return false; XRenderColor d; @@ -21,11 +151,10 @@ rxvt_color::set (rxvt_term *t, Pixel p) d.alpha = 0xffff; return - XftColorAllocValue (t->Xdisplay, - t->Xvisual, - t->Xcmap, - &d, - &c); + XftColorAllocValue (display->display, + display->visual, + display->cmap, + &d, &c); #else this->p = p; #endif @@ -34,18 +163,18 @@ rxvt_color::set (rxvt_term *t, Pixel p) } bool -rxvt_color::set (rxvt_term *t, const char *name) +rxvt_color::set (rxvt_display *display, const char *name) { XColor xc; - if (XParseColor (t->Xdisplay, t->Xcmap, name, &xc)) - return set (t, xc.red, xc.green, xc.blue); + if (XParseColor (display->display, display->cmap, name, &xc)) + return set (display, xc.red, xc.green, xc.blue); return false; } bool -rxvt_color::set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned short cb) +rxvt_color::set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb) { XColor xc; @@ -54,14 +183,14 @@ rxvt_color::set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned sh xc.blue = cb; xc.flags = DoRed | DoGreen | DoBlue; - if (XAllocColor (t->Xdisplay, t->Xcmap, &xc)) - return set (t, xc.pixel); + if (XAllocColor (display->display, display->cmap, &xc)) + return set (display, xc.pixel); return false; } void -rxvt_color::get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned short &cb) +rxvt_color::get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb) { #if XFT cr = c.color.red; @@ -71,7 +200,7 @@ rxvt_color::get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned XColor c; c.pixel = p; - XQueryColor (t->Xdisplay, t->Xcmap, &c); + XQueryColor (display->display, display->cmap, &c); cr = c.red; cg = c.green; @@ -79,3 +208,13 @@ rxvt_color::get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned #endif } +void +rxvt_color::free (rxvt_display *display) +{ +#if XFT + XftColorFree (display->display, display->visual, display->cmap, &c); +#else + XFreeColors (display->display, display->cmap, &c, 1, AllPlanes); +#endif +} + diff --git a/src/rxvtcolor.h b/src/rxvtcolor.h index 55a9741b..ad0eb02e 100644 --- a/src/rxvtcolor.h +++ b/src/rxvtcolor.h @@ -7,29 +7,91 @@ # include #endif +#include "iom.h" + #include "rxvtlib.h" +#include "rxvtstl.h" + +#include "callback.h" struct rxvt_vars; +struct xevent_watcher; + +struct rxvt_display { + int referenced; + char *name; + + io_manager_vec xw; + io_watcher x_watcher; void x_event (io_watcher &w, short revents); + +//public + Display *display; + int depth; + int screen; + Visual *visual; + Colormap cmap; + Window root; + + bool open (); + void close (); + + void reg (xevent_watcher *w); + void unreg (xevent_watcher *w); + + rxvt_display (const char *name); + ~rxvt_display (); +}; + +struct xevent_watcher : watcher, callback1 { + Window window; + + template + xevent_watcher (O1 *object, void (O2::*method)(XEvent &)) + : callback1(object,method) + { } + + void start (rxvt_display *display, Window window) + { + this->window = window; + display->reg (this); + } + void stop (rxvt_display *display) + { + display->unreg (this); + } +}; + +struct rxvt_displays { + vector list; + + rxvt_display *get (const char *name); + void release (rxvt_display *display); +}; + +extern rxvt_displays displays; + typedef unsigned long Pixel; struct rxvt_color { #if XFT - XftColor c; - operator Pixel() const { return c.pixel; } + XftColor c; + operator Pixel() const { return c.pixel; } #else - Pixel p; - operator Pixel() const { return p; } + Pixel p; + operator Pixel() const { return p; } #endif - bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } - bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } + bool operator == (const rxvt_color &b) const { return Pixel(*this) == Pixel(b); } + bool operator != (const rxvt_color &b) const { return Pixel(*this) != Pixel(b); } - void get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned short &cb); - - bool set (rxvt_term *t, Pixel p); - bool set (rxvt_term *t, const char *name); - bool set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned short cb); + void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); + + bool set (rxvt_display *display, Pixel p); + bool set (rxvt_display *display, const char *name); + bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb); + + void free (rxvt_display *display); }; #endif diff --git a/src/rxvtlib.h.in b/src/rxvtlib.h.in index 5801c1ae..ddbd8193 100644 --- a/src/rxvtlib.h.in +++ b/src/rxvtlib.h.in @@ -1,24 +1,6 @@ #ifndef _RXVTLIB_H_ /* include once only */ #define _RXVTLIB_H_ -/* - * section 1 generated by GNU autoconf for @build@ - * this section may be changed as appropriate _before_ building - */ -/***************************************************************************** - * SECTION 1 * - *****************************************************************************/ - -/* - * The following line MUST not be changed without also changing - * config.h in the main directory before building - */ -// none anymore - -/***************************************************************************** - * INCLUDES * - *****************************************************************************/ - #include #include #include @@ -58,15 +40,12 @@ extern "C" { /* whatever normal size corresponds to a unsigned integer pointer */ @rxvt_u_intp_define@ -/***************************************************************************** - * SECTION 2 * - * DO NOT TOUCH ANYTHING BELOW HERE * - *****************************************************************************/ - struct rxvt_fontset; struct rxvt_color; struct rxvt_vars; /* defined later on */ struct rxvt_term; +struct rxvt_display; +struct rxvt_im; typedef struct rxvt_term *rxvt_t; @@ -263,16 +242,11 @@ struct rxvt_vars { menuBar_t menuBar; unsigned long Options; XSizeHints szHint; - Display *Xdisplay; - int Xdepth; - int Xscreen; - Visual *Xvisual; - Colormap Xcmap; + rxvt_display *display; rxvt_color *PixColors; short numPixColors; Cursor TermWin_cursor; /* cursor for vt window */ int sb_shadow; /* scrollbar shadow width */ - int Xfd; /* file descriptor of X server connection */ int cmd_fd; /* pty file descriptor; connected to command */ int tty_fd; /* tty file descriptor; connected to child */ int numlock_state; diff --git a/src/rxvtstl.h b/src/rxvtstl.h index 933203b5..d1ecc72d 100644 --- a/src/rxvtstl.h +++ b/src/rxvtstl.h @@ -8,8 +8,7 @@ template static inline T max (T a, U b) { return a > b ? template struct vector : simplevec -{ -}; +{ }; #if 0 template diff --git a/src/screen.C b/src/screen.C index 37aa045c..8133f7e5 100644 --- a/src/screen.C +++ b/src/screen.C @@ -94,18 +94,18 @@ inline void fill_text (text_t *start, text_t value, int len) #define CLEAR_ROWS(row, num) \ if (TermWin.mapped) \ - XClearArea (Xdisplay, drawBuffer, TermWin.int_bwidth, \ + XClearArea (display->display, drawBuffer, TermWin.int_bwidth, \ Row2Pixel(row), (unsigned int)TermWin.width, \ (unsigned int)Height2Pixel(num), False) #define CLEAR_CHARS(x, y, num) \ if (TermWin.mapped) \ - XClearArea (Xdisplay, drawBuffer, x, y, \ + XClearArea (display->display, drawBuffer, x, y, \ (unsigned int)Width2Pixel(num), \ (unsigned int)Height2Pixel(1), False) #define ERASE_ROWS(row, num) \ - XFillRectangle (Xdisplay, drawBuffer, TermWin.gc, \ + XFillRectangle (display->display, drawBuffer, TermWin.gc, \ TermWin.int_bwidth, Row2Pixel(row), \ (unsigned int)TermWin.width, \ (unsigned int)Height2Pixel(num)) @@ -1281,10 +1281,10 @@ rxvt_term::scr_erase_screen (int mode) { ren = (rstyle & (RS_fgMask | RS_bgMask)); gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)]; - XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); + XChangeGC(display->display, TermWin.gc, GCForeground, &gcvalue); ERASE_ROWS(row, num); gcvalue.foreground = PixColors[Color_fg]; - XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); + XChangeGC(display->display, TermWin.gc, GCForeground, &gcvalue); } for (; num--; row++) { @@ -1580,12 +1580,12 @@ rxvt_term::scr_rvideo_mode (int mode) #if defined(TRANSPARENT) if (!(Options & Opt_transparent) || am_transparent == 0) #endif - XSetWindowBackground(Xdisplay, TermWin.vt, + XSetWindowBackground(display->display, TermWin.vt, PixColors[Color_bg]); gcvalue.foreground = PixColors[Color_fg]; gcvalue.background = PixColors[Color_bg]; - XChangeGC(Xdisplay, TermWin.gc, GCBackground | GCForeground, + XChangeGC(display->display, TermWin.gc, GCBackground | GCForeground, &gcvalue); scr_clear (); scr_touch (true); @@ -1828,7 +1828,7 @@ rxvt_term::scr_bell () # ifdef MAPALERT_OPTION if (Options & Opt_mapAlert) # endif - XMapWindow(Xdisplay, TermWin.parent[0]); + XMapWindow(display->display, TermWin.parent[0]); # endif if (Options & Opt_visualBell) { @@ -1836,7 +1836,7 @@ rxvt_term::scr_bell () scr_rvideo_mode (!rvideo); /* refresh also done */ } else - XBell(Xdisplay, 0); + XBell(display->display, 0); #endif } @@ -2082,7 +2082,7 @@ rxvt_term::scr_refresh (unsigned char refresh_type) SWAP_IT(wlen, len, int); D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); - XCopyArea (Xdisplay, TermWin.vt, TermWin.vt, + XCopyArea (display->display, TermWin.vt, TermWin.vt, TermWin.gc, 0, Row2Pixel (len + i), (unsigned int)TermWin_TotalWidth (), (unsigned int)Height2Pixel (wlen - len + 1), @@ -2250,7 +2250,7 @@ rxvt_term::scr_refresh (unsigned char refresh_type) font->draw (xpixel, ypixel, text, count, fore, back); if ((rend & RS_Uline) && (font->descent > 1)) - XDrawLine(Xdisplay, drawBuffer, TermWin.gc, + XDrawLine(display->display, drawBuffer, TermWin.gc, xpixel, ypixel + font->ascent + 1, xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); } /* for (col....) */ @@ -2275,9 +2275,9 @@ rxvt_term::scr_refresh (unsigned char refresh_type) { #ifndef NO_CURSORCOLOR if (ISSET_PIXCOLOR (Color_cursor)) - XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); + XSetForeground (display->display, TermWin.gc, PixColors[Color_cursor]); #endif - XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, + XDrawRectangle(display->display, drawBuffer, TermWin.gc, Col2Pixel(oldcursor.col), Row2Pixel(oldcursor.row), (unsigned int)(Width2Pixel(cursorwidth) - 1), @@ -2298,7 +2298,7 @@ rxvt_term::scr_refresh (unsigned char refresh_type) * clear the whole screen height, note that width == 0 is treated * specially by XClearArea */ - XClearArea(Xdisplay, TermWin.vt, 0, 0, + XClearArea(display->display, TermWin.vt, 0, 0, (unsigned int)TermWin.int_bwidth, (unsigned int)TermWin_TotalHeight(), False); if (clearlast && TermWin.int_bwidth) @@ -2306,12 +2306,12 @@ rxvt_term::scr_refresh (unsigned char refresh_type) * clear the whole screen height, note that width == 0 is treated * specially by XClearArea */ - XClearArea(Xdisplay, TermWin.vt, + XClearArea(display->display, TermWin.vt, TermWin.width + TermWin.int_bwidth, 0, (unsigned int)TermWin.int_bwidth, (unsigned int)TermWin_TotalHeight(), False); if (refresh_type & SMOOTH_REFRESH) - XSync(Xdisplay, False); + XSync(display->display, False); num_scr = 0; num_scr_allow = 1; @@ -2339,11 +2339,11 @@ rxvt_term::scr_clear() while (i--) if (TermWin.parent[i] != None) - XClearWindow(Xdisplay, TermWin.parent[i]); + XClearWindow(display->display, TermWin.parent[i]); } #endif - XClearWindow (Xdisplay, TermWin.vt); + XClearWindow (display->display, TermWin.vt); } /* ------------------------------------------------------------------------- */ @@ -2516,7 +2516,7 @@ rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) for (;;) { - if (XGetWindowProperty(Xdisplay, win, prop, (long)(nread / 4), + if (XGetWindowProperty(display->display, win, prop, (long)(nread / 4), (long)(PROP_SIZE / 4), delete_prop, AnyPropertyType, &ct.encoding, &ct.format, &ct.nitems, &bytes_after, @@ -2545,7 +2545,7 @@ rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) * XConvertSelection() but nothing was presented */ D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); - selection_paste (Xroot, XA_CUT_BUFFER0, False); + selection_paste (display->root, XA_CUT_BUFFER0, False); } nread = -1; /* discount any previous stuff */ @@ -2556,7 +2556,7 @@ rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) char **cl; int cr; - if (XmbTextPropertyToTextList (Xdisplay, &ct, &cl, + if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 && cl) { for (int i = 0; i < cr; i++) @@ -2609,7 +2609,7 @@ rxvt_term::selection_property (Window win, Atom prop) unsigned long bytes_after, nitems; unsigned char *s = NULL; - a = XGetWindowProperty(Xdisplay, win, prop, 0L, 1L, False, + a = XGetWindowProperty(display->display, win, prop, 0L, 1L, False, xa[XA_INCR], &atype, &afmt, &nitems, &bytes_after, &s); if (s) @@ -2620,8 +2620,8 @@ rxvt_term::selection_property (Window win, Atom prop) if (atype == xa[XA_INCR]) { /* start an INCR transfer */ D_SELECT((stderr, "rxvt_selection_property: INCR: starting transfer")); - XDeleteProperty(Xdisplay, win, prop); - XFlush(Xdisplay); + XDeleteProperty(display->display, win, prop); + XFlush(display->display); reget_time = 1; selection_wait = Sel_incr; } @@ -2686,7 +2686,7 @@ rxvt_term::selection_request (Time tm, int x, int y) } selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); - selection_paste (Xroot, XA_CUT_BUFFER0, False); + selection_paste (display->root, XA_CUT_BUFFER0, False); } int @@ -2704,10 +2704,10 @@ rxvt_term::selection_request_other (Atom target, int selnum) sel = XA_SECONDARY; else sel = xa[XA_CLIPBOARD]; - if (XGetSelectionOwner(Xdisplay, sel) != None) + if (XGetSelectionOwner(display->display, sel) != None) { D_SELECT((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum])); - XConvertSelection(Xdisplay, sel, target, xa[XA_VT_SELECTION], + XConvertSelection(display->display, sel, target, xa[XA_VT_SELECTION], TermWin.vt, selection_request_time); return 1; } @@ -2833,8 +2833,8 @@ rxvt_term::selection_make (Time tm) selection.text = new_selection_text; - XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm); - if (XGetSelectionOwner(Xdisplay, XA_PRIMARY) != TermWin.vt) + XSetSelectionOwner(display->display, XA_PRIMARY, TermWin.vt, tm); + if (XGetSelectionOwner(display->display, XA_PRIMARY) != TermWin.vt) rxvt_print_error("can't get primary selection"); @@ -2842,14 +2842,14 @@ rxvt_term::selection_make (Time tm) XTextProperty ct; char *cl = (char *)selection.text; - if (XmbTextListToTextProperty(Xdisplay, &cl, 1, XStringStyle, &ct) >= 0) + if (XmbTextListToTextProperty(display->display, &cl, 1, XStringStyle, &ct) >= 0) { - XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, + XChangeProperty(display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, ct.value, ct.nitems); XFree (ct.value); } else - XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, + XChangeProperty(display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, selection.text, (int)selection.len); } @@ -3373,7 +3373,7 @@ typedef CARD32 Atom32; * EXT: SelectionRequest */ void -rxvt_term::selection_send (const XSelectionRequestEvent *rq) +rxvt_term::selection_send (const XSelectionRequestEvent &rq) { XSelectionEvent ev; XTextProperty ct; @@ -3382,13 +3382,13 @@ rxvt_term::selection_send (const XSelectionRequestEvent *rq) ev.type = SelectionNotify; ev.property = None; - ev.display = rq->display; - ev.requestor = rq->requestor; - ev.selection = rq->selection; - ev.target = rq->target; - ev.time = rq->time; + ev.display = rq.display; + ev.requestor = rq.requestor; + ev.selection = rq.selection; + ev.target = rq.target; + ev.time = rq.time; - if (rq->target == xa[XA_TARGETS]) + if (rq.target == xa[XA_TARGETS]) { Atom32 target_list[5]; Atom32 *target = target_list; @@ -3400,34 +3400,34 @@ rxvt_term::selection_send (const XSelectionRequestEvent *rq) #if X_HAVE_UTF8_STRING *target++ = (Atom32) xa[XA_UTF8_STRING]; #endif - XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_ATOM, + XChangeProperty(display->display, rq.requestor, rq.property, XA_ATOM, (8 * sizeof(target_list[0])), PropModeReplace, (unsigned char *)target_list, target - target_list); - ev.property = rq->property; + ev.property = rq.property; } - else if (rq->target == xa[XA_MULTIPLE]) + else if (rq.target == xa[XA_MULTIPLE]) { /* TODO: Handle MULTIPLE */ } - else if (rq->target == xa[XA_TIMESTAMP] && selection.text) + else if (rq.target == xa[XA_TIMESTAMP] && selection.text) { - XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_INTEGER, + XChangeProperty(display->display, rq.requestor, rq.property, XA_INTEGER, (8 * sizeof(Time)), PropModeReplace, (unsigned char *)&selection_time, 1); - ev.property = rq->property; + ev.property = rq.property; } - else if (rq->target == XA_STRING - || rq->target == xa[XA_TEXT] - || rq->target == xa[XA_COMPOUND_TEXT] - || rq->target == xa[XA_UTF8_STRING] + else if (rq.target == XA_STRING + || rq.target == xa[XA_TEXT] + || rq.target == xa[XA_COMPOUND_TEXT] + || rq.target == xa[XA_UTF8_STRING] ) { short freect = 0; int selectlen; char *cl; - target = rq->target; + target = rq.target; if (target == XA_STRING) // we actually don't do XA_STRING, but who cares, as i18n clients @@ -3458,7 +3458,7 @@ rxvt_term::selection_send (const XSelectionRequestEvent *rq) selectlen = 0; } - if (XmbTextListToTextProperty(Xdisplay, &cl, 1, style, &ct) >= 0) + if (XmbTextListToTextProperty(display->display, &cl, 1, style, &ct) >= 0) freect = 1; else { @@ -3467,15 +3467,15 @@ rxvt_term::selection_send (const XSelectionRequestEvent *rq) ct.nitems = selectlen; } - XChangeProperty(Xdisplay, rq->requestor, rq->property, - target, 8, PropModeReplace, - ct.value, (int)ct.nitems); - ev.property = rq->property; + XChangeProperty (display->display, rq.requestor, rq.property, + target, 8, PropModeReplace, + ct.value, (int)ct.nitems); + ev.property = rq.property; if (freect) XFree (ct.value); } - XSendEvent(Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); + XSendEvent (display->display, rq.requestor, False, 0L, (XEvent *)&ev); } /* ------------------------------------------------------------------------- * @@ -3501,7 +3501,7 @@ rxvt_term::set_position (XPoint *pos) { XWindowAttributes xwa; - XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa); + XGetWindowAttributes (display->display, TermWin.vt, &xwa); pos->x = Col2Pixel (screen.cur.col) + xwa.x; pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; } diff --git a/src/scrollbar-next.C b/src/scrollbar-next.C index 4c73bb72..d9c4041a 100644 --- a/src/scrollbar-next.C +++ b/src/scrollbar-next.C @@ -123,7 +123,7 @@ rxvt_term::renderPixmap (const char *const *data, int width, int height) Pixmap d; GC pointcolour; - d = XCreatePixmap(Xdisplay, scrollBar.win, width, height, XDEPTH); + d = XCreatePixmap(display->display, scrollBar.win, width, height, XDEPTH); for (y = 0; y < height; y++) { @@ -137,7 +137,7 @@ rxvt_term::renderPixmap (const char *const *data, int width, int height) pointcolour = darkGC; else /* if (a == '#' || a == 'b' || a) */ pointcolour = blackGC; - XDrawPoint(Xdisplay, d, pointcolour, x, y); + XDrawPoint(display->display, d, pointcolour, x, y); } } return d; @@ -154,11 +154,11 @@ rxvt_term::init_scrollbar_stuff () gcvalue.graphics_exposures = False; gcvalue.foreground = PixColors[Color_Black]; - blackGC = XCreateGC(Xdisplay, scrollBar.win, + blackGC = XCreateGC(display->display, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); gcvalue.foreground = PixColors[Color_White]; - whiteGC = XCreateGC(Xdisplay, scrollBar.win, + whiteGC = XCreateGC(display->display, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0xaeba; @@ -167,7 +167,7 @@ rxvt_term::init_scrollbar_stuff () //if (!rXAllocColor (&xcol, "light gray"))//TODO//D// xcol.pixel = PixColors[Color_AntiqueWhite]; light = gcvalue.foreground = xcol.pixel; - grayGC = XCreateGC(Xdisplay, scrollBar.win, + grayGC = XCreateGC(display->display, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0x51aa; @@ -176,10 +176,10 @@ rxvt_term::init_scrollbar_stuff () //if (!rXAllocColor (&xcol, "dark gray"))//TODO//D// xcol.pixel = PixColors[Color_Grey25]; dark = gcvalue.foreground = xcol.pixel; - darkGC = XCreateGC(Xdisplay, scrollBar.win, + darkGC = XCreateGC(display->display, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); - stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win, + stipple = XCreateBitmapFromData(display->display, scrollBar.win, (char *)n_stp_bits, n_stp_width, n_stp_height); @@ -188,9 +188,9 @@ rxvt_term::init_scrollbar_stuff () gcvalue.fill_style = FillOpaqueStippled; gcvalue.stipple = stipple; - /* XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[Color_Red]); */ + /* XSetWindowBackground(display->display, scrollBar.win, PixColors[Color_Red]); */ - stippleGC = XCreateGC(Xdisplay, scrollBar.win, + stippleGC = XCreateGC(display->display, scrollBar.win, GCForeground | GCBackground | GCStipple | GCFillStyle | GCGraphicsExposures, &gcvalue); @@ -216,15 +216,15 @@ rxvt_term::drawBevel (Drawable d, int x1, int y1, int w, int h) x2 = x1 + w - 1; /* right point */ y2 = y1 + h - 1; /* bottom point */ /* white top and left */ - XDrawLine(Xdisplay, d, whiteGC, x1, y1, x2, y1); - XDrawLine(Xdisplay, d, whiteGC, x1, y1, x1, y2); + XDrawLine(display->display, d, whiteGC, x1, y1, x2, y1); + XDrawLine(display->display, d, whiteGC, x1, y1, x1, y2); /* black bottom and right */ - XDrawLine(Xdisplay, d, blackGC, x1, y2, x2, y2); - XDrawLine(Xdisplay, d, blackGC, x2, y1, x2, y2); + XDrawLine(display->display, d, blackGC, x1, y2, x2, y2); + XDrawLine(display->display, d, blackGC, x2, y1, x2, y2); /* dark inside bottom and right */ x1++, y1++, x2--, y2--; /* move in one point */ - XDrawLine(Xdisplay, d, darkGC, x1, y2, x2, y2); - XDrawLine(Xdisplay, d, darkGC, x2, y1, x2, y2); + XDrawLine(display->display, d, darkGC, x1, y2, x2, y2); + XDrawLine(display->display, d, darkGC, x2, y1, x2, y2); } int @@ -241,28 +241,28 @@ rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scro if (TermWin.nscrolled == 0 || !update) { - XFillRectangle(Xdisplay, scrollBar.win, grayGC, 0, 0, + XFillRectangle(display->display, scrollBar.win, grayGC, 0, 0, SB_WIDTH_NEXT + 1, height); - XDrawRectangle(Xdisplay, scrollBar.win, blackGC, 0, + XDrawRectangle(display->display, scrollBar.win, blackGC, 0, -SB_BORDER_WIDTH, SB_WIDTH_NEXT, height + SB_BORDER_WIDTH); - XFillRectangle(Xdisplay, scrollBar.win, stippleGC, + XFillRectangle(display->display, scrollBar.win, stippleGC, SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height); } if (TermWin.nscrolled) { if (last_top < scrollBar.top || !update) - XFillRectangle(Xdisplay, scrollBar.win, stippleGC, + XFillRectangle(display->display, scrollBar.win, stippleGC, SB_LEFT_PADDING, SB_PADDING + last_top, SB_BUTTON_WIDTH, scrollBar.top - last_top); if (scrollBar.bot < last_bot || !update) - XFillRectangle(Xdisplay, scrollBar.win, stippleGC, + XFillRectangle(display->display, scrollBar.win, stippleGC, SB_LEFT_PADDING, scrollBar.bot + SB_PADDING, SB_BUTTON_WIDTH, (last_bot - scrollBar.bot)); - XFillRectangle(Xdisplay, scrollBar.win, grayGC, + XFillRectangle(display->display, scrollBar.win, grayGC, SB_LEFT_PADDING, scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH, scrollbar_len); - XCopyArea(Xdisplay, dimple, scrollBar.win, whiteGC, 0, 0, + XCopyArea(display->display, 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 + @@ -279,12 +279,12 @@ rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scro SB_BUTTON_HEIGHT); s = (scrollbar_isUp()) ? upArrowHi : upArrow; - XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0, + XCopyArea(display->display, 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; - XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0, + XCopyArea(display->display, s, scrollBar.win, whiteGC, 0, 0, ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); } diff --git a/src/scrollbar-plain.C b/src/scrollbar-plain.C index 48115c46..d4fad2bb 100644 --- a/src/scrollbar-plain.C +++ b/src/scrollbar-plain.C @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: scrollbar-plain.c *----------------------------------------------------------------------* * @@ -30,38 +30,38 @@ int rxvt_term::scrollbar_show_plain (int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) { - int xsb = 0; - int sbwidth = scrollBar.width - 1; + int xsb = 0; + int sbwidth = scrollBar.width - 1; if ((scrollBar.init & R_SB_PLAIN) == 0) { - XGCValues gcvalue; + XGCValues gcvalue; scrollBar.init |= R_SB_PLAIN; gcvalue.foreground = PixColors[Color_fg]; gcvalue.background = PixColors[Color_bg]; - pscrollbarGC = XCreateGC(Xdisplay, scrollBar.win, - GCForeground | GCBackground - | GCFillStyle, &gcvalue); + pscrollbarGC = XCreateGC (display->display, scrollBar.win, + GCForeground | GCBackground, &gcvalue); } - /* instead of XClearWindow (Xdisplay, scrollBar.win); */ + /* instead of XClearWindow (display->display, scrollBar.win); */ xsb = (Options & Opt_scrollBar_right) ? 1 : 0; if (last_top < scrollBar.top) - XClearArea(Xdisplay, scrollBar.win, - sb_shadow + xsb, last_top, - sbwidth + 1, (scrollBar.top - last_top), False); + XClearArea (display->display, scrollBar.win, + sb_shadow + xsb, last_top, + sbwidth + 1, (scrollBar.top - last_top), False); if (scrollBar.bot < last_bot) - XClearArea(Xdisplay, scrollBar.win, - sb_shadow + xsb, scrollBar.bot, - sbwidth + 1, (last_bot - scrollBar.bot), False); + XClearArea (display->display, scrollBar.win, + sb_shadow + xsb, scrollBar.bot, + sbwidth + 1, (last_bot - scrollBar.bot), False); /* scrollbar slider */ - XFillRectangle(Xdisplay, scrollBar.win, pscrollbarGC, - xsb + 1, scrollBar.top, sbwidth, scrollbar_len); + XFillRectangle (display->display, scrollBar.win, pscrollbarGC, + xsb + 1, scrollBar.top, sbwidth, scrollbar_len); return 1; } -#endif /* XTERM_SCROLLBAR */ -/*----------------------- end-of-file (C source) -----------------------*/ + +#endif + diff --git a/src/scrollbar-rxvt.C b/src/scrollbar-rxvt.C index 5d93de07..48675415 100644 --- a/src/scrollbar-rxvt.C +++ b/src/scrollbar-rxvt.C @@ -66,17 +66,17 @@ rxvt_term::Draw_button (int x, int y, int state, int dirn) pt[0].y = pt[1].y = y; pt[2].y = y + sz - 1; } - XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC, + XFillPolygon(display->display, scrollBar.win, scrollbarGC, pt, 3, Convex, CoordModeOrigin); /* draw base */ - XDrawLine(Xdisplay, scrollBar.win, (dirn == UP ? bot : top), + XDrawLine(display->display, scrollBar.win, (dirn == UP ? bot : top), pt[0].x, pt[0].y, pt[1].x, pt[1].y); /* draw shadow on left */ pt[1].x = x + sz2 - 1; pt[1].y = y + (dirn == UP ? 0 : sz - 1); - XDrawLine(Xdisplay, scrollBar.win, top, + XDrawLine(display->display, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); #if (SHADOW > 1) @@ -92,7 +92,7 @@ rxvt_term::Draw_button (int x, int y, int state, int dirn) pt[0].y++; pt[1].y--; } - XDrawLine(Xdisplay, scrollBar.win, top, + XDrawLine(display->display, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); #endif /* draw shadow on right */ @@ -100,7 +100,7 @@ rxvt_term::Draw_button (int x, int y, int state, int dirn) /* pt[2].x = x + sz2; */ pt[1].y = y + (dirn == UP ? sz - 1 : 0); pt[2].y = y + (dirn == UP ? 0 : sz - 1); - XDrawLine(Xdisplay, scrollBar.win, bot, + XDrawLine(display->display, scrollBar.win, bot, pt[2].x, pt[2].y, pt[1].x, pt[1].y); #if (SHADOW > 1) /* doubled */ @@ -115,7 +115,7 @@ rxvt_term::Draw_button (int x, int y, int state, int dirn) pt[2].y--; pt[1].y++; } - XDrawLine(Xdisplay, scrollBar.win, bot, + XDrawLine(display->display, scrollBar.win, bot, pt[2].x, pt[2].y, pt[1].x, pt[1].y); #endif } @@ -134,22 +134,22 @@ rxvt_term::scrollbar_show_rxvt (int update __attribute__((unused)), int last_top gcvalue.foreground = PixColors[Color_trough]; if (sbshadow) { - XSetWindowBackground(Xdisplay, scrollBar.win, + XSetWindowBackground(display->display, scrollBar.win, gcvalue.foreground); - XClearWindow(Xdisplay, scrollBar.win); + XClearWindow(display->display, scrollBar.win); } } else { - /* instead of XClearWindow (Xdisplay, scrollBar.win); */ + /* instead of XClearWindow (display->display, scrollBar.win); */ if (last_top < scrollBar.top) - XClearArea(Xdisplay, scrollBar.win, + XClearArea(display->display, scrollBar.win, sbshadow, last_top, sbwidth, (scrollBar.top - last_top), False); if (scrollBar.bot < last_bot) - XClearArea(Xdisplay, scrollBar.win, + XClearArea(display->display, scrollBar.win, sbshadow, scrollBar.bot, sbwidth, (last_bot - scrollBar.bot), False); @@ -165,23 +165,23 @@ rxvt_term::scrollbar_show_rxvt (int update __attribute__((unused)), int last_top else xofs = sbshadow ? sbwidth : sbwidth - 1; - XDrawLine(Xdisplay, scrollBar.win, botShadowGC, + XDrawLine(display->display, scrollBar.win, botShadowGC, xofs, 0, xofs, scrollBar.end + sbwidth); } #endif - XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC, + XFillRectangle(display->display, scrollBar.win, scrollbarGC, sbshadow, scrollBar.top, sbwidth, scrollbar_len); if (sbshadow) /* trough shadow */ - rxvt_Draw_Shadow(Xdisplay, scrollBar.win, + rxvt_Draw_Shadow(display->display, scrollBar.win, botShadowGC, topShadowGC, 0, 0, sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */ scrollBar.end + (sbwidth + 1) + sbshadow); /* shadow for scrollbar slider */ - rxvt_Draw_Shadow(Xdisplay, scrollBar.win, + rxvt_Draw_Shadow(display->display, scrollBar.win, topShadowGC, botShadowGC, sbshadow, scrollBar.top, sbwidth, scrollbar_len); diff --git a/src/scrollbar-xterm.C b/src/scrollbar-xterm.C index c85c0d67..c48ec2fb 100644 --- a/src/scrollbar-xterm.C +++ b/src/scrollbar-xterm.C @@ -42,7 +42,7 @@ rxvt_term::scrollbar_show_xterm (int update __attribute__((unused)), int last_to XGCValues gcvalue; scrollBar.init |= R_SB_XTERM; - gcvalue.stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win, + gcvalue.stipple = XCreateBitmapFromData(display->display, scrollBar.win, (char *)x_stp_bits, x_stp_width, x_stp_height); if (!gcvalue.stipple) @@ -54,29 +54,29 @@ rxvt_term::scrollbar_show_xterm (int update __attribute__((unused)), int last_to gcvalue.foreground = PixColors[Color_fg]; gcvalue.background = PixColors[Color_bg]; - xscrollbarGC = XCreateGC(Xdisplay, scrollBar.win, + xscrollbarGC = XCreateGC(display->display, scrollBar.win, GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); gcvalue.foreground = PixColors[Color_border]; - ShadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue); + ShadowGC = XCreateGC(display->display, scrollBar.win, GCForeground, &gcvalue); } - /* instead of XClearWindow (Xdisplay, scrollBar.win); */ + /* instead of XClearWindow (display->display, scrollBar.win); */ xsb = (Options & Opt_scrollBar_right) ? 1 : 0; if (last_top < scrollBar.top) - XClearArea(Xdisplay, scrollBar.win, + XClearArea(display->display, scrollBar.win, sb_shadow + xsb, last_top, sbwidth, (scrollBar.top - last_top), False); if (scrollBar.bot < last_bot) - XClearArea(Xdisplay, scrollBar.win, + XClearArea(display->display, scrollBar.win, sb_shadow + xsb, scrollBar.bot, sbwidth, (last_bot - scrollBar.bot), False); /* scrollbar slider */ - XFillRectangle(Xdisplay, scrollBar.win, xscrollbarGC, + XFillRectangle(display->display, scrollBar.win, xscrollbarGC, xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len); - XDrawLine(Xdisplay, scrollBar.win, ShadowGC, + XDrawLine(display->display, scrollBar.win, ShadowGC, xsb ? 0 : sbwidth, scrollBar.beg, xsb ? 0 : sbwidth, scrollBar.end); return 1; diff --git a/src/scrollbar.C b/src/scrollbar.C index e8f6b199..641da58d 100644 --- a/src/scrollbar.C +++ b/src/scrollbar.C @@ -44,14 +44,14 @@ rxvt_term::scrollbar_mapping (int map) resize_scrollbar (); if (scrollBar.win) { - XMapWindow(Xdisplay, scrollBar.win); + XMapWindow(display->display, scrollBar.win); change = 1; } } else if (!map && scrollbar_visible()) { scrollBar.state = 0; - XUnmapWindow(Xdisplay, scrollBar.win); + XUnmapWindow(display->display, scrollBar.win); change = 1; } #endif @@ -109,7 +109,7 @@ rxvt_term::resize_scrollbar () if (!scrollBar.win) { /* create the scrollbar window */ - scrollBar.win = XCreateSimpleWindow(Xdisplay, + scrollBar.win = XCreateSimpleWindow(display->display, TermWin.parent[0], window_sb_x, 0, scrollbar_TotalWidth(), @@ -118,18 +118,23 @@ rxvt_term::resize_scrollbar () PixColors[Color_fg], PixColors[Color_bg]); #ifdef DEBUG_X - XStoreName(Xdisplay, scrollBar.win, "scrollbar"); + XStoreName(display->display, scrollBar.win, "scrollbar"); #endif - XDefineCursor(Xdisplay, scrollBar.win, leftptr_cursor); - XSelectInput(Xdisplay, scrollBar.win, - (ExposureMask | ButtonPressMask | ButtonReleaseMask - | Button1MotionMask | Button2MotionMask - | Button3MotionMask)); + XDefineCursor(display->display, scrollBar.win, leftptr_cursor); + + XSelectInput(display->display, scrollBar.win, + ExposureMask | ButtonPressMask | ButtonReleaseMask + | Button1MotionMask | Button2MotionMask + | Button3MotionMask); + scrollbar_ev.start (display, scrollBar.win); + delayed_init = 1; } + scrollbar_show (1); + if (delayed_init) - XMapWindow (Xdisplay, scrollBar.win); + XMapWindow (display->display, scrollBar.win); #endif } diff --git a/src/version.h b/src/version.h index 85130425..ac395beb 100644 --- a/src/version.h +++ b/src/version.h @@ -1,5 +1,5 @@ -#define VERSION "1.8" -#define VSTRING "10800" +#define VERSION "1.9" +#define VSTRING "10900" #define DATE "2004-02-02" #define LSMDATE "02FEB04" -#define LIBVERSION "1:8:0" +#define LIBVERSION "1:9:0" diff --git a/src/xpm.C b/src/xpm.C index 273273cc..772b9ea5 100644 --- a/src/xpm.C +++ b/src/xpm.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: xpm.c *----------------------------------------------------------------------* - * $Id: xpm.C,v 1.7 2004-02-01 01:34:41 pcg Exp $ + * $Id: xpm.C,v 1.8 2004-02-09 07:11:49 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1997 Carsten Haitzler @@ -166,19 +166,19 @@ rxvt_term::resize_pixmap () unsigned int height = TermWin_TotalHeight(); if (TermWin.pixmap != None) - XFreePixmap(Xdisplay, TermWin.pixmap); + XFreePixmap(display->display, TermWin.pixmap); if (bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ TermWin.pixmap = None; if (!(Options & Opt_transparent) || am_transparent == 0) - XSetWindowBackground(Xdisplay, TermWin.vt, + XSetWindowBackground(display->display, TermWin.vt, PixColors[Color_bg]); return; } gcvalue.foreground = PixColors[Color_bg]; - gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue); + gc = XCreateGC(display->display, TermWin.vt, GCForeground, &gcvalue); if (bgPixmap.pixmap != None) { /* we have a specified pixmap */ @@ -199,10 +199,10 @@ rxvt_term::resize_pixmap () if (w == 0) { /* basic X tiling - let the X server do it */ - TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt, + TermWin.pixmap = XCreatePixmap(display->display, TermWin.vt, xpmw, xpmh, (unsigned int)XDEPTH); - XCopyArea(Xdisplay, bgPixmap.pixmap, TermWin.pixmap, gc, + XCopyArea(display->display, bgPixmap.pixmap, TermWin.pixmap, gc, 0, 0, xpmw, xpmh, 0, 0); } else @@ -210,7 +210,7 @@ rxvt_term::resize_pixmap () float incr, p; Pixmap tmp; - TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt, + TermWin.pixmap = XCreatePixmap(display->display, TermWin.vt, width, height, (unsigned int)XDEPTH); /* @@ -218,9 +218,9 @@ rxvt_term::resize_pixmap () */ rxvt_pixmap_incr(&w, &x, &incr, &p, width, xpmw); - tmp = XCreatePixmap(Xdisplay, TermWin.vt, + tmp = XCreatePixmap(display->display, TermWin.vt, width, xpmh, (unsigned int)XDEPTH); - XFillRectangle(Xdisplay, tmp, gc, 0, 0, width, + XFillRectangle(display->display, tmp, gc, 0, 0, width, xpmh); for ( /*nil */ ; x < w; x++, p += incr) @@ -228,7 +228,7 @@ rxvt_term::resize_pixmap () if (p >= xpmw) p = 0; /* copy one column from the original pixmap to the tmp pixmap */ - XCopyArea(Xdisplay, bgPixmap.pixmap, tmp, gc, + XCopyArea(display->display, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0); } @@ -238,29 +238,29 @@ rxvt_term::resize_pixmap () rxvt_pixmap_incr(&h, &y, &incr, &p, height, xpmh); if (y > 0) - XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, 0, width, + XFillRectangle(display->display, TermWin.pixmap, gc, 0, 0, width, y); if (h < height) - XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, (int)h, + XFillRectangle(display->display, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1); for ( /*nil */ ; y < h; y++, p += incr) { if (p >= xpmh) p = 0; /* copy one row from the tmp pixmap to the main pixmap */ - XCopyArea(Xdisplay, tmp, TermWin.pixmap, gc, + XCopyArea(display->display, tmp, TermWin.pixmap, gc, 0, (int)p, width, 1, 0, (int)y); } - XFreePixmap(Xdisplay, tmp); + XFreePixmap(display->display, tmp); } } - XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, TermWin.pixmap); - XFreeGC(Xdisplay, gc); + XSetWindowBackgroundPixmap(display->display, TermWin.vt, TermWin.pixmap); + XFreeGC(display->display, gc); am_transparent = 0; - XClearWindow(Xdisplay, TermWin.vt); + XClearWindow(display->display, TermWin.vt); - XSync(Xdisplay, False); + XSync(display->display, False); } /* @@ -349,10 +349,10 @@ rxvt_term::set_bgPixmap (const char *file) if (bgPixmap.pixmap != None) { - XFreePixmap(Xdisplay, bgPixmap.pixmap); + XFreePixmap(display->display, bgPixmap.pixmap); bgPixmap.pixmap = None; } - XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[Color_bg]); + XSetWindowBackground(display->display, TermWin.vt, PixColors[Color_bg]); if (*file != '\0') { @@ -361,7 +361,7 @@ rxvt_term::set_bgPixmap (const char *file) /* * we already have the required attributes */ - /* XGetWindowAttributes(Xdisplay, TermWin.vt, &attr); */ + /* XGetWindowAttributes(display->display, TermWin.vt, &attr); */ xpmAttr.closeness = 30000; xpmAttr.colormap = XCMAP; @@ -373,7 +373,7 @@ rxvt_term::set_bgPixmap (const char *file) /* search environment variables here too */ f = (char *)rxvt_File_find(file, ".xpm", rs[Rs_path]); if (f == NULL - || XpmReadFileToPixmap(Xdisplay, Xroot, f, + || XpmReadFileToPixmap(display->display, display->root, f, &bgPixmap.pixmap, NULL, &xpmAttr)) { -- 2.34.1