Some preliminary changes to make managed mode more cohesive.

This commit is contained in:
Kris Maglione 2007-04-13 19:23:24 -04:00
parent 54f2e140d8
commit ca77b0cd99
7 changed files with 112 additions and 44 deletions

View File

@ -513,7 +513,7 @@ apply_sizehints(Client *c, XRectangle *r, Bool floating, Bool frame, BlitzAlign
s = &c->size; s = &c->size;
orig = *r; orig = *r;
if(frame) if(frame)
frame2client(r); frame2client(c->sel, r);
bw = 0; bw = 0;
bh = 0; bh = 0;
@ -564,7 +564,7 @@ apply_sizehints(Client *c, XRectangle *r, Bool floating, Bool frame, BlitzAlign
} }
if(frame) if(frame)
client2frame(r); client2frame(c->sel, r);
if(!(s->flags & PMinSize) || !floating) { if(!(s->flags & PMinSize) || !floating) {
if(r->width > orig.width) if(r->width > orig.width)

View File

@ -80,10 +80,15 @@ buttonpress(XEvent *e) {
if(frame_to_top(f)) if(frame_to_top(f))
restack_view(f->view); restack_view(f->view);
if(ptinrect(ev->x, ev->y, &f->grabbox)) if(ingrabbox(f, ev->x, ev->y))
do_mouse_resize(f->client, False,
quadrant(&f->rect, ev->x_root, ev->y_root) & (EAST|WEST));
else if(ptinrect(ev->x, ev->y, &f->grabbox))
do_mouse_resize(f->client, True, CENTER); do_mouse_resize(f->client, True, CENTER);
else if(!ev->subwindow && !ptinrect(ev->x, ev->y, &f->titlebar)) else if(f->area->floating)
do_mouse_resize(f->client, False, quadrant(&f->rect, ev->x_root, ev->y_root)); if(!ev->subwindow && !ptinrect(ev->x, ev->y, &f->titlebar))
do_mouse_resize(f->client, False,
quadrant(&f->rect, ev->x_root, ev->y_root));
if(f->client != selclient()) if(f->client != selclient())
focus(f->client, True); focus(f->client, True);

View File

@ -91,8 +91,9 @@ Bool frame_to_top(Frame *f);
void set_frame_cursor(Frame *f, int x, int y); void set_frame_cursor(Frame *f, int x, int y);
void swap_frames(Frame *fa, Frame *fb); void swap_frames(Frame *fa, Frame *fb);
int frame_delta_h(); int frame_delta_h();
void frame2client(XRectangle *r); void frame2client(Frame *f, XRectangle *r);
void client2frame(XRectangle *r); void client2frame(Frame *f, XRectangle *r);
int ingrabbox(Frame *f, int x, int y);
void draw_frame(Frame *f); void draw_frame(Frame *f);
void draw_frames(); void draw_frames();
void update_frame_widget_colors(Frame *f); void update_frame_widget_colors(Frame *f);

View File

@ -1,6 +1,8 @@
/* Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com> /* Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com>
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include <math.h>
#include <stdio.h>
#include <util.h> #include <util.h>
#include "dat.h" #include "dat.h"
#include "fns.h" #include "fns.h"
@ -72,15 +74,25 @@ insert_frame(Frame *pos, Frame *f, Bool before) {
} }
void void
frame2client(XRectangle *r) { frame2client(Frame *f, XRectangle *r) {
if(f->area->floating) {
r->width = max(r->width - def.border * 2, 1); r->width = max(r->width - def.border * 2, 1);
r->height = max(r->height - frame_delta_h(), 1); r->height = max(r->height - frame_delta_h(), 1);
}else {
r->width = max(r->width - 2, 1);
r->height = max(r->height - labelh(&def.font) - 1, 1);
}
} }
void void
client2frame(XRectangle *r) { client2frame(Frame *f, XRectangle *r) {
if(f->area->floating) {
r->width += def.border * 2; r->width += def.border * 2;
r->height += frame_delta_h(); r->height += frame_delta_h();
}else {
r->width += 2;
r->height +=labelh(&def.font) + 1;
}
} }
void void
@ -98,7 +110,7 @@ resize_frame(Frame *f, XRectangle *r) {
if(f->area->floating) if(f->area->floating)
f->rect = f->crect; f->rect = f->crect;
frame2client(&f->crect); frame2client(f, &f->crect);
if(f->crect.height < labelh(&def.font)) if(f->crect.height < labelh(&def.font))
f->collapsed = True; f->collapsed = True;
@ -126,7 +138,7 @@ resize_frame(Frame *f, XRectangle *r) {
f->rect = f->crect; f->rect = f->crect;
f->rect.x = -def.border; f->rect.x = -def.border;
f->rect.y = -labelh(&def.font); f->rect.y = -labelh(&def.font);
client2frame(&f->rect); client2frame(f, &f->rect);
}else }else
check_frame_constraints(&f->rect); check_frame_constraints(&f->rect);
} }
@ -137,8 +149,10 @@ set_frame_cursor(Frame *f, int x, int y) {
XRectangle r; XRectangle r;
Cursor cur; Cursor cur;
if(!ptinrect(x, y, &f->titlebar) if(f->area->floating
&&!ptinrect(x, y, &f->crect)) { && !ptinrect(x, y, &f->titlebar)
&& !ptinrect(x, y, &f->crect)
&& !ingrabbox(f, x, y)) {
r = f->rect; r = f->rect;
r.x = 0; r.x = 0;
r.y = 0; r.y = 0;
@ -248,10 +262,35 @@ frame_delta_h() {
return def.border + labelh(&def.font); return def.border + labelh(&def.font);
} }
int
ingrabbox(Frame *f, int x, int y) {
int dx, h;
if(f->area->floating)
return 0;
h = labelh(&def.font) / 3;
h = max(h, 4);
if((f == f->area->frame) && f->area->next)
if(x >= f->rect.width - h) {
dx = x - (f->rect.width - h);
if(y <= dx)
return 1;
}
if((f == f->area->frame) && (f->area != f->view->area->next))
if(x <= h && y <= h - x)
return 1;
return 0;
}
void void
draw_frame(Frame *f) { draw_frame(Frame *f) {
BlitzBrush br = { 0 }; BlitzBrush br = { 0 };
XPoint pt[3];
Frame *tf; Frame *tf;
int h;
if(f->view != screen->sel) if(f->view != screen->sel)
return; return;
@ -302,6 +341,30 @@ draw_frame(Frame *f) {
f->grabbox = br.rect; f->grabbox = br.rect;
draw_tile(&br); draw_tile(&br);
if(!f->area->floating) {
XSetLineAttributes(blz.dpy, br.gc, 1, LineSolid, CapButt, JoinMiter);
h = labelh(&def.font) / 3;
h = max(h, 4);
if((f == f->area->frame) && f->area->next) {
pt[0] = (XPoint){ f->rect.width - h, 0 };
pt[1] = (XPoint){ f->rect.width, h };
pt[2] = (XPoint){ f->rect.width, 0 };
XSetForeground(blz.dpy, br.gc, def.normcolor.bg);
XFillPolygon(blz.dpy, br.drawable, br.gc, pt, 3, Convex, CoordModeOrigin);
XSetForeground(blz.dpy, br.gc, br.color.border);
XDrawLines(blz.dpy, br.drawable, br.gc, pt, 2, CoordModeOrigin);
}
if((f == f->area->frame) && (f->area != f->view->area->next)) {
pt[0] = (XPoint){ h, 0 };
pt[1] = (XPoint){ 0, h };
pt[2] = (XPoint){ 0, 0 };
XSetForeground(blz.dpy, br.gc, def.normcolor.bg);
XFillPolygon(blz.dpy, br.drawable, br.gc, pt, 3, Convex, CoordModeOrigin);
XSetForeground(blz.dpy, br.gc, br.color.border);
XDrawLines(blz.dpy, br.drawable, br.gc, pt, 2, CoordModeOrigin);
}
}
XCopyArea( XCopyArea(
/* display */ blz.dpy, /* display */ blz.dpy,
/* src */ pmap, /* src */ pmap,

View File

@ -13,7 +13,6 @@
/* Datatypes: */ /* Datatypes: */
/**************/
typedef struct Dirtab Dirtab; typedef struct Dirtab Dirtab;
struct Dirtab { struct Dirtab {
char *name; char *name;
@ -48,7 +47,6 @@ struct FileId {
}; };
/* Constants */ /* Constants */
/*************/
enum { /* Dirs */ enum { /* Dirs */
FsRoot, FsDClient, FsDClients, FsDBars, FsRoot, FsDClient, FsDClients, FsDBars,
FsDTag, FsDTags, FsDTag, FsDTags,

View File

@ -27,7 +27,7 @@ static char *address, *ns_path;
static Bool check_other_wm; static Bool check_other_wm;
static struct sigaction sa; static struct sigaction sa;
static struct passwd *passwd; static struct passwd *passwd;
static int sleeperfd, sock; static int sleeperfd, sock, exitsignal;
static void static void
usage() { usage() {
@ -54,8 +54,8 @@ scan_wins() {
for(i = 0; i < num; i++) { for(i = 0; i < num; i++) {
if(!XGetWindowAttributes(blz.dpy, wins[i], &wa)) if(!XGetWindowAttributes(blz.dpy, wins[i], &wa))
continue; continue;
if(XGetTransientForHint(blz.dpy, wins[i], &d1) if((XGetTransientForHint(blz.dpy, wins[i], &d1))
&& wa.map_state == IsViewable) && (wa.map_state == IsViewable))
manage_client(create_client(wins[i], &wa)); manage_client(create_client(wins[i], &wa));
} }
} }
@ -167,11 +167,9 @@ init_ns() {
if(stat(ns_path, &st)) if(stat(ns_path, &st))
fatal("Can't stat ns_path '%s':", ns_path); fatal("Can't stat ns_path '%s':", ns_path);
if(getuid() != st.st_uid) if(getuid() != st.st_uid)
fatal("ns_path '%s' exists but is not owned by you", fatal("ns_path '%s' exists but is not owned by you", ns_path);
ns_path);
if(st.st_mode & 077) if(st.st_mode & 077)
fatal("ns_path '%s' exists, but has group or world permissions", fatal("ns_path '%s' exists, but has group or world permissions", ns_path);
ns_path);
} }
static void static void
@ -317,14 +315,13 @@ cleanup_handler(int signal) {
sa.sa_handler = SIG_DFL; sa.sa_handler = SIG_DFL;
sigaction(signal, &sa, nil); sigaction(signal, &sa, nil);
switch(signal) {
case SIGINT:
srv.running = False; srv.running = False;
break;
switch(signal) {
default: default:
cleanup(); exitsignal = signal;
XCloseDisplay(blz.dpy); break;
raise(signal); case SIGINT:
break; break;
} }
} }
@ -429,11 +426,8 @@ main(int argc, char *argv[]) {
XSetWindowAttributes wa; XSetWindowAttributes wa;
int i; int i;
passwd = getpwuid(getuid());
user = estrdup(passwd->pw_name);
wmiirc = "wmiistartrc"; wmiirc = "wmiistartrc";
/* command line args */
ARGBEGIN{ ARGBEGIN{
case 'v': case 'v':
printf("%s", version); printf("%s", version);
@ -452,6 +446,9 @@ main(int argc, char *argv[]) {
break; break;
}ARGEND; }ARGEND;
if(argc)
usage();
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
starting = True; starting = True;
@ -467,8 +464,10 @@ main(int argc, char *argv[]) {
XSync(blz.dpy, False); XSync(blz.dpy, False);
check_other_wm = False; check_other_wm = False;
passwd = getpwuid(getuid());
user = estrdup(passwd->pw_name);
init_environment(); init_environment();
init_traps();
errstr = nil; errstr = nil;
sock = ixp_announce(address); sock = ixp_announce(address);
@ -497,6 +496,7 @@ main(int argc, char *argv[]) {
loadcolor(&blz, &def.focuscolor); loadcolor(&blz, &def.focuscolor);
loadcolor(&blz, &def.normcolor); loadcolor(&blz, &def.normcolor);
init_traps();
init_atoms(); init_atoms();
init_cursors(); init_cursors();
loadfont(&blz, &def.font); loadfont(&blz, &def.font);
@ -580,9 +580,10 @@ main(int argc, char *argv[]) {
ixp_server_close(&srv); ixp_server_close(&srv);
close(sleeperfd); close(sleeperfd);
if(exitsignal)
raise(exitsignal);
if(execstr) if(execstr)
execl("/bin/sh", "sh", "-c", execstr, nil); execl("/bin/sh", "sh", "-c", execstr, nil);
if(errstr) if(errstr)
return 1; return 1;
return 0; return 0;

View File

@ -10,11 +10,11 @@ echo CC ${BASE}$outfile
$CC -o $outfile $CFLAGS $@ 2>$xtmp $CC -o $outfile $CFLAGS $@ 2>$xtmp
status=$? status=$?
cat $xtmp \ cat $xtmp |
| egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|use of C99 long long|ISO C forbids conversion' \ egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|use of C99 long long|ISO C forbids conversion' |
| sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' \ sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
| uniq 1>&2 uniq 1>&2
rm -f $xtmp $xtmp.status rm -f $xtmp
exit $status exit $status