[haiku-commits] r39534 - in haiku/trunk: headers/private/interface src/add-ons/decorators/SATDecorator src/servers/app

Author: czeidler
Date: 2010-11-20 07:47:20 +0100 (Sat, 20 Nov 2010)
New Revision: 39534
Changeset: http://dev.haiku-os.org/changeset/39534

Modified:
   haiku/trunk/headers/private/interface/StackAndTilePrivate.h
   haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp
   haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp
   haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h
   haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp
   haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h
   haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp
   haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h
   haiku/trunk/src/servers/app/Desktop.cpp
   haiku/trunk/src/servers/app/DesktopListener.cpp
   haiku/trunk/src/servers/app/DesktopListener.h
   haiku/trunk/src/servers/app/ServerWindow.cpp
   haiku/trunk/src/servers/app/Window.cpp
Log:
- 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.



Modified: haiku/trunk/headers/private/interface/StackAndTilePrivate.h
===================================================================
--- haiku/trunk/headers/private/interface/StackAndTilePrivate.h 2010-11-20 
04:30:49 UTC (rev 39533)
+++ haiku/trunk/headers/private/interface/StackAndTilePrivate.h 2010-11-20 
06:47:20 UTC (rev 39534)
@@ -15,13 +15,22 @@
 const int32 kMagicSATIdentifier = 'SATI';
 
 
+enum sat_target {
+       kStacking,
+       kTiling
+};
+
+
 enum sat_messages {
        kAddWindowToStack,
        kRemoveWindowFromStack,
        kRemoveWindowFromStackAt,
        kCountWindowsOnStack,
        kWindowOnStackAt,
-       kStackHasWindow
+       kStackHasWindow,
+
+       kSaveAllGroups,
+       kRestoreGroup
 };
 
 

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp        
2010-11-20 04:30:49 UTC (rev 39533)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp        
2010-11-20 06:47:20 UTC (rev 39534)
@@ -853,10 +853,10 @@
                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;

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp       
2010-11-20 04:30:49 UTC (rev 39533)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp       
2010-11-20 06:47:20 UTC (rev 39534)
@@ -11,6 +11,8 @@
 
 #include <Debug.h>
 
+#include "StackAndTilePrivate.h"
+
 #include "SATGroup.h"
 #include "ServerApp.h"
 #include "Window.h"
@@ -347,9 +349,15 @@
 
 
 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 @@
                return false;
        }
 
-       area->UpdateSizeLimits();
+       if (group->CountItems() > 1)
+               area->UpdateSizeLimits();
 
        if (group->CountItems() == 2)
                group->WindowAt(0)->_UpdateSizeLimits();
@@ -692,8 +701,10 @@
 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;
 }
 

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2010-11-20 
04:30:49 UTC (rev 39533)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2010-11-20 
06:47:20 UTC (rev 39534)
@@ -85,7 +85,8 @@
                                                                        return 
fGroupCookie->GetWindowArea(); }
 
                        bool                            
HandleMessage(SATWindow* sender,
-                                                                       
BPrivate::ServerLink& link);
+                                                                       
BPrivate::LinkReceiver& link,
+                                                                       
BPrivate::LinkSender& reply);
 
                        bool                            
PropagateToGroup(SATGroup* group,
                                                                        
WindowArea* area);

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp    
2010-11-20 04:30:49 UTC (rev 39533)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp    
2010-11-20 06:47:20 UTC (rev 39534)
@@ -24,6 +24,7 @@
 
 StackAndTile::StackAndTile()
        :
+       fDesktop(NULL),
        fSATKeyPressed(false),
        fCurrentSATWindow(NULL),
        fTabIsShifting(false)
@@ -48,6 +49,8 @@
 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 @@
 
 
 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 @@
 }
 
 
+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),

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h      
2010-11-20 04:30:49 UTC (rev 39533)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h      
2010-11-20 06:47:20 UTC (rev 39534)
@@ -48,7 +48,8 @@
        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,7 +96,11 @@
                        void                            _StartSAT();
                        void                            _StopSAT();
                        void                            
