27#include <X11/extensions/shape.h>
47 int *final_x,
int *final_y);
52static int roundUp(
int v,
int multiple);
98 ie->
y =
new->y +
new->h;
101 new->y = ie->
y + ie->
h;
112 new->next = ie->
next;
115 new->w = (ie->
w - w);
120 ie->
x =
new->x +
new->w;
123 new->x = ie->
x + ie->
w;
136 int stepx,
int stepy,
137 const char *ijust,
const char *just,
const char *align)
145 if(
Scr->LastRegion) {
146 Scr->LastRegion->next = ir;
148 Scr->LastRegion = ir;
149 if(!
Scr->FirstRegion) {
150 Scr->FirstRegion = ir;
165 ir->
x = ir->
y = ir->
w = ir->
h = 0;
168 (
unsigned int *)&ir->
w, (
unsigned int *)&ir->
h);
170 if(mask & XNegative) {
171 ir->
x +=
Scr->rootw - ir->
w;
173 if(mask & YNegative) {
174 ir->
y +=
Scr->rooth - ir->
h;
185 fprintf(stderr,
"ignoring invalid IconRegion argument \"%s\"\n", ijust);
192 fprintf(stderr,
"ignoring invalid IconRegion argument \"%s\"\n", just);
199 fprintf(stderr,
"ignoring invalid IconRegion argument \"%s\"\n", align);
217 int *final_x,
int *final_y)
234 for(ir =
Scr->FirstRegion; ir; ir = ir->
next) {
249 if(ie->
w >= w && ie->
h >= h) {
268 for(ir =
Scr->FirstRegion; ir; ir = ir->
next) {
275 if(ie->
w >= w && ie->
h >= h) {
287 oldir = tmp_win->
icon->
ir;
305 *final_x = ie->
x + (ie->
w - iconWidth) / 2;
308 *final_x = ie->
x + ie->
w - iconWidth;
312 *final_x = ie->
x + ie->
w - iconWidth;
327 *final_y = ie->
y + (ie->
h - iconHeight) / 2;
330 *final_y = ie->
y + ie->
h - iconHeight;
334 *final_y = ie->
y + ie->
h - iconHeight;
359 if(tmp_win->
icon->
ir != oldir) {
379 for(ir =
Scr->FirstRegion; ir; ir = ir->
next) {
416 if(old->
y == ie->
y) {
417 ie->
w = old->
w + ie->
w;
423 ie->
h = old->
h + ie->
h;
450 unsigned long event_mask;
451 unsigned long valuemask;
452 XSetWindowAttributes attributes;
453 int final_x, final_y;
459 icon = malloc(
sizeof(
struct Icon));
473 if(
Scr->use3Diconmanagers && !
Scr->BeNiceToColormap) {
515 if(image == NULL && tmp_win->
wmhints->flags & IconPixmapHint) {
516 unsigned int IconDepth, IconWidth, IconHeight;
518 if(XGetGeometry(
dpy, tmp_win->
wmhints->icon_pixmap,
521 image->
width = IconWidth;
522 image->
height = IconHeight;
525 if(IconDepth ==
Scr->d_depth)
536 if((tmp_win->
wmhints->flags & IconMaskHint) &&
537 XGetGeometry(
dpy, tmp_win->
wmhints->icon_mask,
542 image->
mask = XCreatePixmap(
dpy,
Scr->Root, IconWidth, IconHeight, 1);
544 gc = XCreateGC(
dpy, image->
mask, 0, NULL);
547 0, 0, IconWidth, IconHeight, 0, 0);
559 if(image == NULL && !
Scr->ForceIcon) {
564 if(image == NULL &&
Scr->UnknownImage != NULL) {
565 image =
Scr->UnknownImage;
578 valuemask = CWBackPixmap;
579 attributes.background_pixmap = image->
pixmap;
583 if(
Scr->NoIconTitlebar ||
594 XRectangle logical_rect;
596 XmbTextExtents(
Scr->IconFont.font_set,
598 &inc_rect, &logical_rect);
599 icon->
w_width = logical_rect.width;
613 icon->
y = icon->
height +
Scr->IconFont.height +
Scr->IconManagerShadowDepth;
623 if(tmp_win->
wmhints->flags & IconWindowHint) {
624 icon->
w = tmp_win->
wmhints->icon_window;
630 tmp_win->
wmhints->flags &= ~IconWindowHint;
646 if((image != NULL) &&
647 image->
mask != None &&
648 !(tmp_win->
wmhints->flags & IconWindowHint)) {
651 if(icon->
w == None) {
652 icon->
w = XCreateSimpleWindow(
dpy,
Scr->Root,
656 event_mask = ExposureMask;
659 if(
Scr->AutoRaiseIcons ||
Scr->ShrinkIconTitles) {
660 event_mask |= EnterWindowMask | LeaveWindowMask;
662 event_mask |= KeyPressMask | ButtonPressMask | ButtonReleaseMask;
665 XWindowAttributes wattr;
667 XGetWindowAttributes(
dpy, icon->
w, &wattr);
668 if(wattr.all_event_masks & ButtonPressMask) {
669 event_mask &= ~ButtonPressMask;
672 XSelectInput(
dpy, icon->
w, event_mask);
674 if(icon->
width == 0) {
678 if(image && !(tmp_win->
wmhints->flags & IconWindowHint)) {
682 icon->
bm_w = XCreateWindow(
dpy, icon->
w,
x, 0,
687 Scr->d_visual, valuemask,
690 XShapeCombineMask(
dpy, icon->
bm_w, ShapeBounding, 0, 0, image->
mask, ShapeSet);
691 XShapeCombineMask(
dpy, icon->
w, ShapeBounding,
x, 0, image->
mask, ShapeSet);
696 rect.width = icon->
width;
697 rect.height = icon->
height;
698 XShapeCombineRectangles(
dpy, icon->
w, ShapeBounding,
699 0, 0, &rect, 1, ShapeSet, 0);
702 if(
Scr->ShrinkIconTitles) {
705 rect.width = icon->
width;
716 XShapeCombineRectangles(
dpy, icon->
w, ShapeBounding,
717 0, 0, &rect, 1, ShapeUnion, 0);
721 if(pattern != NULL) {
725 tmp_win->
icon = icon;
729 final_x = final_y = 0;
730 if(tmp_win->
wmhints->flags & IconPositionHint) {
731 final_x = tmp_win->
wmhints->icon_x;
732 final_y = tmp_win->
wmhints->icon_y;
736 PlaceIcon(tmp_win, def_x, def_y, &final_x, &final_y);
740 if(
visible(tmp_win) || (tmp_win->
wmhints->flags & IconPositionHint)) {
741 if(final_x >
Scr->rootw) {
742 final_x =
Scr->rootw - icon->
w_width - (2 *
Scr->IconBorderWidth);
744 if(
Scr->ShrinkIconTitles && icon->
bm_w) {
754 if(final_y >
Scr->rooth)
756 Scr->IconFont.height - 6 - (2 *
Scr->IconBorderWidth);
761 XMoveWindow(
dpy, icon->
w, final_x, final_y);
768 XMapSubwindows(
dpy, icon->
w);
771 XDefineCursor(
dpy, icon->
w,
Scr->IconCursor);
795 for(nptr = tmp_win->
iconslist; nptr != NULL;) {
798 if(icon != tmp_win->
icon) {
817 XDestroyWindow(
dpy, icon->
w);
869 if(tmp_win->
wmhints->flags & IconPositionHint) {
875 unsigned int iww, iwh;
882 x = defx + ((int) iww) / 2;
883 y = defy + ((int) iwh) / 2;
885 for(ir =
Scr->FirstRegion; ir; ir = ir->
next) {
886 if(
x >= ir->
x &&
x < (ir->
x + ir->
w) &&
887 y >= ir->
y &&
y < (ir->
y + ir->
h)) {
899 if(
x != defx ||
y != defy) {
927 if(ip && ip->
used ==
false &&
928 ((ip->
x == ie->
x && ip->
w == ie->
w) ||
929 (ip->
y == ie->
y && ip->
h == ie->
h))) {
936 else if(in && in->
used ==
false &&
937 ((in->
x == ie->
x && in->
w == ie->
w) ||
938 (in->
y == ie->
y && in->
h == ie->
h))) {
969 int width, twidth, mwidth,
len,
x;
972 XRectangle logical_rect;
974 if(!tmp_win || !tmp_win->
icon) {
977 icon = tmp_win->
icon;
989 XmbTextExtents(
Scr->IconFont.font_set,
991 &ink_rect, &logical_rect);
992 twidth = logical_rect.width;
994 if(
Scr->use3Diconmanagers) {
996 Scr->IconFont.height +
998 Scr->IconManagerShadowDepth, icon->
iconc,
off,
false,
false);
1000 while((
len > 0) && (twidth > mwidth)) {
1002 XmbTextExtents(
Scr->IconFont.font_set,
1004 &ink_rect, &logical_rect);
1005 twidth = logical_rect.width;
1008 XmbDrawString(
dpy, icon->
w,
Scr->IconFont.font_set,
Scr->NormalGC,
1009 x + ((mwidth - twidth) / 2) +
1026 if(!tmp_win || !tmp_win->
icon) {
1029 icon = tmp_win->
icon;
1042 rect.width = icon->
width;
1044 XShapeCombineRectangles(
dpy, icon->
w, ShapeBounding, 0, 0, &rect, 1,
1058 if(!tmp_win || !tmp_win->
icon) {
1061 icon = tmp_win->
icon;
1076 XShapeCombineRectangles(
dpy, icon->
w, ShapeBounding, 0, 0, &rect, 1, ShapeUnion,
1100 XMoveWindow(
dpy, icon->
bm_w,
x, 0);
1103 XShapeCombineMask(
dpy, icon->
w, ShapeBounding,
x, 0, icon->
image->
mask,
1109 rect.width = icon->
width;
1110 rect.height = icon->
height;
1111 XShapeCombineRectangles(
dpy, icon->
w, ShapeBounding, 0, 0, &rect, 1, ShapeSet,
1116 rect.width = icon->
width;
1118 XShapeCombineRectangles(
dpy, icon->
w, ShapeBounding, 0, 0, &rect, 1, ShapeUnion,
1149 fprintf(stderr,
"%s(): Invalid TitleJustification %d\n",
1162 Icon *icon, *old_icon;
1165 old_icon = win->
icon;
1182 if(pattern == NULL) {
1187 if(old_icon == icon) {
1193 if(old_icon && old_icon->
w) {
1194 XUnmapWindow(
dpy, old_icon->
w);
1211 if(old_icon && old_icon->
w) {
1212 XUnmapWindow(
dpy, old_icon->
w);
1222 bool saveForceIcon =
Scr->ForceIcon;
1223 Scr->ForceIcon =
true;
1225 Scr->ForceIcon = saveForceIcon;
1247 XRectangle ink_rect;
1248 XRectangle logical_rect;
1250 if(
Scr->NoIconTitlebar ||
1260 if(
Scr->SortIconMgr) {
1275 XmbTextExtents(
Scr->IconFont.font_set,
1277 &ink_rect, &logical_rect);
1295 Scr->IconManagerShadowDepth;
1307 XShapeCombineMask(
dpy, win->
icon->
bm_w, ShapeBounding, 0, 0,
1309 XShapeCombineMask(
dpy, win->
icon->
w, ShapeBounding,
x, 0,
1317 XShapeCombineRectangles(
dpy, win->
icon->
w, ShapeBounding,
1318 0, 0, &rect, 1, ShapeSet, 0);
1333 XShapeCombineRectangles(
dpy, win->
icon->
w, ShapeBounding, 0,
1334 0, &rect, 1, ShapeUnion, 0);
1337 if(
Scr->ShrinkIconTitles &&
1344 XClearArea(
dpy, win->
icon->
w, 0, 0, 0, 0, True);
1368 return ((v + multiple - 1) / multiple) * multiple;
1380 char *icon_name = NULL;
1385 if(icon_name != NULL) {
1392 if(icon_name != NULL) {
1400 if(icon_name != NULL) {
1408 icon->
match = matched;
1409 icon->
image = image;
#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)
Image * EwmhGetIcon(ScreenInfo *scr, TwmWindow *twm_win)
void SortIconManager(IconMgr *ip)
static IconEntry * FindIconEntry(TwmWindow *tmp_win, IconRegion **irp)
name_list ** AddIconRegion(const char *geom, RegGravity grav1, RegGravity grav2, int stepx, int stepy, const char *ijust, const char *just, const char *align)
static void PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y)
static void splitIconRegionEntry(IconEntry *ie, RegGravity grav1, RegGravity grav2, int w, int h)
static int roundUp(int v, int multiple)
static IconEntry * prevIconEntry(IconEntry *ie, IconRegion *ir)
void ReleaseIconImage(Icon *icon)
void DeleteIcon(Icon *icon)
void IconUp(TwmWindow *tmp_win)
void DeleteIconsList(TwmWindow *tmp_win)
void RedoIconName(TwmWindow *win)
void ExpandIconTitle(TwmWindow *tmp_win)
void IconDown(TwmWindow *tmp_win)
static void ReshapeIcon(Icon *icon)
void ShrinkIconTitle(TwmWindow *tmp_win)
void PaintIcon(TwmWindow *tmp_win)
void RedoIcon(TwmWindow *win)
void CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y)
static Image * LookupIconNameOrClass(TwmWindow *tmp_win, Icon *icon, char **pattern)
static void mergeEntries(IconEntry *old, IconEntry *ie)
int GetIconOffset(Icon *icon)
Image * GetImage(const char *name, ColorPair cp)
void FreeImage(Image *image)
bool GetColorFromList(name_list *list_head, char *name, XClassHint *class, Pixel *ptr)
void * LookInNameList(name_list *list_head, const char *name)
void * LookPatternInList(name_list *list_head, const char *name, XClassHint *class)
void AddToList(name_list **list_head, const char *name, void *ptr)
void * LookInList(name_list *list_head, const char *name, XClassHint *class)
void * LookPatternInNameList(name_list *list_head, const char *name)
void OtpAdd(TwmWindow *twm_win, WinType wintype)
void OtpFreeIcon(TwmWindow *twm_win)
void OtpReassignIcon(TwmWindow *twm_win, Icon *old_icon)
void OtpRaise(TwmWindow *twm_win, WinType wintype)
void twmrc_error_prefix(void)
int ParseIRJustification(const char *s)
int ParseAlignement(const char *s)
int ParseTitleJustification(const char *s)
struct IconEntry * entries
TitleJust TitleJustification
Info and control for every X Window we take over.
XWMHints * wmhints
Window manager hints.
bool iconified
Has the window ever been iconified?
char * name
Current window name. Points into TwmWindow::names.
struct Icon * icon
The current icon.
char * icon_name
Current icon name. Points into TwmWindow::names.
bool icon_on
Is the icon visible.
XClassHint class
Window class info. From XGetClassHint().
bool icon_moved
User explicitly moved the icon.
struct WList * iconmanagerlist
List of the icon managers the window is in.
bool forced
Has had an icon forced upon it.
name_list * iconslist
The current list of potential icons.
bool isicon
Is the window an icon now ?
void GetShadeColors(ColorPair *cp)
Try and create a 'shaded' version of a color for prettier UI.
bool visible(const TwmWindow *tmp_win)
void WMapUpdateIconName(TwmWindow *win)
int RLayoutXParseGeometry(RLayout *layout, const char *geometry, int *x, int *y, unsigned int *width, unsigned int *height)
Parse an X Geometry out to get the positions and sizes.