[haiku-commits] r37801 - haiku/trunk/src/servers/app

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 29 Jul 2010 07:12:46 +0200 (CEST)

Author: czeidler
Date: 2010-07-29 07:12:45 +0200 (Thu, 29 Jul 2010)
New Revision: 37801
Changeset: http://dev.haiku-os.org/changeset/37801

Modified:
   haiku/trunk/src/servers/app/DecorManager.cpp
   haiku/trunk/src/servers/app/DecorManager.h
   haiku/trunk/src/servers/app/Desktop.cpp
   haiku/trunk/src/servers/app/Desktop.h
   haiku/trunk/src/servers/app/ServerApp.cpp
   haiku/trunk/src/servers/app/Window.cpp
   haiku/trunk/src/servers/app/Window.h
Log:
- Make _Windows public.
- Reload all decorators when the decorator has changed in the DecorManager.
- Update copyrights.



Modified: haiku/trunk/src/servers/app/DecorManager.cpp
===================================================================
--- haiku/trunk/src/servers/app/DecorManager.cpp        2010-07-29 02:10:29 UTC 
(rev 37800)
+++ haiku/trunk/src/servers/app/DecorManager.cpp        2010-07-29 05:12:45 UTC 
(rev 37801)
@@ -1,11 +1,14 @@
 /*
- * Copyright (c) 2001-2005, Haiku, Inc.
+ * Copyright (c) 2001-2010, Haiku, Inc.
  * Distributed under the terms of the MIT license.
  *
- * Author: DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ * Author:
+ *             DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ *             Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  */
- 
 
+#include "DecorManager.h"
+
 #include <Directory.h>
 #include <Entry.h>
 #include <File.h>
@@ -20,7 +23,7 @@
 #include "Desktop.h"
 #include "DesktopSettings.h"
 #include "ServerConfig.h"
-#include "DecorManager.h"
+#include "Window.h"
 
 typedef float get_version(void);
 typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect 
rect,
@@ -230,12 +233,13 @@
 
 
 bool
-DecorManager::SetDecorator(int32 index)
+DecorManager::SetDecorator(int32 index, Desktop* desktop)
 {
        DecorInfo* newDecInfo = (DecorInfo*)fDecorList.ItemAt(index);
 
        if (newDecInfo) {
                fCurrentDecor = newDecInfo;
+               _UpdateWindows(desktop);
                return true;
        }
 
@@ -306,3 +310,13 @@
        return NULL;
 }
 
+
+void
+DecorManager::_UpdateWindows(Desktop* desktop)
+{
+       for (int32 i = 0; i < kMaxWorkspaces; i++) {
+               for (Window* window = desktop->Windows(i).LastWindow(); window;
+                               window = window->PreviousWindow(i))
+                       desktop->ReloadDecorator(window);
+       }
+}

Modified: haiku/trunk/src/servers/app/DecorManager.h
===================================================================
--- haiku/trunk/src/servers/app/DecorManager.h  2010-07-29 02:10:29 UTC (rev 
37800)
+++ haiku/trunk/src/servers/app/DecorManager.h  2010-07-29 05:12:45 UTC (rev 
37801)
@@ -2,8 +2,11 @@
  * Copyright (c) 2001-2005, Haiku, Inc.
  * Distributed under the terms of the MIT license.
  *
- * Author: DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ * Author:
+ *             DarkWyrm <bpmagic@xxxxxxxxxxxxxxx>
+ *             Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  */
+
 #ifndef DECOR_MANAGER_H
 #define DECOR_MANAGER_H
 
@@ -35,7 +38,7 @@
                int32           CountDecorators() const;
 
                int32           GetDecorator() const;
-               bool            SetDecorator(int32 index);
+               bool            SetDecorator(int32 index, Desktop* desktop);
                bool            SetR5Decorator(int32 value);
                const char*     GetDecoratorName(int32 index);
 
@@ -47,6 +50,8 @@
                void            _EmptyList();
                DecorInfo*      _FindDecor(const char *name);
 
+               void            _UpdateWindows(Desktop* desktop);
+
                BObjectList<DecorInfo> fDecorList;
                DecorInfo*      fCurrentDecor;
 };

Modified: haiku/trunk/src/servers/app/Desktop.cpp
===================================================================
--- haiku/trunk/src/servers/app/Desktop.cpp     2010-07-29 02:10:29 UTC (rev 
37800)
+++ haiku/trunk/src/servers/app/Desktop.cpp     2010-07-29 05:12:45 UTC (rev 
37801)
@@ -8,6 +8,7 @@
  *             Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  *             Andrej Spielmann <andrej.spielmann@xxxxxxxxxxxx>
  *             Brecht Machiels <brecht@xxxxxxxxxxx>
