X.font_ext = XExtentsOfFontSet(X.font);
}
-static void init_graphics(void)
-{
- XGCValues gv;
- /* Set up root (frame) GC's. */
- gv.foreground = X.black ^ X.white;
- gv.background = X.white;
- gv.function = GXxor;
- gv.line_width = 1;
- gv.subwindow_mode = IncludeInferiors;
- gv.line_width = 2;
- X.graphics = XCreateGC(X.disp, X.root,
- GCForeground | GCBackground | GCFunction |
- GCLineWidth | GCSubwindowMode, &gv);
-}
-
int main(void)
{
- XColor color, exact;
/* Initialize X server*/
check( (X.disp = XOpenDisplay(0)) != NULL,
"could not open display");
X.mode = M_INIT;
X.root = DefaultRootWindow(X.disp);
X.screen = DefaultScreen(X.disp);
- X.black = BlackPixel(X.disp, X.screen);
- X.white = WhitePixel(X.disp, X.screen);
- XAllocNamedColor(X.disp, DefaultColormap(X.disp, X.screen), "DimGray", &color, &exact);
- X.gray = color.pixel;
+ X.clr_bg = 0x00FFFFEA;
+ X.clr_bdr = 0x00000000;
+ X.clr_urgent = 0x00FF7700;
/* initialize all the things */
check_for_wm();
init_cursors();
init_font();
- init_graphics();
mons_init();
client_initall();
keys_init();
{
X.eventfns[ev.type](&ev);
}
+ XSync(X.disp, False);
}
return 0;
Display* disp;
int screen, mode, edge, start_x, start_y, last_x, last_y;
Window root;
- unsigned long black, white, gray;
+ unsigned long clr_bg, clr_bdr, clr_urgent;
Cursor csr_root, csr_point, csr_move;
XFontSet font;
XFontSetExtents *font_ext;
- GC graphics;
void (*eventfns[LASTEvent])(XEvent*);
} XConf;
char* name;
Window frame, win;
int flags, x, y, w, h;
- long hint_flags;
+ long hint_flags, wm_flags;
XSizeHints hints;
} Client;
client_readprops(c);
/* Reparent the window if applicable */
- c->frame = XCreateSimpleWindow(X.disp, X.root, c->x, c->y, c->w, c->h, 1, X.black, X.black);
+ c->frame = XCreateSimpleWindow(X.disp, X.root, c->x, c->y, c->w, c->h, 1, X.clr_bdr, X.clr_bg);
XSelectInput(X.disp, c->frame,
ExposureMask | EnterWindowMask |
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
{
if (c->frame)
{
- XSetWindowBackground(X.disp, c->frame, (Focused == c) ? X.black : X.white);
+ XSetWindowBackground(X.disp, c->frame, ((c->wm_flags & XUrgencyHint) ? X.clr_urgent : X.clr_bg));
XSetWindowBorderWidth(X.disp, c->frame, 1);
- XSetWindowBorder(X.disp, c->frame, (Focused == c) ? X.white : X.black);
+ XSetWindowBorder(X.disp, c->frame, X.clr_bdr);
XSetWindowBorderWidth(X.disp, c->win, 1);
- XSetWindowBorder(X.disp, c->win, (Focused == c) ? X.white : X.black);
+ XSetWindowBorder(X.disp, c->win, X.clr_bdr);
XClearWindow(X.disp, c->frame);
XDefineCursor(X.disp, c->frame, X.csr_point);
if (c->name) {
int ascent = abs(X.font_ext->max_logical_extent.y);
Xutf8DrawString(X.disp, c->frame, X.font,
- X.graphics, BORDER_WIDTH,
+ DefaultGC(X.disp, X.screen),
+ BORDER_WIDTH,
2 + ascent,
c->name, strlen(c->name));
}
}
}
xfree(protos);
+
+
+ XWMHints* hints = XGetWMHints(X.disp, c->win);
+ if (hints)
+ {
+ c->wm_flags = hints->flags;
+ }
+ xfree(hints);
}
void client_shade(Client* c)