forked from Shinonome/dots-hyprland
Fix overview widget for multi monitors
This commit is contained in:
@@ -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 TARGET = [Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags.SAME_APP, 0)];
|
||||||
|
|
||||||
const overviewTick = Variable(false);
|
const overviewTick = Variable(false);
|
||||||
|
const overviewMonitor = Variable(0);
|
||||||
|
|
||||||
export default (overviewMonitor = 0) => {
|
export default () => {
|
||||||
const clientMap = new Map();
|
const clientMap = new Map();
|
||||||
const ContextMenuWorkspaceArray = ({ label, actionFunc, thisWorkspace }) => Widget.MenuItem({
|
const ContextMenuWorkspaceArray = ({ label, actionFunc, thisWorkspace }) => Widget.MenuItem({
|
||||||
label: `${label}`,
|
label: `${label}`,
|
||||||
@@ -64,11 +65,14 @@ export default (overviewMonitor = 0) => {
|
|||||||
if (monitors.length - 1 < monitor) {
|
if (monitors.length - 1 < monitor) {
|
||||||
monitor = monitors.length - 1;
|
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
|
// Truncate if offscreen
|
||||||
if (x + w > monitors[monitor].width) w = monitors[monitor].width - x;
|
if (x + w > monitors[monitor].width) w = monitors[monitor].width - x;
|
||||||
if (y + h > monitors[monitor].height) h = monitors[monitor].height - y;
|
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 iconName = substitute(c);
|
||||||
const appIcon = iconExists(iconName) ? Widget.Icon({
|
const appIcon = iconExists(iconName) ? Widget.Icon({
|
||||||
icon: iconName,
|
icon: iconName,
|
||||||
@@ -220,10 +224,10 @@ export default (overviewMonitor = 0) => {
|
|||||||
const WorkspaceNumber = ({ index, ...rest }) => Widget.Label({
|
const WorkspaceNumber = ({ index, ...rest }) => Widget.Label({
|
||||||
className: 'overview-tasks-workspace-number',
|
className: 'overview-tasks-workspace-number',
|
||||||
label: `${index}`,
|
label: `${index}`,
|
||||||
css: `
|
css: overviewMonitor.bind().as(monitor => `
|
||||||
margin: ${Math.min(monitors[overviewMonitor].width, monitors[overviewMonitor].height) * userOptions.overview.scale * userOptions.overview.wsNumMarginScale}px;
|
margin: ${Math.min(monitors[monitor].width, monitors[monitor].height) * userOptions.overview.scale * userOptions.overview.wsNumMarginScale}px;
|
||||||
font-size: ${monitors[overviewMonitor].height * userOptions.overview.scale * userOptions.overview.wsNumScale}px;
|
font-size: ${monitors[monitor].height * userOptions.overview.scale * userOptions.overview.wsNumScale}px;
|
||||||
`,
|
`),
|
||||||
setup: (self) => self.hook(Hyprland.active.workspace, (self) => {
|
setup: (self) => self.hook(Hyprland.active.workspace, (self) => {
|
||||||
// Update when going to new ws group
|
// Update when going to new ws group
|
||||||
const currentGroup = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN);
|
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',
|
className: 'overview-tasks-workspace',
|
||||||
vpack: 'center',
|
vpack: 'center',
|
||||||
// Rounding and adding 1px to minimum width/height to work around scaling inaccuracy:
|
// Rounding and adding 1px to minimum width/height to work around scaling inaccuracy:
|
||||||
css: `
|
css: overviewMonitor.bind().as(monitor => `
|
||||||
min-width: ${1 + Math.round(monitors[overviewMonitor].width * userOptions.overview.scale)}px;
|
min-width: ${1 + Math.round(monitors[monitor].width * userOptions.overview.scale)}px;
|
||||||
min-height: ${1 + Math.round(monitors[overviewMonitor].height * userOptions.overview.scale)}px;
|
min-height: ${1 + Math.round(monitors[monitor].height * userOptions.overview.scale)}px;
|
||||||
`,
|
`),
|
||||||
children: [Widget.EventBox({
|
children: [Widget.EventBox({
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
onPrimaryClick: () => {
|
onPrimaryClick: () => {
|
||||||
@@ -431,5 +435,5 @@ export default (overviewMonitor = 0) => {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
});
|
}).hook(Hyprland, () => { overviewMonitor.value = Hyprland.active.monitor.id; });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user