1818# You should have received a copy of the GNU Lesser General Public License along
1919# with this program; if not, see <http://www.gnu.org/licenses/>.
2020from typing import Set , List , Dict
21+ from functools import partial
2122import asyncio
2223import sys
2324import time
25+ import signal
2426
2527import importlib .resources
2628
@@ -294,7 +296,7 @@ def load_css(widget) -> str:
294296
295297 return theme
296298
297- def show_menu (self , _unused , _event ):
299+ def show_menu (self , _unused , event ):
298300 """Show menu at mouse pointer."""
299301 tray_menu = Gtk .Menu ()
300302 theme = self .load_css (tray_menu )
@@ -333,7 +335,8 @@ def show_menu(self, _unused, _event):
333335 tray_menu .add (item )
334336
335337 tray_menu .show_all ()
336- tray_menu .popup_at_pointer (None ) # use current event
338+ tray_menu .popup (None , None , None , None , event .button ,
339+ Gtk .get_current_event_time ())
337340
338341 def emit_notification (self , title , message , priority , error = False ,
339342 notification_id = None ):
@@ -347,6 +350,11 @@ def emit_notification(self, title, message, priority, error=False,
347350 self .send_notification (notification_id , notification )
348351
349352
353+ def signal_handler (app , _signum , _frame ):
354+ event = Gdk .EventButton ()
355+ event .button = 1
356+ app .show_menu (None , event )
357+
350358def main ():
351359 qapp = qubesadmin .Qubes ()
352360 # qapp = qubesadmin.tests.mock_app.MockQubesComplete()
@@ -355,6 +363,9 @@ def main():
355363 app = DevicesTray (
356364 'org.qubes.qui.tray.Devices' , qapp , dispatcher )
357365
366+ signal_handler_wrapper = partial (signal_handler , app )
367+ signal .signal (signal .SIGUSR1 , signal_handler_wrapper )
368+
358369 loop = asyncio .get_event_loop ()
359370 return_code = qui .utils .run_asyncio_and_show_errors (
360371 loop , [asyncio .ensure_future (dispatcher .listen_for_events ())],
0 commit comments