Commit 059579e48fa3515194d1b10df434302dfd922a1b

Sam Lantinga 2014-08-23T10:47:50

Fixed bug 2696 - Mac: fix display mode refresh rate calculation Alex Szpakowski SDL's Cocoa backend uses the CGDisplayMode API to get refresh rate information about a display mode, but CGDisplayModeGetRefreshRate will return 0 on most non-CRT monitors. The only way I know of to get correct refresh rate information in OS X is via the CoreVideo DisplayLink API. I have attached a patch which tries to use the CVDisplayLinkGetNominalOutputVideoRefreshPeriod function if CGDisplayModeGetRefreshRate fails, which fixes display mode refresh rate information on the monitors I tested. The CVDisplayLink API requires linking with the CoreVideo framework, and the patch updates the various build files to do so.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bbcb87b..1c21984 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -970,6 +970,7 @@ elseif(APPLE)
     set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
     set(HAVE_SDL_FILE TRUE)
     set(SDL_FRAMEWORK_COCOA 1)
+    set(SDL_FRAMEWORK_COREVIDEO 1)
   else()
     message_error("SDL_FILE must be enabled to build on MacOS X")
   endif()
@@ -1029,6 +1030,10 @@ elseif(APPLE)
   endif()
 
   # Actually load the frameworks at the end so we don't duplicate include.
+  if(SDL_FRAMEWORK_COREVIDEO)
+    find_library(COREVIDEO CoreVideo)
+    list(APPEND EXTRA_LIBS ${COREVIDEO})
+  endif()
   if(SDL_FRAMEWORK_COCOA)
     find_library(COCOA_LIBRARY Cocoa)
     list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
index 4faf0d5..ccb702b 100755
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -810,6 +810,9 @@
 		DB31407217554B71006C0E22 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 007317C10858E15000B2BC32 /* Carbon.framework */; };
 		DB31408B17554D37006C0E22 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CFA89C106B4BA100758660 /* ForceFeedback.framework */; };
 		DB31408D17554D3C006C0E22 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CFA89C106B4BA100758660 /* ForceFeedback.framework */; };
+		FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
+		FA73671E19A54140004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
+		FA73671F19A54144004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -1109,6 +1112,7 @@
 		F5A2EF3900C6A39A01000001 /* BUGS.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = BUGS.txt; path = ../../BUGS.txt; sourceTree = SOURCE_ROOT; };
 		F5A2EF3A00C6A3C201000001 /* README-macosx.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = "README-macosx.txt"; path = "../../README-macosx.txt"; sourceTree = SOURCE_ROOT; };
 		F5F81AD400D706B101000001 /* Readme SDL Developer.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = "Readme SDL Developer.txt"; path = "pkg-support/Readme SDL Developer.txt"; sourceTree = SOURCE_ROOT; };
+		FA73671C19A540EF004122E4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = /System/Library/Frameworks/CoreVideo.framework; sourceTree = "<absolute>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1116,6 +1120,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */,
 				007317A20858DECD00B2BC32 /* AudioToolbox.framework in Frameworks */,
 				007317A30858DECD00B2BC32 /* AudioUnit.framework in Frameworks */,
 				007317A40858DECD00B2BC32 /* Cocoa.framework in Frameworks */,
@@ -1131,6 +1136,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73671E19A54140004122E4 /* CoreVideo.framework in Frameworks */,
 				007317A90858DECD00B2BC32 /* AudioToolbox.framework in Frameworks */,
 				007317AA0858DECD00B2BC32 /* AudioUnit.framework in Frameworks */,
 				007317AB0858DECD00B2BC32 /* Cocoa.framework in Frameworks */,
@@ -1145,6 +1151,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73671F19A54144004122E4 /* CoreVideo.framework in Frameworks */,
 				DB31406C17554B71006C0E22 /* AudioToolbox.framework in Frameworks */,
 				DB31406D17554B71006C0E22 /* AudioUnit.framework in Frameworks */,
 				DB31406E17554B71006C0E22 /* Cocoa.framework in Frameworks */,
@@ -1738,6 +1745,7 @@
 		BEC562FE0761C0E800A33029 /* Linked Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				FA73671C19A540EF004122E4 /* CoreVideo.framework */,
 				00D0D08310675DD9004B05EF /* CoreFoundation.framework */,
 				007317C10858E15000B2BC32 /* Carbon.framework */,
 				0073179B0858DECD00B2BC32 /* AudioToolbox.framework */,
