]> git.lizzy.rs Git - plan9front.git/commitdiff
cmd/rio: Add support for wallpapers (My implementation centers the wallpaper instead... rio
authorElias Fleckenstein <fleckenstein@elidragon.com>
Tue, 31 Aug 2021 12:04:07 +0000 (12:04 +0000)
committerElias Fleckenstein <fleckenstein@elidragon.com>
Tue, 31 Aug 2021 12:04:07 +0000 (12:04 +0000)
sys/src/cmd/rio/dat.h
sys/src/cmd/rio/data.c
sys/src/cmd/rio/fns.h
sys/src/cmd/rio/rio.c

index dac32da5fde3210f6291c169032e81b913cb5e01..93003780bae6ce51c146bca83bf6bdc0aaa42af2 100644 (file)
@@ -296,6 +296,7 @@ Cursor      query;
 Cursor *corners[9];
 
 Image  *background;
+Image  *wallpaper;
 Image  *cols[NCOL];
 Image  *titlecol;
 Image  *lighttitlecol;
index 86e43c72fd94ac14194feb12a3ad5391b7797ac3..55a26d4b71561406f29f06b477c4e97a27aff8fb 100644 (file)
@@ -173,10 +173,39 @@ Cursor *corners[9] = {
 };
 
 void
-iconinit(void)
+backgroundinit(void)
+{              
+       background = allocimage(display, screen->r, screen->chan, 1, 0x777777FF);
+       
+       if (wallpaper) {
+               Rectangle r = Rect(
+                       (screen->r.min.x + screen->r.max.x - Dx(wallpaper->r)) / 2,
+                       (screen->r.min.y + screen->r.max.y - Dy(wallpaper->r)) / 2,
+                       (screen->r.min.x + screen->r.max.x + Dx(wallpaper->r)) / 2,
+                       (screen->r.min.y + screen->r.max.y + Dy(wallpaper->r)) / 2
+               );
+
+               draw(background, r, wallpaper, nil, wallpaper->r.min);
+       }
+}
+
+void
+wallpaperinit(void)
 {
-       background = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF);
+       int fd;
+       
+       fd = open("/usr/glenda/lib/wallpaper", OREAD);
+       if(fd >= 0) {
+               wallpaper = readimage(display, fd, 0);
+               close(fd);
+       } else {
+               wallpaper = nil;
+       }
+}
 
+void
+iconinit(void)
+{
        /* greys are multiples of 0x11111100+0xFF, 14* being palest */
        cols[BACK] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0xFFFFFFFF^reverse);
        cols[BORD] = allocimage(display, Rect(0,0,1,1), CMAP8, 1, 0x999999FF^reverse);
index 8562c2cd97cd08215d4c9ea7bd5547d7e941d478..4d4597355ef14ebafc12547871074d6b778b567c 100644 (file)
@@ -17,6 +17,8 @@ void  error(char*);
 void   killprocs(void);
 int    shutdown(void*, char*);
 void   iconinit(void);
+void   wallpaperinit(void);
+void   backgroundinit(void);
 void   *erealloc(void*, uint);
 void *emalloc(uint);
 char *estrdup(char*);
index 9c18a6955ebf2d28856f72fdabf0ae2c0e473f97..29fa11426785d7627d222b072856d2636588b86b 100644 (file)
@@ -186,6 +186,8 @@ threadmain(int argc, char *argv[])
                exits("display open");
        }
        iconinit();
+       wallpaperinit();
+       backgroundinit();
 
        exitchan = chancreate(sizeof(int), 0);
        winclosechan = chancreate(sizeof(Window*), 0);
@@ -202,7 +204,7 @@ threadmain(int argc, char *argv[])
        wscreen = allocscreen(screen, background, 0);
        if(wscreen == nil)
                error("can't allocate screen");
-       draw(view, viewr, background, nil, ZP);
+       draw(view, Rect(0, 0, viewr.max.x, viewr.max.y), background, nil, ZP);
        flushimage(display, 1);
 
        timerinit();
@@ -594,10 +596,12 @@ resized(void)
        freescrtemps();
        view = screen;
        freescreen(wscreen);
+       freeimage(background);
+       backgroundinit();
        wscreen = allocscreen(screen, background, 0);
        if(wscreen == nil)
                error("can't re-allocate screen");
-       draw(view, view->r, background, nil, ZP);
+       draw(view, Rect(0, 0, view->r.max.x, view->r.max.y), background, nil, ZP);
        o = subpt(viewr.max, viewr.min);
        n = subpt(view->clipr.max, view->clipr.min);
        qsort(window, nwindow, sizeof(window[0]), wtopcmp);