Sun Jun 2 20:23:07 2002 Michael Jennings (mej)

Latest Escreen patch along with twin support from Azundris.


SVN revision: 6297
This commit is contained in:
Michael Jennings 2002-06-03 00:24:22 +00:00
parent 6df3396a5d
commit 981b29c895
33 changed files with 1844 additions and 1453 deletions

View File

@ -4679,3 +4679,7 @@ Thu May 23 14:12:28 2002 Michael Jennings (mej)
More cleanups and warning removals. More cleanups and warning removals.
---------------------------------------------------------------------- ----------------------------------------------------------------------
Sun Jun 2 20:23:07 2002 Michael Jennings (mej)
Latest Escreen patch along with twin support from Azundris.
----------------------------------------------------------------------

View File

@ -618,9 +618,14 @@ rather than a shell. Forces Eterm mode.
.BI \-U " URL" ", \-\-url " URL .BI \-U " URL" ", \-\-url " URL
Pick up a "screen" session at Pick up a "screen" session at
.I URL .I URL
rather than a local one. URLs look like so (screen://user@host.dom/options), rather than a local (-U "") one. URLs look like so
with all parts optional, defaulting to current user at localhost, (screen://user@host.dom:port/screen_options), with all parts optional,
respectively. Forces Escreen mode, overrides \-\-exec. defaulting to "screen://current_user@localhost:22/-xRR". Forces Escreen mode,
overrides \-\-exec. Note that only screen-options (see "man screen") are
allowed; do not pass a command (with or without arguments) here: to pass
a command to the screen-session, use
.I screen [<options>] <command> [<args>]
instead.
.TP .TP
.BI \-Z " lclport:fw:fwport,delay" ", \-\-fw " lclport:fw:fwport,delay .BI \-Z " lclport:fw:fwport,delay" ", \-\-fw " lclport:fw:fwport,delay
The URL given to \-U is in an intranet behind firewall The URL given to \-U is in an intranet behind firewall

View File

@ -1,10 +1,17 @@
#!/bin/sh #!/bin/sh
TYPENAMES=""
for i in button_t buttonbar_t menu_t menuitem_t ; do
TYPENAMES="$TYPENAMES -T $i"
done
for i in *.c src/*.c utils/*.c ; do for i in *.c src/*.c utils/*.c ; do
if test -f $i; then if test -f $i; then
echo Reformatting $i echo Reformatting $i
indent -bap -br -ce -ci4 -cli2 -cs -di1 -i4 -l140 -lp -lps -nbc -npcs -nss -nsob -psl $i indent -bad -bap -bbo -br -brs -cdw -ce -ci4 -cli2 -cs -di1 -i4 -l180 \
fi -lp -lps -nbc -nbfda -npcs -nprs -nsob -nss -nut -psl -saf -sai -saw $TYPENAMES $i
fi
done done
perl -p -i.bak -e 's/(\w+)_t (\*+)\s+/$1_t $2/g;' */*.[ch] perl -p -i.bak -e 's/(\w+)_t (\*+)\s+/$1_t $2/g;' */*.[ch]

View File

@ -42,6 +42,9 @@ static const char cvs_ident[] = "$Id$";
#include "scrollbar.h" #include "scrollbar.h"
#include "term.h" #include "term.h"
#include "windows.h" #include "windows.h"
#ifdef ESCREEN
# include "screamcfg.h"
#endif
action_t *action_list = NULL; action_t *action_list = NULL;
@ -60,9 +63,12 @@ action_handle_echo(event_t *ev, action_t *action)
USE_VAR(ev); USE_VAR(ev);
REQUIRE_RVAL(action->param.string != NULL, 0); REQUIRE_RVAL(action->param.string != NULL, 0);
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen_mode && TermWin.screen) /* translate escapes */ if (TermWin.screen && TermWin.screen->backend) {
# ifdef NS_HAVE_SCREEN
/* translate escapes */
ns_parse_screen_interactive(TermWin.screen, action->param.string); ns_parse_screen_interactive(TermWin.screen, action->param.string);
else # endif
} else
#endif #endif
tt_write((unsigned char *) action->param.string, strlen(action->param.string)); tt_write((unsigned char *) action->param.string, strlen(action->param.string));
return 1; return 1;
@ -140,8 +146,7 @@ action_check_modifiers(unsigned short mod, int x_mod)
/* When we do have to check the modifiers, we do so in this order to eliminate the /* When we do have to check the modifiers, we do so in this order to eliminate the
most popular choices first. If any test fails, we return FALSE. */ most popular choices first. If any test fails, we return FALSE. */
D_ACTIONS(("Checking modifier set 0x%08x (" MOD_FMT ") vs. X modifier set 0x%08x (" MOD_FMT ")\n", D_ACTIONS(("Checking modifier set 0x%08x (" MOD_FMT ") vs. X modifier set 0x%08x (" MOD_FMT ")\n", mod, SHOW_MODS(mod), x_mod, SHOW_X_MODS(x_mod)));
mod, SHOW_MODS(mod), x_mod, SHOW_X_MODS(x_mod)));
if (mod != MOD_ANY) { if (mod != MOD_ANY) {
/* LOGICAL_XOR() returns true if either the first parameter or the second parameter /* LOGICAL_XOR() returns true if either the first parameter or the second parameter
is true, but not both...just like XOR. If the mask we're looking for is set in is true, but not both...just like XOR. If the mask we're looking for is set in
@ -197,8 +202,7 @@ action_dispatch(event_t *ev, KeySym keysym)
ASSERT_RVAL(ev != NULL, 0); ASSERT_RVAL(ev != NULL, 0);
ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 0); ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 0);
D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", ev, ev->xbutton.button, keysym, ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
ev, ev->xbutton.button, keysym, ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
for (action = action_list; action; action = action->next) { for (action = action_list; action; action = action->next) {
/* The very first thing we do is match the event type to the type /* The very first thing we do is match the event type to the type
of the current action. This means that we'll only run through of the current action. This means that we'll only run through

View File

@ -50,6 +50,10 @@ static const char cvs_ident[] = "$Id$";
static inline void draw_string(buttonbar_t *, Drawable, GC, int, int, char *, size_t); static inline void draw_string(buttonbar_t *, Drawable, GC, int, int, char *, size_t);
buttonbar_t *buttonbar = NULL; buttonbar_t *buttonbar = NULL;
#ifdef ESCREEN
button_t *drag = NULL;
#endif
long bbar_total_h = -1; long bbar_total_h = -1;
static inline void static inline void
@ -70,8 +74,7 @@ draw_string(buttonbar_t *bbar, Drawable d, GC gc, int x, int y, char *str, size_
return; return;
} }
buttonbar_t * buttonbar_t *bbar_create(void)
bbar_create(void)
{ {
buttonbar_t *bbar; buttonbar_t *bbar;
Cursor cursor; Cursor cursor;
@ -188,8 +191,7 @@ bbar_handle_enter_notify(event_t *ev)
return 0; return 0;
} }
bbar_draw(bbar, IMAGE_STATE_SELECTED, 0); bbar_draw(bbar, IMAGE_STATE_SELECTED, 0);
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);
&unused_mask);
b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
if (b) { if (b) {
bbar_select_button(bbar, b); bbar_select_button(bbar, b);
@ -231,6 +233,9 @@ bbar_handle_button_press(event_t *ev)
if (bbar->current) { if (bbar->current) {
bbar_click_button(bbar, bbar->current); bbar_click_button(bbar, bbar->current);
button_check_action(bbar, bbar->current, ev->xbutton.button, ev->xbutton.time); button_check_action(bbar, bbar->current, ev->xbutton.button, ev->xbutton.time);
#ifdef ESCREEN
drag = bbar->current;
#endif
} }
return 1; return 1;
} }
@ -244,6 +249,10 @@ bbar_handle_button_release(event_t *ev)
int unused_root_x, unused_root_y; int unused_root_x, unused_root_y;
unsigned int unused_mask; unsigned int unused_mask;
#ifdef ESCREEN
drag = NULL;
#endif
D_EVENTS(("bbar_handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); D_EVENTS(("bbar_handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0); REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
@ -252,8 +261,7 @@ bbar_handle_button_release(event_t *ev)
return 0; return 0;
} }
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);
&unused_mask);
b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
if (b) { if (b) {
@ -285,8 +293,7 @@ bbar_handle_motion_notify(event_t *ev)
return 0; return 0;
} }
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev)); while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev));
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &mask);
&mask);
D_BBAR((" -> Pointer is at %d, %d with mask 0x%08x\n", ev->xbutton.x, ev->xbutton.y, mask)); D_BBAR((" -> Pointer is at %d, %d with mask 0x%08x\n", ev->xbutton.x, ev->xbutton.y, mask));
b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
@ -315,8 +322,7 @@ bbar_dispatch_event(event_t *ev)
return (0); return (0);
} }
buttonbar_t * buttonbar_t *find_bbar_by_window(Window win)
find_bbar_by_window(Window win)
{ {
buttonbar_t *bbar; buttonbar_t *bbar;
@ -500,8 +506,7 @@ button_calc_size(buttonbar_t *bbar, button_t *button)
D_BBAR((" -> Final icon dimensions are %hux%hu\n", button->icon_w, button->icon_h)); D_BBAR((" -> Final icon dimensions are %hux%hu\n", button->icon_w, button->icon_h));
} }
#endif #endif
D_BBAR((" -> Set button to %dx%d at %d, %d and icon to %dx%d\n", button->w, button->h, button->x, button->y, button->icon_w, D_BBAR((" -> Set button to %dx%d at %d, %d and icon to %dx%d\n", button->w, button->h, button->x, button->y, button->icon_w, button->icon_h));
button->icon_h));
} }
void void
@ -577,8 +582,7 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
ASSERT_RVAL(fontname != NULL, 0); ASSERT_RVAL(fontname != NULL, 0);
D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth, D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth, bbar->fheight, bbar->h));
bbar->fheight, bbar->h));
if (bbar->font) { if (bbar->font) {
free_font(bbar->font); free_font(bbar->font);
} }
@ -603,8 +607,7 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
return 1; return 1;
} }
button_t * button_t *find_button_by_text(buttonbar_t *bbar, char *text)
find_button_by_text(buttonbar_t *bbar, char *text)
{ {
register button_t *b; register button_t *b;
@ -623,8 +626,7 @@ find_button_by_text(buttonbar_t *bbar, char *text)
return NULL; return NULL;
} }
button_t * button_t *find_button_by_index(buttonbar_t *bbar, long idx)
find_button_by_index(buttonbar_t *bbar, long idx)
{ {
register button_t *b; register button_t *b;
long i; long i;
@ -639,8 +641,7 @@ find_button_by_index(buttonbar_t *bbar, long idx)
return ((i == idx) ? (b) : (NULL)); return ((i == idx) ? (b) : (NULL));
} }
button_t * button_t *find_button_by_coords(buttonbar_t *bbar, int x, int y)
find_button_by_coords(buttonbar_t *bbar, int x, int y)
{ {
register button_t *b; register button_t *b;
@ -659,8 +660,7 @@ find_button_by_coords(buttonbar_t *bbar, int x, int y)
return NULL; return NULL;
} }
button_t * button_t *button_create(char *text)
button_create(char *text)
{ {
button_t *button; button_t *button;
@ -791,8 +791,7 @@ bbar_click_button(buttonbar_t *bbar, button_t *button)
if (image_mode_is(image_button, MODE_MASK)) { if (image_mode_is(image_button, MODE_MASK)) {
paste_simage(images[image_button].clicked, image_button, bbar->win, bbar->win, button->x, button->y, button->w, button->h); paste_simage(images[image_button].clicked, image_button, bbar->win, bbar->win, button->x, button->y, button->w, button->h);
} else { } else {
draw_shadow_from_colors(bbar->win, PixColors[menuBottomShadowColor], PixColors[menuTopShadowColor], button->x, button->y, button->w, draw_shadow_from_colors(bbar->win, PixColors[menuBottomShadowColor], PixColors[menuTopShadowColor], button->x, button->y, button->w, button->h, 2);
button->h, 2);
} }
if (image_mode_is(image_button, MODE_AUTO)) { if (image_mode_is(image_button, MODE_AUTO)) {
enl_ipc_sync(); enl_ipc_sync();
@ -826,38 +825,48 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
case ACTION_ECHO: case ACTION_ECHO:
if (!press) { if (!press) {
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen_mode && TermWin.screen) { /* translate escapes */ if (TermWin.screen && TermWin.screen->backend) { /* translate escapes */
if (prvs != 1) { button_t *b = bbar->buttons;
button_t *b = bbar->buttons; _ns_disp *d2 = TermWin.screen->dsps;
_ns_disp *d2 = TermWin.screen->dsps; int n = (button->action.string)[1] - '0';
int n = (button->action.string)[1] - '0';
while (b && !(b->flags & NS_SCREAM_CURR)) /* find active disp */ if (prvs != 1) {
b = b->next; /* when trying to change name of non- */ /* find active disp */
if (b && b != button) { /* active display, make that disp active */ for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next);
if (b && b != button) {
/* when trying to change name of non- */
/* active display, make that disp active */
button->flags |= NS_SCREAM_CURR; button->flags |= NS_SCREAM_CURR;
b->flags &= ~NS_SCREAM_CURR; b->flags &= ~NS_SCREAM_CURR;
bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK); bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK);
button->flags &= ~NS_SCREAM_CURR; button->flags &= ~NS_SCREAM_CURR;
b->flags |= NS_SCREAM_CURR; b->flags |= NS_SCREAM_CURR;
while (d2 && d2->index != n) for (; d2 && d2->index != n; d2 = d2->next);
d2 = d2->next; if (d2) {
if (d2) /* pre-adjust curr ptr */
TermWin.screen->curr = d2; /* pre-adjust curr ptr */ TermWin.screen->curr = d2;
else } else {
D_ESCREEN(("no display %d in this session : (\n", n)); D_ESCREEN(("no display %d in this session : (\n", n));
(void) ns_screen_command(TermWin.screen, button->action.string); }
ns_go2_disp(TermWin.screen, n);
} }
if (prvs == 2) /* middle button -- kill */ if (prvs == 2) {
(void) ns_parse_screen_key(TermWin.screen, NS_SCREEN_KILL); /* middle button -- kill */
else /* right button -- rename */ (void) ns_rem_disp(TermWin.screen, n);
(void) ns_parse_screen_key(TermWin.screen, NS_SCREEN_RENAME); } else {
} else /* left button -- select */ /* right button -- rename */
(void) ns_screen_command(TermWin.screen, button->action.string); (void) ns_ren_disp(TermWin.screen, n, NULL);
} else /* not in screen-mode, use normal facilities */ }
} else {
/* left button -- select */
ns_go2_disp(TermWin.screen, n);
}
} else
#endif #endif
/* not in screen-mode, use normal facilities */
tt_write((unsigned char *) button->action.string, strlen(button->action.string)); tt_write((unsigned char *) button->action.string, strlen(button->action.string));
} }
break; break;
@ -1138,6 +1147,7 @@ buttonbar_t *bbar_insert_button(buttonbar_t *bbar, button_t *button, int after,
} else { } else {
int c = 0; int c = 0;
button_t *b = bbar->rbuttons; button_t *b = bbar->rbuttons;
do { do {
c++; c++;
} while ((b = b->next)); } while ((b = b->next));
@ -1154,11 +1164,12 @@ buttonbar_t *bbar_insert_button(buttonbar_t *bbar, button_t *button, int after,
} }
} }
} else { /* add to buttons */ } else { /* add to buttons */
if (!bbar->buttons || after < 0) { /* first button */ if (!bbar->buttons || after < 0) { /* first button */
button->next = bbar->buttons; button->next = bbar->buttons;
bbar->buttons = button; bbar->buttons = button;
} else { } else {
button_t *b = bbar->buttons; button_t *b = bbar->buttons;
while (after-- > 0 && b->next) while (after-- > 0 && b->next)
b = b->next; b = b->next;
button->next = b->next; button->next = b->next;
@ -1173,6 +1184,7 @@ buttonbar_t *bbar_insert_button(buttonbar_t *bbar, button_t *button, int after,
if (!state) { if (!state) {
if (buttonbar) { if (buttonbar) {
buttonbar_t *bar = buttonbar; buttonbar_t *bar = buttonbar;
while (bar->next) while (bar->next)
bar = bar->next; bar = bar->next;
bar->next = bbar; bar->next = bbar;

View File

@ -96,6 +96,9 @@ typedef struct buttonbar_struct {
/************ Variables ************/ /************ Variables ************/
extern buttonbar_t *buttonbar; extern buttonbar_t *buttonbar;
extern long bbar_total_h; extern long bbar_total_h;
#ifdef ESCREEN
extern button_t *drag;
#endif
/************ Function Prototypes ************/ /************ Function Prototypes ************/
_XFUNCPROTOBEGIN _XFUNCPROTOBEGIN

View File

@ -141,7 +141,7 @@ static RETSIGTYPE handle_crash(int);
/* local variables */ /* local variables */
int my_ruid, my_euid, my_rgid, my_egid; int my_ruid, my_euid, my_rgid, my_egid;
char initial_dir[PATH_MAX + 1]; char initial_dir[PATH_MAX + 1];
static char *ptydev = NULL, *ttydev = NULL; /* pty/tty name */ static char *ptydev = NULL, *ttydev = NULL; /* pty/tty name */
int cmd_fd = -1; /* file descriptor connected to the command */ int cmd_fd = -1; /* file descriptor connected to the command */
int pipe_fd = -1; int pipe_fd = -1;
pid_t cmd_pid = -1; /* process id if child */ pid_t cmd_pid = -1; /* process id if child */
@ -150,6 +150,7 @@ unsigned int num_fds = 0; /* number of file descriptors being used */
struct stat ttyfd_stat; /* original status of the tty we will use */ struct stat ttyfd_stat; /* original status of the tty we will use */
int refresh_count = 0, refresh_limit = 1, refresh_type = FAST_REFRESH; int refresh_count = 0, refresh_limit = 1, refresh_type = FAST_REFRESH;
unsigned char cmdbuf_base[CMD_BUF_SIZE], *cmdbuf_ptr, *cmdbuf_endp; unsigned char cmdbuf_base[CMD_BUF_SIZE], *cmdbuf_ptr, *cmdbuf_endp;
/* Addresses pasting large amounts of data /* Addresses pasting large amounts of data
* code pinched from xterm * code pinched from xterm
*/ */
@ -157,10 +158,12 @@ static char *v_buffer; /* pointer to physical buffer */
static char *v_bufstr = NULL; /* beginning of area to write */ static char *v_bufstr = NULL; /* beginning of area to write */
static char *v_bufptr; /* end of area to write */ static char *v_bufptr; /* end of area to write */
static char *v_bufend; /* end of physical buffer */ static char *v_bufend; /* end of physical buffer */
#ifdef USE_XIM #ifdef USE_XIM
XIM xim_input_method = NULL; XIM xim_input_method = NULL;
XIC xim_input_context = NULL; /* input context */ XIC xim_input_context = NULL; /* input context */
static XIMStyle xim_input_style = 0; static XIMStyle xim_input_style = 0;
# ifndef XSetIMValues # ifndef XSetIMValues
extern char *XSetIMValues(XIM im, ...); extern char *XSetIMValues(XIM im, ...);
# endif # endif
@ -952,10 +955,10 @@ const char *
get_ctrl_char_name(char c) get_ctrl_char_name(char c)
{ {
const char *lookup[] = { const char *lookup[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", /* 0-7 */ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", /* 0-7 */
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", /* 8-15 */ "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", /* 8-15 */
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", /* 16-23 */ "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", /* 16-23 */
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" /* 24-31 */ "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" /* 24-31 */
}; };
return ((c < ' ') ? (lookup[(int) c]) : ("")); return ((c < ' ') ? (lookup[(int) c]) : (""));
@ -1416,7 +1419,7 @@ get_tty(void)
privileges(INVOKE); privileges(INVOKE);
# ifndef __CYGWIN32__ # ifndef __CYGWIN32__
fchown(fd, my_ruid, gid); /* fail silently */ fchown(fd, my_ruid, gid); /* fail silently */
fchmod(fd, mode); fchmod(fd, mode);
# endif # endif
privileges(REVERT); privileges(REVERT);
@ -1673,28 +1676,28 @@ get_ttymode(ttymode_t *tio)
/* get parameters -- gtty */ /* get parameters -- gtty */
if (ioctl(0, TIOCGETP, &(tio->sg)) < 0) { if (ioctl(0, TIOCGETP, &(tio->sg)) < 0) {
tio->sg.sg_erase = CERASE; /* ^H */ tio->sg.sg_erase = CERASE; /* ^H */
tio->sg.sg_kill = CKILL; /* ^U */ tio->sg.sg_kill = CKILL; /* ^U */
} }
tio->sg.sg_flags = (CRMOD | ECHO | EVENP | ODDP); tio->sg.sg_flags = (CRMOD | ECHO | EVENP | ODDP);
/* get special characters */ /* get special characters */
if (ioctl(0, TIOCGETC, &(tio->tc)) < 0) { if (ioctl(0, TIOCGETC, &(tio->tc)) < 0) {
tio->tc.t_intrc = CINTR; /* ^C */ tio->tc.t_intrc = CINTR; /* ^C */
tio->tc.t_quitc = CQUIT; /* ^\ */ tio->tc.t_quitc = CQUIT; /* ^\ */
tio->tc.t_startc = CSTART; /* ^Q */ tio->tc.t_startc = CSTART; /* ^Q */
tio->tc.t_stopc = CSTOP; /* ^S */ tio->tc.t_stopc = CSTOP; /* ^S */
tio->tc.t_eofc = CEOF; /* ^D */ tio->tc.t_eofc = CEOF; /* ^D */
tio->tc.t_brkc = -1; tio->tc.t_brkc = -1;
} }
/* get local special chars */ /* get local special chars */
if (ioctl(0, TIOCGLTC, &(tio->lc)) < 0) { if (ioctl(0, TIOCGLTC, &(tio->lc)) < 0) {
tio->lc.t_suspc = CSUSP; /* ^Z */ tio->lc.t_suspc = CSUSP; /* ^Z */
tio->lc.t_dsuspc = CDSUSP; /* ^Y */ tio->lc.t_dsuspc = CDSUSP; /* ^Y */
tio->lc.t_rprntc = CRPRNT; /* ^R */ tio->lc.t_rprntc = CRPRNT; /* ^R */
tio->lc.t_flushc = CFLUSH; /* ^O */ tio->lc.t_flushc = CFLUSH; /* ^O */
tio->lc.t_werasc = CWERASE; /* ^W */ tio->lc.t_werasc = CWERASE; /* ^W */
tio->lc.t_lnextc = CLNEXT; /* ^V */ tio->lc.t_lnextc = CLNEXT; /* ^V */
} }
/* get line discipline */ /* get line discipline */
ioctl(0, TIOCGETD, &(tio->line)); ioctl(0, TIOCGETD, &(tio->line));
@ -1760,6 +1763,7 @@ create_fontset(const char *font1, const char *font2)
#ifdef USE_XIM #ifdef USE_XIM
static int xim_real_init(void); static int xim_real_init(void);
# ifdef USE_X11R6_XIM # ifdef USE_X11R6_XIM
static void xim_destroy_cb(XIM xim, XPointer client_data, XPointer call_data); static void xim_destroy_cb(XIM xim, XPointer client_data, XPointer call_data);
static void xim_instantiate_cb(Display * display, XPointer client_data, XPointer call_data); static void xim_instantiate_cb(Display * display, XPointer client_data, XPointer call_data);
@ -1843,8 +1847,7 @@ xim_get_area(XRectangle * preedit_rect, XRectangle * status_rect, XRectangle * n
preedit_rect->x = needed_rect->width + (scrollbar_is_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->y = Height2Pixel(TermWin.nrow - 1);
preedit_rect->width = preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + (!(Options & Opt_scrollbar_right) ? (scrollbar_trough_width()) : 0);
Width2Pixel(TermWin.ncol + 1) - needed_rect->width + (!(Options & Opt_scrollbar_right) ? (scrollbar_trough_width()) : 0);
preedit_rect->height = Height2Pixel(1); preedit_rect->height = Height2Pixel(1);
status_rect->x = (scrollbar_is_visible() && !(Options & Opt_scrollbar_right)) ? (scrollbar_trough_width()) : 0; status_rect->x = (scrollbar_is_visible() && !(Options & Opt_scrollbar_right)) ? (scrollbar_trough_width()) : 0;
@ -1995,9 +1998,7 @@ xim_real_init(void)
xim_set_size(&rect); xim_set_size(&rect);
xim_get_position(&spot); xim_get_position(&spot);
xim_set_color(&fg, &bg); xim_set_color(&fg, &bg);
preedit_attr = preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL);
XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset,
NULL);
} else if (xim_input_style & XIMPreeditArea) { } else if (xim_input_style & XIMPreeditArea) {
xim_set_color(&fg, &bg); xim_set_color(&fg, &bg);
/* The necessary width of preedit area is unknown until create input context. */ /* The necessary width of preedit area is unknown until create input context. */
@ -2270,12 +2271,14 @@ run_command(char **argv)
return (ptyfd); return (ptyfd);
} }
#ifdef ESCREEN
/***************************************************************************/ /***************************************************************************/
/* Escreen: callbacks */ /* Escreen: callbacks */
/***********************/ /***********************/
#ifdef ESCREEN static int
int
set_scroll_x(void *xd, int x) set_scroll_x(void *xd, int x)
{ {
USE_VAR(xd); USE_VAR(xd);
@ -2283,7 +2286,7 @@ set_scroll_x(void *xd, int x)
return NS_FAIL; return NS_FAIL;
} }
int static int
set_scroll_y(void *xd, int y) set_scroll_y(void *xd, int y)
{ {
USE_VAR(xd); USE_VAR(xd);
@ -2291,7 +2294,7 @@ set_scroll_y(void *xd, int y)
return NS_FAIL; return NS_FAIL;
} }
int static int
set_scroll_w(void *xd, int w) set_scroll_w(void *xd, int w)
{ {
USE_VAR(xd); USE_VAR(xd);
@ -2299,7 +2302,7 @@ set_scroll_w(void *xd, int w)
return NS_FAIL; return NS_FAIL;
} }
int static int
set_scroll_h(void *xd, int h) set_scroll_h(void *xd, int h)
{ {
USE_VAR(xd); USE_VAR(xd);
@ -2307,7 +2310,7 @@ set_scroll_h(void *xd, int h)
return NS_FAIL; return NS_FAIL;
} }
int static int
redraw(void *xd) redraw(void *xd)
{ {
USE_VAR(xd); USE_VAR(xd);
@ -2315,7 +2318,7 @@ redraw(void *xd)
return NS_FAIL; return NS_FAIL;
} }
int static int
redraw_xywh(void *xd, int x, int y, int w, int h) redraw_xywh(void *xd, int x, int y, int w, int h)
{ {
USE_VAR(xd); USE_VAR(xd);
@ -2323,8 +2326,7 @@ redraw_xywh(void *xd, int x, int y, int w, int h)
return NS_FAIL; return NS_FAIL;
} }
static button_t * static button_t *screen_button_create(char *text, char code)
screen_button_create(char *text, char code)
{ {
button_t *b; button_t *b;
char p[3]; char p[3];
@ -2344,9 +2346,12 @@ screen_button_create(char *text, char code)
/* add a new screen display to button bar. /* add a new screen display to button bar.
if our user's configured a bbar, we'll add to that, if our user's configured a bbar, we'll add to that,
otherwise, we'll create one. */ otherwise, we'll create one.
int xd address of the pointer to the buttonbar in question
ins_disp(void *xd, int after, char *name) after insert after which display?
name the display's name */
static int
ins_disp(void *xd, int after, int as, char *name)
{ {
buttonbar_t *bbar; buttonbar_t *bbar;
button_t *button; button_t *button;
@ -2357,12 +2362,10 @@ ins_disp(void *xd, int after, char *name)
bbar = *((buttonbar_t **) xd); bbar = *((buttonbar_t **) xd);
if (!(button = screen_button_create(name, '0' + after + 1))) { if (!(button = screen_button_create(name, '0' + as))) {
return NS_FAIL; return NS_FAIL;
} }
D_ESCREEN(("%s after %d...\n", name, after));
if ((bbar = bbar_insert_button(bbar, button, after, FALSE))) { if ((bbar = bbar_insert_button(bbar, button, after, FALSE))) {
*((buttonbar_t **) xd) = bbar; *((buttonbar_t **) xd) = bbar;
return NS_SUCC; return NS_SUCC;
@ -2372,7 +2375,8 @@ ins_disp(void *xd, int after, char *name)
return NS_FAIL; return NS_FAIL;
} }
# if 0 #if 0
/* add supa-dupa right buttons for screen-features. /* add supa-dupa right buttons for screen-features.
if our user's configured a bbar, we'll add to that, if our user's configured a bbar, we'll add to that,
otherwise, we'll create one. */ otherwise, we'll create one. */
@ -2388,9 +2392,9 @@ add_screen_ctl_button(buttonbar_t **xd, char *name, char key)
bbar = *xd; bbar = *xd;
if (!(button = screen_button_create(name, key))) { if (!(button = screen_button_create(name, key)))
return NS_FAIL; return NS_FAIL;
}
if ((bbar = bbar_insert_button(bbar, button, -1, TRUE))) { if ((bbar = bbar_insert_button(bbar, button, -1, TRUE))) {
*xd = bbar; *xd = bbar;
return NS_SUCC; return NS_SUCC;
@ -2399,11 +2403,12 @@ add_screen_ctl_button(buttonbar_t **xd, char *name, char key)
button_free(button); button_free(button);
return NS_FAIL; return NS_FAIL;
} }
# endif #endif
/* delete n'th button /* delete n'th button
n index of the button (not screen, not data -- the button) */ xd address of the pointer to the buttonbar in question
int n index of the button (not screen, not data -- the button) */
static int
del_disp(void *xd, int n) del_disp(void *xd, int n)
{ {
buttonbar_t *bbar = *((buttonbar_t **) xd); buttonbar_t *bbar = *((buttonbar_t **) xd);
@ -2413,16 +2418,6 @@ del_disp(void *xd, int n)
REQUIRE_RVAL(bbar, NS_FAIL); REQUIRE_RVAL(bbar, NS_FAIL);
REQUIRE_RVAL(bbar->buttons, NS_FAIL); REQUIRE_RVAL(bbar->buttons, NS_FAIL);
#if DEBUG >= DEBUG_ESCREEN
if (DEBUG_LEVEL >= DEBUG_ESCREEN) {
int c;
for (c = 0, b2 = bbar->buttons; b2; c++, b2 = b2->next) {
D_ESCREEN(("%02d: \"%s\"\n", c, b2->text));
}
}
#endif
b2 = button = bbar->buttons; b2 = button = bbar->buttons;
if (n == 0) { if (n == 0) {
bbar->buttons = bbar->buttons->next; bbar->buttons = bbar->buttons->next;
@ -2443,8 +2438,6 @@ del_disp(void *xd, int n)
} }
} }
D_ESCREEN(("deleting button %d (%s)...\n", bi, button->text));
button->next = NULL; button->next = NULL;
button_free(button); button_free(button);
@ -2454,12 +2447,12 @@ del_disp(void *xd, int n)
} }
/* update the button-representation of a screen-display. /* update the button-representation of a screen-display.
xd xd address of the pointer to the buttonbar in question
n the button's index (in the list of buttons) n the button's index (in the list of buttons)
flags the new flags for the display (or -1 to ignore) flags the new flags for the display (or -1 to ignore)
name the new name for the display (or NULL) name the new name for the display (or NULL)
<- error code */ <- error code */
int static int
upd_disp(void *xd, int n, int flags, char *name) upd_disp(void *xd, int n, int flags, char *name)
{ {
buttonbar_t *bbar = *((buttonbar_t **) xd); buttonbar_t *bbar = *((buttonbar_t **) xd);
@ -2484,20 +2477,49 @@ upd_disp(void *xd, int n, int flags, char *name)
return NS_SUCC; return NS_SUCC;
} }
/* expire all buttons
xd address of the pointer to the buttonbar in question
n how many buttons do we want to throw out (normally all of them)?
<- error code */
static int
expire_buttons(void *xd, int n)
{
buttonbar_t *bbar = *((buttonbar_t **) xd);
button_t *b, *p;
REQUIRE_RVAL(bbar, NS_FAIL);
if (n < 1) {
return NS_FAIL;
}
if ((b = bbar->buttons)) {
for (; n; n--) {
p = b;
b = b->next;
}
p->next = NULL;
button_free(bbar->buttons);
bbar->buttons = b;
}
return NS_SUCC;
}
/* display a status line the screen program sent us */ /* display a status line the screen program sent us */
int static int
err_msg(void *xd, int err, char *msg) err_msg(void *xd, int err, char *msg)
{ {
char *sc[] = { "Copy mode", "Bell in" }; char *sc[] = { "Copy mode", "Bell in", "Wuff, Wuff!!" };
int n, nsc = sizeof(sc) / sizeof(char *); int n, nsc = sizeof(sc) / sizeof(char *);
USE_VAR(xd);
USE_VAR(err);
/* there are certain things that would make sense if we were displaying /* there are certain things that would make sense if we were displaying
a status-line; they do not, however, warrant an alert-box, so we drop a status-line; they do not, however, warrant an alert-box, so we drop
them here. */ them here. */
if (msg && *msg) {
USE_VAR(xd);
USE_VAR(err);
if (strlen(msg)) {
for (n = 0; n < nsc; n++) { for (n = 0; n < nsc; n++) {
if (!strncmp(msg, sc[n], strlen(sc[n]))) { if (!strncmp(msg, sc[n], strlen(sc[n]))) {
break; break;
@ -2511,7 +2533,7 @@ err_msg(void *xd, int err, char *msg)
} }
/* send text to the application (normally "screen") in the terminal */ /* send text to the application (normally "screen") in the terminal */
int static int
inp_text(void *xd, int id, char *txt) inp_text(void *xd, int id, char *txt)
{ {
USE_VAR(xd); USE_VAR(xd);
@ -2522,7 +2544,7 @@ inp_text(void *xd, int id, char *txt)
} }
/* open a dialog */ /* open a dialog */
int static int
input_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (void *, char *, size_t, size_t)) input_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (void *, char *, size_t, size_t))
{ {
switch (menu_dialog(xd, prompt, maxlen, retstr, inp_tab)) { switch (menu_dialog(xd, prompt, maxlen, retstr, inp_tab)) {
@ -2536,19 +2558,21 @@ input_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (
} }
/* run a program (normally "screen") inside the terminal */ /* run a program (normally "screen") inside the terminal */
int static int
exe_prg(void *xd, char **argv) exe_prg(void *xd, char **argv)
{ {
USE_VAR(xd); USE_VAR(xd);
return run_command(argv); return run_command(argv);
} }
/********************* Azundris' toys ***************************/
/****** Azundris' playthings :-) ******/
#define DIRECT_MASK (~(RS_Cursor|RS_Select|RS_fontMask)) #define DIRECT_MASK (~(RS_Cursor|RS_Select|RS_fontMask))
#define COLOUR_MASK (RS_fgMask|RS_bgMask) #define COLOUR_MASK (RS_fgMask|RS_bgMask)
#define DIRECT_SET_SCREEN(x,y,fg,bg) (screen.text[ys+y])[x]=fg; (screen.rend[ys+y])[x]=bg&DIRECT_MASK; #define DIRECT_SET_SCREEN(x,y,fg,bg) (screen.text[ys+y])[x]=fg; (screen.rend[ys+y])[x]=bg&DIRECT_MASK;
#define CLEAR (1<<16) #define CLEAR (1<<16)
static void static void
direct_write_screen(int x, int y, char *fg, rend_t bg) direct_write_screen(int x, int y, char *fg, rend_t bg)
{ {
@ -2569,10 +2593,12 @@ bosconian(int n)
{ {
int x, y; int x, y;
int ys = TermWin.saveLines - TermWin.view_start; int ys = TermWin.saveLines - TermWin.view_start;
for (; n != 0; n--) { for (; n != 0; n--) {
for (y = 0; y < TermWin.nrow; y++) { for (y = 0; y < TermWin.nrow; y++) {
text_t *t = screen.text[ys + y]; text_t *t = screen.text[ys + y];
rend_t *r = screen.rend[ys + y]; rend_t *r = screen.rend[ys + y];
for (x = 0; x < TermWin.ncol; x++) { for (x = 0; x < TermWin.ncol; x++) {
t[x] = random() & 0xff; t[x] = random() & 0xff;
r[x] = random() & COLOUR_MASK; r[x] = random() & COLOUR_MASK;
@ -2588,10 +2614,12 @@ unbosconian(void)
int x, y; int x, y;
int ys = TermWin.saveLines - TermWin.view_start; int ys = TermWin.saveLines - TermWin.view_start;
rend_t bg; rend_t bg;
do { do {
bg = CLEAR; bg = CLEAR;
for (y = 0; (bg == CLEAR) && y < TermWin.nrow; y++) { for (y = 0; (bg == CLEAR) && y < TermWin.nrow; y++) {
rend_t *r = screen.rend[ys + y]; rend_t *r = screen.rend[ys + y];
for (x = 0; (bg == CLEAR) && x < TermWin.ncol; x++) { for (x = 0; (bg == CLEAR) && x < TermWin.ncol; x++) {
if (r[x] != CLEAR) { if (r[x] != CLEAR) {
bg = r[x]; bg = r[x];
@ -2602,6 +2630,7 @@ unbosconian(void)
for (y = 0; y < TermWin.nrow; y++) { for (y = 0; y < TermWin.nrow; y++) {
text_t *t = screen.text[ys + y]; text_t *t = screen.text[ys + y];
rend_t *r = screen.rend[ys + y]; rend_t *r = screen.rend[ys + y];
for (x = 0; x < TermWin.ncol; x++) { for (x = 0; x < TermWin.ncol; x++) {
if (r[x] == bg) { if (r[x] == bg) {
r[x] = CLEAR; r[x] = CLEAR;
@ -2613,12 +2642,11 @@ unbosconian(void)
} }
} while (bg != CLEAR); } while (bg != CLEAR);
} }
#undef DIRECT_MASK #undef DIRECT_MASK
#undef COLOUR_MASK #undef COLOUR_MASK
#undef DIRECT_SET_SCREEN #undef DIRECT_SET_SCREEN
#define MATRIX_HI CLEAR
#define MATRIX_LO ((4<<8)|CLEAR)
static void static void
matrix(int n) matrix(int n)
{ {
@ -2634,8 +2662,10 @@ matrix(int n)
} }
MEMSET(s, 0, TermWin.ncol); MEMSET(s, 0, TermWin.ncol);
#define MATRIX_HI CLEAR
#define MATRIX_LO ((4<<8)|CLEAR)
for (; n != 0; n--) { while (n--) {
for (x = 0; x < TermWin.ncol; x++) { for (x = 0; x < TermWin.ncol; x++) {
if (!(random() & 3)) { if (!(random() & 3)) {
if ((y = s[x])) { if ((y = s[x])) {
@ -2684,7 +2714,8 @@ matrix(int n)
} }
break; break;
default: t[x] = random() & 0xff; /* hold */ default:
t[x] = random() & 0xff; /* hold */
} }
} }
} }
@ -2692,6 +2723,7 @@ matrix(int n)
} }
FREE(s); FREE(s);
} }
#undef MATRIX_HI #undef MATRIX_HI
#undef MATRIX_LO #undef MATRIX_LO
@ -2701,11 +2733,9 @@ waitstate(void *xd, int ms)
{ {
int y = 1; int y = 1;
time_t dur = (time_t) (ms / 1000); time_t dur = (time_t) (ms / 1000);
#if 0
time_t fin = dur + time(NULL);
#endif
USE_VAR(xd); USE_VAR(xd);
if (!(random() & 7)) { if (!(random() & 7)) {
if (!(random() & 3)) { if (!(random() & 3)) {
matrix(31); matrix(31);
@ -2725,8 +2755,10 @@ waitstate(void *xd, int ms)
scr_refresh(FAST_REFRESH); scr_refresh(FAST_REFRESH);
sleep(dur); sleep(dur);
return 0; return 0;
} }
#undef CLEAR #undef CLEAR
/* Set everything up for escreen mode */ /* Set everything up for escreen mode */
@ -2745,6 +2777,7 @@ escreen_init(char **argv)
ns_register_red(efuns, redraw); ns_register_red(efuns, redraw);
ns_register_rda(efuns, redraw_xywh); ns_register_rda(efuns, redraw_xywh);
ns_register_exb(efuns, expire_buttons);
ns_register_ins(efuns, ins_disp); ns_register_ins(efuns, ins_disp);
ns_register_del(efuns, del_disp); ns_register_del(efuns, del_disp);
@ -2767,7 +2800,7 @@ escreen_init(char **argv)
menuitem_t *i; menuitem_t *i;
if (rs_delay >= 0) { if (rs_delay >= 0) {
TermWin.screen->delay = rs_delay; /* more flexible ways later */ TermWin.screen->delay = rs_delay; /* more flexible ways later */
} }
if ((m = menu_create(NS_MENU_TITLE))) { if ((m = menu_create(NS_MENU_TITLE))) {
char *sc[] = { char *sc[] = {
@ -2793,11 +2826,8 @@ escreen_init(char **argv)
int n, nsc = sizeof(sc) / sizeof(char *); int n, nsc = sizeof(sc) / sizeof(char *);
if (menu_list) { if (menu_list) {
for (n = 0; n < menu_list->nummenus; n++) { /* blend in w/ l&f */ for (n = 0; n < menu_list->nummenus; n++) { /* blend in w/ l&f */
if (menu_list->menus[n]->font) { if (menu_list->menus[n]->font) {
#ifdef NS_DEBUG
D_ESCREEN(("%d: %p\n", n, menu_list->menus[n]->font));
#endif
m->font = menu_list->menus[n]->font; m->font = menu_list->menus[n]->font;
m->fwidth = menu_list->menus[n]->fwidth; m->fwidth = menu_list->menus[n]->fwidth;
m->fheight = menu_list->menus[n]->fheight; m->fheight = menu_list->menus[n]->fheight;
@ -2810,22 +2840,16 @@ escreen_init(char **argv)
} }
for (n = 0; n < (nsc - 1); n += 2) { for (n = 0; n < (nsc - 1); n += 2) {
if (!strcmp(sc[n], "-")) { /* separator */ if (!strcmp(sc[n], "-")) {
/* separator */
if ((i = menuitem_create(NULL))) { if ((i = menuitem_create(NULL))) {
menu_add_item(m, i); menu_add_item(m, i);
menuitem_set_action(i, MENUITEM_SEP, NULL); menuitem_set_action(i, MENUITEM_SEP, NULL);
} }
} /* menu entry */ } else if ((i = menuitem_create(sc[n]))) {
else if ((i = menuitem_create(sc[n]))) { /* menu entry */
menuitem_set_action(i, n && strcmp(sc[n + 1], NS_SCREEN_INIT) menuitem_set_action(i, n && strcmp(sc[n + 1], NS_SCREEN_INIT)
&& strcmp(sc[n + 1], NS_SCREEN_PRVS_REG) ? MENUITEM_ECHO : MENUITEM_LITERAL, sc[n + 1]); && strcmp(sc[n + 1], NS_SCREEN_PRVS_REG) ? MENUITEM_ECHO : MENUITEM_LITERAL, sc[n + 1]);
# ifdef NS_DEBUG
{
char buf[64];
sprintf(buf, NS_PREFIX "escreen_menu: registered %s as", sc[n]);
ns_desc_string(i->action.string, buf);
}
# endif
menu_add_item(m, i); menu_add_item(m, i);
} }
} }
@ -2846,32 +2870,31 @@ escreen_init(char **argv)
button_free(button); button_free(button);
} else { } else {
int j, k = menu_list ? menu_list->nummenus : 0; int j, k = menu_list ? menu_list->nummenus : 0;
menu_list = menulist_add_menu(menu_list, m); menu_list = menulist_add_menu(menu_list, m);
for (j = k; j < menu_list->nummenus; j++) for (j = k; j < menu_list->nummenus; j++) {
event_data_add_mywin(&menu_event_data, menu_list->menus[j]->win); event_data_add_mywin(&menu_event_data, menu_list->menus[j]->win);
}
if (!k) if (!k)
menu_init(); menu_init();
button_set_action(button, ACTION_MENU, NS_MENU_TITLE); button_set_action(button, ACTION_MENU, NS_MENU_TITLE);
} }
} }
} }
/* add_screen_ctl_button(&buttonbar,"New",'c'); */ /* add_screen_ctl_button(&buttonbar,"New",'c'); */
cmd_fd = TermWin.screen->fd; return TermWin.screen->fd;
} else {
return -1;
} }
# undef ETERM_PREFIX return -1;
# undef ESCREEN_PREFIX
return cmd_fd;
} }
#endif #endif
/* init_command() */ /* init_command() */
void void
init_command(char **argv) init_command(char **argv)
{ {
int (*command_func)(char **); int (*command_func) (char **);
/* Use init function appropriate for how we were compiled. */ /* Use init function appropriate for how we were compiled. */
#ifdef ESCREEN #ifdef ESCREEN
@ -2953,13 +2976,13 @@ cmd_write(const unsigned char *str, unsigned int count)
/* try and get more space from the end */ /* try and get more space from the end */
unsigned char *src, *dst; unsigned char *src, *dst;
dst = (cmdbuf_base + sizeof(cmdbuf_base) - 1); /* max pointer */ dst = (cmdbuf_base + sizeof(cmdbuf_base) - 1); /* max pointer */
if ((cmdbuf_ptr + n) > dst) if ((cmdbuf_ptr + n) > dst)
n = (dst - cmdbuf_ptr); /* max # chars to insert */ n = (dst - cmdbuf_ptr); /* max # chars to insert */
if ((cmdbuf_endp + n) > dst) if ((cmdbuf_endp + n) > dst)
cmdbuf_endp = (dst - n); /* truncate end if needed */ cmdbuf_endp = (dst - n); /* truncate end if needed */
/* equiv: memmove ((cmdbuf_ptr+n), cmdbuf_ptr, n); */ /* equiv: memmove ((cmdbuf_ptr+n), cmdbuf_ptr, n); */
src = cmdbuf_endp; src = cmdbuf_endp;
@ -3064,8 +3087,26 @@ cmd_getc(void)
#endif #endif
} }
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen_mode) if (TermWin.screen) {
parse_screen_status_if_necessary(); switch (TermWin.screen->backend) {
case NS_MODE_NONE:
break;
case NS_MODE_NEGOTIATE:
# ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
parse_screen_status_if_necessary();
break;
# endif
# ifdef NS_HAVE_SCREAM
case NS_MODE_SCREAM:
break;
# endif
default:
D_ESCREEN(("mode %d not supported...\n", TermWin.screen->backend));
TermWin.screen->backend = NS_MODE_NONE;
TermWin.screen_mode = NS_MODE_NONE;
}
}
#endif #endif
/* characters already read in */ /* characters already read in */
@ -3075,7 +3116,7 @@ cmd_getc(void)
for (;;) { for (;;) {
v_doPending(); v_doPending();
while (XPending(Xdisplay)) { /* process pending X events */ while (XPending(Xdisplay)) { /* process pending X events */
XEvent ev; XEvent ev;
@ -3282,7 +3323,7 @@ main_loop(void)
#endif #endif
do { do {
while ((ch = cmd_getc()) == 0); /* wait for something */ while ((ch = cmd_getc()) == 0); /* wait for something */
if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') { if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') {
/* Read a text string from the input buffer */ /* Read a text string from the input buffer */
int nlines = 0; int nlines = 0;
@ -3321,8 +3362,7 @@ main_loop(void)
break; break;
} }
} }
D_SCREEN(("Adding %d lines (%d chars); str == %8p, cmdbuf_ptr == %8p, cmdbuf_endp == %8p\n", D_SCREEN(("Adding %d lines (%d chars); str == %8p, cmdbuf_ptr == %8p, cmdbuf_endp == %8p\n", nlines, cmdbuf_ptr - str, str, cmdbuf_ptr, cmdbuf_endp));
nlines, cmdbuf_ptr - str, str, cmdbuf_ptr, cmdbuf_endp));
scr_add_lines(str, nlines, (cmdbuf_ptr - str)); scr_add_lines(str, nlines, (cmdbuf_ptr - str));
} else { } else {
switch (ch) { switch (ch) {
@ -3397,7 +3437,7 @@ v_writeBig(int f, char *d, int len)
*/ */
if (len > 0) { if (len > 0) {
if (v_bufend < v_bufptr + len) { /* we've run out of room */ if (v_bufend < v_bufptr + len) { /* we've run out of room */
if (v_bufstr != v_buffer) { if (v_bufstr != v_buffer) {
/* there is unused space, move everything down */ /* there is unused space, move everything down */
/* possibly overlapping bcopy here */ /* possibly overlapping bcopy here */
@ -3410,7 +3450,7 @@ v_writeBig(int f, char *d, int len)
if (v_bufend < v_bufptr + len) { if (v_bufend < v_bufptr + len) {
/* still won't fit: get more space */ /* still won't fit: get more space */
/* Don't use XtRealloc because an error is not fatal. */ /* Don't use XtRealloc because an error is not fatal. */
int size = v_bufptr - v_buffer; /* save across realloc */ int size = v_bufptr - v_buffer; /* save across realloc */
v_buffer = REALLOC(v_buffer, size + len); v_buffer = REALLOC(v_buffer, size + len);
if (v_buffer) { if (v_buffer) {
@ -3420,13 +3460,13 @@ v_writeBig(int f, char *d, int len)
} else { } else {
/* no memory: ignore entire write request */ /* no memory: ignore entire write request */
print_error("cannot allocate buffer space\n"); print_error("cannot allocate buffer space\n");
v_buffer = v_bufstr; /* restore clobbered pointer */ v_buffer = v_bufstr; /* restore clobbered pointer */
c = 0; c = 0;
} }
} }
} }
if (v_bufend >= v_bufptr + len) { /* new stuff will fit */ if (v_bufend >= v_bufptr + len) { /* new stuff will fit */
memcpy(v_bufptr, d, len); /* bcopy(d, v_bufptr, len); */ memcpy(v_bufptr, d, len); /* bcopy(d, v_bufptr, len); */
v_bufptr += len; v_bufptr += len;
} }
} }
@ -3452,13 +3492,13 @@ v_writeBig(int f, char *d, int len)
} }
D_TTY(("Wrote %d characters\n", written)); D_TTY(("Wrote %d characters\n", written));
v_bufstr += written; v_bufstr += written;
if (v_bufstr >= v_bufptr) /* we wrote it all */ if (v_bufstr >= v_bufptr) /* we wrote it all */
v_bufstr = v_bufptr = v_buffer; v_bufstr = v_bufptr = v_buffer;
} }
/* /*
* If we have lots of unused memory allocated, return it * If we have lots of unused memory allocated, return it
*/ */
if (v_bufend - v_bufptr > 1024) { /* arbitrary hysteresis */ if (v_bufend - v_bufptr > 1024) { /* arbitrary hysteresis */
/* save pointers across realloc */ /* save pointers across realloc */
int start = v_bufstr - v_buffer; int start = v_bufstr - v_buffer;
int size = v_bufptr - v_buffer; int size = v_bufptr - v_buffer;
@ -3471,7 +3511,7 @@ v_writeBig(int f, char *d, int len)
v_bufend = v_buffer + allocsize; v_bufend = v_buffer + allocsize;
} else { } else {
/* should we print a warning if couldn't return memory? */ /* should we print a warning if couldn't return memory? */
v_buffer = v_bufstr - start; /* restore clobbered pointer */ v_buffer = v_bufstr - start; /* restore clobbered pointer */
} }
} }
} }

View File

@ -238,6 +238,7 @@ if (test) PrivateModes |= (bit); else PrivateModes &= ~(bit);} while (0)
#endif #endif
#define VT100_ANS "\033[?1;2c" /* vt100 answerback */ #define VT100_ANS "\033[?1;2c" /* vt100 answerback */
#define LINUX_ANS "\033[?6;5c" /* linux answerback */
#ifndef ESCZ_ANSWER #ifndef ESCZ_ANSWER
# define ESCZ_ANSWER VT100_ANS /* obsolete ANSI ESC[c */ # define ESCZ_ANSWER VT100_ANS /* obsolete ANSI ESC[c */
#endif #endif
@ -359,6 +360,7 @@ extern void init_locale(void);
#else #else
# define init_locale() ((void)0) # define init_locale() ((void)0)
#endif #endif
extern int escreen_init(char **);
extern int run_command(char **); extern int run_command(char **);
extern void init_command(char **); extern void init_command(char **);
extern void tt_winsize(int); extern void tt_winsize(int);

View File

@ -182,7 +182,7 @@ eterm_default_font_locale(char ***fonts, char ***mfonts, char **mencoding, int *
if ((locale = getenv("LC_ALL")) == NULL) if ((locale = getenv("LC_ALL")) == NULL)
if ((locale = getenv("LC_CTYPE")) == NULL) if ((locale = getenv("LC_CTYPE")) == NULL)
if ((locale = getenv("LANG")) == NULL) if ((locale = getenv("LANG")) == NULL)
locale = "C"; /* failsafe */ locale = "C"; /* failsafe */
/* Obtain a "normalized" name of current encoding. /* Obtain a "normalized" name of current encoding.
* The current encoding is available via nl_langinfo(). * The current encoding is available via nl_langinfo().

View File

@ -144,7 +144,7 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border * bord, unsigned char up)
unsigned int r, g, b; unsigned int r, g, b;
int real_depth = 0, depth_factor; int real_depth = 0, depth_factor;
register int br, bg, bb; /* Bitshifts */ register int br, bg, bb; /* Bitshifts */
register unsigned int mr, mg, mb; /* Bitmasks */ register unsigned int mr, mg, mb; /* Bitmasks */
GC gc; GC gc;
if (!bord) if (!bord)

View File

@ -144,7 +144,7 @@ enl_ipc_send(char *str)
} }
} }
len = strlen(str); len = strlen(str);
for (; XCheckTypedWindowEvent(Xdisplay, my_ipc_win, ClientMessage, &ev);); /* Discard any out-of-sync messages */ for (; XCheckTypedWindowEvent(Xdisplay, my_ipc_win, ClientMessage, &ev);); /* Discard any out-of-sync messages */
ev.xclient.type = ClientMessage; ev.xclient.type = ClientMessage;
ev.xclient.serial = 0; ev.xclient.serial = 0;
ev.xclient.send_event = True; ev.xclient.send_event = True;

View File

@ -72,7 +72,7 @@
# define DEBUG_ACTIONS 4 # define DEBUG_ACTIONS 4
# define D_ACTIONS(x) DPRINTF4(x) # define D_ACTIONS(x) DPRINTF4(x)
# define DEBUG_ESCREEN 4 # define DEBUG_ESCREEN 4
# define D_ESCREEN(x) DPRINTF4(x) # define D_ESCREEN(x) DPRINTF4(x)
# define DEBUG_PROFILE 5 # define DEBUG_PROFILE 5
# define D_PROFILE(x) DPRINTF5(x) # define D_PROFILE(x) DPRINTF5(x)

View File

@ -46,6 +46,9 @@ static const char cvs_ident[] = "$Id$";
#include "scrollbar.h" #include "scrollbar.h"
#include "term.h" #include "term.h"
#include "windows.h" #include "windows.h"
#ifdef ESCREEN
# include "screamcfg.h"
#endif
unsigned char paused = 0; unsigned char paused = 0;
event_master_t event_master; event_master_t event_master;
@ -70,8 +73,7 @@ event_register_dispatcher(event_dispatcher_t func, event_dispatcher_init_t init)
/* Add a secondary event dispatcher */ /* Add a secondary event dispatcher */
event_master.num_dispatchers++; event_master.num_dispatchers++;
event_master.dispatchers = event_master.dispatchers = (event_dispatcher_t *) REALLOC(event_master.dispatchers, sizeof(event_dispatcher_t) * event_master.num_dispatchers);
(event_dispatcher_t *) REALLOC(event_master.dispatchers, sizeof(event_dispatcher_t) * event_master.num_dispatchers);
event_master.dispatchers[event_master.num_dispatchers - 1] = (event_dispatcher_t) func; event_master.dispatchers[event_master.num_dispatchers - 1] = (event_dispatcher_t) func;
(init) (); /* Initialize the dispatcher's data */ (init) (); /* Initialize the dispatcher's data */
} }
@ -226,8 +228,7 @@ handle_property_notify(event_t *ev)
if ((ev->xany.window == TermWin.parent) || (ev->xany.window == Xroot)) { if ((ev->xany.window == TermWin.parent) || (ev->xany.window == Xroot)) {
D_EVENTS(("On %s. prop (_WIN_WORKSPACE) == 0x%08x, ev->xproperty.atom == 0x%08x\n", D_EVENTS(("On %s. prop (_WIN_WORKSPACE) == 0x%08x, ev->xproperty.atom == 0x%08x\n",
((ev->xany.window == Xroot) ? "the root window" : "TermWin.parent"), ((ev->xany.window == Xroot) ? "the root window" : "TermWin.parent"), (int) props[PROP_DESKTOP], (int) ev->xproperty.atom));
(int) props[PROP_DESKTOP], (int) ev->xproperty.atom));
if (ev->xproperty.atom == props[PROP_DESKTOP]) { if (ev->xproperty.atom == props[PROP_DESKTOP]) {
win = get_desktop_window(); win = get_desktop_window();
if (win == (Window) 1) { if (win == (Window) 1) {
@ -267,8 +268,7 @@ handle_property_notify(event_t *ev)
} }
#endif #endif
if ((ev->xany.window == Xroot) && (image_mode_any(MODE_AUTO))) { if ((ev->xany.window == Xroot) && (image_mode_any(MODE_AUTO))) {
D_EVENTS(("On the root window. prop (ENLIGHTENMENT_COMMS) == %d, ev->xproperty.atom == %d\n", (int) props[PROP_ENL_COMMS], D_EVENTS(("On the root window. prop (ENLIGHTENMENT_COMMS) == %d, ev->xproperty.atom == %d\n", (int) props[PROP_ENL_COMMS], (int) ev->xproperty.atom));
(int) ev->xproperty.atom));
if ((props[PROP_ENL_COMMS] != None) && (ev->xproperty.atom == props[PROP_ENL_COMMS])) { if ((props[PROP_ENL_COMMS] != None) && (ev->xproperty.atom == props[PROP_ENL_COMMS])) {
if ((enl_ipc_get_win()) != None) { if ((enl_ipc_get_win()) != None) {
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
@ -333,8 +333,7 @@ handle_client_message(event_t *ev)
unsigned char *data; unsigned char *data;
unsigned long Size, RemainingBytes; unsigned long Size, RemainingBytes;
XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, &Size, &RemainingBytes, &data);
&Size, &RemainingBytes, &data);
if (data != NULL) { if (data != NULL) {
XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data)); XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data));
selection_paste(Xroot, XA_CUT_BUFFER0, True); selection_paste(Xroot, XA_CUT_BUFFER0, True);
@ -453,8 +452,7 @@ handle_focus_in(event_t *ev)
unsigned int unused_mask; unsigned int unused_mask;
TermWin.focus = 1; TermWin.focus = 1;
XQueryPointer(Xdisplay, TermWin.parent, &unused_root, &child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), XQueryPointer(Xdisplay, TermWin.parent, &unused_root, &child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);
&unused_mask);
if (child == TermWin.vt) { if (child == TermWin.vt) {
if (images[image_bg].current != images[image_bg].selected) { if (images[image_bg].current != images[image_bg].selected) {
images[image_bg].current = images[image_bg].selected; images[image_bg].current = images[image_bg].selected;
@ -517,8 +515,7 @@ handle_configure_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0); REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, ConfigureNotify, ev)) { while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, ConfigureNotify, ev)) {
D_EVENTS(("New event: Window 0x%08x, %dx%d at %d, %d\n", ev->xany.window, ev->xconfigure.width, D_EVENTS(("New event: Window 0x%08x, %dx%d at %d, %d\n", ev->xany.window, ev->xconfigure.width, ev->xconfigure.height, ev->xconfigure.x, ev->xconfigure.y));
ev->xconfigure.height, ev->xconfigure.x, ev->xconfigure.y));
} }
if (ev->xany.window == TermWin.parent) { if (ev->xany.window == TermWin.parent) {
int x = ev->xconfigure.x, y = ev->xconfigure.y; int x = ev->xconfigure.x, y = ev->xconfigure.y;
@ -740,6 +737,62 @@ handle_button_release(event_t *ev)
D_EVENTS(("handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); D_EVENTS(("handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
#ifdef ESCREEN
if (!XEVENT_IS_MYWIN(ev, &primary_data) && drag && TermWin.screen && TermWin.screen->backend && TermWin.screen->userdef) {
buttonbar_t *bbar = *((buttonbar_t **) (TermWin.screen->userdef));
button_t *b;
int fm = 0, to = 0;
if (!bbar || !(b = bbar->buttons)) {
return 0;
}
while (b && (b != drag)) {
b = b->next;
fm++;
}
if (!b) {
/* dragged button is not on the bar with our displays on */
return 0;
}
if (bbar->current) {
b = bbar->buttons;
while (b && (b != bbar->current)) {
b = b->next;
to++;
}
if (!b) {
/* dragged-to button is not on the bar with our displays */
return 0;
}
}
if (!bbar->current) {
/* tab torn off */
char *u = ns_get_url(TermWin.screen, fm);
if (u) {
char *c;
size_t l = strlen(orig_argv0) + strlen(u) + 7;
if ((c = MALLOC(l))) {
snprintf(c, l, "%s%s -U %s", ((orig_argv0[0] == '/') || ((orig_argv0[0] == '.') && (orig_argv0[1] == '/'))) ? "" : "./", orig_argv0, u);
D_ESCREEN(("(experimental) creating other frame using \"%s\"\n", c));
(void) ns_run(TermWin.screen->efuns, c);
FREE(c);
}
FREE(u);
}
return 1;
} else if (buttonbar->current != drag) {
/* tab "moved" */
ns_mov_disp(TermWin.screen, fm, to);
return 1;
}
}
#endif
if (button_state.ignore_release == 1) { if (button_state.ignore_release == 1) {
button_state.ignore_release = 0; button_state.ignore_release = 0;
return 0; return 0;
@ -802,8 +855,11 @@ handle_motion_notify(event_t *ev)
COUNT_EVENT(motion_cnt); COUNT_EVENT(motion_cnt);
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0); REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
if ((PrivateModes & PrivMode_mouse_report) && !(button_state.bypass_keystate))
if ((PrivateModes & PrivMode_mouse_report) && !(button_state.bypass_keystate)) {
mouse_drag_report(&(ev->xbutton));
return 1; return 1;
}
if (ev->xany.window == TermWin.vt) { if (ev->xany.window == TermWin.vt) {
if (ev->xbutton.state & (Button1Mask | Button3Mask)) { if (ev->xbutton.state & (Button1Mask | Button3Mask)) {
@ -812,8 +868,7 @@ handle_motion_notify(event_t *ev)
unsigned int unused_mask; unsigned int unused_mask;
while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt, MotionNotify, ev)); while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt, MotionNotify, ev));
XQueryPointer(Xdisplay, TermWin.vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), XQueryPointer(Xdisplay, TermWin.vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);
&(ev->xbutton.y), &unused_mask);
#ifdef MOUSE_THRESHOLD #ifdef MOUSE_THRESHOLD
/* deal with a `jumpy' mouse */ /* deal with a `jumpy' mouse */
if ((ev->xmotion.time - button_state.button_press) > MOUSE_THRESHOLD) if ((ev->xmotion.time - button_state.button_press) > MOUSE_THRESHOLD)

View File

@ -44,6 +44,7 @@ char **etfonts = NULL;
unsigned char font_idx = DEF_FONT_IDX, font_cnt = 0; unsigned char font_idx = DEF_FONT_IDX, font_cnt = 0;
int def_font_idx = DEF_FONT_IDX; int def_font_idx = DEF_FONT_IDX;
char *rs_font[NFONTS]; char *rs_font[NFONTS];
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
char *rs_mfont[NFONTS]; char *rs_mfont[NFONTS];
char **etmfonts = NULL; char **etmfonts = NULL;
@ -229,15 +230,14 @@ font_cache_del(const void *info)
update the "next" pointer of the font prior to the one we're actually deleting. */ update the "next" pointer of the font prior to the one we're actually deleting. */
for (current = font_cache; current->next; current = current->next) { for (current = font_cache; current->next; current = current->next) {
if (((current->next->type == FONT_TYPE_X) && (current->next->fontinfo.xfontinfo == (XFontStruct *) info))) { if (((current->next->type == FONT_TYPE_X) && (current->next->fontinfo.xfontinfo == (XFontStruct *) info))) {
D_FONT((" -> Match found at current->next (%8p, current == %8p). Font name is \"%s\"\n", current->next, current, D_FONT((" -> Match found at current->next (%8p, current == %8p). Font name is \"%s\"\n", current->next, current, NONULL(current->next->name)));
NONULL(current->next->name)));
if (--(current->next->ref_cnt) == 0) { if (--(current->next->ref_cnt) == 0) {
D_FONT((" -> Reference count is now 0. Deleting from cache.\n")); D_FONT((" -> Reference count is now 0. Deleting from cache.\n"));
tmp = current->next; tmp = current->next;
current->next = current->next->next; current->next = current->next->next;
XFreeFont(Xdisplay, (XFontStruct *) info); XFreeFont(Xdisplay, (XFontStruct *) info);
if (cur_font == tmp) { if (cur_font == tmp) {
cur_font = current; /* If we're nuking the last entry in the cache, point cur_font to the *new* last entry. */ cur_font = current; /* If we're nuking the last entry in the cache, point cur_font to the *new* last entry. */
} }
FREE(tmp->name); FREE(tmp->name);
FREE(tmp); FREE(tmp);
@ -455,8 +455,7 @@ change_font(int init, const char *fontname)
short idx = 0, old_idx = font_idx; short idx = 0, old_idx = font_idx;
int fh, fw = 0; int fh, fw = 0;
D_FONT(("change_font(%d, \"%s\"): def_font_idx == %u, font_idx == %u\n", init, NONULL(fontname), (unsigned int) def_font_idx, D_FONT(("change_font(%d, \"%s\"): def_font_idx == %u, font_idx == %u\n", init, NONULL(fontname), (unsigned int) def_font_idx, (unsigned int) font_idx));
(unsigned int) font_idx));
if (init) { if (init) {
font_idx = def_font_idx; font_idx = def_font_idx;
@ -585,8 +584,7 @@ change_font(int init, const char *fontname)
TermWin.fprop = 1; /* Proportional font */ TermWin.fprop = 1; /* Proportional font */
/* For proportional fonts with large size variations, do some math-fu to try and help the appearance */ /* For proportional fonts with large size variations, do some math-fu to try and help the appearance */
if (TermWin.fprop && (Options & Opt_proportional) && TermWin.font->per_char if (TermWin.fprop && (Options & Opt_proportional) && TermWin.font->per_char && (TermWin.font->max_bounds.width - TermWin.font->min_bounds.width >= 3)) {
&& (TermWin.font->max_bounds.width - TermWin.font->min_bounds.width >= 3)) {
int cw, n = 0, sum = 0, sumsq = 0, min_w, max_w; int cw, n = 0, sum = 0, sumsq = 0, min_w, max_w;
unsigned int i; unsigned int i;
double dev; double dev;
@ -634,7 +632,7 @@ change_font(int init, const char *fontname)
fw = boldFont->min_bounds.width; fw = boldFont->min_bounds.width;
fh = boldFont->ascent + boldFont->descent + rs_line_space; fh = boldFont->ascent + boldFont->descent + rs_line_space;
if (TermWin.fprop == 0) { /* bold font must also be monospaced */ if (TermWin.fprop == 0) { /* bold font must also be monospaced */
if (fw != boldFont->max_bounds.width) if (fw != boldFont->max_bounds.width)
fw = -1; fw = -1;
} else { } else {
@ -651,8 +649,7 @@ change_font(int init, const char *fontname)
TermWin.width = TermWin.ncol * TermWin.fwidth; TermWin.width = TermWin.ncol * TermWin.fwidth;
TermWin.height = TermWin.nrow * TermWin.fheight; TermWin.height = TermWin.nrow * TermWin.fheight;
D_FONT((" -> New font width/height = %ldx%ld, making the terminal size %ldx%ld\n", TermWin.fwidth, TermWin.fheight, TermWin.width, D_FONT((" -> New font width/height = %ldx%ld, making the terminal size %ldx%ld\n", TermWin.fwidth, TermWin.fheight, TermWin.width, TermWin.height));
TermWin.height));
/* If we're initializing, *we* do the size hints. If not, resize the parent window. */ /* If we're initializing, *we* do the size hints. If not, resize the parent window. */
if (init) { if (init) {

View File

@ -53,9 +53,9 @@ static const char cvs_ident[] = "$Id$";
# include <string.h> # include <string.h>
/* --- Macros, Types --------- */ /* --- Macros, Types --------- */
# define MAX_STATES 4 /* max # states for the FSM */ # define MAX_STATES 4 /* max # states for the FSM */
# define MAX_SWITCHER 2U /* per state */ # define MAX_SWITCHER 2U /* per state */
# define MAX_VAL 256 /* for temp allocation */ # define MAX_VAL 256 /* for temp allocation */
typedef unsigned char u_char; typedef unsigned char u_char;
typedef unsigned int u_int; typedef unsigned int u_int;
@ -77,7 +77,7 @@ typedef struct s_state {
u_int num_xlat; /* number of translations */ u_int num_xlat; /* number of translations */
K_XLAT *xlat; /* State translations ((dynamic - realloc'ed) */ K_XLAT *xlat; /* State translations ((dynamic - realloc'ed) */
u_int num_switcher; /* number of switcher keys */ u_int num_switcher; /* number of switcher keys */
K_SWITCH switcher[MAX_SWITCHER]; /* switcher keys to other states */ K_SWITCH switcher[MAX_SWITCHER]; /* switcher keys to other states */
u_char life; /* 0 = until switched by key */ u_char life; /* 0 = until switched by key */
u_char prev_state; /* filled when jumped to a new state */ u_char prev_state; /* filled when jumped to a new state */
} K_STATE; } K_STATE;
@ -109,10 +109,9 @@ static char elot_xlat_plain[] =
"65-122:193,194,216,196,197,214,195,199,201,206,202,203,204,205,207,208,81,209,211,212,200,217,87,215,213,198,91,92,93,94,95,96,225,226,248,228,229,246,227,231,233,238,234,235,236,237,239,240,113,241,243,244,232,249,242,247,245,230"; "65-122:193,194,216,196,197,214,195,199,201,206,202,203,204,205,207,208,81,209,211,212,200,217,87,215,213,198,91,92,93,94,95,96,225,226,248,228,229,246,227,231,233,238,234,235,236,237,239,240,113,241,243,244,232,249,242,247,245,230";
/* c and s give copyright and section sign */ /* c and s give copyright and section sign */
static char elot_xlat_acc[] = static char elot_xlat_acc[] = "65-122:182,194,216,196,184,214,195,185,186,206,202,203,204,205,188,208,81,209,211,212,200,191,87,215,190,198,91,92,93,94,95,96,220,226,"
"65-122:182,194,216,196,184,214,195,185,186,206,202,203,204,205,188,208,81,209,211,212,200,191,87,215,190,198,91,92,93,94,95,96,220,226,"
/*248 */ "169,228,221,246,227,222,223,238,234,235,236,237,252,240,113,241," /*243 */ "167,244,232,254,242,247,253,230"; /*248 */ "169,228,221,246,227,222,223,238,234,235,236,237,252,240,113,241," /*243 */ "167,244,232,254,242,247,253,230";
static char elot_xlat_acc_xtra[] = "46-62:183,47,48,49,50,51,52,53,54,55,56,57,58,59,171,61,187"; /* anw teleia, quotes */ static char elot_xlat_acc_xtra[] = "46-62:183,47,48,49,50,51,52,53,54,55,56,57,58,59,171,61,187"; /* anw teleia, quotes */
static char elot_xlat_uml[] = static char elot_xlat_uml[] =
"65-122:193,194,216,196,197,214,195,199,218,206,202,203,204,205,207,208,81,209,211,212,200,217,87,215,219,198,91,92,93,94,95,96,225,226,248,228,229,246,227,231,250,238,234,235,236,237,239,240,113,241,243,244,232,249,242,247,251,230"; "65-122:193,194,216,196,197,214,195,199,218,206,202,203,204,205,207,208,81,209,211,212,200,217,87,215,219,198,91,92,93,94,95,96,225,226,248,228,229,246,227,231,250,238,234,235,236,237,239,240,113,241,243,244,232,249,242,247,251,230";
static char elot_xlat_umacc[] = static char elot_xlat_umacc[] =
@ -123,7 +122,7 @@ static char i437_xlat_plain[] =
"65-122:128,129,150,131,132,148,130,134,136,141,137,138,139,140,142,143,81,144,145,146,135,151,87,149,147,133,91,92,93,94,95,96,152,153,175,155,156,173,154,158,160,165,161,162,163,164,166,167,113,168,169,171,159,224,170,174,172,157"; "65-122:128,129,150,131,132,148,130,134,136,141,137,138,139,140,142,143,81,144,145,146,135,151,87,149,147,133,91,92,93,94,95,96,152,153,175,155,156,173,154,158,160,165,161,162,163,164,166,167,113,168,169,171,159,224,170,174,172,157";
static char i437_xlat_acc[] = static char i437_xlat_acc[] =
"65-122:234,129,150,131,235,148,130,236,237,141,137,138,139,140,238,143,81,144,145,146,135,240,87,149,239,133,91,92,93,94,95,96,225,153,175,155,226,173,154,227,229,165,161,162,163,164,230,167,113,168,169,171,159,233,170,174,231,157"; "65-122:234,129,150,131,235,148,130,236,237,141,137,138,139,140,238,143,81,144,145,146,135,240,87,149,239,133,91,92,93,94,95,96,225,153,175,155,226,173,154,227,229,165,161,162,163,164,230,167,113,168,169,171,159,233,170,174,231,157";
static char i437_xlat_acc_xtra[] = "46-46:250"; /* anw teleia */ static char i437_xlat_acc_xtra[] = "46-46:250"; /* anw teleia */
static char i437_xlat_uml[] = static char i437_xlat_uml[] =
"65-122:128,129,150,131,132,148,130,134,136,141,137,138,139,140,142,143,81,144,145,146,135,151,87,149,147,133,91,92,93,94,95,96,152,153,175,155,156,173,154,158,228,165,161,162,163,164,166,167,113,168,169,171,159,224,170,174,232,157"; "65-122:128,129,150,131,132,148,130,134,136,141,137,138,139,140,142,143,81,144,145,146,135,151,87,149,147,133,91,92,93,94,95,96,152,153,175,155,156,173,154,158,228,165,161,162,163,164,166,167,113,168,169,171,159,224,170,174,232,157";
static char i437_xlat_umacc[] = static char i437_xlat_umacc[] =
@ -196,7 +195,7 @@ kstate_init_all(int greek_mode)
kstate_setcurr(i); kstate_setcurr(i);
kstate_init(); kstate_init();
} }
if (greek_mode < 0 || greek_mode >= NUM_XLAT_TYPES) /* avoid death */ if (greek_mode < 0 || greek_mode >= NUM_XLAT_TYPES) /* avoid death */
greek_mode = GREEK_ELOT928; greek_mode = GREEK_ELOT928;
xlat_now = &xlat_type[greek_mode]; xlat_now = &xlat_type[greek_mode];
kstate_setcurr(0); kstate_setcurr(0);
@ -310,7 +309,7 @@ kstate_cxlat(unsigned int c)
/* check for ascii switcher */ /* check for ascii switcher */
for (i = 0; i < pStateNow->num_switcher; i++) for (i = 0; i < pStateNow->num_switcher; i++)
if (pStateNow->switcher[i].type == 'A' && /* only ascii here */ if (pStateNow->switcher[i].type == 'A' && /* only ascii here */
c == pStateNow->switcher[i].code) { c == pStateNow->switcher[i].code) {
kstate_setcurr(pStateNow->switcher[i].nextstate); kstate_setcurr(pStateNow->switcher[i].nextstate);
pStateNow->switcher[i].on = 1; pStateNow->switcher[i].on = 1;

File diff suppressed because it is too large Load Diff

View File

@ -47,18 +47,16 @@ static const char cvs_ident[] = "$Id$";
# include "screamcfg.h" # include "screamcfg.h"
#endif #endif
menulist_t *menu_list = NULL;
#ifndef ESCREEN
static
#endif
event_dispatcher_data_t menu_event_data;
static GC topShadowGC, botShadowGC; static GC topShadowGC, botShadowGC;
static Time button_press_time; static Time button_press_time;
static int button_press_x = 0, button_press_y = 0; static int button_press_x = 0, button_press_y = 0;
#ifndef ESCREEN #ifndef ESCREEN
static static
#endif #endif
menu_t *current_menu; menu_t *current_menu;
menulist_t *menu_list = NULL;
event_dispatcher_data_t menu_event_data;
static inline void grab_pointer(Window win); static inline void grab_pointer(Window win);
static inline void ungrab_pointer(void); static inline void ungrab_pointer(void);
@ -74,8 +72,7 @@ grab_pointer(Window win)
D_EVENTS(("Grabbing control of pointer for window 0x%08x.\n", win)); D_EVENTS(("Grabbing control of pointer for window 0x%08x.\n", win));
success = XGrabPointer(Xdisplay, win, False, success = XGrabPointer(Xdisplay, win, False,
EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask
| Button1MotionMask | Button2MotionMask | Button3MotionMask, | Button1MotionMask | Button2MotionMask | Button3MotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
if (success != GrabSuccess) { if (success != GrabSuccess) {
switch (success) { switch (success) {
case GrabNotViewable: case GrabNotViewable:
@ -262,12 +259,10 @@ menu_handle_button_press(event_t *ev)
ungrab_pointer(); ungrab_pointer();
menu_reset_all(menu_list); menu_reset_all(menu_list);
current_menu = NULL; current_menu = NULL;
XTranslateCoordinates(Xdisplay, ev->xany.window, Xroot, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y), XTranslateCoordinates(Xdisplay, ev->xany.window, Xroot, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_win);
&unused_win);
child_win = find_window_by_coords(Xroot, 0, 0, ev->xbutton.x, ev->xbutton.y); child_win = find_window_by_coords(Xroot, 0, 0, ev->xbutton.x, ev->xbutton.y);
if (child_win != None) { if (child_win != None) {
XTranslateCoordinates(Xdisplay, Xroot, child_win, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y), XTranslateCoordinates(Xdisplay, Xroot, child_win, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_win);
&unused_win);
ev->xany.window = child_win; ev->xany.window = child_win;
D_EVENTS(("Sending synthetic event on to window 0x%08x at %d, %d\n", child_win, ev->xbutton.x, ev->xbutton.y)); D_EVENTS(("Sending synthetic event on to window 0x%08x at %d, %d\n", child_win, ev->xbutton.x, ev->xbutton.y));
XSendEvent(Xdisplay, child_win, False, 0, ev); XSendEvent(Xdisplay, child_win, False, 0, ev);
@ -297,8 +292,7 @@ menu_handle_button_release(event_t *ev)
if (current_menu && (current_menu->state & MENU_STATE_IS_DRAGGING)) { if (current_menu && (current_menu->state & MENU_STATE_IS_DRAGGING)) {
/* Dragging-and-release mode */ /* Dragging-and-release mode */
D_MENU(("Drag-and-release mode, detected release. Button press time is %lu, release time is %lu\n", button_press_time, D_MENU(("Drag-and-release mode, detected release. Button press time is %lu, release time is %lu\n", button_press_time, ev->xbutton.time));
ev->xbutton.time));
ungrab_pointer(); ungrab_pointer();
if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) { if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) {
@ -315,14 +309,13 @@ menu_handle_button_release(event_t *ev)
menu_reset_all(menu_list); menu_reset_all(menu_list);
current_menu = NULL; current_menu = NULL;
} else { } else {
current_menu->state &= ~MENU_STATE_IS_DRAGGING; /* Click, brief drag, release == single click */ current_menu->state &= ~MENU_STATE_IS_DRAGGING; /* Click, brief drag, release == single click */
} }
} else { } else {
/* Single-click mode */ /* Single-click mode */
D_MENU(("Single click mode, detected click. Button press time is %lu, release time is %lu\n", button_press_time, D_MENU(("Single click mode, detected click. Button press time is %lu, release time is %lu\n", button_press_time, ev->xbutton.time));
ev->xbutton.time));
if (current_menu && (ev->xbutton.x >= 0) && (ev->xbutton.y >= 0) && (ev->xbutton.x < current_menu->w) if (current_menu && (ev->xbutton.x >= 0) && (ev->xbutton.y >= 0) && (ev->xbutton.x < current_menu->w)
&& (ev->xbutton.y < current_menu->h)) { && (ev->xbutton.y < current_menu->h)) {
/* Click inside the menu window. Activate the current item. */ /* Click inside the menu window. Activate the current item. */
@ -463,22 +456,18 @@ menu_t *menu_create(char *title)
xattr.colormap = cmap; xattr.colormap = cmap;
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
mask = mask = PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask | Button3MotionMask;
PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask |
Button3MotionMask;
} }
menu = (menu_t *) MALLOC(sizeof(menu_t)); menu = (menu_t *) MALLOC(sizeof(menu_t));
MEMSET(menu, 0, sizeof(menu_t)); MEMSET(menu, 0, sizeof(menu_t));
menu->title = STRDUP(title ? title : ""); menu->title = STRDUP(title ? title : "");
menu->win = XCreateWindow(Xdisplay, Xroot, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, menu->win = XCreateWindow(Xdisplay, Xroot, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr);
CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr);
XDefineCursor(Xdisplay, menu->win, cursor); XDefineCursor(Xdisplay, menu->win, cursor);
XSelectInput(Xdisplay, menu->win, mask); XSelectInput(Xdisplay, menu->win, mask);
XStoreName(Xdisplay, menu->win, menu->title); XStoreName(Xdisplay, menu->win, menu->title);
menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr);
CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr);
menu->gc = LIBAST_X_CREATE_GC(0, NULL); menu->gc = LIBAST_X_CREATE_GC(0, NULL);
menuitem_clear_current(menu); menuitem_clear_current(menu);
@ -674,16 +663,14 @@ menuitem_change_current(menuitem_t *item)
current = menuitem_get_current(current_menu); current = menuitem_get_current(current_menu);
if (current != item) { if (current != item) {
D_MENU(("Changing current item in menu \"%s\" from \"%s\" to \"%s\"\n", current_menu->title, (current ? current->text : "(NULL)"), D_MENU(("Changing current item in menu \"%s\" from \"%s\" to \"%s\"\n", current_menu->title, (current ? current->text : "(NULL)"), (item ? item->text : "(NULL)")));
(item ? item->text : "(NULL)")));
if (current) { if (current) {
/* Reset the current item */ /* Reset the current item */
menuitem_deselect(current_menu); menuitem_deselect(current_menu);
/* If we're changing from one submenu to another and neither is a child of the other, or if we're changing from a submenu to /* If we're changing from one submenu to another and neither is a child of the other, or if we're changing from a submenu to
no current item at all, reset the tree for the current submenu */ no current item at all, reset the tree for the current submenu */
if (current->type == MENUITEM_SUBMENU && current->action.submenu != NULL) { if (current->type == MENUITEM_SUBMENU && current->action.submenu != NULL) {
if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu != NULL if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu != NULL && !menu_is_child(current->action.submenu, item->action.submenu)
&& !menu_is_child(current->action.submenu, item->action.submenu)
&& !menu_is_child(item->action.submenu, current->action.submenu)) && !menu_is_child(item->action.submenu, current->action.submenu))
|| (!item)) { || (!item)) {
menu_reset_tree(current->action.submenu); menu_reset_tree(current->action.submenu);
@ -896,8 +883,7 @@ menuitem_select(menu_t *menu)
item = menuitem_get_current(menu); item = menuitem_get_current(menu);
REQUIRE(item != NULL); REQUIRE(item != NULL);
D_MENU(("Selecting new current item \"%s\" within menu \"%s\" (window 0x%08x, selection window 0x%08x)\n", item->text, menu->title, D_MENU(("Selecting new current item \"%s\" within menu \"%s\" (window 0x%08x, selection window 0x%08x)\n", item->text, menu->title, menu->win, menu->swin));
menu->win, menu->swin));
item->state |= MENU_STATE_IS_CURRENT; item->state |= MENU_STATE_IS_CURRENT;
XMoveWindow(Xdisplay, menu->swin, item->x, item->y); XMoveWindow(Xdisplay, menu->swin, item->x, item->y);
XMapWindow(Xdisplay, menu->swin); XMapWindow(Xdisplay, menu->swin);
@ -907,8 +893,7 @@ menuitem_select(menu_t *menu)
enl_ipc_sync(); enl_ipc_sync();
} else if (!image_mode_is(image_submenu, MODE_MASK)) { } else if (!image_mode_is(image_submenu, MODE_MASK)) {
draw_shadow_from_colors(menu->swin, top, bottom, 0, 0, item->w - MENU_VGAP, item->h, 2); draw_shadow_from_colors(menu->swin, top, bottom, 0, 0, item->w - MENU_VGAP, item->h, 2);
draw_arrow_from_colors(menu->swin, top, bottom, item->w - 3 * MENU_HGAP, (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, draw_arrow_from_colors(menu->swin, top, bottom, item->w - 3 * MENU_HGAP, (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, DRAW_ARROW_RIGHT);
DRAW_ARROW_RIGHT);
} }
} else { } else {
if (image_mode_is(image_menu, MODE_MASK)) { if (image_mode_is(image_menu, MODE_MASK)) {
@ -923,8 +908,7 @@ menuitem_select(menu_t *menu)
XSetForeground(Xdisplay, menu->gc, images[image_menu].selected->fg); XSetForeground(Xdisplay, menu->gc, images[image_menu].selected->fg);
draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len); draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len);
if (item->rtext) { if (item->rtext) {
draw_string(menu->swin, menu->gc, item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP, item->h - MENU_VGAP, draw_string(menu->swin, menu->gc, item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP, item->h - MENU_VGAP, item->rtext, item->rlen);
item->rtext, item->rlen);
} }
XSetForeground(Xdisplay, menu->gc, images[image_menu].norm->fg); XSetForeground(Xdisplay, menu->gc, images[image_menu].norm->fg);
} }
@ -953,8 +937,7 @@ menu_display_submenu(menu_t *menu, menuitem_t *item)
REQUIRE(item->action.submenu != NULL); REQUIRE(item->action.submenu != NULL);
submenu = item->action.submenu; submenu = item->action.submenu;
D_MENU(("Displaying submenu \"%s\" (window 0x%08x) of menu \"%s\" (window 0x%08x)\n", submenu->title, submenu->win, menu->title, D_MENU(("Displaying submenu \"%s\" (window 0x%08x) of menu \"%s\" (window 0x%08x)\n", submenu->title, submenu->win, menu->title, menu->win));
menu->win));
menu_invoke(item->x + item->w, item->y, menu->win, submenu, CurrentTime); menu_invoke(item->x + item->w, item->y, menu->win, submenu, CurrentTime);
/* Invoking the submenu makes it current. Undo that behavior. */ /* Invoking the submenu makes it current. Undo that behavior. */
@ -985,6 +968,7 @@ menu_draw(menu_t *menu)
{ {
register unsigned short i, len; register unsigned short i, len;
unsigned long width, height; unsigned long width, height;
#if 0 #if 0
char *safeaction; char *safeaction;
#endif #endif
@ -1113,10 +1097,8 @@ menu_draw(menu_t *menu)
str_y = menu->fheight + MENU_VGAP; str_y = menu->fheight + MENU_VGAP;
len = strlen(menu->title); len = strlen(menu->title);
XTextExtents(menu->font, menu->title, len, &direction, &ascent, &descent, &chars); XTextExtents(menu->font, menu->title, len, &direction, &ascent, &descent, &chars);
draw_string(menu->bg, menu->gc, center_coords(2 * MENU_HGAP, menu->w - 2 * MENU_HGAP) - (chars.width >> 1), draw_string(menu->bg, 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);
str_y - chars.descent - MENU_VGAP / 2, menu->title, len); draw_shadow(menu->bg, topShadowGC, botShadowGC, str_x, str_y - chars.descent - MENU_VGAP / 2 + 1, menu->w - (4 * MENU_HGAP), MENU_VGAP, 2);
draw_shadow(menu->bg, topShadowGC, botShadowGC, str_x, str_y - chars.descent - MENU_VGAP / 2 + 1, menu->w - (4 * MENU_HGAP), MENU_VGAP,
2);
str_y += MENU_VGAP; str_y += MENU_VGAP;
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
@ -1130,11 +1112,9 @@ menu_draw(menu_t *menu)
item->y = str_y - 2 * MENU_VGAP; item->y = str_y - 2 * MENU_VGAP;
item->w = menu->w - MENU_HGAP; item->w = menu->w - MENU_HGAP;
item->h = 2 * MENU_VGAP; item->h = 2 * MENU_VGAP;
D_MENU(("Hot Area at %hu, %hu to %hu, %hu (width %hu, height %hu)\n", item->x, item->y, item->x + item->w, 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));
item->y + item->h, item->w, item->h));
} }
draw_shadow(menu->bg, botShadowGC, topShadowGC, str_x, str_y - MENU_VGAP - MENU_VGAP / 2, menu->w - 4 * MENU_HGAP, MENU_VGAP, draw_shadow(menu->bg, botShadowGC, topShadowGC, str_x, str_y - MENU_VGAP - MENU_VGAP / 2, menu->w - 4 * MENU_HGAP, MENU_VGAP, 2);
2);
} else { } else {
str_y += menu->fheight + MENU_VGAP; str_y += menu->fheight + MENU_VGAP;
@ -1143,18 +1123,15 @@ menu_draw(menu_t *menu)
item->y = str_y - menu->fheight - MENU_VGAP / 2; item->y = str_y - menu->fheight - MENU_VGAP / 2;
item->w = menu->w - MENU_HGAP; item->w = menu->w - MENU_HGAP;
item->h = menu->fheight + MENU_VGAP; item->h = menu->fheight + MENU_VGAP;
D_MENU(("Hot Area at %hu, %hu to %hu, %hu (width %hu, height %hu)\n", item->x, item->y, item->x + item->w, 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));
item->y + item->h, item->w, item->h));
} }
switch (item->type) { switch (item->type) {
case MENUITEM_SUBMENU: case MENUITEM_SUBMENU:
if (image_mode_is(image_submenu, MODE_MASK)) { if (image_mode_is(image_submenu, MODE_MASK)) {
paste_simage(images[image_submenu].norm, image_submenu, menu->win, menu->bg, item->x, item->y, item->w - MENU_VGAP, paste_simage(images[image_submenu].norm, image_submenu, menu->win, menu->bg, item->x, item->y, item->w - MENU_VGAP, item->h);
item->h);
} else { } else {
draw_arrow_from_colors(menu->bg, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor], draw_arrow_from_colors(menu->bg, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor],
item->x + item->w - 3 * MENU_HGAP, item->y + (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, item->x + item->w - 3 * MENU_HGAP, item->y + (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, DRAW_ARROW_RIGHT);
DRAW_ARROW_RIGHT);
} }
break; break;
#if 0 #if 0
@ -1179,8 +1156,7 @@ menu_draw(menu_t *menu)
} }
draw_string(menu->bg, menu->gc, str_x, str_y - MENU_VGAP / 2, item->text, item->len); draw_string(menu->bg, menu->gc, str_x, str_y - MENU_VGAP / 2, item->text, item->len);
if (item->rtext) { if (item->rtext) {
draw_string(menu->bg, menu->gc, str_x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 3 * MENU_HGAP, draw_string(menu->bg, menu->gc, str_x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 3 * MENU_HGAP, str_y - MENU_VGAP / 2, item->rtext, item->rlen);
str_y - MENU_VGAP / 2, item->rtext, item->rlen);
} }
} }
} }
@ -1226,16 +1202,34 @@ menu_action(menuitem_t *item)
break; break;
case MENUITEM_ECHO: case MENUITEM_ECHO:
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen_mode && TermWin.screen) { /* translate escapes */ if (TermWin.screen && TermWin.screen->backend) {
ns_parse_screen_interactive(TermWin.screen, item->action.string); /* translate escapes */
switch (TermWin.screen->backend) {
# ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
ns_parse_screen_interactive(TermWin.screen, item->action.string);
break;
# endif
default:
tt_write((unsigned char *) item->action.string, strlen(item->action.string));
}
} else } else
#endif #endif
tt_write((unsigned char *) item->action.string, strlen(item->action.string)); tt_write((unsigned char *) item->action.string, strlen(item->action.string));
break; break;
case MENUITEM_LITERAL: case MENUITEM_LITERAL:
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen_mode && TermWin.screen) { /* translate escapes */ if (TermWin.screen) {
(void) ns_screen_command(TermWin.screen, item->action.string); /* translate escapes */
switch (TermWin.screen->backend) {
# ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
(void) ns_screen_command(TermWin.screen, item->action.string);
break;
# endif
default:
tt_write((unsigned char *) item->action.string, strlen(item->action.string));
}
} else } else
#endif #endif
tt_write((unsigned char *) item->action.string, strlen(item->action.string)); tt_write((unsigned char *) item->action.string, strlen(item->action.string));
@ -1310,7 +1304,7 @@ menu_tab(void *xd, char *sc[], int nsc, char *b, size_t l, size_t m)
for (n = n2; n < nsc; n++) { for (n = n2; n < nsc; n++) {
if (!strncasecmp(b, sc[n], l)) { if (!strncasecmp(b, sc[n], l)) {
if (strcmp(b, sc[n])) { if (strcmp(b, sc[n])) {
if (strlen(sc[n]) >= m) /* buffer would overflow => fail */ if (strlen(sc[n]) >= m) /* buffer would overflow => fail */
return -1; return -1;
strcpy(b, sc[n]); strcpy(b, sc[n]);
return 0; return 0;
@ -1366,8 +1360,8 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
} }
if ((m = menu_create(prompt))) { if ((m = menu_create(prompt))) {
for (l = 0; l < menu_list->nummenus; l++) { /* copycat font entry to */ for (l = 0; l < menu_list->nummenus; l++) { /* copycat font entry to */
if (menu_list->menus[l]->font) { /* blend in with l&f */ if (menu_list->menus[l]->font) { /* blend in with l&f */
m->font = menu_list->menus[l]->font; m->font = menu_list->menus[l]->font;
m->fwidth = menu_list->menus[l]->fwidth; m->fwidth = menu_list->menus[l]->fwidth;
m->fheight = menu_list->menus[l]->fheight; m->fheight = menu_list->menus[l]->fheight;
@ -1385,17 +1379,21 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
if (m->font) { /* pre-calc width so we can center the dialog */ if (m->font) { /* pre-calc width so we can center the dialog */
l = strlen(prompt); l = strlen(prompt);
if (i->len > l) if (i->len > l) {
l = XTextWidth(m->font, i->text, i->len); l = XTextWidth(m->font, i->text, i->len);
else } else {
l = XTextWidth(m->font, prompt, l); l = XTextWidth(m->font, prompt, l);
} else }
} else {
l = 200; l = 200;
}
menuitem_set_action(i, MENUITEM_STRING, "error"); menuitem_set_action(i, MENUITEM_STRING, "error");
menu_add_item(m, i); menu_add_item(m, i);
menu_invoke((int) ((TermWin_TotalWidth() - l) / 2), (int) (TermWin_TotalHeight() / 2) - 20, TermWin.parent, m, CurrentTime); menu_invoke((int) ((TermWin_TotalWidth() - l) / 2), (int) (TermWin_TotalHeight() / 2) - 20, TermWin.parent, m, CurrentTime);
ungrab_pointer();
do { do {
do { do {
while (!XPending(Xdisplay)); while (!XPending(Xdisplay));
@ -1413,18 +1411,26 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
if (l < maxlen) { if (l < maxlen) {
b[l + 1] = '\0'; b[l + 1] = '\0';
b[l] = ch; b[l] = ch;
if (!l && (maxlen == 1)) {
/* special case: one char */
/* answer auto-returns */
f = 1;
}
} }
} else if ((ch == '\n') || (ch == '\r')) } else if ((ch == '\n') || (ch == '\r')) {
f = 1; f = 1;
else if (ch == '\x08') { } else if (ch == '\x08') {
if (maxlen && l) if (maxlen && l) {
b[--l] = '\0'; b[--l] = '\0';
}
} else if ((ch == '\t') && inp_tab) { } else if ((ch == '\t') && inp_tab) {
if (!tab) if (!tab) {
tab = l; tab = l;
}
inp_tab(xd, b, tab, maxlen); inp_tab(xd, b, tab, maxlen);
} else if (ch == '\x1b') } else if (ch == '\x1b') {
f = 2; f = 2;
}
i->len = strlen(b); i->len = strlen(b);
menu_draw(m); menu_draw(m);
} while (!f); } while (!f);
@ -1433,8 +1439,9 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
i->len = strlen(old); i->len = strlen(old);
/* we could just return b, but it might be longer than we need */ /* we could just return b, but it might be longer than we need */
if (retstr) if (retstr) {
*retstr = (!maxlen || (f == 2)) ? NULL : strdup(b); *retstr = (!maxlen || (f == 2)) ? NULL : strdup(b);
}
ret = (f == 2) ? -2 : 0; ret = (f == 2) ? -2 : 0;
} }
m->font = NULL; m->font = NULL;

View File

@ -78,7 +78,7 @@ network_display(const char *display)
if (display[0] != ':' && strncmp(display, "unix:", 5)) if (display[0] != ':' && strncmp(display, "unix:", 5))
return display; /* nothing to do */ return display; /* nothing to do */
ifc.ifc_len = sizeof(buffer); /* Get names of all ifaces */ ifc.ifc_len = sizeof(buffer); /* Get names of all ifaces */
ifc.ifc_buf = buffer; ifc.ifc_buf = buffer;
if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
@ -111,9 +111,7 @@ network_display(const char *display)
if (colon == NULL) if (colon == NULL)
colon = ":0.0"; colon = ":0.0";
sprintf(ipaddress, "%d.%d.%d.%d%s", sprintf(ipaddress, "%d.%d.%d.%d%s", (int) ((addr >> 030) & 0xFF), (int) ((addr >> 020) & 0xFF), (int) ((addr >> 010) & 0xFF), (int) (addr & 0xFF), colon);
(int) ((addr >> 030) & 0xFF),
(int) ((addr >> 020) & 0xFF), (int) ((addr >> 010) & 0xFF), (int) (addr & 0xFF), colon);
rval = ipaddress; rval = ipaddress;
break; break;

View File

@ -75,12 +75,14 @@ static void *parse_xim(char *, void *);
static void *parse_multichar(char *, void *); static void *parse_multichar(char *, void *);
static char *rs_pipe_name = NULL; static char *rs_pipe_name = NULL;
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
static int rs_shade = 0; static int rs_shade = 0;
static char *rs_tint = NULL; static char *rs_tint = NULL;
#endif #endif
static unsigned long rs_buttonbars = 1; static unsigned long rs_buttonbars = 1;
static char *rs_font_effects = NULL; static char *rs_font_effects = NULL;
#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) #if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
static char *rs_bigfont_key = NULL; static char *rs_bigfont_key = NULL;
static char *rs_smallfont_key = NULL; static char *rs_smallfont_key = NULL;
@ -101,11 +103,13 @@ char *rs_geometry = NULL; /* Geometry string */
int rs_desktop = -1; int rs_desktop = -1;
char *rs_path = NULL; char *rs_path = NULL;
int rs_saveLines = SAVELINES; /* Lines in the scrollback buffer */ int rs_saveLines = SAVELINES; /* Lines in the scrollback buffer */
#ifdef USE_XIM #ifdef USE_XIM
char *rs_input_method = NULL; char *rs_input_method = NULL;
char *rs_preedit_type = NULL; char *rs_preedit_type = NULL;
#endif #endif
char *rs_name = NULL; char *rs_name = NULL;
#ifndef NO_BOLDFONT #ifndef NO_BOLDFONT
char *rs_boldFont = NULL; char *rs_boldFont = NULL;
#endif #endif
@ -119,6 +123,7 @@ unsigned long rs_scrollbar_width = 0;
char *rs_finished_title = NULL; char *rs_finished_title = NULL;
char *rs_finished_text = NULL; char *rs_finished_text = NULL;
char *rs_term_name = NULL; char *rs_term_name = NULL;
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
char *rs_pixmapScale = NULL; char *rs_pixmapScale = NULL;
char *rs_icon = NULL; char *rs_icon = NULL;
@ -127,6 +132,7 @@ char *rs_cmod_red = NULL;
char *rs_cmod_green = NULL; char *rs_cmod_green = NULL;
char *rs_cmod_blue = NULL; char *rs_cmod_blue = NULL;
unsigned long rs_cache_size = (unsigned long) -1; unsigned long rs_cache_size = (unsigned long) -1;
# ifdef BACKGROUND_CYCLING_SUPPORT # ifdef BACKGROUND_CYCLING_SUPPORT
char *rs_anim_pixmap_list = NULL; char *rs_anim_pixmap_list = NULL;
char **rs_anim_pixmaps = NULL; char **rs_anim_pixmaps = NULL;
@ -136,6 +142,7 @@ static char *rs_pixmaps[image_max];
#endif #endif
char *rs_theme = NULL; char *rs_theme = NULL;
char *rs_config_file = NULL; char *rs_config_file = NULL;
#ifdef ESCREEN #ifdef ESCREEN
char *rs_url = NULL; char *rs_url = NULL;
char *rs_hop = NULL; char *rs_hop = NULL;
@ -143,6 +150,7 @@ int rs_delay = -1;
#endif #endif
unsigned int rs_line_space = 0; unsigned int rs_line_space = 0;
unsigned int rs_meta_mod = 0, rs_alt_mod = 0, rs_numlock_mod = 0; unsigned int rs_meta_mod = 0, rs_alt_mod = 0, rs_numlock_mod = 0;
#ifdef KEYSYM_ATTRIBUTE #ifdef KEYSYM_ATTRIBUTE
unsigned char *KeySym_map[256]; /* probably mostly empty */ unsigned char *KeySym_map[256]; /* probably mostly empty */
#endif #endif
@ -164,8 +172,7 @@ static const struct {
} optList[] = { } optList[] = {
OPT_STR('t', "theme", "select a theme", &rs_theme), OPT_STR('t', "theme", "select a theme", &rs_theme),
OPT_STR('X', "config-file", "choose an alternate config file", &rs_config_file), OPT_STR('X', "config-file", "choose an alternate config file", &rs_config_file), OPT_STR('d', "display", "X server to connect to", &display_name),
OPT_STR('d', "display", "X server to connect to", &display_name),
#ifdef ESCREEN #ifdef ESCREEN
OPT_STR('U', "URL", "an URL pointing at a screen-session to pick up", &rs_url), OPT_STR('U', "URL", "an URL pointing at a screen-session to pick up", &rs_url),
OPT_STR('Z', "[lclport:]fw[:fwport]", "the destination machine -U can only be seen by the firewall fw. tunnel.", &rs_hop), OPT_STR('Z', "[lclport:]fw[:fwport]", "the destination machine -U can only be seen by the firewall fw. tunnel.", &rs_hop),
@ -185,8 +192,7 @@ static const struct {
OPT_ILONG("debug", "level of debugging information to show (0-5)", &DEBUG_LEVEL), OPT_ILONG("debug", "level of debugging information to show (0-5)", &DEBUG_LEVEL),
#endif #endif
OPT_BLONG("install", "install a private colormap", &Options, Opt_install), OPT_BLONG("install", "install a private colormap", &Options, Opt_install),
OPT_BOOL('h', "help", "display usage information", NULL, 0), OPT_BOOL('h', "help", "display usage information", NULL, 0), OPT_BLONG("version", "display version and configuration information", NULL, 0),
OPT_BLONG("version", "display version and configuration information", NULL, 0),
/* =======[ Color options ]======= */ /* =======[ Color options ]======= */
OPT_BOOL('r', "reverse-video", "reverse video", &Options, Opt_reverse_video), OPT_BOOL('r', "reverse-video", "reverse video", &Options, Opt_reverse_video),
OPT_STR('b', "background-color", "background color", &rs_color[bgColor]), OPT_STR('b', "background-color", "background color", &rs_color[bgColor]),
@ -196,8 +202,7 @@ static const struct {
OPT_LONG("color2", "color 2", &rs_color[minColor + 2]), OPT_LONG("color2", "color 2", &rs_color[minColor + 2]),
OPT_LONG("color3", "color 3", &rs_color[minColor + 3]), OPT_LONG("color3", "color 3", &rs_color[minColor + 3]),
OPT_LONG("color4", "color 4", &rs_color[minColor + 4]), OPT_LONG("color4", "color 4", &rs_color[minColor + 4]),
OPT_LONG("color5", "color 5", &rs_color[minColor + 5]), OPT_LONG("color5", "color 5", &rs_color[minColor + 5]), OPT_LONG("color6", "color 6", &rs_color[minColor + 6]), OPT_LONG("color7", "color 7", &rs_color[minColor + 7]),
OPT_LONG("color6", "color 6", &rs_color[minColor + 6]), OPT_LONG("color7", "color 7", &rs_color[minColor + 7]),
#ifndef NO_BRIGHTCOLOR #ifndef NO_BRIGHTCOLOR
OPT_LONG("color8", "color 8", &rs_color[minBright]), OPT_LONG("color8", "color 8", &rs_color[minBright]),
OPT_LONG("color9", "color 9", &rs_color[minBright + 1]), OPT_LONG("color9", "color 9", &rs_color[minBright + 1]),
@ -212,8 +217,7 @@ static const struct {
#endif /* NO_BOLDUNDERLINE */ #endif /* NO_BOLDUNDERLINE */
OPT_LONG("pointer-color", "mouse pointer color", &rs_color[pointerColor]), OPT_LONG("pointer-color", "mouse pointer color", &rs_color[pointerColor]),
#ifndef NO_CURSORCOLOR #ifndef NO_CURSORCOLOR
OPT_STR('c', "cursor-color", "cursor color", &rs_color[cursorColor]), OPT_STR('c', "cursor-color", "cursor color", &rs_color[cursorColor]), OPT_LONG("cursor-text-color", "cursor text color", &rs_color[cursorColor2]),
OPT_LONG("cursor-text-color", "cursor text color", &rs_color[cursorColor2]),
#endif /* NO_CURSORCOLOR */ #endif /* NO_CURSORCOLOR */
/* =======[ X11 options ]======= */ /* =======[ X11 options ]======= */
OPT_STR('g', "geometry", "WxH+X+Y = size and position", &rs_geometry), OPT_STR('g', "geometry", "WxH+X+Y = size and position", &rs_geometry),
@ -265,8 +269,7 @@ static const struct {
OPT_LONG("mfont1", "multichar font 1", &rs_mfont[1]), OPT_LONG("mfont1", "multichar font 1", &rs_mfont[1]),
OPT_LONG("mfont2", "multichar font 2", &rs_mfont[2]), OPT_LONG("mfont2", "multichar font 2", &rs_mfont[2]),
OPT_LONG("mfont3", "multichar font 3", &rs_mfont[3]), OPT_LONG("mfont3", "multichar font 3", &rs_mfont[3]),
OPT_LONG("mfont4", "multichar font 4", &rs_mfont[4]), OPT_LONG("mfont4", "multichar font 4", &rs_mfont[4]), OPT_LONG("mencoding", "multichar encoding mode (eucj/sjis/euckr/big5/gb)", &rs_multichar_encoding),
OPT_LONG("mencoding", "multichar encoding mode (eucj/sjis/euckr/big5/gb)", &rs_multichar_encoding),
#endif /* MULTI_CHARSET */ #endif /* MULTI_CHARSET */
#ifdef USE_XIM #ifdef USE_XIM
OPT_LONG("input-method", "XIM input method", &rs_input_method), OPT_LONG("preedit-type", "XIM preedit type", &rs_preedit_type), OPT_LONG("input-method", "XIM input method", &rs_input_method), OPT_LONG("preedit-type", "XIM preedit type", &rs_preedit_type),
@ -302,20 +305,16 @@ static const struct {
OPT_BLONG("resize-gravity", "toggle gravitation to nearest corner on resize", &Options, Opt_resize_gravity), OPT_BLONG("resize-gravity", "toggle gravitation to nearest corner on resize", &Options, Opt_resize_gravity),
/* =======[ Keyboard options ]======= */ /* =======[ Keyboard options ]======= */
#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) #if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
OPT_LONG("big-font-key", "keysym for font size increase", &rs_bigfont_key), OPT_LONG("big-font-key", "keysym for font size increase", &rs_bigfont_key), OPT_LONG("small-font-key", "keysym for font size decrease", &rs_smallfont_key),
OPT_LONG("small-font-key", "keysym for font size decrease", &rs_smallfont_key),
#endif #endif
OPT_ILONG("meta-mod", "modifier to interpret as the Meta key", &rs_meta_mod), OPT_ILONG("meta-mod", "modifier to interpret as the Meta key", &rs_meta_mod),
OPT_ILONG("alt-mod", "modifier to interpret as the Alt key", &rs_alt_mod), OPT_ILONG("alt-mod", "modifier to interpret as the Alt key", &rs_alt_mod), OPT_ILONG("numlock-mod", "modifier to interpret as the NumLock key", &rs_numlock_mod),
OPT_ILONG("numlock-mod", "modifier to interpret as the NumLock key", &rs_numlock_mod),
#ifdef GREEK_SUPPORT #ifdef GREEK_SUPPORT
OPT_LONG("greek-keyboard", "greek keyboard mapping (iso or ibm)", &rs_greek_keyboard), OPT_LONG("greek-keyboard", "greek keyboard mapping (iso or ibm)", &rs_greek_keyboard),
#endif #endif
OPT_BLONG("app-keypad", "application keypad mode", &PrivateModes, PrivMode_aplKP), OPT_BLONG("app-keypad", "application keypad mode", &PrivateModes, PrivMode_aplKP), OPT_BLONG("app-cursor", "application cursor key mode", &PrivateModes, PrivMode_aplCUR),
OPT_BLONG("app-cursor", "application cursor key mode", &PrivateModes, PrivMode_aplCUR),
/* =======[ Misc options ]======= */ /* =======[ Misc options ]======= */
OPT_INT('L', "save-lines", "lines to save in scrollback buffer", &rs_saveLines), OPT_INT('L', "save-lines", "lines to save in scrollback buffer", &rs_saveLines), OPT_ILONG("min-anchor-size", "minimum size of the scrollbar anchor", &rs_min_anchor_size),
OPT_ILONG("min-anchor-size", "minimum size of the scrollbar anchor", &rs_min_anchor_size),
#ifdef BORDER_WIDTH_OPTION #ifdef BORDER_WIDTH_OPTION
OPT_INT('w', "border-width", "term window border width", &(TermWin.internalBorder)), OPT_INT('w', "border-width", "term window border width", &(TermWin.internalBorder)),
#endif #endif
@ -330,8 +329,7 @@ static const struct {
OPT_LONG("term-name", "value to use for setting $TERM", &rs_term_name), OPT_LONG("term-name", "value to use for setting $TERM", &rs_term_name),
OPT_LONG("pipe-name", "filename of console pipe to emulate -C", &rs_pipe_name), OPT_LONG("pipe-name", "filename of console pipe to emulate -C", &rs_pipe_name),
OPT_STR('a', "attribute", "parse an attribute in the specified context", NULL), OPT_STR('a', "attribute", "parse an attribute in the specified context", NULL),
OPT_BOOL('C', "console", "grab console messages", &Options, Opt_console), OPT_BOOL('C', "console", "grab console messages", &Options, Opt_console), OPT_ARGS('e', "exec", "execute a command rather than a shell", &rs_exec_args)
OPT_ARGS('e', "exec", "execute a command rather than a shell", &rs_exec_args)
}; };
/* Print usage information */ /* Print usage information */
@ -402,8 +400,7 @@ version(void)
" " PIXMAP_IDENT "\n" " " PIXMAP_IDENT "\n"
" " SCREEN_IDENT "\n" " " SCREEN_IDENT "\n"
" " SCROLLBAR_IDENT "\n" " " SCROLLBAR_IDENT "\n"
" " STARTUP_IDENT "\n" " " STARTUP_IDENT "\n" " " SYSTEM_IDENT "\n" " " TERM_IDENT "\n" " " TIMER_IDENT "\n" " " UTMP_IDENT "\n" " " WINDOWS_IDENT "\n" "\n");
" " SYSTEM_IDENT "\n" " " TERM_IDENT "\n" " " TIMER_IDENT "\n" " " UTMP_IDENT "\n" " " WINDOWS_IDENT "\n" "\n");
printf("Debugging configuration: "); printf("Debugging configuration: ");
#ifdef DEBUG #ifdef DEBUG
@ -894,7 +891,7 @@ get_options(int argc, char *argv[])
} else if (!strcasecmp(opt, "attribute")) { } else if (!strcasecmp(opt, "attribute")) {
conf_parse_line(NULL, val_ptr); conf_parse_line(NULL, val_ptr);
} else { /* It's not --exec */ } else { /* It's not --exec */
if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */ if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */
D_OPTIONS(("Boolean option detected\n")); D_OPTIONS(("Boolean option detected\n"));
if (val_ptr) { if (val_ptr) {
if (BOOL_OPT_ISTRUE(val_ptr)) { if (BOOL_OPT_ISTRUE(val_ptr)) {
@ -917,7 +914,7 @@ get_options(int argc, char *argv[])
*(optList[j].maskvar) |= optList[j].mask; *(optList[j].maskvar) |= optList[j].mask;
} }
} }
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */ } else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
D_OPTIONS(("Integer option detected\n")); D_OPTIONS(("Integer option detected\n"));
*((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0); *((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0);
} else { /* String value */ } else { /* String value */
@ -965,13 +962,13 @@ get_options(int argc, char *argv[])
if ((val_ptr == NULL) || ((*val_ptr == '-') && (optList[j].short_opt != 'F') && (optList[j].short_opt != 'g'))) { if ((val_ptr == NULL) || ((*val_ptr == '-') && (optList[j].short_opt != 'F') && (optList[j].short_opt != 'g'))) {
print_error("option -%c requires a%s value\n", opt[pos], (optList[j].flag & OPT_INTEGER ? "n integer" : " string")); print_error("option -%c requires a%s value\n", opt[pos], (optList[j].flag & OPT_INTEGER ? "n integer" : " string"));
CHECK_BAD(); CHECK_BAD();
if (val_ptr) { /* If the "arg" was actually an option, don't skip it */ if (val_ptr) { /* If the "arg" was actually an option, don't skip it */
i--; i--;
} }
continue; continue;
} }
} }
if (opt[pos] == 'e') { /* It's an exec */ if (opt[pos] == 'e') { /* It's an exec */
register unsigned short k, len; register unsigned short k, len;
@ -1006,12 +1003,12 @@ get_options(int argc, char *argv[])
} else if (opt[pos] == 'a') { } else if (opt[pos] == 'a') {
conf_parse_line(NULL, val_ptr); conf_parse_line(NULL, val_ptr);
} else { } else {
if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */ if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */
D_OPTIONS(("Boolean option detected\n")); D_OPTIONS(("Boolean option detected\n"));
if (optList[j].maskvar) { if (optList[j].maskvar) {
*(optList[j].maskvar) |= optList[j].mask; *(optList[j].maskvar) |= optList[j].mask;
} }
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */ } else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
D_OPTIONS(("Integer option detected\n")); D_OPTIONS(("Integer option detected\n"));
*((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0); *((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0);
D_OPTIONS(("Got value %d\n", *((int *) optList[j].pval))); D_OPTIONS(("Got value %d\n", *((int *) optList[j].pval)));
@ -1140,7 +1137,7 @@ get_initial_options(int argc, char *argv[])
D_OPTIONS(("val_ptr == %s done == %d\n", val_ptr, done)); D_OPTIONS(("val_ptr == %s done == %d\n", val_ptr, done));
if ((val_ptr == NULL) || (*val_ptr == '-')) { if ((val_ptr == NULL) || (*val_ptr == '-')) {
print_error("option -%c requires a string value\n", opt[pos]); print_error("option -%c requires a string value\n", opt[pos]);
if (val_ptr) { /* If the "arg" was actually an option, don't skip it */ if (val_ptr) { /* If the "arg" was actually an option, don't skip it */
i--; i--;
} }
continue; continue;
@ -1191,8 +1188,7 @@ parse_color(char *buff, void *state)
if (!BEG_STRCASECMP(tmp, "reverse")) { if (!BEG_STRCASECMP(tmp, "reverse")) {
Options |= Opt_reverse_video; Options |= Opt_reverse_video;
} else if (BEG_STRCASECMP(tmp, "normal")) { } else if (BEG_STRCASECMP(tmp, "normal")) {
print_error("Parse error in file %s, line %lu: Invalid value \"%s\" for attribute video\n", print_error("Parse error in file %s, line %lu: Invalid value \"%s\" for attribute video\n", file_peek_path(), file_peek_line(), tmp);
file_peek_path(), file_peek_line(), tmp);
} }
} else if (!BEG_STRCASECMP(buff, "color ")) { } else if (!BEG_STRCASECMP(buff, "color ")) {
@ -1201,8 +1197,7 @@ parse_color(char *buff, void *state)
n = num_words(buff); n = num_words(buff);
if (n < 3) { if (n < 3) {
print_error("Parse error in file %s, line %lu: Invalid parameter list \"%s\" for \n" print_error("Parse error in file %s, line %lu: Invalid parameter list \"%s\" for \n" "attribute color", file_peek_path(), file_peek_line(), NONULL(tmp));
"attribute color", file_peek_path(), file_peek_line(), NONULL(tmp));
return NULL; return NULL;
} }
tmp = get_pword(2, buff); tmp = get_pword(2, buff);
@ -1234,15 +1229,13 @@ parse_color(char *buff, void *state)
return NULL; return NULL;
} else { } else {
tmp = get_word(1, tmp); tmp = get_word(1, tmp);
print_error("Parse error in file %s, line %lu: Invalid color index \"%s\"\n", print_error("Parse error in file %s, line %lu: Invalid color index \"%s\"\n", file_peek_path(), file_peek_line(), NONULL(tmp));
file_peek_path(), file_peek_line(), NONULL(tmp));
FREE(tmp); FREE(tmp);
} }
} }
} }
if (n != 5) { if (n != 5) {
print_error("Parse error in file %s, line %lu: Invalid parameter list \"%s\" for \n" print_error("Parse error in file %s, line %lu: Invalid parameter list \"%s\" for \n" "attribute color", file_peek_path(), file_peek_line(), NONULL(tmp));
"attribute color", file_peek_path(), file_peek_line(), NONULL(tmp));
return NULL; return NULL;
} }
g1 = get_pword(4, buff); g1 = get_pword(4, buff);
@ -1292,8 +1285,7 @@ parse_color(char *buff, void *state)
FREE(tmp); FREE(tmp);
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context color\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context color\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
return state; return state;
} }
@ -1332,8 +1324,7 @@ parse_attributes(char *buff, void *state)
if (!BEG_STRCASECMP(tmp, "fx ") || !BEG_STRCASECMP(tmp, "effect")) { if (!BEG_STRCASECMP(tmp, "fx ") || !BEG_STRCASECMP(tmp, "effect")) {
if (parse_font_fx(get_pword(2, tmp)) != 1) { if (parse_font_fx(get_pword(2, tmp)) != 1) {
print_error("Parse error in file %s, line %lu: Syntax error in font effects specification\n", print_error("Parse error in file %s, line %lu: Syntax error in font effects specification\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
} }
} else if (!BEG_STRCASECMP(tmp, "prop")) { } else if (!BEG_STRCASECMP(tmp, "prop")) {
tmp = get_pword(2, tmp); tmp = get_pword(2, tmp);
@ -1342,8 +1333,7 @@ parse_attributes(char *buff, void *state)
} else if (BOOL_OPT_ISFALSE(tmp)) { } else if (BOOL_OPT_ISFALSE(tmp)) {
Options &= ~(Opt_proportional); Options &= ~(Opt_proportional);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid/missing boolean value for attribute proportional\n", print_error("Parse error in file %s, line %lu: Invalid/missing boolean value for attribute proportional\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
} }
} else if (isdigit(*tmp)) { } else if (isdigit(*tmp)) {
n = (unsigned char) strtoul(tmp, (char **) NULL, 0); n = (unsigned char) strtoul(tmp, (char **) NULL, 0);
@ -1369,8 +1359,7 @@ parse_attributes(char *buff, void *state)
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context attributes\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context attributes\n", file_peek_path(), file_peek_line(), (buff ? buff : ""));
file_peek_path(), file_peek_line(), (buff ? buff : ""));
} }
return state; return state;
} }
@ -1393,8 +1382,7 @@ parse_toggles(char *buff, void *state)
} else if (BOOL_OPT_ISFALSE(tmp)) { } else if (BOOL_OPT_ISFALSE(tmp)) {
bool_val = 0; bool_val = 0;
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" in context toggles\n", print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" in context toggles\n", file_peek_path(), file_peek_line(), tmp);
file_peek_path(), file_peek_line(), tmp);
return NULL; return NULL;
} }
@ -1584,8 +1572,7 @@ parse_toggles(char *buff, void *state)
Options &= ~(Opt_resize_gravity); Options &= ~(Opt_resize_gravity);
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context toggles\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context toggles\n", file_peek_path(), file_peek_line(), buff);
file_peek_line(), buff);
} }
return state; return state;
} }
@ -1624,8 +1611,7 @@ parse_keyboard(char *buff, void *state)
if (sym >= 0xff00) if (sym >= 0xff00)
sym -= 0xff00; sym -= 0xff00;
if (sym < 0 || sym > 0xff) { if (sym < 0 || sym > 0xff) {
print_error("Parse error in file %s, line %lu: Keysym 0x%x out of range 0xff00-0xffff\n", print_error("Parse error in file %s, line %lu: Keysym 0x%x out of range 0xff00-0xffff\n", file_peek_path(), file_peek_line(), sym + 0xff00);
file_peek_path(), file_peek_line(), sym + 0xff00);
return NULL; return NULL;
} }
s = get_word(3, buff); s = get_word(3, buff);
@ -1653,8 +1639,7 @@ parse_keyboard(char *buff, void *state)
char *tmp = get_pword(2, buff); char *tmp = get_pword(2, buff);
if (!tmp) { if (!tmp) {
print_error("Parse error in file %s, line %lu: Missing modifier value for attribute meta_mod\n", print_error("Parse error in file %s, line %lu: Missing modifier value for attribute meta_mod\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
rs_meta_mod = (unsigned int) strtoul(tmp, (char **) NULL, 0); rs_meta_mod = (unsigned int) strtoul(tmp, (char **) NULL, 0);
@ -1663,8 +1648,7 @@ parse_keyboard(char *buff, void *state)
char *tmp = get_pword(2, buff); char *tmp = get_pword(2, buff);
if (!tmp) { if (!tmp) {
print_error("Parse error in file %s, line %lu: Missing modifier value for attribute alt_mod\n", print_error("Parse error in file %s, line %lu: Missing modifier value for attribute alt_mod\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
rs_alt_mod = (unsigned int) strtoul(tmp, (char **) NULL, 0); rs_alt_mod = (unsigned int) strtoul(tmp, (char **) NULL, 0);
@ -1673,8 +1657,7 @@ parse_keyboard(char *buff, void *state)
char *tmp = get_pword(2, buff); char *tmp = get_pword(2, buff);
if (!tmp) { if (!tmp) {
print_error("Parse error in file %s, line %lu: Missing modifier value for attribute numlock_mod\n", print_error("Parse error in file %s, line %lu: Missing modifier value for attribute numlock_mod\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
rs_numlock_mod = (unsigned int) strtoul(tmp, (char **) NULL, 0); rs_numlock_mod = (unsigned int) strtoul(tmp, (char **) NULL, 0);
@ -1685,8 +1668,7 @@ parse_keyboard(char *buff, void *state)
char *tmp = get_pword(2, buff); char *tmp = get_pword(2, buff);
if (!tmp) { if (!tmp) {
print_error("Parse error in file %s, line %lu: Missing boolean value for attribute greek\n", print_error("Parse error in file %s, line %lu: Missing boolean value for attribute greek\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
if (BOOL_OPT_ISTRUE(tmp)) { if (BOOL_OPT_ISTRUE(tmp)) {
@ -1702,8 +1684,7 @@ parse_keyboard(char *buff, void *state)
} else if (BOOL_OPT_ISFALSE(tmp)) { } else if (BOOL_OPT_ISFALSE(tmp)) {
/* This space intentionally left no longer blank =^) */ /* This space intentionally left no longer blank =^) */
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" for attribute %s\n", print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" for attribute %s\n", file_peek_path(), file_peek_line(), tmp, buff);
file_peek_path(), file_peek_line(), tmp, buff);
return NULL; return NULL;
} }
#else #else
@ -1715,8 +1696,7 @@ parse_keyboard(char *buff, void *state)
char *tmp = get_pword(2, buff); char *tmp = get_pword(2, buff);
if (!tmp) { if (!tmp) {
print_error("Parse error in file %s, line %lu: Missing boolean value for attribute app_keypad\n", print_error("Parse error in file %s, line %lu: Missing boolean value for attribute app_keypad\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
if (BOOL_OPT_ISTRUE(tmp)) { if (BOOL_OPT_ISTRUE(tmp)) {
@ -1724,8 +1704,7 @@ parse_keyboard(char *buff, void *state)
} else if (BOOL_OPT_ISFALSE(tmp)) { } else if (BOOL_OPT_ISFALSE(tmp)) {
PrivateModes &= ~(PrivMode_aplKP); PrivateModes &= ~(PrivMode_aplKP);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" for attribute app_keypad\n", print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" for attribute app_keypad\n", file_peek_path(), file_peek_line(), tmp);
file_peek_path(), file_peek_line(), tmp);
return NULL; return NULL;
} }
@ -1734,8 +1713,7 @@ parse_keyboard(char *buff, void *state)
char *tmp = get_pword(2, buff); char *tmp = get_pword(2, buff);
if (!tmp) { if (!tmp) {
print_error("Parse error in file %s, line %lu: Missing boolean value for attribute app_cursor\n", print_error("Parse error in file %s, line %lu: Missing boolean value for attribute app_cursor\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
if (BOOL_OPT_ISTRUE(tmp)) { if (BOOL_OPT_ISTRUE(tmp)) {
@ -1743,14 +1721,12 @@ parse_keyboard(char *buff, void *state)
} else if (BOOL_OPT_ISFALSE(tmp)) { } else if (BOOL_OPT_ISFALSE(tmp)) {
PrivateModes &= ~(PrivMode_aplCUR); PrivateModes &= ~(PrivMode_aplCUR);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" for attribute app_cursor\n", print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" for attribute app_cursor\n", file_peek_path(), file_peek_line(), tmp);
file_peek_path(), file_peek_line(), tmp);
return NULL; return NULL;
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context keyboard\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context keyboard\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
return state; return state;
} }
@ -1818,8 +1794,7 @@ parse_misc(char *buff, void *state)
#endif #endif
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context misc\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context misc\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
return state; return state;
} }
@ -1855,16 +1830,14 @@ parse_imageclasses(char *buff, void *state)
if (tmp) { if (tmp) {
rs_anim_pixmap_list = STRDUP(tmp); rs_anim_pixmap_list = STRDUP(tmp);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid parameter list \"\" for attribute anim\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid parameter list \"\" for attribute anim\n", file_peek_path(), file_peek_line());
file_peek_line());
} }
#else #else
print_warning("Support for the anim attribute was not compiled in, ignoring\n"); print_warning("Support for the anim attribute was not compiled in, ignoring\n");
#endif #endif
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context imageclasses\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context imageclasses\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
return state; return state;
} }
@ -1938,8 +1911,7 @@ parse_image(char *buff, void *state)
char *allow_list = get_pword(4, buff); char *allow_list = get_pword(4, buff);
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"mode\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"mode\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (!mode) { if (!mode) {
@ -1985,8 +1957,7 @@ parse_image(char *buff, void *state)
return NULL; return NULL;
} }
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"state\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"state\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (!strcasecmp(state, "normal")) { if (!strcasecmp(state, "normal")) {
@ -2028,18 +1999,15 @@ parse_image(char *buff, void *state)
char *fg = get_word(2, buff), *bg = get_word(3, buff); char *fg = get_word(2, buff), *bg = get_word(3, buff);
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"color\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"color\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"color\" with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"color\" with no image state defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (!fg || !bg) { if (!fg || !bg) {
print_error("Parse error in file %s, line %lu: Foreground and background colors must be specified with \"color\"\n", print_error("Parse error in file %s, line %lu: Foreground and background colors must be specified with \"color\"\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
if (!BEG_STRCASECMP(fg, "0x")) { if (!BEG_STRCASECMP(fg, "0x")) {
@ -2060,13 +2028,11 @@ parse_image(char *buff, void *state)
char *filename = get_pword(2, buff); char *filename = get_pword(2, buff);
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image state defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (!filename) { if (!filename) {
@ -2082,13 +2048,11 @@ parse_image(char *buff, void *state)
char *geom = get_pword(2, buff); char *geom = get_pword(2, buff);
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image state defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (!geom) { if (!geom) {
@ -2104,13 +2068,11 @@ parse_image(char *buff, void *state)
imlib_t *iml = images[idx].current->iml; imlib_t *iml = images[idx].current->iml;
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered color modifier with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered color modifier with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (!color) { if (!color) {
@ -2176,21 +2138,18 @@ parse_image(char *buff, void *state)
} }
update_cmod(iml->bmod); update_cmod(iml->bmod);
} else { } else {
print_error("Parse error in file %s, line %lu: Color must be either \"image\", \"red\", \"green\", or \"blue\"\n", print_error("Parse error in file %s, line %lu: Color must be either \"image\", \"red\", \"green\", or \"blue\"\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
#endif #endif
} else if (!BEG_STRCASECMP(buff, "border ")) { } else if (!BEG_STRCASECMP(buff, "border ")) {
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"border\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"border\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (num_words(buff + 7) < 4) { if (num_words(buff + 7) < 4) {
print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"border\"\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"border\"\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
RESET_AND_ASSIGN(images[idx].current->iml->border, (Imlib_Border *) MALLOC(sizeof(Imlib_Border))); RESET_AND_ASSIGN(images[idx].current->iml->border, (Imlib_Border *) MALLOC(sizeof(Imlib_Border)));
@ -2203,22 +2162,19 @@ parse_image(char *buff, void *state)
if ((images[idx].current->iml->border->left == 0) && (images[idx].current->iml->border->right == 0) if ((images[idx].current->iml->border->left == 0) && (images[idx].current->iml->border->right == 0)
&& (images[idx].current->iml->border->top == 0) && (images[idx].current->iml->border->bottom == 0)) { && (images[idx].current->iml->border->top == 0) && (images[idx].current->iml->border->bottom == 0)) {
FREE(images[idx].current->iml->border); FREE(images[idx].current->iml->border);
images[idx].current->iml->border = (Imlib_Border *) NULL; /* No sense in wasting CPU time and memory if there are no borders */ images[idx].current->iml->border = (Imlib_Border *) NULL; /* No sense in wasting CPU time and memory if there are no borders */
} }
} else if (!BEG_STRCASECMP(buff, "bevel ")) { } else if (!BEG_STRCASECMP(buff, "bevel ")) {
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image state defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (num_words(buff + 6) < 5) { if (num_words(buff + 6) < 5) {
print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"bevel\"\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"bevel\"\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current->iml->bevel != NULL) { if (images[idx].current->iml->bevel != NULL) {
@ -2247,18 +2203,15 @@ parse_image(char *buff, void *state)
} }
} else if (!BEG_STRCASECMP(buff, "padding ")) { } else if (!BEG_STRCASECMP(buff, "padding ")) {
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image type defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
if (num_words(buff + 8) < 4) { if (num_words(buff + 8) < 4) {
print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"padding\"\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"padding\"\n", file_peek_path(), file_peek_line());
file_peek_line());
return NULL; return NULL;
} }
RESET_AND_ASSIGN(images[idx].current->iml->pad, (Imlib_Border *) MALLOC(sizeof(Imlib_Border))); RESET_AND_ASSIGN(images[idx].current->iml->pad, (Imlib_Border *) MALLOC(sizeof(Imlib_Border)));
@ -2274,8 +2227,7 @@ parse_image(char *buff, void *state)
images[idx].current->iml->pad = (Imlib_Border *) NULL; images[idx].current->iml->pad = (Imlib_Border *) NULL;
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context image\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context image\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
return ((void *) state); return ((void *) state);
} }
@ -2364,8 +2316,7 @@ parse_actions(char *buff, void *state)
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context action\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context action\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
return state; return state;
} }
@ -2389,8 +2340,7 @@ parse_menu(char *buff, void *state)
sprintf(tmp, "Eterm_Menu_%u", menu_list->nummenus); sprintf(tmp, "Eterm_Menu_%u", menu_list->nummenus);
menu_set_title(menu, tmp); menu_set_title(menu, tmp);
print_error("Parse error in file %s, line %lu: Menu context ended without giving a title. Defaulted to \"%s\".\n", print_error("Parse error in file %s, line %lu: Menu context ended without giving a title. Defaulted to \"%s\".\n", file_peek_path(), file_peek_line(), tmp);
file_peek_path(), file_peek_line(), tmp);
} }
menu_list = menulist_add_menu(menu_list, menu); menu_list = menulist_add_menu(menu_list, menu);
return NULL; return NULL;
@ -2419,8 +2369,7 @@ parse_menu(char *buff, void *state)
menuitem_set_action(item, MENUITEM_SEP, (char *) NULL); menuitem_set_action(item, MENUITEM_SEP, (char *) NULL);
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context menu\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context menu\n", file_peek_path(), file_peek_line(), buff);
file_peek_line(), buff);
} }
return ((void *) menu); return ((void *) menu);
} }
@ -2441,8 +2390,7 @@ parse_menuitem(char *buff, void *state)
ASSERT_RVAL(menu != NULL, state); ASSERT_RVAL(menu != NULL, state);
if (*buff == CONF_END_CHAR) { if (*buff == CONF_END_CHAR) {
if (!(curitem->text)) { if (!(curitem->text)) {
print_error("Parse error in file %s, line %lu: Menuitem context ended with no text given. Discarding this entry.\n", print_error("Parse error in file %s, line %lu: Menuitem context ended with no text given. Discarding this entry.\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
FREE(curitem); FREE(curitem);
} else { } else {
menu_add_item(menu, curitem); menu_add_item(menu, curitem);
@ -2491,14 +2439,12 @@ parse_menuitem(char *buff, void *state)
menuitem_set_action(curitem, MENUITEM_SEP, action); menuitem_set_action(curitem, MENUITEM_SEP, action);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid menu item action \"%s\"\n", file_peek_path(), file_peek_line(), print_error("Parse error in file %s, line %lu: Invalid menu item action \"%s\"\n", file_peek_path(), file_peek_line(), NONULL(type));
NONULL(type));
} }
FREE(action); FREE(action);
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context menu\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context menu\n", file_peek_path(), file_peek_line(), buff);
file_peek_line(), buff);
} }
return ((void *) curitem); return ((void *) curitem);
} }
@ -2531,13 +2477,12 @@ parse_bbar(char *buff, void *state)
print_error("Parse error in file %s, line %lu: Attribute dock requires a parameter\n", file_peek_path(), file_peek_line()); print_error("Parse error in file %s, line %lu: Attribute dock requires a parameter\n", file_peek_path(), file_peek_line());
} else if (!BEG_STRCASECMP(where, "top")) { } else if (!BEG_STRCASECMP(where, "top")) {
bbar_set_docked(bbar, BBAR_DOCKED_TOP); bbar_set_docked(bbar, BBAR_DOCKED_TOP);
} else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */ } else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */
bbar_set_docked(bbar, BBAR_DOCKED_BOTTOM); bbar_set_docked(bbar, BBAR_DOCKED_BOTTOM);
} else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */ } else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */
bbar_set_docked(bbar, BBAR_UNDOCKED); bbar_set_docked(bbar, BBAR_UNDOCKED);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute dock\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute dock\n", file_peek_path(), file_peek_line(), where);
file_peek_line(), where);
} }
} else if (!BEG_STRCASECMP(buff, "visible ")) { } else if (!BEG_STRCASECMP(buff, "visible ")) {
@ -2548,8 +2493,7 @@ parse_bbar(char *buff, void *state)
} else if (BOOL_OPT_ISFALSE(tmp)) { } else if (BOOL_OPT_ISFALSE(tmp)) {
bbar_set_visible(bbar, 0); bbar_set_visible(bbar, 0);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" in context button_bar\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid boolean value \"%s\" in context button_bar\n", file_peek_path(), file_peek_line(), tmp);
file_peek_line(), tmp);
} }
} else if (!BEG_STRCASECMP(buff, "button ") || !BEG_STRCASECMP(buff, "rbutton ")) { } else if (!BEG_STRCASECMP(buff, "button ") || !BEG_STRCASECMP(buff, "rbutton ")) {
@ -2611,8 +2555,7 @@ parse_bbar(char *buff, void *state)
bbar_add_button(bbar, button); bbar_add_button(bbar, button);
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context menu\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context menu\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
return ((void *) bbar); return ((void *) bbar);
} }
@ -2629,8 +2572,7 @@ parse_xim(char *buff, void *state)
} else if (!BEG_STRCASECMP(buff, "preedit_type ")) { } else if (!BEG_STRCASECMP(buff, "preedit_type ")) {
RESET_AND_ASSIGN(rs_preedit_type, get_word(2, buff)); RESET_AND_ASSIGN(rs_preedit_type, get_word(2, buff));
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context xim\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context xim\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
#else #else
print_warning("XIM support was not compiled in, ignoring entire context\n"); print_warning("XIM support was not compiled in, ignoring entire context\n");
@ -2657,14 +2599,12 @@ parse_multichar(char *buff, void *state)
&& BEG_STRCASECMP(rs_multichar_encoding, "gb") && BEG_STRCASECMP(rs_multichar_encoding, "gb")
&& BEG_STRCASECMP(rs_multichar_encoding, "iso-10646") && BEG_STRCASECMP(rs_multichar_encoding, "iso-10646")
&& BEG_STRCASECMP(rs_multichar_encoding, "none")) { && BEG_STRCASECMP(rs_multichar_encoding, "none")) {
print_error("Parse error in file %s, line %lu: Invalid multichar encoding mode \"%s\"\n", print_error("Parse error in file %s, line %lu: Invalid multichar encoding mode \"%s\"\n", file_peek_path(), file_peek_line(), rs_multichar_encoding);
file_peek_path(), file_peek_line(), rs_multichar_encoding);
FREE(rs_multichar_encoding); FREE(rs_multichar_encoding);
return NULL; return NULL;
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid parameter list \"\" for attribute encoding\n", print_error("Parse error in file %s, line %lu: Invalid parameter list \"\" for attribute encoding\n", file_peek_path(), file_peek_line());
file_peek_path(), file_peek_line());
} }
} else if (!BEG_STRCASECMP(buff, "font ")) { } else if (!BEG_STRCASECMP(buff, "font ")) {
@ -2672,8 +2612,7 @@ parse_multichar(char *buff, void *state)
unsigned char n; unsigned char n;
if (num_words(buff) != 3) { if (num_words(buff) != 3) {
print_error("Parse error in file %s, line %lu: Invalid parameter list \"%s\" for attribute font\n", print_error("Parse error in file %s, line %lu: Invalid parameter list \"%s\" for attribute font\n", file_peek_path(), file_peek_line(), NONULL(tmp));
file_peek_path(), file_peek_line(), NONULL(tmp));
return NULL; return NULL;
} }
if (isdigit(*tmp)) { if (isdigit(*tmp)) {
@ -2690,8 +2629,7 @@ parse_multichar(char *buff, void *state)
} }
} else { } else {
print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context multichar\n", print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context multichar\n", file_peek_path(), file_peek_line(), buff);
file_peek_path(), file_peek_line(), buff);
} }
#else #else
if (*buff == CONF_BEGIN_CHAR) { if (*buff == CONF_BEGIN_CHAR) {
@ -2950,7 +2888,7 @@ post_parse(void)
if (rs_pixmaps[i]) { if (rs_pixmaps[i]) {
reset_simage(images[i].norm, RESET_ALL_SIMG); reset_simage(images[i].norm, RESET_ALL_SIMG);
load_image(rs_pixmaps[i], images[i].norm); load_image(rs_pixmaps[i], images[i].norm);
FREE(rs_pixmaps[i]); /* These are created by STRDUP() */ FREE(rs_pixmaps[i]); /* These are created by STRDUP() */
} }
#else #else
/* Right now, solid mode is the only thing we can do without pixmap support. */ /* Right now, solid mode is the only thing we can do without pixmap support. */
@ -3123,8 +3061,7 @@ post_parse(void)
if (n > 2) { if (n > 2) {
iml->mod->gamma = (int) strtol(get_pword(3, rs_cmod_image), (char **) NULL, 0); iml->mod->gamma = (int) strtol(get_pword(3, rs_cmod_image), (char **) NULL, 0);
} }
D_PIXMAP(("From image cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_image, D_PIXMAP(("From image cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_image, iml->mod->brightness, iml->mod->contrast, iml->mod->gamma));
iml->mod->brightness, iml->mod->contrast, iml->mod->gamma));
FREE(rs_cmod_image); FREE(rs_cmod_image);
} }
if (rs_cmod_red) { if (rs_cmod_red) {
@ -3142,8 +3079,7 @@ post_parse(void)
if (n > 2) { if (n > 2) {
iml->rmod->gamma = (int) strtol(get_pword(3, rs_cmod_red), (char **) NULL, 0); iml->rmod->gamma = (int) strtol(get_pword(3, rs_cmod_red), (char **) NULL, 0);
} }
D_PIXMAP(("From red cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_red, D_PIXMAP(("From red cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_red, iml->rmod->brightness, iml->rmod->contrast, iml->rmod->gamma));
iml->rmod->brightness, iml->rmod->contrast, iml->rmod->gamma));
FREE(rs_cmod_red); FREE(rs_cmod_red);
update_cmod(iml->rmod); update_cmod(iml->rmod);
} }
@ -3162,8 +3098,7 @@ post_parse(void)
if (n > 2) { if (n > 2) {
iml->gmod->gamma = (int) strtol(get_pword(3, rs_cmod_green), (char **) NULL, 0); iml->gmod->gamma = (int) strtol(get_pword(3, rs_cmod_green), (char **) NULL, 0);
} }
D_PIXMAP(("From green cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_green, D_PIXMAP(("From green cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_green, iml->gmod->brightness, iml->gmod->contrast, iml->gmod->gamma));
iml->gmod->brightness, iml->gmod->contrast, iml->gmod->gamma));
FREE(rs_cmod_green); FREE(rs_cmod_green);
update_cmod(iml->gmod); update_cmod(iml->gmod);
} }
@ -3182,8 +3117,7 @@ post_parse(void)
if (n > 2) { if (n > 2) {
iml->bmod->gamma = (int) strtol(get_pword(3, rs_cmod_blue), (char **) NULL, 0); iml->bmod->gamma = (int) strtol(get_pword(3, rs_cmod_blue), (char **) NULL, 0);
} }
D_PIXMAP(("From blue cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_blue, D_PIXMAP(("From blue cmod string %s to brightness %d, contrast %d, and gamma %d\n", rs_cmod_blue, iml->bmod->brightness, iml->bmod->contrast, iml->bmod->gamma));
iml->bmod->brightness, iml->bmod->contrast, iml->bmod->gamma));
FREE(rs_cmod_blue); FREE(rs_cmod_blue);
update_cmod(iml->bmod); update_cmod(iml->bmod);
} }
@ -3234,11 +3168,11 @@ post_parse(void)
unsigned long w, h; unsigned long w, h;
int count; int count;
count = num_words(rs_anim_pixmap_list) - 1; /* -1 for the delay */ count = num_words(rs_anim_pixmap_list) - 1; /* -1 for the delay */
rs_anim_pixmaps = (char **) MALLOC(sizeof(char *) * (count + 1)); rs_anim_pixmaps = (char **) MALLOC(sizeof(char *) * (count + 1));
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
temp = get_word(i + 2, rs_anim_pixmap_list); /* +2 rather than +1 to account for the delay */ temp = get_word(i + 2, rs_anim_pixmap_list); /* +2 rather than +1 to account for the delay */
if (temp == NULL) if (temp == NULL)
break; break;
if (num_words(temp) != 3) { if (num_words(temp) != 3) {
@ -3326,8 +3260,7 @@ save_config(char *path, unsigned char save_theme)
*(--tmp) = '/'; *(--tmp) = '/';
} }
if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) { if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) {
print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (theme_dir ? theme_dir : PKGDATADIR "/themes/Eterm\n"), print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (theme_dir ? theme_dir : PKGDATADIR "/themes/Eterm\n"), path);
path);
return errno; return errno;
} }
} }
@ -3356,8 +3289,7 @@ save_config(char *path, unsigned char save_theme)
*(--tmp) = '/'; *(--tmp) = '/';
} }
if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) { if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) {
print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (user_dir ? user_dir : PKGDATADIR "/themes/Eterm\n"), print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (user_dir ? user_dir : PKGDATADIR "/themes/Eterm\n"), path);
path);
return errno; return errno;
} }
} }
@ -3418,8 +3350,7 @@ save_config(char *path, unsigned char save_theme)
fprintf(fp, " desktop %d\n", rs_desktop); fprintf(fp, " desktop %d\n", rs_desktop);
} }
} }
fprintf(fp, " scrollbar_type %s\n", fprintf(fp, " scrollbar_type %s\n", (scrollbar_get_type() == SCROLLBAR_XTERM ? "xterm" : (scrollbar_get_type() == SCROLLBAR_MOTIF ? "motif" : "next")));
(scrollbar_get_type() == SCROLLBAR_XTERM ? "xterm" : (scrollbar_get_type() == SCROLLBAR_MOTIF ? "motif" : "next")));
fprintf(fp, " scrollbar_width %d\n", scrollbar_anchor_width()); fprintf(fp, " scrollbar_width %d\n", scrollbar_anchor_width());
fprintf(fp, " font default %u\n", (unsigned int) font_idx); fprintf(fp, " font default %u\n", (unsigned int) font_idx);
fprintf(fp, " font proportional %d\n", ((Options & Opt_proportional) ? 1 : 0)); fprintf(fp, " font proportional %d\n", ((Options & Opt_proportional) ? 1 : 0));
@ -3561,33 +3492,27 @@ save_config(char *path, unsigned char save_theme)
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
if (simg->iml->mod) { if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
simg->iml->mod->gamma);
} }
if (simg->iml->rmod) { if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
simg->iml->rmod->gamma);
} }
if (simg->iml->gmod) { if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
simg->iml->gmod->gamma);
} }
if (simg->iml->bmod) { if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
simg->iml->bmod->gamma);
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left,
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
simg->iml->pad->bottom);
} }
/* Selected state */ /* Selected state */
@ -3622,33 +3547,27 @@ save_config(char *path, unsigned char save_theme)
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
if (simg->iml->mod) { if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
simg->iml->mod->gamma);
} }
if (simg->iml->rmod) { if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
simg->iml->rmod->gamma);
} }
if (simg->iml->gmod) { if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
simg->iml->gmod->gamma);
} }
if (simg->iml->bmod) { if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
simg->iml->bmod->gamma);
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left,
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
simg->iml->pad->bottom);
} }
} }
@ -3684,33 +3603,27 @@ save_config(char *path, unsigned char save_theme)
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
if (simg->iml->mod) { if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
simg->iml->mod->gamma);
} }
if (simg->iml->rmod) { if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
simg->iml->rmod->gamma);
} }
if (simg->iml->gmod) { if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
simg->iml->gmod->gamma);
} }
if (simg->iml->bmod) { if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
simg->iml->bmod->gamma);
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left,
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
simg->iml->pad->bottom);
} }
} }
@ -3746,33 +3659,27 @@ save_config(char *path, unsigned char save_theme)
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
if (simg->iml->mod) { if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
simg->iml->mod->gamma);
} }
if (simg->iml->rmod) { if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
simg->iml->rmod->gamma);
} }
if (simg->iml->gmod) { if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
simg->iml->gmod->gamma);
} }
if (simg->iml->bmod) { if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
simg->iml->bmod->gamma);
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left,
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
simg->iml->pad->bottom);
} }
} }
fprintf(fp, " end image\n"); fprintf(fp, " end image\n");
@ -4008,8 +3915,7 @@ save_config(char *path, unsigned char save_theme)
} }
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
if (KeySym_map[i]) { if (KeySym_map[i]) {
fprintf(fp, " keysym 0xff%02x \'%s\'\n", i, fprintf(fp, " keysym 0xff%02x \'%s\'\n", i, safe_print_string((char *) (KeySym_map[i] + 1), (unsigned long) KeySym_map[i][0]));
safe_print_string((char *) (KeySym_map[i] + 1), (unsigned long) KeySym_map[i][0]));
} }
} }
#ifdef GREEK_SUPPORT #ifdef GREEK_SUPPORT

