From b9102a4a867a5b7d3ce9132c71ab9c541d3f5e41 Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Thu, 16 Jan 2025 00:48:51 +0900 Subject: [PATCH 1/9] Fix overview widget for multi monitors --- .../ags/modules/overview/overview_hyprland.js | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index ebbe07f4e..2bb207330 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -21,8 +21,9 @@ const NUM_OF_WORKSPACES_SHOWN = userOptions.overview.numOfCols * userOptions.ove const TARGET = [Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags.SAME_APP, 0)]; const overviewTick = Variable(false); +const overviewMonitor = Variable(0); -export default (overviewMonitor = 0) => { +export default () => { const clientMap = new Map(); const ContextMenuWorkspaceArray = ({ label, actionFunc, thisWorkspace }) => Widget.MenuItem({ label: `${label}`, @@ -64,11 +65,14 @@ export default (overviewMonitor = 0) => { if (monitors.length - 1 < monitor) { monitor = monitors.length - 1; } + // Properly scale for multi monitors + w *= monitors[overviewMonitor.value].width / monitors[monitor].width; + h *= monitors[overviewMonitor.value].height / monitors[monitor].height; // Truncate if offscreen if (x + w > monitors[monitor].width) w = monitors[monitor].width - x; if (y + h > monitors[monitor].height) h = monitors[monitor].height - y; - if(c.length == 0) c = initialClass; + if (c.length == 0) c = initialClass; const iconName = substitute(c); const appIcon = iconExists(iconName) ? Widget.Icon({ icon: iconName, @@ -220,10 +224,10 @@ export default (overviewMonitor = 0) => { const WorkspaceNumber = ({ index, ...rest }) => Widget.Label({ className: 'overview-tasks-workspace-number', label: `${index}`, - css: ` - margin: ${Math.min(monitors[overviewMonitor].width, monitors[overviewMonitor].height) * userOptions.overview.scale * userOptions.overview.wsNumMarginScale}px; - font-size: ${monitors[overviewMonitor].height * userOptions.overview.scale * userOptions.overview.wsNumScale}px; - `, + css: overviewMonitor.bind().as(monitor => ` + margin: ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale * userOptions.overview.wsNumMarginScale}px; + font-size: ${monitors[monitor].height * userOptions.overview.scale * userOptions.overview.wsNumScale}px; + `), setup: (self) => self.hook(Hyprland.active.workspace, (self) => { // Update when going to new ws group const currentGroup = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN); @@ -235,10 +239,10 @@ export default (overviewMonitor = 0) => { className: 'overview-tasks-workspace', vpack: 'center', // Rounding and adding 1px to minimum width/height to work around scaling inaccuracy: - css: ` - min-width: ${1 + Math.round(monitors[overviewMonitor].width * userOptions.overview.scale)}px; - min-height: ${1 + Math.round(monitors[overviewMonitor].height * userOptions.overview.scale)}px; - `, + css: overviewMonitor.bind().as(monitor => ` + min-width: ${1 + Math.round(monitors[monitor].width * userOptions.overview.scale)}px; + min-height: ${1 + Math.round(monitors[monitor].height * userOptions.overview.scale)}px; + `), children: [Widget.EventBox({ hexpand: true, onPrimaryClick: () => { @@ -431,5 +435,5 @@ export default (overviewMonitor = 0) => { }) ) }), - }); + }).hook(Hyprland, () => { overviewMonitor.value = Hyprland.active.monitor.id; }); } From daeae9a0f862865afc94a721843ba18f59d01e1a Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Thu, 16 Jan 2025 01:02:25 +0900 Subject: [PATCH 2/9] Change execution order --- .config/ags/modules/overview/overview_hyprland.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index 2bb207330..2d51adfb8 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -65,12 +65,12 @@ export default () => { if (monitors.length - 1 < monitor) { monitor = monitors.length - 1; } - // Properly scale for multi monitors - w *= monitors[overviewMonitor.value].width / monitors[monitor].width; - h *= monitors[overviewMonitor.value].height / monitors[monitor].height; // Truncate if offscreen if (x + w > monitors[monitor].width) w = monitors[monitor].width - x; if (y + h > monitors[monitor].height) h = monitors[monitor].height - y; + // Properly scale for multi monitors + w *= monitors[overviewMonitor.value].width / monitors[monitor].width; + h *= monitors[overviewMonitor.value].height / monitors[monitor].height; if (c.length == 0) c = initialClass; const iconName = substitute(c); From 546e949c9ea4933ddb94d3ee6012ac43ecc7669b Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Thu, 16 Jan 2025 01:07:08 +0900 Subject: [PATCH 3/9] Revert execution order and properly fix the code --- .config/ags/modules/overview/overview_hyprland.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index 2d51adfb8..bbdda34e5 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -65,12 +65,12 @@ export default () => { if (monitors.length - 1 < monitor) { monitor = monitors.length - 1; } - // Truncate if offscreen - if (x + w > monitors[monitor].width) w = monitors[monitor].width - x; - if (y + h > monitors[monitor].height) h = monitors[monitor].height - y; // Properly scale for multi monitors w *= monitors[overviewMonitor.value].width / monitors[monitor].width; h *= monitors[overviewMonitor.value].height / monitors[monitor].height; + // Truncate if offscreen + if (x + w > monitors[overviewMonitor.value].width) w = monitors[overviewMonitor.value].width - x; + if (y + h > monitors[overviewMonitor.value].height) h = monitors[overviewMonitor.value].height - y; if (c.length == 0) c = initialClass; const iconName = substitute(c); From db1b814d1bf862d5bce35827399284938175551c Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Thu, 16 Jan 2025 01:24:53 +0900 Subject: [PATCH 4/9] Fix overviewMonitor update timing --- .config/ags/modules/overview/overview_hyprland.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index bbdda34e5..d0755902a 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -414,7 +414,10 @@ export default () => { } }) .hook(App, (box, name, visible) => { // Update on open - if (name == 'overview' && visible) box.attribute.update(box); + if (name == 'overview' && visible) { + overviewMonitor.value = Hyprland.active.monitor.id + box.attribute.update(box); + } }) }, }); @@ -434,6 +437,6 @@ export default () => { workspaces: userOptions.overview.numOfCols, }) ) - }), - }).hook(Hyprland, () => { overviewMonitor.value = Hyprland.active.monitor.id; }); + }) + }) } From 2aaacc625f3d019bd5b0f4efa46cd326763b1d88 Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Thu, 16 Jan 2025 01:25:34 +0900 Subject: [PATCH 5/9] Add semicolon --- .config/ags/modules/overview/overview_hyprland.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index d0755902a..362e9e610 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -438,5 +438,5 @@ export default () => { }) ) }) - }) + }); } From c06af2c47c586cd2e088cc143e96d644a598702b Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Thu, 16 Jan 2025 01:27:29 +0900 Subject: [PATCH 6/9] Add another missing semicolon --- .config/ags/modules/overview/overview_hyprland.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index 362e9e610..0ce07d146 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -415,7 +415,7 @@ export default () => { }) .hook(App, (box, name, visible) => { // Update on open if (name == 'overview' && visible) { - overviewMonitor.value = Hyprland.active.monitor.id + overviewMonitor.value = Hyprland.active.monitor.id; box.attribute.update(box); } }) From b03a48421cf15a06a11496aa5556fa118d3ab8b6 Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Fri, 17 Jan 2025 16:31:22 +0900 Subject: [PATCH 7/9] Fix font-size consistency --- .config/ags/modules/overview/overview_hyprland.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index 0ce07d146..77d3bb3ca 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -152,10 +152,10 @@ export default () => { maxWidthChars: 1, // Doesn't matter what number truncate: 'end', className: `margin-top-5 ${xwayland ? 'txt txt-italic' : 'txt'}`, - css: ` + css: overviewMonitor.bind().as(monitor => ` font-size: ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale / 14.6}px; margin: 0px ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale / 10}px; - `, + `), // If the title is too short, include the class label: (title.length <= 1 ? `${c}: ${title}` : title), }) From 8fce1190bf9ab2f73ebde0b2a030d66a10c3329e Mon Sep 17 00:00:00 2001 From: Toshimichi0915 Date: Fri, 17 Jan 2025 16:36:44 +0900 Subject: [PATCH 8/9] Style fix --- .config/ags/modules/overview/overview_hyprland.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index 77d3bb3ca..fb83fccfd 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -437,6 +437,6 @@ export default () => { workspaces: userOptions.overview.numOfCols, }) ) - }) + }), }); } From 626feeeb2d73df841e4f389f9ba51f8763b4f26d Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 15 Feb 2025 16:14:29 +0100 Subject: [PATCH 9/9] format --- .config/ags/modules/overview/overview_hyprland.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/overview/overview_hyprland.js b/.config/ags/modules/overview/overview_hyprland.js index fb83fccfd..d4f7cc3ae 100644 --- a/.config/ags/modules/overview/overview_hyprland.js +++ b/.config/ags/modules/overview/overview_hyprland.js @@ -153,9 +153,9 @@ export default () => { truncate: 'end', className: `margin-top-5 ${xwayland ? 'txt txt-italic' : 'txt'}`, css: overviewMonitor.bind().as(monitor => ` - font-size: ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale / 14.6}px; - margin: 0px ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale / 10}px; - `), + font-size: ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale / 14.6}px; + margin: 0px ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale / 10}px; + `), // If the title is too short, include the class label: (title.length <= 1 ? `${c}: ${title}` : title), })