diff --git a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
index c04386b..d6619c2 100755
--- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
+++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
@@ -555,6 +555,51 @@
 		DB89957918A19ABA0092407C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; };
 		DB89957A18A19ABA0092407C /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; };
 		DB89958418A19B130092407C /* testhotplug.c in Sources */ = {isa = PBXBuildFile; fileRef = DB89958318A19B130092407C /* testhotplug.c */; };
+		FA73672319A54A90004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672819A54AB6004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672919A54AB9004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672A19A54AC0004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672B19A54AC2004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672C19A54AC5004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672D19A54AC7004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672E19A54ACA004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73672F19A54ACC004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673019A54AD0004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673119A54AD3004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673219A54AD5004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673319A54AD8004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673419A54ADB004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673519A54ADE004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673619A54AE1004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673719A54AE3004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673819A54AE6004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673919A54AE8004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673A19A54AEB004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673B19A54AED004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673C19A54AF0004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673D19A54AF3004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673E19A54AF6004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73673F19A54AF8004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674019A54AFB004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674119A54AFE004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674219A54B01004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674319A54B04004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674419A54B06004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674519A54B09004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674619A54B0B004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674719A54B0F004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674819A54B13004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674919A54B16004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674A19A54B19004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674B19A54B1B004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674C19A54B1F004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674D19A54B22004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674E19A54B25004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73674F19A54B28004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73675019A54B2B004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73675119A54B2F004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73675219A54B32004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
+		FA73675319A54B35004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -1141,6 +1186,7 @@
 		DB89957E18A19ABA0092407C /* testhotplug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testhotplug; sourceTree = BUILT_PRODUCTS_DIR; };
 		DB89958318A19B130092407C /* testhotplug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testhotplug.c; path = ../../test/testhotplug.c; sourceTree = "<group>"; };
 		DBBC552C182831D700F3CA8D /* TestDropFile-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "TestDropFile-Info.plist"; sourceTree = "<group>"; };
+		FA73672219A54A90004122E4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = /System/Library/Frameworks/CoreVideo.framework; sourceTree = "<absolute>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1148,6 +1194,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672919A54AB9004122E4 /* CoreVideo.framework in Frameworks */,
 				0017957C10741F7900F5D044 /* Cocoa.framework in Frameworks */,
 				0017957D10741F7900F5D044 /* CoreAudio.framework in Frameworks */,
 				0017957E10741F7900F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1164,6 +1211,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672A19A54AC0004122E4 /* CoreVideo.framework in Frameworks */,
 				0017959D107421BF00F5D044 /* Cocoa.framework in Frameworks */,
 				0017959E107421BF00F5D044 /* CoreAudio.framework in Frameworks */,
 				0017959F107421BF00F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1180,6 +1228,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673319A54AD8004122E4 /* CoreVideo.framework in Frameworks */,
 				0017971110742F3200F5D044 /* Cocoa.framework in Frameworks */,
 				0017971210742F3200F5D044 /* CoreAudio.framework in Frameworks */,
 				0017971310742F3200F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1197,6 +1246,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673419A54ADB004122E4 /* CoreVideo.framework in Frameworks */,
 				00179738107430D600F5D044 /* Cocoa.framework in Frameworks */,
 				00179739107430D600F5D044 /* CoreAudio.framework in Frameworks */,
 				0017973A107430D600F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1213,6 +1263,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672B19A54AC2004122E4 /* CoreVideo.framework in Frameworks */,
 				0017975E107431B300F5D044 /* Cocoa.framework in Frameworks */,
 				0017975F107431B300F5D044 /* CoreAudio.framework in Frameworks */,
 				00179760107431B300F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1230,6 +1281,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673719A54AE3004122E4 /* CoreVideo.framework in Frameworks */,
 				0017977E107432AE00F5D044 /* Cocoa.framework in Frameworks */,
 				0017977F107432AE00F5D044 /* CoreAudio.framework in Frameworks */,
 				00179780107432AE00F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1247,6 +1299,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673819A54AE6004122E4 /* CoreVideo.framework in Frameworks */,
 				0017979E1074334C00F5D044 /* Cocoa.framework in Frameworks */,
 				0017979F1074334C00F5D044 /* CoreAudio.framework in Frameworks */,
 				001797A01074334C00F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1264,6 +1317,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673B19A54AED004122E4 /* CoreVideo.framework in Frameworks */,
 				001797C0107433C600F5D044 /* Cocoa.framework in Frameworks */,
 				001797C1107433C600F5D044 /* CoreAudio.framework in Frameworks */,
 				001797C2107433C600F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1280,6 +1334,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673E19A54AF6004122E4 /* CoreVideo.framework in Frameworks */,
 				001798021074355200F5D044 /* Cocoa.framework in Frameworks */,
 				001798031074355200F5D044 /* CoreAudio.framework in Frameworks */,
 				001798041074355200F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1296,6 +1351,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673F19A54AF8004122E4 /* CoreVideo.framework in Frameworks */,
 				001798841074392D00F5D044 /* Cocoa.framework in Frameworks */,
 				001798851074392D00F5D044 /* CoreAudio.framework in Frameworks */,
 				001798861074392D00F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1312,6 +1368,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674219A54B01004122E4 /* CoreVideo.framework in Frameworks */,
 				001798A5107439DF00F5D044 /* Cocoa.framework in Frameworks */,
 				001798A6107439DF00F5D044 /* CoreAudio.framework in Frameworks */,
 				001798A7107439DF00F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1328,6 +1385,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674619A54B0B004122E4 /* CoreVideo.framework in Frameworks */,
 				001798E210743BEC00F5D044 /* Cocoa.framework in Frameworks */,
 				001798E310743BEC00F5D044 /* CoreAudio.framework in Frameworks */,
 				001798E410743BEC00F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1344,6 +1402,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674C19A54B1F004122E4 /* CoreVideo.framework in Frameworks */,
 				0017990610743F1000F5D044 /* Cocoa.framework in Frameworks */,
 				0017990710743F1000F5D044 /* CoreAudio.framework in Frameworks */,
 				0017990810743F1000F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1361,6 +1420,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73675219A54B32004122E4 /* CoreVideo.framework in Frameworks */,
 				0017992810743FB700F5D044 /* Cocoa.framework in Frameworks */,
 				0017992910743FB700F5D044 /* CoreAudio.framework in Frameworks */,
 				0017992A10743FB700F5D044 /* ForceFeedback.framework in Frameworks */,
