Skip to content

Commit

Permalink
Prevent to start multiselection of tabs by long press unexpectedly wh…
Browse files Browse the repository at this point in the history
…en the mouse button was released immediately but it took time due to low system performance
  • Loading branch information
piroor committed Jan 21, 2020
1 parent 6a4874d commit 0970e35
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion webextensions/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ async function onSelectionChange(info) {
}

let TSTLongPressTimer;
let shoudHandleTSTLongPress = false;
let mousedownHandled = false;

function onTSTAPIMessage(message) {
Expand All @@ -127,9 +128,11 @@ function onTSTAPIMessage(message) {
return;
}
mousedownHandled = true;
shoudHandleTSTLongPress = true;
return DragSelectionManager.onMouseDown(message).then(action => {
if (action & Constants.kCLICK_ACTION_REGULAR_CLICK &&
configs.enableDragSelectionByLongPress) {
configs.enableDragSelectionByLongPress &&
shoudHandleTSTLongPress) {
TSTLongPressTimer = setTimeout(async () => {
TSTLongPressTimer = undefined;
const window = await browser.windows.get(message.window, { populate: true });
Expand All @@ -152,6 +155,7 @@ function onTSTAPIMessage(message) {
});

case Constants.kTSTAPI_NOTIFY_TAB_MOUSEUP:
shoudHandleTSTLongPress = false;
if (!mousedownHandled)
return;
if (TSTLongPressTimer) {
Expand Down

0 comments on commit 0970e35

Please sign in to comment.