Query font for status window height

This commit is contained in:
Ray Chason
2026-08-10 09:28:03 +03:00
committed by Pasi Kallinen
parent 647fd71a2d
commit a7eb50fb36
2 changed files with 17 additions and 12 deletions
+10 -9
View File
@@ -749,27 +749,28 @@ nhFreePixel(
Dimension
nhFontHeight(Widget w)
{
Arg args[1];
XFontStruct *fs;
#ifdef _XawTextSink_h
Widget sink;
Widget sink = NULL;
XawTextPosition pos = 0;
int resWidth, resHeight;
Arg args[1];
XtSetArg(args[0], XtNtextSink, &sink);
XtGetValues(w, args, 1);
XawTextSinkFindPosition(sink, pos, 0, 0, 0, &pos, &resWidth, &resHeight);
return resHeight;
#else
XFontStruct *fs;
Arg args[1];
if (sink != NULL) {
XawTextSinkFindPosition(sink, pos, 0, 0, 0, &pos, &resWidth, &resHeight);
return resHeight;
}
#endif
XtSetArg(args[0], XtNfont, &fs);
XtGetValues(w, args, 1);
/* Assume font height is ascent + descent. */
return = fs->ascent + fs->descent;
#endif
return fs->ascent + fs->descent;
}
static String *default_resource_data = 0, /* NULL-terminated arrays */
+7 -3
View File
@@ -1113,6 +1113,12 @@ create_tty_status(Widget parent, Widget top)
X11_status_widget = XtCreateManagedWidget("status_form", windowWidgetClass,
form, args, num_args);
int height = nhFontHeight(X11_status_widget) * 3;
num_args = 0;
XtSetArg(args[num_args], XtNheight, height); num_args++;
XtSetValues(form, args, num_args);
XtSetValues(X11_status_widget, args, num_args);
XtAddCallback(X11_status_widget, XtNexposeCallback, tty_status_exposed,
(XtPointer) 0);
@@ -1194,15 +1200,13 @@ tty_status_redraw(Widget w)
};
Arg args[5];
int num_args;
XFontStruct *font;
Dimension width;
/* Get the height of the font and the width of the widget */
num_args = 0;
XtSetArg(args[num_args], XtNfont, &font); num_args++;
XtSetArg(args[num_args], XtNwidth, &width); num_args++;
XtGetValues(w, args, num_args);
int height = font->max_bounds.ascent + font->max_bounds.descent;
int height = nhFontHeight(w);
int x = 0;
int y = 0;