Ejemplo n.º 1
0
void RandROutput::handleEvent(XRROutputChangeNotifyEvent *event)
{
	int changed = 0;

	kDebug() << "[OUTPUT] Got event for " << m_name;
	kDebug() << "       crtc: " << event->crtc;
	kDebug() << "       mode: " << event->mode;
	kDebug() << "       rotation: " << event->rotation;
	kDebug() << "       connection: " << event->connection;

	//FIXME: handling these events incorrectly, causing an X11 I/O error...
	// Disable for now.
// 	kWarning() << "FIXME: Output event ignored!";
// 	return;
	
	RRCrtc currentCrtc = m_crtc->id();
	if (event->crtc != currentCrtc)
	{
		changed |= RandR::ChangeCrtc;
		// update crtc settings
		if (currentCrtc != None)
			m_crtc->loadSettings(true);
			//m_screen->crtc(m_currentCrtc)->loadSettings(true);
		setCrtc(m_screen->crtc(event->crtc), false);
		if (currentCrtc != None)
			m_crtc->loadSettings(true);
	}

	if (event->mode != mode().id())
		changed |= RandR::ChangeMode;
	
	if (event->rotation != rotation())
		changed |= RandR::ChangeRotation;
	
	if((event->connection == RR_Connected) != m_connected)
	{
		changed |= RandR::ChangeConnection;
		m_connected = (event->connection == RR_Connected);
		loadSettings(false);
		if (!m_connected && currentCrtc != None)
			setCrtc(m_screen->crtc(None), true);
	}

	// check if we are still connected, if not, release the crtc connection
	if(!m_connected && m_crtc->isValid())
		setCrtc(m_screen->crtc(None), true);

	if(changed)
		emit outputChanged(m_id, changed);
}
Ejemplo n.º 2
0
void RandROutput::handleEvent(XRROutputChangeNotifyEvent *event)
{
	int changed = 0;

#if 1
	kDebug() << "[OUTPUT] Got event for " << m_name;
	kDebug() << "       crtc: " << event->crtc;
	kDebug() << "       mode: " << event->mode;
	kDebug() << "       rotation: " << event->rotation;
	kDebug() << "       connection: " << event->connection;
#endif
	if (event->crtc != m_currentCrtc)
	{
		changed |= RandR::ChangeCrtc;
		// update crtc settings
		if (m_currentCrtc != None)
			m_screen->crtc(m_currentCrtc)->loadSettings(true);
		setCrtc(event->crtc);
		if (m_currentCrtc != None)
			m_screen->crtc(m_currentCrtc)->loadSettings(true);
	}

	if (event->mode != mode())
	{
		changed |= RandR::ChangeMode;

	}
	if (event->rotation != rotation())
	{
		changed |= RandR::ChangeRotation;
	}
	if ((event->connection == RR_Connected) != m_connected)
	{
		changed |= RandR::ChangeConnection;
		m_connected = !m_connected;
		if (!m_connected && m_currentCrtc != None)
			setCrtc(None);
	}

	// check if we are still connected, if not, release the crtc connection
	if (!m_connected && m_currentCrtc != None)
		setCrtc(None);

	if (changed)
		emit outputChanged(m_id, changed);
}
Ejemplo n.º 3
0
void RandROutput::queryOutputInfo(void)
{
	XRROutputInfo *info = XRRGetOutputInfo(QX11Info::display(), m_screen->resources(), m_id);
	Q_ASSERT(info);
	
	if (RandR::timestamp != info->timestamp)
		RandR::timestamp = info->timestamp;
	
	// Set up the output's connection status, name, and current
	// CRT controller.
	m_connected = (info->connection == RR_Connected);
	m_name = info->name;
	
	kDebug() << "XID" << m_id << "is output" << m_name <<
	            (isConnected() ? "(connected)" : "(disconnected)");
	
	setCrtc(m_screen->crtc(info->crtc));
	kDebug() << "Possible CRTCs for output" << m_name << ":";

	if (!info->ncrtc) {
		kDebug() << "   - none";
	}
	for(int i = 0; i < info->ncrtc; ++i) {
		kDebug() << "   - CRTC" << info->crtcs[i];
		m_possibleCrtcs.append(info->crtcs[i]);
	}
	
	//TODO: is it worth notifying changes on mode list changing?
	m_modes.clear();
	
	for (int i = 0; i < info->nmode; ++i) {
		if (i < info->npreferred) {
			m_preferredMode = m_screen->mode(info->modes[i]);
		}
		m_modes.append(info->modes[i]);
	}
	
	//get all possible rotations
	m_rotations = 0;
	for (int i = 0; i < m_possibleCrtcs.count(); ++i)
	{
		RandRCrtc *crtc = m_screen->crtc(m_possibleCrtcs.at(i));
		Q_ASSERT(crtc);
		m_rotations |= crtc->rotations();
	}
	m_originalRotation = m_crtc->rotation();
	m_originalRate     = m_crtc->refreshRate();
	m_originalRect     = m_crtc->rect();
	
	if(isConnected()) {
		kDebug() << "Current configuration for output" << m_name << ":";
		kDebug() << "   - Refresh rate:" << m_originalRate;
		kDebug() << "   - Rect:" << m_originalRect;
		kDebug() << "   - Rotation:" << m_originalRotation;
	}
	
	XRRFreeOutputInfo(info);
}
Ejemplo n.º 4
0
void RandROutput::loadSettings(bool notify)
{
	int changes = 0;
	XRROutputInfo *info = XRRGetOutputInfo(QX11Info::display(), m_screen->resources(), m_id);
	Q_ASSERT(info);


	if (RandR::timestamp != info->timestamp)
		RandR::timestamp = info->timestamp;

	// this information shouldn't change, so
	m_name = info->name;

	m_possibleCrtcs.clear();
	for (int i = 0; i < info->ncrtc; ++i)
		m_possibleCrtcs.append(info->crtcs[i]);

	//check if the crtc changed
	if (info->crtc != m_currentCrtc)
	{
		setCrtc(info->crtc);
		changes |= RandR::ChangeCrtc;
	}

			

	bool connected = (info->connection == RR_Connected);
	if (connected != m_connected)
	{
		m_connected = connected;
		changes |= RandR::ChangeConnection;
	}

	//CHECK: is it worth notifying changes on mode list changing?
	//get modes
	m_modes.clear();
	for (int i = 0; i < info->nmode; ++i)
		m_modes.append(info->modes[i]);

	//get all possible rotations
	m_rotations = 0;
	for (int i = 0; i < m_possibleCrtcs.count(); ++i)
	{
		RandRCrtc *crtc = m_screen->crtc(m_possibleCrtcs.at(i));
		Q_ASSERT(crtc);
		m_rotations |= crtc->rotations();
	}

	// free the info
	XRRFreeOutputInfo(info);

	if (changes && notify)
		emit outputChanged(m_id, changes);
}