void TabSwitcherObject::handleEvent(UserEvent event) { if ((event.type == UserEvent::MouseDown) && (event.button == Qt::LeftButton)) { if (embryoRect().contains(event.mousePosition)) { emit tabController()->tabToBeAdded(); } else { TabDrawMap map = tabDrawMap(); int index = hitCloseButton(event.mousePosition, map); if (index >= 0) { emit tabController()->tabToBeRemoved(index); return; } QPointF offset; index = hitTab(event.mousePosition, map, offset); if (index >= 0) { if (data().currentIndex != index) { emit tabController()->tabToBeActivated(index); } m_clickPoint = event.mousePosition; m_clickOffset = offset; m_clickTabUid = data().items[index].uid; m_isDragging = false; return; } } } if ((event.type == UserEvent::MouseMove) && (!m_clickTabUid.isNull())) { if (!m_isDragging) { m_isDragging = ((event.mousePosition - m_clickPoint).manhattanLength() < QApplication::startDragDistance()); if (m_isDragging) { emit tabController()->tabToBeginDragging(m_clickTabUid); } } if (m_isDragging) { emit tabController()->tabToContinueDragging(m_clickTabUid, supervisor()->positionFromLocalToGlobal(event.mousePosition) - m_clickOffset); } } if (event.type == UserEvent::MouseUp) { if (m_isDragging) { emit tabController()->tabToBeDropped(m_clickTabUid, supervisor()->positionFromLocalToGlobal(event.mousePosition) - m_clickOffset); } m_clickTabUid = QUuid(); m_isDragging = false; } }
int elves(int nargs, char **args) { unsigned num_elves; // if an argument is passed, use that as the number of elves num_elves = 10; if (nargs == 2) { num_elves = atoi(args[1]); } // Suppress unused warnings. Remove these when finished. (void) work; (void) supervisor; (void) elf; (void) num_elves; // TODO print_lock = sem_create("print", 1); elf_lock = sem_create("elf", num_elves); complete_lock = sem_create("complete_lk", 1); elf_complete = -1; kprintf("Starting up Keebler Factory!\n"); supervisor(NULL, num_elves); return 0; }
int TabSwitcherObject::dropIndex(const QPointF &globalPos) const { int result = -1; QPointF pos = supervisor()->positionFromGlobalToLocal(globalPos); if (rect().contains(pos)) { result = qBound(0, int((pos.x() - rect().left()) / currentTabWidth()), m_data.items.count()); } return result; }
int c_shell(Song song) { int score = 100; if (override_switch()) { score = supervisor(song); } else { score = manual_override(song); } return score; }
void KHeap::expand( uint32_t new_size ) { // Sanity check. ASSERT(new_size>end_address()-start_address()); // Get the nearest following page boundary. if( (new_size&0xFFFFF000)!=0 ) { new_size &= 0xFFFFF000; new_size += 0x1000; } // Make sure we are not overreaching ourselves. ASSERT( start_address()+new_size<=max_address()); // This should always be on a page boundary. uint32_t old_size=end_address()-start_address(); uint32_t i=old_size; while( i<new_size ) { paging.alloc_frame( paging.get_page(start_address()+i, true, paging.kernel_directory), supervisor(), !readonly() ); i += 0x1000 /* page size */; } end_address( start_address()+new_size ); }
int main(int argc, char* argv[]) { Network yarp; Glib::thread_init(); Gtk::Main kit(argc, argv); Glib::Dispatcher dispatcher; Glib::Mutex lockMutex; queue<Vision *> visionM_PIpe; queue<Vector> potentialVectorM_PIpe; PlannerSupervisor supervisor(dispatcher, lockMutex, visionM_PIpe, potentialVectorM_PIpe); if (!supervisor.start()) { throw std::runtime_error("Couldn't start supervisor thread!"); } Gui myGui(dispatcher, lockMutex, visionM_PIpe, potentialVectorM_PIpe); Gtk::Main::run(myGui); supervisor.stop(); }
void TabSwitcherObject::moveCurrentTab(const QPointF &globalPos) { m_isMovingCurrentTab = true; m_movingCurrentTabPos = supervisor()->positionFromGlobalToLocal(globalPos); redraw(); }
void TelldusMain::start(void) { TelldusCore::EventRef clientEvent = d->eventHandler.addEvent(); TelldusCore::EventRef dataEvent = d->eventHandler.addEvent(); TelldusCore::EventRef executeActionEvent = d->eventHandler.addEvent(); TelldusCore::EventRef janitor = d->eventHandler.addEvent(); // Used for regular cleanups Timer supervisor(janitor); // Tells the janitor to go back to work supervisor.setInterval(60); // Once every minute supervisor.start(); EventUpdateManager eventUpdateManager; TelldusCore::EventRef deviceUpdateEvent = eventUpdateManager.retrieveUpdateEvent(); eventUpdateManager.start(); ControllerManager controllerManager(dataEvent, deviceUpdateEvent); DeviceManager deviceManager(&controllerManager, deviceUpdateEvent); deviceManager.setExecuteActionEvent(executeActionEvent); ConnectionListener clientListener(L"TelldusClient", clientEvent); std::list<ClientCommunicationHandler *> clientCommunicationHandlerList; TelldusCore::EventRef handlerEvent = d->eventHandler.addEvent(); #ifdef _MACOSX // This is only needed on OS X ControllerListener controllerListener(d->controllerChangeEvent); #endif while(!d->stopEvent->isSignaled()) { if (!d->eventHandler.waitForAny()) { continue; } if (clientEvent->isSignaled()) { // New client connection TelldusCore::EventDataRef eventDataRef = clientEvent->takeSignal(); ConnectionListenerEventData *data = dynamic_cast<ConnectionListenerEventData*>(eventDataRef.get()); if (data) { ClientCommunicationHandler *clientCommunication = new ClientCommunicationHandler(data->socket, handlerEvent, &deviceManager, deviceUpdateEvent, &controllerManager); clientCommunication->start(); clientCommunicationHandlerList.push_back(clientCommunication); } } if (d->controllerChangeEvent->isSignaled()) { TelldusCore::EventDataRef eventDataRef = d->controllerChangeEvent->takeSignal(); ControllerChangeEventData *data = dynamic_cast<ControllerChangeEventData*>(eventDataRef.get()); if (data) { controllerManager.deviceInsertedOrRemoved(data->vid, data->pid, "", data->inserted); } } if (dataEvent->isSignaled()) { TelldusCore::EventDataRef eventData = dataEvent->takeSignal(); ControllerEventData *data = dynamic_cast<ControllerEventData*>(eventData.get()); if (data) { deviceManager.handleControllerMessage(*data); } } if (handlerEvent->isSignaled()) { handlerEvent->popSignal(); for ( std::list<ClientCommunicationHandler *>::iterator it = clientCommunicationHandlerList.begin(); it != clientCommunicationHandlerList.end(); ) { if ((*it)->isDone()) { delete *it; it = clientCommunicationHandlerList.erase(it); } else { ++it; } } } if (executeActionEvent->isSignaled()) { deviceManager.executeActionEvent(); } if (janitor->isSignaled()) { // Clear all of them if there is more than one while(janitor->isSignaled()) { janitor->popSignal(); } #ifndef _MACOSX controllerManager.queryControllerStatus(); #endif } } supervisor.stop(); }