mcde: menu shortcuts work under the global menu; Command+comma opens the settings

Motif refuses accelerators of an unmanaged menu bar (RCPopup.c,
AllWidgetsAccessible), and the global menu unmanages the program's bar:
no menu shortcut worked while dtbar ran.  Our Motif gets
_XmMenuBarSetExported; McdeGlobalMenu.c marks the bars it hides.  A
preferences/options/settings item without a shortcut gets Command+comma.

Tested on Xvfb with dtbar: dtpad Command+F opens Find/Change, dtterm
Command+comma opens Global Options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lotherkandClaude Opus 5.5 committed 2026-11-11 23:10:20 +00:00
1 parent c1367c039b
commit 06c5f3fe47
4 files changed
+104 -4

No files matched your search

+10 -2
View File
@@ -81,8 +81,16 @@ place of CDE; pkgsrc builds it on any platform from `pkgsrc/`.
`include/Mcde/GlobalMenu.h` (a selection, properties, client messages);
the program side is `lib/DtSvc/DtUtil2/McdeGlobalMenu.c`, started by
`DtInitialize`, so every CDE program takes part without a change of its own
and without a Motif patch: an Xt create hook finds its XmMenuBar, the bar
hides it and shows its tree, a click calls the button's own callback. The
and without a change of its own: an Xt create hook finds its XmMenuBar, the
bar hides it (unmanaged) and shows its tree, a click calls the button's
own callback. Motif refuses the accelerators of an unmanaged menu bar
(RCPopup.c, AllWidgetsAccessible), so the hidden bar is marked with
`_XmMenuBarSetExported` (motif/lib/Xm/RowColumnP.h, our Motif) and its
shortcuts keep working -- dtpad Command+F with the bar running, tested.
A push button named options/preferences/settings/global (or labelled
Preferences, Options..., Settings..., Global...) without a shortcut gets
Command+comma, as on every desktop of that kind (dtterm: Global Options,
tested). The
text form is `McdeMenuModel.c` with its test (`test_menumodel`, `make
check`). A foreign window is registered with a hidden core widget, never
with a shell (a shell stops on "Event with wrong window").
+52 -1
View File
@@ -27,6 +27,7 @@
#include <X11/Shell.h>
#include <Xm/Xm.h>
#include <Xm/RowColumn.h>
#include <Xm/RowColumnP.h> /* _XmMenuBarSetExported: MCDE's Motif */
#include <Xm/CascadeB.h>
#include <Xm/CascadeBG.h>
#include <Xm/PushB.h>
@@ -118,6 +119,47 @@ LabelText(Widget w, const char *resource, char *buf, size_t len)
XmStringFree(xs);
}
/*
* Command+, opens a program's settings, in every program (Konrad: "cmd + ,
* for preferences in whatever (dt) app is in focus"). CDE's programs name
* that item differently -- dtcm "options", dtfile "setPreferences", dtmail
* "Mail Options...", dtterm "Global..." -- so an item is found by its
* widget name or its English label, and gets the shortcut if it has none.
* A menu of switches called "options" (dtpad, dtcalc) is no settings item:
* only push buttons count.
*/
static Boolean
IsSettingsItem(Widget w, const char *label)
{
static const char *const names[] = { "options", "setPreferences",
"preferences", "settings", "global", "Mail Options...", NULL };
static const char *const labels[] = { "Preferences", "Set Preferences",
"Options...", "Mail Options...", "Global...", "Settings...", NULL };
const char *n = XtName(w);
int i;
for (i = 0; names[i] != NULL; i++)
if (strcmp(n, names[i]) == 0)
return True;
for (i = 0; labels[i] != NULL; i++)
if (strncmp(label, labels[i], strlen(labels[i])) == 0)
return True;
return False;
}
static void
SettingsShortcut(Widget w, const char *label, const char *accelText)
{
XmString t;
if (accelText[0] != '\0' || !IsSettingsItem(w, label))
return;
t = XmStringCreateLocalized("Cmd+,");
XtVaSetValues(w, XmNaccelerator, "Mod4<Key>comma",
XmNacceleratorText, t, NULL);
XmStringFree(t);
}
static void
Walk(Exported *e, Widget rc, int depth, McdeMenuItem *items)
{
@@ -169,6 +211,11 @@ Walk(Exported *e, Widget rc, int depth, McdeMenuItem *items)
if (m->kind == MCDE_MENU_PUSH || m->kind == MCDE_MENU_TOGGLE)
LabelText(w, XmNacceleratorText, m->accelerator,
sizeof m->accelerator);
if (m->kind == MCDE_MENU_PUSH) {
SettingsShortcut(w, m->label, m->accelerator);
LabelText(w, XmNacceleratorText, m->accelerator,
sizeof m->accelerator);
}
}
e->items[e->count++] = w;
if (sub != NULL)
@@ -220,6 +267,8 @@ Place(Exported *e)
if (!Alive(mb) || ShellOf(mb) != e->shell)
continue;
/* hidden, but its accelerators (Command+F, ...) still work */
_XmMenuBarSetExported(mb, bar != None);
if (bar != None && XtIsManaged(mb))
XtUnmanageChild(mb);
else if (bar == None && !XtIsManaged(mb))
@@ -243,8 +292,10 @@ ChangeHook(Widget w, XtPointer client, XtPointer call)
return;
for (i = 0; i < nmenubars; i++)
if (Alive(menubars[i]) && XtParent(menubars[i]) == d->widget &&
XtIsManaged(menubars[i]))
XtIsManaged(menubars[i])) {
_XmMenuBarSetExported(menubars[i], True);
XtUnmanageChild(menubars[i]);
}
}
/* the cascades are told they open, so that they bring their entries up to
+37 -1
View File
@@ -44,6 +44,7 @@ static char *rcsid = "$XConsortium: RCPopup.c /main/7 1996/03/28 15:15:24 daniel
#include <X11/CoreP.h>
#include <X11/CompositeP.h>
#include <X11/ShellP.h>
#include <X11/Xutil.h>
#include <Xm/CascadeBGP.h>
#include <Xm/CascadeBP.h>
#include <Xm/GadgetP.h>
@@ -1097,13 +1098,48 @@ MatchInKeyboardList(
* accessible if it, and its ancestors, are both sensitive and
* managed. This is useful for MenuBars and Option Menus only.
*/
/* MCDE: menu bars the global menu shows in the desktop's top bar; their
* window hides them (unmanaged), the accelerators stay (RowColumnP.h) */
static XContext exportedContext = 0;
void
_XmMenuBarSetExported(Widget bar, Boolean exported)
{
XtPointer v;
if (bar == NULL || !XtIsWidget(bar))
return;
if (exportedContext == 0)
exportedContext = XUniqueContext();
if (exported)
XSaveContext(XtDisplay(bar), (XID) bar, exportedContext,
(XPointer) bar);
else if (XFindContext(XtDisplay(bar), (XID) bar, exportedContext,
(XPointer *) &v) == 0)
XDeleteContext(XtDisplay(bar), (XID) bar, exportedContext);
}
static Boolean
IsExported(Widget w)
{
XPointer v;
return exportedContext != 0 && XtIsWidget(w) &&
XFindContext(XtDisplay(w), (XID) w, exportedContext, &v) == 0;
}
static Boolean
AllWidgetsAccessible(
Widget w )
{
Widget bar = w;
while (w && XtParent(w) && !XtIsShell(w))
{
if (!XtIsSensitive(w) || !XtIsManaged(w) || !w->core.mapped_when_managed)
if (!XtIsSensitive(w))
return (False);
if ((!XtIsManaged(w) || !w->core.mapped_when_managed) &&
!(w == bar && IsExported(w)))
return (False);
w = XtParent(w);
+5
View File
@@ -278,6 +278,11 @@ typedef struct _XmRowColumnClassRec
externalref XmRowColumnClassRec xmRowColumnClassRec;
/* MCDE: a menu bar shown by the desktop's global menu (DtSvc,
* McdeGlobalMenu.c) is unmanaged in its window, but its accelerators
* still work (RCPopup.c, AllWidgetsAccessible) */
extern void _XmMenuBarSetExported(Widget bar, Boolean exported);
/* Constraint Definition */