xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #724: tray-mixed-clicks.patch

File tray-mixed-clicks.patch, 3.6 KB (added by Antoine Martin, 7 years ago)

proposed fix

  • src/xpra/client/gtk_base/gtk_tray_menu_base.py

    ### Eclipse Workspace Patch 1.0
    #P Xpra
     
    5050SPEED_OPTIONS[100]  = "Lowest Latency"
    5151
    5252
     53def TrayCheckMenuItem(*args):
     54    """ We add a button handler to catch clicks that somehow do not
     55        trigger the "toggled" signal on some platforms (win32?) when we
     56        show the tray menu with a right click and click on the item with the left click.
     57        (or the other way around?)
     58    """
     59    c = CheckMenuItem(*args)
     60    def on_button_press_event(*args):
     61        log.info("on_button_press_event%s", args)
     62        c.toggled()
     63    c.add_events(gtk.gdk.BUTTON_PRESS_MASK)
     64    c.connect("button-press-event", on_button_press_event)
     65    return c
     66
     67
    5368def make_min_auto_menu(title, min_options, options, get_current_min_value, get_current_value, set_min_value_cb, set_value_cb):
    5469    #note: we must keep references to the parameters on the submenu
    5570    #(closures and gtk callbacks don't mix so well!)
     
    7085            options[value] = "%s%%" % value
    7186        for s in sorted(options.keys()):
    7287            t = options.get(s)
    73             qi = CheckMenuItem(t)
     88            qi = TrayCheckMenuItem(t)
    7489            qi.set_draw_as_radio(True)
    7590            candidate_match = s>=max(0, value)
    7691            qi.set_active(not found_match and candidate_match)
     
    153168        name = ENCODINGS_TO_NAME.get(encoding, encoding)
    154169        descr = ENCODINGS_HELP.get(encoding)
    155170        NAME_TO_ENCODING[name] = encoding
    156         encoding_item = CheckMenuItem(name)
     171        encoding_item = TrayCheckMenuItem(name)
    157172        if descr:
    158173            if encoding not in server_encodings:
    159174                descr += "\n(not available on this server)"
     
    292307        return menuitem(title, image, tooltip, cb)
    293308
    294309    def checkitem(self, title, cb=None, active=False):
    295         """ Utility method for easily creating a CheckMenuItem """
    296         check_item = CheckMenuItem(title)
     310        """ Utility method for easily creating a TrayCheckMenuItem """
     311        check_item = TrayCheckMenuItem(title)
    297312        check_item.set_active(active)
    298313        if cb:
    299314            check_item.connect("toggled", cb)
     
    436451                            "Secondary" : "SECONDARY"}
    437452            from xpra.clipboard.translated_clipboard import TranslatedClipboardProtocolHelper
    438453            for label, remote_clipboard in LABEL_TO_NAME.items():
    439                 clipboard_item = CheckMenuItem(label)
     454                clipboard_item = TrayCheckMenuItem(label)
    440455                def remote_clipboard_changed(item):
    441456                    assert can_clipboard
    442457                    item = ensure_item_selected(clipboard_submenu, item)
     
    715730        menu = gtk.Menu()
    716731        menu.ignore_events = False
    717732        def onoffitem(label, active, cb):
    718             c = CheckMenuItem(label)
     733            c = TrayCheckMenuItem(label)
    719734            c.set_draw_as_radio(True)
    720735            c.set_active(active)
    721736            def submenu_uncheck(item, menu):
     
    855870                log("setting compression level to %s", c)
    856871                self.client.set_deflate_level(c)
    857872        for i in range(0, 10):
    858             c = CheckMenuItem(str(compression_options.get(i, i)))
     873            c = TrayCheckMenuItem(str(compression_options.get(i, i)))
    859874            c.set_draw_as_radio(True)
    860875            c.set_active(i==self.client.compression_level)
    861876            c.connect('activate', set_compression)