monitor.cpp 810 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #if defined(Hiro_Monitor)
  2. namespace hiro {
  3. auto pMonitor::count() -> uint {
  4. return QApplication::desktop()->screenCount();
  5. }
  6. auto pMonitor::dpi(uint monitor) -> Position {
  7. //Qt does not support per-monitor DPI retrieval
  8. return {
  9. QApplication::desktop()->logicalDpiX(),
  10. QApplication::desktop()->logicalDpiY()
  11. };
  12. }
  13. auto pMonitor::geometry(uint monitor) -> Geometry {
  14. QRect rectangle = QApplication::desktop()->screenGeometry(monitor);
  15. return {rectangle.x(), rectangle.y(), rectangle.width(), rectangle.height()};
  16. }
  17. auto pMonitor::primary() -> uint {
  18. return QApplication::desktop()->primaryScreen();
  19. }
  20. auto pMonitor::workspace(uint monitor) -> Geometry {
  21. if(Monitor::count() == 1) {
  22. return Desktop::workspace();
  23. } else {
  24. return Monitor::geometry(monitor);
  25. }
  26. }
  27. }
  28. #endif