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
|
2004-06-29 01:38:16 +04:00
|
|
|
// Author: Adi Oanca <adioanca@mymail.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>
|
2004-01-22 03:32:07 +03:00
|
|
|
#include <Entry.h>
|
2004-01-13 03:56:36 +03:00
|
|
|
#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 "AccelerantDriver.h"
|
|
|
|
#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"
|
|
|
|
#include "ServerWindow.h"
|
2003-01-29 02:58:06 +03:00
|
|
|
#include "ViewDriver.h"
|
2004-06-11 06:46:48 +04:00
|
|
|
#include "DirectDriver.h"
|
2004-01-12 01:12:55 +03:00
|
|
|
#include "WinBorder.h"
|
|
|
|
#include "Workspace.h"
|
2003-02-12 14:24:26 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
//#define DEBUG_DESKTOP
|
|
|
|
#define DEBUG_KEYHANDLING
|
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
|
|
|
fDragMessage = NULL;
|
|
|
|
fActiveRootLayer = NULL;
|
2004-04-05 00:28:14 +04:00
|
|
|
fMouseTarget = NULL;
|
2004-01-14 03:54:45 +03:00
|
|
|
fActiveScreen = NULL;
|
2004-01-22 03:32:07 +03:00
|
|
|
fScreenShotIndex = 1;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
Desktop::~Desktop(void)
|
|
|
|
{
|
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;
|
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-22 03:32:07 +03:00
|
|
|
for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++)
|
2004-01-12 01:12:55 +03:00
|
|
|
delete (WinBorder*)ptr;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
void Desktop::Init(void)
|
|
|
|
{
|
|
|
|
DisplayDriver *driver = NULL;
|
|
|
|
int32 driverCount = 0;
|
|
|
|
bool initDrivers = true;
|
|
|
|
|
|
|
|
while(initDrivers)
|
|
|
|
{
|
|
|
|
|
|
|
|
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.
|
|
|
|
driver = new AccelerantDriver();
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else if(DISPLAYDRIVER == DIRECTDRIVER)
|
|
|
|
{
|
|
|
|
// Eventually, it would be nice to do away with ViewDriver and replace it with
|
|
|
|
// one which uses a double-buffered BDirectWindow as a rendering context
|
|
|
|
driver = new DirectDriver();
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Eventually, it would be nice to do away with ViewDriver and replace it with
|
|
|
|
// one which uses a double-buffered BDirectWindow as a rendering context
|
|
|
|
driver = new ViewDriver();
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
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);
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: be careful, of screen initialization - monitor may not support 640x480
|
2004-01-12 01:12:55 +03:00
|
|
|
fScreenList.AddItem(sc);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
if ( (DISPLAYDRIVER != HWDRIVER) && (driverCount == 1) )
|
2004-01-12 01:12:55 +03:00
|
|
|
initDrivers = false;
|
|
|
|
}
|
2004-01-22 03:32:07 +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-03-28 19:02:53 +04:00
|
|
|
if (driverCount < 1){
|
2004-01-12 01:12:55 +03:00
|
|
|
delete this;
|
2004-03-28 19:02:53 +04:00
|
|
|
return;
|
|
|
|
}
|
2004-01-22 03:32:07 +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-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);
|
2004-03-28 19:02:53 +04:00
|
|
|
rl->RebuildFullRegion();
|
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.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
Screen* Desktop::ScreenAt(int32 index) const
|
|
|
|
{
|
|
|
|
Screen *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-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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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-08-29 19:01:44 +04:00
|
|
|
// TODO: hide mouse in the old ActiveRootLayer & show it in the new ActiveRootLayer
|
2004-03-28 19:02:53 +04:00
|
|
|
fActiveRootLayer->FullInvalidate(fActiveRootLayer->Bounds());
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
RootLayer* Desktop::RootLayerAt(int32 index)
|
|
|
|
{
|
|
|
|
RootLayer *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-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
|
|
|
|
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.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void Desktop::AddWinBorder(WinBorder* winBorder)
|
|
|
|
{
|
2004-06-19 17:04:50 +04:00
|
|
|
desktop->fGeneralLock.Lock();
|
|
|
|
|
2004-01-12 01:12:55 +03:00
|
|
|
if(fWinBorderList.HasItem(winBorder))
|
2003-02-20 21:05:35 +03:00
|
|
|
return;
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
// special case for Tracker background window.
|
2004-06-11 22:21:57 +04:00
|
|
|
if (winBorder->fLevel == B_SYSTEM_LAST)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
|
|
|
// 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);
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
else
|
2004-01-22 03:32:07 +03:00
|
|
|
// other windows are added to the current RootLayer only.
|
2004-01-12 01:12:55 +03:00
|
|
|
ActiveRootLayer()->AddWinBorder(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
// add that pointer to user winboder list so that we can keep track of them.
|
2004-01-13 03:56:36 +03:00
|
|
|
fLayerLock.Lock();
|
2004-01-12 01:12:55 +03:00
|
|
|
fWinBorderList.AddItem(winBorder);
|
2004-01-13 03:56:36 +03:00
|
|
|
fLayerLock.Unlock();
|
2004-06-19 17:04:50 +04:00
|
|
|
|
|
|
|
desktop->fGeneralLock.Unlock();
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
void Desktop::RemoveWinBorder(WinBorder* winBorder)
|
|
|
|
{
|
2004-06-19 17:04:50 +04:00
|
|
|
desktop->fGeneralLock.Lock();
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if(winBorder->fLevel == B_SYSTEM_LAST)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
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
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
else
|
2004-01-12 01:12:55 +03:00
|
|
|
winBorder->GetRootLayer()->RemoveWinBorder(winBorder);
|
2003-09-09 01:18:39 +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();
|
2004-06-19 17:04:50 +04:00
|
|
|
|
|
|
|
desktop->fGeneralLock.Unlock();
|
2003-08-31 21:38:34 +04:00
|
|
|
}
|
2004-01-22 03:32:07 +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-22 03:32:07 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-22 03:32:07 +03:00
|
|
|
// Input related methods
|
|
|
|
//---------------------------------------------------------------------------
|
2004-07-30 19:16:59 +04:00
|
|
|
void Desktop::MouseEventHandler(int32 code, BPortLink& msg)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
// TODO: locking mechanism needs SERIOUS rethought
|
2004-07-30 19:16:59 +04:00
|
|
|
switch(code)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
|
|
|
case B_MOUSE_DOWN:
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
// 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
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
PointerEvent evt;
|
|
|
|
evt.code = B_MOUSE_DOWN;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.where.x);
|
|
|
|
msg.Read<float>(&evt.where.y);
|
|
|
|
msg.Read<int32>(&evt.modifiers);
|
|
|
|
msg.Read<int32>(&evt.buttons);
|
|
|
|
msg.Read<int32>(&evt.clicks);
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
// printf("MOUSE DOWN: at (%f, %f)\n", evt.where.x, evt.where.y);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
WinBorder *target=NULL;
|
|
|
|
RootLayer *rl=NULL;
|
2004-11-06 23:04:39 +03:00
|
|
|
Workspace *ws=NULL;
|
2004-01-13 03:56:36 +03:00
|
|
|
rl = ActiveRootLayer();
|
|
|
|
ws = rl->ActiveWorkspace();
|
2004-07-30 19:16:59 +04:00
|
|
|
target = rl->WinBorderAt(evt.where);
|
2004-06-11 06:46:48 +04:00
|
|
|
if (target)
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
fGeneralLock.Lock();
|
|
|
|
rl->fMainLock.Lock();
|
2004-11-06 19:54:05 +03:00
|
|
|
|
|
|
|
STRACE(("Target: %s\n", target->GetName()));
|
|
|
|
STRACE(("Front: %s\n", ws->FrontLayer()->GetName()));
|
|
|
|
STRACE(("Focus: %s\n", ws->FocusLayer()->GetName()));
|
|
|
|
|
|
|
|
WinBorder *previousFocus=NULL;
|
|
|
|
WinBorder *activeFocus=NULL;
|
|
|
|
BRegion invalidRegion;
|
|
|
|
|
2004-11-06 23:04:39 +03:00
|
|
|
BMessage downmsg(B_MOUSE_DOWN);
|
|
|
|
downmsg.AddInt64("when",evt.when);
|
|
|
|
downmsg.AddPoint("where",evt.where);
|
|
|
|
downmsg.AddInt32("modifiers",evt.modifiers);
|
|
|
|
downmsg.AddInt32("buttons",evt.buttons);
|
|
|
|
downmsg.AddInt32("clicks",evt.clicks);
|
|
|
|
|
2004-11-06 19:54:05 +03:00
|
|
|
if (target!=ws->FrontLayer())
|
2004-06-23 01:43:24 +04:00
|
|
|
{
|
|
|
|
ws->BringToFrontANormalWindow(target);
|
|
|
|
ws->SearchAndSetNewFront(target);
|
|
|
|
previousFocus = ws->FocusLayer();
|
2004-07-10 10:28:41 +04:00
|
|
|
ws->SearchAndSetNewFocus(target);
|
|
|
|
activeFocus = ws->FocusLayer();
|
2004-06-23 01:43:24 +04:00
|
|
|
|
|
|
|
activeFocus->Window()->Lock();
|
|
|
|
|
|
|
|
if (target == activeFocus && target->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK)
|
2004-07-30 19:16:59 +04:00
|
|
|
target->MouseDown(evt, true);
|
2004-07-02 00:01:32 +04:00
|
|
|
else
|
2004-07-30 19:16:59 +04:00
|
|
|
target->MouseDown(evt, false);
|
2004-06-23 01:43:24 +04:00
|
|
|
|
2004-11-06 19:54:05 +03:00
|
|
|
// may or may not be empty.
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: B_MOUSE_DOWN: what if modal of floating windows are in front of us?
|
2004-06-23 01:43:24 +04:00
|
|
|
invalidRegion.Include(&(activeFocus->fFull));
|
|
|
|
invalidRegion.Include(&(activeFocus->fTopLayer->fFull));
|
2004-06-29 01:38:16 +04:00
|
|
|
activeFocus->fParent->RebuildAndForceRedraw(invalidRegion, activeFocus);
|
2004-06-23 01:43:24 +04:00
|
|
|
|
|
|
|
if (previousFocus != activeFocus && previousFocus)
|
|
|
|
{
|
|
|
|
if (previousFocus->fVisible.CountRects() > 0)
|
|
|
|
{
|
|
|
|
invalidRegion.MakeEmpty();
|
|
|
|
invalidRegion.Include(&(previousFocus->fVisible));
|
|
|
|
activeFocus->fParent->Invalidate(invalidRegion);
|
2004-06-21 00:02:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-02 00:01:32 +04:00
|
|
|
fMouseTarget = target;
|
2004-11-06 23:04:39 +03:00
|
|
|
|
2004-11-06 19:54:05 +03:00
|
|
|
STRACE(("2Target: %s\n", target->GetName()));
|
|
|
|
STRACE(("2Front: %s\n", ws->FrontLayer()->GetName()));
|
|
|
|
STRACE(("2Focus: %s\n", ws->FocusLayer()->GetName()));
|
2004-06-23 01:43:24 +04:00
|
|
|
|
2004-11-06 23:04:39 +03:00
|
|
|
fMouseTarget->Window()->SendMessageToClient(&downmsg);
|
2004-06-23 01:43:24 +04:00
|
|
|
activeFocus->Window()->Unlock();
|
2004-06-21 00:02:32 +04:00
|
|
|
}
|
2004-07-02 00:01:32 +04:00
|
|
|
else // target == ws->FrontLayer()
|
2004-06-23 01:43:24 +04:00
|
|
|
{
|
2004-06-29 01:38:16 +04:00
|
|
|
// only if target has the focus!
|
|
|
|
if (target == ws->FocusLayer())
|
|
|
|
{
|
|
|
|
target->Window()->Lock();
|
2004-07-30 19:16:59 +04:00
|
|
|
target->MouseDown(evt, true);
|
2004-11-06 23:04:39 +03:00
|
|
|
target->Window()->SendMessageToClient(&downmsg);
|
2004-06-29 01:38:16 +04:00
|
|
|
target->Window()->Unlock();
|
|
|
|
}
|
2004-11-06 19:54:05 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
previousFocus = ws->FocusLayer();
|
|
|
|
ws->SearchAndSetNewFocus(target);
|
|
|
|
activeFocus = ws->FocusLayer();
|
|
|
|
|
|
|
|
activeFocus->Window()->Lock();
|
|
|
|
|
|
|
|
if (target == activeFocus && target->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK)
|
|
|
|
target->MouseDown(evt, true);
|
|
|
|
else
|
|
|
|
target->MouseDown(evt, false);
|
|
|
|
|
|
|
|
// may or may not be empty.
|
|
|
|
|
|
|
|
// TODO: B_MOUSE_DOWN: what if modal of floating windows are in front of us?
|
|
|
|
invalidRegion.Include(&(activeFocus->fFull));
|
|
|
|
invalidRegion.Include(&(activeFocus->fTopLayer->fFull));
|
|
|
|
activeFocus->fParent->RebuildAndForceRedraw(invalidRegion, activeFocus);
|
|
|
|
|
|
|
|
if (previousFocus != activeFocus && previousFocus)
|
|
|
|
{
|
|
|
|
if (previousFocus->fVisible.CountRects() > 0)
|
|
|
|
{
|
|
|
|
invalidRegion.MakeEmpty();
|
|
|
|
invalidRegion.Include(&(previousFocus->fVisible));
|
|
|
|
activeFocus->fParent->Invalidate(invalidRegion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fMouseTarget = target;
|
2004-11-06 23:04:39 +03:00
|
|
|
fMouseTarget->Window()->SendMessageToClient(&downmsg);
|
|
|
|
|
2004-11-06 19:54:05 +03:00
|
|
|
activeFocus->Window()->Unlock();
|
|
|
|
}
|
2004-06-21 00:02:32 +04:00
|
|
|
}
|
2004-06-19 17:04:50 +04:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
rl->fMainLock.Unlock();
|
|
|
|
fGeneralLock.Unlock();
|
|
|
|
}
|
2004-06-23 01:43:24 +04:00
|
|
|
else // target == NULL
|
|
|
|
{
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
case B_MOUSE_UP:
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
// 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
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
PointerEvent evt;
|
|
|
|
evt.code = B_MOUSE_UP;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.where.x);
|
|
|
|
msg.Read<float>(&evt.where.y);
|
|
|
|
msg.Read<int32>(&evt.modifiers);
|
|
|
|
|
2004-11-06 23:04:39 +03:00
|
|
|
if (!fMouseTarget)
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-11-06 23:04:39 +03:00
|
|
|
WinBorder *target = ActiveRootLayer()->WinBorderAt(BPoint(evt.where.x, evt.where.y));
|
|
|
|
if(!target)
|
|
|
|
break;
|
|
|
|
fMouseTarget=target;
|
2004-04-05 00:28:14 +04:00
|
|
|
}
|
2004-11-06 23:04:39 +03:00
|
|
|
|
|
|
|
fMouseTarget->Window()->Lock();
|
|
|
|
fMouseTarget->MouseUp(evt);
|
|
|
|
|
|
|
|
BMessage upmsg(B_MOUSE_UP);
|
|
|
|
upmsg.AddInt64("when",evt.when);
|
|
|
|
upmsg.AddPoint("where",evt.where);
|
|
|
|
upmsg.AddInt32("modifiers",evt.modifiers);
|
2004-01-21 05:58:39 +03:00
|
|
|
|
2004-11-06 23:04:39 +03:00
|
|
|
fMouseTarget->Window()->SendMessageToClient(&upmsg);
|
|
|
|
fMouseTarget->Window()->Unlock();
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
STRACE(("MOUSE UP: at (%f, %f)\n", evt.where.x, evt.where.y));
|
2004-01-13 03:56:36 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
case B_MOUSE_MOVED:
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
// 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-21 05:58:39 +03:00
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
PointerEvent evt;
|
|
|
|
evt.code = B_MOUSE_MOVED;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.where.x);
|
|
|
|
msg.Read<float>(&evt.where.y);
|
|
|
|
msg.Read<int32>(&evt.buttons);
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-11-06 23:04:39 +03:00
|
|
|
fActiveScreen->DDriver()->MoveCursorTo(evt.where.x, evt.where.y);
|
|
|
|
|
|
|
|
if (!fMouseTarget)
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-07-30 19:16:59 +04:00
|
|
|
WinBorder *target = ActiveRootLayer()->WinBorderAt(BPoint(evt.where.x, evt.where.y));
|
2004-11-06 23:04:39 +03:00
|
|
|
if(!target)
|
|
|
|
break;
|
|
|
|
fMouseTarget=target;
|
2004-05-16 23:19:45 +04:00
|
|
|
}
|
2004-11-06 23:04:39 +03:00
|
|
|
|
|
|
|
fMouseTarget->Window()->Lock();
|
|
|
|
fMouseTarget->MouseMoved(evt);
|
|
|
|
|
|
|
|
BMessage movemsg(B_MOUSE_MOVED);
|
|
|
|
movemsg.AddInt64("when",evt.when);
|
|
|
|
movemsg.AddPoint("where",evt.where);
|
|
|
|
movemsg.AddInt32("buttons",evt.buttons);
|
|
|
|
|
|
|
|
fMouseTarget->Window()->SendMessageToClient(&movemsg);
|
|
|
|
fMouseTarget->Window()->Unlock();
|
2004-04-05 00:28:14 +04:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
case B_MOUSE_WHEEL_CHANGED:
|
|
|
|
{
|
2004-11-06 23:04:39 +03:00
|
|
|
// FEATURE: This is a tentative change: mouse wheel messages are always sent to the window
|
|
|
|
// under the cursor. It's pretty stupid to send it to the active window unless a particular
|
|
|
|
// view has locked focus via SetMouseEventMask
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
PointerEvent evt;
|
|
|
|
evt.code = B_MOUSE_WHEEL_CHANGED;
|
|
|
|
msg.Read<int64>(&evt.when);
|
|
|
|
msg.Read<float>(&evt.wheel_delta_x);
|
|
|
|
msg.Read<float>(&evt.wheel_delta_y);
|
2004-11-06 23:04:39 +03:00
|
|
|
|
|
|
|
BMessage wheelmsg(B_MOUSE_WHEEL_CHANGED);
|
|
|
|
wheelmsg.AddInt64("when",evt.when);
|
|
|
|
wheelmsg.AddFloat("be:wheel_delta_x",evt.wheel_delta_x);
|
|
|
|
wheelmsg.AddFloat("be:wheel_delta_y",evt.wheel_delta_y);
|
|
|
|
|
|
|
|
if(!fMouseTarget)
|
|
|
|
{
|
|
|
|
fMouseTarget = ActiveRootLayer()->WinBorderAt(GetDisplayDriver()->GetCursorPosition());
|
|
|
|
|
|
|
|
// We do nothing because there ain't a window to receive the message
|
|
|
|
if(!fMouseTarget)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fMouseTarget->Window()->Lock();
|
|
|
|
fMouseTarget->Window()->SendMessageToClient(&wheelmsg);
|
|
|
|
fMouseTarget->Window()->Unlock();
|
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
default:
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
printf("\nDesktop::MouseEventHandler(): WARNING: unknown message\n\n");
|
2004-01-22 03:32:07 +03:00
|
|
|
break;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
void Desktop::KeyboardEventHandler(int32 code, BPortLink& msg)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
2004-07-30 19:16:59 +04:00
|
|
|
|
|
|
|
switch(code)
|
2004-01-22 03:32:07 +03:00
|
|
|
{
|
|
|
|
case B_KEY_DOWN:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifier-independent ASCII code for the character
|
|
|
|
// 4) int32 repeat count
|
|
|
|
// 5) int32 modifiers
|
|
|
|
// 6) int8[3] UTF-8 data generated
|
|
|
|
// 7) int8 number of bytes to follow containing the
|
|
|
|
// generated string
|
|
|
|
// 8) Character string generated by the keystroke
|
|
|
|
// 9) int8[16] state of all keys
|
2004-07-30 19:16:59 +04:00
|
|
|
|
|
|
|
bigtime_t time;
|
|
|
|
int32 scancode, modifiers;
|
|
|
|
int8 utf[3];
|
|
|
|
char *string = NULL;
|
|
|
|
int32 keystate;
|
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
|
|
|
msg.Read<int32>(&modifiers);
|
|
|
|
msg.Read(utf, sizeof(utf));
|
|
|
|
msg.ReadString(&string);
|
|
|
|
msg.Read<int32>(&keystate);
|
|
|
|
if (string)
|
|
|
|
free(string);
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
if(DISPLAYDRIVER==HWDRIVER)
|
|
|
|
{
|
|
|
|
// Check for workspace change or safe video mode
|
|
|
|
if(scancode>0x01 && scancode<0x0e)
|
|
|
|
{
|
|
|
|
if(scancode==0x0d)
|
|
|
|
{
|
|
|
|
if(modifiers & (B_LEFT_COMMAND_KEY |
|
|
|
|
B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY))
|
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change)
|
2004-01-22 03:32:07 +03:00
|
|
|
STRACE(("Safe Video Mode invoked - code unimplemented\n"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(modifiers & B_CONTROL_KEY)
|
|
|
|
{
|
|
|
|
STRACE(("Set Workspace %ld\n",scancode-1));
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
//TODO: SetWorkspace in KeyboardEventHandler
|
2004-01-22 03:32:07 +03:00
|
|
|
//SetWorkspace(scancode-2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tab key
|
|
|
|
if(scancode==0x26 && (modifiers & B_CONTROL_KEY))
|
|
|
|
{
|
|
|
|
ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
|
|
|
|
if(deskbar)
|
|
|
|
{
|
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrintScreen
|
|
|
|
if(scancode==0xe)
|
|
|
|
{
|
|
|
|
if(GetDisplayDriver())
|
|
|
|
{
|
|
|
|
char filename[128];
|
|
|
|
BEntry entry;
|
|
|
|
|
|
|
|
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
|
|
|
entry.SetTo(filename);
|
|
|
|
|
|
|
|
while(entry.Exists())
|
|
|
|
{
|
|
|
|
fScreenShotIndex++;
|
|
|
|
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
|
|
|
}
|
|
|
|
fScreenShotIndex++;
|
|
|
|
GetDisplayDriver()->DumpToFile(filename);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// F12
|
|
|
|
if(scancode>0x1 && scancode<0xe)
|
|
|
|
{
|
|
|
|
if(scancode==0xd)
|
|
|
|
{
|
|
|
|
if(modifiers & (B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY | B_LEFT_OPTION_KEY))
|
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. (DisplayDriver API change)
|
2004-01-22 03:32:07 +03:00
|
|
|
STRACE(("Safe Video Mode invoked - code unimplemented\n"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY))
|
|
|
|
{
|
|
|
|
STRACE(("Set Workspace %ld\n",scancode-1));
|
2004-08-29 19:01:44 +04:00
|
|
|
//TODO: SetWorkspace in KeyboardEventHandler
|
2004-01-22 03:32:07 +03:00
|
|
|
//SetWorkspace(scancode-2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Tab
|
|
|
|
if(scancode==0x26 && (modifiers & B_SHIFT_KEY))
|
|
|
|
{
|
|
|
|
STRACE(("Twitcher\n"));
|
|
|
|
ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
|
|
|
|
if(deskbar)
|
|
|
|
{
|
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pause/Break
|
|
|
|
if(scancode==0x7f)
|
|
|
|
{
|
|
|
|
if(GetDisplayDriver())
|
|
|
|
{
|
|
|
|
char filename[128];
|
|
|
|
BEntry entry;
|
|
|
|
|
|
|
|
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
|
|
|
entry.SetTo(filename);
|
|
|
|
|
|
|
|
while(entry.Exists())
|
|
|
|
{
|
|
|
|
fScreenShotIndex++;
|
|
|
|
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
|
|
|
}
|
|
|
|
fScreenShotIndex++;
|
|
|
|
|
|
|
|
GetDisplayDriver()->DumpToFile(filename);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We got this far, so apparently it's safe to pass to the active
|
|
|
|
// window.
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Pass on key down message to client window with the focus
|
2004-01-22 03:32:07 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_KEY_UP:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifier-independent ASCII code for the character
|
|
|
|
// 4) int32 modifiers
|
|
|
|
// 5) int8[3] UTF-8 data generated
|
|
|
|
// 6) int8 number of bytes to follow containing the
|
|
|
|
// generated string
|
|
|
|
// 7) Character string generated by the keystroke
|
|
|
|
// 8) int8[16] state of all keys
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
bigtime_t time;
|
|
|
|
int32 scancode;
|
|
|
|
int32 ascii;
|
|
|
|
int32 modifiers;
|
|
|
|
int8 utf[3];
|
|
|
|
int8 bytes;
|
|
|
|
char *string;
|
|
|
|
int8 keystate[16];
|
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
|
|
|
msg.Read<int32>(&ascii);
|
|
|
|
msg.Read<int32>(&modifiers);
|
|
|
|
msg.Read(utf, sizeof(utf));
|
|
|
|
msg.Read<int8>(&bytes);
|
|
|
|
msg.ReadString(&string);
|
|
|
|
msg.Read(keystate, sizeof(keystate));
|
|
|
|
if (string)
|
|
|
|
free(string);
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
STRACE(("Key Up: 0x%lx\n",scancode));
|
|
|
|
|
|
|
|
if(DISPLAYDRIVER==HWDRIVER)
|
|
|
|
{
|
|
|
|
// Tab key
|
|
|
|
if(scancode==0x26 && (modifiers & B_CONTROL_KEY))
|
|
|
|
{
|
|
|
|
ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
|
|
|
|
if(deskbar)
|
|
|
|
{
|
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(scancode==0x26 && (modifiers & B_LEFT_SHIFT_KEY))
|
|
|
|
{
|
|
|
|
ServerApp *deskbar=app_server->FindApp("application/x-vnd.Be-TSKB");
|
|
|
|
if(deskbar)
|
|
|
|
{
|
|
|
|
printf("Send Twitcher message key to Deskbar - unimplmemented\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We got this far, so apparently it's safe to pass to the active
|
|
|
|
// window.
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Pass on key up message to client window with the focus
|
2004-01-22 03:32:07 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_UNMAPPED_KEY_DOWN:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifiers
|
|
|
|
// 4) int32 number of elements in the key state array to follow
|
|
|
|
// 5) int8 state of all keys
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
bigtime_t time;
|
|
|
|
int32 scancode;
|
|
|
|
int32 modifiers;
|
|
|
|
int32 elements;
|
|
|
|
//int8 keystate[16];
|
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
|
|
|
msg.Read<int32>(&modifiers);
|
|
|
|
msg.Read<int32>(&elements);
|
|
|
|
//msg.Read(keystate, elements);
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
#ifdef DEBUG_KEYHANDLING
|
2004-07-30 19:16:59 +04:00
|
|
|
printf("Unmapped Key Down: 0x%lx\n", scancode);
|
2004-01-22 03:32:07 +03:00
|
|
|
#endif
|
2004-08-29 19:01:44 +04:00
|
|
|
|
|
|
|
// TODO: Pass on unmapped key down message to client window with the focus
|
2004-01-22 03:32:07 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_UNMAPPED_KEY_UP:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 raw key code (scancode)
|
|
|
|
// 3) int32 modifiers
|
|
|
|
// 4) int32 number of elements in the key state array to follow
|
|
|
|
// 5) int8 state of all keys
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
bigtime_t time;
|
|
|
|
int32 scancode;
|
|
|
|
int32 modifiers;
|
|
|
|
int32 elements;
|
|
|
|
//int8 keystate[16];
|
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
|
|
|
msg.Read<int32>(&modifiers);
|
|
|
|
msg.Read<int32>(&elements);
|
|
|
|
//msg.Read(keystate, elements);
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
#ifdef DEBUG_KEYHANDLING
|
2004-07-30 19:16:59 +04:00
|
|
|
printf("Unmapped Key Up: 0x%lx\n", scancode);
|
2004-01-22 03:32:07 +03:00
|
|
|
#endif
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Pass on unmapped key up message to client window with the focus
|
2004-01-22 03:32:07 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_MODIFIERS_CHANGED:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) int64 bigtime_t object of when the message was sent
|
|
|
|
// 2) int32 modifiers
|
|
|
|
// 3) int32 old modifiers
|
|
|
|
// 4) int32 number of elements in the key state array to follow
|
|
|
|
// 5) int8 state of all keys
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
bigtime_t time;
|
|
|
|
int32 scancode;
|
|
|
|
int32 modifiers;
|
|
|
|
int32 elements;
|
|
|
|
//int8 keystate[16];
|
|
|
|
|
|
|
|
msg.Read<bigtime_t>(&time);
|
|
|
|
msg.Read<int32>(&scancode);
|
|
|
|
msg.Read<int32>(&modifiers);
|
|
|
|
msg.Read<int32>(&elements);
|
|
|
|
//msg.Read(keystate, elements);
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
#ifdef DEBUG_KEYHANDLING
|
|
|
|
printf("Modifiers Changed\n");
|
|
|
|
#endif
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Pass on modifier change message to client window with the focus
|
2004-01-22 03:32:07 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2004-01-22 03:32:07 +03:00
|
|
|
|
|
|
|
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-22 03:32:07 +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-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::RemoveSubsetWindow(WinBorder* wb)
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
WinBorder *winBorder = NULL;
|
2004-01-17 19:33:22 +03:00
|
|
|
|
|
|
|
fLayerLock.Lock();
|
2004-01-12 01:12:55 +03:00
|
|
|
int32 count = fWinBorderList.CountItems();
|
2004-01-22 03:32:07 +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-06-11 22:21:57 +04:00
|
|
|
if (winBorder->fLevel == B_NORMAL_FEEL)
|
2004-01-13 03:56:36 +03:00
|
|
|
winBorder->Window()->fWinFMWList.RemoveItem(wb);
|
2003-07-06 23:48:17 +04:00
|
|
|
}
|
2004-01-17 19:33:22 +03:00
|
|
|
fLayerLock.Unlock();
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
RootLayer *rl = winBorder->GetRootLayer();
|
2004-01-17 19:33:22 +03:00
|
|
|
|
|
|
|
if (!fGeneralLock.IsLocked())
|
|
|
|
debugger("Desktop::RemoveWinBorder() - fGeneralLock must be locked!\n");
|
|
|
|
if (!(rl->fMainLock.IsLocked()))
|
|
|
|
debugger("Desktop::RemoveWinBorder() - fMainLock must be locked!\n");
|
|
|
|
|
2004-01-22 03:32:07 +03:00
|
|
|
int32 countWKs = rl->WorkspaceCount();
|
|
|
|
for (int32 i=0; i < countWKs; i++)
|
2004-07-11 14:01:01 +04:00
|
|
|
rl->WorkspaceAt(i+1)->RemoveWinBorder(wb);
|
2004-01-22 03:32:07 +03:00
|
|
|
|
2004-01-12 01:12:55 +03: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
|
|
|
|
|
|
|
WinBorder* Desktop::FindWinBorderByServerWindowTokenAndTeamID(int32 token, team_id teamID)
|
|
|
|
{
|
2004-01-14 03:26:15 +03:00
|
|
|
WinBorder* wb;
|
|
|
|
fLayerLock.Lock();
|
2004-01-22 03:32:07 +03:00
|
|
|
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-22 03:32:07 +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());
|
2004-01-22 03:32:07 +03:00
|
|
|
WinBorder *wb = NULL;
|
|
|
|
Workspace *ws = ActiveRootLayer()->ActiveWorkspace();
|
|
|
|
for(wb = (WinBorder*)ws->GoToTopItem(); wb != NULL; wb = (WinBorder*)ws->GoToLowerItem())
|
|
|
|
{
|
2004-01-12 01:12:55 +03:00
|
|
|
if (!wb->IsHidden())
|
|
|
|
wb->PrintToStream();
|
|
|
|
}
|
|
|
|
}
|