overview & cheatsheet: fix window focus after open/close layer with kb (#502)

This commit is contained in:
end-4
2024-05-18 15:23:48 +07:00
parent 8955fcab2b
commit ecfacef55f
4 changed files with 66 additions and 26 deletions
@@ -0,0 +1,16 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
const { Box, EventBox } = Widget;
export const clickCloseRegion = ({ name, multimonitor = true, expand = true }) => {
return EventBox({
child: Box({ expand: expand }),
setup: (self) => self.on('button-press-event', (self, event) => { // Any mouse button
if (multimonitor) closeWindowOnAllMonitors(name);
else App.closeWindow(name);
}),
})
}
export default clickCloseRegion;
+36 -23
View File
@@ -5,6 +5,7 @@ import Keybinds from "./keybinds.js";
import PeriodicTable from "./periodictable.js"; import PeriodicTable from "./periodictable.js";
import { ExpandingIconTabContainer } from '../.commonwidgets/tabcontainer.js'; import { ExpandingIconTabContainer } from '../.commonwidgets/tabcontainer.js';
import { checkKeybind } from '../.widgetutils/keybind.js'; import { checkKeybind } from '../.widgetutils/keybind.js';
import clickCloseRegion from '../.commonwidgets/clickcloseregion.js';
const cheatsheets = [ const cheatsheets = [
{ {
@@ -86,29 +87,41 @@ const SheetContent = (id) => {
return sheetContents[id]; return sheetContents[id];
} }
export default (id) => PopupWindow({ export default (id) => {
monitor: id, const widgetContent = Widget.Box({
name: `cheatsheet${id}`,
layer: 'overlay',
keymode: 'on-demand',
visible: false,
child: Widget.Box({
vertical: true, vertical: true,
className: "cheatsheet-bg spacing-v-5",
children: [ children: [
Widget.Box({ CheatsheetHeader(),
vertical: true, SheetContent(id),
className: "cheatsheet-bg spacing-v-5", ]
children: [ });
CheatsheetHeader(), return PopupWindow({
SheetContent(id), monitor: id,
] name: `cheatsheet${id}`,
}), layer: 'overlay',
], keymode: 'on-demand',
setup: (self) => self.on('key-press-event', (widget, event) => { // Typing visible: false,
if (checkKeybind(event, userOptions.keybinds.cheatsheet.nextTab)) anchor: ['top', 'bottom', 'left', 'right'],
sheetContents[id].nextTab(); child: Widget.Box({
else if (checkKeybind(event, userOptions.keybinds.cheatsheet.prevTab)) vertical: true,
sheetContents[id].prevTab(); children: [
clickCloseRegion({ name: 'cheatsheet' }),
Widget.Box({
children: [
clickCloseRegion({ name: 'cheatsheet' }),
widgetContent,
clickCloseRegion({ name: 'cheatsheet' }),
]
}),
clickCloseRegion({ name: 'cheatsheet' }),
],
setup: (self) => self.on('key-press-event', (widget, event) => { // Typing
if (checkKeybind(event, userOptions.keybinds.cheatsheet.nextTab))
sheetContents[id].nextTab();
else if (checkKeybind(event, userOptions.keybinds.cheatsheet.prevTab))
sheetContents[id].prevTab();
})
}) })
}) });
}); }
+2 -1
View File
@@ -4,7 +4,7 @@ import PopupWindow from '../.widgethacks/popupwindow.js';
import { monitors } from '../.miscutils/hyprlanddata.js'; import { monitors } from '../.miscutils/hyprlanddata.js';
const WINDOWS_NEED_CLICK2CLOSE = [ const WINDOWS_NEED_CLICK2CLOSE = [
'sideleft', 'sideright', 'overview', 'cheatsheet' 'sideleft', 'sideright'
]; ];
const range = (length, start = 1) => Array.from({ length }, (_, i) => i + start); const range = (length, start = 1) => Array.from({ length }, (_, i) => i + start);
@@ -15,6 +15,7 @@ export default (monitor = 0) => PopupWindow({
layer: 'top', layer: 'top',
anchor: ['top', 'bottom', 'left', 'right'], anchor: ['top', 'bottom', 'left', 'right'],
exclusivity: 'ignore', exclusivity: 'ignore',
keymode: 'none',
child: Widget.EventBox({ child: Widget.EventBox({
attribute: { attribute: {
checkWindowRelevance: (currentName) => { checkWindowRelevance: (currentName) => {
+12 -2
View File
@@ -1,18 +1,28 @@
import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import { SearchAndWindows } from "./windowcontent.js"; import { SearchAndWindows } from "./windowcontent.js";
import PopupWindow from '../.widgethacks/popupwindow.js'; import PopupWindow from '../.widgethacks/popupwindow.js';
import { clickCloseRegion } from '../.commonwidgets/clickcloseregion.js';
export default (id = '') => PopupWindow({ export default (id = '') => PopupWindow({
name: `overview${id}`, name: `overview${id}`,
// exclusivity: 'ignore', // exclusivity: 'ignore',
keymode: 'on-demand', keymode: 'on-demand',
visible: false, visible: false,
anchor: ['top'], anchor: ['top', 'bottom', 'left', 'right'],
layer: 'overlay', layer: 'overlay',
child: Widget.Box({ child: Widget.Box({
vertical: true, vertical: true,
children: [ children: [
SearchAndWindows(), clickCloseRegion({ name: 'overview', multimonitor: false, expand: false }),
Widget.Box({
children: [
clickCloseRegion({ name: 'overview', multimonitor: false }),
SearchAndWindows(),
clickCloseRegion({ name: 'overview', multimonitor: false }),
]
}),
clickCloseRegion({ name: 'overview', multimonitor: false }),
] ]
}), }),
}) })