void KeyHandlesSheet::OnCursorStillDown(const Input::Cursor& cursor) { if (cursor.isPressed) { if (!mIsFrameSelecting) { if (cursor.delta != Vec2F()) mIsFrameSelecting = true; } if (mIsFrameSelecting) { mSelectionFrame->enabled = true; Vec2F current(mTimeline->WorldToLocal(cursor.position.x), mTree->GetLineNumber(cursor.position.y)); mSelectionRect.left = Math::Min(mBeginSelectPoint.x, current.x); mSelectionRect.right = Math::Max(mBeginSelectPoint.x, current.x); mSelectionRect.top = Math::Floor(Math::Min(mBeginSelectPoint.y, current.y)); mSelectionRect.bottom = Math::Ceil(Math::Max(mBeginSelectPoint.y, current.y)); DeselectAll(); for (auto handle : mBeginSelectHandles) SelectHandle(handle); for (auto handle : mHandles) { Vec2F handlePos(handle->GetPosition().x, mTree->GetLineNumber(handle->GetScreenPosition().y)); if (handlePos.x > mSelectionRect.left && handlePos.x < mSelectionRect.right && handlePos.y > mSelectionRect.top && handlePos.y < mSelectionRect.bottom + 0.5f) { SelectHandle(handle); } } } } }
int main(int argc,char *argv[]) { int listenfd; int serverPort = 8888; struct sockaddr_in serveraddr; int nread = 0; int nwrite = 0; int err = 0; int ret = 0; socklen_t socklen = sizeof(serveraddr); do{ listenfd = socket(AF_INET,SOCK_STREAM,0); if (listenfd < 0) { err = errno; printf("socket(),error:%s\n",strerror(errno)); break; } int opt = 1; if (setsockopt(listenfd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)) < 0) { err = errno; printf("setsockopt(),error:%s\n",strerror(errno)); break; } bzero(&serveraddr,sizeof(serveraddr)); serveraddr.sin_family = AF_INET; serveraddr.sin_addr.s_addr = INADDR_ANY; serveraddr.sin_port = htons(8888); ret = bind(listenfd,(struct sockaddr*)&serveraddr,socklen); if (ret < 0) { err = errno; printf("bind(),error:%s\n",strerror(errno)); break; } ret = listen(listenfd,1024); if (ret < 0) { err = errno; printf("listen(),error:%s\n",strerror(errno)); break; } err = SetNonblocking(listenfd); if (0 != err) { err = errno; printf("setnonblockint(),error:%s\n",strerror(errno)); break; } printf("server startup,listen on port 8888!\n"); err = SelectHandle(listenfd); if (0 != err) { printf("SelectHandle(),error:%s\n",strerror(errno)); break; } } while(0); if (-1 != listenfd) { close(listenfd); } return err; }