Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions browser-features/chrome/common/mouse-gesture/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const ContextMenuCodec = t.type({

const MouseGestureConfigRequired = t.type({
rockerGesturesEnabled: t.boolean,
wheelGesturesEnabled: t.boolean,
sensitivity: t.number,
showTrail: t.boolean,
showLabel: t.boolean,
Expand All @@ -66,6 +67,7 @@ export type MouseGestureConfig = t.TypeOf<typeof MouseGestureConfigCodec>;
export const defaultConfig: MouseGestureConfig = {
enabled: false,
rockerGesturesEnabled: true,
wheelGesturesEnabled: true,
sensitivity: 40,
showTrail: true,
showLabel: true,
Expand Down
41 changes: 40 additions & 1 deletion browser-features/chrome/common/mouse-gesture/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export class MouseGestureController {
globalThis.addEventListener("mousemove", this.handleMouseMove);
globalThis.addEventListener("mouseup", this.handleMouseUp);
globalThis.addEventListener("contextmenu", this.handleContextMenu, true);
globalThis.addEventListener("wheel", this.handleMouseWheel, {
passive: false,
});
this.eventListenersAttached = true;
}
}
Expand All @@ -58,6 +61,7 @@ export class MouseGestureController {
this.handleContextMenu,
true,
);
globalThis.removeEventListener("wheel", this.handleMouseWheel);
this.eventListenersAttached = false;
}

Expand Down Expand Up @@ -236,6 +240,41 @@ export class MouseGestureController {
this.resetGestureState();
};

private handleMouseWheel = (event: WheelEvent): void => {
if (!this.isGestureActive || !isEnabled()) {
return;
}

const config = getConfig();
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!config.wheelGesturesEnabled) {
return;
}

let action: string | null = null;
if (event.deltaY < 0) {
action = "gecko-show-previous-tab";
} else if (event.deltaY > 0) {
action = "gecko-show-next-tab";
}

if (action) {
executeGestureAction(action);
event.preventDefault();
event.stopPropagation();

this.isContextMenuPrevented = true;

if (this.preventionTimeoutId) {
clearTimeout(this.preventionTimeoutId);
}
this.preventionTimeoutId = setTimeout(() => {
this.isContextMenuPrevented = false;
this.preventionTimeoutId = null;
}, getConfig().contextMenu.preventionTimeout);
}
};

private getTotalMovement(): number {
if (this.mouseTrail.length < 2) return 0;

Expand Down Expand Up @@ -578,4 +617,4 @@ export class MouseGestureController {
const normalizedDistance = dtw[n][m] / trailTotalWeight;
return Math.max(0, 1 - normalizedDistance);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ export function GeneralSettings({
disabled={!config.enabled}
/>
</div>
<div className="flex items-center justify-between py-2">
<span className="text-base-content/90">
{t("mouseGesture.wheelGesturesEnabled")}
</span>
<Switch
checked={config.wheelGesturesEnabled ?? true}
onChange={() => updateConfig({ wheelGesturesEnabled: !(config.wheelGesturesEnabled ?? true) })}
disabled={!config.enabled}
/>
</div>

<div className="flex items-center justify-between py-2">
<span className="text-base-content/90">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Beskrivelse af bevægelsen",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Gå tilbage",
"gecko-forward": "Gå frem",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description du geste",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Précédent",
"gecko-forward": "Suivant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Deskripsi gestur",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "ジェスチャーの説明",
"rockerGesturesEnabled": "ロッカージェスチャーを有効にする",
"rockerGesturesDescription": "右クリックしながら左に動かすとページを戻り、右クリックしながら右に動かすと進みます。 (実験的)",
"wheelGesturesEnabled": "ホイールジェスチャーを有効にする",
"actions": {
"gecko-back": "戻る",
"gecko-forward": "進む",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "ジェスチャーの説明",
"rockerGesturesEnabled": "ロッカージェスチャーを有効にする",
"rockerGesturesDescription": "右クリックしながら左に動かすとページを戻り、右クリックしながら右に動かすと進みます。 (実験的)",
"wheelGesturesEnabled": "ホイールジェスチャーを有効にする",
"actions": {
"gecko-back": "戻る",
"gecko-forward": "進む",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Descrição do gesto",
"rockerGesturesEnabled": "Ativar gestos de balanço",
"rockerGesturesDescription": "Clique com o botão direito do mouse e mova para a esquerda para voltar, clique com o botão direito do mouse e mova para a direita para avançar. (experimental)",
"wheelGesturesEnabled": "Ativar gestos de roda",
"actions": {
"gecko-back": "Voltar",
"gecko-forward": "Avançar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Descrição do gesto",
"rockerGesturesEnabled": "Ativar os gestos de baloiço",
"rockerGesturesDescription": "Clique com o botão direito do rato e mova para a esquerda para voltar atrás, clique com o botão direito do rato e mova para a direita para avançar. (Experimental)",
"wheelGesturesEnabled": "Ativar gestos de roda",
"actions": {
"gecko-back": "Voltar atrás",
"gecko-forward": "Avançar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Описание жеста",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Beskrivning av gest",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Gå tillbaka",
"gecko-forward": "Gå framåt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Hareketin açıklaması",
"rockerGesturesEnabled": "Rocker hareketlerini etkinleştirin",
"rockerGesturesDescription": "Geri gitmek için sağ tıklayın ve sola hareket edin, ileri gitmek için sağ tıklayın ve sağa hareket edin. (Deneysel)",
"wheelGesturesEnabled": "Tekerlek hareketlerini etkinleştirin",
"actions": {
"gecko-back": "Geri",
"gecko-forward": "İleri",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Опис жесту",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Повернутися",
"gecko-forward": "Вперед",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "Description of the gesture",
"rockerGesturesEnabled": "Enable rocker gestures",
"rockerGesturesDescription": "Right-click and move left to go back, right-click and move right to go forward. (Experimental)",
"wheelGesturesEnabled": "Enable wheel gestures",
"actions": {
"gecko-back": "Go Back",
"gecko-forward": "Go Forward",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "手势说明",
"rockerGesturesEnabled": "启用摇杆手势",
"rockerGesturesDescription": "右键单击并向左移动以返回,右键单击并向右移动以前进。(实验性)",
"wheelGesturesEnabled": "启用滚轮手势",
"actions": {
"gecko-back": "转到上一页",
"gecko-forward": "转到下一页",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@
"actionDescription": "手勢說明",
"rockerGesturesEnabled": "啟用搖桿手勢",
"rockerGesturesDescription": "按一下滑鼠右鍵並向左移動可返回,按一下滑鼠右鍵並向右移動可向前。(實驗性質)",
"wheelGesturesEnabled": "啟用滾輪手勢",
"actions": {
"gecko-back": "返回",
"gecko-forward": "前進",
Expand Down