diff --git a/screendump/en.plist b/screendump/en.plist index fe27d27..40a0e8d 100644 --- a/screendump/en.plist +++ b/screendump/en.plist @@ -20,10 +20,6 @@ com.apple.private.hid.client.service-protected - com.apple.private.hid.manager.client - - com.apple.private.hid.client.admin - com.apple.private.IOSurface.protected-access com.apple.QuartzCore.displayable-context @@ -36,8 +32,6 @@ com.apple.private.allow-explicit-graphics-priority - com.apple.private.xpc.launchd.app-server - com.apple.CommCenter.fine-grained spi @@ -46,15 +40,5 @@ com.apple.private.security.disk-device-access - com.apple.private.touch.eeprom.access - - com.apple.security.exception.iokit-user-client-class - RootDomainUserClient - com.apple.private.ioaccelmemoryinfo - - com.apple.gpumemd.client - - com.apple.backboardd.virtualDisplay - \ No newline at end of file diff --git a/screendump/layout/DEBIAN/control b/screendump/layout/DEBIAN/control index f03b118..29a2d3c 100644 --- a/screendump/layout/DEBIAN/control +++ b/screendump/layout/DEBIAN/control @@ -7,6 +7,6 @@ Description: VNC for ios Maintainer: Julio Author: julioverne, Sharat M R Section: Tweaks -Version: 0.0.3a +Version: 0.0.3d Depiction: http://julioverne.github.io/description.html?id=com.julioverne.screendump13 Icon: file:///Library/PreferenceLoader/Preferences/screendump/ScreenDump@2x.png diff --git a/screendump/layout/Library/PreferenceLoader/Preferences/screendump/Preferences.plist b/screendump/layout/Library/PreferenceLoader/Preferences/screendump/Preferences.plist index 9ea694e..9869565 100644 Binary files a/screendump/layout/Library/PreferenceLoader/Preferences/screendump/Preferences.plist and b/screendump/layout/Library/PreferenceLoader/Preferences/screendump/Preferences.plist differ diff --git a/screendump/main.mm b/screendump/main.mm index 7c04e1d..c39aec4 100644 --- a/screendump/main.mm +++ b/screendump/main.mm @@ -19,6 +19,9 @@ static size_t bits_per_sample = 8; static size_t size_image; +static size_t prefferH; +static size_t prefferW; + static CFTypeRef (*$GSSystemCopyCapability)(CFStringRef); static CFTypeRef (*$GSSystemGetCapability)(CFStringRef); static BOOL (*$MGGetBoolAnswer)(CFStringRef); @@ -83,10 +86,15 @@ static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size) return good; } -static void upFrameLoop(); static IOSurfaceRef screenSurface = NULL; static IOMobileFramebufferRef framebufferConnection = NULL; +@interface FrameUpdater : NSObject +@property (nonatomic, retain) NSTimer* myTimer; +- (void)startFrameLoop; +- (void)stopFrameLoop; +@end + static void VNCSetup() { if(!screenSurface) { @@ -100,8 +108,8 @@ static void VNCSetup() //width = size.width/2; //height = size.height/2; - width = IOSurfaceGetWidth(screenSurface) / 2; - height = IOSurfaceGetHeight(screenSurface) / 2; + width = prefferW==0?IOSurfaceGetWidth(screenSurface):prefferW; + height = prefferW==0?IOSurfaceGetHeight(screenSurface):prefferH; size_image = IOSurfaceGetAllocSize(screenSurface); bytesPerRow = IOSurfaceGetBytesPerRow(screenSurface); @@ -149,11 +157,15 @@ static void VNCSettings(bool shouldStart, NSString* password) VNCUpdateRunState(CCSisEnabled); } + + static void VNCUpdateRunState(bool shouldStart) { if(screen == NULL) { return; } + + if(CCSPassword && CCSPassword.length) { screen->authPasswdData = (void *) CCSPassword; } else { @@ -167,12 +179,14 @@ static void VNCUpdateRunState(bool shouldStart) rfbRunEventLoop(screen, -1, true); isLoopFrame = YES; - dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ - upFrameLoop(); - }); + + [[FrameUpdater shared] startFrameLoop]; } else { isLoopFrame = NO; + + [[FrameUpdater shared] stopFrameLoop]; + rfbShutdownServer(screen, true); } isVNCRunning = shouldStart; @@ -188,36 +202,91 @@ static void loadPrefs(void) defaults = (NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, CFSTR("mobile"), kCFPreferencesAnyHost)?:@{}; CFRelease(keyList); } + + prefferH = [[defaults objectForKey:@"height"]?:@(0) intValue]; + prefferW = [[defaults objectForKey:@"width"]?:@(0) intValue]; + BOOL isEnabled = [[defaults objectForKey:@"CCSisEnabled"]?:@NO boolValue]; NSString *password = [defaults objectForKey:@"CCSPassword"]; VNCSettings(isEnabled, password); } } -static void upFrameLoop() + +static uint32_t oldSeed; + +@implementation FrameUpdater +{ + NSOperationQueue *q; +} +@synthesize myTimer; ++ (id)shared +{ + static __strong FrameUpdater* initFrame; + if(!initFrame) { + initFrame = [[[self class] alloc] init]; + } + return initFrame; +} +- (id)init +{ + self = [super init]; + + q = [[NSOperationQueue alloc] init]; + + return self; +} +- (void)_upFrameLoop +{ + if(isLoopFrame && CCSisEnabled) { + //check if screen changed + uint32_t newSeed = IOSurfaceGetSeed(screenSurface); + + if(oldSeed != newSeed && rfbIsActive(screen)) { + oldSeed = newSeed; + [q addOperationWithBlock: ^{ + IOSurfaceAcceleratorTransferSurface(accelerator, screenSurface, static_buffer, NULL, NULL, NULL, NULL); + rfbMarkRectAsModified(screen, 0, 0, width, height); + }]; + } + } else { + [self stopFrameLoop]; + } +} +- (void)stopFrameLoop +{ + if(myTimer && [myTimer isValid]) { + dispatch_async(dispatch_get_main_queue(), ^(void){ + [myTimer invalidate]; + }); + } +} +- (void)startFrameLoop { if(size_image == 0) { VNCSetup(); } - while(isLoopFrame && CCSisEnabled) { - if(rfbIsActive(screen) && IOSurfaceIsInUse(screenSurface)) { - IOSurfaceAcceleratorTransferSurface(accelerator, screenSurface, static_buffer, NULL, NULL, NULL, NULL); - //check if screen changed - void * buffBytes = IOSurfaceGetBaseAddress(static_buffer); - if(buffBytes && !(memcmp(buffBytes, "\xFF\x00\xFF\xFF\xFF\x00\xFF\xFF\xFF", 9) == 0)) { - rfbMarkRectAsModified(screen, 0, 0, width, height); - } - //sleep(1/100); - } - } + [self stopFrameLoop]; + dispatch_async(dispatch_get_main_queue(), ^(void){ + myTimer = [NSTimer scheduledTimerWithTimeInterval:1/400 target:self selector:@selector(_upFrameLoop) userInfo:nil repeats:YES]; + }); } +-(void)dealloc +{ + [self stopFrameLoop]; +} +@end - +static void restartServer() +{ + exit(0); +} int main(int argc, const char *argv[]) { CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.cosmosgenius.screendump/preferences.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); - + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)restartServer, CFSTR("com.cosmosgenius.screendump/restart"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + loadPrefs(); VNCSetup(); diff --git a/screendumpLowFrame/en.plist b/screendumpLowFrame/en.plist index 6033ad2..40a0e8d 100644 --- a/screendumpLowFrame/en.plist +++ b/screendumpLowFrame/en.plist @@ -20,10 +20,6 @@ com.apple.private.hid.client.service-protected - com.apple.private.hid.manager.client - - com.apple.private.hid.client.admin - com.apple.private.IOSurface.protected-access com.apple.QuartzCore.displayable-context @@ -36,9 +32,6 @@ com.apple.private.allow-explicit-graphics-priority - com.apple.private.xpc.launchd.app-server - - com.apple.CommCenter.fine-grained spi @@ -47,15 +40,5 @@ com.apple.private.security.disk-device-access - com.apple.private.touch.eeprom.access - - com.apple.security.exception.iokit-user-client-class - RootDomainUserClient - com.apple.private.ioaccelmemoryinfo - - com.apple.gpumemd.client - - com.apple.backboardd.virtualDisplay - \ No newline at end of file diff --git a/screendumpLowFrame/layout/DEBIAN/control b/screendumpLowFrame/layout/DEBIAN/control index 050732b..3e5b82a 100644 --- a/screendumpLowFrame/layout/DEBIAN/control +++ b/screendumpLowFrame/layout/DEBIAN/control @@ -7,4 +7,3 @@ Maintainer: Sharat M R Author: Sharat M R Section: Tweaks Version: 0.0.3 -Installed-Size: 3100