Open Not-a-true-statement opened 1 month ago
Looking at the x, y, width, height
properties of the monitors in the hyprctl monitors -j
output, the monitors do overlap.
Monitor 1 is positioned at 0,0 with a width of 1920, monitor 0 is positioned at 1080,0, so they do overlap according to those numbers.
Sadly there is no good way to map hyprland monitors to gdkmonitors in gtk3. You either have to try to map them using coordinates, which ags does, but this breaks when the monitors overlap, or map them using the display name, which is more robust, but uses functions which have been deprecated for long a long now. I have a function, which gets the display name from an gdkmknitor here in my dots , this can be easily modified to get the gdkmonitor from its name.
Looking at the
x, y, width, height
properties of the monitors in thehyprctl monitors -j
output, the monitors do overlap.Monitor 1 is positioned at 0,0 with a width of 1920, monitor 0 is positioned at 1080,0, so they do overlap according to those numbers.
If you look at the rotations (transform in the output) you will see that monitor 1 is rotated sideways and monitor 0 is upside down. This means that monitor height is the actual width therefore they do not overlap.
I will look into your implementation of determining the correct monitor.
I have rewritten my code and implemented the solution by @kotontrion . The following code works well for now.
// UTIL.JS file (slightly rewritten)
export function getMonitorName(gdkmonitor) {
const screen = display?.get_default_screen();
const screenCount = display?.get_n_monitors() ?? 1;
for(let i = 0; i < screenCount; ++i) {
if(gdkmonitor === display?.get_monitor(i))
return screen?.get_monitor_plug_name(i) ?? null;
}
return null;
}
// config.js
App.config({
style: "./src/stylesheets/stylesheet.css",
windows: () => {
let bars = [];
let monitors = hyprland.monitors;
for (let monitorIndex = 0; monitorIndex < monitors.length; monitorIndex++) {
const monitor = monitors[monitorIndex];
let { id, name } = monitor;
console.log(monitor);
// Find correct GTK monitor for hyperland monitor
const monitorCount = display?.get_n_monitors();
for (let index = 0; index < (monitorCount ?? 1); index++) {
let monitor = display?.get_monitor(index);
if(getMonitorName(monitor) === name)
bars.push(Bar(monitor, id))
}
}
return bars;
}
})
Seems like when getting the gtk monitor using the util function (which was merged with #400) does not retrieve the correct monitor. Currently it retrieves 2 correct monitors and 1 duplicate. I have checked the location of each monitor placement and none of them is overlapping since the code looks for XY, presumably top left.
How i am trying to use it
Checking for info
Output:
When i look for monitors that are detected
Output:
Output for hyprctl monitors -j