Channel* Pipe::getChannel( const ChannelPath& path ) { const Windows& windows = getWindows(); EQASSERT( windows.size() > path.windowIndex ); if( windows.size() <= path.windowIndex ) return 0; return windows[ path.windowIndex ]->getChannel( path ); }
bool Pipe::_cmdDestroyWindow( co::ICommand& cmd ) { co::ObjectICommand command( cmd ); LBLOG( LOG_INIT ) << "Destroy window " << command << std::endl; Window* window = _findWindow( command.get< UUID >( )); LBASSERT( window ); // re-set shared windows accordingly Window* newSharedWindow = 0; const Windows& windows = getWindows(); for( Windows::const_iterator i = windows.begin(); i != windows.end(); ++i ) { Window* candidate = *i; if( candidate == window ) continue; // ignore if( candidate->getSharedContextWindow() == window ) { if( newSharedWindow ) candidate->setSharedContextWindow( newSharedWindow ); else { newSharedWindow = candidate; newSharedWindow->setSharedContextWindow( candidate ); } } LBASSERT( candidate->getSharedContextWindow() != window ); } const bool stopped = window->isStopped(); window->send( getServer(), fabric::CMD_WINDOW_CONFIG_EXIT_REPLY ) << stopped; Config* config = getConfig(); config->unmapObject( window ); Global::getNodeFactory()->releaseWindow( window ); return true; }
//--------------------------------------------------------------------------- // update //--------------------------------------------------------------------------- void Pipe::update( const uint128_t& frameID, const uint32_t frameNumber ) { if( !isRunning( )) return; EQASSERT( isActive( )) PipeFrameStartClockPacket startClockPacket; send( startClockPacket ); PipeFrameStartPacket startPacket; startPacket.frameID = frameID; startPacket.frameNumber = frameNumber; startPacket.version = getVersion(); send( startPacket ); EQLOG( LOG_TASKS ) << "TASK pipe start frame " << &startPacket << std::endl; const Windows& windows = getWindows(); for( Windows::const_iterator i = windows.begin(); i != windows.end(); ++i ) (*i)->updateDraw( frameID, frameNumber ); for( Windows::const_iterator i = windows.begin(); i != windows.end(); ++i ) (*i)->updatePost( frameID, frameNumber ); if( !_lastDrawWindow ) // no FrameDrawFinish sent { PipeFrameDrawFinishPacket drawFinishPacket; drawFinishPacket.frameNumber = frameNumber; drawFinishPacket.frameID = frameID; send( drawFinishPacket ); EQLOG( LOG_TASKS ) << "TASK pipe draw finish " << getName() << " " << &drawFinishPacket << std::endl; } _lastDrawWindow = 0; PipeFrameFinishPacket finishPacket; finishPacket.frameID = frameID; finishPacket.frameNumber = frameNumber; send( finishPacket ); EQLOG( LOG_TASKS ) << "TASK pipe finish frame " << &finishPacket << std::endl; }
void Container::init() { if (m_bInit) return; m_bInit = true; showBar(); string windows = getWindows(); while (!windows.empty()){ unsigned long id = strtoul(getToken(windows, ',').c_str(), NULL, 10); Contact *contact = getContacts()->contact(id); if (contact == NULL) continue; addUserWnd(new UserWnd(id, getWndConfig(id), false)); } if (m_tabBar->count() == 0) QTimer::singleShot(0, this, SLOT(close())); setWindows(NULL); clearWndConfig(); m_tabBar->raiseTab(getActiveWindow()); show(); }
void Application::newConnection() { QLocalSocket *socket = m_localServer->nextPendingConnection(); if (!socket) { return; } socket->waitForReadyRead(1000); MainWindow *window = (getWindows().isEmpty() ? NULL : getWindow()); QString data; QTextStream stream(socket); stream >> data; const QStringList encodedArguments = QString(QByteArray::fromBase64(data.toUtf8())).split(QLatin1Char(' ')); QStringList decodedArguments; for (int i = 0; i < encodedArguments.count(); ++i) { decodedArguments.append(QString(QByteArray::fromBase64(encodedArguments.at(i).toUtf8()))); } m_commandLineParser.parse(decodedArguments); const QString session = m_commandLineParser.value(QLatin1String("session")); const bool isPrivate = m_commandLineParser.isSet(QLatin1String("privatesession")); if (session.isEmpty()) { if (!window || !SettingsManager::getValue(QLatin1String("Browser/OpenLinksInNewTab")).toBool() || (isPrivate && !window->getWindowsManager()->isPrivate())) { window = createWindow(isPrivate); } } else { const SessionInformation sessionData = SessionsManager::getSession(session); if (sessionData.isClean || QMessageBox::warning(NULL, tr("Warning"), tr("This session was not saved correctly.\nAre you sure that you want to restore this session anyway?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { for (int i = 0; i < sessionData.windows.count(); ++i) { createWindow(isPrivate, false, sessionData.windows.at(i)); } } } if (window) { if (m_commandLineParser.positionalArguments().isEmpty()) { window->triggerAction(ActionsManager::NewTabAction); } else { const QStringList urls = m_commandLineParser.positionalArguments(); for (int i = 0; i < urls.count(); ++i) { window->openUrl(urls.at(i)); } } } delete socket; if (window) { window->raise(); window->activateWindow(); if (m_isHidden) { setHidden(false); } else { window->storeWindowState(); window->restoreWindowState(); } } }
bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { bool previousHoverState = m_mouseHover; if(ewol::key::statusLeave == _event.getStatus()) { m_mouseHover = false; m_buttonPressed = false; } else { vec2 relativePos = relativePosition(_event.getPos()); // prevent error from ouside the button if( relativePos.x() < m_selectableAreaPos.x() || relativePos.y() < m_selectableAreaPos.y() || relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() || relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { m_mouseHover = false; m_buttonPressed = false; } else { m_mouseHover = true; } } bool previousPressed = m_buttonPressed; //EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover); if (true == m_mouseHover) { if (1 == _event.getId()) { if(ewol::key::statusDown == _event.getStatus()) { m_buttonPressed = true; markToRedraw(); } if(ewol::key::statusUp == _event.getStatus()) { m_buttonPressed = false; markToRedraw(); } if(ewol::key::statusSingle == _event.getStatus()) { m_buttonPressed = false; m_mouseHover = false; // create a context menu : m_widgetContextMenu = ewol::widget::ContextMenu::create(); if (nullptr == m_widgetContextMenu) { EWOL_ERROR("Allocation Error"); return true; } vec2 tmpPos = m_origin + m_selectableAreaPos + m_selectableAreaSize; tmpPos.setX( tmpPos.x() - m_minSize.x()/2.0); m_widgetContextMenu->setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos ); std::shared_ptr<ewol::widget::ColorChooser> myColorChooser = widget::ColorChooser::create(); myColorChooser->setColor(m_textColorFg.get()); // set it in the pop-up-system : m_widgetContextMenu->setSubWidget(myColorChooser); myColorChooser->signalChange.bind(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange); std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows(); if (currentWindows == nullptr) { EWOL_ERROR("Can not get the curent Windows..."); m_widgetContextMenu.reset(); } else { currentWindows->popUpWidgetPush(m_widgetContextMenu); } markToRedraw(); } } } if( m_mouseHover != previousHoverState || m_buttonPressed != previousPressed) { if (true == m_buttonPressed) { changeStatusIn(STATUS_PRESSED); } else { if (true == m_mouseHover) { changeStatusIn(STATUS_HOVER); } else { changeStatusIn(STATUS_UP); } } } return m_mouseHover; }
void Container::init() { if (m_bInit) return; QFrame *frm = new QFrame(this, "container"); setCentralWidget(frm); connect(CorePlugin::m_plugin, SIGNAL(modeChanged()), this, SLOT(modeChanged())); QVBoxLayout *lay = new QVBoxLayout(frm); m_wnds = new QWidgetStack(frm); m_wnds->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); lay->addWidget(m_wnds); m_tabSplitter = new Splitter(frm); m_tabSplitter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); m_tabBar = new UserTabBar(m_tabSplitter); m_tabBar->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding)); m_tabBar->hide(); m_bInit = true; m_status = new ContainerStatus(m_tabSplitter); lay->addWidget(m_tabSplitter); connect(m_tabBar, SIGNAL(selected(int)), this, SLOT(contactSelected(int))); connect(this, SIGNAL(toolBarPositionChanged(QToolBar*)), this, SLOT(toolbarChanged(QToolBar*))); connect(m_status, SIGNAL(sizeChanged(int)), this, SLOT(statusChanged(int))); m_accel = new QAccel(this); connect(m_accel, SIGNAL(activated(int)), this, SLOT(accelActivated(int))); setupAccel(); showBar(); for (list<UserWnd*>::iterator it = m_childs.begin(); it != m_childs.end(); ++it) addUserWnd((*it), false); m_childs.clear(); string windows = getWindows(); while (!windows.empty()){ unsigned long id = strtoul(getToken(windows, ',').c_str(), NULL, 10); Contact *contact = getContacts()->contact(id); if (contact == NULL) continue; Buffer config; const char *cfg = getWndConfig(id); if (cfg && *cfg){ config << "[Title]\n" << cfg; config.setWritePos(0); config.getSection(); } addUserWnd(new UserWnd(id, &config, false, true), true); } if (m_tabBar->count() == 0) QTimer::singleShot(0, this, SLOT(close())); setWindows(NULL); clearWndConfig(); m_tabBar->raiseTab(getActiveWindow()); show(); }
Pipe::~Pipe() { LBASSERT( getWindows().empty( )); delete _impl; }