--- texk/xdvik/CHANGES | 10 ++ texk/xdvik/c-auto.in | 8 - texk/xdvik/configure.ac | 1 texk/xdvik/dvi-init.c | 4 texk/xdvik/events.c | 13 ++ texk/xdvik/gui/Panner.c | 18 ++- texk/xdvik/gui/help-window.c | 10 +- texk/xdvik/gui/mag.c | 12 ++ texk/xdvik/gui/pagesel.c | 4 texk/xdvik/gui/print-dialog.c | 5 + texk/xdvik/gui/search-dialog.c | 2 texk/xdvik/gui/sfSelFile.c | 18 ++- texk/xdvik/gui/xm_filesel.c | 10 +- texk/xdvik/m4/xdvi-func-xkbbell.m4 | 29 +++++ texk/xdvik/util.c | 4 texk/xdvik/x_util.c | 179 ++++++++++++++----------------------- texk/xdvik/x_util.h | 3 texk/xdvik/xdvi.c | 10 -- texk/xdvik/xdvi.h | 8 - 19 files changed, 197 insertions(+), 151 deletions(-) Index: texlive-bin-2012.20120623/texk/xdvik/CHANGES =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/CHANGES 2012-04-02 17:27:30.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/CHANGES 2012-06-23 19:18:45.461791034 +0900 @@ -9,6 +9,16 @@ may contain undetected bugs. Such versions shouldn't be used by distributors. + * 22.85.01-CVS4 (2012-04-23): + + xdvi.h, xdvi.c, x_util.h, x_util.c, dvi-init.c: Fixed bugs in + property handling on 64-bit systems (related to source specials). + + m4/xdvi-check-iconv.m4, m4/xdvi-check-langinfo.m4, + m4/xdvi-func-working-vsnprintf.m4: fixed copyright notices; + configure.ac: removed some obsolete lines. + + Added support for XkbBell, to make the console bell work again. + + Fixed #3514485 (mksedscript improperly handles macro values in + c-auto.in that contain spaces) (fix from TeX Live). + * 22.85 (2012-04-01): + configure.ac: check for ulltostr is no longer used + hypertex.c, gui/xm_toolbar.c: avoid compiler warnings about mixed Index: texlive-bin-2012.20120623/texk/xdvik/c-auto.in =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/c-auto.in 2012-04-25 23:45:36.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/c-auto.in 2012-06-23 19:18:45.469791040 +0900 @@ -305,6 +305,9 @@ /* Define if you have the header file. */ #undef HAVE_X11_XPM_H +/* Define if your system has XkbBell(). */ +#undef HAVE_XKB_BELL_EXT + /* Define to 1 if you have the header file. */ #undef HAVE_XM_XPMP_H @@ -405,11 +408,6 @@ /* Define to 1 if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS Index: texlive-bin-2012.20120623/texk/xdvik/configure.ac =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/configure.ac 2012-04-18 18:29:09.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/configure.ac 2012-06-23 19:20:03.533794644 +0900 @@ -87,6 +87,7 @@ XDVI_SYS_STREAMS XDVI_SYS_OLD_LINUX XDVI_FUNC_POLL +XDVI_FUNC_XKB_BELL dnl ####### Index: texlive-bin-2012.20120623/texk/xdvik/dvi-init.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/dvi-init.c 2012-06-23 19:14:31.957783059 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/dvi-init.c 2012-06-23 19:18:45.513791036 +0900 @@ -1642,8 +1642,8 @@ dvi_property_length = strlen(globals.dvi_name) + 1; /* also copy the terminating 0 */ dvi_property = xmalloc(dvi_property_length); - /* NOTE: we don't use dvi_inode like non-k xdvi, since dvi_name is - always fully expanded with xdvik. */ + /* NOTE: we don't use dvi_inode like non-k xdvi, since xdvik keeps closer + track of when the path points to a different inode. */ strcpy(dvi_property, globals.dvi_name); } Index: texlive-bin-2012.20120623/texk/xdvik/events.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/events.c 2012-06-23 19:14:31.957783059 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/events.c 2012-06-23 19:18:45.513791036 +0900 @@ -103,6 +103,14 @@ extern int errno; #endif /* X_NOT_STDC_ENV */ +#if HAVE_XKB_BELL_EXT +# include +# define XdviBell(display, window, percent) \ + XkbBell(display, window, percent, (Atom) None) +#else +# define XdviBell(display, window, percent) XBell(display, percent) +#endif + /* Linux prefers O_ASYNC over FASYNC; SGI IRIX does the opposite. */ #if !defined(FASYNC) && defined(O_ASYNC) # define FASYNC O_ASYNC @@ -1296,7 +1304,7 @@ if (event->type != ButtonPress || mouse_release != null_mouse || MAGNIFIER_ACTIVE || mane.shrinkfactor == 1 || *num_params != 1) { - XBell(DISP, 0); + XdviBell(DISP, event->xany.window, 0); if (mane.shrinkfactor == 1) { statusline_info(STATUS_SHORT, "No magnification available at shrink factor 1"); @@ -5284,7 +5292,8 @@ that window. */ if (have_src_specials && do_update_property - && globals.win_expose.min_x != 1 && globals.win_expose.max_y - globals.win_expose.min_y != 1 + && globals.win_expose.min_x != 1 + && globals.win_expose.max_y - globals.win_expose.min_y != 1 && currwin.base_x == 0 && currwin.base_y == 0) { update_window_property(XtWindow(globals.widgets.top_level), True); } Index: texlive-bin-2012.20120623/texk/xdvik/gui/Panner.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/Panner.c 2008-07-02 00:42:36.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/Panner.c 2012-06-23 19:18:45.521791036 +0900 @@ -48,6 +48,14 @@ extern Bool XmuDistinguishablePixels(); /* not defined in any Xmu headers */ +#if HAVE_XKB_BELL_EXT +# include +# define panBell(display, window, percent) \ + XkbBell(display, window, percent, (Atom) None) +#else +# define panBell(display, window, percent) XBell(display, percent) +#endif + /* ====================================================================== begin copy from Simple.c @@ -1020,7 +1028,7 @@ UNUSED(num_params); if (!get_event_xy (pw, event, &x, &y)) { - XBell (XtDisplay(gw), 0); /* should do error message */ + panBell(XtDisplay(gw), XtWindow(gw), 0); /* should do error message */ return; } @@ -1085,7 +1093,7 @@ if (!pw->panner.tmp.doing) return; if (!get_event_xy (pw, event, &x, &y)) { - XBell (XtDisplay(gw), 0); /* should do error message */ + panBell(XtDisplay(gw), XtWindow(gw), 0); /* should do error message */ return; } @@ -1116,7 +1124,7 @@ UNUSED(num_params); if (*num_params != 2) { - XBell (XtDisplay(gw), 0); + panBell (XtDisplay(gw), XtWindow(gw), 0); return; } @@ -1205,7 +1213,7 @@ if (*num_params < 2 || XmuCompareISOLatin1 (params[0], "rubberband") != 0) { - XBell (XtDisplay(gw), 0); + panBell (XtDisplay(gw), XtWindow(gw), 0); return; } @@ -1216,7 +1224,7 @@ } else if (XmuCompareISOLatin1 (params[1], "toggle") == 0) { rb = !pw->panner.rubber_band; } else { - XBell (XtDisplay(gw), 0); + panBell (XtDisplay(gw), XtWindow(gw), 0); return; } Index: texlive-bin-2012.20120623/texk/xdvik/gui/help-window.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/help-window.c 2009-06-29 08:47:26.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/help-window.c 2012-06-23 19:18:45.521791036 +0900 @@ -56,6 +56,14 @@ #include "topic-window.h" #include "help-window.h" +#if HAVE_XKB_BELL_EXT +# include +# define XdviBell(display, window, percent) \ + XkbBell(display, window, percent, (Atom) None) +#else +# define XdviBell(display, window, percent) XBell(display, percent) +#endif + /* missing features that will be listed in the help window */ #if !XDVI_XT_TIMER_HACK #define HAVE_MISSING_FEATURES 1 @@ -1087,7 +1095,7 @@ } } if (!matched) { - XBell(DISP, 0); + XdviBell(DISP, XtWindow(help_shell), 0); popup_message(help_shell, MSG_WARN, NULL, Index: texlive-bin-2012.20120623/texk/xdvik/gui/mag.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/mag.c 2008-07-02 00:42:36.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/mag.c 2012-06-23 19:18:45.521791036 +0900 @@ -52,6 +52,14 @@ #include "util.h" #include "pagesel.h" +#if HAVE_XKB_BELL_EXT +# include +# define XdviBell(display, window, percent) \ + XkbBell(display, window, percent, (Atom) None) +#else +# define XdviBell(display, window, percent) XBell(display, percent) +#endif + /* to measure distance of pointer from ruler in ruler mode */ static int g_ruler_pos_x = 0, g_ruler_pos_y = 0; @@ -627,7 +635,7 @@ int n = atoi(p + 1) - 1; if (n < 0 || n >= (int)get_magglass_items() || get_magglass_width(n) <= 0) { - XBell(DISP, 0); + XdviBell(DISP, event->xany.window, 0); return; } magnifier.width = get_magglass_width(n); @@ -642,7 +650,7 @@ magnifier.width = 0; } if (magnifier.width == 0) { - XBell(DISP, 0); + XdviBell(DISP, event->xany.window, 0); return; } } Index: texlive-bin-2012.20120623/texk/xdvik/gui/pagesel.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/pagesel.c 2008-07-02 00:42:36.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/pagesel.c 2012-06-23 19:18:45.521791036 +0900 @@ -728,7 +728,7 @@ int pageno = current_page; if (button == 5) { if (current_page >= total_pages - 1) { - XBell(DISP, 0); + xdvi_bell(); /* statusline_info(STATUS_SHORT, "Last page of DVI file"); */ return; } @@ -736,7 +736,7 @@ } else { if (current_page == 0) { - XBell(DISP, 0); + xdvi_bell(); /* statusline_info(STATUS_SHORT, "First page of DVI file"); */ return; } Index: texlive-bin-2012.20120623/texk/xdvik/gui/print-dialog.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/print-dialog.c 2009-03-31 23:59:37.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/print-dialog.c 2012-06-23 19:18:45.521791036 +0900 @@ -91,6 +91,11 @@ #define XTranslations XtNtranslations #endif /* MOTIF */ +#if HAVE_XKB_BELL_EXT +# include +# define XBell(dpy, percent) XkbBell(dpy, mane.win, percent, (Atom) None) +#endif + struct output_format_mapping { const char *fmt_string; outputFormatT fmt; Index: texlive-bin-2012.20120623/texk/xdvik/gui/search-dialog.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/search-dialog.c 2009-03-31 23:59:37.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/search-dialog.c 2012-06-23 19:18:45.533791040 +0900 @@ -339,7 +339,7 @@ return; } - XBell(DISP, 0); + xdvi_bell(); popup_message(get_matching_parent(w, globals.widgets.top_level, "find_popup", NULL), MSG_ERR, NULL, Index: texlive-bin-2012.20120623/texk/xdvik/gui/sfSelFile.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/sfSelFile.c 2009-11-10 19:28:49.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/sfSelFile.c 2012-06-23 19:18:45.533791040 +0900 @@ -54,6 +54,14 @@ extern int errno; #endif +#if HAVE_XKB_BELL_EXT +# include +# define sfBell(display, window, percent) \ + XkbBell(display, window, percent, (Atom) None) +#else +# define sfBell(display, window, percent) XBell(display, percent) +#endif + #define SEL_FILE_CANCEL -1 #define SEL_FILE_OK 0 #define SEL_FILE_NULL 1 @@ -147,7 +155,7 @@ raise_file_selector(void) { if (selFile != NULL && XtIsManaged(selFile)) { - XBell(DISP, 10); + sfBell(DISP, XtWindow(selFile), 10); XRaiseWindow(DISP, XtWindow(selFile)); return; } @@ -795,7 +803,9 @@ SFchdir(SFstartDir); errno = 0; if (!name || *name == 0 || (fp = XFOPEN(name, mode)) == NULL) { - XBell(DISP, 0); + sfBell(DISP, + (selFile != NULL && XtIsManaged(selFile)) + ? XtWindow(selFile) : (Window) NULL, 0); return NULL; } return fp; @@ -854,7 +864,7 @@ XEvent event; if (XtIsManaged(callback->shell)) { - XBell(DISP, 10); + sfBell(DISP, XtWindow(callback->shell), 10); XRaiseWindow(DISP, XtWindow(callback->shell)); return; } @@ -966,7 +976,7 @@ w = XtParent(w); } if (w == NULL || w == globals.widgets.top_level) { - XBell(DISP, 0); + sfBell(DISP, event.xany.window, 0); continue; } break; Index: texlive-bin-2012.20120623/texk/xdvik/gui/xm_filesel.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/gui/xm_filesel.c 2009-11-10 19:28:49.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/gui/xm_filesel.c 2012-06-23 19:18:45.533791040 +0900 @@ -43,6 +43,14 @@ #include #include +#if HAVE_XKB_BELL_EXT +# include +# define XdviBell(display, window, percent) \ + XkbBell(display, window, percent, (Atom) None) +#else +# define XdviBell(display, window, percent) XBell(display, percent) +#endif + /* static Widget dialog = NULL; */ /* static char *browse_fname = NULL; */ @@ -156,7 +164,7 @@ XsraSelFilePopup(struct filesel_callback *callback) { if (XtIsManaged(callback->shell)) { - XBell(DISP, 10); + XdviBell(DISP, XtWindow(callback->shell), 10); XRaiseWindow(DISP, XtWindow(callback->shell)); return; } Index: texlive-bin-2012.20120623/texk/xdvik/util.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/util.c 2012-04-02 17:27:30.000000000 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/util.c 2012-06-23 19:18:45.537791036 +0900 @@ -83,6 +83,10 @@ extern void *realloc(); #endif +#if HAVE_XKB_BELL_EXT +# include +# define XBell(dpy, percent) XkbBell(dpy, mane.win, percent, (Atom) None) +#endif /* if POSIX O_NONBLOCK is not available, use O_NDELAY */ #if !defined O_NONBLOCK && defined O_NDELAY Index: texlive-bin-2012.20120623/texk/xdvik/x_util.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/x_util.c 2012-06-23 19:14:31.957783059 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/x_util.c 2012-06-23 19:18:45.537791036 +0900 @@ -196,35 +196,24 @@ }; static Atom atoms[XtNumber(atom_names)]; -Window -get_window_id(char *window_p) -{ - Window w; - unsigned char *tmp; - tmp = (unsigned char *)window_p; - -#if !(defined(WORD64) || defined(LONG64)) - w = (*((xuint32 *) window_p)); +/* + * On 64-bit platforms, XGetWindowProperty and related functions convert + * properties with format=32 to arrays of longs. This function keeps that + * convention. + * The return value is the total number of bytes in the buffer. + */ + +#if defined(WORD64) || defined(LONG64) +# define LONG_CONV_64(bytes, format) ((bytes) << ((format) >> 5)) #else -# if WORDS_BIGENDIAN - w = ((unsigned long)tmp[0] << 24) | - ((unsigned long)tmp[1] << 16) | - ((unsigned long)tmp[2] << 8) | - (unsigned long)tmp[3]; -# else - w = ((unsigned long)tmp[3] << 24) | - ((unsigned long)tmp[2] << 16) | - ((unsigned long)tmp[1] << 8) | - (unsigned long)tmp[0]; -# endif +# define LONG_CONV_64(bytes, format) (bytes) #endif - return w; -} size_t property_get_data(Window w, Atom a, char **ret_buf, int (*x_get_property)(Display *, Window, Atom, long, - long, Bool, Atom, Atom *, int *, unsigned long *, + long, Bool, Atom, + Atom *, int *, unsigned long *, unsigned long *, unsigned char **)) { /* all of these are in 8-bit units */ @@ -253,13 +242,17 @@ nitems_ret *= (format_ret / 8); /* convert to bytes */ - while ((byte_offset + nitems_ret) >= buffer_len) { - buffer_len += 256; - buffer = xrealloc(buffer, buffer_len); + if (LONG_CONV_64(byte_offset + nitems_ret, format_ret) >= buffer_len) { + buffer_len += 256 + * ((LONG_CONV_64(byte_offset + nitems_ret, format_ret) + - buffer_len) / 256 + 1); + buffer = (buffer == NULL ? xmalloc(buffer_len) + : xrealloc(buffer, buffer_len)); } /* the +1 captures the extra '\0' that Xlib puts after the end. */ - memcpy(buffer + byte_offset, prop_ret, nitems_ret + 1); + memcpy(buffer + LONG_CONV_64(byte_offset, format_ret), prop_ret, + LONG_CONV_64(nitems_ret, format_ret) + 1); byte_offset += nitems_ret; XFree(prop_ret); @@ -273,42 +266,28 @@ XFree(prop_ret); *ret_buf = (char *)buffer; - return byte_offset; + return LONG_CONV_64(byte_offset, format_ret); } -size_t -property_get_window_list(char **window_list) +static size_t +property_get_window_list(long **window_list) { size_t len = property_get_data(DefaultRootWindow(DISP), - atom_xdvi_windows(), window_list, + atom_xdvi_windows(), (char **) window_list, XGetWindowProperty); if (len == 0) { TRACE_CLIENT((stderr, "No \"xdvi windows\" property found")); return 0; } - if (len % 4 != 0) { - TRACE_CLIENT((stderr, "\"XDVI_WINDOWS\" property had incorrect size; deleting it.")); + if (len % sizeof(long) != 0) { + TRACE_CLIENT((stderr, + "\"XDVI_WINDOWS\" property had incorrect size; deleting it.")); XDeleteProperty(DISP, DefaultRootWindow(DISP), atom_xdvi_windows()); return 0; } - return len; -} -void -set_window_id(Window w, unsigned char *data) -{ -#if WORDS_BIGENDIAN - data[0] = (unsigned int)w >> 24; - data[1] = (unsigned int)w >> 16; - data[2] = (unsigned int)w >> 8; - data[3] = (unsigned int)w; -#else - data[0] = (unsigned int)w; - data[1] = (unsigned int)w >> 8; - data[2] = (unsigned int)w >> 16; - data[3] = (unsigned int)w >> 24; -#endif + return len / sizeof (long); } /** @@ -325,16 +304,16 @@ /* - * Delete all occurences of window w from the window list property. Then, - * if `prepend' is true, prepend the window ID to the existing list. + * Delete all occurrences of window w from the window list property. + * Then, if `prepend' is true, prepend the window ID to the existing list. */ void update_window_property(Window w, Boolean prepend) { - char *wlist; + long *wlist; size_t wlist_len; - char *wlist_end; - char *wp; + long *wlist_end; + long *wp; #if 0 int i; #endif /* 0 */ @@ -347,33 +326,27 @@ wlist_end = wlist + wlist_len; #if 0 - for (i = 0, wp = wlist; wp < wlist_end; wp += 4, i++) { - fprintf(stderr, "WIN %d: %08lx; len: %d\n", i, get_window_id(wp), wlist_len); + for (i = 0, wp = wlist; wp < wlist_end; ++wp, ++i) { + fprintf(stderr, "WIN %d: %08lx; len: %d\n", i, *wp, wlist_len); } #endif /* 0 */ - for (wp = wlist; wp < wlist_end; wp += 4) { - if (get_window_id(wp) == w) { /* match, remove our ID */ - wlist_len -= 4; - wlist_end -= 4; - memmove(wp, wp + 4, wlist_end - wp); - wp -= 4; /* new item is now at wp; don't skip it in next iteration */ + for (wp = wlist; wp < wlist_end; ++wp) { + if (*wp == w) { /* match, remove our ID */ + --wlist_len; + --wlist_end; + memmove(wp, wp + 1, (wlist_end - wp) * sizeof (long)); + --wp; /* new item is now at wp; don't skip it in next iteration */ } } if (prepend) { /* add our ID again to front */ -#if (defined(WORD64) || defined(LONG64)) - unsigned char data[4]; - set_window_id(w, data); -#else - xuint32 data = w; -#endif /* Note: no need to realloc wlist, since the original length was sufficient for all elements. */ - memmove(wlist + 4, wlist, wlist_len); - wlist_len += 4; - memcpy(wlist, &data, 4); + memmove(wlist + 1, wlist, wlist_len * sizeof (long)); + ++wlist_len; + *wlist = w; } if (wlist_len == 0) @@ -382,8 +355,7 @@ else XChangeProperty(DISP, DefaultRootWindow(DISP), atom_xdvi_windows(), atom_xdvi_windows(), 32, - PropModeReplace, (unsigned char *)wlist, - wlist_len / 4); + PropModeReplace, (unsigned char *)wlist, wlist_len); XFlush(DISP); } @@ -1102,30 +1074,32 @@ } /* - * Check for another running copy of xdvi. If same_file is true, return - * the window ID of that other instance only if it has currently loaded the - * same file; else, return 0. + * Check for another running copy of xdvi. + * If same_file is true, return the window ID of an instance that has + * currently loaded the same file, or 0 if none exists. * If same_file is false, return the first valid xdvi window ID. */ + Window get_xdvi_window_id(Boolean same_file, property_cbT callback) { - char *window_list; + long *window_list; size_t window_list_len; - char *window_list_end; - char *wp; - char *p; + long *window_list_end; + long *wp; + long *p; Boolean need_rewrite = False; Window ret_window = 0; /* - * Get window list. Copy it over (we'll be calling property_get_data() again). + * Get window list. + * Copy it over (we'll be calling property_get_data() again). */ if ((window_list_len = property_get_window_list(&p)) == 0) return 0; - window_list = xmalloc(window_list_len); - memcpy(window_list, p, window_list_len); + window_list = xmalloc(window_list_len * sizeof (long)); + memcpy(window_list, p, window_list_len * sizeof (long)); XdviOldErrorHandler = XSetErrorHandler(XdviErrorHandler); @@ -1134,16 +1108,13 @@ window_list_end = window_list + window_list_len; TRACE_CLIENT((stderr, "My property: `%s'", dvi_property)); - for (wp = window_list; wp < window_list_end; wp += 4) { - Window w; + for (wp = window_list; wp < window_list_end; ++wp) { char *buf_ret; size_t len; - w = get_window_id(wp); - - TRACE_CLIENT((stderr, "Checking window %08lx", w)); + TRACE_CLIENT((stderr, "Checking window %08lx", *wp)); - len = property_get_data(w, atom_dvi_file(), &buf_ret, + len = property_get_data((Window) *wp, atom_dvi_file(), &buf_ret, XdviGetWindowProperty); if (len == 0) { @@ -1151,39 +1122,33 @@ that the application the window had belonged to had been killed with signal 9 */ - TRACE_CLIENT((stderr, "Window %08lx: doesn't exist any more, deleting", w)); - window_list_len -= 4; - window_list_end -= 4; - memmove(wp, wp + 4, window_list_end - wp); - wp -= 4; /* new item is now at wp; don't skip it in next iteration */ + TRACE_CLIENT((stderr, + "Window %08lx: doesn't exist any more, deleting", *wp)); + --window_list_len; + --window_list_end; + memmove(wp, wp + 1, (window_list_end - wp) * sizeof (long)); + --wp; /* new item is now at wp; don't skip it in next iteration */ need_rewrite = True; continue; } else { /* window still alive */ if (globals.debug & DBG_CLIENT) { -#if 0 - unsigned long ino; - int i; - - ino = 0; - for (i = 7; i >= 0; --i) - ino = (ino << 8) | (unsigned char)(buf_ret[i]); -#endif - TRACE_CLIENT((stderr, "Window %08lx: property: `%s'", w, buf_ret)); + TRACE_CLIENT((stderr, + "Window %08lx: property: `%s'", *wp, buf_ret)); } /* invoke callback if given */ if (callback != NULL) { - callback(w); + callback((Window) *wp); } if (!same_file && ret_window == 0) { - ret_window = w; + ret_window = *wp; if (callback == 0) /* can return early */ break; } else if (strcmp(buf_ret, dvi_property) == 0 && ret_window == 0) { /* match */ - ret_window = w; + ret_window = *wp; if (callback == 0) /* can return early */ break; } @@ -1196,7 +1161,7 @@ XChangeProperty(DISP, DefaultRootWindow(DISP), atom_xdvi_windows(), atom_xdvi_windows(), 32, PropModeReplace, (unsigned char *)window_list, - window_list_len / 4); + window_list_len); return ret_window; } Index: texlive-bin-2012.20120623/texk/xdvik/x_util.h =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/x_util.h 2012-06-23 19:14:31.957783059 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/x_util.h 2012-06-23 19:18:45.537791036 +0900 @@ -50,10 +50,7 @@ long, Bool, Atom, Atom *, int *, unsigned long *, unsigned long *, unsigned char **)); -extern size_t property_get_window_list(char **window_list); extern void set_dvi_property(void); -extern void set_window_id(Window w, unsigned char *data); -extern Window get_window_id(char *window_p); extern void update_window_property(Window w, Boolean prepend); extern void update_dvi_property(void); extern void property_initialize(void); Index: texlive-bin-2012.20120623/texk/xdvik/xdvi.c =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/xdvi.c 2012-06-23 19:14:31.957783059 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/xdvi.c 2012-06-23 19:18:45.537791036 +0900 @@ -3300,14 +3300,8 @@ /* Store window id for use by src_client_check(). */ { - /* was xuint32, but need 8-byte alignment on some 64-bit systems. */ - long data; -#if !(defined(WORD64) || defined(LONG64)) - data = XtWindow(globals.widgets.top_level); -#else - set_window_id(XtWindow(globals.widgets.top_level), - (unsigned char *)&data); -#endif + long data = XtWindow(globals.widgets.top_level); + XChangeProperty(DISP, DefaultRootWindow(DISP), atom_xdvi_windows(), atom_xdvi_windows(), 32, PropModePrepend, (unsigned char *)&data, 1); Index: texlive-bin-2012.20120623/texk/xdvik/xdvi.h =================================================================== --- texlive-bin-2012.20120623.orig/texk/xdvik/xdvi.h 2012-06-23 19:14:31.957783059 +0900 +++ texlive-bin-2012.20120623/texk/xdvik/xdvi.h 2012-06-23 19:18:45.545791044 +0900 @@ -188,14 +188,6 @@ #include /* get WORD64 and LONG64 */ -#ifndef WORD64 -# ifdef LONG64 -typedef unsigned int xuint32; -# else -typedef unsigned long xuint32; -# endif -#endif - #if defined(HAVE_STDINT_H) #include #elif defined(HAVE_INTTYPES_H) Index: texlive-bin-2012.20120623/texk/xdvik/m4/xdvi-func-xkbbell.m4 =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ texlive-bin-2012.20120623/texk/xdvik/m4/xdvi-func-xkbbell.m4 2012-06-24 14:41:38.141798287 +0900 @@ -0,0 +1,29 @@ +# Autoconf macros for xdvik. +# Copyright (C) 2012 Paul Vojta +# Adapted from xterm, Copyright 1997-2010,2011 by Thomas E. Dickey +# +# This file is free software; the copyright holder +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# XDVI_FUNC_XKB_BELL +# ------------------------- +# Check for whether the XkbBell() extension is present in the X libraries. + +dnl ### Check for XkbBell() functionality. Adapted from xterm's version. +AC_DEFUN([XDVI_FUNC_XKB_BELL],[ +AC_CACHE_CHECK([for XKB Bell extension], xdvi_cv_func_xkb_bell, +[xdvi_save_LIBS=$LIBS +LIBS="$X_PRE_LIBS"$1" $LIBS $X_LIBS -lX11" +AC_TRY_LINK([ +#include +#include /* has the prototype */ +],[ + Atom y; + XkbBell((Display *)0, (Window)0, 0, y); +],[xdvi_cv_func_xkb_bell=yes],[xdvi_cv_func_xkb_bell=no]) +LIBS=$xdvi_save_LIBS]) +if test "$xdvi_cv_func_xkb_bell" = yes; then + X_PRE_LIBS="$X_PRE_LIBS"$1 + AC_DEFINE([HAVE_XKB_BELL_EXT], 1, [Define if your system has XkbBell().]) +fi])