Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-4106

[GTK3] Context menu in editor sporadically shows empty area on scrolling down

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Normal Normal
    • None
    • rhel-7.9.z
    • gtk3
    • None
    • Moderate
    • 5
    • rhel-display-desktop-foundation
    • ssg_display
    • 8
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • DESKTOP Cycle #1 10.beta phase, DESKTOP Cycle #3 10.beta phase, DESKTOP Cycle #4 10.beta phase, DESKTOP Cycle #5 10.beta phase, DESKTOP Cycle #2 10.beta phase
    • None
    • None
    • If docs needed, set a value
    • None
    • 57,005

      Description of problem:

      See Eclipse bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=564910

      Version-Release number of selected component (if applicable):

      GTK 3.22.30-5 (gtk3-3.22.30-5.el7.x86_64)

      How reproducible:

      In Eclipse, reproducible with steps listed here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=564910#c1

      See video attached to the Eclipse bug: https://bugs.eclipse.org/bugs/attachment.cgi?id=287854

      So far we have no GTK+ snippet (or Eclipse SWT only snippet) to reproduce the problem with.

      Actual results:

      Context menu shows ever-growing blank area when scrolling down.

      Expected results:

      Context menu has no blank area when scrolling down.

      Additional info:

      After adding prints, it seems that scroll_offset has very high values while this method runs (when the bug occurs):

      static void
      gtk_menu_scroll_by (GtkMenu *menu,
      gint step)
      {
      GtkMenuPrivate *priv = menu->priv;
      GtkBorder arrow_border;
      GtkWidget *widget;
      gint offset;
      gint view_height;

      widget = GTK_WIDGET (menu);
      offset = priv->scroll_offset + step;

      get_arrows_border (menu, &arrow_border);

      /* Don't scroll over the top if we weren't before: */
      if ((priv->scroll_offset >= 0) && (offset < 0))
      offset = 0;

      view_height = gdk_window_get_height (gtk_widget_get_window (widget));

      if (priv->scroll_offset == 0 &&
      view_height >= priv->requested_height)
      return;

      /* Don't scroll past the bottom if we weren't before: */
      if (priv->scroll_offset > 0)
      view_height -= arrow_border.top;

      /* Since arrows are shown, reduce view height even more */
      view_height -= arrow_border.bottom;

      if ((priv->scroll_offset + view_height <= priv->requested_height) &&
      (offset + view_height > priv->requested_height))
      offset = priv->requested_height - view_height;

      if (offset != priv->scroll_offset)
      gtk_menu_scroll_to (menu, offset);
      }

      While checking the GTK+ code in gtkmenu.c, I noticed this bug and patch:

      https://bugzilla.gnome.org/show_bug.cgi?id=678113
      https://github.com/GNOME/gtk/commit/bd3ca2b30efc534f8b7c18dfd8a9f072592044c7

      After adding clamping to the method above, the blank area of the menu was reduced to only 1 blank item at most (while not ideal, still a lot better than before, see attached video "bug564910_gtkmenu_offset_clamp.mp4"):

      diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
      index 8f7715022f..09cbec26ab 100644
      — a/gtk/gtkmenu.c
      +++ b/gtk/gtkmenu.c
      @@ -4175,7 +4175,12 @@ gtk_menu_scroll_by (GtkMenu *menu,
      offset = priv->requested_height - view_height;

      if (offset != priv->scroll_offset)
      +

      { + offset = CLAMP (offset, + MIN (priv->scroll_offset, 0), + MAX (priv->scroll_offset, priv->requested_height - view_height)); gtk_menu_scroll_to (menu, offset); + }

      }

      static gboolean

              mclasen@redhat.com Matthias Clasen
              jira-bugzilla-migration RH Bugzilla Integration
              Matthias Clasen Matthias Clasen
              Radek Duda Radek Duda
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: