Skip to content

Commit

Permalink
modalDialog: use the MonitorConstraint object to properly place dialogs
Browse files Browse the repository at this point in the history
This is needed to help keep the DisplayChange dialog centered on
resolution changes
  • Loading branch information
JosephMcc authored and clefebvre committed Oct 20, 2024
1 parent db8e003 commit 714662e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions js/ui/modalDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Params = imports.misc.params;
const Util = imports.misc.util;

const Dialog = imports.ui.dialog;
const Layout = imports.ui.layout;
const Lightbox = imports.ui.lightbox;
const Main = imports.ui.main;

Expand Down Expand Up @@ -82,8 +83,10 @@ var ModalDialog = GObject.registerClass({

Main.uiGroup.add_actor(this);

let constraint = new Clutter.BindConstraint({ source: global.stage,
coordinate: Clutter.BindCoordinate.POSITION | Clutter.BindCoordinate.SIZE });
let constraint = new Clutter.BindConstraint({
source: global.stage,
coordinate: Clutter.BindCoordinate.POSITION | Clutter.BindCoordinate.SIZE
});
this.add_constraint(constraint);

this.backgroundStack = new St.Widget({ layout_manager: new Clutter.BinLayout() });
Expand All @@ -92,6 +95,8 @@ var ModalDialog = GObject.registerClass({
x_fill: true,
y_fill: true
});
this._monitorConstraint = new Layout.MonitorConstraint();
this._backgroundBin.add_constraint(this._monitorConstraint);
this.add_actor(this._backgroundBin);

this.dialogLayout = new Dialog.Dialog(this.backgroundStack, params.styleClass);
Expand Down Expand Up @@ -177,10 +182,7 @@ var ModalDialog = GObject.registerClass({
}

_fadeOpen() {
let monitor = Main.layoutManager.currentMonitor;

this._backgroundBin.set_position(monitor.x, monitor.y);
this._backgroundBin.set_size(monitor.width, monitor.height);
this._monitorConstraint.index = global.display.get_current_monitor();

this._setState(State.OPENING);

Expand Down

0 comments on commit 714662e

Please sign in to comment.