This repository has been archived by the owner on May 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added aspect ratio * Reading /System/Library/Displays/Overrides/
- Loading branch information
Eun
committed
Jul 25, 2014
1 parent
a9d1e06
commit 2b0ee0d
Showing
13 changed files
with
297 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// CustomResolution.h | ||
// DisableMonitor | ||
// | ||
// Created by salzmann on 25.07.14. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface CustomResolution : NSObject | ||
{ | ||
CGDirectDisplayID displayID; | ||
} | ||
- (id)initWithDisplayID:(CGDirectDisplayID)aDisplay; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// CustomResolution.m | ||
// DisableMonitor | ||
// | ||
// Created by salzmann on 25.07.14. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <IOKit/graphics/IOGraphicsLib.h> | ||
#import "CustomResolution.h" | ||
#import "DisplayData.h" | ||
|
||
@implementation CustomResolution | ||
|
||
- (id)initWithDisplayID:(CGDirectDisplayID)aDisplay { | ||
self = [super init]; | ||
if (self) { | ||
displayID = aDisplay; | ||
|
||
[self ReadResolutions]; | ||
|
||
} | ||
return self; | ||
} | ||
- (void)dealloc { | ||
[super dealloc]; | ||
} | ||
|
||
- (void) ReadResolutions | ||
{ | ||
io_service_t service = IOServicePortFromCGDisplayID(displayID); | ||
if (service) | ||
{ | ||
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(service, kIODisplayOnlyPreferredName); | ||
NSNumber *displayVendorID = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayVendorID]]; | ||
NSNumber *displayProductID = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductID]]; | ||
|
||
NSString *filePath = [NSString stringWithFormat:@"/System/Library/Displays/Overrides/DisplayVendorID-%x/DisplayProductID-%x", (int)[displayVendorID integerValue], (int)[displayProductID integerValue]]; | ||
|
||
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) | ||
{ | ||
NSDictionary *displayDict = [[NSDictionary alloc] initWithContentsOfFile:filePath]; | ||
NSArray *scaleResolutions = [displayDict objectForKey:@"scale-resolutions"]; | ||
|
||
for (NSData *data in scaleResolutions) | ||
{ | ||
NSData *data4 = [data subdataWithRange:NSMakeRange(0, 4)]; | ||
int width = CFSwapInt32BigToHost(*(int*)([data4 bytes])); | ||
data4 = [data subdataWithRange:NSMakeRange(4, 4)]; | ||
int height = CFSwapInt32BigToHost(*(int*)([data4 bytes])); | ||
data4 = [data subdataWithRange:NSMakeRange(8, 4)]; | ||
int unknown = CFSwapInt32BigToHost(*(int*)([data4 bytes])); | ||
NSLog(@"%dx%dx%d", (int)width, (int)height, unknown); | ||
|
||
} | ||
|
||
[displayDict release]; | ||
} | ||
|
||
[deviceInfo release]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-17 KB
(90%)
...deproj/project.xcworkspace/xcuserdata/salzmann.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.