mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ignore clicks that dont correspond to SMIL elements
This commit is contained in:
parent
e23664383d
commit
f25465a49d
@ -1031,7 +1031,7 @@ class IframeBoss:
|
|||||||
par = None
|
par = None
|
||||||
else:
|
else:
|
||||||
par = smil_element_at(data.pos, self.smil_anchor_map, self.smil_par_list)
|
par = smil_element_at(data.pos, self.smil_anchor_map, self.smil_par_list)
|
||||||
self.send_message('audio_ebook_message', type='start_play_at', par=par or None, anchor=data.anchor or None)
|
self.send_message('audio_ebook_message', type='start_play_at', par=par or None, anchor=data.anchor or None, pos=data.pos or None)
|
||||||
else:
|
else:
|
||||||
console.error(f'Unknown audio ebook message type from main: {data.type}')
|
console.error(f'Unknown audio ebook message type from main: {data.type}')
|
||||||
|
|
||||||
|
@ -356,9 +356,14 @@ class ReadAudioEbook:
|
|||||||
# start playing from where we are
|
# start playing from where we are
|
||||||
self.send_message('play')
|
self.send_message('play')
|
||||||
return
|
return
|
||||||
self.pause()
|
if message.pos:
|
||||||
error_dialog(_('Audio element not found'), _(
|
# this is a click ignore it as no smil element was found at
|
||||||
'Could not play audio as no associated audio was found'))
|
# click location
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.pause()
|
||||||
|
error_dialog(_('Audio element not found'), _(
|
||||||
|
'Could not play audio as no associated audio was found'))
|
||||||
elif message.type is 'marked':
|
elif message.type is 'marked':
|
||||||
if message.anchor:
|
if message.anchor:
|
||||||
self.last_marked_smil_id = message.anchor
|
self.last_marked_smil_id = message.anchor
|
||||||
|
@ -110,8 +110,7 @@ def smil_element_at(pos, anchor_map, par_list):
|
|||||||
br = af.get_bounding_client_rect(elem)
|
br = af.get_bounding_client_rect(elem)
|
||||||
if br.x <= pos.x <= (br.x + br.width) and br.y <= pos.y <= (br.y + br.height):
|
if br.x <= pos.x <= (br.x + br.width) and br.y <= pos.y <= (br.y + br.height):
|
||||||
return par
|
return par
|
||||||
# fallback to first visible anchor
|
return None
|
||||||
return smil_element_at(None, anchor_map, par_list)
|
|
||||||
else: # use first visible anchor
|
else: # use first visible anchor
|
||||||
for par in par_list:
|
for par in par_list:
|
||||||
if par.anchor and par.audio and is_anchor_on_screen(par.anchor):
|
if par.anchor and par.audio and is_anchor_on_screen(par.anchor):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user