#include <X11/Xlib.h>

#include <stdexcept>

#include "screen.hh"

namespace uw {
  Screen::Screen() {
    dp = XOpenDisplay(nullptr);
    if (dp == nullptr) throw std::runtime_error("X画面を開くに失敗。");

    screen = DefaultScreen(dp);
    w = RootWindow(dp, screen);
    extent.width = DisplayWidth(dp, screen);
    extent.height = DisplayHeight(dp, screen);
  }

  Screen::~Screen() {
    XCloseDisplay(dp);
  }
}
