* Renamed DirectWindowSupport/Data to DirectWindowInfo.

* Cleanup of the fullscreen stuff.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32743 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-08-27 09:19:40 +00:00
parent 78ca6157b6
commit a5a64d5481
5 changed files with 131 additions and 104 deletions

View File

@ -8,7 +8,7 @@
*/
#include "DirectWindowSupport.h"
#include "DirectWindowInfo.h"
#include <stdio.h>
#include <string.h>
@ -20,13 +20,14 @@
#include "clipping.h"
DirectWindowData::DirectWindowData()
DirectWindowInfo::DirectWindowInfo()
:
full_screen(false),
fBufferInfo(NULL),
fSem(-1),
fAcknowledgeSem(-1),
fBufferArea(-1)
fBufferArea(-1),
fOriginalFeel(B_NORMAL_WINDOW_FEEL),
fFullScreen(false)
{
fBufferArea = create_area("direct area", (void**)&fBufferInfo,
B_ANY_ADDRESS, DIRECT_BUFFER_INFO_AREA_SIZE,
@ -40,7 +41,7 @@ DirectWindowData::DirectWindowData()
}
DirectWindowData::~DirectWindowData()
DirectWindowInfo::~DirectWindowInfo()
{
// this should make the client die in case it's still running
fBufferInfo->bits = NULL;
@ -53,7 +54,7 @@ DirectWindowData::~DirectWindowData()
status_t
DirectWindowData::InitCheck() const
DirectWindowInfo::InitCheck() const
{
if (fBufferArea < B_OK)
return fBufferArea;
@ -67,7 +68,7 @@ DirectWindowData::InitCheck() const
status_t
DirectWindowData::GetSyncData(direct_window_sync_data& data) const
DirectWindowInfo::GetSyncData(direct_window_sync_data& data) const
{
data.area = fBufferArea;
data.disable_sem = fSem;
@ -78,30 +79,7 @@ DirectWindowData::GetSyncData(direct_window_sync_data& data) const
status_t
DirectWindowData::_SyncronizeWithClient()
{
// Releasing this semaphore causes the client to call
// BDirectWindow::DirectConnected()
status_t status = release_sem(fSem);
if (status != B_OK)
return status;
// Wait with a timeout of half a second until the client exits
// from its DirectConnected() implementation
do {
#if 0
status = acquire_sem(fAcknowledgeSem);
#else
status = acquire_sem_etc(fAcknowledgeSem, 1, B_TIMEOUT, 500000);
#endif
} while (status == B_INTERRUPTED);
return status;
}
status_t
DirectWindowData::SetState(direct_buffer_state bufferState,
DirectWindowInfo::SetState(direct_buffer_state bufferState,
direct_driver_state driverState, RenderingBuffer* buffer,
const BRect& windowFrame, const BRegion& clipRegion)
{
@ -142,7 +120,7 @@ DirectWindowData::SetState(direct_buffer_state bufferState,
break;
default:
syslog(LOG_ERR,
"unknown colorspace in DirectWindowData::SetState()!\n");
"unknown colorspace in DirectWindowInfo::SetState()!\n");
fBufferInfo->bits_per_pixel = 0;
break;
}
@ -153,7 +131,6 @@ DirectWindowData::SetState(direct_buffer_state bufferState,
// TODO
fBufferInfo->window_bounds = to_clipping_rect(windowFrame);
// TODO: Review this
const int32 kMaxClipRectsCount = (DIRECT_BUFFER_INFO_AREA_SIZE
- sizeof(direct_buffer_info)) / sizeof(clipping_rect);
@ -167,3 +144,38 @@ DirectWindowData::SetState(direct_buffer_state bufferState,
return _SyncronizeWithClient();
}
void
DirectWindowInfo::EnableFullScreen(const BRect& frame, window_feel feel)
{
fOriginalFrame = frame;
fOriginalFeel = feel;
fFullScreen = true;
}
void
DirectWindowInfo::DisableFullScreen()
{
fFullScreen = false;
}
status_t
DirectWindowInfo::_SyncronizeWithClient()
{
// Releasing this semaphore causes the client to call
// BDirectWindow::DirectConnected()
status_t status = release_sem(fSem);
if (status != B_OK)
return status;
// Wait with a timeout of half a second until the client exits
// from its DirectConnected() implementation
do {
status = acquire_sem_etc(fAcknowledgeSem, 1, B_TIMEOUT, 500000);
} while (status == B_INTERRUPTED);
return status;
}

View File

@ -3,8 +3,8 @@
* Distributed under the terms of the MIT License.
*
*/
#ifndef DIRECT_WINDOW_SUPPORT_H
#define DIRECT_WINDOW_SUPPORT_H
#ifndef DIRECT_WINDOW_INFO_H
#define DIRECT_WINDOW_INFO_H
#include <Autolock.h>
@ -15,16 +15,15 @@
class RenderingBuffer;
class DirectWindowData {
class DirectWindowInfo {
public:
DirectWindowData();
~DirectWindowData();
DirectWindowInfo();
~DirectWindowInfo();
status_t InitCheck() const;
status_t GetSyncData(
direct_window_sync_data& data) const;
status_t SyncronizeWithClient();
status_t SetState(direct_buffer_state bufferState,
direct_driver_state driverState,
@ -32,8 +31,13 @@ public:
const BRect& windowFrame,
const BRegion& clipRegion);
BRect old_window_frame;
bool full_screen;
void EnableFullScreen(const BRect& frame,
window_feel feel);
void DisableFullScreen();
bool IsFullScreen() const { return fFullScreen; }
const BRect& OriginalFrame() const { return fOriginalFrame; }
window_feel OriginalFeel() const { return fOriginalFeel; }
private:
status_t _SyncronizeWithClient();
@ -42,7 +46,11 @@ private:
sem_id fSem;
sem_id fAcknowledgeSem;
area_id fBufferArea;
BRect fOriginalFrame;
window_feel fOriginalFeel;
bool fFullScreen;
};
#endif // DIRECT_WINDOW_SUPPORT_H
#endif // DIRECT_WINDOW_INFO_H

View File

@ -23,7 +23,7 @@ Server app_server :
DefaultDecorator.cpp
Desktop.cpp
DesktopSettings.cpp
DirectWindowSupport.cpp
DirectWindowInfo.cpp
DrawState.cpp
EventDispatcher.cpp
EventStream.cpp

View File

@ -51,7 +51,7 @@
#include "AppServer.h"
#include "Desktop.h"
#include "DirectWindowSupport.h"
#include "DirectWindowInfo.h"
#include "DrawingEngine.h"
#include "HWInterface.h"
#include "Overlay.h"
@ -166,9 +166,8 @@ ServerWindow::ServerWindow(const char* title, ServerApp* app,
fCurrentDrawingRegion(),
fCurrentDrawingRegionValid(false),
fDirectWindowData(NULL),
fIsDirectlyAccessing(false),
fDirectWindowFeel(B_NORMAL_WINDOW_FEEL)
fDirectWindowInfo(NULL),
fIsDirectlyAccessing(false)
{
STRACE(("ServerWindow(%s)::ServerWindow()\n", title));
@ -208,7 +207,7 @@ ServerWindow::~ServerWindow()
BPrivate::gDefaultTokens.RemoveToken(fServerToken);
delete fDirectWindowData;
delete fDirectWindowInfo;
STRACE(("ServerWindow(%p) will exit NOW\n", this));
delete_sem(fDeathSemaphore);
@ -1073,7 +1072,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
fLink.StartMessage(status);
if (status == B_OK) {
struct direct_window_sync_data syncData;
fDirectWindowData->GetSyncData(syncData);
fDirectWindowInfo->GetSyncData(syncData);
fLink.Attach(&syncData, sizeof(syncData));
}
@ -1088,7 +1087,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<bool>(&enable);
status_t status = B_OK;
if (fDirectWindowData != NULL)
if (fDirectWindowInfo != NULL)
_DirectWindowSetFullScreen(enable);
else
status = B_BAD_TYPE;
@ -3404,12 +3403,8 @@ ServerWindow::ScreenChanged(const BMessage* message)
{
SendMessageToClient(message);
if (fDirectWindowData != NULL && fDirectWindowData->full_screen) {
BRect screenFrame = fWindow->Screen()->Frame();
fDesktop->ResizeWindowBy(fWindow,
screenFrame.Width() - fWindow->Frame().Width(),
screenFrame.Height() - fWindow->Frame().Height());
}
if (fDirectWindowInfo != NULL && fDirectWindowInfo->IsFullScreen())
_ResizeToFullScreen();
}
@ -3437,42 +3432,18 @@ ServerWindow::MakeWindow(BRect frame, const char* name,
}
status_t
ServerWindow::_EnableDirectWindowMode()
{
if (fDirectWindowData != NULL) {
// already in direct window mode
return B_ERROR;
}
fDirectWindowData = new (nothrow) DirectWindowData;
if (fDirectWindowData == NULL)
return B_NO_MEMORY;
status_t status = fDirectWindowData->InitCheck();
if (status != B_OK) {
delete fDirectWindowData;
fDirectWindowData = NULL;
return status;
}
return B_OK;
}
void
ServerWindow::HandleDirectConnection(int32 bufferState, int32 driverState)
{
ASSERT_MULTI_LOCKED(fDesktop->WindowLocker());
if (fDirectWindowData == NULL)
if (fDirectWindowInfo == NULL)
return;
STRACE(("HandleDirectConnection(bufferState = %ld, driverState = %ld)\n",
bufferState, driverState));
status_t status = fDirectWindowData->SetState(
status_t status = fDirectWindowInfo->SetState(
(direct_buffer_state)bufferState, (direct_driver_state)driverState,
fDesktop->HWInterface()->FrontBuffer(), fWindow->Frame(),
fWindow->VisibleContentRegion());
@ -3487,8 +3458,8 @@ ServerWindow::HandleDirectConnection(int32 bufferState, int32 driverState)
// The client application didn't release the semaphore
// within the given timeout. Or something else went wrong.
// Deleting this member should make it crash.
delete fDirectWindowData;
fDirectWindowData = NULL;
delete fDirectWindowInfo;
fDirectWindowInfo = NULL;
} else if ((bufferState & B_DIRECT_MODE_MASK) == B_DIRECT_START)
fIsDirectlyAccessing = true;
else if ((bufferState & B_DIRECT_MODE_MASK) == B_DIRECT_STOP)
@ -3587,35 +3558,71 @@ ServerWindow::_MessageNeedsAllWindowsLocked(uint32 code) const
}
void
ServerWindow::_ResizeToFullScreen()
{
BRect screenFrame = fWindow->Screen()->Frame();
fDesktop->MoveWindowBy(fWindow,
screenFrame.left - fWindow->Frame().left,
screenFrame.top - fWindow->Frame().top);
fDesktop->ResizeWindowBy(fWindow,
screenFrame.Width() - fWindow->Frame().Width(),
screenFrame.Height() - fWindow->Frame().Height());
}
status_t
ServerWindow::_EnableDirectWindowMode()
{
if (fDirectWindowInfo != NULL) {
// already in direct window mode
return B_ERROR;
}
fDirectWindowInfo = new(std::nothrow) DirectWindowInfo;
if (fDirectWindowInfo == NULL)
return B_NO_MEMORY;
status_t status = fDirectWindowInfo->InitCheck();
if (status != B_OK) {
delete fDirectWindowInfo;
fDirectWindowInfo = NULL;
return status;
}
return B_OK;
}
void
ServerWindow::_DirectWindowSetFullScreen(bool enable)
{
window_feel feel = kWindowScreenFeel;
if (enable) {
fDesktop->HWInterface()->SetCursorVisible(false);
fDirectWindowData->old_window_frame = fWindow->Frame();
BRect screenFrame = fWindow->Screen()->Frame();
fDirectWindowFeel = fWindow->Feel();
fDesktop->MoveWindowBy(fWindow, -fWindow->Frame().left,
-fWindow->Frame().top);
fDesktop->ResizeWindowBy(fWindow,
screenFrame.Width() - fWindow->Frame().Width(),
screenFrame.Height() - fWindow->Frame().Height());
fDirectWindowInfo->EnableFullScreen(fWindow->Frame(), fWindow->Feel());
_ResizeToFullScreen();
} else {
const BRect &oldFrame = fDirectWindowData->old_window_frame;
const BRect& originalFrame = fDirectWindowInfo->OriginalFrame();
fDirectWindowInfo->DisableFullScreen();
// Resize window back to its original size
fDesktop->MoveWindowBy(fWindow,
oldFrame.left - fWindow->Frame().left,
oldFrame.top - fWindow->Frame().top);
originalFrame.left - fWindow->Frame().left,
originalFrame.top - fWindow->Frame().top);
fDesktop->ResizeWindowBy(fWindow,
oldFrame.Width() - fWindow->Frame().Width(),
oldFrame.Height() - fWindow->Frame().Height());
originalFrame.Width() - fWindow->Frame().Width(),
originalFrame.Height() - fWindow->Frame().Height());
fDesktop->HWInterface()->SetCursorVisible(true);
}
fDirectWindowData->full_screen = enable;
fDesktop->SetWindowFeel(fWindow,
enable ? kWindowScreenFeel : fDirectWindowFeel);
fDesktop->SetWindowFeel(fWindow, feel);
}

View File

@ -41,7 +41,7 @@ class Window;
class Workspace;
class View;
class ServerPicture;
class DirectWindowData;
class DirectWindowInfo;
struct window_info;
#define AS_UPDATE_DECORATOR 'asud'
@ -103,7 +103,7 @@ public:
void HandleDirectConnection(int32 bufferState,
int32 driverState = 0);
bool HasDirectFrameBufferAccess() const
{ return fDirectWindowData != NULL; }
{ return fDirectWindowInfo != NULL; }
bool IsDirectlyAccessing() const
{ return fIsDirectlyAccessing; }
@ -133,6 +133,7 @@ private:
virtual void _PrepareQuit();
virtual void _GetLooperName(char* name, size_t size);
void _ResizeToFullScreen();
status_t _EnableDirectWindowMode();
void _DirectWindowSetFullScreen(bool set);
@ -174,9 +175,8 @@ private:
BRegion fCurrentDrawingRegion;
bool fCurrentDrawingRegionValid;
DirectWindowData* fDirectWindowData;
DirectWindowInfo* fDirectWindowInfo;
bool fIsDirectlyAccessing;
window_feel fDirectWindowFeel;
};
#endif // SERVER_WINDOW_H