Example #1
0
XWindow * WindowlistMenu::getSelectedWindow() {

  WindowList::const_iterator it = _windowList.begin();
  const WindowList::const_iterator end = _windowList.end();

  XWindow * win = 0;

  unsigned int x = 0;
  for (; it != end; it++) {
    if ( static_cast<unsigned int>(_current_index) == x++ ) {
      win = dynamic_cast<XWindow *>(*it);
    }
  }

  if (0 == win)
    std::cerr << BBTOOL << ": " << "WindowlistMenu: getSelectedWindow--couldn't get window.  this won't turn out well.\n";

  if (_debug && win)
    std::cout << BBTOOL << ": " << "WindowlistMenu: getSelectedWindow: currently-selected window: ["
              << bt::toLocale(win->title()) << "]\n";
  return win;

}
Example #2
0
void WindowlistMenu::showCycleMenu( WindowList theList ) {

  bt::Menu::clear();
  bt::Menu::setTitle(bt::toUnicode(_menu_title));
  if (_menu_title.length() > 0)
    bt::Menu::showTitle();

  _windowList = theList;

  WindowList::const_iterator it;
  const WindowList::const_iterator end = theList.end();

  // first, find out if we have any windows in our list for anything other
  // than the current desktop
  _desktop_nbr = _screen->getDesktopNumber();
  bool onlyThisDesktop = true;
  for (it = theList.begin(); it != end; it++) {
    unsigned int dNbr = (*it)->desktop();
    if ( (dNbr != _desktop_nbr) && (! (*it)->isSticky()) ) {
      onlyThisDesktop = false;
      break;
    }
  }

  // now add the windows to our list
  unsigned int i = 0;

  for (it = theList.begin(); it != end; it++) {
	  XWindow *win = (*it);
	  bt::ustring title = win->title();
	  unsigned int dNbr = win->desktop();
	  bt::ustring newTitle = bt::ellideText(title, 100, bt::toUnicode(" ... "));
	  if (! onlyThisDesktop) {
		  bt::ustring suffix = _screen->getDesktopName(dNbr);
		  if (suffix.size() > 0) {
			  newTitle.append(bt::toUnicode(" ("));
			  newTitle.append(suffix);
			  newTitle.append(bt::toUnicode(")"));
		  }
	  }
	  if (win->iconic()) {
		  newTitle.insert(0, bt::toUnicode("("));
		  newTitle.append(bt::toUnicode(")"));
	  }

	  bt::Menu::insertItem( newTitle, i++ );
  }

  // this is our current window, before cycling.  set it checked as a
  // visual indicator
  bt::Menu::setItemChecked(0, true);

  int x = _config->getNumberValue("cyclemenux", 20);
  int y = _config->getNumberValue("cyclemenuy", 20);

  // now show the menu
  bt::Menu::popup(x, y, false);
  bt::Menu::move(x,y);

  // reset our marker as we will increment it in selectNext...
  _current_index = -1;

  // we don't have anything selected initially, so we need to set the
  // selection to the second one (the first one is the
  // currently-selected window
  selectNext();
  selectNext();

}