mcde: dtterm shows the tab bar only when there are tabs
With one tab the window shows the terminal alone. XmTabStack places its tab box whether it is managed or not (Motif 2.3.8, TabStack.c: PickSizes, Layout), so the stack now sits in a form, and while there is a single tab its top is moved up by the tab box's height: the bar lies above the window and X clips it. The second tab brings it back; closing to one takes it away again (after the page is really destroyed). Measured on Xvfb (build/mcde-shots/tabbar-*.png): one tab, no bar; Ctrl+Shift+T, two tabs with the bar; Ctrl+Shift+W, one tab, no bar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8e8587f9b
commit
1d71a2d14d
1 file changed
+42
-3
+42
-3
@@ -33,6 +33,7 @@
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/TabStack.h>
|
||||
#include <Xm/Form.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
Reference in new issue
Block a user