X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=1e1987d6ce960beb9454c3d439f60e61d2eaa4c0;hb=de776ba84d1033716a58b79828cab79390165f0a;hp=bab17a439dcd22ec4d6c1cfb6b5a4dd02a7e9b7c;hpb=370f758d740cda81264f23d9d1a24a99e18ba0bd;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index bab17a4..1e1987d 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -52,7 +52,7 @@ static const char *cvstag = "$scrotwm$"; -#define SWM_VERSION "0.9.6" +#define SWM_VERSION "0.9.8" #include #include @@ -110,6 +110,8 @@ static const char *cvstag = "$scrotwm$"; #define SWM_D_KEY 0x0200 #define SWM_D_QUIRK 0x0400 #define SWM_D_SPAWN 0x0800 +#define SWM_D_EVENTQ 0x1000 +#define SWM_D_CONF 0x2000 u_int32_t swm_debug = 0 | SWM_D_MISC @@ -124,6 +126,8 @@ u_int32_t swm_debug = 0 | SWM_D_KEY | SWM_D_QUIRK | SWM_D_SPAWN + | SWM_D_EVENTQ + | SWM_D_CONF ; #else #define DPRINTF(x...) @@ -146,7 +150,7 @@ u_int32_t swm_debug = 0 #define SWM_MAX_FONT_STEPS (3) #ifndef SWM_LIB -#define SWM_LIB "/usr/X11R6/lib/swmhack.so" +#define SWM_LIB "/usr/local/lib/libswmhack.so" #endif char **start_argv; @@ -415,6 +419,127 @@ int quirks_size = 0, quirks_length = 0; struct quirk *quirks = NULL; /* events */ +#ifdef SWM_DEBUG +void +dumpevent(XEvent *e) +{ + char *name = NULL; + + switch (e->type) { + case KeyPress: + name = "KeyPress"; + break; + case KeyRelease: + name = "KeyRelease"; + break; + case ButtonPress: + name = "ButtonPress"; + break; + case ButtonRelease: + name = "ButtonRelease"; + break; + case MotionNotify: + name = "MotionNotify"; + break; + case EnterNotify: + name = "EnterNotify"; + break; + case LeaveNotify: + name = "LeaveNotify"; + break; + case FocusIn: + name = "FocusIn"; + break; + case FocusOut: + name = "FocusOut"; + break; + case KeymapNotify: + name = "KeymapNotify"; + break; + case Expose: + name = "Expose"; + break; + case GraphicsExpose: + name = "GraphicsExpose"; + break; + case NoExpose: + name = "NoExpose"; + break; + case VisibilityNotify: + name = "VisibilityNotify"; + break; + case CreateNotify: + name = "CreateNotify"; + break; + case DestroyNotify: + name = "DestroyNotify"; + break; + case UnmapNotify: + name = "UnmapNotify"; + break; + case MapNotify: + name = "MapNotify"; + break; + case MapRequest: + name = "MapRequest"; + break; + case ReparentNotify: + name = "ReparentNotify"; + break; + case ConfigureNotify: + name = "ConfigureNotify"; + break; + case ConfigureRequest: + name = "ConfigureRequest"; + break; + case GravityNotify: + name = "GravityNotify"; + break; + case ResizeRequest: + name = "ResizeRequest"; + break; + case CirculateNotify: + name = "CirculateNotify"; + break; + case CirculateRequest: + name = "CirculateRequest"; + break; + case PropertyNotify: + name = "PropertyNotify"; + break; + case SelectionClear: + name = "SelectionClear"; + break; + case SelectionRequest: + name = "SelectionRequest"; + break; + case SelectionNotify: + name = "SelectionNotify"; + break; + case ColormapNotify: + name = "ColormapNotify"; + break; + case ClientMessage: + name = "ClientMessage"; + break; + case MappingNotify: + name = "MappingNotify"; + break; + } + + if (name) + DNPRINTF(SWM_D_EVENTQ ,"window: %lu event: %s (%d), %d " + "remaining\n", + e->xany.window, name, e->type, QLength(display)); + else + DNPRINTF(SWM_D_EVENTQ, "window: %lu unknown event %d, %d " + "remaining\n", + e->xany.window, e->type, QLength(display)); +} +#else +#define dumpevent(e) +#endif /* SWM_DEBUG */ + void expose(XEvent *); void keypress(XEvent *); void buttonpress(XEvent *); @@ -1391,7 +1516,8 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip) DNPRINTF(SWM_D_STACK, "stack_master: workspace: %d\n rot=%s flip=%s", ws->idx, rot ? "yes" : "no", flip ? "yes" : "no"); - if ((winno = count_win(ws, 0)) == 0) + winno = count_win(ws, 0); + if (winno == 0 && count_win(ws, 1) == 0) return; if (ws->focus == NULL) @@ -1640,15 +1766,20 @@ horizontal_stack(struct workspace *ws, struct swm_geometry *g) /* fullscreen view */ void -max_stack(struct workspace *ws, struct swm_geometry *g) { +max_stack(struct workspace *ws, struct swm_geometry *g) +{ XWindowChanges wc; struct swm_geometry gg = *g; struct ws_win *win, *winfocus; unsigned int mask; + int winno; + + /* XXX this function needs to be rewritten it sucks crap */ DNPRINTF(SWM_D_STACK, "max_stack: workspace: %d\n", ws->idx); - if (count_win(ws, 0) == 0) + winno = count_win(ws, 0); + if (winno == 0 && count_win(ws, 1) == 0) return; if (ws->focus == NULL) @@ -1661,8 +1792,10 @@ max_stack(struct workspace *ws, struct swm_geometry *g) { /* XXX maximize? */ stack_floater(win, ws->r); XMapRaised(display, win->id); - } else + } else { + /* XXX this sucks */ XUnmapWindow(display, win->id); + } } else { bzero(&wc, sizeof wc); wc.border_width = 1; @@ -2252,7 +2385,7 @@ setup_spawn(void) " -nb $bar_color" " -nf $bar_font_color" " -sb $bar_border" - " -sf bar_color", 0); + " -sf $bar_color", 0); } /* key bindings */ @@ -2926,7 +3059,9 @@ conf_load(char *filename) size_t linelen, lineno = 0; int wordlen, i, optind; struct config_option *opt; - DPRINTF("conf_load begin\n"); + + DNPRINTF(SWM_D_CONF, "conf_load begin\n"); + if (filename == NULL) { fprintf(stderr, "conf_load: no filename\n"); return (1); @@ -2935,6 +3070,7 @@ conf_load(char *filename) warn("conf_load: fopen"); return (1); } + while (!feof(config)) { if ((line = fparseln(config, &linelen, &lineno, NULL, 0)) == NULL) { @@ -3004,8 +3140,10 @@ conf_load(char *filename) free(optsub); free(line); } + fclose(config); - DPRINTF("conf_load end\n"); + DNPRINTF(SWM_D_CONF, "conf_load end\n"); + return (0); } @@ -3157,10 +3295,7 @@ unmanage_window(struct ws_win *win) DNPRINTF(SWM_D_MISC, "unmanage_window: %lu\n", win->id); - /* don't unmanage if we are switching workspaces */ ws = win->ws; - if (ws->restack) - return; /* find a window to focus */ if (ws->focus == win) @@ -3304,23 +3439,22 @@ focusin(XEvent *e) void focusout(XEvent *e) { + struct swm_screen *s; + Window rr, cr; + int x, y, wx, wy; + unsigned int mask; + DNPRINTF(SWM_D_EVENT, "focusout: window: %lu\n", e->xfocus.window); if (cur_focus && cur_focus->ws->r && cur_focus->id == e->xfocus.window) { - struct swm_screen *s = cur_focus->ws->r->s; - Window rr, cr; - int x, y, wx, wy; - unsigned int mask; - - /* Try to detect synergy hiding the cursor. */ + s = cur_focus->ws->r->s; if (XQueryPointer(display, cur_focus->id, &rr, &cr, &x, &y, &wx, &wy, &mask) != False && cr == 0 && !mask && - x == DisplayWidth(display, s->idx)/2 && - y == DisplayHeight(display, s->idx)/2) { + x == DisplayWidth(display, s->idx) / 2 && + y == DisplayHeight(display, s->idx) / 2) unfocus_win(cur_focus); - } } } @@ -3392,14 +3526,7 @@ propertynotify(XEvent *e) void unmapnotify(XEvent *e) { - XDestroyWindowEvent *ev = &e->xdestroywindow; - struct ws_win *win; - DNPRINTF(SWM_D_EVENT, "unmapnotify: window: %lu\n", e->xunmap.window); - - if ((win = find_window(ev->window)) != NULL) - if (win->transient) - unmanage_window(win); } void @@ -3834,6 +3961,7 @@ main(int argc, char *argv[]) while (XPending(display)) { XNextEvent(display, &e); if (e.type < LASTEvent) { + dumpevent(&e); if (handler[e.type]) handler[e.type](&e); else