TopWindow& TopWindow::TopMost(bool b, bool) { GuiLock __; topmost = b; SyncState(); return *this; }
TopWindow& TopWindow::FullScreen(bool b) { GuiLock __; fullscreen = b; SyncState(); return *this; }
void MenuBar::ChildGotFocus() { if(submenu && !submenuitem->HasFocusDeep() && !ExistsTimeCallback()) { if(submenu->IsOpen()) submenu->DelayedClose(); } KillDelayedClose(); SyncState(); }
bool CTrafficLights::SetState(eTrafficLightState state) { if(state < TRAFFIC_LIGHT_STATE_MAX) { m_eStateSet = state; m_ulTimeSet = SharedUtility::GetTime(); #ifdef _SERVER SyncState(); #endif return true; } return false; }
//------------------------------------------------------------------------- // 功能: 设定物件状态 //------------------------------------------------------------------------- void KObj::SetState(int nState, int nPlaySoundFlag/* = 0*/) { if (nState < 0) return; m_nState = nState; switch (m_nKind) { case Obj_Kind_Box: if (nState == OBJ_BOX_STATE_CLOSE) BoxClose(); else if (nState == OBJ_BOX_STATE_OPEN) BoxOpen(); break; case Obj_Kind_Door: if (nState == OBJ_DOOR_STATE_CLOSE) DoorClose(); else if (nState == OBJ_DOOR_STATE_OPEN) DoorOpen(); break; case Obj_Kind_Prop: if (nState == OBJ_PROP_STATE_HIDE) { m_nBornTime = m_nLifeTime; } break; } #ifndef _SERVER if (nPlaySoundFlag) PlaySound(); #endif #ifdef _SERVER SyncState(); #endif }
void TopWindow::Overlap(bool effect) { GuiLock __; state = OVERLAPPED; SyncState(); }
void TopWindow::Maximize(bool effect) { GuiLock __; state = MAXIMIZED; SyncState(); }
void TopWindow::Minimize(bool) { GuiLock __; state = MINIMIZED; SyncState(); }
void TopWindow::Open(Ctrl *owner) { LLOG("TopWindow::Open"); GuiLock __; if(dokeys && (!GUI_AKD_Conservative() || GetAccessKeysDeep() <= 1)) DistributeAccessKeys(); USRLOG(" OPEN " + Desc(this)); LLOG("OPEN " << Name() << " owner: " << UPP::Name(owner)); IgnoreMouseUp(); bool weplace = owner && center == 1 || center == 2 || !GetRect().IsEmpty(); if(fullscreen) SetRect(0, 0, Xwidth, Xheight); else CenterRect(owner); LLOG("Open NextRequest " << NextRequest(Xdisplay)); Create(owner, false, false); XSetWMProperties (Xdisplay, GetWindow(), NULL, NULL, NULL, 0, NULL, NULL, NULL); xminsize.cx = xmaxsize.cx = Null; title2.Clear(); if(!weplace) { LLOG("SyncCaption"); SyncCaption(); } LLOG("SyncSizeHints"); size_hints->flags = 0; SyncSizeHints(); Rect r = GetRect(); size_hints->x = r.left; size_hints->y = r.top; size_hints->width = r.Width(); size_hints->height = r.Height(); size_hints->win_gravity = StaticGravity; size_hints->flags |= PPosition|PSize|PWinGravity; if(owner) { ASSERT(owner->IsOpen()); LLOG("XSetTransientForHint"); XSetTransientForHint(Xdisplay, GetWindow(), owner->GetWindow()); } LLOG("XSetWMNormalHints"); XSetWMNormalHints(Xdisplay, GetWindow(), size_hints); Atom protocols[3]; protocols[0] = XAtom("WM_DELETE_WINDOW"); protocols[1] = XAtom("WM_TAKE_FOCUS"); protocols[2] = XAtom("_NET_WM_PING"); LLOG("XSetWMProtocols"); XSetWMProtocols(Xdisplay, GetWindow(), protocols, 3); String x = GetExeTitle().ToString(); const char *progname = ~x; class_hint->res_name = (char *)progname; class_hint->res_class = (char *)progname; XSetClassHint(Xdisplay, GetWindow(), class_hint); LLOG("WndShow(" << visible << ")"); WndShow(visible); if(visible) { XEvent e; LLOG("XWindowEvent"); XWindowEvent(Xdisplay, top->window, VisibilityChangeMask, &e); ignoretakefocus = true; SetTimeCallback(500, THISBACK(EndIgnoreTakeFocus)); LLOG("SetWndFocus"); SetWndFocus(); for(int i = 0; i < 50; i++) { // X11 tries to move our window, so ignore the first set of ConfigureNotify // and move the window into position after FocusIn - but not if we want WM to // place the window if(weplace) while(XCheckTypedWindowEvent(Xdisplay, top->window, ConfigureNotify, &e)) { if(e.xconfigure.window != top->window) ProcessEvent(&e); } if(XCheckTypedWindowEvent(Xdisplay, top->window, FocusIn, &e)) { ProcessEvent(&e); if(e.xfocus.window == top->window) break; } Sleep(10); } } if(weplace) { WndSetPos(GetRect()); LLOG("SyncCaption"); SyncCaption(); } LLOG(">Open NextRequest " << NextRequest(Xdisplay)); LLOG(">OPENED " << Name()); PlaceFocus(); StateH(OPEN); Vector<int> fe = GetPropertyInts(top->window, XAtom("_NET_FRAME_EXTENTS")); if(fe.GetCount() >= 4 && fe[0] >= 0 && fe[0] <= 16 && fe[1] >= 0 && fe[1] <= 16 && //fluxbox returns wrong numbers - quick&dirty workaround fe[2] >= 0 && fe[2] <= 64 && fe[3] >= 0 && fe[3] <= 48) { GuiLock __; windowFrameMargin.left = max(windowFrameMargin.left, fe[0]); windowFrameMargin.right = max(windowFrameMargin.right, fe[1]); windowFrameMargin.top = max(windowFrameMargin.top, fe[2]); windowFrameMargin.bottom = max(windowFrameMargin.bottom, fe[3]); } if(IsOpen() && top) top->owner = owner; long curr_pid = getpid(); static Window wm_client_leader; ONCELOCK { wm_client_leader = XCreateSimpleWindow(Xdisplay, Xroot, 0, 0, 1, 1, 0, 0, 0); XChangeProperty(Xdisplay, wm_client_leader, XAtom("WM_CLIENT_LEADER"), XA_WINDOW, 32, PropModeReplace, (byte *)&wm_client_leader, 1); XChangeProperty(Xdisplay, wm_client_leader, XAtom("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, (byte *) &curr_pid, 1); } Window win = GetWindow(); XChangeProperty(Xdisplay, win, XAtom("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, (byte *) &curr_pid, 1); XChangeProperty(Xdisplay, win, XAtom("WM_CLIENT_LEADER"), XA_WINDOW, 32, PropModeReplace, (byte *)&wm_client_leader, 1); int version = 5; XChangeProperty(Xdisplay, win, XAtom("XdndAware"), XA_ATOM, 32, 0, (byte *)&version, 1); SyncState(); FixIcons(); }
bool MenuBar::Key(dword key, int count) { LLOG("KEY " << GetKeyDesc(key)); bool horz = IsChild(); if((horz ? key == K_RIGHT : key == K_DOWN)) { Ctrl *ctrl = GetFocusChildDeep(); LLOG("MenuBar::Key(" << key << ") -> IterateFocusForward for " << UPP::Name(ctrl) << ", pane " << UPP::Name(&pane)); if(HasMouseDeep()) GetMouseCtrl()->Refresh(); if(ctrl && IterateFocusForward(ctrl, &pane, false, false, true)) return true; Ctrl *f = pane.GetFirstChild(); if(!f) return true; if(f->IsEnabled()) { f->SetFocus(); return true; } if(IterateFocusForward(pane.GetFirstChild(), &pane, false, false, true)) return true; } else if((horz ? key == K_LEFT : key == K_UP)) { Ctrl *ctrl = GetFocusChildDeep(); LLOG("MenuBar::Key(" << key << ") -> IterateFocusBackward for " << UPP::Name(ctrl) << ", pane " << UPP::Name(&pane)); if(HasMouseDeep()) GetMouseCtrl()->Refresh(); if(ctrl && IterateFocusBackward(ctrl, &pane, false, true)) return true; Ctrl *f = pane.GetLastChild(); if(!f) return true; if(f->IsEnabled()) { f->SetFocus(); return true; } if(IterateFocusBackward(pane.GetLastChild(), &pane, false, true)) return true; } else if(parentmenu && !parentmenu->IsChild() && key == K_LEFT || key == K_ESCAPE) { if(HasMouseDeep()) GetMouseCtrl()->Refresh(); if(parentmenu && parentmenu->submenu) parentmenu->submenuitem->SetFocus(); else if(IsChild() && HasFocusDeep()) { if(restorefocus) restorefocus->SetFocus(); doeffect = true; return true; } if(IsPopUp()) { SubmenuClose(); return true; } doeffect = true; } if(parentmenu && parentmenu->IsChild() && parentmenu->GetActiveSubmenu() && parentmenu->pane.GetFirstChild() && parentmenu->submenuitem) { Ctrl *smi = parentmenu->submenuitem; Ctrl *q = smi; q->Refresh(); if(key == K_RIGHT) for(;;) { q = q->GetNext(); if(!q) q = parentmenu->pane.GetFirstChild(); if(q == smi) break; if(PullMenu(q)) { q->Refresh(); SyncState(); return true; } } if(key == K_LEFT) for(;;) { q = q->GetPrev(); if(!q) q = parentmenu->pane.GetLastChild(); if(q == smi) break; if(PullMenu(q)) { q->Refresh(); SyncState(); return true; } } } LLOG("MenuBar::Key -> HotKey"); return HotKey(key); }
void MenuBar::ChildLostFocus() { SyncState(); }