diff --git a/ChangeLog b/ChangeLog index 4c006b2..eccb175 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2651,3 +2651,15 @@ Wed Oct 27 18:46:04 PDT 1999 Michael Jennings which I can do much about. :-) ------------------------------------------------------------------------------- +Thu Oct 28 13:12:17 PDT 1999 Michael Jennings + + I fixed the popup scrollbar bug with transparency, but I fixed lots + more than that. I removed a lot of duplicate event handling, lots of + duplicate redraws, and lots of unnecessary transparency updates. In + doing so, I fixed the latency problem people had been reporting with + several shaded/tinted transparent Eterms while changing desktops. I + also threw solid color transparency support in the mix while I was at + it. All in all, you should notice significant speedups in transparent + Eterms. + +------------------------------------------------------------------------------- diff --git a/src/events.c b/src/events.c index f36c63a..7531242 100644 --- a/src/events.c +++ b/src/events.c @@ -44,6 +44,7 @@ static const char cvs_ident[] = "$Id$"; #include "command.h" #include "e.h" #include "events.h" +#include "font.h" #include "menus.h" #include "options.h" #include "pixmap.h" @@ -226,6 +227,8 @@ handle_property_notify(event_t * ev) { Atom prop; + Window win; + Pixmap pmap; D_EVENTS(("handle_property_notify(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); @@ -234,14 +237,22 @@ handle_property_notify(event_t * ev) prop = XInternAtom(Xdisplay, "_WIN_WORKSPACE", True); D_EVENTS(("handle_property_notify(): On %s. prop == 0x%08x, ev->xproperty.atom == 0x%08x\n", ((ev->xany.window == Xroot) ? "the root window" : "TermWin.parent"), (int) prop, (int) ev->xproperty.atom)); if (ev->xproperty.atom == prop) { - if (desktop_pixmap != None) { - free_desktop_pixmap(); + win = get_desktop_window(); + if (win == (Window) 1) { + /* The desktop window is unchanged. Ignore this event. */ + return 1; } - desktop_window = get_desktop_window(); + /* The desktop window has changed somehow. */ if (desktop_window == None) { + free_desktop_pixmap(); FOREACH_IMAGE(if (image_mode_is(idx, MODE_TRANS)) {image_set_mode(idx, MODE_IMAGE); image_allow_mode(idx, ALLOW_IMAGE);}); return 1; } + pmap = get_desktop_pixmap(); + if (pmap == (Pixmap) 1) { + /* Pixmap is unchanged */ + return 1; + } redraw_all_images(); return 1; } @@ -250,8 +261,10 @@ handle_property_notify(event_t * ev) prop = XInternAtom(Xdisplay, "_XROOTPMAP_ID", True); D_EVENTS(("handle_property_notify(): On desktop_window [0x%08x]. prop == 0x%08x, ev->xproperty.atom == 0x%08x\n", (int) desktop_window, (int) prop, (int) ev->xproperty.atom)); if (ev->xproperty.atom == prop) { - if (desktop_pixmap != None) { - free_desktop_pixmap(); + pmap = get_desktop_pixmap(); + if (pmap == (Pixmap) 1) { + /* Pixmap is unchanged */ + return 1; } redraw_all_images(); return 1; @@ -314,7 +327,7 @@ handle_client_message(event_t * ev) return 1; } #endif /* OFFIX_DND */ - return 0; + return 1; } unsigned char @@ -372,7 +385,7 @@ handle_focus_in(event_t * ev) XSetICFocus(Input_Context); #endif } - return 0; + return 1; } unsigned char @@ -396,7 +409,7 @@ handle_focus_out(event_t * ev) XUnsetICFocus(Input_Context); #endif } - return 0; + return 1; } unsigned char @@ -409,11 +422,34 @@ handle_configure_notify(event_t * ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0); while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, ConfigureNotify, &unused_xevent)); - handle_external_resize(); + if (ev->xany.window == TermWin.parent) { + 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)); + /* If the font change count is non-zero, this event is telling us we resized ourselves. */ + if (font_change_count > 0) { + font_change_count--; + } + if ((width != (unsigned int) szHint.width) || (height != (unsigned int) szHint.height)) { + /* We were resized externally. Handle the resize. */ + D_EVENTS((" -> External resize detected.\n")); + handle_resize(width, height); #ifdef USE_XIM - xim_set_status_position(); + xim_set_status_position(); #endif - return 0; + /* A resize requires the additional handling of a move */ + handle_move(x, y); + } else if ((x != TermWin.x) || (y != TermWin.y)) { + /* There was an external move, but no resize. Handle the move. */ + D_EVENTS((" -> External move detected.\n")); + handle_move(x, y); + } else { + D_EVENTS((" -> Bogus ConfigureNotify detected, ignoring.\n")); + } + } + return 1; } unsigned char @@ -474,12 +510,14 @@ handle_expose(event_t * ev) while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, Expose, &unused_xevent)); while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, GraphicsExpose, &unused_xevent)); } +#if 0 if (desktop_window != None) { XSelectInput(Xdisplay, desktop_window, PropertyChangeMask); } +#endif P_SETTIMEVAL(expose_stop); P_EVENT_TIME("Expose", expose_start, expose_stop); - return 0; + return 1; } unsigned char @@ -643,7 +681,7 @@ handle_motion_notify(event_t * ev) P_EVENT_TIME("MotionNotify", motion_start, motion_stop); return 1; } - return 0; + return 1; } unsigned char @@ -654,7 +692,9 @@ process_x_event(event_t * ev) #endif COUNT_EVENT(event_cnt); +#if 0 D_EVENTS(("process_x_event(ev [%8p] %s on window 0x%08x)\n", ev, event_type_to_name(ev->xany.type), ev->xany.window)); +#endif if (primary_data.handlers[ev->type] != NULL) { return ((primary_data.handlers[ev->type]) (ev)); } diff --git a/src/menus.c b/src/menus.c index dcfc372..ac3e735 100644 --- a/src/menus.c +++ b/src/menus.c @@ -224,6 +224,7 @@ menu_handle_expose(event_t * ev) { XEvent unused_xevent; + menu_t *menu; D_EVENTS(("menu_handle_expose(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window)); @@ -231,7 +232,10 @@ menu_handle_expose(event_t * ev) while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, Expose, &unused_xevent)); while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, GraphicsExpose, &unused_xevent)); - return 0; + if ((menu = find_menu_by_window(menu_list, ev->xany.window)) != NULL) { + menu_draw(menu); + } + return 1; } unsigned char diff --git a/src/pixmap.c b/src/pixmap.c index ac9b388..a5d2eca 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -120,6 +120,15 @@ get_image_type(unsigned short type) return (""); } +unsigned char +image_mode_any(unsigned char mode) +{ + unsigned char ismode = 0; + + FOREACH_IMAGE(if (image_mode_is(idx, mode)) ismode=1;); + return ismode; +} + unsigned short parse_pixmap_ops(char *str) { @@ -557,7 +566,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short return; } if (desktop_pixmap == None) { - desktop_pixmap = get_desktop_pixmap(); + get_desktop_pixmap(); last_x = last_y = -1; if (desktop_pixmap != None && need_colormod()) { pixmap = desktop_pixmap; @@ -972,17 +981,6 @@ load_image(const char *file, short type) return 0; } -void -free_desktop_pixmap(void) -{ - - if (desktop_pixmap_is_mine) { - XFreePixmap(Xdisplay, desktop_pixmap); - desktop_pixmap_is_mine = 0; - } - desktop_pixmap = None; -} - # ifdef PIXMAP_OFFSET # define MOD_IS_SET(mod) ((mod) && ((mod)->brightness != 0xff || (mod)->contrast != 0xff || (mod)->gamma != 0xff)) @@ -1179,7 +1177,11 @@ get_desktop_window(void) if (w != Xroot) { XSelectInput(Xdisplay, w, PropertyChangeMask); } - return (desktop_window = w); + if (desktop_window == w) { + return ((Window) 1); + } else { + return (desktop_window = w); + } } } @@ -1195,37 +1197,77 @@ get_desktop_pixmap(void) Pixmap p; Atom prop, type, prop2; int format; + static Pixmap color_pixmap = None; unsigned long length, after; unsigned char *data; - if (desktop_window == None) - return None; + if (desktop_window == None) { + free_desktop_pixmap(); + return (desktop_pixmap = None); + } prop = XInternAtom(Xdisplay, "_XROOTPMAP_ID", True); prop2 = XInternAtom(Xdisplay, "_XROOTCOLOR_PIXEL", True); if (prop == None && prop2 == None) { - return None; + free_desktop_pixmap(); + return (desktop_pixmap = None); } if (prop != None) { XGetWindowProperty(Xdisplay, desktop_window, prop, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data); if (type == XA_PIXMAP) { p = *((Pixmap *) data); - D_PIXMAP((" Found pixmap 0x%08x\n", p)); - return p; + if (p != None) { + D_PIXMAP((" Found pixmap 0x%08x\n", p)); + if (desktop_pixmap == p) { + return ((Pixmap) 1); + } else { + free_desktop_pixmap(); + return (desktop_pixmap = p); + } + } } } if (prop2 != None) { XGetWindowProperty(Xdisplay, desktop_window, prop2, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data); if (type == XA_CARDINAL) { - D_PIXMAP((" Solid color not yet supported.\n")); - return None; + + XGCValues gcvalue; + GC gc; + Pixel pix; + + free_desktop_pixmap(); + pix = *((Pixel *) data); + D_PIXMAP((" Found solid color 0x%08x\n", pix)); + gcvalue.foreground = pix; + gcvalue.background = pix; + gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground | GCBackground, &gcvalue); + + if (color_pixmap != None) { + XFreePixmap(Xdisplay, color_pixmap); + } + color_pixmap = XCreatePixmap(Xdisplay, TermWin.vt, 16, 16, Xdepth); + XFillRectangle(Xdisplay, color_pixmap, gc, 0, 0, 16, 16); + return (desktop_pixmap = color_pixmap); } } D_PIXMAP(("No suitable attribute found.\n")); - return None; + free_desktop_pixmap(); + return (desktop_pixmap = None); } + +void +free_desktop_pixmap(void) +{ + + if (desktop_pixmap_is_mine && desktop_pixmap != None) { + XFreePixmap(Xdisplay, desktop_pixmap); + desktop_pixmap_is_mine = 0; + } + desktop_pixmap = None; +} + # endif /* PIXMAP_OFFSET */ void diff --git a/src/pixmap.h b/src/pixmap.h index d34832c..2d4b99f 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -94,13 +94,13 @@ enum { /* Helper macros */ #define FOREACH_IMAGE(x) do {unsigned char idx; for (idx = 0; idx < image_max; idx++) { x } } while (0) -#define redraw_all_images() do {render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); \ - scr_touch(); scrollbar_show(0); enl_ipc_sync();} while (0) #define image_set_mode(which, bit) do {images[which].mode &= ~(MODE_MASK); images[which].mode |= (bit);} while (0) #define image_allow_mode(which, bit) (images[which].mode |= (bit)) #define image_disallow_mode(which, bit) (images[which].mode &= ~(bit)) #define image_mode_is(which, bit) (images[which].mode & (bit)) #define image_mode_fallback(which) do {if (image_mode_is((which), ALLOW_IMAGE)) {image_set_mode((which), MODE_IMAGE);} else {image_set_mode((which), MODE_SOLID);}} while (0) +#define redraw_all_images() do {render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); \ + scr_touch(); scrollbar_show(0); if (image_mode_any(MODE_AUTO)) enl_ipc_sync();} while (0) /* Elements of an simage to be reset */ #define RESET_NONE (0UL) @@ -158,6 +158,7 @@ extern Window desktop_window; _XFUNCPROTOBEGIN extern const char *get_image_type(unsigned short); +extern unsigned char image_mode_any(unsigned char); extern unsigned short parse_pixmap_ops(char *); extern unsigned short set_pixmap_scale(const char *, pixmap_t *); extern unsigned char check_image_ipc(unsigned char); diff --git a/src/scrollbar.c b/src/scrollbar.c index a066906..c97137b 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -108,26 +108,25 @@ Draw_up_button(int x, int y, int state) pt[1].x = x + sz2 - 1; pt[1].y = y; XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# if (SHADOW > 1) - /* doubled */ - pt[0].x++; - pt[0].y--; - pt[1].y++; - XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# endif + if (scrollbar_get_shadow() > 1) { + pt[0].x++; + pt[0].y--; + pt[1].y++; + XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); + } /* draw shadow */ pt[0].x = x + sz2; pt[0].y = y; pt[1].x = x + sz - 1; pt[1].y = y + sz - 1; XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# if (SHADOW > 1) - /* doubled */ - pt[0].y++; - pt[1].x--; - pt[1].y--; - XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# endif + if (scrollbar_get_shadow() > 1) { + /* doubled */ + pt[0].y++; + pt[1].x--; + pt[1].y--; + XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); + } } /* draw triangular down button with a shadow of SHADOW (1 or 2) pixels */ @@ -172,26 +171,26 @@ Draw_dn_button(int x, int y, int state) pt[1].x = x + sz2 - 1; pt[1].y = y + sz - 1; XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# if (SHADOW > 1) - /* doubled */ - pt[0].x++; - pt[0].y++; - pt[1].y--; - XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# endif + if (scrollbar_get_shadow() > 1) { + /* doubled */ + pt[0].x++; + pt[0].y++; + pt[1].y--; + XDrawLine(Xdisplay, scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); + } /* draw shadow */ pt[0].x = x + sz2; pt[0].y = y + sz - 1; pt[1].x = x + sz - 1; pt[1].y = y; XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# if (SHADOW > 1) - /* doubled */ - pt[0].y--; - pt[1].x--; - pt[1].y++; - XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -# endif + if (scrollbar_get_shadow() > 1) { + /* doubled */ + pt[0].y--; + pt[1].x--; + pt[1].y++; + XDrawLine(Xdisplay, scrollBar.win, bot, pt[0].x, pt[0].y, pt[1].x, pt[1].y); + } } #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ @@ -233,6 +232,11 @@ scrollbar_init(void) } #endif + if (scrollBar.type == SCROLLBAR_XTERM) { + scrollbar_set_shadow(0); + } else { + scrollbar_set_shadow((Options & Opt_scrollBar_floating) ? 0 : SHADOW); + } event_register_dispatcher(scrollbar_dispatch_event, scrollbar_event_init_dispatcher); } @@ -243,7 +247,9 @@ scrollbar_event_init_dispatcher(void) MEMSET(&scrollbar_event_data, 0, sizeof(event_dispatcher_data_t)); +#if 0 EVENT_DATA_ADD_HANDLER(scrollbar_event_data, ConfigureNotify, sb_handle_configure_notify); +#endif EVENT_DATA_ADD_HANDLER(scrollbar_event_data, EnterNotify, sb_handle_enter_notify); EVENT_DATA_ADD_HANDLER(scrollbar_event_data, LeaveNotify, sb_handle_leave_notify); EVENT_DATA_ADD_HANDLER(scrollbar_event_data, FocusIn, sb_handle_focus_in); @@ -268,6 +274,7 @@ scrollbar_event_init_dispatcher(void) } +#if 0 unsigned char sb_handle_configure_notify(event_t * ev) { @@ -277,8 +284,9 @@ sb_handle_configure_notify(event_t * ev) REQUIRE_RVAL(XEVENT_IS_PARENT(ev, &scrollbar_event_data), 0); redraw_image(image_sb); - return 0; + return 1; } +#endif unsigned char sb_handle_enter_notify(event_t * ev) @@ -304,7 +312,7 @@ sb_handle_enter_notify(event_t * ev) images[image_sb].current = images[image_sb].selected; render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); } - return 0; + return 1; } unsigned char @@ -331,7 +339,7 @@ sb_handle_leave_notify(event_t * ev) images[image_sb].current = images[image_sb].norm; render_simage(images[image_sb].current, scrollbar_get_win(), scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); } - return 0; + return 1; } unsigned char @@ -342,7 +350,7 @@ sb_handle_focus_in(event_t * ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &scrollbar_event_data), 0); - return 0; + return 1; } unsigned char @@ -353,7 +361,7 @@ sb_handle_focus_out(event_t * ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &scrollbar_event_data), 0); - return 0; + return 1; } unsigned char @@ -371,7 +379,7 @@ sb_handle_expose(event_t * ev) if (scrollbar_win_is_scrollbar(ev->xany.window)) { scrollbar_show(0); } - return 0; + return 1; } unsigned char @@ -663,11 +671,6 @@ scrollbar_reset(void) } #endif last_top = last_bot = 0; - if (scrollBar.type == SCROLLBAR_XTERM) { - scrollbar_set_shadow(0); - } else { - scrollbar_set_shadow((Options & Opt_scrollBar_floating) ? 0 : SHADOW); - } scrollBar.init = 0; } @@ -697,6 +700,7 @@ 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_show(0); } @@ -880,7 +884,7 @@ scrollbar_show(short mouseoffset) } } if (image_mode_is(image_up, MODE_AUTO) || image_mode_is(image_down, MODE_AUTO) || image_mode_is(image_sb, MODE_AUTO) || image_mode_is(image_sa, MODE_AUTO)) { - enl_ipc_sync(); + // enl_ipc_sync(); } #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ diff --git a/src/scrollbar.h b/src/scrollbar.h index ccd7896..6855d64 100644 --- a/src/scrollbar.h +++ b/src/scrollbar.h @@ -43,7 +43,7 @@ #define scrollbar_isMotion() (scrollBar.state == 'm') #define scrollbar_isUp() (scrollBar.state == 'U') #define scrollbar_isDn() (scrollBar.state == 'D') -#define scrollbar_isUpDn() isupper (scrollBar.state) +#define scrollbar_isUpDn() (isupper(scrollBar.state)) #define scrollbar_setNone() do { D_SCROLLBAR(("scrollbar_setNone(): Cancelling motion.\n")); scrollBar.state = 1; } while (0) #define scrollbar_setMotion() do { D_SCROLLBAR(("scrollbar_setMotion()\n")); scrollBar.state = 'm'; } while (0) #define scrollbar_setUp() do { D_SCROLLBAR(("scrollbar_setUp()\n")); scrollBar.state = 'U'; } while (0) @@ -55,10 +55,10 @@ # define scrollbar_win_is_uparrow(w) ((w) == scrollBar.up_win) # define scrollbar_win_is_downarrow(w) ((w) == scrollBar.dn_win) # define scrollbar_win_is_anchor(w) ((w) == scrollBar.sa_win) -# define scrollbar_is_pixmapped() ((images[image_sb].current->iml->im) && (images[image_sb].mode & MODE_MASK)) -# define scrollbar_uparrow_is_pixmapped() ((images[image_up].current->iml->im) && (images[image_up].mode & MODE_MASK)) -# define scrollbar_downarrow_is_pixmapped() ((images[image_down].current->iml->im) && (images[image_down].mode & MODE_MASK)) -# define scrollbar_anchor_is_pixmapped() ((images[image_sa].current->iml->im) && (images[image_sa].mode & MODE_MASK)) +# define scrollbar_is_pixmapped() (images[image_sb].mode & MODE_MASK) +# define scrollbar_uparrow_is_pixmapped() (images[image_up].mode & MODE_MASK) +# define scrollbar_downarrow_is_pixmapped() (images[image_down].mode & MODE_MASK) +# define scrollbar_anchor_is_pixmapped() (images[image_sa].mode & MODE_MASK) # define scrollbar_upButton(w, y) ( scrollbar_uparrow_is_pixmapped() ? scrollbar_win_is_uparrow(w) \ : ((scrollBar.type == SCROLLBAR_NEXT && (y) > scrollBar.end && (y) <= scrollbar_dn_loc()) \ || (scrollBar.type != SCROLLBAR_NEXT && (y) < scrollBar.beg))) @@ -102,7 +102,7 @@ : ((scrollBar.type == SCROLLBAR_NEXT) ? (scrollBar.end + scrollBar.width + 2) : (scrollBar.end + 1))) /* Scrollbar operations */ -#define map_scrollbar(show) do {if (scrollbar_mapping(show)) {scr_touch(); parent_resize();} PrivMode(show, PrivMode_scrollBar); } while (0) +#define map_scrollbar(show) do {PrivMode(show, PrivMode_scrollBar); if (scrollbar_mapping(show)) {scr_touch(); parent_resize();} } while (0) #define scrollbar_get_shadow() (scrollBar.shadow) #define scrollbar_set_shadow(s) do { scrollBar.shadow = (s); } while (0) #define scrollbar_get_win() (scrollBar.win) diff --git a/src/startup.c b/src/startup.c index 050936e..a2a8100 100644 --- a/src/startup.c +++ b/src/startup.c @@ -276,9 +276,7 @@ eterm_bootstrap(int argc, char *argv[]) D_CMD(("init_command()\n")); init_command(rs_execArgs); - if (Options & Opt_borderless) { - handle_external_resize(); - } + parent_resize(); main_loop(); diff --git a/src/startup.h b/src/startup.h index 6a36514..25aa05d 100644 --- a/src/startup.h +++ b/src/startup.h @@ -94,24 +94,25 @@ /************ Structures ************/ typedef struct { - int internalBorder; /* Internal border size */ - short width, height; /* window size [pixels] */ - short fwidth, fheight; /* font width and height [pixels] */ - short fprop; /* font is proportional */ - short ncol, nrow; /* window size [characters] */ - short focus; /* window has focus */ - short saveLines; /* number of lines that fit in scrollback */ - short nscrolled; /* number of line actually scrolled */ - short view_start; /* scrollback view starts here */ - Window parent, vt; /* parent (main) and vt100 window */ - GC gc; /* GC for drawing text */ - XFontStruct * font; /* main font structure */ - XFontSet fontset; + int internalBorder; /* Internal border size */ + short x, y; /* TermWin.parent coordinates */ + short width, height; /* window size [pixels] */ + short fwidth, fheight; /* font width and height [pixels] */ + short fprop; /* font is proportional */ + short ncol, nrow; /* window size [characters] */ + short focus; /* window has focus */ + short saveLines; /* number of lines that fit in scrollback */ + short nscrolled; /* number of line actually scrolled */ + short view_start; /* scrollback view starts here */ + Window parent, vt; /* parent (main) and vt100 window */ + GC gc; /* GC for drawing text */ + XFontStruct * font; /* main font structure */ + XFontSet fontset; # ifndef NO_BOLDFONT - XFontStruct * boldFont; /* bold font */ + XFontStruct * boldFont; /* bold font */ # endif # ifdef MULTI_CHARSET - XFontStruct * mfont; /* multibyte font structure */ + XFontStruct * mfont; /* multibyte font structure */ # endif } TermWin_t; diff --git a/src/term.c b/src/term.c index 57ba41f..d2d1ef4 100644 --- a/src/term.c +++ b/src/term.c @@ -1728,7 +1728,6 @@ xterm_seq(int op, const char *str) 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)); if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { free_desktop_pixmap(); - desktop_pixmap = None; /* Force the re-read */ } if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { XFreePixmap(Xdisplay, viewport_pixmap); @@ -1797,14 +1796,12 @@ xterm_seq(int op, const char *str) redraw_all_images(); break; case 3: - if (desktop_pixmap != None) { - free_desktop_pixmap(); - } get_desktop_window(); if (desktop_window == None) { FOREACH_IMAGE(if (image_mode_is(idx, MODE_TRANS)) {image_set_mode(idx, MODE_IMAGE); image_allow_mode(idx, ALLOW_IMAGE);}); break; } + get_desktop_pixmap(); redraw_all_images(); break; #endif diff --git a/src/windows.c b/src/windows.c index 29ca62c..5c83cc6 100644 --- a/src/windows.c +++ b/src/windows.c @@ -493,14 +493,18 @@ set_width(unsigned short width) void update_size_hints(void) { + D_X11(("update_size_hints() called.\n")); szHint.base_width = (2 * TermWin.internalBorder); szHint.base_height = (2 * TermWin.internalBorder); szHint.base_width += ((scrollbar_visible()) ? (scrollbar_trough_width()) : (0)); + D_X11(("Size Hints: base width/height == %lux%lu\n", szHint.base_width, szHint.base_height)); szHint.min_width = szHint.base_width + szHint.width_inc; szHint.min_height = szHint.base_height + szHint.height_inc; szHint.width = szHint.base_width + TermWin.width; szHint.height = szHint.base_height + TermWin.height; + D_X11((" Minimum width/height == %lux%lu, width/height == %lux%lu\n", + szHint.min_width, szHint.min_height, szHint.width, szHint.height)); szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; XSetWMNormalHints(Xdisplay, TermWin.parent, &szHint); @@ -510,10 +514,11 @@ update_size_hints(void) void term_resize(int width, int height) { - D_SCREEN(("term_resize(%d, %d)\n", width, height)); + D_X11(("term_resize(%d, %d)\n", width, height)); TermWin.width = TermWin.ncol * TermWin.fwidth; TermWin.height = TermWin.nrow * TermWin.fheight; - XMoveResizeWindow(Xdisplay, TermWin.vt, ((Options & Opt_scrollBar_right) ? (0) : (scrollbar_trough_width())), 0, width, height + 1); + D_X11((" -> New TermWin width/height == %lux%lu\n", TermWin.width, TermWin.height)); + XMoveResizeWindow(Xdisplay, TermWin.vt, ((Options & Opt_scrollBar_right) ? (0) : ((scrollbar_visible()) ? (scrollbar_trough_width()) : (0))), 0, width, height + 1); render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 1); if (image_mode_is(image_bg, MODE_AUTO)) { enl_ipc_sync(); @@ -524,8 +529,10 @@ term_resize(int width, int height) void parent_resize(void) { + D_X11(("parent_resize() called.\n")); update_size_hints(); XResizeWindow(Xdisplay, TermWin.parent, szHint.width, szHint.height); + D_X11((" -> New parent width/height == %lux%lu\n", szHint.width, szHint.height)); term_resize(szHint.width, szHint.height); scrollbar_resize(szHint.width, szHint.height); } @@ -537,6 +544,7 @@ handle_resize(unsigned int width, unsigned int height) int new_ncol = (width - szHint.base_width) / TermWin.fwidth; int new_nrow = (height - szHint.base_height) / TermWin.fheight; + D_EVENTS(("handle_resize(%u, %u)\n", width, height)); if (first_time || (new_ncol != TermWin.ncol) || (new_nrow != TermWin.nrow)) { int curr_screen = -1; @@ -556,29 +564,24 @@ handle_resize(unsigned int width, unsigned int height) scr_change_screen(curr_screen); } first_time = 0; - } else if (image_mode_is(image_bg, MODE_TRANS) || image_mode_is(image_bg, MODE_VIEWPORT)) { + } +#if 0 + else if (image_mode_is(image_bg, MODE_TRANS) || image_mode_is(image_bg, MODE_VIEWPORT)) { term_resize(width, height); scrollbar_resize(width, height); scr_touch(); } +#endif } -/* Handle configure notify events telling us we've been resized */ void -handle_external_resize(void) +handle_move(int x, int y) { - Window root; - int x, y; - unsigned int border, depth, width, height; - - /* If the font change count is non-zero, this event - is telling us we resized ourselves. Ignore it. */ - if (font_change_count > 0) { - font_change_count--; - return; + if (image_mode_any(MODE_TRANS | MODE_VIEWPORT)) { + redraw_all_images(); } - XGetGeometry(Xdisplay, TermWin.parent, &root, &x, &y, &width, &height, &border, &depth); - handle_resize(width, height); + TermWin.x = x; + TermWin.y = y; } #ifdef XTERM_COLOR_CHANGE diff --git a/src/windows.h b/src/windows.h index 83ce8c8..9314c2b 100644 --- a/src/windows.h +++ b/src/windows.h @@ -51,7 +51,7 @@ extern void update_size_hints(void); extern void term_resize(int, int); extern void parent_resize(void); extern void handle_resize(unsigned int, unsigned int); -extern void handle_external_resize(void); +extern void handle_move(int, int); #ifdef XTERM_COLOR_CHANGE extern void set_window_color(int, const char *); #else