Skip to content

[Global Menu] Make dynamically inserted items appear instantly

Zhenge Chen requested to merge amnore/plasma-workspace:master into master

Currently the global menu have problems with dynamically inserted items, which doesn't appear until switching to another window and back. I did some debugging and identified three places causing this:

  1. In gmenu-dbusmenu-proxy, the proxy expands all sections in a menu when it is requested. However, when the Changed signal is received for a section from the gtk side, the proxy only emits the LayoutChanged signal for that section. Because the global menu widget doesn't know about sections, the menu isn't updated.

  2. Also in gmenu-dbusmenu-proxy, a submenu and its item in top level menu have two different ids, while at the widget side, they have the same id. Currently the proxy uses the item's id, but when a Changed signal is received and forwarded for the submenu (with the submenu's id), the menu is, again, not updated, because the widget doesn't know about the submenu's id.

  3. In libdbusmenuqt, the code seems to assume that a LayoutChanged signal will be sent when AboutToShow() is called, but I did not observe that when debugging. When a LayoutChanged signal is sent later after a submenu updates, it is ignored for the first time. This causes a submenu not updated when adding an item for the first time.

I've made the following changes to fix the issues:

  1. When a Changed signal is received, menu proxy will also emit a LayoutChanged signal for the top level menu containing the changed section. The code assumes that All sections are within the same group.

  2. Use the submenu's id instead of item's id to match the id in LayoutChanged signal.

  3. Remove the part which causes the LayoutChanged signal to be ignored for the first time.

I updated the test program in libdbusmenuqt to test the changes. There is also a gtk program I'm using when debugging, but I did not add it because it requires gtk to compile. I'm attaching it below.

gtk.c

Edited by Zhenge Chen

Merge request reports