I assume that you are using Unity. I haven't tested this, but I think that
gsettings set com.canonical.unity-gtk-module blacklist "['emacs25']"
should partially solve the issue — your compiled emacs will no longer use the Global Menu, but its own menu, which should be better-behaved. If needed, you can have a longer list of elements in the blacklist — e.g.
"['emacs25', 'emacs26']". Restart Emacs after executing the above command!
(Possibly first run:
gsettings get com.canonical.unity-gtk-module blacklist
to ensure that the list is empty to begin with, and you're not clobbering anything.)
emacs24 from the default repositories has a hardcoded blacklist, but this does not carry over to
Note: you might need to use the utility
xprop (e.g. with
xprop WM_CLASS — you need the first of the displayed strings) to determine the "WM_CLASS" of your emacs window and use that instead of emacs25.