MCDE: a backdrop per workspace (t0290)

dtsystemsettings has a Workspace menu on the Desktop page: This
Workspace (the active one) or one of the named workspaces, read from
DtWsmGetWorkspaceList.  A chosen backdrop goes to that workspace: dtwm
learned f.change_backdrop_ws INDEX PATH PIXMAP STYLE (the same parse as
f.change_backdrop, with the workspace index first) and
McdeBackdropFromFile on pSD->pWS[INDEX]; SetNewBackdrop keeps the choice
with SaveWorkspaceResources, so dtsession carries it to the next login
and ChangeToWorkspace shows it.  Measured under Xvfb: the menu lists
This Workspace, One, Two, Three, Four; Two + Ankh.bm printed
'dtwm: backdrop ws=1 .../backdrops/Ankh.bm style=0'.  WmMain.c now
includes WmFunction.h (the MCDE prototypes were implicit).
This commit is contained in:
lotherk committed 2026-11-16 10:05:40 +00:00
1 parent 9b41251028
commit e3d8227249
4 files changed
+144 -6

No files matched your search

+2
View File
@@ -209,6 +209,8 @@ typedef void (*DtWsmMarqueeSelectionProc) ();
* window manager f.* functions!
**********************************************************************/
#define DTWM_REQ_CHANGE_BACKDROP "f.change_backdrop"
/* MCDE: the same for one workspace: "f.change_backdrop_ws INDEX PATH PIXMAP STYLE" */
#define MCDE_REQ_CHANGE_BACKDROP_WS "f.change_backdrop_ws"
#define DTWM_REQ_RESTART "f.restart"
/**********************************************************************
+93 -6
View File
@@ -76,6 +76,13 @@
static Widget pageDesktop, pageSaver, tabDesktop, tabSaver;
/* the workspace the next backdrop choice goes to; -1 is the active one */
#define MAX_WORKSPACES 16
static char *wsNames[MAX_WORKSPACES + 1];
static Widget wsButtons[MAX_WORKSPACES + 1];
static int wsCount;
static int targetWorkspace = -1;
/* ---- pictures, small ---------------------------------------------------- */
static int
@@ -409,6 +416,76 @@ Slideshow(void)
}
}
/* append one request to dtwm's _DT_WM_REQUEST property */
static void
SendWmRequest(Display *dpy, const char *request)
{
Window wmWindow;
Atom prop = XInternAtom(dpy, "_DT_WM_REQUEST", False);
if (_DtGetMwmWindow(dpy, DefaultRootWindow(dpy), &wmWindow) !=
Success)
return;
XChangeProperty(dpy, wmWindow, prop, XA_STRING, 8, PropModeAppend,
(unsigned char *) request, (int) strlen(request) + 1);
XFlush(dpy);
}
/* the backdrop for TARGETWORKSPACE (the active one when it is -1) */
static void
ApplyBackdrop(Display *dpy, const char *path, int imageStyle)
{
if (targetWorkspace < 0) {
(void) _DtWsmChangeBackdrop(dpy, DefaultRootWindow(dpy),
(char *) path, None,
(DtWsmBackdropImageType) imageStyle);
XFlush(dpy);
} else {
char request[1600];
snprintf(request, sizeof request,
"f.change_backdrop_ws %d %s 0 %d", targetWorkspace, path,
imageStyle);
SendWmRequest(dpy, request);
}
}
/* the workspaces of this screen, by title; the first entry is the active
* one ("This Workspace") */
static void
ReadWorkspaces(Display *dpy)
{
Atom *list = NULL;
int n = 0, i;
wsCount = 0;
wsNames[0] = strdup("This Workspace");
if (DtWsmGetWorkspaceList(dpy, DefaultRootWindow(dpy), &list, &n) !=
Success || list == NULL)
return;
for (i = 0; i < n && wsCount < MAX_WORKSPACES; i++) {
DtWsmWorkspaceInfo *info = NULL;
if (DtWsmGetWorkspaceInfo(dpy, DefaultRootWindow(dpy),
list[i], &info) == Success && info != NULL) {
wsNames[wsCount + 1] = strdup(info->pchTitle != NULL ?
info->pchTitle : "Workspace");
DtWsmFreeWorkspaceInfo(info);
} else
wsNames[wsCount + 1] = strdup("Workspace");
wsCount++;
}
XFree(list);
}
static void
WorkspaceChosen(Widget w, XtPointer data, XtPointer call)
{
(void) w;
(void) call;
targetWorkspace = (int) (size_t) data - 1;
}
static void
PictureChosen(Widget w, XtPointer data, XtPointer call)
{
@@ -428,9 +505,7 @@ PictureChosen(Widget w, XtPointer data, XtPointer call)
XmToggleButtonSetState(changeToggle, False, False);
SendSlideshow(dpy, "0");
}
(void) _DtWsmChangeBackdrop(dpy, DefaultRootWindow(dpy), path, None,
(DtWsmBackdropImageType) style);
XFlush(dpy);
ApplyBackdrop(dpy, path, style);
SetPreview(path, pictures[i]);
}
@@ -548,9 +623,7 @@ StyleChosen(Widget w, XtPointer data, XtPointer call)
snprintf(path, sizeof path, "%s/%s", places[place].dir,
pictures[k]);
(void) _DtWsmChangeBackdrop(dpy, DefaultRootWindow(dpy),
path, None, (DtWsmBackdropImageType) style);
XFlush(dpy);
ApplyBackdrop(dpy, path, style);
break;
}
}
@@ -700,6 +773,20 @@ MakeDesktopPage(Widget parent)
page = XtVaCreateWidget("desktopPage", xmRowColumnWidgetClass, parent,
XmNspacing, 8, NULL);
/* the workspace the next choice belongs to: "This Workspace" (the
* active one) or one of the named workspaces */
targetWorkspace = -1;
ReadWorkspaces(dpy);
row = XtVaCreateManagedWidget("workspaceRow", xmRowColumnWidgetClass,
page, XmNorientation, XmHORIZONTAL, XmNspacing, 8, NULL);
{
Widget menu = OptionMenu(row, "workspaceMenu", "Workspace:",
(const char *const *) wsNames, wsCount + 1, wsButtons,
WorkspaceChosen);
XtVaSetValues(menu, XmNmenuHistory, wsButtons[0], NULL);
}
top = XtVaCreateManagedWidget("current", xmFormWidgetClass, page, NULL);
/* the frame gets the size: the drawing area alone was laid out 0 high
* (measured) */
+48
View File
@@ -1996,6 +1996,54 @@ HandleDtWmRequest (WmScreenData *pSD, XEvent *pev)
}
}
}
else if (!strncmp (pchReq, MCDE_REQ_CHANGE_BACKDROP_WS,
strlen(MCDE_REQ_CHANGE_BACKDROP_WS)))
{
/*
* MCDE: "f.change_backdrop_ws INDEX PATH PIXMAP STYLE",
* the same as below for one workspace (0-based).
*/
Pixmap pixmap = None;
int imageType = DtWSM_BACKDROP_IMAGETYPE_TILED;
char *pchPath, *pchPix, *pchType, *end;
int ws = -1;
pchPath = pchReq + strlen(MCDE_REQ_CHANGE_BACKDROP_WS);
while (*pchPath == ' ')
pchPath++;
ws = (int) strtol(pchPath, &end, 10);
if (end == pchPath)
ws = -1;
pchPath = end;
while (*pchPath == ' ')
pchPath++;
pchType = strrchr (pchPath, ' ');
if (pchType)
*pchType++ = '\0';
pchPix = pchType ? strrchr (pchPath, ' ') : NULL;
if (pchPix)
*pchPix++ = '\0';
if (ws < 0 || ws >= (int) pSD->numWorkspaces || !pchPix ||
!*pchPath)
{
Warning (((char *)GETMESSAGE(32, 3, "Missing path name for backdrop change request.")));
}
else
{
sscanf (pchPix, "%lx", &pixmap);
sscanf (pchType, "%d", &imageType);
if (getenv("MCDE_DESK_DEBUG") != NULL)
fprintf(stderr, "dtwm: backdrop ws=%d %s style=%d\n",
ws, pchPath, imageType);
if (pixmap == None)
McdeBackdropFromFile (&pSD->pWS[ws], pchPath,
imageType);
else
SetNewBackdrop (&pSD->pWS[ws], pixmap,
(String) pchPath,
(DtWsmBackdropImageType) imageType);
}
}
else if (!strncmp (pchReq, DTWM_REQ_CHANGE_BACKDROP,
strlen(DTWM_REQ_CHANGE_BACKDROP)))
{
+1
View File
@@ -49,6 +49,7 @@
#include "WmError.h"
#include "WmIPC.h"
#include "WmMcdeDisplays.h"
#include "WmFunction.h"
#include "WmBackdrop.h"