_ActivateWindow(SATWindow* window);
+                       bool                            
_HandleMessage(BPrivate::LinkReceiver& link,
+                                                                       
BPrivate::LinkSender& reply);
 
+                       Desktop*                        fDesktop;
+
                        bool                            fSATKeyPressed;
                
                        SATWindowMap            fSATWindowMap;

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp        
2010-11-20 04:30:49 UTC (rev 39533)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp        
2010-11-20 06:47:20 UTC (rev 39534)
@@ -33,7 +33,7 @@
 
 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 @@
                        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 @@
                        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 @@
 
                        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 @@
                                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 @@
                                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 @@
                        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 @@
                                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 @@
 
                        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 @@
                        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:

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h  2010-11-20 
04:30:49 UTC (rev 39533)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h  2010-11-20 
06:47:20 UTC (rev 39534)
@@ -19,7 +19,8 @@
 {
 public:
        static bool                             HandleMessage(SATWindow* sender,
-                                                               
BPrivate::ServerLink& link);
+                                                               
BPrivate::LinkReceiver& link,
+                                                               
BPrivate::LinkSender& reply);
 };
 
 

Modified: haiku/trunk/src/servers/app/Desktop.cpp
===================================================================
--- haiku/trunk/src/servers/app/Desktop.cpp     2010-11-20 04:30:49 UTC (rev 
39533)
+++ haiku/trunk/src/servers/app/Desktop.cpp     2010-11-20 06:47:20 UTC (rev 
39534)
@@ -2078,7 +2078,6 @@
        ::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 @@
                        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.

Modified: haiku/trunk/src/servers/app/DesktopListener.cpp
===================================================================
--- haiku/trunk/src/servers/app/DesktopListener.cpp     2010-11-20 04:30:49 UTC 
(rev 39533)
+++ haiku/trunk/src/servers/app/DesktopListener.cpp     2010-11-20 06:47:20 UTC 
(rev 39534)
@@ -49,14 +49,14 @@
 
 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;
                }

Modified: haiku/trunk/src/servers/app/DesktopListener.h
===================================================================
--- haiku/trunk/src/servers/app/DesktopListener.h       2010-11-20 04:30:49 UTC 
(rev 39533)
+++ haiku/trunk/src/servers/app/DesktopListener.h       2010-11-20 06:47:20 UTC 
(rev 39534)
@@ -32,7 +32,8 @@
        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 @@
        const DesktopListenerDLList&    GetDesktopListenerList();
 
                        bool                            
MessageForListener(Window* sender,
-                                                                       
BPrivate::ServerLink& link);
+                                                                       
BPrivate::LinkReceiver& link,
+                                                                       
BPrivate::LinkSender& reply);
 
                        void                            
NotifyWindowAdded(Window* window);
                        void                            
NotifyWindowRemoved(Window* window);

Modified: haiku/trunk/src/servers/app/ServerWindow.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerWindow.cpp        2010-11-20 04:30:49 UTC 
(rev 39533)
+++ haiku/trunk/src/servers/app/ServerWindow.cpp        2010-11-20 06:47:20 UTC 
(rev 39534)
@@ -1161,7 +1161,8 @@
 
                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()) {

Modified: haiku/trunk/src/servers/app/Window.cpp
===================================================================
--- haiku/trunk/src/servers/app/Window.cpp      2010-11-20 04:30:49 UTC (rev 
39533)
+++ haiku/trunk/src/servers/app/Window.cpp      2010-11-20 06:47:20 UTC (rev 
39534)
@@ -1072,6 +1072,9 @@
 bool
 Window::GetDecoratorSettings(BMessage* settings)
 {
+       if (fDesktop)
+               fDesktop->GetDecoratorSettings(this, *settings);
+
        if (fDecorator)
                return fDecorator->GetSettings(settings);
 


Other related posts:

  • » [haiku-commits] r39534 - in haiku/trunk: headers/private/interface src/add-ons/decorators/SATDecorator src/servers/app - clemens . zeidler