Skip to content

Fully implement GdkDisplay in Quartz

John Ralls requested to merge jralls/gtk:quartz-monitor into gtk-3-24

As I proposed in #1312 (closed) this implements all necessary functions in gdkdisplay-quartz (leaving off the ones that really apply only to X11; those are mostly removed in master). ∂∂e gdkscreen-quartz and gdkdevicemanager*quartz are rendered redundant and can be removed for Gtk4.

I've implemented almost everything at the CoreGraphics/Quartz Display Services level instead of NSScreen. This has the advantage of being at the same level as the Cairo implementation, that CGDirectDisplayIDs don't change between reboots, and that the latency between CoreGraphics calling a CGDisplayReconfigurationCallback and Cocoa is no longer a concern. The only exceptions are for gdk_quartz_monitor_get_workarea and gdk_quartz_display_get_monitor_at_window: Both need NSScreen calls because CoreGraphics is unaware of NSWindows and the menubar and dock that reduce the monitor's usable area.

Also included here are accommodations to Apple API changes since MacOS Lion. I've addressed those with both compile time and runtime checks so that deprecation warnings are issued only if one is compiling against a new SDK with --macos_x_min_required set to an older version.

There are a couple of deprecation warnings remaining. The really difficult one is the deprecation of NSView scrollRectBy; the accompanying note is that one should subclass NSScrollView instead. Implementing that will require us to change the basic one-NSView-per-toplevel design to an NSView-per-window. I'm not really sure what to do about the deprecation of the NSView lockfocus family of functions. The compiler notes say to subclass NSView and implement drawRect instead, but they're used as directed by the Cocoa View Programming Guide (sadly no longer maintained) for coordinate conversions in event handlers, not when we're trying to draw.

I'm currently away from my multi-monitor rig so I can't completely test it and I won't merge until I do (around the second week of December) but it's ready now for code review.

Merge request reports