12#include <X11/extensions/shape.h>
35static void Draw3DCorner(Window w,
int x,
int y,
int width,
int height,
83 fprintf(stderr,
"SetupFrame: x=%d, y=%d, w=%d, h=%d, bw=%d\n",
98#define MARGIN (16 - 1)
109 if(
y + h + bw < limit) {
121 if(
x + w + bw < limit) {
152 if(occwin != NULL && occwin->
twm_win != NULL) {
153 if(tmp_win != occwin->
twm_win) {
154 fprintf(stderr,
"%s(): %p not the expected Occupy window %p.\n",
155 __func__, tmp_win, occwin->
twm_win);
190 title_width = xwc.width = w - (2 * tmp_win->
frame_bw3D);
215 title_width = tmp_win->
rightx +
Scr->TBInfo.rightoff;
216 if(title_width < xwc.width) {
217 xwc.width = title_width;
239 title_width = xwc.width;
267 xwc.border_width = bw;
270 xwcm |= (CWX | CWY | CWBorderWidth);
273 XConfigureWindow(
dpy, tmp_win->
title_w, xwcm, &xwc);
282 if(tmp_win->
attr.width != w) {
310 XWindowChanges frame_wc;
311 unsigned int frame_mask;
315 frame_wc.border_width = tmp_win->
frame_bw = bw;
319 frame_mask |= CWBorderWidth;
324 frame_wc.x =
Scr->rootw + 1;
325 frame_wc.y =
Scr->rooth + 1;
335 frame_mask |= (CWX | CWY | CWWidth | CWHeight);
336 XConfigureWindow(
dpy, tmp_win->
frame, frame_mask, &frame_wc);
347 tmp_win->
attr.width, tmp_win->
attr.height);
384 if(
Scr->use3Dtitles) {
385 xwc.width -=
Scr->TitleButtonShadowDepth;
398 xwcm = CWX | CWWidth;
416 if(
Scr->TBInfo.nright > 0) {
417 xwc.width -= 2 *
Scr->TitlePadding;
421 if(
Scr->use3Dtitles) {
422 xwc.width -=
Scr->TitleButtonShadowDepth;
434 xwcm = CWX | CWWidth;
459 memset(&client_event, 0,
sizeof(client_event));
461 client_event.type = ConfigureNotify;
462 client_event.xconfigure.display =
dpy;
463 client_event.xconfigure.event = tmp_win->
w;
464 client_event.xconfigure.window = tmp_win->
w;
467 client_event.xconfigure.y = (
y + tmp_win->
frame_bw +
470 client_event.xconfigure.width = tmp_win->
attr.width;
471 client_event.xconfigure.height = tmp_win->
attr.height;
472 client_event.xconfigure.border_width = tmp_win->
old_bw;
475 client_event.xconfigure.above = tmp_win->
frame;
476 client_event.xconfigure.override_redirect = False;
477 XSendEvent(
dpy, tmp_win->
w, False, StructureNotifyMask, &client_event);
518 XShapeCombineShape(
dpy, tmp->
frame, ShapeBounding,
520 ShapeBounding, ShapeSet);
522 XShapeCombineShape(
dpy, tmp->
frame, ShapeBounding,
539 XRectangle newBounding[2];
540 XRectangle newClip[2];
556 newBounding[1].y =
Scr->TitleHeight;
557 newBounding[1].width = tmp->
attr.width + fbw2 + 2 * tmp->
frame_bw3D;
558 newBounding[1].height = tmp->
attr.height + fbw2 + 2 * tmp->
frame_bw3D;
559 XShapeCombineRectangles(
dpy, tmp->
frame, ShapeBounding, 0, 0,
560 newBounding, 2, ShapeSet, YXBanded);
570 XShapeCombineRectangles(
dpy, tmp->
frame, ShapeClip, 0, 0,
571 newClip, 2, ShapeSet, YXBanded);
580 XShapeCombineMask(
dpy, tmp->
frame, ShapeBounding, 0, 0,
582 XShapeCombineMask(
dpy, tmp->
frame, ShapeClip, 0, 0,
621 basex = ((si->
num * maxwidth) / si->
denom);
640 if(basex > maxwidth - tw) {
641 basex = maxwidth - tw;
663 unsigned long valuemask;
664 XSetWindowAttributes attributes;
665 int leftx, rightx,
y;
685 leftx =
y =
Scr->TBInfo.leftx;
692 attributes.win_gravity = NorthWestGravity;
693 attributes.background_pixel = tmp_win->
title.
back;
694 attributes.border_pixel = tmp_win->
title.
fore;
695 attributes.event_mask = (ButtonPressMask | ButtonReleaseMask |
697 attributes.cursor =
Scr->ButtonCursor;
698 valuemask = (CWWinGravity | CWBackPixel | CWBorderPixel | CWEventMask |
705 nb =
Scr->TBInfo.nleft +
Scr->TBInfo.nright;
715 fprintf(stderr,
"%s: unable to allocate %d titlebuttons\n",
720 int boxwidth = (
Scr->TBInfo.width +
Scr->TBInfo.pad);
721 unsigned int h = (
Scr->TBInfo.width -
Scr->TBInfo.border * 2);
724 tb = tb->
next, tbw++) {
729 attributes.win_gravity = NorthEastGravity;
734 attributes.win_gravity = NorthWestGravity;
740 valuemask, &attributes);
741 if(
Scr->NameDecorations) {
742 XStoreName(
dpy, tbw->
window,
"TB button");
761 fprintf(stderr,
"%s: unable to add titlebar button \"%s\"\n",
834 const int titlew = width -
Scr->TBInfo.titlex -
Scr->TBInfo.rightoff;
859 fprintf(stderr,
"%s(): Unexpected Scr->TitleJustification %d, "
860 "treating as left\n", __func__,
Scr->TitleJustification);
863 if(
Scr->use3Dtitles) {
864 tmp_win->
name_x +=
Scr->TitleShadowDepth + 2;
879 if(
Scr->use3Dtitles) {
880 tmp_win->
name_x -=
Scr->TitleShadowDepth - 2;
893 if(
Scr->use3Dtitles) {
894 if(tmp_win->
name_x < (
Scr->TBInfo.titlex + 2 *
Scr->TitleShadowDepth)) {
895 tmp_win->
name_x =
Scr->TBInfo.titlex + 2 *
Scr->TitleShadowDepth;
898 else if(tmp_win->
name_x <
Scr->TBInfo.titlex) {
908 if(
Scr->use3Dtitles) {
928 if(
Scr->use3Dtitles) {
948 tmp_win->
rightx = width -
Scr->TBInfo.rightoff;
952 + (
Scr->TBInfo.nright > 0 ?
Scr->TitlePadding : 0)
953 +
Scr->FramePadding);
954 if(rx < tmp_win->rightx) {
969 XSetWindowAttributes attributes;
970 unsigned long valuemask;
971 int h = (
Scr->TitleHeight - 2 *
Scr->FramePadding);
972 int y =
Scr->FramePadding;
996 if(
Scr->HighlightPixmapName) {
1005 if(
Scr->use3Dtitles && (
Scr->Monochrome != COLOR)) {
1023 valuemask = CWBackPixmap;
1027 valuemask = CWBackPixel;
1028 attributes.background_pixel = tmp_win->
title.
fore;
1038 if(
Scr->use3Dtitles) {
1039 y +=
Scr->TitleShadowDepth;
1040 h -= 2 *
Scr->TitleShadowDepth;
1047#define MKWIN() XCreateWindow(dpy, tmp_win->title_w, 0, y, \
1048 Scr->TBInfo.width, h, \
1049 0, Scr->d_depth, CopyFromParent, \
1050 Scr->d_visual, valuemask, &attributes)
1053 if(
Scr->NameDecorations) {
1059 if(
Scr->NameDecorations) {
1078 if(
Scr->HighlightPixmapName) {
1097 XSetWindowAttributes attributes;
1098 unsigned long valuemask;
1099 int h = (
Scr->TitleHeight - 2 *
Scr->FramePadding);
1100 int y =
Scr->FramePadding;
1120 if(
Scr->HighlightPixmapName) {
1121 cp = tmp_win->
title;
1130 valuemask = CWBackPixmap;
1134 valuemask = CWBackPixel;
1135 attributes.background_pixel = tmp_win->
title.
fore;
1139 if(
Scr->use3Dtitles) {
1140 y +=
Scr->TitleShadowDepth;
1141 h -= 2 *
Scr->TitleShadowDepth;
1148#define MKWIN() XCreateWindow(dpy, tmp_win->title_w, 0, y, \
1149 Scr->TBInfo.width, h, \
1150 0, Scr->d_depth, CopyFromParent, \
1151 Scr->d_visual, valuemask, &attributes)
1154 if(
Scr->NameDecorations) {
1160 if(
Scr->NameDecorations) {
1192 if(
Scr->use3Dtitles) {
1198 -
Scr->TBInfo.rightoff -
Scr->TitlePadding;
1206 if(
Scr->SunkFocusWindowTitle && (
Scr->Focus == tmp_win) &&
1212 Scr->TitleHeight,
Scr->TitleShadowDepth,
1213 tmp_win->
title, state,
true,
false);
1220 if(
Scr->use3Dtitles) {
1221 int width, mwidth,
len;
1222 XRectangle ink_rect;
1223 XRectangle logical_rect;
1232 XmbTextExtents(
Scr->TitleBarFont.font_set,
1234 &ink_rect, &logical_rect);
1235 width = logical_rect.width;
1237 Scr->TBInfo.rightoff -
Scr->TitlePadding -
1238 Scr->TitleShadowDepth - 4;
1239 while((
len > 0) && (width > mwidth)) {
1241 XmbTextExtents(
Scr->TitleBarFont.font_set,
1243 &ink_rect, &logical_rect);
1244 width = logical_rect.width;
1252 ((
Scr->Monochrome != COLOR) ? XmbDrawImageString : XmbDrawString)
1256 (
Scr->TitleHeight - logical_rect.height) / 2 + (- logical_rect.y),
1269 XmbDrawString(
dpy, tmp_win->
title_w,
Scr->TitleBarFont.font_set,
1272 tmp_win->
name, strlen(tmp_win->
name));
1286 int nb =
Scr->TBInfo.nleft +
Scr->TBInfo.nright;
1288 for(i = 0, tbw = tmp_win->
titlebuttons; i < nb; i++, tbw++) {
1324 XRectangle rects [2];
1330 width - thick + 2 * bw, height - thick + 2 * bw,
1331 bw, cp,
on,
true,
false);
1336 width - thick + bw, height - thick,
1337 bw, cp,
on,
true,
false);
1340 rects [0].x =
x + width - thick;
1342 rects [0].width = thick;
1343 rects [0].height = height;
1345 rects [1].y =
y + width - thick;
1346 rects [1].width = width - thick;
1347 rects [1].height = thick;
1348 XSetClipRectangles(
dpy,
Scr->BorderGC, 0, 0, rects, 2, Unsorted);
1351 width - thick + bw, height - thick + bw,
1352 bw, cp,
on,
true,
false);
1353 XSetClipMask(
dpy,
Scr->BorderGC, None);
1358 rects [0].width = thick;
1359 rects [0].height = height;
1360 rects [1].x =
x + thick;
1361 rects [1].y =
y + height - thick;
1362 rects [1].width = width - thick;
1363 rects [1].height = thick;
1364 XSetClipRectangles(
dpy,
Scr->BorderGC, 0, 0, rects, 2, Unsorted);
1367 width - thick, height - thick + bw,
1368 bw, cp,
on,
true,
false);
1369 XSetClipMask(
dpy,
Scr->BorderGC, None);
1373 fprintf(stderr,
"Internal error: Invalid Draw3DCorner type %d\n",
1403 Scr->BorderShadowDepth, cp,
off,
true,
false);
1409 Scr->BorderShadowDepth, cp,
on,
true,
false);
1421#define CORNERLEN (Scr->TitleHeight + tmp_win->frame_bw3D)
1454 Scr->BorderShadowDepth, cp,
off,
true,
false);
1461 Scr->BorderShadowDepth, cp,
off,
true,
false);
1468 Scr->BorderShadowDepth, cp,
off,
true,
false);
1475 Scr->BorderShadowDepth, cp,
off,
true,
false);
1494 Scr->BorderShadowDepth, cp,
off,
true,
false);
1501 Scr->BorderShadowDepth, cp,
off,
true,
false);
1516 XSetWindowAttributes attr;
1525 h =
Scr->TitleHeight + wd;
1529#if defined DEBUG && DEBUG
1530 fprintf(stderr,
"wd=%d h=%d, fw=%d fh=%d x=%d y=%d\n",
1531 wd, h, fw, fh,
x,
y);
1550 if((
x < -wd) || (
y < -wd)) {
1551 cursor =
Scr->FrameCursor;
1557 else if(
y >= fh - h) {
1564 else if(
x >= fw - h) {
1568 else if(
y >= fh - h) {
1578 else if(
y >= fh - h) {
1582 cursor =
Scr->FrameCursor;
1584 attr.cursor = cursor;
1585 XChangeWindowAttributes(
dpy, tmp_win->
frame, CWCursor, &attr);
#define FB(fix_fore, fix_back)
void Draw3DBorder(Window w, int x, int y, int width, int height, int bw, ColorPair cp, ButtonState state, bool fill, bool forcebw)
int frame_x
X position on screen of frame.
Window hilite_wl
Left hilite window in titlebar.
Image * LoliteImage
Titlebar lolite backround.
int actual_frame_x
Saved frame_x when squeezed.
int actual_frame_y
Saved frame_y when squeezed.
Window lolite_wl
Left lolite window in titlebar.
unsigned int title_width
Width of the full title bar.
Window hilite_wr
Right hilite window in titlebar.
int title_x
X coord of window title relative to title_w.
Image * HiliteImage
Titlebar hilite backround.
int frame_y
Y position on screen of frame.
unsigned int name_width
width of name text
int rightx
Position of of right titlebar buttons.
Window frame
The X window for the overall frame.
Window lolite_wr
Right lolite window in titlebar.
int frame_bw
2d border width.
TBWindow * titlebuttons
Button windows in the titlebar.
unsigned int title_height
Height of the full title bar.
Window title_w
The title bar Window.
Cursor curcurs
Current resize cursor.
unsigned int frame_width
Width of frame.
int highlightxl
Position of hilite_wl and lolite_wl.
unsigned int frame_height
Height of frame.
int frame_bw3D
3d border width.
int name_x
Position of window title text, relative to title_w.
int title_y
Y coord of window title relative to title_w.
int highlightxr
Position of hilite_wr and lolite_wr.
Image * GetImage(const char *name, ColorPair cp)
Pixmap mk_blackgray_pixmap(const char *which, Drawable dw, unsigned long fg, unsigned long bg)
void get_blackgray_size(int *width, int *height)
void ResizeOccupyWindow(TwmWindow *win)
RArea RAreaNew(int x, int y, int width, int height)
Construct an RArea from given components.
int RLayoutFindBottomEdge(const RLayout *self, const RArea *area)
Find the bottom of the top stripe of self that area fits into.
int RLayoutFindRightEdge(const RLayout *self, const RArea *area)
Find the right edge of the left-most stripe of self that area fits into.
int RLayoutFindLeftEdge(const RLayout *self, const RArea *area)
Find the left edge of the right-most stripe of self that area fits into.
int RLayoutFindTopEdge(const RLayout *self, const RArea *area)
Find the top of the bottom stripe of self that area fits into.
A particular extent of space.
Info and control for every X Window we take over.
ColorPair border_tile
ColorPair for non-focused window borders.
bool titlehighlight
Should I highlight the title bar?
bool wShaped
This window is Shape'd.
bool isiconmgr
This is an icon manager window.
bool heightEverChangedByUser
Has TwmWindow::attr height ever changed? Used only in sessions.
Window w
The actual X Window handle.
int old_bw
Original window border width before we took it over and made our own bordering.
char * name
Current window name. Points into TwmWindow::names.
bool widthEverChangedByUser
Has TwmWindow::attr width ever changed? Used only in sessions.
SqueezeInfo * squeeze_info
Control info for title squeezing.
ColorPair borderC
ColorPair for focused window borders.
struct IconMgr * iconmgrp
Pointer to the icon manager structure, for windows that are icon managers.
ColorPair title
ColorPair for various other titlebar bits.
XWindowAttributes attr
Window attributes from XGetWindowAttributes().
bool UnmapByMovingFarAway
bool isoccupy
This is an Occupy window.
bool highlight
Should highlight this window.
bool squeezed
Is the window squeezed ?
void CreateWindowTitlebarButtons(TwmWindow *tmp_win)
void SetBorderCursor(TwmWindow *tmp_win, int x, int y)
void PaintTitle(TwmWindow *tmp_win)
void ComputeTitleLocation(TwmWindow *tmp)
void SetFrameShape(TwmWindow *tmp)
void PaintTitleButton(TwmWindow *tmp_win, TBWindow *tbw)
void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw)
static void Draw3DCorner(Window w, int x, int y, int width, int height, int thick, int bw, ColorPair cp, CornerType type)
void PaintTitleButtons(TwmWindow *tmp_win)
void PaintBorders(TwmWindow *tmp_win, bool focus)
void SetupFrame(TwmWindow *tmp_win, int x, int y, int w, int h, int bw, bool sendEvent)
static void CreateHighlightWindows(TwmWindow *tmp_win)
static void ComputeWindowTitleOffsets(TwmWindow *tmp_win, unsigned int width, bool squeeze)
static void CreateLowlightWindows(TwmWindow *tmp_win)
void DeleteHighlightWindows(TwmWindow *tmp_win)
bool visible(const TwmWindow *tmp_win)
void WMapSetupWindow(TwmWindow *win, int x, int y, int w, int h)