@@ -1378,6 +1438,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672F19A54ACC004122E4 /* CoreVideo.framework in Frameworks */,
 				002F340B09CA1BFF00EBEB88 /* Cocoa.framework in Frameworks */,
 				002A866B10730548007319AE /* CoreAudio.framework in Frameworks */,
 				002A866C10730548007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1394,6 +1455,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673619A54AE1004122E4 /* CoreVideo.framework in Frameworks */,
 				002F342A09CA1F0300EBEB88 /* Cocoa.framework in Frameworks */,
 				002A866210730547007319AE /* CoreAudio.framework in Frameworks */,
 				002A866310730547007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1410,6 +1472,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674019A54AFB004122E4 /* CoreVideo.framework in Frameworks */,
 				002F344609CA1FB300EBEB88 /* Cocoa.framework in Frameworks */,
 				002A868010730549007319AE /* CoreAudio.framework in Frameworks */,
 				002A868110730549007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1426,6 +1489,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674119A54AFE004122E4 /* CoreVideo.framework in Frameworks */,
 				002F346309CA204F00EBEB88 /* Cocoa.framework in Frameworks */,
 				002A868610730549007319AE /* CoreAudio.framework in Frameworks */,
 				002A868710730549007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1442,6 +1506,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674B19A54B1B004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166D7116A1CFB200A1396C /* AudioToolbox.framework in Frameworks */,
 				DB166D7216A1CFB200A1396C /* AudioUnit.framework in Frameworks */,
 				DB166D7316A1CFB200A1396C /* Carbon.framework in Frameworks */,
@@ -1459,6 +1524,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673119A54AD3004122E4 /* CoreVideo.framework in Frameworks */,
 				BBFC08C0164C6862003E6A99 /* Cocoa.framework in Frameworks */,
 				BBFC08C1164C6862003E6A99 /* CoreAudio.framework in Frameworks */,
 				BBFC08C2164C6862003E6A99 /* ForceFeedback.framework in Frameworks */,
