- Make MessageForListener a bit more flexible, passing a fix ServerLink is sometimes not enough and a separate sender and receiver is needed.
- Add communication part to restore and save S&T groups. - Fix call of GetDecoratorSettings listener hook. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39534 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,13 +15,22 @@ namespace BPrivate {
|
||||
const int32 kMagicSATIdentifier = 'SATI';
|
||||
|
||||
|
||||
enum sat_target {
|
||||
kStacking,
|
||||
kTiling
|
||||
};
|
||||
|
||||
|
||||
enum sat_messages {
|
||||
kAddWindowToStack,
|
||||
kRemoveWindowFromStack,
|
||||
kRemoveWindowFromStackAt,
|
||||
kCountWindowsOnStack,
|
||||
kWindowOnStackAt,
|
||||
kStackHasWindow
|
||||
kStackHasWindow,
|
||||
|
||||
kSaveAllGroups,
|
||||
kRestoreGroup
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -853,10 +853,10 @@ SATGroup::RestoreGroup(const BMessage& archive, StackAndTile* sat)
|
||||
Tab* bottom = tempHTabs[bottomTab];
|
||||
|
||||
// adding windows to area
|
||||
int64 windowId;
|
||||
uint64 windowId;
|
||||
WindowArea* area = NULL;
|
||||
for (int32 i = 0;
|
||||
areaArchive.FindInt64("window", i, &windowId) == B_OK; i++) {
|
||||
for (int32 i = 0; areaArchive.FindInt64("window", i,
|
||||
(int64*)&windowId) == B_OK; i++) {
|
||||
SATWindow* window = sat->FindSATWindow(windowId);
|
||||
if (!window)
|
||||
continue;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <Debug.h>
|
||||
|
||||
#include "StackAndTilePrivate.h"
|
||||
|
||||
#include "SATGroup.h"
|
||||
#include "ServerApp.h"
|
||||
#include "Window.h"
|
||||
@@ -347,9 +349,15 @@ SATWindow::GetGroup()
|
||||
|
||||
|
||||
bool
|
||||
SATWindow::HandleMessage(SATWindow* sender, BPrivate::ServerLink& link)
|
||||
SATWindow::HandleMessage(SATWindow* sender, BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply)
|
||||
{
|
||||
return StackingEventHandler::HandleMessage(sender, link);
|
||||
int32 target;
|
||||
link.Read<int32>(&target);
|
||||
if (target == kStacking)
|
||||
return StackingEventHandler::HandleMessage(sender, link, reply);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -382,7 +390,8 @@ SATWindow::AddedToGroup(SATGroup* group, WindowArea* area)
|
||||
return false;
|
||||
}
|
||||
|
||||
area->UpdateSizeLimits();
|
||||
if (group->CountItems() > 1)
|
||||
area->UpdateSizeLimits();
|
||||
|
||||
if (group->CountItems() == 2)
|
||||
group->WindowAt(0)->_UpdateSizeLimits();
|
||||
@@ -692,8 +701,10 @@ SATWindow::Id()
|
||||
bool
|
||||
SATWindow::SetSettings(const BMessage& message)
|
||||
{
|
||||
if (message.FindInt64("window_id", (int64*)&fId) != B_OK)
|
||||
uint64 id;
|
||||
if (message.FindInt64("window_id", (int64*)&id) != B_OK)
|
||||
return false;
|
||||
fId = id;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ public:
|
||||
return fGroupCookie->GetWindowArea(); }
|
||||
|
||||
bool HandleMessage(SATWindow* sender,
|
||||
BPrivate::ServerLink& link);
|
||||
BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply);
|
||||
|
||||
bool PropagateToGroup(SATGroup* group,
|
||||
WindowArea* area);
|
||||
|
||||
@@ -24,6 +24,7 @@ using namespace std;
|
||||
|
||||
StackAndTile::StackAndTile()
|
||||
:
|
||||
fDesktop(NULL),
|
||||
fSATKeyPressed(false),
|
||||
fCurrentSATWindow(NULL),
|
||||
fTabIsShifting(false)
|
||||
@@ -48,6 +49,8 @@ StackAndTile::Identifier()
|
||||
void
|
||||
StackAndTile::ListenerRegistered(Desktop* desktop)
|
||||
{
|
||||
fDesktop = desktop;
|
||||
|
||||
WindowList& windows = desktop->AllWindows();
|
||||
for (Window *window = windows.FirstWindow(); window != NULL;
|
||||
window = window->NextWindow(kAllWindowList))
|
||||
@@ -68,13 +71,17 @@ StackAndTile::ListenerUnregistered()
|
||||
|
||||
|
||||
bool
|
||||
StackAndTile::HandleMessage(Window* sender, BPrivate::ServerLink& link)
|
||||
StackAndTile::HandleMessage(Window* sender, BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply)
|
||||
{
|
||||
if (sender == NULL)
|
||||
return _HandleMessage(link, reply);
|
||||
|
||||
SATWindow* satWindow = GetSATWindow(sender);
|
||||
if (!satWindow)
|
||||
return false;
|
||||
|
||||
return satWindow->HandleMessage(satWindow, link);
|
||||
return satWindow->HandleMessage(satWindow, link, reply);
|
||||
}
|
||||
|
||||
|
||||
@@ -441,6 +448,65 @@ StackAndTile::_ActivateWindow(SATWindow* satWindow)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
StackAndTile::_HandleMessage(BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply)
|
||||
{
|
||||
int32 what;
|
||||
link.Read<int32>(&what);
|
||||
|
||||
switch (what) {
|
||||
case BPrivate::kSaveAllGroups:
|
||||
{
|
||||
BMessage allGroupsArchive;
|
||||
GroupIterator groups(this, fDesktop);
|
||||
while (true) {
|
||||
SATGroup* group = groups.NextGroup();
|
||||
if (group == NULL)
|
||||
break;
|
||||
if (group->CountItems() <= 1)
|
||||
continue;
|
||||
BMessage groupArchive;
|
||||
if (group->ArchiveGroup(groupArchive) != B_OK)
|
||||
continue;
|
||||
allGroupsArchive.AddMessage("group", &groupArchive);
|
||||
}
|
||||
int32 size = allGroupsArchive.FlattenedSize();
|
||||
char buffer[size];
|
||||
if (allGroupsArchive.Flatten(buffer, size) == B_OK) {
|
||||
reply.StartMessage(B_OK);
|
||||
reply.Attach<int32>(size);
|
||||
reply.Attach(buffer, size);
|
||||
} else
|
||||
reply.StartMessage(B_ERROR);
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
|
||||
case BPrivate::kRestoreGroup:
|
||||
{
|
||||
int32 size;
|
||||
if (link.Read<int32>(&size) == B_OK) {
|
||||
char buffer[size];
|
||||
BMessage group;
|
||||
if (link.Read(buffer, size) == B_OK
|
||||
&& group.Unflatten(buffer) == B_OK) {
|
||||
status_t status = SATGroup::RestoreGroup(group, this);
|
||||
reply.StartMessage(status);
|
||||
reply.Flush();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
GroupIterator::GroupIterator(StackAndTile* sat, Desktop* desktop)
|
||||
:
|
||||
fStackAndTile(sat),
|
||||
|
||||
@@ -48,7 +48,8 @@ public:
|
||||
virtual void ListenerUnregistered();
|
||||
|
||||
virtual bool HandleMessage(Window* sender,
|
||||
BPrivate::ServerLink& link);
|
||||
BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply);
|
||||
|
||||
virtual void WindowAdded(Window* window);
|
||||
virtual void WindowRemoved(Window* window);
|
||||
@@ -95,6 +96,10 @@ private:
|
||||
void _StartSAT();
|
||||
void _StopSAT();
|
||||
void _ActivateWindow(SATWindow* window);
|
||||
bool _HandleMessage(BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply);
|
||||
|
||||
Desktop* fDesktop;
|
||||
|
||||
bool fSATKeyPressed;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ const float kMaxTabWidth = 165.;
|
||||
|
||||
bool
|
||||
StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
BPrivate::ServerLink& link)
|
||||
BPrivate::LinkReceiver& link, BPrivate::LinkSender& reply)
|
||||
{
|
||||
Desktop* desktop = sender->GetDesktop();
|
||||
StackAndTile* stackAndTile = sender->GetStackAndTile();
|
||||
@@ -63,8 +63,8 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
SATWindow* parent = area->WindowList().ItemAt(position);
|
||||
Window* window = desktop->WindowForClientLooperPort(port);
|
||||
if (!parent || !window) {
|
||||
link.StartMessage(B_BAD_VALUE);
|
||||
link.Flush();
|
||||
reply.StartMessage(B_BAD_VALUE);
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
if (!parent->StackWindow(candidate))
|
||||
return false;
|
||||
|
||||
link.StartMessage(B_OK);
|
||||
link.Flush();
|
||||
reply.StartMessage(B_OK);
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
case kRemoveWindowFromStack:
|
||||
@@ -94,8 +94,8 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
|
||||
Window* window = desktop->WindowForClientLooperPort(port);
|
||||
if (!window) {
|
||||
link.StartMessage(B_BAD_VALUE);
|
||||
link.Flush();
|
||||
reply.StartMessage(B_BAD_VALUE);
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
SATWindow* candidate = stackAndTile->GetSATWindow(window);
|
||||
@@ -116,8 +116,8 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
return false;
|
||||
SATWindow* removeWindow = area->WindowList().ItemAt(position);
|
||||
if (!removeWindow) {
|
||||
link.StartMessage(B_BAD_VALUE);
|
||||
link.Flush();
|
||||
reply.StartMessage(B_BAD_VALUE);
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
return false;
|
||||
|
||||
ServerWindow* window = removeWindow->GetWindow()->ServerWindow();
|
||||
link.StartMessage(B_OK);
|
||||
link.Attach<port_id>(window->ClientLooperPort());
|
||||
link.Attach<int32>(window->ClientToken());
|
||||
link.Attach<team_id>(window->ClientTeam());
|
||||
link.Flush();
|
||||
reply.StartMessage(B_OK);
|
||||
reply.Attach<port_id>(window->ClientLooperPort());
|
||||
reply.Attach<int32>(window->ClientToken());
|
||||
reply.Attach<team_id>(window->ClientTeam());
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
case kCountWindowsOnStack:
|
||||
@@ -137,9 +137,9 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
WindowArea* area = sender->GetWindowArea();
|
||||
if (!area)
|
||||
return false;
|
||||
link.StartMessage(B_OK);
|
||||
link.Attach<int32>(area->WindowList().CountItems());
|
||||
link.Flush();
|
||||
reply.StartMessage(B_OK);
|
||||
reply.Attach<int32>(area->WindowList().CountItems());
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
case kWindowOnStackAt:
|
||||
@@ -152,17 +152,17 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
return false;
|
||||
SATWindow* satWindow = area->WindowList().ItemAt(position);
|
||||
if (!satWindow) {
|
||||
link.StartMessage(B_BAD_VALUE);
|
||||
link.Flush();
|
||||
reply.StartMessage(B_BAD_VALUE);
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
|
||||
ServerWindow* window = satWindow->GetWindow()->ServerWindow();
|
||||
link.StartMessage(B_OK);
|
||||
link.Attach<port_id>(window->ClientLooperPort());
|
||||
link.Attach<int32>(window->ClientToken());
|
||||
link.Attach<team_id>(window->ClientTeam());
|
||||
link.Flush();
|
||||
reply.StartMessage(B_OK);
|
||||
reply.Attach<port_id>(window->ClientLooperPort());
|
||||
reply.Attach<int32>(window->ClientToken());
|
||||
reply.Attach<team_id>(window->ClientTeam());
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
case kStackHasWindow:
|
||||
@@ -177,8 +177,8 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
|
||||
Window* window = desktop->WindowForClientLooperPort(port);
|
||||
if (!window) {
|
||||
link.StartMessage(B_BAD_VALUE);
|
||||
link.Flush();
|
||||
reply.StartMessage(B_BAD_VALUE);
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
SATWindow* candidate = stackAndTile->GetSATWindow(window);
|
||||
@@ -188,9 +188,9 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||
WindowArea* area = sender->GetWindowArea();
|
||||
if (!area)
|
||||
return false;
|
||||
link.StartMessage(B_OK);
|
||||
link.Attach<bool>(area->WindowList().HasItem(candidate));
|
||||
link.Flush();
|
||||
reply.StartMessage(B_OK);
|
||||
reply.Attach<bool>(area->WindowList().HasItem(candidate));
|
||||
reply.Flush();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -19,7 +19,8 @@ class StackingEventHandler
|
||||
{
|
||||
public:
|
||||
static bool HandleMessage(SATWindow* sender,
|
||||
BPrivate::ServerLink& link);
|
||||
BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2078,7 +2078,6 @@ Desktop::WriteWindowInfo(int32 serverToken, BPrivate::LinkSender& sender)
|
||||
::Window* tmp = window->Window();
|
||||
if (tmp) {
|
||||
BMessage message;
|
||||
GetDecoratorSettings(tmp, message);
|
||||
if (tmp->GetDecoratorSettings(&message)) {
|
||||
BRect tabFrame;
|
||||
message.FindRect("tab frame", &tabFrame);
|
||||
@@ -2445,6 +2444,27 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
break;
|
||||
}
|
||||
|
||||
case AS_TALK_TO_DESKTOP_LISTENER:
|
||||
{
|
||||
port_id clientReplyPort;
|
||||
if (link.Read<port_id>(&clientReplyPort) != B_OK)
|
||||
break;
|
||||
|
||||
BPrivate::LinkSender reply(clientReplyPort);
|
||||
LockAllWindows();
|
||||
if (MessageForListener(NULL, link, reply)) {
|
||||
UnlockAllWindows();
|
||||
break;
|
||||
}
|
||||
|
||||
// unhandled message at least send an error if needed
|
||||
if (link.NeedsReply()) {
|
||||
reply.StartMessage(B_ERROR);
|
||||
reply.Flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// ToDo: Remove this again. It is a message sent by the
|
||||
// invalidate_on_exit kernel debugger add-on to trigger a redraw
|
||||
// after exiting a kernel debugger session.
|
||||
|
||||
@@ -49,14 +49,14 @@ DesktopObservable::GetDesktopListenerList()
|
||||
|
||||
bool
|
||||
DesktopObservable::MessageForListener(Window* sender,
|
||||
BPrivate::ServerLink& link)
|
||||
BPrivate::LinkReceiver& link, BPrivate::LinkSender& reply)
|
||||
{
|
||||
int32 identifier;
|
||||
link.Read<int32>(&identifier);
|
||||
for (DesktopListener* listener = fDesktopListenerList.First();
|
||||
listener != NULL; listener = fDesktopListenerList.GetNext(listener)) {
|
||||
if (listener->Identifier() == identifier) {
|
||||
if (!listener->HandleMessage(sender, link))
|
||||
if (!listener->HandleMessage(sender, link, reply))
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ public:
|
||||
virtual void ListenerUnregistered() = 0;
|
||||
|
||||
virtual bool HandleMessage(Window* sender,
|
||||
BPrivate::ServerLink& link) = 0;
|
||||
BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply) = 0;
|
||||
|
||||
virtual void WindowAdded(Window* window) = 0;
|
||||
virtual void WindowRemoved(Window* window) = 0;
|
||||
@@ -85,7 +86,8 @@ public:
|
||||
const DesktopListenerDLList& GetDesktopListenerList();
|
||||
|
||||
bool MessageForListener(Window* sender,
|
||||
BPrivate::ServerLink& link);
|
||||
BPrivate::LinkReceiver& link,
|
||||
BPrivate::LinkSender& reply);
|
||||
|
||||
void NotifyWindowAdded(Window* window);
|
||||
void NotifyWindowRemoved(Window* window);
|
||||
|
||||
@@ -1161,7 +1161,8 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
|
||||
case AS_TALK_TO_DESKTOP_LISTENER:
|
||||
{
|
||||
if (fDesktop->MessageForListener(fWindow, fLink))
|
||||
if (fDesktop->MessageForListener(fWindow, fLink.Receiver(),
|
||||
fLink.Sender()))
|
||||
break;
|
||||
// unhandled message at least send an error if needed
|
||||
if (link.NeedsReply()) {
|
||||
|
||||
@@ -1072,6 +1072,9 @@ Window::SetDecoratorSettings(const BMessage& settings, BRegion& dirty)
|
||||
bool
|
||||
Window::GetDecoratorSettings(BMessage* settings)
|
||||
{
|
||||
if (fDesktop)
|
||||
fDesktop->GetDecoratorSettings(this, *settings);
|
||||
|
||||
if (fDecorator)
|
||||
return fDecorator->GetSettings(settings);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user