mirror of https://github.com/0intro/wmii
A bunch of minor changes.
This commit is contained in:
parent
156ef505f2
commit
81d63271d1
|
@ -8,7 +8,7 @@ static void (*handler[LASTEvent])(XEvent*);
|
|||
|
||||
void
|
||||
dispatch_event(XEvent *e) {
|
||||
/* printevent(e); */
|
||||
/* print("%E\n", e); */
|
||||
if(e->type < nelem(handler) && handler[e->type])
|
||||
handler[e->type](e);
|
||||
}
|
||||
|
|
|
@ -110,6 +110,8 @@ main(int argc, char *argv[]) {
|
|||
char *s;
|
||||
|
||||
fmtinstall('r', errfmt);
|
||||
extern int fmtevent(Fmt*);
|
||||
fmtinstall('E', fmtevent);
|
||||
|
||||
ARGBEGIN{
|
||||
default:
|
||||
|
|
|
@ -45,24 +45,24 @@ restrut(void) {
|
|||
* Not ideal.
|
||||
*/
|
||||
if(Dy(strut[Top])) {
|
||||
if(strut[Top].min.x <= scr.rect.min.x)
|
||||
if(Dx(strut[Left]))
|
||||
if(Dy(strut[Top]) < Dx(strut[Left]))
|
||||
strut[Left] = ZR;
|
||||
else
|
||||
strut[Top] = ZR;
|
||||
if(strut[Top].max.x >= scr.rect.max.x)
|
||||
if(Dx(strut[Right]))
|
||||
if(Dy(strut[Top]) < Dx(strut[Right]))
|
||||
strut[Right] = ZR;
|
||||
else
|
||||
strut[Top] = ZR;
|
||||
}
|
||||
if(Dy(strut[Bottom])) {
|
||||
if(strut[Bottom].min.x <= scr.rect.min.x)
|
||||
if(Dx(strut[Left]))
|
||||
if(Dy(strut[Bottom]) < Dx(strut[Left]))
|
||||
strut[Left] = ZR;
|
||||
else
|
||||
strut[Bottom] = ZR;
|
||||
if(strut[Bottom].max.x >= scr.rect.max.x)
|
||||
if(Dx(strut[Right]))
|
||||
if(Dy(strut[Bottom]) < Dx(strut[Right]))
|
||||
strut[Right] = ZR;
|
||||
else
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <bio.h>
|
||||
|
@ -73,7 +74,6 @@ spawn3(int fd[3], const char *file, char *argv[]) {
|
|||
/* Some ideas from Russ Cox's libthread port. */
|
||||
int p[2];
|
||||
int pid;
|
||||
int _errno;
|
||||
|
||||
if(pipe(p) < 0)
|
||||
return -1;
|
||||
|
@ -86,15 +86,13 @@ spawn3(int fd[3], const char *file, char *argv[]) {
|
|||
dup2(fd[2], 2);
|
||||
|
||||
execvp(file, argv);
|
||||
write(p[1], &errno, sizeof _errno);
|
||||
write(p[1], &errno, sizeof errno);
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
close(p[1]);
|
||||
if(read(p[0], &_errno, sizeof _errno) == sizeof _errno) {
|
||||
if(read(p[0], &errno, sizeof errno) == sizeof errno)
|
||||
pid = -1;
|
||||
errno = _errno;
|
||||
}
|
||||
close(p[0]);
|
||||
break;
|
||||
case -1: /* can't happen */
|
||||
|
@ -129,43 +127,26 @@ spawn3l(int fd[3], const char *file, ...) {
|
|||
return spawn3(fd, file, argv);
|
||||
}
|
||||
|
||||
/* Only works on *BSD (only FreeBSD confirmed). GDB on my Linux
|
||||
* doesn't like -x <pipe>, and /proc/%d/exe is the correct /proc
|
||||
* path.
|
||||
*/
|
||||
#ifdef __linux__
|
||||
# define PROGTXT "exe"
|
||||
#else
|
||||
# define PROGTXT "file"
|
||||
#endif
|
||||
void
|
||||
backtrace(char *btarg) {
|
||||
|
||||
static void
|
||||
_backtrace(int pid, char *btarg) {
|
||||
char *proc, *spid, *gdbcmd;
|
||||
int fd[3], p[2];
|
||||
int pid, status, cmdfd;
|
||||
|
||||
proc = sxprint("/proc/%d/" PROGTXT, getpid());
|
||||
spid = sxprint("%d", getpid());
|
||||
|
||||
switch(pid = fork()) {
|
||||
case -1:
|
||||
return;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
int status, cmdfd;
|
||||
|
||||
if(pipe(p) < 0)
|
||||
exit(0);
|
||||
goto done;
|
||||
closeexec(p[0]);
|
||||
|
||||
gdbcmd = estrdup("/tmp/gdbcmd.XXXXXX");
|
||||
cmdfd = mkstemp(gdbcmd);
|
||||
if(cmdfd < 0)
|
||||
exit(1);
|
||||
goto done;
|
||||
|
||||
fprint(cmdfd, "bt %s\n", btarg);
|
||||
fprint(cmdfd, "detach\n");
|
||||
|
@ -174,9 +155,12 @@ backtrace(char *btarg) {
|
|||
fd[0] = open("/dev/null", O_RDONLY);
|
||||
fd[1] = p[1];
|
||||
fd[2] = dup(2);
|
||||
|
||||
proc = sxprint("/proc/%d/" PROGTXT, pid);
|
||||
spid = sxprint("%d", pid);
|
||||
if(spawn3l(fd, "gdb", "gdb", "-batch", "-x", gdbcmd, proc, spid, nil) < 0) {
|
||||
unlink(gdbcmd);
|
||||
exit(1);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Why? Because gdb freezes waiting for user input
|
||||
|
@ -185,16 +169,36 @@ backtrace(char *btarg) {
|
|||
*/
|
||||
Biobuf bp;
|
||||
char *s;
|
||||
int i = 0;
|
||||
|
||||
Binit(&bp, p[0], OREAD);
|
||||
while((s = Brdstr(&bp, '\n', 1))) {
|
||||
if(i++ >= 4)
|
||||
fprint(2, "%s\n", s);
|
||||
Dprint(DStack, "%s\n", s);
|
||||
free(s);
|
||||
}
|
||||
unlink(gdbcmd);
|
||||
exit(0);
|
||||
|
||||
done:
|
||||
kill(pid, SIGKILL);
|
||||
waitpid(pid, &status, 0);
|
||||
}
|
||||
|
||||
void
|
||||
backtrace(char *btarg) {
|
||||
int pid;
|
||||
|
||||
/* Fork so we can backtrace the child. Keep this stack
|
||||
* frame minimal, so the trace is fairly clean.
|
||||
*/
|
||||
switch(pid = fork()) {
|
||||
case -1:
|
||||
return;
|
||||
case 0:
|
||||
kill(getpid(), SIGSTOP);
|
||||
_exit(0);
|
||||
default:
|
||||
_backtrace(pid, btarg);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -172,6 +172,9 @@ area_moveto(Area *to, Frame *f) {
|
|||
|
||||
assert(to->view == f->view);
|
||||
|
||||
if(f->client->fullscreen && !to->floating)
|
||||
return;
|
||||
|
||||
from = f->area;
|
||||
fromfloating = from->floating;
|
||||
|
||||
|
@ -228,6 +231,10 @@ area_detach(Frame *f) {
|
|||
float_detach(f);
|
||||
else
|
||||
column_detach(f);
|
||||
|
||||
if(v->sel->sel == nil && v->area->sel)
|
||||
v->sel = v->area;
|
||||
|
||||
view_arrange(v);
|
||||
}
|
||||
|
||||
|
|
|
@ -221,8 +221,10 @@ client_manage(Client *c) {
|
|||
f = c->sel;
|
||||
if(!(c->w.ewmh.type & TypeSplash))
|
||||
if(newgroup) {
|
||||
/* XXX: Look over this.
|
||||
if(f->area != f->view->sel)
|
||||
f->view->oldsel = f->view->sel;
|
||||
*/
|
||||
}else {
|
||||
frame_restack(c->sel, c->sel->area->sel);
|
||||
view_restack(c->sel->view);
|
||||
|
|
|
@ -102,7 +102,8 @@ enum DebugOpt {
|
|||
DEwmh = 1<<2,
|
||||
DFocus = 1<<3,
|
||||
DGeneric= 1<<4,
|
||||
NDebugOpt = 5,
|
||||
DStack = 1<<5,
|
||||
NDebugOpt = 6,
|
||||
};
|
||||
|
||||
/* Data Structures */
|
||||
|
|
|
@ -35,13 +35,13 @@ float_detach(Frame *f) {
|
|||
|
||||
frame_remove(f);
|
||||
|
||||
f->area = nil;
|
||||
if(a->sel == f) {
|
||||
if(!pr)
|
||||
pr = a->frame;
|
||||
a->sel = nil;
|
||||
area_setsel(a, pr);
|
||||
}
|
||||
f->area = nil;
|
||||
|
||||
if(v->oldsel)
|
||||
area_focus(v->oldsel);
|
||||
|
|
|
@ -90,6 +90,7 @@ char* debugtab[] = {
|
|||
"ewmh",
|
||||
"focus",
|
||||
"generic",
|
||||
"stack",
|
||||
};
|
||||
|
||||
static char* barpostab[] = {
|
||||
|
@ -431,6 +432,11 @@ message_root(void *p, IxpMsg *m) {
|
|||
if(s == nil)
|
||||
return nil;
|
||||
|
||||
if(!strcmp(s, "backtrace")) {
|
||||
backtrace(m->pos);
|
||||
return nil;
|
||||
}
|
||||
|
||||
switch(getsym(s)) {
|
||||
case LBAR: /* bar on? <"top" | "bottom"> */
|
||||
s = msg_getword(m);
|
||||
|
|
|
@ -253,7 +253,7 @@ view_update(View *v) {
|
|||
for(c=client; c; c=c->next) {
|
||||
f = c->sel;
|
||||
if(f && f->view == v
|
||||
&& !(f->area->max && f->area->floating && f->area != v->sel))
|
||||
&& !(f->area && f->area->max && f->area->floating && f->area != v->sel))
|
||||
client_resize(c, f->r);
|
||||
else {
|
||||
unmap_frame(c);
|
||||
|
@ -312,8 +312,10 @@ view_attach(View *v, Frame *f) {
|
|||
}
|
||||
else if((ff = client_groupframe(c, v)))
|
||||
a = ff->area;
|
||||
else if(starting && v->sel->floating)
|
||||
a = v->area->next;
|
||||
else if(v->sel->floating) {
|
||||
if(starting || c->sel && c->sel->area && !c->sel->area->floating)
|
||||
a = v->area->next;
|
||||
}
|
||||
|
||||
area_attach(a, f);
|
||||
/* TODO: Decide whether to focus this frame */
|
||||
|
@ -322,9 +324,13 @@ view_attach(View *v, Frame *f) {
|
|||
|| view_selclient(v) && (view_selclient(v)->group == c->group)
|
||||
|| group_leader(c->group) && !client_viewframe(group_leader(c->group),
|
||||
c->sel->view);
|
||||
if(!(c->w.ewmh.type & (TypeSplash|TypeDock)))
|
||||
if(newgroup)
|
||||
frame_focus(f);
|
||||
if(!(c->w.ewmh.type & (TypeSplash|TypeDock))) {
|
||||
if(newgroup)
|
||||
frame_focus(f);
|
||||
else if(c->group && f->area->sel->client->group == c->group)
|
||||
/* XXX: Stack. */
|
||||
area_setsel(f->area, f);
|
||||
}
|
||||
|
||||
if(c->sel == nil)
|
||||
c->sel = f;
|
||||
|
|
|
@ -487,7 +487,7 @@ drawstring(Image *dst, Font *font,
|
|||
y = r.min.y + Dy(r) / 2 - h / 2 + font->ascent;
|
||||
|
||||
/* shorten text if necessary */
|
||||
SET(w);
|
||||
w = 0;
|
||||
while(len > 0) {
|
||||
w = textwidth_l(font, buf, len + min(shortened, 3));
|
||||
if(w <= Dx(r) - (font->height & ~1))
|
||||
|
|
Loading…
Reference in New Issue