-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Menus spawned by layershell clients are not size constrained #148
Comments
I can't reproduce the "correct" behavior, even without layer shell. For me this simplified script (with all the manual overflow handling and layer shell stuff removed) overflows the screen without any scroll buttons. I'm using GTK v3.24.33 and Sway v1.7: #!/usr/bin/env python3
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
class Window(Gtk.Window):
def __init__(self):
super().__init__()
menu_item = self.overflow_menu()
self.tray = Gtk.MenuBar()
self.tray.add(Gtk.MenuItem(label="Empty"))
self.tray.add(menu_item)
self.add(self.tray)
self.set_default_size(200, -1)
self.show_all()
def overflow_menu(self):
overflow_menu = Gtk.Menu()
for i in range(200):
overflow_menu.add(Gtk.MenuItem(label=f"Overflow-{i:>3d}"))
overflow_item = Gtk.MenuItem(label="Overflow")
overflow_item.set_submenu(overflow_menu)
return overflow_item
def main():
win = Window()
win.connect('destroy', Gtk.main_quit)
try:
Gtk.main()
except KeyboardInterrupt:
print()
if __name__ == '__main__':
main() Interestingly setting |
Just tested your modified version again on labwc (also wlroots based) and it constrains the menu correctly for me on Gtk 3.24.24. |
Once a menu gets larger than the screen it will not restrict its size to
gdk_monitor_get_workarea()
like GTK usually seems to do when not using layershell.I've added a reproducer based on an implementation by @LBCrion for sfwbar below.
If changing
use_layershell=True
toFalse
in the bottom, the usual GTK behavior kicks in which constrains the menu window to the workspace size and adds scroll buttons. If that boolean is kept asTrue
instead, the window will be used as a layershell window and an additional_clamp_menu()
callback will be installed. Without that callback (e.g. by removing theconnect()
call or stubbing out_clamp_menu()
) the issue become visible.I am not sure if this can (and should) be handled by gtk-layer-shell internally or if that is something that users of the library have to take care of. In the second case it should likely be documented somewhere that this might be required depending on the expected menu sizes.
Ref: LBCrion/sfwbar#75
Ref: LBCrion/sfwbar@760e68e
Python reproducer:
The text was updated successfully, but these errors were encountered: