36#include "functions_defs.h"
75 if(
Scr->NoIconManagers) {
86 if(
Scr->use3Diconmanagers) {
90 if(
Scr->siconifyPm == None) {
99 ws =
Scr->workSpaceMgr.workSpaceList;
100 for(
IconMgr *q =
Scr->iconmgr; q != NULL; q = q->nextv) {
109 snprintf(imname,
sizeof(imname),
"%s Icon Manager", p->name);
111 if(!p->geometry || !strlen(p->geometry)) {
112 p->geometry =
"+0+0";
116 (
unsigned int *) &p->width, (
unsigned int *)&p->height);
119 (
Scr->ThreeDBorderWidth ?
Scr->ThreeDBorderWidth :
Scr->BorderWidth);
121 if(mask & XNegative) {
122 gx +=
Scr->rootw - p->width - 2 * bw;
123 gravity = (mask & YNegative) ? SouthEastGravity : NorthEastGravity;
126 gravity = (mask & YNegative) ? SouthWestGravity : NorthWestGravity;
128 if(mask & YNegative) {
129 gy +=
Scr->rooth - p->height - 2 * bw;
132 background =
Scr->IconManagerC.back;
142 p->w = XCreateSimpleWindow(
dpy,
Scr->Root,
143 gx, gy, p->width, p->height, 1,
144 Scr->Black, background);
156 icon_name = strdup(p->icon_name);
159 asprintf(&icon_name,
"%s Icons", p->name);
162 wmhints.initial_state = NormalState;
163 wmhints.input = True;
164 wmhints.flags = InputHint | StateHint;
166 clhints.res_name = icon_name;
167 clhints.res_class =
"TwmIconManager";
169 XmbSetWMProperties(
dpy, p->w, imname, icon_name, NULL, 0, NULL,
182 p->twm_win->occupation = 1 << ws->
number;
186 if(ws->
number !=
Scr->currentvs->wsw->currentwspc->number) {
187 p->twm_win->vs = NULL;
191 p->twm_win->occupation = 1;
196 "CreateIconManagers: IconMgr %p: twm_win=%p win=0x%lx "
197 "name='%s' x=%d y=%d w=%d h=%d occupation=%x\n",
198 p, p->twm_win, p->twm_win->w, p->name,
199 gx, gy, p->width, p->height, p->twm_win->occupation);
203 XSizeHints sizehints;
205 sizehints.flags = PWinGravity;
206 sizehints.win_gravity = gravity;
207 XSetWMSizeHints(
dpy, p->w, &sizehints, XA_WM_NORMAL_HINTS);
210 p->twm_win->mapped =
false;
212 if(p->twm_win && (p->twm_win->wmhints->initial_state == IconicState)) {
213 p->twm_win->isicon =
true;
215 else if(!
Scr->NoIconManagers &&
Scr->ShowIconManager) {
216 p->twm_win->isicon =
false;
219 p->twm_win->isicon =
true;
227 if(
Scr->workSpaceManagerActive) {
228 Scr->workSpaceMgr.workSpaceList->iconmgr =
Scr->iconmgr;
243 for(
IconMgr *q =
Scr->iconmgr; q != NULL; q = q->nextv) {
272 fprintf(stderr,
"AllocateIconManager\n");
273 fprintf(stderr,
" name=\"%s\" icon_name=\"%s\", geom=\"%s\", col=%d\n",
274 name, icon_name, geom, columns);
277 if(
Scr->NoIconManagers) {
284 p = calloc(1,
sizeof(
IconMgr));
293 if(
Scr->iconmgr == NULL) {
295 Scr->iconmgr->lasti = p;
298 Scr->iconmgr->lasti->next = p;
300 Scr->iconmgr->lasti = p;
322 if(!
Scr->workSpaceManagerActive) {
327 ws =
Scr->workSpaceMgr.workSpaceList;
332 for(ws = ws->
next; ws != NULL; ws = ws->
next) {
333 IconMgr *ip, *previ, *p = NULL;
351 for(ip = imfirst->
next; ip != NULL; ip = ip->
next) {
409 int cur_row, cur_col, new_row, new_col;
410 int row_inc, col_inc;
427 if((tmp =
Current->next) == NULL) {
434 if((tmp =
Current->prev) == NULL) {
483 for(tmp = ip->
first; tmp != NULL; tmp = tmp->
next) {
484 if(tmp->
row == new_row && tmp->
col == new_col) {
493 "%s: unable to find window (%d, %d) in icon manager\n",
505 XWarpPointer(
dpy, None, tmp->
icon, 0, 0, 0, 0, 5, 5);
509 int tbx =
Scr->TBInfo.titlex;
513 Scr->TitleHeight / 4);
516 XWarpPointer(
dpy, None, tmp->
twm->
w, 0, 0, 0, 0, 5, 5);
559 case F_FORWMAPICONMGR:
560 if((tmp = tmp->
next) == NULL) {
565 case F_BACKMAPICONMGR:
566 if((tmp = tmp->
prev) == NULL) {
581 fprintf(stderr,
"%s: unable to find open window in icon manager\n",
593 XWarpPointer(
dpy, None, tmp->
icon, 0, 0, 0, 0, 5, 5);
599 Scr->TitleHeight / 4);
602 XWarpPointer(
dpy, None, tmp->
twm->
w, 0, 0, 0, 0, 5, 5);
633#define ITER(i) (dir == F_NEXTICONMGR ? (i)->next : (i)->prev)
634#define IPOFSP(sp) (dir == F_NEXTICONMGR ? sp->iconmgr : sp->iconmgr->lasti)
635#define TEST(ip) if ((ip)->count != 0 && (ip)->twm_win->mapped) \
636 { got_it = true; break; }
639 for(tmp_ip =
ITER(ip); tmp_ip; tmp_ip =
ITER(tmp_ip)) {
645 int inc = (dir == F_NEXTICONMGR ? 1 : -1);
647 for(screen = origscreen + inc; ; screen += inc) {
651 else if(screen < 0) {
657 for(tmp_ip =
IPOFSP(sp); tmp_ip; tmp_ip =
ITER(tmp_ip)) {
661 if(got_it || screen == origscreen) {
679 XWarpPointer(
dpy, None, tmp_ip->
active->
icon, 0, 0, 0, 0, 5, 5);
682 XWarpPointer(
dpy, None, tmp_ip->
w, 0, 0, 0, 0, 5, 5);
704 || tmp_win->
w ==
Scr->workSpaceMgr.occupyWindow->w) {
709 if(
Scr->NoIconManagers) {
717 if(
Scr->IconManagerDontShow
724 &tmp_win->
class)) == NULL) {
725 if(
Scr->workSpaceManagerActive) {
726 ip =
Scr->workSpaceMgr.workSpaceList->iconmgr;
738 unsigned long valuemask;
739 XSetWindowAttributes attributes;
749 tmp = calloc(1,
sizeof(
WList));
773 if(
Scr->use3Diconmanagers) {
774 if(!
Scr->BeNiceToColormap) {
781 h =
Scr->IconManagerFont.avg_height
796 valuemask = (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor);
797 attributes.background_pixel = tmp->
cp.
back;
798 attributes.border_pixel = tmp->
cp.
back;
799 attributes.event_mask = (KeyPressMask | ButtonPressMask |
800 ButtonReleaseMask | ExposureMask);
801 if(
Scr->IconManagerFocus) {
802 attributes.event_mask |= (EnterWindowMask | LeaveWindowMask);
804 attributes.cursor =
Scr->IconMgrCursor;
805 tmp->
w = XCreateWindow(
dpy, ip->
w, 0, 0, 1,
807 CopyFromParent, CopyFromParent,
809 valuemask, &attributes);
813 valuemask = (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor);
814 attributes.background_pixel = tmp->
cp.
back;
815 attributes.border_pixel =
Scr->Black;
816 attributes.event_mask = (ButtonReleaseMask | ButtonPressMask
818 attributes.cursor =
Scr->ButtonCursor;
820 tmp->
icon = XCreateWindow(
dpy, tmp->
w, 0, 0,
826 valuemask, &attributes);
832 if(
Scr->WindowMask) {
833 XRaiseWindow(
dpy,
Scr->WindowMask);
835 XMapWindow(
dpy, tmp->
w);
845 XMapWindow(
dpy, ip->
w);
910 if(ip->
first == NULL) {
916 else if(
Scr->SortIconMgr) {
917 for(tmp1 = ip->
first; tmp1 != NULL; tmp1 = tmp1->
next) {
919 if(
Scr->CaseSensitive) {
929 if(tmp->
prev == NULL) {
950 if(tmp->
prev == NULL) {
957 if(tmp->
next == NULL) {
985 WList *tmp, *tmp1, *save;
1005 XDestroyWindow(
dpy, tmp->
icon);
1008 XDestroyWindow(
dpy, tmp->
w);
1013 if(ip->
count == 0) {
1039 Active->iconmgr->active = active;
1052 if(
Scr->use3Diconmanagers) {
1054 Scr->IconManagerShadowDepth, tmp->
cp,
1060 XDrawRectangle(
dpy, tmp->
w,
Scr->NormalGC, 2, 2, tmp->
width - 5,
1063 XSetForeground(
dpy,
Scr->NormalGC,
1067 XDrawRectangle(
dpy, tmp->
w,
Scr->NormalGC, 0, 0, tmp->
width - 1,
1069 XDrawRectangle(
dpy, tmp->
w,
Scr->NormalGC, 1, 1, tmp->
width - 3,
1096 for(tmp1 = ip->
first; tmp1 != NULL; tmp1 = tmp1->
next) {
1098 if((tmp2 = tmp1->
next) == NULL) {
1102 if(
Scr->CaseSensitive) {
1108 if(compresult > 0) {
1136 for(twm_win =
Scr->FirstWindow; twm_win != NULL; twm_win = twm_win->
next) {
1145 int newwidth, i, row, col, maxcol, colinc, rowinc, wheight, wwidth;
1151 wheight =
Scr->IconManagerFont.avg_height
1165 for(i = 0, tmp = ip->
first; tmp != NULL; i++, tmp = tmp->
next) {
1175 new_x = col * colinc;
1176 new_y = (row - 1) * rowinc;
1179 if(tmp->
x != new_x || tmp->
y != new_y ||
1181 XMoveResizeWindow(
dpy, tmp->
w, new_x, new_y, wwidth, wheight);
1182 if(tmp->
height != wheight)
1190 tmp->
width = wwidth;
1198 ip->
height = row * rowinc;
1202 newwidth = maxcol * colinc;
1207 XResizeWindow(
dpy, ip->
w, newwidth, ip->
height);
1211 if(mask & XNegative) {
1215 if(mask & YNegative) {
1219 savewidth = ip->
width;
1225 ip->
width = savewidth;
1230 fprintf(stderr,
"IconMgr %s %p name='%s' geom='%s'\n",
1235 fprintf(stderr,
"next = %p, prev = %p, lasti = %p, nextv = %p\n",
1250 XRectangle ink_rect, logical_rect;
1252 XmbTextExtents(
Scr->IconManagerFont.font_set,
1254 &ink_rect, &logical_rect);
1256 if(
UpdateFont(&
Scr->IconManagerFont, logical_rect.height)) {
1264 ((
Scr->use3Diconmanagers && (
Scr->Monochrome != COLOR)) ?
1265 XmbDrawImageString : XmbDrawString)
1268 Scr->IconManagerFont.font_set,
1271 (
Scr->IconManagerFont.avg_height - logical_rect.height) / 2
1272 + (- logical_rect.y)
1298 if(
Scr->use3Diconmanagers && iconmanagerlist->
iconifypm) {
1300 iconmanagerlist->
icon,
1301 Scr->NormalGC, 0, 0,
1306 XCopyPlane(
dpy,
Scr->siconifyPm, iconmanagerlist->
icon,
1307 Scr->NormalGC, 0, 0,
void GrabButtons(TwmWindow *tmp_win)
void GrabKeys(TwmWindow *tmp_win)
TwmWindow * AddWindow(Window w, AWType wtype, IconMgr *iconp, VirtualScreen *vs)
#define FB(fix_fore, fix_back)
int NumScreens
How many Screens are on our display.
ScreenInfo ** ScreenList
List of ScreenInfo structs for each Screen.
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.
unsigned int title_width
Width of the full title bar.
int frame_y
Y position on screen of frame.
Window frame
The X window for the overall frame.
unsigned int title_height
Height of the full title bar.
Window title_w
The title bar Window.
unsigned int frame_width
Width of frame.
unsigned int frame_height
Height of frame.
int frame_bw3D
3d border width.
int highlightxr
Position of hilite_wr and lolite_wr.
void NotActiveIconManager(WList *active)
IconMgr * AllocateIconManager(char *name, char *icon_name, char *geom, int columns)
void JumpIconManager(int dir)
void PackIconManagers(void)
void AllocateOtherIconManagers(void)
void MoveIconManager(int dir)
void DrawIconManagerBorder(WList *tmp, bool fill)
void CreateIconManagers(void)
void RemoveIconManager(TwmWindow *tmp_win)
void ActiveIconManager(WList *active)
void InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win)
void RemoveFromIconManager(IconMgr *ip, WList *tmp)
void dump_iconmanager(IconMgr *mgr, char *label)
void ShowIconifiedIcon(TwmWindow *tmp_win)
void CurrentIconManagerEntry(WList *current)
void DrawIconManagerIconName(TwmWindow *tmp_win)
void SortIconManager(IconMgr *ip)
WList * AddIconManager(TwmWindow *tmp_win)
void MoveMappedIconManager(int dir)
void PackIconManager(IconMgr *ip)
const unsigned int im_iconified_icon_width
Pixmap Create2DIconManagerIcon(void)
Pixmap Create3DIconManagerIcon(ColorPair cp)
const unsigned int im_iconified_icon_height
bool GetColorFromList(name_list *list_head, char *name, XClassHint *class, Pixel *ptr)
void * LookInList(name_list *list_head, const char *name, XClassHint *class)
void OtpRaise(TwmWindow *twm_win, WinType wintype)
struct IconMgr * nextv
Next workspace's icon manager head.
struct IconMgr * prev
Prev iconmgr in this workspace.
struct IconMgr * lasti
Last iconmgr in this workspace.
struct IconMgr * next
Next iconmgr in this workspace.
Info and control for each X Screen we control.
int screen
Which screen (i.e., the x after the dot in ":0.x").
Info and control for every X Window we take over.
struct TwmWindow * next
Next TwmWindow on the Screen.
bool iswspmgr
This is a workspace manager window.
bool isiconmgr
This is an icon manager window.
Window w
The actual X Window handle.
bool istransient
This is a transient window.
char * name
Current window name. Points into TwmWindow::names.
char * icon_name
Current icon name. Points into TwmWindow::names.
int occupation
Workspaces the window is in (bitmap).
bool mapped
Is the window mapped ?
XClassHint class
Window class info. From XGetClassHint().
struct IconMgr * iconmgrp
Pointer to the icon manager structure, for windows that are icon managers.
struct WList * iconmanagerlist
List of the icon managers the window is in.
bool isicon
Is the window an icon now ?
bool UpdateFont(MyFont *font, int height)
Try adjusting a font's height.
void GetShadeColors(ColorPair *cp)
Try and create a 'shaded' version of a color for prettier UI.
void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw)
bool visible(const TwmWindow *tmp_win)
void SetMapStateProp(TwmWindow *tmp_win, int state)
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.