X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=wm.c;h=8c5814ffbd0c256b3507aeee70127553e3c2a155;hb=16c67f32d62849792c8e6d4fdec22a1896f9c279;hp=843aaac30fbd83ddbd89febb77b4fe37d6e5694e;hpb=3a69c5173cdd24959410870bec2a10a76272e034;p=dwm.git diff --git a/wm.c b/wm.c index 843aaac..8c5814f 100644 --- a/wm.c +++ b/wm.c @@ -16,14 +16,14 @@ /* X structs */ Display *dpy; Window root, barwin; -Atom wm_atom[WMLast], net_atom[NetLast]; +Atom net_atom[NetLast]; Cursor cursor[CurLast]; XRectangle rect, barrect; Bool running = True; +Client *clients = NULL; -char *bartext; +char *bartext, tag[256]; int screen, sel_screen; -unsigned int lock_mask, numlock_mask; /* draw structs */ Brush brush = {0}; @@ -63,47 +63,6 @@ scan_wins() XFree(wins); } -static int -win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) -{ - Atom real; - int format; - unsigned long res, extra; - int status; - - status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format, - &res, &extra, prop); - - if(status != Success || *prop == 0) { - return 0; - } - if(res == 0) { - free((void *) *prop); - } - return res; -} - -int -win_proto(Window w) -{ - Atom *protocols; - long res; - int protos = 0; - int i; - - res = win_property(w, wm_atom[WMProtocols], XA_ATOM, 20L, - ((unsigned char **) &protocols)); - if(res <= 0) { - return protos; - } - for(i = 0; i < res; i++) { - if(protocols[i] == wm_atom[WMDelete]) - protos |= WM_PROTOCOL_DELWIN; - } - free((char *) protocols); - return protos; -} - /* * There's no way to check accesses to destroyed windows, thus * those cases are ignored (especially on UnmapNotify's). @@ -144,32 +103,6 @@ startup_error_handler(Display *dpy, XErrorEvent *error) } static void -init_lock_keys() -{ - XModifierKeymap *modmap; - KeyCode numlock; - int i; - static int masks[] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask - }; - - numlock_mask = 0; - modmap = XGetModifierMapping(dpy); - numlock = XKeysymToKeycode(dpy, XStringToKeysym("Num_Lock")); - - if(modmap && modmap->max_keypermod > 0) { - int max = (sizeof(masks) / sizeof(int)) * modmap->max_keypermod; - for(i = 0; i < max; i++) - if(numlock && (modmap->modifiermap[i] == numlock)) - numlock_mask = masks[i / modmap->max_keypermod]; - } - XFreeModifiermap(modmap); - - lock_mask = 255 & ~(numlock_mask | LockMask); -} - -static void cleanup() { /* @@ -228,9 +161,6 @@ main(int argc, char *argv[]) x_error_handler = XSetErrorHandler(error_handler); /* init atoms */ - wm_atom[WMState] = XInternAtom(dpy, "WM_STATE", False); - wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); - wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); @@ -243,7 +173,7 @@ main(int argc, char *argv[]) cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); - init_lock_keys(); + update_keys(); brush.drawable = XCreatePixmap(dpy, root, rect.width, rect.height, DefaultDepth(dpy, screen)); @@ -264,12 +194,13 @@ main(int argc, char *argv[]) barrect.width, barrect.height, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); - bartext = 0; + bartext = NULL; XDefineCursor(dpy, barwin, cursor[CurNormal]); XMapRaised(dpy, barwin); draw_bar(); - wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask; + wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ + | LeaveWindowMask; wa.cursor = cursor[CurNormal]; XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);