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
-# $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
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
}
}
+#ifdef TRANSPARENT
void
rxvt_term::rootwin_cb (XEvent &ev)
{
want_full_refresh = 1;
}
}
+#endif
void
rxvt_term::button_press (const XButtonEvent &ev)
#include <cstdlib>
-#define DISPLAY r->Xdisplay
+#define DISPLAY r->display->display
#define DRAWABLE r->TermWin.vt
#define GC r->TermWin.gc
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);
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;
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
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 */
putenv ("TERMINFO=" RXVT_TERMINFO);
#endif
- if (Xdepth <= 2)
+ if (display->depth <= 2)
putenv ("COLORTERM=" COLORTERMENV "-mono");
else
putenv ("COLORTERM=" COLORTERMENVFULL);
{
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));
}
/* 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
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
greek_init();
#endif
- Xfd = XConnectionNumber (Xdisplay);
-
#ifdef CURSOR_BLINK
-
if (Options & Opt_cursorBlink)
(void)gettimeofday (&lastcursorchange, NULL);
#endif
{
#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];
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)))
&& 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++)
{
{
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];
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 */
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,
: 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
#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(),
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))
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
}
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) */
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
#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() */
#endif
template<class watcher>
-struct io_manager_vec : protected vector<watcher *> {
- friend class io_manager;
-protected:
+struct io_manager_vec : vector<watcher *> {
#if IOM_CHECK
bool activity;
#endif
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
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;
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
return GET_R;
}
+static int (*old_xerror_handler)(Display *dpy, XErrorEvent *event);
+
void
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);
}
#if 0
#ifdef DEBUG_X
- XSynchronize(Xdisplay, True);
+ XSynchronize(display->display, True);
#endif
#endif
#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;
}
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 ();
}
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;
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
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
}
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,
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
/* 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. */
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
}
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;
#endif
window_calc (width, height);
- XSetWMNormalHints (Xdisplay, TermWin.parent[0], &szHint);
+ XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
if (!ignoreparent)
{
#ifdef SMART_RESIZE
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)
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;
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
{
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
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)
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;
}
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);
}
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;
break; /* neutral */
}
- rxvt_Draw_Shadow(Xdisplay, menuBar.win, top, bot,
+ rxvt_Draw_Shadow(display->display, menuBar.win, top, bot,
x, 0, len, menuBar_TotalHeight());
}
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');
}
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
}
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);
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);
{
#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);
}
{
#ifdef USE_XIM
if (TermWin.fontset)
- XmbDrawString(Xdisplay,
+ XmbDrawString(display->display,
ActiveMenu->win, TermWin.fontset,
gc,
ActiveMenu->w - (xoff + Width2Pixel(xright)),
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);
if (ActiveMenu == NULL)
return;
if (ActiveMenu->win != None)
- XDestroyWindow(Xdisplay, ActiveMenu->win);
+ XDestroyWindow(display->display, ActiveMenu->win);
ActiveMenu->win = None;
ActiveMenu->item = NULL;
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
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 ();
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);
{
#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);
}
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
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);
break;
case MotionNotify:
- while (XCheckTypedWindowEvent(Xdisplay, TermWin.parent[0],
+ while (XCheckTypedWindowEvent(display->display, TermWin.parent[0],
MotionNotify, (XEvent *) ev)) ;
if (ActiveMenu)
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);
#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;
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
#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
(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
#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)
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;
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);
/* 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 ();
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
#include "../config.h"
#include <rxvt.h>
+#include <rxvtcolor.h>
-// TODO: free colors again
+#include <unistd.h>
+#include <fcntl.h>
+/////////////////////////////////////////////////////////////////////////////
+
+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;
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
}
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;
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;
XColor c;
c.pixel = p;
- XQueryColor (t->Xdisplay, t->Xcmap, &c);
+ XQueryColor (display->display, display->cmap, &c);
cr = c.red;
cg = c.green;
#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
+}
+
# include <X11/Xft/Xft.h>
#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<xevent_watcher> 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<void, XEvent &> {
+ Window window;
+
+ template<class O1, class O2>
+ xevent_watcher (O1 *object, void (O2::*method)(XEvent &))
+ : callback1<void, XEvent &>(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<rxvt_display *> 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
#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 <stdio.h>
#include <ctype.h>
#include <errno.h>
/* 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;
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;
template<typename T>
struct vector : simplevec<T>
-{
-};
+{ };
#if 0
template<typename T>
#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))
{
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++)
{
#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);
# ifdef MAPALERT_OPTION
if (Options & Opt_mapAlert)
# endif
- XMapWindow(Xdisplay, TermWin.parent[0]);
+ XMapWindow(display->display, TermWin.parent[0]);
# endif
if (Options & Opt_visualBell)
{
scr_rvideo_mode (!rvideo); /* refresh also done */
}
else
- XBell(Xdisplay, 0);
+ XBell(display->display, 0);
#endif
}
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),
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....) */
{
#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),
* 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)
* 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;
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);
}
/* ------------------------------------------------------------------------- */
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,
* 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 */
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++)
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)
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;
}
}
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
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;
}
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");
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);
}
* EXT: SelectionRequest
*/
void
-rxvt_term::selection_send (const XSelectionRequestEvent *rq)
+rxvt_term::selection_send (const XSelectionRequestEvent &rq)
{
XSelectionEvent ev;
XTextProperty ct;
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;
#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
selectlen = 0;
}
- if (XmbTextListToTextProperty(Xdisplay, &cl, 1, style, &ct) >= 0)
+ if (XmbTextListToTextProperty(display->display, &cl, 1, style, &ct) >= 0)
freect = 1;
else
{
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);
}
\f
/* ------------------------------------------------------------------------- *
{
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;
}
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++)
{
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;
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;
//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;
//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);
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);
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
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 +
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);
}
-/*--------------------------------*-C-*---------------------------------*
+/*----------------------------------------------------------------------*
* File: scrollbar-plain.c
*----------------------------------------------------------------------*
*
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
+
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)
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 */
/* 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 */
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
}
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);
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);
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)
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;
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
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(),
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
}
-#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"
/*--------------------------------*-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 <raster@zip.com.au>
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 */
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
float incr, p;
Pixmap tmp;
- TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
+ TermWin.pixmap = XCreatePixmap(display->display, TermWin.vt,
width, height,
(unsigned int)XDEPTH);
/*
*/
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)
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);
}
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);
}
/*
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')
{
/*
* we already have the required attributes
*/
- /* XGetWindowAttributes(Xdisplay, TermWin.vt, &attr); */
+ /* XGetWindowAttributes(display->display, TermWin.vt, &attr); */
xpmAttr.closeness = 30000;
xpmAttr.colormap = XCMAP;
/* 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))
{