X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=wm.c;h=8c5814ffbd0c256b3507aeee70127553e3c2a155;hb=16c67f32d62849792c8e6d4fdec22a1896f9c279;hp=b8b30534ce3371591a7406809e4114439ca450b7;hpb=439e15d09f6fa9271d3b49ef97194f0c80ebe161;p=dwm.git diff --git a/wm.c b/wm.c index b8b3053..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, *shell; +char *bartext, tag[256]; int screen, sel_screen; -unsigned int lock_mask, numlock_mask; /* draw structs */ Brush brush = {0}; @@ -56,54 +56,13 @@ scan_wins() if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) continue; if(wa.map_state == IsViewable) - /*manage*/; + manage(create_client(wins[i], &wa)); } } if(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() { /* @@ -219,9 +152,6 @@ main(int argc, char *argv[]) if(other_wm_running) error("gridwm: another window manager is already running\n"); - if(!(shell = getenv("SHELL"))) - shell = "/bin/sh"; - rect.x = rect.y = 0; rect.width = DisplayWidth(dpy, screen); rect.height = DisplayHeight(dpy, screen); @@ -231,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); @@ -246,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)); @@ -267,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);