Fixed a bug that would prevent the workspace module from being scrolled. (#609)

This commit is contained in:
Jas Singh
2024-12-24 01:09:09 -08:00
committed by GitHub
parent af88c267f4
commit d8a59c1d18
6 changed files with 56 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
import { bind } from 'astal';
import { Gdk, Gtk } from 'astal/gtk3';
import AstalWp from 'gi://AstalWp?version=0.1';
import { capitalizeFirstLetter } from 'src/lib/utils';
import { capitalizeFirstLetter, isScrollDown, isScrollUp } from 'src/lib/utils';
import options from 'src/options';
const { raiseMaximumVolume } = options.menus.volume;
@@ -34,15 +34,14 @@ export const Slider = ({ device, type }: SliderProps): JSX.Element => {
}}
setup={(self) => {
self.connect('scroll-event', (_, event: Gdk.Event) => {
const [directionSuccess, direction] = event.get_scroll_direction();
const [deltasSuccess, , yScroll] = event.get_scroll_deltas();
if (isScrollUp(event)) {
const newVolume = device.volume + 0.05;
device.set_volume(Math.min(newVolume, 1));
}
if (directionSuccess) {
const newVolume = device.volume + (direction === Gdk.ScrollDirection.DOWN ? 0.05 : -0.05);
device.set_volume(Math.min(newVolume, 1));
} else if (deltasSuccess) {
const newVolume = device.volume - yScroll / 100;
device.set_volume(Math.min(newVolume, 1));
if (isScrollDown(event)) {
const newVolume = device.volume - 0.05;
device.set_volume(newVolume);
}
});
}}