Overview
Context
Changes
Added Set3000x2000Res.m version [627bff5aee].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* This small program sets the resolution to 3000x2000 in HiDPI mode.
*
* Unfortunately, this is necessary because macOS does not allow selecting 3:2
* resolutions as used by some travel displays.
*
* Compile with:
* clang -framework CoreGraphics -framework Foundation Set3000x2000Res.m
*/
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
int
main()
{
NSArray *allModes = (NSArray *)CGDisplayCopyAllDisplayModes(
CGMainDisplayID(), (CFDictionaryRef)@{
(NSString *)kCGDisplayShowDuplicateLowResolutionModes: @YES
});
CGDisplayModeRef pickedMode = NULL;
for (id object in allModes) {
CGDisplayModeRef mode = (CGDisplayModeRef)object;
if (CGDisplayModeGetWidth(mode) == 1500 &&
CGDisplayModeGetHeight(mode) == 1000 &&
CGDisplayModeGetRefreshRate(mode) == 60) {
pickedMode = mode;
break;
}
}
if (pickedMode == NULL) {
NSLog(@"Mode not found!");
return 1;
}
CGDisplayConfigRef config;
if (CGBeginDisplayConfiguration(&config) != kCGErrorSuccess) {
NSLog(@"CGBeginDisplayConfiguration failed!");
return 1;
}
if (CGConfigureDisplayWithDisplayMode(config, CGMainDisplayID(),
pickedMode, NULL) != kCGErrorSuccess) {
NSLog(@"CGConfigureDisplayWithMode failed!");
return 1;
}
if (CGCompleteDisplayConfiguration(config, kCGConfigurePermanently) !=
kCGErrorSuccess) {
NSLog(@"CGCompleteDisplayConfiguration failed!");
return 1;
}
return 0;
}
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |