Changeset 259944 in webkit


Ignore:
Timestamp:
Apr 12, 2020 2:28:45 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Use gdk_window_move_to_rect() to position popup menus
https://bugs.webkit.org/show_bug.cgi?id=210069

Reviewed by Michael Catanzaro.

  • UIProcess/gtk/WebPopupMenuProxyGtk.cpp:

(WebKit::WebPopupMenuProxyGtk::showPopupMenu):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259943 r259944  
     12020-04-12  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Use gdk_window_move_to_rect() to position popup menus
     4        https://bugs.webkit.org/show_bug.cgi?id=210069
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        * UIProcess/gtk/WebPopupMenuProxyGtk.cpp:
     9        (WebKit::WebPopupMenuProxyGtk::showPopupMenu):
     10
    1112020-04-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    212
  • trunk/Source/WebKit/UIProcess/gtk/WebPopupMenuProxyGtk.cpp

    r246677 r259944  
    253253        return;
    254254
     255    auto* toplevel = gtk_widget_get_toplevel(m_webView);
     256    if (GTK_IS_WINDOW(toplevel)) {
     257        gtk_window_set_transient_for(GTK_WINDOW(m_popup), GTK_WINDOW(toplevel));
     258        gtk_window_group_add_window(gtk_window_get_group(GTK_WINDOW(toplevel)), GTK_WINDOW(m_popup));
     259    }
     260    gtk_window_set_attached_to(GTK_WINDOW(m_popup), m_webView);
     261    gtk_window_set_screen(GTK_WINDOW(m_popup), gtk_widget_get_screen(m_webView));
     262
    255263    auto* display = gtk_widget_get_display(m_webView);
    256264    auto* monitor = gdk_display_get_monitor_at_window(display, gtk_widget_get_window(m_webView));
     
    269277    gtk_scrolled_window_set_min_content_height(swindow, itemCount * itemHeight);
    270278
     279    IntPoint menuPosition = convertWidgetPointToScreenPoint(m_webView, rect.location());
     280#if GTK_CHECK_VERSION(3, 24, 0)
     281    GdkRectangle windowRect = { menuPosition.x(), menuPosition.y(), rect.width(), rect.height() };
     282    gdk_window_move_to_rect(gtk_widget_get_window(m_popup), &windowRect, GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST,
     283        static_cast<GdkAnchorHints>(GDK_ANCHOR_FLIP | GDK_ANCHOR_SLIDE | GDK_ANCHOR_RESIZE), 0, 0);
     284#else
    271285    GtkRequisition menuRequisition;
    272286    gtk_widget_get_preferred_size(m_popup, &menuRequisition, nullptr);
    273     IntPoint menuPosition = convertWidgetPointToScreenPoint(m_webView, rect.location());
    274     // FIXME: We can't ensure the menu will be on screen in Wayland.
    275     // https://blog.gtk.org/2016/07/15/future-of-relative-window-positioning/
    276     // https://gitlab.gnome.org/GNOME/gtk/issues/997
     287
    277288    if (menuPosition.x() + menuRequisition.width > area.x + area.width)
    278289        menuPosition.setX(area.x + area.width - menuRequisition.width);
     
    284295        menuPosition.move(0, -menuRequisition.height);
    285296    gtk_window_move(GTK_WINDOW(m_popup), menuPosition.x(), menuPosition.y());
    286 
    287     auto* toplevel = gtk_widget_get_toplevel(m_webView);
    288     if (GTK_IS_WINDOW(toplevel)) {
    289         gtk_window_set_transient_for(GTK_WINDOW(m_popup), GTK_WINDOW(toplevel));
    290         gtk_window_group_add_window(gtk_window_get_group(GTK_WINDOW(toplevel)), GTK_WINDOW(m_popup));
    291     }
    292     gtk_window_set_attached_to(GTK_WINDOW(m_popup), m_webView);
    293     gtk_window_set_screen(GTK_WINDOW(m_popup), gtk_widget_get_screen(m_webView));
     297#endif
    294298
    295299    const GdkEvent* event = m_client->currentlyProcessedMouseDownEvent() ? m_client->currentlyProcessedMouseDownEvent()->nativeEvent() : nullptr;
Note: See TracChangeset for help on using the changeset viewer.