diff options
Diffstat (limited to 'video/compositor.c')
| -rw-r--r-- | video/compositor.c | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/video/compositor.c b/video/compositor.c index ba67598..924664b 100644 --- a/video/compositor.c +++ b/video/compositor.c @@ -27,8 +27,10 @@ struct window }; static uint16_t next_window=0; +static uint16_t next_x=50; +static uint16_t next_y=50; -#define MAX_WINDOWS 10 +#define MAX_WINDOWS 100 struct window windows[MAX_WINDOWS]; @@ -60,6 +62,12 @@ uint32_t usery=0; for(uint16_t x=win->posx;x<win->posx+win->width;x++) { + backbuffer[(win->posy-1)*vesa_width+x]=0xffffff; + backbuffer[(win->posy+win->height)*vesa_width+x]=0xffffff; + } + + for(uint16_t x=win->posx;x<win->posx+win->width;x++) + { usery=0; userx++; for(uint16_t y=win->posy;y<win->posy+win->height;y++) @@ -96,7 +104,14 @@ uint32_t usery=0; } else { - backbuffer[y*vesa_width+x]=0xffffff; + if(win->vmem) + { + if(userx<640&&usery<480)backbuffer[y*vesa_width+x]=~(user_vmem[userx+usery*640]); + } + else + { + backbuffer[y*vesa_width+x]=0xffffff; + } } } @@ -126,60 +141,32 @@ static void put_mouse() void compositor_add_window(uint32_t addr) { - windows[next_window].posx=100; - windows[next_window].posy=100; + if (next_window>=MAX_WINDOWS)kpanic("max number of windows reached. increase MAX_WINDOWS"); - windows[next_window].width=640; - windows[next_window].height=480; + windows[next_window]=windows[0]; - windows[next_window].color=0xAAAA00AA; - windows[next_window].active=0; - windows[next_window].vmem=addr; + windows[0].posx=next_x; + windows[0].posy=next_y; - next_window++; -} - - -void compositor_init(uint16_t width, uint16_t height, uint16_t pitch) -{ - vesa_width=width; - vesa_height=height; - klog("initialized composing window manager to %d x %d",width,height); - - - windows[0].posx=800; - windows[0].posy=500; + next_x+=100; + next_y+=100; windows[0].width=640; windows[0].height=480; - windows[0].color=0xAAAA0000; + windows[0].color=0xAAAA00AA; windows[0].active=0; - windows[0].vmem=0; + windows[0].vmem=addr; next_window++; +} - /* - windows[1].posx=200; - windows[1].posy=200; - - windows[1].width=640; - windows[1].height=480; - - windows[1].color=0xAA00AA00; - windows[1].active=0; - windows[1].vmem=0; - - windows[2].posx=400; - windows[2].posy=300; - - windows[2].width=640; - windows[2].height=480; - windows[2].color=0xAA0000AA; - windows[2].active=0; - windows[2].vmem=0; - */ +void compositor_init(uint16_t width, uint16_t height, uint16_t pitch) +{ + vesa_width=width; + vesa_height=height; + klog("initialized composing window manager to %d x %d",width,height); } void compositor_swap_buffers() @@ -189,7 +176,7 @@ void compositor_swap_buffers() // klog("swap"); memcpy(backbuffer,bgimage,vesa_height*vesa_width*4);// TODO optimize? rects only too? - for(int i=0;i<next_window;i++) + for(int i=next_window-1;i>=0;i--) { put_rect(&windows[i]); } @@ -237,6 +224,15 @@ void compositor_mouse_handle(uint16_t x,uint16_t y, uint8_t key) w->active=false; } } + + if(active!=-1&&active!=0&&(key&1)) + { + struct window temp; + temp=windows[active]; + windows[active]=windows[0]; + windows[0]=temp; + + } } void compositor_set_background(char *ppm_raw_filename) |
