Exemplo n.º 1
0
DesktopWindow* GetOrdinalWindow(DescType ordinal, Boolean toplevel, BrowserDesktopWindow* container)
{
	int index = -1;
	int count = 0;
	if (ordinal == kAEMiddle || ordinal == kAEAny)
	{
		count = GetWindowCount(toplevel, container);
	}
	switch (ordinal)
	{
		case kAEFirst:
			index = 1;
			break;
		case kAELast:
			index = -1;
			break;
		case kAEMiddle:
			if (count == 0)
				return NULL;
			index = (count+1) / 2;
			break;
		case kAEAny:
			if (count == 0)
				return NULL;
			index = (random() % count) + 1;
			break;
		default:
			return NULL;
	}
	return GetNumberedWindow(index, toplevel, container);
}
Exemplo n.º 2
0
// 根据索引获得区域
bool CTempletFree::GetWndRect(int index, LPRECT lpRect)
{
	if ((index>81) || (index>GetWindowCount()))
		return false;

	*lpRect=m_rectWindow[index];
	return true;
}
Exemplo n.º 3
0
void CPluginW2800::SetWindow(int nTab)
{
	if (!InfoW2800 || !InfoW2800->AdvControl)
		return;

	// We have to find **current** window ID because Far entangles them constantly
	INT_PTR iNewPos = -1;
	if (pwList && (nTab >= 0) && (nTab < pwList->size()))
	{
		MArray<WindowInfo> wCurrent;
		// Load window list
		WLoadWindows(wCurrent, GetWindowCount());
		INT_PTR i = WExists((*pwList)[nTab], wCurrent);
		if (i >= 0)
			iNewPos = wCurrent[i].Pos;
	}

	if ((iNewPos >= 0)
		&& InfoW2800->AdvControl(&guid_ConEmu, ACTL_SETCURRENTWINDOW, iNewPos, NULL))
		InfoW2800->AdvControl(&guid_ConEmu, ACTL_COMMIT, 0, 0);
}
Exemplo n.º 4
0
	// Main code to find a window from it's z-order number.
DesktopWindow* GetNumberedWindow(int number, Boolean toplevel, BrowserDesktopWindow* container)
{
	int count;
	count = GetWindowCount(toplevel, container);
	if (number < 0)
		number = count + number;
	else
		number -= 1;
	if (number < 0 || number >= count)
	{
		return NULL;
	}

	int this_index = 0;
	if (container)
	{
		OpWorkspace* workspace = container->GetWorkspace();
		DesktopWindow* sub_win;
		int sub_count;
		if (workspace)
		{
			sub_count = workspace->GetDesktopWindowCount();
			for (int j = 0; j < sub_count; j++)
			{
				sub_win = workspace->GetDesktopWindowFromStack(j);
				if (sub_win && sub_win->GetType() == OpTypedObject::WINDOW_TYPE_DOCUMENT)
				{
					if (this_index == number)
						return sub_win;
					this_index++;
				}
			}
		}
		return NULL;
	}

	DesktopWindowCollection& windows = g_application->GetDesktopWindowCollection();
	int win_num = 0;
	void* theWin;
	while ((theWin = GetNSWindowWithNumber(win_num++)))
	{
		for (DesktopWindowCollectionItem* item = windows.GetFirstToplevel(); item; item = item->GetSiblingItem())
		{
			DesktopWindow* win = item->GetDesktopWindow();
			if (win)
			{
				CocoaOpWindow* opwin = (CocoaOpWindow*)win->GetOpWindow();
				if (opwin && (opwin->IsSameWindow(theWin)))
				{
					// It is a desktop window. Great!
					if (toplevel || win->GetType() == OpTypedObject::WINDOW_TYPE_DOCUMENT)
					{
						if (this_index == number)
							return win;
						this_index++;
					}
					else if (win->GetType() == OpTypedObject::WINDOW_TYPE_BROWSER)
					{
						OpWorkspace* workspace = win->GetWorkspace();
						DesktopWindow* sub_win;
						int sub_count;
						if (workspace)
						{
							sub_count = workspace->GetDesktopWindowCount();
							for (int j = 0; j < sub_count; j++)
							{
								sub_win = workspace->GetDesktopWindowFromStack(j);
								if (sub_win && sub_win->GetType() == OpTypedObject::WINDOW_TYPE_DOCUMENT)
								{
									if (this_index == number)
										return sub_win;
									this_index++;
								}
							}
						}
					}
				}
			}
		}
	}
	return NULL;
}