Implemented AS_GET_WINDOW_LIST and AS_GET_WINDOW_INFO.
Renamed Desktop::FindWinBorderByServerWindowTokenAndTeamID() to FindWinBorderByClientToken(). Every ServerWindow now gets a server token. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13455 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+87
-17
@@ -1,18 +1,24 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved.
|
* Copyright 2001-2005, Haiku.
|
||||||
// Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// File Name: Desktop.cpp
|
* Authors:
|
||||||
// Author: Adi Oanca <[email protected]>
|
* Adrian Oanca <[email protected]>
|
||||||
// Stephan Aßmus <[email protected]>
|
* Stephan Aßmus <[email protected]>
|
||||||
// Description: Class used to encapsulate desktop management
|
* Axel Dörfler, [email protected]
|
||||||
//
|
*/
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
/** Class used to encapsulate desktop management */
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
|
|
||||||
|
#include <WindowInfo.h>
|
||||||
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
#include "AppServer.h"
|
#include "AppServer.h"
|
||||||
#include "DisplayDriverPainter.h"
|
#include "DisplayDriverPainter.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
@@ -50,7 +56,6 @@
|
|||||||
|
|
||||||
Desktop::Desktop()
|
Desktop::Desktop()
|
||||||
: fWinBorderList(64),
|
: fWinBorderList(64),
|
||||||
fWinLock("desktop window list lock"),
|
|
||||||
fRootLayerList(2),
|
fRootLayerList(2),
|
||||||
fActiveRootLayer(NULL),
|
fActiveRootLayer(NULL),
|
||||||
fScreenList(2),
|
fScreenList(2),
|
||||||
@@ -402,19 +407,84 @@ Desktop::SetWinBorderFeel(WinBorder *winBorder, uint32 feel)
|
|||||||
|
|
||||||
|
|
||||||
WinBorder *
|
WinBorder *
|
||||||
Desktop::FindWinBorderByServerWindowTokenAndTeamID(int32 token, team_id teamID)
|
Desktop::FindWinBorderByClientToken(int32 token, team_id teamID)
|
||||||
{
|
{
|
||||||
WinBorder *wb;
|
BAutolock locker(this);
|
||||||
|
|
||||||
Lock();
|
WinBorder *wb;
|
||||||
for (int32 i = 0; (wb = (WinBorder *)fWinBorderList.ItemAt(i)); i++) {
|
for (int32 i = 0; (wb = (WinBorder *)fWinBorderList.ItemAt(i)); i++) {
|
||||||
if (wb->Window()->ClientToken() == token
|
if (wb->Window()->ClientToken() == token
|
||||||
&& wb->Window()->ClientTeam() == teamID)
|
&& wb->Window()->ClientTeam() == teamID)
|
||||||
break;
|
return wb;
|
||||||
}
|
}
|
||||||
Unlock();
|
|
||||||
|
|
||||||
return wb;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Desktop::WriteWindowList(team_id team, BPrivate::LinkSender& sender)
|
||||||
|
{
|
||||||
|
BAutolock locker(this);
|
||||||
|
|
||||||
|
// compute the number of windows
|
||||||
|
|
||||||
|
int32 count = 0;
|
||||||
|
if (team >= B_OK) {
|
||||||
|
for (int32 i = 0; i < fWinBorderList.CountItems(); i++) {
|
||||||
|
WinBorder* border = (WinBorder*)fWinBorderList.ItemAt(i);
|
||||||
|
|
||||||
|
if (border->Window()->ClientTeam() == team)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
count = fWinBorderList.CountItems();
|
||||||
|
|
||||||
|
// write list
|
||||||
|
|
||||||
|
sender.StartMessage(SERVER_TRUE);
|
||||||
|
sender.Attach<int32>(count);
|
||||||
|
|
||||||
|
for (int32 i = 0; i < fWinBorderList.CountItems(); i++) {
|
||||||
|
WinBorder* border = (WinBorder*)fWinBorderList.ItemAt(i);
|
||||||
|
|
||||||
|
if (team >= B_OK && border->Window()->ClientTeam() != team)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sender.Attach<int32>(border->Window()->ServerToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Desktop::WriteWindowInfo(int32 serverToken, BPrivate::LinkSender& sender)
|
||||||
|
{
|
||||||
|
BAutolock locker(this);
|
||||||
|
BAutolock tokenLocker(BPrivate::gDefaultTokens);
|
||||||
|
|
||||||
|
ServerWindow* window;
|
||||||
|
if (BPrivate::gDefaultTokens.GetToken(serverToken,
|
||||||
|
B_SERVER_TOKEN, (void**)&window) != B_OK) {
|
||||||
|
sender.StartMessage(B_ENTRY_NOT_FOUND);
|
||||||
|
sender.Flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window_info info;
|
||||||
|
window->GetInfo(info);
|
||||||
|
|
||||||
|
int32 length = window->Title() ? strlen(window->Title()) : 0;
|
||||||
|
|
||||||
|
sender.StartMessage(B_OK);
|
||||||
|
sender.Attach<int32>(sizeof(window_info) + length + 1);
|
||||||
|
sender.Attach(&info, sizeof(window_info));
|
||||||
|
if (length > 0)
|
||||||
|
sender.Attach(window->Title(), length + 1);
|
||||||
|
else
|
||||||
|
sender.Attach<char>('\0');
|
||||||
|
sender.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+26
-26
@@ -1,31 +1,38 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2005, Haiku, Inc. All rights reserved.
|
* Copyright 2001-2005, Haiku.
|
||||||
// Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// File Name: Desktop.h
|
* Authors:
|
||||||
// Author: Adi Oanca <[email protected]>
|
* Adrian Oanca <[email protected]>
|
||||||
// Stephan Aßmus <[email protected]>
|
* Stephan Aßmus <[email protected]>
|
||||||
// Description: Class used to encapsulate desktop management
|
* Axel Dörfler, [email protected]
|
||||||
//
|
*/
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#ifndef _DESKTOP_H_
|
#ifndef _DESKTOP_H_
|
||||||
#define _DESKTOP_H_
|
#define _DESKTOP_H_
|
||||||
|
|
||||||
|
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <ServerScreen.h>
|
#include <Autolock.h>
|
||||||
|
|
||||||
|
#include "ServerScreen.h"
|
||||||
|
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BPortLink;
|
|
||||||
class DisplayDriver;
|
class DisplayDriver;
|
||||||
class HWInterface;
|
class HWInterface;
|
||||||
class Layer;
|
class Layer;
|
||||||
class RootLayer;
|
class RootLayer;
|
||||||
class WinBorder;
|
class WinBorder;
|
||||||
|
|
||||||
class Desktop {
|
namespace BPrivate {
|
||||||
|
class LinkSender;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Desktop : public BLocker {
|
||||||
public:
|
public:
|
||||||
// startup methods
|
// startup methods
|
||||||
Desktop();
|
Desktop();
|
||||||
@@ -64,13 +71,11 @@ class Desktop {
|
|||||||
inline int32 CountRootLayers() const
|
inline int32 CountRootLayers() const
|
||||||
{ return fRootLayerList.CountItems(); }
|
{ return fRootLayerList.CountItems(); }
|
||||||
|
|
||||||
|
|
||||||
inline DisplayDriver* GetDisplayDriver() const
|
inline DisplayDriver* GetDisplayDriver() const
|
||||||
{ return ScreenAt(0)->GetDisplayDriver(); }
|
{ return ScreenAt(0)->GetDisplayDriver(); }
|
||||||
inline HWInterface* GetHWInterface() const
|
inline HWInterface* GetHWInterface() const
|
||||||
{ return ScreenAt(0)->GetHWInterface(); }
|
{ return ScreenAt(0)->GetHWInterface(); }
|
||||||
|
|
||||||
|
|
||||||
// Methods for layer(WinBorder) manipulation.
|
// Methods for layer(WinBorder) manipulation.
|
||||||
void AddWinBorder(WinBorder *winBorder);
|
void AddWinBorder(WinBorder *winBorder);
|
||||||
void RemoveWinBorder(WinBorder *winBorder);
|
void RemoveWinBorder(WinBorder *winBorder);
|
||||||
@@ -81,8 +86,9 @@ class Desktop {
|
|||||||
void RemoveWinBorderFromSubset(WinBorder *winBorder,
|
void RemoveWinBorderFromSubset(WinBorder *winBorder,
|
||||||
WinBorder *fromWinBorder);
|
WinBorder *fromWinBorder);
|
||||||
|
|
||||||
WinBorder* FindWinBorderByServerWindowTokenAndTeamID(int32 token,
|
WinBorder* FindWinBorderByClientToken(int32 token, team_id teamID);
|
||||||
team_id teamID);
|
//WinBorder* FindWinBorderByServerToken(int32 token);
|
||||||
|
|
||||||
// get list of registed windows
|
// get list of registed windows
|
||||||
const BList& WindowList() const
|
const BList& WindowList() const
|
||||||
{
|
{
|
||||||
@@ -91,13 +97,8 @@ class Desktop {
|
|||||||
return fWinBorderList;
|
return fWinBorderList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// locking with regards to registered windows list
|
void WriteWindowList(team_id team, BPrivate::LinkSender& sender);
|
||||||
bool Lock()
|
void WriteWindowInfo(int32 serverToken, BPrivate::LinkSender& sender);
|
||||||
{ return fWinLock.Lock(); }
|
|
||||||
void Unlock()
|
|
||||||
{ return fWinLock.Unlock(); }
|
|
||||||
bool IsLocked() const
|
|
||||||
{ return fWinLock.IsLocked(); }
|
|
||||||
|
|
||||||
// Methods for various desktop stuff handled by the server
|
// Methods for various desktop stuff handled by the server
|
||||||
void SetScrollBarInfo(const scroll_bar_info &info);
|
void SetScrollBarInfo(const scroll_bar_info &info);
|
||||||
@@ -119,7 +120,6 @@ class Desktop {
|
|||||||
void _AddGraphicsCard(HWInterface* interface);
|
void _AddGraphicsCard(HWInterface* interface);
|
||||||
|
|
||||||
BList fWinBorderList;
|
BList fWinBorderList;
|
||||||
BLocker fWinLock;
|
|
||||||
|
|
||||||
BList fRootLayerList;
|
BList fRootLayerList;
|
||||||
RootLayer* fActiveRootLayer;
|
RootLayer* fActiveRootLayer;
|
||||||
@@ -135,4 +135,4 @@ class Desktop {
|
|||||||
|
|
||||||
extern Desktop *gDesktop;
|
extern Desktop *gDesktop;
|
||||||
|
|
||||||
#endif // _DESKTOP_H_
|
#endif // _DESKTOP_H_
|
||||||
|
|||||||
@@ -609,6 +609,20 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
// LayerData ld;
|
// LayerData ld;
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case AS_GET_WINDOW_LIST:
|
||||||
|
team_id team;
|
||||||
|
link.Read<team_id>(&team);
|
||||||
|
|
||||||
|
gDesktop->WriteWindowList(team, fLink.Sender());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AS_GET_WINDOW_INFO:
|
||||||
|
int32 serverToken;
|
||||||
|
link.Read<int32>(&serverToken);
|
||||||
|
|
||||||
|
gDesktop->WriteWindowInfo(serverToken, fLink.Sender());
|
||||||
|
break;
|
||||||
|
|
||||||
case AS_UPDATE_COLORS:
|
case AS_UPDATE_COLORS:
|
||||||
{
|
{
|
||||||
// NOTE: R2: Eventually we will have windows which will notify their children of changes in
|
// NOTE: R2: Eventually we will have windows which will notify their children of changes in
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <ViewAux.h>
|
#include <ViewAux.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <TokenSpace.h>
|
||||||
|
#include <WindowInfo.h>
|
||||||
|
|
||||||
#include "AppServer.h"
|
#include "AppServer.h"
|
||||||
#include "BGet++.h"
|
#include "BGet++.h"
|
||||||
@@ -87,6 +89,8 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app,
|
|||||||
fCurrentLayer(NULL)
|
fCurrentLayer(NULL)
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow(%s)::ServerWindow()\n", title));
|
STRACE(("ServerWindow(%s)::ServerWindow()\n", title));
|
||||||
|
|
||||||
|
fServerToken = BPrivate::gDefaultTokens.NewToken(B_SERVER_TOKEN, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,6 +106,8 @@ ServerWindow::~ServerWindow()
|
|||||||
|
|
||||||
free(const_cast<char *>(fTitle));
|
free(const_cast<char *>(fTitle));
|
||||||
|
|
||||||
|
BPrivate::gDefaultTokens.RemoveToken(fServerToken);
|
||||||
|
|
||||||
STRACE(("#ServerWindow(%s) will exit NOW\n", fTitle));
|
STRACE(("#ServerWindow(%s) will exit NOW\n", fTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,6 +323,31 @@ ServerWindow::NotifyScreenModeChanged(const BRect frame, const color_space color
|
|||||||
SendMessageToClient(&msg);
|
SendMessageToClient(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerWindow::GetInfo(window_info& info)
|
||||||
|
{
|
||||||
|
info.team = ClientTeam();
|
||||||
|
info.server_token = ServerToken();
|
||||||
|
|
||||||
|
info.thread = Thread();
|
||||||
|
info.client_token = ClientToken();
|
||||||
|
info.client_port = fClientLooperPort;
|
||||||
|
info.workspaces = fWinBorder->Workspaces();
|
||||||
|
|
||||||
|
info.layer = 0; // ToDo: what is this???
|
||||||
|
info.type = kNormalWindow; // ToDo: do this for real
|
||||||
|
info.flags = fWinBorder->WindowFlags();
|
||||||
|
info.window_left = (int)floor(fWinBorder->Frame().left);
|
||||||
|
info.window_top = (int)floor(fWinBorder->Frame().top);
|
||||||
|
info.window_right = (int)floor(fWinBorder->Frame().right);
|
||||||
|
info.window_bottom = (int)floor(fWinBorder->Frame().bottom);
|
||||||
|
|
||||||
|
info.show_hide_level = fWinBorder->IsHidden() ? 1 : -1; // ???
|
||||||
|
info.is_mini = fWinBorder->IsHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets the font state for a layer
|
\brief Sets the font state for a layer
|
||||||
\param layer The layer to set the font
|
\param layer The layer to set the font
|
||||||
@@ -1185,15 +1216,15 @@ myRootLayer->Unlock();
|
|||||||
case AS_ADD_TO_SUBSET:
|
case AS_ADD_TO_SUBSET:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message AS_ADD_TO_SUBSET\n", Title()));
|
STRACE(("ServerWindow %s: Message AS_ADD_TO_SUBSET\n", Title()));
|
||||||
WinBorder *wb;
|
WinBorder *windowBorder;
|
||||||
int32 mainToken;
|
int32 mainToken;
|
||||||
team_id teamID;
|
team_id teamID;
|
||||||
|
|
||||||
link.Read<int32>(&mainToken);
|
link.Read<int32>(&mainToken);
|
||||||
link.Read(&teamID, sizeof(team_id));
|
link.Read(&teamID, sizeof(team_id));
|
||||||
|
|
||||||
wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
|
windowBorder = gDesktop->FindWinBorderByClientToken(mainToken, teamID);
|
||||||
if (wb) {
|
if (windowBorder) {
|
||||||
fLink.StartMessage(SERVER_TRUE);
|
fLink.StartMessage(SERVER_TRUE);
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
|
|
||||||
@@ -1201,7 +1232,7 @@ myRootLayer->Unlock();
|
|||||||
BPrivate::PortLink msg(-1, -1);
|
BPrivate::PortLink msg(-1, -1);
|
||||||
msg.StartMessage(AS_ROOTLAYER_ADD_TO_SUBSET);
|
msg.StartMessage(AS_ROOTLAYER_ADD_TO_SUBSET);
|
||||||
msg.Attach<WinBorder*>(fWinBorder);
|
msg.Attach<WinBorder*>(fWinBorder);
|
||||||
msg.Attach<WinBorder*>(wb);
|
msg.Attach<WinBorder*>(windowBorder);
|
||||||
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
||||||
} else {
|
} else {
|
||||||
fLink.StartMessage(SERVER_FALSE);
|
fLink.StartMessage(SERVER_FALSE);
|
||||||
@@ -1212,22 +1243,22 @@ myRootLayer->Unlock();
|
|||||||
case AS_REM_FROM_SUBSET:
|
case AS_REM_FROM_SUBSET:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message AS_REM_FROM_SUBSET\n", Title()));
|
STRACE(("ServerWindow %s: Message AS_REM_FROM_SUBSET\n", Title()));
|
||||||
WinBorder *wb;
|
WinBorder *windowBorder;
|
||||||
int32 mainToken;
|
int32 mainToken;
|
||||||
team_id teamID;
|
team_id teamID;
|
||||||
|
|
||||||
link.Read<int32>(&mainToken);
|
link.Read<int32>(&mainToken);
|
||||||
link.Read(&teamID, sizeof(team_id));
|
link.Read(&teamID, sizeof(team_id));
|
||||||
|
|
||||||
wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
|
windowBorder = gDesktop->FindWinBorderByClientToken(mainToken, teamID);
|
||||||
if (wb) {
|
if (windowBorder) {
|
||||||
fLink.StartMessage(SERVER_TRUE);
|
fLink.StartMessage(SERVER_TRUE);
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
|
|
||||||
BPrivate::PortLink msg(-1, -1);
|
BPrivate::PortLink msg(-1, -1);
|
||||||
msg.StartMessage(AS_ROOTLAYER_REMOVE_FROM_SUBSET);
|
msg.StartMessage(AS_ROOTLAYER_REMOVE_FROM_SUBSET);
|
||||||
msg.Attach<WinBorder*>(fWinBorder);
|
msg.Attach<WinBorder*>(fWinBorder);
|
||||||
msg.Attach<WinBorder*>(wb);
|
msg.Attach<WinBorder*>(windowBorder);
|
||||||
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
||||||
} else {
|
} else {
|
||||||
fLink.StartMessage(SERVER_FALSE);
|
fLink.StartMessage(SERVER_FALSE);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class Workspace;
|
|||||||
class RootLayer;
|
class RootLayer;
|
||||||
class Layer;
|
class Layer;
|
||||||
class ServerPicture;
|
class ServerPicture;
|
||||||
|
struct window_info;
|
||||||
|
|
||||||
#define AS_UPDATE_DECORATOR 'asud'
|
#define AS_UPDATE_DECORATOR 'asud'
|
||||||
#define AS_UPDATE_COLORS 'asuc'
|
#define AS_UPDATE_COLORS 'asuc'
|
||||||
@@ -103,6 +104,9 @@ public:
|
|||||||
|
|
||||||
// server "private" - try not to use.
|
// server "private" - try not to use.
|
||||||
inline int32 ClientToken() const { return fHandlerToken; }
|
inline int32 ClientToken() const { return fHandlerToken; }
|
||||||
|
inline int32 ServerToken() const { return fServerToken; }
|
||||||
|
|
||||||
|
void GetInfo(window_info& info);
|
||||||
|
|
||||||
// ToDo: public??
|
// ToDo: public??
|
||||||
SubWindowList fSubWindowList;
|
SubWindowList fSubWindowList;
|
||||||
@@ -144,6 +148,7 @@ private:
|
|||||||
|
|
||||||
BMessage fClientViewsWithInvalidCoords;
|
BMessage fClientViewsWithInvalidCoords;
|
||||||
|
|
||||||
|
int32 fServerToken;
|
||||||
int32 fHandlerToken;
|
int32 fHandlerToken;
|
||||||
|
|
||||||
Layer* fCurrentLayer;
|
Layer* fCurrentLayer;
|
||||||
|
|||||||
Reference in New Issue
Block a user