int nmiss;
X.font = XCreateFontSet(X.disp, FONT_NAME, &miss, &nmiss, &def);
if (!X.font)
+ {
+ X.font = XCreateFontSet(X.disp, "fixed", &miss, &nmiss, &def);
+ }
+ if (!X.font)
{
printf("anvil: fatal error: unable to create font set for title font\n");
exit(1);
XSync(X.disp, False);
/* initialize all the things */
+ Atoms_Init();
InitCursors();
InitFont();
Client_InitAll();
Keys_Init();
Monitors_Init();
- Atoms_Init();
/* setup window life-cycle management event handlers */
X.eventfns[MapRequest] = XMapRequest;
{
Client* c = NULL;
XWindowAttributes attr;
+
if (XGetWindowAttributes(X.disp, win, &attr) && !attr.override_redirect)
{
- /* we care about it, let's add it to withdrawn */
+ /* we care about it, let's add it to the list */
c = Allocate(1, sizeof(Client));
c->win = win;
c->x = attr.x;
}
}
Client_Place(c);
-
}
return c;
}
c->y = mon->y + c->rel_y;
Client_MoveResize(c);
+ /* set mouse to titlebar if mapping for first time */
+ if (!(c->wm_flags & F_MAPPED_ONCE))
+ {
+ Mouse_ToTitle(c);
+ c->wm_flags |= F_MAPPED_ONCE;
+ }
+
+ /* update, map and redraw */
ReadProps(c);
SetWMState(c, NormalState);
XMapWindow(X.disp, c->frame);
c->rel_y = c->y - Monitors[monitor].y;
}
-
-
-
-
void Client_InitAll(void)
{
-// /* TODO: Find all top-level windows and register them correctly
-//
-// * Find all root children with override_redirect set False
-// * Add them to withdrawn list if WM_STATE = withdrawn
-// * Add them as floating and unshaded if WM_STATE = Normal
-// * Add them as floating ad shaded if WM_STATE = Iconic
-//
-// */
-//
-// unsigned int nwins;
-// Window d1, d2, *wins = NULL;
-// XWindowAttributes attr;
-// if (XQueryTree(X.disp, X.root, &d1, &d2, &wins, &nwins))
-// {
-// for (unsigned int i = 0; i < nwins; i++)
-// {
-// if (XGetWindowAttributes(X.disp, wins[i], &attr) && (attr.override_redirect == False))
-// {
-// Client* c = client_add(wins[i], &attr);
-// c->flags |= F_FLOATING;
-// }
-// }
-// xfree(wins);
-// }
+ unsigned int nwins;
+ Window d1, d2, *wins = NULL;
+ XWindowAttributes attr;
+ if (XQueryTree(X.disp, X.root, &d1, &d2, &wins, &nwins))
+ {
+ for (unsigned int i = 0; i < nwins; i++)
+ {
+ if (XGetWindowAttributes(X.disp, wins[i], &attr) && (attr.override_redirect == False) && (attr.map_state == IsViewable))
+ {
+ Client* c = Client_Create(wins[i]);
+ c->wm_flags |= F_MAPPED_ONCE;
+ Client_Show(c);
+ }
+ }
+ xfree(wins);
+ Client_UpdateAll();
+ }
}
void Client_UpdateAll(void)
// }
//}
-
static void ReadProps(Client* c)
{
Atom *protos = NULL, actual_type, *wintype;