View File

@ -62,6 +62,7 @@ static Imlib_Border bord_none = { 0, 0, 0, 0 };
#endif #endif
Pixmap buffer_pixmap = None; Pixmap buffer_pixmap = None;
#ifdef PIXMAP_OFFSET #ifdef PIXMAP_OFFSET
Pixmap desktop_pixmap = None, viewport_pixmap = None; Pixmap desktop_pixmap = None, viewport_pixmap = None;
Window desktop_window = None; Window desktop_window = None;
@ -333,8 +334,7 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap)
pmap->op = op; pmap->op = op;
changed++; changed++;
} }
D_PIXMAP(("Returning %hu, *pmap == { op [%hu], w [%hd], h [%hd], x [%hd], y [%hd] }\n", changed, pmap->op, pmap->w, pmap->h, pmap->x, D_PIXMAP(("Returning %hu, *pmap == { op [%hu], w [%hd], h [%hd], x [%hd], y [%hd] }\n", changed, pmap->op, pmap->w, pmap->h, pmap->x, pmap->y));
pmap->y));
return changed; return changed;
} }
@ -628,8 +628,7 @@ check_image_ipc(unsigned char reset)
} }
); );
/* *INDENT-ON* */ /* *INDENT-ON* */
print_error("Looks like this version of Enlightenment doesn't support the IPC " print_error("Looks like this version of Enlightenment doesn't support the IPC " "commands I need. Disallowing \"auto\" mode for all images.\n");
"commands I need. Disallowing \"auto\" mode for all images.\n");
FREE(reply); FREE(reply);
checked = 2; checked = 2;
return 0; return 0;
@ -678,8 +677,7 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
XSetFillStyle(Xdisplay, gc, FillTiled); XSetFillStyle(Xdisplay, gc, FillTiled);
XFillRectangle(Xdisplay, p, gc, 0, 0, width, height); XFillRectangle(Xdisplay, p, gc, 0, 0, width, height);
} else { } else {
D_PIXMAP(("Copying %hux%hu rectangle at %d, %d from %ux%u desktop pixmap 0x%08x onto p.\n", width, height, x, y, pw, D_PIXMAP(("Copying %hux%hu rectangle at %d, %d from %ux%u desktop pixmap 0x%08x onto p.\n", width, height, x, y, pw, ph, desktop_pixmap));
ph, desktop_pixmap));
XCopyArea(Xdisplay, desktop_pixmap, p, gc, x, y, width, height, 0, 0); XCopyArea(Xdisplay, desktop_pixmap, p, gc, x, y, width, height, 0, 0);
} }
if ((which != image_bg || (image_toggles & IMOPT_ITRANS) || images[image_bg].current != images[image_bg].norm) if ((which != image_bg || (image_toggles & IMOPT_ITRANS) || images[image_bg].current != images[image_bg].norm)
@ -706,6 +704,7 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
Pixmap p = None, mask = None; Pixmap p = None, mask = None;
GC gc; GC gc;
Screen *scr; Screen *scr;
D_PIXMAP(("create_viewport_pixmap(%8p, 0x%08x, %d, %d, %hu, %hu) called.\n", simg, d, x, y, width, height)); D_PIXMAP(("create_viewport_pixmap(%8p, 0x%08x, %d, %d, %hu, %hu) called.\n", simg, d, x, y, width, height));
scr = ScreenOfDisplay(Xdisplay, Xscreen); scr = ScreenOfDisplay(Xdisplay, Xscreen);
if (!scr) if (!scr)
@ -719,6 +718,7 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
} }
if (viewport_pixmap == None) { if (viewport_pixmap == None) {
imlib_t *tmp_iml = images[image_bg].current->iml; imlib_t *tmp_iml = images[image_bg].current->iml;
imlib_context_set_image(tmp_iml->im); imlib_context_set_image(tmp_iml->im);
imlib_context_set_drawable(d); imlib_context_set_drawable(d);
imlib_image_set_has_alpha(0); imlib_image_set_has_alpha(0);
@ -782,19 +782,19 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
} }
void void
paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsigned short x, unsigned short y, paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsigned short x, unsigned short y, unsigned short w, unsigned short h)
unsigned short w, unsigned short h)
{ {
Pixmap pmap = None, mask = None; Pixmap pmap = None, mask = None;
GC gc; GC gc;
ASSERT(simg != NULL); ASSERT(simg != NULL);
REQUIRE(d != None); REQUIRE(d != None);
D_PIXMAP(("paste_simage(%8p, %s, 0x%08x, 0x%08x, %hd, %hd, %hd, %hd) called.\n", simg, get_image_type(which), D_PIXMAP(("paste_simage(%8p, %s, 0x%08x, 0x%08x, %hd, %hd, %hd, %hd) called.\n", simg, get_image_type(which), (int) win, (int) d, x, y, w, h));
(int) win, (int) d, x, y, w, h));
if (which != image_max) { if (which != image_max) {
if (image_mode_is(which, MODE_AUTO) && image_mode_is(which, ALLOW_AUTO)) { if (image_mode_is(which, MODE_AUTO) && image_mode_is(which, ALLOW_AUTO)) {
char buff[255], *reply; char buff[255], *reply;
const char *iclass, *state; const char *iclass, *state;
check_image_ipc(0); check_image_ipc(0);
if (image_mode_is(which, MODE_AUTO)) { if (image_mode_is(which, MODE_AUTO)) {
iclass = get_iclass_name(which); iclass = get_iclass_name(which);
@ -810,8 +810,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) d, state, w, h); snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) d, state, w, h);
reply = enl_send_and_wait(buff); reply = enl_send_and_wait(buff);
if (strstr(reply, "Error")) { if (strstr(reply, "Error")) {
print_error print_error("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
image_mode_fallback(which); image_mode_fallback(which);
FREE(reply); FREE(reply);
} else { } else {
@ -829,8 +828,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
LIBAST_X_FREE_GC(gc); LIBAST_X_FREE_GC(gc);
return; return;
} else { } else {
print_error print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
FREE(reply); FREE(reply);
image_mode_fallback(which); image_mode_fallback(which);
} }
@ -839,6 +837,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
} }
} else if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) { } else if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) {
Pixmap p; Pixmap p;
gc = LIBAST_X_CREATE_GC(0, NULL); gc = LIBAST_X_CREATE_GC(0, NULL);
p = create_trans_pixmap(simg, which, win, x, y, w, h); p = create_trans_pixmap(simg, which, win, x, y, w, h);
if (p != None) { if (p != None) {
@ -850,6 +849,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
LIBAST_X_FREE_GC(gc); LIBAST_X_FREE_GC(gc);
} else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) { } else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) {
Pixmap p; Pixmap p;
gc = LIBAST_X_CREATE_GC(0, NULL); gc = LIBAST_X_CREATE_GC(0, NULL);
p = create_viewport_pixmap(simg, win, x, y, w, h); p = create_viewport_pixmap(simg, win, x, y, w, h);
if (simg->iml->bevel != NULL) { if (simg->iml->bevel != NULL) {
@ -950,6 +950,7 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width,
{ {
GC gc; GC gc;
XGCValues gcvalue; XGCValues gcvalue;
ASSERT(buffer_pixmap == None); ASSERT(buffer_pixmap == None);
buffer_pixmap = LIBAST_X_CREATE_PIXMAP(width, height); buffer_pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
gcvalue.foreground = (Pixel) fill; gcvalue.foreground = (Pixel) fill;
@ -957,6 +958,7 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width,
XSetGraphicsExposures(Xdisplay, gc, False); XSetGraphicsExposures(Xdisplay, gc, False);
if (mode == MODE_SOLID) { if (mode == MODE_SOLID) {
simage_t *simg; simage_t *simg;
simg = images[image_bg].current; simg = images[image_bg].current;
if (simg->pmap->pixmap) { if (simg->pmap->pixmap) {
LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap); LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
@ -977,6 +979,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
GC gc; GC gc;
Pixmap pixmap = None; Pixmap pixmap = None;
Screen *scr; Screen *scr;
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
short xsize, ysize; short xsize, ysize;
short xpos = 0, ypos = 0; short xpos = 0, ypos = 0;
@ -990,8 +993,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
ASSERT(simg->iml != NULL); ASSERT(simg->iml != NULL);
ASSERT(simg->pmap != NULL); ASSERT(simg->pmap != NULL);
REQUIRE(win != None); REQUIRE(win != None);
D_PIXMAP(("Rendering simg->iml->im %8p (%s) at %hux%hu onto window 0x%08x\n", simg->iml->im, get_image_type(which), D_PIXMAP(("Rendering simg->iml->im %8p (%s) at %hux%hu onto window 0x%08x\n", simg->iml->im, get_image_type(which), width, height, win));
width, height, win));
D_PIXMAP(("Image mode is 0x%02x\n", images[which].mode)); D_PIXMAP(("Image mode is 0x%02x\n", images[which].mode));
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
if ((which == image_bg) && image_mode_is(image_bg, MODE_VIEWPORT)) { if ((which == image_bg) && image_mode_is(image_bg, MODE_VIEWPORT)) {
@ -1003,7 +1005,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
return; return;
gcvalue.foreground = gcvalue.background = PixColors[bgColor]; gcvalue.foreground = gcvalue.background = PixColors[bgColor];
gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue); gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
pixmap = simg->pmap->pixmap; /* Save this for later */ pixmap = simg->pmap->pixmap; /* Save this for later */
if ((which == image_bg) && (buffer_pixmap != None)) { if ((which == image_bg) && (buffer_pixmap != None)) {
LIBAST_X_FREE_PIXMAP(buffer_pixmap); LIBAST_X_FREE_PIXMAP(buffer_pixmap);
buffer_pixmap = None; buffer_pixmap = None;
@ -1012,6 +1014,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
if ((images[which].mode & MODE_AUTO) && (images[which].mode & ALLOW_AUTO)) { if ((images[which].mode & MODE_AUTO) && (images[which].mode & ALLOW_AUTO)) {
char buff[255]; char buff[255];
const char *iclass, *state; const char *iclass, *state;
check_image_ipc(0); check_image_ipc(0);
if (image_mode_is(which, MODE_AUTO)) { if (image_mode_is(which, MODE_AUTO)) {
iclass = get_iclass_name(which); iclass = get_iclass_name(which);
@ -1025,15 +1028,16 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
if (iclass) { if (iclass) {
if (renderop & RENDER_FORCE_PIXMAP) { if (renderop & RENDER_FORCE_PIXMAP) {
char *reply; char *reply;
snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) win, state, width, height); snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) win, state, width, height);
reply = enl_send_and_wait(buff); reply = enl_send_and_wait(buff);
if (strstr(reply, "Error")) { if (strstr(reply, "Error")) {
print_error print_error("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
image_mode_fallback(which); image_mode_fallback(which);
FREE(reply); FREE(reply);
} else { } else {
Pixmap pmap, mask; Pixmap pmap, mask;
pmap = (Pixmap) strtoul(reply, (char **) NULL, 0); pmap = (Pixmap) strtoul(reply, (char **) NULL, 0);
mask = (Pixmap) strtoul(get_pword(2, reply), (char **) NULL, 0); mask = (Pixmap) strtoul(get_pword(2, reply), (char **) NULL, 0);
FREE(reply); FREE(reply);
@ -1057,8 +1061,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap); snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
enl_ipc_send(buff); enl_ipc_send(buff);
} else { } else {
print_error print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
FREE(reply); FREE(reply);
image_mode_fallback(which); image_mode_fallback(which);
} }
@ -1094,8 +1097,8 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} }
} else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) { } else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) {
Pixmap p; Pixmap p;
D_PIXMAP(("Viewport mode enabled. viewport_pixmap == 0x%08x and simg->pmap->pixmap == 0x%08x\n", viewport_pixmap,
simg->pmap->pixmap)); D_PIXMAP(("Viewport mode enabled. viewport_pixmap == 0x%08x and simg->pmap->pixmap == 0x%08x\n", viewport_pixmap, simg->pmap->pixmap));
p = create_viewport_pixmap(simg, win, 0, 0, width, height); p = create_viewport_pixmap(simg, win, 0, 0, width, height);
if (p && (p != simg->pmap->pixmap)) { if (p && (p != simg->pmap->pixmap)) {
if (simg->pmap->pixmap != None) { if (simg->pmap->pixmap != None) {
@ -1126,6 +1129,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
int h = simg->pmap->h; int h = simg->pmap->h;
int x = simg->pmap->x; int x = simg->pmap->x;
int y = simg->pmap->y; int y = simg->pmap->y;
imlib_context_set_image(simg->iml->im); imlib_context_set_image(simg->iml->im);
imlib_context_set_drawable(win); imlib_context_set_drawable(win);
imlib_context_set_anti_alias(1); imlib_context_set_anti_alias(1);
@ -1136,6 +1140,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
D_PIXMAP(("w == %d, h == %d, x == %d, y == %d, xsize == %d, ysize == %d\n", w, h, x, y, xsize, ysize)); D_PIXMAP(("w == %d, h == %d, x == %d, y == %d, xsize == %d, ysize == %d\n", w, h, x, y, xsize, ysize));
if ((simg->pmap->op & OP_PROPSCALE) && w && h) { if ((simg->pmap->op & OP_PROPSCALE) && w && h) {
double x_ratio, y_ratio; double x_ratio, y_ratio;
x_ratio = ((double) width) / ((double) xsize); x_ratio = ((double) width) / ((double) xsize);
y_ratio = ((double) height) / ((double) ysize); y_ratio = ((double) height) / ((double) ysize);
if (x_ratio > 1) { if (x_ratio > 1) {
@ -1185,6 +1190,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} }
if (xscaled != width || yscaled != height || xpos != 0 || ypos != 0) { if (xscaled != width || yscaled != height || xpos != 0 || ypos != 0) {
unsigned char single; unsigned char single;
/* This tells us if we have a single, non-tiled image which does not entirely fill the window */ /* This tells us if we have a single, non-tiled image which does not entirely fill the window */
single = ((xscaled < width || yscaled < height) && !(simg->pmap->op & OP_TILE)) ? 1 : 0; single = ((xscaled < width || yscaled < height) && !(simg->pmap->op & OP_TILE)) ? 1 : 0;
pixmap = simg->pmap->pixmap; pixmap = simg->pmap->pixmap;
@ -1275,6 +1281,7 @@ search_path(const char *pathlist, const char *file)
const char *path; const char *path;
int maxpath, len; int maxpath, len;
struct stat fst; struct stat fst;
if (!pathlist || !file) { /* If either one is NULL, there really isn't much point in going on.... */ if (!pathlist || !file) { /* If either one is NULL, there really isn't much point in going on.... */
return ((const char *) NULL); return ((const char *) NULL);
} }
@ -1328,6 +1335,7 @@ search_path(const char *pathlist, const char *file)
} }
for (path = pathlist; path != NULL && *path != '\0'; path = p) { for (path = pathlist; path != NULL && *path != '\0'; path = p) {
int n; int n;
/* colon delimited */ /* colon delimited */
if ((p = strchr(path, ':')) == NULL) if ((p = strchr(path, ':')) == NULL)
p = strchr(path, '\0'); p = strchr(path, '\0');
@ -1339,6 +1347,7 @@ search_path(const char *pathlist, const char *file)
if (*path == '~') { if (*path == '~') {
unsigned int l; unsigned int l;
char *home_dir = getenv("HOME"); char *home_dir = getenv("HOME");
if (home_dir && *home_dir) { if (home_dir && *home_dir) {
l = strlen(home_dir); l = strlen(home_dir);
if (l + n < (unsigned) maxpath) { if (l + n < (unsigned) maxpath) {
@ -1382,6 +1391,7 @@ load_image(const char *file, simage_t *simg)
Imlib_Image *im; Imlib_Image *im;
Imlib_Load_Error im_err; Imlib_Load_Error im_err;
char *geom; char *geom;
ASSERT_RVAL(file != NULL, 0); ASSERT_RVAL(file != NULL, 0);
ASSERT_RVAL(simg != NULL, 0); ASSERT_RVAL(simg != NULL, 0);
D_PIXMAP(("load_image(%s, %8p)\n", file, simg)); D_PIXMAP(("load_image(%s, %8p)\n", file, simg));
@ -1447,6 +1457,7 @@ update_cmod_tables(imlib_t *iml)
{ {
colormod_t *mod = iml->mod, *rmod = iml->rmod, *gmod = iml->gmod, *bmod = iml->bmod; colormod_t *mod = iml->mod, *rmod = iml->rmod, *gmod = iml->gmod, *bmod = iml->bmod;
DATA8 rt[256], gt[256], bt[256]; DATA8 rt[256], gt[256], bt[256];
REQUIRE(mod || rmod || gmod || bmod); REQUIRE(mod || rmod || gmod || bmod);
/* When any changes is made to any individual color modifier for an image, /* When any changes is made to any individual color modifier for an image,
this function must be called to update the overall Imlib2 color modifier. */ this function must be called to update the overall Imlib2 color modifier. */
@ -1510,12 +1521,14 @@ shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
{ {
unsigned char *ptr; unsigned char *ptr;
int x, y; int x, y;
ptr = (unsigned char *) data + (w * sizeof(DATA16)); ptr = (unsigned char *) data + (w * sizeof(DATA16));
if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
/* No saturation */ /* No saturation */
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -w; x < 0; x++) { for (x = -w; x < 0; x++) {
int r, g, b; int r, g, b;
b = ((DATA16 *) ptr)[x]; b = ((DATA16 *) ptr)[x];
r = (b & 0x7c00) * rm; r = (b & 0x7c00) * rm;
g = (b & 0x3e0) * gm; g = (b & 0x3e0) * gm;
@ -1530,6 +1543,7 @@ shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -w; x < 0; x++) { for (x = -w; x < 0; x++) {
int r, g, b; int r, g, b;
b = ((DATA16 *) ptr)[x]; b = ((DATA16 *) ptr)[x];
r = (b & 0x7c00) * rm; r = (b & 0x7c00) * rm;
g = (b & 0x3e0) * gm; g = (b & 0x3e0) * gm;
@ -1552,12 +1566,14 @@ shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm)
{ {
unsigned char *ptr; unsigned char *ptr;
int x, y; int x, y;
ptr = (unsigned char *) data + (w * sizeof(DATA16)); ptr = (unsigned char *) data + (w * sizeof(DATA16));
if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
/* No saturation */ /* No saturation */
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -w; x < 0; x++) { for (x = -w; x < 0; x++) {
int r, g, b; int r, g, b;
b = ((DATA16 *) ptr)[x]; b = ((DATA16 *) ptr)[x];
r = (b & 0xf800) * rm; r = (b & 0xf800) * rm;
g = (b & 0x7e0) * gm; g = (b & 0x7e0) * gm;
@ -1572,6 +1588,7 @@ shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm)
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -w; x < 0; x++) { for (x = -w; x < 0; x++) {
int r, g, b; int r, g, b;
b = ((DATA16 *) ptr)[x]; b = ((DATA16 *) ptr)[x];
r = (b & 0xf800) * rm; r = (b & 0xf800) * rm;
g = (b & 0x7e0) * gm; g = (b & 0x7e0) * gm;
@ -1594,12 +1611,14 @@ shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
{ {
unsigned char *ptr; unsigned char *ptr;
int x, y; int x, y;
ptr = (unsigned char *) data + (w * 4); ptr = (unsigned char *) data + (w * 4);
if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
/* No saturation */ /* No saturation */
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -(w * 4); x < 0; x += 4) { for (x = -(w * 4); x < 0; x += 4) {
int r, g, b; int r, g, b;
# ifdef WORDS_BIGENDIAN # ifdef WORDS_BIGENDIAN
r = (ptr[x + 1] * rm) >> 8; r = (ptr[x + 1] * rm) >> 8;
g = (ptr[x + 2] * gm) >> 8; g = (ptr[x + 2] * gm) >> 8;
@ -1622,6 +1641,7 @@ shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -(w * 4); x < 0; x += 4) { for (x = -(w * 4); x < 0; x += 4) {
int r, g, b; int r, g, b;
# ifdef WORDS_BIGENDIAN # ifdef WORDS_BIGENDIAN
r = (ptr[x + 1] * rm) >> 8; r = (ptr[x + 1] * rm) >> 8;
g = (ptr[x + 2] * gm) >> 8; g = (ptr[x + 2] * gm) >> 8;
@ -1656,12 +1676,14 @@ shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm)
{ {
unsigned char *ptr; unsigned char *ptr;
int x, y; int x, y;
ptr = (unsigned char *) data + (w * 3); ptr = (unsigned char *) data + (w * 3);
if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
/* No saturation */ /* No saturation */
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -(w * 3); x < 0; x += 3) { for (x = -(w * 3); x < 0; x += 3) {
int r, g, b; int r, g, b;
# ifdef WORDS_BIGENDIAN # ifdef WORDS_BIGENDIAN
r = (ptr[x + 0] * rm) >> 8; r = (ptr[x + 0] * rm) >> 8;
g = (ptr[x + 1] * gm) >> 8; g = (ptr[x + 1] * gm) >> 8;
@ -1684,6 +1706,7 @@ shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm)
for (y = h; --y >= 0;) { for (y = h; --y >= 0;) {
for (x = -(w * 3); x < 0; x += 3) { for (x = -(w * 3); x < 0; x += 3) {
int r, g, b; int r, g, b;
# ifdef WORDS_BIGENDIAN # ifdef WORDS_BIGENDIAN
r = (ptr[x + 0] * rm) >> 8; r = (ptr[x + 0] * rm) >> 8;
g = (ptr[x + 1] * gm) >> 8; g = (ptr[x + 1] * gm) >> 8;
@ -1718,6 +1741,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
XImage *ximg; XImage *ximg;
register unsigned long i; register unsigned long i;
#if 0 #if 0
register unsigned long v; register unsigned long v;
unsigned long x, y; unsigned long x, y;
@ -1728,6 +1752,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
unsigned short rm, gm, bm, shade; unsigned short rm, gm, bm, shade;
Imlib_Color ctab[256]; Imlib_Color ctab[256];
int real_depth = 0; int real_depth = 0;
D_PIXMAP(("colormod_trans(p == 0x%08x, gc, w == %hu, h == %hu) called.\n", p, w, h)); D_PIXMAP(("colormod_trans(p == 0x%08x, gc, w == %hu, h == %hu) called.\n", p, w, h));
REQUIRE(p != None); REQUIRE(p != None);
if (iml->mod) { if (iml->mod) {
@ -1758,6 +1783,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
if (Xdepth <= 8) { if (Xdepth <= 8) {
XColor cols[256]; XColor cols[256];
for (i = 0; i < (unsigned long) (1 << Xdepth); i++) { for (i = 0; i < (unsigned long) (1 << Xdepth); i++) {
cols[i].pixel = i; cols[i].pixel = i;
cols[i].flags = DoRed | DoGreen | DoBlue; cols[i].flags = DoRed | DoGreen | DoBlue;
@ -1771,6 +1797,7 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
} else if (Xdepth == 16) { } else if (Xdepth == 16) {
XWindowAttributes xattr; XWindowAttributes xattr;
XGetWindowAttributes(Xdisplay, desktop_window, &xattr); XGetWindowAttributes(Xdisplay, desktop_window, &xattr);
if ((xattr.visual->green_mask == 0x3e0)) { if ((xattr.visual->green_mask == 0x3e0)) {
real_depth = 15; real_depth = 15;
@ -1804,9 +1831,11 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
/* Swap rm and bm for bgr */ /* Swap rm and bm for bgr */
{ {
XWindowAttributes xattr; XWindowAttributes xattr;
XGetWindowAttributes(Xdisplay, desktop_window, &xattr); XGetWindowAttributes(Xdisplay, desktop_window, &xattr);
if (xattr.visual->blue_mask > xattr.visual->red_mask) { if (xattr.visual->blue_mask > xattr.visual->red_mask) {
unsigned short tmp; unsigned short tmp;
tmp = rm; tmp = rm;
rm = bm; rm = bm;
bm = tmp; bm = tmp;
@ -1855,6 +1884,7 @@ update_desktop_info(int *w, int *h)
unsigned int pw, ph, pb, pd; unsigned int pw, ph, pb, pd;
int px, py; int px, py;
Window dummy; Window dummy;
if (w) { if (w) {
*w = 0; *w = 0;
} }
@ -1883,8 +1913,7 @@ update_desktop_info(int *w, int *h)
XGetGeometry(Xdisplay, desktop_pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd); XGetGeometry(Xdisplay, desktop_pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd);
} }
if ((pw <= 0) || (ph <= 0)) { if ((pw <= 0) || (ph <= 0)) {
print_error("Value of desktop pixmap property is invalid. Please restart your \n" print_error("Value of desktop pixmap property is invalid. Please restart your \n" "window manager or use Esetroot to set a new one.");
"window manager or use Esetroot to set a new one.");
desktop_pixmap = None; desktop_pixmap = None;
return 0; return 0;
} }
@ -1907,6 +1936,7 @@ get_desktop_window(void)
unsigned char *data; unsigned char *data;
unsigned int nchildren; unsigned int nchildren;
Window w, root, *children, parent; Window w, root, *children, parent;
D_PIXMAP(("Current desktop window is 0x%08x\n", (unsigned int) desktop_window)); D_PIXMAP(("Current desktop window is 0x%08x\n", (unsigned int) desktop_window));
if ((desktop_window != None) && (desktop_window != Xroot)) { if ((desktop_window != None) && (desktop_window != Xroot)) {
XSelectInput(Xdisplay, desktop_window, None); XSelectInput(Xdisplay, desktop_window, None);
@ -1925,11 +1955,8 @@ get_desktop_window(void)
} }
if ((XGetWindowProperty if ((XGetWindowProperty(Xdisplay, w, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data)) != Success) {
(Xdisplay, w, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data)) != Success) { if ((XGetWindowProperty(Xdisplay, w, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data)) != Success) {
if ((XGetWindowProperty
(Xdisplay, w, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after,
&data)) != Success) {
continue; continue;
} }
} }
@ -1962,9 +1989,10 @@ get_desktop_pixmap(void)
static Pixmap color_pixmap = None, orig_desktop_pixmap; static Pixmap color_pixmap = None, orig_desktop_pixmap;
unsigned long length, after; unsigned long length, after;
unsigned char *data; unsigned char *data;
D_PIXMAP(("Current desktop pixmap is 0x%08x\n", (unsigned int) desktop_pixmap)); D_PIXMAP(("Current desktop pixmap is 0x%08x\n", (unsigned int) desktop_pixmap));
if (desktop_pixmap == None) { if (desktop_pixmap == None) {
orig_desktop_pixmap = None; /* Forced re-read. */ orig_desktop_pixmap = None; /* Forced re-read. */
} }
if (desktop_window == None) { if (desktop_window == None) {
D_PIXMAP(("No desktop window. Aborting.\n")); D_PIXMAP(("No desktop window. Aborting.\n"));
@ -1977,8 +2005,7 @@ get_desktop_pixmap(void)
LIBAST_X_FREE_PIXMAP(color_pixmap); LIBAST_X_FREE_PIXMAP(color_pixmap);
color_pixmap = None; color_pixmap = None;
} }
XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data);
&format, &length, &after, &data);
if (type == XA_PIXMAP) { if (type == XA_PIXMAP) {
p = *((Pixmap *) data); p = *((Pixmap *) data);
XFree(data); XFree(data);
@ -1998,6 +2025,7 @@ get_desktop_pixmap(void)
GC gc; GC gc;
XGCValues gcvalue; XGCValues gcvalue;
Screen *scr = ScreenOfDisplay(Xdisplay, Xscreen); Screen *scr = ScreenOfDisplay(Xdisplay, Xscreen);
gcvalue.foreground = gcvalue.background = PixColors[bgColor]; gcvalue.foreground = gcvalue.background = PixColors[bgColor];
gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue); gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
XGetGeometry(Xdisplay, p, &w, &px, &py, &pw, &ph, &pb, &pd); XGetGeometry(Xdisplay, p, &w, &px, &py, &pw, &ph, &pb, &pd);
@ -2025,12 +2053,12 @@ get_desktop_pixmap(void)
} else { } else {
XFree(data); XFree(data);
} }
XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data);
&format, &length, &after, &data);
if (type == XA_CARDINAL) { if (type == XA_CARDINAL) {
XGCValues gcvalue; XGCValues gcvalue;
GC gc; GC gc;
Pixel pix; Pixel pix;
free_desktop_pixmap(); free_desktop_pixmap();
pix = *((Pixel *) data); pix = *((Pixel *) data);
XFree(data); XFree(data);
@ -2068,12 +2096,14 @@ shaped_window_apply_mask(Drawable d, Pixmap mask)
{ {
static signed char have_shape = -1; static signed char have_shape = -1;
REQUIRE(d != None); REQUIRE(d != None);
REQUIRE(mask != None); REQUIRE(mask != None);
D_PIXMAP(("shaped_window_apply_mask(d [0x%08x], mask [0x%08x]) called.\n", d, mask)); D_PIXMAP(("shaped_window_apply_mask(d [0x%08x], mask [0x%08x]) called.\n", d, mask));
# ifdef HAVE_X_SHAPE_EXT # ifdef HAVE_X_SHAPE_EXT
if (have_shape == -1) { /* Don't know yet. */ if (have_shape == -1) { /* Don't know yet. */
int unused; int unused;
D_PIXMAP(("Looking for shape extension.\n")); D_PIXMAP(("Looking for shape extension.\n"));
if (XQueryExtension(Xdisplay, "SHAPE", &unused, &unused, &unused)) { if (XQueryExtension(Xdisplay, "SHAPE", &unused, &unused, &unused)) {
have_shape = 1; have_shape = 1;
@ -2102,6 +2132,7 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
Imlib_Color_Modifier tmp_cmod; Imlib_Color_Modifier tmp_cmod;
XWMHints *wm_hints; XWMHints *wm_hints;
int w = 8, h = 8; int w = 8, h = 8;
if (pwm_hints) { if (pwm_hints) {
wm_hints = pwm_hints; wm_hints = pwm_hints;
} else { } else {
@ -2118,6 +2149,7 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
if (icon_path != NULL) { if (icon_path != NULL) {
XIconSize *icon_sizes; XIconSize *icon_sizes;
int count, i; int count, i;
temp_im = imlib_load_image_with_error_return(filename, &im_err); temp_im = imlib_load_image_with_error_return(filename, &im_err);
if (temp_im == NULL) { if (temp_im == NULL) {
print_error("Unable to load icon file \"%s\" -- %s\n", filename, imlib_strerror(im_err)); print_error("Unable to load icon file \"%s\" -- %s\n", filename, imlib_strerror(im_err));
@ -2126,8 +2158,7 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
if (XGetIconSizes(Xdisplay, Xroot, &icon_sizes, &count)) { if (XGetIconSizes(Xdisplay, Xroot, &icon_sizes, &count)) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
D_PIXMAP(("Got icon sizes: Width %d to %d +/- %d, Height %d to %d +/- %d\n", icon_sizes[i].min_width, D_PIXMAP(("Got icon sizes: Width %d to %d +/- %d, Height %d to %d +/- %d\n", icon_sizes[i].min_width,
icon_sizes[i].max_width, icon_sizes[i].width_inc, icon_sizes[i].min_height, icon_sizes[i].max_height, icon_sizes[i].max_width, icon_sizes[i].width_inc, icon_sizes[i].min_height, icon_sizes[i].max_height, icon_sizes[i].height_inc));
icon_sizes[i].height_inc));
if (icon_sizes[i].max_width > 64 || icon_sizes[i].max_height > 64) { if (icon_sizes[i].max_width > 64 || icon_sizes[i].max_height > 64) {
continue; continue;
} }

View File

@ -90,6 +90,7 @@ typedef struct __ns_sess { /* a whole screen-session with many clients */
char *home; /* user's home dir. so we can find .screenrc */ char *home; /* user's home dir. so we can find .screenrc */
char *sysrc; /* global screen config */ char *sysrc; /* global screen config */
void *userdef; /* the term-app can store a pointer here */ void *userdef; /* the term-app can store a pointer here */
char *name; /* session name */
int fd; /* fd for communication */ int fd; /* fd for communication */
char escape,literal; /* talking to screen: defaults to ^A, a */ char escape,literal; /* talking to screen: defaults to ^A, a */
int escdef; /* where was the escape sequence defined? */ int escdef; /* where was the escape sequence defined? */
@ -131,13 +132,14 @@ typedef struct __ns_efuns { /* callbacks into the terminal program */
int (*set_scroll_h)(void *,int); int (*set_scroll_h)(void *,int);
int (*redraw)(void *); int (*redraw)(void *);
int (*redraw_xywh)(void *,int,int,int,int); int (*redraw_xywh)(void *,int,int,int,int);
int (*ins_disp)(void *,int,char *); int (*expire_buttons)(void *,int);
int (*ins_disp)(void *,int,int,char *);
int (*del_disp)(void *,int); int (*del_disp)(void *,int);
int (*upd_disp)(void *,int,int,char *); int (*upd_disp)(void *,int,int,char *);
int (*err_msg)(void *,int,char *); int (*err_msg)(void *,int,char *);
int (*execute)(void *,char **); int (*execute)(void *,char **);
int (*inp_text)(void *,int,char *); int (*inp_text)(void *,int,char *);
int (*input_dialog)(void *,char *,int,char **,int (*)(void *,char *,size_t,size_t)); int (*inp_dial)(void *,char *,int,char **,int (*)(void *,char *,size_t,size_t));
int (*inp_tab)(void *,char *[],int,char *,size_t,size_t); int (*inp_tab)(void *,char *[],int,char *,size_t,size_t);
int (*waitstate)(void *,int); int (*waitstate)(void *,int);
} _ns_efuns; } _ns_efuns;
@ -162,18 +164,16 @@ _ns_efuns *ns_new_efuns(void);
_ns_efuns *ns_dst_efuns(_ns_efuns **); _ns_efuns *ns_dst_efuns(_ns_efuns **);
_ns_efuns *ns_get_efuns(_ns_sess *,_ns_disp *); _ns_efuns *ns_get_efuns(_ns_sess *,_ns_disp *);
/* debug */
void ns_desc_string(char *,char *);
void ns_desc_hop(_ns_hop *,char *);
void ns_desc_sess(_ns_sess *,char *);
/* convenience */
_ns_disp *disp_fetch_or_make(_ns_sess *,int);
/* transparent attach/detach */ /* transparent attach/detach */
_ns_sess *ns_attach_by_sess(_ns_sess **,int *); _ns_sess *ns_attach_by_sess(_ns_sess **,int *);
_ns_sess *ns_attach_by_URL(char *,char *,_ns_efuns **,int *,void *); _ns_sess *ns_attach_by_URL(char *,char *,_ns_efuns **,int *,void *);
int ns_detach(_ns_sess **);
/* convenience */
int ns_run(_ns_efuns *, char *);
int ns_get_ssh_port(void);
int disp_get_real_by_screen(_ns_sess *,int);
int disp_get_screen_by_real(_ns_sess *,int);
/* send command to screen */ /* send command to screen */
int ns_screen_command(_ns_sess *, char *); int ns_screen_command(_ns_sess *, char *);
@ -202,21 +202,25 @@ int ns_parse_screen(_ns_sess *,int,int,char *);
/* backend abstraction */
/* things the term might ask screen/scream to do ***************************/ /* things the term might ask screen/scream to do ***************************/
int ns_scroll2x(_ns_sess *,int); int ns_scroll2x(_ns_sess *,int);
int ns_scroll2y(_ns_sess *,int); int ns_scroll2y(_ns_sess *,int);
int ns_go2_disp(_ns_sess *,int); int ns_go2_disp(_ns_sess *,int);
int ns_add_disp(_ns_sess *,int,char *); int ns_add_disp(_ns_sess *,int,char *);
int ns_mov_disp(_ns_sess * s,int,int);
int ns_rsz_disp(_ns_sess *,int,int,int); int ns_rsz_disp(_ns_sess *,int,int,int);
int ns_rem_disp(_ns_sess *,int); int ns_rem_disp(_ns_sess *,int);
int ns_ren_disp(_ns_sess *,int,char *); int ns_ren_disp(_ns_sess *,int,char *);
int ns_log_disp(_ns_sess *,int,char *); int ns_log_disp(_ns_sess *,int,char *);
int ns_upd_stat(_ns_sess *); int ns_upd_stat(_ns_sess *);
int ns_input_dialog(_ns_sess *,char *,int,char **,int (*)(void *,char *,size_t,size_t)); int ns_inp_dial(_ns_sess *,char *,int,char **,int (*)(void *,char *,size_t,size_t));
char *ns_get_url(_ns_sess *,int);
/* register efuns (callbacks) **********************************************/ /* frontend abstraction */
/* things we might ask the terminal to do (register efuns (callbacks)) *****/
void ns_register_ssx(_ns_efuns *,int (*set_scroll_x)(void *,int)); void ns_register_ssx(_ns_efuns *,int (*set_scroll_x)(void *,int));
void ns_register_ssy(_ns_efuns *,int (*set_scroll_y)(void *,int)); void ns_register_ssy(_ns_efuns *,int (*set_scroll_y)(void *,int));
void ns_register_ssw(_ns_efuns *,int (*set_scroll_w)(void *,int)); void ns_register_ssw(_ns_efuns *,int (*set_scroll_w)(void *,int));
@ -224,8 +228,9 @@ void ns_register_ssh(_ns_efuns *,int (*set_scroll_h)(void *,int));
void ns_register_red(_ns_efuns *,int (*redraw)(void *)); void ns_register_red(_ns_efuns *,int (*redraw)(void *));
void ns_register_rda(_ns_efuns *,int (*redraw_xywh)(void *,int,int,int,int)); void ns_register_rda(_ns_efuns *,int (*redraw_xywh)(void *,int,int,int,int));
void ns_register_exb(_ns_efuns *,int (*expire_buttons)(void *,int));
void ns_register_ins(_ns_efuns *,int (*ins_disp)(void *,int,char *)); void ns_register_ins(_ns_efuns *,int (*ins_disp)(void *,int,int,char *));
void ns_register_del(_ns_efuns *,int (*del_disp)(void *,int)); void ns_register_del(_ns_efuns *,int (*del_disp)(void *,int));
void ns_register_upd(_ns_efuns *,int (*upd_disp)(void *,int,int,char *)); void ns_register_upd(_ns_efuns *,int (*upd_disp)(void *,int,int,char *));
@ -238,20 +243,6 @@ void ns_register_inp(_ns_efuns *,int (*)(void *,char *,int,char **,int (*)(void
void ns_register_tab(_ns_efuns *,int (*)(void *,char *[],int,char *,size_t,size_t)); void ns_register_tab(_ns_efuns *,int (*)(void *,char *[],int,char *,size_t,size_t));
void ns_register_fun(_ns_efuns *,int (*)(void *,int)); void ns_register_fun(_ns_efuns *,int (*)(void *,int));
/* from command.c */
extern int set_scroll_x(void *, int);
extern int set_scroll_y(void *, int);
extern int set_scroll_w(void *, int);
extern int set_scroll_h(void *, int);
extern int redraw(void *);
extern int redraw_xywh(void *, int, int, int, int);
extern int ins_disp(void *, int, char *);
extern int del_disp(void *, int);
extern int upd_disp(void *, int, int, char *);
extern int err_msg(void *, int, char *);
extern int inp_text(void *, int, char *);
extern int input_dialog(void *, char *, int, char **, int (*) (void *, char *, size_t, size_t));
extern int exe_prg(void *, char **);
extern int escreen_init(char **);
/***************************************************************************/ /***************************************************************************/

View File

@ -15,11 +15,8 @@
undef it, you're on your own. */ undef it, you're on your own. */
#define NS_PARANOID #define NS_PARANOID
/* define NS_DEBUG to get debug-info. no support for those who undef this. */ /* compile in support for the GNU "screen" program as a backend */
#undef NS_DEBUG #define NS_HAVE_SCREEN 1
/* debug memory stuff. never actually used this. */
#undef NS_DEBUG_MEM
#define NS_MAXCMD 512 #define NS_MAXCMD 512
@ -32,7 +29,7 @@
#define NS_SCREEN_OPTS "-xRR" #define NS_SCREEN_OPTS "-xRR"
#define NS_SCREEN_GREP "grep escape \"$SCREENRC\" 2>/dev/null || grep escape ~/.screenrc 2>/dev/null || grep escape \"$SYSSCREENRC\" 2>/dev/null || grep escape /etc/screenrc 2>/dev/null || grep escape /usr/local/etc/screenrc 2>/dev/null || echo \"escape ^Aa\"\n" #define NS_SCREEN_GREP "grep escape \"$SCREENRC\" 2>/dev/null || grep escape ~/.screenrc 2>/dev/null || grep escape \"$SYSSCREENRC\" 2>/dev/null || grep escape /etc/screenrc 2>/dev/null || grep escape /usr/local/etc/screenrc 2>/dev/null || echo \"escape ^Aa\"\n"
#define NS_SCREEM_CALL "%s 2>/dev/null || %s" #define NS_SCREEM_CALL "%s 2>/dev/null || %s"
#define NS_WRAP_CALL "export TERM=vt100; %s" #define NS_WRAP_CALL "export TERM=vt100; screen -wipe; %s"
#define NS_SCREEN_RC ".screenrc" #define NS_SCREEN_RC ".screenrc"
/* this should never change. the escape-char for an out-of-the-box "screen". /* this should never change. the escape-char for an out-of-the-box "screen".
@ -48,7 +45,9 @@
else is used in the session, libscream will convert it on the fly. */ else is used in the session, libscream will convert it on the fly. */
/* DO NOT use \005Lw for your status, it breaks older screens!! */ /* DO NOT use \005Lw for your status, it breaks older screens!! */
#define NS_SCREEN_UPDATE "\x01w" #define NS_SCREEN_UPDATE "\x01w"
#define NS_SCREEN_INIT "\x0c\x01Z\x01:hardstatus lastline\r\x01:defhstatus \"\\005w\"\r\x01:hstatus \"\\005w\"\r\x01:msgminwait 0\r\x01:msgwait 1\r\x01:nethack off\r" NS_SCREEN_UPDATE #define NS_SCREEN_VERSION "\x01v"
#define NS_SCREEN_SESSION "\x01:sessionname\r"
#define NS_SCREEN_INIT "\x01:msgminwait 0\r\x01:msgwait 1\r\x01:hardstatus lastline\r\x01:defhstatus \"\\005w\"\r\x01:hstatus \"\\005w\"\r\x01:nethack off\r\x0c" NS_SCREEN_UPDATE NS_SCREEN_VERSION NS_SCREEN_SESSION
#define NS_SCREEN_PRVS_REG "\x01:focus up\r" #define NS_SCREEN_PRVS_REG "\x01:focus up\r"
#define NS_DFLT_SSH_PORT 22 #define NS_DFLT_SSH_PORT 22
@ -59,14 +58,11 @@
#define NS_SCREEN_FLAGS "*-$!@L&Z" #define NS_SCREEN_FLAGS "*-$!@L&Z"
#define NS_SCREEN_DK_CMD "unknown command '" #define NS_SCREEN_DK_CMD_T "unknown command '"
#define NS_SCREEN_VERSION "scre%s %d.%d.%d %s %s" #define NS_SCREEN_SESS_T "This session is named '"
#define NS_SCREEN_VERSION_T "scre%2s %d.%d.%d %16s %32s"
#define NS_SCREEN_NO_DEBUG "Sorry, screen was compiled without -DDEBUG option." #define NS_SCREEN_NO_DEBUG "Sorry, screen was compiled without -DDEBUG option."
/* if >0, force an update every NS_SCREEN_UPD_FREQ seconds.
a bit of a last resort. */
#define NS_SCREEN_UPD_FREQ 0
/* should be 1s */ /* should be 1s */
#define NS_INIT_DELAY 1 #define NS_INIT_DELAY 1
@ -79,7 +75,7 @@
#define NS_MENU_TITLE "Escreen" #define NS_MENU_TITLE "Escreen"
/* prefix for debug info */ /* prefix for debug info */
#define NS_PREFIX "libscream::" #define NS_PREFIX "screamClient::"

View File

@ -41,6 +41,12 @@ static const char cvs_ident[] = "$Id$";
#include "profile.h" #include "profile.h"
#include "term.h" #include "term.h"
#ifdef ESCREEN
# include "screamcfg.h"
#endif
static int pb = 0;
/* These arrays store the text and rendering info that were last drawn to the screen. */ /* These arrays store the text and rendering info that were last drawn to the screen. */
static text_t **drawn_text = NULL; static text_t **drawn_text = NULL;
static rend_t **drawn_rend = NULL; static rend_t **drawn_rend = NULL;
@ -177,8 +183,7 @@ scr_reset(void)
buf_rend = CALLOC(rend_t *, total_rows); buf_rend = CALLOC(rend_t *, total_rows);
drawn_rend = CALLOC(rend_t *, TermWin.nrow); drawn_rend = CALLOC(rend_t *, TermWin.nrow);
swap.rend = CALLOC(rend_t *, TermWin.nrow); swap.rend = CALLOC(rend_t *, TermWin.nrow);
D_SCREEN(("screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p\n", screen.text, screen.rend, swap.text, D_SCREEN(("screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p\n", screen.text, screen.rend, swap.text, swap.rend));
swap.rend));
for (i = 0; i < TermWin.nrow; i++) { for (i = 0; i < TermWin.nrow; i++) {
j = i + TermWin.saveLines; j = i + TermWin.saveLines;
@ -221,8 +226,7 @@ scr_reset(void)
buf_rend = REALLOC(buf_rend, total_rows * sizeof(rend_t *)); buf_rend = REALLOC(buf_rend, total_rows * sizeof(rend_t *));
drawn_rend = REALLOC(drawn_rend, TermWin.nrow * sizeof(rend_t *)); drawn_rend = REALLOC(drawn_rend, TermWin.nrow * sizeof(rend_t *));
swap.rend = REALLOC(swap.rend, TermWin.nrow * sizeof(rend_t *)); swap.rend = REALLOC(swap.rend, TermWin.nrow * sizeof(rend_t *));
D_SCREEN(("screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p\n", screen.text, screen.rend, swap.text, D_SCREEN(("screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p\n", screen.text, screen.rend, swap.text, swap.rend));
swap.rend));
/* we have fewer rows so fix up number of scrolled lines */ /* we have fewer rows so fix up number of scrolled lines */
UPPER_BOUND(screen.row, TermWin.nrow - 1); UPPER_BOUND(screen.row, TermWin.nrow - 1);
@ -238,8 +242,7 @@ scr_reset(void)
buf_rend = REALLOC(buf_rend, total_rows * sizeof(rend_t *)); buf_rend = REALLOC(buf_rend, total_rows * sizeof(rend_t *));
drawn_rend = REALLOC(drawn_rend, TermWin.nrow * sizeof(rend_t *)); drawn_rend = REALLOC(drawn_rend, TermWin.nrow * sizeof(rend_t *));
swap.rend = REALLOC(swap.rend, TermWin.nrow * sizeof(rend_t *)); swap.rend = REALLOC(swap.rend, TermWin.nrow * sizeof(rend_t *));
D_SCREEN(("screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p\n", screen.text, screen.rend, swap.text, D_SCREEN(("screen.text == %8p, screen.rend == %8p, swap.text == %8p, swap.rend == %8p\n", screen.text, screen.rend, swap.text, swap.rend));
swap.rend));
k = MIN(TermWin.nscrolled, TermWin.nrow - prev_nrow); k = MIN(TermWin.nscrolled, TermWin.nrow - prev_nrow);
for (i = prev_total_rows; i < total_rows - k; i++) { for (i = prev_total_rows; i < total_rows - k; i++) {
@ -724,13 +727,13 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
c = str[i++]; c = str[i++];
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
if ((encoding_method != LATIN1) && (chstat == WBYTE)) { if ((encoding_method != LATIN1) && (chstat == WBYTE)) {
rstyle |= RS_multiMask; /* multibyte 2nd byte */ rstyle |= RS_multiMask; /* multibyte 2nd byte */
chstat = SBYTE; chstat = SBYTE;
if (encoding_method == EUCJ) { if (encoding_method == EUCJ) {
c |= 0x80; /* maybe overkill, but makes it selectable */ c |= 0x80; /* maybe overkill, but makes it selectable */
} }
} else if (chstat == SBYTE) { } else if (chstat == SBYTE) {
if ((encoding_method != LATIN1) && (multi_byte || (c & 0x80))) { /* multibyte 1st byte */ if ((encoding_method != LATIN1) && (multi_byte || (c & 0x80))) { /* multibyte 1st byte */
rstyle &= ~RS_multiMask; rstyle &= ~RS_multiMask;
rstyle |= RS_multi1; rstyle |= RS_multi1;
chstat = WBYTE; chstat = WBYTE;
@ -756,8 +759,8 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
screen.row++; screen.row++;
row = screen.row + TermWin.saveLines; row = screen.row + TermWin.saveLines;
} }
stp = screen.text[row]; /* _must_ refresh */ stp = screen.text[row]; /* _must_ refresh */
srp = screen.rend[row]; /* _must_ refresh */ srp = screen.rend[row]; /* _must_ refresh */
continue; continue;
case '\r': case '\r':
LOWER_BOUND(stp[last_col], screen.col); LOWER_BOUND(stp[last_col], screen.col);
@ -785,8 +788,8 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
screen.row++; screen.row++;
row = screen.row + TermWin.saveLines; row = screen.row + TermWin.saveLines;
} }
stp = screen.text[row]; /* _must_ refresh */ stp = screen.text[row]; /* _must_ refresh */
srp = screen.rend[row]; /* _must_ refresh */ srp = screen.rend[row]; /* _must_ refresh */
screen.col = 0; screen.col = 0;
screen.flags &= ~Screen_WrapNext; screen.flags &= ~Screen_WrapNext;
} }
@ -820,7 +823,7 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen_mode) { if (TermWin.screen_mode) {
if (screen.row >= TermWin.nrow - 1) { /* last row -> upd-flag */ if (screen.row >= TermWin.nrow - 1) { /* last row -> upd-flag */
TermWin.screen_pending |= 1; TermWin.screen_pending |= 1;
} }
} }
@ -908,7 +911,7 @@ scr_gotorc(int row, int col, int relative)
screen.row += row; screen.row += row;
} }
} else { } else {
if (screen.flags & Screen_Relative) { /* relative origin mode */ if (screen.flags & Screen_Relative) { /* relative origin mode */
screen.row = row + screen.tscroll; screen.row = row + screen.tscroll;
UPPER_BOUND(screen.row, screen.bscroll); UPPER_BOUND(screen.row, screen.bscroll);
} else } else
@ -916,9 +919,9 @@ scr_gotorc(int row, int col, int relative)
} }
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen_mode) { if (TermWin.screen_mode) {
if (screen.row >= TermWin.nrow - 1) { /* last row -> upd-flag */ if (screen.row >= TermWin.nrow - 1) { /* last row -> upd-flag */
TermWin.screen_pending |= 1; TermWin.screen_pending |= 1;
} else if (TermWin.screen_pending) { /* left last -> upd-finis */ } else if (TermWin.screen_pending) { /* left last -> upd-finis */
TermWin.screen_pending |= 2; TermWin.screen_pending |= 2;
} }
} }
@ -1048,7 +1051,7 @@ scr_erase_screen(int mode)
default: default:
return; return;
} }
if (row >= 0 && row <= TermWin.nrow) { /* check OOB */ if (row >= 0 && row <= TermWin.nrow) { /* check OOB */
UPPER_BOUND(num, (TermWin.nrow - row)); UPPER_BOUND(num, (TermWin.nrow - row));
if (rstyle & RS_RVid || rstyle & RS_Uline) if (rstyle & RS_RVid || rstyle & RS_Uline)
ren = -1; ren = -1;
@ -1477,8 +1480,7 @@ scr_expose(int x, int y, int width, int height)
rect_end.row = Pixel2Row(y + height + TermWin.fheight - 1); rect_end.row = Pixel2Row(y + height + TermWin.fheight - 1);
BOUND(rect_end.row, 0, nr); BOUND(rect_end.row, 0, nr);
D_SCREEN(("scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)\n", x, y, width, height, rect_beg.col, rect_beg.row, D_SCREEN(("scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)\n", x, y, width, height, rect_beg.col, rect_beg.row, rect_end.col, rect_end.row));
rect_end.col, rect_end.row));
for (i = rect_beg.row; i <= rect_end.row; i++) { for (i = rect_beg.row; i <= rect_end.row; i++) {
MEMSET(&(drawn_text[i][rect_beg.col]), 0, rect_end.col - rect_beg.col + 1); MEMSET(&(drawn_text[i][rect_beg.col]), 0, rect_end.col - rect_beg.col + 1);
@ -1624,6 +1626,7 @@ scr_refresh(int type)
int (*draw_string) (), (*draw_image_string) (); int (*draw_string) (), (*draw_image_string) ();
register int low_x = 99999, low_y = 99999, high_x = 0, high_y = 0; register int low_x = 99999, low_y = 99999, high_x = 0, high_y = 0;
Drawable draw_buffer; Drawable draw_buffer;
#ifndef NO_BOLDFONT #ifndef NO_BOLDFONT
int bfont = 0; /* we've changed font to bold font */ int bfont = 0; /* we've changed font to bold font */
#endif #endif
@ -1716,9 +1719,9 @@ scr_refresh(int type)
/* compare new text with old - if exactly the same then continue */ /* compare new text with old - if exactly the same then continue */
rt1 = srp[col]; rt1 = srp[col];
rt2 = drp[col]; rt2 = drp[col];
if ((stp[col] == dtp[col]) /* must match characters to skip */ if ((stp[col] == dtp[col]) /* must match characters to skip */
&&((rt1 == rt2) /* either rendition the same or */ &&((rt1 == rt2) /* either rendition the same or */
||((stp[col] == ' ') /* space w/ no bg change */ ||((stp[col] == ' ') /* space w/ no bg change */
&&(GET_BGATTR(rt1) == GET_BGATTR(rt2))))) { &&(GET_BGATTR(rt1) == GET_BGATTR(rt2))))) {
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
/* if first byte is multibyte then compare second bytes */ /* if first byte is multibyte then compare second bytes */
@ -1786,8 +1789,8 @@ scr_refresh(int type)
/* XXX : maybe do the same thing for RS_multi2 */ /* XXX : maybe do the same thing for RS_multi2 */
/* corrupt character - you're outta there */ /* corrupt character - you're outta there */
rend &= ~RS_multiMask; rend &= ~RS_multiMask;
drp[col] = rend; /* TODO check: may also want */ drp[col] = rend; /* TODO check: may also want */
dtp[col] = ' '; /* to poke into stp/srp */ dtp[col] = ' '; /* to poke into stp/srp */
buffer[0] = ' '; buffer[0] = ' ';
} }
if (wbyte) { if (wbyte) {
@ -1829,10 +1832,10 @@ scr_refresh(int type)
rvid = !rvid; rvid = !rvid;
if (rend & RS_Cursor) { if (rend & RS_Cursor) {
if (focus) { if (focus) {
is_cursor = 2; /* normal cursor */ is_cursor = 2; /* normal cursor */
rvid = !rvid; rvid = !rvid;
} else { } else {
is_cursor = 1; /* outline cursor */ is_cursor = 1; /* outline cursor */
rend &= ~RS_Cursor; rend &= ~RS_Cursor;
} }
srp[col] &= ~RS_Cursor; srp[col] &= ~RS_Cursor;
@ -2028,12 +2031,10 @@ scr_refresh(int type)
gcmask |= (GCForeground | GCBackground); gcmask |= (GCForeground | GCBackground);
XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue);
if (font->ascent < ascent) { if (font->ascent < ascent) {
XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, Row2Pixel(row), Width2Pixel(len), ascent - font->ascent);
Row2Pixel(row), Width2Pixel(len), ascent - font->ascent);
} }
if (font->descent < descent) { if (font->descent < descent) {
XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, Row2Pixel(row) + ascent + font->descent, Width2Pixel(len), descent - font->descent);
Row2Pixel(row) + ascent + font->descent, Width2Pixel(len), descent - font->descent);
} }
SWAP_IT(gcvalue.foreground, gcvalue.background, ltmp); SWAP_IT(gcvalue.foreground, gcvalue.background, ltmp);
XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue);
@ -2099,22 +2100,18 @@ scr_refresh(int type)
#endif #endif
} }
if (buffer_pixmap) { if (buffer_pixmap) {
D_SCREEN(("Update box dimensions: from (%d, %d) to (%d, %d). Dimensions %dx%d\n", low_x, low_y, high_x, high_y, D_SCREEN(("Update box dimensions: from (%d, %d) to (%d, %d). Dimensions %dx%d\n", low_x, low_y, high_x, high_y, high_x - low_x + 1, high_y - low_y + 1));
high_x - low_x + 1, high_y - low_y + 1));
XClearArea(Xdisplay, TermWin.vt, low_x, low_y, high_x - low_x + 1, high_y - low_y + 1, False); XClearArea(Xdisplay, TermWin.vt, low_x, low_y, high_x - low_x + 1, high_y - low_y + 1, False);
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) { if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin.internalBorder - 1, 0, XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, TermWin.internalBorder - 1, 0);
1, TermWin_TotalHeight() - 1, TermWin.internalBorder - 1, 0);
XClearArea(Xdisplay, TermWin.vt, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, False); XClearArea(Xdisplay, TermWin.vt, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, False);
} }
if (fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) { if (fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin_TotalWidth() - 2, 0, XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, TermWin_TotalWidth() - 2, 0);
1, TermWin_TotalHeight() - 1, TermWin_TotalWidth() - 2, 0);
XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, False); XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, False);
} }
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP_RIGHT]) { if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, 0, TermWin.internalBorder - 1, XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, 0, TermWin.internalBorder - 1);
TermWin_TotalWidth() - 1, 1, 0, TermWin.internalBorder - 1);
XClearArea(Xdisplay, TermWin.vt, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, False); XClearArea(Xdisplay, TermWin.vt, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, False);
} }
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) { if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
@ -2409,9 +2406,7 @@ selection_fetch(Window win, unsigned prop, int delete)
return; return;
} }
for (nread = 0, bytes_after = 1; bytes_after > 0;) { for (nread = 0, bytes_after = 1; bytes_after > 0;) {
if ((XGetWindowProperty if ((XGetWindowProperty(Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems, &bytes_after, &data) != Success)
(Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems, &bytes_after,
&data) != Success)
|| (actual_type == None) || (data == NULL)) { || (actual_type == None) || (data == NULL)) {
D_SELECT(("Unable to fetch the value of property %d from window 0x%08x\n", (int) prop, (int) win)); D_SELECT(("Unable to fetch the value of property %d from window 0x%08x\n", (int) prop, (int) win));
if (data != NULL) { if (data != NULL) {
@ -2420,8 +2415,7 @@ selection_fetch(Window win, unsigned prop, int delete)
return; return;
} }
nread += nitems; nread += nitems;
D_SELECT(("Got selection info: Actual type %d (format %d), %lu items at 0x%08x, %lu bytes left over.\n", D_SELECT(("Got selection info: Actual type %d (format %d), %lu items at 0x%08x, %lu bytes left over.\n", (int) actual_type, actual_fmt, nitems, data, bytes_after));
(int) actual_type, actual_fmt, nitems, data, bytes_after));
if (nitems == 0) { if (nitems == 0) {
D_SELECT(("Retrieval of incremental selection complete.\n")); D_SELECT(("Retrieval of incremental selection complete.\n"));
@ -2850,7 +2844,7 @@ selection_delimit_word(int col, int row, row_col_t *beg, row_col_t *end)
} }
if (!(Options & Opt_xterm_select)) { if (!(Options & Opt_xterm_select)) {
if (beg_col == col && beg_col > 0) { if (beg_col == col && beg_col > 0) {
if (DELIMIT_TEXT(*stp)) /* space or tab or cutchar */ if (DELIMIT_TEXT(*stp)) /* space or tab or cutchar */
break; break;
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
srp = &(screen.rend[beg_row + row_offset][beg_col - 1]); srp = &(screen.rend[beg_row + row_offset][beg_col - 1]);
@ -2913,7 +2907,7 @@ selection_delimit_word(int col, int row, row_col_t *beg, row_col_t *end)
} }
if (!(Options & Opt_xterm_select)) { if (!(Options & Opt_xterm_select)) {
if (end_col == col && end_col < last_col) { if (end_col == col && end_col < last_col) {
if (DELIMIT_TEXT(*stp)) /* space or tab or cutchar */ if (DELIMIT_TEXT(*stp)) /* space or tab or cutchar */
break; break;
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
srp = &(screen.rend[end_row + row_offset][end_col + 1]); srp = &(screen.rend[end_row + row_offset][end_col + 1]);
@ -3258,8 +3252,7 @@ selection_send(XSelectionRequestEvent * rq)
target_list[0] = (Atom32) props[PROP_SELECTION_TARGETS]; target_list[0] = (Atom32) props[PROP_SELECTION_TARGETS];
target_list[1] = (Atom32) XA_STRING; target_list[1] = (Atom32) XA_STRING;
XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target,
(8 * sizeof(target_list[0])), PropModeReplace, (8 * sizeof(target_list[0])), PropModeReplace, (unsigned char *) target_list, (sizeof(target_list) / sizeof(target_list[0])));
(unsigned char *) target_list, (sizeof(target_list) / sizeof(target_list[0])));
ev.xselection.property = rq->property; ev.xselection.property = rq->property;
#if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H) #if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H)
} else if (rq->target == XA_TEXT(Xdisplay) || rq->target == XA_COMPOUND_TEXT(Xdisplay)) { } else if (rq->target == XA_TEXT(Xdisplay) || rq->target == XA_COMPOUND_TEXT(Xdisplay)) {
@ -3271,8 +3264,7 @@ selection_send(XSelectionRequestEvent * rq)
xtextp.nitems = 0; xtextp.nitems = 0;
if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) { if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) {
if (xtextp.nitems > 0 && xtextp.value != NULL) { if (xtextp.nitems > 0 && xtextp.value != NULL) {
XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_COMPOUND_TEXT(Xdisplay), 8, PropModeReplace, xtextp.value, XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_COMPOUND_TEXT(Xdisplay), 8, PropModeReplace, xtextp.value, xtextp.nitems);
xtextp.nitems);
ev.xselection.property = rq->property; ev.xselection.property = rq->property;
} }
} }
@ -3284,6 +3276,30 @@ selection_send(XSelectionRequestEvent * rq)
XSendEvent(Xdisplay, rq->requestor, False, 0, &ev); XSendEvent(Xdisplay, rq->requestor, False, 0, &ev);
} }
void /* drag report as used by the "twin" program */
mouse_drag_report(XButtonEvent * ev)
{
int button_number, key_state, x = Pixel2Col(ev->x), y = Pixel2Row(ev->y);
switch (ev->button) {
case AnyButton: /* Button release */
button_number = pb + Button1; /* yeah, yeah */
break;
case Button1: /* Button press */
case Button2:
case Button3:
pb = button_number = ev->button - Button1;
break;
default: /* Wheel mouse */
button_number = 64 + ev->button - Button3 - 1;
break;
}
key_state = ((ev->state & (ShiftMask | ControlMask))
+ ((ev->state & Mod1Mask) ? 2 : 0));
tt_printf((unsigned char *) "\033[5M%c%c%c%c%c",
(32 + button_number + (key_state << 2)), (32 + (x & 0x7f) + 1), (32 + ((x >> 7) & 0x7f) + 1), (32 + (y & 0x7f) + 1), (32 + ((y >> 7) & 0x7f) + 1));
}
void void
mouse_report(XButtonEvent * ev) mouse_report(XButtonEvent * ev)
{ {
@ -3296,7 +3312,7 @@ mouse_report(XButtonEvent * ev)
case Button1: /* Button press */ case Button1: /* Button press */
case Button2: case Button2:
case Button3: case Button3:
button_number = ev->button - Button1; pb = button_number = ev->button - Button1;
break; break;
default: /* Wheel mouse */ default: /* Wheel mouse */
button_number = 64 + ev->button - Button3 - 1; button_number = 64 + ev->button - Button3 - 1;
@ -3304,8 +3320,7 @@ mouse_report(XButtonEvent * ev)
} }
key_state = ((ev->state & (ShiftMask | ControlMask)) key_state = ((ev->state & (ShiftMask | ControlMask))
+ ((ev->state & Mod1Mask) ? 2 : 0)); + ((ev->state & Mod1Mask) ? 2 : 0));
tt_printf((unsigned char *) "\033[M%c%c%c", tt_printf((unsigned char *) "\033[M%c%c%c", (32 + button_number + (key_state << 2)), (32 + Pixel2Col(ev->x) + 1), (32 + Pixel2Row(ev->y) + 1));
(32 + button_number + (key_state << 2)), (32 + Pixel2Col(ev->x) + 1), (32 + Pixel2Row(ev->y) + 1));
} }
void void
@ -3366,27 +3381,13 @@ xim_get_position(XPoint * pos)
#endif #endif
#ifdef ESCREEN #ifdef ESCREEN
# ifdef NS_HAVE_SCREEN
void void
parse_screen_status_if_necessary(void) parse_screen_status_if_necessary(void)
{ {
#if 0
static int hc = 0;
#endif
ns_parse_screen(TermWin.screen, (TermWin.screen_pending > 1), TermWin.ncol, screen.text[TermWin.nrow + TermWin.saveLines - 1]); ns_parse_screen(TermWin.screen, (TermWin.screen_pending > 1), TermWin.ncol, screen.text[TermWin.nrow + TermWin.saveLines - 1]);
if (TermWin.screen_pending > 1) if (TermWin.screen_pending > 1)
TermWin.screen_pending = 0; TermWin.screen_pending = 0;
#if 0
{
FILE *fh;
int c;
if ((fh = fopen("Escreen.log", "a"))) {
for (c = 0; c < 8; c++)
if (strcmp(drawn_text[c], drawn_text[c + 1]))
fprintf(fh, "%2d \"%s\"\n", c, drawn_text[c]);
fclose(fh);
}
}
#endif
} }
# endif
#endif #endif

View File

@ -302,6 +302,7 @@ extern void selection_extend_colrow(int, int, int, int);
extern void selection_rotate(int, int); extern void selection_rotate(int, int);
extern void selection_send(XSelectionRequestEvent *); extern void selection_send(XSelectionRequestEvent *);
extern void mouse_report(XButtonEvent *); extern void mouse_report(XButtonEvent *);
extern void mouse_drag_report(XButtonEvent *);
extern void mouse_tracking(int, int, int, int, int); extern void mouse_tracking(int, int, int, int, int);
extern void debug_colors(void); extern void debug_colors(void);
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET

View File

@ -54,14 +54,16 @@ scrollbar_t scrollbar = {
0, 0, 0, 0,
0, 0 0, 0
}; };
#ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
short scroll_arrow_delay; short scroll_arrow_delay;
#endif #endif
static GC gc_scrollbar; static GC gc_scrollbar;
static short last_top = 0, last_bot = 0; static short last_top = 0, last_bot = 0;
#ifdef XTERM_SCROLLBAR #ifdef XTERM_SCROLLBAR
static GC gc_stipple, gc_border; static GC gc_stipple, gc_border;
static unsigned char xterm_sb_bits[] = { 0xaa, 0x0a, 0x55, 0x05 }; /* 12x2 bitmap */ static unsigned char xterm_sb_bits[] = { 0xaa, 0x0a, 0x55, 0x05 }; /* 12x2 bitmap */
#endif #endif
#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR)
static GC gc_top, gc_bottom; static GC gc_top, gc_bottom;
@ -216,8 +218,7 @@ sb_handle_button_press(event_t *ev)
#endif /* NO_SCROLLBAR_REPORT */ #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(("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, 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));
scrollbar.win));
if (scrollbar_win_is_uparrow(ev->xany.window)) { if (scrollbar_win_is_uparrow(ev->xany.window)) {
scrollbar_draw_uparrow(IMAGE_STATE_CLICKED, 0); scrollbar_draw_uparrow(IMAGE_STATE_CLICKED, 0);
@ -242,7 +243,7 @@ sb_handle_button_press(event_t *ev)
} }
switch (ev->xbutton.button) { switch (ev->xbutton.button) {
case Button2: case Button2:
button_state.mouse_offset = scrollbar_anchor_height() / 2; /* Align to center */ button_state.mouse_offset = scrollbar_anchor_height() / 2; /* Align to center */
if (!scrollbar_win_is_anchor(ev->xany.window)) { if (!scrollbar_win_is_anchor(ev->xany.window)) {
scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height());
} else if (scrollbar.type == SCROLLBAR_XTERM) { } else if (scrollbar.type == SCROLLBAR_XTERM) {
@ -332,8 +333,7 @@ sb_handle_motion_notify(event_t *ev)
return 1; return 1;
D_EVENTS(("MotionNotify event for window 0x%08x\n", ev->xany.window)); 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, 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));
scrollbar.win));
if ((scrollbar_win_is_trough(ev->xany.window) || scrollbar_win_is_anchor(ev->xany.window)) && scrollbar_is_moving()) { if ((scrollbar_win_is_trough(ev->xany.window) || scrollbar_win_is_anchor(ev->xany.window)) && scrollbar_is_moving()) {
Window unused_root, unused_child; Window unused_root, unused_child;
@ -341,8 +341,7 @@ sb_handle_motion_notify(event_t *ev)
unsigned int unused_mask; unsigned int unused_mask;
while (XCheckTypedWindowEvent(Xdisplay, scrollbar.win, MotionNotify, ev)); while (XCheckTypedWindowEvent(Xdisplay, scrollbar.win, MotionNotify, ev));
XQueryPointer(Xdisplay, scrollbar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), XQueryPointer(Xdisplay, scrollbar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);
&(ev->xbutton.y), &unused_mask);
scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height());
refresh_count = refresh_limit = 0; refresh_count = refresh_limit = 0;
scr_refresh(refresh_type); scr_refresh(refresh_type);
@ -558,11 +557,9 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sa].current->bg, "")); XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sa].current->bg, ""));
XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sa].current->bg, "")); XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sa].current->bg, ""));
if (scrollbar_anchor_is_pressed()) { if (scrollbar_anchor_is_pressed()) {
draw_shadow(scrollbar.sa_win, gc_bottom, gc_top, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(), draw_shadow(scrollbar.sa_win, gc_bottom, gc_top, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(), scrollbar_get_shadow());
scrollbar_get_shadow());
} else { } else {
draw_shadow(scrollbar.sa_win, gc_top, gc_bottom, 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());
scrollbar_get_shadow());
} }
} }
#endif #endif
@ -603,8 +600,7 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
UPPER_BOUND(th, scrollbar_anchor_height() >> 1); UPPER_BOUND(th, scrollbar_anchor_height() >> 1);
D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th)); D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th));
if ((tw > 0) && (th > 0)) { if ((tw > 0) && (th > 0)) {
paste_simage(images[image_st].current, image_st, scrollbar.sa_win, pmap, paste_simage(images[image_st].current, image_st, scrollbar.sa_win, pmap, (scrollbar_anchor_width() - tw) >> 1, (scrollbar_anchor_height() - th) >> 1, tw, th);
(scrollbar_anchor_width() - tw) >> 1, (scrollbar_anchor_height() - th) >> 1, tw, th);
XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, pmap); XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, pmap);
XClearWindow(Xdisplay, scrollbar.sa_win); XClearWindow(Xdisplay, scrollbar.sa_win);
IMLIB_FREE_PIXMAP(pmap); IMLIB_FREE_PIXMAP(pmap);
@ -668,8 +664,7 @@ scrollbar_draw_trough(unsigned char image_state, unsigned char force_modes)
XFillRectangle(Xdisplay, scrollbar.win, gc_scrollbar, 0, 0, scrollbar_trough_width(), scrollbar_trough_height()); XFillRectangle(Xdisplay, scrollbar.win, gc_scrollbar, 0, 0, scrollbar_trough_width(), scrollbar_trough_height());
XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sb].current->bg, "")); XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sb].current->bg, ""));
XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sb].current->bg, "")); XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sb].current->bg, ""));
draw_shadow(scrollbar.win, gc_bottom, gc_top, 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());
scrollbar_get_shadow());
} }
return; return;
} }
@ -693,8 +688,7 @@ scrollbar_init(int width, int height)
Attributes.override_redirect = TRUE; Attributes.override_redirect = TRUE;
Attributes.save_under = TRUE; Attributes.save_under = TRUE;
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
mask = ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask mask = ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask | Button3MotionMask;
| Button1MotionMask | Button2MotionMask | Button3MotionMask;
scrollbar_calc_size(width, height); scrollbar_calc_size(width, height);
scrollbar.anchor_top = scrollbar.scrollarea_start; scrollbar.anchor_top = scrollbar.scrollarea_start;
scrollbar.anchor_bottom = scrollbar.scrollarea_end; scrollbar.anchor_bottom = scrollbar.scrollarea_end;
@ -725,8 +719,7 @@ scrollbar_init(int width, int height)
/* The anchor window */ /* The anchor window */
scrollbar.sa_win = scrollbar.sa_win =
XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar.anchor_top, scrollbar_anchor_width(), XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar.anchor_top, scrollbar_anchor_width(),
scrollbar_anchor_height(), 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWColormap, scrollbar_anchor_height(), 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWColormap, &Attributes);
&Attributes);
XSelectInput(Xdisplay, scrollbar.sa_win, mask); XSelectInput(Xdisplay, scrollbar.sa_win, mask);
XMapWindow(Xdisplay, scrollbar.sa_win); XMapWindow(Xdisplay, scrollbar.sa_win);
D_SCROLLBAR(("Created scrollbar anchor window 0x%08x\n", scrollbar.sa_win)); D_SCROLLBAR(("Created scrollbar anchor window 0x%08x\n", scrollbar.sa_win));
@ -776,6 +769,11 @@ void
scrollbar_calc_size(int width, int height) scrollbar_calc_size(int width, int height)
{ {
D_SCROLLBAR(("scrollbar_calc_size(%d, %d), type == %u\n", width, height, scrollbar_get_type())); D_SCROLLBAR(("scrollbar_calc_size(%d, %d), type == %u\n", width, height, scrollbar_get_type()));
#ifdef ESCREEN
if (TermWin.screen && TermWin.screen->backend != NS_MODE_NONE) {
UPPER_BOUND(height, Height2Pixel(TermWin.nrow));
}
#endif
scrollbar.scrollarea_start = 0; scrollbar.scrollarea_start = 0;
scrollbar.scrollarea_end = height; scrollbar.scrollarea_end = height;
scrollbar.up_arrow_loc = 0; scrollbar.up_arrow_loc = 0;
@ -800,8 +798,7 @@ scrollbar_calc_size(int width, int height)
scrollbar.height = height - (2 * scrollbar_get_shadow()); scrollbar.height = height - (2 * scrollbar_get_shadow());
scrollbar.win_width = scrollbar.width + (2 * scrollbar_get_shadow()); scrollbar.win_width = scrollbar.width + (2 * scrollbar_get_shadow());
scrollbar.win_height = height; scrollbar.win_height = height;
D_X11((" -> New scrollbar width/height == %hux%hu, win_width/height == %hux%hu\n", scrollbar.width, scrollbar.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.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, 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)); scrollbar.scrollarea_end, scrollbar.up_arrow_loc, scrollbar.down_arrow_loc));
} }
@ -816,8 +813,7 @@ scrollbar_resize(int width, int height)
D_SCROLLBAR(("scrollbar_resize(%d, %d)\n", width, height)); D_SCROLLBAR(("scrollbar_resize(%d, %d)\n", width, height));
scrollbar_calc_size(width, height); scrollbar_calc_size(width, height);
D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, y, %d, %d)\n", scrollbar.win, D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, y, %d, %d)\n", scrollbar.win,
((Options & Opt_scrollbar_right) ? (width - scrollbar_trough_width()) : (0)), scrollbar_trough_width(), ((Options & Opt_scrollbar_right) ? (width - scrollbar_trough_width()) : (0)), scrollbar_trough_width(), scrollbar.win_height));
scrollbar.win_height));
XMoveResizeWindow(Xdisplay, scrollbar.win, ((Options & Opt_scrollbar_right) ? (width - scrollbar_trough_width()) : (0)), XMoveResizeWindow(Xdisplay, scrollbar.win, ((Options & Opt_scrollbar_right) ? (width - scrollbar_trough_width()) : (0)),
bbar_calc_docked_height(BBAR_DOCKED_TOP), scrollbar_trough_width(), scrollbar.win_height); bbar_calc_docked_height(BBAR_DOCKED_TOP), scrollbar_trough_width(), scrollbar.win_height);
scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK); scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK);

