diff options
Diffstat (limited to 'graphics.c')
-rw-r--r-- | graphics.c | 41 |
1 files changed, 29 insertions, 12 deletions
@@ -7,6 +7,7 @@ #include "guifs.h" +Point mousexy; Mousectl *mouse; Keyboardctl *keyboard; Channel *updatechan; @@ -21,7 +22,7 @@ drawgui(GuiElement *g) if(memcmp(&g->rect, &g->border, sizeof(Rectangle)) != 0 && Dx(g->border) > 0 && Dy(g->border) > 0){ /* draw the border first */ - Image *bc = getprop(g, Pbordercolour).colour->image; + Image *bc = getprop(g, Pbordercolour, 1).colour->image; Rectangle r; /* top part */ @@ -55,7 +56,7 @@ drawgui(GuiElement *g) if(Dx(g->rect) > 0 && Dy(g->rect) > 0){ /* Draw the background */ - Image *bg = getprop(g, Pbackground).colour->image; + Image *bg = getprop(g, Pbackground, 1).colour->image; draw(screen, g->rect, bg, nil, ZP); spec.draw(g); @@ -75,8 +76,8 @@ drawcontainer(GuiElement *g) void drawtextbox(GuiElement *g) { - Rune *text = getprop(g, Ptext).text; - Image *fg = getprop(g, Ptextcolour).colour->image; + Rune *text = getprop(g, Ptext, 1).text; + Image *fg = getprop(g, Ptextcolour, 1).colour->image; runestring(screen, g->content.min, fg, ZP, font, text); @@ -116,6 +117,8 @@ guiproc(void *) { int i; ulong c; + Rune r; + if(initdraw(nil, nil, "guifs") < 0) sysfatal("initdraw failed"); @@ -127,25 +130,28 @@ guiproc(void *) enum { Aupdategui, Aresize, - Amouse, Amkcolour, + Amouse, + Akeyboard, Aaltend, }; - Alt a[] = { + Alt alts[] = { [Aupdategui] = {updatechan, &i, CHANRCV}, [Aresize] = {mouse->resizec, nil, CHANRCV}, - [Amouse] = - {mouse->c, &mouse->Mouse, CHANRCV}, [Amkcolour] = {mkcolourchan, &c, CHANRCV}, + [Amouse] = + {mouse->c, &mouse->Mouse, CHANRCV}, + [Akeyboard] = + {keyboard->c, &r, CHANRCV}, [Aaltend] = {nil, nil, CHANEND}, }; while(1){ - int which = alt(a); + int which = alt(alts); switch(which){ case Aupdategui: @@ -154,16 +160,27 @@ guiproc(void *) case Aresize: resized(1); break; - case Amouse: - break; case Amkcolour: { - Colour *col = emalloc(sizeof(Colour)); col->image = allocimage(display, Rect(0,0,1,1), screen->chan, 1, c); col->code = c; send(newcolourchan, &col); } + break; + case Amouse: + mousexy = mouse->Mouse.xy; + if(!root) + break; + if(mouseevent(mouse->Mouse.buttons)) + resized(0); + break; + case Akeyboard: + if(!root) + break; + if(keyboardevent(r)) + resized(1); + break; } } } |