diff --git a/programs/dtterm/Tabs.c b/programs/dtterm/Tabs.c index 62817414..46b7c616 100644 --- a/programs/dtterm/Tabs.c +++ b/programs/dtterm/Tabs.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "TermView.h" #include "TermViewMenu.h" @@ -171,19 +172,51 @@ TabSelected(Widget w, XtPointer client, XtPointer call) } } +/* One tab, no tab bar. XmTabStack places its tab box whether it is + * managed or not (Motif 2.3.8, TabStack.c: PickSizes, Layout), so the + * stack sits in a form, and with a single tab its top is moved up by the + * tab box's height: the bar lies above the window and X clips it away. */ +static void +TabBar(Widget container) +{ + Widget box = XtNameToWidget(container, "tabBox"); + Dimension h = 0; + int up; + + if (box == NULL || container->core.being_destroyed) + return; + XtVaGetValues(box, XmNheight, &h, NULL); + up = _McdeTabsCount(container) <= 1 ? -(int) h : 0; + XtVaSetValues(container, XmNtopOffset, up, NULL); +} + +static void +TabBarLater(XtPointer data, XtIntervalId *id) +{ + (void) id; + TabBar((Widget) data); +} + Widget _McdeTabsContainer(Widget shell) { - Widget c = XtNameToWidget(shell, "mcdeTabs"); - Arg args[4]; + Widget c = XtNameToWidget(shell, "mcdeTabsFrame.mcdeTabs"), frame; + Arg args[8]; int n = 0; if (c != NULL) return c; + frame = XtVaCreateManagedWidget("mcdeTabsFrame", xmFormWidgetClass, + shell, XmNmarginWidth, 0, XmNmarginHeight, 0, + XmNshadowThickness, 0, NULL); XtSetArg(args[n], XmNtabSide, XmTABS_ON_TOP); n++; XtSetArg(args[n], XmNtabStyle, XmTABS_BEVELED); n++; XtSetArg(args[n], XmNshadowThickness, 1); n++; - c = XmCreateTabStack(shell, "mcdeTabs", args, n); + XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; + XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; + XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; + XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; + c = XmCreateTabStack(frame, "mcdeTabs", args, n); XtAddCallback(c, XmNtabSelectedCallback, TabSelected, NULL); XtManageChild(c); return c; @@ -302,6 +335,9 @@ _McdeTabsAdopt(Widget view) TermFocus, (XtPointer) view); XmTabStackSelectTab(page, True); Focus(view); + /* the tab bar shows from the second tab on */ + XtAppAddTimeOut(XtWidgetToApplicationContext(view), 0, TabBarLater, + (XtPointer) XtParent(page)); } Boolean @@ -348,5 +384,8 @@ _McdeTabsClose(Widget view) /* the neighbour comes to the front, then the tab goes */ XmTabStackSelectTab(tabs[at + 1 < count ? at + 1 : at - 1], True); XtDestroyWidget(page); + /* back to one tab: the bar goes, once the page is really gone */ + XtAppAddTimeOut(XtWidgetToApplicationContext(container), 0, + TabBarLater, (XtPointer) container); return True; }