@@ -1475,6 +1541,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672319A54A90004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33C109CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A863010730405007319AE /* libSDL2.a in Frameworks */,
 				002A864D10730546007319AE /* CoreAudio.framework in Frameworks */,
@@ -1491,6 +1558,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672819A54AB6004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33BF09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A865310730547007319AE /* CoreAudio.framework in Frameworks */,
 				002A865410730547007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1507,6 +1575,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672E19A54ACA004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33BC09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A866E10730548007319AE /* CoreAudio.framework in Frameworks */,
 				002A866F10730548007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1523,6 +1592,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674F19A54B28004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33B809CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A868F1073054A007319AE /* CoreAudio.framework in Frameworks */,
 				002A86901073054A007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1539,6 +1609,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673919A54AE8004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33B709CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A867410730548007319AE /* CoreAudio.framework in Frameworks */,
 				002A867510730548007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1555,6 +1626,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673A19A54AEB004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33B509CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A867710730548007319AE /* CoreAudio.framework in Frameworks */,
 				002A867810730548007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1571,6 +1643,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673C19A54AF0004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33B609CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A867A10730549007319AE /* CoreAudio.framework in Frameworks */,
 				002A867B10730549007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1587,6 +1660,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674919A54B16004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33B209CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A868910730549007319AE /* CoreAudio.framework in Frameworks */,
 				002A868A10730549007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1603,6 +1677,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73675019A54B2B004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33B009CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A86981073054A007319AE /* CoreAudio.framework in Frameworks */,
 				002A86991073054A007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1619,6 +1694,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73675119A54B2F004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33AF09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A86951073054A007319AE /* CoreAudio.framework in Frameworks */,
 				002A86961073054A007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1635,6 +1711,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73675319A54B35004122E4 /* CoreVideo.framework in Frameworks */,
 				002F33AA09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
 				002A864110730546007319AE /* CoreAudio.framework in Frameworks */,
 				002A864210730546007319AE /* ForceFeedback.framework in Frameworks */,
@@ -1651,6 +1728,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672C19A54AC5004122E4 /* CoreVideo.framework in Frameworks */,
 				DB0F48DD17CA51E5008798C5 /* Cocoa.framework in Frameworks */,
 				DB0F48DE17CA51E5008798C5 /* CoreAudio.framework in Frameworks */,
 				DB0F48DF17CA51E5008798C5 /* ForceFeedback.framework in Frameworks */,
@@ -1667,6 +1745,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673019A54AD0004122E4 /* CoreVideo.framework in Frameworks */,
 				DB0F48F317CA5212008798C5 /* Cocoa.framework in Frameworks */,
 				DB0F48F417CA5212008798C5 /* CoreAudio.framework in Frameworks */,
 				DB0F48F517CA5212008798C5 /* ForceFeedback.framework in Frameworks */,
@@ -1690,6 +1769,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673219A54AD5004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166DB116A1D2F600A1396C /* Cocoa.framework in Frameworks */,
 				DB166DB216A1D2F600A1396C /* CoreAudio.framework in Frameworks */,
 				DB166DB316A1D2F600A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1706,6 +1786,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673D19A54AF3004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166DC816A1D36A00A1396C /* Cocoa.framework in Frameworks */,
 				DB166DC916A1D36A00A1396C /* CoreAudio.framework in Frameworks */,
 				DB166DCA16A1D36A00A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1722,6 +1803,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674319A54B04004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166DE016A1D50C00A1396C /* Cocoa.framework in Frameworks */,
 				DB166DE116A1D50C00A1396C /* CoreAudio.framework in Frameworks */,
 				DB166DE216A1D50C00A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1739,6 +1821,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674419A54B06004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166DF716A1D57C00A1396C /* Cocoa.framework in Frameworks */,
 				DB166DF816A1D57C00A1396C /* CoreAudio.framework in Frameworks */,
 				DB166DF916A1D57C00A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1756,6 +1839,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674519A54B09004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166E0E16A1D5AD00A1396C /* Cocoa.framework in Frameworks */,
 				DB166E0F16A1D5AD00A1396C /* CoreAudio.framework in Frameworks */,
 				DB166E1016A1D5AD00A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1773,6 +1857,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674719A54B0F004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166E2B16A1D64D00A1396C /* Cocoa.framework in Frameworks */,
 				DB166E2C16A1D64D00A1396C /* CoreAudio.framework in Frameworks */,
 				DB166E2D16A1D64D00A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1789,6 +1874,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674819A54B13004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166E4116A1D69000A1396C /* Cocoa.framework in Frameworks */,
 				DB166E4216A1D69000A1396C /* CoreAudio.framework in Frameworks */,
 				DB166E4316A1D69000A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1806,6 +1892,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674A19A54B19004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166E5B16A1D6F300A1396C /* Cocoa.framework in Frameworks */,
 				DB166E5C16A1D6F300A1396C /* CoreAudio.framework in Frameworks */,
 				DB166E5D16A1D6F300A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1822,6 +1909,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674D19A54B22004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166E7116A1D78400A1396C /* Cocoa.framework in Frameworks */,
 				DB166E7216A1D78400A1396C /* CoreAudio.framework in Frameworks */,
 				DB166E7316A1D78400A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1838,6 +1926,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73674E19A54B25004122E4 /* CoreVideo.framework in Frameworks */,
 				DB166E8416A1D78C00A1396C /* Cocoa.framework in Frameworks */,
 				DB166E8516A1D78C00A1396C /* CoreAudio.framework in Frameworks */,
 				DB166E8616A1D78C00A1396C /* ForceFeedback.framework in Frameworks */,