+ *             Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  */
 
 
@@ -393,7 +394,7 @@
        fSettings = new DesktopSettingsPrivate(fServerReadOnlyMemory);
 
        for (int32 i = 0; i < kMaxWorkspaces; i++) {
-               _Windows(i).SetIndex(i);
+               Windows(i).SetIndex(i);
                
fWorkspaces[i].RestoreConfiguration(*fSettings->WorkspacesMessage(i));
        }
 
@@ -1518,7 +1519,7 @@
                if (i == fCurrentWorkspace && window->IsVisible())
                        visibleBefore = window->VisibleRegion();
 
-               Window* backmost = window->Backmost(_Windows(i).LastWindow(), 
i);
+               Window* backmost = window->Backmost(Windows(i).LastWindow(), i);
                if (backmost != NULL) {
                        // check if the backmost window is really behind it
                        Window* previous = window->PreviousWindow(i);
@@ -1531,13 +1532,13 @@
 
                        if (previous == NULL) {
                                // need to reinsert window before its backmost 
window
-                               _Windows(i).RemoveWindow(window);
-                               _Windows(i).AddWindow(window, 
backmost->NextWindow(i));
+                               Windows(i).RemoveWindow(window);
+                               Windows(i).AddWindow(window, 
backmost->NextWindow(i));
                                changed = true;
                        }
                }
 
-               Window* frontmost = 
window->Frontmost(_Windows(i).FirstWindow(), i);
+               Window* frontmost = window->Frontmost(Windows(i).FirstWindow(), 
i);
                if (frontmost != NULL) {
                        // check if the frontmost window is really in front of 
it
                        Window* next = window->NextWindow(i);
@@ -1550,8 +1551,8 @@
 
                        if (next == NULL) {
                                // need to reinsert window behind its frontmost 
window
-                               _Windows(i).RemoveWindow(window);
-                               _Windows(i).AddWindow(window, frontmost);
+                               Windows(i).RemoveWindow(window);
+                               Windows(i).AddWindow(window, frontmost);
                                changed = true;
                        }
                }
@@ -1900,6 +1901,24 @@
 
 
 void
+Desktop::ReloadDecorator(Window* window)
+{
+       AutoWriteLocker _(fWindowLock);
+
+       BRegion oldBorder;
+       window->GetBorderRegion(&oldBorder);
+
+       window->ReloadDecorator();
+
+       BRegion border;
+       window->GetBorderRegion(&border);
+
+       border.Include(&oldBorder);
+       _RebuildAndRedrawAfterWindowChange(window, border);
+}
+
+
+void
 Desktop::MinimizeApplication(team_id team)
 {
        AutoWriteLocker locker(fWindowLock);
@@ -2068,14 +2087,14 @@
                return;
        }
 
-       int32 count = _Windows(workspace).Count();
+       int32 count = Windows(workspace).Count();
 
        // write list
 
        sender.StartMessage(B_OK);
        sender.Attach<int32>(count);
 
-       for (Window *window = _Windows(workspace).LastWindow(); window != NULL;
+       for (Window *window = Windows(workspace).LastWindow(); window != NULL;
                        window = window->PreviousWindow(workspace)) {
                sender.Attach<int32>(window->ServerWindow()->ServerToken());
        }
@@ -2118,7 +2137,7 @@
 
        int32 count = 0;
 
-       for (Window *window = _Windows(workspace).LastWindow(); window != NULL;
+       for (Window *window = Windows(workspace).LastWindow(); window != NULL;
                        window = window->PreviousWindow(workspace)) {
                team_id team = window->ServerWindow()->ClientTeam();
                if (count > 1) {
@@ -2427,7 +2446,7 @@
 
 
 WindowList&
-Desktop::_Windows(int32 index)
+Desktop::Windows(int32 index)
 {
        return fWorkspaces[index].Windows();
 }
@@ -2452,18 +2471,18 @@
                if (fFront != NULL && fFront->IsNormal()
                        && floating->HasInSubset(fFront)) {
                        // is now visible
-                       if (_Windows(previousWorkspace).HasWindow(floating)
+                       if (Windows(previousWorkspace).HasWindow(floating)
                                && previousWorkspace != nextWorkspace
                                && 
!floating->InSubsetWorkspace(previousWorkspace)) {
                                // but no longer on the previous workspace
-                               
_Windows(previousWorkspace).RemoveWindow(floating);
+                               
Windows(previousWorkspace).RemoveWindow(floating);
                                floating->SetCurrentWorkspace(-1);
                        }
 
-                       if (!_Windows(nextWorkspace).HasWindow(floating)) {
+                       if (!Windows(nextWorkspace).HasWindow(floating)) {
                                // but wasn't before
-                               _Windows(nextWorkspace).AddWindow(floating,
-                                       
floating->Frontmost(_Windows(nextWorkspace).FirstWindow(),
+                               Windows(nextWorkspace).AddWindow(floating,
+                                       
floating->Frontmost(Windows(nextWorkspace).FirstWindow(),
                                        nextWorkspace));
                                floating->SetCurrentWorkspace(nextWorkspace);
                                if (mouseEventWindow != fFront)
@@ -2472,11 +2491,11 @@
                                // TODO: put the floating last in the floating 
window list to
                                // preserve the on screen window order
                        }
-               } else if (_Windows(previousWorkspace).HasWindow(floating)
+               } else if (Windows(previousWorkspace).HasWindow(floating)
                        && !floating->InSubsetWorkspace(previousWorkspace)) {
                        // was visible, but is no longer
 
-                       _Windows(previousWorkspace).RemoveWindow(floating);
+                       Windows(previousWorkspace).RemoveWindow(floating);
                        floating->SetCurrentWorkspace(-1);
                        _HideWindow(floating);
 
@@ -2710,7 +2729,7 @@
                if (workspace_in_workspaces(i, oldWorkspaces)) {
                        // window is on this workspace, is it anymore?
                        if (!workspace_in_workspaces(i, newWorkspaces)) {
-                               _Windows(i).RemoveWindow(window);
+                               Windows(i).RemoveWindow(window);
                                if (fLastWorkspaceFocus[i] == window)
                                        fLastWorkspaceFocus[i] = NULL;
 
@@ -2725,8 +2744,8 @@
                } else {
                        // window was not on this workspace, is it now?
                        if (workspace_in_workspaces(i, newWorkspaces)) {
-                               _Windows(i).AddWindow(window,
-                                       
window->Frontmost(_Windows(i).FirstWindow(), i));
+                               Windows(i).AddWindow(window,
+                                       
window->Frontmost(Windows(i).FirstWindow(), i));
 
                                if (i == CurrentWorkspace()) {
                                        // make the window visible in current 
workspace
@@ -3155,9 +3174,9 @@
                                // But only normal windows are following
                                uint32 oldWorkspaces = 
movedWindow->Workspaces();
 
-                               
_Windows(previousIndex).RemoveWindow(movedWindow);
-                               _Windows(index).AddWindow(movedWindow,
-                                       
movedWindow->Frontmost(_Windows(index).FirstWindow(),
+                               
Windows(previousIndex).RemoveWindow(movedWindow);
+                               Windows(index).AddWindow(movedWindow,
+                                       
movedWindow->Frontmost(Windows(index).FirstWindow(),
                                        index));
 
                                // TODO: subset windows will always flicker 
this way
@@ -3170,9 +3189,9 @@
                                InvokeSetWindowWorkspaces(movedWindow, 
movedWindow->Workspaces());
                        } else {
                                // make sure it's frontmost
-                               _Windows(index).RemoveWindow(movedWindow);
-                               _Windows(index).AddWindow(movedWindow,
-                                       
movedWindow->Frontmost(_Windows(index).FirstWindow(),
+                               Windows(index).RemoveWindow(movedWindow);
+                               Windows(index).AddWindow(movedWindow,
+                                       
movedWindow->Frontmost(Windows(index).FirstWindow(),
                                        index));
                        }
                }
@@ -3223,7 +3242,7 @@
        WindowList windows(kWorkingList);
        BList previousRegions;
 
-       for (Window* window = _Windows(index).FirstWindow();
+       for (Window* window = Windows(index).FirstWindow();
                        window != NULL; window = window->NextWindow(index)) {
                BPoint position = window->Anchor(index).position;
 
@@ -3277,7 +3296,7 @@
        _RebuildClippingForAllWindows(stillAvailableOnScreen);
        _SetBackground(stillAvailableOnScreen);
 
-       for (Window* window = _Windows(index).FirstWindow(); window != NULL;
+       for (Window* window = Windows(index).FirstWindow(); window != NULL;
                        window = window->NextWindow(index)) {
                // send B_WORKSPACE_ACTIVATED message
                window->WorkspaceActivated(index, true);
@@ -3313,7 +3332,7 @@
        // Set new focus, but keep focus to a floating window if still visible
        if (movedWindow != NULL)
                SetFocusWindow(movedWindow);
-       else if (!_Windows(index).HasWindow(FocusWindow())
+       else if (!Windows(index).HasWindow(FocusWindow())
                || (FocusWindow() != NULL && !FocusWindow()->IsFloating()))
                SetFocusWindow(fLastWorkspaceFocus[index]);
 

Modified: haiku/trunk/src/servers/app/Desktop.h
===================================================================
--- haiku/trunk/src/servers/app/Desktop.h       2010-07-29 02:10:29 UTC (rev 
37800)
+++ haiku/trunk/src/servers/app/Desktop.h       2010-07-29 05:12:45 UTC (rev 
37801)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2009, Haiku.
+ * Copyright 2001-2010, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -8,6 +8,7 @@
  *             Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  *             Andrej Spielmann, <andrej.spielmann@xxxxxxxxxxxx>
  *             Brecht Machiels <brecht@xxxxxxxxxxx>
+ *             Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
  */
 #ifndef DESKTOP_H
 #define DESKTOP_H
@@ -232,6 +233,8 @@
                        void                            Redraw();
                        void                            RedrawBackground();
 
+                       void                            ReloadDecorator(Window* 
window);
+
                        BRegion&                        BackgroundRegion()
                                                                        { 
return fBackgroundRegion; }
 
@@ -249,6 +252,7 @@
                                                                        
BPrivate::LinkSender& sender);
 
                        WindowList&                     CurrentWindows();
+                       WindowList&                     Windows(int32 index);
 
 private:
                        void                            _LaunchInputServer();
@@ -257,8 +261,6 @@
                        void                            _DispatchMessage(int32 
code,
                                                                        
BPrivate::LinkReceiver &link);
 
-                       WindowList&                     _Windows(int32 index);
-
                        void                            _UpdateFloating(int32 
previousWorkspace = -1,
                                                                        int32 
nextWorkspace = -1,
                                                                        Window* 
mouseEventWindow = NULL);

Modified: haiku/trunk/src/servers/app/ServerApp.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerApp.cpp   2010-07-29 02:10:29 UTC (rev 
37800)
+++ haiku/trunk/src/servers/app/ServerApp.cpp   2010-07-29 05:12:45 UTC (rev 
37801)
@@ -625,7 +625,7 @@
 
                        int32 index;
                        link.Read<int32>(&index);
-                       if (gDecorManager.SetDecorator(index))
+                       if (gDecorManager.SetDecorator(index, fDesktop))
                                
fDesktop->BroadcastToAllApps(AS_UPDATE_DECORATOR);
                        break;
                }

Modified: haiku/trunk/src/servers/app/Window.cpp
===================================================================
--- haiku/trunk/src/servers/app/Window.cpp      2010-07-29 02:10:29 UTC (rev 
37800)
+++ haiku/trunk/src/servers/app/Window.cpp      2010-07-29 05:12:45 UTC (rev 
37801)
@@ -543,6 +543,20 @@
 
 
 void
+Window::ReloadDecorator()
+{
+       if (fLook != B_NO_BORDER_WINDOW_LOOK) {
+               delete fDecorator;
+               // we need a new decorator
+               fDecorator = gDecorManager.AllocateDecorator(fDesktop, 
fDrawingEngine,
+                       Frame(), Title(), fLook, fFlags);
+               if (IsFocus())
+                       fDecorator->SetFocus(true);
+       }
+}
+
+
+void
 Window::SetScreen(const ::Screen* screen)
 {
        ASSERT_MULTI_WRITE_LOCKED(fDesktop->ScreenLocker());

Modified: haiku/trunk/src/servers/app/Window.h
===================================================================
--- haiku/trunk/src/servers/app/Window.h        2010-07-29 02:10:29 UTC (rev 
37800)
+++ haiku/trunk/src/servers/app/Window.h        2010-07-29 05:12:45 UTC (rev 
37801)
@@ -71,6 +71,8 @@
                        ::EventTarget&          EventTarget() const
                                                                        { 
return fWindow->EventTarget(); }
 
+                       void                            ReloadDecorator();
+
                        void                            SetScreen(const 
::Screen* screen);
                        const ::Screen*         Screen() const;
 


Other related posts: