From 7e829c1bad21f53755239d4d3d0b85a141930303 Mon Sep 17 00:00:00 2001 From: croneter Date: Wed, 1 May 2019 08:56:11 +0200 Subject: [PATCH] Refresh widgets only on homescreen to prevent cursor from jumping within libraries --- resources/lib/app/application.py | 2 ++ resources/lib/library_sync/common.py | 9 +++++++-- resources/lib/service_entry.py | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/resources/lib/app/application.py b/resources/lib/app/application.py index 1a119cc4..9d3fc0d0 100644 --- a/resources/lib/app/application.py +++ b/resources/lib/app/application.py @@ -27,6 +27,8 @@ class App(object): self.stop_pkc = False # This will suspend the main thread also self.suspend = False + # Update Kodi widgets + self.update_widgets = False # Need to lock all methods and functions messing with Plex Companion subscribers self.lock_subscriber = RLock() # Need to lock everything messing with Kodi/PKC playqueues diff --git a/resources/lib/library_sync/common.py b/resources/lib/library_sync/common.py index 44368424..5497dbf8 100644 --- a/resources/lib/library_sync/common.py +++ b/resources/lib/library_sync/common.py @@ -3,7 +3,7 @@ from __future__ import absolute_import, division, unicode_literals import xbmc -from .. import utils, variables as v +from .. import utils, app, variables as v PLAYLIST_SYNC_ENABLED = (v.DEVICE != 'Microsoft UWP' and utils.settings('enablePlaylistSync') == 'true') @@ -42,7 +42,12 @@ def update_kodi_library(video=True, music=True): Updates the Kodi library and thus refreshes the Kodi views and widgets """ if video: - xbmc.executebuiltin('UpdateLibrary(video)') + if not xbmc.getCondVisibility('Window.IsMedia'): + xbmc.executebuiltin('UpdateLibrary(video)') + else: + # Prevent cursor from moving - refresh later + xbmc.executebuiltin('Container.Refresh') + app.APP.update_widgets = True if music: xbmc.executebuiltin('UpdateLibrary(music)') diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index b00e879b..e259dec8 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -486,6 +486,8 @@ class Service(object): elif plex_command == 'EXIT-PKC': LOG.info('Received command from another instance to quit') app.APP.stop_pkc = True + else: + raise RuntimeError('Unknown command: %s', plex_command) if task: backgroundthread.BGThreader.addTasksToFront([task]) continue @@ -494,6 +496,15 @@ class Service(object): xbmc.sleep(100) continue + if app.APP.update_widgets and not xbmc.getCondVisibility('Window.IsMedia'): + ''' + In case an update happened but we were not on the homescreen + and now we are, force widgets to update. Prevents cursor from + moving/jumping in libraries + ''' + app.APP.update_widgets = False + xbmc.executebuiltin('UpdateLibrary(video)') + # Before proceeding, need to make sure: # 1. Server is online # 2. User is set