repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: a1d4ebf7f84474f8e2ff6da9dbc09f32861f6e33: path_to: revision_to:
commit a1d4ebf7f84474f8e2ff6da9dbc09f32861f6e33 Author: Marc LehmannDate: Mon Feb 9 07:11:49 2004 +0000 *** empty log message *** diff --git a/Changes b/Changes
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+1.9
+ - fixed bug in plain scrollbar causing x errors in XCreateGC.
+
1.8 Mon Feb 2 20:09:18 CET 2004
- almost total conversion to C++. Except for introducing
new bugs, this should not change much.
diff --git a/src/Makefile.in b/src/Makefile.in
--- 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
--- a/src/command.C
+++ b/src/command.C
@@ -55,7 +55,7 @@
/*{{{ Convert the keypress event into a string */
void
-rxvt_term::lookup_key (XKeyEvent *ev)
+rxvt_term::lookup_key (XKeyEvent &ev)
{
int ctrl, meta, shft, len;
unsigned int newlen;
@@ -72,13 +72,13 @@ rxvt_term::lookup_key (XKeyEvent *ev)
*
* Always permit `shift' to override the current setting
*/
- shft = (ev->state & ShiftMask);
- ctrl = (ev->state & ControlMask);
- meta = (ev->state & ModMetaMask);
+ shft = (ev.state & ShiftMask);
+ ctrl = (ev.state & ControlMask);
+ meta = (ev.state & ModMetaMask);
- if (numlock_state || (ev->state & ModNumLockMask))
+ if (numlock_state || (ev.state & ModNumLockMask))
{
- numlock_state = (ev->state & ModNumLockMask);
+ numlock_state = (ev.state & ModNumLockMask);
PrivMode((!numlock_state), PrivMode_aplKP);
}
@@ -91,7 +91,7 @@ rxvt_term::lookup_key (XKeyEvent *ev)
#ifdef X_HAVE_UTF8_STRING
if (enc_utf8 && 0)
- len = Xutf8LookupString (Input_Context, ev, (char *)kbuf,
+ len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf,
KBUFSZ, &keysym, &status_return);
else
#endif
@@ -104,7 +104,7 @@ rxvt_term::lookup_key (XKeyEvent *ev)
if (rs[Rs_imLocale])
SET_LOCALE (rs[Rs_imLocale]);
// assume wchar_t == unicode or better
- len = XwcLookupString (Input_Context, ev, wkbuf,
+ len = XwcLookupString (Input_Context, &ev, wkbuf,
KBUFSZ, &keysym, &status_return);
if (rs[Rs_imLocale])
SET_LOCALE (locale);
@@ -128,7 +128,7 @@ rxvt_term::lookup_key (XKeyEvent *ev)
#endif
{
- len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &compose);
+ len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose);
valid_keysym = !len;
}
@@ -229,7 +229,7 @@ rxvt_term::lookup_key (XKeyEvent *ev)
{
/* normal XTerm key bindings */
case XK_Insert: /* Shift+Insert = paste mouse selection */
- selection_request (ev->time, 0, 0);
+ selection_request (ev.time, 0, 0);
return;
/* rxvt extras */
case XK_KP_Add: /* Shift+KP_Add = bigger font */
@@ -344,7 +344,7 @@ rxvt_term::lookup_key (XKeyEvent *ev)
meta = 1;
#endif
#ifdef MOD4_TAB_MAKES_META
- if (ev->state & Mod4Mask)
+ if (ev.state & Mod4Mask)
meta = 1;
#endif
newlen = 0;
@@ -755,7 +755,7 @@ rxvt_term::flush ()
}
- XFlush (Xdisplay);
+ XFlush (display->display);
}
void
@@ -767,50 +767,6 @@ rxvt_term::check_cb (check_watcher &w)
flush ();
}
-void
-rxvt_term::process_x_events ()
-{
- do
- {
- XEvent xev;
-
- XNextEvent (Xdisplay, &xev);
-
-#if defined(CURSOR_BLINK)
- if ((Options & Opt_cursorBlink) && xev.type == KeyPress)
- {
- if (hidden_cursor)
- {
- hidden_cursor = 0;
- want_refresh = 1;
- }
-
- cursor_blink_ev.start (NOW + BLINK_INTERVAL);
- }
-#endif
-
-#if defined(POINTER_BLANK)
- if ((Options & Opt_pointerBlank) && pointerBlankDelay > 0)
- {
- if (xev.type == MotionNotify
- || xev.type == ButtonPress
- || xev.type == ButtonRelease)
- if (hidden_pointer)
- pointer_unblank ();
-
- if (xev.type == KeyPress && hidden_pointer == 0)
- pointer_blank ();
- }
-#endif
-
-#ifdef USE_XIM
- if (!XFilterEvent (&xev, xev.xany.window))
-#endif
- process_x_event (&xev);
- }
- while (XPending (Xdisplay));
-}
-
#ifdef CURSOR_BLINK
void
rxvt_term::cursor_blink_cb (time_watcher &w)
@@ -835,15 +791,6 @@ rxvt_term::text_blink_cb (time_watcher &w)
}
#endif
-void
-rxvt_term::x_cb (io_watcher &w, short revents)
-{
- SET_R (this);
- SET_LOCALE (locale);
-
- process_x_events ();
-}
-
bool
rxvt_term::pty_fill ()
{
@@ -1044,7 +991,7 @@ rxvt_term::cmd_getc ()
void
rxvt_term::pointer_unblank ()
{
- XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor);
+ XDefineCursor (display->display, TermWin.vt, TermWin_cursor);
recolour_cursor ();
hidden_pointer = 0;
@@ -1059,8 +1006,8 @@ rxvt_term::pointer_blank ()
if (!(Options & Opt_pointerBlank))
return;
- XDefineCursor (Xdisplay, TermWin.vt, blank_cursor);
- XFlush (Xdisplay);
+ XDefineCursor (display->display, TermWin.vt, blank_cursor);
+ XFlush (display->display);
hidden_pointer = 1;
}
@@ -1076,13 +1023,13 @@ rxvt_term::pointer_cb (time_watcher &w)
#endif
void
-rxvt_term::mouse_report (const XButtonEvent *ev)
+rxvt_term::mouse_report (const XButtonEvent &ev)
{
int button_number, key_state = 0;
int x, y;
- x = ev->x;
- y = ev->y;
+ x = ev.x;
+ y = ev.y;
pixel_position (&x, &y);
if (MEvent.button == AnyButton)
@@ -1151,16 +1098,51 @@ rxvt_term::mouse_report (const XButtonEvent *ev)
void
rxvt_W11_process_x_event(XEvent *ev)
{
- rxvt_t *r = rxvt_get_r();
+ rxvt_t *r = rxvt_get_r();
- process_x_event (ev);
+ x_cb (*ev);
}
#endif
/*{{{ process an X event */
void
-rxvt_term::process_x_event (XEvent *ev)
+rxvt_term::x_cb (XEvent &ev)
{
+ SET_R (this);
+ SET_LOCALE (locale);
+
+#if defined(CURSOR_BLINK)
+ if ((Options & Opt_cursorBlink) && ev.type == KeyPress)
+ {
+ if (hidden_cursor)
+ {
+ hidden_cursor = 0;
+ want_refresh = 1;
+ }
+
+ cursor_blink_ev.start (NOW + BLINK_INTERVAL);
+ }
+#endif
+
+#if defined(POINTER_BLANK)
+ if ((Options & Opt_pointerBlank) && pointerBlankDelay > 0)
+ {
+ if (ev.type == MotionNotify
+ || ev.type == ButtonPress
+ || ev.type == ButtonRelease)
+ if (hidden_pointer)
+ pointer_unblank ();
+
+ if (ev.type == KeyPress && hidden_pointer == 0)
+ pointer_blank ();
+ }
+#endif
+
+#ifdef USE_XIM
+ if (XFilterEvent (&ev, None))
+ return;
+#endif
+
Window unused_root, unused_child;
int unused_root_x, unused_root_y;
unsigned int unused_mask;
@@ -1211,25 +1193,25 @@ rxvt_term::process_x_event (XEvent *ev)
struct tm *ltt;
(void)gettimeofday(&tp, NULL);
ltt = localtime(&(tp.tv_sec));
- D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == TermWin.parent[0] ? "parent" : (ev->xany.window == TermWin.vt ? "vt" : (ev->xany.window == scrollBar.win ? "scroll" : (ev->xany.window == menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == TermWin.parent[0] ? TermWin.parent[0] : (ev->xany.window == TermWin.vt ? TermWin.vt : (ev->xany.window == scrollBar.win ? scrollBar.win : (ev->xany.window == menuBar.win ? menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial));
+ D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev.type], (ev.xany.window == TermWin.parent[0] ? "parent" : (ev.xany.window == TermWin.vt ? "vt" : (ev.xany.window == scrollBar.win ? "scroll" : (ev.xany.window == menuBar.win ? "menubar" : "UNKNOWN")))), (ev.xany.window == TermWin.parent[0] ? TermWin.parent[0] : (ev.xany.window == TermWin.vt ? TermWin.vt : (ev.xany.window == scrollBar.win ? scrollBar.win : (ev.xany.window == menuBar.win ? menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev.xany.send_event ? "S" : " ", ev.xany.serial));
#endif
- switch (ev->type)
+ switch (ev.type)
{
case KeyPress:
- lookup_key ((XKeyEvent *)ev);
+ lookup_key (ev.xkey);
break;
#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
case KeyRelease:
{
- if (!(ev->xkey.state & ControlMask))
+ if (!(ev.xkey.state & ControlMask))
mouse_slip_wheel_speed = 0;
else
{
KeySym ks;
- ks = XKeycodeToKeysym(Xdisplay, ev->xkey.keycode, 0);
+ ks = XKeycodeToKeysym(display->display, ev.xkey.keycode, 0);
if (ks == XK_Control_L || ks == XK_Control_R)
mouse_slip_wheel_speed = 0;
}
@@ -1238,23 +1220,23 @@ rxvt_term::process_x_event (XEvent *ev)
#endif
case ButtonPress:
- button_press ((XButtonEvent *)ev);
+ button_press (ev.xbutton);
break;
case ButtonRelease:
- button_release ((XButtonEvent *)ev);
+ button_release (ev.xbutton);
break;
case ClientMessage:
- if (ev->xclient.format == 32
- && (Atom)ev->xclient.data.l[0] == xa[XA_WMDELETEWINDOW])
+ if (ev.xclient.format == 32
+ && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW])
destroy ();
#ifdef OFFIX_DND
/* OffiX Dnd (drag 'n' drop) protocol */
- else if (ev->xclient.message_type == xa[XA_DNDPROTOCOL]
- && (ev->xclient.data.l[0] == DndFile
- || ev->xclient.data.l[0] == DndDir
- || ev->xclient.data.l[0] == DndLink))
+ else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL]
+ && (ev.xclient.data.l[0] == DndFile
+ || ev.xclient.data.l[0] == DndDir
+ || ev.xclient.data.l[0] == DndLink))
{
/* Get Dnd data */
Atom ActualType;
@@ -1262,25 +1244,25 @@ rxvt_term::process_x_event (XEvent *ev)
unsigned char *data;
unsigned long Size, RemainingBytes;
- XGetWindowProperty(Xdisplay, Xroot,
+ XGetWindowProperty(display->display, display->root,
xa[XA_DNDSELECTION],
0L, 1000000L,
False, AnyPropertyType,
&ActualType, &ActualFormat,
&Size, &RemainingBytes,
&data);
- XChangeProperty(Xdisplay, Xroot,
+ XChangeProperty(display->display, display->root,
XA_CUT_BUFFER0, XA_STRING,
8, PropModeReplace,
data, STRLEN(data));
- selection_paste (Xroot, XA_CUT_BUFFER0, True);
- XSetInputFocus(Xdisplay, Xroot, RevertToNone, CurrentTime);
+ selection_paste (display->root, XA_CUT_BUFFER0, True);
+ XSetInputFocus(display->display, display->root, RevertToNone, CurrentTime);
}
#endif /* OFFIX_DND */
break;
case MappingNotify:
- XRefreshKeyboardMapping(&(ev->xmapping));
+ XRefreshKeyboardMapping(&(ev.xmapping));
break;
/*
@@ -1294,7 +1276,7 @@ rxvt_term::process_x_event (XEvent *ev)
* which ought to make things real slow!
*/
case VisibilityNotify:
- switch (ev->xvisibility.state)
+ switch (ev.xvisibility.state)
{
case VisibilityUnobscured:
refresh_type = FAST_REFRESH;
@@ -1344,18 +1326,18 @@ rxvt_term::process_x_event (XEvent *ev)
break;
case ConfigureNotify:
- if (ev->xconfigure.window == TermWin.parent[0])
+ if (ev.xconfigure.window == TermWin.parent[0])
{
- int height, width;
+ int height, width;
do
{ /* Wrap lots of configures into one */
- width = ev->xconfigure.width;
- height = ev->xconfigure.height;
+ width = ev.xconfigure.width;
+ height = ev.xconfigure.height;
D_SIZE((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
}
- while (XCheckTypedWindowEvent(Xdisplay, ev->xconfigure.window,
- ConfigureNotify, ev));
+ while (XCheckTypedWindowEvent(display->display, ev.xconfigure.window, ConfigureNotify, &ev));
+
if (szHint.width != width || szHint.height != height)
{
D_SIZE((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height));
@@ -1385,12 +1367,12 @@ rxvt_term::process_x_event (XEvent *ev)
case SelectionNotify:
if (selection_wait == Sel_normal)
- selection_paste (ev->xselection.requestor,
- ev->xselection.property, True);
+ selection_paste (ev.xselection.requestor,
+ ev.xselection.property, True);
break;
case SelectionRequest:
- selection_send (&(ev->xselectionrequest));
+ selection_send (ev.xselectionrequest);
break;
case UnmapNotify:
@@ -1408,70 +1390,54 @@ rxvt_term::process_x_event (XEvent *ev)
break;
case PropertyNotify:
- if (ev->xproperty.atom == xa[XA_VT_SELECTION])
- {
- if (ev->xproperty.state == PropertyNewValue)
- selection_property (ev->xproperty.window,
- ev->xproperty.atom);
- break;
- }
+ if (ev.xproperty.atom == xa[XA_VT_SELECTION])
+ if (ev.xproperty.state == PropertyNewValue)
+ selection_property (ev.xproperty.window, ev.xproperty.atom);
+ break;
+
#ifdef TRANSPARENT
- /*
- * if user used some Esetroot compatible prog to set the root bg,
- * use the property to determine the pixmap. We use it later on.
- */
- if (xa[XA_XROOTPMAPID] == 0)
- xa[XA_XROOTPMAPID] = XInternAtom(Xdisplay,
- "_XROOTPMAP_ID", False);
- if (ev->xproperty.atom != xa[XA_XROOTPMAPID])
- break;
- /* FALLTHROUGH */
case ReparentNotify:
- if ((Options & Opt_transparent) && check_our_parents ())
- {
- if (am_transparent)
- want_full_refresh = 1;
- }
-#endif /* TRANSPARENT */
+ rootwin_cb (ev);
break;
+#endif /* TRANSPARENT */
case GraphicsExpose:
case Expose:
- if (ev->xany.window == TermWin.vt)
+ if (ev.xany.window == TermWin.vt)
{
#ifdef NO_SLOW_LINK_SUPPORT
- scr_expose (ev->xexpose.x, ev->xexpose.y,
- ev->xexpose.width, ev->xexpose.height, False);
+ scr_expose (ev.xexpose.x, ev.xexpose.y,
+ ev.xexpose.width, ev.xexpose.height, False);
#else
// don't understand this, so commented it out
- scr_expose (ev->xexpose.x, ev->xexpose.y,
- ev->xexpose.width, ev->xexpose.height, False);
- //scr_expose (ev->xexpose.x, 0,
- // ev->xexpose.width, TermWin.height, False);
+ scr_expose (ev.xexpose.x, ev.xexpose.y,
+ ev.xexpose.width, ev.xexpose.height, False);
+ //scr_expose (ev.xexpose.x, 0,
+ // ev.xexpose.width, TermWin.height, False);
#endif
want_refresh = 1;
}
else
{
- XEvent unused_xevent;
+ XEvent unused_event;
- while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window,
+ while (XCheckTypedWindowEvent(display->display, ev.xany.window,
Expose,
- &unused_xevent)) ;
- while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window,
+ &unused_event)) ;
+ while (XCheckTypedWindowEvent(display->display, ev.xany.window,
GraphicsExpose,
- &unused_xevent)) ;
- if (isScrollbarWindow(ev->xany.window))
+ &unused_event)) ;
+ if (isScrollbarWindow(ev.xany.window))
{
scrollBar.setIdle();
scrollbar_show (0);
}
#ifdef MENUBAR
- if (menubar_visible () && isMenuBarWindow(ev->xany.window))
+ if (menubar_visible () && isMenuBarWindow(ev.xany.window))
menubar_expose ();
#endif
#ifdef RXVT_GRAPHICS
- Gr_expose (ev->xany.window);
+ Gr_expose (ev.xany.window);
#endif
}
@@ -1483,36 +1449,37 @@ rxvt_term::process_x_event (XEvent *ev)
pointer_unblank ();
#endif
#if MENUBAR
- if (isMenuBarWindow(ev->xany.window))
+ if (isMenuBarWindow(ev.xany.window))
{
- menubar_control (&(ev->xbutton));
+ menubar_control (&(ev.xbutton));
break;
}
#endif
if ((PrivateModes & PrivMode_mouse_report) && !(bypass_keystate))
break;
- if (ev->xany.window == TermWin.vt)
+ if (ev.xany.window == TermWin.vt)
{
- if ((ev->xbutton.state & (Button1Mask | Button3Mask)))
+ if ((ev.xbutton.state & (Button1Mask | Button3Mask)))
{
- while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt,
- MotionNotify, ev)) ;
- XQueryPointer(Xdisplay, TermWin.vt,
+ while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev))
+ ;
+
+ XQueryPointer(display->display, TermWin.vt,
&unused_root, &unused_child,
&unused_root_x, &unused_root_y,
- &(ev->xbutton.x), &(ev->xbutton.y),
+ &(ev.xbutton.x), &(ev.xbutton.y),
&unused_mask);
#ifdef MOUSE_THRESHOLD
/* deal with a `jumpy' mouse */
- if ((ev->xmotion.time - MEvent.time) > MOUSE_THRESHOLD)
+ if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD)
{
#endif
- selection_extend ((ev->xbutton.x), (ev->xbutton.y),
- (ev->xbutton.state & Button3Mask) ? 2 : 0);
+ selection_extend ((ev.xbutton.x), (ev.xbutton.y),
+ (ev.xbutton.state & Button3Mask) ? 2 : 0);
#ifdef SELECTION_SCROLLING
- if (ev->xbutton.y < TermWin.int_bwidth
- || Pixel2Row(ev->xbutton.y) > (TermWin.nrow-1))
+ if (ev.xbutton.y < TermWin.int_bwidth
+ || Pixel2Row(ev.xbutton.y) > (TermWin.nrow-1))
{
int dist;
@@ -1527,21 +1494,21 @@ rxvt_term::process_x_event (XEvent *ev)
/* save the event params so we can highlight
* the selection in the pending-scroll loop
*/
- selection_save_x=ev->xbutton.x;
- selection_save_y=ev->xbutton.y;
+ selection_save_x=ev.xbutton.x;
+ selection_save_y=ev.xbutton.y;
selection_save_state=
- (ev->xbutton.state & Button3Mask) ? 2 : 0;
+ (ev.xbutton.state & Button3Mask) ? 2 : 0;
/* calc number of lines to scroll */
- if (ev->xbutton.yxbutton.y;
+ dist = TermWin.int_bwidth - ev.xbutton.y;
}
else
{
scroll_selection_dir = DN;
- dist = ev->xbutton.y -
+ dist = ev.xbutton.y -
(TermWin.int_bwidth + TermWin.height);
}
scroll_selection_lines=(Pixel2Height(dist)/
@@ -1564,16 +1531,16 @@ rxvt_term::process_x_event (XEvent *ev)
}
}
- else if (isScrollbarWindow(ev->xany.window) && scrollbar_isMotion())
+ else if (isScrollbarWindow(ev.xany.window) && scrollbar_isMotion())
{
- while (XCheckTypedWindowEvent(Xdisplay, scrollBar.win,
- MotionNotify, ev)) ;
- XQueryPointer(Xdisplay, scrollBar.win,
+ while (XCheckTypedWindowEvent(display->display, scrollBar.win,
+ MotionNotify, &ev)) ;
+ XQueryPointer(display->display, scrollBar.win,
&unused_root, &unused_child,
&unused_root_x, &unused_root_y,
- &(ev->xbutton.x), &(ev->xbutton.y),
+ &(ev.xbutton.x), &(ev.xbutton.y),
&unused_mask);
- scr_move_to (scrollbar_position(ev->xbutton.y) - csrO,
+ scr_move_to (scrollbar_position(ev.xbutton.y) - csrO,
scrollbar_size());
scr_refresh (refresh_type);
refresh_limit = 0;
@@ -1584,33 +1551,59 @@ rxvt_term::process_x_event (XEvent *ev)
}
void
-rxvt_term::button_press (XButtonEvent *ev)
+rxvt_term::rootwin_cb (XEvent &ev)
+{
+ SET_R (this);
+ SET_LOCALE (locale);
+
+ if (ev.type == PropertyNotify)
+ {
+ /*
+ * if user used some Esetroot compatible prog to set the root bg,
+ * use the property to determine the pixmap. We use it later on.
+ */
+ if (xa[XA_XROOTPMAPID] == 0)
+ xa[XA_XROOTPMAPID] = XInternAtom(display->display, "_XROOTPMAP_ID", False);
+
+ if (ev.xproperty.atom != xa[XA_XROOTPMAPID])
+ return;
+ }
+
+ if ((Options & Opt_transparent) && check_our_parents ())
+ {
+ if (am_transparent)
+ want_full_refresh = 1;
+ }
+}
+
+void
+rxvt_term::button_press (const XButtonEvent &ev)
{
int reportmode = 0, clickintime;
- bypass_keystate = ev->state & (ModMetaMask | ShiftMask);
+ bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
if (!bypass_keystate)
reportmode = !!(PrivateModes & PrivMode_mouse_report);
/*
* VT window processing of button press
*/
- if (ev->window == TermWin.vt)
+ if (ev.window == TermWin.vt)
{
#if RXVT_GRAPHICS
- if (ev->subwindow != None)
- rxvt_Gr_ButtonPress (ev->x, ev->y);
+ if (ev.subwindow != None)
+ rxvt_Gr_ButtonPress (ev.x, ev.y);
else
#endif
{
- clickintime = ev->time - MEvent.time < MULTICLICK_TIME;
+ clickintime = ev.time - MEvent.time < MULTICLICK_TIME;
if (reportmode)
{
/* mouse report from vt window */
/* save the xbutton state (for ButtonRelease) */
- MEvent.state = ev->state;
+ MEvent.state = ev.state;
#ifdef MOUSE_REPORT_DOUBLECLICK
- if (ev->button == MEvent.button && clickintime)
+ if (ev.button == MEvent.button && clickintime)
{
/* same button, within alloted time */
MEvent.clicks++;
@@ -1629,29 +1622,29 @@ rxvt_term::button_press (XButtonEvent *ev)
{
/* different button, or time expired */
MEvent.clicks = 1;
- MEvent.button = ev->button;
+ MEvent.button = ev.button;
mouse_report (ev);
}
#else
- MEvent.button = ev->button;
+ MEvent.button = ev.button;
mouse_report (ev);
#endif /* MOUSE_REPORT_DOUBLECLICK */
}
else
{
- if (ev->button != MEvent.button)
+ if (ev.button != MEvent.button)
MEvent.clicks = 0;
- switch (ev->button)
+ switch (ev.button)
{
case Button1:
/* allow shift+left click to extend selection */
- if (ev->state & ShiftMask && !(PrivateModes & PrivMode_mouse_report))
+ if (ev.state & ShiftMask && !(PrivateModes & PrivMode_mouse_report))
{
if (MEvent.button == Button1 && clickintime)
- selection_rotate (ev->x, ev->y);
+ selection_rotate (ev.x, ev.y);
else
- selection_extend (ev->x, ev->y, 1);
+ selection_extend (ev.x, ev.y, 1);
}
else
{
@@ -1660,7 +1653,7 @@ rxvt_term::button_press (XButtonEvent *ev)
else
MEvent.clicks = 1;
- selection_click (MEvent.clicks, ev->x, ev->y);
+ selection_click (MEvent.clicks, ev.x, ev.y);
}
MEvent.button = Button1;
@@ -1668,14 +1661,14 @@ rxvt_term::button_press (XButtonEvent *ev)
case Button3:
if (MEvent.button == Button3 && clickintime)
- selection_rotate (ev->x, ev->y);
+ selection_rotate (ev.x, ev.y);
else
- selection_extend (ev->x, ev->y, 1);
+ selection_extend (ev.x, ev.y, 1);
MEvent.button = Button3;
break;
}
}
- MEvent.time = ev->time;
+ MEvent.time = ev.time;
return;
}
}
@@ -1683,7 +1676,7 @@ rxvt_term::button_press (XButtonEvent *ev)
/*
* Scrollbar window processing of button press
*/
- if (isScrollbarWindow(ev->window))
+ if (isScrollbarWindow(ev.window))
{
scrollBar.setIdle ();
/*
@@ -1705,17 +1698,17 @@ rxvt_term::button_press (XButtonEvent *ev)
* click on scrollbar - send pageup/down
*/
if ((scrollBar.style == R_SB_NEXT
- && scrollbarnext_upButton(ev->y))
+ && scrollbarnext_upButton(ev.y))
|| (scrollBar.style == R_SB_RXVT
- && scrollbarrxvt_upButton(ev->y)))
+ && scrollbarrxvt_upButton(ev.y)))
tt_printf("\033[A");
else if ((scrollBar.style == R_SB_NEXT
- && scrollbarnext_dnButton(ev->y))
+ && scrollbarnext_dnButton(ev.y))
|| (scrollBar.style == R_SB_RXVT
- && scrollbarrxvt_dnButton(ev->y)))
+ && scrollbarrxvt_dnButton(ev.y)))
tt_printf("\033[B");
else
- switch (ev->button)
+ switch (ev.button)
{
case Button2:
tt_printf("\014");
@@ -1736,16 +1729,16 @@ rxvt_term::button_press (XButtonEvent *ev)
if (scrollBar.style == R_SB_NEXT)
{
- if (scrollbarnext_upButton(ev->y))
+ if (scrollbarnext_upButton(ev.y))
upordown = -1; /* up */
- else if (scrollbarnext_dnButton(ev->y))
+ else if (scrollbarnext_dnButton(ev.y))
upordown = 1; /* down */
}
else if (scrollBar.style == R_SB_RXVT)
{
- if (scrollbarrxvt_upButton(ev->y))
+ if (scrollbarrxvt_upButton(ev.y))
upordown = -1; /* up */
- else if (scrollbarrxvt_dnButton(ev->y))
+ else if (scrollbarrxvt_dnButton(ev.y))
upordown = 1; /* down */
}
if (upordown)
@@ -1762,7 +1755,7 @@ rxvt_term::button_press (XButtonEvent *ev)
}
}
else
- switch (ev->button)
+ switch (ev.button)
{
case Button2:
switch (scrollbar_align)
@@ -1778,28 +1771,28 @@ rxvt_term::button_press (XButtonEvent *ev)
break;
}
if (scrollBar.style == R_SB_XTERM
- || scrollbar_above_slider(ev->y)
- || scrollbar_below_slider(ev->y))
- scr_move_to ( scrollbar_position(ev->y) - csrO,
+ || scrollbar_above_slider(ev.y)
+ || scrollbar_below_slider(ev.y))
+ scr_move_to ( scrollbar_position(ev.y) - csrO,
scrollbar_size());
scrollBar.setMotion ();
break;
case Button1:
if (scrollbar_align == R_SB_ALIGN_CENTRE)
- csrO = ev->y - scrollBar.top;
+ csrO = ev.y - scrollBar.top;
/* FALLTHROUGH */
case Button3:
if (scrollBar.style != R_SB_XTERM)
{
- if (scrollbar_above_slider(ev->y))
+ if (scrollbar_above_slider(ev.y))
# ifdef RXVT_SCROLL_FULL
scr_page (UP, TermWin.nrow - 1);
# else
scr_page (UP, TermWin.nrow / 4);
# endif
- else if (scrollbar_below_slider(ev->y))
+ else if (scrollbar_below_slider(ev.y))
# ifdef RXVT_SCROLL_FULL
scr_page (DN, TermWin.nrow - 1);
# else
@@ -1810,9 +1803,9 @@ rxvt_term::button_press (XButtonEvent *ev)
}
else
{
- scr_page ((ev->button == Button1 ? DN : UP),
+ scr_page ((ev.button == Button1 ? DN : UP),
(TermWin.nrow
- * scrollbar_position(ev->y)
+ * scrollbar_position(ev.y)
/ scrollbar_size()));
}
break;
@@ -1824,15 +1817,15 @@ rxvt_term::button_press (XButtonEvent *ev)
/*
* Menubar window processing of button press
*/
- if (isMenuBarWindow(ev->window))
+ if (isMenuBarWindow(ev.window))
menubar_control (ev);
#endif
}
void
-rxvt_term::button_release (XButtonEvent *ev)
+rxvt_term::button_release (const XButtonEvent &ev)
{
- int reportmode = 0;
+ int reportmode = 0;
csrO = 0; /* reset csr Offset */
if (!bypass_keystate)
@@ -1850,11 +1843,11 @@ rxvt_term::button_release (XButtonEvent *ev)
#ifdef SELECTION_SCROLLING
pending_scroll_selection=0;
#endif
- if (ev->window == TermWin.vt)
+ if (ev.window == TermWin.vt)
{
#ifdef RXVT_GRAPHICS
- if (ev->subwindow != None)
- rxvt_Gr_ButtonRelease(ev->x, ev->y);
+ if (ev.subwindow != None)
+ rxvt_Gr_ButtonRelease(ev.x, ev.y);
else
#endif
@@ -1863,13 +1856,13 @@ rxvt_term::button_release (XButtonEvent *ev)
{
/* mouse report from vt window */
/* don't report release of wheel "buttons" */
- if (ev->button >= 4)
+ if (ev.button >= 4)
return;
#ifdef MOUSE_REPORT_DOUBLECLICK
/* only report the release of 'slow' single clicks */
if (MEvent.button != AnyButton
- && (ev->button != MEvent.button
- || (ev->time - MEvent.time
+ && (ev.button != MEvent.button
+ || (ev.time - MEvent.time
> MULTICLICK_TIME / 2)))
{
MEvent.clicks = 0;
@@ -1888,17 +1881,17 @@ rxvt_term::button_release (XButtonEvent *ev)
*/
if (PrivateModes & PrivMode_mouse_report
&& bypass_keystate
- && ev->button == Button1 && MEvent.clicks <= 1)
- selection_extend (ev->x, ev->y, 0);
+ && ev.button == Button1 && MEvent.clicks <= 1)
+ selection_extend (ev.x, ev.y, 0);
- switch (ev->button)
+ switch (ev.button)
{
case Button1:
case Button3:
- selection_make (ev->time);
+ selection_make (ev.time);
break;
case Button2:
- selection_request (ev->time, ev->x, ev->y);
+ selection_request (ev.time, ev.x, ev.y);
break;
#ifdef MOUSE_WHEEL
case Button4:
@@ -1907,15 +1900,15 @@ rxvt_term::button_release (XButtonEvent *ev)
int i;
page_dirn v;
- v = (ev->button == Button4) ? UP : DN;
- if (ev->state & ShiftMask)
+ v = (ev.button == Button4) ? UP : DN;
+ if (ev.state & ShiftMask)
i = 1;
else if ((Options & Opt_mouseWheelScrollPage))
i = TermWin.nrow - 1;
else
i = 5;
# ifdef MOUSE_SLIP_WHEELING
- if (ev->state & ControlMask)
+ if (ev.state & ControlMask)
{
mouse_slip_wheel_speed += (v ? -1 : 1);
mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;
@@ -1942,7 +1935,7 @@ rxvt_term::button_release (XButtonEvent *ev)
}
}
#ifdef MENUBAR
- else if (isMenuBarWindow(ev->window))
+ else if (isMenuBarWindow(ev.window))
menubar_control (ev);
#endif
}
@@ -1969,16 +1962,16 @@ rxvt_term::check_our_parents ()
if (!(Options & Opt_transparent))
return pchanged; /* Don't try any more */
- XGetWindowAttributes(Xdisplay, Xroot, &wrootattr);
+ XGetWindowAttributes(display->display, display->root, &wrootattr);
rootdepth = wrootattr.depth;
- XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
+ XGetWindowAttributes(display->display, TermWin.parent[0], &wattr);
if (rootdepth != wattr.depth)
{
if (am_transparent)
{
pchanged = 1;
- XSetWindowBackground(Xdisplay, TermWin.vt,
+ XSetWindowBackground(display->display, TermWin.vt,
PixColors[Color_bg]);
am_transparent = am_pixmap_trans = 0;
}
@@ -1986,7 +1979,7 @@ rxvt_term::check_our_parents ()
}
/* Get all X ops out of the queue so that our information is up-to-date. */
- XSync(Xdisplay, False);
+ XSync(display->display, False);
/*
* Make the frame window set by the window manager have
@@ -1994,7 +1987,7 @@ rxvt_term::check_our_parents ()
* windows for each client, so we have to take care about that.
*/
i = (xa[XA_XROOTPMAPID] != 0
- && (XGetWindowProperty(Xdisplay, Xroot, xa[XA_XROOTPMAPID],
+ && (XGetWindowProperty(display->display, display->root, xa[XA_XROOTPMAPID],
0L, 1L, False, XA_PIXMAP, &atype, &aformat,
&nitems, &bytes_after, &prop) == Success));
if (!i || prop == NULL)
@@ -2008,7 +2001,7 @@ rxvt_term::check_our_parents ()
if (have_pixmap)
{
/*
- * Copy Xroot pixmap transparency
+ * Copy display->root pixmap transparency
*/
int sx, sy, nx, ny;
unsigned int nw, nh;
@@ -2017,7 +2010,7 @@ rxvt_term::check_our_parents ()
GC gc;
XGCValues gcvalue;
- XTranslateCoordinates(Xdisplay, TermWin.parent[0], Xroot,
+ XTranslateCoordinates(display->display, TermWin.parent[0], display->root,
0, 0, &sx, &sy, &cr);
nw = (unsigned int)szHint.width;
nh = (unsigned int)szHint.height;
@@ -2037,7 +2030,7 @@ rxvt_term::check_our_parents ()
MIN_IT(nw, (unsigned int)(wrootattr.width - sx));
MIN_IT(nh, (unsigned int)(wrootattr.height - sy));
allowedxerror = -1;
- image = XGetImage(Xdisplay, rootpixmap, sx, sy, nw, nh, AllPlanes,
+ image = XGetImage(display->display, rootpixmap, sx, sy, nw, nh, AllPlanes,
ZPixmap);
/* XXX: handle BadMatch - usually because we're outside the pixmap */
/* XXX: may need a delay here? */
@@ -2049,7 +2042,7 @@ rxvt_term::check_our_parents ()
pchanged = 1;
if (TermWin.pixmap != None)
{
- XFreePixmap(Xdisplay, TermWin.pixmap);
+ XFreePixmap(display->display, TermWin.pixmap);
TermWin.pixmap = None;
}
}
@@ -2058,18 +2051,18 @@ rxvt_term::check_our_parents ()
else
{
if (TermWin.pixmap != None)
- XFreePixmap(Xdisplay, TermWin.pixmap);
- TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt,
+ XFreePixmap(display->display, TermWin.pixmap);
+ TermWin.pixmap = XCreatePixmap(display->display, TermWin.vt,
(unsigned int)szHint.width,
(unsigned int)szHint.height,
(unsigned int)image->depth);
- gc = XCreateGC(Xdisplay, TermWin.vt, 0UL, &gcvalue);
- XPutImage(Xdisplay, TermWin.pixmap, gc, image, 0, 0,
+ gc = XCreateGC(display->display, TermWin.vt, 0UL, &gcvalue);
+ XPutImage(display->display, TermWin.pixmap, gc, image, 0, 0,
nx, ny, (unsigned int)image->width,
(unsigned int)image->height);
- XFreeGC(Xdisplay, gc);
+ XFreeGC(display->display, gc);
XDestroyImage(image);
- XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt,
+ XSetWindowBackgroundPixmap(display->display, TermWin.vt,
TermWin.pixmap);
if (!am_transparent || !am_pixmap_trans)
pchanged = 1;
@@ -2082,16 +2075,16 @@ rxvt_term::check_our_parents ()
/*
* InheritPixmap transparency
*/
- D_X((stderr, "InheritPixmap Seeking to %08lx", Xroot));
+ D_X((stderr, "InheritPixmap Seeking to %08lx", display->root));
for (i = 1; i < (int)(sizeof(TermWin.parent) / sizeof(Window));
i++)
{
oldp = TermWin.parent[i];
- XQueryTree(Xdisplay, TermWin.parent[i - 1], &root,
+ XQueryTree(display->display, TermWin.parent[i - 1], &root,
&TermWin.parent[i], &list, &n);
XFree(list);
D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i]));
- if (TermWin.parent[i] == Xroot)
+ if (TermWin.parent[i] == display->root)
{
if (oldp != None)
pchanged = 1;
@@ -2105,7 +2098,7 @@ rxvt_term::check_our_parents ()
{
for (; n < (unsigned int)i; n++)
{
- XGetWindowAttributes(Xdisplay, TermWin.parent[n], &wattr);
+ XGetWindowAttributes(display->display, TermWin.parent[n], &wattr);
D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL"));
if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
{
@@ -2118,9 +2111,9 @@ rxvt_term::check_our_parents ()
/ sizeof(TermWin.parent[0])))
{
D_X((stderr, "InheritPixmap Turning off"));
- XSetWindowBackground(Xdisplay, TermWin.parent[0],
+ XSetWindowBackground(display->display, TermWin.parent[0],
PixColors[Color_fg]);
- XSetWindowBackground(Xdisplay, TermWin.vt,
+ XSetWindowBackground(display->display, TermWin.vt,
PixColors[Color_bg]);
am_transparent = 0;
/* XXX: also turn off Opt_transparent? */
@@ -2140,9 +2133,9 @@ rxvt_term::check_our_parents ()
# endif
D_X((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
for (n = 0; n < (unsigned int)i; n++)
- XSetWindowBackgroundPixmap(Xdisplay, TermWin.parent[n],
+ XSetWindowBackgroundPixmap(display->display, TermWin.parent[n],
ParentRelative);
- XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt,
+ XSetWindowBackgroundPixmap(display->display, TermWin.vt,
ParentRelative);
am_transparent = 1;
}
@@ -2844,23 +2837,23 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
* commands
*/
case 1: /* deiconify window */
- XMapWindow(Xdisplay, TermWin.parent[0]);
+ XMapWindow(display->display, TermWin.parent[0]);
break;
case 2: /* iconify window */
- XIconifyWindow(Xdisplay, TermWin.parent[0],
- DefaultScreen(Xdisplay));
+ XIconifyWindow(display->display, TermWin.parent[0],
+ DefaultScreen(display->display));
break;
case 3: /* set position (pixels) */
- XMoveWindow(Xdisplay, TermWin.parent[0], args[1], args[2]);
+ XMoveWindow(display->display, TermWin.parent[0], args[1], args[2]);
break;
case 4: /* set size (pixels) */
set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
break;
case 5: /* raise window */
- XRaiseWindow(Xdisplay, TermWin.parent[0]);
+ XRaiseWindow(display->display, TermWin.parent[0]);
break;
case 6: /* lower window */
- XLowerWindow(Xdisplay, TermWin.parent[0]);
+ XLowerWindow(display->display, TermWin.parent[0]);
break;
case 7: /* refresh window */
scr_touch (true);
@@ -2878,18 +2871,18 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
* reports - some output format copied from XTerm
*/
case 11: /* report window state */
- XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
+ XGetWindowAttributes(display->display, TermWin.parent[0], &wattr);
tt_printf("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
break;
case 13: /* report window position */
- XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
- XTranslateCoordinates(Xdisplay, TermWin.parent[0], wattr.root,
+ XGetWindowAttributes(display->display, TermWin.parent[0], &wattr);
+ XTranslateCoordinates(display->display, TermWin.parent[0], wattr.root,
-wattr.border_width, -wattr.border_width,
&x, &y, &wdummy);
tt_printf("\033[3;%d;%dt", x, y);
break;
case 14: /* report window size (pixels) */
- XGetWindowAttributes(Xdisplay, TermWin.parent[0], &wattr);
+ XGetWindowAttributes(display->display, TermWin.parent[0], &wattr);
tt_printf("\033[4;%d;%dt", wattr.height, wattr.width);
break;
case 18: /* report window size (chars) */
@@ -2897,11 +2890,11 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs)
break;
#if 0 /* XXX: currently disabled due to security concerns */
case 20: /* report icon label */
- XGetIconName(Xdisplay, TermWin.parent[0], &s);
+ XGetIconName(display->display, TermWin.parent[0], &s);
tt_printf("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */
break;
case 21: /* report window title */
- XFetchName(Xdisplay, TermWin.parent[0], &s);
+ XFetchName(display->display, TermWin.parent[0], &s);
tt_printf("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */
break;
#endif
diff --git a/src/defaultfont.C b/src/defaultfont.C
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- a/src/rxvtstl.h +++ b/src/rxvtstl.h @@ -8,8 +8,7 @@ templatestatic 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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)) {
-----END OF PAGE-----