MCDE dtbar: the M menu does what it says (t0102)
Software Update... starts dtsystemsettings with -pane update (spawned
directly, no shell and no foreign text); measured under Xvfb: the Software
Update pane opens (Running/Available/New packages/Source, Check Now).
Force Quit names the program of the focused window, as the reference does
("Force Quit Dtfile"): _NET_ACTIVE_WINDOW, then the keyboard focus, then the
program whose menus the bar carries -- the first two are not set in an Xvfb
session without a window manager's active-window property, the third is
(dtbar's client window, WM_CLASS). The item carries Cmd+Option+Esc as its
accelerator text, Log Out carries Shift+Cmd+Q.
New in the menu: "Makronix Software..." (insensitive until the package
catalogue, t0056) and "Front Panel" with Show or Hide (Cmd+Option+D,
dtaction f.toggle_frontpanel, bound in dtwm's WmResParse.c:604 and
WmResource.c:527) and Settings... (insensitive until the bar's pane, t0112).
tools/mcde-shot.sh gained MCDE_SHOT_EXTRA: a program of the session started
beside the main one, so that a picture can show dtbar with dtfile.
Evidence: docs/screenshots/leopard/apple-menu-mcde.png (M menu open, Force
Quit Dtfile); the update pane opened from the menu (/tmp/opencode/mmenu-
update2.png in this session, same commands); dtbar's menu list shows every
entry with its state. Not exercised: Log Out, Lock Screen and the power
items (they end the session; the AGENTS list them as hazards), and the
front panel itself is not part of the Xvfb session, so the toggle's effect
was not photographed -- the action and its binding are named above.
This commit is contained in:
1 parent
b4eb4949bc
commit
ff5248a6de
1 file changed
+127
-3
+127
-3
@@ -29,6 +29,7 @@
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Shell.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xmu/WinUtil.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/CascadeBG.h>
|
||||
#include <Xm/Form.h>
|
||||
@@ -54,6 +55,7 @@ static Widget shell, form, bar, clockLabel;
|
||||
static Widget sink; /* the root's and the client's events go here */
|
||||
static Atom aBar, aMenu, aActive, aActivate, aRefresh, aUtf8, aManager;
|
||||
static Atom aNetActive, aLeader, aCommand;
|
||||
static Widget forceQuitItem;
|
||||
static Window client; /* the window whose menus are shown */
|
||||
static Boolean focused = True; /* client's program has the focus */
|
||||
static McdeMenuItem items[MCDE_MENU_MAX];
|
||||
@@ -279,6 +281,107 @@ ForceQuit(Widget w, XtPointer data, XtPointer call)
|
||||
ShowForceQuit();
|
||||
}
|
||||
|
||||
/* a program of the session, started directly (no shell, no foreign text):
|
||||
* dtsystemsettings with the pane as its one argument */
|
||||
static void
|
||||
RunProgram(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
char *argv[] = { "dtsystemsettings", "-pane", (char *) data, NULL };
|
||||
|
||||
(void) w;
|
||||
(void) call;
|
||||
Spawn(argv);
|
||||
}
|
||||
|
||||
static void
|
||||
SetAccel(Widget item, const char *text)
|
||||
{
|
||||
XmString s = XmStringCreateLocalized((char *) text);
|
||||
|
||||
XtVaSetValues(item, XmNacceleratorText, s, NULL);
|
||||
XmStringFree(s);
|
||||
}
|
||||
|
||||
/* the program of a window: the WM_CLASS class string, else the window name */
|
||||
static void
|
||||
ProgramOf(Window w, char *buf, size_t len)
|
||||
{
|
||||
XClassHint ch;
|
||||
XTextProperty tp;
|
||||
|
||||
buf[0] = '\0';
|
||||
if (w == None)
|
||||
return;
|
||||
if (XGetClassHint(dpy, w, &ch)) {
|
||||
const char *name = ch.res_class != NULL && ch.res_class[0] != '\0' ?
|
||||
ch.res_class : ch.res_name;
|
||||
|
||||
if (name != NULL)
|
||||
snprintf(buf, len, "%s", name);
|
||||
if (ch.res_name != NULL)
|
||||
XFree(ch.res_name);
|
||||
if (ch.res_class != NULL)
|
||||
XFree(ch.res_class);
|
||||
}
|
||||
if (buf[0] == '\0' && XGetWMName(dpy, w, &tp) && tp.value != NULL) {
|
||||
snprintf(buf, len, "%.*s", (int) tp.nitems, (char *) tp.value);
|
||||
XFree(tp.value);
|
||||
}
|
||||
}
|
||||
|
||||
/* the program of the focused window (MCDE: the reference names it in the
|
||||
* Force Quit item, "Force Quit Finder"). _NET_ACTIVE_WINDOW first; a window
|
||||
* manager that does not set it leaves the keyboard focus, and with the bar
|
||||
* focused the program whose menus it carries. */
|
||||
static void
|
||||
ActiveProgram(char *buf, size_t len)
|
||||
{
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long n, after;
|
||||
unsigned char *data = NULL;
|
||||
Window active = None;
|
||||
int revert;
|
||||
Window focus;
|
||||
|
||||
buf[0] = '\0';
|
||||
if (XGetWindowProperty(dpy, DefaultRootWindow(dpy), aNetActive, 0, 1,
|
||||
False, XA_WINDOW, &type, &format, &n, &after, &data) == Success &&
|
||||
data != NULL && n == 1 && format == 32)
|
||||
active = (Window) *(long *) data;
|
||||
if (data != NULL)
|
||||
XFree(data);
|
||||
if (active != None)
|
||||
ProgramOf(XmuClientWindow(dpy, active), buf, len);
|
||||
if (buf[0] == '\0') {
|
||||
XGetInputFocus(dpy, &focus, &revert);
|
||||
if (focus != None && focus != PointerRoot)
|
||||
ProgramOf(XmuClientWindow(dpy, focus), buf, len);
|
||||
}
|
||||
if (buf[0] == '\0' && client != None)
|
||||
ProgramOf(XmuClientWindow(dpy, client), buf, len);
|
||||
}
|
||||
|
||||
/* the Force Quit item names the program when the M menu opens */
|
||||
static void
|
||||
FillForceQuit(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
char name[128], label[192];
|
||||
XmString s;
|
||||
|
||||
(void) w;
|
||||
(void) data;
|
||||
(void) call;
|
||||
ActiveProgram(name, sizeof name);
|
||||
if (name[0] != '\0')
|
||||
snprintf(label, sizeof label, "Force Quit %s", name);
|
||||
else
|
||||
snprintf(label, sizeof label, "Force Quit...");
|
||||
s = XmStringCreateLocalized(label);
|
||||
XtVaSetValues(forceQuitItem, XmNlabelString, s, NULL);
|
||||
XmStringFree(s);
|
||||
}
|
||||
|
||||
/* Favourites (~/.dt/favourites, by hand) and Recent Items (~/.dt/recent,
|
||||
* by dtbar): items.c */
|
||||
static Widget favouritesMenu, recentMenu;
|
||||
@@ -482,7 +585,10 @@ MakeMMenu(void)
|
||||
char logout[200];
|
||||
|
||||
Push(menu, "About This Computer", 'A', About, NULL);
|
||||
Push(menu, "Software Update...", 'U', NULL, NULL);
|
||||
Push(menu, "Software Update...", 'U', RunProgram, "update");
|
||||
/* the package catalogue is a task of its own (t0056): insensitive
|
||||
* until it exists, as the reference's "Mac OS X Software..." */
|
||||
Push(menu, "Makronix Software...", 'w', NULL, NULL);
|
||||
Separator(menu);
|
||||
Push(menu, "System Settings...", 'S', RunAction, "dtsystemsettings");
|
||||
Separator(menu);
|
||||
@@ -495,7 +601,21 @@ MakeMMenu(void)
|
||||
XtAddCallback(menu, XmNmapCallback, FillFavourites, NULL);
|
||||
XtAddCallback(menu, XmNmapCallback, FillRecent, NULL);
|
||||
Separator(menu);
|
||||
Push(menu, "Force Quit...", 'Q', ForceQuit, NULL);
|
||||
forceQuitItem = Push(menu, "Force Quit...", 'Q', ForceQuit, NULL);
|
||||
SetAccel(forceQuitItem, "Cmd+Option+Esc");
|
||||
XtAddCallback(menu, XmNmapCallback, FillForceQuit, NULL);
|
||||
Separator(menu);
|
||||
{
|
||||
Widget panelMenu = Pulldown(menu, "frontPanel");
|
||||
Widget item;
|
||||
|
||||
(void) Cascade(menu, "Front Panel", 'F', panelMenu);
|
||||
item = Push(panelMenu, "Show or Hide", 'H', MAction,
|
||||
"f.toggle_frontpanel");
|
||||
SetAccel(item, "Cmd+Option+D");
|
||||
/* the pane of the bar comes with t0112 */
|
||||
Push(panelMenu, "Settings...", 'E', NULL, NULL);
|
||||
}
|
||||
Separator(menu);
|
||||
Push(menu, "Sleep", 'l', DoPower, (XtPointer) (size_t) MCDE_POWER_SLEEP);
|
||||
Push(menu, "Restart...", 't', AskPower,
|
||||
@@ -505,7 +625,11 @@ MakeMMenu(void)
|
||||
Separator(menu);
|
||||
Push(menu, "Lock Screen", 'k', MAction, "LockDisplay");
|
||||
LogOutLabel(logout, sizeof logout);
|
||||
Push(menu, logout, 'O', MAction, "ExitSession");
|
||||
{
|
||||
Widget item = Push(menu, logout, 'O', MAction, "ExitSession");
|
||||
|
||||
SetAccel(item, "Shift+Cmd+Q");
|
||||
}
|
||||
/* the Makronix logo, 16 pixels (icons/MakronixDtlogo.t.pm), given when
|
||||
* the button is made so that Motif sizes it; the letter M where the
|
||||
* icon is missing (the resource mcdeM.labelString) */
|
||||
|
||||
Reference in new issue
Block a user