add option to always activate menu while holding CTRL

This commit is contained in:
Tamius Han 2026-01-25 23:33:37 +01:00
parent e1dd0f9c04
commit dbdcb4e367
9 changed files with 56 additions and 30 deletions

View File

@ -313,7 +313,8 @@ export interface InPlayerUIOptions {
activatorAlignment: MenuPosition, activatorAlignment: MenuPosition,
minEnabledWidth: number, // don't show UI if player is narrower than % of screen width minEnabledWidth: number, // don't show UI if player is narrower than % of screen width
minEnabledHeight: number, // don't show UI if player is narrower than % of screen height minEnabledHeight: number, // don't show UI if player is narrower than % of screen height
activation: 'player' | 'player-ctrl' | 'trigger-zone' | 'distance' | 'none', // what needs to be hovered in order for UI to be visible activation: 'player' | 'trigger-zone' | 'distance' | 'none', // what needs to be hovered in order for UI to be visible
activateWithCtrl: boolean,
activationDistance: number, activationDistance: number,
activationDistanceUnits: '%' | 'px', activationDistanceUnits: '%' | 'px',
activatorPadding: {x: number, y: number} activatorPadding: {x: number, y: number}

View File

@ -254,8 +254,6 @@ export default class UWServer {
} }
async getCurrentSite(sender: Runtime.MessageSender) { async getCurrentSite(sender: Runtime.MessageSender) {
this.logger.info('getCurrentSite', 'received get-current-site ...');
const site = await this.getVideoTab(); const site = await this.getVideoTab();
// Don't propagate 'INVALID SITE' to the popup. // Don't propagate 'INVALID SITE' to the popup.

View File

@ -161,7 +161,8 @@ export default class EventBus {
*/ */
private sendToTunnel(command: string, config: any, context: EventBusContext = {}) { private sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
if (!context.visitedBusses) { if (!context.visitedBusses) {
console.error('Visited busses is missing from contextn. This is illegal.'); // this should never trigger on production version of the extension.
console.error('Visited busses is missing from context. This is illegal.');
return; return;
} }
context.visitedBusses = [...context.visitedBusses ?? [], this.uuid]; context.visitedBusses = [...context.visitedBusses ?? [], this.uuid];
@ -220,8 +221,8 @@ export default class EventBus {
const payload = event.data.payload as EventBusMessage; const payload = event.data.payload as EventBusMessage;
console.info(this.name, 'received message from iframe. command:', payload);
if (!payload.context?.visitedBusses) { if (!payload.context?.visitedBusses) {
// this should never be visible to a real user
console.warn('Received iframe message without context. Doing nothing in order to avoid infinite loop. Event:', event); console.warn('Received iframe message without context. Doing nothing in order to avoid infinite loop. Event:', event);
return; return;
} }

View File

@ -197,7 +197,6 @@ class Logger {
storageChangeListener(changes: any, area: any) { storageChangeListener(changes: any, area: any) {
if (!changes.uwLogger) { if (!changes.uwLogger) {
console.info('We dont have any logging settings, not processing frther');
return; return;
} }

View File

@ -364,8 +364,15 @@ export class AardDebugUi {
Active: ${ar}, changed since last check? ${testResults.aspectRatioUpdated} letterbox width: ${testResults.letterboxWidth} offset ${testResults.letterboxOffset}<br/> Active: ${ar}, changed since last check? ${testResults.aspectRatioUpdated} letterbox width: ${testResults.letterboxWidth} offset ${testResults.letterboxOffset}<br/>
<sup>(last: ${this._lastAr})</sup> <sup>(last: ${this._lastAr})</sup>
Paused until? ${Date.now() < timers.pauseUntil ? ((timers.pauseUntil - Date.now()) / 1000) + 's' : 'not paused'}; ${
<sup>now: ${Date.now()}ms; until:${timers.pauseUntil}ms; diff: ${(+timers.pauseUntil - Date.now())} </sup> timers ?
`
Paused until? ${Date.now() < timers?.pauseUntil ? ((timers?.pauseUntil - Date.now()) / 1000) + 's' : 'not paused'};
<sup>now: ${Date.now()}ms; until:${timers?.pauseUntil}ms; diff: ${(+timers?.pauseUntil - Date.now())} </sup>
` :
`- timers are missing -`
}
image in black level probe (aka "not letterbox"): ${testResults.notLetterbox} image in black level probe (aka "not letterbox"): ${testResults.notLetterbox}
`; `;

View File

@ -299,11 +299,13 @@ export class ClientMenu {
} }
private bindGlobalMouse(anchorEl: HTMLElement) { private bindGlobalMouse(anchorEl: HTMLElement) {
// const forceRecheckAfter = 5000;
// let lastRecalculation = performance.now();
const playerRect = anchorEl.getBoundingClientRect(); const playerRect = anchorEl.getBoundingClientRect();
let menuActivatorRect, cx, cy; let menuActivatorRect, cx, cy;
let activationRadius = this.getActivationRadius(anchorEl);
const activationRadius = this.getActivationRadius(anchorEl);
const recalculateActivator = () => { const recalculateActivator = () => {
menuActivatorRect = this.trigger.getBoundingClientRect(); menuActivatorRect = this.trigger.getBoundingClientRect();
@ -314,10 +316,18 @@ export class ClientMenu {
recalculateActivator(); recalculateActivator();
this.onDocumentMouseMove = (e: MouseEvent) => { this.onDocumentMouseMove = (e: MouseEvent) => {
this.lastMouseMove = performance.now(); const now = performance.now();
this.lastMouseMove = now;
// activateWithCtrl is independent from other options.
// Depending on user settings, UI can be triggered even if we aren't holding CTRL
if (this.config.ui.activateWithCtrl) {
this.isWithinActivation = e.ctrlKey;
}
if (!this.isWithinActivation && this.config.ui.activation !== 'none') {
if (activationRadius) { if (activationRadius) {
if (! menuActivatorRect.width) { if (! menuActivatorRect.width || !menuActivatorRect.height) {
recalculateActivator(); recalculateActivator();
} }
const d = Math.hypot(e.clientX - cx, e.clientY - cy); const d = Math.hypot(e.clientX - cx, e.clientY - cy);
@ -328,8 +338,8 @@ export class ClientMenu {
e.clientX >= playerRect.left && e.clientX >= playerRect.left &&
e.clientX <= playerRect.right && e.clientX <= playerRect.right &&
e.clientY >= playerRect.top && e.clientY >= playerRect.top &&
e.clientY <= playerRect.bottom && e.clientY <= playerRect.bottom;
(this.config.ui.activation !== 'player-ctrl' || e.ctrlKey); }
} }
this.updateVisibility(); this.updateVisibility();

View File

@ -88,7 +88,6 @@ class UI {
'uw-show-settings-window': { 'uw-show-settings-window': {
function: (commandData, context) => { function: (commandData, context) => {
console.warn('received show settings window:', commandData, context, 'is global?', this.isGlobal);
this.createSettingsWindow(commandData?.initialState); this.createSettingsWindow(commandData?.initialState);
} }
} }

View File

@ -19,14 +19,14 @@
v-model="settings.active.ui.inPlayer.activation" v-model="settings.active.ui.inPlayer.activation"
@change="saveSettings()" @change="saveSettings()"
> >
<option value="none">
Never activate UI with mouse movement alone
</option>
<option value="player"> <option value="player">
When mouse moves over player, always When mouse moves over player, always
</option> </option>
<option value="player-ctrl">
When mouse moves over player, while holding CTRL key
</option>
<option value="distance"> <option value="distance">
When mouse is close to the menu activator (experimental) When mouse is close to the menu activator
</option> </option>
<!-- <option value="trigger-zone"> <!-- <option value="trigger-zone">
When mouse moves over trigger zone When mouse moves over trigger zone
@ -35,6 +35,18 @@
</div> </div>
</div> </div>
<div class="field">
<div class="label">
<input type="checkbox"
v-model="settings.active.ui.inPlayer.activateWithCtrl"
@change="saveSettings()"
>
</div>
<div class="text-left">
Also show on CTRL + mouse move
</div>
</div>
<div v-show="settings.active.ui.inPlayer.activation === 'distance'" class="field"> <div v-show="settings.active.ui.inPlayer.activation === 'distance'" class="field">
<div class="label"> <div class="label">
Show menu when mouse is closer than: Show menu when mouse is closer than:

View File

@ -271,7 +271,6 @@ export default defineComponent({
this.selectedTab = this.defaultTab; this.selectedTab = this.defaultTab;
} }
console.log('does event bus exist yet?', this.eventBus);
if (!this.eventBus) { if (!this.eventBus) {
// inter-frame communication should be set up by eventBus for free // inter-frame communication should be set up by eventBus for free
this.eventBus = new EventBus({name: 'ui-window'}); this.eventBus = new EventBus({name: 'ui-window'});