static void xpropnotify(XEvent* e)
{
- (void)e;
- /* TODO: update window titles */
XPropertyEvent* ev = &(e->xproperty);
Client* c = client_get(ev->window);
if (c)
keys_run(&(e->xkey));
}
-int main(void)
+static void init_cursors(void)
{
- XColor color, red, white, exact;
- /* Initialize X server*/
- check( (X.disp = XOpenDisplay(0)) != NULL,
- "could not open display");
- 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;
-
- /* configure mouse cursors */
+ XColor red, white, exact;
Colormap cmap = DefaultColormap(X.disp, X.screen);
X.csr_root = XCreateFontCursor(X.disp, XC_left_ptr);
XAllocNamedColor(X.disp, cmap, "red", &red, &exact);
X.csr_point = XCreateFontCursor(X.disp, XC_left_ptr);
XRecolorCursor(X.disp, X.csr_point, &red, &white);
XDefineCursor(X.disp, X.root, X.csr_root);
+}
+static void init_font(void)
+{
/* load the font */
char **miss, *def;
int nmiss;
}
check(X.font != NULL, "unable to create font set for title font");
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;
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.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;
+ /* initialize anvil-specific stuff */
check_for_wm();
+ init_cursors();
+ init_font();
+ init_graphics();
mons_init();
client_initall();
keys_init();
mons_towspace(Focused, arg->i);
}
+#ifdef __APPLE__
+#define MODKEY Mod1Mask
+#else
#define MODKEY Mod4Mask
+#endif
static Key keys[] = {
{ MODKEY, XK_1, set_workspace, {.i = 0 } },
{ MODKEY, XK_8, set_workspace, {.i = 7 } },
{ MODKEY, XK_9, set_workspace, {.i = 8 } },
{ MODKEY, XK_0, set_workspace, {.i = 9 } },
-
{ MODKEY|ShiftMask, XK_1, to_workspace, {.i = 0 } },
{ MODKEY|ShiftMask, XK_2, to_workspace, {.i = 1 } },
{ MODKEY|ShiftMask, XK_3, to_workspace, {.i = 2 } },
/* adds a new client to the most appropriate monitor */
void mons_addclient(Client* c)
{
- /* for now just add it to the first monitor in the list */
- c->next = Monitors->cspace->floating;
- Monitors->cspace->floating = c;
- /* now find the best one */
- mons_place(c);
+ Monitor* mon = pickmon();
+ c->next = mon->cspace->floating;
+ mon->cspace->floating = c;
+ int cw = c->w + 2*BORDER_WIDTH;
+ int ch = c->h + 2*BORDER_WIDTH + TITLE_HEIGHT;
+ c->x = mon->midx - cw/2;
+ c->y = mon->midy - ch/2;
}
void mons_delclient(Client* c)
}
}
}
- /* if we changed monitiors, make sure we update accordingly */
+ /* if we changed monitors, make sure we update accordingly */
if (closest && loc.monitor != closest)
{
loc.workspace->floating = delclient(loc.workspace->floating, c);