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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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