2004-01-17 21:37:57 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-02-28 23:23:51 +03:00
|
|
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
2004-01-17 21:37:57 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: Workspace.cpp
|
2005-02-28 23:23:51 +03:00
|
|
|
// Author: Adi Oanca <adioanca@cotty.iren.ro>
|
2005-04-23 14:05:33 +04:00
|
|
|
// Description: Tracks windows inside one workspace
|
2004-01-17 21:37:57 +03:00
|
|
|
//
|
2004-07-11 14:01:01 +04:00
|
|
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
// Notes: IMPORTANT WARNING
|
|
|
|
// This object does not use any locking mechanism. It is designed
|
2005-02-28 23:23:51 +03:00
|
|
|
// to be used by RootLayer class ONLY. DO NOT USE from elsewhere!
|
|
|
|
//
|
|
|
|
// Design Spec:
|
|
|
|
// The purpose of this class it to have visible windows appear in the
|
|
|
|
// correct order as defined by GUI guidelines. Those define 3 main type of windows:
|
2005-07-07 00:19:22 +04:00
|
|
|
// normal windows, modal and floating windows. Aditionally there must be support
|
2005-02-28 23:23:51 +03:00
|
|
|
// for another 2 types of windows which will be used in special cases. We're talking
|
|
|
|
// about system front windows which always will be the front-most and have focus, and
|
|
|
|
// system last windows which will always be behind all other kind of windows.
|
|
|
|
//
|
|
|
|
// Normal windows will always be in Workspace's list, be it they are hidden
|
2005-11-24 20:45:26 +03:00
|
|
|
// or not. They are added by hand (AddWindowLayer()) only. Same goes for system last
|
2005-02-28 23:23:51 +03:00
|
|
|
// windows, system first, modall all and floating all windows. Those remaining
|
|
|
|
// are: modal subset, modal app, floating subset and floating app. Those will be
|
|
|
|
// added and removed on-the-fly as they are needed.
|
|
|
|
//
|
|
|
|
// To keep correct track of modal subset/app and floating subset/app windows
|
|
|
|
// we need to have them in a list. Also, we want every normal window to
|
|
|
|
// maintain its floating windows order. For that we define a list for every normal
|
|
|
|
// window in which we'll add floating subset & app windows alongside with subset
|
|
|
|
// modals. Application modals go in a separate list which is hold for every
|
|
|
|
// application (ServerApp) object. For normal window's list: when a floating win
|
|
|
|
// is need (when normal window becomes front) it is always removed and automaticaly
|
|
|
|
// added to workspace's list. When that normal looses front state, it reinserts
|
|
|
|
// all floating windows it has used back into its list, thus saving the exact order
|
|
|
|
// of floating windows. Modal windows are never removed from normal or application's
|
|
|
|
// list, but they are automaticaly added and removed from workspace's list as needed.
|
|
|
|
// (ex: a modal app won't appear until a normal window from the same app is visible)
|
|
|
|
//
|
|
|
|
// Front status is a bit hard to explain. It's a state which helps keep
|
|
|
|
// the wanted order. For example, if a modal window is set to have front status,
|
|
|
|
// an automatic search is made to see if another modal was created after this
|
|
|
|
// one and thus needs to have front state (read: thus have to be in front this).
|
|
|
|
// Another use is to have floating windows pop up in front of a normal window when
|
|
|
|
// no modal exist to steal front state.
|
2004-01-17 21:37:57 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-01-12 01:12:55 +03:00
|
|
|
#include <stdio.h>
|
2005-02-28 23:23:51 +03:00
|
|
|
#include <stdlib.h>
|
2004-01-12 01:12:55 +03:00
|
|
|
#include <Window.h>
|
2005-06-07 05:29:12 +04:00
|
|
|
#include <TypeConstants.h>
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
#include "Workspace.h"
|
|
|
|
#include "Layer.h"
|
2005-11-24 20:45:26 +03:00
|
|
|
#include "WindowLayer.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "ServerWindow.h"
|
2004-01-13 04:03:29 +03:00
|
|
|
#include "ServerApp.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "RGBColor.h"
|
2005-06-17 20:34:22 +04:00
|
|
|
#include "SubWindowList.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-01-21 05:58:39 +03:00
|
|
|
//#define DEBUG_WORKSPACE
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_WORKSPACE
|
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_WORKSPACE
|
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACESTREAM() PrintToStream()
|
|
|
|
#else
|
|
|
|
# define STRACESTREAM() ;
|
|
|
|
#endif
|
|
|
|
|
2005-10-29 14:19:23 +04:00
|
|
|
void
|
|
|
|
Workspace::State::PrintToStream()
|
|
|
|
{
|
|
|
|
printf("WS::State - Front: %s\n", Front? Front->Name(): "NULL");
|
|
|
|
printf("WS::State - Focus: %s\n", Focus? Focus->Name(): "NULL");
|
|
|
|
printf("WS::State - Active: %s\n", Active? Active->Name(): "NULL");
|
|
|
|
|
|
|
|
for (int32 i = 0; i < WindowList.CountItems(); ++i) {
|
|
|
|
Layer *l = (Layer*)WindowList.ItemAt(i);
|
|
|
|
if (l)
|
|
|
|
printf("\t %ld - %s\n", i, l->Name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2005-02-28 23:23:51 +03:00
|
|
|
/*!
|
|
|
|
\brief Creates a new Workspace object which has its own resolution and background color.
|
|
|
|
*/
|
|
|
|
Workspace::Workspace(const int32 ID, const uint32 colorspace, const RGBColor& BGColor)
|
|
|
|
: fBGColor(BGColor)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
STRACE(("New Workspace(%ld)\n", fID));
|
2004-01-12 01:12:55 +03:00
|
|
|
fID = ID;
|
2005-10-08 20:44:28 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
fBottomItem = NULL;
|
|
|
|
fTopItem = NULL;
|
|
|
|
fFocusItem = NULL;
|
|
|
|
fFrontItem = NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
memset(&fDisplayMode, 0, sizeof(fDisplayMode));
|
|
|
|
fDisplayMode.space = colorspace;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2005-02-28 23:23:51 +03:00
|
|
|
/*!
|
|
|
|
\brief Frees internal data.
|
|
|
|
*/
|
2004-06-26 06:15:48 +04:00
|
|
|
Workspace::~Workspace(void)
|
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
STRACE(("~Workspace(%ld) - say bye bye\n", fID));
|
|
|
|
fFocusItem = NULL;
|
|
|
|
fFrontItem = NULL;
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
ListData *toast;
|
2004-06-26 06:15:48 +04:00
|
|
|
while(fBottomItem)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
toast = fBottomItem;
|
|
|
|
fBottomItem = fBottomItem->upperItem;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
fPool.ReleaseMemory(toast);
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
fBottomItem = NULL;
|
|
|
|
fTopItem = NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Adds layer ptr to workspace's list of WindowLayers.
|
2004-06-26 06:15:48 +04:00
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
void
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::AddWindowLayer(WindowLayer *winBorder)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-11-24 20:45:26 +03:00
|
|
|
STRACE(("W(%ld)::AddWindowLayer(%s)\n", fID, winBorder?winBorder->Name():"NULL"));
|
2005-07-07 00:19:22 +04:00
|
|
|
if (winBorder->Level() == B_FLOATING_APP) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// floating windows are automaticaly added when needed
|
|
|
|
// you cannot add one by hand.
|
|
|
|
return;
|
|
|
|
}
|
2004-01-14 18:55:10 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (HasItem(winBorder)) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// NOTE: you may remove 'debugger' at Release Candidate time
|
2005-11-24 20:45:26 +03:00
|
|
|
debugger("WindowLayer ALREADY in Workspace's list\n");
|
2005-02-28 23:23:51 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// allocate a new item
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* item = fPool.GetCleanMemory(winBorder);
|
2004-07-10 10:28:41 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// place this winBorder in what seems the most appropriate location.
|
|
|
|
// Do not change front window
|
|
|
|
placeInFront(item, false);
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
/*
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Removes a WindowLayer from workspace's list.
|
2004-06-26 06:15:48 +04:00
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
void
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::RemoveWindowLayer(WindowLayer *winBorder)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-11-24 20:45:26 +03:00
|
|
|
STRACE(("W(%ld)::RemoveWindowLayer(%s)\n", fID, winBorder?winBorder->Name():"NULL"));
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* item = HasItem(winBorder);
|
|
|
|
|
|
|
|
if (item) {
|
2004-01-17 19:33:22 +03:00
|
|
|
RemoveItem(item);
|
2005-02-28 23:23:51 +03:00
|
|
|
fPool.ReleaseMemory(item);
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::HasWindowLayer(const WindowLayer* winBorder) const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
return HasItem(winBorder) ? true: false;
|
2004-01-17 19:33:22 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer *
|
2005-07-07 00:19:22 +04:00
|
|
|
Workspace::Focus() const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fFocusItem ? fFocusItem->layerPtr : NULL;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer *
|
2005-07-07 00:19:22 +04:00
|
|
|
Workspace::Front() const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
return fFrontItem ? fFrontItem->layerPtr: NULL;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer *
|
2005-07-07 00:19:22 +04:00
|
|
|
Workspace::Active() const
|
|
|
|
{
|
2005-09-19 02:43:31 +04:00
|
|
|
// in case of a normal or modal window
|
|
|
|
if (fFrontItem && fFrontItem == fFocusItem)
|
|
|
|
return fFrontItem->layerPtr;
|
|
|
|
|
|
|
|
// a floating window is considered active if it has focus.
|
|
|
|
if (fFocusItem && (fFocusItem->layerPtr->Level() == B_FLOATING_APP ||
|
|
|
|
fFocusItem->layerPtr->Level() == B_FLOATING_ALL))
|
|
|
|
return fFocusItem->layerPtr;
|
|
|
|
|
|
|
|
return NULL;
|
2005-07-07 00:19:22 +04:00
|
|
|
}
|
|
|
|
|
2005-11-11 00:52:59 +03:00
|
|
|
/*!
|
|
|
|
\brief Method that returns the state of window manager.
|
|
|
|
\param state - a pointer to a valid Workspace::State structure
|
|
|
|
\return void
|
|
|
|
|
|
|
|
Fills the state structure with the most important window manager attibutes:
|
|
|
|
front window, focus window, active window and the list of windows starting from
|
|
|
|
the backmost one at position 0 and ending with the most visible window.
|
|
|
|
*/
|
2005-09-16 09:10:21 +04:00
|
|
|
void
|
|
|
|
Workspace::GetState(Workspace::State *state) const
|
|
|
|
{
|
|
|
|
state->Front = Front();
|
|
|
|
state->Focus = Focus();
|
2005-09-20 02:41:48 +04:00
|
|
|
state->Active = Active();
|
2005-09-16 09:10:21 +04:00
|
|
|
|
2005-11-11 00:52:59 +03:00
|
|
|
ListData *cursor = fTopItem;
|
2005-09-16 09:10:21 +04:00
|
|
|
while (cursor) {
|
|
|
|
if (!cursor->layerPtr->IsHidden())
|
|
|
|
state->WindowList.AddItem(cursor->layerPtr);
|
2005-11-11 00:52:59 +03:00
|
|
|
cursor = cursor->lowerItem;
|
2005-09-16 09:10:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::AttemptToSetFront(WindowLayer *newFront)
|
2005-09-16 09:10:21 +04:00
|
|
|
{
|
|
|
|
return MoveToFront(newFront);
|
|
|
|
}
|
|
|
|
|
2005-10-03 01:55:45 +04:00
|
|
|
int32
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::AttemptToSetFocus(WindowLayer *newFocus)
|
2005-09-16 09:10:21 +04:00
|
|
|
{
|
2005-10-03 01:55:45 +04:00
|
|
|
ListData* newFocusItem = HasItem(newFocus);
|
|
|
|
|
|
|
|
return _SetFocus(newFocusItem);
|
2005-09-16 09:10:21 +04:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-09-16 09:10:21 +04:00
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::AttemptToMoveToBack(WindowLayer *newBack)
|
2005-09-16 09:10:21 +04:00
|
|
|
{
|
|
|
|
return MoveToBack(newBack);
|
|
|
|
}
|
2005-09-19 02:43:31 +04:00
|
|
|
|
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::AttemptToActivate(WindowLayer *toActivate)
|
2005-09-19 02:43:31 +04:00
|
|
|
{
|
|
|
|
MoveToFront(toActivate);
|
2005-10-03 01:55:45 +04:00
|
|
|
AttemptToSetFocus(toActivate);
|
2005-09-19 02:43:31 +04:00
|
|
|
return Active() == toActivate;
|
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
/*
|
|
|
|
\brief This method provides you the list of visible windows in this workspace.
|
2005-11-24 20:45:26 +03:00
|
|
|
\param list The list of visible WindowLayers found in this workspace.
|
|
|
|
\param itemCount Number of WindowLayer pointers found in the list.
|
2005-02-28 23:23:51 +03:00
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::GetWindowLayerList(void **list, int32 *itemCount ) const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
int32 count = 0;
|
|
|
|
ListData* cursor;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
cursor = fBottomItem;
|
|
|
|
while (cursor) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (!cursor->layerPtr->IsHidden())
|
|
|
|
count++;
|
|
|
|
cursor = cursor->upperItem;
|
|
|
|
}
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (*itemCount < count) {
|
2005-03-13 02:26:05 +03:00
|
|
|
// buffer not big enough. buffer must be count high
|
|
|
|
*itemCount = count;
|
|
|
|
return false;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (list) {
|
|
|
|
*itemCount = count;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
cursor = fBottomItem;
|
2005-07-07 00:19:22 +04:00
|
|
|
while (cursor) {
|
|
|
|
if (!cursor->layerPtr->IsHidden()) {
|
|
|
|
*list = cursor->layerPtr;
|
2005-03-13 02:26:05 +03:00
|
|
|
list++;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
cursor = cursor->upperItem;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-03-13 02:26:05 +03:00
|
|
|
|
2005-03-19 21:58:47 +03:00
|
|
|
return true;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-10-03 01:55:45 +04:00
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Makes the specified WindowLayer the focus one.
|
|
|
|
\param newFocus WindowLayer which will try to take focus state.
|
2005-10-03 01:55:45 +04:00
|
|
|
\return 0 - setting focus failed, focus did not change.
|
2005-11-24 20:45:26 +03:00
|
|
|
1 - the new focus WindowLayer is \a winBorder
|
2005-10-03 01:55:45 +04:00
|
|
|
2 - focus changed but not to \a winBorder because in front of it there
|
|
|
|
are other modal windows.
|
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
Set a new focus WindowLayer if possible.
|
2005-10-03 01:55:45 +04:00
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-10-03 01:55:45 +04:00
|
|
|
int32
|
|
|
|
Workspace::_SetFocus(ListData *newFocusItem)
|
2005-07-07 00:19:22 +04:00
|
|
|
{
|
2005-10-03 01:55:45 +04:00
|
|
|
if (!newFocusItem || newFocusItem == fFocusItem
|
|
|
|
|| (newFocusItem && !newFocusItem->layerPtr->IsHidden()
|
|
|
|
&& newFocusItem->layerPtr->WindowFlags() & B_AVOID_FOCUS))
|
|
|
|
return 0L;
|
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer *newFocus = newFocusItem->layerPtr;
|
2005-10-03 01:55:45 +04:00
|
|
|
bool rv = 1;
|
|
|
|
|
|
|
|
switch(newFocus->Level()) {
|
|
|
|
case B_MODAL_APP:
|
|
|
|
case B_NORMAL: {
|
|
|
|
ListData *item = newFocusItem->upperItem;
|
|
|
|
while ( item &&
|
|
|
|
!item->layerPtr->IsHidden() &&
|
|
|
|
((item->layerPtr->Level() == B_MODAL_APP &&
|
|
|
|
item->layerPtr->App()->ClientTeam() == newFocus->App()->ClientTeam()) ||
|
|
|
|
item->layerPtr->Level() >= B_MODAL_ALL))
|
|
|
|
{
|
|
|
|
if (item->layerPtr->WindowFlags() & B_AVOID_FOCUS)
|
|
|
|
newFocusItem = NULL;
|
|
|
|
else
|
|
|
|
newFocusItem = item;
|
|
|
|
rv = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_SYSTEM_FIRST:
|
|
|
|
case B_MODAL_ALL: {
|
|
|
|
ListData *item = newFocusItem->upperItem;
|
|
|
|
while ( item &&
|
|
|
|
!item->layerPtr->IsHidden() &&
|
|
|
|
item->layerPtr->Level() >= newFocus->Level())
|
|
|
|
{
|
|
|
|
if (item->layerPtr->WindowFlags() & B_AVOID_FOCUS)
|
|
|
|
newFocusItem = NULL;
|
|
|
|
else
|
|
|
|
newFocusItem = item;
|
|
|
|
rv = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-10-03 01:55:45 +04:00
|
|
|
default:
|
|
|
|
break;
|
2005-07-07 00:19:22 +04:00
|
|
|
}
|
|
|
|
|
2005-10-03 01:55:45 +04:00
|
|
|
fFocusItem = newFocusItem;
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-10-03 01:55:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Makes the specified WindowLayer the front one.
|
|
|
|
\param newFront WindowLayer which will try to take front state.
|
2005-02-28 23:23:51 +03:00
|
|
|
\param doNotDisturb In case user is busy typing something, don't bring \a newFront
|
|
|
|
in front stealing front&focus, but place imediately after.
|
2005-11-24 20:45:26 +03:00
|
|
|
\return True if the list of WindowLayers has changed, false otherwise.
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
This method tries to make \a newFront the new front WindowLayer. "It tries" because
|
2005-07-07 00:19:22 +04:00
|
|
|
if this a B_NORMAL window with subset or application modals those will be displayed
|
|
|
|
in front and get the front state. If no subset or application modals exist, then this
|
|
|
|
B_NORMAL window will get front (and focus) state and subset and application floating
|
|
|
|
window will be shown in front.
|
2005-02-28 23:23:51 +03:00
|
|
|
Note that floating windows cannot get/have front state.
|
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::MoveToFront(WindowLayer *newFront, bool doNotDisturb)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
STRACE(("\nWks(%ld)::MoveToFront ~%s~ \n", fID, newFront?newFront->Name():"NULL"));
|
2005-02-28 23:23:51 +03:00
|
|
|
if (!newFront)
|
|
|
|
return false;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (newFront->IsHidden() || newFront->Level() == B_SYSTEM_LAST)
|
2005-02-28 23:23:51 +03:00
|
|
|
return false;
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFrontItem && newFront == fFrontItem->layerPtr) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// we didn't change windows order
|
|
|
|
return false;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
return ShowWindowLayer(newFront);
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Moves the specified WindowLayer in the back as it is possible.
|
|
|
|
\param newLast WindowLayer which will be placed in the back.
|
|
|
|
\return True if the list of WindowLayers has changed, false otherwise.
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer \a newLast will go in the back as much as possible. Note that this
|
2005-07-07 00:19:22 +04:00
|
|
|
action is tricky. While normal windows will always go into the back, front modal windows
|
|
|
|
won't go into the back if the next front window will be a B_NORMAL or B_MODAL_APP part
|
|
|
|
of the same team which was previously created. If it were possible it would
|
|
|
|
undermine the role of modal windows in the system. Another example regards B_FLOATING_APP
|
|
|
|
windows. These will ge in the back as possible, but never farther than the front
|
|
|
|
B_NORMAL window in front of which they appear.
|
2005-02-28 23:23:51 +03:00
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::MoveToBack(WindowLayer *newLast)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
STRACE(("Wks(%ld)::MoveToBack(%s) \n", fID, newLast? newLast->Name(): "NULL"));
|
2005-02-28 23:23:51 +03:00
|
|
|
if (newLast->IsHidden())
|
2004-01-12 01:12:55 +03:00
|
|
|
return false;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
ListData *newLastItem;
|
|
|
|
newLastItem = HasItem(newLast);
|
|
|
|
if (!newLastItem)
|
|
|
|
return false;
|
|
|
|
|
2005-03-27 14:00:37 +04:00
|
|
|
ListData *previous = newLastItem->upperItem;
|
|
|
|
bool returnValue = false;
|
|
|
|
bool changeFront = false;
|
|
|
|
int32 level = newLast->Level();
|
2005-02-28 23:23:51 +03:00
|
|
|
if (level > B_SYSTEM_FIRST)
|
|
|
|
level = B_SYSTEM_FIRST;
|
|
|
|
|
|
|
|
if (fFrontItem && fFrontItem == newLastItem)
|
|
|
|
changeFront = true;
|
|
|
|
|
|
|
|
switch(newLast->Level())
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_MODAL_ALL:
|
|
|
|
case B_SYSTEM_FIRST:
|
|
|
|
case B_SYSTEM_LAST:
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
// these kind of windows do not change position
|
|
|
|
return false;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
break;
|
|
|
|
case B_NORMAL:
|
|
|
|
{
|
|
|
|
ListData *cursor = newLastItem->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// we are already the back-most window.
|
|
|
|
if (!cursor || cursor->layerPtr->Level() == B_SYSTEM_LAST )
|
|
|
|
return false;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (changeFront)
|
|
|
|
saveFloatingWindows(fFrontItem);
|
|
|
|
}
|
|
|
|
// NOTE: no 'break;' here...
|
|
|
|
case B_FLOATING_APP:
|
|
|
|
case B_FLOATING_ALL:
|
|
|
|
{
|
2005-03-27 14:00:37 +04:00
|
|
|
returnValue = placeToBack(newLastItem);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case B_MODAL_APP:
|
|
|
|
{
|
|
|
|
ListData *cursor = newLastItem->upperItem;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// we are already the back-most window.
|
|
|
|
if (!cursor || cursor->layerPtr->Level() == B_SYSTEM_LAST )
|
|
|
|
return false;
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// this is a modal app
|
2005-06-23 21:40:35 +04:00
|
|
|
if (newLast->App()->fAppSubWindowList.HasItem(newLast)) {
|
|
|
|
ListData* before;
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// remove now to properly place later
|
|
|
|
RemoveItem(newLastItem);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
while (cursor) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (!cursor->layerPtr->IsHidden()
|
|
|
|
&& cursor->layerPtr->Level() > B_SYSTEM_LAST
|
2005-06-23 21:40:35 +04:00
|
|
|
&& cursor->layerPtr->App()->ClientTeam() == newLast->App()->ClientTeam())
|
2005-02-28 23:23:51 +03:00
|
|
|
break;
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
cursor = cursor->upperItem;
|
|
|
|
}
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (cursor)
|
|
|
|
before = cursor->lowerItem;
|
|
|
|
else
|
|
|
|
before = fTopItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
InsertItem(newLastItem, before);
|
2005-06-23 21:40:35 +04:00
|
|
|
} else {
|
|
|
|
// this is a modal subset
|
2005-02-28 23:23:51 +03:00
|
|
|
// this subset modal is visible, it means its main window must be visible. search for it.
|
|
|
|
ListData *mainWindowItem, *before;
|
|
|
|
int32 indexThis = 0, indexCursor;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// search by going deep
|
2005-06-23 21:40:35 +04:00
|
|
|
while (cursor) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (cursor->layerPtr->Level() == B_NORMAL && !cursor->layerPtr->IsHidden()
|
2005-06-17 20:34:22 +04:00
|
|
|
&& (indexThis = cursor->layerPtr->fSubWindowList.IndexOf(newLast)) >= 0)
|
2005-02-28 23:23:51 +03:00
|
|
|
break;
|
|
|
|
cursor = cursor->upperItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cursor)
|
|
|
|
debugger("MoveToBack: SubsetWindow: can't find main Window!\n");
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
RemoveItem(newLastItem);
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// good. found our main window. now go up and properly place.
|
2005-06-23 21:40:35 +04:00
|
|
|
mainWindowItem = cursor;
|
|
|
|
before = cursor->lowerItem;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
cursor = cursor->lowerItem;
|
|
|
|
while (cursor) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (cursor->layerPtr->Level() == B_MODAL_APP && !cursor->layerPtr->IsHidden()
|
2005-06-23 21:40:35 +04:00
|
|
|
&& cursor->layerPtr->App()->ClientTeam() == newLast->App()->ClientTeam())
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-06-17 20:34:22 +04:00
|
|
|
indexCursor = mainWindowItem->layerPtr->fSubWindowList.IndexOf(cursor->layerPtr);
|
2005-02-28 23:23:51 +03:00
|
|
|
if (indexCursor >= 0)
|
|
|
|
{
|
|
|
|
if (indexThis < indexCursor)
|
|
|
|
{
|
|
|
|
before = cursor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
before = cursor->lowerItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cursor = cursor->lowerItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
InsertItem(newLastItem, before);
|
|
|
|
}
|
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
debugger("MoveToBack: unknown window feel\n");
|
|
|
|
return false;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-27 14:00:37 +04:00
|
|
|
if (previous == newLastItem->upperItem)
|
|
|
|
returnValue = false;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// The following applies ONLY to B_NORMAL and B_MODAL_APP windows.
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (changeFront)
|
|
|
|
{
|
|
|
|
ListData *newFront;
|
|
|
|
newFront = findNextFront();
|
|
|
|
if (newFront)
|
2005-03-27 14:00:37 +04:00
|
|
|
returnValue |= MoveToFront(newFront->layerPtr);
|
2005-02-28 23:23:51 +03:00
|
|
|
else
|
|
|
|
debugger("MoveToBack: can't find new front! We should find one!\n");
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
return returnValue;
|
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Hides a WindowLayer.
|
|
|
|
\param winBorder WindowLayer to be hidden.
|
|
|
|
\return True if the list of WindowLayers has changed, false otherwise.
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer \a winBorder will be hidden. Some, like floating or subset modals
|
2005-07-07 00:19:22 +04:00
|
|
|
may also be removed from Workspace's list.
|
2005-11-24 20:45:26 +03:00
|
|
|
If \a winBorder if the front WindowLayer, another one (or none) will be automaticaly
|
2005-07-07 00:19:22 +04:00
|
|
|
chosen. Same goes for focus.
|
2005-02-28 23:23:51 +03:00
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::HideWindowLayer(WindowLayer *winBorder)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-11-24 20:45:26 +03:00
|
|
|
STRACE(("W(%ld)::HideWindowLayer(%s) \n", fID, winBorder? winBorder->Name(): "NULL"));
|
2005-07-07 00:19:22 +04:00
|
|
|
bool returnValue = false;
|
|
|
|
int32 level = winBorder->Level();
|
|
|
|
bool changeFront = false;
|
|
|
|
bool changeFocus = false;
|
|
|
|
ListData* nextFocus = NULL;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
if (fFrontItem && fFrontItem->layerPtr == winBorder)
|
|
|
|
changeFront = true;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFocusItem && fFocusItem->layerPtr == winBorder) {
|
2005-02-28 23:23:51 +03:00
|
|
|
changeFocus = true;
|
2005-07-07 00:19:22 +04:00
|
|
|
nextFocus = fFocusItem->lowerItem;
|
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
if (level > B_SYSTEM_FIRST)
|
|
|
|
level = B_SYSTEM_FIRST;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
switch (level) {
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_MODAL_ALL:
|
2004-01-12 01:12:55 +03:00
|
|
|
case B_SYSTEM_FIRST:
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_SYSTEM_LAST:
|
|
|
|
case B_FLOATING_ALL:
|
|
|
|
// window is just hidden. do nothing. its position is OK as it is now.
|
|
|
|
returnValue = true;
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_FLOATING_APP:
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFrontItem && fFrontItem->layerPtr->Level() == B_NORMAL) {
|
|
|
|
ListData* item = HasItem(winBorder);
|
|
|
|
if (item) {
|
2005-11-24 20:45:26 +03:00
|
|
|
fFrontItem->layerPtr->fSubWindowList.AddWindowLayer(winBorder);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
RemoveItem(item);
|
|
|
|
fPool.ReleaseMemory(item);
|
|
|
|
|
|
|
|
returnValue = true;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_NORMAL:
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-10-03 01:55:45 +04:00
|
|
|
if (fFrontItem && fFrontItem->layerPtr == winBorder)
|
|
|
|
saveFloatingWindows(fFrontItem);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// remove B_MODAL_SUBSET windows present before this window.
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* itemThis = HasItem(winBorder);
|
|
|
|
ListData* toast;
|
|
|
|
ListData* item = itemThis->lowerItem;
|
|
|
|
while (item) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// if this modal subset is in our list ONLY (not in other visible normal window's one),
|
|
|
|
// then remove from Workspace's list.
|
2005-07-07 00:19:22 +04:00
|
|
|
if (item->layerPtr->Level() == B_MODAL_APP) {
|
|
|
|
if (winBorder->fSubWindowList.HasItem(item->layerPtr)) {
|
|
|
|
if (!searchFirstMainWindow(item->layerPtr)) {
|
2005-04-23 14:05:33 +04:00
|
|
|
// if this modal subset has front state, make sure another window will get that status.
|
|
|
|
if (fFrontItem == item)
|
|
|
|
changeFront = true;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
toast = item;
|
|
|
|
item = item->lowerItem;
|
2005-04-23 14:05:33 +04:00
|
|
|
RemoveItem(toast);
|
|
|
|
fPool.ReleaseMemory(toast);
|
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
} else if (!searchANormalWindow(item->layerPtr)
|
|
|
|
&& !(item->layerPtr->Workspaces() & (0x00000001 << fID))) {
|
2005-04-23 14:05:33 +04:00
|
|
|
// if this modal subset has front state, make sure another window will get that status.
|
|
|
|
if (fFrontItem == item)
|
|
|
|
changeFront = true;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
toast = item;
|
|
|
|
item = item->lowerItem;
|
2005-04-23 14:05:33 +04:00
|
|
|
RemoveItem(toast);
|
|
|
|
fPool.ReleaseMemory(toast);
|
2005-07-07 00:19:22 +04:00
|
|
|
} else
|
|
|
|
item = item->lowerItem;
|
|
|
|
} else
|
|
|
|
item = item->lowerItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
returnValue = true;
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_MODAL_APP:
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
// if a subset modal, then remove from Workspace's list.
|
2005-07-18 13:22:34 +04:00
|
|
|
if (winBorder->App()->fAppSubWindowList.HasItem(winBorder)) {
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* toast = HasItem(winBorder);
|
|
|
|
if (toast) {
|
2005-02-28 23:23:51 +03:00
|
|
|
RemoveItem(toast);
|
|
|
|
fPool.ReleaseMemory(toast);
|
|
|
|
|
|
|
|
returnValue = true;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
default:
|
2005-11-24 20:45:26 +03:00
|
|
|
debugger("HideWindowLayer: what kind of window is this?\n");
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// select a new Front if needed
|
2005-07-07 00:19:22 +04:00
|
|
|
if (changeFront) {
|
|
|
|
fFrontItem = NULL;
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* newFront = findNextFront();
|
2005-02-28 23:23:51 +03:00
|
|
|
if (newFront)
|
2005-07-07 00:19:22 +04:00
|
|
|
MoveToFront(newFront->layerPtr);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!HasItem(fFocusItem))
|
|
|
|
fFocusItem = NULL;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// floating windows can have focus state. what if this removed window is
|
|
|
|
// the focus window? There will be no focus anymore.
|
|
|
|
// So, start a search to set the new focus
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!fFocusItem || changeFocus) {
|
|
|
|
if (!HasItem(nextFocus))
|
|
|
|
nextFocus = NULL;
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (nextFocus == NULL) {
|
|
|
|
nextFocus = fBottomItem;
|
|
|
|
|
|
|
|
while (nextFocus) {
|
|
|
|
if (!nextFocus->layerPtr->IsHidden()
|
|
|
|
&& !(nextFocus->layerPtr->WindowFlags() & B_AVOID_FOCUS))
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
nextFocus = nextFocus->upperItem;
|
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
fFocusItem = nextFocus;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Shows a WindowLayer.
|
|
|
|
\param winBorder WindowLayer to be show.
|
|
|
|
\return True if the list of WindowLayers has changed, false otherwise.
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer \a winBorder will be shown. Other windows like floating or modal
|
2005-07-07 00:19:22 +04:00
|
|
|
ones will be placed in front if needed. Front & Focus state will be given to \a winBorder
|
|
|
|
unless a modal windows steals both.
|
2005-02-28 23:23:51 +03:00
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::ShowWindowLayer(WindowLayer *winBorder, bool userBusy)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-11-24 20:45:26 +03:00
|
|
|
STRACE(("W(%ld)::ShowWindowLayer(%s) \n", fID, winBorder? winBorder->Name(): "NULL"));
|
2005-07-07 00:19:22 +04:00
|
|
|
bool returnValue = false;
|
|
|
|
int32 level = winBorder->Level();
|
2005-02-28 23:23:51 +03:00
|
|
|
if (level > B_SYSTEM_FIRST)
|
|
|
|
level = B_SYSTEM_FIRST;
|
|
|
|
|
|
|
|
// Before you go understand this method, please note that 'placeInFront' MUST be
|
|
|
|
// called of EVERY window except B_FLOATING_APP when
|
|
|
|
// ADDING a new window to Workspace's list!!!
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
switch (level) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// B_MODAL_ALL, B_FLOATNG_ALL, B_SYSTEM_FIRST & B_SYSTEM_LAST
|
|
|
|
// will be removed ONLY when are deleted!
|
|
|
|
// ALSO, they will ALWAYS be the first/last windows in hierarchy, no matter
|
|
|
|
// if they are hidden or not - they keep their order.
|
|
|
|
|
|
|
|
case B_MODAL_ALL:
|
|
|
|
case B_SYSTEM_FIRST:
|
|
|
|
case B_SYSTEM_LAST:
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
// nothing special to be done. just compare indexes to see if front state will change.
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFrontItem) {
|
|
|
|
int32 reverseIndexThis, reverseIndexFront;
|
|
|
|
ListData* itemThis = HasItem(winBorder, &reverseIndexThis);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
HasItem(fFrontItem->layerPtr, &reverseIndexFront);
|
|
|
|
|
|
|
|
if (reverseIndexThis < reverseIndexFront) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fFrontItem->layerPtr->Level() == B_NORMAL)
|
|
|
|
saveFloatingWindows(fFrontItem);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
fFrontItem = itemThis;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
|
|
|
// of course, if there is no front item, then set this one.
|
2005-02-28 23:23:51 +03:00
|
|
|
fFrontItem = HasItem(winBorder);
|
|
|
|
}
|
|
|
|
returnValue = true;
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_FLOATING_ALL:
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
// simply relocate. A floating window can't have front state.
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* itemThis = HasItem(winBorder);
|
2005-02-28 23:23:51 +03:00
|
|
|
RemoveItem(itemThis);
|
|
|
|
placeInFront(itemThis, userBusy);
|
|
|
|
|
|
|
|
returnValue = true;
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
// FLOATING windows are always removed from Workspace's list when changing to a new front window.
|
|
|
|
|
|
|
|
case B_FLOATING_APP:
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
// see if we have a front window which is a B_NORMAL window and who's list of floating
|
|
|
|
// and modal windows contains our window.
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFrontItem && fFrontItem->layerPtr->Level() == B_NORMAL) {
|
2005-03-17 20:36:30 +03:00
|
|
|
// if this winBorder is the focus it is already the first among floating app windows.
|
|
|
|
if (fFocusItem && fFocusItem->layerPtr == winBorder)
|
|
|
|
break;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* itemThis = NULL;
|
2005-02-28 23:23:51 +03:00
|
|
|
// remove from B_NORMAL's list.
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFrontItem->layerPtr->fSubWindowList.RemoveItem(winBorder)) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// we need to add this window
|
2005-07-07 00:19:22 +04:00
|
|
|
itemThis = fPool.GetCleanMemory(winBorder);
|
|
|
|
} else {
|
|
|
|
itemThis = HasItem(winBorder);
|
2005-02-28 23:23:51 +03:00
|
|
|
// window is already in Workspace's list. Find and temporarly remove.
|
|
|
|
if (itemThis)
|
|
|
|
RemoveItem(itemThis);
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (itemThis) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// insert in front of other B_FLOATING_APP windows.
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* item = fFrontItem->lowerItem;
|
|
|
|
while (item && item->layerPtr->Level() == B_FLOATING_APP)
|
2005-02-28 23:23:51 +03:00
|
|
|
item = item->lowerItem;
|
|
|
|
|
|
|
|
InsertItem(itemThis, item);
|
|
|
|
|
|
|
|
returnValue = true;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_NORMAL:
|
2004-01-12 01:12:55 +03:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* itemThis = HasItem(winBorder);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!itemThis) {
|
2005-11-24 20:45:26 +03:00
|
|
|
debugger("ShowWindowLayer: B_NORMAL window - cannot find specified window in workspace's list\n");
|
2005-02-28 23:23:51 +03:00
|
|
|
return false;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// front status will change. if a normal window has front state,
|
|
|
|
// remove and save floating windows order that may be above it.
|
|
|
|
if (fFrontItem && fFrontItem->layerPtr->Level() == B_NORMAL)
|
|
|
|
saveFloatingWindows(fFrontItem);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
RemoveItem(itemThis);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
placeInFront(itemThis, userBusy);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* newFront = itemThis;
|
2004-01-13 04:03:29 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (windowHasVisibleModals(winBorder))
|
|
|
|
newFront = putModalsInFront(itemThis);
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFrontItem) {
|
|
|
|
if (!userBusy) {
|
|
|
|
int32 revFrontItemIndex, revNewFrontIndex;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
HasItem(fFrontItem, &revFrontItemIndex);
|
|
|
|
HasItem(newFront, &revNewFrontIndex);
|
|
|
|
if (revNewFrontIndex < revFrontItemIndex)
|
|
|
|
fFrontItem = newFront;
|
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
2005-02-28 23:23:51 +03:00
|
|
|
fFrontItem = newFront;
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fFrontItem->layerPtr->Level() == B_NORMAL)
|
|
|
|
putFloatingInFront(fFrontItem);
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
returnValue = true;
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
2004-01-17 19:33:22 +03:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
// MODAL windows usualy stay in Workspace's list, but they are scatered, so we must gather them
|
|
|
|
// when needed.
|
|
|
|
|
|
|
|
case B_MODAL_APP:
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
// build a list of modal windows to know what windows should be placed before this one.
|
2005-07-07 00:19:22 +04:00
|
|
|
BList tempList;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// APP modal
|
2005-07-07 00:19:22 +04:00
|
|
|
if (winBorder->App()->fAppSubWindowList.HasItem(winBorder)) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// take only application's modals
|
2005-06-17 20:34:22 +04:00
|
|
|
tempList.AddList(&winBorder->App()->fAppSubWindowList);
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fFrontItem
|
2005-06-23 21:40:35 +04:00
|
|
|
&& fFrontItem->layerPtr->App()->ClientTeam() == winBorder->App()->ClientTeam())
|
2005-02-28 23:23:51 +03:00
|
|
|
userBusy = false;
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
|
|
|
// SUBSET modal
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer *mainWindow = searchFirstMainWindow(winBorder);
|
2005-07-07 00:19:22 +04:00
|
|
|
if (mainWindow) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// add both mainWindow's subset modals and application's modals
|
2005-06-17 20:34:22 +04:00
|
|
|
tempList.AddList(&mainWindow->fSubWindowList);
|
|
|
|
tempList.AddList(&winBorder->App()->fAppSubWindowList);
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fFrontItem && fFrontItem->layerPtr == mainWindow)
|
|
|
|
userBusy = false;
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
2005-03-13 20:07:40 +03:00
|
|
|
// none of the unhiden normal windows havs this window as part of its subset.
|
2005-02-28 23:23:51 +03:00
|
|
|
// as a result this window won't be added to Workspace's list for it to be shown.
|
|
|
|
return false;
|
2004-01-17 19:33:22 +03:00
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// === list ready ===
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// front status will change. if a normal window has front state,
|
|
|
|
// remove and save floating windows order that may be above it.
|
|
|
|
if (fFrontItem && fFrontItem->layerPtr->Level() == B_NORMAL)
|
|
|
|
saveFloatingWindows(fFrontItem);
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
// find and remove the Workspace's entry for this WindowLayer.
|
2005-02-28 23:23:51 +03:00
|
|
|
ListData *itemThis;
|
|
|
|
itemThis = HasItem(winBorder);
|
2005-07-07 00:19:22 +04:00
|
|
|
if (itemThis) {
|
2005-02-28 23:23:51 +03:00
|
|
|
RemoveItem(itemThis);
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
2005-02-28 23:23:51 +03:00
|
|
|
// not found? no problem. create a new entry.
|
|
|
|
itemThis = fPool.GetCleanMemory(winBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
placeInFront(itemThis, userBusy);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// now place other modals windows above
|
|
|
|
int32 revIndexThis, revIndexItem;
|
|
|
|
ListData *newFront = itemThis;
|
|
|
|
|
|
|
|
// find the index of this window in Workspace's list. It will be used to place higher
|
|
|
|
// indexed windows above, if it's the case.
|
|
|
|
HasItem(itemThis, &revIndexThis);
|
|
|
|
|
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* before = itemThis->lowerItem;
|
|
|
|
int32 i, count;
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer** wbList;
|
2005-07-07 00:19:22 +04:00
|
|
|
ListData* itemX;
|
|
|
|
int32 indexThisInTempList;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
indexThisInTempList = tempList.IndexOf(winBorder);
|
|
|
|
if (indexThisInTempList < 0)
|
2005-11-24 20:45:26 +03:00
|
|
|
debugger("ShowWindowLayer: modal window: design flaw!!!\n");
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
count = tempList.CountItems();
|
2005-11-24 20:45:26 +03:00
|
|
|
wbList = (WindowLayer**)tempList.Items();
|
2005-07-07 00:19:22 +04:00
|
|
|
for (i = indexThisInTempList; i < count; i++) {
|
|
|
|
if (!wbList[i]->IsHidden()) {
|
|
|
|
itemX = HasItem(wbList[i], &revIndexItem);
|
|
|
|
if (itemX && revIndexItem > revIndexThis) {
|
2005-02-28 23:23:51 +03:00
|
|
|
removeAndPlaceBefore(itemX, before);
|
2005-07-07 00:19:22 +04:00
|
|
|
newFront = itemX;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (fFrontItem) {
|
|
|
|
if (!userBusy) {
|
|
|
|
int32 revFrontItemIndex, revNewFrontIndex;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
HasItem(fFrontItem, &revFrontItemIndex);
|
|
|
|
HasItem(newFront, &revNewFrontIndex);
|
|
|
|
if (revNewFrontIndex < revFrontItemIndex)
|
|
|
|
fFrontItem = newFront;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fFrontItem->layerPtr->Level() == B_NORMAL)
|
|
|
|
putFloatingInFront(fFrontItem);
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
2005-02-28 23:23:51 +03:00
|
|
|
fFrontItem = newFront;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
returnValue = true;
|
2005-07-07 00:19:22 +04:00
|
|
|
break;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
default:
|
|
|
|
debugger("What kind of window is this???\n");
|
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (!HasItem(fFocusItem))
|
|
|
|
fFocusItem = NULL;
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// set new Focus if needed
|
2005-07-07 00:19:22 +04:00
|
|
|
if (Focus() == NULL) {
|
|
|
|
ListData* cursor = fBottomItem;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
fFocusItem = NULL;
|
|
|
|
while (cursor != NULL && fFocusItem == NULL) {
|
|
|
|
if (!cursor->layerPtr->IsHidden()
|
|
|
|
&& !(cursor->layerPtr->WindowFlags() & B_AVOID_FOCUS)) {
|
|
|
|
if (cursor->layerPtr->Level() == B_FLOATING_APP
|
|
|
|
|| cursor->layerPtr->Level() == B_FLOATING_ALL) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// set focus to floating windows only if directly targeted
|
2005-07-07 00:19:22 +04:00
|
|
|
if (cursor->layerPtr == winBorder) {
|
2005-02-28 23:23:51 +03:00
|
|
|
fFocusItem = cursor;
|
2005-07-07 00:19:22 +04:00
|
|
|
} else
|
2005-02-28 23:23:51 +03:00
|
|
|
cursor = cursor->upperItem;
|
2005-07-07 00:19:22 +04:00
|
|
|
} else
|
2005-02-28 23:23:51 +03:00
|
|
|
fFocusItem = cursor;
|
2005-07-07 00:19:22 +04:00
|
|
|
} else
|
2005-02-28 23:23:51 +03:00
|
|
|
cursor = cursor->upperItem;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
return returnValue;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
status_t
|
|
|
|
Workspace::SetDisplayMode(const display_mode &mode)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-10-08 20:44:28 +04:00
|
|
|
fDisplayMode = mode;
|
|
|
|
return B_OK;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
status_t
|
|
|
|
Workspace::GetDisplayMode(display_mode &mode) const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-10-08 20:44:28 +04:00
|
|
|
mode = fDisplayMode;
|
|
|
|
return B_OK;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
void
|
|
|
|
Workspace::SetBGColor(const RGBColor &c)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
|
|
|
fBGColor = c;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
RGBColor
|
|
|
|
Workspace::BGColor(void) const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fBGColor;
|
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
/*!
|
|
|
|
\brief Retrieves settings from a container message passed to PutSettings
|
|
|
|
\param A BMessage containing data from a PutSettings() call
|
|
|
|
|
|
|
|
This function will place default values whenever a particular setting cannot
|
|
|
|
be found.
|
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
void
|
|
|
|
Workspace::GetSettings(const BMessage &msg)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-06-07 05:29:12 +04:00
|
|
|
BMessage container;
|
|
|
|
rgb_color *color;
|
|
|
|
ssize_t size;
|
|
|
|
|
|
|
|
char fieldname[4];
|
|
|
|
sprintf(fieldname,"%d",(uint8)fID);
|
|
|
|
|
|
|
|
// First, find the container message corresponding to the workspace's index
|
|
|
|
if(msg.FindMessage(fieldname,&container)!=B_OK)
|
|
|
|
{
|
|
|
|
GetDefaultSettings();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
if(container.FindInt32("timing_pixel_clock",(int32*)&fDisplayMode.timing.pixel_clock) != B_OK)
|
|
|
|
fDisplayMode.timing.pixel_clock=25175;
|
|
|
|
if(container.FindInt16("timing_h_display",(int16*)&fDisplayMode.timing.h_display)!=B_OK)
|
|
|
|
fDisplayMode.timing.h_display=640;
|
|
|
|
if(container.FindInt16("timing_h_sync_start",(int16*)&fDisplayMode.timing.h_sync_start)!=B_OK)
|
|
|
|
fDisplayMode.timing.h_sync_start=656;
|
|
|
|
if(container.FindInt16("timing_h_sync_end",(int16*)&fDisplayMode.timing.h_sync_end)!=B_OK)
|
|
|
|
fDisplayMode.timing.h_sync_end=752;
|
|
|
|
if(container.FindInt16("timing_h_total",(int16*)&fDisplayMode.timing.h_total)!=B_OK)
|
|
|
|
fDisplayMode.timing.h_total=800;
|
|
|
|
if(container.FindInt16("timing_v_display",(int16*)&fDisplayMode.timing.v_display)!=B_OK)
|
|
|
|
fDisplayMode.timing.v_display=480;
|
|
|
|
if(container.FindInt16("timing_v_sync_start",(int16*)&fDisplayMode.timing.v_sync_start)!=B_OK)
|
|
|
|
fDisplayMode.timing.v_sync_start=490;
|
|
|
|
if(container.FindInt16("timing_v_sync_end",(int16*)&fDisplayMode.timing.v_sync_end)!=B_OK)
|
|
|
|
fDisplayMode.timing.v_sync_end=492;
|
|
|
|
if(container.FindInt16("timing_v_total",(int16*)&fDisplayMode.timing.v_total)!=B_OK)
|
|
|
|
fDisplayMode.timing.v_total=525;
|
|
|
|
if(container.FindInt32("timing_flags",(int32*)&fDisplayMode.timing.flags)!=B_OK)
|
|
|
|
fDisplayMode.timing.flags=0;
|
2005-06-07 05:29:12 +04:00
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
if(container.FindInt32("color_space", (int32*)&fDisplayMode.space) != B_OK)
|
|
|
|
fDisplayMode.space = B_CMAP8;
|
2005-06-07 05:29:12 +04:00
|
|
|
|
|
|
|
if(container.FindData("bgcolor",B_RGB_COLOR_TYPE,(const void **)&color,&size)==B_OK)
|
|
|
|
fBGColor.SetColor(*color);
|
|
|
|
else
|
|
|
|
fBGColor.SetColor(0,0,0);
|
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
if(container.FindInt16("virtual_width", (int16 *)&fDisplayMode.virtual_width) != B_OK)
|
|
|
|
fDisplayMode.virtual_width = 640;
|
|
|
|
if(container.FindInt16("virtual_height", (int16 *)&fDisplayMode.virtual_height) != B_OK)
|
|
|
|
fDisplayMode.virtual_height = 480;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
//! Sets workspace settings to defaults
|
|
|
|
void Workspace::GetDefaultSettings(void)
|
|
|
|
{
|
2005-06-07 05:29:12 +04:00
|
|
|
fBGColor.SetColor(0,0,0);
|
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
fDisplayMode.timing.pixel_clock = 25175;
|
|
|
|
fDisplayMode.timing.h_display = 640;
|
|
|
|
fDisplayMode.timing.h_sync_start = 656;
|
|
|
|
fDisplayMode.timing.h_sync_end = 752;
|
|
|
|
fDisplayMode.timing.h_total = 800;
|
|
|
|
fDisplayMode.timing.v_display = 480;
|
|
|
|
fDisplayMode.timing.v_sync_start = 490;
|
|
|
|
fDisplayMode.timing.v_sync_end = 492;
|
|
|
|
fDisplayMode.timing.v_total = 525;
|
|
|
|
fDisplayMode.timing.flags = 0;
|
|
|
|
fDisplayMode.space = B_CMAP8;
|
2005-06-07 05:29:12 +04:00
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
fDisplayMode.virtual_width = 640;
|
|
|
|
fDisplayMode.virtual_height = 480;
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*!
|
|
|
|
\brief Places the screen settings for the workspace in the passed BMessage
|
|
|
|
\param msg BMessage pointer to receive the settings
|
|
|
|
\param index The index number of the workspace in the desktop
|
|
|
|
|
|
|
|
This function will fail if passed a NULL pointer. The settings for the workspace are
|
2005-06-07 05:29:12 +04:00
|
|
|
saved in a BMessage in a BMessage.
|
|
|
|
|
|
|
|
The message itself is placed in a field string based on its index - "1", "2", etc.
|
2004-06-26 06:15:48 +04:00
|
|
|
|
|
|
|
The format is as follows:
|
2005-06-07 05:29:12 +04:00
|
|
|
display_timing "timing_XXX" -> fDisplayTiming members (see Accelerant.h)
|
2004-06-26 06:15:48 +04:00
|
|
|
uint32 "color_space" -> color space of the workspace
|
|
|
|
rgb_color "bgcolor" -> background color of the workspace
|
|
|
|
int16 "virtual_width" -> virtual width of the workspace
|
|
|
|
int16 "virtual_height" -> virtual height of the workspace
|
|
|
|
*/
|
2005-06-07 05:29:12 +04:00
|
|
|
void Workspace::PutSettings(BMessage *msg, const uint8 &index) const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-06-07 05:29:12 +04:00
|
|
|
if(!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BMessage container;
|
|
|
|
rgb_color color=fBGColor.GetColor32();
|
|
|
|
|
|
|
|
// a little longer than we need in case someone tries to pass index=255 or something
|
|
|
|
char fieldname[4];
|
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
container.AddInt32("timing_pixel_clock",fDisplayMode.timing.pixel_clock);
|
|
|
|
container.AddInt16("timing_h_display",fDisplayMode.timing.h_display);
|
|
|
|
container.AddInt16("timing_h_sync_start",fDisplayMode.timing.h_sync_start);
|
|
|
|
container.AddInt16("timing_h_sync_end",fDisplayMode.timing.h_sync_end);
|
|
|
|
container.AddInt16("timing_h_total",fDisplayMode.timing.h_total);
|
|
|
|
container.AddInt16("timing_v_display",fDisplayMode.timing.v_display);
|
|
|
|
container.AddInt16("timing_v_sync_start",fDisplayMode.timing.v_sync_start);
|
|
|
|
container.AddInt16("timing_v_sync_end",fDisplayMode.timing.v_sync_end);
|
|
|
|
container.AddInt16("timing_v_total",fDisplayMode.timing.v_total);
|
|
|
|
container.AddInt32("timing_flags",fDisplayMode.timing.flags);
|
2005-06-07 05:29:12 +04:00
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
container.AddInt32("color_space", fDisplayMode.space);
|
|
|
|
container.AddData("bgcolor", B_RGB_COLOR_TYPE, &color, sizeof(rgb_color));
|
2005-06-07 05:29:12 +04:00
|
|
|
|
2005-10-08 20:44:28 +04:00
|
|
|
container.AddInt16("virtual_width", fDisplayMode.virtual_width);
|
|
|
|
container.AddInt16("virtual_height", fDisplayMode.virtual_height);
|
2005-06-07 05:29:12 +04:00
|
|
|
|
|
|
|
sprintf(fieldname,"%d",index);
|
|
|
|
|
|
|
|
// Just in case...
|
|
|
|
msg->RemoveName(fieldname);
|
|
|
|
|
|
|
|
msg->AddMessage(fieldname,&container);
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2004-06-26 06:15:48 +04:00
|
|
|
/*!
|
|
|
|
\brief Places default settings for the workspace in the passed BMessage
|
|
|
|
\param msg BMessage pointer to receive the settings
|
|
|
|
\param index The index number of the workspace in the desktop
|
|
|
|
*/
|
2005-06-07 05:29:12 +04:00
|
|
|
void Workspace::PutDefaultSettings(BMessage *msg, const uint8 &index)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-06-07 05:29:12 +04:00
|
|
|
if(!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BMessage container;
|
|
|
|
rgb_color color={ 0,0,0,255 };
|
|
|
|
|
|
|
|
// a little longer than we need in case someone tries to pass index=255 or something
|
|
|
|
char fieldname[4];
|
|
|
|
|
|
|
|
// These default settings the same ones as found in ~/config/settings/
|
|
|
|
// app_server_settings on R5
|
|
|
|
|
|
|
|
container.AddInt32("timing_pixel_clock",25175);
|
|
|
|
container.AddInt16("timing_h_display",640);
|
|
|
|
container.AddInt16("timing_h_sync_start",656);
|
|
|
|
container.AddInt16("timing_h_sync_end",752);
|
|
|
|
container.AddInt16("timing_h_total",800);
|
|
|
|
container.AddInt16("timing_v_display",480);
|
|
|
|
container.AddInt16("timing_v_sync_start",490);
|
|
|
|
container.AddInt16("timing_v_sync_end",492);
|
|
|
|
container.AddInt16("timing_v_total",525);
|
|
|
|
container.AddInt32("timing_flags",0);
|
|
|
|
|
|
|
|
container.AddInt32("color_space",B_CMAP8);
|
|
|
|
container.AddData("bgcolor",B_RGB_COLOR_TYPE,&color,sizeof(rgb_color));
|
|
|
|
|
|
|
|
container.AddInt16("virtual_width",640);
|
|
|
|
container.AddInt16("virtual_height",480);
|
|
|
|
|
|
|
|
sprintf(fieldname,"%d",index);
|
|
|
|
|
|
|
|
// Just in case...
|
|
|
|
msg->RemoveName(fieldname);
|
|
|
|
|
2005-06-23 22:48:10 +04:00
|
|
|
msg->AddMessage(fieldname, &container);
|
2004-06-26 06:15:48 +04:00
|
|
|
}
|
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Debug method
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
Workspace::PrintToStream() const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
printf("Workspace %ld hierarchy shown from back to front:\n", fID);
|
2004-06-26 06:15:48 +04:00
|
|
|
for (ListData *item = fTopItem; item != NULL; item = item->lowerItem)
|
|
|
|
{
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer *wb = (WindowLayer*)item->layerPtr;
|
2005-06-23 22:48:10 +04:00
|
|
|
printf("\tName: %s\t%s", wb->Name(), wb->IsHidden()?"Hidden\t": "Visible\t");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_FLOATING_APP_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_FLOATING_APP_WINDOW_FEEL");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_FLOATING_ALL_WINDOW_FEEL");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_MODAL_SUBSET_WINDOW_FEEL");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_MODAL_APP_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_MODAL_APP_WINDOW_FEEL");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_MODAL_ALL_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_MODAL_ALL_WINDOW_FEEL");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_NORMAL_WINDOW_FEEL)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_NORMAL_WINDOW_FEEL");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() == B_SYSTEM_LAST)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_SYSTEM_LAST");
|
2005-04-16 17:30:49 +04:00
|
|
|
if(wb->Feel() >= B_SYSTEM_FIRST)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", "B_SYSTEM_FIRST");
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2005-06-23 22:48:10 +04:00
|
|
|
printf("Focus Layer:\t%s\n", fFocusItem? fFocusItem->layerPtr->Name(): "NULL");
|
|
|
|
printf("Front Layer:\t%s\n\n", fFrontItem? fFrontItem->layerPtr->Name(): "NULL");
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
Workspace::PrintItem(ListData *item) const
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2004-01-13 04:03:29 +03:00
|
|
|
printf("ListData members:\n");
|
2004-06-26 06:15:48 +04:00
|
|
|
if(item)
|
|
|
|
{
|
2005-11-24 20:45:26 +03:00
|
|
|
printf("WindowLayer:\t%s\n", item->layerPtr? item->layerPtr->Name(): "NULL");
|
2005-06-23 22:48:10 +04:00
|
|
|
printf("UpperItem:\t%s\n", item->upperItem? item->upperItem->layerPtr->Name(): "NULL");
|
|
|
|
printf("LowerItem:\t%s\n", item->lowerItem? item->lowerItem->layerPtr->Name(): "NULL");
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("NULL item\n");
|
2004-01-13 04:03:29 +03:00
|
|
|
}
|
|
|
|
}
|
2004-07-10 14:54:20 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// PRIVATE
|
|
|
|
//----------------------------------------------------------------------------------
|
2005-02-28 23:23:51 +03:00
|
|
|
/*
|
|
|
|
Insert item in the top-bottom direction.
|
|
|
|
*/
|
2005-06-23 21:40:35 +04:00
|
|
|
void
|
|
|
|
Workspace::InsertItem(ListData *item, ListData *before)
|
2004-07-10 14:54:20 +04:00
|
|
|
{
|
|
|
|
// insert before one other item;
|
2005-06-23 21:40:35 +04:00
|
|
|
if (before) {
|
|
|
|
if (before->upperItem)
|
|
|
|
before->upperItem->lowerItem = item;
|
|
|
|
|
|
|
|
item->upperItem = before->upperItem;
|
|
|
|
item->lowerItem = before;
|
|
|
|
before->upperItem = item;
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (fTopItem == before)
|
2004-07-10 14:54:20 +04:00
|
|
|
fTopItem = item;
|
2005-06-23 21:40:35 +04:00
|
|
|
} else {
|
2005-02-28 23:23:51 +03:00
|
|
|
// insert item at the end.
|
2005-06-23 21:40:35 +04:00
|
|
|
item->upperItem = fBottomItem;
|
|
|
|
if (fBottomItem)
|
2005-02-28 23:23:51 +03:00
|
|
|
fBottomItem->lowerItem = item;
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
fBottomItem = item;
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (!fTopItem)
|
|
|
|
fTopItem = item;
|
2004-07-10 14:54:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
void
|
|
|
|
Workspace::RemoveItem(ListData *item)
|
2004-07-10 14:54:20 +04:00
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
if (!item)
|
2004-07-10 14:54:20 +04:00
|
|
|
return;
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (fBottomItem == item)
|
2004-07-10 14:54:20 +04:00
|
|
|
fBottomItem = item->upperItem;
|
|
|
|
else
|
|
|
|
item->lowerItem->upperItem = item->upperItem;
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (fTopItem == item)
|
2004-07-10 14:54:20 +04:00
|
|
|
fTopItem = item->lowerItem;
|
|
|
|
else
|
|
|
|
item->upperItem->lowerItem = item->lowerItem;
|
|
|
|
|
|
|
|
// set all these to NULL to avoid confusion later.
|
|
|
|
|
|
|
|
item->upperItem = NULL;
|
|
|
|
item->lowerItem = NULL;
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (fFocusItem == item)
|
2004-07-10 14:54:20 +04:00
|
|
|
fFocusItem = NULL;
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (fFrontItem == item)
|
2004-07-10 14:54:20 +04:00
|
|
|
fFrontItem = NULL;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
ListData*
|
|
|
|
Workspace::HasItem(const ListData *item, int32 *index) const
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
int32 idx = 0;
|
|
|
|
ListData* itemX;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
for (itemX = fBottomItem; itemX != NULL; itemX = itemX->upperItem) {
|
|
|
|
if (item == itemX)
|
2005-02-28 23:23:51 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index && itemX)
|
|
|
|
*index = idx;
|
|
|
|
|
|
|
|
return itemX;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
ListData*
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::HasItem(const WindowLayer *layer, int32 *index) const
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-07-07 00:19:22 +04:00
|
|
|
int32 idx = 0;
|
|
|
|
ListData* itemX;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
for (itemX = fBottomItem; itemX != NULL; itemX = itemX->upperItem) {
|
|
|
|
if (layer == itemX->layerPtr)
|
2005-02-28 23:23:51 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index && itemX)
|
|
|
|
*index = idx;
|
|
|
|
|
|
|
|
return itemX;
|
|
|
|
}
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the index of the specified item starting from the back-most window.
|
|
|
|
*/
|
2005-06-23 21:40:35 +04:00
|
|
|
int32
|
|
|
|
Workspace::IndexOf(const ListData *item) const
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
if (!item)
|
|
|
|
return -1;
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
int32 index = 0;
|
|
|
|
for (ListData *itemX = fTopItem; itemX != NULL; itemX = itemX->lowerItem) {
|
|
|
|
if (itemX->layerPtr == item->layerPtr)
|
2005-02-28 23:23:51 +03:00
|
|
|
return index;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
|
|
|
|
inline bool
|
|
|
|
Workspace::placeToBack(ListData *newLast)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
int32 level = newLast->layerPtr->Level();
|
|
|
|
ListData* cursor = newLast->upperItem;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
switch (level) {
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_FLOATING_ALL:
|
|
|
|
case B_FLOATING_APP:
|
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
int32 count = 0;
|
|
|
|
while (cursor && cursor->layerPtr->Level() == level) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (!cursor->layerPtr->IsHidden())
|
|
|
|
count++;
|
2005-06-23 21:40:35 +04:00
|
|
|
cursor = cursor->upperItem;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// we're already the last floating window
|
|
|
|
if (count == 0)
|
|
|
|
return false;
|
2005-06-23 21:40:35 +04:00
|
|
|
else {
|
|
|
|
bool changeFocus = false;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
if (fFocusItem == newLast)
|
|
|
|
changeFocus = true;
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (changeFocus) {
|
|
|
|
ListData* cursor = newLast->upperItem;
|
|
|
|
while (cursor
|
|
|
|
&& (cursor->layerPtr->IsHidden()
|
|
|
|
|| cursor->layerPtr->WindowFlags() & B_AVOID_FOCUS)
|
|
|
|
&& cursor->layerPtr->Level() == level) {
|
2005-02-28 23:23:51 +03:00
|
|
|
cursor = cursor->upperItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
// give focus only if a unhidden floating window could be selected
|
|
|
|
// otherwise this('newLast') window keeps focus
|
|
|
|
if (cursor->layerPtr->Level() == level)
|
|
|
|
fFocusItem = cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveItem(newLast);
|
2005-07-07 00:19:22 +04:00
|
|
|
InsertItem(newLast, cursor ? cursor->lowerItem : fTopItem);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2005-06-23 21:40:35 +04:00
|
|
|
break;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
case B_NORMAL:
|
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
int32 count = 0;
|
|
|
|
int32 cursorLevel;
|
|
|
|
while (cursor) {
|
2005-02-28 23:23:51 +03:00
|
|
|
cursorLevel = cursor->layerPtr->Level();
|
|
|
|
if (cursorLevel == B_MODAL_APP)
|
|
|
|
cursorLevel = B_NORMAL;
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
if (cursorLevel < level) {
|
2005-02-28 23:23:51 +03:00
|
|
|
break;
|
2005-06-23 21:40:35 +04:00
|
|
|
} else {
|
2005-02-28 23:23:51 +03:00
|
|
|
count++;
|
|
|
|
cursor = cursor->upperItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// we're already the last normal window
|
|
|
|
if (count == 0)
|
|
|
|
return false;
|
2005-06-23 21:40:35 +04:00
|
|
|
else {
|
2005-02-28 23:23:51 +03:00
|
|
|
RemoveItem(newLast);
|
2005-07-07 00:19:22 +04:00
|
|
|
InsertItem(newLast, cursor ? cursor->lowerItem : fTopItem);
|
2005-02-28 23:23:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
2005-06-23 21:40:35 +04:00
|
|
|
break;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
}
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Based on it's WindowLayer type, places this item in front as it is possible.
|
2005-02-28 23:23:51 +03:00
|
|
|
*/
|
2005-06-23 21:40:35 +04:00
|
|
|
void
|
|
|
|
Workspace::placeInFront(ListData *item, const bool userBusy)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
int32 level = item->layerPtr->Level();
|
|
|
|
ListData* cursor = fBottomItem;
|
|
|
|
int32 cursorLevel;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
// make MODAL windows act just like normal ones.
|
|
|
|
if (level == B_MODAL_APP)
|
|
|
|
level = B_NORMAL;
|
|
|
|
|
|
|
|
// B_SYSTEM_LAST - always place (the most) last
|
2005-07-07 00:19:22 +04:00
|
|
|
if (level == B_SYSTEM_LAST) {
|
2005-02-28 23:23:51 +03:00
|
|
|
InsertItem(item, fTopItem);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// search for the exact place...
|
2005-07-07 00:19:22 +04:00
|
|
|
while (cursor) {
|
|
|
|
cursorLevel = cursor->layerPtr->Level();
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
// make MODAL windows act just like normal ones.
|
|
|
|
if (cursorLevel == B_MODAL_APP)
|
|
|
|
cursorLevel = B_NORMAL;
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (level < cursorLevel) {
|
2005-02-28 23:23:51 +03:00
|
|
|
cursor = cursor->upperItem;
|
|
|
|
continue;
|
2005-07-07 00:19:22 +04:00
|
|
|
} else {
|
2005-02-28 23:23:51 +03:00
|
|
|
// that's it, we've found the proper place.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
if (cursor) {
|
2005-02-28 23:23:51 +03:00
|
|
|
// if user is busy typing something, or has an opened menu...
|
|
|
|
if (userBusy && cursor == fFrontItem)
|
|
|
|
InsertItem(item, cursor);
|
|
|
|
else
|
|
|
|
InsertItem(item, cursor->lowerItem);
|
2005-07-07 00:19:22 +04:00
|
|
|
} else
|
2005-02-28 23:23:51 +03:00
|
|
|
InsertItem(item, fTopItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
inline bool
|
|
|
|
Workspace::removeAndPlaceBefore(ListData *item, ListData *beforeItem)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
if (item && item != beforeItem) {
|
2005-02-28 23:23:51 +03:00
|
|
|
RemoveItem(item);
|
|
|
|
// insert into proper place.
|
|
|
|
InsertItem(item, beforeItem);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2005-11-24 20:45:26 +03:00
|
|
|
\brief Insert the specified WindowLayer before given item. First search the
|
|
|
|
specified WindowLayer in Workspace's list an remove it.
|
2005-02-28 23:23:51 +03:00
|
|
|
\resolution: private
|
|
|
|
*/
|
2005-06-23 21:40:35 +04:00
|
|
|
inline bool
|
2005-11-24 20:45:26 +03:00
|
|
|
Workspace::removeAndPlaceBefore(const WindowLayer *wb, ListData *beforeItem)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
return removeAndPlaceBefore(HasItem(wb), beforeItem);
|
|
|
|
}
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
inline WindowLayer*
|
|
|
|
Workspace::searchANormalWindow(WindowLayer *wb) const
|
2005-04-23 14:05:33 +04:00
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
ListData* listItem = fBottomItem;
|
|
|
|
while (listItem) {
|
2005-04-23 14:05:33 +04:00
|
|
|
if (listItem->layerPtr->Level() == B_NORMAL && !listItem->layerPtr->IsHidden()
|
2005-06-23 21:40:35 +04:00
|
|
|
&& listItem->layerPtr->App()->ClientTeam() == wb->App()->ClientTeam())
|
|
|
|
return listItem->layerPtr;
|
2005-04-23 14:05:33 +04:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
listItem = listItem->upperItem;
|
2005-04-23 14:05:33 +04:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
inline WindowLayer*
|
|
|
|
Workspace::searchFirstMainWindow(WindowLayer *wb) const
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
ListData* listItem = fBottomItem;
|
|
|
|
while (listItem) {
|
2005-02-28 23:23:51 +03:00
|
|
|
if (listItem->layerPtr->Level() == B_NORMAL && !listItem->layerPtr->IsHidden()
|
2005-06-23 21:40:35 +04:00
|
|
|
&& listItem->layerPtr->App()->ClientTeam() == wb->App()->ClientTeam()
|
2005-06-17 20:34:22 +04:00
|
|
|
&& listItem->layerPtr->fSubWindowList.HasItem(wb))
|
2005-06-23 21:40:35 +04:00
|
|
|
return listItem->layerPtr;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
listItem = listItem->upperItem;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
inline
|
2005-11-24 20:45:26 +03:00
|
|
|
bool Workspace::windowHasVisibleModals(const WindowLayer *winBorder) const
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
int32 i, count;
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer **wbList;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
// check window's list
|
2005-06-17 20:34:22 +04:00
|
|
|
count = winBorder->fSubWindowList.CountItems();
|
2005-11-24 20:45:26 +03:00
|
|
|
wbList = (WindowLayer**)winBorder->fSubWindowList.Items();
|
2005-02-28 23:23:51 +03:00
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (wbList[i]->Level() == B_MODAL_APP && !wbList[i]->IsHidden())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// application's list only has modal windows.
|
2005-06-17 20:34:22 +04:00
|
|
|
count = winBorder->App()->fAppSubWindowList.CountItems();
|
2005-11-24 20:45:26 +03:00
|
|
|
wbList = (WindowLayer**)winBorder->App()->fAppSubWindowList.Items();
|
2005-02-28 23:23:51 +03:00
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (!wbList[i]->IsHidden())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
inline
|
|
|
|
ListData* Workspace::putModalsInFront(ListData *item)
|
|
|
|
{
|
|
|
|
int32 i, count, revIndex, revIndexItem;
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer **wbList;
|
2005-02-28 23:23:51 +03:00
|
|
|
ListData *itemX;
|
|
|
|
ListData *lastPlaced = NULL;
|
|
|
|
ListData *before = item->lowerItem;
|
|
|
|
|
|
|
|
HasItem(item, &revIndex);
|
|
|
|
|
|
|
|
// check window's list
|
2005-06-17 20:34:22 +04:00
|
|
|
count = item->layerPtr->fSubWindowList.CountItems();
|
2005-11-24 20:45:26 +03:00
|
|
|
wbList = (WindowLayer**)item->layerPtr->fSubWindowList.Items();
|
2005-02-28 23:23:51 +03:00
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (wbList[i]->Level() == B_MODAL_APP && !wbList[i]->IsHidden())
|
|
|
|
{
|
|
|
|
itemX = HasItem(wbList[i], &revIndexItem);
|
|
|
|
if (!itemX)
|
|
|
|
{
|
|
|
|
itemX = fPool.GetCleanMemory(wbList[i]);
|
|
|
|
|
|
|
|
InsertItem(itemX, before);
|
|
|
|
lastPlaced = itemX;
|
|
|
|
}
|
|
|
|
else if (revIndexItem > revIndex)
|
|
|
|
{
|
|
|
|
removeAndPlaceBefore(itemX, before);
|
|
|
|
lastPlaced = itemX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// application's list only has modal windows.
|
2005-06-17 20:34:22 +04:00
|
|
|
count = item->layerPtr->App()->fAppSubWindowList.CountItems();
|
2005-11-24 20:45:26 +03:00
|
|
|
wbList = (WindowLayer**)item->layerPtr->App()->fAppSubWindowList.Items();
|
2005-02-28 23:23:51 +03:00
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (!wbList[i]->IsHidden())
|
|
|
|
{
|
|
|
|
itemX = HasItem(wbList[i], &revIndexItem);
|
|
|
|
if (!itemX)
|
|
|
|
{
|
|
|
|
itemX = fPool.GetCleanMemory(wbList[i]);
|
|
|
|
|
|
|
|
InsertItem(itemX, before);
|
|
|
|
lastPlaced = itemX;
|
|
|
|
}
|
|
|
|
else if (revIndexItem > revIndex)
|
|
|
|
{
|
|
|
|
removeAndPlaceBefore(itemX, before);
|
|
|
|
lastPlaced = itemX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
return lastPlaced;
|
2004-07-10 14:54:20 +04:00
|
|
|
}
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
void
|
|
|
|
Workspace::putFloatingInFront(ListData *item)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
int32 i;
|
|
|
|
ListData *newItem;
|
|
|
|
ListData *before = item->lowerItem;
|
2005-11-24 20:45:26 +03:00
|
|
|
WindowLayer *wb;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
i = 0;
|
2005-11-24 20:45:26 +03:00
|
|
|
while ((wb = (WindowLayer*)item->layerPtr->fSubWindowList.ItemAt(i)))
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
if (wb->Level() == B_MODAL_APP)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!wb->IsHidden())
|
|
|
|
{
|
|
|
|
newItem = fPool.GetCleanMemory(wb);
|
|
|
|
|
|
|
|
InsertItem(newItem, before);
|
|
|
|
|
2005-06-17 20:34:22 +04:00
|
|
|
item->layerPtr->fSubWindowList.RemoveItem(i);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
inline
|
|
|
|
void Workspace::saveFloatingWindows(ListData *itemNormal)
|
|
|
|
{
|
|
|
|
ListData *item = itemNormal->lowerItem;
|
|
|
|
ListData *toast;
|
|
|
|
while(item)
|
|
|
|
{
|
|
|
|
if (item->layerPtr->Level() == B_FLOATING_APP)
|
|
|
|
{
|
2005-11-24 20:45:26 +03:00
|
|
|
itemNormal->layerPtr->fSubWindowList.AddWindowLayer(item->layerPtr);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
toast = item;
|
|
|
|
item = item->lowerItem;
|
|
|
|
RemoveItem(toast);
|
|
|
|
fPool.ReleaseMemory(toast);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
inline
|
|
|
|
ListData* Workspace::findNextFront() const
|
|
|
|
{
|
|
|
|
ListData *item = fBottomItem;
|
|
|
|
|
|
|
|
while(item)
|
|
|
|
{
|
|
|
|
if (!item->layerPtr->IsHidden()
|
|
|
|
&& item->layerPtr->Level() != B_FLOATING_ALL
|
|
|
|
&& item->layerPtr->Level() != B_FLOATING_APP
|
2005-04-16 17:30:49 +04:00
|
|
|
&& !(item->layerPtr->WindowFlags() & B_AVOID_FRONT))
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
item = item->upperItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we cannot ignore anymore B_AVOID_FRONT windows.
|
|
|
|
|
|
|
|
item = fBottomItem;
|
|
|
|
while(item)
|
|
|
|
{
|
|
|
|
if (!item->layerPtr->IsHidden()
|
|
|
|
&& item->layerPtr->Level() != B_FLOATING_ALL
|
|
|
|
&& item->layerPtr->Level() != B_FLOATING_APP)
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
item = item->upperItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: BAD, bad memory manager!!! replace!!!
|
|
|
|
Workspace::MemoryPool::MemoryPool()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Workspace::MemoryPool::~MemoryPool()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2005-11-24 20:45:26 +03:00
|
|
|
ListData* Workspace::MemoryPool::GetCleanMemory(WindowLayer *winBorder)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
ListData *item = (ListData*)malloc(sizeof(ListData));
|
|
|
|
item->layerPtr = winBorder;
|
|
|
|
item->upperItem = NULL;
|
|
|
|
item->lowerItem = NULL;
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
void Workspace::MemoryPool::ReleaseMemory(ListData *mem)
|
|
|
|
{
|
|
|
|
free(mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::MemoryPool::expandBuffer(int32 start)
|
|
|
|
{
|
2005-06-17 20:34:22 +04:00
|
|
|
}
|