• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to get CGScreenRegisterMoveCallback working?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get CGScreenRegisterMoveCallback working?


  • Subject: Re: How to get CGScreenRegisterMoveCallback working?
  • From: "Steve McLeod" <email@hidden>
  • Date: Wed, 29 Oct 2008 19:50:25 +0100

Thanks Nick,

I tried creating a RunLoop, that runs for 10 seconds, but I still had no
joy. I guess I'm still making beginner mistakes. Any ideas from the code
below, which now has a RunLoop?

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>

void MyScreenRefreshCallback (CGRectCount count, const CGRect * rectArray,
void * userParameter){
    NSLog(@"Refreshed");
}

void MyScreenUpdateMoveCallback (CGScreenUpdateMoveDelta delta, size_t
count, const CGRect * rectArray, void * userParameter) {
    NSLog(@"Updated");
}

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSLog(@"Started");

    CGRegisterScreenRefreshCallback(MyScreenRefreshCallback, NULL);
    CGScreenRegisterMoveCallback(MyScreenUpdateMoveCallback, NULL);

    NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
    [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow: 10]];

    NSLog(@"Finished");

    [pool drain];
    return 0;
}



2008/10/29 Nick Zitzmann <email@hidden>

>
> On Oct 29, 2008, at 12:00 PM, Steve McLeod wrote:
>
>  I am trying to detect whether any window moves on the screen. As far as I
>> can tell CGScreenRegisterMoveCallback should let me do this. But in the
>> little test code below, which registers callbacks then waits 20 seconds, I
>> never see the message "Updated" or "Refreshed". The code builds and runs
>> without warnings.
>>
>> Any ideas?
>>
>
>
> You need to create and run a run loop.
>
> Nick Zitzmann
> <http://www.chronosnet.com/>
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to get CGScreenRegisterMoveCallback working?
      • From: Nick Zitzmann <email@hidden>
References: 
 >How to get CGScreenRegisterMoveCallback working? (From: "Steve McLeod" <email@hidden>)
 >Re: How to get CGScreenRegisterMoveCallback working? (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: How to get CGScreenRegisterMoveCallback working?
  • Next by Date: Re: ASL & Unicode in Xcode's Console
  • Previous by thread: Re: How to get CGScreenRegisterMoveCallback working?
  • Next by thread: Re: How to get CGScreenRegisterMoveCallback working?
  • Index(es):
    • Date
    • Thread