Skip to content

Commit

Permalink
#1707: keep track of when we modify the tray icon, so we don't overwr…
Browse files Browse the repository at this point in the history
…ite it with the startup reset code

git-svn-id: https://xpra.org/svn/Xpra/trunk@19719 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 26, 2018
1 parent 2857164 commit d0814db
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/xpra/client/gtk_base/statusicon_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# A tray implemented using gtk.StatusIcon

import os
from xpra.os_util import WIN32, OSX, POSIX, PYTHON3
from xpra.os_util import WIN32, OSX, POSIX, PYTHON3, monotonic_time
from xpra.util import envbool
from xpra.gtk_common.gobject_compat import import_gtk, import_gdk
gtk = import_gtk()
Expand Down Expand Up @@ -177,6 +177,7 @@ def set_icon_from_pixbuf(self, tray_icon):
else:
tray_icon = tray_icon.scale_simple(tw, th, INTERP_HYPER)
self.tray_widget.set_from_pixbuf(tray_icon)
self.icon_timestamp = monotonic_time()


def main():
Expand Down
12 changes: 9 additions & 3 deletions src/xpra/client/mixins/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ def setup_xpra_tray(*args):
self.tray = self.setup_xpra_tray(self.tray_icon or "xpra")
if self.tray:
self.tray.show()
#re-set the icon after a short delay,
#seems to help with buggy tray geometries:
self.timeout_add(1000, self.tray.set_icon)
icon_timestamp = self.tray.icon_timestamp
def reset_icon():
#re-set the icon after a short delay,
#seems to help with buggy tray geometries,
#but don't do it if we have already changed the icon
#(ie: the dynamic window icon code may have set a new one)
if icon_timestamp==self.tray.icon_timestamp:
self.tray.set_icon()
self.timeout_add(1000, reset_icon)
if self.delay_tray:
self.connect("first-ui-received", setup_xpra_tray)
else:
Expand Down
3 changes: 3 additions & 0 deletions src/xpra/client/tray_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from xpra.platform.paths import get_icon_filename
from xpra.log import Logger
from xpra.os_util import monotonic_time
from collections import deque
log = Logger("tray")

Expand All @@ -31,6 +32,7 @@ def __init__(self, _client, app_id, menu, tooltip, icon_filename, size_changed_c
self.geometry_guess = None
self.tray_event_locations = deque(maxlen=512)
self.default_icon_extension = "png"
self.icon_timestamp = 0

def __repr__(self):
return "Tray(%i:%s)" % (self.app_id, self.tooltip)
Expand Down Expand Up @@ -91,6 +93,7 @@ def set_icon_from_file(self, filename):
if not self.tray_widget:
return
self.do_set_icon_from_file(filename)
self.icon_timestamp = monotonic_time()

def do_set_icon_from_file(self, filename):
raise Exception("override me!")
Expand Down
3 changes: 3 additions & 0 deletions src/xpra/platform/darwin/osx_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from xpra.log import Logger
log = Logger("tray", "osx")

from xpra.os_util import monotonic_time
from xpra.client.tray_base import TrayBase
from xpra.gtk_common.gtk_util import pixbuf_new_from_data, pixbuf_new_from_file, COLORSPACE_RGB
from xpra.platform.darwin.osx_menu import getOSXMenuHelper
Expand Down Expand Up @@ -68,12 +69,14 @@ def set_blinking(self, on):
def set_icon_from_data(self, pixels, has_alpha, w, h, rowstride, options={}):
tray_icon = pixbuf_new_from_data(pixels, COLORSPACE_RGB, has_alpha, 8, w, h, rowstride)
self.macapp.set_dock_icon_pixbuf(tray_icon)
self.icon_timestamp = monotonic_time()

def do_set_icon_from_file(self, filename):
if not self.macapp:
return
pixbuf = pixbuf_new_from_file(filename)
self.macapp.set_dock_icon_pixbuf(pixbuf)
self.icon_timestamp = monotonic_time()


def set_global_menu(self):
Expand Down
3 changes: 3 additions & 0 deletions src/xpra/platform/win32/win32_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from xpra.log import Logger
log = Logger("tray", "win32")

from xpra.os_util import monotonic_time
from xpra.platform.win32 import constants as win32con
from xpra.platform.win32.gui import EnumDisplayMonitors, GetMonitorInfo
from xpra.platform.win32.win32_NotifyIcon import win32NotifyIcon
Expand Down Expand Up @@ -86,10 +87,12 @@ def set_tooltip(self, name):
def set_icon_from_data(self, pixels, has_alpha, w, h, rowstride, options={}):
if self.tray_widget:
self.tray_widget.set_icon_from_data(pixels, has_alpha, w, h, rowstride, options)
self.icon_timestamp = monotonic_time()

def do_set_icon_from_file(self, filename):
if self.tray_widget:
self.tray_widget.set_icon(filename)
self.icon_timestamp = monotonic_time()

def set_blinking(self, on):
if self.tray_widget:
Expand Down
3 changes: 2 additions & 1 deletion src/xpra/platform/xposix/appindicator_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
log = Logger("tray", "posix")

from xpra.util import envbool
from xpra.os_util import is_unity
from xpra.os_util import is_unity, monotonic_time
from xpra.client.tray_base import TrayBase
from xpra.platform.paths import get_icon_dir, get_icon_filename

Expand Down Expand Up @@ -109,6 +109,7 @@ def do_set_icon_from_file(self, filename):
log("do_set_icon_from_file(%s) setting icon=%s", filename, noext)
self.tray_widget.set_icon(noext)
self._has_icon = True
self.icon_timestamp = monotonic_time()


def main():
Expand Down

0 comments on commit d0814db

Please sign in to comment.