Added the onclicked even where it belongs, in the module handling the click.

This commit is contained in:
Jas Singh
2024-06-11 01:29:57 -07:00
parent fad852c13f
commit 9619f90e4f
5 changed files with 18 additions and 17 deletions

View File

@@ -1,5 +1,8 @@
const hyprland = await Service.import("hyprland");
const audio = await Service.import("audio");
import { globalMousePos } from "../../../globals.js";
const Volume = () => {
const icons = {
101: "󰕾",
@@ -36,7 +39,16 @@ const Volume = () => {
}),
isVisible: true,
props: {
// on_primary_click: (a,b) => App.toggleWindow("audiomenu"),
on_primary_click: (a, b, c, d) => {
const monX = hyprland.monitors[hyprland.active.monitor.id].x;
const monY = hyprland.monitors[hyprland.active.monitor.id].y;
const cursorPos = Utils.exec("hyprctl cursorpos").split(", ").map(Number);
cursorPos[0] = cursorPos[0] - monX;
cursorPos[1] = cursorPos[1] - monY;
globalMousePos.value = cursorPos;
App.toggleWindow("audiomenu");
},
},
};
};

View File

@@ -1,6 +1,3 @@
const hyprland = await Service.import("hyprland");
import { globalMousePos } from "../../globals.js";
export const BarItemBox = (child) => {
const computeVisible = () => {
if (Object.hasOwnProperty.call(child, "isVis")) {
@@ -11,16 +8,6 @@ export const BarItemBox = (child) => {
};
return Widget.Button({
on_primary_click: (a, b, c, d) => {
const monX = hyprland.monitors[hyprland.active.monitor.id].x;
const monY = hyprland.monitors[hyprland.active.monitor.id].y;
const cursorPos = Utils.exec("hyprctl cursorpos").split(", ").map(Number);
cursorPos[0] = cursorPos[0] - monX;
cursorPos[1] = cursorPos[1] - monY;
globalMousePos.value = cursorPos;
App.toggleWindow("audiomenu");
},
class_name: "bar_item_box_visible",
child: child.component,
visible: computeVisible(),