Ignore clicks that dont correspond to SMIL elements

This commit is contained in:
Kovid Goyal 2023-10-25 08:41:38 +05:30
parent e23664383d
commit f25465a49d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 6 deletions

View File

@ -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}')

View File

@ -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

View File

@ -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):