osd: hide on mouse movement

works for left side but not right side... oh well, still better than nothing
This commit is contained in:
end-4
2025-03-30 09:12:53 +02:00
parent a97af6f3bc
commit dcdb53da9e
3 changed files with 42 additions and 8 deletions
+15 -2
View File
@@ -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 Brightness from '../../../services/brightness.js';
import Indicator from '../../../services/indicator.js';
import { distance } from '../../.miscutils/mathfuncs.js';
const OSD_DISMISS_DISTANCE = 10;
const WindowTitle = async () => {
try {
@@ -41,18 +44,28 @@ const WindowTitle = async () => {
export default async (monitor = 0) => {
const optionalWindowTitleInstance = await WindowTitle();
let scrollCursorX, scrollCursorY;
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
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
Brightness[monitor].screen_value -= 0.05;
},
onPrimaryClick: () => {
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({
homogeneous: false,
children: [