Changeset 252898 in webkit


Ignore:
Timestamp:
Nov 27, 2019 2:19:38 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] WebDriver: moving toplevel windows is not supported under wayland
https://bugs.webkit.org/show_bug.cgi?id=204614

Reviewed by Alejandro G. Castro.

So we can stop trying and simply ignore the requests to move the window.

  • UIProcess/API/glib/WebKitUIClient.cpp:

(UIClient::windowConfigureEventCallback): Ensure we only move or resize when actually required and reduce the
time we wait for configure events to 200ms (1 second was too long).

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r252893 r252898  
     12019-11-27  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WebDriver: moving toplevel windows is not supported under wayland
     4        https://bugs.webkit.org/show_bug.cgi?id=204614
     5
     6        Reviewed by Alejandro G. Castro.
     7
     8        So we can stop trying and simply ignore the requests to move the window.
     9
     10        * UIProcess/API/glib/WebKitUIClient.cpp:
     11        (UIClient::windowConfigureEventCallback): Ensure we only move or resize when actually required and reduce the
     12        time we wait for configure events to 200ms (1 second was too long).
     13
    1142019-11-26  Antti Koivisto  <antti@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp

    r252492 r252898  
    3636#include "WebProcessProxy.h"
    3737#include "WebsiteDataStore.h"
     38#include <WebCore/PlatformDisplay.h>
    3839#include <wtf/glib/GRefPtr.h>
    3940#include <wtf/glib/RunLoopSourcePriority.h>
     
    143144    {
    144145        GdkRectangle geometry = { 0, 0, 0, 0 };
    145         gtk_window_get_position(window, &geometry.x, &geometry.y);
     146        // Position a toplevel window is not supported under wayland.
     147        if (WebCore::PlatformDisplay::sharedDisplay().type() != WebCore::PlatformDisplay::Type::Wayland) {
     148            gtk_window_get_position(window, &geometry.x, &geometry.y);
     149            if (geometry.x != targetGeometry->x || geometry.y != targetGeometry->y)
     150                return FALSE;
     151        }
     152
    146153        gtk_window_get_size(window, &geometry.width, &geometry.height);
    147         if (geometry.x == targetGeometry->x && geometry.y == targetGeometry->y && geometry.width == targetGeometry->width && geometry.height == targetGeometry->height)
    148             RunLoop::current().stop();
    149 
     154        if (geometry.width != targetGeometry->width || geometry.height != targetGeometry->height)
     155            return FALSE;
     156
     157        RunLoop::current().stop();
    150158        return FALSE;
    151159    }
     
    163171        GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
    164172        if (webkit_web_view_is_controlled_by_automation(m_webView) && WebCore::widgetIsOnscreenToplevelWindow(window) && gtk_widget_get_visible(window)) {
    165             if ((geometry.x < 0 || geometry.y < 0) && (geometry.width <= 0 || geometry.height <= 0))
     173            bool needsMove = false;
     174            // Position a toplevel window is not supported under wayland.
     175            if (WebCore::PlatformDisplay::sharedDisplay().type() != WebCore::PlatformDisplay::Type::Wayland) {
     176                if (geometry.x >= 0 && geometry.y >= 0) {
     177                    int x, y;
     178                    gtk_window_get_position(GTK_WINDOW(window), &x, &y);
     179                    needsMove = x != geometry.x || y != geometry.y;
     180                }
     181            }
     182
     183            bool needsResize = false;
     184            if (geometry.width > 0 && geometry.height > 0) {
     185                int width, height;
     186                gtk_window_get_size(GTK_WINDOW(window), &width, &height);
     187                needsResize = width != geometry.width || height != geometry.height;
     188            }
     189
     190            if (!needsMove && !needsResize)
    166191                return;
    167192
    168193            auto signalID = g_signal_connect(window, "configure-event", G_CALLBACK(windowConfigureEventCallback), &geometry);
    169             if (geometry.x >= 0 && geometry.y >= 0)
     194            if (needsMove)
    170195                gtk_window_move(GTK_WINDOW(window), geometry.x, geometry.y);
    171             if (geometry.width > 0 && geometry.height > 0)
     196            if (needsResize)
    172197                gtk_window_resize(GTK_WINDOW(window), geometry.width, geometry.height);
    173198
    174199            // We need the move/resize to happen synchronously in automation mode, so we use a nested RunLoop
    175             // to wait, up top 1 second, for the configure events.
     200            // to wait, up top 200 milliseconds, for the configure events.
    176201            auto timer = makeUnique<RunLoop::Timer<UIClient>>(RunLoop::main(), this, &UIClient::setWindowFrameTimerFired);
    177202            timer->setPriority(RunLoopSourcePriority::RunLoopTimer);
    178             timer->startOneShot(1_s);
     203            timer->startOneShot(200_ms);
    179204            RunLoop::run();
    180205            timer = nullptr;
Note: See TracChangeset for help on using the changeset viewer.