forked from Shinonome/dots-hyprland
osd: hide on mouse movement
works for left side but not right side... oh well, still better than nothing
This commit is contained in:
@@ -7,4 +7,10 @@ export function truncateToPrecision(value, precision) {
|
|||||||
const factor = Math.pow(10, precision);
|
const factor = Math.pow(10, precision);
|
||||||
const result = Math.round(value * factor) / factor;
|
const result = Math.round(value * factor) / factor;
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function distance(x1, y1, x2, y2) {
|
||||||
|
const distanceX = Math.abs(x1 - x2);
|
||||||
|
const distanceY = Math.abs(y1 - y2);
|
||||||
|
return Math.sqrt(distanceX * distanceX + distanceY * distanceY)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,9 @@ import App from 'resource:///com/github/Aylur/ags/app.js';
|
|||||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import Brightness from '../../../services/brightness.js';
|
import Brightness from '../../../services/brightness.js';
|
||||||
import Indicator from '../../../services/indicator.js';
|
import Indicator from '../../../services/indicator.js';
|
||||||
|
import { distance } from '../../.miscutils/mathfuncs.js';
|
||||||
|
|
||||||
|
const OSD_DISMISS_DISTANCE = 10;
|
||||||
|
|
||||||
const WindowTitle = async () => {
|
const WindowTitle = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -41,18 +44,28 @@ const WindowTitle = async () => {
|
|||||||
|
|
||||||
export default async (monitor = 0) => {
|
export default async (monitor = 0) => {
|
||||||
const optionalWindowTitleInstance = await WindowTitle();
|
const optionalWindowTitleInstance = await WindowTitle();
|
||||||
|
let scrollCursorX, scrollCursorY;
|
||||||
return Widget.EventBox({
|
return Widget.EventBox({
|
||||||
onScrollUp: () => {
|
onScrollUp: (self, event) => {
|
||||||
|
let _;
|
||||||
|
[_, scrollCursorX, scrollCursorY] = event.get_coords();
|
||||||
Indicator.popup(1); // Since the brightness and speaker are both on the same window
|
Indicator.popup(1); // Since the brightness and speaker are both on the same window
|
||||||
Brightness[monitor].screen_value += 0.05;
|
Brightness[monitor].screen_value += 0.05;
|
||||||
},
|
},
|
||||||
onScrollDown: () => {
|
onScrollDown: (self, event) => {
|
||||||
|
let _;
|
||||||
|
[_, scrollCursorX, scrollCursorY] = event.get_coords();
|
||||||
Indicator.popup(1); // Since the brightness and speaker are both on the same window
|
Indicator.popup(1); // Since the brightness and speaker are both on the same window
|
||||||
Brightness[monitor].screen_value -= 0.05;
|
Brightness[monitor].screen_value -= 0.05;
|
||||||
},
|
},
|
||||||
onPrimaryClick: () => {
|
onPrimaryClick: () => {
|
||||||
App.toggleWindow('sideleft');
|
App.toggleWindow('sideleft');
|
||||||
},
|
},
|
||||||
|
setup: (self) => self.on('motion-notify-event', (self, event) => {
|
||||||
|
const [_, cursorX, cursorY] = event.get_coords();
|
||||||
|
if (distance(cursorX, cursorY, scrollCursorX, scrollCursorY) >= OSD_DISMISS_DISTANCE)
|
||||||
|
Indicator.popup(-1);
|
||||||
|
}),
|
||||||
child: Widget.Box({
|
child: Widget.Box({
|
||||||
homogeneous: false,
|
homogeneous: false,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ const { execAsync } = Utils;
|
|||||||
import Indicator from '../../../services/indicator.js';
|
import Indicator from '../../../services/indicator.js';
|
||||||
import { StatusIcons } from '../../.commonwidgets/statusicons.js';
|
import { StatusIcons } from '../../.commonwidgets/statusicons.js';
|
||||||
import { Tray } from "./tray.js";
|
import { Tray } from "./tray.js";
|
||||||
|
import { distance } from '../../.miscutils/mathfuncs.js';
|
||||||
|
|
||||||
|
const OSD_DISMISS_DISTANCE = 10;
|
||||||
|
|
||||||
const SeparatorDot = () => Widget.Revealer({
|
const SeparatorDot = () => Widget.Revealer({
|
||||||
transition: 'slide_left',
|
transition: 'slide_left',
|
||||||
@@ -39,7 +42,7 @@ export default (monitor = 0) => {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}, monitor);
|
}, monitor);
|
||||||
const SpaceRightDefaultClicks = (child) => Widget.EventBox({
|
const SpaceRightInteractions = (child) => Widget.EventBox({
|
||||||
onHover: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', true) },
|
onHover: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', true) },
|
||||||
onHoverLost: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', false) },
|
onHoverLost: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', false) },
|
||||||
onPrimaryClick: () => App.toggleWindow('sideright'),
|
onPrimaryClick: () => App.toggleWindow('sideright'),
|
||||||
@@ -48,11 +51,13 @@ export default (monitor = 0) => {
|
|||||||
setup: (self) => self.on('button-press-event', (self, event) => {
|
setup: (self) => self.on('button-press-event', (self, event) => {
|
||||||
if (event.get_button()[1] === 8)
|
if (event.get_button()[1] === 8)
|
||||||
execAsync('playerctl previous').catch(print)
|
execAsync('playerctl previous').catch(print)
|
||||||
|
}).on('motion-notify-event', (self, event) => {
|
||||||
|
Indicator.popup(-1);
|
||||||
}),
|
}),
|
||||||
child: child,
|
child: child,
|
||||||
});
|
});
|
||||||
const emptyArea = SpaceRightDefaultClicks(Widget.Box({ hexpand: true, }));
|
const emptyArea = SpaceRightInteractions(Widget.Box({ hexpand: true, }));
|
||||||
const indicatorArea = SpaceRightDefaultClicks(Widget.Box({
|
const indicatorArea = SpaceRightInteractions(Widget.Box({
|
||||||
children: [
|
children: [
|
||||||
SeparatorDot(),
|
SeparatorDot(),
|
||||||
barStatusIcons
|
barStatusIcons
|
||||||
@@ -68,23 +73,33 @@ export default (monitor = 0) => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let scrollCursorX, scrollCursorY;
|
||||||
return Widget.EventBox({
|
return Widget.EventBox({
|
||||||
onScrollUp: () => {
|
onScrollUp: (self, event) => {
|
||||||
if (!Audio.speaker) return;
|
if (!Audio.speaker) return;
|
||||||
|
let _;
|
||||||
|
[_, scrollCursorX, scrollCursorY] = event.get_coords();
|
||||||
if (Audio.speaker.volume <= 0.09) Audio.speaker.volume += 0.01;
|
if (Audio.speaker.volume <= 0.09) Audio.speaker.volume += 0.01;
|
||||||
else Audio.speaker.volume += 0.03;
|
else Audio.speaker.volume += 0.03;
|
||||||
Indicator.popup(1);
|
Indicator.popup(1);
|
||||||
},
|
},
|
||||||
onScrollDown: () => {
|
onScrollDown: (self, event) => {
|
||||||
if (!Audio.speaker) return;
|
if (!Audio.speaker) return;
|
||||||
|
let _;
|
||||||
|
[_, scrollCursorX, scrollCursorY] = event.get_coords();
|
||||||
if (Audio.speaker.volume <= 0.09) Audio.speaker.volume -= 0.01;
|
if (Audio.speaker.volume <= 0.09) Audio.speaker.volume -= 0.01;
|
||||||
else Audio.speaker.volume -= 0.03;
|
else Audio.speaker.volume -= 0.03;
|
||||||
Indicator.popup(1);
|
Indicator.popup(1);
|
||||||
},
|
},
|
||||||
|
setup: (self) => self.on('motion-notify-event', (self, event) => {
|
||||||
|
const [_, cursorX, cursorY] = event.get_coords();
|
||||||
|
if (distance(cursorX, cursorY, scrollCursorX, scrollCursorY) >= OSD_DISMISS_DISTANCE)
|
||||||
|
Indicator.popup(-1);
|
||||||
|
}),
|
||||||
child: Widget.Box({
|
child: Widget.Box({
|
||||||
children: [
|
children: [
|
||||||
actualContent,
|
actualContent,
|
||||||
SpaceRightDefaultClicks(Widget.Box({ className: 'bar-corner-spacing' })),
|
SpaceRightInteractions(Widget.Box({ className: 'bar-corner-spacing' })),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user