* Resolved a TODO and got rid of Desktop::ActiveScreen().

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32566 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-08-21 13:34:33 +00:00
parent cc93fbbba8
commit fe7f167df1
6 changed files with 28 additions and 27 deletions

View File

@ -302,9 +302,8 @@ Desktop::Desktop(uid_t userID)
fSubsetWindows(kSubsetList),
fFocusList(kFocusList),
fWorkspacesViews(false),
fWorkspacesLock("workspaces list"),
fActiveScreen(NULL),
fWorkspacesLock("workspaces list"),
fWindowLock("window lock"),
fMouseEventWindow(NULL),
@ -369,9 +368,6 @@ Desktop::Init()
fVirtualScreen.SetConfiguration(*this,
fWorkspaces[0].CurrentScreenConfiguration());
// TODO: temporary workaround, fActiveScreen will be removed
fActiveScreen = fVirtualScreen.ScreenAt(0);
if (fVirtualScreen.HWInterface() == NULL) {
debug_printf("Could not initialize graphics output. Exiting.\n");
return B_ERROR;

View File

@ -113,15 +113,10 @@ public:
int32* buttons) const;
// for use by ServerWindow
// Screen and drawing related methods
Screen* ScreenAt(int32 index) const
{ return fActiveScreen; }
Screen* ActiveScreen() const
{ return fActiveScreen; }
CursorManager& GetCursorManager() { return fCursorManager; }
// Screen and drawing related methods
status_t SetScreenMode(int32 workspace, int32 id,
const display_mode& mode, bool makeDefault);
status_t GetScreenMode(int32 workspace, int32 id,
@ -317,8 +312,6 @@ private:
BObjectList<WorkspacesView> fWorkspacesViews;
BLocker fWorkspacesLock;
Screen* fActiveScreen;
CursorManager fCursorManager;
#if USE_MULTI_LOCKER

View File

@ -2263,11 +2263,11 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
ServerWindow* window = fWindowList.ItemAt(i);
if (window->ClientToken() == clientToken) {
// got it!
// found it!
fLink.StartMessage(B_OK);
fLink.Attach<int32>(B_MAIN_SCREEN_ID.id);
// TODO: for now...
fLink.Attach<int32>(window->Window()->Screen()->ID());
status = B_OK;
break;
}
}
}

View File

@ -3550,14 +3550,14 @@ ServerWindow::_MessageLooper()
void
ServerWindow::ScreenChanged(const BMessage *message)
ServerWindow::ScreenChanged(const BMessage* message)
{
// TODO: execute the stop notification earlier
//HandleDirectConnection(B_DIRECT_STOP);
SendMessageToClient(message);
if (fDirectWindowData != NULL && fDirectWindowData->full_screen) {
BRect screenFrame = fDesktop->ActiveScreen()->Frame();
BRect screenFrame = fWindow->Screen()->Frame();
fDesktop->ResizeWindowBy(fWindow,
screenFrame.Width() - fWindow->Frame().Width(),
screenFrame.Height() - fWindow->Frame().Height());
@ -3575,7 +3575,7 @@ ServerWindow::SendMessageToClient(const BMessage* msg, int32 target) const
target = fClientToken;
BMessenger reply;
BMessage::Private messagePrivate((BMessage *)msg);
BMessage::Private messagePrivate((BMessage*)msg);
return messagePrivate.SendMessage(fClientLooperPort, fClientTeam, target,
0, false, reply);
}
@ -3587,7 +3587,7 @@ ServerWindow::MakeWindow(BRect frame, const char* name,
{
// The non-offscreen ServerWindow uses the DrawingEngine instance from
// the desktop.
return new (nothrow) ::Window(frame, name, look, feel, flags,
return new(std::nothrow) ::Window(frame, name, look, feel, flags,
workspace, this, new (nothrow) DrawingEngine(fDesktop->HWInterface()));
}
@ -3799,8 +3799,7 @@ ServerWindow::_DirectWindowSetFullScreen(bool enable)
fDesktop->HWInterface()->SetCursorVisible(false);
fDirectWindowData->old_window_frame = fWindow->Frame();
BRect screenFrame =
fDesktop->ActiveScreen()->Frame();
BRect screenFrame = fWindow->Screen()->Frame();
fDirectWindowFeel = fWindow->Feel();
fDesktop->MoveWindowBy(fWindow, -fWindow->Frame().left,
-fWindow->Frame().top);

View File

@ -162,9 +162,8 @@ Window::Window(const BRect& frame, const char *name,
uint16 width, height;
uint32 colorSpace;
float frequency;
if (fDesktop->ScreenAt(0)) {
fDesktop->ScreenAt(0)->GetMode(width, height,
colorSpace, frequency);
if (Screen() != NULL) {
Screen()->GetMode(width, height, colorSpace, frequency);
// TODO: MOVE THIS AWAY!!! ResizeBy contains calls to virtual methods!
// Also, there is no TopView()!
fFrame.OffsetTo(B_ORIGIN);
@ -564,6 +563,16 @@ Window::PreviousWindow(int32 index) const
}
::Screen*
Window::Screen() const
{
ASSERT_MULTI_LOCKED(fDesktop->WindowLocker());
// TODO: we need to know which screen the window is on
return fDesktop->VirtualScreen().ScreenAt(0);
}
// #pragma mark -
@ -1147,7 +1156,7 @@ Window::_AlterDeltaForSnap(BPoint& delta, bigtime_t now)
BRect frame = fFrame;
BPoint offsetWithinFrame;
// TODO: Perhaps obtain the usable area (not covered by the Deskbar)?
BRect screenFrame = fDesktop->ActiveScreen()->Frame();
BRect screenFrame = Screen()->Frame();
if (fDecorator) {
BRegion reg;

View File

@ -31,6 +31,7 @@ class Decorator;
class Desktop;
class DrawingEngine;
class EventDispatcher;
class Screen;
class WorkspacesView;
// TODO: move this into a proper place
@ -41,6 +42,7 @@ enum {
UPDATE_EXPOSE = 0x02,
};
class Window {
public:
Window(const BRect& frame, const char *name,
@ -65,6 +67,8 @@ public:
::EventTarget& EventTarget() const
{ return fWindow->EventTarget(); }
::Screen* Screen() const;
// setting and getting the "hard" clipping, you need to have
// WriteLock()ed the clipping!
void SetClipping(BRegion* stillAvailableOnScreen);