Example #1
0
 FREObject LNLeapDevice::getClosestScreenHit(int pointableId) {
     ScreenList screenList = controller->calibratedScreens();
     Frame frame = controller->frame();
     PointableList pointables = frame.pointables();
     Pointable pointable;
     
     // TODO: Create a fake pointable width tipPosition and direction instead of looping
     bool didFind = false;
     for (int i = 0; i < pointables.count(); i++) {
         if (pointables[i].id() == pointableId) {
             pointable = pointables[i];
             didFind = true;
             break;
         }
     }
     
     FREObject freScreenId;
     
     if(didFind) {
         Screen screen = screenList.closestScreenHit(pointable);
         FRENewObjectFromInt32(screen.id(), &freScreenId);
     } else {
         FRENewObjectFromInt32(0, &freScreenId);
     }
     return freScreenId;
 }
Example #2
0
status_t
VirtualScreen::SetConfiguration(Desktop& desktop,
	ScreenConfigurations& configurations, uint32* _changedScreens)
{
	// Remember previous screen modes

	typedef std::map<Screen*, display_mode> ScreenModeMap;
	ScreenModeMap previousModes;
	bool previousModesFailed = false;

	if (_changedScreens != NULL) {
		*_changedScreens = 0;

		try {
			for (int32 i = 0; i < fScreenList.CountItems(); i++) {
				Screen* screen = fScreenList.ItemAt(i)->screen;

				display_mode mode;
				screen->GetMode(mode);

				previousModes.insert(std::make_pair(screen, mode));
			}
		} catch (...) {
			previousModesFailed = true;
			*_changedScreens = ~0L;
		}
	}

	_Reset();

	ScreenList list;
	status_t status = gScreenManager->AcquireScreens(&desktop, NULL, 0,
		desktop.TargetScreen(), false, list);
	if (status != B_OK) {
		// TODO: we would try again here with force == true
		return status;
	}

	for (int32 i = 0; i < list.CountItems(); i++) {
		Screen* screen = list.ItemAt(i);

		AddScreen(screen, configurations);

		if (!previousModesFailed && _changedScreens != NULL) {
			// Figure out which screens have changed their mode
			display_mode mode;
			screen->GetMode(mode);

			ScreenModeMap::const_iterator found = previousModes.find(screen);
			if (found != previousModes.end()
				&& memcmp(&mode, &found->second, sizeof(display_mode)))
				*_changedScreens |= 1 << i;
		}
	}

	UpdateFrame();
	return B_OK;
}
Example #3
0
ScreenSetupModel::ScreenSetupModel(ScreenList& screens, int numColumns, int numRows) :
	QAbstractTableModel(NULL),
	m_Screens(screens),
	m_NumColumns(numColumns),
	m_NumRows(numRows)
{
	if (m_NumColumns * m_NumRows > screens.size())
		qFatal("Not enough elements (%u) in screens QList for %d columns and %d rows", screens.size(), m_NumColumns, m_NumRows);
}
Example #4
0
void
ScreenManager::ReleaseScreens(ScreenList& list)
{
	BAutolock locker(this);

	for (int32 i = 0; i < fScreenList.CountItems(); i++) {
		screen_item* item = fScreenList.ItemAt(i);

		for (int32 j = 0; j < list.CountItems(); j++) {
			Screen* screen = list.ItemAt(j);

			if (item->screen == screen)
				item->owner = NULL;
		}
	}
}
Example #5
0
void
VirtualScreen::_Reset()
{
	ScreenList list;
	for (int32 i = 0; i < fScreenList.CountItems(); i++) {
		screen_item* item = fScreenList.ItemAt(i);

		list.AddItem(item->screen);
	}

	gScreenManager->ReleaseScreens(list);
	fScreenList.MakeEmpty();

	fFrame.Set(0, 0, 0, 0);
	fDrawingEngine = NULL;
	fHWInterface = NULL;
}
Example #6
0
status_t
ScreenManager::AcquireScreens(ScreenOwner* owner, int32* wishList,
	int32 wishCount, const char* target, bool force, ScreenList& list)
{
	BAutolock locker(this);
	int32 added = 0;

	// TODO: don't ignore the wish list

	for (int32 i = 0; i < fScreenList.CountItems(); i++) {
		screen_item* item = fScreenList.ItemAt(i);

		if (item->owner == NULL && list.AddItem(item->screen)) {
			item->owner = owner;
			added++;
		}
	}

#if TEST_MODE == 0 && !defined(__x86_64__)
	if (added == 0 && target != NULL) {
		// there's a specific target screen we want to initialize
		// TODO: right now we only support remote screens, but we could
		// also target specific accelerants to support other graphics cards
		HWInterface* interface;
		/*
		if (strncmp(target, "vnc:", 4) == 0)
			interface = new(nothrow) VNCHWInterface(target);
		else*/
		if (strncmp(target, "html5:", 6) == 0)
			interface = new(nothrow) HTML5HWInterface(target);
		else
			interface = new(nothrow) RemoteHWInterface(target);
		if (interface != NULL) {
			screen_item* item = _AddHWInterface(interface);
			if (item != NULL && list.AddItem(item->screen)) {
				item->owner = owner;
				added++;
			}
		}
	}
#endif // TEST_MODE == 0

	return added > 0 ? B_OK : B_ENTRY_NOT_FOUND;
}