diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 3952098ad41..27876e02df0 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -263,10 +263,37 @@ RECT get_work_area(const RECT *monitor_rect) { Atom type; int format; - unsigned long count, remaining; + unsigned long count, remaining, i; long *work_area; RECT work_rect; + /* Try _GTK_WORKAREAS first as _NET_WORKAREA may be incorrect on multi-monitor systems */ + if (!XGetWindowProperty(gdi_display, DefaultRootWindow(gdi_display), + x11drv_atom(_GTK_WORKAREAS_D0), 0, ~0, False, XA_CARDINAL, &type, + &format, &count, &remaining, (unsigned char **)&work_area)) + { + if (type == XA_CARDINAL && format == 32 && count >= 4) + { + for (i = 0; i + 3 < count; i += 4) + { + work_rect.left = work_area[i * 4]; + work_rect.top = work_area[i * 4 + 1]; + work_rect.right = work_rect.left + work_area[i * 4 + 2]; + work_rect.bottom = work_rect.top + work_area[i * 4 + 3]; + + if (IntersectRect(&work_rect, &work_rect, monitor_rect)) + { + TRACE("work_rect:%s.\n", wine_dbgstr_rect(&work_rect)); + XFree(work_area); + return work_rect; + } + } + } + XFree(work_area); + } + + WARN("_GTK_WORKAREAS is not supported, fallback to _NET_WORKAREA. " + "Work areas may be incorrect on multi-monitor systems.\n"); if (!XGetWindowProperty(gdi_display, DefaultRootWindow(gdi_display), x11drv_atom(_NET_WORKAREA), 0, ~0, False, XA_CARDINAL, &type, &format, &count, &remaining, (unsigned char **)&work_area)) diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 328b9561ae4..9bbb48f1eeb 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -464,6 +464,7 @@ enum x11drv_atoms XATOM__NET_WM_WINDOW_TYPE_NORMAL, XATOM__NET_WM_WINDOW_TYPE_UTILITY, XATOM__NET_WORKAREA, + XATOM__GTK_WORKAREAS_D0, XATOM__XEMBED, XATOM__XEMBED_INFO, XATOM_XdndAware, diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index e6e61e801e1..9ec4c7a98f6 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -177,6 +177,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] = "_NET_WM_WINDOW_TYPE_NORMAL", "_NET_WM_WINDOW_TYPE_UTILITY", "_NET_WORKAREA", + "_GTK_WORKAREAS_D0", "_XEMBED", "_XEMBED_INFO", "XdndAware",