vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 1ca87235d52054b34526eb7adad00ee763bb28d4
parent a693733fd50bf95ba59c6eb9a4e1cf59bb6803d5
Author: yiyus <yiyu.jgl@gmail.com>
Date:   Fri, 16 Jul 2010 22:44:39 +0200

second round of updates to a/*.ed, includes makea script

Diffstat:
src/9vx/a/allocb.ed | 1-
src/9vx/a/chan.ed | 2--
src/9vx/a/dat.ed | 1-
src/9vx/a/dev.ed | 1-
src/9vx/a/devcap.c | 2+-
src/9vx/a/devcap.ed | 2--
src/9vx/a/devcons.ed | 2--
src/9vx/a/devdraw.c | 130++++++++++++++++++++++++++++++++++++++++---------------------------------------
src/9vx/a/devdraw.ed | 69++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/9vx/makea | 28++++++++++++++++++++++++++++
src/9vx/screen.h | 1-
11 files changed, 163 insertions(+), 76 deletions(-)

diff --git a/src/9vx/a/allocb.ed b/src/9vx/a/allocb.ed @@ -1,4 +1,3 @@ -,s!"\.\./port/lib\.h"!"lib.h"! ,s!Lock;!Lock lk;! ,s!lock(&ialloc)!lock(\&ialloc.lk)!g ,s!msize(b)!sizeof(Block)+size+Hdrspc! diff --git a/src/9vx/a/chan.ed b/src/9vx/a/chan.ed @@ -1,5 +1,3 @@ -,s!"\.\./port/lib\.h"!"lib.h"! -,s!"\.\./port/error\.h"!"error.h"! ,s!Lock;!Lock lk;!g /dumpmount/-1 s!static !/*static*/ ! ,s!lock(r)!lock(\&r->lk)!g diff --git a/src/9vx/a/dat.ed b/src/9vx/a/dat.ed @@ -1,4 +1,3 @@ -,s!"\.\./port/portdat\.h"!"portdat.h"! /BIOS32ci/,/BIOS32ci;/d /^#define up/c #define up (machp[0]->externup) diff --git a/src/9vx/a/dev.ed b/src/9vx/a/dev.ed @@ -1,4 +1,3 @@ -,s!\.\./port/!!g g/^decreate/ s/(Chan\*, char\*, int, ulong)/(Chan *c, char *name, int mode, ulong perm)/ g/^devremove/ s/(Chan\*)/(Chan *c)/ g/^devwstat/ s/(Chan\*, uchar\*, int)/(Chan *c, uchar *stat, int nstat)/ diff --git a/src/9vx/a/devcap.c b/src/9vx/a/devcap.c @@ -5,7 +5,7 @@ #include "fns.h" #include "error.h" -#include "libsec.h" +#include <libsec.h> enum { diff --git a/src/9vx/a/devcap.ed b/src/9vx/a/devcap.ed @@ -1,5 +1,3 @@ -,s!\.\./port/!!g -/libsec\.h/ s/[<>]/"/g /^capwrite/ s/vlong/vlong vl/ /^capread/ s/vlong/vlong vl/ /^capclose/ s/Chan\*/Chan *c/ diff --git a/src/9vx/a/devcons.ed b/src/9vx/a/devcons.ed @@ -1,5 +1,3 @@ -,s!\.\./port/!!g -/authsrv\.h/ s/[<>]/"/g g/exit(/ s/exit/restoretty(); &/ g/"pool.h"/d ,s!QLock;!QLock lk;!g diff --git a/src/9vx/a/devdraw.c b/src/9vx/a/devdraw.c @@ -6,10 +6,10 @@ #include "error.h" #define Image IMAGE -#include "draw.h" -#include "memdraw.h" -#include "memlayer.h" -#include "cursor.h" +#include <draw.h> +#include <memdraw.h> +#include <memlayer.h> +#include <cursor.h> #include "screen.h" #define blankscreen(x) @@ -678,6 +678,8 @@ drawfreedimage(DImage *dimage) drawfreedimage(dimage->fromname); goto Return; } +// if(dimage->image == screenimage) /* don't free the display */ +// goto Return; ds = dimage->dscreen; l = dimage->image; dimage->dscreen = nil; /* paranoia */ @@ -965,63 +967,6 @@ makescreenimage(void) return di; } -void -drawreplacescreenimage(Memimage *m) -{ - int i; - DImage *di; - - if(screendimage == nil) - return; - - /* - * Replace the screen image because the screen - * was resized. Clients still have references to the - * old screen image, so we can't free it just yet. - */ - drawqlock(); - di = allocdimage(m); - if(di == nil){ - print("no memory to replace screen image\n"); - freememimage(m); - drawqunlock(); - return; - } - - /* Replace old screen image in global name lookup. */ - for(i=0; i<sdraw.nname; i++){ - if(sdraw.name[i].dimage == screendimage) - if(sdraw.name[i].client == nil){ - sdraw.name[i].dimage = di; - break; - } - } - - drawfreedimage(screendimage); - screendimage = di; - screenimage = m; - - /* - * Every client, when it starts, gets a copy of the - * screen image as image 0. Clients only use it - * for drawing if there is no /dev/winname, but - * this /dev/draw provides a winname (early ones - * didn't; winname originated in rio), so the - * image only ends up used to find the screen - * resolution and pixel format during initialization. - * Silently remove the now-outdated image 0s. - */ - for(i=0; i<sdraw.nclient; i++){ - if(sdraw.client[i] && !waserror()){ - drawuninstall(sdraw.client[i], 0); - poperror(); - } - } - - drawqunlock(); - mouseresize(); -} - static int initscreenimage(void) { @@ -2245,9 +2190,9 @@ drawactive(int active) { if(active){ drawblankscreen(0); - sdraw.blanktime = msec(); + sdraw.blanktime = msec()/1000; }else{ - if(blanktime && sdraw.blanktime && (msec() - sdraw.blanktime)/1000/60 >= blanktime) + if(blanktime && sdraw.blanktime && TK2SEC(msec()/1000 - sdraw.blanktime)/60 >= blanktime) drawblankscreen(1); } } @@ -2255,7 +2200,7 @@ drawactive(int active) int drawidletime(void) { - return (msec() - sdraw.blanktime)/1000/60; + return TK2SEC(msec()/1000 - sdraw.blanktime)/60; } /* why is this here? why can't caller use drawqlock himself? */ @@ -2266,3 +2211,60 @@ drawflushr(Rectangle r) flushmemscreen(r); drawqunlock(); } + +void +drawreplacescreenimage(Memimage *m) +{ + int i; + DImage *di; + + if(screendimage == nil) + return; + + /* + * Replace the screen image because the screen + * was resized. Clients still have references to the + * old screen image, so we can't free it just yet. + */ + drawqlock(); + di = allocdimage(m); + if(di == nil){ + print("no memory to replace screen image\n"); + freememimage(m); + drawqunlock(); + return; + } + + /* Replace old screen image in global name lookup. */ + for(i=0; i<sdraw.nname; i++){ + if(sdraw.name[i].dimage == screendimage) + if(sdraw.name[i].client == nil){ + sdraw.name[i].dimage = di; + break; + } + } + + drawfreedimage(screendimage); + screendimage = di; + screenimage = m; + + /* + * Every client, when it starts, gets a copy of the + * screen image as image 0. Clients only use it + * for drawing if there is no /dev/winname, but + * this /dev/draw provides a winname (early ones + * didn't; winname originated in rio), so the + * image only ends up used to find the screen + * resolution and pixel format during initialization. + * Silently remove the now-outdated image 0s. + */ + for(i=0; i<sdraw.nclient; i++){ + if(sdraw.client[i] && !waserror()){ + drawuninstall(sdraw.client[i], 0); + poperror(); + } + } + + drawqunlock(); + mouseresize(); +} diff --git a/src/9vx/a/devdraw.ed b/src/9vx/a/devdraw.ed @@ -18,12 +18,22 @@ g/^ int s;/d #define blankscreen(x) #define ishwimage(x) (0) . -/^drawlookupscreen/ +/^drawlookupscreen/ s;^;; / return 0/ s/return 0/for(;;)/ g/Edepth/d +/l = dimage->image;/d +-1i + l = dimage->image; + dimage->dscreen = nil; /* paranoia */ + dimage->image = nil; +. +/^drawattach/ s;^;; +/initscreenimage/s/(.*)/(!conf.monitor || !initscreenimage())/ +/freememimage(dimage->image);/ s/dimage->image/l/ ,s/dunlock/drawqunlock/g ,s/candlock/drawcanqlock/g ,s/dlock(/drawqlock(/g +,s;MACHP(0)->ticks;msec()/1000;g /^drawqlock/-1 s/static // /^drawqunlock/-1 s/static // /^drawcanqlock/-1 s/static // @@ -37,4 +47,61 @@ drawflushr(Rectangle r) flushmemscreen(r); drawqunlock(); } + +void +drawreplacescreenimage(Memimage *m) +{ + int i; + DImage *di; + + if(screendimage == nil) + return; + + /* + * Replace the screen image because the screen + * was resized. Clients still have references to the + * old screen image, so we can't free it just yet. + */ + drawqlock(); + di = allocdimage(m); + if(di == nil){ + print("no memory to replace screen image\n"); + freememimage(m); + drawqunlock(); + return; + } + + /* Replace old screen image in global name lookup. */ + for(i=0; i<sdraw.nname; i++){ + if(sdraw.name[i].dimage == screendimage) + if(sdraw.name[i].client == nil){ + sdraw.name[i].dimage = di; + break; + } + } + + drawfreedimage(screendimage); + screendimage = di; + screenimage = m; + + /* + * Every client, when it starts, gets a copy of the + * screen image as image 0. Clients only use it + * for drawing if there is no /dev/winname, but + * this /dev/draw provides a winname (early ones + * didn't; winname originated in rio), so the + * image only ends up used to find the screen + * resolution and pixel format during initialization. + * Silently remove the now-outdated image 0s. + */ + for(i=0; i<sdraw.nclient; i++){ + if(sdraw.client[i] && !waserror()){ + drawuninstall(sdraw.client[i], 0); + poperror(); + } + } + + drawqunlock(); + mouseresize(); +} . diff --git a/src/9vx/makea b/src/9vx/makea @@ -0,0 +1,28 @@ +#!/bin/sh + +# Usage: +# makea [-r plan9root] [files] + +orig=$HOME/plan9 +if [ $# -gt 0 ]; then + if [ $1 == "-r" ]; then + shift + orig=$1/sys/src/9 + shift + fi +fi + +files=a/*.ed +if [ $# -gt 0 ]; then + files=$* +fi + +for f in $files; do + name=`echo $f | sed 's,.*/,,;s,\.ed,,'` + ofile=`(ls $orig/port/$name.[ch] || ls $orig/pc/$name.[ch]) 2>/dev/null` + dfile=`echo $ofile | sed 's,.*/,a/,'` + echo -e ",p\nq" | cat $f - | ed -s $ofile | sed ' +/^#include/s,../port/,, +/^#include[ ]+<(libsec\.h|authsrv\.ed|draw\.h|memdraw\.h|memlayer\.h|cursor\.h)>/s,[<>],",g + ' > $dfile +done diff --git a/src/9vx/screen.h b/src/9vx/screen.h @@ -64,7 +64,6 @@ uchar* attachscreen(Rectangle*, ulong*, int*, int*, int*, void**); int drawcanqlock(void); void drawqlock(void); void drawqunlock(void); -void drawreplacescreenimage(Memimage*); void getcolor(ulong, ulong*, ulong*, ulong*); char* getsnarf(void); void flushmemscreen(Rectangle);