1

I'm on Ubuntu 22.04 LTS using GNOME Shell 42.9. I've writen an extension that will position and resize a window based on its title, but I want to position the window in the horizontal center of the display (currently using hard-coded coordinates). I therefore need to know the dimensions of the display/workspace where the window lives.

I've looked through the available libraries listed in docs/reference/shell/urlmap.js (GNOME Shell source), and with its references to display, Meta seems to be where I want to be, but I'm not seeing an obvious function/class that would provide this information.

Can any Extension-knowledgeable soul out there point me in the right direction?

asked Jul 19, 2024 at 18:36
0

1 Answer 1

0

I'm going to answer my question using the approach I discovered (there are likely others)...

By using the window-created callback:

global.display.connect('window-created', this._onWindowCreated.bind(this));

A display argument is provided to the specified callback function. This display argument provides a method for retrieving the geometry of a given monitor:

display.get_monitor_geometry(0);

Using this, I'm able to retrieve the width and height of the specified monitor where the new window exists, and this let's me get it centered on the screen. \o/

answered Jul 20, 2024 at 18:11
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.