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 Dimension
nhFontHeight(Widget w) nhFontHeight(Widget w)
{ {
Arg args[1];
XFontStruct *fs;
#ifdef _XawTextSink_h #ifdef _XawTextSink_h
Widget sink; Widget sink = NULL;
XawTextPosition pos = 0; XawTextPosition pos = 0;
int resWidth, resHeight; int resWidth, resHeight;
Arg args[1];
XtSetArg(args[0], XtNtextSink, &sink); XtSetArg(args[0], XtNtextSink, &sink);
XtGetValues(w, args, 1); XtGetValues(w, args, 1);
XawTextSinkFindPosition(sink, pos, 0, 0, 0, &pos, &resWidth, &resHeight); if (sink != NULL) {
return resHeight; XawTextSinkFindPosition(sink, pos, 0, 0, 0, &pos, &resWidth, &resHeight);
#else return resHeight;
XFontStruct *fs; }
Arg args[1]; #endif
XtSetArg(args[0], XtNfont, &fs); XtSetArg(args[0], XtNfont, &fs);
XtGetValues(w, args, 1); XtGetValues(w, args, 1);
/* Assume font height is ascent + descent. */ /* Assume font height is ascent + descent. */
return = fs->ascent + fs->descent; return fs->ascent + fs->descent;
#endif
} }
static String *default_resource_data = 0, /* NULL-terminated arrays */ 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, X11_status_widget = XtCreateManagedWidget("status_form", windowWidgetClass,
form, args, num_args); 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, XtAddCallback(X11_status_widget, XtNexposeCallback, tty_status_exposed,
(XtPointer) 0); (XtPointer) 0);
@@ -1194,15 +1200,13 @@ tty_status_redraw(Widget w)
}; };
Arg args[5]; Arg args[5];
int num_args; int num_args;
XFontStruct *font;
Dimension width; Dimension width;
/* Get the height of the font and the width of the widget */ /* Get the height of the font and the width of the widget */
num_args = 0; num_args = 0;
XtSetArg(args[num_args], XtNfont, &font); num_args++;
XtSetArg(args[num_args], XtNwidth, &width); num_args++; XtSetArg(args[num_args], XtNwidth, &width); num_args++;
XtGetValues(w, args, 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 x = 0;
int y = 0; int y = 0;