Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-format #35

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# From https://github.com/dhinakg/dotfiles

BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 140
DerivePointerAlignment: false
PointerAlignment: Left
ExperimentalAutoDetectBinPacking: true
SpaceBeforeCpp11BracedList: true
---
Language: ObjC
# Force pointers to the type for C++.
AlignArrayOfStructures: None
SpacesInContainerLiterals: false
BreakStringLiterals: false
ObjCBreakBeforeNestedBlockParam: false
ObjCBlockIndentWidth: 4
---
31 changes: 31 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check code style

on:
push:
pull_request:
workflow_dispatch:

jobs:
format:
name: Check code style
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: cpp-linter/cpp-linter-action@v2
id: linter
with:
style: file
extensions: 'c,h,m,C,H,cpp,mm,hpp,cc,hh,c++,h++,cxx,hxx'
tidy-checks: '-*'
version: '16'
files-changed-only: ${{ github.event_name == 'pull_request' }}
thread-comments: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check for lint failure
if: steps.linter.outputs.checks-failed > 0
run: |
echo "::error::Code style check failed."
exit 1

77 changes: 35 additions & 42 deletions CoreDisplay/Main.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,45 @@
@import Darwin.POSIX.dlfcn;
@import UniformTypeIdentifiers;

__attribute__((constructor))
void load()
{
traceLog=true;
}
__attribute__((constructor)) void load() { traceLog = true; }

dispatch_once_t slsOnce;
NSDictionary* (*dynamic_SLSCopyDisplayInfoDictionary)(int)=NULL;

