diff options
author | Michael Jennings <mej@kainx.org> | 1999-11-19 04:05:24 +0000 |
---|---|---|
committer | Michael Jennings <mej@kainx.org> | 1999-11-19 04:05:24 +0000 |
commit | c58c7d411b8a1a7198b93116bd992a4d6243a192 (patch) | |
tree | dab4dc84aaa7fe31cb8d002d8c14c3ed80b34377 /src | |
parent | 5894debb3a388bf235d824bb1d675bec80425399 (diff) | |
download | eterm-c58c7d411b8a1a7198b93116bd992a4d6243a192.tar.gz |
Thu Nov 18 21:47:02 PST 1999 Michael Jennings <mej@eterm.org>
I've rewritten almost the entire scrollbar. It mostly works, but it
still has issues. I've put an #error directive in so that it won't
compile; take it out if you *really* wanna try it. It's much more
efficient than before.
SVN revision: 1333
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 13 | ||||
-rw-r--r-- | src/actions.c | 39 | ||||
-rw-r--r-- | src/actions.h | 39 | ||||
-rw-r--r-- | src/command.c | 38 | ||||
-rw-r--r-- | src/command.h | 4 | ||||
-rw-r--r-- | src/draw.c | 102 | ||||
-rw-r--r-- | src/draw.h | 54 | ||||
-rw-r--r-- | src/e.c | 40 | ||||
-rw-r--r-- | src/e.h | 39 | ||||
-rw-r--r-- | src/events.c | 54 | ||||
-rw-r--r-- | src/events.h | 47 | ||||
-rw-r--r-- | src/feature.h | 1 | ||||
-rw-r--r-- | src/icon.h (renamed from src/Eterm.xpm) | 0 | ||||
-rw-r--r-- | src/menus.c | 45 | ||||
-rw-r--r-- | src/menus.h | 39 | ||||
-rw-r--r-- | src/misc.c | 94 | ||||
-rw-r--r-- | src/misc.h | 44 | ||||
-rw-r--r-- | src/options.c | 89 | ||||
-rw-r--r-- | src/options.h | 45 | ||||
-rw-r--r-- | src/pixmap.c | 56 | ||||
-rw-r--r-- | src/pixmap.h | 46 | ||||
-rw-r--r-- | src/screen.c | 2 | ||||
-rw-r--r-- | src/scrollbar.c | 1225 | ||||
-rw-r--r-- | src/scrollbar.h | 212 | ||||
-rw-r--r-- | src/startup.c | 8 | ||||
-rw-r--r-- | src/startup.h | 4 | ||||
-rw-r--r-- | src/system.c | 23 | ||||
-rw-r--r-- | src/system.h | 23 | ||||
-rw-r--r-- | src/term.c | 13 | ||||
-rw-r--r-- | src/timer.c | 39 | ||||
-rw-r--r-- | src/timer.h | 39 | ||||
-rw-r--r-- | src/windows.c | 18 |
32 files changed, 1281 insertions, 1253 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 0e0b34f..dcae805 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,8 +2,14 @@ lib_LTLIBRARIES = libEterm.la -libEterm_la_SOURCES = actions.c command.c e.c events.c font.c grkelot.c menus.c misc.c netdisp.c \ - options.c pixmap.c screen.c scrollbar.c startup.c system.c term.c timer.c utmp.c windows.c +libEterm_la_SOURCES = actions.c actions.h command.c command.h debug.h draw.c \ + draw.h e.c e.h eterm_utmp.h events.c events.h feature.h \ + font.c font.h grkelot.c grkelot.h icon.h menus.c menus.h \ + misc.c misc.h netdisp.c options.c options.h pixmap.c \ + pixmap.h profile.h screen.c screen.h scrollbar.c \ + scrollbar.h startup.c startup.h system.c system.h term.c \ + term.h timer.c timer.h utmp.c windows.c windows.h + libEterm_la_DEPENDENCIES = $(top_builddir)/libmej/libmej.la feature.h libEterm_la_LDFLAGS = -release $(VERSION) @@ -14,6 +20,3 @@ Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir) INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/libmej -I.. -I$(includedir) -I$(prefix)/include $(X_CFLAGS) LDADD = libEterm.la $(top_builddir)/libmej/libmej.la -L$(libdir) -L$(prefix)/lib $(LIBS) $(GRLIBS) $(X_LIBS) - -EXTRA_DIST = actions.h command.h debug.h e.h eterm_utmp.h events.h feature.h font.h grkelot.h menus.h misc.h options.h \ - pixmap.h profile.h screen.h scrollbar.h startup.h system.h term.h timer.h windows.h Eterm.xpm diff --git a/src/actions.c b/src/actions.c index 33b4e1a..22f5330 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1,27 +1,24 @@ -/* actions.c -- Eterm action class module - * -- 3 August 1999, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1999-1997, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; diff --git a/src/actions.h b/src/actions.h index 0813a12..52ff0b6 100644 --- a/src/actions.h +++ b/src/actions.h @@ -1,27 +1,24 @@ -/* actions.h -- Eterm action class module header file - * -- 3 August 1999, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1999-1997, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _ACTIONS_H_ diff --git a/src/command.c b/src/command.c index 5d25188..ffe0bf0 100644 --- a/src/command.c +++ b/src/command.c @@ -1766,13 +1766,13 @@ static void xim_get_area(XRectangle *preedit_rect, XRectangle *status_rect, XRectangle *needed_rect) { - preedit_rect->x = needed_rect->width + (scrollbar_visible() && !(Options & Opt_scrollBar_right) ? (scrollbar_trough_width()) : 0); + preedit_rect->x = needed_rect->width + (scrollbar_is_visible() && !(Options & Opt_scrollbar_right) ? (scrollbar_trough_width()) : 0); preedit_rect->y = Height2Pixel(TermWin.nrow - 1); - preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + (!(Options & Opt_scrollBar_right) ? (scrollbar_trough_width()) : 0); + preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + (!(Options & Opt_scrollbar_right) ? (scrollbar_trough_width()) : 0); preedit_rect->height = Height2Pixel(1); - status_rect->x = (scrollbar_visible() && !(Options & Opt_scrollBar_right)) ? (scrollbar_trough_width()) : 0; + status_rect->x = (scrollbar_is_visible() && !(Options & Opt_scrollbar_right)) ? (scrollbar_trough_width()) : 0; status_rect->y = Height2Pixel(TermWin.nrow - 1); status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel(TermWin.ncol + 1); @@ -2035,10 +2035,10 @@ run_command(char *argv[]) /* add Backspace value */ SavedModes |= (PrivateModes & PrivMode_BackSpace); - /* add value for scrollBar */ - if (scrollbar_visible()) { - PrivateModes |= PrivMode_scrollBar; - SavedModes |= PrivMode_scrollBar; + /* add value for scrollbar */ + if (scrollbar_is_visible()) { + PrivateModes |= PrivMode_scrollbar; + SavedModes |= PrivMode_scrollbar; } #if DEBUG >= DEBUG_TTYMODE && defined(HAVE_TERMIOS_H) if (debug_level >= DEBUG_TTYMODE) { @@ -2407,12 +2407,13 @@ cmd_getc(void) XNextEvent(Xdisplay, &ev); #ifdef USE_XIM - if (!XFilterEvent(&ev, ev.xkey.window)) { - event_dispatch(&ev); - } -#else - event_dispatch(&ev); + if (Input_Context != NULL) { + if (!XFilterEvent(&ev, ev.xkey.window)) { + event_dispatch(&ev); + } + } else #endif + event_dispatch(&ev); /* in case button actions pushed chars to cmdbuf */ if (CHARS_READ()) { @@ -2421,12 +2422,12 @@ cmd_getc(void) } #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - if (scrollbar_isUp()) { + if (scrollbar_uparrow_is_pressed()) { if (!scroll_arrow_delay-- && scr_page(UP, 1)) { scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY; refreshed = 0; } - } else if (scrollbar_isDn()) { + } else if (scrollbar_downarrow_is_pressed()) { if (!scroll_arrow_delay-- && scr_page(DN, 1)) { scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY; refreshed = 0; @@ -2443,7 +2444,7 @@ cmd_getc(void) if (refreshed #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - && !(scrollbar_isUpDn()) + && !(scrollbar_arrow_is_pressed()) #endif ) { delay = NULL; @@ -2483,11 +2484,8 @@ cmd_getc(void) refreshed = 1; D_CMD(("cmd_getc(): select() timed out, time to update the screen.\n")); scr_refresh(refresh_type); - /* FIXME: This call is only here to update the anchor size/position. - It should be replaced with a call to a function that does just that - rather than calling a function that updates the background also. */ - if (scrollbar_visible()) { - scrollbar_show(1); + if (scrollbar_is_visible()) { + scrollbar_anchor_update_position(1); } #ifdef USE_XIM xim_send_spot(); diff --git a/src/command.h b/src/command.h index 84c9275..6481514 100644 --- a/src/command.h +++ b/src/command.h @@ -53,7 +53,7 @@ # define DndLink 7 #endif -# define scrollBar_esc 30 +# define scrollbar_esc 30 /* Motif window hints */ #define MWM_HINTS_FUNCTIONS (1L << 0) @@ -98,7 +98,7 @@ # define PrivMode_MouseX11 (1LU<<12) /* too annoying to implement X11 highlight tracking */ /* #define PrivMode_MouseX11Track (1LU<<13) */ -# define PrivMode_scrollBar (1LU<<14) +# define PrivMode_scrollbar (1LU<<14) # define PrivMode_menuBar (1LU<<15) #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11) diff --git a/src/draw.c b/src/draw.c new file mode 100644 index 0000000..d31b869 --- /dev/null +++ b/src/draw.c @@ -0,0 +1,102 @@ +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +static const char cvs_ident[] = "$Id$"; + +#include "config.h" +#include "feature.h" + +#include "../libmej/debug.h" +#include "../libmej/mem.h" +#include "../libmej/strings.h" +#include "debug.h" +#include "draw.h" +#include "misc.h" +#include "pixmap.h" +#include "startup.h" + +void +draw_shadow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h, int shadow) +{ + + ASSERT(w != 0); + ASSERT(h != 0); + LOWER_BOUND(shadow, 1); + + for (w += x - 1, h += y - 1; shadow > 0; shadow--, w--, h--) { + XDrawLine(Xdisplay, win, gc_top, x, y, w, y); + XDrawLine(Xdisplay, win, gc_top, x, y, x, h); + x++; y++; + XDrawLine(Xdisplay, win, gc_bottom, w, h, w, y); + XDrawLine(Xdisplay, win, gc_bottom, w, h, x, h); + } +} + +void +draw_arrow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow, unsigned char type) +{ + + BOUND(shadow, 1, 2); + + switch (type) { + case DRAW_ARROW_UP: + for (; shadow > 0; shadow--, x++, y++, w--) { + XDrawLine(Xdisplay, win, gc_top, x, y + w, x + w / 2, y); + XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x + w / 2, y); + XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x, y + w); + } + break; + case DRAW_ARROW_DOWN: + for (; shadow > 0; shadow--, x++, y++, w--) { + XDrawLine(Xdisplay, win, gc_top, x, y, x + w / 2, y + w); + XDrawLine(Xdisplay, win, gc_top, x, y, x + w, y); + XDrawLine(Xdisplay, win, gc_bottom, x + w, y, x + w / 2, y + w); + } + break; + case DRAW_ARROW_LEFT: + for (; shadow > 0; shadow--, x++, y++, w--) { + XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x + w, y); + XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x, y + w / 2); + XDrawLine(Xdisplay, win, gc_top, x, y + w / 2, x + w, y); + } + break; + case DRAW_ARROW_RIGHT: + for (; shadow > 0; shadow--, x++, y++, w--) { + XDrawLine(Xdisplay, win, gc_top, x, y, x, y + w); + XDrawLine(Xdisplay, win, gc_top, x, y, x + w, y + w / 2); + XDrawLine(Xdisplay, win, gc_bottom, x, y + w, x + w, y + w / 2); + } + break; + default: + break; + } +} + +void +draw_box(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h) +{ + XDrawLine(Xdisplay, win, gc_top, x + w, y, x, y); + XDrawLine(Xdisplay, win, gc_top, x, y, x, y + h); + XDrawLine(Xdisplay, win, gc_bottom, x, y + h, x + w, y + h); + XDrawLine(Xdisplay, win, gc_bottom, x + w, y + h, x + w, y); +} diff --git a/src/draw.h b/src/draw.h new file mode 100644 index 0000000..787eec4 --- /dev/null +++ b/src/draw.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _DRAW_H_ +#define _DRAW_H_ + +#include <X11/Xfuncproto.h> +#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */ + +/************ Macros and Definitions ************/ +#define DRAW_ARROW_UP (1UL << 0) +#define DRAW_ARROW_DOWN (1UL << 1) +#define DRAW_ARROW_LEFT (1UL << 2) +#define DRAW_ARROW_RIGHT (1UL << 3) + +#define draw_uparrow_raised(win, g1, g2, x, y, w, s) draw_arrow(win, g1, g2, x, y, w, s, DRAW_ARROW_UP) +#define draw_uparrow_clicked(win, g1, g2, x, y, w, s) draw_arrow(win, g2, g1, x, y, w, s, DRAW_ARROW_UP) +#define draw_downarrow_raised(win, g1, g2, x, y, w, s) draw_arrow(win, g1, g2, x, y, w, s, DRAW_ARROW_DOWN) +#define draw_downarrow_clicked(win, g1, g2, x, y, w, s) draw_arrow(win, g2, g1, x, y, w, s, DRAW_ARROW_DOWN) + +/************ Structures ************/ + +/************ Variables ************/ + +/************ Function Prototypes ************/ +_XFUNCPROTOBEGIN + +extern void draw_shadow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h, int shadow); +extern void draw_arrow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow, unsigned char type); +extern void draw_box(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h); + +_XFUNCPROTOEND + +#endif /* _DRAW_H_ */ @@ -1,26 +1,24 @@ -/* e.c -- Eterm Enlightenment support - - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; @@ -1,27 +1,24 @@ -/* e.h -- Eterm Enlightenment support module header file - * -- 6 June 1999, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _E_H_ diff --git a/src/events.c b/src/events.c index f3fd8f5..017673a 100644 --- a/src/events.c +++ b/src/events.c @@ -1,27 +1,24 @@ -/* events.c -- Eterm events module - * -- 29 April 1999, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; @@ -158,12 +155,13 @@ event_init_primary_dispatcher(void) event_data_add_mywin(&primary_data, TermWin.parent); event_data_add_mywin(&primary_data, TermWin.vt); - event_data_add_mywin(&primary_data, scrollBar.win); - if (scrollbar_is_pixmapped()) { - event_data_add_mywin(&primary_data, scrollBar.up_win); - event_data_add_mywin(&primary_data, scrollBar.dn_win); - event_data_add_mywin(&primary_data, scrollBar.sa_win); - } +#if 0 + event_data_add_mywin(&primary_data, scrollbar_get_win()); + event_data_add_mywin(&primary_data, scrollbar_get_uparrow_win()); + event_data_add_mywin(&primary_data, scrollbar_get_downarrow_win()); + event_data_add_mywin(&primary_data, scrollbar_get_anchor_win()); +#endif + if (desktop_window != None) { event_data_add_parent(&primary_data, desktop_window); } @@ -388,7 +386,7 @@ handle_focus_in(event_t * ev) redraw_image(image_bg); } if (Options & Opt_scrollbar_popup) { - map_scrollbar(Options & Opt_scrollBar); + map_scrollbar(Options & Opt_scrollbar); } #ifdef USE_XIM if (Input_Context != NULL) diff --git a/src/events.h b/src/events.h index b2184f5..fcf075c 100644 --- a/src/events.h +++ b/src/events.h @@ -1,27 +1,24 @@ -/* events.h -- Eterm events module header file - * -- 29 April 1999, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _EVENTS_H_ @@ -35,10 +32,10 @@ # define XEVENT_IS_MYWIN(ev) (((ev)->xany.window == TermWin.parent) \ || ((ev)->xany.window == TermWin.vt) \ || ((ev)->xany.window == menuBar.win) \ - || (scrollbar_uparrow_is_pixmapped() && ((ev)->xany.window == scrollBar.up_win)) \ - || (scrollbar_downarrow_is_pixmapped() && ((ev)->xany.window == scrollBar.dn_win)) \ - || (scrollbar_anchor_is_pixmapped() && ((ev)->xany.window == scrollBar.sa_win)) \ - || ((ev)->xany.window == scrollBar.win)) + || (scrollbar_uparrow_is_pixmapped() && ((ev)->xany.window == scrollbar.up_win)) \ + || (scrollbar_downarrow_is_pixmapped() && ((ev)->xany.window == scrollbar.dn_win)) \ + || (scrollbar_anchor_is_pixmapped() && ((ev)->xany.window == scrollbar.sa_win)) \ + || ((ev)->xany.window == scrollbar.win)) # define XEVENT_IS_PARENT(ev) (((ev)->xany.window == TermWin.wm_parent) \ || ((ev)->xany.window == TermWin.wm_grandparent)) #endif diff --git a/src/feature.h b/src/feature.h index d6fb85b..a00cc38 100644 --- a/src/feature.h +++ b/src/feature.h @@ -266,7 +266,6 @@ #define FONT0_IDX 2 #ifndef PIXMAP_SUPPORT -# undef PIXMAP_SCROLLBAR # undef BACKING_STORE # undef PIXMAP_OFFSET # undef IMLIB_TRANS diff --git a/src/Eterm.xpm b/src/icon.h index 6e39081..6e39081 100644 --- a/src/Eterm.xpm +++ b/src/icon.h diff --git a/src/menus.c b/src/menus.c index e84c312..519db18 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1,26 +1,24 @@ -/* menus.c -- Eterm popup menu module - - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; @@ -34,6 +32,7 @@ static const char cvs_ident[] = "$Id$"; #include "../libmej/mem.h" #include "../libmej/strings.h" #include "command.h" +#include "draw.h" #include "e.h" #include "events.h" #include "font.h" @@ -906,7 +905,7 @@ menu_draw(menu_t * menu) XTextExtents(menu->font, menu->title, len, &direction, &ascent, &descent, &chars); draw_string(menu->win, menu->gc, center_coords(2 * MENU_HGAP, menu->w - 2 * MENU_HGAP) - (chars.width >> 1), str_y - chars.descent - MENU_VGAP / 2, menu->title, len); - Draw_Shadow(menu->win, topShadowGC, botShadowGC, str_x, str_y - chars.descent - MENU_VGAP / 2 + 1, menu->w - (4 * MENU_HGAP), MENU_VGAP); + draw_shadow(menu->win, topShadowGC, botShadowGC, str_x, str_y - chars.descent - MENU_VGAP / 2 + 1, menu->w - (4 * MENU_HGAP), MENU_VGAP, 2); str_y += MENU_VGAP; for (i = 0; i < menu->numitems; i++) { @@ -923,7 +922,7 @@ menu_draw(menu_t * menu) D_MENU((" -> Hot Area at %hu, %hu to %hu, %hu (width %hu, height %hu)\n", item->x, item->y, item->x + item->w, item->y + item->h, item->w, item->h)); } - Draw_Shadow(menu->win, botShadowGC, topShadowGC, str_x, str_y - MENU_VGAP - MENU_VGAP / 2, menu->w - 4 * MENU_HGAP, MENU_VGAP); + draw_shadow(menu->win, botShadowGC, topShadowGC, str_x, str_y - MENU_VGAP - MENU_VGAP / 2, menu->w - 4 * MENU_HGAP, MENU_VGAP, 2); } else { str_y += menu->fheight + MENU_VGAP; diff --git a/src/menus.h b/src/menus.h index f39aa5b..bab76c2 100644 --- a/src/menus.h +++ b/src/menus.h @@ -1,27 +1,26 @@ -/* menus.h -- Eterm popup menu module header file +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #ifndef _MENUS_H # define _MENUS_H @@ -287,97 +287,3 @@ find_file(const char *file, const char *ext) } -/*----------------------------------------------------------------------* - * miscellaneous drawing routines - */ - -/* - * draw bottomShadow/highlight along top/left sides of the window - */ -void -Draw_tl(Window win, GC gc, int x, int y, int w, int h) -{ - - int shadow = SHADOW; - - if (w == 0 || h == 0) { - shadow = 1; - } - w += (x - 1); - h += (y - 1); - - for (; shadow > 0; shadow--, x++, y++, w--, h--) { - XDrawLine(Xdisplay, win, gc, x, y, w, y); - XDrawLine(Xdisplay, win, gc, x, y, x, h); - } -} - -/* - * draw bottomShadow/highlight along the bottom/right sides of the window - */ -void -Draw_br(Window win, GC gc, int x, int y, int w, int h) -{ - - int shadow = SHADOW; - - if (w == 0 || h == 0) { - shadow = 1; - } - w += (x - 1); - h += (y - 1); - x++; - y++; - - for (; shadow > 0; shadow--, x++, y++, w--, h--) { - XDrawLine(Xdisplay, win, gc, w, h, w, y); - XDrawLine(Xdisplay, win, gc, w, h, x, h); - } -} - -void -Draw_Shadow(Window win, GC topShadow, GC botShadow, int x, int y, int w, int h) -{ - - Draw_tl(win, topShadow, x, y, w, h); - Draw_br(win, botShadow, x, y, w, h); -} - -/* button shapes */ -void -Draw_Triangle(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); - 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); - 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); - 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); - 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); - break; -#endif - } -} @@ -1,26 +1,24 @@ -/* misc.h -- Eterm toolkit header file +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _MISC_H_ @@ -44,11 +42,7 @@ extern char *str_trim(char *str); extern int parse_escaped_string(char *str); extern const char *search_path(const char *pathlist, const char *file, const char *ext); extern const char *find_file(const char *file, const char *ext); -extern void Draw_tl(Window win, GC gc, int x, int y, int w, int h); -extern void Draw_br(Window win, GC gc, int x, int y, int w, int h); -extern void Draw_Shadow(Window win, GC topShadow, GC botShadow, int x, int y, int w, int h); -extern void Draw_Triangle(Window win, GC topShadow, GC botShadow, int x, int y, int w, int type); _XFUNCPROTOEND -#endif /* whole file */ +#endif diff --git a/src/options.c b/src/options.c index f343ecb..f0e6a09 100644 --- a/src/options.c +++ b/src/options.c @@ -1,27 +1,24 @@ -/* options.c -- Eterm options module - * -- 25 July 1997, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; @@ -184,7 +181,7 @@ eterm_func builtins[] = {"appname", builtin_appname, 0}, {(char *) NULL, (eterm_function_ptr) NULL, 0} }; -unsigned long Options = (Opt_scrollBar), image_toggles = 0; +unsigned long Options = (Opt_scrollbar), image_toggles = 0; static menu_t *curmenu; char *theme_dir = NULL, *user_dir = NULL; char **rs_execArgs = NULL; /* Args to exec (-e or --exec) */ @@ -377,14 +374,14 @@ static const struct { /* =======[ Toggles ]======= */ OPT_BOOL('l', "login-shell", "login shell, prepend - to shell name", &Options, Opt_loginShell), - OPT_BOOL('s', "scrollbar", "display scrollbar", &Options, Opt_scrollBar), + OPT_BOOL('s', "scrollbar", "display scrollbar", &Options, Opt_scrollbar), OPT_BOOL('u', "utmp-logging", "make a utmp entry", &Options, Opt_utmpLogging), OPT_BOOL('v', "visual-bell", "visual bell", &Options, Opt_visualBell), OPT_BOOL('H', "home-on-echo", "jump to bottom on output", &Options, Opt_homeOnEcho), OPT_BLONG("home-on-input", "jump to bottom on input", &Options, Opt_homeOnInput), OPT_BOOL('E', "home-on-refresh", "jump to bottom on refresh (^L)", &Options, Opt_homeOnRefresh), - OPT_BLONG("scrollbar-right", "display the scrollbar on the right", &Options, Opt_scrollBar_right), - OPT_BLONG("scrollbar-floating", "display the scrollbar with no trough", &Options, Opt_scrollBar_floating), + OPT_BLONG("scrollbar-right", "display the scrollbar on the right", &Options, Opt_scrollbar_right), + OPT_BLONG("scrollbar-floating", "display the scrollbar with no trough", &Options, Opt_scrollbar_floating), OPT_BLONG("scrollbar-popup", "popup the scrollbar only when focused", &Options, Opt_scrollbar_popup), OPT_BOOL('x', "borderless", "force Eterm to have no borders", &Options, Opt_borderless), #ifndef NO_MAPALERT @@ -585,11 +582,6 @@ version(void) #else printf(" -BACKGROUND_CYCLING_SUPPORT"); #endif -#ifdef PIXMAP_SCROLLBAR - printf(" +PIXMAP_SCROLLBAR"); -#else - printf(" -PIXMAP_SCROLLBAR"); -#endif #ifdef BACKING_STORE printf(" +BACKING_STORE"); #else @@ -1875,9 +1867,9 @@ parse_toggles(char *buff) } } else if (!BEG_STRCASECMP(buff, "scrollbar ")) { if (bool_val) { - Options |= Opt_scrollBar; + Options |= Opt_scrollbar; } else { - Options &= ~(Opt_scrollBar); + Options &= ~(Opt_scrollbar); } } else if (!BEG_STRCASECMP(buff, "utmp_logging ")) { @@ -1932,16 +1924,16 @@ parse_toggles(char *buff) } else if (!BEG_STRCASECMP(buff, "scrollbar_floating ")) { if (bool_val) { - Options |= Opt_scrollBar_floating; + Options |= Opt_scrollbar_floating; } else { - Options &= ~(Opt_scrollBar_floating); + Options &= ~(Opt_scrollbar_floating); } } else if (!BEG_STRCASECMP(buff, "scrollbar_right ")) { if (bool_val) { - Options |= Opt_scrollBar_right; + Options |= Opt_scrollbar_right; } else { - Options &= ~(Opt_scrollBar_right); + Options &= ~(Opt_scrollbar_right); } } else if (!BEG_STRCASECMP(buff, "scrollbar_popup ")) { if (bool_val) { @@ -3092,7 +3084,7 @@ init_defaults(void) } #endif - Options = (Opt_scrollBar | Opt_select_trailing_spaces); + Options = (Opt_scrollbar | Opt_select_trailing_spaces); Xdisplay = NULL; display_name = NULL; rs_term_name = NULL; @@ -3129,19 +3121,19 @@ post_parse(void) if (rs_scrollbar_type) { if (!strcasecmp(rs_scrollbar_type, "xterm")) { #ifdef XTERM_SCROLLBAR - scrollBar.type = SCROLLBAR_XTERM; + scrollbar_set_type(SCROLLBAR_XTERM); #else print_error("Support for xterm scrollbars was not compiled in. Sorry."); #endif } else if (!strcasecmp(rs_scrollbar_type, "next")) { #ifdef NEXT_SCROLLBAR - scrollBar.type = SCROLLBAR_NEXT; + scrollbar_set_type(SCROLLBAR_NEXT); #else print_error("Support for NeXT scrollbars was not compiled in. Sorry."); #endif } else if (!strcasecmp(rs_scrollbar_type, "motif")) { #ifdef MOTIF_SCROLLBAR - scrollBar.type = SCROLLBAR_MOTIF; + scrollbar_set_type(SCROLLBAR_MOTIF); #else print_error("Support for motif scrollbars was not compiled in. Sorry."); #endif @@ -3150,12 +3142,7 @@ post_parse(void) } } if (rs_scrollbar_width) { - scrollBar.width = rs_scrollbar_width; - } - if (scrollBar.type == SCROLLBAR_XTERM) { - scrollbar_set_shadow(0); - } else { - scrollbar_set_shadow((Options & Opt_scrollBar_floating) ? 0 : SHADOW); + scrollbar_set_width(rs_scrollbar_width); } /* set any defaults not already set */ @@ -3168,7 +3155,7 @@ post_parse(void) } /* no point having a scrollbar without having any scrollback! */ if (!TermWin.saveLines) - Options &= ~Opt_scrollBar; + Options &= ~Opt_scrollbar; #ifdef PRINTPIPE if (!rs_print_pipe) @@ -3468,7 +3455,7 @@ save_config(char *path) if (rs_desktop != -1) { fprintf(fp, " desktop %d\n", rs_desktop); } - fprintf(fp, " scrollbar_type %s\n", (scrollBar.type == SCROLLBAR_XTERM ? "xterm" : (scrollBar.type == SCROLLBAR_MOTIF ? "motif" : "next"))); + fprintf(fp, " scrollbar_type %s\n", (scrollbar_get_type() == SCROLLBAR_XTERM ? "xterm" : (scrollbar_get_type() == SCROLLBAR_MOTIF ? "motif" : "next"))); fprintf(fp, " scrollbar_width %d\n", scrollbar_anchor_width()); for (i = 0; i < 5; i++) { fprintf(fp, " font %d %s\n", i, rs_font[i]); @@ -3786,15 +3773,15 @@ save_config(char *path) fprintf(fp, " map_alert %d\n", (Options & Opt_mapAlert ? 1 : 0)); fprintf(fp, " visual_bell %d\n", (Options & Opt_visualBell ? 1 : 0)); fprintf(fp, " login_shell %d\n", (Options & Opt_loginShell ? 1 : 0)); - fprintf(fp, " scrollbar %d\n", (Options & Opt_scrollBar ? 1 : 0)); + fprintf(fp, " scrollbar %d\n", (Options & Opt_scrollbar ? 1 : 0)); fprintf(fp, " utmp_logging %d\n", (Options & Opt_utmpLogging ? 1 : 0)); fprintf(fp, " meta8 %d\n", (Options & Opt_meta8 ? 1 : 0)); fprintf(fp, " iconic %d\n", (Options & Opt_iconic ? 1 : 0)); fprintf(fp, " home_on_echo %d\n", (Options & Opt_homeOnEcho ? 1 : 0)); fprintf(fp, " home_on_input %d\n", (Options & Opt_homeOnInput ? 1 : 0)); fprintf(fp, " home_on_refresh %d\n", (Options & Opt_homeOnRefresh ? 1 : 0)); - fprintf(fp, " scrollbar_floating %d\n", (Options & Opt_scrollBar_floating ? 1 : 0)); - fprintf(fp, " scrollbar_right %d\n", (Options & Opt_scrollBar_right ? 1 : 0)); + fprintf(fp, " scrollbar_floating %d\n", (Options & Opt_scrollbar_floating ? 1 : 0)); + fprintf(fp, " scrollbar_right %d\n", (Options & Opt_scrollbar_right ? 1 : 0)); fprintf(fp, " scrollbar_popup %d\n", (Options & Opt_scrollbar_popup ? 1 : 0)); fprintf(fp, " borderless %d\n", (Options & Opt_borderless ? 1 : 0)); fprintf(fp, " backing_store %d\n", (Options & Opt_backing_store ? 1 : 0)); diff --git a/src/options.h b/src/options.h index 5446ef4..087df0f 100644 --- a/src/options.h +++ b/src/options.h @@ -1,27 +1,24 @@ -/* options.h -- Eterm options module header file - * -- 25 July 1997, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _OPTIONS_H_ @@ -57,12 +54,12 @@ # define Opt_mapAlert (1LU << 4) # define Opt_reverseVideo (1LU << 5) # define Opt_utmpLogging (1LU << 6) -# define Opt_scrollBar (1LU << 7) +# define Opt_scrollbar (1LU << 7) # define Opt_meta8 (1LU << 8) # define Opt_exec (1LU << 9) # define Opt_homeOnEcho (1LU << 10) # define Opt_homeOnRefresh (1LU << 11) -# define Opt_scrollBar_right (1LU << 12) +# define Opt_scrollbar_right (1LU << 12) # define Opt_borderless (1LU << 13) # define Opt_backing_store (1LU << 14) # define Opt_noCursor (1LU << 15) @@ -74,7 +71,7 @@ # define Opt_scrollbar_popup (1LU << 21) # define Opt_select_trailing_spaces (1LU << 22) # define Opt_install (1LU << 23) -# define Opt_scrollBar_floating (1LU << 24) +# define Opt_scrollbar_floating (1LU << 24) # define IMOPT_TRANS (1U << 0) # define IMOPT_VIEWPORT (1U << 1) diff --git a/src/pixmap.c b/src/pixmap.c index 8c45a45..c693709 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -1,26 +1,24 @@ -/* pixmap.c -- Eterm pixmap handling routines - - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; @@ -39,16 +37,14 @@ static const char cvs_ident[] = "$Id$"; #include "../libmej/mem.h" #include "../libmej/strings.h" #include "e.h" +#include "icon.h" #include "startup.h" #include "menus.h" #include "options.h" #include "pixmap.h" #include "screen.h" -#ifdef PIXMAP_SCROLLBAR -# include "scrollbar.h" -#endif +#include "scrollbar.h" #include "term.h" -#include "Eterm.xpm" /* Icon pixmap */ #ifdef PIXMAP_SUPPORT Pixmap desktop_pixmap = None; @@ -63,10 +59,8 @@ image_t images[image_max] = {None, 0, NULL, NULL, NULL, NULL}, {None, 0, NULL, NULL, NULL, NULL}, {None, 0, NULL, NULL, NULL, NULL}, -# ifdef PIXMAP_SCROLLBAR {None, 0, NULL, NULL, NULL, NULL}, {None, 0, NULL, NULL, NULL, NULL}, -# endif {None, 0, NULL, NULL, NULL, NULL}, {None, 0, NULL, NULL, NULL, NULL} }; @@ -96,14 +90,12 @@ get_image_type(unsigned short type) case image_right: return "image_right"; break; -# ifdef PIXMAP_SCROLLBAR case image_sb: return "image_sb"; break; case image_sa: return "image_sa"; break; -# endif case image_menu: return "image_menu"; break; @@ -327,10 +319,8 @@ get_iclass_name(unsigned char which) case image_down: return "ETERM_ARROW_DOWN"; break; case image_left: return "ETERM_ARROW_LEFT"; break; case image_right: return "ETERM_ARROW_RIGHT"; break; -# ifdef PIXMAP_SCROLLBAR case image_sb: return "ETERM_TROUGH"; break; case image_sa: return "ETERM_ANCHOR"; break; -# endif case image_menu: return "ETERM_MENU_ITEM"; break; case image_submenu: return "ETERM_MENU_SUBMENU"; break; default: @@ -475,7 +465,6 @@ redraw_image(unsigned char which) { render_simage(images[image_down].current, scrollbar_get_downarrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); scrollbar_show(0); break; -# ifdef PIXMAP_SCROLLBAR case image_sb: render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); scrollbar_show(0); @@ -484,7 +473,6 @@ redraw_image(unsigned char which) { render_simage(images[image_sa].current, scrollbar_get_anchor_win(), scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); scrollbar_show(0); break; -# endif default: D_PIXMAP(("redraw_image(): Bad value %u\n", which)); break; @@ -800,10 +788,8 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short case image_down: case image_left: case image_right: -# ifdef PIXMAP_SCROLLBAR case image_sb: case image_sa: -# endif cidx = (TermWin.focus ? scrollColor : unfocusedScrollColor); break; case image_menu: diff --git a/src/pixmap.h b/src/pixmap.h index 8111648..da13ea0 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -1,26 +1,24 @@ -/* pixmap.h -- Eterm pixmap module header file +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _PIXMAP_H @@ -61,10 +59,8 @@ enum { image_down, image_left, image_right, -#ifdef PIXMAP_SCROLLBAR image_sb, image_sa, -#endif image_menu, image_submenu, image_max @@ -92,6 +88,12 @@ enum { #define ALLOW_AUTO 0x80 #define ALLOW_MASK 0xf0 +/* Image states */ +#define IMAGE_STATE_CURRENT (0) +#define IMAGE_STATE_NORMAL (1) +#define IMAGE_STATE_SELECTED (2) +#define IMAGE_STATE_CLICKED (3) + /* Helper macros */ #define FOREACH_IMAGE(x) do {unsigned char idx; for (idx = 0; idx < image_max; idx++) { x } } while (0) #define image_set_mode(which, bit) do {images[which].mode &= ~(MODE_MASK); images[which].mode |= (bit);} while (0) diff --git a/src/screen.c b/src/screen.c index d6c6fa7..4cbb921 100644 --- a/src/screen.c +++ b/src/screen.c @@ -3163,7 +3163,7 @@ debug_colors(void) void xim_get_position(XPoint *pos) { pos->x = Col2Pixel(screen.col); - if (scrollbar_visible() && !(Options & Opt_scrollBar_right)) + if (scrollbar_is_visible() && !(Options & Opt_scrollbar_right)) pos->x += scrollbar_trough_width(); pos->y = Height2Pixel(screen.row) + TermWin.font->ascent + TermWin.internalBorder; diff --git a/src/scrollbar.c b/src/scrollbar.c index 5b56b77..51bdea6 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -1,26 +1,24 @@ -/* scrollbar.c -- Eterm scrollbar module - - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; @@ -33,230 +31,51 @@ static const char cvs_ident[] = "$Id$"; #include "../libmej/debug.h" #include "../libmej/mem.h" #include "command.h" +#include "draw.h" #include "e.h" #include "events.h" #include "startup.h" #include "options.h" -#ifdef PIXMAP_SCROLLBAR -# include "pixmap.h" -#endif +#include "pixmap.h" #include "screen.h" #include "scrollbar.h" #include "term.h" #include "windows.h" +#error This code is broken. Try back tomorrow. + event_dispatcher_data_t scrollbar_event_data; -#ifdef PIXMAP_SCROLLBAR -scrollbar_t scrollBar = -{0, 1, 0, 1, 0, SCROLLBAR_DEFAULT_TYPE, 0, 0, SB_WIDTH, 0, 0, 0, 0, 0, 0, 0, None, None, None, None}; -#else -scrollbar_t scrollBar = -{0, 1, 0, 1, 0, SCROLLBAR_DEFAULT_TYPE, 0, 0, SB_WIDTH, 0, 0, 0, 0, 0, 0, 0, None}; -#endif +scrollbar_t scrollbar = { + None, None, None, None, + 0, 1, + 0, 1, + 0, + SCROLLBAR_DEFAULT_TYPE, + 0, + SHADOW, + SB_WIDTH, 0, + 0, 0, + 0, 0 +}; #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING short scroll_arrow_delay; #endif -static GC scrollbarGC; -static short last_top = 0, last_bot = 0; /* old (drawn) values */ -#ifdef XTERM_SCROLLBAR /* bitmap scrollbar */ -static GC shadowGC; -static unsigned char xterm_sb_bits[] = -{0xaa, 0x0a, 0x55, 0x05}; /* 12x2 bitmap */ +static GC gc_scrollbar; +static short last_top = 0, last_bot = 0; +#ifdef XTERM_SCROLLBAR +static GC gc_stipple; +static unsigned char xterm_sb_bits[] = {0xaa, 0x0a, 0x55, 0x05}; /* 12x2 bitmap */ #endif #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) -static GC topShadowGC, botShadowGC; - -/* draw triangular up button with a shadow of SHADOW (1 or 2) pixels */ -void -Draw_up_button(int x, int y, int state) -{ - - const unsigned int sz = (scrollBar.width), sz2 = (scrollBar.width / 2); - XPoint pt[3]; - GC top = None, bot = None; - - D_SCROLLBAR(("Draw_up_button(%d, %d, %d)\n", x, y, state)); - - switch (state) { - case +1: - top = topShadowGC; - bot = botShadowGC; - break; - case -1: - top = botShadowGC; - bot = topShadowGC; - break; - case 0: - default: - top = bot = scrollbarGC; - break; - } - - /* fill triangle */ - pt[0].x = x; - pt[0].y = y + sz - 1; - pt[1].x = x + sz - 1; - pt[1].y = y + sz - 1; - pt[2].x = x + sz2; - pt[2].y = y; - XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC, pt, 3, Convex, CoordModeOrigin); - - /* draw base */ - XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - - /* draw shadow */ - pt[1].x = x + sz2 - 1; - pt[1].y = y; - XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - if (scrollbar_get_shadow() > 1) { - pt[0].x++; - pt[0].y--; - pt[1].y++; - XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - } - /* draw shadow */ - pt[0].x = x + sz2; - pt[0].y = y; - pt[1].x = x + sz - 1; - pt[1].y = y + sz - 1; - XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - if (scrollbar_get_shadow() > 1) { - /* doubled */ - pt[0].y++; - pt[1].x--; - pt[1].y--; - XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - } -} - -/* draw triangular down button with a shadow of SHADOW (1 or 2) pixels */ -void -Draw_dn_button(int x, int y, int state) -{ - - const unsigned int sz = (scrollBar.width), sz2 = (scrollBar.width / 2); - XPoint pt[3]; - GC top = None, bot = None; - - D_SCROLLBAR(("Draw_dn_button(%d, %d, %d)\n", x, y, state)); - - switch (state) { - case +1: - top = topShadowGC; - bot = botShadowGC; - break; - case -1: - top = botShadowGC; - bot = topShadowGC; - break; - case 0: - default: - top = bot = scrollbarGC; - break; - } - - /* fill triangle */ - pt[0].x = x; - pt[0].y = y; - pt[1].x = x + sz - 1; - pt[1].y = y; - pt[2].x = x + sz2; - pt[2].y = y + sz; - XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC, pt, 3, Convex, CoordModeOrigin); - - /* draw base */ - XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - - /* draw shadow */ - pt[1].x = x + sz2 - 1; - pt[1].y = y + sz - 1; - XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - if (scrollbar_get_shadow() > 1) { - /* doubled */ - pt[0].x++; - pt[0].y++; - pt[1].y--; - XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - } - /* draw shadow */ - pt[0].x = x + sz2; - pt[0].y = y + sz - 1; - pt[1].x = x + sz - 1; - pt[1].y = y; - XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - if (scrollbar_get_shadow() > 1) { - /* doubled */ - pt[0].y--; - pt[1].x--; - pt[1].y++; - XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); - } -} +static GC gc_top, gc_bottom; #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ void -scrollbar_init(void) -{ - - Cursor cursor; - long mask; - - D_SCROLLBAR(("scrollbar_init(): Initializing all scrollbar elements.\n")); - - Attributes.background_pixel = PixColors[scrollColor]; - Attributes.border_pixel = PixColors[bgColor]; - Attributes.override_redirect = TRUE; - Attributes.save_under = TRUE; - cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); - mask = ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask - | Button1MotionMask | Button2MotionMask | Button3MotionMask; - - scrollBar.win = XCreateWindow(Xdisplay, TermWin.parent, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, - CWOverrideRedirect | CWBackingStore | CWBackPixel | CWBorderPixel | CWColormap, &Attributes); - XDefineCursor(Xdisplay, scrollBar.win, cursor); - XSelectInput(Xdisplay, scrollBar.win, mask); - D_SCROLLBAR(("scrollbar_init(): Created scrollbar window 0x%08x\n", scrollBar.win)); - -#ifdef PIXMAP_SCROLLBAR - if (scrollbar_uparrow_is_pixmapped()) { - scrollBar.up_win = XCreateWindow(Xdisplay, scrollBar.win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, - CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes); - XSelectInput(Xdisplay, scrollBar.up_win, mask); - D_SCROLLBAR(("scrollbar_init(): Created scrollbar up arrow window 0x%08x\n", scrollBar.up_win)); - } - if (scrollbar_downarrow_is_pixmapped()) { - scrollBar.dn_win = XCreateWindow(Xdisplay, scrollBar.win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, - CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes); - XSelectInput(Xdisplay, scrollBar.dn_win, mask); - D_SCROLLBAR(("scrollbar_init(): Created scrollbar down arrow window 0x%08x\n", scrollBar.dn_win)); - } - if (scrollbar_anchor_is_pixmapped()) { - scrollBar.sa_win = XCreateWindow(Xdisplay, scrollBar.win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, - CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes); - XSelectInput(Xdisplay, scrollBar.sa_win, mask); - D_SCROLLBAR(("scrollbar_init(): Created scrollbar anchor window 0x%08x\n", scrollBar.sa_win)); - } -#endif - - if (scrollBar.type == SCROLLBAR_XTERM) { - scrollbar_set_shadow(0); - } else { - scrollbar_set_shadow((Options & Opt_scrollBar_floating) ? 0 : SHADOW); - } - D_SCROLLBAR(("scrollbar_init(): Set scrollbar shadow to %d\n", scrollbar_get_shadow())); - event_register_dispatcher(scrollbar_dispatch_event, scrollbar_event_init_dispatcher); - -} - -void scrollbar_event_init_dispatcher(void) { MEMSET(&scrollbar_event_data, 0, sizeof(event_dispatcher_data_t)); -#if 0 - EVENT_DATA_ADD_HANDLER(scrollbar_event_data, ConfigureNotify, sb_handle_configure_notify); -#endif EVENT_DATA_ADD_HANDLER(scrollbar_event_data, EnterNotify, sb_handle_enter_notify); EVENT_DATA_ADD_HANDLER(scrollbar_event_data, LeaveNotify, sb_handle_leave_notify); EVENT_DATA_ADD_HANDLER(scrollbar_event_data, FocusIn, sb_handle_focus_in); @@ -267,34 +86,16 @@ scrollbar_event_init_dispatcher(void) EVENT_DATA_ADD_HANDLER(scrollbar_event_data, ButtonRelease, sb_handle_button_release); EVENT_DATA_ADD_HANDLER(scrollbar_event_data, MotionNotify, sb_handle_motion_notify); - event_data_add_mywin(&scrollbar_event_data, scrollBar.win); -#ifdef PIXMAP_SCROLLBAR - if (scrollbar_is_pixmapped()) { - event_data_add_mywin(&scrollbar_event_data, scrollBar.up_win); - event_data_add_mywin(&scrollbar_event_data, scrollBar.dn_win); - event_data_add_mywin(&scrollbar_event_data, scrollBar.sa_win); - } -#endif + event_data_add_mywin(&scrollbar_event_data, scrollbar.win); + event_data_add_mywin(&scrollbar_event_data, scrollbar.up_win); + event_data_add_mywin(&scrollbar_event_data, scrollbar.dn_win); + event_data_add_mywin(&scrollbar_event_data, scrollbar.sa_win); event_data_add_parent(&scrollbar_event_data, TermWin.vt); event_data_add_parent(&scrollbar_event_data, TermWin.parent); } -#if 0 -unsigned char -sb_handle_configure_notify(event_t * ev) -{ - - D_EVENTS(("sb_handle_configure_notify(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); - - REQUIRE_RVAL(XEVENT_IS_PARENT(ev, &scrollbar_event_data), 0); - - redraw_image(image_sb); - return 1; -} -#endif - unsigned char sb_handle_enter_notify(event_t * ev) { @@ -303,21 +104,14 @@ sb_handle_enter_notify(event_t * ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &scrollbar_event_data), 0); - if (scrollbar_uparrow_is_pixmapped() && scrollbar_win_is_uparrow(ev->xany.window)) { - images[image_up].current = images[image_up].selected; - render_simage(images[image_up].current, scrollbar_get_uparrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); - } - if (scrollbar_downarrow_is_pixmapped() && scrollbar_win_is_downarrow(ev->xany.window)) { - images[image_down].current = images[image_down].selected; - render_simage(images[image_down].current, scrollbar_get_downarrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); - } - if (scrollbar_anchor_is_pixmapped() && scrollbar_win_is_anchor(ev->xany.window)) { - images[image_sa].current = images[image_sa].selected; - render_simage(images[image_sa].current, scrollbar_get_anchor_win(), scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); - } - if (scrollbar_is_pixmapped() && scrollbar_win_is_scrollbar(ev->xany.window)) { - images[image_sb].current = images[image_sb].selected; - render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); + if (scrollbar_win_is_uparrow(ev->xany.window)) { + scrollbar_draw_uparrow(IMAGE_STATE_SELECTED, 0); + } else if (scrollbar_win_is_downarrow(ev->xany.window)) { + scrollbar_draw_downarrow(IMAGE_STATE_SELECTED, 0); + } else if (scrollbar_win_is_anchor(ev->xany.window)) { + scrollbar_draw_anchor(IMAGE_STATE_SELECTED, 0); + } else if (scrollbar_win_is_trough(ev->xany.window)) { + scrollbar_draw_trough(IMAGE_STATE_SELECTED, 0); } return 1; } @@ -330,21 +124,14 @@ sb_handle_leave_notify(event_t * ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &scrollbar_event_data), 0); - if (scrollbar_uparrow_is_pixmapped() && scrollbar_win_is_uparrow(ev->xany.window)) { - images[image_up].current = images[image_up].norm; - render_simage(images[image_up].current, scrollbar_get_uparrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); - } - if (scrollbar_downarrow_is_pixmapped() && scrollbar_win_is_downarrow(ev->xany.window)) { - images[image_down].current = images[image_down].norm; - render_simage(images[image_down].current, scrollbar_get_downarrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); - } - if (scrollbar_anchor_is_pixmapped() && scrollbar_win_is_anchor(ev->xany.window)) { - images[image_sa].current = images[image_sa].norm; - render_simage(images[image_sa].current, scrollbar_get_anchor_win(), scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); - } - if (scrollbar_is_pixmapped() && scrollbar_win_is_scrollbar(ev->xany.window)) { - images[image_sb].current = images[image_sb].norm; - render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); + if (scrollbar_win_is_uparrow(ev->xany.window)) { + scrollbar_draw_uparrow(IMAGE_STATE_NORMAL, 0); + } else if (scrollbar_win_is_downarrow(ev->xany.window)) { + scrollbar_draw_downarrow(IMAGE_STATE_NORMAL, 0); + } else if (scrollbar_win_is_anchor(ev->xany.window)) { + scrollbar_draw_anchor(IMAGE_STATE_NORMAL, 0); + } else if (scrollbar_win_is_trough(ev->xany.window)) { + scrollbar_draw_trough(IMAGE_STATE_NORMAL, 0); } return 1; } @@ -383,6 +170,16 @@ sb_handle_expose(event_t * ev) while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, Expose, &unused_xevent)); while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, GraphicsExpose, &unused_xevent)); + + if (scrollbar_win_is_uparrow(ev->xany.window)) { + scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, 0); + } else if (scrollbar_win_is_downarrow(ev->xany.window)) { + scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, 0); + } else if (scrollbar_win_is_anchor(ev->xany.window)) { + scrollbar_draw_anchor(IMAGE_STATE_CURRENT, 0); + } else if (scrollbar_win_is_trough(ev->xany.window)) { + scrollbar_draw_trough(IMAGE_STATE_CURRENT, 0); + } return 1; } @@ -396,16 +193,16 @@ sb_handle_button_press(event_t * ev) button_state.bypass_keystate = (ev->xbutton.state & (Mod1Mask | ShiftMask)); button_state.report_mode = (button_state.bypass_keystate ? 0 : ((PrivateModes & PrivMode_mouse_report) ? 1 : 0)); + scrollbar_cancel_motion(); - scrollbar_setNone(); #ifndef NO_SCROLLBAR_REPORT if (button_state.report_mode) { /* Mouse report disabled scrollbar. Arrows send cursor key up/down, trough sends pageup/pagedown */ - if (scrollbar_upButton(ev->xany.window, ev->xbutton.y)) + if (scrollbar_win_is_uparrow(ev->xany.window)) tt_printf((unsigned char *) "\033[A"); - else if (scrollbar_dnButton(ev->xany.window, ev->xbutton.y)) + else if (scrollbar_win_is_downarrow(ev->xany.window)) tt_printf((unsigned char *) "\033[B"); - else + else { switch (ev->xbutton.button) { case Button2: tt_printf((unsigned char *) "\014"); @@ -417,84 +214,67 @@ sb_handle_button_press(event_t * ev) tt_printf((unsigned char *) "\033[5~"); break; } + } } else #endif /* NO_SCROLLBAR_REPORT */ { D_EVENTS(("ButtonPress event for window 0x%08x at %d, %d\n", ev->xany.window, ev->xbutton.x, ev->xbutton.y)); - D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollBar.up_win, scrollBar.dn_win, scrollBar.sa_win, scrollBar.win)); - - if (scrollbar_upButton(ev->xany.window, ev->xbutton.y)) { + D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollbar.up_win, scrollbar.dn_win, scrollbar.sa_win, scrollbar.win)); - if (scrollbar_uparrow_is_pixmapped() && images[image_up].current != images[image_up].clicked) { - images[image_up].current = images[image_up].clicked; - render_simage(images[image_up].current, scrollbar_get_uparrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); - } + if (scrollbar_win_is_uparrow(ev->xany.window)) { + scrollbar_draw_uparrow(IMAGE_STATE_CLICKED, 0); #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; #endif if (scr_page(UP, 1)) { - scrollbar_setUp(); - } - } else if (scrollbar_dnButton(ev->xany.window, ev->xbutton.y)) { - - if (scrollbar_downarrow_is_pixmapped() && images[image_down].current != images[image_down].clicked) { - images[image_down].current = images[image_down].clicked; - render_simage(images[image_down].current, scrollbar_get_downarrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); + scrollbar_set_uparrow_pressed(1); } + } else if (scrollbar_win_is_downarrow(ev->xany.window)) { + scrollbar_draw_downarrow(IMAGE_STATE_CLICKED, 0); #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; #endif if (scr_page(DN, 1)) { - scrollbar_setDn(); + scrollbar_set_downarrow_pressed(1); } } else { - if (scrollbar_anchor_is_pixmapped() && images[image_sa].current != images[image_sa].clicked) { - images[image_sa].current = images[image_sa].clicked; - render_simage(images[image_sa].current, scrollbar_get_anchor_win(), scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); + if (scrollbar_win_is_anchor(ev->xany.window)) { + scrollbar_draw_anchor(IMAGE_STATE_CLICKED, 0); } switch (ev->xbutton.button) { case Button2: button_state.mouse_offset = scrollbar_anchor_height() / 2; /* Align to center */ - if (scrollbar_is_above_anchor(ev->xany.window, ev->xbutton.y) - || scrollbar_is_below_anchor(ev->xany.window, ev->xbutton.y) - || scrollBar.type == SCROLLBAR_XTERM) { + if (!scrollbar_win_is_anchor(ev->xany.window)) { scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); - } - scrollbar_setMotion(); + } else if (scrollbar.type == SCROLLBAR_XTERM) { + scr_move_to(scrollbar.anchor_top + ev->xbutton.y - button_state.mouse_offset, scrollbar_scrollarea_height()); + } + scrollbar_set_motion(1); break; case Button1: - button_state.mouse_offset = ev->xbutton.y - (scrollbar_anchor_is_pixmapped()? 0 : scrollBar.top); - MAX_IT(button_state.mouse_offset, 1); + button_state.mouse_offset = MAX(ev->xbutton.y, 1); /* drop */ case Button3: + D_SCROLLBAR((" -> Scrollbar type is %u\n", scrollbar_get_type())); #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) - if (scrollBar.type == SCROLLBAR_MOTIF || scrollBar.type == SCROLLBAR_NEXT) { + if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) { if (scrollbar_is_above_anchor(ev->xany.window, ev->xbutton.y)) { - if (images[image_sb].current != images[image_sb].clicked) { - images[image_sb].current = images[image_sb].clicked; - render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); - } + scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); scr_page(UP, TermWin.nrow - 1); } else if (scrollbar_is_below_anchor(ev->xany.window, ev->xbutton.y)) { - if (images[image_sb].current != images[image_sb].clicked) { - images[image_sb].current = images[image_sb].clicked; - render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); - } + scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); scr_page(DN, TermWin.nrow - 1); } else { - if (scrollbar_anchor_is_pixmapped() && images[image_sa].current != images[image_sa].clicked) { - images[image_sa].current = images[image_sa].clicked; - render_simage(images[image_sa].current, scrollbar_get_anchor_win(), scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); - } - scrollbar_setMotion(); + scrollbar_draw_anchor(IMAGE_STATE_CLICKED, 0); + scrollbar_set_motion(1); } } #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ #ifdef XTERM_SCROLLBAR - if (scrollBar.type == SCROLLBAR_XTERM) { - scr_page((ev->xbutton.button == Button1 ? DN : UP), (TermWin.nrow * scrollbar_position(ev->xbutton.y) / scrollbar_scrollarea_height())); + if (scrollbar.type == SCROLLBAR_XTERM) { + scr_page((ev->xbutton.button == Button1 ? DN : UP), TermWin.nrow - 1); } #endif /* XTERM_SCROLLBAR */ break; @@ -519,49 +299,34 @@ sb_handle_button_release(event_t * ev) button_state.mouse_offset = 0; button_state.report_mode = (button_state.bypass_keystate ? 0 : ((PrivateModes & PrivMode_mouse_report) ? 1 : 0)); -#ifdef PIXMAP_SCROLLBAR XQueryPointer(Xdisplay, scrollbar_get_win(), &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); - if (scrollbar_uparrow_is_pixmapped()) { - if (scrollbar_win_is_uparrow(child)) { - images[image_up].current = images[image_up].selected; - render_simage(images[image_up].current, scrollbar_get_uparrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); - } else if (images[image_up].current != images[image_up].norm) { - images[image_up].current = images[image_up].norm; - render_simage(images[image_up].current, scrollbar_get_uparrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); - } + if (scrollbar_win_is_uparrow(child)) { + scrollbar_draw_uparrow(IMAGE_STATE_SELECTED, 0); + } else { + scrollbar_draw_uparrow(IMAGE_STATE_NORMAL, 0); } - if (scrollbar_downarrow_is_pixmapped()) { - if (scrollbar_win_is_downarrow(child)) { - images[image_down].current = images[image_down].selected; - render_simage(images[image_down].current, scrollbar_get_downarrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); - } else if (images[image_down].current != images[image_down].norm) { - images[image_down].current = images[image_down].norm; - render_simage(images[image_down].current, scrollbar_get_downarrow_win(), scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); - } + if (scrollbar_win_is_downarrow(child)) { + scrollbar_draw_downarrow(IMAGE_STATE_SELECTED, 0); + } else { + scrollbar_draw_downarrow(IMAGE_STATE_NORMAL, 0); } - if (scrollbar_anchor_is_pixmapped()) { - if (scrollbar_win_is_anchor(child)) { - images[image_sa].current = images[image_sa].selected; - render_simage(images[image_sa].current, scrollbar_get_anchor_win(), scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); - } else if (images[image_sa].current != images[image_sa].norm) { - images[image_sa].current = images[image_sa].norm; - render_simage(images[image_sa].current, scrollbar_get_anchor_win(), scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); - } + if (scrollbar_win_is_anchor(child)) { + scrollbar_draw_anchor(IMAGE_STATE_SELECTED, 0); + } else { + scrollbar_draw_anchor(IMAGE_STATE_NORMAL, 0); } - if (scrollbar_is_pixmapped()) { - if (scrollbar_win_is_scrollbar(child)) { - images[image_sb].current = images[image_sb].selected; - render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); - } else if (images[image_sb].current != images[image_sb].norm) { - images[image_sb].current = images[image_sb].norm; - render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); - } + if (scrollbar_win_is_trough(child)) { + scrollbar_draw_trough(IMAGE_STATE_SELECTED, 0); + } else { + scrollbar_draw_trough(IMAGE_STATE_NORMAL, 0); } -#endif - - if (scrollbar_isUpDn()) { - scrollbar_setNone(); - scrollbar_show(0); + if (scrollbar_arrow_is_pressed()) { + if (scrollbar_uparrow_is_pressed()) { + scrollbar_set_uparrow_pressed(0); + } else { + scrollbar_set_downarrow_pressed(0); + } + scrollbar_set_motion(0); } return 1; } @@ -577,24 +342,19 @@ sb_handle_motion_notify(event_t * ev) return 1; D_EVENTS(("MotionNotify event for window 0x%08x\n", ev->xany.window)); - D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollBar.up_win, scrollBar.dn_win, scrollBar.sa_win, scrollBar.win)); - - if ((scrollbar_win_is_scrollbar(ev->xany.window) -#ifdef PIXMAP_SCROLLBAR - || (scrollbar_anchor_is_pixmapped() && scrollbar_win_is_anchor(ev->xany.window)) -#endif - ) && scrollbar_isMotion()) { + D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollbar.up_win, scrollbar.dn_win, scrollbar.sa_win, scrollbar.win)); + if ((scrollbar_win_is_trough(ev->xany.window) || scrollbar_win_is_anchor(ev->xany.window)) && scrollbar_is_moving()) { Window unused_root, unused_child; int unused_root_x, unused_root_y; unsigned int unused_mask; - while (XCheckTypedWindowEvent(Xdisplay, scrollBar.win, MotionNotify, ev)); - XQueryPointer(Xdisplay, scrollBar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); + while (XCheckTypedWindowEvent(Xdisplay, scrollbar.win, MotionNotify, ev)); + XQueryPointer(Xdisplay, scrollbar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); refresh_count = refresh_limit = 0; scr_refresh(refresh_type); - scrollbar_show(button_state.mouse_offset); + scrollbar_anchor_update_position(button_state.mouse_offset); } return 1; } @@ -608,45 +368,285 @@ scrollbar_dispatch_event(event_t * ev) return (0); } +/******************************************************************************/ + +void +scrollbar_draw_uparrow(unsigned char image_state, unsigned char force_modes) { + + D_SCROLLBAR(("scrollbar_draw_uparrow(%u, 0x%02x)\n", (unsigned int) image_state, (unsigned int) force_modes)); + if (image_state != IMAGE_STATE_CURRENT) { + if ((image_state == IMAGE_STATE_NORMAL) && (images[image_up].current != images[image_up].norm)) { + images[image_up].current = images[image_up].norm; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_up].current != images[image_up].selected)) { + images[image_up].current = images[image_up].selected; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_up].current != images[image_up].clicked)) { + images[image_up].current = images[image_up].clicked; + force_modes = MODE_MASK; + } + } + if (!image_mode_is(image_up, MODE_MASK)) { + /* Solid mode. Redraw every time since it's cheap. */ + XFillRectangle(Xdisplay, scrollbar.up_win, gc_scrollbar, 0, 0, scrollbar_arrow_width(), scrollbar_arrow_height()); + if (scrollbar_uparrow_is_pressed()) { + draw_uparrow_clicked(scrollbar.up_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow()); + } else { + draw_uparrow_raised(scrollbar.up_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow()); + } + return; + } + if (!((images[image_up].mode & MODE_MASK) & (force_modes))) { + return; + } + render_simage(images[image_up].current, scrollbar.up_win, scrollbar_arrow_width(), scrollbar_arrow_height(), image_up, 0); +} + unsigned char -scrollbar_mapping(unsigned char show) -{ +scrollbar_move_uparrow(void) { + static int last_x = -1, last_y = -1, last_w = -1, last_h = -1; + int x, y, w, h; + + D_SCROLLBAR(("scrollbar_move_uparrow()\n")); + x = scrollbar_get_shadow(); + y = scrollbar_up_loc(); + w = scrollbar_arrow_width(); + h = scrollbar_arrow_height(); + if ((last_x == x) && (last_y == y) && (last_w == w) && (last_h == h)) { + D_SCROLLBAR((" -> No move required, returning 0.\n")); + return 0; + } + D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, %d, %d, %d)\n", scrollbar.up_win, x, y, w, h)); + XMoveResizeWindow(Xdisplay, scrollbar.up_win, x, y, w, h); + last_x = x; + last_y = y; + last_w = w; + last_h = h; + return 1; +} - unsigned char change = 0; +void +scrollbar_draw_downarrow(unsigned char image_state, unsigned char force_modes) { - D_SCROLLBAR(("scrollbar_mapping(%d)\n", show)); + D_SCROLLBAR(("scrollbar_draw_downarrow(%u, 0x%02x)\n", (unsigned int) image_state, (unsigned int) force_modes)); + if (image_state != IMAGE_STATE_CURRENT) { + if ((image_state == IMAGE_STATE_NORMAL) && (images[image_down].current != images[image_down].norm)) { + images[image_down].current = images[image_down].norm; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_down].current != images[image_down].selected)) { + images[image_down].current = images[image_down].selected; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_down].current != images[image_down].clicked)) { + images[image_down].current = images[image_down].clicked; + force_modes = MODE_MASK; + } + } + if (!image_mode_is(image_down, MODE_MASK)) { + /* Solid mode. Redraw every time since it's cheap. */ + XFillRectangle(Xdisplay, scrollbar.dn_win, gc_scrollbar, 0, 0, scrollbar_arrow_width(), scrollbar_arrow_height()); + if (scrollbar_downarrow_is_pressed()) { + draw_downarrow_clicked(scrollbar.dn_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow()); + } else { + draw_downarrow_raised(scrollbar.dn_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow()); + } + return; + } + if (!((images[image_down].mode & MODE_MASK) & (force_modes))) { + return; + } + render_simage(images[image_down].current, scrollbar.dn_win, scrollbar_arrow_width(), scrollbar_arrow_height(), image_down, 0); +} + +unsigned char +scrollbar_move_downarrow(void) { + static int last_x = -1, last_y = -1, last_w = -1, last_h = -1; + int x, y, w, h; + + D_SCROLLBAR(("scrollbar_move_downarrow()\n")); + x = scrollbar_get_shadow(); + y = scrollbar_dn_loc(); + w = scrollbar_arrow_width(); + h = scrollbar_arrow_height(); + if ((last_x == x) && (last_y == y) && (last_w == w) && (last_h == h)) { + D_SCROLLBAR((" -> No move required, returning 0.\n")); + return 0; + } + D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, %d, %d, %d)\n", scrollbar.dn_win, x, y, w, h)); + XMoveResizeWindow(Xdisplay, scrollbar.dn_win, x, y, w, h); + last_x = x; + last_y = y; + last_w = w; + last_h = h; + return 1; +} + +void +scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes) { - if (show && !scrollbar_visible()) { - D_SCROLLBAR((" -> Mapping all scrollbar windows. Returning 1.\n")); - scrollBar.state = 1; - XMapWindow(Xdisplay, scrollBar.win); -#ifdef PIXMAP_SCROLLBAR - if (scrollbar_uparrow_is_pixmapped()) { - XMapWindow(Xdisplay, scrollBar.up_win); + D_SCROLLBAR(("scrollbar_draw_anchor(%u, 0x%02x)\n", (unsigned int) image_state, (unsigned int) force_modes)); + if (image_state != IMAGE_STATE_CURRENT) { + if ((image_state == IMAGE_STATE_NORMAL) && (images[image_sa].current != images[image_sa].norm)) { + images[image_sa].current = images[image_sa].norm; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_sa].current != images[image_sa].selected)) { + images[image_sa].current = images[image_sa].selected; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_sa].current != images[image_sa].clicked)) { + images[image_sa].current = images[image_sa].clicked; + force_modes = MODE_MASK; } - if (scrollbar_downarrow_is_pixmapped()) { - XMapWindow(Xdisplay, scrollBar.dn_win); + } + if (!image_mode_is(image_sa, MODE_MASK)) { + /* Solid mode. Redraw every time since it's cheap. */ +#ifdef XTERM_SCROLLBAR + if (scrollbar.type == SCROLLBAR_XTERM) { + XFillRectangle(Xdisplay, scrollbar.sa_win, gc_stipple, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height()); } - if (scrollbar_anchor_is_pixmapped()) { - XMapWindow(Xdisplay, scrollBar.sa_win); +#endif /* XTERM_SCROLLBAR */ +#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) + if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) { + XFillRectangle(Xdisplay, scrollbar.sa_win, gc_scrollbar, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height()); + draw_shadow(scrollbar.sa_win, gc_top, gc_bottom, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(), scrollbar_get_shadow()); } #endif - change = 1; - } else if (!show && scrollbar_visible()) { - D_SCROLLBAR((" -> Unmapping all scrollbar windows. Returning 1.\n")); - scrollBar.state = 0; -#ifdef PIXMAP_SCROLLBAR - if (scrollbar_uparrow_is_pixmapped()) { - XUnmapWindow(Xdisplay, scrollBar.up_win); - } - if (scrollbar_downarrow_is_pixmapped()) { - XUnmapWindow(Xdisplay, scrollBar.dn_win); + return; + } + if (!((images[image_sa].mode & MODE_MASK) & (force_modes))) { + return; + } + if (scrollbar_anchor_height() > 1) { + render_simage(images[image_sa].current, scrollbar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); + } +} + +unsigned char +scrollbar_move_anchor(void) { + static int last_x = -1, last_y = -1, last_w = -1, last_h = -1; + int x, y, w, h; + + D_SCROLLBAR(("scrollbar_move_anchor()\n")); + x = scrollbar_get_shadow(); + y = scrollbar.anchor_top; + w = scrollbar_anchor_width(); + h = scrollbar_anchor_height(); + if ((last_x == x) && (last_y == y) && (last_w == w) && (last_h == h)) { + D_SCROLLBAR((" -> No move required, returning 0.\n")); + return 0; + } + D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, %d, %d, %d)\n", scrollbar.sa_win, x, y, w, h)); + XMoveResizeWindow(Xdisplay, scrollbar.sa_win, x, y, w, h); + last_x = x; + last_y = y; + last_w = w; + last_h = h; + return 1; +} + +void +scrollbar_draw_trough(unsigned char image_state, unsigned char force_modes) { + + D_SCROLLBAR(("scrollbar_draw_trough(%u, 0x%02x)\n", (unsigned int) image_state, (unsigned int) force_modes)); + if (image_state != IMAGE_STATE_CURRENT) { + if ((image_state == IMAGE_STATE_NORMAL) && (images[image_sb].current != images[image_sb].norm)) { + images[image_sb].current = images[image_sb].norm; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_sb].current != images[image_sb].selected)) { + images[image_sb].current = images[image_sb].selected; + force_modes = MODE_MASK; + } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_sb].current != images[image_sb].clicked)) { + images[image_sb].current = images[image_sb].clicked; + force_modes = MODE_MASK; } - if (scrollbar_anchor_is_pixmapped()) { - XUnmapWindow(Xdisplay, scrollBar.sa_win); + } + if (!image_mode_is(image_sb, MODE_MASK)) { + /* Solid mode. Redraw every time since it's cheap. */ + if (Options & Opt_scrollbar_floating) { + XSetWindowBackground(Xdisplay, scrollbar.win, PixColors[bgColor]); + XClearWindow(Xdisplay, scrollbar.win); + } else { + XFillRectangle(Xdisplay, scrollbar.win, gc_scrollbar, 0, 0, scrollbar_trough_width(), scrollbar_trough_height()); + draw_shadow(scrollbar.win, gc_bottom, gc_top, 0, 0, scrollbar_trough_width(), scrollbar_trough_height(), scrollbar_get_shadow()); } -#endif - XUnmapWindow(Xdisplay, scrollBar.win); + return; + } + if (!((images[image_sb].mode & MODE_MASK) & (force_modes))) { + return; + } + render_simage(images[image_sb].current, scrollbar.win, scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); +} + +void +scrollbar_init(int width, int height) +{ + + Cursor cursor; + long mask; + + D_SCROLLBAR(("scrollbar_init(): Initializing all scrollbar elements.\n")); + + Attributes.background_pixel = PixColors[scrollColor]; + Attributes.border_pixel = PixColors[bgColor]; + Attributes.override_redirect = TRUE; + Attributes.save_under = TRUE; + cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); + mask = ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask + | Button1MotionMask | Button2MotionMask | Button3MotionMask; + scrollbar_calc_size(width, height); + scrollbar.anchor_top = scrollbar.scrollarea_start; + scrollbar.anchor_bottom = scrollbar.scrollarea_end; + + /* Create the scrollbar trough window. It will be the parent to the other windows. */ + scrollbar.win = XCreateWindow(Xdisplay, TermWin.parent, ((Options & Opt_scrollbar_right) ? (width - scrollbar_trough_width()) : (0)), 0, scrollbar_trough_width(), height, + 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWBackingStore | CWBackPixel | CWBorderPixel | CWColormap, &Attributes); + XDefineCursor(Xdisplay, scrollbar.win, cursor); + XSelectInput(Xdisplay, scrollbar.win, mask); + D_SCROLLBAR(("scrollbar_init(): Created scrollbar window 0x%08x\n", scrollbar.win)); + + /* Now the up arrow window. */ + scrollbar.up_win = XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar_up_loc(), scrollbar_arrow_width(), scrollbar_arrow_height(), + 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes); + XSelectInput(Xdisplay, scrollbar.up_win, mask); + D_SCROLLBAR(("scrollbar_init(): Created scrollbar up arrow window 0x%08x\n", scrollbar.up_win)); + + /* The down arrow window */ + scrollbar.dn_win = XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar_dn_loc(), scrollbar_arrow_width(), scrollbar_arrow_height(), + 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes); + XSelectInput(Xdisplay, scrollbar.dn_win, mask); + D_SCROLLBAR(("scrollbar_init(): Created scrollbar down arrow window 0x%08x\n", scrollbar.dn_win)); + + /* The anchor window */ + scrollbar.sa_win = XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar.anchor_top, scrollbar_anchor_width(), scrollbar_anchor_height(), + 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes); + XSelectInput(Xdisplay, scrollbar.sa_win, mask); + XMapWindow(Xdisplay, scrollbar.sa_win); + D_SCROLLBAR(("scrollbar_init(): Created scrollbar anchor window 0x%08x\n", scrollbar.sa_win)); + + if (scrollbar_get_type() != SCROLLBAR_XTERM) { + scrollbar_map_arrows(); + } + event_register_dispatcher(scrollbar_dispatch_event, scrollbar_event_init_dispatcher); + + scrollbar_drawing_init(); + scrollbar_draw(MODE_MASK); +} + +unsigned char +scrollbar_mapping(unsigned char show) +{ + + unsigned char change = 0; + + D_SCROLLBAR(("scrollbar_mapping(%d)\n", show)); + + if (show && !scrollbar_is_visible()) { + D_SCROLLBAR((" -> Mapping scrollbar window. Returning 1.\n")); + scrollbar_set_visible(1); + XMapWindow(Xdisplay, scrollbar.win); + change = 1; + } else if (!show && scrollbar_is_visible()) { + D_SCROLLBAR((" -> Unmapping scrollbar window. Returning 1.\n")); + scrollbar_set_visible(0); + XUnmapWindow(Xdisplay, scrollbar.win); change = 1; } else { D_SCROLLBAR((" -> No action required. Returning 0.\n")); @@ -657,302 +657,297 @@ scrollbar_mapping(unsigned char show) void scrollbar_reset(void) { + D_SCROLLBAR(("scrollbar_reset()\n")); +#if 0 + if (gc_scrollbar != None) { + XFreeGC(Xdisplay, gc_scrollbar); + gc_scrollbar = None; + } +# if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) + if (gc_top != None) { + XFreeGC(Xdisplay, gc_top); + gc_top = None; + } + if (gc_bottom != None) { + XFreeGC(Xdisplay, gc_bottom); + gc_bottom = None; + } +# endif +# ifdef XTERM_SCROLLBAR + if (gc_stipple != None) { + XFreeGC(Xdisplay, gc_stipple); + gc_stipple = None; + } +# endif +#endif /* 0 */ + last_top = last_bot = 0; + scrollbar.init = 0; +} - if (scrollbarGC != None) { - XFreeGC(Xdisplay, scrollbarGC); - scrollbarGC = None; - } -#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) - if (topShadowGC != None) { - XFreeGC(Xdisplay, topShadowGC); - topShadowGC = None; - } - if (botShadowGC != None) { - XFreeGC(Xdisplay, botShadowGC); - botShadowGC = None; +void +scrollbar_calc_size(int width, int height) +{ + D_SCROLLBAR(("scrollbar_calc_size(%d, %d), type == %u\n", width, height, scrollbar_get_type())); + scrollbar.scrollarea_start = 0; + scrollbar.scrollarea_end = height; + scrollbar.up_arrow_loc = 0; + scrollbar.down_arrow_loc = 0; +#ifdef MOTIF_SCROLLBAR + if (scrollbar.type == SCROLLBAR_MOTIF) { + /* arrows are as high as wide - leave 1 pixel gap */ + scrollbar.scrollarea_start += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollbar.scrollarea_end -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollbar.up_arrow_loc = scrollbar_get_shadow(); + scrollbar.down_arrow_loc = scrollbar.scrollarea_end + 1; } #endif -#ifdef XTERM_SCROLLBAR - if (shadowGC != None) { - XFreeGC(Xdisplay, shadowGC); - shadowGC = None; +#ifdef NEXT_SCROLLBAR + if (scrollbar.type == SCROLLBAR_NEXT) { + scrollbar.scrollarea_start = scrollbar_get_shadow(); + scrollbar.scrollarea_end -= (scrollbar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); + scrollbar.up_arrow_loc = scrollbar.scrollarea_end + 1; + scrollbar.down_arrow_loc = scrollbar.scrollarea_end + scrollbar.width + 2; } #endif - last_top = last_bot = 0; - scrollBar.init = 0; + scrollbar.height = height - (2 * scrollbar_get_shadow()); + scrollbar.win_width = scrollbar.width + (2 * scrollbar_get_shadow()); + scrollbar.win_height = height; + D_X11((" -> New scrollbar width/height == %hux%hu, win_width/height == %hux%hu\n", scrollbar.width, scrollbar.height, scrollbar.win_width, scrollbar.win_height)); + D_X11((" -> New scroll area start/end == %hu - %hu, up_arrow_loc == %hu, down_arrow_loc == %hu\n", scrollbar.scrollarea_start, scrollbar.scrollarea_end, + scrollbar.up_arrow_loc, scrollbar.down_arrow_loc)); } void scrollbar_resize(int width, int height) { - - if (!scrollbar_visible()) { + if (!scrollbar_is_visible()) { return; } D_SCROLLBAR(("scrollbar_resize(%d, %d)\n", width, height)); - scrollBar.beg = 0; - scrollBar.end = height; -#ifdef MOTIF_SCROLLBAR - if (scrollBar.type == SCROLLBAR_MOTIF) { - /* arrows are as high as wide - leave 1 pixel gap */ - scrollBar.beg += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; - scrollBar.end -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; - } -#endif -#ifdef NEXT_SCROLLBAR - if (scrollBar.type == SCROLLBAR_NEXT) { - scrollBar.beg = scrollbar_get_shadow(); - scrollBar.end -= (scrollBar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); - } -#endif - width -= scrollbar_trough_width(); - XMoveResizeWindow(Xdisplay, scrollBar.win, ((Options & Opt_scrollBar_right) ? (width) : (0)), 0, scrollbar_trough_width(), height); - scrollBar.init = 0; - scrollBar.height = height - (2 * scrollbar_get_shadow()); - scrollBar.win_width = scrollbar_trough_width(); - scrollBar.win_height = height; - D_X11((" -> New scrollbar width/height == %hux%hu, win_width/height == %hux%hu\n", scrollBar.width, scrollBar.height, scrollBar.win_width, scrollBar.win_height)); - scrollbar_show(0); + scrollbar_calc_size(width, height); + D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, %d, %d, %d)\n", scrollbar.win, ((Options & Opt_scrollbar_right) ? (width - scrollbar_trough_width()) : (0)), 0, scrollbar_trough_width(), height)); + XMoveResizeWindow(Xdisplay, scrollbar.win, ((Options & Opt_scrollbar_right) ? (width - scrollbar_trough_width()) : (0)), 0, scrollbar_trough_width(), height); + scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK); + scrollbar_reposition_and_draw(MODE_MASK); + scrollbar.init = 0; } void scrollbar_change_type(unsigned int type) { + D_SCROLLBAR(("scrollbar_change_type(0x%02x): Current scrollbar type is 0x%02x\n", type, scrollbar_get_type())); + if (scrollbar_get_type() == type) { + /* Nothing to do. */ + return; + } +#ifdef XTERM_SCROLLBAR + if (scrollbar.type == SCROLLBAR_XTERM) { + scrollbar_map_arrows(); + } +#endif #ifdef MOTIF_SCROLLBAR - if (scrollBar.type == SCROLLBAR_MOTIF) { + if (scrollbar.type == SCROLLBAR_MOTIF) { /* arrows are as high as wide - leave 1 pixel gap */ - scrollBar.beg -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; - scrollBar.end += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollbar.scrollarea_start -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollbar.scrollarea_end += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; } #endif #ifdef NEXT_SCROLLBAR - if (scrollBar.type == SCROLLBAR_NEXT) { - scrollBar.beg = 0; - scrollBar.end += (scrollBar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); + if (scrollbar.type == SCROLLBAR_NEXT) { + scrollbar.scrollarea_start = 0; + scrollbar.scrollarea_end += (scrollbar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); } #endif scrollbar_reset(); - scrollBar.type = type; + scrollbar.type = type; +#ifdef XTERM_SCROLLBAR + if (scrollbar.type == SCROLLBAR_XTERM) { + scrollbar_unmap_arrows(); + } +#endif #ifdef MOTIF_SCROLLBAR if (type == SCROLLBAR_MOTIF) { - /* arrows are as high as wide - leave 1 pixel gap */ - scrollBar.beg += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; - scrollBar.end -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollbar.scrollarea_start += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollbar.scrollarea_end -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollbar.up_arrow_loc = scrollbar_get_shadow(); + scrollbar.down_arrow_loc = scrollbar.scrollarea_end + 1; } #endif #ifdef NEXT_SCROLLBAR if (type == SCROLLBAR_NEXT) { - scrollBar.beg = scrollbar_get_shadow(); - scrollBar.end -= (scrollBar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); + scrollbar.scrollarea_start = scrollbar_get_shadow(); + scrollbar.scrollarea_end -= (scrollbar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); + scrollbar.up_arrow_loc = scrollbar.scrollarea_end + 1; + scrollbar.down_arrow_loc = scrollbar.scrollarea_end + scrollbar.width + 2; } #endif - scrollbar_show(1); + scrollbar_reposition_and_draw(MODE_MASK); } void scrollbar_change_width(unsigned short width) { + D_SCROLLBAR(("scrollbar_change_width(%hu): Current width is %hu\n", width, scrollbar_get_width())); if (width == 0) { width = SB_WIDTH; } - if (width == scrollBar.width) { + if (width == scrollbar.width) { /* Nothing to do, so return. */ return; } scrollbar_reset(); - scrollBar.width = width; + scrollbar.width = width; parent_resize(); - scrollbar_show(1); } -unsigned char -scrollbar_show(short mouseoffset) -{ +void +scrollbar_drawing_init(void) { - unsigned char xsb = 0, force_update = 0; - static int focus = -1; + XGCValues gcvalue; - if (!scrollbar_visible()) { - return 0; + D_SCROLLBAR(("scrollbar_drawing_init()\n")); +#ifdef XTERM_SCROLLBAR + gcvalue.stipple = XCreateBitmapFromData(Xdisplay, scrollbar.win, (char *) xterm_sb_bits, 12, 2); + if (!gcvalue.stipple) { + print_error("Unable to create xterm scrollbar bitmap."); + if (scrollbar_get_type() == SCROLLBAR_XTERM) { + scrollbar_set_type(SCROLLBAR_MOTIF); + } + } else { + gcvalue.fill_style = FillOpaqueStippled; + gcvalue.foreground = PixColors[fgColor]; + gcvalue.background = PixColors[bgColor]; + gc_scrollbar = XCreateGC(Xdisplay, scrollbar.win, GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); + gcvalue.foreground = PixColors[borderColor]; + gc_stipple = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); } +#endif /* XTERM_SCROLLBAR */ - D_SCROLLBAR(("scrollbar_show(%d)\n", mouseoffset)); +#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) + gcvalue.foreground = PixColors[scrollColor]; + gc_scrollbar = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); + gcvalue.foreground = PixColors[topShadowColor]; + gc_top = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); + gcvalue.foreground = PixColors[bottomShadowColor]; + gc_bottom = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); +#endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ +} - if (scrollbarGC == None) { +unsigned char +scrollbar_set_focus(short has_focus) { + + static short focus = -1; + XGCValues gcvalue; + + D_SCROLLBAR(("scrollbar_set_focus(%hd): focus == %hd\n", has_focus, focus)); + if (focus != has_focus) { + focus = has_focus; + gcvalue.foreground = PixColors[focus ? scrollColor : unfocusedScrollColor]; + XChangeGC(Xdisplay, gc_scrollbar, GCForeground, &gcvalue); + gcvalue.foreground = PixColors[focus ? topShadowColor : unfocusedTopShadowColor]; + XChangeGC(Xdisplay, gc_top, GCForeground, &gcvalue); + gcvalue.foreground = PixColors[focus ? bottomShadowColor : unfocusedBottomShadowColor]; + XChangeGC(Xdisplay, gc_bottom, GCForeground, &gcvalue); + return (1); + } + return (0); +} - XGCValues gcvalue; +unsigned char +scrollbar_anchor_update_position(short mouseoffset) { -#ifdef XTERM_SCROLLBAR - if (scrollBar.type == SCROLLBAR_XTERM) { - gcvalue.stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win, (char *) xterm_sb_bits, 12, 2); - if (!gcvalue.stipple) { - print_error("Unable to create xterm scrollbar bitmap. Reverting to default scrollbar."); - scrollBar.type = SCROLLBAR_MOTIF; - } else { - gcvalue.fill_style = FillOpaqueStippled; - gcvalue.foreground = PixColors[fgColor]; - gcvalue.background = PixColors[bgColor]; - scrollbarGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); - gcvalue.foreground = PixColors[borderColor]; - shadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue); - } - } -#endif /* XTERM_SCROLLBAR */ + int top = (TermWin.nscrolled - TermWin.view_start); + int bot = top + (TermWin.nrow - 1); + int len = MAX((TermWin.nscrolled + (TermWin.nrow - 1)), 1); -#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) - if (scrollBar.type == SCROLLBAR_MOTIF || scrollBar.type == SCROLLBAR_NEXT) { + D_SCROLLBAR(("scrollbar_anchor_update_position(%hd): top == %d, bot == %d, len == %d\n", mouseoffset, top, bot, len)); + scrollbar.anchor_top = (scrollbar.scrollarea_start + (top * scrollbar_scrollarea_height()) / len); + scrollbar.anchor_bottom = (scrollbar.scrollarea_start + (bot * scrollbar_scrollarea_height()) / len); - gcvalue.foreground = (Xdepth <= 2 ? PixColors[fgColor] : PixColors[scrollColor]); - scrollbarGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue); + if (rs_min_anchor_size && scrollbar.type != SCROLLBAR_XTERM) { + if ((scrollbar_scrollarea_height() > rs_min_anchor_size) && (scrollbar_anchor_height() < rs_min_anchor_size)) { - if ((Options & Opt_scrollBar_floating) && !scrollbar_is_pixmapped() && !background_is_pixmap()) { - XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[bgColor]); + int grab_point = scrollbar.anchor_top + mouseoffset; + + if (grab_point - mouseoffset < scrollbar.scrollarea_start) { + scrollbar.anchor_top = scrollbar.scrollarea_start; + scrollbar.anchor_bottom = rs_min_anchor_size + scrollbar.scrollarea_start; + } else if (scrollbar.anchor_top + rs_min_anchor_size > scrollbar.scrollarea_end) { + scrollbar.anchor_top = scrollbar.scrollarea_end - rs_min_anchor_size; + scrollbar.anchor_bottom = scrollbar.scrollarea_end; } else { - render_simage(images[image_sb].current, scrollBar.win, scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); - if (image_mode_is(image_sb, MODE_AUTO)) { - enl_ipc_sync(); - XClearWindow(Xdisplay, scrollBar.win); - } + scrollbar.anchor_top = grab_point - mouseoffset; + scrollbar.anchor_bottom = scrollbar.anchor_top + rs_min_anchor_size; + } + if (scrollbar.anchor_bottom == scrollbar.scrollarea_end) { + scr_move_to(scrollbar.scrollarea_end, scrollbar_scrollarea_height()); + scr_refresh(DEFAULT_REFRESH); } - gcvalue.foreground = PixColors[topShadowColor]; - topShadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue); - - gcvalue.foreground = PixColors[bottomShadowColor]; - botShadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue); } -#endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ } -#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) - else if (image_mode_is(image_sb, (MODE_TRANS | MODE_VIEWPORT)) || (scrollBar.init == 0)) { - render_simage(images[image_sb].current, scrollBar.win, scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); + if ((scrollbar.anchor_top == last_top) && (scrollbar.anchor_bottom == last_bot) && (scrollbar.init)) { + return 0; + } + if (scrollbar_move_anchor()) { + scrollbar_draw_anchor(IMAGE_STATE_CURRENT, MODE_MASK); } - if (scrollBar.type == SCROLLBAR_MOTIF || scrollBar.type == SCROLLBAR_NEXT) { - if (focus != TermWin.focus) { - XGCValues gcvalue; - - focus = TermWin.focus; - gcvalue.foreground = PixColors[focus ? scrollColor : unfocusedScrollColor]; - XChangeGC(Xdisplay, scrollbarGC, GCForeground, &gcvalue); - gcvalue.foreground = PixColors[focus ? topShadowColor : unfocusedTopShadowColor]; - XChangeGC(Xdisplay, topShadowGC, GCForeground, &gcvalue); + last_top = scrollbar.anchor_top; + last_bot = scrollbar.anchor_bottom; + return 1; +} - gcvalue.foreground = PixColors[focus ? bottomShadowColor : unfocusedBottomShadowColor]; - XChangeGC(Xdisplay, botShadowGC, GCForeground, &gcvalue); - force_update = 1; - } - } -#endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ +void +scrollbar_draw(unsigned char force_modes) +{ + D_SCROLLBAR(("scrollbar_draw(0x%02x)\n", force_modes)); + scrollbar_draw_trough(IMAGE_STATE_CURRENT, force_modes); + scrollbar_draw_anchor(IMAGE_STATE_CURRENT, force_modes); + scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, force_modes); + scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, force_modes); + scrollbar.init = 1; +} - if (mouseoffset) { - int top = (TermWin.nscrolled - TermWin.view_start); - int bot = top + (TermWin.nrow - 1); - int len = max((TermWin.nscrolled + (TermWin.nrow - 1)), 1); - - scrollBar.top = (scrollBar.beg + (top * scrollbar_scrollarea_height()) / len); - scrollBar.bot = (scrollBar.beg + (bot * scrollbar_scrollarea_height()) / len); - - if (rs_min_anchor_size && scrollBar.type != SCROLLBAR_XTERM) { - if ((scrollbar_scrollarea_height() > rs_min_anchor_size) && (scrollbar_anchor_height() < rs_min_anchor_size)) { - - int grab_point = scrollBar.top + mouseoffset; - - if (grab_point - mouseoffset < scrollBar.beg) { - scrollBar.top = scrollBar.beg; - scrollBar.bot = rs_min_anchor_size + scrollBar.beg; - } else if (scrollBar.top + rs_min_anchor_size > scrollBar.end) { - scrollBar.top = scrollBar.end - rs_min_anchor_size; - scrollBar.bot = scrollBar.end; - } else { - scrollBar.top = grab_point - mouseoffset; - scrollBar.bot = scrollBar.top + rs_min_anchor_size; - } - if (scrollBar.bot == scrollBar.end) { - scr_move_to(scrollBar.end, scrollbar_scrollarea_height()); - scr_refresh(DEFAULT_REFRESH); - } - } - } - /* no change */ - if (!force_update && (scrollBar.top == last_top) && (scrollBar.bot == last_bot)) - return 0; +void +scrollbar_reposition_and_draw(unsigned char force_modes) +{ + D_SCROLLBAR(("scrollbar_reposition_and_draw(0x%02x)\n", force_modes)); + if (scrollbar_move_uparrow()) { + scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, force_modes); } -#ifdef XTERM_SCROLLBAR - xsb = ((scrollBar.type == SCROLLBAR_XTERM) && (Options & Opt_scrollBar_right)) ? 1 : 0; -#endif - if (last_top < scrollBar.top) { - XClearArea(Xdisplay, scrollBar.win, scrollbar_get_shadow() + xsb, last_top, scrollBar.width, (scrollBar.top - last_top), False); + if (scrollbar_move_downarrow()) { + scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, force_modes); } - if (scrollBar.bot < last_bot) { - XClearArea(Xdisplay, scrollBar.win, scrollbar_get_shadow() + xsb, scrollBar.bot, scrollBar.width, (last_bot - scrollBar.bot), False); + if (!scrollbar_anchor_update_position(1)) { + scrollbar_draw_anchor(IMAGE_STATE_CURRENT, force_modes); } -#ifdef PIXMAP_SCROLLBAR - if (scrollbar_anchor_is_pixmapped()) { - if ((last_top != scrollBar.top) || (scrollBar.bot != last_bot) || (scrollBar.init == 0)) { - XMoveResizeWindow(Xdisplay, scrollBar.sa_win, scrollbar_get_shadow(), scrollBar.top, scrollBar.width, scrollbar_anchor_height()); - } - if (scrollbar_anchor_height() > 1) { - render_simage(images[image_sa].current, scrollBar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0); - } - } -#endif - last_top = scrollBar.top; - last_bot = scrollBar.bot; + scrollbar.init = 1; +} - /* scrollbar anchor */ -#ifdef XTERM_SCROLLBAR - if (scrollBar.type == SCROLLBAR_XTERM) { - XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC, xsb + 1, scrollBar.top, scrollBar.width - 2, scrollbar_anchor_height()); - XDrawLine(Xdisplay, scrollBar.win, shadowGC, xsb ? 0 : scrollBar.width, scrollBar.beg, xsb ? 0 : scrollBar.width, scrollBar.end); +unsigned char +scrollbar_show(short mouseoffset) +{ + unsigned char force_update = 0; + + if (!scrollbar_is_visible()) { + return 0; } -#endif /* XTERM_SCROLLBAR */ -#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) - if (scrollBar.type == SCROLLBAR_MOTIF || scrollBar.type == SCROLLBAR_NEXT) { - if (!scrollbar_anchor_is_pixmapped()) { - /* Draw the scrollbar anchor in if it's not pixmapped. */ - if (scrollbar_is_pixmapped()) { - XSetTSOrigin(Xdisplay, scrollbarGC, scrollbar_get_shadow(), scrollBar.top); - XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC, scrollbar_get_shadow(), scrollBar.top, scrollBar.width, scrollbar_anchor_height()); - XSetTSOrigin(Xdisplay, scrollbarGC, 0, 0); - } else { - XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC, scrollbar_get_shadow(), scrollBar.top, scrollBar.width, scrollbar_anchor_height()); - } - } - /* Draw trough shadow */ - if (scrollbar_get_shadow() && !scrollbar_is_pixmapped()) { - Draw_Shadow(scrollBar.win, botShadowGC, topShadowGC, 0, 0, scrollbar_trough_width(), scrollbar_trough_height()); - } - /* Draw anchor shadow */ - if (!scrollbar_anchor_is_pixmapped()) { - Draw_Shadow(scrollBar.win, topShadowGC, botShadowGC, scrollbar_get_shadow(), scrollBar.top, scrollBar.width, scrollbar_anchor_height()); - } - /* Draw scrollbar arrows */ - if (scrollbar_uparrow_is_pixmapped()) { - if (scrollBar.init == 0) { - XMoveResizeWindow(Xdisplay, scrollBar.up_win, scrollbar_get_shadow(), scrollbar_up_loc(), scrollbar_arrow_width(), scrollbar_arrow_height()); - render_simage(images[image_up].current, scrollBar.up_win, scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); - } - } else { - Draw_up_button(scrollbar_get_shadow(), scrollbar_up_loc(), (scrollbar_isUp()? -1 : +1)); - } - if (scrollbar_downarrow_is_pixmapped()) { - if (scrollBar.init == 0) { - XMoveResizeWindow(Xdisplay, scrollBar.dn_win, scrollbar_get_shadow(), scrollbar_dn_loc(), scrollbar_arrow_width(), scrollbar_arrow_height()); - render_simage(images[image_down].current, scrollBar.dn_win, scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); - } - } else { - Draw_dn_button(scrollbar_get_shadow(), scrollbar_dn_loc(), (scrollbar_isDn()? -1 : +1)); - } + D_SCROLLBAR(("scrollbar_show(%hd)\n", mouseoffset)); + + force_update = scrollbar_set_focus(TermWin.focus); + if (!(scrollbar.init)) { + force_update++; } - if (image_mode_is(image_up, MODE_AUTO) || image_mode_is(image_down, MODE_AUTO) || image_mode_is(image_sb, MODE_AUTO) || image_mode_is(image_sa, MODE_AUTO)) { - // enl_ipc_sync(); + if (mouseoffset) { + force_update += scrollbar_anchor_update_position(mouseoffset); } -#endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ - - scrollBar.init = 1; + scrollbar_draw_trough(IMAGE_STATE_CURRENT, (force_update) ? (MODE_TRANS | MODE_VIEWPORT) : (MODE_MASK)); + scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, (force_update) ? (MODE_TRANS | MODE_VIEWPORT) : (MODE_MASK)); + scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, (force_update) ? (MODE_TRANS | MODE_VIEWPORT) : (MODE_MASK)); + scrollbar.init = 1; return 1; } diff --git a/src/scrollbar.h b/src/scrollbar.h index 7730e7a..40132f0 100644 --- a/src/scrollbar.h +++ b/src/scrollbar.h @@ -1,137 +1,114 @@ -/* scrollbar.h -- Eterm scrollbar module header file +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _SCROLLBAR_H -# define _SCROLLBAR_H +#define _SCROLLBAR_H -# include <X11/Xfuncproto.h> -# include <ctype.h> -# ifdef PIXMAP_SCROLLBAR -# include <Imlib.h> -# endif -# include "events.h" +#include <X11/Xfuncproto.h> +#include <ctype.h> +#include <Imlib.h> +#include "events.h" /************ Macros and Definitions ************/ /* Scrollbar types we support */ -# define SCROLLBAR_MOTIF 1 -# define SCROLLBAR_XTERM 2 -# define SCROLLBAR_NEXT 3 +#define SCROLLBAR_MOTIF 1 +#define SCROLLBAR_XTERM 2 +#define SCROLLBAR_NEXT 3 + +/* Scrollbar states */ +#define SCROLLBAR_STATE_VISIBLE (1UL << 0) +#define SCROLLBAR_STATE_MOVING (1UL << 1) +#define SCROLLBAR_STATE_UP_CLICKED (1UL << 2) +#define SCROLLBAR_STATE_DOWN_CLICKED (1UL << 3) /* Scrollbar state macros */ -#define scrollbar_visible() (scrollBar.state) -#define scrollbar_isMotion() (scrollBar.state == 'm') -#define scrollbar_isUp() (scrollBar.state == 'U') -#define scrollbar_isDn() (scrollBar.state == 'D') -#define scrollbar_isUpDn() (isupper(scrollBar.state)) -#define scrollbar_setNone() do { D_SCROLLBAR(("scrollbar_setNone(): Cancelling motion.\n")); scrollBar.state = 1; } while (0) -#define scrollbar_setMotion() do { D_SCROLLBAR(("scrollbar_setMotion()\n")); scrollBar.state = 'm'; } while (0) -#define scrollbar_setUp() do { D_SCROLLBAR(("scrollbar_setUp()\n")); scrollBar.state = 'U'; } while (0) -#define scrollbar_setDn() do { D_SCROLLBAR(("scrollbar_setNone()\n")); scrollBar.state = 'D'; } while (0) +#define scrollbar_is_visible() (scrollbar.state & SCROLLBAR_STATE_VISIBLE) +#define scrollbar_is_moving() (scrollbar.state & SCROLLBAR_STATE_MOVING) +#define scrollbar_uparrow_is_pressed() (scrollbar.state & SCROLLBAR_STATE_UP_CLICKED) +#define scrollbar_downarrow_is_pressed() (scrollbar.state & SCROLLBAR_STATE_DOWN_CLICKED) +#define scrollbar_arrow_is_pressed() (scrollbar.state & (SCROLLBAR_STATE_UP_CLICKED | SCROLLBAR_STATE_DOWN_CLICKED)) +#define scrollbar_cancel_motion() (scrollbar.state &= ~(SCROLLBAR_STATE_UP_CLICKED | SCROLLBAR_STATE_DOWN_CLICKED | SCROLLBAR_STATE_MOVING)) +#define scrollbar_set_visible(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_VISIBLE) : (scrollbar.state &= ~(SCROLLBAR_STATE_VISIBLE))) +#define scrollbar_set_motion(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_MOVING) : (scrollbar.state &= ~(SCROLLBAR_STATE_MOVING))) +#define scrollbar_set_uparrow_pressed(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_UP_CLICKED) : (scrollbar.state &= ~(SCROLLBAR_STATE_UP_CLICKED))) +#define scrollbar_set_downarrow_pressed(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_DOWN_CLICKED) : (scrollbar.state &= ~(SCROLLBAR_STATE_DOWN_CLICKED))) /* The various scrollbar elements */ -#ifdef PIXMAP_SCROLLBAR -# define scrollbar_win_is_scrollbar(w) (scrollbar_visible() && (w) == scrollBar.win) -# define scrollbar_win_is_uparrow(w) ((w) == scrollBar.up_win) -# define scrollbar_win_is_downarrow(w) ((w) == scrollBar.dn_win) -# define scrollbar_win_is_anchor(w) ((w) == scrollBar.sa_win) -# define scrollbar_is_pixmapped() (images[image_sb].mode & MODE_MASK) -# define scrollbar_uparrow_is_pixmapped() (images[image_up].mode & MODE_MASK) -# define scrollbar_downarrow_is_pixmapped() (images[image_down].mode & MODE_MASK) -# define scrollbar_anchor_is_pixmapped() (images[image_sa].mode & MODE_MASK) -# define scrollbar_upButton(w, y) ( scrollbar_uparrow_is_pixmapped() ? scrollbar_win_is_uparrow(w) \ - : ((scrollBar.type == SCROLLBAR_NEXT && (y) > scrollBar.end && (y) <= scrollbar_dn_loc()) \ - || (scrollBar.type != SCROLLBAR_NEXT && (y) < scrollBar.beg))) -# define scrollbar_dnButton(w, y) ( scrollbar_downarrow_is_pixmapped() ? scrollbar_win_is_downarrow(w) \ - : ((scrollBar.type == SCROLLBAR_NEXT && (y) > scrollbar_dn_loc()) \ - || (scrollBar.type != SCROLLBAR_NEXT && (y) > scrollBar.end))) -#else -# define scrollbar_win_is_scrollbar(w) (scrollbar_visible() && (w) == scrollBar.win) -# define scrollbar_win_is_uparrow(w) (0) -# define scrollbar_win_is_downarrow(w) (0) -# define scrollbar_win_is_anchor(w) (0) -# define scrollbar_is_pixmapped() (0) -# define scrollbar_uparrow_is_pixmapped() (0) -# define scrollbar_downarrow_is_pixmapped() (0) -# define scrollbar_anchor_is_pixmapped() (0) -# define scrollbar_upButton(w, y) ((scrollBar.type == SCROLLBAR_NEXT && (y) > scrollBar.end && (y) <= scrollbar_dn_loc()) \ - || (scrollBar.type != SCROLLBAR_NEXT && (y) < scrollBar.beg)) -# define scrollbar_dnButton(w, y) ((scrollBar.type == SCROLLBAR_NEXT && (y) > scrollbar_dn_loc()) \ - || (scrollBar.type != SCROLLBAR_NEXT && (y) > scrollBar.end)) -#endif +#define scrollbar_win_is_trough(w) (scrollbar_is_visible() && (w) == scrollbar.win) +#define scrollbar_win_is_uparrow(w) ((w) == scrollbar.up_win) +#define scrollbar_win_is_downarrow(w) ((w) == scrollbar.dn_win) +#define scrollbar_win_is_anchor(w) ((w) == scrollbar.sa_win) +#define scrollbar_is_pixmapped() (images[image_sb].mode & MODE_MASK) +#define scrollbar_uparrow_is_pixmapped() (images[image_up].mode & MODE_MASK) +#define scrollbar_downarrow_is_pixmapped() (images[image_down].mode & MODE_MASK) +#define scrollbar_anchor_is_pixmapped() (images[image_sa].mode & MODE_MASK) /* Scrollbar dimensions */ -#define scrollbar_scrollarea_height() (scrollBar.end - scrollBar.beg) -#define scrollbar_anchor_width() (scrollBar.width) -#define scrollbar_anchor_height() (scrollBar.bot - scrollBar.top) -#define scrollbar_trough_width() (scrollBar.width + 2 * scrollBar.shadow) -#define scrollbar_trough_height() (scrollBar.end + ((scrollBar.type == SCROLLBAR_NEXT) ? (2 * (scrollBar.width + 1) + scrollBar.shadow) \ - : ((scrollBar.width + 1) + scrollBar.shadow))) -#define scrollbar_arrow_width() (scrollBar.width) -#define scrollbar_arrow_height() (scrollBar.width) -#define scrollbar_anchor_max_height() ((menubar_visible()) ? (TermWin.height) : (TermWin.height - ((scrollBar.width + 1) + scrollBar.shadow))) +#define scrollbar_scrollarea_height() (scrollbar.scrollarea_end - scrollbar.scrollarea_start) +#define scrollbar_anchor_width() ((scrollbar.type == SCROLLBAR_XTERM) ? (scrollbar.win_width) : (scrollbar.width)) +#define scrollbar_anchor_height() (scrollbar.anchor_bottom - scrollbar.anchor_top) +#define scrollbar_trough_width() (scrollbar.win_width) +#define scrollbar_trough_height() (scrollbar.win_height) +#define scrollbar_arrow_width() (scrollbar.width) +#define scrollbar_arrow_height() (scrollbar.width) /* Scrollbar positions */ -#define scrollbar_is_above_anchor(w, y) ((y) < scrollBar.top && !scrollbar_win_is_anchor(w)) -#define scrollbar_is_below_anchor(w, y) ((y) > scrollBar.bot && !scrollbar_win_is_anchor(w)) -#define scrollbar_position(y) ((y) - scrollBar.beg) -#define scrollbar_up_loc() (scrollbar_uparrow_is_pixmapped() ? ((scrollBar.type == SCROLLBAR_NEXT) ? (scrollBar.end + 1) : (scrollBar.shadow)) \ - : ((scrollBar.type == SCROLLBAR_NEXT) ? (scrollBar.end + 1) : (scrollBar.shadow))) -#define scrollbar_dn_loc() (scrollbar_downarrow_is_pixmapped() \ - ? ((scrollBar.type == SCROLLBAR_NEXT) ? (scrollBar.end + scrollBar.width + 2) : (scrollBar.end + 1)) \ - : ((scrollBar.type == SCROLLBAR_NEXT) ? (scrollBar.end + scrollBar.width + 2) : (scrollBar.end + 1))) +#define scrollbar_is_above_anchor(w, y) (!scrollbar_win_is_anchor(w) && ((y) < scrollbar.anchor_top)) +#define scrollbar_is_below_anchor(w, y) (!scrollbar_win_is_anchor(w) && ((y) > scrollbar.anchor_bottom)) +#define scrollbar_position(y) ((y) - scrollbar.scrollarea_start) +#define scrollbar_up_loc() (scrollbar.up_arrow_loc) +#define scrollbar_dn_loc() (scrollbar.down_arrow_loc) /* Scrollbar operations */ -#define map_scrollbar(show) do {PrivMode(show, PrivMode_scrollBar); if (scrollbar_mapping(show)) {scr_touch(); parent_resize();} } while (0) -#define scrollbar_get_shadow() (scrollBar.shadow) -#define scrollbar_set_shadow(s) do { scrollBar.shadow = (s); } while (0) -#define scrollbar_get_win() (scrollBar.win) -#define scrollbar_get_uparrow_win() (scrollBar.up_win) -#define scrollbar_get_downarrow_win() (scrollBar.dn_win) -#define scrollbar_get_anchor_win() (scrollBar.sa_win) +#define map_scrollbar(show) do {PrivMode(show, PrivMode_scrollbar); if (scrollbar_mapping(show)) {scr_touch(); parent_resize();} } while (0) +#define scrollbar_map_arrows() do {XMapWindow(Xdisplay, scrollbar.up_win); XMapWindow(Xdisplay, scrollbar.dn_win);} while (0) +#define scrollbar_unmap_arrows() do {XUnmapWindow(Xdisplay, scrollbar.up_win); XUnmapWindow(Xdisplay, scrollbar.dn_win);} while (0) +#define scrollbar_get_shadow() (((scrollbar.type == SCROLLBAR_XTERM) || (Options & Opt_scrollbar_floating)) ? (0) : (scrollbar.shadow)) +#define scrollbar_set_shadow(s) (scrollbar.shadow = (s)) +#define scrollbar_get_type() (scrollbar.type) +#define scrollbar_set_type(t) (scrollbar.type = (t)) +#define scrollbar_get_width() (scrollbar.width) +#define scrollbar_set_width(w) (scrollbar.width = (w)) +#define scrollbar_get_win() (scrollbar.win) +#define scrollbar_get_uparrow_win() (scrollbar.up_win) +#define scrollbar_get_downarrow_win() (scrollbar.dn_win) +#define scrollbar_get_anchor_win() (scrollbar.sa_win) /************ Structures ************/ typedef struct { - short beg, end; /* beg/end of slider sub-window */ - short top, bot; /* top/bot of slider */ - unsigned char state; /* scrollbar state */ - unsigned int type:2; /* scrollbar type (see above) */ - unsigned int init:1; /* has scrollbar been drawn? */ - unsigned int shadow:5; /* shadow width */ - unsigned short width, height; /* scrollbar width and height, without the shadow */ - unsigned short win_width, win_height; /* scrollbar window dimensions */ - short up_arrow_loc, down_arrow_loc; /* y coordinates for arrows */ - unsigned short arrow_width, arrow_height; /* scrollbar arrow dimensions */ - Window win; -# ifdef PIXMAP_SCROLLBAR - Window up_win; - Window dn_win; - Window sa_win; -# endif + Window win, up_win, dn_win, sa_win; + short scrollarea_start, scrollarea_end; + short anchor_top, anchor_bottom; + unsigned char state; + unsigned int type:2; + unsigned int init:1; + unsigned int shadow:5; + unsigned short width, height; + unsigned short win_width, win_height; + short up_arrow_loc, down_arrow_loc; } scrollbar_t; /************ Variables ************/ -extern scrollbar_t scrollBar; +extern scrollbar_t scrollbar; #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING extern short scroll_arrow_delay; #endif @@ -139,9 +116,6 @@ extern short scroll_arrow_delay; /************ Function Prototypes ************/ _XFUNCPROTOBEGIN -extern void Draw_up_button(int, int, int); -extern void Draw_dn_button(int, int, int); -extern void scrollbar_init(void); extern void scrollbar_event_init_dispatcher(void); extern unsigned char sb_handle_configure_notify(event_t *); extern unsigned char sb_handle_enter_notify(event_t *); @@ -153,11 +127,25 @@ extern unsigned char sb_handle_button_press(event_t *); extern unsigned char sb_handle_button_release(event_t *); extern unsigned char sb_handle_motion_notify(event_t *); extern unsigned char scrollbar_dispatch_event(event_t *); +extern void scrollbar_draw_uparrow(unsigned char image_state, unsigned char force_modes); +extern unsigned char scrollbar_move_uparrow(void); +extern void scrollbar_draw_downarrow(unsigned char image_state, unsigned char force_modes); +extern unsigned char scrollbar_move_downarrow(void); +extern void scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes); +extern unsigned char scrollbar_move_anchor(void); +extern void scrollbar_draw_trough(unsigned char image_state, unsigned char force_modes); +extern void scrollbar_init(int, int); extern unsigned char scrollbar_mapping(unsigned char); extern void scrollbar_reset(void); +extern void scrollbar_calc_size(int width, int height); extern void scrollbar_resize(int, int); extern void scrollbar_change_type(unsigned int); extern void scrollbar_change_width(unsigned short); +extern void scrollbar_drawing_init(void); +extern unsigned char scrollbar_set_focus(short has_focus); +extern unsigned char scrollbar_anchor_update_position(short mouseoffset); +extern void scrollbar_draw(unsigned char force_modes); +extern void scrollbar_reposition_and_draw(unsigned char force_modes); extern unsigned char scrollbar_show(short); _XFUNCPROTOEND diff --git a/src/startup.c b/src/startup.c index 4a8e2e3..36a98d9 100644 --- a/src/startup.c +++ b/src/startup.c @@ -205,8 +205,12 @@ eterm_bootstrap(int argc, char *argv[]) Create_Windows(argc, argv); scr_reset(); /* initialize screen */ - scrollbar_mapping(Options & Opt_scrollBar); - scrollbar_resize(szHint.width, szHint.height); + /* Initialize the scrollbar */ + scrollbar_init(szHint.width, szHint.height); + scrollbar_mapping(Options & Opt_scrollbar); + + /* Initialize the menu subsystem. */ + menu_init(); #if DEBUG >= DEBUG_X if (debug_level >= DEBUG_X) { diff --git a/src/startup.h b/src/startup.h index 25aa05d..df70679 100644 --- a/src/startup.h +++ b/src/startup.h @@ -64,9 +64,11 @@ # define UPPER_BOUND(current, other) (((current) > (other)) ? ((current) = (other)) : (current)) # define AT_MOST(current, other) UPPER_BOUND(current, other) # define MIN_IT(current, other) UPPER_BOUND(current, other) +# define BOUND(val, min, max) (((val) < (min)) ? ((val) = (min)) : (((val) > (max)) ? ((val) = (max)) : (val))) +# define CONTAIN(val, min, max) BOUND(val, min, max) # define SWAP_IT(one, two, tmp) do {(tmp) = (one); (one) = (two); (two) = (tmp);} while (0) -/* width of scrollBar, menuBar shadow ... don't change! */ +/* width of scrollbar, menuBar shadow ... don't change! */ # define SHADOW 2 /* convert pixel dimensions to row/column values */ diff --git a/src/system.c b/src/system.c index 1e9825a..693b80d 100644 --- a/src/system.c +++ b/src/system.c @@ -1,5 +1,24 @@ -/* system.c -- Eterm secure system() replacement - * -- 21 August 1997, mej +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; diff --git a/src/system.h b/src/system.h index 48d7746..f4c80c0 100644 --- a/src/system.h +++ b/src/system.h @@ -1,4 +1,25 @@ -/* system.h -- Header file for system.c */ +/* + * Copyright (C) 1999-1997, Michael Jennings + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ #ifndef _SYSTEM_H_ #define _SYSTEM_H_ @@ -151,6 +151,7 @@ lookup_key(XEvent * ev) valid_keysym = (status_return == XLookupKeySym) || (status_return == XLookupBoth); } else { len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(short_buf), &keysym, NULL); + valid_keysym = 1; } #else /* USE_XIM */ len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, NULL); @@ -1181,7 +1182,7 @@ process_window_mode(unsigned int nargs, int args[]) y = args[++i]; x = args[++i]; XResizeWindow(Xdisplay, TermWin.parent, - Width2Pixel(x) + 2 * TermWin.internalBorder + (scrollbar_visible()? scrollbar_trough_width() : 0), + Width2Pixel(x) + 2 * TermWin.internalBorder + (scrollbar_is_visible()? scrollbar_trough_width() : 0), Height2Pixel(y) + 2 * TermWin.internalBorder); break; case 11: @@ -1299,9 +1300,9 @@ process_terminal_mode(int mode, int priv, unsigned int nargs, int arg[]) PrivateModes &= ~(PrivMode_MouseX11); break; -#ifdef scrollBar_esc - case scrollBar_esc: - PrivCases(PrivMode_scrollBar); +#ifdef scrollbar_esc + case scrollbar_esc: + PrivCases(PrivMode_scrollbar); map_scrollbar(state); break; #endif @@ -1879,7 +1880,7 @@ xterm_seq(int op, const char *str) break; case 11: nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, Options, Opt_scrollBar_right); + OPT_SET_OR_TOGGLE(nstr, Options, Opt_scrollbar_right); scrollbar_reset(); map_scrollbar(0); map_scrollbar(1); @@ -1887,7 +1888,7 @@ xterm_seq(int op, const char *str) break; case 12: nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, Options, Opt_scrollBar_floating); + OPT_SET_OR_TOGGLE(nstr, Options, Opt_scrollbar_floating); scrollbar_reset(); map_scrollbar(0); map_scrollbar(1); diff --git a/src/timer.c b/src/timer.c index 399df9d..023fca5 100644 --- a/src/timer.c +++ b/src/timer.c @@ -1,27 +1,24 @@ -/* timer.c -- Eterm timer module - * -- 16 August 1999, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1999-1997, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ static const char cvs_ident[] = "$Id$"; diff --git a/src/timer.h b/src/timer.h index bc3920f..788b7dd 100644 --- a/src/timer.h +++ b/src/timer.h @@ -1,27 +1,24 @@ -/* actions.h -- Eterm action class module header file - * -- 3 August 1999, mej +/* + * Copyright (C) 1999-1997, Michael Jennings * - * This file is original work by Michael Jennings <mej@eterm.org> and - * Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file - * bearing this same message or a similar one, is distributed under - * the GNU Public License (GPL) as outlined in the COPYING file. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Copyright (C) 1999-1997, Michael Jennings and Tuomo Venalainen + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _TIMER_H_ diff --git a/src/windows.c b/src/windows.c index e9505cb..2e477ba 100644 --- a/src/windows.c +++ b/src/windows.c @@ -287,7 +287,7 @@ Create_Windows(int argc, char *argv[]) #endif /* NO_BOLDUNDERLINE */ /* - * get scrollBar/menu shadow colors + * get scrollbar/menu shadow colors * * The calculations of topShadow/bottomShadow values are adapted * from the fvwm window manager. @@ -320,7 +320,7 @@ Create_Windows(int argc, char *argv[]) PixColors[unfocusedMenuTopShadowColor] = get_top_shadow_color(PixColors[unfocusedMenuColor], "unfocusedMenuTopShadowColor"); } - szHint.base_width = (2 * TermWin.internalBorder + (Options & Opt_scrollBar ? scrollbar_trough_width() : 0)); + szHint.base_width = (2 * TermWin.internalBorder + ((Options & Opt_scrollbar) ? scrollbar_trough_width() : 0)); szHint.base_height = (2 * TermWin.internalBorder); flags = (rs_geometry ? XParseGeometry(rs_geometry, &x, &y, &width, &height) : 0); @@ -416,12 +416,12 @@ Create_Windows(int argc, char *argv[]) /* the vt window */ if ((!(Options & Opt_borderless)) && (Options & Opt_backing_store)) { D_X11(("Creating term window with save_under = TRUE\n")); - TermWin.vt = XCreateWindow(Xdisplay, TermWin.parent, (((Options & Opt_scrollBar) && !(Options & Opt_scrollBar_right)) ? scrollbar_trough_width() : 0), 0, + TermWin.vt = XCreateWindow(Xdisplay, TermWin.parent, (((Options & Opt_scrollbar) && !(Options & Opt_scrollbar_right)) ? scrollbar_trough_width() : 0), 0, szHint.width, szHint.height, 0, Xdepth, InputOutput, CopyFromParent, CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWBackingStore | CWColormap, &Attributes); } else { D_X11(("Creating term window with no backing store\n")); - TermWin.vt = XCreateWindow(Xdisplay, TermWin.parent, (((Options & Opt_scrollBar) && !(Options & Opt_scrollBar_right)) ? scrollbar_trough_width() : 0), 0, + TermWin.vt = XCreateWindow(Xdisplay, TermWin.parent, (((Options & Opt_scrollbar) && !(Options & Opt_scrollbar_right)) ? scrollbar_trough_width() : 0), 0, szHint.width, szHint.height, 0, Xdepth, InputOutput, CopyFromParent, CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWColormap, &Attributes); } @@ -442,12 +442,6 @@ Create_Windows(int argc, char *argv[]) /* We're done creating our windows. Now let's initialize the event subsystem to handle them. */ event_init_subsystem((event_dispatcher_t) process_x_event, (event_dispatcher_init_t) event_init_primary_dispatcher); - /* Time for the scrollbar to create its windows and add itself to the event subsystem. */ - scrollbar_init(); - - /* Same for the menu subsystem. */ - menu_init(); - XMapWindow(Xdisplay, TermWin.vt); XMapWindow(Xdisplay, TermWin.parent); XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[bgColor]); @@ -496,7 +490,7 @@ update_size_hints(void) D_X11(("update_size_hints() called.\n")); szHint.base_width = (2 * TermWin.internalBorder); szHint.base_height = (2 * TermWin.internalBorder); - szHint.base_width += ((scrollbar_visible()) ? (scrollbar_trough_width()) : (0)); + szHint.base_width += ((scrollbar_is_visible()) ? (scrollbar_trough_width()) : (0)); D_X11(("Size Hints: base width/height == %lux%lu\n", szHint.base_width, szHint.base_height)); szHint.min_width = szHint.base_width + szHint.width_inc; @@ -518,7 +512,7 @@ term_resize(int width, int height) TermWin.width = TermWin.ncol * TermWin.fwidth; TermWin.height = TermWin.nrow * TermWin.fheight; D_X11((" -> New TermWin width/height == %lux%lu\n", TermWin.width, TermWin.height)); - XMoveResizeWindow(Xdisplay, TermWin.vt, ((Options & Opt_scrollBar_right) ? (0) : ((scrollbar_visible()) ? (scrollbar_trough_width()) : (0))), 0, width, height + 1); + XMoveResizeWindow(Xdisplay, TermWin.vt, ((Options & Opt_scrollbar_right) ? (0) : ((scrollbar_is_visible()) ? (scrollbar_trough_width()) : (0))), 0, width, height + 1); render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 1); if (image_mode_is(image_bg, MODE_AUTO)) { enl_ipc_sync(); |