|  | 
| 3 | 3 | namespace hiro { | 
| 4 | 4 | 
 | 
| 5 | 5 | auto pDesktop::size() -> Size { | 
| 6 |  | -  #if defined(DISPLAY_WINDOWS) | 
| 7 |  | -  return {GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)}; | 
| 8 |  | -  #elif defined(DISPLAY_XORG) | 
| 9 |  | -  auto display = XOpenDisplay(nullptr); | 
| 10 |  | -  int screen = DefaultScreen(display); | 
| 11 |  | -  XWindowAttributes attributes; | 
| 12 |  | -  XGetWindowAttributes(display, RootWindow(display, screen), &attributes); | 
| 13 |  | -  XCloseDisplay(display); | 
| 14 |  | -  return {attributes.width, attributes.height}; | 
| 15 |  | -  #else | 
| 16 |  | -  //this only returns the geometry of the primary monitor rather than the entire desktop | 
| 17 |  | -  QRect rect = QApplication::desktop()->screenGeometry(); | 
|  | 6 | +  QRect rect; | 
|  | 7 | +  for(QScreen* screen : QApplication::screens()) { | 
|  | 8 | +    rect = rect.united(screen->geometry()); | 
|  | 9 | +  } | 
| 18 | 10 |   return {rect.width(), rect.height()}; | 
| 19 |  | -  #endif | 
| 20 | 11 | } | 
| 21 | 12 | 
 | 
| 22 | 13 | auto pDesktop::workspace() -> Geometry { | 
| 23 |  | -  #if defined(DISPLAY_WINDOWS) | 
| 24 |  | -  RECT rc; | 
| 25 |  | -  SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); | 
| 26 |  | -  return {rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top}; | 
| 27 |  | -  #elif defined(DISPLAY_XORG) | 
| 28 |  | -  auto display = XOpenDisplay(nullptr); | 
| 29 |  | -  int screen = DefaultScreen(display); | 
| 30 |  | - | 
| 31 |  | -  int format; | 
| 32 |  | -  unsigned char* data = nullptr; | 
| 33 |  | -  unsigned long items, after; | 
| 34 |  | -  XlibAtom returnAtom; | 
| 35 |  | - | 
| 36 |  | -  XlibAtom netWorkarea = XInternAtom(display, "_NET_WORKAREA", XlibTrue); | 
| 37 |  | -  int result = XGetWindowProperty( | 
| 38 |  | -    display, RootWindow(display, screen), netWorkarea, 0, 4, XlibFalse, | 
| 39 |  | -    XInternAtom(display, "CARDINAL", XlibTrue), &returnAtom, &format, &items, &after, &data | 
| 40 |  | -  ); | 
| 41 |  | - | 
| 42 |  | -  XlibAtom cardinal = XInternAtom(display, "CARDINAL", XlibTrue); | 
| 43 |  | -  if(result == Success && returnAtom == cardinal && format == 32 && items == 4) { | 
| 44 |  | -    unsigned long* workarea = (unsigned long*)data; | 
| 45 |  | -    XCloseDisplay(display); | 
| 46 |  | -    return {(int)workarea[0], (int)workarea[1], (int)workarea[2], (int)workarea[3]}; | 
|  | 14 | +  QRect rect; | 
|  | 15 | +  for(QScreen* screen : QApplication::screens()) { | 
|  | 16 | +    rect = rect.united(screen->geometry()); | 
| 47 | 17 |   } | 
| 48 |  | - | 
| 49 |  | -  XCloseDisplay(display); | 
| 50 |  | -  auto size = Desktop::size(); | 
| 51 |  | -  return {0, 0, size.width(), size.height()}; | 
| 52 |  | -  #else | 
| 53 |  | -  //this only returns the workspace of the primary monitor rather than the entire desktop | 
| 54 |  | -  QRect rect = QApplication::desktop()->availableGeometry(); | 
| 55 | 18 |   return {rect.x(), rect.y(), rect.width(), rect.height()}; | 
| 56 |  | -  #endif | 
| 57 | 19 | } | 
| 58 | 20 | 
 | 
| 59 | 21 | } | 
|  | 
0 commit comments