From 891f99fe81b5c4584dbf01f7fa9605aac28e5aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Fri, 12 May 2017 17:25:50 +0200 Subject: Correctly detect right-clicks before the first check for updates (mga#20540) It uses exactly the same code as net_applet, see 20410 --- mgaapplet | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mgaapplet') diff --git a/mgaapplet b/mgaapplet index a0ac9048..2f996598 100755 --- a/mgaapplet +++ b/mgaapplet @@ -185,6 +185,11 @@ if ($ENV{DESKTOP_SESSION} =~ /plasma$/i) { $icon->set_title('mgaapplet'); $icon->set_status('STATUS_NOTIFIER_STATUS_ACTIVE'); $icon->register; + # We keep this only as a fallback if the DBusMenu service does not work. + # This way, we are sure that right-clicks will always work. (mga#20540) + $icon->signal_connect(context_menu => sub { + $menu->popup(undef, undef, undef, undef, 0, Gtk3::get_current_event_time()) if $menu; + }); } else { $icon = Gtk3::StatusIcon->new; @@ -227,6 +232,16 @@ shouldStart() or die "$localfile should be set to TRUE: please use --force or -f go2State('delayed'); +# NOTE: Must be called after go2State() above to make sure that +# the menu has already been created, else set_context_menu() will complain. +# When mgaapplet is launched automatically when opening a new session, there +# seems to be some latency with DBus and/or DBusMenu, and when this method +# is called too early, it seems to be blocked. So we add a timer here to call +# it again to make sure that right-click events will be correctly handled by +# DBusMenu. If the registration fails again, then the 'context_menu' signal +# will be emitted and caught above (mga#20540). +Glib::Timeout->add(100, sub { $icon->set_context_menu($menu); 0 }) if $is_plasma; + Glib::Timeout->add_seconds($config{FIRST_CHECK_DELAY}/1000, sub { POSIX::sigprocmask(SIG_UNBLOCK, POSIX::SigSet->new(SIGCHLD)); $SIG{CHLD} = \&harvester; -- cgit v1.2.1