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
|
|
|
|
|
|
|
#include "Desktop.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "RootLayer.h"
|
2004-01-13 14:58:41 +03:00
|
|
|
#include "ServerScreen.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "Layer.h"
|
|
|
|
#include "PortMessage.h"
|
|
|
|
#include "DisplayDriver.h"
|
|
|
|
#include "AccelerantDriver.h"
|
2003-01-29 02:58:06 +03:00
|
|
|
#include "ViewDriver.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "WinBorder.h"
|
|
|
|
#include "Workspace.h"
|
|
|
|
#include "Globals.h"
|
2003-09-09 01:18:39 +04:00
|
|
|
#include "ServerWindow.h"
|
2003-02-12 14:24:26 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
//#define REAL_MODE
|
2003-02-12 14:24:26 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
Desktop::Desktop(void){
|
|
|
|
// desktop = this;
|
2003-02-14 14:04:01 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
fDragMessage = NULL;
|
|
|
|
fActiveRootLayer = NULL;
|
|
|
|
fFrontWinBorder = NULL;
|
|
|
|
fFocusWinBorder = NULL;
|
2004-01-14 03:54:45 +03:00
|
|
|
fActiveScreen = NULL;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
Desktop::~Desktop(void){
|
|
|
|
//printf("~Desktop()\n");
|
2004-01-12 01:12:55 +03:00
|
|
|
if (fDragMessage)
|
|
|
|
delete fDragMessage;
|
2003-02-14 14:04:01 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
void *ptr;
|
|
|
|
for(int32 i=0; (ptr=fRootLayerList.ItemAt(i)); i++){
|
2004-01-12 01:12:55 +03:00
|
|
|
delete (RootLayer*)ptr;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
for(int32 i=0; (ptr=fScreenList.ItemAt(i)); i++){
|
2004-01-12 01:12:55 +03:00
|
|
|
delete (Screen*)ptr;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++){
|
2004-01-12 01:12:55 +03:00
|
|
|
delete (WinBorder*)ptr;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::Init(void){
|
2004-01-12 01:12:55 +03:00
|
|
|
DisplayDriver *driver = NULL;
|
2004-01-13 03:56:36 +03:00
|
|
|
int32 driverCount = 0;
|
|
|
|
bool initDrivers = true;
|
|
|
|
|
|
|
|
while(initDrivers){
|
|
|
|
|
|
|
|
#ifdef REAL_MODE
|
|
|
|
// 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.
|
|
|
|
driver = new AccelerantDriver();
|
|
|
|
#else
|
|
|
|
driver = new ViewDriver();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(driver->Initialize()){
|
2004-01-12 01:12:55 +03:00
|
|
|
driverCount++;
|
2004-01-13 03:56:36 +03:00
|
|
|
|
|
|
|
Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, driverCount);
|
|
|
|
// TODO: be careful, it may fail to initialize! - Monitor may not support 640x480
|
2004-01-12 01:12:55 +03:00
|
|
|
fScreenList.AddItem(sc);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
|
|
|
// TODO: remove this when you have a real Driver.
|
|
|
|
if (driverCount == 1)//2)
|
2004-01-12 01:12:55 +03:00
|
|
|
initDrivers = false;
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
else{
|
2004-01-12 01:12:55 +03:00
|
|
|
driver->Shutdown();
|
|
|
|
delete driver;
|
|
|
|
driver = NULL;
|
|
|
|
initDrivers = false;
|
|
|
|
}
|
|
|
|
}
|
2003-02-14 14:04:01 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
if (driverCount < 1){
|
2004-01-12 01:12:55 +03:00
|
|
|
delete this;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2003-01-24 18:19:27 +03: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-13 03:56:36 +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-13 03:56:36 +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-01-13 03:56:36 +03:00
|
|
|
RootLayer *rl = new RootLayer(name, 4, this);
|
2004-01-12 01:12:55 +03:00
|
|
|
rl->SetScreens(screens, 1, 1);
|
|
|
|
|
|
|
|
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
|
|
|
// Methods for multiple monitors.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
Screen* Desktop::ScreenAt(int32 index) const{
|
2004-01-12 01:12:55 +03:00
|
|
|
Screen *sc;
|
2004-01-13 03:56:36 +03:00
|
|
|
sc = static_cast<Screen*>(fScreenList.ItemAt(index));
|
2003-03-01 23:25:08 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
return sc;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
int32 Desktop::ScreenCount() const{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fScreenList.CountItems();
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-14 03:54:45 +03:00
|
|
|
Screen* Desktop::ActiveScreen() const{
|
|
|
|
return fActiveScreen;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::SetActiveRootLayerByIndex(int32 listIndex){
|
2004-01-12 01:12:55 +03:00
|
|
|
RootLayer *rl;
|
2004-01-13 03:56:36 +03:00
|
|
|
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-13 03:56:36 +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;
|
2004-01-14 03:26:15 +03:00
|
|
|
|
|
|
|
// TODO: fix!!!!!!!!!!!!!!!!!!!!!!!! or not?
|
2004-01-13 03:56:36 +03:00
|
|
|
// also set he new front and focus
|
2004-01-14 03:26:15 +03:00
|
|
|
// SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
|
|
|
// SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
// TODO: other tasks required when this happens. I don't know them now.
|
|
|
|
// Rebuild & Invalidate
|
|
|
|
// hide the mouse in the old ActiveRootLayer
|
|
|
|
// show the mouse in new ActiveRootLayer
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
RootLayer* Desktop::ActiveRootLayer() const{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fActiveRootLayer;
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
int32 Desktop::ActiveRootLayerIndex() const{
|
2004-01-12 01:12:55 +03:00
|
|
|
int32 rootLayerCount = CountRootLayers();
|
|
|
|
for(int32 i=0; i<rootLayerCount; i++){
|
|
|
|
if(fActiveRootLayer == (RootLayer*)(fRootLayerList.ItemAt(i)))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
RootLayer* Desktop::RootLayerAt(int32 index){
|
2004-01-12 01:12:55 +03:00
|
|
|
RootLayer *rl;
|
2004-01-13 03:56:36 +03:00
|
|
|
rl = static_cast<RootLayer*>(fRootLayerList.ItemAt(index));
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
return rl;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +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
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
DisplayDriver* Desktop::GetDisplayDriver() const{
|
|
|
|
return ScreenAt(0)->DDriver();
|
|
|
|
}
|
|
|
|
// Methods for layer(WinBorder) manipulation.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::AddWinBorder(WinBorder* winBorder){
|
2004-01-12 01:12:55 +03:00
|
|
|
if(fWinBorderList.HasItem(winBorder))
|
2003-02-20 21:05:35 +03:00
|
|
|
return;
|
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
// special case for Tracker background window.
|
|
|
|
if (winBorder->_level == B_SYSTEM_LAST){
|
|
|
|
// it's added in all RottLayers
|
|
|
|
for(int32 i=0; i<fRootLayerList.CountItems(); i++){
|
2004-01-12 01:12:55 +03:00
|
|
|
((RootLayer*)fRootLayerList.ItemAt(i))->AddWinBorder(winBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// other windows are added to the current RootLayer only.
|
2004-01-13 03:56:36 +03:00
|
|
|
else
|
2004-01-12 01:12:55 +03:00
|
|
|
ActiveRootLayer()->AddWinBorder(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
|
|
|
// add that pointer to user winboder list so that we can keep track of them.
|
|
|
|
fLayerLock.Lock();
|
2004-01-12 01:12:55 +03:00
|
|
|
fWinBorderList.AddItem(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
fLayerLock.Unlock();
|
2004-01-14 03:26:15 +03:00
|
|
|
|
|
|
|
// TODO: remove those 2? I vote for: YES! still... have to think...
|
|
|
|
// SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
|
|
|
// SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::RemoveWinBorder(WinBorder* winBorder){
|
|
|
|
if(winBorder->_level == B_SYSTEM_LAST){
|
2004-01-12 01:12:55 +03:00
|
|
|
for(int32 i=0; i<fRootLayerList.CountItems(); i++)
|
|
|
|
((RootLayer*)fRootLayerList.ItemAt(i))->RemoveWinBorder(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
|
|
|
else{
|
2004-01-12 01:12:55 +03:00
|
|
|
winBorder->GetRootLayer()->RemoveWinBorder(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2004-01-14 03:26:15 +03:00
|
|
|
// TODO: remove those 4? I vote for: YES! still... have to think...
|
|
|
|
// if (winBorder == fFrontWinBorder)
|
|
|
|
// SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
|
|
|
// if (winBorder == fFocusWinBorder)
|
|
|
|
// SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
2003-08-31 21:38:34 +04:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
fLayerLock.Lock();
|
2004-01-12 01:12:55 +03:00
|
|
|
fWinBorderList.RemoveItem(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
fLayerLock.Unlock();
|
2003-08-31 21:38:34 +04:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
bool Desktop::HasWinBorder(WinBorder* winBorder){
|
2004-01-12 01:12:55 +03:00
|
|
|
return fWinBorderList.HasItem(winBorder);
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::SetFrontWinBorder(WinBorder* winBorder){
|
2004-01-12 01:12:55 +03:00
|
|
|
fFrontWinBorder = winBorder;
|
2004-01-13 03:56:36 +03:00
|
|
|
// TODO: implement
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-14 18:55:10 +03:00
|
|
|
// TODO: remove shortly?
|
|
|
|
void Desktop::SetFoooocusWinBorder(WinBorder* winBorder){
|
2004-01-14 03:26:15 +03:00
|
|
|
if (FocusWinBorder() == winBorder && (winBorder && !winBorder->IsHidden()))
|
2004-01-13 03:56:36 +03:00
|
|
|
return;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-01-14 03:26:15 +03:00
|
|
|
fFocusWinBorder = FocusWinBorder();
|
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
// NOTE: we assume both, the old and new focus layer are in the active workspace
|
|
|
|
WinBorder *newFocus = NULL;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
if(fFocusWinBorder){
|
|
|
|
fFocusWinBorder->SetFocus(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(winBorder){
|
2004-01-14 03:26:15 +03:00
|
|
|
// TODO: NO! this call is to determine the correct order! NOT to rebuild/redraw anything!
|
|
|
|
// TODO: WinBorder::SetFront... will do that - both!
|
|
|
|
// TODO: modify later
|
|
|
|
// TODO: same applies for the focus state - RootLayer::SetFocus also does redraw
|
|
|
|
// Workspace::SetFocus - Only determines the focus! Just like above!
|
|
|
|
/*
|
2004-01-13 03:56:36 +03:00
|
|
|
newFocus = winBorder->GetRootLayer()->ActiveWorkspace()->SetFocusLayer(winBorder);
|
|
|
|
newFocus->SetFocus(true);
|
2004-01-14 03:26:15 +03:00
|
|
|
*/
|
|
|
|
Workspace *aws;
|
|
|
|
|
|
|
|
aws = winBorder->GetRootLayer()->ActiveWorkspace();
|
|
|
|
aws->SearchAndSetNewFocus(winBorder);
|
|
|
|
|
|
|
|
//why do put this line? Eh... I will remove it later...
|
|
|
|
newFocus = aws->FocusLayer();
|
|
|
|
|
|
|
|
aws->FocusLayer()->SetFocus(true);
|
|
|
|
|
|
|
|
aws->Invalidate();
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2003-02-20 16:13:01 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
fFocusWinBorder = newFocus;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
WinBorder* Desktop::FrontWinBorder(void) const{
|
|
|
|
return fActiveRootLayer->ActiveWorkspace()->FrontLayer();
|
|
|
|
// return fFrontWinBorder;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
WinBorder* Desktop::FocusWinBorder(void) const{
|
2004-01-14 03:26:15 +03:00
|
|
|
return fActiveRootLayer->ActiveWorkspace()->FocusLayer();
|
|
|
|
// return fFocusWinBorder;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Input related methods
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::MouseEventHandler(PortMessage *msg){
|
|
|
|
switch(msg->Code()){
|
|
|
|
case B_MOUSE_DOWN:{
|
|
|
|
// Attached data:
|
|
|
|
// 1) int64 - time of mouse click
|
|
|
|
// 2) float - x coordinate of mouse click
|
|
|
|
// 3) float - y coordinate of mouse click
|
|
|
|
// 4) int32 - modifier keys down
|
|
|
|
// 5) int32 - buttons down
|
|
|
|
// 6) int32 - clicks
|
|
|
|
|
|
|
|
BPoint pt;
|
|
|
|
int64 dummy;
|
|
|
|
msg->Read<int64>(&dummy);
|
|
|
|
msg->Read<float>(&pt.x);
|
|
|
|
msg->Read<float>(&pt.y);
|
|
|
|
|
|
|
|
printf("MOUSE DOWN: at (%f, %f)\n", pt.x, pt.y);
|
|
|
|
|
|
|
|
WinBorder *target;
|
|
|
|
RootLayer *rl;
|
|
|
|
Workspace *ws;
|
|
|
|
rl = ActiveRootLayer();
|
|
|
|
ws = rl->ActiveWorkspace();
|
|
|
|
target = ws->SearchLayerUnderPoint(pt);
|
|
|
|
if (target){
|
|
|
|
fGeneralLock.Lock();
|
|
|
|
rl->fMainLock.Lock();
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-01-14 03:26:15 +03:00
|
|
|
ws->SearchAndSetNewFront(target);
|
2004-01-14 18:55:10 +03:00
|
|
|
ws->SetFocusLayer(target);
|
2003-02-20 16:13:01 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
rl->fMainLock.Unlock();
|
|
|
|
fGeneralLock.Unlock();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_MOUSE_UP:{
|
|
|
|
// Attached data:
|
|
|
|
// 1) int64 - time of mouse click
|
|
|
|
// 2) float - x coordinate of mouse click
|
|
|
|
// 3) float - y coordinate of mouse click
|
|
|
|
// 4) int32 - modifier keys down
|
|
|
|
|
|
|
|
BPoint pt;
|
|
|
|
int64 dummy;
|
|
|
|
msg->Read<int64>(&dummy);
|
|
|
|
msg->Read<float>(&pt.x);
|
|
|
|
msg->Read<float>(&pt.y);
|
|
|
|
|
|
|
|
printf("MOUSE UP: at (%f, %f)\n", pt.x, pt.y);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_MOUSE_MOVED:{
|
|
|
|
// Attached data:
|
|
|
|
// 1) int64 - time of mouse click
|
|
|
|
// 2) float - x coordinate of mouse click
|
|
|
|
// 3) float - y coordinate of mouse click
|
|
|
|
// 4) int32 - buttons down
|
2004-01-14 03:54:45 +03:00
|
|
|
int64 dummy;
|
|
|
|
float x,y;
|
|
|
|
msg->Read<int64>(&dummy);
|
|
|
|
msg->Read<float>(&x);
|
|
|
|
msg->Read<float>(&y);
|
|
|
|
|
|
|
|
// We need this so that we can see the cursor on the screen
|
|
|
|
if(fActiveScreen)
|
|
|
|
fActiveScreen->DDriver()->MoveCursorTo(x,y);
|
2004-01-13 03:56:36 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_MOUSE_WHEEL_CHANGED:{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:{
|
|
|
|
printf("\nDesktop::MouseEventHandler(): WARNING: unknown message\n\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::KeyboardEventHandler(PortMessage *msg){
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::SetDragMessage(BMessage* msg){
|
|
|
|
if (fDragMessage){
|
2004-01-12 01:12:55 +03:00
|
|
|
delete fDragMessage;
|
|
|
|
fDragMessage = NULL;
|
2003-02-20 16:13:01 +03:00
|
|
|
}
|
2004-01-12 01:12:55 +03:00
|
|
|
|
|
|
|
if (msg)
|
|
|
|
fDragMessage = new BMessage(*msg);
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
BMessage* Desktop::DragMessage(void) const{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fDragMessage;
|
|
|
|
}
|
2003-02-20 16:13:01 +03:00
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
// Methods for various desktop stuff handled by the server
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
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-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
scroll_bar_info Desktop::ScrollBarInfo(void) const{
|
2004-01-12 01:12:55 +03:00
|
|
|
return fScrollBarInfo;
|
|
|
|
}
|
2004-01-13 03:56:36 +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-13 03:56:36 +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-13 03:56:36 +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-13 03:56:36 +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-13 03:56:36 +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-13 03:56:36 +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-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
bool Desktop::ReadWorkspaceData(void){
|
|
|
|
// TODO: implement
|
2004-01-12 01:12:55 +03:00
|
|
|
return true;
|
2003-07-10 21:48:04 +04:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::SaveWorkspaceData(void){
|
|
|
|
// TODO: implement
|
2003-07-10 21:48:04 +04:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::RemoveSubsetWindow(WinBorder* wb){
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *winBorder = NULL;
|
|
|
|
int32 count = fWinBorderList.CountItems();
|
2004-01-13 03:56:36 +03:00
|
|
|
for(int32 i=0; i < count; i++){
|
2004-01-12 01:12:55 +03:00
|
|
|
winBorder = static_cast<WinBorder*>(fWinBorderList.ItemAt(i));
|
2004-01-13 03:56:36 +03:00
|
|
|
if (winBorder->_level == B_NORMAL_FEEL)
|
|
|
|
winBorder->Window()->fWinFMWList.RemoveItem(wb);
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
RootLayer *rl = winBorder->GetRootLayer();
|
|
|
|
int32 countWKs = rl->WorkspaceCount();
|
2004-01-13 03:56:36 +03:00
|
|
|
for (int32 i=0; i < countWKs; i++){
|
2004-01-12 01:12:55 +03:00
|
|
|
rl->WorkspaceAt(i+1)->RemoveLayerPtr(wb);
|
|
|
|
}
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void Desktop::PrintToStream(){
|
2004-01-12 01:12:55 +03:00
|
|
|
printf("RootLayer List:\n=======\n");
|
|
|
|
for(int32 i=0; i<fRootLayerList.CountItems(); i++){
|
|
|
|
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");
|
|
|
|
for(int32 i=0; i<fScreenList.CountItems(); i++){
|
|
|
|
printf("\t%ld\n", ((Screen*)fScreenList.ItemAt(i))->ScreenNumber());
|
|
|
|
}
|
2003-07-06 23:48:17 +04:00
|
|
|
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-16 19:09:36 +03:00
|
|
|
WinBorder* Desktop::FindWinBorderByServerWindowTokenAndTeamID(int32 token, team_id teamID){
|
2004-01-14 03:26:15 +03:00
|
|
|
WinBorder* wb;
|
|
|
|
fLayerLock.Lock();
|
|
|
|
for (int32 i = 0; (wb = (WinBorder*)fWinBorderList.ItemAt(i)); i++){
|
2004-01-16 19:09:36 +03:00
|
|
|
if (wb->Window()->ClientToken() == token
|
|
|
|
&& wb->Window()->ClientTeamID() == teamID)
|
2004-01-14 03:26:15 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
fLayerLock.Unlock();
|
|
|
|
|
|
|
|
return wb;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
2004-01-13 03:56:36 +03:00
|
|
|
void Desktop::PrintVisibleInRootLayerNo(int32 no){
|
2004-01-12 01:12:55 +03:00
|
|
|
if (no<0 || no>=fRootLayerList.CountItems())
|
|
|
|
return;
|
|
|
|
|
|
|
|
printf("Visible windows in RootLayer %ld, Workspace %ld\n",
|
|
|
|
ActiveRootLayerIndex(), ActiveRootLayer()->ActiveWorkspaceIndex());
|
|
|
|
WinBorder *wb = NULL;
|
|
|
|
Workspace *ws = ActiveRootLayer()->ActiveWorkspace();
|
|
|
|
for(wb = (WinBorder*)ws->GoToTopItem(); wb != NULL; wb = (WinBorder*)ws->GoToLowerItem()){
|
|
|
|
if (!wb->IsHidden())
|
|
|
|
wb->PrintToStream();
|
|
|
|
}
|
|
|
|
}
|