void Ctrl::EventLoop0(Ctrl *ctrl) { GuiLock __; ASSERT(IsMainThread()); ASSERT(LoopLevel == 0 || ctrl); LoopLevel++; LLOG("Entering event loop at level " << LoopLevel << BeginIndent); Ptr<Ctrl> ploop; if(ctrl) { ploop = LoopCtrl; LoopCtrl = ctrl; ctrl->inloop = true; } bool quit = false; ProcessEvents(&quit); while(!EndSession() && !quit && ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount()) { // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep"); SyncCaret(); GuiSleep(1000); if(EndSession()) break; // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents"); ProcessEvents(&quit); // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents"); } if(ctrl) LoopCtrl = ploop; LoopLevel--; LLOG(EndIndent << "Leaving event loop "); }
void Ctrl::EventLoop(Ctrl *ctrl) { GuiLock __; ASSERT_(IsMainThread(), "EventLoop can only run in the main thread"); ASSERT(LoopLevel == 0 || ctrl); LoopLevel++; LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN); Ptr<Ctrl> ploop; if(ctrl) { ploop = LoopCtrl; LoopCtrl = ctrl; ctrl->inloop = true; } bool quit = false; int64 loopno = ++EventLoopNo; ProcessEvents(&quit); while(loopno > EndSessionLoopNo && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount())) { // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep"); SyncCaret(); GuiSleep(1000); // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents"); ProcessEvents(&quit); // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents"); } if(ctrl) LoopCtrl = ploop; LoopLevel--; LLOG(LOG_END << "Leaving event loop "); }
void Ctrl::Sync(const Rect& sr) { GuiLock __; LLOG("Sync " << Name() << " " << sr); DoSync(this, sr, true); SyncCaret(); }
Image Ctrl::DoMouse(int e, Point p, int zd) { // LLOG("Ctrl::DoMouse(" << p << ", " << e << ")"); GuiLock __; eventCtrl = this; Image img = DispatchMouse(e, p, zd); SyncCaret(); return img; }
void Ctrl::SetCaret(int x, int y, int cx, int cy) { GuiLock __; caretx = x; carety = y; caretcx = cx; caretcy = cy; SyncCaret(); }
void Ctrl::SetCaret(int x, int y, int cx, int cy) { GuiLock __; caretx = x; carety = y; caretcx = cx; caretcy = cy; fbCaretTm = GetTickCount(); SyncCaret(); }
bool Ctrl::DoKeyFB(dword key, int cnt) { LLOG("DoKeyFB [" << GetKeyDesc(key) << "] " << key << ", " << cnt); bool b = DispatchKey(key, cnt); SyncCaret(); Ctrl *desktop = GetDesktop(); if(desktop) desktop->PostInput(); return b; }
void Ctrl::DoKillFocus(Ptr<Ctrl> pfocusCtrl, Ptr<Ctrl> nfocusCtrl) { GuiLock __; if(pfocusCtrl && !pfocusCtrl->destroying) { pfocusCtrl->StateH(FOCUS); LLOG("LostFocus: " << Name(pfocusCtrl)); pfocusCtrl->LostFocus(); } if(pfocusCtrl && pfocusCtrl->parent && !pfocusCtrl->parent->destroying) pfocusCtrl->parent->ChildLostFocus(); SyncCaret(); }
void Ctrl::Sync() { GuiLock __; LLOG("Sync " << Name()); if(top && IsOpen()) { LLOG("Sync UpdateWindow " << Name()); SyncScroll(); WndUpdate(); } else if(parent) DoSync(parent, GetRect(), inframe); SyncCaret(); }
void Ctrl::WndScrollView(const Rect& r, int dx, int dy) { GuiLock __; if(caretCtrl && caretCtrl->GetTopCtrl() == this) { WndDestroyCaret(); caretRect.Clear(); } #ifdef PLATFORM_WINCE ::ScrollWindowEx(GetHWND(), dx, dy, r, r, NULL, NULL, 0); #else ::ScrollWindow(GetHWND(), dx, dy, r, r); #endif SyncCaret(); }
bool Ctrl::ProcessEvent(bool *quit) { LLOG("@ ProcessEvent"); ASSERT(IsMainThread()); if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle()) ReleaseCtrlCapture(); if(FBProcessEvent(quit)) { LLOG("FBProcesEvent returned true"); SyncTopWindows(); DefferedFocusSync(); SyncCaret(); return true; } return false; }
void Ctrl::WndSetPos(const Rect& rect) { GuiLock __; HWND hwnd = GetHWND(); if(hwnd) { Rect r = rect; AdjustWindowRectEx(r, ::GetWindowLong(hwnd, GWL_STYLE), FALSE, ::GetWindowLong(hwnd, GWL_EXSTYLE)); SetWindowPos(hwnd, NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOACTIVATE|SWP_NOZORDER); if(HasFocusDeep()) { caretCtrl = NULL; SyncCaret(); } } fullrefresh = false; }
bool Ctrl::ProcessEvent(bool *quit) { ASSERT_(IsMainThread(), "ProcessEvent can only run in the main thread"); if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle()) ReleaseCtrlCapture(); MSG msg; if(GetMsg(msg)) { if(msg.message == WM_QUIT && quit) *quit = true; // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": sProcessMSG " << FormatIntHex(msg.message)); sProcessMSG(msg); // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": //sProcessMSG " << FormatIntHex(msg.message)); DefferedFocusSync(); SyncCaret(); return true; } return false; }
void Ctrl::WndScrollView(const Rect& r, int dx, int dy) { GuiLock __; LLOG("WndScrollView " << UPP::Name(this)); if(caretCtrl && caretCtrl->GetTopCtrl() == this) { #if WINCARET WndDestroyCaret(); #else RefreshCaret(); #endif caretRect.Clear(); } #ifdef PLATFORM_WINCE ::ScrollWindowEx(GetHWND(), dx, dy, r, r, NULL, NULL, 0); #else ::ScrollWindow(GetHWND(), dx, dy, r, r); #endif SyncCaret(); }
bool Ctrl::ProcessEvent0(bool *quit, bool fetch) { ASSERT(IsMainThread()); bool r = false; if(IsWaitingEvent0(fetch)) { while(Events.GetCount() > 1) { // Event compression (coalesce autorepeat, mouse moves/wheel, configure) Event& a = Events[0]; Event& b = Events[1]; if(b.type == a.type && a.windowid == b.windowid && a.state == b.state) { if(a.type == GDK_KEY_PRESS && a.value == b.value) b.count += a.count; else if(a.type == GDK_SCROLL) b.value = (int)b.value + (int)a.value; else if(findarg(a.type, GDK_MOTION_NOTIFY, GDK_CONFIGURE) < 0) break; Events.DropHead(); } else break; FocusSync(); } Event& e = Events.Head(); CurrentTime = e.time; CurrentMousePos = e.mousepos; CurrentState = e.state; CurrentEvent = e; Value val = e.value; Events.DropHead(); Ctrl *w = GetTopCtrlFromId(e.windowid); FocusSync(); CaptureSync(); if(w) w->Proc(); r = true; } if(quit) *quit = IsEndSession(); FocusSync(); SyncCaret(); return r; }
bool Ctrl::ProcessEvent(bool *quit) { if(EndSession()) return false; if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle()) ReleaseCtrlCapture(); MSG msg; if(PeekMsg(msg)) { if(msg.message == WM_QUIT && quit) *quit = true; // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": sProcessMSG " << FormatIntHex(msg.message)); sProcessMSG(msg); // LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": //sProcessMSG " << FormatIntHex(msg.message)); DefferedFocusSync(); SyncCaret(); return true; } return false; }
void Ctrl::DefferedFocusSync() { GuiLock __; while(defferedChildLostFocus.GetCount() || defferedSetFocus) { LLOG("Ctrl::DeferredFocusSync, defferedSetFocus = " << UPP::Name(defferedSetFocus)); Vector< Ptr<Ctrl> > b = pick(defferedChildLostFocus); defferedChildLostFocus.Clear(); for(int i = 0; i < b.GetCount(); i++) if(b[i]) { LLOG("Ctrl::DeferredFocusSync -> ChildLostFocus " << UPP::Name(b[i])); b[i]->ChildLostFocus(); } if(defferedSetFocus) { LLOG("Ctrl::DeferredFocusSync -> SetFocus " << UPP::Name(defferedSetFocus)); defferedSetFocus->SetFocus(); } defferedSetFocus = NULL; SyncCaret(); } }
void Ctrl::FocusSync() { GuiLock __; if(focusCtrlWnd && focusCtrlWnd->IsOpen() && gtk_window_is_active(focusCtrlWnd->gtk())) return; Ptr<Ctrl> focus = NULL; static Ptr<Ctrl> ctrl; for(int i = 0; i < wins.GetCount(); i++) if(gtk_window_is_active((GtkWindow *)wins[i].gtk)) { focus = wins[i].ctrl; break; } if(focus != ctrl) { if(ctrl) ctrl->KillFocusWnd(); ctrl = focus; if(ctrl) ctrl->SetFocusWnd(); SyncCaret(); } }
void Ctrl::DoSetFocus(Ptr<Ctrl> pfocusCtrl, Ptr<Ctrl> nfocusCtrl, bool activate) { GuiLock __; if(activate && focusCtrl == nfocusCtrl && nfocusCtrl) { Ctrl *top = nfocusCtrl->GetTopCtrl(); if((!pfocusCtrl || pfocusCtrl->GetTopCtrl() != top) && !top->destroying) { top->StateH(ACTIVATE); top->Activate(); top->RefreshAccessKeysDo(top->VisibleAccessKeys()); } } if(focusCtrl == nfocusCtrl && nfocusCtrl && !nfocusCtrl->destroying) { nfocusCtrl->GotFocus(); nfocusCtrl->StateH(FOCUS); } if(focusCtrl == nfocusCtrl && nfocusCtrl && nfocusCtrl->parent && !nfocusCtrl->parent->destroying) nfocusCtrl->parent->ChildGotFocus(); SyncCaret(); }
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions, const VectorMap<String, ClipData>& data) { GuiLock __; DnDLoop d; d.actions = (byte)actions; d.reject = actions & DND_EXACTIMAGE ? CtrlCoreImg::DndNone() : MakeDragImage(CtrlCoreImg::DndNone(), sample); if(actions & DND_COPY) d.copy = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndCopy(), sample); if(actions & DND_MOVE) d.move = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndMoveX11(), sample); d.SetMaster(*this); d.data = &data; d.action = DND_NONE; d.fmts = Split(fmts, ';'); dndloop = &d; sDnDSource = this; d.Run(); sDnDSource = NULL; SyncCaret(); LLOG("DoDragAndDrop finished"); return d.action; }