diff --git a/src/runner/Runner.tsx b/src/runner/Runner.tsx index 3009e90..9a3f4b7 100644 --- a/src/runner/Runner.tsx +++ b/src/runner/Runner.tsx @@ -225,14 +225,12 @@ function selectNextItem(listbox: Gtk.ListBox) { return; const viewport = listbox.parent as Gtk.Viewport; - const vadjustment = viewport.vadjustment; - const [, , nextRowY] = nextRow.translate_coordinates(viewport, - nextRow.get_allocation().x, nextRow.get_allocation().y); + const vadjustment = (viewport.parent as Gtk.ScrolledWindow).get_vadjustment(); + const nextRowVAllocation = (nextRow.get_allocation().y + nextRow.get_allocation().height); listbox.select_row(nextRow as Gtk.ListBoxRow); - if(vadjustment.value < nextRowY) - vadjustment.set_value(nextRowY - vadjustment.value); -} + if(nextRowVAllocation > viewport.get_allocation().height) + vadjustment.set_value(nextRow.get_allocation().y - viewport.get_allocation().height + nextRow.get_allocation().height);} export function openRunner(props: RunnerProps, placeholders?: Array): Astal.Window { props.width ??= 780; @@ -245,16 +243,16 @@ export function openRunner(props: RunnerProps, placeholders?: Array): As { + valign={Gtk.Align.START} hexpand orientation={Gtk.Orientation.VERTICAL} + $={() => { plugins.forEach(plugin => plugin.init?.()); props.initialText && Runner.setEntryText(props.initialText); }} actionKeyPressed={(self, keyval) => { - const listbox = ((getPopupWindowContainer(self).get_first_child()! - .get_last_child()! as Gtk.ScrolledWindow).get_child()! as Gtk.Viewport) - .get_child()! as Gtk.ListBox; + const listbox = ((getPopupWindowContainer(self).get_last_child() as Gtk.ScrolledWindow) + .get_child() as Gtk.Viewport).get_child() as Gtk.ListBox; switch(keyval) { case Gdk.KEY_F5: @@ -279,8 +277,10 @@ export function openRunner(props: RunnerProps, placeholders?: Array): As return; } - !gtkEntry?.hasFocus && + if(!gtkEntry?.hasFocus) { gtkEntry?.grab_focus(); + listbox.grab_focus(); + } }} actionClosed={() => { [...plugins.values()].forEach(plugin => plugin?.onClose?.()); root.dispose(); @@ -288,45 +288,45 @@ export function openRunner(props: RunnerProps, placeholders?: Array): As instance = null; gtkEntry = null; }}> - + gtkEntry = self} searchDelay={0} onSearchChanged={(self) => { + const listbox = ((self.get_next_sibling()! as Gtk.ScrolledWindow) + .get_child() as Gtk.Viewport).get_child() as Gtk.ListBox; + updateResultsList(listbox, self.text, placeholders); - gtkEntry = self} searchDelay={0} onSearchChanged={(self) => { - const listbox = self.get_next_sibling()?.get_first_child()?.get_first_child() as Gtk.ListBox; - updateResultsList(listbox, self.text, placeholders); + listbox.get_row_at_index(0) && + listbox.select_row(listbox.get_row_at_index(0)); + }} onActivate={(self) => { + const listbox = ((self.get_next_sibling() as Gtk.ScrolledWindow) + .get_child() as Gtk.Viewport).get_child() as Gtk.ListBox; + const resultWidget = listbox.get_selected_row()?.get_child(); - listbox.get_row_at_index(0) && - listbox.select_row(listbox.get_row_at_index(0)); - }} onActivate={(self) => { - const listbox = self.parent.get_last_child()?.get_first_child()?.get_first_child() as Gtk.ListBox; - const resultWidget = listbox.get_selected_row()?.get_child(); + if(resultWidget instanceof ResultWidget && !clickTimeout) { + clickTimeout = timeout(250, () => clickTimeout = undefined); + resultWidget.actionClick(); + resultWidget.closeOnClick && + Runner.close(); + } - if(resultWidget instanceof ResultWidget) { - resultWidget.actionClick(); - resultWidget.closeOnClick && + }} onStopSearch={() => Runner.close()} // close Runner on Escape + /> + + + { + const child = row.get_child()!; + + if(child instanceof ResultWidget && !clickTimeout) { + clickTimeout = timeout(250, () => clickTimeout = undefined); + child.actionClick?.(); + child.closeOnClick && Runner.close(); } - }} onStopSearch={() => Runner.close()} // close Runner on Escape + }} /> - - - { - const child = row.get_child()!; - - if(child instanceof ResultWidget && !clickTimeout) { - clickTimeout = timeout(250, () => clickTimeout = undefined); - child.actionClick?.(); - child.closeOnClick && - Runner.close(); - } - }} - /> - - + as Astal.Window )();