refactor(ags): use export default where possible and make windows funcs so they're only called in config.js

This commit is contained in:
matt1432 2023-10-16 18:11:19 -04:00
parent 92fbddea8d
commit d719d445be
13 changed files with 41 additions and 38 deletions

View file

@ -1,17 +1,15 @@
import { App, Utils } from './imports.js'; import { App, Utils } from './imports.js';
import { Powermenu } from './js/powermenu.js'; import Closer from './js/misc/closer.js';
import { Bar } from './js/bar/main.js'; import Powermenu from './js/powermenu.js';
import { NotificationCenter } from './js/notifications/center.js'; import { Bar } from './js/bar/main.js';
import { NotificationsPopupList } from './js/notifications/popup.js' import NotifCenter from './js/notifications/center.js';
import { Calendar } from './js/date.js'; import NotifPopups from './js/notifications/popup.js'
import { QuickSettings } from './js/quick-settings/main.js'; import Calendar from './js/date.js';
import Overview from './js/overview/main.js'; import QuickSettings from './js/quick-settings/main.js';
import AppLauncher from './js/applauncher/main.js'; import Overview from './js/overview/main.js';
import * as Corners from './js/screen-corners.js'; import AppLauncher from './js/applauncher/main.js';
import * as Corners from './js/screen-corners.js';
import { Closer, closeAll } from './js/misc/closer.js';
globalThis.closeAll = () => closeAll();
const scss = App.configDir + '/scss/main.scss'; const scss = App.configDir + '/scss/main.scss';
@ -35,15 +33,15 @@ export default {
'applauncher': 500, 'applauncher': 500,
}, },
windows: [ windows: [
Powermenu, Powermenu(),
Bar, Bar(),
Closer, Closer(),
NotificationCenter, NotifCenter(),
NotificationsPopupList, NotifPopups(),
Calendar, Calendar(),
QuickSettings, QuickSettings(),
Overview, Overview(),
AppLauncher, AppLauncher(),
Corners.Bottomleft(), Corners.Bottomleft(),
Corners.Bottomright(), Corners.Bottomright(),
], ],

View file