@@ -1854,6 +1943,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73672D19A54AC7004122E4 /* CoreVideo.framework in Frameworks */,
 				DB445EEA18184B7000B306B0 /* Cocoa.framework in Frameworks */,
 				DB445EEB18184B7000B306B0 /* CoreAudio.framework in Frameworks */,
 				DB445EEC18184B7000B306B0 /* ForceFeedback.framework in Frameworks */,
@@ -1871,6 +1961,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FA73673519A54ADE004122E4 /* CoreVideo.framework in Frameworks */,
 				DB89957118A19ABA0092407C /* Cocoa.framework in Frameworks */,
 				DB89957218A19ABA0092407C /* CoreAudio.framework in Frameworks */,
 				DB89957318A19ABA0092407C /* ForceFeedback.framework in Frameworks */,
@@ -1889,6 +1980,7 @@
 		002F33A209CA183B00EBEB88 /* Linked Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				FA73672219A54A90004122E4 /* CoreVideo.framework */,
 				002A869F10730593007319AE /* AudioToolbox.framework */,
 				002A871410730623007319AE /* AudioUnit.framework */,
 				002A873910730675007319AE /* Carbon.framework */,
diff --git a/configure b/configure
index 08ecfbf..3aed9c8 100755
--- a/configure
+++ b/configure
@@ -23338,6 +23338,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
         # The Mac OS X platform requires special setup.
         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
diff --git a/configure.in b/configure.in
index 3c87ea7..73b76fd 100644
--- a/configure.in
+++ b/configure.in
@@ -3215,6 +3215,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
         # The Mac OS X platform requires special setup.
         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
diff --git a/premake/README-macosx.txt b/premake/README-macosx.txt
index 599e96e..55c6dfa 100755
--- a/premake/README-macosx.txt
+++ b/premake/README-macosx.txt
@@ -17,6 +17,7 @@ tests on that platform.
 
 The Mac OS X projects currently have reliance on the following dependencies:
 
+  -CoreVideo.framework
   -AudioToolbox.framework
   -AudioUnit.framework
   -Cocoa.framework
diff --git a/premake/projects/SDL2.lua b/premake/projects/SDL2.lua
index 6e705bf..0eaab6b 100755
--- a/premake/projects/SDL2.lua
+++ b/premake/projects/SDL2.lua
@@ -213,6 +213,7 @@ SDL_project "SDL2"
 		}
 		SDL_links
 		{
+			"CoreVideo.framework",
 			"AudioToolbox.framework",
 			"AudioUnit.framework",
 			"Cocoa.framework",
diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m
index 5f46058..b3025c4 100644
--- a/src/video/cocoa/SDL_cocoamodes.m
+++ b/src/video/cocoa/SDL_cocoamodes.m
@@ -27,6 +27,10 @@
 /* We need this for IODisplayCreateInfoDictionary and kIODisplayOnlyPreferredName */
 #include <IOKit/graphics/IOGraphicsLib.h>
 
+/* We need this for CVDisplayLinkGetNominalOutputVideoRefreshPeriod */
+#include <CoreVideo/CVBase.h>
+#include <CoreVideo/CVDisplayLink.h>
+
 /* we need this for ShowMenuBar() and HideMenuBar(). */
 #include <Carbon/Carbon.h>
 
@@ -114,7 +118,7 @@ CG_SetError(const char *prefix, CGDisplayErr result)
 }
 
 static SDL_bool
-GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
+GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMode *mode)
 {
     SDL_DisplayModeData *data;
     long width = 0;
@@ -133,7 +137,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
         CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
         width = (long) CGDisplayModeGetWidth(vidmode);
         height = (long) CGDisplayModeGetHeight(vidmode);
-        refreshRate = (long) CGDisplayModeGetRefreshRate(vidmode);
+        refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
 
         if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
                             kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
@@ -141,6 +145,9 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
         } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
                             kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
             bpp = 16;
+        } else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
+                            kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            bpp = 30;
         } else {
             bpp = 0;  /* ignore 8-bit and such for now. */
         }
@@ -151,6 +158,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
     #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
     if (!IS_SNOW_LEOPARD_OR_LATER()) {
         CFNumberRef number;
+        double refresh;
         CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
         number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
         CFNumberGetValue(number, kCFNumberLongType, &width);
@@ -159,15 +167,27 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
         number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
         CFNumberGetValue(number, kCFNumberLongType, &bpp);
         number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
-        CFNumberGetValue(number, kCFNumberLongType, &refreshRate);
+        CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
+        refreshRate = (long) (refresh + 0.5);
     }
     #endif
 
+    /* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
+    if (refreshRate == 0 && link != NULL) {
+        CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
+        if ((time.flags & kCVTimeIsIndefinite) == 0 && time.timeValue != 0) {
+            refreshRate = (long) ((time.timeScale / (double) time.timeValue) + 0.5);
+        }
+    }
+
     mode->format = SDL_PIXELFORMAT_UNKNOWN;
     switch (bpp) {
     case 16:
         mode->format = SDL_PIXELFORMAT_ARGB1555;
         break;
+    case 30:
+        mode->format = SDL_PIXELFORMAT_ARGB2101010;
+        break;
     case 32:
         mode->format = SDL_PIXELFORMAT_ARGB8888;
         break;
@@ -241,6 +261,7 @@ Cocoa_InitModes(_THIS)
             SDL_DisplayData *displaydata;
             SDL_DisplayMode mode;
             const void *moderef = NULL;
+            CVDisplayLinkRef link = NULL;
 
             if (pass == 0) {
                 if (!CGDisplayIsMain(displays[i])) {
@@ -277,16 +298,21 @@ Cocoa_InitModes(_THIS)
             }
             displaydata->display = displays[i];
 
+            CVDisplayLinkCreateWithCGDisplay(displays[i], &link);
+
             SDL_zero(display);
             /* this returns a stddup'ed string */
             display.name = (char *)Cocoa_GetDisplayName(displays[i]);
-            if (!GetDisplayMode (_this, moderef, &mode)) {
+            if (!GetDisplayMode(_this, moderef, link, &mode)) {
+                CVDisplayLinkRelease(link);
                 Cocoa_ReleaseDisplayMode(_this, moderef);
                 SDL_free(display.name);
                 SDL_free(displaydata);
                 continue;
             }
 
+            CVDisplayLinkRelease(link);
+
             display.desktop_mode = mode;
             display.current_mode = mode;
             display.driverdata = displaydata;
@@ -328,13 +354,16 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
     #endif
 
     if (modes) {
+        CVDisplayLinkRef link = NULL;
         const CFIndex count = CFArrayGetCount(modes);
         CFIndex i;
 
+        CVDisplayLinkCreateWithCGDisplay(data->display, &link);
+
         for (i = 0; i < count; i++) {
             const void *moderef = CFArrayGetValueAtIndex(modes, i);
             SDL_DisplayMode mode;
-            if (GetDisplayMode(_this, moderef, &mode)) {
+            if (GetDisplayMode(_this, moderef, link, &mode)) {
                 if (IS_SNOW_LEOPARD_OR_LATER()) {
                     CGDisplayModeRetain((CGDisplayModeRef) moderef);
                 }
@@ -342,6 +371,7 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
             }
         }
 
+        CVDisplayLinkRelease(link);
         Cocoa_ReleaseDisplayModeList(_this, modes);
     }
 }