More refactoring of the DirectWindow server code. No new bugs introduced

(hopefully), and now I could enable the B_SCREEN_CHANGED notification since 
it works a bit differently


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32570 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2009-08-21 15:07:40 +00:00
parent 38516368ea
commit f1400a3199
+55 -26
View File
@@ -161,10 +161,14 @@ public:
bool full_screen; bool full_screen;
private: private:
sem_id fSem; bool _HandleStop(const direct_buffer_state &state);
sem_id fAcknowledgeSem; bool _HandleStart(const direct_buffer_state &state);
area_id fBufferArea; bool _HandleModify(const direct_buffer_state &state);
direct_buffer_state fPreviousState;
sem_id fSem;
sem_id fAcknowledgeSem;
area_id fBufferArea;
int32 fTransition;
}; };
@@ -175,7 +179,7 @@ DirectWindowData::DirectWindowData()
fSem(-1), fSem(-1),
fAcknowledgeSem(-1), fAcknowledgeSem(-1),
fBufferArea(-1), fBufferArea(-1),
fPreviousState(B_DIRECT_STOP) fTransition(0)
{ {
fBufferArea = create_area("direct area", (void**)&buffer_info, fBufferArea = create_area("direct area", (void**)&buffer_info,
B_ANY_ADDRESS, B_PAGE_SIZE, B_NO_LOCK, B_READ_WRITE); B_ANY_ADDRESS, B_PAGE_SIZE, B_NO_LOCK, B_READ_WRITE);
@@ -248,30 +252,55 @@ DirectWindowData::SetState(const direct_buffer_state& bufferState,
{ {
BufferState inputState(bufferState); BufferState inputState(bufferState);
BufferState currentState(buffer_info->buffer_state); BufferState currentState(buffer_info->buffer_state);
// Don't issue a DirectConnected() notification bool handle = false;
// if the connection is stopped, and we are called
// with bufferState == B_DIRECT_MODIFY, but save the reason if (inputState.Action() == B_DIRECT_STOP)
// and combine it for next time we are called with B_DIRECT_START handle = _HandleStop(bufferState);
if (currentState.Action() == B_DIRECT_STOP else if (inputState.Action() == B_DIRECT_START)
&& inputState.Action() != B_DIRECT_START) { handle = _HandleStart(bufferState);
fPreviousState = (direct_buffer_state)(fPreviousState else if (inputState.Action() == B_DIRECT_MODIFY)
| inputState.Reason()); handle = _HandleModify(bufferState);
return false;
}
buffer_info->buffer_state = (direct_buffer_state)(bufferState
| BufferState(fPreviousState).Reason());
fPreviousState = B_DIRECT_STOP;
if (driverState != -1) if (driverState != -1)
buffer_info->driver_state = driverState; buffer_info->driver_state = driverState;
return true; return handle;
} }
bool
DirectWindowData::_HandleStop(const direct_buffer_state &state)
{
buffer_info->buffer_state = B_DIRECT_STOP;
if (fTransition-- >= 1)
return true;
return false;
}
bool
DirectWindowData::_HandleStart(const direct_buffer_state &state)
{
buffer_info->buffer_state
= (direct_buffer_state)(BufferState(buffer_info->buffer_state).Reason() | state);
if (fTransition++ >= 0)
return true;
return false;
}
bool
DirectWindowData::_HandleModify(const direct_buffer_state &state)
{
buffer_info->buffer_state = state;
if (fTransition > 0)
return true;
return false;
}
// #pragma mark - // #pragma mark -
@@ -3553,7 +3582,7 @@ void
ServerWindow::ScreenChanged(const BMessage* message) ServerWindow::ScreenChanged(const BMessage* message)
{ {
// TODO: execute the stop notification earlier // TODO: execute the stop notification earlier
//HandleDirectConnection(B_DIRECT_STOP); HandleDirectConnection(B_DIRECT_STOP);
SendMessageToClient(message); SendMessageToClient(message);
if (fDirectWindowData != NULL && fDirectWindowData->full_screen) { if (fDirectWindowData != NULL && fDirectWindowData->full_screen) {
@@ -3563,8 +3592,8 @@ ServerWindow::ScreenChanged(const BMessage* message)
screenFrame.Height() - fWindow->Frame().Height()); screenFrame.Height() - fWindow->Frame().Height());
} }
//HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET, HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET,
//B_SCREEN_CHANGED); B_SCREEN_CHANGED);
} }