SATDecorator implements event handling and handles the stacking api requests.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38170 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef STACK_AND_TILE_PRIVATE_H
|
||||||
|
#define STACK_AND_TILE_PRIVATE_H
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
|
const int32 kMagicSATIdentifier = 'SATI';
|
||||||
|
|
||||||
|
|
||||||
|
enum sat_messages {
|
||||||
|
kAddWindowToStack,
|
||||||
|
kRemoveWindowFromStack,
|
||||||
|
kRemoveWindowFromStackAt,
|
||||||
|
kCountWindowsOnStack,
|
||||||
|
kWindowOnStackAt,
|
||||||
|
kStackHasWindow
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "DrawingEngine.h"
|
#include "DrawingEngine.h"
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG_SATDECORATOR
|
//#define DEBUG_SATDECORATOR
|
||||||
#ifdef DEBUG_SATDECORATOR
|
#ifdef DEBUG_SATDECORATOR
|
||||||
# define STRACE(x) debug_printf x
|
# define STRACE(x) debug_printf x
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -11,9 +11,13 @@
|
|||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
|
|
||||||
#include "SATGroup.h"
|
#include "SATGroup.h"
|
||||||
|
#include "ServerApp.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
SATWindow::SATWindow(StackAndTile* sat, Window* window)
|
SATWindow::SATWindow(StackAndTile* sat, Window* window)
|
||||||
:
|
:
|
||||||
fWindow(window),
|
fWindow(window),
|
||||||
@@ -71,6 +75,13 @@ SATWindow::GetGroup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SATWindow::HandleMessage(SATWindow* sender, BPrivate::ServerLink& link)
|
||||||
|
{
|
||||||
|
return StackingEventHandler::HandleMessage(sender, link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SATWindow::PropagateToGroup(SATGroup* group, WindowArea* area)
|
SATWindow::PropagateToGroup(SATGroup* group, WindowArea* area)
|
||||||
{
|
{
|
||||||
@@ -126,6 +137,27 @@ SATWindow::RemovedFromGroup(SATGroup* group)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SATWindow::StackWindow(SATWindow* child)
|
||||||
|
{
|
||||||
|
SATGroup* group = GetGroup();
|
||||||
|
WindowArea* area = GetWindowArea();
|
||||||
|
if (!group || !area)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool status = group->AddWindow(child, area, this);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
area->WindowList().ItemAt(0)->SetStackedMode(true);
|
||||||
|
// for the case we are the first added window
|
||||||
|
child->SetStackedMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
DoGroupLayout();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SATWindow::RemovedFromArea(WindowArea* area)
|
SATWindow::RemovedFromArea(WindowArea* area)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,10 +72,16 @@ public:
|
|||||||
|
|
||||||
Window* GetWindow() { return fWindow; }
|
Window* GetWindow() { return fWindow; }
|
||||||
SATDecorator* GetDecorator() { return fDecorator; }
|
SATDecorator* GetDecorator() { return fDecorator; }
|
||||||
|
StackAndTile* GetStackAndTile() { return fStackAndTile; }
|
||||||
|
Desktop* GetDesktop() { return fDesktop; }
|
||||||
//! Can be NULL if memory allocation failed!
|
//! Can be NULL if memory allocation failed!
|
||||||
SATGroup* GetGroup();
|
SATGroup* GetGroup();
|
||||||
WindowArea* GetWindowArea() {
|
WindowArea* GetWindowArea() {
|
||||||
return fGroupCookie->GetWindowArea(); }
|
return fGroupCookie->GetWindowArea(); }
|
||||||
|
|
||||||
|
bool HandleMessage(SATWindow* sender,
|
||||||
|
BPrivate::ServerLink& link);
|
||||||
|
|
||||||
bool PropagateToGroup(SATGroup* group, WindowArea* area);
|
bool PropagateToGroup(SATGroup* group, WindowArea* area);
|
||||||
|
|
||||||
//! Move the window to the tab's position.
|
//! Move the window to the tab's position.
|
||||||
@@ -86,6 +92,8 @@ public:
|
|||||||
bool RemovedFromGroup(SATGroup* group);
|
bool RemovedFromGroup(SATGroup* group);
|
||||||
void RemovedFromArea(WindowArea* area);
|
void RemovedFromArea(WindowArea* area);
|
||||||
|
|
||||||
|
bool StackWindow(SATWindow* child);
|
||||||
|
|
||||||
void FindSnappingCandidates();
|
void FindSnappingCandidates();
|
||||||
bool JoinCandidates();
|
bool JoinCandidates();
|
||||||
void DoGroupLayout();
|
void DoGroupLayout();
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
|
|
||||||
|
#include "StackAndTilePrivate.h"
|
||||||
|
|
||||||
#include "Desktop.h"
|
#include "Desktop.h"
|
||||||
#include "SATWindow.h"
|
#include "SATWindow.h"
|
||||||
#include "Tiling.h"
|
#include "Tiling.h"
|
||||||
@@ -35,6 +37,13 @@ StackAndTile::~StackAndTile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
StackAndTile::Identifier()
|
||||||
|
{
|
||||||
|
return BPrivate::kMagicSATIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StackAndTile::ListenerRegistered(Desktop* desktop)
|
StackAndTile::ListenerRegistered(Desktop* desktop)
|
||||||
{
|
{
|
||||||
@@ -57,6 +66,17 @@ StackAndTile::ListenerUnregistered()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
StackAndTile::HandleMessage(Window* sender, BPrivate::ServerLink& link)
|
||||||
|
{
|
||||||
|
SATWindow* satWindow = GetSATWindow(sender);
|
||||||
|
if (!satWindow)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return satWindow->HandleMessage(satWindow, link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StackAndTile::WindowAdded(Window* window)
|
StackAndTile::WindowAdded(Window* window)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "WindowList.h"
|
#include "WindowList.h"
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG_STACK_AND_TILE
|
//#define DEBUG_STACK_AND_TILE
|
||||||
|
|
||||||
#ifdef DEBUG_STACK_AND_TILE
|
#ifdef DEBUG_STACK_AND_TILE
|
||||||
# define STRACE_SAT(x...) debug_printf("SAT: "x)
|
# define STRACE_SAT(x...) debug_printf("SAT: "x)
|
||||||
@@ -40,10 +40,15 @@ public:
|
|||||||
StackAndTile();
|
StackAndTile();
|
||||||
virtual ~StackAndTile();
|
virtual ~StackAndTile();
|
||||||
|
|
||||||
|
virtual int32 Identifier();
|
||||||
|
|
||||||
// DesktopListener hooks
|
// DesktopListener hooks
|
||||||
virtual void ListenerRegistered(Desktop* desktop);
|
virtual void ListenerRegistered(Desktop* desktop);
|
||||||
virtual void ListenerUnregistered();
|
virtual void ListenerUnregistered();
|
||||||
|
|
||||||
|
virtual bool HandleMessage(Window* sender,
|
||||||
|
BPrivate::ServerLink& link);
|
||||||
|
|
||||||
virtual void WindowAdded(Window* window);
|
virtual void WindowAdded(Window* window);
|
||||||
virtual void WindowRemoved(Window* window);
|
virtual void WindowRemoved(Window* window);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
|
|
||||||
|
#include "StackAndTilePrivate.h"
|
||||||
|
|
||||||
#include "SATWindow.h"
|
#include "SATWindow.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
@@ -23,6 +25,178 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
StackingEventHandler::HandleMessage(SATWindow* sender,
|
||||||
|
BPrivate::ServerLink& link)
|
||||||
|
{
|
||||||
|
Desktop* desktop = sender->GetDesktop();
|
||||||
|
StackAndTile* stackAndTile = sender->GetStackAndTile();
|
||||||
|
|
||||||
|
int32 what;
|
||||||
|
link.Read<int32>(&what);
|
||||||
|
|
||||||
|
switch (what) {
|
||||||
|
case kAddWindowToStack:
|
||||||
|
{
|
||||||
|
port_id port;
|
||||||
|
int32 token;
|
||||||
|
team_id team;
|
||||||
|
link.Read<port_id>(&port);
|
||||||
|
link.Read<int32>(&token);
|
||||||
|
link.Read<team_id>(&team);
|
||||||
|
int32 position;
|
||||||
|
if (link.Read<int32>(&position) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WindowArea* area = sender->GetWindowArea();
|
||||||
|
if (!area)
|
||||||
|
return false;
|
||||||
|
if (position < 0)
|
||||||
|
position = area->WindowList().CountItems() - 1;
|
||||||
|
|
||||||
|
SATWindow* parent = area->WindowList().ItemAt(position);
|
||||||
|
Window* window = desktop->WindowForClientLooperPort(port);
|
||||||
|
if (!parent || !window) {
|
||||||
|
link.StartMessage(B_BAD_VALUE);
|
||||||
|
link.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SATWindow* candidate = stackAndTile->GetSATWindow(window);
|
||||||
|
if (!candidate)
|
||||||
|
return false;
|
||||||
|
if (!parent->StackWindow(candidate))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
link.StartMessage(B_OK);
|
||||||
|
link.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kRemoveWindowFromStack:
|
||||||
|
{
|
||||||
|
port_id port;
|
||||||
|
int32 token;
|
||||||
|
team_id team;
|
||||||
|
link.Read<port_id>(&port);
|
||||||
|
link.Read<int32>(&token);
|
||||||
|
if (link.Read<team_id>(&team) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SATGroup* group = sender->GetGroup();
|
||||||
|
if (!group)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Window* window = desktop->WindowForClientLooperPort(port);
|
||||||
|
if (!window) {
|
||||||
|
link.StartMessage(B_BAD_VALUE);
|
||||||
|
link.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SATWindow* candidate = stackAndTile->GetSATWindow(window);
|
||||||
|
if (!candidate)
|
||||||
|
return false;
|
||||||
|
if (!group->RemoveWindow(candidate))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kRemoveWindowFromStackAt:
|
||||||
|
{
|
||||||
|
int32 position;
|
||||||
|
if (link.Read<int32>(&position) != B_OK)
|
||||||
|
return false;
|
||||||
|
SATGroup* group = sender->GetGroup();
|
||||||
|
WindowArea* area = sender->GetWindowArea();
|
||||||
|
if (!area || !group)
|
||||||
|
return false;
|
||||||
|
SATWindow* removeWindow = area->WindowList().ItemAt(position);
|
||||||
|
if (!removeWindow) {
|
||||||
|
link.StartMessage(B_BAD_VALUE);
|
||||||
|
link.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!group->RemoveWindow(removeWindow))
|
||||||
|
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();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kCountWindowsOnStack:
|
||||||
|
{
|
||||||
|
WindowArea* area = sender->GetWindowArea();
|
||||||
|
if (!area)
|
||||||
|
return false;
|
||||||
|
link.StartMessage(B_OK);
|
||||||
|
link.Attach<int32>(area->WindowList().CountItems());
|
||||||
|
link.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kWindowOnStackAt:
|
||||||
|
{
|
||||||
|
int32 position;
|
||||||
|
if (link.Read<int32>(&position) != B_OK)
|
||||||
|
return false;
|
||||||
|
WindowArea* area = sender->GetWindowArea();
|
||||||
|
if (!area)
|
||||||
|
return false;
|
||||||
|
SATWindow* satWindow = area->WindowList().ItemAt(position);
|
||||||
|
if (!satWindow) {
|
||||||
|
link.StartMessage(B_BAD_VALUE);
|
||||||
|
link.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();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kStackHasWindow:
|
||||||
|
{
|
||||||
|
port_id port;
|
||||||
|
int32 token;
|
||||||
|
team_id team;
|
||||||
|
link.Read<port_id>(&port);
|
||||||
|
link.Read<int32>(&token);
|
||||||
|
if (link.Read<team_id>(&team) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Window* window = desktop->WindowForClientLooperPort(port);
|
||||||
|
if (!window) {
|
||||||
|
link.StartMessage(B_BAD_VALUE);
|
||||||
|
link.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SATWindow* candidate = stackAndTile->GetSATWindow(window);
|
||||||
|
if (!candidate)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WindowArea* area = sender->GetWindowArea();
|
||||||
|
if (!area)
|
||||||
|
return false;
|
||||||
|
link.StartMessage(B_OK);
|
||||||
|
link.Attach<bool>(area->WindowList().HasItem(candidate));
|
||||||
|
link.Flush();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SATStacking::SATStacking(SATWindow* window)
|
SATStacking::SATStacking(SATWindow* window)
|
||||||
:
|
:
|
||||||
fSATWindow(window),
|
fSATWindow(window),
|
||||||
@@ -68,24 +242,11 @@ SATStacking::JoinCandidates()
|
|||||||
{
|
{
|
||||||
if (!fStackingCandidate)
|
if (!fStackingCandidate)
|
||||||
return false;
|
return false;
|
||||||
SATGroup* group = fStackingCandidate->GetGroup();
|
|
||||||
WindowArea* area = fStackingCandidate->GetWindowArea();
|
|
||||||
if (!group || !area) {
|
|
||||||
_ClearSearchResult();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool status = group->AddWindow(fSATWindow, area, fStackingCandidate);
|
bool result = fStackingCandidate->StackWindow(fSATWindow);
|
||||||
|
|
||||||
if (status) {
|
|
||||||
area->WindowList().ItemAt(0)->SetStackedMode(true);
|
|
||||||
// for the case we are the first added window
|
|
||||||
fSATWindow->SetStackedMode(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
fStackingCandidate->DoGroupLayout();
|
|
||||||
_ClearSearchResult();
|
_ClearSearchResult();
|
||||||
return status;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,14 @@
|
|||||||
class SATWindow;
|
class SATWindow;
|
||||||
|
|
||||||
|
|
||||||
|
class StackingEventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool HandleMessage(SATWindow* sender,
|
||||||
|
BPrivate::ServerLink& link);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class SATStacking : public SATSnappingBehaviour {
|
class SATStacking : public SATSnappingBehaviour {
|
||||||
public:
|
public:
|
||||||
SATStacking(SATWindow* window);
|
SATStacking(SATWindow* window);
|
||||||
|
|||||||
Reference in New Issue
Block a user