Added an option to make HyprPanel compatible with Hyprland tearing. (#243)

* Adding an option to make HyprPanel compatible with Hyprland tearing.

* Added bar to Tearing Compatibility checks
This commit is contained in:
Jas Singh
2024-09-10 00:58:27 -07:00
committed by GitHub
parent 4721b4fbf9
commit af51aa838d
6 changed files with 41 additions and 15 deletions

View File

@@ -48,6 +48,8 @@ export type OSDOrientation = "horizontal" | "vertical";
export type HexColor = `#${string}`; export type HexColor = `#${string}`;
export type WindowLayer = "top" | "bottom" | "overlay" | "background";
export type MatugenColors = { export type MatugenColors = {
"background": HexColor, "background": HexColor,
"error": HexColor, "error": HexColor,

View File

@@ -29,6 +29,7 @@ import Button from "types/widgets/button.js";
import Gtk from "types/@girs/gtk-3.0/gtk-3.0.js"; import Gtk from "types/@girs/gtk-3.0/gtk-3.0.js";
import './SideEffects'; import './SideEffects';
import { WindowLayer } from "lib/types/options.js";
const { layouts } = options.bar; const { layouts } = options.bar;
@@ -44,14 +45,14 @@ type Section = "battery"
| "network" | "network"
| "bluetooth" | "bluetooth"
| "clock" | "clock"
| "Ram" | "ram"
| "Cpu" | "cpu"
| "Storage" | "storage"
| "Netstat" | "netstat"
| "KbInput" | "kbinput"
| "Updates" | "updates"
| "Weather" | "weather"
| "Power" | "power"
| "systray"; | "systray";
type Layout = { type Layout = {
@@ -134,7 +135,7 @@ function getGdkMonitors(): GdkMonitors {
} }
const numGdkMonitors = display.get_n_monitors(); const numGdkMonitors = display.get_n_monitors();
const gdkMonitors = {}; const gdkMonitors: GdkMonitors = {};
for (let i = 0; i < numGdkMonitors; i++) { for (let i = 0; i < numGdkMonitors; i++) {
const curMonitor = display.get_monitor(i); const curMonitor = display.get_monitor(i);
@@ -144,7 +145,7 @@ function getGdkMonitors(): GdkMonitors {
continue; continue;
} }
const model = curMonitor.get_model(); const model = curMonitor.get_model() || '';
const geometry = curMonitor.get_geometry(); const geometry = curMonitor.get_geometry();
const scaleFactor = curMonitor.get_scale_factor(); const scaleFactor = curMonitor.get_scale_factor();
@@ -260,7 +261,20 @@ export const Bar = (() => {
visible: true, visible: true,
anchor: ["top", "left", "right"], anchor: ["top", "left", "right"],
exclusivity: "exclusive", exclusivity: "exclusive",
layer: options.theme.bar.layer.bind("value"), layer: Utils.merge(
[
options.theme.bar.layer.bind("value"),
options.tear.bind("value")
],
(
barLayer: WindowLayer,
tear: boolean
) => {
if (tear && barLayer === "overlay") {
return "top";
}
return barLayer;
}),
child: Widget.Box({ child: Widget.Box({
class_name: 'bar-panel-container', class_name: 'bar-panel-container',
child: Widget.CenterBox({ child: Widget.CenterBox({

View File

@@ -40,7 +40,7 @@ export default () => {
return mon; return mon;
} }
), ),
layer: "overlay", layer: options.tear.bind("value").as(tear => tear ? "top" : "overlay"),
anchor: position.bind("value").as(v => getPosition(v)), anchor: position.bind("value").as(v => getPosition(v)),
exclusivity: "normal", exclusivity: "normal",
child: Widget.Box({ child: Widget.Box({

View File

@@ -98,7 +98,7 @@ export default () => Widget.Window({
}), }),
name: `indicator`, name: `indicator`,
class_name: "indicator", class_name: "indicator",
layer: "overlay", layer: options.tear.bind("value").as(tear => tear ? "top" : "overlay"),
anchor: location.bind("value").as(v => getPosition(v)), anchor: location.bind("value").as(v => getPosition(v)),
click_through: true, click_through: true,
child: Widget.Box({ child: Widget.Box({

View File

@@ -1,7 +1,7 @@
import { opt, mkOptions } from "lib/option" import { opt, mkOptions } from "lib/option"
import { NetstatIcon, NetstatLabelType, PowerIcon, RateUnit, ResourceLabelType, StorageIcon, UpdatesIcon } from "lib/types/bar"; import { NetstatIcon, NetstatLabelType, PowerIcon, RateUnit, ResourceLabelType, StorageIcon, UpdatesIcon } from "lib/types/bar";
import { KbIcon, KbLabelType } from "lib/types/customModules/kbLayout"; import { KbIcon, KbLabelType } from "lib/types/customModules/kbLayout";
import { BarButtonStyles, NotificationAnchor, OSDAnchor, OSDOrientation } from "lib/types/options"; import { BarButtonStyles, NotificationAnchor, OSDAnchor, OSDOrientation, WindowLayer } from "lib/types/options";
import { MatugenScheme, MatugenTheme, MatugenVariation } from "lib/types/options"; import { MatugenScheme, MatugenTheme, MatugenVariation } from "lib/types/options";
import { UnitType } from "lib/types/weather"; import { UnitType } from "lib/types/weather";
@@ -130,7 +130,7 @@ const options = mkOptions(OPTIONS, {
bar: { bar: {
scaling: opt(100), scaling: opt(100),
floating: opt(false), floating: opt(false),
layer: opt<"top" | "bottom" | "overlay" | "background">("top"), layer: opt<WindowLayer>("top"),
margin_top: opt("0.5em"), margin_top: opt("0.5em"),
opacity: opt(100), opacity: opt(100),
margin_bottom: opt("0em"), margin_bottom: opt("0em"),
@@ -1067,6 +1067,8 @@ const options = mkOptions(OPTIONS, {
terminal: opt("kitty"), terminal: opt("kitty"),
tear: opt(false),
wallpaper: { wallpaper: {
enable: opt(true), enable: opt(true),
image: opt(""), image: opt(""),

View File

@@ -25,6 +25,14 @@ export const BarGeneral = () => {
} }
}), }),
Option({ opt: options.terminal, title: 'Terminal', subtitle: "Tools such as 'btop' will open in this terminal", type: 'string' }), Option({ opt: options.terminal, title: 'Terminal', subtitle: "Tools such as 'btop' will open in this terminal", type: 'string' }),
Option({
opt: options.tear,
title: 'Tearing Compatible',
subtitle:
"Makes HyprPanel compatible with Hyprland tearing.\n" +
"Enabling this will change all overlays (Notifications, OSDs, Bar) to the \'top\' layer instead the \'overlay\' layer.",
type: 'boolean'
}),
Header('Scaling'), Header('Scaling'),
Option({ opt: options.theme.bar.scaling, title: 'Bar', type: 'number', min: 1, max: 100, increment: 5 }), Option({ opt: options.theme.bar.scaling, title: 'Bar', type: 'number', min: 1, max: 100, increment: 5 }),