Fixed a bug that would prevent the workspace module from being scrolled. (#609)
This commit is contained in:
@@ -162,7 +162,7 @@ const navigateWorkspace = (
|
||||
while (attempts < workspacesList.length) {
|
||||
const targetWS = workspacesList[newIndex];
|
||||
if (!isWorkspaceIgnored(ignoredWorkspaces, targetWS)) {
|
||||
hyprlandService.message_async(`dispatch workspace ${targetWS}`);
|
||||
hyprlandService.dispatch('workspace', targetWS.toString());
|
||||
return;
|
||||
}
|
||||
newIndex = (newIndex + step + workspacesList.length) % workspacesList.length;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import options from 'src/options';
|
||||
import { createThrottledScrollHandlers, getCurrentMonitorWorkspaces } from './helpers';
|
||||
import { BarBoxChild, SelfButton } from 'src/lib/types/bar';
|
||||
import { BarBoxChild } from 'src/lib/types/bar';
|
||||
import { WorkspaceModule } from './workspaces';
|
||||
import { bind, Variable } from 'astal';
|
||||
import { GtkWidget } from 'src/lib/types/widget';
|
||||
import { Gdk } from 'astal/gtk3';
|
||||
import { Astal, Gdk } from 'astal/gtk3';
|
||||
import { isScrollDown, isScrollUp } from 'src/lib/utils';
|
||||
|
||||
const { workspaces, scroll_speed } = options.bar.workspaces;
|
||||
|
||||
@@ -27,23 +28,27 @@ const Workspaces = (monitor = -1): BarBoxChild => {
|
||||
boxClass: 'workspaces',
|
||||
isBox: true,
|
||||
props: {
|
||||
setup: (self: SelfButton): void => {
|
||||
setup: (self: Astal.EventBox): void => {
|
||||
let scrollHandlers: number;
|
||||
Variable.derive([bind(scroll_speed)], (scroll_speed) => {
|
||||
if (scrollHandlers) {
|
||||
self.disconnect(scrollHandlers);
|
||||
}
|
||||
|
||||
const { throttledScrollUp, throttledScrollDown } = createThrottledScrollHandlers(
|
||||
scroll_speed,
|
||||
currentMonitorWorkspaces,
|
||||
);
|
||||
|
||||
const scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => {
|
||||
const eventDirection = event.get_scroll_direction()[1];
|
||||
if (eventDirection === Gdk.ScrollDirection.UP) {
|
||||
throttledScrollUp();
|
||||
} else if (eventDirection === Gdk.ScrollDirection.DOWN) {
|
||||
scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => {
|
||||
if (isScrollUp(event)) {
|
||||
throttledScrollDown();
|
||||
}
|
||||
});
|
||||
|
||||
self.disconnect(scrollHandlers);
|
||||
if (isScrollDown(event)) {
|
||||
throttledScrollUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -26,9 +26,9 @@ export const WidgetContainer = (child: BarBoxChild): JSX.Element => {
|
||||
|
||||
if (child.isBox) {
|
||||
return (
|
||||
<box className={buttonClassName} visible={computeVisible(child)}>
|
||||
{child.component}
|
||||
</box>
|
||||
<eventbox visible={computeVisible(child)} {...child.props}>
|
||||
<box className={buttonClassName}>{child.component}</box>
|
||||
</eventbox>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user