Files
haiku-beta6/src/servers/app/WindowList.cpp
T
Axel Dörfler 34227d2c34 A couple of changes related to modal and floating windows:
* Desktop::SetWindowFeel() is now working, but doesn't respect the window
  position yet (ie. floating windows would have to be moved to front).
* WindowLayer::Workspaces() now always reflects exactly the lists it's in
  (at least after Desktop::AddWindow() has been called). WindowList::AddWindow()
  and RemoveWindow() now update this flag to be correct at all times.
* Fixed Desktop::_ChangeWindowWorkspaces() to not set the current workspace
  for windows that are not on the current workspace, and vice versa.
  It also would hide windows that were already hidden, and tried to show
  windows that actually were hidden (did no other harm than triggering
  a rebuild of the global clipping).
* Floating windows now work as expected.
* Desktop::SetFocusWindow() won't give a window focus that has a modal.
* Renamed OnWorkspace() to InWorkspace().
* ServerApp::InWorkspace() now works correctly, added ServerApp::Workspaces()
  as well.
* WindowLayer::SubsetWorkspaces() returns the workspaces mask this modal or
  floating window should be in.
* New window flag B_SAME_POSITION_IN_ALL_WORKSPACES should work as well.
* Floating and modal windows now have always set this flag.
* Added a WindowList::HasWindow() method.
* Desktop windows (windows with the desktop feel) can now have focus again
  (I accidently broke that before).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15434 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-09 13:17:43 +00:00

127 lines
2.4 KiB
C++

/*
* Copyright (c) 2005, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Axel Dörfler, [email protected]
*/
#include "DesktopSettings.h"
#include "WindowLayer.h"
const BPoint kInvalidWindowPosition = BPoint(INFINITY, INFINITY);
window_anchor::window_anchor()
:
next(NULL),
previous(NULL),
position(kInvalidWindowPosition)
{
}
// #pragma mark -
WindowList::WindowList(int32 index)
:
fIndex(index),
fFirstWindow(NULL),
fLastWindow(NULL)
{
}
WindowList::~WindowList()
{
}
void
WindowList::SetIndex(int32 index)
{
fIndex = index;
}
void
WindowList::AddWindow(WindowLayer* window, WindowLayer* before)
{
window_anchor& windowAnchor = window->Anchor(fIndex);
if (before != NULL) {
window_anchor& beforeAnchor = before->Anchor(fIndex);
// add view before this one
windowAnchor.next = before;
windowAnchor.previous = beforeAnchor.previous;
if (windowAnchor.previous != NULL)
windowAnchor.previous->Anchor(fIndex).next = window;
beforeAnchor.previous = window;
if (fFirstWindow == before)
fFirstWindow = window;
} else {
// add view to the end of the list
if (fLastWindow != NULL) {
fLastWindow->Anchor(fIndex).next = window;
windowAnchor.previous = fLastWindow;
} else {
fFirstWindow = window;
windowAnchor.previous = NULL;
}
windowAnchor.next = NULL;
fLastWindow = window;
}
if (fIndex < kMaxWorkspaces)
window->SetWorkspaces(window->Workspaces() | (1UL << fIndex));
}
void
WindowList::RemoveWindow(WindowLayer* window)
{
window_anchor& windowAnchor = window->Anchor(fIndex);
if (fFirstWindow == window) {
// it's the first child
fFirstWindow = windowAnchor.next;
} else {
// it must have a previous sibling, then
windowAnchor.previous->Anchor(fIndex).next = windowAnchor.next;
}
if (fLastWindow == window) {
// it's the last child
fLastWindow = windowAnchor.previous;
} else {
// then it must have a next sibling
windowAnchor.next->Anchor(fIndex).previous = windowAnchor.previous;
}
if (fIndex < kMaxWorkspaces)
window->SetWorkspaces(window->Workspaces() & ~(1UL << fIndex));
windowAnchor.previous = NULL;
windowAnchor.next = NULL;
}
bool
WindowList::HasWindow(WindowLayer* window) const
{
if (window == NULL)
return false;
return window->Anchor(fIndex).next != NULL
|| window->Anchor(fIndex).previous != NULL
|| fFirstWindow == window
|| fLastWindow == window;
}