2004-01-17 21:37:57 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-21 02:50:02 +04:00
|
|
|
// Copyright (c) 2001-2002, 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: Desktop.cpp
|
2005-01-17 00:35:02 +03:00
|
|
|
// Author: Adi Oanca <adioanca@cotty.iren.ro>
|
2004-01-17 21:37:57 +03:00
|
|
|
// Description: Class used to encapsulate desktop management
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2004-01-13 03:56:36 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <Region.h>
|
2004-01-12 01:12:55 +03:00
|
|
|
#include <Message.h>
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
#include "AppServer.h"
|
2004-01-13 03:56:36 +03:00
|
|
|
#include "Desktop.h"
|
2004-01-22 03:32:07 +03:00
|
|
|
#include "DisplayDriver.h"
|
|
|
|
#include "Globals.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "Layer.h"
|
2004-01-22 03:32:07 +03:00
|
|
|
#include "RootLayer.h"
|
|
|
|
#include "ServerConfig.h"
|
|
|
|
#include "ServerScreen.h"
|
2005-02-28 23:23:51 +03:00
|
|
|
#include "ServerApp.h"
|
2004-01-22 03:32:07 +03:00
|
|
|
#include "ServerWindow.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "WinBorder.h"
|
|
|
|
#include "Workspace.h"
|
2003-02-12 14:24:26 +03:00
|
|
|
|
2005-03-30 03:00:58 +04:00
|
|
|
#if DISPLAYDRIVER == HWDRIVER
|
2005-04-12 12:22:16 +04:00
|
|
|
// #include "AccelerantDriver.h"
|
|
|
|
#include "DisplayDriverPainter.h"
|
2005-03-30 03:00:58 +04:00
|
|
|
#elif DISPLAYDRIVER == DIRECTDRIVER
|
2005-03-29 21:36:38 +04:00
|
|
|
#include "DirectDriver.h"
|
2005-03-30 03:00:58 +04:00
|
|
|
#elif DISPLAYDRIVER == PAINTERDRIVER
|
2005-03-29 21:36:38 +04:00
|
|
|
#include "DisplayDriverPainter.h"
|
2005-03-30 03:00:58 +04:00
|
|
|
#else
|
|
|
|
#include "ViewDriver.h"
|
|
|
|
#endif
|
2005-03-25 22:46:28 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
//#define DEBUG_DESKTOP
|
2003-02-12 14:24:26 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
#ifdef DEBUG_DESKTOP
|
|
|
|
#define STRACE(a) printf(a)
|
|
|
|
#else
|
|
|
|
#define STRACE(a) /* nothing */
|
|
|
|
#endif
|
2003-02-14 14:04:01 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
Desktop::Desktop(void)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fActiveRootLayer = NULL;
|
2004-01-14 03:54:45 +03:00
|
|
|
fActiveScreen = NULL;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
Desktop::~Desktop(void)
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
void *ptr;
|
2005-01-17 00:35:02 +03:00
|
|
|
|
|
|
|
for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++)
|
|
|
|
delete (WinBorder*)ptr;
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
for(int32 i=0; (ptr=fRootLayerList.ItemAt(i)); i++)
|
2004-01-12 01:12:55 +03:00
|
|
|
delete (RootLayer*)ptr;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
for(int32 i=0; (ptr=fScreenList.ItemAt(i)); i++)
|
2004-01-12 01:12:55 +03:00
|
|
|
delete (Screen*)ptr;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2005-03-29 19:39:08 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
Desktop::Init(void)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
2005-03-29 19:39:08 +04:00
|
|
|
DisplayDriver *driver = NULL;
|
|
|
|
|
|
|
|
#if DISPLAYDRIVER == HWDRIVER
|
|
|
|
// If we're using the AccelerantDriver for rendering, eventually we will loop through
|
|
|
|
// drivers until one can't initialize in order to support multiple monitors. For now,
|
|
|
|
// we'll just load one and be done with it.
|
2005-01-23 21:22:48 +03:00
|
|
|
|
2005-03-29 19:39:08 +04:00
|
|
|
bool initDrivers = true;
|
|
|
|
while (initDrivers) {
|
2005-04-12 12:22:16 +04:00
|
|
|
// driver = new AccelerantDriver();
|
|
|
|
driver = new DisplayDriverPainter();
|
2005-03-29 19:39:08 +04:00
|
|
|
AddDriver(driver);
|
|
|
|
initDrivers = false;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2003-02-14 14:04:01 +03:00
|
|
|
|
2005-03-29 19:39:08 +04:00
|
|
|
#elif DISPLAYDRIVER == DIRECTDRIVER
|
|
|
|
// It would be nice to have this for the default testing driver. Someday....
|
|
|
|
driver = new DirectDriver();
|
|
|
|
AddDriver(driver);
|
|
|
|
|
|
|
|
#elif DISPLAYDRIVER == PAINTERDRIVER
|
|
|
|
// It would be nice to have this for the default testing driver. Someday....
|
|
|
|
driver = new DisplayDriverPainter();
|
|
|
|
AddDriver(driver);
|
|
|
|
|
|
|
|
#else
|
|
|
|
// It would be nice to not ever need this again....
|
|
|
|
driver = new ViewDriver();
|
|
|
|
AddDriver(driver);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (fScreenList.CountItems() < 1) {
|
2004-01-12 01:12:55 +03:00
|
|
|
delete this;
|
2004-03-28 19:02:53 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-03-29 19:39:08 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
InitMode();
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
SetActiveRootLayerByIndex(0);
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-03-29 19:39:08 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
Desktop::AddDriver(DisplayDriver *driver)
|
2005-01-23 21:22:48 +03:00
|
|
|
{
|
2005-03-28 18:29:18 +04:00
|
|
|
if (driver->Initialize()) {
|
2005-01-23 21:22:48 +03:00
|
|
|
// TODO: be careful of screen initialization - monitor may not support 640x480
|
2005-03-30 03:04:26 +04:00
|
|
|
Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, fScreenList.CountItems()+1);
|
2005-03-28 18:29:18 +04:00
|
|
|
// Screen *sc = new Screen(driver, BPoint(640, 480), B_CMAP8, fScreenList.CountItems()+1);
|
|
|
|
// Screen *sc = new Screen(driver, BPoint(640, 480), B_GRAY8, fScreenList.CountItems()+1);
|
|
|
|
// Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB15, fScreenList.CountItems()+1);
|
|
|
|
// Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB16, fScreenList.CountItems()+1);
|
2005-04-12 12:22:16 +04:00
|
|
|
// Screen *sc = new Screen(driver, BPoint(1024, 768), B_RGB32, fScreenList.CountItems()+1);
|
2005-01-23 21:22:48 +03:00
|
|
|
fScreenList.AddItem(sc);
|
2005-03-28 18:29:18 +04:00
|
|
|
} else {
|
2005-01-23 21:22:48 +03:00
|
|
|
driver->Shutdown();
|
|
|
|
delete driver;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
void Desktop::InitMode(void)
|
|
|
|
{
|
|
|
|
// this is init mode for n-SS.
|
2004-01-14 03:54:45 +03:00
|
|
|
fActiveScreen = fScreenList.ItemAt(0)? (Screen*)fScreenList.ItemAt(0): NULL;
|
2004-01-22 03:32:07 +03:00
|
|
|
for (int32 i=0; i<fScreenList.CountItems(); i++)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
char name[32];
|
|
|
|
sprintf(name, "RootLayer %ld", i+1);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
|
|
|
Screen *screens[1];
|
|
|
|
screens[0] = (Screen*)fScreenList.ItemAt(i);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-02-24 15:03:51 +03:00
|
|
|
RootLayer *rl = new RootLayer(name, 4, this, GetDisplayDriver());
|
2004-01-12 01:12:55 +03:00
|
|
|
rl->SetScreens(screens, 1, 1);
|
2005-01-22 00:06:59 +03:00
|
|
|
rl->RunThread();
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
fRootLayerList.AddItem(rl);
|
2003-03-01 23:25:08 +03:00
|
|
|
}
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-22 03:32:07 +03:00
|
|
|
// Methods for multiple monitors.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
Screen* Desktop::ScreenAt(int32 index) const
|
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
return static_cast<Screen*>(fScreenList.ItemAt(index));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
int32 Desktop::ScreenCount(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fScreenList.CountItems();
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
Screen* Desktop::ActiveScreen(void) const
|
|
|
|
{
|
2004-01-14 03:54:45 +03:00
|
|
|
return fActiveScreen;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
void Desktop::SetActiveRootLayerByIndex(int32 listIndex)
|
|
|
|
{
|
|
|
|
RootLayer *rl=RootLayerAt(listIndex);
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
if (rl)
|
|
|
|
SetActiveRootLayer(rl);
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
void Desktop::SetActiveRootLayer(RootLayer* rl)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
if (fActiveRootLayer == rl)
|
|
|
|
return;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
fActiveRootLayer = rl;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
RootLayer* Desktop::ActiveRootLayer(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fActiveRootLayer;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
int32 Desktop::ActiveRootLayerIndex(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
int32 rootLayerCount = CountRootLayers();
|
2004-01-22 03:32:07 +03:00
|
|
|
for(int32 i=0; i<rootLayerCount; i++)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
if(fActiveRootLayer == (RootLayer*)(fRootLayerList.ItemAt(i)))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
RootLayer* Desktop::RootLayerAt(int32 index)
|
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
return static_cast<RootLayer*>(fRootLayerList.ItemAt(index));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
int32 Desktop::CountRootLayers() const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fRootLayerList.CountItems();
|
|
|
|
}
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
inline
|
2004-01-22 03:32:07 +03:00
|
|
|
DisplayDriver* Desktop::GetDisplayDriver() const
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
return ScreenAt(0)->DDriver();
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-22 03:32:07 +03:00
|
|
|
// Methods for layer(WinBorder) manipulation.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
void Desktop::AddWinBorder(WinBorder *winBorder)
|
|
|
|
{
|
|
|
|
if (!winBorder)
|
|
|
|
return;
|
|
|
|
|
2005-03-19 22:08:19 +03:00
|
|
|
// R2: how to determine the RootLayer to which this window should be added???
|
|
|
|
// for now, use ActiveRootLayer() because we only have one instance.
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
int32 feel = winBorder->Window()->Feel();
|
|
|
|
|
2005-03-19 22:08:19 +03:00
|
|
|
// we are ServerApp thread, we need to lock RootLayer here.
|
|
|
|
ActiveRootLayer()->Lock();
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// we're playing with window list. lock first.
|
|
|
|
Lock();
|
|
|
|
|
|
|
|
if (fWinBorderList.HasItem(winBorder))
|
|
|
|
{
|
|
|
|
Unlock();
|
2005-03-31 00:06:50 +04:00
|
|
|
ActiveRootLayer()->Unlock();
|
2005-02-28 23:23:51 +03:00
|
|
|
debugger("AddWinBorder: WinBorder already in Desktop list\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we have a new window. store a record of it.
|
|
|
|
fWinBorderList.AddItem(winBorder);
|
|
|
|
|
|
|
|
// add FLOATING_APP windows to the local list of all normal windows.
|
|
|
|
// This is to keep the order all floating windows (app or subset) when we go from
|
|
|
|
// one normal window to another.
|
2005-03-13 22:53:44 +03:00
|
|
|
if (feel == B_FLOATING_APP_WINDOW_FEEL || feel == B_NORMAL_WINDOW_FEEL)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
WinBorder *wb = NULL;
|
|
|
|
int32 count = fWinBorderList.CountItems();
|
2005-03-13 22:53:44 +03:00
|
|
|
int32 feelToLookFor = (feel == B_NORMAL_WINDOW_FEEL ?
|
|
|
|
B_FLOATING_APP_WINDOW_FEEL :
|
|
|
|
B_NORMAL_WINDOW_FEEL);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
for(int32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
wb = (WinBorder*)fWinBorderList.ItemAt(i);
|
|
|
|
if (wb->App()->ClientTeamID() == winBorder->App()->ClientTeamID()
|
2005-03-13 22:53:44 +03:00
|
|
|
&& wb->Window()->Feel() == feelToLookFor)
|
2005-02-28 23:23:51 +03:00
|
|
|
// R2: RootLayer comparison is needed.
|
|
|
|
{
|
2005-03-13 22:53:44 +03:00
|
|
|
feel == B_NORMAL_WINDOW_FEEL ?
|
|
|
|
winBorder->fFMWList.AddWinBorder(wb) :
|
|
|
|
wb->fFMWList.AddWinBorder(winBorder);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add application's list of modal windows.
|
|
|
|
if (feel == B_MODAL_APP_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
winBorder->App()->fAppFMWList.AddWinBorder(winBorder);
|
|
|
|
}
|
|
|
|
|
2005-03-19 22:08:19 +03:00
|
|
|
// send WinBorder to be added to workspaces
|
|
|
|
ActiveRootLayer()->AddWinBorder(winBorder);
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// hey, unlock!
|
|
|
|
Unlock();
|
|
|
|
|
2005-03-19 22:08:19 +03:00
|
|
|
ActiveRootLayer()->Unlock();
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Desktop::RemoveWinBorder(WinBorder *winBorder)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
if (!winBorder)
|
|
|
|
return;
|
|
|
|
|
2005-03-19 22:08:19 +03:00
|
|
|
// we are ServerApp thread, we need to lock RootLayer here.
|
|
|
|
ActiveRootLayer()->Lock();
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// we're playing with window list. lock first.
|
|
|
|
Lock();
|
|
|
|
|
|
|
|
// remove from main WinBorder list.
|
|
|
|
if (fWinBorderList.RemoveItem(winBorder))
|
|
|
|
{
|
|
|
|
int32 feel = winBorder->Window()->Feel();
|
|
|
|
|
|
|
|
// floating app/subset and modal_subset windows require special atention because
|
|
|
|
// they are/may_be added to the list of a lot normal windows.
|
|
|
|
if (feel == B_FLOATING_SUBSET_WINDOW_FEEL
|
|
|
|
|| feel == B_MODAL_SUBSET_WINDOW_FEEL
|
|
|
|
|| feel == B_FLOATING_APP_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
WinBorder *wb = NULL;
|
|
|
|
int32 count = fWinBorderList.CountItems();
|
2004-06-19 17:04:50 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
for (int32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
wb = (WinBorder*)fWinBorderList.ItemAt(i);
|
|
|
|
|
|
|
|
if (wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL
|
|
|
|
&& wb->App()->ClientTeamID() == winBorder->App()->ClientTeamID())
|
|
|
|
// R2: RootLayer comparison is needed. We'll see.
|
|
|
|
{
|
|
|
|
wb->fFMWList.RemoveItem(winBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove from application's list
|
|
|
|
if (feel == B_MODAL_APP_WINDOW_FEEL)
|
|
|
|
{
|
|
|
|
winBorder->App()->fAppFMWList.RemoveItem(winBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Unlock();
|
2005-03-31 00:06:50 +04:00
|
|
|
ActiveRootLayer()->Unlock();
|
2005-02-28 23:23:51 +03:00
|
|
|
debugger("RemoveWinBorder: WinBorder not found in Desktop list\n");
|
2003-02-20 21:05:35 +03:00
|
|
|
return;
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2003-02-20 21:05:35 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// Tell to winBorder's RootLayer about this.
|
|
|
|
ActiveRootLayer()->RemoveWinBorder(winBorder);
|
|
|
|
|
2005-03-18 22:00:45 +03:00
|
|
|
// unlock!
|
|
|
|
Unlock();
|
2005-03-19 22:08:19 +03:00
|
|
|
|
|
|
|
ActiveRootLayer()->Unlock();
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Desktop::AddWinBorderToSubset(WinBorder *winBorder, WinBorder *toWinBorder)
|
|
|
|
{
|
2005-03-18 22:00:45 +03:00
|
|
|
// NOTE: we can safely lock the entire method body, because this method is called from
|
|
|
|
// RootLayer's thread only.
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// we're playing with window list. lock first.
|
|
|
|
Lock();
|
|
|
|
|
|
|
|
if (!winBorder || !toWinBorder
|
|
|
|
|| !fWinBorderList.HasItem(winBorder) || !fWinBorderList.HasItem(toWinBorder))
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
Unlock();
|
|
|
|
debugger("AddWinBorderToSubset: NULL WinBorder or not found in Desktop list\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (winBorder->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL
|
|
|
|
|| winBorder->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
|
|
|
&& toWinBorder->Window()->Feel() == B_NORMAL_WINDOW_FEEL
|
|
|
|
&& toWinBorder->App()->ClientTeamID() == winBorder->App()->ClientTeamID()
|
|
|
|
&& !toWinBorder->fFMWList.HasItem(winBorder))
|
|
|
|
{
|
|
|
|
// add to normal_window's list
|
|
|
|
toWinBorder->fFMWList.AddWinBorder(winBorder);
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
else
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
Unlock();
|
|
|
|
debugger("AddWinBorderToSubset: you must add a subset_window to a normal_window's subset with the same team_id\n");
|
|
|
|
return;
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// send WinBorder to be added to workspaces, if not already in there.
|
|
|
|
ActiveRootLayer()->AddSubsetWinBorder(winBorder, toWinBorder);
|
2005-03-18 22:00:45 +03:00
|
|
|
|
|
|
|
// hey, unlock!
|
|
|
|
Unlock();
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
void Desktop::RemoveWinBorderFromSubset(WinBorder *winBorder, WinBorder *fromWinBorder)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
2005-03-18 22:00:45 +03:00
|
|
|
// NOTE: we can safely lock the entire method body, because this method is called from
|
|
|
|
// RootLayer's thread only.
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// we're playing with window list. lock first.
|
|
|
|
Lock();
|
|
|
|
|
|
|
|
if (!winBorder || !fromWinBorder
|
|
|
|
|| !fWinBorderList.HasItem(winBorder) || !fWinBorderList.HasItem(fromWinBorder))
|
|
|
|
{
|
|
|
|
Unlock();
|
|
|
|
debugger("RemoveWinBorderFromSubset: NULL WinBorder or not found in Desktop list\n");
|
|
|
|
return;
|
|
|
|
}
|
2004-06-19 17:04:50 +04:00
|
|
|
|
2005-03-18 22:00:45 +03:00
|
|
|
// remove WinBorder from workspace, if needed - some other windows may still have it in their subset
|
|
|
|
ActiveRootLayer()->RemoveSubsetWinBorder(winBorder, fromWinBorder);
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fromWinBorder->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
//remove from this normal_window's subset.
|
|
|
|
fromWinBorder->fFMWList.RemoveItem(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
else
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
Unlock();
|
|
|
|
debugger("RemoveWinBorderFromSubset: you must remove a subset_window from a normal_window's subset\n");
|
|
|
|
return;
|
|
|
|
}
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
// hey, unlock!
|
|
|
|
Unlock();
|
2003-08-31 21:38:34 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
WinBorder* Desktop::FindWinBorderByServerWindowTokenAndTeamID(int32 token, team_id teamID)
|
|
|
|
{
|
|
|
|
WinBorder* wb;
|
|
|
|
|
|
|
|
Lock();
|
|
|
|
for (int32 i = 0; (wb = (WinBorder*)fWinBorderList.ItemAt(i)); i++)
|
|
|
|
{
|
|
|
|
if (wb->Window()->ClientToken() == token
|
|
|
|
&& wb->Window()->ClientTeamID() == teamID)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Unlock();
|
|
|
|
|
|
|
|
return wb;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-22 03:32:07 +03:00
|
|
|
// Methods for various desktop stuff handled by the server
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::SetScrollBarInfo(const scroll_bar_info &info)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fScrollBarInfo = info;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
scroll_bar_info Desktop::ScrollBarInfo(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fScrollBarInfo;
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
void Desktop::SetMenuInfo(const menu_info &info)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fMenuInfo = info;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
menu_info Desktop::MenuInfo(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fMenuInfo;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
void Desktop::UseFFMouse(const bool &useffm)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fFFMouseMode = useffm;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
bool Desktop::FFMouseInUse(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fFFMouseMode;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
void Desktop::SetFFMouseMode(const mode_mouse &value)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
fMouseMode = value;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
mode_mouse Desktop::FFMouseMode(void) const
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fMouseMode;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
void Desktop::PrintToStream(void)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("RootLayer List:\n=======\n");
|
2004-01-22 03:32:07 +03:00
|
|
|
for(int32 i=0; i<fRootLayerList.CountItems(); i++)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%s\n", ((RootLayer*)fRootLayerList.ItemAt(i))->GetName());
|
|
|
|
((RootLayer*)fRootLayerList.ItemAt(i))->PrintToStream();
|
|
|
|
printf("-------\n");
|
|
|
|
}
|
|
|
|
printf("=======\nActive RootLayer: %s\n", fActiveRootLayer? fActiveRootLayer->GetName(): "NULL");
|
2004-01-13 03:56:36 +03:00
|
|
|
// printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(): "NULL");
|
2003-07-06 23:48:17 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("Screen List:\n");
|
2004-01-22 03:32:07 +03:00
|
|
|
for(int32 i=0; i<fScreenList.CountItems(); i++)
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("\t%ld\n", ((Screen*)fScreenList.ItemAt(i))->ScreenNumber());
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
void Desktop::PrintVisibleInRootLayerNo(int32 no)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|