void ewmh_init(void) { char myname[] = "wmii"; long win; ewmhwin = createwindow(&scr.root, Rect(0, 0, 1, 1), 0 /*depth*/, InputOnly, nil, 0); win = ewmhwin->xid; changeprop_long(&scr.root, Net("SUPPORTING_WM_CHECK"), "WINDOW", &win, 1); changeprop_long(ewmhwin, Net("SUPPORTING_WM_CHECK"), "WINDOW", &win, 1); changeprop_string(ewmhwin, Net("WM_NAME"), myname); changeprop_long(&scr.root, Net("DESKTOP_VIEWPORT"), "CARDINAL", (long[2]){0, 0}, 2);
void ewmh_setstrut(Window *w, Rectangle struts[4]) { long strut[Last]; int i; strut[LeftMin] = struts[Left].min.y; strut[Left] = struts[Left].max.x; strut[LeftMax] = struts[Left].max.y; strut[RightMin] = struts[Right].min.y; strut[Right] = -struts[Right].min.x; strut[RightMax] = struts[Right].max.y; strut[TopMin] = struts[Top].min.x; strut[Top] = struts[Top].max.y; strut[TopMax] = struts[Top].max.x; strut[BottomMin] = struts[Bottom].min.x; strut[Bottom] = -struts[Bottom].min.y; strut[BottomMax] = struts[Bottom].max.x; for(i=0; i<Last; i++) if(strut[i] < 0) strut[i] = 0; changeprop_long(w, Net("WM_STRUT_PARTIAL"), "CARDINAL", strut, nelem(strut)); }
/**************************************************************************//** * @author Paul Blasi, Caitlin Taggart * * @par Description: * Main execution point of the app. Initializes the window and prepares the * main objects to be drawn on the screen. Also sets up the callback events. * * @returns Execution outcome. * *****************************************************************************/ int main(int argc, char *argv[]) { //set up the window glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT); glutInitWindowPosition(100, 100); glutCreateWindow("Pong"); glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //specify callbacks glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutKeyboardFunc(Keyboard); glutKeyboardUpFunc(KeyboardUp); glutSpecialFunc(SpecialKeys); glutSpecialUpFunc(SpecialKeysUp); glutTimerFunc(30, Animate, 1); //TODO set up players and ball BALL = Ball(Point(100, 50),5, WHITE); LEFT_PLAYER = Paddle(Point(10, 50), 10, 40, WHITE); RIGHT_PLAYER = Paddle(Point(190, 50), 10, 40, WHITE); NET = Net(Point(100, 50), VERTICAL, WHITE, 98); TOP_WALL = Wall(Point(100, 99), HORIZONTAL, WHITE, 198); BOTTOM_WALL = Wall(Point(100, 1), HORIZONTAL, WHITE, 198); LEFT_WALL = Wall(Point(1, 50), VERTICAL, WHITE, 98); RIGHT_WALL = Wall(Point(199, 50), VERTICAL, WHITE, 98); COLLISION_MAN.RegisterCollision(&BALL, &LEFT_PLAYER, BallCollideWithLeftPaddle); COLLISION_MAN.RegisterCollision(&BALL, &RIGHT_PLAYER, BallCollideWithRightPaddle); COLLISION_MAN.RegisterCollision(&BALL, &TOP_WALL, BallCollideWithWall); COLLISION_MAN.RegisterCollision(&BALL, &BOTTOM_WALL, BallCollideWithWall); COLLISION_MAN.RegisterCollision(&BALL, &LEFT_WALL, Score); COLLISION_MAN.RegisterCollision(&BALL, &RIGHT_WALL, Score); COLLISION_MAN.RegisterCollision(&LEFT_PLAYER, &TOP_WALL, LeftCollideWithWall); COLLISION_MAN.RegisterCollision(&LEFT_PLAYER, &BOTTOM_WALL, LeftCollideWithWall); COLLISION_MAN.RegisterCollision(&LEFT_PLAYER, &LEFT_WALL, LeftCollideWithWall); COLLISION_MAN.RegisterCollision(&LEFT_PLAYER, &NET, LeftCollideWithWall); COLLISION_MAN.RegisterCollision(&RIGHT_PLAYER, &TOP_WALL, RightCollideWithWall); COLLISION_MAN.RegisterCollision(&RIGHT_PLAYER, &BOTTOM_WALL, RightCollideWithWall); COLLISION_MAN.RegisterCollision(&RIGHT_PLAYER, &RIGHT_WALL, RightCollideWithWall); COLLISION_MAN.RegisterCollision(&RIGHT_PLAYER, &NET, RightCollideWithWall); glutMainLoop(); return 0; }
void NetworkPNL::GetValue(int node, bool &valueValid, std::vector<int> &parents, std::vector<double> &values) { MarkCallFunction("GetValue unfin x", true); int len = GetOutcomeCount(node); MarkCallFunction("GetValue unfin x", true, (String() << node << "#" << len).c_str()); TokArr evid(m_pWNet->Net().EvidenceBoard()->Get()); parents.resize(0); values.resize(0); m_pWNet->ClearEvid(); if(evid.size()) { if ( m_pWNet->Net().nNetNode() > 1) { m_pWNet->EditEvidence(evid); evid = m_pWNet->GetJPD(Graph().NodeName(node)); } else { valueValid = false; return; } } else { evid = m_pWNet->GetJPD(Graph().NodeName(node)); } valueValid = true; values.resize(len); Vector<int> aiNode, aiValue; String x; int i; x = String(evid); // Token().Resolve(evid); Net().ExtractTokArr(evid, &aiNode, &aiValue); for(i = evid.size(); --i >= 0;) { if(aiValue[0] >= len || aiValue[0] < 0) { ThrowInternalError("outcome index exceed limit", "GetValue"); valueValid = false; return; } values[aiValue[i]] = evid[i].FltValue(); } }
void CN_VISITOR::checkZoneItemConnection( CN_ZONE* aZone, CN_ITEM* aItem ) { auto zoneItem = static_cast<CN_ZONE*> ( aZone ); if( zoneItem->Net() != aItem->Net() && !aItem->CanChangeNet() ) return; if( zoneItem->ContainsPoint( aItem->GetAnchor( 0 ) ) || ( aItem->Parent()->Type() == PCB_TRACE_T && zoneItem->ContainsPoint( aItem->GetAnchor( 1 ) ) ) ) { zoneItem->Connect( aItem ); aItem->Connect( zoneItem ); } }
//_________________________________________________________________________________ Boolean TWANControler::Connect (strPtr remote) { INetAlert alert; SocketStatus err; TMidiClient * client; TInetAddress * addr = new TInetAddress (fServer->GetInetRef ()); if (!addr) { alert.Report (fDrvName, strConnectFailure, strMemFail, 0L); goto failed; } fFeedback->Lookup (remote); if (!addr->SetAddress (remote)) { // looking for inet address alert.Report (fDrvName, strLookupFailure, remote, 0L); goto failed; } if (FindUDPRemote (addr->GetIP())) { // check for existing connection alert.Report (fDrvName, strAlreadyOpened, remote, 0L); goto failed; } fFeedback->Connecting (addr->HostName()); client = new TMidiClient (Net()->port, this, addr); // creates TCP client if (!client) { alert.Report (fDrvName, strConnectFailure, strMemFail, 0L); goto failed; } err = client->ClientOpen (addr->GetAddress()); // opens TCP client if (err != noErr) { delete client; alert.Report (fDrvName, strConnectFailure, remote, 0L); goto failed; } if (!AddRemote (client)) { // add client in TCP remote list alert.Report (fDrvName, strRemCreateFailure, strMemFail, 0L); goto failed; } fFeedback->CheckLatency (addr->HostName()); client->Start (GetRefNum()); // start sending ID packets CallCheckCompletion (client->GetID(), kCompletionTimeout, false); return true; failed: fFeedback->Failed (0); return false; }
int NetworkPNL::GetEvidence(int node) { MarkCallFunction("GetEvidence", true); Vector<int> aiNode, aiValue; if (m_pWNet->Net().EvidenceBoard()->IsEmpty()) return -1; if (!(m_pWNet->Net().EvidenceBoard()->IsNodeHere(Tok(m_pWNet->Net().Token().Node(node)))) || m_pWNet->Net().EvidenceBoard()->IsHidden(Tok(m_pWNet->Net().Token().Node(node)))) return -1; Net().ExtractTokArr(m_pWNet->Net().EvidenceBoard()->Get(), &aiNode, &aiValue); for(int i = aiNode.size(); --i >= 0;) { if(aiNode[i] == node) { return aiValue[i]; } } ThrowInternalError("Not found evidence", "GetEvidence");// must be here, but ... return -1; }
WDistributions &NetworkPNL::Distributions() const { return Net().Distributions(); }
TokenCover &NetworkPNL::Token() const { return Net().Token(); }
WGraph &NetworkPNL::Graph() const { return Net().Graph(); }
TYPE("DOCK"), TYPE("NORMAL"), TYPE("MENU"), TYPE("SPLASH"), TYPE("TOOLBAR"), /* Actions */ NET("WM_ALLOWED_ACTIONS"), ACTION("FULLSCREEN"), /* Desktops */ NET("DESKTOP_NAMES"), NET("NUMBER_OF_DESKTOPS"), /* Client List */ NET("CLIENT_LIST"), NET("CLIENT_LIST_STACKING"), }; changeprop_long(&scr.root, Net("SUPPORTED"), "ATOM", supported, nelem(supported)); } inline bool ewmh_responsive_p(Client *c) { return c->w.ewmh.ping == 0 || (ulong)(nsec() / 1000000) - c->w.ewmh.ping < PingTime; } void ewmh_checkresponsive(Client *c) { if(!ewmh_responsive_p(c)) if(!c->dead) frame_draw(c->sel); else if(c->dead++ == 1) event("Unresponsive %#C\n", c);