diff --git a/ChangeLog b/ChangeLog index aa4a472..cc1d4bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2768,3 +2768,17 @@ Fri Nov 12 17:55:05 PST 1999 Michael Jennings now documented for the first time. ------------------------------------------------------------------------------- +Fri Nov 12 19:37:35 PST 1999 Michael Jennings + + Okay, I've fixed a lot here. First off, I fixed the bug Gnea + pointed out with toggling Max Size in E. + Turned out to be a symptom of a much larger problem, but it should be + fixed now. Then I corrected the XIM issues pointed out by Sung-Hyun + Nam and Jerome De Greef + , as well as a stupid typo on my part that + Jerome happened upon. Next I fixed the bug Adam Lucas + spotted with changing the scrollbar type. While + fixing that, I also fixed changing the scrollbar width. Both + operations are a lot smoother and cleaner now. + +------------------------------------------------------------------------------- diff --git a/src/command.c b/src/command.c index 0e4acda..5d25188 100644 --- a/src/command.c +++ b/src/command.c @@ -1785,6 +1785,8 @@ xim_destroy_cb(XIM xim, XPointer client_data, XPointer call_data) { Input_Context = NULL; XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, xim_instantiate_cb, NULL); + xim = NULL; + client_data = call_data = (XPointer) 0; } static void @@ -1794,6 +1796,8 @@ xim_instantiate_cb(Display *display, XPointer client_data, XPointer call_data) if (Input_Context) { XUnregisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, xim_instantiate_cb, NULL); } + display = NULL; + client_data = call_data = (XPointer) 0; } #endif @@ -1812,10 +1816,10 @@ xim_real_init(void) XVaNestedList preedit_attr = NULL; XVaNestedList status_attr = NULL; - REQUIRE(Input_Context == NULL); + REQUIRE_RVAL(Input_Context == NULL, -1); - if (rs_inputMethod && *rs_inputMethod) { - strncpy(tmp, rs_inputMethod, sizeof(tmp) - 1); + if (rs_input_method && *rs_input_method) { + strncpy(tmp, rs_input_method, sizeof(tmp) - 1); for (s = tmp; *s; s = next_s + 1) { for (; *s && isspace(*s); s++); if (!*s) { @@ -1873,7 +1877,7 @@ xim_real_init(void) XCloseIM(xim); return -1; } - strncpy(tmp, (rs_preeditType ? rs_preeditType : "OverTheSpot,OffTheSpot,Root"), sizeof(tmp) - 1); + strncpy(tmp, (rs_preedit_type ? rs_preedit_type : "OverTheSpot,OffTheSpot,Root"), sizeof(tmp) - 1); for (found = 0, s = tmp; *s && !found; s = next_s + 1) { unsigned short i; diff --git a/src/events.c b/src/events.c index 7531242..192e9c6 100644 --- a/src/events.c +++ b/src/events.c @@ -426,8 +426,8 @@ handle_configure_notify(event_t * ev) int x = ev->xconfigurerequest.x, y = ev->xconfigurerequest.y; unsigned int width = ev->xconfigurerequest.width, height = ev->xconfigurerequest.height; - D_EVENTS((" -> TermWin.parent is %ldx%ld at (%d, %d). TermWin.x == %hd, TermWin.y == %hd\n", - width, height, x, y, TermWin.x, TermWin.y)); + D_EVENTS((" -> TermWin.parent is %ldx%ld at (%d, %d). Internal cache data shows %dx%d at (%hd, %hd)\n", + width, height, x, y, szHint.width, szHint.height, TermWin.x, TermWin.y)); /* If the font change count is non-zero, this event is telling us we resized ourselves. */ if (font_change_count > 0) { font_change_count--; diff --git a/src/options.c b/src/options.c index 35c86b1..d8d24bc 100644 --- a/src/options.c +++ b/src/options.c @@ -195,8 +195,8 @@ int rs_desktop = -1; char *rs_path = NULL; int rs_saveLines = SAVELINES; /* Lines in the scrollback buffer */ #ifdef USE_XIM -char *rs_inputMethod = NULL; -char *rs_preeditType = NULL; +char *rs_input_method = NULL; +char *rs_preedit_type = NULL; #endif char *rs_name = NULL; #ifndef NO_BOLDFONT @@ -371,8 +371,8 @@ static const struct { &rs_multchar_encoding), #endif /* MULTI_CHARSET */ #ifdef USE_XIM - OPT_LONG("input-method", "XIM input method", &rs_inputMethod), - OPT_LONG("preedit-type", "XIM preedit type", &rs_preeditType), + OPT_LONG("input-method", "XIM input method", &rs_input_method), + OPT_LONG("preedit-type", "XIM preedit type", &rs_preedit_type), #endif /* =======[ Toggles ]======= */ @@ -2417,7 +2417,7 @@ parse_image(char *buff) iml->mod->contrast = (int) strtol(PWord(2, mods), (char **) NULL, 0); } if (n > 2) { - iml->rmod->gamma = (int) strtol(PWord(3, mods), (char **) NULL, 0); + iml->mod->gamma = (int) strtol(PWord(3, mods), (char **) NULL, 0); } } else if (!BEG_STRCASECMP(color, "red ")) { RESET_AND_ASSIGN(iml->rmod, (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier))); @@ -2721,9 +2721,9 @@ parse_xim(char *buff) #ifdef USE_XIM if (!BEG_STRCASECMP(buff, "input_method ")) { - RESET_AND_ASSIGN(rs_inputMethod, Word(2, buff)); + RESET_AND_ASSIGN(rs_input_method, Word(2, buff)); } else if (!BEG_STRCASECMP(buff, "preedit_type ")) { - RESET_AND_ASSIGN(rs_preeditType, Word(2, buff)); + RESET_AND_ASSIGN(rs_preedit_type, Word(2, buff)); } else { print_error("Parse error in file %s, line %lu: Attribute \"%s\" is not valid within context xim", file_peek_path(), file_peek_line(), buff); @@ -3762,7 +3762,9 @@ save_config(char *path) #ifdef MULTI_CHARSET fprintf(fp, " begin multichar\n"); - fprintf(fp, " encoding %s\n", rs_multchar_encoding); + if (rs_multichar_encoding) { + fprintf(fp, " encoding %s\n", rs_multchar_encoding); + } for (i = 0; i < 5; i++) { fprintf(fp, " font %d %s\n", i, rs_mfont[i]); } @@ -3771,8 +3773,12 @@ save_config(char *path) #ifdef USE_XIM fprintf(fp, " begin xim\n"); - fprintf(fp, " input_method %s\n", rs_input_method); - fprintf(fp, " preedit_type %s\n", rs_preedit_type); + if (rs_input_method) { + fprintf(fp, " input_method %s\n", rs_input_method); + } + if (rs_preedit_type) { + fprintf(fp, " preedit_type %s\n", rs_preedit_type); + } fprintf(fp, " end xim\n\n"); #endif diff --git a/src/options.h b/src/options.h index f324601..5446ef4 100644 --- a/src/options.h +++ b/src/options.h @@ -227,8 +227,8 @@ extern time_t rs_anim_delay; extern char *rs_path; extern char *rs_noCursor; #ifdef USE_XIM -extern char *rs_inputMethod; -extern char *rs_preeditType; +extern char *rs_input_method; +extern char *rs_preedit_type; #endif extern char *rs_name; extern char *rs_config_file; diff --git a/src/scrollbar.c b/src/scrollbar.c index 82c64af..5b56b77 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -708,11 +708,66 @@ scrollbar_resize(int width, int height) #endif width -= scrollbar_trough_width(); XMoveResizeWindow(Xdisplay, scrollBar.win, ((Options & Opt_scrollBar_right) ? (width) : (0)), 0, scrollbar_trough_width(), height); - D_X11((" -> New scrollbar width/height == %lux%lu\n", scrollbar_trough_width(), height)); scrollBar.init = 0; + scrollBar.height = height - (2 * scrollbar_get_shadow()); + scrollBar.win_width = scrollbar_trough_width(); + scrollBar.win_height = height; + D_X11((" -> New scrollbar width/height == %hux%hu, win_width/height == %hux%hu\n", scrollBar.width, scrollBar.height, scrollBar.win_width, scrollBar.win_height)); scrollbar_show(0); } +void +scrollbar_change_type(unsigned int type) +{ +#ifdef MOTIF_SCROLLBAR + if (scrollBar.type == SCROLLBAR_MOTIF) { + /* arrows are as high as wide - leave 1 pixel gap */ + scrollBar.beg -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollBar.end += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + } +#endif +#ifdef NEXT_SCROLLBAR + if (scrollBar.type == SCROLLBAR_NEXT) { + scrollBar.beg = 0; + scrollBar.end += (scrollBar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); + } +#endif + + scrollbar_reset(); + scrollBar.type = type; + +#ifdef MOTIF_SCROLLBAR + if (type == SCROLLBAR_MOTIF) { + /* arrows are as high as wide - leave 1 pixel gap */ + scrollBar.beg += scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + scrollBar.end -= scrollbar_arrow_height() + scrollbar_get_shadow() + 1; + } +#endif +#ifdef NEXT_SCROLLBAR + if (type == SCROLLBAR_NEXT) { + scrollBar.beg = scrollbar_get_shadow(); + scrollBar.end -= (scrollBar.width * 2 + (scrollbar_get_shadow() ? scrollbar_get_shadow() : 1) + 2); + } +#endif + scrollbar_show(1); +} + +void +scrollbar_change_width(unsigned short width) +{ + if (width == 0) { + width = SB_WIDTH; + } + if (width == scrollBar.width) { + /* Nothing to do, so return. */ + return; + } + scrollbar_reset(); + scrollBar.width = width; + parent_resize(); + scrollbar_show(1); +} + unsigned char scrollbar_show(short mouseoffset) { @@ -771,7 +826,7 @@ scrollbar_show(short mouseoffset) #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ } #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) - else if (image_mode_is(image_sb, (MODE_TRANS | MODE_VIEWPORT))) { + else if (image_mode_is(image_sb, (MODE_TRANS | MODE_VIEWPORT)) || (scrollBar.init == 0)) { render_simage(images[image_sb].current, scrollBar.win, scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); } if (scrollBar.type == SCROLLBAR_MOTIF || scrollBar.type == SCROLLBAR_NEXT) { @@ -836,7 +891,7 @@ scrollbar_show(short mouseoffset) } #ifdef PIXMAP_SCROLLBAR if (scrollbar_anchor_is_pixmapped()) { - if ((last_top != scrollBar.top) || (scrollBar.bot != last_bot)) { + if ((last_top != scrollBar.top) || (scrollBar.bot != last_bot) || (scrollBar.init == 0)) { XMoveResizeWindow(Xdisplay, scrollBar.sa_win, scrollbar_get_shadow(), scrollBar.top, scrollBar.width, scrollbar_anchor_height()); } if (scrollbar_anchor_height() > 1) { diff --git a/src/scrollbar.h b/src/scrollbar.h index 6855d64..7730e7a 100644 --- a/src/scrollbar.h +++ b/src/scrollbar.h @@ -156,6 +156,8 @@ extern unsigned char scrollbar_dispatch_event(event_t *); extern unsigned char scrollbar_mapping(unsigned char); extern void scrollbar_reset(void); extern void scrollbar_resize(int, int); +extern void scrollbar_change_type(unsigned int); +extern void scrollbar_change_width(unsigned short); extern unsigned char scrollbar_show(short); _XFUNCPROTOEND diff --git a/src/term.c b/src/term.c index f634437..3ccfd39 100644 --- a/src/term.c +++ b/src/term.c @@ -109,7 +109,7 @@ lookup_key(XEvent * ev) int ctrl, meta, shft, len; KeySym keysym; #ifdef USE_XIM - int valid_keysym; + int valid_keysym = 0; static unsigned char short_buf[256]; unsigned char *kbuf = short_buf; int kbuf_alloced = 0; @@ -1810,41 +1810,29 @@ xterm_seq(int op, const char *str) if (nstr && *nstr) { if (!strcasecmp(nstr, "xterm")) { #ifdef XTERM_SCROLLBAR - scrollBar.type = SCROLLBAR_XTERM; + scrollbar_change_type(SCROLLBAR_XTERM); #else print_error("Support for xterm scrollbars was not compiled in. Sorry."); #endif } else if (!strcasecmp(nstr, "next")) { #ifdef NEXT_SCROLLBAR - scrollBar.type = SCROLLBAR_NEXT; + scrollbar_change_type(SCROLLBAR_NEXT); #else print_error("Support for NeXT scrollbars was not compiled in. Sorry."); #endif } else if (!strcasecmp(nstr, "motif")) { #ifdef MOTIF_SCROLLBAR - scrollBar.type = SCROLLBAR_MOTIF; + scrollbar_change_type(SCROLLBAR_MOTIF); #else print_error("Support for motif scrollbars was not compiled in. Sorry."); #endif } else { print_error("Unrecognized scrollbar type \"%s\".", nstr); } - scrollbar_reset(); - map_scrollbar(0); - map_scrollbar(1); - scrollbar_show(0); } nstr = (char *) strsep(&tnstr, ";"); if (nstr && *nstr) { - scrollBar.width = strtoul(nstr, (char **) NULL, 0); - if (scrollBar.width == 0) { - print_error("Invalid scrollbar length \"%s\".", nstr); - scrollBar.width = SB_WIDTH; - } - scrollbar_reset(); - map_scrollbar(0); - map_scrollbar(1); - scrollbar_show(0); + scrollbar_change_width((unsigned short) strtoul(nstr, (char **) NULL, 0)); } break; case 11: diff --git a/src/windows.c b/src/windows.c index 99ba5b6..815dbc8 100644 --- a/src/windows.c +++ b/src/windows.c @@ -560,6 +560,9 @@ handle_resize(unsigned int width, unsigned int height) TermWin.nrow = new_nrow; term_resize(width, height); + szHint.width = szHint.base_width + TermWin.width; + szHint.height = szHint.base_height + TermWin.height; + D_X11((" -> New szHint.width/height == %lux%lu\n", szHint.width, szHint.height)); scrollbar_resize(width, height); scr_reset();