画面の横端にマウスカーソルが来ると反対側に移動するアプリ for Mac(ダミーソース)

Quartz Eventにいました。
Carbon版 http://d.hatena.ne.jp/bootblack/20061216/p1
と構成?は同じです。前にも増して超シンプルで静寂です。右から左へ左から右へ移動するだけです。
ちなみにmy appはこれじゃないです(苦笑)。

#include <ApplicationServices/ApplicationServices.h>

#define Delta 30

//Available in Mac OS X v10.4 and later.
CGEventRef CGMouseEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef inEvent, void *refcon)
{
    // ScreenMax is MainScreen's bottom-right Position
    CGRect  mainscreen = CGDisplayBounds(CGMainDisplayID());
    CGPoint ScreenMax  = CGPointMake(mainscreen.size.width - 1, mainscreen.size.height - 1);
    
    // get MouseLocation
    CGPoint MouseLocation = CGEventGetLocation(inEvent);
    
    if(!((MouseLocation.x == 0            &&  MouseLocation.y == 0          ) ||
         (MouseLocation.x == 0            &&  MouseLocation.y == ScreenMax.y) ||
         (MouseLocation.x == ScreenMax.x  &&  MouseLocation.y ==    0       ) ||
         (MouseLocation.x == ScreenMax.x  &&  MouseLocation.y == ScreenMax.y) ||
         (MouseLocation.x > 0             &&  MouseLocation.x < ScreenMax.x))) {

        if (MouseLocation.x == 0) {                      // left edge
            MouseLocation.x = ScreenMax.x - Delta;
        } else if (MouseLocation.x == ScreenMax.x) {    // right edge
            MouseLocation.x = Delta;
        }

        // move MouseCursor Position
        CGWarpMouseCursorPosition(MouseLocation);
    }
    
    return inEvent;
}


int main (int argc, const char * argv[])
{
    CFMachPortRef        eventTap;
    CGEventMask          eventMask;
    CFRunLoopSourceRef   runLoopSource;

    eventMask   = CGEventMaskBit(kCGEventMouseMoved) | CGEventMaskBit(kCGEventLeftMouseDragged);
    eventTap    = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 
                                   kCGEventTapOptionListenOnly, eventMask, CGMouseEventCallback, NULL);
    if (!eventTap) {
        printf("Hello, World!\n");
    }
    
    runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
    CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);

    CGEventTapEnable(eventTap, true);
    CFRunLoopRun();
    
    CFRelease(runLoopSource);
    return 0;
}