import options from 'src/options'; import { DropdownMenuProps } from 'src/lib/types/dropdownmenu'; import { BarEventMargins } from './eventBoxes/index'; import { globalEventBoxes } from 'src/globals/dropdown'; import { bind } from 'astal'; import { App, Astal, Gdk } from 'astal/gtk3'; import { Revealer } from 'astal/gtk3/widget'; import { locationMap } from 'src/lib/types/defaults/bar'; const { location } = options.theme.bar; export default ({ name, child, transition, exclusivity = Astal.Exclusivity.IGNORE, ...props }: DropdownMenuProps): JSX.Element => { return ( { const key = event.get_keyval()[1]; if (key === Gdk.KEY_Escape) { App.get_window(name)?.set_visible(false); } }} visible={false} application={App} keymode={Astal.Keymode.ON_DEMAND} exclusivity={exclusivity} layer={Astal.Layer.TOP} anchor={bind(location).as((ln) => { if (locationMap[ln] === Astal.WindowAnchor.TOP) { return Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT; } if (locationMap[ln] === Astal.WindowAnchor.BOTTOM) { return Astal.WindowAnchor.BOTTOM | Astal.WindowAnchor.LEFT; } })} {...props} > { const buttonClicked = event.get_button()[1]; if (buttonClicked === Gdk.BUTTON_PRIMARY || buttonClicked === Gdk.BUTTON_SECONDARY) { App.get_window(name)?.set_visible(false); } }} > {bind(location).as((lcn) => { if (locationMap[lcn] === Astal.WindowAnchor.TOP) { return ; } return ; })} { const buttonClicked = event.get_button()[1]; if (buttonClicked === Gdk.BUTTON_PRIMARY || buttonClicked === Gdk.BUTTON_SECONDARY) { return true; } }} setup={(self) => { globalEventBoxes.set({ ...globalEventBoxes.get(), [name]: self, }); }} > { App.connect('window-toggled', (_, window) => { self.set_reveal_child(window.visible); }); }} transitionType={transition} transitionDuration={bind(options.menus.transitionTime)} > {child} {bind(location).as((lcn) => { if (locationMap[lcn] === Astal.WindowAnchor.BOTTOM) { return ; } return ; })} ); };