Esempio n. 1
0
/**
 * Add a window to the window stack.
 * @param w Window to add.
 */
void WindowManager::AddToStack(Window *w)
{
	assert(w->lower == nullptr && w->higher == nullptr);
	assert(!this->HasWindow(w));

	uint w_prio = GetWindowZPriority(w->wtype);
	if (this->top == nullptr || w_prio >= GetWindowZPriority(this->top->wtype)) {
		/* Add to the top. */
		w->lower = this->top;
		w->higher = nullptr;
		if (this->top != nullptr) this->top->higher = w;
		this->top = w;
		if (this->bottom == nullptr) this->bottom = w;
		return;
	}
	Window *stack = this->top;
	while (stack->lower != nullptr && w_prio < GetWindowZPriority(stack->lower->wtype)) stack = stack->lower;

	w->lower = stack->lower;
	if (stack->lower != nullptr) {
		stack->lower->higher = w;
	} else {
		assert(this->bottom == stack);
		this->bottom = w;
	}
	w->higher = stack;
	stack->lower = w;
}
Esempio n. 2
0
/**
 * Raise a window.
 * @param w Window to raise.
 */
void WindowManager::RaiseWindow(Window *w)
{
	if (w != this->top && GetWindowZPriority(w->wtype) >= GetWindowZPriority(w->higher->wtype)) {
		this->RemoveFromStack(w);
		this->AddToStack(w);
		w->MarkDirty();
	}
}
Esempio n. 3
0
/**
 * Is the screen empty below the rectangle?
 * @param rect Area to test.
 * @return Tested area is clear.
 */
bool ComputeInitialPosition::IsScreenEmpty(const Rectangle32 &rect)
{
	uint new_prio = GetWindowZPriority(this->skip->wtype);

	if (rect.base.x < 0 || rect.base.y < 0
			|| rect.base.x + rect.width  > _video.GetXSize()
			|| rect.base.y + rect.height > _video.GetYSize()) return false;

	for (Window *w = _window_manager.top; w != nullptr; w = w->lower) {
		if (w == this->skip || new_prio > GetWindowZPriority(w->wtype)) continue;
		if (w->rect.Intersects(rect)) return false;
	}
	return true;
}
Esempio n. 4
0
/**
 * Add a window to the window stack.
 * @param w Window to add.
 */
void WindowManager::AddToStack(Window *w)
{
	assert(w->lower == nullptr && w->higher == nullptr);
	assert(!this->HasWindow(w));

	if (w->wtype == WC_MAINDISPLAY) { // Add the main world display as viewport.
		assert(this->viewport == nullptr);
		this->viewport = static_cast<Viewport *>(w);
	}

	if (this->select_valid && this->select_window != nullptr) this->select_window->selector->MarkDirty();
	this->select_valid = false;

	uint w_prio = GetWindowZPriority(w->wtype);
	if (this->top == nullptr || w_prio >= GetWindowZPriority(this->top->wtype)) {
		/* Add to the top. */
		w->lower = this->top;
		w->higher = nullptr;
		if (this->top != nullptr) this->top->higher = w;
		this->top = w;
		if (this->bottom == nullptr) this->bottom = w;
		return;
	}
	Window *stack = this->top;
	while (stack->lower != nullptr && w_prio < GetWindowZPriority(stack->lower->wtype)) stack = stack->lower;

	w->lower = stack->lower;
	if (stack->lower != nullptr) {
		stack->lower->higher = w;
	} else {
		assert(this->bottom == stack);
		this->bottom = w;
	}
	w->higher = stack;
	stack->lower = w;
}