X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=4ef1088eb5a8ce530bbf48d65079c64f6fb94360;hb=769cba6f7f9837b2f47b89aec44757fab8b9aeae;hp=2dd1d008eeaa102d24df7a8929af54341e6faafc;hpb=1b78470ebd12245145473b5c424f0607db9276fa;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 2dd1d00..4ef1088 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -52,7 +52,7 @@ static const char *cvstag = "$scrotwm$"; -#define SWM_VERSION "0.9.14" +#define SWM_VERSION "0.9.15" #include #include @@ -94,6 +94,7 @@ static const char *cvstag = "$scrotwm$"; #endif #endif +#define SWM_DEBUG /* #define SWM_DEBUG */ #ifdef SWM_DEBUG #define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0) @@ -337,7 +338,7 @@ struct layout { { horizontal_stack, horizontal_config, 0, "[-]" }, { max_stack, NULL, SWM_L_FOCUSPREV | SWM_L_MAPONFOCUS, "[ ]"}, - { NULL, NULL, 0}, + { NULL, NULL, 0, NULL }, }; #define SWM_H_SLICE (32) @@ -369,9 +370,9 @@ enum { SWM_S_COLOR_BAR, SWM_S_COLOR_BAR_BORDER, SWM_S_COLOR_BAR_FONT, SWM_S_COLOR_FOCUS, SWM_S_COLOR_UNFOCUS, SWM_S_COLOR_MAX }; /* physical screen mapping */ -#define SWM_WS_MAX (10) /* XXX Too small? */ +#define SWM_WS_MAX (10) struct swm_screen { - int idx; /* screen index */ + int idx; /* screen index */ struct swm_region_list rl; /* list of regions on this screen */ struct swm_region_list orl; /* list of old regions */ Window root; @@ -1707,7 +1708,6 @@ stack_floater(struct ws_win *win, struct swm_region *r) wc.y = (HEIGHT(r) - win->g.h) / 2; } - /* XXX need to fix manual moving into a new region */ /* adjust for region */ if (wc.x < r->g.x) wc.x += r->g.x; @@ -2198,6 +2198,7 @@ resize(struct ws_win *win, union arg *args) { XEvent ev; Time time = 0; + struct swm_region *r = win->ws->r; DNPRINTF(SWM_D_MOUSE, "resize: win %lu floating %d trans %d\n", win->id, win->floating, win->transient); @@ -2219,6 +2220,14 @@ resize(struct ws_win *win, union arg *args) handler[ev.type](&ev); break; case MotionNotify: + /* do not allow resize outside of region */ + if (ev.xmotion.y_root < r->g.y || + ev.xmotion.y_root >= r->g.y + r->g.h - 1) + continue; + if (ev.xmotion.x_root < r->g.x || + ev.xmotion.x_root >= r->g.x + r->g.w - 1) + continue; + if (ev.xmotion.x <= 1) ev.xmotion.x = 1; if (ev.xmotion.y <= 1) @@ -2273,6 +2282,7 @@ move(struct ws_win *win, union arg *args) XEvent ev; Time time = 0; int restack = 0; + struct swm_region *r = win->ws->r; DNPRINTF(SWM_D_MOUSE, "move: win %lu floating %d trans %d\n", win->id, win->floating, win->transient); @@ -2297,6 +2307,14 @@ move(struct ws_win *win, union arg *args) handler[ev.type](&ev); break; case MotionNotify: + /* don't allow to move window out of region */ + if (ev.xmotion.y_root < r->g.y || + ev.xmotion.y_root + win->g.h >= r->g.y + r->g.h - 1) + continue; + if (ev.xmotion.x_root < r->g.x || + ev.xmotion.x_root + win->g.w >= r->g.x + r->g.w - 1) + continue; + win->g.x = ev.xmotion.x_root; win->g.y = ev.xmotion.y_root; @@ -2320,8 +2338,6 @@ move(struct ws_win *win, union arg *args) /* drain events */ while (XCheckMaskEvent(display, EnterWindowMask, &ev)); - - /* XXX need to fix manual moving into a new region */ } /* key definitions */ @@ -3748,14 +3764,14 @@ destroynotify(XEvent *e) struct workspace *ws; struct ws_win_list *wl; XDestroyWindowEvent *ev = &e->xdestroywindow; - int unmanaged = 0; DNPRINTF(SWM_D_EVENT, "destroynotify: window %lu\n", ev->window); if ((win = find_window(ev->window)) == NULL) { if ((win = find_unmanaged_window(ev->window)) == NULL) return; - unmanaged = 1; + free_window(win); + return; } /* find a window to focus */ @@ -3797,8 +3813,7 @@ destroynotify(XEvent *e) } } } - if (unmanaged == 0) - unmanage_window(win); + unmanage_window(win); free_window(win); ignore_enter = 1; @@ -4344,6 +4359,7 @@ main(int argc, char *argv[]) int xfd, i; fd_set rd; +swm_debug = 0; start_argv = argv; fprintf(stderr, "Welcome to scrotwm V%s cvs tag: %s\n", SWM_VERSION, cvstag);