Subject: bug#22000: Patch addressing the menu-bar frame-resize interaction

From: Vivek Dasmohapatra <[email-masked]>
Date: Fri, 12 Oct 2018 19:25:21 +0100 (BST)

>> I might be able to fix it with a style change, if I can defeat the gtk3 
> docs
>> and figure out if/how to set a style property on a widget.
>
> Let's postpone that for the moment.

It's done, see latest patchset.

> Anyway, the primary warning I see is the following:
>
> (emacs:4182): Gtk-WARNING **: gtk_scrolled_window_add(): cannot add non 
> scrollable widget use gtk_scrolled_window_add_with_viewport() instead

Aha! I think I know what's happening. You used to have to add the viewport
manually for widgets that weren't inherently scrollable. I'll add
some #if guarded code for the earlier GTK versions.

> #if GTK_CHECK_VERSION (3, 16, 0)
>  GtkPolicyType menuscroll_policy = GTK_POLICY_EXTERNAL;
> #else
>  GtkPolicyType menuscroll_policy = GTK_POLICY_NEVER;
> #endif
>  ...
>  menuscroll = get_frame_param (f, Qmenu_bar_scrollbar);
>  if (EQ (menuscroll, Qautomatic))
>    menuscroll_policy = GTK_POLICY_AUTOMATIC;
>  else if (EQ (menuscroll, Qalways))
>    menuscroll_policy = GTK_POLICY_ALWAYS;
>
> Doesn't this mean that when a frame has the 'menu-bar-scrollbar'
> parameter set we effectively override the version check above?

Nope - EXTERNAL is the new policy which actually does what we want:
truncated menu bar. That is the default behaviour, except on earlier
GTK versions where we get the current frame-jitter behaviour by default.

We only override if the frame paramter is set to 'always or 'automatic,
neither of which is the default.

> so we always put this into a _scrolled_ window regardless of whether
> GTK can handle that.  That's the crucial problem here.

The problem is that earlier GTK versions need a viewport added explicitly
between the scrollbar and the menubar - that's easy enough to do now that
I know that's what's needed.

> In short: (1) would allow users to specify whether they want a
> scrollable menu bar window.  (2) would allow them to specify whether
> that window should be really scrollable.  And we should make the menu
> bar scrollable and thus provide (1) iff GTK supports it (so GTK 3.8 is
> probably the minimum version where we can do that).  And for GTK < 3.8
> nothing would change at all to what we have now.

I think we can achieve all of the above with a couple of lines to add the 
intermediate viewport for GTK versions that require it. Otherwise we
already have the default behaviour you described (I think).