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) {
|
while (attempts < workspacesList.length) {
|
||||||
const targetWS = workspacesList[newIndex];
|
const targetWS = workspacesList[newIndex];
|
||||||
if (!isWorkspaceIgnored(ignoredWorkspaces, targetWS)) {
|
if (!isWorkspaceIgnored(ignoredWorkspaces, targetWS)) {
|
||||||
hyprlandService.message_async(`dispatch workspace ${targetWS}`);
|
hyprlandService.dispatch('workspace', targetWS.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newIndex = (newIndex + step + workspacesList.length) % workspacesList.length;
|
newIndex = (newIndex + step + workspacesList.length) % workspacesList.length;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import options from 'src/options';
|
import options from 'src/options';
|
||||||
import { createThrottledScrollHandlers, getCurrentMonitorWorkspaces } from './helpers';
|
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 { WorkspaceModule } from './workspaces';
|
||||||
import { bind, Variable } from 'astal';
|
import { bind, Variable } from 'astal';
|
||||||
import { GtkWidget } from 'src/lib/types/widget';
|
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;
|
const { workspaces, scroll_speed } = options.bar.workspaces;
|
||||||
|
|
||||||
@@ -27,23 +28,27 @@ const Workspaces = (monitor = -1): BarBoxChild => {
|
|||||||
boxClass: 'workspaces',
|
boxClass: 'workspaces',
|
||||||
isBox: true,
|
isBox: true,
|
||||||
props: {
|
props: {
|
||||||
setup: (self: SelfButton): void => {
|
setup: (self: Astal.EventBox): void => {
|
||||||
|
let scrollHandlers: number;
|
||||||
Variable.derive([bind(scroll_speed)], (scroll_speed) => {
|
Variable.derive([bind(scroll_speed)], (scroll_speed) => {
|
||||||
|
if (scrollHandlers) {
|
||||||
|
self.disconnect(scrollHandlers);
|
||||||
|
}
|
||||||
|
|
||||||
const { throttledScrollUp, throttledScrollDown } = createThrottledScrollHandlers(
|
const { throttledScrollUp, throttledScrollDown } = createThrottledScrollHandlers(
|
||||||
scroll_speed,
|
scroll_speed,
|
||||||
currentMonitorWorkspaces,
|
currentMonitorWorkspaces,
|
||||||
);
|
);
|
||||||
|
|
||||||
const scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => {
|
scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => {
|
||||||
const eventDirection = event.get_scroll_direction()[1];
|
if (isScrollUp(event)) {
|
||||||
if (eventDirection === Gdk.ScrollDirection.UP) {
|
|
||||||
throttledScrollUp();
|
|
||||||
} else if (eventDirection === Gdk.ScrollDirection.DOWN) {
|
|
||||||
throttledScrollDown();
|
throttledScrollDown();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
self.disconnect(scrollHandlers);
|
if (isScrollDown(event)) {
|
||||||
|
throttledScrollUp();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ export const WidgetContainer = (child: BarBoxChild): JSX.Element => {
|
|||||||
|
|
||||||
if (child.isBox) {
|
if (child.isBox) {
|
||||||
return (
|
return (
|
||||||
<box className={buttonClassName} visible={computeVisible(child)}>
|
<eventbox visible={computeVisible(child)} {...child.props}>
|
||||||
{child.component}
|
<box className={buttonClassName}>{child.component}</box>
|
||||||
</box>
|
</eventbox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { bind } from 'astal';
|
import { bind } from 'astal';
|
||||||
import { Gdk, Gtk } from 'astal/gtk3';
|
import { Gdk, Gtk } from 'astal/gtk3';
|
||||||
import AstalWp from 'gi://AstalWp?version=0.1';
|
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';
|
import options from 'src/options';
|
||||||
|
|
||||||
const { raiseMaximumVolume } = options.menus.volume;
|
const { raiseMaximumVolume } = options.menus.volume;
|
||||||
@@ -34,15 +34,14 @@ export const Slider = ({ device, type }: SliderProps): JSX.Element => {
|
|||||||
}}
|
}}
|
||||||
setup={(self) => {
|
setup={(self) => {
|
||||||
self.connect('scroll-event', (_, event: Gdk.Event) => {
|
self.connect('scroll-event', (_, event: Gdk.Event) => {
|
||||||
const [directionSuccess, direction] = event.get_scroll_direction();
|
if (isScrollUp(event)) {
|
||||||
const [deltasSuccess, , yScroll] = event.get_scroll_deltas();
|
const newVolume = device.volume + 0.05;
|
||||||
|
device.set_volume(Math.min(newVolume, 1));
|
||||||
|
}
|
||||||
|
|
||||||
if (directionSuccess) {
|
if (isScrollDown(event)) {
|
||||||
const newVolume = device.volume + (direction === Gdk.ScrollDirection.DOWN ? 0.05 : -0.05);
|
const newVolume = device.volume - 0.05;
|
||||||
device.set_volume(Math.min(newVolume, 1));
|
device.set_volume(newVolume);
|
||||||
} else if (deltasSuccess) {
|
|
||||||
const newVolume = device.volume - yScroll / 100;
|
|
||||||
device.set_volume(Math.min(newVolume, 1));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
2
src/lib/types/bar.d.ts
vendored
2
src/lib/types/bar.d.ts
vendored
@@ -13,7 +13,7 @@ export type BarBoxChild = {
|
|||||||
isBox?: boolean;
|
isBox?: boolean;
|
||||||
boxClass: string;
|
boxClass: string;
|
||||||
tooltip_text?: string | Binding<string>;
|
tooltip_text?: string | Binding<string>;
|
||||||
} & ({ isBox: true; props: Widget.BoxProps } | { isBox?: false; props: Widget.ButtonProps });
|
} & ({ isBox: true; props: Widget.EventBoxProps } | { isBox?: false; props: Widget.ButtonProps });
|
||||||
|
|
||||||
export type SelfButton = Button<Child, Attribute>;
|
export type SelfButton = Button<Child, Attribute>;
|
||||||
|
|
||||||
|
|||||||
@@ -399,7 +399,20 @@ export const isMiddleClick = (event: Astal.ClickEvent): boolean => event.button
|
|||||||
*
|
*
|
||||||
* @returns True if the event is a scroll up, false otherwise.
|
* @returns True if the event is a scroll up, false otherwise.
|
||||||
*/
|
*/
|
||||||
export const isScrollUp = (event: Astal.ScrollEvent): boolean => event.direction === Gdk.ScrollDirection.UP;
|
export const isScrollUp = (event: Gdk.Event): boolean => {
|
||||||
|
const [directionSuccess, direction] = event.get_scroll_direction();
|
||||||
|
const [deltaSuccess, , yScroll] = event.get_scroll_deltas();
|
||||||
|
|
||||||
|
if (directionSuccess && direction === Gdk.ScrollDirection.UP) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deltaSuccess && yScroll < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an event is a scroll down.
|
* Checks if an event is a scroll down.
|
||||||
@@ -410,4 +423,17 @@ export const isScrollUp = (event: Astal.ScrollEvent): boolean => event.direction
|
|||||||
*
|
*
|
||||||
* @returns True if the event is a scroll down, false otherwise.
|
* @returns True if the event is a scroll down, false otherwise.
|
||||||
*/
|
*/
|
||||||
export const isScrollDown = (event: Astal.ScrollEvent): boolean => event.direction === Gdk.ScrollDirection.DOWN;
|
export const isScrollDown = (event: Gdk.Event): boolean => {
|
||||||
|
const [directionSuccess, direction] = event.get_scroll_direction();
|
||||||
|
const [deltaSuccess, , yScroll] = event.get_scroll_deltas();
|
||||||
|
|
||||||
|
if (directionSuccess && direction === Gdk.ScrollDirection.DOWN) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deltaSuccess && yScroll > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user