(define-module (wlroots types damage-ring)
  #:use-module ((system foreign) #:prefix ffi:)
  #:use-module (wlroots utils)
  #:use-module (wlroots util box)
  #:use-module (wlroots types)
  #:use-module (oop goops)
  #:duplicates (merge-accessors merge-generics replace warn-override-core warn last)
  #:export (.width .height .current .previous-idx))

(define-wlr-types-class wlr-damage-ring ()
  (width #:accessor .width)
  (height #:accessor .height)
  (current #:accessor .current)
  (previous-idx #:accessor .previous-idx)
  #:descriptor %wlr-damage-ring-struct)

(define-wlr-procedure (wlr-damage-ring-init ring)
  (ffi:void "wlr_damage_ring_init" (list '*))
  (% (unwrap-wlr-damage-ring ring)))
(define-wlr-procedure (wlr-damage-ring-finish ring)
  (ffi:void "wlr_damage_ring_finish" (list '*))
  (% (unwrap-wlr-damage-ring ring)))
(define-wlr-procedure (wlr-damage-ring-set-bounds ring width height)
  (ffi:void "wlr_damage_ring_set_bounds" (list '* ffi:int32 ffi:int32))
  (% (unwrap-wlr-damage-ring ring) width height))
(define-wlr-procedure (wlr-damage-ring-add-box ring box)
  (ffi:int8 "wlr_damage_ring_add_box" (list '* '*))
  (not (zero? (% (unwrap-wlr-damage-ring ring) (unwrap-wlr-box box)))))
(define-wlr-procedure (wlr-damage-ring-add-whole ring)
  (ffi:void "wlr_damage_ring_add_whole" (list '*))
  (% (unwrap-wlr-damage-ring ring)))
(define-wlr-procedure (wlr-damage-ring-rotate ring)
  (ffi:void "wlr_damage_ring_rotate" (list '*))
  (% (unwrap-wlr-damage-ring ring)))