@ -114,8 +114,7 @@ const Applauncher = ({ windowName = 'applauncher' } = {}) => {
}); });
}; };
// FIXME: make it unfocusable export default () => PopupWindow({
export default PopupWindow({
name: 'applauncher', name: 'applauncher',
focusable: true, focusable: true,
child: Applauncher(), child: Applauncher(),

View file

@ -17,15 +17,14 @@ import { Revealer } from './fullscreen.js';
//import KeyboardLayout from './keyboard-layout.js'; //import KeyboardLayout from './keyboard-layout.js';
export const Bar = Window({ export const Bar = () => Window({
name: 'bar', name: 'bar',
layer: 'overlay', layer: 'overlay',
anchor: [ 'top', 'left', 'right' ], anchor: [ 'top', 'left', 'right' ],
exclusive: true, exclusive: true,
child: Revealer({ child: Revealer({
child: CenterBox({ child: CenterBox({
className: 'transparent', className: 'bar',
style: 'margin: 5px',
vertical: false, vertical: false,
startWidget: Box({ startWidget: Box({

View file

@ -72,7 +72,7 @@ const CalendarWidget = () => Box({
}), }),
}); });
export const Calendar = PopupWindow({ export default () => PopupWindow({
anchor: [ 'top', 'right' ], anchor: [ 'top', 'right' ],
margin: [ 8, 182, 0, 0], margin: [ 8, 182, 0, 0],
name: 'calendar', name: 'calendar',

View file

@ -14,13 +14,14 @@ const ALWAYS_OPEN = [
]; ];
export const closeAll = () => { const closeAll = () => {
App.windows.forEach(w => { App.windows.forEach(w => {
if (!ALWAYS_OPEN.some(window => window === w.name)) if (!ALWAYS_OPEN.some(window => window === w.name))
App.closeWindow(w.name) App.closeWindow(w.name)
}); });
App.closeWindow('closer'); App.closeWindow('closer');
}; };
globalThis.closeAll = () => closeAll();
Pointers.connect('new-line', (_, out) => { Pointers.connect('new-line', (_, out) => {
if (out) { if (out) {
@ -59,7 +60,7 @@ Pointers.connect('new-line', (_, out) => {
} }
}) })
export const Closer = Window({ export default () => Window({
name: 'closer', name: 'closer',
popup: true, popup: true,
layer: 'top', layer: 'top',

View file

@ -6,7 +6,6 @@ import GLib from 'gi://GLib';
import { Draggable } from '../misc/drag.js'; import { Draggable } from '../misc/drag.js';
import { EventBox } from '../misc/cursorbox.js' import { EventBox } from '../misc/cursorbox.js'
import { closeAll } from '../misc/closer.js';
const NotificationIcon = notif => { const NotificationIcon = notif => {
@ -19,7 +18,7 @@ const NotificationIcon = notif => {
iconCmd = box => { iconCmd = box => {
if (!box.get_parent().get_parent().get_parent().get_parent().get_parent()._dragging) { if (!box.get_parent().get_parent().get_parent().get_parent().get_parent()._dragging) {
execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh ${app.app.get_string('StartupWMClass')} ${app.app.get_string('Exec')}`]).catch(print); execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh ${app.app.get_string('StartupWMClass')} ${app.app.get_string('Exec')}`]).catch(print);
closeAll(); globalThis.closeAll();
} }
} }
} }
@ -28,7 +27,7 @@ const NotificationIcon = notif => {
if (!box.get_parent().get_parent().get_parent().get_parent().get_parent()._dragging) { if (!box.get_parent().get_parent().get_parent().get_parent().get_parent()._dragging) {
execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh discord ${app.app.get_string('Exec')}`]) execAsync(['bash', '-c', `$AGS_PATH/launch-app.sh discord ${app.app.get_string('Exec')}`])
.catch(print); .catch(print);
closeAll(); globalThis.closeAll();
} }
} }
} }

View file

@ -134,7 +134,7 @@ const NotificationCenterWidget = Box({
], ],
}); });
export const NotificationCenter = PopupWindow({ export default () => PopupWindow({
name: 'notification-center', name: 'notification-center',
anchor: [ 'top', 'right' ], anchor: [ 'top', 'right' ],
margin: [ 8, 60, 0, 0 ], margin: [ 8, 60, 0, 0 ],

View file

@ -77,7 +77,7 @@ const PopupList = ({ transition = 'none' } = {}) => Box({
], ],
}); });
export const NotificationsPopupList = Window({ export default () => Window({
name: `notifications`, name: `notifications`,
anchor: [ 'top', 'left' ], anchor: [ 'top', 'left' ],
child: PopupList(), child: PopupList(),

View file

@ -11,7 +11,7 @@ function update(box) {
updateClients(box); updateClients(box);
} }
export default PopupWindow({ export default () => PopupWindow({
name: 'overview', name: 'overview',
transition: 'crossfade', transition: 'crossfade',

View file

@ -37,7 +37,7 @@ const PowermenuWidget = CenterBox({
}), }),
}); });
export const Powermenu = PopupWindow({ export default () => PopupWindow({
name: 'powermenu', name: 'powermenu',
transition: 'crossfade', transition: 'crossfade',
child: PowermenuWidget, child: PowermenuWidget,

View file

@ -69,7 +69,7 @@ const QuickSettingsWidget = Box({
], ],
}); });
export const QuickSettings = PopupWindow({ export default () => PopupWindow({
name: 'quick-settings', name: 'quick-settings',
anchor: [ 'top', 'right' ], anchor: [ 'top', 'right' ],
margin: [ 8, 5, 0, ], margin: [ 8, 5, 0, ],

View file

@ -1,3 +1,7 @@
.bar {
margin: 5px;
}
.osk-toggle, .osk-toggle,
.tablet-toggle, .tablet-toggle,
.heart-toggle { .heart-toggle {

View file

@ -44,6 +44,9 @@ undershoot {
.powermenu-clickhandler { .powermenu-clickhandler {
background-color: black; } background-color: black; }
.bar {
margin: 5px; }
.osk-toggle, .osk-toggle,
.tablet-toggle, .tablet-toggle,
.heart-toggle { .heart-toggle {