[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#591265: #591265 xterm: active icon is too big



See fix (attached), which will be part of #263

-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
# ftp://invisible-island.net/xterm/patches/temp/xterm-262a.patch.gz
# patch by Thomas E. Dickey <dickey@invisible-island.net>
# created  Wed Sep  1 00:35:26 UTC 2010
# ------------------------------------------------------------------------------
# charproc.c     |   51 ++++++++++++++++++++++++++++++++++++++++++++++-----
# fontutils.c    |   14 ++++++++------
# misc.c         |   14 +++++++-------
# ptyx.h         |    8 +++++---
# version.h      |    4 ++--
# xterm.log.html |   20 +++++++++++++++++++-
# 6 files changed, 87 insertions(+), 24 deletions(-)
# ------------------------------------------------------------------------------
Index: charproc.c
--- xterm-262+/charproc.c	2010-08-29 22:51:09.000000000 +0000
+++ xterm-262a/charproc.c	2010-08-31 23:03:49.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: charproc.c,v 1.1076 2010/08/29 22:51:09 tom Exp $ */
+/* $XTermId: charproc.c,v 1.1078 2010/08/31 23:03:49 tom Exp $ */
 
 /*
 
@@ -550,7 +550,7 @@
 #ifndef NO_ACTIVE_ICON
     Bres("activeIcon", "ActiveIcon", misc.active_icon, False),
     Ires("iconBorderWidth", XtCBorderWidth, misc.icon_border_width, 2),
-    Fres("iconFont", "IconFont", screen.fnt_icon.fs, XtDefaultFont),
+    Sres("iconFont", "IconFont", screen.icon_fontname, "nil2"),
     Cres("iconBorderColor", XtCBorderColor, misc.icon_border_pixel, XtDefaultBackground),
 #endif				/* NO_ACTIVE_ICON */
 
@@ -6369,11 +6369,17 @@
     init_Bres(screen.quiet_grab);
 
 #ifndef NO_ACTIVE_ICON
-    TScreenOf(wnew)->fnt_icon.fs = TScreenOf(request)->fnt_icon.fs;
+    init_Sres(screen.icon_fontname);
+    TScreenOf(wnew)->fnt_icon.fs = XLoadQueryFont(TScreenOf(wnew)->display,
+						  TScreenOf(wnew)->icon_fontname);
+    TRACE(("iconFont '%s' %sloaded successfully\n",
+	   TScreenOf(wnew)->icon_fontname,
+	   TScreenOf(wnew)->fnt_icon.fs ? "" : "NOT "));
     init_Bres(misc.active_icon);
     init_Ires(misc.icon_border_width);
     wnew->misc.icon_border_pixel = request->misc.icon_border_pixel;
 #endif /* NO_ACTIVE_ICON */
+
     init_Bres(misc.titeInhibit);
     init_Bres(misc.tiXtraScroll);
     init_Bres(misc.dynamicColors);
@@ -7171,14 +7177,49 @@
     screen->event_mask = values->event_mask;
 
 #ifndef NO_ACTIVE_ICON
+    /*
+     * Normally, the font-number for icon fonts does not correspond with any of
+     * the menu-selectable fonts.  If we cannot load the font given for the
+     * iconFont resource, try with font1 aka "Unreadable".
+     */
+    screen->icon_fontnum = -1;
+    if (screen->fnt_icon.fs == 0) {
+	screen->fnt_icon.fs = XLoadQueryFont(screen->display,
+					     screen->MenuFontName(fontMenu_font1));
+	TRACE(("%susing font1 '%s' as iconFont\n",
+	       (screen->fnt_icon.fs
+		? ""
+		: "NOT "),
+	       screen->MenuFontName(fontMenu_font1)));
+    }
+#if OPT_RENDERFONT
+    /*
+     * If we still have no result from iconFont resource (perhaps because fonts
+     * are missing) but are using Xft, try to use that instead.  We prefer
+     * bitmap fonts in any case, since scaled fonts are usually less readable,
+     * particularly at small sizes.
+     */
+    if (UsingRenderFont(xw)
+	&& screen->fnt_icon.fs == 0) {
+	screen->icon_fontnum = fontMenu_default;
+	screen->fnt_icon.fs = screen->fnts[0].fs;	/* need for next-if */
+	TRACE(("using TrueType font as iconFont\n"));
+    }
+#endif
     if (xw->misc.active_icon && screen->fnt_icon.fs) {
 	int iconX = 0, iconY = 0;
 	Widget shell = SHELL_OF(xw);
 	VTwin *win = &(screen->iconVwin);
+	int save_fontnum = screen->menu_font_number;
 
-	TRACE(("Initializing active-icon\n"));
-	XtVaGetValues(shell, XtNiconX, &iconX, XtNiconY, &iconY, (XtPointer) 0);
+	TRACE(("Initializing active-icon %d\n", screen->icon_fontnum));
+	screen->menu_font_number = screen->icon_fontnum;
+	XtVaGetValues(shell,
+		      XtNiconX, &iconX,
+		      XtNiconY, &iconY,
+		      (XtPointer) 0);
 	xtermComputeFontInfo(xw, &(screen->iconVwin), screen->fnt_icon.fs, 0);
+	screen->menu_font_number = save_fontnum;
 
 	/* since only one client is permitted to select for Button
 	 * events, we have to let the window manager get 'em...
Index: fontutils.c
--- xterm-262+/fontutils.c	2010-06-15 08:18:58.000000000 +0000
+++ xterm-262a/fontutils.c	2010-08-31 22:50:53.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: fontutils.c,v 1.344 2010/06/15 08:18:58 tom Exp $ */
+/* $XTermId: fontutils.c,v 1.345 2010/08/31 22:50:53 tom Exp $ */
 
 /************************************************************
 
@@ -1795,6 +1795,9 @@
     TScreen *screen = TScreenOf(xw);
 
     int i, j, width, height;
+#if OPT_RENDERFONT
+    int fontnum = screen->menu_font_number;
+#endif
 
 #if OPT_RENDERFONT
     /*
@@ -1804,9 +1807,8 @@
      * font-loading for fixed-fonts still goes on whether or not this chunk
      * overrides it.
      */
-    if (UsingRenderFont(xw)) {
+    if (UsingRenderFont(xw) && fontnum >= 0) {
 	char *face_name = getFaceName(xw, False);
-	int fontnum = screen->menu_font_number;
 	XftFont *norm = screen->renderFontNorm[fontnum].font;
 	XftFont *bold = screen->renderFontBold[fontnum].font;
 	XftFont *ital = screen->renderFontItal[fontnum].font;
@@ -1820,8 +1822,8 @@
 	    XftPattern *pat;
 	    double face_size = xw->misc.face_size[fontnum];
 
-	    TRACE(("xtermComputeFontInfo norm(face %s, size %f)\n",
-		   face_name,
+	    TRACE(("xtermComputeFontInfo font %d: norm(face %s, size %f)\n",
+		   fontnum, face_name,
 		   xw->misc.face_size[fontnum]));
 
 	    if (face_size <= 0.0) {
@@ -2030,7 +2032,7 @@
     /*
      * Are we handling a bitmap font?
      */
-    if (!UsingRenderFont(xw))
+    else
 #endif /* OPT_RENDERFONT */
     {
 	if (is_double_width_font(font) && !(screen->fnt_prop)) {
Index: misc.c
--- xterm-262+/misc.c	2010-08-30 08:26:45.000000000 +0000
+++ xterm-262a/misc.c	2010-09-01 00:19:06.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: misc.c,v 1.507 2010/08/30 08:26:45 tom Exp $ */
+/* $XTermId: misc.c,v 1.508 2010/09/01 00:19:06 tom Exp $ */
 
 /*
  * Copyright 1999-2009,2010 by Thomas E. Dickey
@@ -3450,11 +3450,11 @@
 	    result = MdFlag(xw->flags, LINEFEED);
 	    break;
 	}
-	reply.a_param[count++] = params[0];
-	reply.a_param[count++] = result;
+	reply.a_param[count++] = (ParmType) params[0];
+	reply.a_param[count++] = (ParmType) result;
     }
     reply.a_type = ANSI_CSI;
-    reply.a_nparam = count;
+    reply.a_nparam = (ParmType) count;
     reply.a_inters = '$';
     reply.a_final = 'y';
     unparseseq(xw, &reply);
@@ -3680,12 +3680,12 @@
 	    break;
 #endif /* OPT_READLINE */
 	}
-	reply.a_param[count++] = params[0];
-	reply.a_param[count++] = result;
+	reply.a_param[count++] = (ParmType) params[0];
+	reply.a_param[count++] = (ParmType) result;
     }
     reply.a_type = ANSI_CSI;
     reply.a_pintro = '?';
-    reply.a_nparam = count;
+    reply.a_nparam = (ParmType) count;
     reply.a_inters = '$';
     reply.a_final = 'y';
     unparseseq(xw, &reply);
Index: ptyx.h
--- xterm-262+/ptyx.h	2010-08-19 09:30:01.000000000 +0000
+++ xterm-262a/ptyx.h	2010-09-01 00:16:50.000000000 +0000
@@ -1,4 +1,4 @@
-/* $XTermId: ptyx.h,v 1.671 2010/08/19 09:30:01 Ryan.Johnson Exp $ */
+/* $XTermId: ptyx.h,v 1.673 2010/09/01 00:16:50 tom Exp $ */
 
 /*
  * Copyright 1999-2009,2010 by Thomas E. Dickey
@@ -1581,7 +1581,7 @@
 	long		event_mask;
 	unsigned	send_mouse_pos;	/* user wants mouse transition  */
 					/* and position information	*/
-	unsigned	ext_mode_mouse; /* support large terminals      */
+	Boolean		ext_mode_mouse; /* support large terminals      */
 	Boolean		send_focus_pos; /* user wants focus in/out info */
 	Boolean		quiet_grab;	/* true if no cursor change on focus */
 #if OPT_PASTE64
@@ -1695,7 +1695,9 @@
 	XTermFonts	fnts[fMAX];	/* normal/bold/etc for terminal	*/
 	Boolean		free_bold_box;	/* same_font_size's austerity	*/
 #ifndef NO_ACTIVE_ICON
-	XTermFonts	fnt_icon;	/* icon font */
+	XTermFonts	fnt_icon;	/* icon font			*/
+	String		icon_fontname;	/* name of icon font		*/
+	int		icon_fontnum;	/* number to use for icon font	*/
 #endif /* NO_ACTIVE_ICON */
 	int		enbolden;	/* overstrike for bold font	*/
 	XPoint		*box;		/* draw unselected cursor	*/
Index: version.h
--- xterm-262+/version.h	2010-07-16 00:42:31.000000000 +0000
+++ xterm-262a/version.h	2010-08-31 09:28:23.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * $XTermId: version.h,v 1.320 2010/07/16 00:42:31 tom Exp $
+ * $XTermId: version.h,v 1.321 2010/08/31 09:28:23 tom Exp $
  * ----------------------------------------------------------------------------
  * this file is part of xterm
  *
@@ -39,7 +39,7 @@
  * version of X to which this version of xterm has been built.  The number in
  * parentheses is my patch number (Thomas E. Dickey).
  */
-#define XTERM_PATCH   262
+#define XTERM_PATCH   263
 
 #ifndef __vendorversion__
 #define __vendorversion__ "XTerm"
Index: xterm.log.html
--- xterm-262+/xterm.log.html	2010-08-30 00:19:46.000000000 +0000
+++ xterm-262a/xterm.log.html	2010-08-31 23:16:32.000000000 +0000
@@ -31,7 +31,7 @@
  * sale, use or other dealings in this Software without prior written        *
  * authorization.                                                            *
  *****************************************************************************
-  $XTermId: xterm.log.html,v 1.965 2010/08/30 00:19:46 tom Exp $
+  $XTermId: xterm.log.html,v 1.966 2010/08/31 23:16:32 tom Exp $
   -->
 <HTML>
 <HEAD>
@@ -56,6 +56,7 @@
 is the latest version of this file.
 
 <UL>
+<LI><A HREF="#xterm_dev">Development</A>
 <LI><A HREF="#xterm_262">Patch #262 - 2010/8/30</A>
 <LI><A HREF="#xterm_261">Patch #261 - 2010/6/28</A>
 <LI><A HREF="#xterm_260">Patch #260 - 2010/6/20</A>
@@ -321,6 +322,23 @@
 <LI><A HREF="#xterm_01">Patch #1 - 1996/1/6</A>
 </UL>
 
+<H1><A NAME="xterm_dev">Development</A></H1>
+<ul>
+	<li>further extend initialization for active-icon font to check if
+	    the font was not loaded succesfully,
+	    to retry with <code>font1</code>,
+	    or as even (if TrueType fonts are used) to use a TrueType font.
+	    The retries are to help with cases as in
+	    <a href="#xterm_241">patch #241</a> where the bitmap fonts are
+	    not available.
+
+	<li>fix special case of active-icon used when TrueType font is
+	    specified for the xterm window,
+	    from <a href="#xterm_261">patch #261</a> change.
+	    In that case, the default font's size was used for layout of the
+	    active icon's window (Debian #591265).
+</ul>
+
 <H1><A NAME="xterm_262">Patch #262 - 2010/8/30</A></H1>
 <ul>
 	<li>fix a case where changing the cursor color via escape sequences

Attachment: signature.asc
Description: Digital signature


Reply to: