[hackers] [wmii] Fix for 64 bit architectures. Some cleanup.

From: Kris Maglione <jg_AT_suckless.org>
Date: Tue Jun 26 01:51:29 2007

changeset: 2164:d6404716b170
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Mon Jun 25 19:51:10 2007 -0400
summary: Fix for 64 bit architectures. Some cleanup.

diff -r 08c51f7f92c9 -r d6404716b170 cmd/wmii/client.c
--- a/cmd/wmii/client.c Mon Jun 18 18:43:11 2007 -0400
+++ b/cmd/wmii/client.c Mon Jun 25 19:51:10 2007 -0400
@@ -268,7 +268,7 @@ frame_hints(Frame *f, Rectangle r, Align
 
 static void
 set_client_state(Client * c, int state) {
- long data[] = { state, None };
+ Atom data[] = { state, None };
         changeprop(&c->w, "WM_STATE", "WM_STATE", data, nelem(data));
 }
 
diff -r 08c51f7f92c9 -r d6404716b170 cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Mon Jun 18 18:43:11 2007 -0400
+++ b/cmd/wmii/frame.c Mon Jun 25 19:51:10 2007 -0400
@@ -144,7 +144,8 @@ bdown_event(Window *w, XButtonEvent *e)
                         XAllowEvents(display, ReplayPointer, e->time);
                         break;
                 }
- XUngrabPointer(display, e->time);
+ if(e->button != Button1)
+ XUngrabPointer(display, e->time);
         }else{
                 if(e->button == Button1) {
                         if(frame_to_top(f))
diff -r 08c51f7f92c9 -r d6404716b170 cmd/wmii/main.c
--- a/cmd/wmii/main.c Mon Jun 18 18:43:11 2007 -0400
+++ b/cmd/wmii/main.c Mon Jun 25 19:51:10 2007 -0400
@@ -239,7 +239,7 @@ struct {
 
 /*
  * There's no way to check accesses to destroyed windows, thus
- * those cases are ignored (especially on UnmapNotifys).
+ * those cases are ignored (especially on UnmapNotifies).
  * Other types of errors call Xlib's default error handler, which
  * calls exit().
  */
diff -r 08c51f7f92c9 -r d6404716b170 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Mon Jun 18 18:43:11 2007 -0400
+++ b/cmd/wmii/x11.c Mon Jun 25 19:51:10 2007 -0400
@@ -464,26 +464,26 @@ Font *
 Font *
 loadfont(char *name) {
         Font *f;
- char **missing = nil, *def = "?";
+ XFontStruct **xfonts;
+ char **missing, **font_names;
         int n, i;
 
+ missing = nil;
         f = emallocz(sizeof *f);
         f->name = estrdup(name);
-
- f->set = XCreateFontSet(display, name, &missing, &n, &def);
+ f->set = XCreateFontSet(display, name, &missing, &n, nil);
         if(missing) {
- fprintf(stderr, "%s: missing fontset%s for '%s':", argv0,
- (n > 1 ? "s":""), name);
+ setvbuf(stderr, nil, _IOLBF, 0);
+ fprintf(stderr, "%s: note: missing fontset%s for '%s':", argv0,
+ (n > 1 ? "s" : ""), name);
                 for(i = 0; i < n; i++)
- fprintf(stderr, "%s %s", (i ? ",":""), missing[i]);
+ fprintf(stderr, "%s %s", (i ? "," : ""), missing[i]);
                 fprintf(stderr, "\n");
+ setvbuf(stderr, nil, _IONBF, 0);
                 freestringlist(missing);
         }
 
         if(f->set) {
- XFontStruct **xfonts;
- char **font_names;
-
                 XFontsOfFontSet(f->set, &xfonts, &font_names);
                 f->ascent = xfonts[0]->ascent;
                 f->descent = xfonts[0]->descent;
diff -r 08c51f7f92c9 -r d6404716b170 rc/sh.wmii
--- a/rc/sh.wmii Mon Jun 18 18:43:11 2007 -0400
+++ b/rc/sh.wmii Mon Jun 25 19:51:10 2007 -0400
@@ -1,11 +1,12 @@
 #!sh
 # WMII Configuration
-load std
-load string
-load regex
-
-mount -Aa {os dial unix!/tmp/ns.kris.:1/wmii >[1=0]} / || exit
-#mount -Aa {os rc -c 'dial $WMII_ADDRESS' >[1=0]} /
+load std string regex expr echo
+
+argv0 = $0
+
+#mount -Aa {os dial unix!/tmp/ns.kris.:1/wmii >[1=0]} / || raise mount
+#mount -Aa {styxmon {os rc -c 'dial $WMII_ADDRESS' >[1=0]}} / || raise mount
+mount -Aa {os rc -c 'dial $WMII_ADDRESS' >[1=0]} / || raise mount
 
 MODKEY=Mod1
 UP=k
@@ -14,6 +15,7 @@ RIGHT=l
 RIGHT=l
 
 WMII_FONT=fixed
+WMII_FONT='drift,-*-fixed-*-*-*-*-9-*-*-*-*-*-*-*'
 WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F')
 WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F')
 WMII_BACKGROUND='#333333'
@@ -21,13 +23,15 @@ WMII_TERM=urxvt
 WMII_TERM=urxvt
 
 fn wmiimenu {
- run_command ${re sg '#' '"#"' (dmenu -b -fn $WMII_FONT
- -nf ${hd $WMII_NORMCOLORS} -nb ${index 2 $WMII_NORMCOLORS}
- -sf ${hd $WMII_FOCUSCOLORS} -sb ${index 2 $WMII_FOCUSCOLORS})}
+ (nf nb nil sf sb nil) := ($WMII_NORMCOLORS $WMII_FOCUSCOLORS)
+ os -d ${hostenv HOME} (
+ dmenu -b -fn $WMII_FONT
+ -nf $nf -nb $nb -sf $sf -sb $sb)
 }
 
 fn 9menu {
- run_command (wmii9menu -font $WMII_FONT
+ os -d ${hostenv HOME} (
+ wmii9menu -font ${hd ${split , $WMII_FONT}}
                 -^(nf nb br)^$WMII_NORMCOLORS
                 -^(sf sb br)^$WMII_FOCUSCOLORS $*)
 }
@@ -36,21 +40,37 @@ echo '/./ -> 60+40' >/colrules
 echo '/./ -> 60+40' >/colrules
 
 # Tagging Rules
-{ echo '/Firefox/ -> www
+echo '
+/Firefox/ -> www
 /XMMS.*/ -> ~
 /MPlayer.*/ -> ~
 /.*/ -> !
 /.*/ -> 1
-' } >/tagrules
+' >/tagrules
 
 subfn seq {
- arg := $*
- result=`{os seq $arg}
+ result=${expr $* seq}
 }
 
 subfn hostenv {
         arg := $"*
- result="{os sh -c ${quote eval echo -n '$'$arg}}
+ result="{os rc -c 'echo -n $'^$arg </dev/null}
+}
+
+subfn ftl {
+ result=${tl $*}
+ result=$"result
+}
+
+subfn lines {
+ ifs := "{echo}
+ arg = $*
+ result = `{$arg}
+}
+
+fn dprint {
+ arg := $*
+ or {~ $#debug 0} {~ $debug '' 0} { echo $arg }
 }
 
 # Status Bar Info
@@ -60,43 +80,52 @@ fn status {
 
 # Events
 fn Event-Start {
- if { ~ $1 wmiirc } {
+ if {~ $1 wmiirc} {
                 rm -f $progs_file
                 exit
         }
 }
 
 fn Event-Key {
- echo Key-$1
+ dprint Key-$1
         Key-$1 $1
 }
 
-fn Event-CreateTag { echo $WMII_NORMCOLORS $* >> /lbar/$"* }
+fn Event-CreateTag { echo $WMII_NORMCOLORS $* > /lbar/$"* }
 fn Event-DestroyTag { rm /lbar/$"* }
 fn Event-FocusTag { echo $WMII_FOCUSCOLORS $* > /lbar/$"* }
 fn Event-UnfocusTag { echo $WMII_NORMCOLORS $* > /lbar/$"* }
-fn Event-UrgentTag { echo '*'${tl $*} > ${quote /lbar/${tl $*} } }
-fn Event-NotUrgentTag { echo ${tl $*} > ${quote /lbar/${tl $*} } }
-
-fn Event-LeftBarClick { echo view ${tl $*} >/ctl }
+fn Event-UrgentTag { echo '*'${ftl $*} > /lbar/${ftl $*} }
+fn Event-NotUrgentTag { echo ${tl $*} > /lbar/${ftl $*} }
+
+fn Event-LeftBarClick {
+ (button name) := $*
+ if {~ $button 1} { echo view $name >/ctl }
+}
+fn Event-LeftBarMouseDown {
+ (button name) := $*
+ if {~ $button 3} { echo view "{9menu ${lines read_tags}} >/ctl & }
+}
 lastcmd=''
 fn Event-ClientMouseDown {
         (client button) := $*
- if { ~ $button 3 } {
- lastcmd = `{9menu -initial $lastcmd Nop Delete}
- cmp := {~ $do $1}
- or {and {$cmp Nop} {echo Do nothing}
- } {and {$cmp Delete} {echo kill >/client/$client/ctl}}
+ if {~ $button 3} {
+ lastcmd = `{9menu -initial $lastcmd Nop Delete Fullscreen}
+ cmp := {~ $lastcmd $*}
+ if {$cmp Nop} {
+ } {$cmp Delete} { echo kill >/client/$client/ctl
+ } {$cmp Fullscreen} { echo Fullscreen >/client/$client/ctl
+ }
         }
 }
 
 # Actions
 fn Action {
         (action args) := $*
- if {whatis Action-$action | grep -s '^load std; fn '} {
+ if {~ "{whatis Action-$action >[2]/dev/null} 'load std; fn '*} {
                 Action-$action $args
         } {
- run_command ${config_whatis $action} $args </dev/null
+ run_command ${config_whatis $action} $args
         }
 }
 fn Action-quit { echo quit >>/ctl }
@@ -105,13 +134,14 @@ fn Action-rehash {
         proglist ${hostenv PATH} >$progs_file
 }
 fn Action-status {
- if {rm /rbar/status >[2]/dev/null} {
- sleep 2
- }
+ flag x -
+ if {rm /rbar/status >[2]/dev/null} { sleep 1 }
         echo $WMII_NORMCOLORS >/rbar/status
- while {status >/rbar/status} {
- sleep 1
- }
+ while {status >/rbar/status} { sleep 1 }
+}
+fn Action-sh.wmii {
+ os -b inferno $argv0 &
+ exit
 }
 
 # Key Bindings
@@ -127,8 +157,8 @@ fn Key-$MODKEY-Control-t {
 
 fn Key-$MODKEY-$LEFT { echo select left >/tag/sel/ctl }
 fn Key-$MODKEY-$RIGHT { echo select right >/tag/sel/ctl }
+fn Key-$MODKEY-$UP { echo select up >/tag/sel/ctl }
 fn Key-$MODKEY-$DOWN { echo select down >/tag/sel/ctl }
-fn Key-$MODKEY-$UP { echo select up >/tag/sel/ctl }
 
 fn Key-$MODKEY-Shift-$LEFT { echo send sel left >/tag/sel/ctl }
 fn Key-$MODKEY-Shift-$RIGHT { echo send sel right >/tag/sel/ctl }
@@ -145,7 +175,7 @@ fn Key-$MODKEY-Shift-c { echo kill >/cli
 fn Key-$MODKEY-Shift-c { echo kill >/client/sel/ctl }
 
 fn Key-$MODKEY-a { Action `{actionlist | wmiimenu} & }
-fn Key-$MODKEY-p { run_command `{wmiimenu <$progs_file} </dev/null & }
+fn Key-$MODKEY-p { run_command rc -c "{wmiimenu <$progs_file} & }
 fn Key-$MODKEY-Return { run_command $WMII_TERM & }
 fn Key-$MODKEY-t { echo view `{read_tags | wmiimenu} >/ctl & }
 fn Key-$MODKEY-Shift-t {
@@ -153,6 +183,18 @@ fn Key-$MODKEY-Shift-t {
         read_tags | wmiimenu >/client/$sel/tags
 }
 
+fn next_tag {
+ os awk -v curtag'='${lines sed 1q /tag/sel/ctl} '
+ NR==1 {first = $0}
+ $0==curtag { if(getline) print $0; else print first; exit }'
+}
+fn Key-$MODKEY-n {
+ echo view `{read_tags | next_tag} >/ctl
+}
+fn Key-$MODKEY-b {
+ echo view `{read_tags | tail -r | next_tag} >/ctl
+}
+
 for(i in ${seq 0 9}) {
         fn Key-$MODKEY-$i { echo view ${tl ${splitr $1 -}} >/ctl }
         fn Key-Shift-$MODKEY-$i { echo ${tl ${splitr $1 -}} >/client/sel/tags}
@@ -160,11 +202,10 @@ for(i in ${seq 0 9}) {
 
 # Functions
 fn proglist {
- apply {ls -lp $*} /n/local^${split : $"*} |
- grep '^[^d][^ ]*x' |
- getlines {
- echo ${index 10 ${split ' ' $line}}
- } | sort | uniq
+ os find ${split : $"*} -maxdepth 1 -type f | sed 's,.*/,,' | sort | uniq
+ #for(d in /n/local^${split : $"*}) {
+ # fs filter {mode -d} $d
+ #} | sed 's,.*/,,' | sort | uniq
 }
 
 fn getfuns {
@@ -190,14 +231,11 @@ fn read_tags {
 }
 
 subfn config_whatis {
- result="{os sh -c ${quote eval PATH'='${hostenv WMII_CONFPATH} which $*}}
+ result=${lines os rc -c 'PATH=$WMII_CONFPATH which $*' $*}
 }
 
 fn run_command {
- @{ pctl newpgrp
- vars := 'DISPLAY=:1' 'PATH=/home/kris/wmiiinst/bin:$PATH'
- os sh -c ${quote eval $vars $*}
- } $*
+ os -b -d ${hostenv HOME} $* &
 }
 
 # WM Configuration
@@ -216,16 +254,15 @@ Action rehash &
 Action rehash &
 
 # Tag Bar Setup
-seltag="{cat /tag/sel/ctl}
-comm -2 ${pipe read_tags} ${pipe ls -p /lbar/*} | getlines {
- rm /lbar/$line
-}
+{ifs:="{echo}; seltag=`{sed 1q /tag/sel/ctl}}
+comm -13 ${pipe from {read_tags}} ${pipe from {ls -p /lbar/*}} |
+ getlines { rm /lbar/$line }
 read_tags | getlines {
         if {~ $line $seltag} {
- echo $WMII_FOCUSCOLORS $line >/lbar/$line
- } {
- echo $WMII_NORMCOLORS $line >/lbar/$line
- }
+ echo $WMII_FOCUSCOLORS $line
+ } {
+ echo $WMII_NORMCOLORS $line
+ } >/lbar/$line
 }
 
 # Keygrab Setup
@@ -236,8 +273,11 @@ echo Start wmiirc >/event
 # Event Loop
 getlines {
         (event args) := ${split ' ' $line}
- echo Event-$event: $args
- rescue '*' { echo Exception: $exception } {
- Event-$event $args
- }
+ dprint Event-$event: $args
+ rescue '*' { dprint Exception: $exception } {
+ if {whatis Event-$event >/dev/null >[2=1]} {
+ Event-$event $args
+ }
+ } </dev/null
+ dprint loop
 } </event
Received on Tue Jun 26 2007 - 01:51:29 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:22 UTC