--- rxvt-unicode/src/scrollbar.C 2004/02/01 01:34:41 1.12 +++ rxvt-unicode/src/scrollbar.C 2004/04/08 20:31:45 1.15 @@ -1,11 +1,12 @@ /*--------------------------------*-C-*---------------------------------* - * File: scrollbar.c + * File: scrollbar.C *----------------------------------------------------------------------* * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1998 Alfredo K. Kojima * - N*XTstep like scrollbars * Copyright (c) 1999-2001 Geoff Wing + * Copyright (c) 2004 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,21 +38,21 @@ int change = 0; #ifdef HAVE_SCROLLBARS - if (map && !scrollbar_visible()) + if (map && !scrollbar_visible ()) { scrollBar.setIdle (); if (!scrollBar.win) resize_scrollbar (); if (scrollBar.win) { - XMapWindow(Xdisplay, scrollBar.win); + XMapWindow (display->display, scrollBar.win); change = 1; } } - else if (!map && scrollbar_visible()) + else if (!map && scrollbar_visible ()) { scrollBar.state = 0; - XUnmapWindow(Xdisplay, scrollBar.win); + XUnmapWindow (display->display, scrollBar.win); change = 1; } #endif @@ -109,27 +110,32 @@ 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(), + scrollbar_TotalWidth (), szHint.height, 0, 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 } @@ -143,24 +149,24 @@ #ifdef HAVE_SCROLLBARS int top, bot, len, adj; - if (!scrollbar_visible()) + if (!scrollbar_visible ()) return 0; if (update) { top = (TermWin.nscrolled - TermWin.view_start); bot = top + (TermWin.nrow - 1); - len = max((TermWin.nscrolled + (TermWin.nrow - 1)), 1); - adj = (((bot - top) * scrollbar_size()) % len) > 0 ? 1 : 0; + len = max ((TermWin.nscrolled + (TermWin.nrow - 1)), 1); + adj = (((bot - top) * scrollbar_size ()) % len) > 0 ? 1 : 0; - scrollBar.top = (scrollBar.beg + (top * scrollbar_size()) / len); - scrollbar_len = ((bot - top) * scrollbar_size()) / len + - scrollbar_minheight() + adj; + scrollBar.top = (scrollBar.beg + (top * scrollbar_size ()) / len); + scrollbar_len = ((bot - top) * scrollbar_size ()) / len + + scrollbar_minheight () + adj; scrollBar.bot = (scrollBar.top + scrollbar_len); /* no change */ if (scrollBar.top == last_top && scrollBar.bot == last_bot - && (scrollBar.state == last_state || !scrollbar_isUpDn())) + && (scrollBar.state == last_state || !scrollbar_isUpDn ())) return 0; } @@ -197,15 +203,15 @@ if (scrollstyle) { # ifdef NEXT_SCROLLBAR - if (STRNCASECMP(scrollstyle, "next", 4) == 0) + if (STRNCASECMP (scrollstyle, "next", 4) == 0) style = R_SB_NEXT; # endif # ifdef XTERM_SCROLLBAR - if (STRNCASECMP(scrollstyle, "xterm", 5) == 0) + if (STRNCASECMP (scrollstyle, "xterm", 5) == 0) style = R_SB_XTERM; # endif # ifdef PLAIN_SCROLLBAR - if (STRNCASECMP(scrollstyle, "plain", 5) == 0) + if (STRNCASECMP (scrollstyle, "plain", 5) == 0) style = R_SB_PLAIN; # endif @@ -221,11 +227,11 @@ width = SB_WIDTH_RXVT; if (style != R_SB_NEXT) /* dishonour request - for now */ - if (thickness && (i = atoi(thickness)) >= SB_WIDTH_MINIMUM) - width = min(i, SB_WIDTH_MAXIMUM); + if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) + width = min (i, SB_WIDTH_MAXIMUM); # if defined(RXVT_SCROLLBAR) - if (!(Options & Opt_scrollBar_floating) && style == R_SB_RXVT) + if (! (Options & Opt_scrollBar_floating) && style == R_SB_RXVT) sb_shadow = SHADOW; # endif @@ -235,9 +241,9 @@ /* scrollbar_align = R_SB_ALIGN_CENTRE; */ if (scrollalign) { - if (STRNCASECMP(scrollalign, "top", 3) == 0) + if (STRNCASECMP (scrollalign, "top", 3) == 0) scrollbar_align = R_SB_ALIGN_TOP; - else if (STRNCASECMP(scrollalign, "bottom", 6) == 0) + else if (STRNCASECMP (scrollalign, "bottom", 6) == 0) scrollbar_align = R_SB_ALIGN_BOTTOM; } #endif