View File

@ -76,7 +76,8 @@ eterm_bootstrap(int argc, char *argv[])
int i; int i;
char *val; char *val;
static char windowid_string[20], *display_string, *term_string; /* "WINDOWID=\0" = 10 chars, UINT_MAX = 10 chars */ static char windowid_string[20], *display_string, *term_string; /* "WINDOWID=\0" = 10 chars, UINT_MAX = 10 chars */
orig_argv0 = argv[0]; orig_argv0 = argv[0];
/* Security enhancements -- mej */ /* Security enhancements -- mej */
@ -156,8 +157,7 @@ eterm_bootstrap(int argc, char *argv[])
sprintf(tmp, "ETERM_THEME_ROOT=%s", theme_dir); sprintf(tmp, "ETERM_THEME_ROOT=%s", theme_dir);
putenv(tmp); putenv(tmp);
} }
if ((user_dir = conf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG), if ((user_dir = conf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG), (PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME))) != NULL) {
(PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME))) != NULL) {
char *tmp; char *tmp;
D_OPTIONS(("conf_parse_theme() returned \"%s\"\n", user_dir)); D_OPTIONS(("conf_parse_theme() returned \"%s\"\n", user_dir));
@ -172,7 +172,7 @@ eterm_bootstrap(int argc, char *argv[])
len = strlen(initial_dir); len = strlen(initial_dir);
if (rs_path) { if (rs_path) {
len += strlen(rs_path) + 1; /* +1 for the colon */ len += strlen(rs_path) + 1; /* +1 for the colon */
} }
if (theme_dir) { if (theme_dir) {
len += strlen(theme_dir) + 1; len += strlen(theme_dir) + 1;
@ -204,15 +204,6 @@ eterm_bootstrap(int argc, char *argv[])
p = p ? (p + 1) : orig_argv0; p = p ? (p + 1) : orig_argv0;
if (rs_url || !strncasecmp(ESCREEN_PREFIX, p, strlen(ESCREEN_PREFIX))) if (rs_url || !strncasecmp(ESCREEN_PREFIX, p, strlen(ESCREEN_PREFIX)))
TermWin.screen_mode = NS_MODE_SCREEN; TermWin.screen_mode = NS_MODE_SCREEN;
# ifdef NS_DEBUG
if (!strncasecmp(ESCREEN_PREFIX, p, strlen(ESCREEN_PREFIX)))
fputs("You called me \"Escreen\"!\n", stderr);
else if (!strncasecmp(ETERM_PREFIX, p, strlen(ETERM_PREFIX)))
fputs("You called me \"Eterm\"!\n", stderr);
else
fputs("Stop calling me funky names!\n", stderr);
fprintf(stderr, "Escreen mode is %d (%d rows, URL is \"%s\")\n", TermWin.screen_mode, TermWin.nrow, rs_url);
# endif
} }
#endif #endif

View File

@ -56,7 +56,7 @@ wait_for_chld(int system_pid)
/* If the child that exited is the command we spawned, or if the /* If the child that exited is the command we spawned, or if the
child exited before fork() returned in the parent, it must be child exited before fork() returned in the parent, it must be
our immediate child that exited. We exit gracefully. */ our immediate child that exited. We exit gracefully. */
if ((pid == -1) && (errno == ECHILD)) { /* No children exist. Punt. */ if ((pid == -1) && (errno == ECHILD)) { /* No children exist. Punt. */
errno = save_errno; errno = save_errno;
break; break;
} }

View File

@ -58,7 +58,7 @@ unsigned char meta_char = 033; /* Alt-key prefix */
unsigned long PrivateModes = PrivMode_Default; unsigned long PrivateModes = PrivMode_Default;
unsigned long SavedModes = PrivMode_Default; unsigned long SavedModes = PrivMode_Default;
char *def_colorName[] = { char *def_colorName[] = {
"rgb:aa/aa/aa", "rgb:0/0/0", /* fg/bg */ "rgb:aa/aa/aa", "rgb:0/0/0", /* fg/bg */
"rgb:0/0/0", /* 0: black (#000000) */ "rgb:0/0/0", /* 0: black (#000000) */
#ifndef NO_BRIGHTCOLOR #ifndef NO_BRIGHTCOLOR
/* low-intensity colors */ /* low-intensity colors */
@ -200,6 +200,7 @@ lookup_key(XEvent * ev)
static int numlock_state = 0; static int numlock_state = 0;
int ctrl, meta, shft, len; int ctrl, meta, shft, len;
KeySym keysym; KeySym keysym;
#ifdef USE_XIM #ifdef USE_XIM
int valid_keysym = 0; int valid_keysym = 0;
static unsigned char short_buf[256]; static unsigned char short_buf[256];
@ -244,15 +245,13 @@ lookup_key(XEvent * ev)
} else { } else {
/* No XIM input context. Do it the normal way. */ /* No XIM input context. Do it the normal way. */
len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(short_buf), &keysym, NULL); len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(short_buf), &keysym, NULL);
D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len)));
len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len)));
valid_keysym = 1; valid_keysym = 1;
} }
#else /* USE_XIM */ #else /* USE_XIM */
/* Translate the key event into its corresponding string according to X. This also gets us a keysym. */ /* Translate the key event into its corresponding string according to X. This also gets us a keysym. */
len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, NULL); len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, NULL);
D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len)));
len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len)));
/* If there is no string and it's a Latin2-7 character, replace it with the Latin1 character instead. */ /* If there is no string and it's a Latin2-7 character, replace it with the Latin1 character instead. */
if (!len && (keysym >= 0x0100) && (keysym < 0x0900)) { if (!len && (keysym >= 0x0100) && (keysym < 0x0900)) {
@ -262,6 +261,7 @@ lookup_key(XEvent * ev)
#endif /* USE_XIM */ #endif /* USE_XIM */
#ifdef ESCREEN #ifdef ESCREEN
# ifdef NS_HAVE_SCREEN
if (escreen_escape) { if (escreen_escape) {
if (kbuf[0]) { if (kbuf[0]) {
escreen_escape = 0; escreen_escape = 0;
@ -273,6 +273,7 @@ lookup_key(XEvent * ev)
escreen_escape = 1; escreen_escape = 1;
LK_RET(); LK_RET();
} }
# endif
#endif #endif
#ifdef USE_XIM #ifdef USE_XIM
@ -338,31 +339,31 @@ lookup_key(XEvent * ev)
shft = 0; shft = 0;
} else if (!ctrl && !meta && (PrivateModes & PrivMode_ShiftKeys)) { } else if (!ctrl && !meta && (PrivateModes & PrivMode_ShiftKeys)) {
switch (keysym) { switch (keysym) {
case XK_Prior: /* Shift-PgUp scrolls up a page */ case XK_Prior: /* Shift-PgUp scrolls up a page */
if (TermWin.saveLines) { if (TermWin.saveLines) {
scr_page(UP, (TermWin.nrow - CONTEXT_LINES)); scr_page(UP, (TermWin.nrow - CONTEXT_LINES));
LK_RET(); LK_RET();
} }
break; break;
case XK_Next: /* Shift-PgDn scrolls down a page */ case XK_Next: /* Shift-PgDn scrolls down a page */
if (TermWin.saveLines) { if (TermWin.saveLines) {
scr_page(DN, (TermWin.nrow - CONTEXT_LINES)); scr_page(DN, (TermWin.nrow - CONTEXT_LINES));
LK_RET(); LK_RET();
} }
break; break;
case XK_Insert: /* Shift-Ins pastes the current selection. */ case XK_Insert: /* Shift-Ins pastes the current selection. */
selection_paste(XA_PRIMARY); selection_paste(XA_PRIMARY);
LK_RET(); LK_RET();
break; break;
case XK_KP_Add: /* Shift-Plus on the keypad increases the font size */ case XK_KP_Add: /* Shift-Plus on the keypad increases the font size */
change_font(0, BIGGER_FONT); change_font(0, BIGGER_FONT);
LK_RET(); LK_RET();
break; break;
case XK_KP_Subtract: /* Shift-Minus on the keypad decreases the font size */ case XK_KP_Subtract: /* Shift-Minus on the keypad decreases the font size */
change_font(0, SMALLER_FONT); change_font(0, SMALLER_FONT);
LK_RET(); LK_RET();
break; break;
@ -495,13 +496,13 @@ lookup_key(XEvent * ev)
break; break;
#ifdef XK_KP_Left #ifdef XK_KP_Left
case XK_KP_Left: /* \033Ot or standard cursor key */ case XK_KP_Left: /* \033Ot or standard cursor key */
case XK_KP_Up: /* \033Ox or standard cursor key */ case XK_KP_Up: /* \033Ox or standard cursor key */
case XK_KP_Right: /* \033Ov or standard cursor key */ case XK_KP_Right: /* \033Ov or standard cursor key */
case XK_KP_Down: /* \033Or or standard cursor key */ case XK_KP_Down: /* \033Or or standard cursor key */
if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
len = 3; len = 3;
strcpy(kbuf, "\033OZ"); /* The Z is replaced by t, x, v, or r */ strcpy(kbuf, "\033OZ"); /* The Z is replaced by t, x, v, or r */
kbuf[2] = ("txvr"[keysym - XK_KP_Left]); kbuf[2] = ("txvr"[keysym - XK_KP_Left]);
break; break;
} else { } else {
@ -509,16 +510,16 @@ lookup_key(XEvent * ev)
} }
/* Continue on with the normal cursor keys... */ /* Continue on with the normal cursor keys... */
#endif #endif
case XK_Left: /* "\033[D" */ case XK_Left: /* "\033[D" */
case XK_Up: /* "\033[A" */ case XK_Up: /* "\033[A" */
case XK_Right: /* "\033[C" */ case XK_Right: /* "\033[C" */
case XK_Down: /* "\033[B" */ case XK_Down: /* "\033[B" */
len = 3; len = 3;
strcpy(kbuf, "\033[@"); strcpy(kbuf, "\033[@");
kbuf[2] = ("DACB"[keysym - XK_Left]); kbuf[2] = ("DACB"[keysym - XK_Left]);
if (PrivateModes & PrivMode_aplCUR) { if (PrivateModes & PrivMode_aplCUR) {
kbuf[1] = 'O'; kbuf[1] = 'O';
} else if (shft) { /* do Shift first */ } else if (shft) { /* do Shift first */
kbuf[2] = ("dacb"[keysym - XK_Left]); kbuf[2] = ("dacb"[keysym - XK_Left]);
} else if (ctrl) { } else if (ctrl) {
kbuf[1] = 'O'; kbuf[1] = 'O';
@ -658,31 +659,31 @@ lookup_key(XEvent * ev)
break; break;
#endif /* XK_KP_Begin */ #endif /* XK_KP_Begin */
case XK_KP_F1: /* "\033OP" */ case XK_KP_F1: /* "\033OP" */
case XK_KP_F2: /* "\033OQ" */ case XK_KP_F2: /* "\033OQ" */
case XK_KP_F3: /* "\033OR" */ case XK_KP_F3: /* "\033OR" */
case XK_KP_F4: /* "\033OS" */ case XK_KP_F4: /* "\033OS" */
len = 3; len = 3;
strcpy(kbuf, "\033OP"); strcpy(kbuf, "\033OP");
kbuf[2] += (keysym - XK_KP_F1); kbuf[2] += (keysym - XK_KP_F1);
break; break;
case XK_KP_Multiply: /* "\033Oj" : "*" */ case XK_KP_Multiply: /* "\033Oj" : "*" */
case XK_KP_Add: /* "\033Ok" : "+" */ case XK_KP_Add: /* "\033Ok" : "+" */
case XK_KP_Separator: /* "\033Ol" : "," */ case XK_KP_Separator: /* "\033Ol" : "," */
case XK_KP_Subtract: /* "\033Om" : "-" */ case XK_KP_Subtract: /* "\033Om" : "-" */
case XK_KP_Decimal: /* "\033On" : "." */ case XK_KP_Decimal: /* "\033On" : "." */
case XK_KP_Divide: /* "\033Oo" : "/" */ case XK_KP_Divide: /* "\033Oo" : "/" */
case XK_KP_0: /* "\033Op" : "0" */ case XK_KP_0: /* "\033Op" : "0" */
case XK_KP_1: /* "\033Oq" : "1" */ case XK_KP_1: /* "\033Oq" : "1" */
case XK_KP_2: /* "\033Or" : "2" */ case XK_KP_2: /* "\033Or" : "2" */
case XK_KP_3: /* "\033Os" : "3" */ case XK_KP_3: /* "\033Os" : "3" */
case XK_KP_4: /* "\033Ot" : "4" */ case XK_KP_4: /* "\033Ot" : "4" */
case XK_KP_5: /* "\033Ou" : "5" */ case XK_KP_5: /* "\033Ou" : "5" */
case XK_KP_6: /* "\033Ov" : "6" */ case XK_KP_6: /* "\033Ov" : "6" */
case XK_KP_7: /* "\033Ow" : "7" */ case XK_KP_7: /* "\033Ow" : "7" */
case XK_KP_8: /* "\033Ox" : "8" */ case XK_KP_8: /* "\033Ox" : "8" */
case XK_KP_9: /* "\033Oy" : "9" */ case XK_KP_9: /* "\033Oy" : "9" */
/* allow shift to override */ /* allow shift to override */
if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) {
len = 3; len = 3;
@ -811,8 +812,7 @@ sprintf((char *) kbuf,"\033[%02d~", (int)((n) + (keysym - fkey))); \
tt_write(&ch, 1); tt_write(&ch, 1);
} }
D_TTY(("After handling: len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", D_TTY(("After handling: len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len)));
len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len)));
tt_write(kbuf, len); /* Send the resulting string to the child process */ tt_write(kbuf, len); /* Send the resulting string to the child process */
LK_RET(); LK_RET();
@ -923,8 +923,8 @@ process_escape_seq(void)
scr_add_lines((unsigned char *) "\n\r", 1, 2); scr_add_lines((unsigned char *) "\n\r", 1, 2);
break; break;
case 'G': case 'G':
if ((ch = cmd_getc()) == 'Q') { /* query graphics */ if ((ch = cmd_getc()) == 'Q') { /* query graphics */
tt_printf((unsigned char *) "\033G0\n"); /* no graphics */ tt_printf((unsigned char *) "\033G0\n"); /* no graphics */
} else { } else {
do { do {
ch = cmd_getc(); ch = cmd_getc();
@ -992,7 +992,7 @@ process_csi_seq(void)
cmd_ungetc(); /* New escape sequence starting in the middle of one. Punt. */ cmd_ungetc(); /* New escape sequence starting in the middle of one. Punt. */
return; return;
} else if (ch < ' ') { } else if (ch < ' ') {
scr_add_lines(&ch, 0, 1); /* Insert verbatim non-printable character (NPC) */ scr_add_lines(&ch, 0, 1); /* Insert verbatim non-printable character (NPC) */
return; return;
} }
if (ch == '-') /* HACK: Ignore this sequence, but finish reading */ if (ch == '-') /* HACK: Ignore this sequence, but finish reading */
@ -1093,7 +1093,7 @@ process_csi_seq(void)
/* TODO: A different response should be sent depending on the value of /* TODO: A different response should be sent depending on the value of
priv and of arg[0], but what should those reponses be? */ priv and of arg[0], but what should those reponses be? */
#ifndef NO_VT100_ANS #ifndef NO_VT100_ANS
tt_printf(VT100_ANS); tt_printf((unsigned char *) VT100_ANS);
#endif #endif
break; break;
case 'd': /* Cursor to row n "\e[<n>d" */ case 'd': /* Cursor to row n "\e[<n>d" */
@ -1113,10 +1113,10 @@ process_csi_seq(void)
case 'i': case 'i':
switch (arg[0]) { switch (arg[0]) {
case 0: case 0:
scr_printscreen(0); /* Print screen "\e[0i" */ scr_printscreen(0); /* Print screen "\e[0i" */
break; break;
case 5: case 5:
process_print_pipe(); /* Start printing to print pipe "\e[5i" */ process_print_pipe(); /* Start printing to print pipe "\e[5i" */
break; break;
} }
break; break;
@ -1373,8 +1373,7 @@ process_window_mode(unsigned int nargs, int args[])
BOUND(y, 1, scr->height / TermWin.fheight); BOUND(y, 1, scr->height / TermWin.fheight);
BOUND(x, 1, scr->width / TermWin.fwidth); BOUND(x, 1, scr->width / TermWin.fwidth);
XResizeWindow(Xdisplay, TermWin.parent, XResizeWindow(Xdisplay, TermWin.parent,
Width2Pixel(x) + 2 * TermWin.internalBorder + (scrollbar_is_visible()? scrollbar_trough_width() : 0), Width2Pixel(x) + 2 * TermWin.internalBorder + (scrollbar_is_visible()? scrollbar_trough_width() : 0), Height2Pixel(y) + 2 * TermWin.internalBorder);
Height2Pixel(y) + 2 * TermWin.internalBorder);
break; break;
case 11: case 11:
break; break;
@ -1385,8 +1384,7 @@ process_window_mode(unsigned int nargs, int args[])
break; break;
case 14: case 14:
/* Store current width and height in x and y */ /* Store current width and height in x and y */
XGetGeometry(Xdisplay, TermWin.parent, &dummy_child, &dummy_x, &dummy_y, (unsigned int *) (&x), (unsigned int *) (&y), XGetGeometry(Xdisplay, TermWin.parent, &dummy_child, &dummy_x, &dummy_y, (unsigned int *) (&x), (unsigned int *) (&y), &dummy_border, &dummy_depth);
&dummy_border, &dummy_depth);
snprintf(buff, sizeof(buff), "\033[4;%d;%dt", y, x); snprintf(buff, sizeof(buff), "\033[4;%d;%dt", y, x);
tt_write((unsigned char *) buff, strlen(buff)); tt_write((unsigned char *) buff, strlen(buff));
break; break;
@ -1536,6 +1534,7 @@ process_terminal_mode(int mode, int priv, unsigned int nargs, int arg[])
case 1001: case 1001:
break; /* X11 mouse highlighting */ break; /* X11 mouse highlighting */
#endif #endif
case 1010: /* Scroll to bottom on TTY output */ case 1010: /* Scroll to bottom on TTY output */
if (Options & Opt_home_on_output) if (Options & Opt_home_on_output)
Options &= ~Opt_home_on_output; Options &= ~Opt_home_on_output;
@ -1803,6 +1802,7 @@ xterm_seq(int op, const char *str)
char *nstr, *tnstr, *valptr; char *nstr, *tnstr, *valptr;
unsigned char eterm_seq_op; unsigned char eterm_seq_op;
XWMHints *wm_hints; XWMHints *wm_hints;
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
unsigned char changed = 0, scaled = 0, which = 0; unsigned char changed = 0, scaled = 0, which = 0;
char *color, *mod, *orig_tnstr; char *color, *mod, *orig_tnstr;
@ -1949,7 +1949,7 @@ xterm_seq(int op, const char *str)
free_desktop_pixmap(); free_desktop_pixmap();
} else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { } else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) {
LIBAST_X_FREE_PIXMAP(viewport_pixmap); LIBAST_X_FREE_PIXMAP(viewport_pixmap);
viewport_pixmap = None; /* Force the re-read */ viewport_pixmap = None; /* Force the re-read */
} }
# endif # endif
changed = 1; changed = 1;
@ -1958,15 +1958,14 @@ xterm_seq(int op, const char *str)
if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) {
break; break;
} }
D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n", mod, color, D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n", mod, color, get_image_type(which), valptr));
get_image_type(which), valptr));
changed = 1; changed = 1;
# ifdef PIXMAP_OFFSET # ifdef PIXMAP_OFFSET
if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) {
free_desktop_pixmap(); free_desktop_pixmap();
} else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { } else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) {
LIBAST_X_FREE_PIXMAP(viewport_pixmap); LIBAST_X_FREE_PIXMAP(viewport_pixmap);
viewport_pixmap = None; /* Force the re-read */ viewport_pixmap = None; /* Force the re-read */
} }
# endif # endif
if (!strcasecmp(color, "image")) { if (!strcasecmp(color, "image")) {
@ -2307,8 +2306,7 @@ xterm_seq(int op, const char *str)
xev.message_type = props[PROP_DESKTOP]; xev.message_type = props[PROP_DESKTOP];
xev.format = 32; xev.format = 32;
xev.data.l[0] = rs_desktop; xev.data.l[0] = rs_desktop;
XChangeProperty(Xdisplay, TermWin.parent, xev.message_type, XA_CARDINAL, 32, PropModeReplace, XChangeProperty(Xdisplay, TermWin.parent, xev.message_type, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &rs_desktop, 1);
(unsigned char *) &rs_desktop, 1);
XSendEvent(Xdisplay, Xroot, False, SubstructureNotifyMask, (XEvent *) & xev); XSendEvent(Xdisplay, Xroot, False, SubstructureNotifyMask, (XEvent *) & xev);
} }
break; break;

