Glib::RefPtr<Gdk::Monitor> primary_monitor = window->get_screen()->get_display()->get_primary_monitor();
if (primary_monitor) {
Gdk::Rectangle monitor_size;
primary_monitor->get_geometry(monitor_size);
// adapt size
width = monitor_size.get_width() / 1.8;
height = monitor_size.get_height() / 2;
}
This works on X11 and Windows, but not on Wayland! I've get a nullptr and the defaults for width/height are used instead.