MCDE front panel: dock halves, drag to keep, printer and xterm

Konrad, 2026-11-15: "wenn keep in dock angewaehlt, muss das icon nach links
wandern"; icons drag & drop; the print widget back on the right; the
programs not in the dock in a separate area; the panel's terminal is xterm.

- The dock part (WmMcdePanel.c) is two halves now: the kept programs left,
  a vertical separator, the running programs that are not in the dock
  right.  A running icon dragged out to the left (or onto the kept half)
  is kept and moves to the left; a kept icon dragged out to the right (or
  onto the running half) is removed and moves back.
- The dump separator is an XmSeparator widget, not a gadget: Motif's
  XtQueryGeometry/XtTranslateCoords crash on gadgets (one dtwm core dump
  measured before the change).
- The Printer control is back in the main row, position 7, left of the
  trash (it was in the Desktop drawer); the dock part is inserted left of
  it, so the order is switch | dock | printer | trash, and a file dragged
  from dtfile onto the printer prints.
- The System (Terminal) control runs Xterm/XTerm, not Terminal/dtterm.
- MCDE_PANEL_DEBUG prints the part's absolute position for tests.

Measured in Xvfb (1280x800, fresh HOME, ttsession + dtwm + dtbar):
xclock kept by dragging its icon out to the left -> ~/.dt/panel-apps has
"XClock 'xclock' '-digital'", debug "2 buttons (1 kept)", area 60 -> 126
wide with the separator at +64; dragging it out to the right again empties
panel-apps ("2 buttons (0 kept)", area 120).  Screenshots: two icons with
the divider, the printer and the trash right of them.  make mcde-linux
MCDE_DIRS="install programs/dtwm" and "... programs/localized/C/types"
exit=0.
This commit is contained in:
lotherk committed 2026-11-15 21:26:09 +00:00
1 parent a667613ef3
commit 9e137005cd
3 files changed
+187 -62

No files matched your search

