a curious student
a curious student

Reputation: 62

gtk4-rs: Get Monitors as gdk::Monitor not as a glib::Object

I'm using the gtk4-layer-shell rust bindings and want to position my window on a specific monitor.

I have the following code:

let monitors: gio::ListModel = gdk::Display::default().unwrap().monitors();

let monitor: glib::Object = monitors.item(0).unwrap();

Thus I get the monitor as a glib::Object. But gtk4-layer-shell expects a gdk::Monitor to passed to window.set_monitor. I don't know how to work further with the glib::Object.

Libraries used: gtk4-rs, gdk4, gtk4-layer-shell.

Upvotes: 1

Views: 163

Answers (1)

Jmb
Jmb

Reputation: 23443

You can use monitor.downcast::<gdk::Monitor>() to convert a glib::Object instance into a gdk::Monitor.

Upvotes: 2

Related Questions