* 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
@@ -8,7 +8,7 @@
*/ */
#include "DirectWindowSupport.h" #include "DirectWindowInfo.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -20,13 +20,14 @@
#include "clipping.h" #include "clipping.h"
DirectWindowData::DirectWindowData() DirectWindowInfo::DirectWindowInfo()
: :
full_screen(false),
fBufferInfo(NULL), fBufferInfo(NULL),
fSem(-1), fSem(-1),
fAcknowledgeSem(-1), fAcknowledgeSem(-1),
fBufferArea(-1) fBufferArea(-1),
fOriginalFeel(B_NORMAL_WINDOW_FEEL),
fFullScreen(false)
{ {
fBufferArea = create_area("direct area", (void**)&fBufferInfo, fBufferArea = create_area("direct area", (void**)&fBufferInfo,
B_ANY_ADDRESS, DIRECT_BUFFER_INFO_AREA_SIZE, 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 // this should make the client die in case it's still running
fBufferInfo->bits = NULL; fBufferInfo->bits = NULL;
@@ -53,7 +54,7 @@ DirectWindowData::~DirectWindowData()
status_t status_t
DirectWindowData::InitCheck() const DirectWindowInfo::InitCheck() const
{ {
if (fBufferArea < B_OK) if (fBufferArea < B_OK)
return fBufferArea; return fBufferArea;
@@ -67,7 +68,7 @@ DirectWindowData::InitCheck() const
status_t status_t
DirectWindowData::GetSyncData(direct_window_sync_data& data) const DirectWindowInfo::GetSyncData(direct_window_sync_data& data) const
{ {
data.area = fBufferArea; data.area = fBufferArea;
data.disable_sem = fSem; data.disable_sem = fSem;
@@ -78,30 +79,7 @@ DirectWindowData::GetSyncData(direct_window_sync_data& data) const
status_t status_t
DirectWindowData::_SyncronizeWithClient() DirectWindowInfo::SetState(direct_buffer_state bufferState,
{
// 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,
direct_driver_state driverState, RenderingBuffer* buffer, direct_driver_state driverState, RenderingBuffer* buffer,
const BRect& windowFrame, const BRegion& clipRegion) const BRect& windowFrame, const BRegion& clipRegion)
{ {
@@ -142,7 +120,7 @@ DirectWindowData::SetState(direct_buffer_state bufferState,
break; break;
default: default:
syslog(LOG_ERR, syslog(LOG_ERR,
"unknown colorspace in DirectWindowData::SetState()!\n"); "unknown colorspace in DirectWindowInfo::SetState()!\n");
fBufferInfo->bits_per_pixel = 0; fBufferInfo->bits_per_pixel = 0;
break; break;
} }
@@ -153,7 +131,6 @@ DirectWindowData::SetState(direct_buffer_state bufferState,
// TODO // TODO
fBufferInfo->window_bounds = to_clipping_rect(windowFrame); fBufferInfo->window_bounds = to_clipping_rect(windowFrame);
// TODO: Review this
const int32 kMaxClipRectsCount = (DIRECT_BUFFER_INFO_AREA_SIZE const int32 kMaxClipRectsCount = (DIRECT_BUFFER_INFO_AREA_SIZE
- sizeof(direct_buffer_info)) / sizeof(clipping_rect); - sizeof(direct_buffer_info)) / sizeof(clipping_rect);
@@ -167,3 +144,38 @@ DirectWindowData::SetState(direct_buffer_state bufferState,
return _SyncronizeWithClient(); 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;
}
@@ -3,8 +3,8 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
*/ */
#ifndef DIRECT_WINDOW_SUPPORT_H #ifndef DIRECT_WINDOW_INFO_H
#define DIRECT_WINDOW_SUPPORT_H #define DIRECT_WINDOW_INFO_H
#include <Autolock.h> #include <Autolock.h>
@@ -15,16 +15,15 @@
class RenderingBuffer; class RenderingBuffer;
class DirectWindowData { class DirectWindowInfo {
public: public:
DirectWindowData(); DirectWindowInfo();
~DirectWindowData(); ~DirectWindowInfo();
status_t InitCheck() const; status_t InitCheck() const;
status_t GetSyncData( status_t GetSyncData(
direct_window_sync_data& data) const; direct_window_sync_data& data) const;
status_t SyncronizeWithClient();
status_t SetState(direct_buffer_state bufferState, status_t SetState(direct_buffer_state bufferState,
direct_driver_state driverState, direct_driver_state driverState,
@@ -32,8 +31,13 @@ public:
const BRect& windowFrame, const BRect& windowFrame,
const BRegion& clipRegion); const BRegion& clipRegion);
BRect old_window_frame; void EnableFullScreen(const BRect& frame,
bool full_screen; window_feel feel);
void DisableFullScreen();
bool IsFullScreen() const { return fFullScreen; }
const BRect& OriginalFrame() const { return fOriginalFrame; }
window_feel OriginalFeel() const { return fOriginalFeel; }
private: private:
status_t _SyncronizeWithClient(); status_t _SyncronizeWithClient();
@@ -42,7 +46,11 @@ private:
sem_id fSem; sem_id fSem;
sem_id fAcknowledgeSem; sem_id fAcknowledgeSem;
area_id fBufferArea; area_id fBufferArea;
BRect fOriginalFrame;
window_feel fOriginalFeel;
bool fFullScreen;
}; };
#endif // DIRECT_WINDOW_SUPPORT_H #endif // DIRECT_WINDOW_INFO_H
+1 -1
View File
@@ -23,7 +23,7 @@ Server app_server :
DefaultDecorator.cpp DefaultDecorator.cpp
Desktop.cpp Desktop.cpp
DesktopSettings.cpp DesktopSettings.cpp
DirectWindowSupport.cpp DirectWindowInfo.cpp
DrawState.cpp DrawState.cpp
EventDispatcher.cpp EventDispatcher.cpp
EventStream.cpp EventStream.cpp
+64 -57
View File
@@ -51,7 +51,7 @@
#include "AppServer.h" #include "AppServer.h"
#include "Desktop.h" #include "Desktop.h"
#include "DirectWindowSupport.h" #include "DirectWindowInfo.h"
#include "DrawingEngine.h" #include "DrawingEngine.h"
#include "HWInterface.h" #include "HWInterface.h"
#include "Overlay.h" #include "Overlay.h"
@@ -166,9 +166,8 @@ ServerWindow::ServerWindow(const char* title, ServerApp* app,
fCurrentDrawingRegion(), fCurrentDrawingRegion(),
fCurrentDrawingRegionValid(false), fCurrentDrawingRegionValid(false),
fDirectWindowData(NULL), fDirectWindowInfo(NULL),
fIsDirectlyAccessing(false), fIsDirectlyAccessing(false)
fDirectWindowFeel(B_NORMAL_WINDOW_FEEL)
{ {
STRACE(("ServerWindow(%s)::ServerWindow()\n", title)); STRACE(("ServerWindow(%s)::ServerWindow()\n", title));
@@ -208,7 +207,7 @@ ServerWindow::~ServerWindow()
BPrivate::gDefaultTokens.RemoveToken(fServerToken); BPrivate::gDefaultTokens.RemoveToken(fServerToken);
delete fDirectWindowData; delete fDirectWindowInfo;
STRACE(("ServerWindow(%p) will exit NOW\n", this)); STRACE(("ServerWindow(%p) will exit NOW\n", this));
delete_sem(fDeathSemaphore); delete_sem(fDeathSemaphore);
@@ -1073,7 +1072,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
fLink.StartMessage(status); fLink.StartMessage(status);
if (status == B_OK) { if (status == B_OK) {
struct direct_window_sync_data syncData; struct direct_window_sync_data syncData;
fDirectWindowData->GetSyncData(syncData); fDirectWindowInfo->GetSyncData(syncData);
fLink.Attach(&syncData, sizeof(syncData)); fLink.Attach(&syncData, sizeof(syncData));
} }
@@ -1088,7 +1087,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<bool>(&enable); link.Read<bool>(&enable);
status_t status = B_OK; status_t status = B_OK;
if (fDirectWindowData != NULL) if (fDirectWindowInfo != NULL)
_DirectWindowSetFullScreen(enable); _DirectWindowSetFullScreen(enable);
else else
status = B_BAD_TYPE; status = B_BAD_TYPE;
@@ -3404,12 +3403,8 @@ ServerWindow::ScreenChanged(const BMessage* message)
{ {
SendMessageToClient(message); SendMessageToClient(message);
if (fDirectWindowData != NULL && fDirectWindowData->full_screen) { if (fDirectWindowInfo != NULL && fDirectWindowInfo->IsFullScreen())
BRect screenFrame = fWindow->Screen()->Frame(); _ResizeToFullScreen();
fDesktop->ResizeWindowBy(fWindow,
screenFrame.Width() - fWindow->Frame().Width(),
screenFrame.Height() - fWindow->Frame().Height());
}
} }
@@ -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 void
ServerWindow::HandleDirectConnection(int32 bufferState, int32 driverState) ServerWindow::HandleDirectConnection(int32 bufferState, int32 driverState)
{ {
ASSERT_MULTI_LOCKED(fDesktop->WindowLocker()); ASSERT_MULTI_LOCKED(fDesktop->WindowLocker());
if (fDirectWindowData == NULL) if (fDirectWindowInfo == NULL)
return; return;
STRACE(("HandleDirectConnection(bufferState = %ld, driverState = %ld)\n", STRACE(("HandleDirectConnection(bufferState = %ld, driverState = %ld)\n",
bufferState, driverState)); bufferState, driverState));
status_t status = fDirectWindowData->SetState( status_t status = fDirectWindowInfo->SetState(
(direct_buffer_state)bufferState, (direct_driver_state)driverState, (direct_buffer_state)bufferState, (direct_driver_state)driverState,
fDesktop->HWInterface()->FrontBuffer(), fWindow->Frame(), fDesktop->HWInterface()->FrontBuffer(), fWindow->Frame(),
fWindow->VisibleContentRegion()); fWindow->VisibleContentRegion());
@@ -3487,8 +3458,8 @@ ServerWindow::HandleDirectConnection(int32 bufferState, int32 driverState)
// The client application didn't release the semaphore // The client application didn't release the semaphore
// within the given timeout. Or something else went wrong. // within the given timeout. Or something else went wrong.
// Deleting this member should make it crash. // Deleting this member should make it crash.
delete fDirectWindowData; delete fDirectWindowInfo;
fDirectWindowData = NULL; fDirectWindowInfo = NULL;
} else if ((bufferState & B_DIRECT_MODE_MASK) == B_DIRECT_START) } else if ((bufferState & B_DIRECT_MODE_MASK) == B_DIRECT_START)
fIsDirectlyAccessing = true; fIsDirectlyAccessing = true;
else if ((bufferState & B_DIRECT_MODE_MASK) == B_DIRECT_STOP) 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 void
ServerWindow::_DirectWindowSetFullScreen(bool enable) ServerWindow::_DirectWindowSetFullScreen(bool enable)
{ {
window_feel feel = kWindowScreenFeel;
if (enable) { if (enable) {
fDesktop->HWInterface()->SetCursorVisible(false); fDesktop->HWInterface()->SetCursorVisible(false);
fDirectWindowData->old_window_frame = fWindow->Frame(); fDirectWindowInfo->EnableFullScreen(fWindow->Frame(), fWindow->Feel());
BRect screenFrame = fWindow->Screen()->Frame(); _ResizeToFullScreen();
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());
} else { } 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, fDesktop->MoveWindowBy(fWindow,
oldFrame.left - fWindow->Frame().left, originalFrame.left - fWindow->Frame().left,
oldFrame.top - fWindow->Frame().top); originalFrame.top - fWindow->Frame().top);
fDesktop->ResizeWindowBy(fWindow, fDesktop->ResizeWindowBy(fWindow,
oldFrame.Width() - fWindow->Frame().Width(), originalFrame.Width() - fWindow->Frame().Width(),
oldFrame.Height() - fWindow->Frame().Height()); originalFrame.Height() - fWindow->Frame().Height());
fDesktop->HWInterface()->SetCursorVisible(true); fDesktop->HWInterface()->SetCursorVisible(true);
} }
fDirectWindowData->full_screen = enable; fDesktop->SetWindowFeel(fWindow, feel);
fDesktop->SetWindowFeel(fWindow,
enable ? kWindowScreenFeel : fDirectWindowFeel);
} }
+4 -4
View File
@@ -41,7 +41,7 @@ class Window;
class Workspace; class Workspace;
class View; class View;
class ServerPicture; class ServerPicture;
class DirectWindowData; class DirectWindowInfo;
struct window_info; struct window_info;
#define AS_UPDATE_DECORATOR 'asud' #define AS_UPDATE_DECORATOR 'asud'
@@ -103,7 +103,7 @@ public:
void HandleDirectConnection(int32 bufferState, void HandleDirectConnection(int32 bufferState,
int32 driverState = 0); int32 driverState = 0);
bool HasDirectFrameBufferAccess() const bool HasDirectFrameBufferAccess() const
{ return fDirectWindowData != NULL; } { return fDirectWindowInfo != NULL; }
bool IsDirectlyAccessing() const bool IsDirectlyAccessing() const
{ return fIsDirectlyAccessing; } { return fIsDirectlyAccessing; }
@@ -133,6 +133,7 @@ private:
virtual void _PrepareQuit(); virtual void _PrepareQuit();
virtual void _GetLooperName(char* name, size_t size); virtual void _GetLooperName(char* name, size_t size);
void _ResizeToFullScreen();
status_t _EnableDirectWindowMode(); status_t _EnableDirectWindowMode();
void _DirectWindowSetFullScreen(bool set); void _DirectWindowSetFullScreen(bool set);
@@ -174,9 +175,8 @@ private:
BRegion fCurrentDrawingRegion; BRegion fCurrentDrawingRegion;
bool fCurrentDrawingRegionValid; bool fCurrentDrawingRegionValid;
DirectWindowData* fDirectWindowData; DirectWindowInfo* fDirectWindowInfo;
bool fIsDirectlyAccessing; bool fIsDirectlyAccessing;
window_feel fDirectWindowFeel;
}; };
#endif // SERVER_WINDOW_H #endif // SERVER_WINDOW_H