/** * Second out of two main update functions. * Gets triggered by a timer for automatics recompilations. * Can be called both from GLRender or from any other scope. */ void SoXipGLSLPrograms::GLValidityCheck() { bool dirty = false; GLint prog = 0; ProgramBatch * batch = 0; ShaderProgramManager * manager = ShaderProgramManager::getInstance(); if (!manager) { dirty = true; } else { for (int i = 0; i < mProgramBatchList.getLength(); i++) { batch = reinterpret_cast<ProgramBatch *>(mProgramBatchList[i]); prog = manager->getProgramHandle(batch->tag.getString()); if (!glIsProgram(prog)) dirty = true; } } if (dirty) { mTimedUpdate = true; startNotify(); } }
/** * Second out of two main update functions. * Gets triggered by a timer for automatics recompilations. * Can be called both from GLRender or from any other scope. */ void SoXipGLSLPrograms::AutoUpdateAction() { bool dirty = false; ProgramBatch * batch = 0; for (int i = 0; i < mProgramBatchList.getLength(); i++) { batch = reinterpret_cast<ProgramBatch *>(mProgramBatchList[i]); dirty |= checkTimeStamps(&batch->vertShader, vpFilenames[i]); dirty |= checkTimeStamps(&batch->geomShader, gpFilenames[i]); dirty |= checkTimeStamps(&batch->fragShader, fpFilenames[i]); } if (dirty) { mTimedUpdate = true; startNotify(); } }
void ChatWindow::MessageReceived( BMessage * msg ) { switch ( msg->what ) { case IM::SETTINGS_UPDATED: { if (msg->FindString("people_handler", &fPeopleHandler) != B_OK) { fPeopleHandler = kDefaultPeopleHandler; }; RebuildDisplay(); } break; case IM::USER_STOPPED_TYPING: { BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what",IM::USER_STOPPED_TYPING); im_msg.AddRef("contact",&fEntry); fMan->SendMessage(&im_msg); stopSelfTypingTimer(); } break; case IM::USER_STARTED_TYPING: { BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what", IM::USER_STARTED_TYPING); im_msg.AddRef("contact", &fEntry); fMan->SendMessage(&im_msg); startSelfTypingTimer(); } break; case IM::DESKBAR_ICON_CLICKED: { // deskbar icon clicked, move to current workspace and activate SetWorkspaces( 1 << current_workspace() ); Activate(); } break; case IM::ERROR: case IM::MESSAGE: { entry_ref contact; if ( msg->FindRef("contact",&contact) != B_OK ) return; if ( contact != fEntry ) // message not for us, skip it. return; int32 im_what=IM::ERROR; if ( msg->FindInt32("im_what",&im_what) != B_OK ) im_what = IM::ERROR; // int32 old_sel_start, old_sel_end; char timestr[10]; time_t now = time(NULL); strftime(timestr, sizeof(timestr),"[%H:%M]: ", localtime(&now) ); switch ( im_what ) { case IM::STATUS_CHANGED: { // This means we're rebuilding menus we don't rally need to rebuild.. BuildProtocolMenu(); } break; case IM::MESSAGE_SENT: { fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); BString message; msg->FindString("message", &message); if (message.Compare("/me ", 4) == 0) { fText->Append(_T("* You "), C_ACTION, C_ACTION, F_ACTION); message.Remove(0, 4); fText->Append(message.String(), C_ACTION, C_ACTION, F_ACTION); } else { fText->Append(_T("You say: "), C_OWNNICK, C_OWNNICK, F_TEXT); //fText->Append(msg->FindString("message"), C_TEXT, C_TEXT, F_TEXT); emoticor->AddText(fText,msg->FindString("message"), C_TEXT, F_TEXT,C_TEXT,F_EMOTICON); //by xeD } fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); } break; case IM::ERROR: { BMessage error; msg->FindMessage("message", &error); int32 error_what = -1; error.FindInt32("im_what", &error_what ); if ( error_what != IM::USER_STARTED_TYPING && error_what != IM::USER_STOPPED_TYPING ) { // ignore messages du to typing fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); fText->Append("Error: ", C_TEXT, C_TEXT, F_TEXT); fText->Append(msg->FindString("error"), C_TEXT, C_TEXT, F_TEXT); fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); if (!IsActive()) startNotify(); } } break; case IM::MESSAGE_RECEIVED: { if ( msg->FindString("message") == NULL ) { // no message to display, probably opened by user return; } fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); BString protocol = msg->FindString("protocol"); BString message = msg->FindString("message"); if (protocol.Length() > 0) { fName.ReplaceAll("$protocol$",protocol.String()); } else { fName.ReplaceAll("$protocol$"," "); }; if (message.Compare("/me ", 4) == 0) { fText->Append("* ", C_ACTION, C_ACTION, F_ACTION); fText->Append(fName.String(), C_ACTION, C_ACTION, F_ACTION); fText->Append(" ", C_ACTION, C_ACTION, F_ACTION); message.Remove(0, 4); fText->Append(message.String(), C_ACTION, C_ACTION, F_ACTION); } else { fText->Append(fName.String(), C_OTHERNICK, C_OTHERNICK, F_TEXT); fText->Append(": ", C_OTHERNICK, C_OTHERNICK, F_TEXT); emoticor->AddText(fText,msg->FindString("message"), C_TEXT, F_TEXT,C_TEXT,F_EMOTICON); //by xeD } fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); if (!IsActive()) startNotify(); stopTypingTimer(); } break; case IM::CONTACT_STARTED_TYPING: { startTypingTimer(); } break; case IM::CONTACT_STOPPED_TYPING: { stopTypingTimer(); } break; } fText->ScrollToSelection(); } break; case SEND_MESSAGE: { if (fInput->TextLength() == 0) return; BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what",IM::SEND_MESSAGE); im_msg.AddRef("contact",&fEntry); im_msg.AddString("message", fInput->Text() ); BMenu *menu = fProtocolMenu->Menu(); if (menu) { IconMenuItem *item = dynamic_cast<IconMenuItem*>(menu->FindMarked()); if ( item ) { BString connection = item->Extra(); if (connection.Length() > 0) { IM::Connection conn(connection.String()); im_msg.AddString("protocol", conn.Protocol()); im_msg.AddString("id", conn.ID()); } } }; if ( fMan->SendMessage(&im_msg) == B_OK ) { fInput->SetText(""); } else { LOG("im_emoclient", liHigh, "Error sending message to im_server"); fText->Append(_T("Error: im_server not running, can't send message\n"), C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); }; } break; case SHOW_INFO: { BMessage open_msg(B_REFS_RECEIVED); open_msg.AddRef("refs", &fEntry); be_roster->Launch(fPeopleHandler.String(), &open_msg); } break; case VIEW_LOG: { BMessage open(B_REFS_RECEIVED); open.AddRef("refs", &fEntry); be_roster->Launch("application/x-vnd.BeClan.im_binlog_viewer", &open); } break; case VIEW_WEBPAGE: { entry_ref htmlRef; be_roster->FindApp("application/x-vnd.Be.URL.http", &htmlRef); BPath htmlPath(&htmlRef); BMessage argv(B_ARGV_RECEIVED); argv.AddString("argv", htmlPath.Path()); int32 length = -1; char *url = ReadAttribute(BNode(&fEntry), "META:url", &length); if ((url != NULL) && (length > 1)) { url = (char *)realloc(url, (length + 1) * sizeof(char)); url[length] = '\0'; argv.AddString("argv", url); argv.AddInt32("argc", 2); be_roster->Launch(&htmlRef, &argv); } else { LOG("im_emoclient", liMedium, "Contact had no homepage"); }; if (url) free(url); } break; case VIEW_EMOTICONS: { //find emoticon button BView* button = FindView("Emoticons"); BRect buttonBounds = button->Bounds(); //move emoticon window to just below the button BPoint emotLeftBottom = button->ConvertToScreen(buttonBounds.LeftBottom()); popup->SetTargetForItems(this); popup->Go(emotLeftBottom,true,true); } break; case ADD_EMOTICON: { int32 index=msg->FindInt32("index"); BString txt; emoticor->config->menu.FindString("face",index,&txt); txt << " "; fInput->Insert(txt.String()); } break; case EMAIL: { BMessage open_msg(B_REFS_RECEIVED); open_msg.AddRef("refs", &fEntry); // "application/x-vnd.Be-MAIL" be_roster->Launch("text/x-email", &open_msg ); } break; case BLOCK: { IM::Contact contact(fEntry); char status[256]; if ( contact.GetStatus( status, sizeof(status) ) != B_OK ) status[0] = 0; if ( strcmp(status, BLOCKED_TEXT) == 0 ) { // already blocked, unblocked contact.SetStatus(OFFLINE_TEXT); BMessage update_msg(IM::UPDATE_CONTACT_STATUS); update_msg.AddRef("contact", &fEntry); fMan->SendMessage( &update_msg ); } else { if ( contact.SetStatus(BLOCKED_TEXT) != B_OK ) { LOG("im_emoclient", liHigh, "Block: Error setting contact status"); } } } break; case AUTH: { BMessage auth_msg(IM::MESSAGE); auth_msg.AddInt32("im_what", IM::REQUEST_AUTH); auth_msg.AddRef("contact", &fEntry); fMan->SendMessage( &auth_msg ); } break; case B_NODE_MONITOR: { int32 opcode=0; if ( msg->FindInt32("opcode",&opcode) != B_OK ) return; switch ( opcode ) { case B_ENTRY_REMOVED: { // oops. should we close down this window now? // Nah, we'll just disable everything. fInput->MakeEditable(false); fInput->SetViewColor( 198,198,198 ); fInput->Invalidate(); BString title( Title() ); title += " - DELETED!"; SetTitle( title.String() ); } break; case B_ENTRY_MOVED: { entry_ref ref; msg->FindInt32("device", &ref.device); msg->FindInt64("to directory", &ref.directory); ref.set_name( msg->FindString("name") ); fEntry = ref; BEntry entry(&fEntry); if ( !entry.Exists() ) { LOG("im_emoclient", liHigh, "Entry moved: New entry invalid"); } } break; case B_STAT_CHANGED: case B_ATTR_CHANGED: reloadContact(); BuildProtocolMenu(); break; } } break; case kResizeMessage: { BView *view = NULL; msg->FindPointer("view", reinterpret_cast<void**>(&view)); if (dynamic_cast<BScrollView *>(view)) { BPoint point; msg->FindPoint("loc", &point); fResize->MoveTo(fResize->Frame().left, point.y); fTextScroll->ResizeTo(fTextScroll->Frame().Width(), point.y - 1 - fDock->Frame().Height() - 1); fInputScroll->MoveTo(fInputScroll->Frame().left, point.y + 3); fInputScroll->ResizeTo( fInputScroll->Bounds().Width(), fStatusBar->Frame().top - fInputScroll->Frame().top ); fInput->SetTextRect(fInput->Bounds()); fInput->ScrollToSelection(); if ( fSendButton ) { fSendButton->MoveTo(fSendButton->Frame().left, point.y + 3); fSendButton->ResizeTo( fSendButton->Bounds().Width(), fStatusBar->Frame().top - fSendButton->Frame().top ); } }; } break; case B_MOUSE_WHEEL_CHANGED: { fText->MessageReceived(msg); } break; case B_COPY: { int32 start = 0; int32 end = 0; fInput->GetSelection(&start, &end); //printf("%ld - > %ld\n", start, end); } break; case B_SIMPLE_DATA: { entry_ref ref; BNode node; // attr_info info; for (int i = 0; msg->FindRef("refs", i, &ref) == B_OK; i++) { node = BNode(&ref); char *type = ReadAttribute(node, "BEOS:TYPE"); if (strcmp(type, "application/x-person") == 0) { char *name = ReadAttribute(node, "META:name"); char *nickname = ReadAttribute(node, "META:nickname"); char connection[100]; IM::Contact con(ref); con.ConnectionAt(0, connection); if (fInput->TextLength() > 0) fInput->Insert("\n"); fInput->Insert(name); fInput->Insert(" ("); fInput->Insert(nickname); fInput->Insert("): "); fInput->Insert(connection); free(name); free(nickname); }; free(type); }; fInput->ScrollToOffset(fInput->TextLength()); } break; case CLEAR_TYPING: stopTypingTimer(); break; case PROTOCOL_SELECTED: { // a protocol has been selected. Since BMenuField doesn't resize until later, // we have to wait 1000us before actually responding to the change, see below if ( fProtocolHack ) delete fProtocolHack; BMessage protoHack(PROTOCOL_SELECTED2); fProtocolHack = new BMessageRunner( BMessenger(this), &protoHack, 1000, 1 ); } break; case PROTOCOL_SELECTED2: // do what should be done on protocol change fStatusBar->PositionViews(); fInfoView->ResizeTo( fStatusBar->Bounds().Width() - fInfoView->Frame().left, fInfoView->Bounds().Height() ); break; default: BWindow::MessageReceived(msg); } }