Skip to content

Commit

Permalink
Fix scale-monitor-framebuffer inconsistencies (#534)
Browse files Browse the repository at this point in the history
* Fix scale-monitor-framebuffer inconsistencies
  • Loading branch information
aunetx committed Feb 26, 2024
1 parent 08dac28 commit 48f5dbe
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/components/applications.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import Shell from 'gi://Shell';
import Clutter from 'gi://Clutter';
import Meta from 'gi://Meta';
import Gio from 'gi://Gio'
import * as Main from 'resource:///org/gnome/shell/ui/main.js';

import { PaintSignals } from '../effects/paint_signals.js';
import { ApplicationsService } from '../dbus/services.js';

const mutter_gsettings = new Gio.Settings({ schema: 'org.gnome.mutter' });


export const ApplicationsBlur = class ApplicationsBlur {
constructor(connections, settings, _) {
Expand Down Expand Up @@ -416,15 +419,27 @@ export const ApplicationsBlur = class ApplicationsBlur {
});
}

/// Compute the size and position for a blur actor.
/// If `scale-monitor-framebuffer` experimental feature if on, we don't need to manage scaling.
/// Else, on wayland, we need to divide by the scale to get the correct result.
compute_allocation(meta_window) {
const scale_monitor_framebuffer = mutter_gsettings.get_strv('experimental-features')
.includes('scale-monitor-framebuffer');
const is_wayland = Meta.is_wayland_compositor();
const monitor_index = meta_window.get_monitor();
// check if the window is using wayland, or xwayland/xorg for rendering
const scale = !scale_monitor_framebuffer && is_wayland && meta_window.get_client_type() == 0
? Main.layoutManager.monitors[monitor_index].geometry_scale
: 1;

let frame = meta_window.get_frame_rect();
let buffer = meta_window.get_buffer_rect();

return {
x: (frame.x - buffer.x),
y: (frame.y - buffer.y),
width: frame.width,
height: frame.height
x: (frame.x - buffer.x) / scale,
y: (frame.y - buffer.y) / scale,
width: frame.width / scale,
height: frame.height / scale
};
}

Expand Down Expand Up @@ -532,4 +547,4 @@ export const ApplicationsBlur = class ApplicationsBlur {
if (this.settings.DEBUG)
console.log(`[Blur my Shell > applications] ${str}`);
}
};
};

0 comments on commit 48f5dbe

Please sign in to comment.