Disable focus of popup when using touch

Context menu on Firefox will not target the text properly if the focus is on the popup window.
This commit is contained in:
toasted-nutbread 2019-08-09 22:29:14 -04:00
parent 710ffb88fc
commit 345b9c6f9d
2 changed files with 12 additions and 7 deletions

View File

@ -290,7 +290,8 @@ class Frontend {
if (!hideResults && (!this.textSourceLast || !this.textSourceLast.equals(textSource))) { if (!hideResults && (!this.textSourceLast || !this.textSourceLast.equals(textSource))) {
searched = true; searched = true;
this.pendingLookup = true; this.pendingLookup = true;
hideResults = !await this.searchTerms(textSource) && !await this.searchKanji(textSource); const focus = (type === 'mouse');
hideResults = !await this.searchTerms(textSource, focus) && !await this.searchKanji(textSource, focus);
success = true; success = true;
} }
} catch (e) { } catch (e) {
@ -313,7 +314,7 @@ class Frontend {
} }
} }
async searchTerms(textSource) { async searchTerms(textSource, focus) {
textSource.setEndOffset(this.options.scanning.length); textSource.setEndOffset(this.options.scanning.length);
const {definitions, length} = await apiTermsFind(textSource.text()); const {definitions, length} = await apiTermsFind(textSource.text());
@ -329,7 +330,7 @@ class Frontend {
textSource.getRect(), textSource.getRect(),
definitions, definitions,
this.options, this.options,
{sentence, url} {sentence, url, focus}
); );
this.textSourceLast = textSource; this.textSourceLast = textSource;
@ -340,7 +341,7 @@ class Frontend {
return true; return true;
} }
async searchKanji(textSource) { async searchKanji(textSource, focus) {
textSource.setEndOffset(1); textSource.setEndOffset(1);
const definitions = await apiKanjiFind(textSource.text()); const definitions = await apiKanjiFind(textSource.text());
@ -354,7 +355,7 @@ class Frontend {
textSource.getRect(), textSource.getRect(),
definitions, definitions,
this.options, this.options,
{sentence, url} {sentence, url, focus}
); );
this.textSourceLast = textSource; this.textSourceLast = textSource;

View File

@ -269,7 +269,9 @@ class Display {
async termsShow(definitions, options, context) { async termsShow(definitions, options, context) {
try { try {
if (context && context.focus) {
window.focus(); window.focus();
}
this.definitions = definitions; this.definitions = definitions;
this.options = options; this.options = options;
@ -321,7 +323,9 @@ class Display {
async kanjiShow(definitions, options, context) { async kanjiShow(definitions, options, context) {
try { try {
if (context && context.focus) {
window.focus(); window.focus();
}
this.definitions = definitions; this.definitions = definitions;
this.options = options; this.options = options;