#include <X11/Xlib.h>

#include "background.hh"

namespace uw {
  Background::Background(const std::string &filename)
    : filename(filename), i(s, filename), o(s, i) {
  }

  Background::~Background() {}

  bool Background::setWallpaper(Mode mode) {
    if (mode == Mode::FILL) {
      o.fill();
    } else if (mode == Mode::CENTER) {
      o.center();
    } else if (mode == Mode::TILE) {
      o.tile();
    } else {
      return false;
    }

    XFlush(s.getDisplay());

    return true;
  }
}