Exemple #1
0
QRect Window::GetConstrainedShellBounds(const QRect& preferredSize)
{
  QRect result(preferredSize);

  GuiWidgetsTweaklet* guiTweaklet(Tweaklets::Get(GuiWidgetsTweaklet::KEY));
  int screenNum = guiTweaklet->GetClosestScreenNumber(result);
  QRect bounds(guiTweaklet->GetAvailableScreenSize(screenNum));

  if (result.height() > bounds.height()) {
    result.setHeight(bounds.height());
  }

  if (result.width() > bounds.width()) {
    result.setWidth(bounds.width());
  }

  result.moveLeft( std::max<int>(bounds.x(), std::min<int>(result.x(), bounds.x()
    + bounds.width() - result.width())));
  result.moveTop(std::max<int>(bounds.y(), std::min<int>(result.y(), bounds.y()
    + bounds.height() - result.height())));

  return result;
}
Exemple #2
0
Rectangle Window::GetConstrainedShellBounds(const Rectangle& preferredSize) 
{
  Rectangle result(preferredSize);

  GuiWidgetsTweaklet* guiTweaklet(Tweaklets::Get(GuiWidgetsTweaklet::KEY));
  int screenNum = guiTweaklet->GetClosestScreenNumber(result);
  Rectangle bounds(guiTweaklet->GetAvailableScreenSize(screenNum));

  if (result.height > bounds.height) {
    result.height = bounds.height;
  }

  if (result.width > bounds.width) {
    result.width = bounds.width;
  }

  result.x = std::max<int>(bounds.x, std::min<int>(result.x, bounds.x
    + bounds.width - result.width));
  result.y = std::max<int>(bounds.y, std::min<int>(result.y, bounds.y
    + bounds.height - result.height));

  return result;
}