emSvgServerModel::JobHandle emSvgServerModel::StartRenderJob( SvgHandle svgHandle, double srcX, double srcY, double srcWidth, double srcHeight, emColor bgColor, emImage * outputImage, double priority, emEngine * listenEngine ) { RenderJob * job; job=new RenderJob; job->Priority=priority; job->ListenEngine=listenEngine; job->ProcRunId=((SvgInstance*)svgHandle)->ProcRunId; job->InstanceId=((SvgInstance*)svgHandle)->InstanceId; job->SrcX=srcX; job->SrcY=srcY; job->SrcWidth=srcWidth; job->SrcHeight=srcHeight; job->BgColor=bgColor; job->OutputImage=outputImage; job->TgtW=outputImage->GetWidth(); job->TgtH=outputImage->GetHeight(); AddJobToWaitingList(job); WakeUp(); return job; }
void Selector::Update(ISelectable *p) { ScopedLock lock = ScopedLock(&m_mutex); m_modified = true; UpdateMap(p->GetFD(this)); WakeUp(); }
void EventQueue::Push(const Event &event) { ScopeLock protect(mutex); events.push(event); WakeUp(); }
void wxCFEventLoop::CommonModeObserverCallBack(CFRunLoopObserverRef WXUNUSED(observer), int activity) { if ( activity & kCFRunLoopBeforeTimers ) { // process pending wx events first as they correspond to low-level events // which happened before, i.e. typically pending events were queued by a // previous call to Dispatch() and if we didn't process them now the next // call to it might enqueue them again (as happens with e.g. socket events // which would be generated as long as there is input available on socket // and this input is only removed from it when pending event handlers are // executed) if ( wxTheApp && ShouldProcessIdleEvents() ) wxTheApp->ProcessPendingEvents(); } if ( activity & kCFRunLoopBeforeWaiting ) { if ( ShouldProcessIdleEvents() && ProcessIdle() ) { WakeUp(); } else { #if wxUSE_THREADS wxMutexGuiLeaveOrEnter(); #endif } } }
Selector::~Selector() { m_loop = false; WakeUp(); Thread::Stop(); do { ScopedLock lock = ScopedLock(&m_mutex); restart: m_modified = false; for(std::map<int, ISelectable *>::iterator it = m_map.begin(); it != m_map.end(); it++) { it->second->DoClose(this); if (m_modified) goto restart; } } while(0); if (m_map.size() > 0) { abort(); //Tried to delete selector with items left in it } if (close(m_controlfd) < 0) abort(); }
void BaseRenderer::SetRenderingEnabled(bool const isEnabled, TCompletionHandler completionHandler) { if (isEnabled == m_isEnabled) { if (completionHandler != nullptr) completionHandler(); return; } m_renderingEnablingCompletionHandler = move(completionHandler); if (isEnabled) { // wake up rendering thread WakeUp(); } else { // here we set up value only if rendering disabled m_isEnabled = false; // if renderer thread is waiting for message let it go CancelMessageWaiting(); } }
emStopwatchPanel::emStopwatchPanel( ParentArg parent, const emString & name, emClockFileModel * fileModel, emColor fgColor ) : emFilePanel(parent,name,fileModel) { FileModel=fileModel; FgColor=fgColor; TimeField=new emTkTextField(this,"time_field"); StartStopButton=new emTkButton( this,"start_stop_button","Start/Stop", "Start or stop the stopwatch.\n" "Remember that the action is performed\n" "at releasing of the mouse button." ); ClearButton=new emTkButton( this,"clear_button","Clear", "Reset the stopwatch to zero time." ); FileModel->TkLook.Apply(this,true); AddWakeUpSignal(GetVirFileStateSignal()); AddWakeUpSignal(FileModel->GetChangeSignal()); AddWakeUpSignal(StartStopButton->GetClickSignal()); AddWakeUpSignal(ClearButton->GetClickSignal()); UpdateTimeFieldAndButtons(); WakeUp(); }
//位置を動かす力を加える void Body::ApplyCorrect(ho::VECTOR3DOUBLE *pvecForce, ho::VECTOR3DOUBLE *pvecLocalPos) { if (Fixed) return; WakeUp(); //目覚める vecPos += *pvecForce * InverseMass; //並進加速度は位置に関係なく加算される ho::VECTOR3DOUBLE vecLocalL = ho::VECTOR3DOUBLE::GetCrossProduct(*pvecLocalPos, *pvecForce); //姿勢変化に影響する角運動量は相対位置と力のベクトルとの外積で求まる ho::VECTOR3DOUBLE vecOmega2 = vecLocalL * mtrxInverseInertiaTensorT;//変化する角運動量ベクトルと慣性テンソルの逆行列を積算して、変化する角度ωを求める /* //これは行列で同じ回転をする場合 ho::Matrix mtrx, mtrxOmega(&vecOmega2.Normalize(), vecOmega2.GetPower()); qtAngle.CalcMatrix(&mtrx); mtrx = mtrxOmega * mtrx; qtAngle = ho::Quaternion(&mtrx); */ qtAngle += 0.5 * ho::Quaternion(0, vecOmega2.x, vecOmega2.y, vecOmega2.z) * qtAngle; //角速度ωに応じて姿勢を変化させる //qtAngle.Normalize(); //クォータニオンを正規化 CalcmtrxInverseInertiaTensorT(); //姿勢(クォータニオン)が変化したので、現在時刻(現在姿勢)での慣性テンソルの逆行列を計算しておく return; }
int PipeRead(struct File* file, BYTE* buffer, DWORD count) { DWORD size = 0, chars = 0; int read = 0; if (!count) return 0; if (file->flags & FILE_NONBLOCK) { if (PIPE_LOCK(file)) return 0; // if (PIPE_EMPTY(file)) // { /* return -EAGAIN? */ // return 0; // } }else{ while (PIPE_EMPTY(file) || PIPE_LOCK(file)) { if (PIPE_EMPTY(file)) return 0; KePrint("WAIT\n"); // WAIT_ON(&PIPE_WAIT(file), (PIPE_LOCK(file) == 0)); } } PIPE_LOCK(file)++; while (count > 0 && (size = PIPE_SIZE(file))) { char* pipeBuf = PIPE_BUF(file) + PIPE_START(file); chars = PIPE_MAX_RCHUNK(file); if (chars > count) chars = count; if (chars > size) chars = size; read += chars; PIPE_START(file) += chars; PIPE_START(file) &= (PIPE_BUFFER_SIZE - 1); PIPE_SIZE(file) -= chars; count -= chars; memcpy(buffer, pipeBuf, chars); buffer+=chars; } PIPE_LOCK(file)--; WakeUp(&PIPE_WAIT(file)); return read; }
void GraphicsScene::mouseReleaseEvent( QGraphicsSceneMouseEvent * event ) { if (WakeUp(QPointF(event->scenePos().x(),event->scenePos().y()))) { event->setAccepted ( true ) ; clearSelection(); } QGraphicsScene::mouseReleaseEvent(event); }
void WorkerThread::DoWork( WorkItem* item, int priority, bool toBeDeleted ) { wxLogMessage( _T( "scheduling WorkItem %p, prio = %d" ), item, priority ); item->m_priority = priority; item->m_toBeDeleted = toBeDeleted; m_workItems.Push( item ); WakeUp(); }
static PollIO* Register(PollIO *io, bool init_permit_recv, bool init_permit_send) { Thread::Mutex::Scoped l(locker_event); ionew[io->fd] = io; if ( init_permit_recv ) { io->newevent |= POLLIN; io->update = true; } if ( init_permit_send ) { io->newevent |= POLLOUT; io->update = true; } WakeUp(); return io; }
void EventLoop::QueueInLoop(const Functor& rCallBack) { { MutexLockGuard lock(m_Mutex); m_vPendingFunctors.push_back(rCallBack); } if (!IsInLoopThread() || m_bCallingFunctors) { WakeUp(); } }
//直線速度のみに影響を与える力積を加える void Body::ApplyLinearForce(ho::VECTOR3DOUBLE *pvecForce) { if (Fixed) return; WakeUp(); //目覚める vecParallelV += *pvecForce * InverseMass; //並進加速度は位置に関係なく加算される return; }
void GraphDriver::EnsureNextIterationLocked() { mGraphImpl->GetMonitor().AssertCurrentThreadOwns(); if (IsWaitingIndefinitly()) { WakeUp(); } if (mNeedAnotherIteration) { return; } mNeedAnotherIteration = true; }
//力積を加える void Body::ApplyForce(ho::VECTOR3DOUBLE *pvecForce, ho::VECTOR3DOUBLE *pvecLocalPos) { if (Fixed) return; WakeUp(); //目覚める vecParallelV += *pvecForce * InverseMass; //並進加速度は位置に関係なく加算される vecL += ho::VECTOR3DOUBLE::GetCrossProduct(*pvecLocalPos, *pvecForce); //角加速度は相対位置と力のベクトルとの外積で求まる vecOmega = vecL * mtrxInverseInertiaTensorT;//角運動量ベクトルと慣性テンソルの逆行列を積算して、角速度ωを求める return; }
void Selector::Add(ISelectable *p) { int fd = p->GetFD(this); if (fd < 0 || fd >= FD_SETSIZE) abort(); //Invalid FD this is a bug if (m_map.find(fd) != m_map.end()) abort(); //Duplicate FD? ScopedLock lock = ScopedLock(&m_mutex); m_modified = true; m_map[fd] = p; UpdateMap(fd); FindHighestFD(); WakeUp(); }
void BaseRenderer::StopThread() { // send message to stop rendering in render thread m_commutator->PostMessage(m_threadName, make_unique_dp<StopRenderingMessage>(), MessagePriority::High); // wake up render thread if necessary if (!m_isEnabled) { WakeUp(); } // wait for render thread completion m_selfThread.Join(); }
void emX11WindowPort::InvalidatePainting(double x, double y, double w, double h) { double x2,y2; x2=x+w; if (x2>ClipX2) x2=ClipX2; if (x<ClipX1) x=ClipX1; if (x>=x2) return; y2=y+h; if (y2>ClipY2) y2=ClipY2; if (y<ClipY1) y=ClipY1; if (y>=y2) return; InvalidRects.Unite((int)x,(int)y,(int)ceil(x2),(int)ceil(y2)); if (InvalidRects.GetCount()>64) InvalidRects.SetToMinMax(); WakeUp(); }
void emSvgServerModel::CloseSvg(SvgHandle svgHandle) { CloseJobStruct * job; SvgInstance * inst; inst=(SvgInstance*)svgHandle; if (inst->ProcRunId==ProcRunId) { job=new CloseJobStruct; job->ProcRunId=inst->ProcRunId; job->InstanceId=inst->InstanceId; job->Orphan=true; AddJobToWaitingList(job); WakeUp(); } delete inst; }
emSvgServerModel::JobHandle emSvgServerModel::StartOpenJob( const emString & filePath, SvgHandle * svgHandleReturn, double priority, emEngine * listenEngine ) { OpenJob * job; job=new OpenJob; job->Priority=priority; job->ListenEngine=listenEngine; job->FilePath=filePath; job->SvgHandleReturn=svgHandleReturn; AddJobToWaitingList(job); WakeUp(); return job; }
// sets the "should exit" flag and wakes up the loop so that it terminates // soon void ScheduleExit( int rc = 0 ) { wxCHECK_RET( IsInsideRun(), wxT("can't call ScheduleExit() if not running") ); m_exitcode = rc; m_shouldExit = true; OnExit(); // all we have to do to exit from the loop is to (maybe) wake it up so that // it can notice that Exit() had been called // // in particular, do *not* use here calls such as PostQuitMessage() (under // MSW) which terminate the current event loop here because we're not sure // that it is going to be processed by the correct event loop: it would be // possible that another one is started and terminated by mistake if we do // this WakeUp(); }
void emX11WindowPort::SetPosSize( double x, double y, PosSizeArgSpec posSpec, double w, double h, PosSizeArgSpec sizeSpec ) { if ((GetWindowFlags()&emWindow::WF_FULLSCREEN)!=0) { posSpec=PSAS_IGNORE; sizeSpec=PSAS_IGNORE; } if (posSpec==PSAS_IGNORE) { x=GetViewX(); y=GetViewY(); } else { if (posSpec==PSAS_WINDOW) { x+=BorderL; y+=BorderT; } x=floor(x+0.5); y=floor(y+0.5); PosForced=true; PosPending=true; } if (sizeSpec==PSAS_IGNORE) { w=GetViewWidth(); h=GetViewHeight(); } else { if (sizeSpec==PSAS_WINDOW) { w-=BorderL+BorderR; h-=BorderT+BorderB; } w=floor(w+0.5); h=floor(h+0.5); if (w<MinPaneW) w=MinPaneW; if (h<MinPaneH) h=MinPaneH; SizeForced=true; SizePending=true; } SetViewGeometry(x,y,w,h,Screen.PixelTallness); WakeUp(); }
void AlsaPlayer::PrepareShutdownInternal () { int result = 0; LOG_ALSA ("AlsaPlayer::PrepareShutdownInternal ().\n"); // Wait for the audio thread to finish shutdown = true; if (audio_thread != NULL) { WakeUp (); result = pthread_join (*audio_thread, NULL); if (result != 0) { LOG_AUDIO ("AudioPlayer::Shutdown (): failed to join the audio thread (error code: %i).\n", result); } else { // Only free the thread if we could join it. g_free (audio_thread); } audio_thread = NULL; } }
void Selector::Remove(ISelectable *p) { int fd = p->GetFD(this); if (fd < 0 || fd >= FD_SETSIZE) abort(); //Invalid FD this is a bug if (m_map.find(fd) == m_map.end()) abort(); //No FD to remove ScopedLock lock = ScopedLock(&m_mutex); m_modified = true; FD_CLR(fd, &m_freads); FD_CLR(fd, &m_fwrites); FD_CLR(fd, &m_fexcept); m_map.erase(m_map.find(fd)); std::map<int, struct timespec>::iterator it = m_timeout.find(fd); if (it != m_timeout.end()) m_timeout.erase(it); FindHighestFD(); WakeUp(); }
void CStatusEffectContainer::CheckRegen(uint32 tick) { DSP_DEBUG_BREAK_IF(m_POwner == nullptr); if (!m_POwner->isDead()) { if ((tick - m_RegenCheckTime) < 3000 ) { return; } CCharEntity* PChar = nullptr; if(m_POwner->objtype == TYPE_PC) { PChar = (CCharEntity*)m_POwner; } m_RegenCheckTime = tick; int16 regen = m_POwner->getMod(MOD_REGEN); int16 poison = m_POwner->getMod(MOD_REGEN_DOWN); int16 refresh = m_POwner->getMod(MOD_REFRESH) - m_POwner->getMod(MOD_REFRESH_DOWN); int16 regain = m_POwner->getMod(MOD_REGAIN) - m_POwner->getMod(MOD_REGAIN_DOWN); bool update = false; if (m_POwner->addHP(regen)) update = true; if(poison) { int16 damage = battleutils::HandleStoneskin(m_POwner, poison); if(damage > 0) { DelStatusEffectSilent(EFFECT_HEALING); m_POwner->addHP(-damage); WakeUp(); update = true; } } if (m_POwner->getMod(MOD_AVATAR_PERPETUATION) > 0 && (m_POwner->objtype == TYPE_PC)) { int16 perpetuation = m_POwner->getMod(MOD_AVATAR_PERPETUATION); if (m_POwner->StatusEffectContainer->HasStatusEffect(EFFECT_ASTRAL_FLOW)) perpetuation = 0; else { if (m_POwner->PPet != nullptr && PChar != nullptr) { if(m_POwner->PPet->objtype == TYPE_PET) { CPetEntity* PPet = (CPetEntity*)m_POwner->PPet; CItem* hands = PChar->getEquip(SLOT_HANDS); // carbuncle mitts only work on carbuncle if (hands && hands->getID() == 14062 && PPet->name == "Carbuncle"){ perpetuation /= 2; } } perpetuation -= charutils::AvatarPerpetuationReduction(PChar); if( perpetuation < 1 ) perpetuation = 1; } } if (m_POwner->addMP(refresh - perpetuation)) update = true; if( m_POwner->health.mp == 0 && m_POwner->PPet != nullptr && m_POwner->PPet->objtype == TYPE_PET) { CPetEntity* PPet = (CPetEntity*)m_POwner->PPet; if (PPet->getPetType() == PETTYPE_AVATAR) { petutils::DespawnPet(m_POwner); } } } else { if (m_POwner->addMP(refresh)) update = true; } if (m_POwner->addTP(regain)) update = true; if (m_POwner->PPet && ((CPetEntity*)(m_POwner->PPet))->getPetType() == PETTYPE_AUTOMATON) { ((CAutomatonEntity*)(m_POwner->PPet))->burdenTick(); } if( m_POwner->status != STATUS_DISAPPEAR && (m_POwner->objtype == TYPE_PC) && update) { charutils::UpdateHealth((CCharEntity*)m_POwner); } } }
void emX11WindowPort::PreConstruct() { XSetWindowAttributes xswa; XWMHints xwmh; XClassHint xch; XSizeHints xsh; XGCValues xgcv; long eventMask,extraEventMask; double vrx,vry,vrw,vrh,d; int border; bool haveBorder; if ((GetWindowFlags()&emWindow::WF_FULLSCREEN)!=0) { Screen.LeaveFullscreenModes(&GetWindow()); Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh); MinPaneW=1; MinPaneH=1; PaneX=(int)(vrx+0.5); PaneY=(int)(vry+0.5); PaneW=(int)(vrw+0.5); PaneH=(int)(vrh+0.5); BorderL=0; BorderT=0; BorderR=0; BorderB=0; haveBorder=false; Focused=true; } else if ((GetWindowFlags()&(emWindow::WF_POPUP|emWindow::WF_UNDECORATED))!=0) { Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh); MinPaneW=1; MinPaneH=1; PaneX=(int)(vrx+vrw*emGetDblRandom(0.22,0.28)+0.5); PaneY=(int)(vry+vrh*emGetDblRandom(0.22,0.28)+0.5); PaneW=(int)(vrw*0.5+0.5); PaneH=(int)(vrh*0.5+0.5); BorderL=0; BorderT=0; BorderR=0; BorderB=0; haveBorder=false; Focused=true; } else { Screen.LeaveFullscreenModes(&GetWindow()); Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh); MinPaneW=32; MinPaneH=32; if (!Owner && (GetWindowFlags()&emWindow::WF_MODAL)==0) { d=emMin(vrw,vrh)*0.08; PaneX=(int)(vrx+d*emGetDblRandom(0.5,1.5)+0.5); PaneY=(int)(vry+d*emGetDblRandom(0.8,1.2)+0.5); PaneW=(int)(vrw-d*2.0+0.5); PaneH=(int)(vrh-d*2.0+0.5); } else { PaneX=(int)(vrx+vrw*emGetDblRandom(0.22,0.28)+0.5); PaneY=(int)(vry+vrh*emGetDblRandom(0.22,0.28)+0.5); PaneW=(int)(vrw*0.5+0.5); PaneH=(int)(vrh*0.5+0.5); } // Some window managers seem to expect that we would expect this: BorderL=3; BorderT=18; BorderR=3; BorderB=3; haveBorder=true; if ((GetWindowFlags()&emWindow::WF_MODAL)!=0) Focused=true; else Focused=false; } ClipX1=PaneX; ClipY1=PaneY; ClipX2=PaneX+PaneW; ClipY2=PaneY+PaneH; PosForced=false; PosPending=false; SizeForced=false; SizePending=false; InvalidRects.Set(PaneX,PaneY,PaneX+PaneW,PaneY+PaneH); Title.Empty(); TitlePending=true; IconPending=true; Cursor=-1; CursorPending=true; PostConstructed=false; Mapped=false; InputStateClock=0; LastButtonPress=EM_KEY_NONE; RepeatKey=EM_KEY_NONE; memset(&ComposeStatus,0,sizeof(ComposeStatus)); memset(&xsh,0,sizeof(xsh)); xsh.flags =PMinSize; xsh.min_width =MinPaneW; xsh.min_height=MinPaneH; eventMask= ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask| KeyPressMask|KeyReleaseMask|StructureNotifyMask|SubstructureNotifyMask| VisibilityChangeMask|FocusChangeMask ; memset(&xswa,0,sizeof(xswa)); xswa.bit_gravity=ForgetGravity; xswa.colormap=Screen.Colmap; xswa.event_mask=eventMask; if (haveBorder) { xswa.override_redirect=False; border=1; } else { xswa.override_redirect=True; border=0; } XMutex.Lock(); Win=XCreateWindow( Disp, Screen.RootWin, PaneX-BorderL, PaneY-BorderT, PaneW, PaneH, border, Screen.VisuDepth, InputOutput, Screen.Visu, CWBitGravity|CWColormap|CWEventMask|CWOverrideRedirect, &xswa ); XMutex.Unlock(); Screen.WCThread->AddWindow(Win); if (Owner) { XMutex.Lock(); XSetTransientForHint(Disp,Win,Owner->Win); XMutex.Unlock(); } if (Screen.InputMethod) { XMutex.Lock(); InputContext=XCreateIC( Screen.InputMethod, XNInputStyle,XIMPreeditNothing|XIMStatusNothing, XNClientWindow,Win, (char*)NULL ); XMutex.Unlock(); if (InputContext==NULL) { emFatalError("Failed to create X input context."); } } else { InputContext=NULL; } if (InputContext) { XMutex.Lock(); XGetICValues(InputContext,XNFilterEvents,&extraEventMask,(char*)NULL); XMutex.Unlock(); eventMask|=extraEventMask; } XMutex.Lock(); XSelectInput(Disp,Win,eventMask); XMutex.Unlock(); memset(&xwmh,0,sizeof(xwmh)); xwmh.flags=(InputHint|StateHint); xwmh.input=True; xwmh.initial_state=NormalState; memset(&xch,0,sizeof(xch)); xch.res_name =(char*)GetWMResName().Get(); xch.res_class=(char*)"EagleMode"; XMutex.Lock(); XmbSetWMProperties(Disp,Win,Title.Get(),NULL,NULL,0,&xsh,&xwmh,&xch); XMutex.Unlock(); XMutex.Lock(); XChangeProperty( Disp, Win, Screen.WM_PROTOCOLS, XA_ATOM, 32, PropModeReplace, (const unsigned char*)&Screen.WM_DELETE_WINDOW, 1 ); XMutex.Unlock(); memset(&xgcv,0,sizeof(xgcv)); XMutex.Lock(); Gc=XCreateGC(Disp,Win,0,&xgcv); XMutex.Unlock(); SetViewFocused(Focused); SetViewGeometry(PaneX,PaneY,PaneW,PaneH,Screen.PixelTallness); WakeUp(); }
void emX11WindowPort::HandleEvent(XEvent & event) { emInputEvent inputEvent; emX11WindowPort * wp; char tmp[256]; char keymap[32]; KeySym ks; emInputKey key; Status status; int i,x,y,w,h,mask,repeat,variant,len; double mx,my; bool inside; // Remember: // - Calling InputToView may delete this window port. // - The grab stuff is very very tricky. switch (event.type) { case MotionNotify: mx=PaneX+event.xmotion.x+Screen.MouseWarpX; my=PaneY+event.xmotion.y+Screen.MouseWarpY; if ( Screen.InputState.GetMouseX()!=mx || Screen.InputState.GetMouseY()!=my ) { Screen.InputState.SetMouse(mx,my); Screen.InputStateClock++; } for (i=0; i<3; i++) { if (i==0) { key=EM_KEY_LEFT_BUTTON ; mask=Button1Mask; } else if (i==1) { key=EM_KEY_MIDDLE_BUTTON; mask=Button2Mask; } else { key=EM_KEY_RIGHT_BUTTON ; mask=Button3Mask; } if (Screen.InputState.Get(key) && (event.xmotion.state&mask)==0) { Screen.InputState.Set(key,false); Screen.InputStateClock++; } } return; case ButtonPress: mx=PaneX+event.xbutton.x+Screen.MouseWarpX; my=PaneY+event.xbutton.y+Screen.MouseWarpY; if ( Screen.InputState.GetMouseX()!=mx || Screen.InputState.GetMouseY()!=my ) { Screen.InputState.SetMouse(mx,my); Screen.InputStateClock++; } wp=SearchOwnedPopupAt(mx,my); if (wp) { if (wp->Mapped) { event.xbutton.x+=PaneX-wp->PaneX; event.xbutton.y+=PaneY-wp->PaneY; wp->HandleEvent(event); } return; } if (ModalDescendants>0) { FocusModalDescendant(true); return; } inside=( mx>=PaneX && mx<PaneX+PaneW && my>=PaneY && my<PaneY+PaneH ); if ( !inside && Screen.GrabbingWinPort==this && (GetWindowFlags()&emWindow::WF_POPUP)!=0 ) { XMutex.Lock(); XAllowEvents(Disp,ReplayPointer,CurrentTime); XMutex.Unlock(); Screen.GrabbingWinPort=NULL; LastButtonPress=EM_KEY_NONE; SignalWindowClosing(); } for (i=Screen.WinPorts.GetCount()-1; i>=0; i--) { wp=Screen.WinPorts[i]; if ( (wp->GetWindowFlags()&emWindow::WF_POPUP)!=0 && wp!=this && !wp->IsAncestorOf(this) ) { wp->SignalWindowClosing(); } } if (!inside) return; if (!Focused && event.xbutton.button>=1 && event.xbutton.button<=5) { RequestFocus(); Screen.UpdateKeymapAndInputState(); } if (event.xbutton.button>=1 && event.xbutton.button<=3) { if (event.xbutton.button==1) key=EM_KEY_LEFT_BUTTON; else if (event.xbutton.button==2) key=EM_KEY_MIDDLE_BUTTON; else key=EM_KEY_RIGHT_BUTTON; if (!Screen.InputState.Get(key)) { Screen.InputState.Set(key,true); Screen.InputStateClock++; if ( key==LastButtonPress && event.xbutton.time>LastButtonPressTime && event.xbutton.time-LastButtonPressTime<=330 && event.xbutton.x>=LastButtonPressX-10 && event.xbutton.x<=LastButtonPressX+10 && event.xbutton.y>=LastButtonPressY-10 && event.xbutton.y<=LastButtonPressY+10 ) { repeat=LastButtonPressRepeat+1; } else { repeat=0; } LastButtonPress=key; LastButtonPressTime=event.xbutton.time; LastButtonPressX=event.xbutton.x; LastButtonPressY=event.xbutton.y; LastButtonPressRepeat=repeat; inputEvent.Setup(key,"",repeat,0); InputStateClock=Screen.InputStateClock; InputToView(inputEvent,Screen.InputState); return; } } else if (event.xbutton.button==4) { inputEvent.Setup(EM_KEY_WHEEL_UP,"",0,0); InputStateClock=Screen.InputStateClock; InputToView(inputEvent,Screen.InputState); return; } else if (event.xbutton.button==5) { inputEvent.Setup(EM_KEY_WHEEL_DOWN,"",0,0); InputStateClock=Screen.InputStateClock; InputToView(inputEvent,Screen.InputState); return; } return; case ButtonRelease: mx=PaneX+event.xbutton.x+Screen.MouseWarpX; my=PaneY+event.xbutton.y+Screen.MouseWarpY; if ( Screen.InputState.GetMouseX()!=mx || Screen.InputState.GetMouseY()!=my ) { Screen.InputState.SetMouse(mx,my); Screen.InputStateClock++; } if (event.xbutton.button>=1 && event.xbutton.button<=3) { if (event.xbutton.button==1) key=EM_KEY_LEFT_BUTTON; else if (event.xbutton.button==2) key=EM_KEY_MIDDLE_BUTTON; else key=EM_KEY_RIGHT_BUTTON; if (Screen.InputState.Get(key)) { Screen.InputState.Set(key,false); Screen.InputStateClock++; inputEvent.Eat(); InputStateClock=Screen.InputStateClock; InputToView(inputEvent,Screen.InputState); return; } } return; case KeyPress: i=event.xkey.keycode/8; mask=1<<(event.xkey.keycode&7); if (i<32 && (Screen.Keymap[i]&mask)==0) { Screen.Keymap[i]|=mask; Screen.UpdateInputStateFromKeymap(); } if (InputContext) { XMutex.Lock(); len=XmbLookupString( InputContext, &event.xkey, tmp, sizeof(tmp)-1, &ks, &status ); XMutex.Unlock(); if (status!=XLookupChars && status!=XLookupBoth) len=0; if (status!=XLookupKeySym && status!=XLookupBoth) ks=0; } else { XMutex.Lock(); len=XLookupString( &event.xkey, tmp, sizeof(tmp)-1, &ks, &ComposeStatus ); XMutex.Unlock(); } tmp[len]=0; key=emX11Screen::ConvertKey(ks,&variant); if (key==EM_KEY_NONE && !tmp[0]) return; repeat=0; if ( key!=EM_KEY_NONE && Screen.InputState.Get(key) && RepeatKey==key ) { repeat=KeyRepeat+1; } if (ModalDescendants>0) return; RepeatKey=key; KeyRepeat=repeat; inputEvent.Setup(key,tmp,repeat,variant); InputStateClock=Screen.InputStateClock; InputToView(inputEvent,Screen.InputState); return; case KeyRelease: memset(keymap,0,sizeof(keymap)); XMutex.Lock(); XQueryKeymap(Disp,keymap); XMutex.Unlock(); i=event.xkey.keycode/8; mask=1<<(event.xkey.keycode&7); if (i<32 && (keymap[i]&mask)==0) { RepeatKey=EM_KEY_NONE; if ((Screen.Keymap[i]&mask)!=0) { Screen.Keymap[i]&=~mask; Screen.UpdateInputStateFromKeymap(); } } return; case Expose: x=event.xexpose.x; y=event.xexpose.y; w=event.xexpose.width; h=event.xexpose.height; InvalidatePainting(PaneX+x,PaneY+y,w,h); return; case FocusIn: if ( event.xfocus.mode==NotifyNormal || event.xfocus.mode==NotifyWhileGrabbed ) { if (InputContext) { XMutex.Lock(); XSetICFocus(InputContext); XMutex.Unlock(); } Screen.UpdateKeymapAndInputState(); RepeatKey=EM_KEY_NONE; if (!Focused) { Focused=true; SetViewFocused(true); } if (ModalDescendants>0) FocusModalDescendant(); } return; case FocusOut: if ( event.xfocus.mode==NotifyNormal || event.xfocus.mode==NotifyWhileGrabbed ) { if (InputContext) { XMutex.Lock(); XUnsetICFocus(InputContext); XMutex.Unlock(); } if (Focused) { Focused=false; SetViewFocused(false); } LastButtonPress=EM_KEY_NONE; RepeatKey=EM_KEY_NONE; } return; case ConfigureNotify: // The meaning of the coordinates from event.xconfigure depends on // the window manager. Therefore: GetAbsWinGeometry(Disp,Win,&x,&y,&w,&h); if (PaneX!=x || PaneY!=y || PaneW!=w || PaneH!=h) { PaneX=x; PaneY=y; PaneW=w; PaneH=h; ClipX1=PaneX; ClipY1=PaneY; ClipX2=PaneX+PaneW; ClipY2=PaneY+PaneH; InvalidRects.Set(PaneX,PaneY,PaneX+PaneW,PaneY+PaneH); WakeUp(); if (!PosPending && !SizePending) { SetViewGeometry( PaneX,PaneY, PaneW,PaneH, Screen.PixelTallness ); } else if (!PosPending) { SetViewGeometry( PaneX,PaneY, GetViewWidth(),GetViewHeight(), Screen.PixelTallness ); } else if (!SizePending) { SetViewGeometry( GetViewX(),GetViewY(), PaneW,PaneH, Screen.PixelTallness ); } Screen.InputStateClock++; } return; case MapNotify: if (event.xmap.window==Win && !Mapped) { Mapped=true; WakeUp(); } return; case UnmapNotify: if (event.xmap.window==Win && Mapped) { Mapped=false; } return; case ClientMessage: if (event.xclient.data.l[0]==(long)Screen.WM_DELETE_WINDOW) { if (ModalDescendants<=0) SignalWindowClosing(); else FocusModalDescendant(true); } return; } }
void WakeUpEventSet() { eventset.insert(this); update = true; WakeUp(); }
void wxEventLoopBase::WakeUpIdle() { WakeUp(); }