Skip to content

Commit

Permalink
#3956 wait for handshake to generate the menu
Browse files Browse the repository at this point in the history
this is a workaround for an appindicator bug that ignores all the menu updates once we have called 'set_menu()'
  • Loading branch information
totaam committed Sep 9, 2023
1 parent 57c5baa commit b76cca2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion xpra/client/gtk3/menu_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ def __init__(self, client):
self.menu = None
self.menu_shown = False
self.menu_icon_size = get_icon_size()
self.handshake_menuitem : Callable = self.do_handshake_menuitem
def shortcut():
self.handshake_menuitem = self.menuitem
self.client.after_handshake(shortcut)

def build(self):
if self.menu is None:
Expand Down Expand Up @@ -402,7 +406,7 @@ def after_handshake(self, cb:Callable, *args) -> None:
self.client.after_handshake(cb, *args)


def handshake_menuitem(self, *args, **kwargs) -> Gtk.ImageMenuItem:
def do_handshake_menuitem(self, *args, **kwargs) -> Gtk.ImageMenuItem:
""" Same as menuitem() but this one will be disabled until we complete the server handshake """
mi = self.menuitem(*args, **kwargs)
set_sensitive(mi, False)
Expand Down
11 changes: 8 additions & 3 deletions xpra/client/mixins/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from gi.repository import GLib

from xpra.platform.gui import get_native_tray_classes, get_native_tray_menu_helper_class
from xpra.os_util import bytestostr
from xpra.os_util import bytestostr, WIN32, OSX
from xpra.util import envint, make_instance, ConnectionMessage, XPRA_APP_ID
from xpra.client.base.stub_client_mixin import StubClientMixin
from xpra.log import Logger
Expand Down Expand Up @@ -40,8 +40,13 @@ def init(self, opts) -> None:
if opts.delay_tray:
self.connect("first-ui-received", self.setup_xpra_tray)
else:
#show shortly after the main loop starts running:
GLib.timeout_add(TRAY_DELAY, self.setup_xpra_tray)
if WIN32 or OSX:
# show shortly after the main loop starts running:
GLib.timeout_add(TRAY_DELAY, self.setup_xpra_tray)
else:
# wait for handshake:
# see appindicator bug #3956
self.after_handshake(self.setup_xpra_tray)

def setup_xpra_tray(self, *args) -> None:
log("setup_xpra_tray%s", args)
Expand Down

0 comments on commit b76cca2

Please sign in to comment.