macOS: Fix extra dock icons visible when doing a job using Qt WebEngine such as converting to PDF or searching in Get books. Fixes #2023395 [Multiple Dock Icons When Searching for Books](https://bugs.launchpad.net/calibre/+bug/2023395)

Apparently a recent macOS update changed some behavior. Now we need to
have LSBackgroundOnly=1 in the Info.plist for calibre-parallel otherwise
when using Qt we get a dock icon for the process. Sigh.
This commit is contained in:
Kovid Goyal 2023-06-12 13:50:26 +05:30
parent 565b86b853
commit fdf95531e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 1 deletions

View File

@ -742,15 +742,24 @@ class Freeze:
e = plist['CFBundleDocumentTypes'][0]
e['CFBundleTypeExtensions'] = [x.lower() for x in formats]
def headless_plist(plist):
plist['CFBundleDisplayName'] = 'calibre worker process'
plist['CFBundleExecutable'] = 'calibre-parallel'
plist['CFBundleIdentifier'] = 'com.calibre-ebook.calibre-parallel'
plist['LSBackgroundOnly'] = '1'
plist.pop('CFBundleDocumentTypes')
self.create_app_clone('ebook-viewer.app', partial(specialise_plist, 'ebook-viewer', input_formats))
self.create_app_clone('ebook-edit.app', partial(specialise_plist, 'ebook-edit', edit_formats),
base_dir=join(self.contents_dir, 'ebook-viewer.app', 'Contents'))
self.create_app_clone('headless.app', headless_plist,
base_dir=join(self.contents_dir, 'ebook-viewer.app', 'Contents', 'ebook-edit.app', 'Contents'))
# We need to move the webengine resources into the deepest sub-app
# because the sandbox gets set to the nearest enclosing app which
# means that WebEngine will fail to access its resources when running
# in the sub-apps unless they are present inside the sub app bundle
# somewhere
base_dest = join(self.contents_dir, 'ebook-viewer.app', 'Contents', 'ebook-edit.app', 'Contents', 'SharedSupport')
base_dest = join(self.contents_dir, 'ebook-viewer.app', 'Contents', 'ebook-edit.app', 'Contents', 'headless.app', 'Contents', 'SharedSupport')
os.mkdir(base_dest)
base_src = os.path.realpath(join(self.frameworks_dir, 'QtWebEngineCore.framework/Resources'))
items = [join(base_src, 'qtwebengine_locales')] + glob.glob(join(base_src, '*.pak')) + glob.glob(join(base_src, '*.dat'))

View File

@ -73,6 +73,9 @@ class Worker:
@property
def executable(self):
if ismacos and not hasattr(sys, 'running_from_setup'):
base = os.path.dirname(sys.executables_location)
return os.path.join(base, 'ebook-viewer.app/Contents/ebook-edit.app/Contents/headless.app/Contents/MacOS', self.exe_name)
return exe_path(self.exe_name)
@property