/**
* gdk_display_link_source_new:
+ * @display_id: the identifier of the monitor
*
* Creates a new `GSource` that will activate the dispatch function upon
* notification from a CVDisplayLink that a new frame should be drawn.
* Returns: (transfer full): A newly created `GSource`
*/
GSource *
-gdk_display_link_source_new (void)
+gdk_display_link_source_new (CGDirectDisplayID display_id)
{
GdkDisplayLinkSource *impl;
GSource *source;
source = g_source_new (&gdk_display_link_source_funcs, sizeof *impl);
impl = (GdkDisplayLinkSource *)source;
+ impl->display_id = display_id;
- /*
- * Create our link based on currently connected displays.
- * If there are multiple displays, this will be something that tries
- * to work for all of them. In the future, we may want to explore multiple
- * links based on the connected displays.
+ /* Create DisplayLink for timing information for the display in
+ * question so that we can produce graphics for that display at whatever
+ * rate it can provide.
*/
- ret = CVDisplayLinkCreateWithActiveCGDisplays (&impl->display_link);
- if (ret != kCVReturnSuccess)
+ if (CVDisplayLinkCreateWithCGDisplay (display_id, &impl->display_link) != kCVReturnSuccess)
{
g_warning ("Failed to initialize CVDisplayLink!");
return source;
typedef struct
{
- GSource source;
+ GSource source;
- CVDisplayLinkRef display_link;
- gint64 refresh_interval;
- guint refresh_rate;
+ CGDirectDisplayID display_id;
+ CVDisplayLinkRef display_link;
+ gint64 refresh_interval;
+ guint refresh_rate;
- volatile gint64 presentation_time;
- volatile guint needs_dispatch;
+ volatile gint64 presentation_time;
+ volatile guint needs_dispatch;
} GdkDisplayLinkSource;
-GSource *gdk_display_link_source_new (void);
+GSource *gdk_display_link_source_new (CGDirectDisplayID display_id);
void gdk_display_link_source_pause (GdkDisplayLinkSource *source);
void gdk_display_link_source_unpause (GdkDisplayLinkSource *source);
static void
gdk_macos_display_load_display_link (GdkMacosDisplay *self)
{
- self->frame_source = gdk_display_link_source_new ();
+ self->frame_source = gdk_display_link_source_new (CGMainDisplayID ());
g_source_set_callback (self->frame_source,
gdk_macos_display_frame_cb,
self,