View File

@ -62,8 +62,7 @@ timer_add(unsigned long msec, timer_handler_t handler, void *data)
timer->handler = handler; timer->handler = handler;
timer->data = data; timer->data = data;
timer->next = NULL; timer->next = NULL;
D_TIMER(("Added timer. Timer set to %lu/%lu with handler %8p and data %8p\n", timer->time.tv_sec, timer->time.tv_usec, timer->handler, D_TIMER(("Added timer. Timer set to %lu/%lu with handler %8p and data %8p\n", timer->time.tv_sec, timer->time.tv_usec, timer->handler, timer->data));
timer->data));
return ((timerhdl_t) timer); return ((timerhdl_t) timer);
} }

View File

@ -93,6 +93,7 @@ void
add_utmp_entry(const char *pty, const char *hostname, int fd) add_utmp_entry(const char *pty, const char *hostname, int fd)
{ {
struct passwd *pwent = getpwuid(my_ruid); struct passwd *pwent = getpwuid(my_ruid);
# ifdef HAVE_UTMPX_H # ifdef HAVE_UTMPX_H
struct utmpx utmp; struct utmpx utmp;
struct utmp utmp2; struct utmp utmp2;
@ -109,12 +110,12 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
if (!strncmp(pty, "/dev/", 5)) if (!strncmp(pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */ pty += 5; /* skip /dev/ prefix */
if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3)) if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */ strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
else { else {
int n; int n;
if (sscanf(pty, "pts/%d", &n) == 1) if (sscanf(pty, "pts/%d", &n) == 1)
sprintf(ut_id, "vt%02x", n); /* sysv naming */ sprintf(ut_id, "vt%02x", n); /* sysv naming */
else { else {
print_error("can't parse tty name \"%s\"\n", pty); print_error("can't parse tty name \"%s\"\n", pty);
ut_id[0] = '\0'; /* entry not made */ ut_id[0] = '\0'; /* entry not made */
@ -340,7 +341,7 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
if (!strncmp(pty, "/dev/", 5)) if (!strncmp(pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */ pty += 5; /* skip /dev/ prefix */
if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3)) if (!strncmp(pty, "pty", 3) || !strncmp(pty, "tty", 3))
strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */ strncpy(ut_id, (pty + 3), sizeof(ut_id)); /* bsd naming */
else { else {
print_error("can't parse tty name \"%s\"\n", pty); print_error("can't parse tty name \"%s\"\n", pty);
ut_id[0] = '\0'; /* entry not made */ ut_id[0] = '\0'; /* entry not made */

View File

@ -144,8 +144,7 @@ get_bottom_shadow_color(Pixel norm_color, const char *type)
xcol.blue /= 2; xcol.blue /= 2;
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red, print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red, xcol.green, xcol.blue);
xcol.green, xcol.blue);
xcol.pixel = PixColors[minColor]; xcol.pixel = PixColors[minColor];
} }
return (xcol.pixel); return (xcol.pixel);
@ -177,8 +176,7 @@ get_top_shadow_color(Pixel norm_color, const char *type)
xcol.blue = MIN(white.blue, (xcol.blue * 7) / 5); xcol.blue = MIN(white.blue, (xcol.blue * 7) / 5);
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red, print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red, xcol.green, xcol.blue);
xcol.green, xcol.blue);
xcol.pixel = PixColors[WhiteColor]; xcol.pixel = PixColors[WhiteColor];
} }
return (xcol.pixel); return (xcol.pixel);
@ -208,9 +206,7 @@ get_color_by_name(const char *name, const char *fallback)
name = fallback; name = fallback;
if (name) { if (name) {
if (!XParseColor(Xdisplay, cmap, name, &xcol)) { if (!XParseColor(Xdisplay, cmap, name, &xcol)) {
print_warning print_warning("Unable to resolve \"%s\" as a color name. This should never fail. Please repair/restore your RGB database.\n", name);
("Unable to resolve \"%s\" as a color name. This should never fail. Please repair/restore your RGB database.\n",
name);
return ((Pixel) - 1); return ((Pixel) - 1);
} }
} else { } else {
@ -223,8 +219,7 @@ get_color_by_name(const char *name, const char *fallback)
name = fallback; name = fallback;
if (name) { if (name) {
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", name, xcol.pixel, xcol.red, print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", name, xcol.pixel, xcol.red, xcol.green, xcol.blue);
xcol.green, xcol.blue);
return ((Pixel) - 1); return ((Pixel) - 1);
} }
} else { } else {
@ -249,12 +244,10 @@ get_color_by_pixel(Pixel pixel, Pixel fallback)
} }
} }
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on 0x%08x.\n", xcol.pixel, print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on 0x%08x.\n", xcol.pixel, xcol.red, xcol.green, xcol.blue, fallback);
xcol.red, xcol.green, xcol.blue, fallback);
xcol.pixel = fallback; xcol.pixel = fallback;
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map.\n", xcol.pixel, xcol.red, xcol.green, print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map.\n", xcol.pixel, xcol.red, xcol.green, xcol.blue);
xcol.blue);
return ((Pixel) 0); return ((Pixel) 0);
} }
} }
@ -299,7 +292,7 @@ process_colors(void)
break; break;
#endif #endif
default: default:
pixel = PixColors[fgColor]; /* None */ pixel = PixColors[fgColor]; /* None */
break; break;
} }
} }
@ -323,8 +316,7 @@ process_colors(void)
PixColors[unfocusedTopShadowColor] = get_top_shadow_color(images[image_sb].disabled->bg, "unfocusedTopShadowColor"); PixColors[unfocusedTopShadowColor] = get_top_shadow_color(images[image_sb].disabled->bg, "unfocusedTopShadowColor");
PixColors[menuBottomShadowColor] = get_bottom_shadow_color(images[image_menu].norm->bg, "menuBottomShadowColor"); PixColors[menuBottomShadowColor] = get_bottom_shadow_color(images[image_menu].norm->bg, "menuBottomShadowColor");
PixColors[unfocusedMenuBottomShadowColor] = PixColors[unfocusedMenuBottomShadowColor] = get_bottom_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuBottomShadowColor");
get_bottom_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuBottomShadowColor");
PixColors[menuTopShadowColor] = get_top_shadow_color(images[image_menu].norm->bg, "menuTopShadowColor"); PixColors[menuTopShadowColor] = get_top_shadow_color(images[image_menu].norm->bg, "menuTopShadowColor");
PixColors[unfocusedMenuTopShadowColor] = get_top_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuTopShadowColor"); PixColors[unfocusedMenuTopShadowColor] = get_top_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuTopShadowColor");
} }
@ -360,8 +352,7 @@ Create_Windows(int argc, char *argv[])
} }
Attributes.colormap = cmap; Attributes.colormap = cmap;
szHint.base_width = szHint.base_width = (2 * TermWin.internalBorder + ((Options & Opt_scrollbar) ? (scrollbar_get_width() + (2 * scrollbar_get_shadow())) : 0));
(2 * TermWin.internalBorder + ((Options & Opt_scrollbar) ? (scrollbar_get_width() + (2 * scrollbar_get_shadow())) : 0));
szHint.base_height = (2 * TermWin.internalBorder) + bbar_calc_docked_height(BBAR_DOCKED); szHint.base_height = (2 * TermWin.internalBorder) + bbar_calc_docked_height(BBAR_DOCKED);
flags = (rs_geometry ? XParseGeometry(rs_geometry, &x, &y, &width, &height) : 0); flags = (rs_geometry ? XParseGeometry(rs_geometry, &x, &y, &width, &height) : 0);
@ -401,8 +392,7 @@ Create_Windows(int argc, char *argv[])
Attributes.background_pixel = PixColors[bgColor]; Attributes.background_pixel = PixColors[bgColor];
Attributes.border_pixel = PixColors[bgColor]; Attributes.border_pixel = PixColors[bgColor];
D_X11(("Size Hints: x %d, y %d. Width/Height: Base %dx%d, Minimum %dx%d, Current %dx%d, Increment %dx%d\n", D_X11(("Size Hints: x %d, y %d. Width/Height: Base %dx%d, Minimum %dx%d, Current %dx%d, Increment %dx%d\n",
szHint.x, szHint.y, szHint.base_width, szHint.base_height, szHint.min_width, szHint.min_height, szHint.x, szHint.y, szHint.base_width, szHint.base_height, szHint.min_width, szHint.min_height, szHint.width, szHint.height, szHint.width_inc, szHint.height_inc));
szHint.width, szHint.height, szHint.width_inc, szHint.height_inc));
TermWin.parent = XCreateWindow(Xdisplay, Xroot, szHint.x, szHint.y, szHint.width, szHint.height, 0, Xdepth, InputOutput, TermWin.parent = XCreateWindow(Xdisplay, Xroot, szHint.x, szHint.y, szHint.width, szHint.height, 0, Xdepth, InputOutput,
#ifdef PREFER_24BIT #ifdef PREFER_24BIT
Xvisual, Xvisual,
@ -426,8 +416,7 @@ Create_Windows(int argc, char *argv[])
XSetWMProperties(Xdisplay, TermWin.parent, NULL, NULL, argv, argc, &szHint, &wmHint, &classHint); XSetWMProperties(Xdisplay, TermWin.parent, NULL, NULL, argv, argc, &szHint, &wmHint, &classHint);
XSelectInput(Xdisplay, Xroot, PropertyChangeMask); XSelectInput(Xdisplay, Xroot, PropertyChangeMask);
XSelectInput(Xdisplay, TermWin.parent, XSelectInput(Xdisplay, TermWin.parent, (KeyPressMask | FocusChangeMask | StructureNotifyMask | VisibilityChangeMask | PropertyChangeMask));
(KeyPressMask | FocusChangeMask | StructureNotifyMask | VisibilityChangeMask | PropertyChangeMask));
if (mwmhints.flags) { if (mwmhints.flags) {
prop = XInternAtom(Xdisplay, "_MOTIF_WM_HINTS", False); prop = XInternAtom(Xdisplay, "_MOTIF_WM_HINTS", False);
XChangeProperty(Xdisplay, TermWin.parent, prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS); XChangeProperty(Xdisplay, TermWin.parent, prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS);
@ -449,20 +438,17 @@ Create_Windows(int argc, char *argv[])
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
/* the vt window */ /* the vt window */
TermWin.x = TermWin.x = (((Options & Opt_scrollbar) && !(Options & Opt_scrollbar_right)) ? (scrollbar_get_width() + (2 * scrollbar_get_shadow())) : 0);
(((Options & Opt_scrollbar) && !(Options & Opt_scrollbar_right)) ? (scrollbar_get_width() + (2 * scrollbar_get_shadow())) : 0);
TermWin.y = bbar_calc_docked_height(BBAR_DOCKED_TOP); TermWin.y = bbar_calc_docked_height(BBAR_DOCKED_TOP);
TermWin.vt = TermWin.vt = XCreateWindow(Xdisplay, TermWin.parent, TermWin.x, TermWin.y, szHint.width, szHint.height, 0, Xdepth, InputOutput, CopyFromParent,
XCreateWindow(Xdisplay, TermWin.parent, TermWin.x, TermWin.y, szHint.width, szHint.height, 0, Xdepth, InputOutput, CopyFromParent, CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWColormap, &Attributes);
CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWColormap, &Attributes);
D_X11(("Created terminal window 0x%08x at %dx%d\n", TermWin.vt, TermWin.x, TermWin.y)); D_X11(("Created terminal window 0x%08x at %dx%d\n", TermWin.vt, TermWin.x, TermWin.y));
if (!(background_is_pixmap()) && !(Options & Opt_borderless)) { if (!(background_is_pixmap()) && !(Options & Opt_borderless)) {
XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[bgColor]); XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[bgColor]);
XClearWindow(Xdisplay, TermWin.vt); XClearWindow(Xdisplay, TermWin.vt);
} }
XDefineCursor(Xdisplay, TermWin.vt, TermWin_cursor); XDefineCursor(Xdisplay, TermWin.vt, TermWin_cursor);
TermWin.mask = TermWin.mask = (EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask | Button3MotionMask);
(EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button3MotionMask);
XSelectInput(Xdisplay, TermWin.vt, TermWin.mask); XSelectInput(Xdisplay, TermWin.vt, TermWin.mask);
/* If the user wants a specific desktop, tell the WM that */ /* If the user wants a specific desktop, tell the WM that */
@ -562,15 +548,13 @@ update_size_hints(void)
szHint.width_inc = TermWin.fwidth; szHint.width_inc = TermWin.fwidth;
szHint.height_inc = TermWin.fheight; szHint.height_inc = TermWin.fheight;
D_X11(("Size Hints: base width/height == %lux%lu, width/height increment == %lux%lu\n", szHint.base_width, szHint.base_height, D_X11(("Size Hints: base width/height == %lux%lu, width/height increment == %lux%lu\n", szHint.base_width, szHint.base_height, szHint.width_inc, szHint.height_inc));
szHint.width_inc, szHint.height_inc));
szHint.min_width = szHint.base_width + szHint.width_inc; szHint.min_width = szHint.base_width + szHint.width_inc;
szHint.min_height = szHint.base_height + szHint.height_inc; szHint.min_height = szHint.base_height + szHint.height_inc;
szHint.width = szHint.base_width + TermWin.width; szHint.width = szHint.base_width + TermWin.width;
szHint.height = szHint.base_height + TermWin.height; szHint.height = szHint.base_height + TermWin.height;
D_X11((" Minimum width/height == %lux%lu, width/height == %lux%lu\n", D_X11((" Minimum width/height == %lux%lu, width/height == %lux%lu\n", szHint.min_width, szHint.min_height, szHint.width, szHint.height));
szHint.min_width, szHint.min_height, szHint.width, szHint.height));
szHint.flags = PMinSize | PResizeInc | PBaseSize; szHint.flags = PMinSize | PResizeInc | PBaseSize;
XSetWMNormalHints(Xdisplay, TermWin.parent, &szHint); XSetWMNormalHints(Xdisplay, TermWin.parent, &szHint);
@ -691,7 +675,7 @@ set_window_color(int idx, const char *color)
/* handle color aliases */ /* handle color aliases */
if (isdigit(*color)) { if (isdigit(*color)) {
i = atoi(color); i = atoi(color);
if (i >= 8 && i <= 15) { /* bright colors */ if (i >= 8 && i <= 15) { /* bright colors */
i -= 8; i -= 8;
# ifndef NO_BRIGHTCOLOR # ifndef NO_BRIGHTCOLOR
PixColors[idx] = PixColors[minBright + i]; PixColors[idx] = PixColors[minBright + i];

View File

@ -55,8 +55,7 @@ set_pixmap_property(Pixmap p)
if (prop_root != None && prop_esetroot != None) { if (prop_root != None && prop_esetroot != None) {
XGetWindowProperty(Xdisplay, Xroot, prop_root, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_root); XGetWindowProperty(Xdisplay, Xroot, prop_root, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_root);
if (type == XA_PIXMAP) { if (type == XA_PIXMAP) {
XGetWindowProperty(Xdisplay, Xroot, prop_esetroot, 0L, 1L, False, AnyPropertyType, XGetWindowProperty(Xdisplay, Xroot, prop_esetroot, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_esetroot);
&type, &format, &length, &after, &data_esetroot);
if (data_root && data_esetroot) { if (data_root && data_esetroot) {
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): data_root == 0x%08x, data_esetroot == 0x%08x\n", __FILE__, fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): data_root == 0x%08x, data_esetroot == 0x%08x\n", __FILE__,
@ -64,8 +63,7 @@ set_pixmap_property(Pixmap p)
} }
if (type == XA_PIXMAP && *((Pixmap *) data_root) == *((Pixmap *) data_esetroot)) { if (type == XA_PIXMAP && *((Pixmap *) data_root) == *((Pixmap *) data_esetroot)) {
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): XKillClient() is being called.\n", __FILE__, __LINE__, fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): XKillClient() is being called.\n", __FILE__, __LINE__, (unsigned int) p);
(unsigned int) p);
} }
XKillClient(Xdisplay, *((Pixmap *) data_root)); XKillClient(Xdisplay, *((Pixmap *) data_root));
} }
@ -84,8 +82,7 @@ set_pixmap_property(Pixmap p)
XChangeProperty(Xdisplay, Xroot, prop_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1); XChangeProperty(Xdisplay, Xroot, prop_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
XChangeProperty(Xdisplay, Xroot, prop_esetroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1); XChangeProperty(Xdisplay, Xroot, prop_esetroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): _XROOTPMAP_ID and ESETROOT_PMAP_ID set to 0x%08x.\n", __FILE__, __LINE__, fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): _XROOTPMAP_ID and ESETROOT_PMAP_ID set to 0x%08x.\n", __FILE__, __LINE__, (unsigned int) p, (unsigned int) p);
(unsigned int) p, (unsigned int) p);
} }
XSetCloseDownMode(Xdisplay, RetainPermanent); XSetCloseDownMode(Xdisplay, RetainPermanent);
XFlush(Xdisplay); XFlush(Xdisplay);
@ -147,15 +144,13 @@ main(int argc, char *argv[])
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: Display name is \"%s\"\n", __FILE__, __LINE__, displayname ? displayname : "(nil)"); fprintf(stderr, "%s:%d: Display name is \"%s\"\n", __FILE__, __LINE__, displayname ? displayname : "(nil)");
fprintf(stderr, "%s:%d: Background color name is \"%s\"\n", __FILE__, __LINE__, bgcolor ? bgcolor : "(nil)"); fprintf(stderr, "%s:%d: Background color name is \"%s\"\n", __FILE__, __LINE__, bgcolor ? bgcolor : "(nil)");
fprintf(stderr, "%s:%d: Image will be %s\n", __FILE__, __LINE__, fprintf(stderr, "%s:%d: Image will be %s\n", __FILE__, __LINE__, scale ? "scaled" : (center ? "centered" : (fit ? "fit" : "tiled")));
scale ? "scaled" : (center ? "centered" : (fit ? "fit" : "tiled")));
fprintf(stderr, "%s:%d: Image file is %s\n", __FILE__, __LINE__, fname ? fname : "(nil)"); fprintf(stderr, "%s:%d: Image file is %s\n", __FILE__, __LINE__, fname ? fname : "(nil)");
} }
if (!displayname) { if (!displayname) {
displayname = getenv("DISPLAY"); displayname = getenv("DISPLAY");
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: Display name set to %s via getenv(\"DISPLAY\")\n", __FILE__, __LINE__, fprintf(stderr, "%s:%d: Display name set to %s via getenv(\"DISPLAY\")\n", __FILE__, __LINE__, displayname ? displayname : "(nil)");
displayname ? displayname : "(nil)");
} }
} }
if (!displayname) { if (!displayname) {

View File

@ -27,10 +27,10 @@ static const char cvs_ident[] = "$Id$";
#include <stdio.h> #include <stdio.h>
const char *lookup[] = { const char *lookup[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", /* 0-7 */ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", /* 0-7 */
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", /* 8-15 */ "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", /* 8-15 */
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", /* 16-23 */ "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", /* 16-23 */
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" /* 24-31 */ "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" /* 24-31 */
}; };
int int