Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 99876. ------------------------------------------------------------ revno: 99876 committer: Dan Nicolaescu branch nick: trunk timestamp: Sun 2010-04-11 14:45:59 -0700 message: Remove C_SWITCH_SYSTEM_TEMACS. diff: === modified file 'admin/CPP-DEFINES' --- admin/CPP-DEFINES 2010-04-01 23:08:14 +0000 +++ admin/CPP-DEFINES 2010-04-11 21:45:59 +0000 @@ -106,7 +106,6 @@ CRT0_DUMMIES C_SWITCH_MACHINE C_SWITCH_SYSTEM -C_SWITCH_SYSTEM_TEMACS C_SWITCH_X_SYSTEM DATA_SEG_BITS DATA_START ------------------------------------------------------------ revno: 99875 committer: Dan Nicolaescu branch nick: trunk timestamp: Sun 2010-04-11 14:43:28 -0700 message: Remove C_SWITCH_SYSTEM_TEMACS. * s/darwin.h (C_SWITCH_SYSTEM_TEMACS): Remove. (malloc, realloc, free): Use emacs, not temacs for conditional definition. * Makefile.in (C_SWITCH_SYSTEM_TEMACS): Remove. (ALL_CFLAGS): Do not use C_SWITCH_SYSTEM_TEMACS. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2010-04-11 20:04:24 +0000 +++ src/ChangeLog 2010-04-11 21:43:28 +0000 @@ -1,5 +1,13 @@ 2010-04-11 Dan Nicolaescu + Remove C_SWITCH_SYSTEM_TEMACS. + * s/darwin.h (C_SWITCH_SYSTEM_TEMACS): Remove. + (malloc, realloc, free): Use emacs, not temacs for conditional + definition. + + * Makefile.in (C_SWITCH_SYSTEM_TEMACS): Remove. + (ALL_CFLAGS): Do not use C_SWITCH_SYSTEM_TEMACS. + Use autoconf, not cpp for some variables. * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) (C_SWITCH_X_SITE): Define using autoconf, not cpp. === modified file 'src/Makefile.in' --- src/Makefile.in 2010-04-11 20:04:24 +0000 +++ src/Makefile.in 2010-04-11 21:43:28 +0000 @@ -166,12 +166,6 @@ #define LD_SWITCH_SYSTEM_TEMACS #endif -/* Some s/SYSTEM.h files define this to request special switches - for compiling temacs. */ -#ifndef C_SWITCH_SYSTEM_TEMACS -#define C_SWITCH_SYSTEM_TEMACS -#endif - /* Some m/MACHINE.h files define this to request special switches in ld. */ #ifndef LD_SWITCH_MACHINE #define LD_SWITCH_MACHINE @@ -258,7 +252,7 @@ /* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM since it may have -I options that should override those two. */ -ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} +ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} ALL_OBJC_CFLAGS=$(ALL_CFLAGS) @GNU_OBJC_CFLAGS@ .SUFFIXES: .m === modified file 'src/s/darwin.h' --- src/s/darwin.h 2010-03-30 02:47:23 +0000 +++ src/s/darwin.h 2010-04-11 21:43:28 +0000 @@ -165,9 +165,7 @@ each); under Cocoa 31 commands are required. */ #define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_NSGUI -Xlinker -headerpad -Xlinker HEADERPAD_EXTRA -#define C_SWITCH_SYSTEM_TEMACS -Dtemacs - -#ifdef temacs +#ifdef emacs #define malloc unexec_malloc #define realloc unexec_realloc #define free unexec_free ------------------------------------------------------------ revno: 99874 committer: Dan Nicolaescu branch nick: trunk timestamp: Sun 2010-04-11 13:17:24 -0700 message: Use autoconf, not cpp for some variables. * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) (C_SWITCH_X_SITE): Define using autoconf. * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) (C_SWITCH_X_SITE): Define using autoconf. * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE): Define using autoconf, not cpp. (ALL_CFLAGS): Use them as make variables. diff: === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2010-04-07 13:43:04 +0000 +++ lib-src/ChangeLog 2010-04-11 20:17:24 +0000 @@ -1,3 +1,9 @@ +2010-04-11 Dan Nicolaescu + + * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE): Define using + autoconf, not cpp. + (ALL_CFLAGS): Use them as make variables. + 2010-04-07 Christoph (tiny change) * makefile.w32-in (OTHER_PLATFORM_SUPPORT): Use parenthesis === modified file 'lib-src/Makefile.in' --- lib-src/Makefile.in 2010-03-24 18:02:56 +0000 +++ lib-src/Makefile.in 2010-04-11 20:17:24 +0000 @@ -34,6 +34,8 @@ version=@version@ configuration=@configuration@ EXEEXT=@EXEEXT@ +C_SWITCH_SYSTEM=@c_switch_system@ +C_SWITCH_MACHINE=@c_switch_machine@ # Program name transformation. TRANSFORM = @program_transform_name@ @@ -168,14 +170,6 @@ #define LIBS_MACHINE #endif -#ifndef C_SWITCH_SYSTEM -#define C_SWITCH_SYSTEM -#endif - -#ifndef C_SWITCH_MACHINE -#define C_SWITCH_MACHINE -#endif - #undef MOVEMAIL_NEEDS_BLESSING #ifndef MAIL_USE_FLOCK #ifndef MAIL_USE_LOCKF @@ -194,11 +188,11 @@ /* Those files shared with other GNU utilities need HAVE_CONFIG_H defined before they know they can take advantage of the information in ../src/config.h. */ -ALL_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \ +ALL_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) -DHAVE_CONFIG_H \ -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CPPFLAGS} ${CFLAGS} -LINK_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \ +LINK_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) -DHAVE_CONFIG_H \ -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CFLAGS} -CPP_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \ +CPP_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) -DHAVE_CONFIG_H \ -I. -I../src -I${srcdir} -I${srcdir}/../src ${CPPFLAGS} ${CFLAGS} .SUFFIXES: .m === modified file 'lwlib/ChangeLog' --- lwlib/ChangeLog 2010-04-11 18:25:09 +0000 +++ lwlib/ChangeLog 2010-04-11 20:17:24 +0000 @@ -1,3 +1,8 @@ +2010-04-11 Dan Nicolaescu + + * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) + (C_SWITCH_X_SITE): Define using autoconf. + 2010-04-11 Jan Djärv * lwlib-Xaw.c (widget_xft_data): New for Xft data. === modified file 'lwlib/Makefile.in' --- lwlib/Makefile.in 2010-01-13 08:35:10 +0000 +++ lwlib/Makefile.in 2010-04-11 20:17:24 +0000 @@ -26,6 +26,8 @@ srcdir=@srcdir@ VPATH=@srcdir@ C_SWITCH_X_SITE=@C_SWITCH_X_SITE@ +C_SWITCH_SYSTEM=@c_switch_system@ +C_SWITCH_MACHINE=@c_switch_machine@ CC=@CC@ CFLAGS=@CFLAGS@ === modified file 'oldXMenu/ChangeLog' --- oldXMenu/ChangeLog 2010-03-10 15:17:13 +0000 +++ oldXMenu/ChangeLog 2010-04-11 20:17:24 +0000 @@ -1,3 +1,8 @@ +2010-04-11 Dan Nicolaescu + + * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) + (C_SWITCH_X_SITE): Define using autoconf. + 2010-03-10 Chong Yidong * Branch for 23.2. === modified file 'oldXMenu/Makefile.in' --- oldXMenu/Makefile.in 2010-01-13 08:35:10 +0000 +++ oldXMenu/Makefile.in 2010-04-11 20:17:24 +0000 @@ -46,6 +46,8 @@ srcdir=@srcdir@ VPATH=@srcdir@ C_SWITCH_X_SITE=@C_SWITCH_X_SITE@ +C_SWITCH_SYSTEM=@c_switch_system@ +C_SWITCH_MACHINE=@c_switch_machine@ EXTRA=insque.o CC=@CC@ ------------------------------------------------------------ revno: 99873 committer: Dan Nicolaescu branch nick: trunk timestamp: Sun 2010-04-11 13:04:24 -0700 message: Use autoconf, not cpp for some variables. * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) (C_SWITCH_X_SITE): Define using autoconf, not cpp. (ALL_CFLAGS): Use them as make variables. (really-lwlib, really-oldXMenu): Do not pass them. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2010-04-11 18:25:09 +0000 +++ src/ChangeLog 2010-04-11 20:04:24 +0000 @@ -1,3 +1,11 @@ +2010-04-11 Dan Nicolaescu + + Use autoconf, not cpp for some variables. + * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) + (C_SWITCH_X_SITE): Define using autoconf, not cpp. + (ALL_CFLAGS): Use them as make variables. + (really-lwlib, really-oldXMenu): Do not pass them. + 2010-04-11 Jan Djärv * xmenu.c (apply_systemfont_to_dialog): New. === modified file 'src/Makefile.in' --- src/Makefile.in 2010-04-01 23:08:14 +0000 +++ src/Makefile.in 2010-04-11 20:04:24 +0000 @@ -75,11 +75,14 @@ LIBXPM=@LIBXPM@ XFT_LIBS=@XFT_LIBS@ +C_SWITCH_SYSTEM=@c_switch_system@ +C_SWITCH_MACHINE=@c_switch_machine@ + +C_SWITCH_X_SITE=@C_SWITCH_X_SITE@ + # ========================== start of cpp stuff ======================= /* From here on, comments must be done in C syntax. */ -C_SWITCH_SYSTEM= - /* just to be sure the sh is used */ SHELL=/bin/sh @@ -180,16 +183,6 @@ #define LD_SWITCH_MACHINE_TEMACS #endif -/* Some m/MACHINE.h files define this to request special switches in cc. */ -#ifndef C_SWITCH_MACHINE -#define C_SWITCH_MACHINE -#endif - -/* Some s/SYSTEM.h files define this to request special switches in cc. */ -#ifndef C_SWITCH_SYSTEM -#define C_SWITCH_SYSTEM -#endif - /* These macros are for switches specifically related to X Windows. */ #ifndef C_SWITCH_X_MACHINE #define C_SWITCH_X_MACHINE @@ -199,10 +192,6 @@ #define C_SWITCH_X_SYSTEM #endif -#ifndef C_SWITCH_X_SITE -#define C_SWITCH_X_SITE -#endif - #ifndef LD_SWITCH_X_SITE #define LD_SWITCH_X_SITE #endif @@ -269,7 +258,7 @@ /* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM since it may have -I options that should override those two. */ -ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} +ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} ALL_OBJC_CFLAGS=$(ALL_CFLAGS) @GNU_OBJC_CFLAGS@ .SUFFIXES: .m @@ -924,9 +913,6 @@ /* Encode the values of these two macros in Make variables, so we can use $(...) to substitute their values within "...". */ -C_SWITCH_MACHINE_1 = C_SWITCH_MACHINE -C_SWITCH_SYSTEM_1 = C_SWITCH_SYSTEM -C_SWITCH_X_SITE_1 = C_SWITCH_X_SITE C_SWITCH_X_MACHINE_1 = C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM_1 = C_SWITCH_X_SYSTEM @@ -936,11 +922,8 @@ really-lwlib: cd ${lwlibdir}; ${MAKE} ${MFLAGS} \ CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \ - "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \ "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \ - "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \ - "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \ - "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)" + "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" @true /* make -t should not create really-lwlib. */ .PHONY: really-lwlib #else /* not USE_X_TOOLKIT */ @@ -949,11 +932,8 @@ really-oldXMenu: cd ${oldXMenudir}; ${MAKE} ${MFLAGS} \ CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \ - "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \ "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \ - "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \ - "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \ - "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)" + "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" @true /* make -t should not create really-oldXMenu. */ .PHONY: really-oldXMenu #endif /* not USE_X_TOOLKIT */ ------------------------------------------------------------ revno: 99872 [merge] committer: Jan D. branch nick: trunk timestamp: Sun 2010-04-11 20:26:13 +0200 message: Use XFT in Lucid dialogs if available. * xmenu.c (apply_systemfont_to_dialog): New. (create_and_show_dialog): Call apply_systemfont_to_dialog if HAVE_XFT. * lwlib-Xaw.c (widget_xft_data): New for Xft data. (fill_xft_data, openFont, get_text_width_and_height) (draw_text, set_text, find_xft_data, command_press) (command_reset): New functions. (xaw_update_one_widget): Call set_text for dialog and buttons if HAVE_XFT. Also set internalHeight for buttons. (xaw_destroy_instance): Free all Xft related data. (button_actions, buttonTrans): New structures. (make_dialog): Call XtAppAddActions for button_actions. Find xft font to use and call fill_xft_data for widgets. (xaw_create_dialog): Pass instance parameter to make_dialog. * lwlib-int.h (_widget_instance): Add Xft data if HAVE_XFT. Override translations for buttons. If depth is 16 or more, tell Xaw3d to not be nice to colormap. Remove separator widget, use XtNhorizDistance on first right button instead. * xresources.texi (Lucid Resources): Mention faceName for dialogs. diff: === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2010-04-08 16:20:32 +0000 +++ doc/emacs/ChangeLog 2010-04-11 18:25:09 +0000 @@ -1,3 +1,7 @@ +2010-04-11 Jan Djärv + + * xresources.texi (Lucid Resources): Mention faceName for dialogs. + 2010-04-08 Jan Djärv * xresources.texi (Lucid Resources): Mention faceName to set Xft fonts. === modified file 'doc/emacs/xresources.texi' --- doc/emacs/xresources.texi 2010-04-08 16:20:32 +0000 +++ doc/emacs/xresources.texi 2010-04-11 18:25:09 +0000 @@ -399,8 +399,9 @@ @end table @node Lucid Resources -@appendixsec Lucid Menu X Resources +@appendixsec Lucid Menu And Dialog X Resources @cindex Menu X Resources (Lucid widgets) +@cindex Dialog X Resources (Lucid widgets) @cindex Lucid Widget X Resources @ifnottex @@ -434,12 +435,13 @@ To specify a font, use fontconfig font names as values to the @code{faceName} resource. -If Emacs is not built with the Xft library, Lucid menus can only display -old style fonts. If Emacs is built with Xft and you prefer the old fonts, -you have to specify @samp{none} to @code{faceName}: +If Emacs is not built with the Xft library, Lucid menus and dialogs can only +display old style fonts. If Emacs is built with Xft and you prefer the old +fonts, you have to specify @samp{none} to @code{faceName}: @example Emacs.pane.menubar.faceName: none +Emacs.pane.dialog.faceName: none @end example @noindent @@ -477,7 +479,7 @@ For dialog boxes, use @samp{dialog*}: @example -Emacs.dialog*.font: 8x16 +Emacs.dialog*.faceName: Sans-12 @end example @noindent === modified file 'etc/NEWS' --- etc/NEWS 2010-04-09 15:35:30 +0000 +++ etc/NEWS 2010-04-11 18:25:09 +0000 @@ -65,7 +65,8 @@ ** GTK scroll-bars are now placed on the right by default. Use `set-scroll-bar-mode' to change this. -** Lucid menus can display antialiased fonts if Emacs is build with Xft. +** Lucid menus and dialogs can display antialiased fonts if Emacs is built +with Xft. ** New scrolling commands `scroll-up-command' and `scroll-down-command' (bound to [next] and [prior]) does not signal errors at top/bottom === modified file 'lwlib/ChangeLog' --- lwlib/ChangeLog 2010-04-08 16:20:32 +0000 +++ lwlib/ChangeLog 2010-04-11 18:25:09 +0000 @@ -1,3 +1,23 @@ +2010-04-11 Jan Djärv + + * lwlib-Xaw.c (widget_xft_data): New for Xft data. + (fill_xft_data, openFont, get_text_width_and_height) + (draw_text, set_text, find_xft_data, command_press) + (command_reset): New functions. + (xaw_update_one_widget): Call set_text for dialog and buttons + if HAVE_XFT. Also set internalHeight for buttons. + (xaw_destroy_instance): Free all Xft related data. + (button_actions, buttonTrans): New structures. + (make_dialog): Call XtAppAddActions for button_actions. + Find xft font to use and call fill_xft_data for widgets. + (xaw_create_dialog): Pass instance parameter to make_dialog. + + * lwlib-int.h (_widget_instance): Add Xft data if HAVE_XFT. + Override translations for buttons. If depth is 16 or more, tell + Xaw3d to not be nice to colormap. + Remove separator widget, use XtNhorizDistance on first right button + instead. + 2010-04-08 Jan Djärv * xlwmenu.c (xlwmenu_default_font): Make static. === modified file 'lwlib/lwlib-Xaw.c' --- lwlib/lwlib-Xaw.c 2010-01-13 08:35:10 +0000 +++ lwlib/lwlib-Xaw.c 2010-04-11 18:25:09 +0000 @@ -54,6 +54,22 @@ #include +#ifdef HAVE_XFT +#include + +struct widget_xft_data +{ + Widget widget; + XftFont *xft_font; + XftDraw *xft_draw; + XftColor xft_fg, xft_bg; + int p_width, p_height; + Pixmap p; +}; + + +#endif + static void xaw_generic_callback (/*Widget, XtPointer, XtPointer*/); @@ -130,6 +146,207 @@ } #endif +#ifdef HAVE_XFT +static void +fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font) +{ + data->widget = widget; + data->xft_font = font; + Pixel bg, fg; + XColor colors[2]; + int screen = XScreenNumberOfScreen (XtScreen (widget)); + + XtVaGetValues (widget, + XtNbackground, &bg, + XtNforeground, &fg, + NULL); + + colors[0].pixel = data->xft_fg.pixel = fg; + colors[1].pixel = data->xft_bg.pixel = bg; + XQueryColors (XtDisplay (widget), + DefaultColormapOfScreen (XtScreen (widget)), + colors, 2); + + data->xft_fg.color.alpha = 0xFFFF; + data->xft_fg.color.red = colors[0].red; + data->xft_fg.color.green = colors[0].green; + data->xft_fg.color.blue = colors[0].blue; + data->xft_bg.color.alpha = 0xFFFF; + data->xft_bg.color.red = colors[1].red; + data->xft_bg.color.green = colors[1].green; + data->xft_bg.color.blue = colors[1].blue; + + data->p = None; + data->xft_draw = 0; + data->p_width = data->p_height = 0; +} + +static XftFont* +openFont (Widget widget, char *name) +{ + char *fname = name; + int screen = XScreenNumberOfScreen (XtScreen (widget)); + int len = strlen (fname), i = len-1; + XftFont *fn; + + /* Try to convert Gtk-syntax (Sans 9) to Xft syntax Sans-9. */ + while (i > 0 && isdigit (fname[i])) + --i; + if (fname[i] == ' ') + { + fname = xstrdup (name); + fname[i] = '-'; + } + + fn = XftFontOpenName (XtDisplay (widget), screen, fname); + if (fname != name) free (fname); + + return fn; +} + +static int +get_text_width_and_height (Widget widget, char *text, + XftFont *xft_font, + int *height) +{ + int w = 0, h = 0; + char *bp = text; + + while (bp && *bp != '\0') + { + XGlyphInfo gi; + char *cp = strchr (bp, '\n'); + XftTextExtentsUtf8 (XtDisplay (widget), xft_font, + (FcChar8 *) bp, + cp ? cp - bp : strlen (bp), + &gi); + bp = cp ? cp + 1 : NULL; + h += xft_font->height; + if (w < gi.width) w = gi.width; + } + + *height = h; + return w; +} + +static void +draw_text (struct widget_xft_data *data, char *lbl, int inverse) +{ + Screen *sc = XtScreen (data->widget); + int screen = XScreenNumberOfScreen (sc); + int y = data->xft_font->ascent; + int x = inverse ? 0 : 2; + char *bp = lbl; + + data->xft_draw = XftDrawCreate (XtDisplay (data->widget), + data->p, + DefaultVisual (XtDisplay (data->widget), + screen), + DefaultColormapOfScreen (sc)); + XftDrawRect (data->xft_draw, + inverse ? &data->xft_fg : &data->xft_bg, + 0, 0, data->p_width, data->p_height); + + if (!inverse) y += 2; + while (bp && *bp != '\0') + { + char *cp = strchr (bp, '\n'); + XftDrawStringUtf8 (data->xft_draw, + inverse ? &data->xft_bg : &data->xft_fg, + data->xft_font, x, y, bp, cp ? cp - bp : strlen (bp)); + bp = cp ? cp + 1 : NULL; + /* 1.2 gives reasonable line spacing. */ + y += data->xft_font->height * 1.2; + } + +} + + +static void +set_text (struct widget_xft_data *data, Widget toplevel, char *lbl, int margin) +{ + int screen = XScreenNumberOfScreen (XtScreen (data->widget)); + int width, height; + + width = get_text_width_and_height (data->widget, lbl, data->xft_font, + &height); + data->p_width = width + margin; + data->p_height = height + margin; + + data->p = XCreatePixmap (XtDisplay (data->widget), + XtWindow (toplevel), + data->p_width, + data->p_height, + DefaultDepthOfScreen (XtScreen (data->widget))); + draw_text (data, lbl, 0); + XtVaSetValues (data->widget, XtNbitmap, data->p, NULL); +} + +static struct widget_xft_data * +find_xft_data (Widget widget) +{ + widget_instance *inst = NULL; + Widget parent = XtParent (widget); + struct widget_xft_data *data = NULL; + int nr; + while (parent && !inst) + { + inst = lw_get_widget_instance (parent); + parent = XtParent (parent); + } + if (!inst || !inst->xft_data || !inst->xft_data[0].xft_font) return; + + for (nr = 0; data == NULL && nr < inst->nr_xft_data; ++nr) + { + if (inst->xft_data[nr].widget == widget) + data = &inst->xft_data[nr]; + } + + return data; +} + +static void +command_press (Widget widget, + XEvent* event, + String *params, + Cardinal *num_params) +{ + struct widget_xft_data *data = find_xft_data (widget); + if (data) + { + char *lbl; + /* Since this isn't used for rectangle buttons, use it to for armed. */ + XtVaSetValues (widget, XtNcornerRoundPercent, 1, NULL); + + XtVaGetValues (widget, XtNlabel, &lbl, NULL); + draw_text (data, lbl, 1); + } +} + +static void +command_reset (Widget widget, + XEvent* event, + String *params, + Cardinal *num_params) +{ + struct widget_xft_data *data = find_xft_data (widget); + if (data) + { + Dimension cr; + XtVaGetValues (widget, XtNcornerRoundPercent, &cr, NULL); + if (cr == 1) + { + char *lbl; + XtVaSetValues (widget, XtNcornerRoundPercent, 0, NULL); + XtVaGetValues (widget, XtNlabel, &lbl, NULL); + draw_text (data, lbl, 0); + } + } +} + + +#endif + void #ifdef PROTOTYPES xaw_update_one_widget (widget_instance *instance, Widget widget, @@ -150,15 +367,21 @@ #endif if (XtIsSubclass (widget, dialogWidgetClass)) { - Arg al[1]; - int ac = 0; - XtSetArg (al[ac], XtNlabel, val->contents->value); ac++; - XtSetValues (widget, al, ac); + +#ifdef HAVE_XFT + if (instance->xft_data && instance->xft_data[0].xft_font) + { + set_text (&instance->xft_data[0], instance->parent, + val->contents->value, 10); + } +#endif + XtVaSetValues (widget, XtNlabel, val->contents->value, NULL); } else if (XtIsSubclass (widget, commandWidgetClass)) { Dimension bw = 0; - Arg al[3]; + Arg al[10]; + int ac = 0; XtVaGetValues (widget, XtNborderWidth, &bw, NULL); if (bw == 0) @@ -174,10 +397,30 @@ } XtSetSensitive (widget, val->enabled); - XtSetArg (al[0], XtNlabel, val->value); + XtSetArg (al[ac], XtNlabel, val->value);ac++; /* Force centered button text. Se above. */ - XtSetArg (al[1], XtNjustify, XtJustifyCenter); - XtSetValues (widget, al, 2); + XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++; +#ifdef HAVE_XFT + if (instance->xft_data && instance->xft_data[0].xft_font) + { + int th; + int nr; + for (nr = 0; nr < instance->nr_xft_data; ++nr) + if (instance->xft_data[nr].widget == widget) + break; + if (nr < instance->nr_xft_data) + { + set_text (&instance->xft_data[nr], instance->parent, + val->value, 6); + + /* Must set internalHeight to twice the highlight thickness, + or else it gets overwritten by our pixmap. Probably a bug. */ + XtVaGetValues (widget, XtNhighlightThickness, &th, NULL); + XtSetArg (al[ac], XtNinternalHeight, 2*th);ac++; + } + } +#endif + XtSetValues (widget, al, ac); XtRemoveAllCallbacks (widget, XtNcallback); XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance); } @@ -198,6 +441,28 @@ xaw_destroy_instance (instance) widget_instance *instance; { +#ifdef HAVE_XFT + if (instance->xft_data) + { + int i; + for (i = 0; i < instance->nr_xft_data; ++i) + { + if (instance->xft_data[i].xft_draw) + XftDrawDestroy (instance->xft_data[i].xft_draw); + if (instance->xft_data[i].p != None) + { + XtVaSetValues (instance->xft_data[i].widget, XtNbitmap, None, + NULL); + XFreePixmap (XtDisplay (instance->widget), + instance->xft_data[i].p); + } + } + if (instance->xft_data[0].xft_font) + XftFontClose (XtDisplay (instance->widget), + instance->xft_data[0].xft_font); + free (instance->xft_data); + } +#endif if (XtIsSubclass (instance->widget, dialogWidgetClass)) /* Need to destroy the Shell too. */ XtDestroyWidget (XtParent (instance->widget)); @@ -298,8 +563,21 @@ }; static Boolean actions_initted = False; +#ifdef HAVE_XFT +static XtActionsRec button_actions[] = + { + { "my_reset", command_reset }, + { "my_press", command_press }, + }; +char buttonTrans[] = + ": reset() my_reset()\n" + ": set() my_press()\n" + ": my_reset() notify() unset()\n"; +#endif + static Widget -make_dialog (name, parent, pop_up_p, shell_title, icon_name, text_input_slot, radio_box, list, left_buttons, right_buttons) +make_dialog (name, parent, pop_up_p, shell_title, icon_name, text_input_slot, + radio_box, list, left_buttons, right_buttons, instance) char* name; Widget parent; Boolean pop_up_p; @@ -310,6 +588,7 @@ Boolean list; int left_buttons; int right_buttons; + widget_instance *instance; { Arg av [20]; int ac = 0; @@ -319,6 +598,10 @@ Widget dialog; Widget button; XtTranslations override; +#ifdef HAVE_XFT + XftFont *xft_font = 0; + XtTranslations button_override; +#endif if (! pop_up_p) abort (); /* not implemented */ if (text_input_slot) abort (); /* not implemented */ @@ -330,6 +613,10 @@ XtAppContext app = XtWidgetToApplicationContext (parent); XtAppAddActions (app, xaw_actions, sizeof (xaw_actions) / sizeof (xaw_actions[0])); +#ifdef HAVE_XFT + XtAppAddActions (app, button_actions, + sizeof (button_actions) / sizeof (button_actions[0])); +#endif actions_initted = True; } @@ -351,6 +638,49 @@ override = XtParseTranslationTable (dialogOverride); XtOverrideTranslations (dialog, override); +#ifdef HAVE_XFT + { + int num; + Widget *ch = NULL; + Widget w = 0; + XtVaGetValues (dialog, + XtNnumChildren, &num, + XtNchildren, &ch, NULL); + for (i = 0; i < num; ++i) + { + if (!XtIsSubclass (ch[i], commandWidgetClass) + && XtIsSubclass (ch[i], labelWidgetClass)) + { + w = ch[i]; + break; + } + } + instance->xft_data = 0; + instance->nr_xft_data = 0; + if (w) + { + XtResource rec[] = + { { "faceName", "FaceName", XtRString, sizeof(String), 0, XtRString, + (XtPointer)"Sans-14" }}; + char *faceName; + XtVaGetSubresources (dialog, &faceName, "Dialog", "dialog", + rec, 1, 0, NULL); + if (strcmp ("none", faceName) != 0) + xft_font = openFont (dialog, faceName); + if (xft_font) + { + instance->nr_xft_data = left_buttons + right_buttons + 1; + instance->xft_data = calloc (instance->nr_xft_data, + sizeof(*instance->xft_data)); + + fill_xft_data (&instance->xft_data[0], w, xft_font); + } + } + + button_override = XtParseTranslationTable (buttonTrans); + } +#endif + bc = 0; button = 0; for (i = 0; i < left_buttons; i++) @@ -362,51 +692,56 @@ XtSetArg (av [ac], XtNtop, XtChainBottom); ac++; XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++; XtSetArg (av [ac], XtNresizable, True); ac++; +#ifdef HAVE_XAW3D + if (DefaultDepthOfScreen (XtScreen (dialog)) >= 16) + { + /* Turn of dithered shadow if we can. Looks bad */ + XtSetArg (av [ac], "beNiceToColormap", False); ac++; + } +#endif sprintf (button_name, "button%d", ++bc); button = XtCreateManagedWidget (button_name, commandWidgetClass, dialog, av, ac); +#ifdef HAVE_XFT + if (xft_font) + { + fill_xft_data (&instance->xft_data[bc], button, xft_font); + XtOverrideTranslations (button, button_override); + } +#endif } - if (right_buttons) - { - /* Create a separator - I want the separator to take up the slack between the buttons on - the right and the buttons on the left (that is I want the buttons - after the separator to be packed against the right edge of the - window) but I can't seem to make it do it. - */ - ac = 0; - XtSetArg (av [ac], XtNfromHoriz, button); ac++; -/* XtSetArg (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */ - XtSetArg (av [ac], XtNleft, XtChainLeft); ac++; - XtSetArg (av [ac], XtNright, XtChainRight); ac++; - XtSetArg (av [ac], XtNtop, XtChainBottom); ac++; - XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++; - XtSetArg (av [ac], XtNlabel, ""); ac++; - XtSetArg (av [ac], XtNwidth, 30); ac++; /* #### aaack!! */ - XtSetArg (av [ac], XtNborderWidth, 0); ac++; - XtSetArg (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++; - XtSetArg (av [ac], XtNresizable, False); ac++; - XtSetArg (av [ac], XtNsensitive, False); ac++; - button = XtCreateManagedWidget ("separator", - /* labelWidgetClass, */ - /* This has to be Command to fake out - the Dialog widget... */ - commandWidgetClass, - dialog, av, ac); - } for (i = 0; i < right_buttons; i++) { ac = 0; XtSetArg (av [ac], XtNfromHoriz, button); ac++; + if (i == 0) + { + /* Separator to the other buttons. */ + XtSetArg (av [ac], XtNhorizDistance, 30); ac++; + } XtSetArg (av [ac], XtNleft, XtChainRight); ac++; XtSetArg (av [ac], XtNright, XtChainRight); ac++; XtSetArg (av [ac], XtNtop, XtChainBottom); ac++; XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++; XtSetArg (av [ac], XtNresizable, True); ac++; +#ifdef HAVE_XAW3D + if (DefaultDepthOfScreen (XtScreen (dialog)) >= 16) + { + /* Turn of dithered shadow if we can. Looks bad */ + XtSetArg (av [ac], "beNiceToColormap", False); ac++; + } +#endif sprintf (button_name, "button%d", ++bc); button = XtCreateManagedWidget (button_name, commandWidgetClass, dialog, av, ac); +#ifdef HAVE_XFT + if (xft_font) + { + fill_xft_data (&instance->xft_data[bc], button, xft_font); + XtOverrideTranslations (button, button_override); + } +#endif } return dialog; @@ -472,8 +807,7 @@ widget = make_dialog (name, parent, pop_up_p, shell_name, icon_name, text_input_slot, radio_box, - list, left_buttons, right_buttons); - + list, left_buttons, right_buttons, instance); return widget; } === modified file 'lwlib/lwlib-int.h' --- lwlib/lwlib-int.h 2010-01-13 08:35:10 +0000 +++ lwlib/lwlib-int.h 2010-04-11 18:25:09 +0000 @@ -28,11 +28,17 @@ extern char *safe_strdup __P ((const char *)); +struct widget_xft_data; + typedef struct _widget_instance { Widget widget; Widget parent; Boolean pop_up_p; +#ifdef HAVE_XFT + struct widget_xft_data *xft_data; + int nr_xft_data; +#endif struct _widget_info* info; struct _widget_instance* next; } widget_instance; === modified file 'src/ChangeLog' --- src/ChangeLog 2010-04-11 16:15:09 +0000 +++ src/ChangeLog 2010-04-11 18:25:09 +0000 @@ -1,3 +1,8 @@ +2010-04-11 Jan Djärv + + * xmenu.c (apply_systemfont_to_dialog): New. + (create_and_show_dialog): Call apply_systemfont_to_dialog if HAVE_XFT. + 2010-04-11 Stefan Monnier * process.c (exec_sentinel): Preserve current-buffer. === modified file 'src/xmenu.c' --- src/xmenu.c 2010-04-08 16:20:32 +0000 +++ src/xmenu.c 2010-04-11 18:25:09 +0000 @@ -954,6 +954,19 @@ #ifdef USE_LUCID static void +apply_systemfont_to_dialog (w) + Widget w; +{ + const char *fn = xsettings_get_system_normal_font (); + if (fn) + { + XrmDatabase db = XtDatabase (XtDisplay (w)); + if (db) + XrmPutStringResource (&db, "*dialog.faceName", fn); + } +} + +static void apply_systemfont_to_menu (w) Widget w; { @@ -964,15 +977,15 @@ if (XtIsShell (w)) /* popup menu */ { - Widget *childs[1]; + Widget *childs = NULL; int num = 0; XtVaGetValues (w, XtNnumChildren, &num, NULL); if (num != 1) return; /* Should only be one. */ childs[0] = 0; - XtVaGetValues (w, XtNchildren, childs, NULL); - if (childs[0] && *childs[0]) w = *childs[0]; + XtVaGetValues (w, XtNchildren, &childs, NULL); + if (childs && *childs) w = *childs; } /* Only use system font if the default is used for the menu. */ @@ -2047,11 +2060,13 @@ abort(); dialog_id = widget_id_tick++; +#ifdef HAVE_XFT + apply_systemfont_to_dialog (f->output_data.x->widget); +#endif lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, f->output_data.x->widget, 1, 0, dialog_selection_callback, 0, 0); lw_modify_all_widgets (dialog_id, first_wv->contents, True); - /* Display the dialog box. */ lw_pop_up_all_widgets (dialog_id); popup_activated_flag = 1; ------------------------------------------------------------ revno: 99871 committer: Stefan Monnier branch nick: trunk timestamp: Sun 2010-04-11 12:15:09 -0400 message: * process.c (exec_sentinel): Preserve current-buffer. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2010-04-11 15:53:13 +0000 +++ src/ChangeLog 2010-04-11 16:15:09 +0000 @@ -1,5 +1,7 @@ 2010-04-11 Stefan Monnier + * process.c (exec_sentinel): Preserve current-buffer. + * process.c (read_process_output): Move the save-current-buffer to apply to both the filter and the non-filter branches. === modified file 'src/process.c' --- src/process.c 2010-04-11 15:53:13 +0000 +++ src/process.c 2010-04-11 16:15:09 +0000 @@ -6840,6 +6840,11 @@ XSETBUFFER (obuffer, current_buffer); okeymap = current_buffer->keymap; + /* There's no good reason to let sentinels change the current + buffer, and many callers of accept-process-output, sit-for, and + friends don't expect current-buffer to be changed from under them. */ + record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + sentinel = p->sentinel; if (NILP (sentinel)) return; ------------------------------------------------------------ revno: 99870 committer: Stefan Monnier branch nick: trunk timestamp: Sun 2010-04-11 11:53:13 -0400 message: (read_process_output): Move the save-current-buffer to apply to both the filter and the non-filter branches. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2010-04-10 20:38:48 +0000 +++ src/ChangeLog 2010-04-11 15:53:13 +0000 @@ -1,3 +1,8 @@ +2010-04-11 Stefan Monnier + + * process.c (read_process_output): Move the save-current-buffer to + apply to both the filter and the non-filter branches. + 2010-04-10 Dan Nicolaescu * s/msdos.h (UNEXEC): New definition. === modified file 'src/process.c' --- src/process.c 2010-04-02 03:10:33 +0000 +++ src/process.c 2010-04-11 15:53:13 +0000 @@ -5314,6 +5314,8 @@ struct coding_system *coding = proc_decode_coding_system[channel]; int carryover = p->decoding_carryover; int readmax = 4096; + int count = SPECPDL_INDEX (); + Lisp_Object odeactivate; chars = (char *) alloca (carryover + readmax); if (carryover) @@ -5386,15 +5388,16 @@ /* Now set NBYTES how many bytes we must decode. */ nbytes += carryover; + odeactivate = Vdeactivate_mark; + /* There's no good reason to let process filters change the current + buffer, and many callers of accept-process-output, sit-for, and + friends don't expect current-buffer to be changed from under them. */ + record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + /* Read and dispose of the process output. */ outstream = p->filter; if (!NILP (outstream)) { - /* We inhibit quit here instead of just catching it so that - hitting ^G when a filter happens to be running won't screw - it up. */ - int count = SPECPDL_INDEX (); - Lisp_Object odeactivate; Lisp_Object obuffer, okeymap; Lisp_Object text; int outer_running_asynch_code = running_asynch_code; @@ -5402,10 +5405,12 @@ /* No need to gcpro these, because all we do with them later is test them for EQness, and none of them should be a string. */ - odeactivate = Vdeactivate_mark; XSETBUFFER (obuffer, current_buffer); okeymap = current_buffer->keymap; + /* We inhibit quit here instead of just catching it so that + hitting ^G when a filter happens to be running won't screw + it up. */ specbind (Qinhibit_quit, Qt); specbind (Qlast_nonmenu_event, Qt); @@ -5474,9 +5479,6 @@ restore_search_regs (); running_asynch_code = outer_running_asynch_code; - /* Handling the process output should not deactivate the mark. */ - Vdeactivate_mark = odeactivate; - /* Restore waiting_for_user_input_p as it was when we were called, in case the filter clobbered it. */ waiting_for_user_input_p = waiting; @@ -5492,27 +5494,19 @@ cause trouble (for example it would make sit_for return). */ if (waiting_for_user_input_p == -1) record_asynch_buffer_change (); - - unbind_to (count, Qnil); - return nbytes; } /* If no filter, write into buffer if it isn't dead. */ - if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) + else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) { Lisp_Object old_read_only; int old_begv, old_zv; int old_begv_byte, old_zv_byte; - Lisp_Object odeactivate; int before, before_byte; int opoint_byte; Lisp_Object text; struct buffer *b; - int count = SPECPDL_INDEX (); - - odeactivate = Vdeactivate_mark; - - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + Fset_buffer (p->buffer); opoint = PT; opoint_byte = PT_BYTE; @@ -5610,13 +5604,14 @@ if (old_begv != BEGV || old_zv != ZV) Fnarrow_to_region (make_number (old_begv), make_number (old_zv)); - /* Handling the process output should not deactivate the mark. */ - Vdeactivate_mark = odeactivate; current_buffer->read_only = old_read_only; SET_PT_BOTH (opoint, opoint_byte); - unbind_to (count, Qnil); } + /* Handling the process output should not deactivate the mark. */ + Vdeactivate_mark = odeactivate; + + unbind_to (count, Qnil); return nbytes; } ------------------------------------------------------------ revno: 99869 committer: Chong Yidong branch nick: trunk timestamp: Sat 2010-04-10 19:54:50 -0400 message: Update comint-password-prompt-regexp (Bug#2817). * comint.el (comint-password-prompt-regexp): Use regexp-opt, and recognize ssh-keygen prompt (Bug#2817). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-04-10 15:51:46 +0000 +++ lisp/ChangeLog 2010-04-10 23:54:50 +0000 @@ -1,3 +1,8 @@ +2010-04-10 Jari Aalto + + * comint.el (comint-password-prompt-regexp): Use regexp-opt, and + recognize ssh-keygen prompt (Bug#2817). + 2010-04-10 Michael Albinus * net/tramp.el (tramp-do-copy-or-rename-file): Add progress reporter. === modified file 'lisp/comint.el' --- lisp/comint.el 2010-01-13 08:35:10 +0000 +++ lisp/comint.el 2010-04-10 23:54:50 +0000 @@ -340,11 +340,17 @@ ;; Some implementations of passwd use "Password (again)" as the 2nd prompt. ;; Something called "perforce" uses "Enter password:". (defcustom comint-password-prompt-regexp - "\\(\\(Enter \\|[Oo]ld \\|[Nn]ew \\|'s \\|login \\|\ -Kerberos \\|CVS \\|UNIX \\| SMB \\|LDAP \\|\\[sudo] \\|^\\)\ -\[Pp]assword\\( (again)\\)?\\|\ -pass phrase\\|\\(Enter \\|Repeat \\|Bad \\)?[Pp]assphrase\\)\ -\\(?:, try again\\)?\\(?: for [^:]+\\)?:\\s *\\'" + (concat + "^\\(" + (regexp-opt + '("Enter" "Enter same" "Old" "old" "New" "new" "'s" "login" + "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "[sudo]" "Repeat" "Bad")) + " +\\)?" + (regexp-opt + '("password" "Password" "passphrase" "Passphrase" + "pass phrase" "Pass phrase")) + "\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?\ +\\(?: for [^:]+\\)?:\\s *\\'") "Regexp matching prompts for passwords in the inferior process. This is used by `comint-watch-for-password-prompt'." :type 'regexp ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.