diff --git a/AGENTS.md b/AGENTS.md index b429a1ab..2ad0524f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,6 +58,8 @@ place of CDE; pkgsrc builds it on any platform from `pkgsrc/`. with a shell (a shell stops on "Event with wrong window"). `MCDE_NO_GLOBAL_MENU` keeps a program's menu bar in its window, `MCDE_GLOBAL_MENU_DEBUG` logs what the program side does. + dtwm places and maximizes windows below the bar (`McdeExcludeBar` in + `programs/dtwm/WmMultiHead.c`); a full-screen window covers it. - `programs/dtterm/Profiles.c` -- terminal profiles (font, colours, command) from `~/.dt/dtterm.profiles`, else `config/dtterm.profiles`; the parser is plain C with its own test (`test_profiles.c`, `make check`). A view with a diff --git a/programs/dtwm/WmMultiHead.c b/programs/dtwm/WmMultiHead.c index a850c176..ad1be515 100644 --- a/programs/dtwm/WmMultiHead.c +++ b/programs/dtwm/WmMultiHead.c @@ -169,3 +169,25 @@ WmHeadInfo_t *GetHeadInfoById(int id) { free(WmHI); return NULL; } + + +/* MCDE: the area below the top bar (WmMultiHead.h) */ +void +McdeExcludeBar(int screen, int *px, int *py, int *pwidth, int *pheight) +{ + char name[32]; + Window bar; + XWindowAttributes a; + + (void) px; + (void) pwidth; + if (*py != 0) + return; + snprintf(name, sizeof name, "_MCDE_BAR_S%d", screen); + bar = XGetSelectionOwner(DISPLAY, XInternAtom(DISPLAY, name, False)); + if (bar == None || !XGetWindowAttributes(DISPLAY, bar, &a) || + a.map_state != IsViewable || a.y != 0 || a.height >= *pheight) + return; + *py += a.height; + *pheight -= a.height; +} diff --git a/programs/dtwm/WmMultiHead.h b/programs/dtwm/WmMultiHead.h index 3e488447..40833ec1 100644 --- a/programs/dtwm/WmMultiHead.h +++ b/programs/dtwm/WmMultiHead.h @@ -35,4 +35,12 @@ typedef struct _WmHeadInfo { WmHeadInfo_t *GetHeadInfo(const ClientData *pcd); WmHeadInfo_t *GetHeadInfoById(int id); +/* + * MCDE: the bar at the top of the screen (programs/dtbar) is no window dtwm + * manages (override-redirect); while it runs, it owns _MCDE_BAR_S. + * An area at the top of the screen (*PY == 0) loses the bar's height, so + * that windows are placed and maximized below it. + */ +void McdeExcludeBar(int screen, int *px, int *py, int *pwidth, int *pheight); + #endif /* _WmMultiHead_h */ diff --git a/programs/dtwm/WmWinInfo.c b/programs/dtwm/WmWinInfo.c index c931c9fc..09616abe 100644 --- a/programs/dtwm/WmWinInfo.c +++ b/programs/dtwm/WmWinInfo.c @@ -3499,6 +3499,14 @@ FindClientPlacement (ClientData *pCD) screenWidth = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD)); screenHeight = DisplayHeight (DISPLAY, SCREEN_FOR_CLIENT(pCD)); } + { + /* MCDE: below the top bar (WmMultiHead.c) */ + int bx = screenX, by = screenY, bw = screenWidth, bh = screenHeight; + + McdeExcludeBar(SCREEN_FOR_CLIENT(pCD), &bx, &by, &bw, &bh); + screenY = by; + screenHeight = bh; + } while (!placed) { @@ -4031,6 +4039,10 @@ void GetMaxInfo (ClientData *pCD, int *pX, int *pY, int *pWidth, int *pHeight) width = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT (pCD)); height = DisplayHeight (DISPLAY, SCREEN_FOR_CLIENT (pCD)); } + /* MCDE: a maximized window stays below the top bar (WmMultiHead.c); + * a full-screen one covers it */ + if (!pCD->maxConfig && !(pCD->fullscreen && !pCD->fullscreenAuto)) + McdeExcludeBar (SCREEN_FOR_CLIENT (pCD), &x, &y, &width, &height); FrameToClient (pCD, &x, &y, &width, &height);