+12 -4
View File
@@ -155,10 +155,18 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
(`none` by default, `minimize` or `maximize`); the Appearance pane writes
it and restarts dtwm (`_DtWmRestartNoConfirm`).
- **Front panel**: Files, Mail, Terminal, Network, Desktop Style left of the
workspace switch (Konrad, 2026-11-11), running programs and trash right. No
clock in the panel (the bar has it). Actions at the end of `types/dt.dt.src`
take no shell variables and no `CDE_INSTALLATION_TOP` inside `'...'`
(`docs/reference/frontpanel.txt`).
workspace switch (Konrad, 2026-11-11); right of it the programs of the dock,
the printer and the trash, in that order (Konrad, 2026-11-15). The Terminal
starts **xterm** (`PUSH_ACTION Xterm`, `CLIENT_NAME XTerm`; Konrad does not
want dtterm as the panel's terminal). The dock part is WmMcdePanel.c: kept
programs left, a vertical separator, the running programs that are not in
the dock right; dragging an icon out to the left keeps it (to the kept
half), out to the right unkeeps it. No clock in the panel (the bar has it).
Actions at the end of `types/dt.dt.src` take no shell variables and no
`CDE_INSTALLATION_TOP` inside `'...'` (`docs/reference/frontpanel.txt`).
Not done: dragging an icon into a drawer (subpanel) or out of one; the
drawers' CDE install zone accepts dropped files, not panel icons (open
point, t0258).
- **Pictures**: PNG goes through `McdeImageGetPixmap` (libpng), because Motif
2.3.8 draws an RGB PNG as its blue channel only
(`docs/reference/motif-png.txt`); free with `McdeImageFreePixmap`.
+157 -40
View File
@@ -68,8 +68,8 @@ typedef struct {
static Kept kept[MAX_APPS];
static int nkept;
static Widget area, spacer, menu, menuItem;
static ControlData *trash;
static Widget area, spacer, menu, menuItem, separator, prevWidget;
static ControlData *trash, *anchor;
static XtIntervalId pending;
/* the buttons now: class, kept (an index into kept[]) or running only */
@@ -278,10 +278,16 @@ DebugGeometry(XtPointer data, XtIntervalId *id)
(void) data;
(void) id;
fprintf(stderr, "dtwm panel: area %dx%d+%d managed %d; parent %dx%d; "
"trash +%d; shell %dx%d\n", XtWidth(area), XtHeight(area),
XtX(area), XtIsManaged(area), XtWidth(p), XtHeight(p), XtX(t),
XtWidth(panel.shell), XtHeight(panel.shell));
{
Position ax = 0, ay = 0;
XtTranslateCoords(area, 0, 0, &ax, &ay);
fprintf(stderr, "dtwm panel: area %dx%d+%d managed %d at %d,%d; "
"parent %dx%d; trash +%d; shell %dx%d\n", XtWidth(area),
XtHeight(area), XtX(area), XtIsManaged(area), (int) ax,
(int) ay, XtWidth(p), XtHeight(p), XtX(t),
XtWidth(panel.shell), XtHeight(panel.shell));
}
}
static void
@@ -402,6 +408,49 @@ McdePanelPost(Widget form, XButtonEvent *ev)
* part, which finds the button under the pointer (XmObjectAtPoint). */
static int pressedButton = -1;
/* the half of the part at a root position: 1 kept (left of the divider),
* 2 running (right), 0 outside; a button under the pointer answers for its
* own half */
static int
ZoneAtRoot(int xr, int yr)
{
Position ax = 0, ay = 0;
Widget g;
int b, x;
if (area == NULL || !XtIsManaged(area))
return 0;
XtTranslateCoords(area, 0, 0, &ax, &ay);
x = xr - ax;
if (x < 0 || x >= (int) XtWidth(area) || yr - ay < 0 ||
yr - ay >= (int) XtHeight(area))
return 0;
g = XmObjectAtPoint(area, (Position) x, (Position) (yr - ay));
for (b = 0; b < nbuttons; b++)
if (buttons[b].w == g)
return buttons[b].keptIndex >= 0 ? 1 : 2;
if (separator != NULL && XtIsManaged(separator)) {
Position sx = 0, sy = 0;
XtTranslateCoords(separator, 0, 0, &sx, &sy);
return xr < sx ? 1 : 2;
}
/* no divider yet: the empty room before the first icon is the dock's
* left half, the room after the last one its right half */
if (nbuttons > 0) {
Position bx = 0, by = 0;
XtTranslateCoords(buttons[0].w, 0, 0, &bx, &by);
if (xr < bx)
return 1;
XtTranslateCoords(buttons[nbuttons - 1].w, 0, 0, &bx, &by);
bx += (Position) XtWidth(buttons[nbuttons - 1].w);
if (xr >= bx)
return 2;
}
return 0;
}
static void
Pressed(Widget w, XtPointer data, XEvent *ev, Boolean *cont)
{
@@ -435,12 +484,25 @@ Pressed(Widget w, XtPointer data, XEvent *ev, Boolean *cont)
}
if (ev->type == ButtonRelease && ev->xbutton.button == Button1) {
Position ax = 0, ay = 0;
int zone;
XtTranslateCoords(area, 0, 0, &ax, &ay);
/* let go left of the part, having moved there */
if (buttons[b].keptIndex < 0 && ev->xbutton.x_root < ax &&
zone = ZoneAtRoot(ev->xbutton.x_root, ev->xbutton.y_root);
/* dropped on the kept half (left of the divider): keep */
if (zone == 1 && buttons[b].keptIndex < 0)
Keep(b);
/* dropped on the running half (right of the divider): unkeep */
else if (zone == 2 && buttons[b].keptIndex >= 0)
Unkeep(b);
/* let go left of the part, having moved there: keep */
else if (buttons[b].keptIndex < 0 && ev->xbutton.x_root < ax &&
pressX - ev->xbutton.x_root > 8)
Keep(b);
/* and right of it: unkeep (out of the dock) */
else if (buttons[b].keptIndex >= 0 &&
ev->xbutton.x_root > ax + (int) XtWidth(area) &&
ev->xbutton.x_root - pressX > 8)
Unkeep(b);
return;
}
if (ev->type != ButtonPress || ev->xbutton.button != Button3)
@@ -483,15 +545,16 @@ AddButton(const char *cls, int keptIndex)
XtSetArg(al[ac], XmNstring, NULL); ac++;
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
if (nbuttons == 0) {
if (prevWidget == NULL) {
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
} else {
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
XtSetArg(al[ac], XmNleftWidget, buttons[nbuttons - 1].w); ac++;
XtSetArg(al[ac], XmNleftWidget, prevWidget); ac++;
}
w = _DtCreateControl(area, "mcdeApp", al, ac);
XtFree(icon);
XtManageChild(w);
prevWidget = w;
XtAddCallback(w, XmNcallback, Clicked, (XtPointer) (intptr_t) nbuttons);
buttons[nbuttons].w = w;
snprintf(buttons[nbuttons].cls, sizeof buttons[nbuttons].cls, "%s", cls);
@@ -619,20 +682,56 @@ Update(void)
for (i = 0; i < nbuttons; i++)
XtDestroyWidget(buttons[i].w);
nbuttons = 0;
for (i = 0; i < nkept; i++)
AddButton(kept[i].cls, i);
for (e = pSD->clientList; e != NULL; e = e->nextSibling) {
ClientData *pCD = e->pCD;
if (separator != NULL) {
XtDestroyWidget(separator);
separator = NULL;
}
/* the programs of the dock come first (left), then the divider, then
* the running ones that are not in the dock -- macOS's two halves in
* CDE's look (Konrad, 2026-11-15) */
{
char run[MAX_APPS][64];
int nrun = 0;
if (pCD == NULL || e != &pCD->clientEntry || !IsProgram(pCD) ||
KeptIndex(pCD->clientClass) >= 0 ||
InPanel(pCD->clientClass))
continue;
for (j = 0; j < nbuttons; j++)
if (strcasecmp(buttons[j].cls, pCD->clientClass) == 0)
break;
if (j == nbuttons)
AddButton(pCD->clientClass, -1);
for (e = pSD->clientList; e != NULL; e = e->nextSibling) {
ClientData *pCD = e->pCD;
if (pCD == NULL || e != &pCD->clientEntry ||
!IsProgram(pCD) ||
KeptIndex(pCD->clientClass) >= 0 ||
InPanel(pCD->clientClass))
continue;
for (j = 0; j < nrun; j++)
if (strcasecmp(run[j], pCD->clientClass) == 0)
break;
if (j == nrun && nrun < MAX_APPS)
snprintf(run[nrun++], sizeof run[0], "%s",
pCD->clientClass);
}
prevWidget = NULL;
for (i = 0; i < nkept; i++)
AddButton(kept[i].cls, i);
if (nkept > 0 && nrun > 0) {
Arg al[8];
int ac = 0;
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], XmNtopOffset, 2); ac++;
XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM);
ac++;
XtSetArg(al[ac], XmNbottomOffset, 2); ac++;
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET);
ac++;
XtSetArg(al[ac], XmNleftWidget, prevWidget); ac++;
XtSetArg(al[ac], XmNleftOffset, 4); ac++;
XtSetArg(al[ac], XmNorientation, XmVERTICAL); ac++;
separator = XmCreateSeparator(area,
"mcdeDockSeparator", al, ac);
XtManageChild(separator);
prevWidget = separator;
}
for (i = 0; i < nrun; i++)
AddButton(run[i], -1);
}
if (getenv("MCDE_PANEL_DEBUG"))
fprintf(stderr, "dtwm panel: %d buttons (%d kept)\n", nbuttons,
@@ -656,6 +755,16 @@ Update(void)
else
width += XtWidth(buttons[i].w);
}
if (separator != NULL && XtIsManaged(separator)) {
XtWidgetGeometry pref;
width += 4; /* its left offset */
if (XtQueryGeometry(separator, NULL, &pref) != XtGeometryNo &&
(pref.request_mode & CWWidth))
width += pref.width;
else
width += XtWidth(separator);
}
/* the panel gives back what the part had: Grow asks only for the
* difference */
if (XtIsManaged(area) && shown > 1 && shown != width)
@@ -684,27 +793,35 @@ McdePanelCreate(void)
int ac;
trash = NULL;
for (i = 0; i < panel.box_data_count && trash == NULL; i++)
anchor = NULL;
for (i = 0; i < panel.box_data_count; i++)
for (j = 0; j < panel.box_data[i]->control_data_count; j++) {
ControlData *c = panel.box_data[i]->control_data[j];
const char *name =
(const char *) c->element_values[CONTROL_NAME].parsed_value;
if (name != NULL && strcmp(name, "Trash") == 0 &&
c->icon != NULL && c->arrow != NULL) {
if (name == NULL || c->icon == NULL || c->arrow == NULL)
continue;
if (strcmp(name, "Trash") == 0)
trash = c;
break;
}
/* the part goes left of the printer, else of the trash:
* the machine's programs stay together on the right and
* the printer is the drop target at the end */
if (strcmp(name, "Printer") == 0)
anchor = c;
}
if (anchor == NULL)
anchor = trash;
if (getenv("MCDE_PANEL_DEBUG"))
fprintf(stderr, "dtwm panel: create, trash %s\n",
trash != NULL ? "found" : "not found");
if (trash == NULL)
fprintf(stderr, "dtwm panel: create, trash %s, anchor %s\n",
trash != NULL ? "found" : "not found",
anchor != NULL ? "found" : "not found");
if (trash == NULL || anchor == NULL)
return;
ReadKept();
/* the part, in the control row before the trash */
XtVaGetValues(trash->icon, XmNleftAttachment, &att, XmNleftWidget,
XtVaGetValues(anchor->icon, XmNleftAttachment, &att, XmNleftWidget,
&left, NULL);
/* the background of the row it sits in: a colour, or a pattern
* (UI.c gives the control forms a pixmap in some colour modes) */
@@ -712,7 +829,7 @@ McdePanelCreate(void)
Pixel bg;
Pixmap pm = XmUNSPECIFIED_PIXMAP;
XtVaGetValues(XtParent(trash->icon), XmNbackground, &bg,
XtVaGetValues(XtParent(anchor->icon), XmNbackground, &bg,
XmNbackgroundPixmap, &pm, NULL);
ac = 0;
XtSetArg(al[ac], XmNbackground, bg); ac++;
@@ -730,21 +847,21 @@ McdePanelCreate(void)
}
XtSetArg(al[ac], XmNresizePolicy, XmRESIZE_NONE); ac++;
XtSetArg(al[ac], XmNwidth, 1); ac++;
area = XmCreateForm(XtParent(trash->icon), "mcdeRunning", al, ac);
XtVaSetValues(trash->icon, XmNleftAttachment, XmATTACH_WIDGET,
area = XmCreateForm(XtParent(anchor->icon), "mcdeRunning", al, ac);
XtVaSetValues(anchor->icon, XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, area, NULL);
/* its blank in the arrow row, before the trash's arrow */
att = XmATTACH_FORM;
left = NULL;
XtVaGetValues(trash->arrow, XmNleftAttachment, &att, XmNleftWidget,
XtVaGetValues(anchor->arrow, XmNleftAttachment, &att, XmNleftWidget,
&left, NULL);
{
Pixel bg;
Pixmap pm = XmUNSPECIFIED_PIXMAP;
XtVaGetValues(trash->arrow, XmNbackground, &bg, NULL);
XtVaGetValues(XtParent(trash->arrow), XmNbackgroundPixmap, &pm,
XtVaGetValues(anchor->arrow, XmNbackground, &bg, NULL);
XtVaGetValues(XtParent(anchor->arrow), XmNbackgroundPixmap, &pm,
NULL);
ac = 0;
XtSetArg(al[ac], XmNbackground, bg); ac++;
@@ -764,11 +881,11 @@ McdePanelCreate(void)
XmString empty = XmStringCreateLocalized("");
XtSetArg(al[ac], XmNlabelString, empty); ac++;
spacer = XmCreateLabel(XtParent(trash->arrow),
spacer = XmCreateLabel(XtParent(anchor->arrow),
"mcdeRunningArrows", al, ac);
XmStringFree(empty);
}
XtVaSetValues(trash->arrow, XmNleftAttachment, XmATTACH_WIDGET,
XtVaSetValues(anchor->arrow, XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, spacer, NULL);
XtAddEventHandler(area, ButtonPressMask | ButtonReleaseMask, False,
+18 -18
View File
@@ -84,8 +84,8 @@ CONTROL System
POSITION_HINTS 3
ICON Fpterm
LABEL %|nls-18014-#Terminal#|
PUSH_ACTION Terminal
CLIENT_NAME dtterm
PUSH_ACTION Xterm
CLIENT_NAME XTerm
HELP_TOPIC FPOnItemTerm
HELP_VOLUME FPanel
}
@@ -116,12 +116,27 @@ CONTROL Style
HELP_VOLUME FPanel
}
CONTROL Trash
CONTROL Printer
{
TYPE icon
CONTAINER_NAME Top
CONTAINER_TYPE BOX
POSITION_HINTS 7
LABEL %|nls-18006-#Default#|
ICON Fpprnt
PUSH_ACTION DtPrint
DROP_ACTION DtPrint
DROP_ANIMATION PrinterDrop
HELP_TOPIC FPOnItemPrinter
HELP_VOLUME FPanel
}
CONTROL Trash
{
TYPE icon
CONTAINER_NAME Top
CONTAINER_TYPE BOX
POSITION_HINTS 8
ICON Fptrsh
LABEL %|nls-18010-#Trash#|
ALTERNATE_ICON Fptrsh7
@@ -399,21 +414,6 @@ SUBPANEL DesktopSubpanel
TITLE Desktop
}
CONTROL Printer
{
TYPE icon
CONTAINER_NAME DesktopSubpanel
CONTAINER_TYPE SUBPANEL
POSITION_HINTS 1
LABEL %|nls-18006-#Default#|
ICON Fpprnt
PUSH_ACTION DtPrint
DROP_ACTION DtPrint
DROP_ANIMATION PrinterDrop
HELP_TOPIC FPOnItemPrinter
HELP_VOLUME FPanel
}
CONTROL PrintManager
{
TYPE icon