refactor(ags): remove blur and unused stuff from popup window class
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-04-10 21:04:19 -04:00
parent d2a2878c11
commit 555d1db3ba
9 changed files with 12 additions and 49 deletions

View file

@ -128,10 +128,7 @@ WindowProps<Child> & {
transition?: HyprTransition;
on_open?(self: PopupWindow<Child, Attr>): void
on_close?(self: PopupWindow<Child, Attr>): void
blur?: boolean
close_on_unfocus?: CloseType
attribute?: Attr;
content?: Widget
anchor?: Array<'top' | 'bottom' | 'right' | 'left'>;
};
import { PopupWindow } from 'ts/misc/popup';

View file

@ -152,5 +152,5 @@ export default () => PopupWindow({
name: 'applauncher',
transition: 'slide top',
keymode: 'on-demand',
content: Applauncher(),
child: Applauncher(),
});

View file

@ -90,7 +90,7 @@ export default () => PopupWindow({
anchor: ['top'],
margins: [TOP_MARGIN, 0, 0, 0],
content: Box({
child: Box({
class_name: 'date',
vertical: true,

View file

@ -1,12 +1,8 @@
import Gtk from 'gi://Gtk?version=3.0';
const Hyprland = await Service.import('hyprland');
const { Box, register } = Widget;
const { timeout } = Utils;
// Types
/* Types */
import { Window } from 'resource:///com/github/Aylur/ags/widgets/window.js';
import { Variable as Var } from 'types/variable';
import {
CloseType,
@ -20,26 +16,17 @@ export class PopupWindow<
Attr,
> extends Window<Child, Attr> {
static {
register(this, {
Widget.register(this, {
properties: {
content: ['widget', 'rw'],
close_on_unfocus: ['string', 'rw'],
transition: ['string', 'rw'],
},
});
}
#content: Var<Gtk.Widget>;
#close_on_unfocus: CloseType;
#transition: HyprTransition;
get content() {
return this.#content.value;
}
set content(value: Gtk.Widget) {
this.#content.setValue(value);
this.child.show_all();
}
get close_on_unfocus() {
return this.#close_on_unfocus;
}
@ -59,7 +46,6 @@ export class PopupWindow<
constructor({
transition = 'slide top',
transition_duration = 800,
on_open = () => {/**/},
on_close = () => {/**/},
@ -68,25 +54,15 @@ export class PopupWindow<
visible = false,
anchor = [],
layer = 'overlay',
attribute,
content = Box(),
blur = false,
close_on_unfocus = 'released',
...rest
}: PopupWindowProps<Child, Attr>) {
const contentVar = Variable(Box() as Gtk.Widget);
if (content) {
contentVar.setValue(content);
}
super({
...rest,
name: `win-${name}`,
visible,
anchor,
layer,
attribute,
setup: () => {
const id = App.connect('config-parsed', () => {
// Add way to make window open on startup
@ -98,17 +74,10 @@ export class PopupWindow<
App.disconnect(id);
});
if (blur) {
Hyprland.messageAsync('[[BATCH]] ' +
`keyword layerrule ignorealpha 0.97, win-${name}; ` +
`keyword layerrule blur, win-${name}`);
}
Hyprland.messageAsync(
`keyword layerrule animation ${transition}, win-${name}`,
);
},
child: contentVar.bind(),
});
this.hook(App, (_, currentName, isOpen) => {
@ -117,14 +86,11 @@ export class PopupWindow<
on_open(this);
}
else {
timeout(Number(transition_duration), () => {
on_close(this);
});
}
}
});
this.#content = contentVar;
this.#close_on_unfocus = close_on_unfocus;
this.#transition = transition;
}

View file

@ -22,5 +22,5 @@ export const NotifCenter = () => PopupWindow({
transition: 'slide bottom',
monitor: 1,
content: NotifCenterWidget(),
child: NotifCenterWidget(),
});

View file

@ -21,5 +21,5 @@ export const NotifCenter = () => PopupWindow({
anchor: ['top', 'right'],
margins: [TOP_MARGIN, 0, 0, 0],
content: NotifCenterWidget(),
child: NotifCenterWidget(),
});

View file

@ -74,5 +74,5 @@ export default () => PopupWindow({
exclusivity: 'ignore',
close_on_unfocus: 'stay',
transition: 'slide bottom',
content: OSDs(),
child: OSDs(),
});

View file

@ -45,5 +45,5 @@ const PowermenuWidget = () => CenterBox({
export default () => PopupWindow({
name: 'powermenu',
transition: 'slide bottom',
content: PowermenuWidget(),
child: PowermenuWidget(),
});

View file

@ -54,5 +54,5 @@ export default () => PopupWindow({
name: 'quick-settings',
anchor: ['top', 'right'],
margins: [TOP_MARGIN, 0, 0, 0],
content: QuickSettingsWidget(),
child: QuickSettingsWidget(),
});