Tomotaka SUWA
t-suw****@users*****
2005年 9月 23日 (金) 11:27:44 JST
Index: AquaSKK/PrivateRunLoop.cpp diff -u /dev/null AquaSKK/PrivateRunLoop.cpp:1.1.2.1 --- /dev/null Fri Sep 23 11:27:44 2005 +++ AquaSKK/PrivateRunLoop.cpp Fri Sep 23 11:27:44 2005 @@ -0,0 +1,84 @@ +/* + $Id: PrivateRunLoop.cpp,v 1.1.2.1 2005/09/23 02:27:44 t-suwa Exp $ + + MacOS X implementation of the SKK input method. + + Copyright (C) 2005 Tomotaka SUWA <t.suw****@mac*****> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <CoreFoundation/CoreFoundation.h> +#include <CoreServices/CoreServices.h> +#include "PrivateRunLoop.h" + +PrivateRunLoop::PrivateRunLoop( + const CFStringRef mode, CFRunLoopSourceRef runLoopSource) + : mode_(mode), runLoop_(0) +{ + // Û + runLoopSource_ = (CFRunLoopSourceRef)CFRetain(runLoopSource); + + // ^XN(=Xbh)®¹ÊmpÌbZ[WL [ð쬷é + MPCreateQueue(¬ifyQueue_); + + // ^XNðç¹é + MPCreateTask(PrivateRunLoop::entryPoint, + this, + 0, + notifyQueue_, + NULL, + NULL, + 0, + &taskID_); +} + +PrivateRunLoop::~PrivateRunLoop() +{ + // ^XNð~ßé + CFRunLoopStop(runLoop_); + + // ®SÉ®¹·éÌðÒ + MPWaitOnQueue(notifyQueue_, NULL, NULL, NULL, kDurationForever); + MPDeleteQueue(notifyQueue_); + + // jü + CFRelease(runLoopSource_); +} + +// ^XN{Ì +OSStatus PrivateRunLoop::entryPoint(void* param) +{ + PrivateRunLoop* self = (PrivateRunLoop*)param; + self->runLoop_ = CFRunLoopGetCurrent(); + + // ÄÎÛðÇÁ + CFRunLoopAddSource(self->runLoop_, + self->runLoopSource_, + self->mode_); + + // CFRunLoopStop() ªÄÎêéÜÅCxgð·é + SInt32 result; + do { + result = CFRunLoopRunInMode(self->mode_, 1, true); + } while(result != kCFRunLoopRunStopped); + + // ãn + CFRunLoopRemoveSource(self->runLoop_, + self->runLoopSource_, + self->mode_); + + return 0; +} Index: AquaSKK/PrivateRunLoop.h diff -u /dev/null AquaSKK/PrivateRunLoop.h:1.1.2.1 --- /dev/null Fri Sep 23 11:27:44 2005 +++ AquaSKK/PrivateRunLoop.h Fri Sep 23 11:27:44 2005 @@ -0,0 +1,39 @@ +/* + $Id: PrivateRunLoop.h,v 1.1.2.1 2005/09/23 02:27:44 t-suwa Exp $ + + MacOS X implementation of the SKK input method. + + Copyright (C) 2005 Tomotaka SUWA <t.suw****@mac*****> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#pragma once + +// Æ©Ì RunLoop ðç¹éNX +class PrivateRunLoop { + const CFStringRef mode_; + CFRunLoopRef runLoop_; + CFRunLoopSourceRef runLoopSource_; + MPQueueID notifyQueue_; + MPTaskID taskID_; + + // ^XN{Ì + static OSStatus entryPoint(void* param); + +public: + PrivateRunLoop(const CFStringRef mode, CFRunLoopSourceRef runLoopSource); + ~PrivateRunLoop(); +};