Ejemplo n.º 1
0
Blackbox::Blackbox(char **m_argv, const char *dpy_name,
                   const std::string& rc, bool multi_head)
  : bt::Application(m_argv[0], dpy_name, multi_head),
    grab_count(0u), _resource(rc)
{
  if (! XSupportsLocale())
    fprintf(stderr, _("X server does not support locale\n"));

  if (XSetLocaleModifiers("") == NULL)
    fprintf(stderr, _("cannot set locale modifiers\n"));

  argv = m_argv;

  active_screen = 0;
  focused_window = (BlackboxWindow *) 0;
  _ewmh = (bt::EWMH*) 0;

  init_icccm();

  if (! multi_head || display().screenCount() == 1)
    screen_list_count = 1;
  else
    screen_list_count = display().screenCount();

  _resource.load(*this);

  screen_list = new BScreen*[screen_list_count];
  unsigned int managed = 0;
  for (unsigned int i = 0; i < screen_list_count; ++i) {
    BScreen *screen = new BScreen(this, i);

    if (! screen->isScreenManaged()) {
      delete screen;
      continue;
    }

    screen_list[i] = screen;
    ++managed;
  }

  if (managed == 0) {
    fprintf(stderr, _("%s: no manageable screens found, exiting...\n"),
            applicationName().c_str());
    ::exit(3);
  }

  screen_list_count = managed;

  // start with the first managed screen as the active screen
  setActiveScreen(screen_list[0]);

  XSynchronize(XDisplay(), false);
  XSync(XDisplay(), false);

  timer = new bt::Timer(this, this);
  timer->setTimeout(0l);
}