[hackers] [wmii] A bunch of minor changes. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Mon, 8 Sep 2008 03:09:30 +0000 (UTC)

changeset: 2346:af3bdd290932
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sun Sep 07 23:09:25 2008 -0400
files: cmd/strut/event.c cmd/strut/main.c cmd/strut/win.c cmd/wmii/_util.c cmd/wmii/area.c cmd/wmii/client.c cmd/wmii/dat.h cmd/wmii/float.c cmd/wmii/message.c cmd/wmii/view.c cmd/wmii/x11.c
description:
A bunch of minor changes.

diff -r be1de843845f -r af3bdd290932 cmd/strut/event.c
--- a/cmd/strut/event.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/strut/event.c Sun Sep 07 23:09:25 2008 -0400
@@ -8,7 +8,7 @@
 
 void
 dispatch_event(XEvent *e) {
- /* printevent(e); */
+ /* print("%E\n", e); */
         if(e->type < nelem(handler) && handler[e->type])
                 handler[e->type](e);
 }
diff -r be1de843845f -r af3bdd290932 cmd/strut/main.c
--- a/cmd/strut/main.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/strut/main.c Sun Sep 07 23:09:25 2008 -0400
@@ -110,6 +110,8 @@
         char *s;
 
         fmtinstall('r', errfmt);
+extern int fmtevent(Fmt*);
+ fmtinstall('E', fmtevent);
 
         ARGBEGIN{
         default:
diff -r be1de843845f -r af3bdd290932 cmd/strut/win.c
--- a/cmd/strut/win.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/strut/win.c Sun Sep 07 23:09:25 2008 -0400
@@ -45,24 +45,24 @@
          * 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
diff -r be1de843845f -r af3bdd290932 cmd/wmii/_util.c
--- a/cmd/wmii/_util.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/_util.c Sun Sep 07 23:09:25 2008 -0400
@@ -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 @@
         /* 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 @@
                 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 @@
         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 @@
         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 @@
          */
         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;
+ }
 
 }
 
diff -r be1de843845f -r af3bdd290932 cmd/wmii/area.c
--- a/cmd/wmii/area.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/area.c Sun Sep 07 23:09:25 2008 -0400
@@ -172,6 +172,9 @@
 
         assert(to->view == f->view);
 
+ if(f->client->fullscreen && !to->floating)
+ return;
+
         from = f->area;
         fromfloating = from->floating;
 
@@ -228,6 +231,10 @@
                 float_detach(f);
         else
                 column_detach(f);
+
+ if(v->sel->sel == nil && v->area->sel)
+ v->sel = v->area;
+
         view_arrange(v);
 }
 
diff -r be1de843845f -r af3bdd290932 cmd/wmii/client.c
--- a/cmd/wmii/client.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/client.c Sun Sep 07 23:09:25 2008 -0400
@@ -221,8 +221,10 @@
         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);
diff -r be1de843845f -r af3bdd290932 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/dat.h Sun Sep 07 23:09:25 2008 -0400
@@ -102,7 +102,8 @@
         DEwmh = 1<<2,
         DFocus = 1<<3,
         DGeneric= 1<<4,
- NDebugOpt = 5,
+ DStack = 1<<5,
+ NDebugOpt = 6,
 };
 
 /* Data Structures */
diff -r be1de843845f -r af3bdd290932 cmd/wmii/float.c
--- a/cmd/wmii/float.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/float.c Sun Sep 07 23:09:25 2008 -0400
@@ -35,13 +35,13 @@
 
         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);
diff -r be1de843845f -r af3bdd290932 cmd/wmii/message.c
--- a/cmd/wmii/message.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/message.c Sun Sep 07 23:09:25 2008 -0400
@@ -90,6 +90,7 @@
         "ewmh",
         "focus",
         "generic",
+ "stack",
 };
 
 static char* barpostab[] = {
@@ -430,6 +431,11 @@
         s = msg_getword(m);
         if(s == nil)
                 return nil;
+
+ if(!strcmp(s, "backtrace")) {
+ backtrace(m->pos);
+ return nil;
+ }
 
         switch(getsym(s)) {
         case LBAR: /* bar on? <"top" | "bottom"> */
diff -r be1de843845f -r af3bdd290932 cmd/wmii/view.c
--- a/cmd/wmii/view.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/view.c Sun Sep 07 23:09:25 2008 -0400
@@ -253,7 +253,7 @@
         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 @@
         }
         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_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;
diff -r be1de843845f -r af3bdd290932 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Mon Aug 25 16:10:19 2008 -0400
+++ b/cmd/wmii/x11.c Sun Sep 07 23:09:25 2008 -0400
@@ -487,7 +487,7 @@
         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))
Received on Mon Sep 08 2008 - 03:09:30 UTC

This archive was generated by hypermail 2.2.0 : Mon Sep 08 2008 - 03:12:04 UTC