NSDictionary* CoreDisplay_DisplayCreateInfoDictionary(int edi)
{
trace(@"thic: CoreDisplay_DisplayCreateInfoDictionary %d %@",edi,NSThread.callStackSymbols);

dispatch_once(&slsOnce,^()
{
dynamic_SLSCopyDisplayInfoDictionary=dlsym(RTLD_DEFAULT,"SLSCopyDisplayInfoDictionary");
trace(@"thic: dlsym %p %s",dynamic_SLSCopyDisplayInfoDictionary,dlerror());
});

if(!dynamic_SLSCopyDisplayInfoDictionary)
{
return nil;
}

NSDictionary* result=dynamic_SLSCopyDisplayInfoDictionary(edi);

NSMutableDictionary* mutable=result.mutableCopy;
result.release;
NSDictionary* (*dynamic_SLSCopyDisplayInfoDictionary)(int) = NULL;

NSDictionary* CoreDisplay_DisplayCreateInfoDictionary(int edi) {
trace(@"thic: CoreDisplay_DisplayCreateInfoDictionary %d %@", edi, NSThread.callStackSymbols);

dispatch_once(&slsOnce, ^() {
dynamic_SLSCopyDisplayInfoDictionary = dlsym(RTLD_DEFAULT, "SLSCopyDisplayInfoDictionary");
trace(@"thic: dlsym %p %s", dynamic_SLSCopyDisplayInfoDictionary, dlerror());
});

if (!dynamic_SLSCopyDisplayInfoDictionary) {
return nil;
}

NSDictionary* result = dynamic_SLSCopyDisplayInfoDictionary(edi);

NSMutableDictionary* mutable = result.mutableCopy;
result.release;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-method-access"
NSString* type=[[UTType _typeOfCurrentDevice] identifier];
NSString* type = [[UTType _typeOfCurrentDevice] identifier];
#pragma clang diagnostic pop
NSString* path=[NSString stringWithFormat:@"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/%@.icns",type];
trace(@"thic: adding %@",path);
mutable[@"display-icon"]=path;
mutable[@"display-resolution-preview-icon"]=path;
// TODO: these are for placing the screen image over the icon
/*mutable[@"resolution-preview-width"]=
mutable[@"resolution-preview-height"]=
mutable[@"resolution-preview-x"]=
mutable[@"resolution-preview-x"]=*/
trace(@"thic: result %@",mutable);
return mutable;
NSString* path = [NSString stringWithFormat:@"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/%@.icns", type];

trace(@"thic: adding %@", path);
mutable[@"display-icon"] = path;
mutable[@"display-resolution-preview-icon"] = path;

// TODO: these are for placing the screen image over the icon
/*mutable[@"resolution-preview-width"]=
mutable[@"resolution-preview-height"]=
mutable[@"resolution-preview-x"]=
mutable[@"resolution-preview-x"]=*/

trace(@"thic: result %@", mutable);

return mutable;
}
20 changes: 9 additions & 11 deletions IOSurface/Main.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@

size_t IOSurfaceGetPropertyMaximu$(CFStringRef);

size_t IOSurfaceGetPropertyMaximum(CFStringRef property)
{
size_t real=IOSurfaceGetPropertyMaximu$(property);
if(real==INT_MAX)
{
// TODO: actually fetch the value somehow?
// returned by working IOSurface on Zoe, but could vary on different GPUs

return 0x2000;
}
return real;
size_t IOSurfaceGetPropertyMaximum(CFStringRef property) {
size_t real = IOSurfaceGetPropertyMaximu$(property);
if (real == INT_MAX) {
// TODO: actually fetch the value somehow?
// returned by working IOSurface on Zoe, but could vary on different GPUs

return 0x2000;
}
return real;
}

#endif
67 changes: 29 additions & 38 deletions QuartzCore/Animations.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
// Control Center fade out
// TODO: check necessary

#if MAJOR>=12
#if MAJOR >= 12

@interface CAPresentationModifierGroup(Shim)
@interface CAPresentationModifierGroup (Shim)
@end

@implementation CAPresentationModifierGroup(Shim)
@implementation CAPresentationModifierGroup (Shim)

-(void)flushWithTransaction
{
- (void)flushWithTransaction {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-method-access"
[self flush];
[self flush];
#pragma clang diagnostic pop
}

Expand All @@ -26,49 +25,41 @@ -(void)flushWithTransaction

BOOL brightnessHack;

int transactionBoolCount=0;
NSString* transactionFakeKey(int key)
{
return [NSString stringWithFormat:@"fake%d",key];
}
int transactionBoolCount = 0;
NSString* transactionFakeKey(int key) { return [NSString stringWithFormat:@"fake%d", key]; }

@interface CATransaction(Shim)
@interface CATransaction (Shim)
@end

@implementation CATransaction(Shim)
@implementation CATransaction (Shim)

+(void)setBoolValue:(BOOL)value forKey:(int)key
{
[self setValue:[NSNumber numberWithBool:value] forKey:transactionFakeKey(key)];
+ (void)setBoolValue:(BOOL)value forKey:(int)key {
[self setValue:[NSNumber numberWithBool:value] forKey:transactionFakeKey(key)];
}

+(BOOL)boolValueForKey:(int)key
{
// MinhTon's fix for brightness slider on MacBook5,1
// TODO: a mystery

if(brightnessHack)
{
return false;
}

BOOL result=((NSNumber*)[self valueForKey:transactionFakeKey(key)]).boolValue;

return result;
+ (BOOL)boolValueForKey:(int)key {
// MinhTon's fix for brightness slider on MacBook5,1
// TODO: a mystery

if (brightnessHack) {
return false;
}

BOOL result = ((NSNumber*)[self valueForKey:transactionFakeKey(key)]).boolValue;

return result;
}

+(int)registerBoolKey
{
transactionBoolCount++;

return transactionBoolCount;
+ (int)registerBoolKey {
transactionBoolCount++;

return transactionBoolCount;
}
@end

void animationsSetup()
{
// removed Cat/Mojave check here because it's in Main - Amy
brightnessHack=[process isEqualToString:@"/System/Library/CoreServices/ControlCenter.app/Contents/MacOS/ControlCenter"];
void animationsSetup() {
// removed Cat/Mojave check here because it's in Main - Amy
brightnessHack = [process isEqualToString:@"/System/Library/CoreServices/ControlCenter.app/Contents/MacOS/ControlCenter"];
}

#endif
Loading