void EmulatedCardWindow::resizeEvent(int w, int h)
{
	//Emulated cards cannot resize to full screen, ever.
	int maxWidth = Settings::LunaSettings()->emulatedCardWidth;
	int maxHeight = Settings::LunaSettings()->emulatedCardHeight;

	if (!m_fullScreenMode) {
		maxHeight = maxHeight - Settings::LunaSettings()->positiveSpaceTopPadding;
	}

	w = (w > maxWidth ? maxWidth : w);
	h = (h > maxHeight ? maxHeight : h);

	if (w>h) {
		//Going to a landscape card
		setNewEmuRect(maxHeight, maxWidth);
		if (m_channel)
			m_channel->sendAsyncMessage(new View_Resize(routingId(), maxHeight, maxWidth, false));
	} else {
		//Going to a portrait card
		setNewEmuRect(maxWidth, maxHeight);
		if (m_channel)
			m_channel->sendAsyncMessage(new View_Resize(routingId(), maxWidth, maxHeight, false));
	}


}
void DashboardWebApp::attach(SysMgrWebBridge* page)
{
	WindowedWebApp::attach(page);

	const StringVariantMap& stageArgs = page->stageArguments();

	StringVariantMap::const_iterator it = stageArgs.find("icon");
	if (it != stageArgs.end()) {

		m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetIcon(routingId(), it.value().toString().toStdString()));
	}

	it = stageArgs.find("clickablewhenlocked");
	if (it == stageArgs.end())
		it = stageArgs.find("clickableWhenLocked");

	if (it != stageArgs.end()) {

		QVariant v = it.value();
		if (v.type() == QVariant::Bool)
			m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetClickableWhenLocked(routingId(), v.toBool()));
		else if (v.type() == QVariant::String)
			m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetClickableWhenLocked(routingId(), stringIsTrue(v.toString().toStdString())));
	}

	// Restricted to systemui
	if (page->appId() == "com.palm.systemui") {

		it = stageArgs.find("persistent");
		if (it != stageArgs.end()) {

			QVariant v = it.value();
			if (v.type() == QVariant::Bool)
				m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetPersistent(routingId(), v.toBool()));	
			else if (v.type() == QVariant::String)
				m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetPersistent(routingId(), stringIsTrue(v.toString().toStdString())));	
		}
	}

	it = stageArgs.find("webosdragmode");
	if (it != stageArgs.end()) {

		QVariant v = it.value();
		if (v.type() == QVariant::String && v.toString() == "manual") {
			WindowProperties prop;
			prop.setDashboardManualDragMode(true);
			setWindowProperties(prop);
		}
	}
}
示例#3
0
void AlertWebApp::setSoundParams(const QString& fileName, const QString& soundClass)
{
	if(!getKey() || !m_channel)
		return;
	
	m_channel->sendAsyncMessage(new ViewHost_Alert_SetSoundParams(routingId(), fileName.toStdString(), soundClass.toStdString()));
}
void EmulatedCardWindow::resizeEventSync(int w, int h)
{
	//Emulated cards cannot resize to full screen, ever.
	int maxWidth = Settings::LunaSettings()->emulatedCardWidth;
	int maxHeight = Settings::LunaSettings()->emulatedCardHeight;

	if (!m_fullScreenMode) {
		maxHeight = maxHeight - Settings::LunaSettings()->positiveSpaceTopPadding;

	}

	w = (w > maxWidth ? maxWidth : w);
	h = (h > maxHeight ? maxHeight : h);

	if (w>h) {
		//Going to a landscape card
		setNewEmuRect(maxHeight, maxWidth);
		if (m_channel) {

			SystemUiController::instance()->aboutToSendSyncMessage();

			int dummy = 0;
			m_channel->sendSyncMessage(new View_SyncResize(routingId(), maxHeight, maxWidth, false, &dummy));
		}
	} else {
		//Going to a portrait card
		setNewEmuRect(maxWidth, maxHeight);
		if (m_channel) {

			SystemUiController::instance()->aboutToSendSyncMessage();

			int dummy = 0;
			m_channel->sendSyncMessage(new View_SyncResize(routingId(), maxWidth, maxHeight, false, &dummy));
		}
	}


}
示例#5
0
void CardHostWindow::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
{
	event->accept();

	Event evt;
	evt.type = Event::MouseHover;
	QRectF br = boundingRect();
	evt.mouseHoverOldX = event->lastPos().x() - br.x();
	evt.mouseHoverOldY = event->lastPos().y() - br.y();
	evt.mouseHoverX = event->pos().x() - br.x();
	evt.mouseHoverY = event->pos().y() - br.y();
	evt.time = Time::curSysTimeMs();
	if (m_channel)
		m_channel->sendAsyncMessage(new View_InputEvent(routingId(),
								SysMgrEventWrapper(&evt)));
}
示例#6
0
void AlertWebApp::attach(SysMgrWebBridge* page)
{
	const StringVariantMap& stageArgs = page->stageArguments();

	StringVariantMap::const_iterator itSound = stageArgs.find("sound");
	StringVariantMap::const_iterator itSoundClass = stageArgs.find("soundclass");

	WindowedWebApp::attach(page);

	m_channel->sendAsyncMessage(new ViewHost_Alert_SetSoundParams(routingId(),
																  (itSound != stageArgs.end()) ?
																  (*itSound).toString().toStdString() : std::string(), 
																  (itSoundClass != stageArgs.end()) ?
																  (*itSoundClass).toString().toStdString() : std::string()));

	startPowerdActivity();
}
示例#7
0
void AlertWebApp::updateContentRect()
{
    QWebFrame* frame = page()->page()->mainFrame();
    QWebElement el = frame->findFirstElement("[x-palm-popup-content]");
    QRect r;
    if (!el.isNull()) {
        r = el.geometry();
    	r.setLeft(MAX(0, r.left()));
	    r.setRight(MIN(r.right(), (int) m_windowWidth));
    	r.setTop(MAX(0, r.top()));
	    r.setBottom(MIN(r.bottom(), (int) m_windowHeight));
    }

	m_channel->sendAsyncMessage(new ViewHost_Alert_SetContentRect(routingId(),
																  r.left(), r.right(), 
																  r.top(), r.bottom()));
}
示例#8
0
bool CardHostWindow::touchEvent(QTouchEvent* event)
{
    if (!m_focused || m_pendingFocus == PendingFocusFalse) {
        return false;
    }

    if (m_paused)
        return true;

    if (m_channel) {

        typedef QList<QTouchEvent::TouchPoint> TouchPoints;
        TouchPoints touchPoints = event->touchPoints();

        QPointF topLeft = boundingRect().topLeft();

        for (TouchPoints::const_iterator it = touchPoints.begin();
             it != touchPoints.end(); ++it) {

//			printf("TouchPoint Id: %d, State: %d, pos: %g, %g\n",
//				   (*it).id(), (*it).state(), (*it).pos().x(), (*it).pos().y());

            qreal adjustmentAngle = m_adjustmentAngle;


            int displayWidth = Settings::LunaSettings()->displayWidth;
            int displayHeight = Settings::LunaSettings()->displayHeight;
            QPointF pt = (*it).pos();
            pt -= topLeft;
            int x = pt.x();
            int y = pt.y();

            //		adjustmentAngle, x, y, displayWidth, displayHeight);
            if (adjustmentAngle == 90) { //0,0 in upper right
                int tmp = y;
                y = x;
                x = tmp;

                y = displayHeight-y;
            }
            else if (adjustmentAngle == -90) { //0,0 in lower left

                int tmp = y;
                y = x;
                x = tmp;

                x = displayWidth-x;
            } else if (adjustmentAngle == 0) { //0,0 in upper left
                //Do nothing
            }
            else if (adjustmentAngle == 180) { //0,0 in lower right / screen dimensions flip
                x = displayWidth-x;
                y = displayHeight-y;
            }


            switch ((*it).state()) {
            case Qt::TouchPointPressed: {

                Event evt;
                evt.type = Event::PenDown;
                evt.id = (*it).id();
                evt.x = x;
                evt.y = y;
                evt.z = 0;
                evt.key = Event::Key_Null;
                evt.button = Event::Left;
                evt.modifiers = Event::modifiersFromQt(event->modifiers());
                evt.time = Time::curTimeMs();
                evt.clickCount = 1;

                m_channel->sendAsyncMessage (new View_InputEvent(routingId(),
                                                                 SysMgrEventWrapper(&evt)));

                break;
            }
            case Qt::TouchPointMoved: {

                Event evt;
                evt.type = Event::PenMove;
                evt.id = (*it).id();
                evt.x = x;
                evt.y = y;
                evt.z = 0;
                evt.key = Event::Key_Null;
                evt.button = Event::Left;
                evt.modifiers = Event::modifiersFromQt(event->modifiers());
                evt.time = Time::curTimeMs();
                evt.clickCount = 0;

                m_channel->sendAsyncMessage (new View_InputEvent(routingId(),
                                                                 SysMgrEventWrapper(&evt)));

                break;
            }
            case Qt::TouchPointReleased: {

                Event evt;
                evt.type = Event::PenUp;
                evt.id = (*it).id();
                evt.x = x;
                evt.y = y;
                evt.z = 0;
                evt.key = Event::Key_Null;
                evt.button = Event::Left;
                evt.modifiers = Event::modifiersFromQt(event->modifiers());
                evt.time = Time::curTimeMs();
                evt.clickCount = 0;

                m_channel->sendAsyncMessage (new View_InputEvent(routingId(),
                                                                 SysMgrEventWrapper(&evt)));

                break;
            }
            default:
                continue;
            }
        }
    }

    return true;
}
示例#9
0
void DashboardWebApp::attach(WebPage* page)
{
	WindowProperties prop;
	WindowedWebApp::attach(page);

	const StringVariantMap& stageArgs = page->stageArguments();

	StringVariantMap::const_iterator it = stageArgs.find("icon");
	if (it != stageArgs.end()) {

		m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetIcon(routingId(), it->second.toString().toStdString()));
	}

	it = stageArgs.find("clickablewhenlocked");
	if (it == stageArgs.end())
		it = stageArgs.find("clickableWhenLocked");

	if (it != stageArgs.end()) {

		QVariant v = it->second;
		if (v.type() == QVariant::Bool)
			m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetClickableWhenLocked(routingId(), v.toBool()));
		else if (v.type() == QVariant::String)
			m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetClickableWhenLocked(routingId(), stringIsTrue(v.toString().toStdString())));
	}

	// Restricted to systemui
	if (page->appId() == "com.palm.systemui") {

		it = stageArgs.find("persistent");
		if (it != stageArgs.end()) {

			QVariant v = it->second;
			if (v.type() == QVariant::Bool)
				m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetPersistent(routingId(), v.toBool()));	
			else if (v.type() == QVariant::String)
				m_channel->sendAsyncMessage(new ViewHost_Dashboard_SetPersistent(routingId(), stringIsTrue(v.toString().toStdString())));	
		}
	}

	it = stageArgs.find("webosdragmode");
	if (it != stageArgs.end()) {

		QVariant v = it->second;
		if (v.type() == QVariant::String && v.toString() == "manual") {
			prop.setDashboardManualDragMode(true);
		}
	}

	it = stageArgs.find("dashheight");
	if (it != stageArgs.end()) {
		g_warning("found dashheight argument");
		QVariant v = it->second;
		if(v.type() == QVariant::Int) {
			g_warning("dashheight is unsigned int");
			if(v.toUInt()) {
				g_warning("read successful, setting variables");
				if(v.toUInt() <= 320) {
					prop.setDashHeight(v.toUInt());
					resizeEvent(WebAppManager::instance()->currentUiWidth(), v.toUInt(), false);
				}
				else {
					prop.setDashHeight(320);
					resizeEvent(WebAppManager::instance()->currentUiWidth(), 320, false);
				}
			}
			else {
				g_warning("dashheight not unsigned int, default height");
				prop.setDashHeight(kDashboardWindowHeight);
			}
		}
	}
	
	g_warning("setting window properties");
	setWindowProperties(prop);
}