Skip to content

Commit

Permalink
Display mode management
Browse files Browse the repository at this point in the history
mszoek committed Oct 14, 2024
1 parent 9d1ad91 commit cdb1c41
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CoreServices/WindowServer/BSDFramebuffer.m
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ - (int)openFramebuffer: (const char *)device

_currentMode->width = width;
_currentMode->height = height;
_currentMode->depth = depth;
_currentMode->refresh = 0; // FIXME: can we get this?
_currentMode->flags = 0;

@@ -210,7 +211,6 @@ - (uint32_t)getDisplayID {

// we can't change resolutions without a drm driver so this will always fail
-(BOOL)setMode:(struct CGDisplayMode *)mode {
NSLog(@"%@ setMode always returns NO", [self class]);
return NO;
}

1 change: 1 addition & 0 deletions CoreServices/WindowServer/rpc.h
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@ struct CGDisplayMode {
int refcount;
uint32_t width;
uint32_t height;
uint32_t depth;
float refresh;
uint32_t flags;
};
39 changes: 39 additions & 0 deletions Frameworks/CoreGraphics/CGDirectDisplay.m
Original file line number Diff line number Diff line change
@@ -760,6 +760,45 @@ void CGDisplayModeRelease(CGDisplayModeRef mode) {
}

// Getting Information About a Display Mode
size_t CGDisplayModeGetWidth(CGDisplayModeRef mode) {
if(mode == NULL)
return 0;
return mode->width;
}

size_t CGDisplayModeGetHeight(CGDisplayModeRef mode) {
if(mode == NULL)
return 0;
return mode->height;
}

double CGDisplayModeGetRefreshRate(CGDisplayModeRef mode) {
if(mode == NULL)
return 0;
return mode->refresh;
}

uint32_t CGDisplayModeGetIOFlags(CGDisplayModeRef mode) {
if(mode == NULL)
return 0;
return mode->flags;
}

int32_t CGDisplayModeGetIODisplayModeID(CGDisplayModeRef mode) {
return 0;
}

bool CGDisplayModeIsUsableForDesktopGUI(CGDisplayModeRef mode) {
if(mode == NULL)
return false;
if(mode->width >= 1024 && mode->height >= 768 && mode->depth >= 24)
return true;
return false;
}

CFTypeID CGDisplayModeGetTypeID(void) {
return 0; // FIXME
}


// WindowServer info

0 comments on commit cdb1c41

Please sign in to comment.