EmergencyWindowManager::EmergencyWindowManager(int maxWidth, int maxHeight)
	: WindowManagerBase(maxWidth, maxHeight)
	, m_emergencyWindow(0)
    , m_cornerContainer(0)
{
    memset(m_corners, 0, sizeof(m_corners));
	setObjectName("EmergencyWindowManager");

    ::memset(m_corners, 0, 4 * sizeof(QGraphicsPixmapItem*));

	connect(SystemUiController::instance(), SIGNAL(signalPositiveSpaceChanged(const QRect&)),
			this, SLOT(slotPositiveSpaceChanged(const QRect&)));
	connect(SystemService::instance(), SIGNAL(signalIncomingPhoneCall()),
			this, SLOT(slotIncomingPhoneCall()));
	connect(SystemUiController::instance(), SIGNAL(signalEmergencyModeHomeButtonPressed()),
			this, SLOT(slotHomeButtonPressed()));
	connect(SystemUiController::instance(), SIGNAL(signalEmergencyModeWindowFocusChange(bool)),
			this, SLOT(slotEmergencyModeWindowFocusChange(bool)));
	connect(SystemUiController::instance(), SIGNAL(signalUiRotationCompleted()),
			this, SLOT(slotUiRotationCompleted()));

	m_winRect.setRect(0, 0, maxWidth, maxHeight);

	grabGesture(Qt::TapGesture);
	grabGesture(Qt::TapAndHoldGesture);
	grabGesture(Qt::PinchGesture);
	grabGesture((Qt::GestureType) SysMgrGestureFlick);
	grabGesture((Qt::GestureType) SysMgrGestureSingleClick);

	setVisible(false);
}
MaximizeState::MaximizeState(CardWindowManager* wm)
	: CardWindowManagerState(wm)
	, m_exiting(false)
	, m_disableDirectRendering(0)
{
	setObjectName("Maximize");

	// react to incoming phone calls while maximized
	QSignalTransition* trans = new QSignalTransition(SystemService::instance(), 
		SIGNAL(signalIncomingPhoneCall()));
	addTransition(trans);
	connect(trans, SIGNAL(triggered()), SLOT(slotIncomingPhoneCall()));
}