feat(agsV2): switch to async hyprMessage wrapper
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
8ee3530330
commit
276c399f49
6 changed files with 25 additions and 19 deletions
|
@ -37,3 +37,11 @@ export const get_gdkmonitor_from_desc = (desc: string): Gdk.Monitor => {
|
|||
export const get_monitor_desc = (mon: AstalHyprland.Monitor): string => {
|
||||
return `desc:${mon.description}`;
|
||||
};
|
||||
|
||||
export const hyprMessage = (message: string) => new Promise<string>((resolution = () => { /**/ }) => {
|
||||
Hyprland.message_async(message, (_, asyncResult) => {
|
||||
const result = Hyprland.message_finish(asyncResult);
|
||||
|
||||
resolution(result);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import { bind, Variable } from 'astal';
|
|||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
const Hyprland = AstalHyprland.get_default();
|
||||
|
||||
import { get_hyprland_monitor_desc, get_monitor_desc } from '../../lib';
|
||||
import { get_hyprland_monitor_desc, get_monitor_desc, hyprMessage } from '../../lib';
|
||||
|
||||
|
||||
const FullscreenState = Variable({
|
||||
|
@ -12,7 +12,7 @@ const FullscreenState = Variable({
|
|||
clientAddrs: new Map() as Map<string, string>,
|
||||
});
|
||||
|
||||
Hyprland.connect('event', () => {
|
||||
Hyprland.connect('event', async() => {
|
||||
const arrayEquals = (a1: unknown[], a2: unknown[]) =>
|
||||
a1.sort().toString() === a2.sort().toString();
|
||||
|
||||
|
@ -20,7 +20,7 @@ Hyprland.connect('event', () => {
|
|||
m1.size === m2.size &&
|
||||
Array.from(m1.keys()).every((key) => m1.get(key) === m2.get(key));
|
||||
|
||||
const newMonitors = JSON.parse(Hyprland.message('j/monitors')) as AstalHyprland.Monitor[];
|
||||
const newMonitors = JSON.parse(await hyprMessage('j/monitors')) as AstalHyprland.Monitor[];
|
||||
|
||||
const fs = FullscreenState.get();
|
||||
const fsClients = Hyprland.get_clients().filter((c) => {
|
||||
|
|
|
@ -7,6 +7,7 @@ import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
|||
const Hyprland = AstalHyprland.get_default();
|
||||
|
||||
import Separator from '../../misc/separator';
|
||||
import { hyprMessage } from '../../../lib';
|
||||
|
||||
|
||||
export default () => {
|
||||
|
@ -37,8 +38,8 @@ export default () => {
|
|||
updateVars();
|
||||
Hyprland.connect('notify::focused-client', () => updateVars());
|
||||
Hyprland.connect('client-removed', () => updateVars());
|
||||
Hyprland.connect('client-added', () => {
|
||||
updateVars(Hyprland.get_client(JSON.parse(Hyprland.message('j/activewindow')).address));
|
||||
Hyprland.connect('client-added', async() => {
|
||||
updateVars(Hyprland.get_client(JSON.parse(await hyprMessage('j/activewindow')).address));
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
@ -4,6 +4,8 @@ import { timeout } from 'astal';
|
|||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
const Hyprland = AstalHyprland.get_default();
|
||||
|
||||
import { hyprMessage } from '../../../lib';
|
||||
|
||||
|
||||
const URGENT_DURATION = 1000;
|
||||
|
||||
|
@ -17,7 +19,7 @@ const Workspace = ({ id = 0 }) => (
|
|||
tooltip_text={id.toString()}
|
||||
|
||||
onClickRelease={() => {
|
||||
Hyprland.message_async(`dispatch workspace ${id}`, () => { /**/ });
|
||||
hyprMessage(`dispatch workspace ${id}`);
|
||||
}}
|
||||
>
|
||||
<box
|
||||
|
|
|
@ -2,8 +2,7 @@ import { Astal, Widget } from 'astal/gtk3';
|
|||
import { register, property } from 'astal/gobject';
|
||||
import { Binding, idle } from 'astal';
|
||||
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
const Hyprland = AstalHyprland.get_default();
|
||||
import { hyprMessage } from '../../lib';
|
||||
|
||||
/* Types */
|
||||
type CloseType = 'none' | 'stay' | 'released' | 'clicked';
|
||||
|
@ -59,10 +58,7 @@ class PopupWindow extends Widget.Window {
|
|||
});
|
||||
|
||||
const setTransition = (_: PopupWindow, t: HyprTransition | Binding<HyprTransition>) => {
|
||||
Hyprland.message_async(
|
||||
`keyword layerrule animation ${t}, ${this.name}`,
|
||||
() => { /**/ },
|
||||
);
|
||||
hyprMessage(`keyword layerrule animation ${t}, ${this.name}`);
|
||||
};
|
||||
|
||||
this.connect('notify::transition', setTransition);
|
||||
|
|
|
@ -7,8 +7,7 @@ import AstalIO from 'gi://AstalIO?version=0.1';
|
|||
import AstalNotifd from 'gi://AstalNotifd?version=0.1';
|
||||
const Notifications = AstalNotifd.get_default();
|
||||
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
const Hyprland = AstalHyprland.get_default();
|
||||
import { hyprMessage } from '../../lib';
|
||||
|
||||
import { HasNotifs } from './notification';
|
||||
import { get_hyprland_monitor } from '../../lib';
|
||||
|
@ -83,9 +82,9 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
|||
@property(Boolean)
|
||||
declare dragging: boolean;
|
||||
|
||||
get hovered(): boolean {
|
||||
const layers = JSON.parse(Hyprland.message('j/layers')) as LayerResult;
|
||||
const cursorPos = JSON.parse(Hyprland.message('j/cursorpos')) as CursorPos;
|
||||
private async get_hovered(): Promise<boolean> {
|
||||
const layers = JSON.parse(await hyprMessage('j/layers')) as LayerResult;
|
||||
const cursorPos = JSON.parse(await hyprMessage('j/cursorpos')) as CursorPos;
|
||||
|
||||
const window = this.get_window();
|
||||
|
||||
|
@ -214,8 +213,8 @@ export class NotifGestureWrapper extends Widget.EventBox {
|
|||
|
||||
// Handle timeout before sliding away if it is a popup
|
||||
if (this.popup_timer !== 0) {
|
||||
this.timer_object = interval(1000, () => {
|
||||
if (!this.hovered) {
|
||||
this.timer_object = interval(1000, async() => {
|
||||
if (!(await this.get_hovered())) {
|
||||
if (this.popup_timer === 0) {
|
||||
this.slideAway('Left');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue