Changeset 103929 in webkit


Ignore:
Timestamp:
Jan 3, 2012 1:17:04 AM (12 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Use gdk_screen_get_monitor_workarea() when available for screenAvailableRect()
https://bugs.webkit.org/show_bug.cgi?id=75435

Reviewed by Martin Robinson.

Source/WebCore:

  • platform/gtk/GtkVersioning.c:

(getScreenCurrentDesktop):
(getScreenWorkArea):
(gdk_screen_get_monitor_workarea): Implement it when GTK+ < 3.3.6.

  • platform/gtk/GtkVersioning.h:
  • platform/gtk/PlatformScreenGtk.cpp:

(WebCore::screenAvailableRect): Use
gdk_screen_get_monitor_workarea() instead of our own
implementation.

Source/WebKit/gtk:

  • GNUmakefile.am: Make sure unit tests link to X11.

Tools:

  • GNUmakefile.am: Make sure DRT links to X11.
  • WebKitTestRunner/GNUmakefile.am: Make sure WTR links to X11.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r103923 r103929  
     12012-01-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Use gdk_screen_get_monitor_workarea() when available for screenAvailableRect()
     4        https://bugs.webkit.org/show_bug.cgi?id=75435
     5
     6        Reviewed by Martin Robinson.
     7
     8        * platform/gtk/GtkVersioning.c:
     9        (getScreenCurrentDesktop):
     10        (getScreenWorkArea):
     11        (gdk_screen_get_monitor_workarea): Implement it when GTK+ < 3.3.6.
     12        * platform/gtk/GtkVersioning.h:
     13        * platform/gtk/PlatformScreenGtk.cpp:
     14        (WebCore::screenAvailableRect): Use
     15        gdk_screen_get_monitor_workarea() instead of our own
     16        implementation.
     17
    1182012-01-02  Kentaro Hara  <haraken@chromium.org>
    219
  • trunk/Source/WebCore/platform/gtk/GtkVersioning.c

    r93854 r103929  
    2222
    2323#include <gtk/gtk.h>
     24
     25#ifdef GDK_WINDOWING_X11
     26#include <X11/Xatom.h>
     27#include <gdk/gdkx.h>
     28#endif
    2429
    2530#if !GTK_CHECK_VERSION(2, 14, 0)
     
    304309#endif // GTK_CHECK_VERSION(2, 22, 0)
    305310
     311#if !GTK_CHECK_VERSION(3, 3, 6)
     312#ifdef GDK_WINDOWING_X11
     313static int getScreenCurrentDesktop(GdkScreen *screen)
     314{
     315    Display *display = GDK_DISPLAY_XDISPLAY(gdk_screen_get_display(screen));
     316    Window rootWindow = XRootWindow(display, GDK_SCREEN_XNUMBER(screen));
     317    Atom currentDesktop = XInternAtom(display, "_NET_CURRENT_DESKTOP", True);
     318
     319    Atom type;
     320    int format;
     321    unsigned long itemsCount, bytesAfter;
     322    unsigned char *returnedData = NULL;
     323    XGetWindowProperty(display, rootWindow, currentDesktop, 0, G_MAXLONG, False, XA_CARDINAL,
     324                       &type, &format, &itemsCount, &bytesAfter, &returnedData);
     325
     326    int workspace = 0;
     327    if (type == XA_CARDINAL && format == 32 && itemsCount > 0)
     328        workspace = (int)returnedData[0];
     329
     330    if (returnedData)
     331        XFree(returnedData);
     332
     333    return workspace;
     334}
     335
     336static void getScreenWorkArea(GdkScreen *screen, GdkRectangle *area)
     337{
     338    Display *display = GDK_DISPLAY_XDISPLAY(gdk_screen_get_display(screen));
     339    Atom workArea = XInternAtom(display, "_NET_WORKAREA", True);
     340
     341    /* Defaults in case of error. */
     342    area->x = 0;
     343    area->y = 0;
     344    area->width = gdk_screen_get_width(screen);
     345    area->height = gdk_screen_get_height(screen);
     346
     347    if (workArea == None)
     348        return;
     349
     350    Window rootWindow = XRootWindow(display, GDK_SCREEN_XNUMBER(screen));
     351    Atom type;
     352    int format;
     353    unsigned long itemsCount, bytesAfter;
     354    unsigned char *returnedData = 0;
     355    int result = XGetWindowProperty(display, rootWindow, workArea, 0, 4 * 32 /* Max length */, False, AnyPropertyType,
     356                                    &type, &format, &itemsCount, &bytesAfter, &returnedData);
     357    if (result != Success || type == None || !format || bytesAfter || itemsCount % 4)
     358        return;
     359
     360    int desktop = getScreenCurrentDesktop(screen);
     361    long *workAreas = (long *)returnedData;
     362    area->x = workAreas[desktop * 4];
     363    area->y = workAreas[desktop * 4 + 1];
     364    area->width = workAreas[desktop * 4 + 2];
     365    area->height = workAreas[desktop * 4 + 3];
     366
     367    XFree(returnedData);
     368}
     369#endif // GDK_WINDOWING_X11
     370
     371void gdk_screen_get_monitor_workarea(GdkScreen *screen, int monitor, GdkRectangle *area)
     372{
     373    gdk_screen_get_monitor_geometry(screen, monitor, area);
     374
     375#ifdef GDK_WINDOWING_X11
     376    GdkRectangle workArea;
     377    getScreenWorkArea(screen, &workArea);
     378    gdk_rectangle_intersect(&workArea, area, area);
     379#endif
     380}
     381#endif // GTK_CHECK_VERSION(3, 3, 6)
  • trunk/Source/WebCore/platform/gtk/GtkVersioning.h

    r95901 r103929  
    118118#endif
    119119
     120#if !GTK_CHECK_VERSION(3, 3, 6)
     121void gdk_screen_get_monitor_workarea(GdkScreen *, int monitor, GdkRectangle *area);
     122#endif
     123
    120124G_END_DECLS
    121125
  • trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp

    r102802 r103929  
    3939
    4040#include <gtk/gtk.h>
    41 
    42 #if PLATFORM(X11)
    43 #include <gdk/gdkx.h>
    44 #include <X11/Xatom.h>
    45 #endif
    4641
    4742namespace WebCore {
     
    135130        return FloatRect();
    136131
    137 #if PLATFORM(X11)
    138132    GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformPageClient());
    139133    if (container && !gtk_widget_get_realized(container))
     
    144138        return FloatRect();
    145139
    146     GdkWindow* rootWindow = gdk_screen_get_root_window(screen);
    147     GdkDisplay* display = gdk_window_get_display(rootWindow);
    148     Atom xproperty = gdk_x11_get_xatom_by_name_for_display(display, "_NET_WORKAREA");
     140    gint monitor = container ? gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(container)) : 0;
    149141
    150     Atom retType;
    151     int retFormat;
    152     long *workAreaPos = NULL;
    153     unsigned long retNItems;
    154     unsigned long retAfter;
    155     int xRes = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XWINDOW(rootWindow), xproperty,
    156         0, 4, FALSE, XA_CARDINAL, &retType, &retFormat, &retNItems, &retAfter, (guchar**)&workAreaPos);
     142    GdkRectangle workArea;
     143    gdk_screen_get_monitor_workarea(screen, monitor, &workArea);
    157144
    158     FloatRect rect;
    159     if (xRes == Success && workAreaPos != NULL && retType == XA_CARDINAL && retNItems == 4 && retFormat == 32) {
    160         rect = FloatRect(workAreaPos[0], workAreaPos[1], workAreaPos[2], workAreaPos[3]);
    161         // rect contains the available space in the whole screen not just in the monitor
    162         // containing the widget, so we intersect it with the monitor rectangle.
    163         rect.intersect(screenRect(widget));
    164     } else
    165         rect = screenRect(widget);
     145    return FloatRect(workArea.x, workArea.y, workArea.width, workArea.height);
    166146
    167     if (workAreaPos)
    168         XFree(workAreaPos);
    169 
    170     return rect;
    171 #else
    172     return screenRect(widget);
    173 #endif
    174147}
    175148
  • trunk/Source/WebKit/gtk/ChangeLog

    r103321 r103929  
     12012-01-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Use gdk_screen_get_monitor_workarea() when available for screenAvailableRect()
     4        https://bugs.webkit.org/show_bug.cgi?id=75435
     5
     6        Reviewed by Martin Robinson.
     7
     8        * GNUmakefile.am: Make sure unit tests link to X11.
     9
    1102011-12-20  Yuta Kitamura  <yutak@chromium.org>
    211
  • trunk/Source/WebKit/gtk/GNUmakefile.am

    r102448 r103929  
    421421        $(GLIB_CFLAGS) \
    422422        $(GTK_CFLAGS) \
    423         $(LIBSOUP_CFLAGS)
     423        $(LIBSOUP_CFLAGS) \
     424        $(XRENDER_LIBS) \
     425        $(XT_LIBS)
    424426
    425427webkit_tests_ldadd = \
  • trunk/Tools/ChangeLog

    r103928 r103929  
     12012-01-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Use gdk_screen_get_monitor_workarea() when available for screenAvailableRect()
     4        https://bugs.webkit.org/show_bug.cgi?id=75435
     5
     6        Reviewed by Martin Robinson.
     7
     8        * GNUmakefile.am: Make sure DRT links to X11.
     9        * WebKitTestRunner/GNUmakefile.am: Make sure WTR links to X11.
     10
    1112011-12-04  Philippe Normand  <pnormand@igalia.com>
    212
  • trunk/Tools/GNUmakefile.am

    r103038 r103929  
    159159        $(LIBSOUP_LIBS) \
    160160        $(FREETYPE_LIBS) \
    161         $(WINMM_LIBS)
     161        $(WINMM_LIBS) \
     162        $(XRENDER_LIBS) \
     163        $(XT_LIBS)
    162164
    163165Programs_DumpRenderTree_LDFLAGS = \
  • trunk/Tools/WebKitTestRunner/GNUmakefile.am

    r101710 r103929  
    5252        $(LIBSOUP_LIBS) \
    5353        $(FREETYPE_LIBS) \
    54         $(WINMM_LIBS)
     54        $(WINMM_LIBS) \
     55        $(XRENDER_LIBS) \
     56        $(XT_LIBS)
    5557
    5658Programs_WebKitTestRunner_LDFLAGS = \
Note: See TracChangeset for help on using the changeset viewer.