Added configurable scaling priorities in options. (#277)

This commit is contained in:
Jas Singh
2024-09-21 00:43:53 -07:00
committed by GitHub
parent afb245f8d6
commit 6be9030ac5
4 changed files with 21 additions and 1 deletions

View File

@@ -213,3 +213,5 @@ type MatugenTheme = 'light' | 'dark';
export type ColorMapKey = keyof typeof defaultColorMap;
export type ColorMapValue = (typeof defaultColorMap)[ColorMapKey];
export type ScalingPriority = 'gdk' | 'hyprland' | 'both';

View File

@@ -1,5 +1,6 @@
const hyprland = await Service.import('hyprland');
import options from 'options';
import { bash } from 'lib/utils';
import { Widget as TWidget } from 'types/@girs/gtk-3.0/gtk-3.0.cjs';
import { Monitor } from 'types/service/hyprland';
@@ -12,6 +13,7 @@ type NestedBox = Box<NestedRevealer, unknown>;
type NestedEventBox = EventBox<NestedBox, unknown>;
const { location } = options.theme.bar;
const { scalingPriority } = options;
export const moveBoxToCursor = <T extends NestedEventBox>(self: T, fixed: boolean): void => {
if (fixed) {
@@ -49,7 +51,14 @@ export const moveBoxToCursor = <T extends NestedEventBox>(self: T, fixed: boolea
// end of the monitor is the 1430th pixel.
const gdkScale = Utils.exec('bash -c "echo $GDK_SCALE"');
if (/^\d+(.\d+)?$/.test(gdkScale)) {
if (scalingPriority.value === 'both') {
const scale = parseFloat(gdkScale);
monWidth = monWidth / scale;
monHeight = monHeight / scale;
monWidth = monWidth / hyprScaling;
monHeight = monHeight / hyprScaling;
} else if (/^\d+(.\d+)?$/.test(gdkScale) && scalingPriority.value === 'gdk') {
const scale = parseFloat(gdkScale);
monWidth = monWidth / scale;
monHeight = monHeight / scale;

View File

@@ -16,6 +16,7 @@ import {
NotificationAnchor,
OSDAnchor,
OSDOrientation,
ScalingPriority,
WindowLayer,
} from 'lib/types/options';
import { MatugenScheme, MatugenTheme, MatugenVariations } from 'lib/types/options';
@@ -1053,6 +1054,8 @@ const options = mkOptions(OPTIONS, {
},
},
scalingPriority: opt<ScalingPriority>('gdk'),
terminal: opt('kitty'),
tear: opt(false),

View File

@@ -50,6 +50,12 @@ export const BarGeneral = (): Scrollable<Child, Attribute> => {
}),
Header('Scaling'),
Option({
opt: options.scalingPriority,
title: 'Scaling Priority',
type: 'enum',
enums: ['both', 'gdk', 'hyprland'],
}),
Option({
opt: options.theme.bar.scaling,
title: 'Bar',