Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configurable scaling priorities in options. #277

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
11 changes: 10 additions & 1 deletion modules/menus/shared/dropdown/locationHandler/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
NotificationAnchor,
OSDAnchor,
OSDOrientation,
ScalingPriority,
WindowLayer,
} from 'lib/types/options';
import { MatugenScheme, MatugenTheme, MatugenVariations } from 'lib/types/options';
Expand Down Expand Up @@ -1053,6 +1054,8 @@ const options = mkOptions(OPTIONS, {
},
},

scalingPriority: opt<ScalingPriority>('gdk'),

terminal: opt('kitty'),

tear: opt(false),
Expand Down
6 changes: 6 additions & 0 deletions widget/settings/pages/config/general/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading