1
0

lhide.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <draw.h>
  4. #include <memdraw.h>
  5. #include <memlayer.h>
  6. /*
  7. * Hide puts that portion of screenr now on the screen into the window's save area.
  8. * Expose puts that portion of screenr now in the save area onto the screen.
  9. *
  10. * Hide and Expose both require that the layer structures in the screen
  11. * match the geometry they are being asked to update, that is, they update the
  12. * save area (hide) or screen (expose) based on what those structures tell them.
  13. * This means they must be called at the correct time during window shuffles.
  14. */
  15. static
  16. void
  17. lhideop(Memimage *src, Rectangle screenr, Rectangle clipr, void *etc, int insave)
  18. {
  19. Rectangle r;
  20. Memlayer *l;
  21. USED(clipr.min.x);
  22. USED(insave);
  23. l = etc;
  24. if(src != l->save){ /* do nothing if src is already in save area */
  25. r = rectsubpt(screenr, l->delta);
  26. memdraw(l->save, r, src, screenr.min, nil, screenr.min, S);
  27. }
  28. }
  29. void
  30. memlhide(Memimage *i, Rectangle screenr)
  31. {
  32. if(i->layer->save == nil)
  33. return;
  34. if(rectclip(&screenr, i->layer->screen->image->r) == 0)
  35. return;
  36. _memlayerop(lhideop, i, screenr, screenr, i->layer);
  37. }
  38. static
  39. void
  40. lexposeop(Memimage *dst, Rectangle screenr, Rectangle clipr, void *etc, int insave)
  41. {
  42. Memlayer *l;
  43. Rectangle r;
  44. USED(clipr.min.x);
  45. if(insave) /* if dst is save area, don't bother */
  46. return;
  47. l = etc;
  48. r = rectsubpt(screenr, l->delta);
  49. if(l->save)
  50. memdraw(dst, screenr, l->save, r.min, nil, r.min, S);
  51. else
  52. l->refreshfn(dst, r, l->refreshptr);
  53. }
  54. void
  55. memlexpose(Memimage *i, Rectangle screenr)
  56. {
  57. if(rectclip(&screenr, i->layer->screen->image->r) == 0)
  58. return;
  59. _memlayerop(lexposeop, i, screenr, screenr, i->layer);
  60. }