diff options
| -rw-r--r-- | userspace/init.c | 24 | ||||
| -rw-r--r-- | video/compositor.c | 118 | ||||
| -rw-r--r-- | video/compositor.h | 9 |
3 files changed, 115 insertions, 36 deletions
diff --git a/userspace/init.c b/userspace/init.c index 255b274..e432ef9 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -4,11 +4,11 @@ * * */ +#define LAUNCH_COUNT 0 static char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; static char *argv1[]={"xterm","/bin/fsh",0}; /* -#define LAUNCH_COUNT 3 char *argv1[][4]={ {"/bin/xterm","xterm","/bin/fsh",0}, @@ -17,24 +17,30 @@ char *argv1[][4]={ }; */ -void fork_and_exec(char **argv) +void fork_and_exec() { int pid=fork(); - if(!pid) //child { - execve(argv[0],&argv[1],env1); + execve("/bin/xterm",argv1,env1); } } int main(int argc, char **argv) { - execve("/bin/xterm",argv1,env1); - /* + int pid=fork(); + for(int i=0;i<LAUNCH_COUNT;i++) { - fork_and_exec(argv1[i]); + fork_and_exec(); + } + + int tty_fd=_open("/dev/tty"); + + while(1) + { + char buf[1]; + read(tty_fd,buf,1); // + fork_and_exec(); } - wait(999);/// TODO: here we should wait for commnads to spawn new processes? - */ } diff --git a/video/compositor.c b/video/compositor.c index d7094b1..2b67385 100644 --- a/video/compositor.c +++ b/video/compositor.c @@ -17,22 +17,27 @@ ringbuffer bg_invl; -// TODO: int16 int32 mixed nonsense -// +// TODO: int16 int32 mixed nonsense ! struct window { uint32_t pid; ringbuffer *invl; + struct pdirectory *vmem; // retreive from task manager? int16_t posx; int16_t posy; + uint16_t width; uint16_t height; uint16_t active; + bool draw_border; bool draw_meat; + + bool borderless; // never show borders + bool fixed; // can not be moved }; struct icon @@ -127,7 +132,6 @@ static uint32_t get_pixel(uint8_t *src, int x,int y) static void put_pixel_alpha(uint8_t *dst, int x,int y, uint32_t color) { // TODO: do not use hardcoded alpha! - uint16_t a=0xaa; uint32_t col=get_pixel(dst,x,y); @@ -139,10 +143,11 @@ static void put_pixel_alpha(uint8_t *dst, int x,int y, uint32_t color) uint8_t src_b=color&0xff; uint8_t src_g=(color&0xff00)>>8; uint8_t src_r=(color&0xff0000)>>16; + uint8_t src_a=(color&0xff000000)>>24; - uint8_t out_r=((src_r*(0xff-a))>>8)+((a*dst_r)>>8); - uint8_t out_g=((src_g*(0xff-a))>>8)+((a*dst_g)>>8); - uint8_t out_b=((src_b*(0xff-a))>>8)+((a*dst_b)>>8); + uint8_t out_r=((src_r*(src_a))>>8)+(((0xff-src_a)*dst_r)>>8); + uint8_t out_g=((src_g*(src_a))>>8)+(((0xff-src_a)*dst_g)>>8); + uint8_t out_b=((src_b*(src_a))>>8)+(((0xff-src_a)*dst_b)>>8); put_pixel(dst, x,y,(out_r<<16)+(out_g<<8)+out_b); } @@ -162,7 +167,6 @@ static void cpy_rect(uint8_t *src, uint16_t src_x, uint16_t src_y, if(transp&&transp_key==val)continue; // TODO: quick workaround for arrow black if(alpha) - put_pixel_alpha(dst,dst_x+x,dst_y+y,val); else put_pixel(dst,dst_x+x,dst_y+y,val); @@ -508,12 +512,20 @@ void compositor_kb_handle(char c) void compositor_mouse_handle(int16_t diff_x,int16_t diff_y, uint8_t key) { // klog("%d %d %d",diff_x,diff_y,key); - static uint8_t lastkey; + static uint8_t lastkey=0; + + if(!(key&2)&&(lastkey&2)) // right mouse click + { + lastkey=key; + klog("tell init to spawn new foolshell"); + fd_write(get_tty(1),'0'); // tell init to spawn new xterm + } mouse_x+=diff_x; mouse_y+=diff_y; mouse_k=key; + if(mouse_x<0)mouse_x=0; if(mouse_y<0)mouse_y=0; @@ -642,13 +654,62 @@ void compositor_mouse_handle(int16_t diff_x,int16_t diff_y, uint8_t key) lastkey=key; } + +/** THIS CAN LOAD WINDOWS ARGB BITMAPS WITH BITMAPINFOHEADER */ +void load_bmp(uint8_t *dst,char *filename) +{ + + klog("loading bitmap %s",filename); + fd dat=mount_file_open(filename); + char B=fd_read(&dat); // 0x0 + char M=fd_read(&dat); // 0x1 + //klog("id = %c%c",M,B); + if(M!='M'||B!='B')kpanic("not a (windows) bitmap!"); + + uint32_t size=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x02 + klog("bytes = 0x%08x",size); + + // skip next 4 reserved bytes + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + + uint32_t off=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x0a + //klog("offset = 0x%08X",off); + + // skip next 4 bytes + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + fd_read(&dat); + + uint32_t w=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x12 + uint32_t h=(fd_read(&dat))+(fd_read(&dat)<<8)+(fd_read(&dat)<<16)+(fd_read(&dat)<<24); //0x16 + klog("width=%d,height=%d",w,h); + + for(int i=0;i<off-0xa;i++)fd_read(&dat); // skip to data + + // read the image from left to right line by line + for(int y=0;y<h;y++) + for(int x=0;x<w;x++) + { + { + uint32_t val=(fd_read(&dat)<<24)+(fd_read(&dat)<<16)+(fd_read(&dat)<<8)+(fd_read(&dat)); + if(x>=vesa_width)continue; + if(y>=vesa_height)continue; + put_pixel_alpha(dst,x,y,val); + } + } + +} + // load background image or generate one if (param == 0) void compositor_set_background(char *ppm_raw_filename) { // TODO: think about funny things to do with timer and update // some generated / or modified bg regularly // // uint64_t t=timer_get_ms()/333; // - klog("loading theme..."); fd bg=mount_file_open(ppm_raw_filename); @@ -663,33 +724,36 @@ void compositor_set_background(char *ppm_raw_filename) if(x>=vesa_width)continue; if(y>=vesa_height)continue; put_pixel(icon_data,x,y,val); + put_pixel(bgimage,x,y,val); i++; } } + klog("finished"); // generating simple background... - int center_x=vesa_width/2; - int center_y=vesa_height/2; - - int max_dist = center_x*center_x+center_y*center_y; + int center_x=vesa_width/2; + int center_y=vesa_height/2; + int max_dist = center_x*center_x+center_y*center_y; - for(int x=0;x<vesa_width;x++) + for(int x=0;x<vesa_width;x++) + { + for(int y=0;y<vesa_height;y++) { - for(int y=0;y<vesa_height;y++) + uint32_t val; + if(y%2) { - uint32_t val; - if(y%2) - { - int diffx=center_x-x; - int diffy=center_y-y; - int dist=diffx*diffx+diffy*diffy; - val = 0xaa*dist/max_dist; - } - else val=0x0; - val=0x002b36; - - put_pixel(bgimage,x,y,val); + int diffx=center_x-x; + int diffy=center_y-y; + int dist=diffx*diffx+diffy*diffy; + val = 0xaa*dist/max_dist; } + else val=0x0; + //val=0x002b36; + +// put_pixel(bgimage,x,y,val); } + } + + load_bmp(bgimage,"/home/miguel/skin.bmp"); } diff --git a/video/compositor.h b/video/compositor.h index f497d6c..e3204a6 100644 --- a/video/compositor.h +++ b/video/compositor.h @@ -1,6 +1,15 @@ #include <stdint.h> #include "ringbuffer.h" +/** + * @file + * + * Super Light composting window manager for Fool 0S. + * Can be run directly on a 32bit or 24bit Framebuffer. + * + * + */ + void compositor_wake(); void compositor_wake2(); void compositor_init(uint16_t width, uint16_t height,uint16_t bpp, uint16_t pitch); |
