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;
+24 -11
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,23 +87,34 @@ 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,
children: [
Widget.Box({
vertical: true, vertical: true,
className: "cheatsheet-bg spacing-v-5", className: "cheatsheet-bg spacing-v-5",
children: [ children: [
CheatsheetHeader(), CheatsheetHeader(),
SheetContent(id), SheetContent(id),
] ]
});
return PopupWindow({
monitor: id,
name: `cheatsheet${id}`,
layer: 'overlay',
keymode: 'on-demand',
visible: false,
anchor: ['top', 'bottom', 'left', 'right'],
child: Widget.Box({
vertical: true,
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 setup: (self) => self.on('key-press-event', (widget, event) => { // Typing
if (checkKeybind(event, userOptions.keybinds.cheatsheet.nextTab)) if (checkKeybind(event, userOptions.keybinds.cheatsheet.nextTab))
@@ -111,4 +123,5 @@ export default (id) => PopupWindow({
sheetContents[id].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) => {
+11 -1
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: [
clickCloseRegion({ name: 'overview', multimonitor: false, expand: false }),
Widget.Box({
children: [
clickCloseRegion({ name: 'overview', multimonitor: false }),
SearchAndWindows(), SearchAndWindows(),
clickCloseRegion({ name: 'overview', multimonitor: false }),
]
}),
clickCloseRegion({ name: 'overview', multimonitor: false }),
] ]
}), }),
}) })