modified so use BSession again
various fixes especialy regarding app_server connection git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6048 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+214
-202
@@ -44,13 +44,13 @@
|
|||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
// Project Includes ------------------------------------------------------------
|
||||||
#include <AppMisc.h>
|
#include <AppMisc.h>
|
||||||
|
#include <PortLink.h>
|
||||||
|
#include <PortMessage.h>
|
||||||
#include <Session.h>
|
#include <Session.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
#include <TokenSpace.h>
|
#include <TokenSpace.h>
|
||||||
#include <MessageUtils.h>
|
#include <MessageUtils.h>
|
||||||
#include <WindowAux.h>
|
#include <WindowAux.h>
|
||||||
#include <AppServerLink.h>
|
|
||||||
#include <PortMessage.h>
|
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
// Standard Includes -----------------------------------------------------------
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -217,12 +217,11 @@ BWindow::BWindow(BMessage* data)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
BWindow::~BWindow(){
|
BWindow::~BWindow(){
|
||||||
|
|
||||||
// the following lines, remove all existing shortcuts and delete accelList
|
// the following lines, remove all existing shortcuts and delete accelList
|
||||||
int32 noOfItems;
|
int32 noOfItems;
|
||||||
|
|
||||||
noOfItems = accelList.CountItems();
|
noOfItems = accelList.CountItems();
|
||||||
for ( int index = noOfItems; index >= 0; index-- ) {
|
for ( int index = noOfItems-1; index >= 0; index-- ) {
|
||||||
_BCmdKey *cmdKey;
|
_BCmdKey *cmdKey;
|
||||||
|
|
||||||
cmdKey = (_BCmdKey*)accelList.ItemAt( index );
|
cmdKey = (_BCmdKey*)accelList.ItemAt( index );
|
||||||
@@ -232,14 +231,13 @@ BWindow::~BWindow(){
|
|||||||
delete cmdKey->message;
|
delete cmdKey->message;
|
||||||
delete cmdKey;
|
delete cmdKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: release other dynamically-allocated objects
|
// TODO: release other dinamicaly alocated objects
|
||||||
|
|
||||||
// disable pulsing
|
// disable pulsing
|
||||||
SetPulseRate( 0 );
|
SetPulseRate( 0 );
|
||||||
|
|
||||||
delete session;
|
delete session;
|
||||||
delete fServerLink;
|
|
||||||
delete_port( receive_port );
|
delete_port( receive_port );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,10 +328,10 @@ void BWindow::Quit(){
|
|||||||
|
|
||||||
// ... also its children
|
// ... also its children
|
||||||
//detachTopView();
|
//detachTopView();
|
||||||
|
STRACE(("Trying to stop connection...\n"));
|
||||||
// tell app_server, this window will finish execution
|
// tell app_server, this window will finish execution
|
||||||
stopConnection();
|
stopConnection();
|
||||||
|
STRACE(("Connection stopped!\n"));
|
||||||
if (fFlags & B_QUIT_ON_WINDOW_CLOSE)
|
if (fFlags & B_QUIT_ON_WINDOW_CLOSE)
|
||||||
be_app->PostMessage( B_QUIT_REQUESTED );
|
be_app->PostMessage( B_QUIT_REQUESTED );
|
||||||
|
|
||||||
@@ -374,9 +372,9 @@ void BWindow::Minimize(bool minimize){
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode(AS_WINDOW_MINIMIZE);
|
session->WriteInt32( AS_WINDOW_MINIMIZE );
|
||||||
fServerLink->Attach<bool>( minimize );
|
session->WriteBool( minimize );
|
||||||
fServerLink->Flush();
|
session->Sync( );
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -386,14 +384,16 @@ status_t BWindow::SendBehind(const BWindow* window){
|
|||||||
if (!window)
|
if (!window)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
int32 rCode;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
PortMessage pmsg;
|
session->WriteInt32( AS_SEND_BEHIND );
|
||||||
fServerLink->SetOpCode( AS_SEND_BEHIND );
|
session->WriteInt32( _get_object_token_(window) );
|
||||||
fServerLink->Attach<int32>( _get_object_token_(window) );
|
session->Sync();
|
||||||
fServerLink->FlushWithReply(&pmsg);
|
session->ReadInt32( &rCode );
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
return (pmsg.Code() == SERVER_TRUE)? B_OK : B_ERROR;
|
return rCode == SERVER_TRUE? B_OK : B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -960,23 +960,24 @@ void BWindow::MenusEnded(){
|
|||||||
|
|
||||||
void BWindow::SetSizeLimits(float minWidth, float maxWidth,
|
void BWindow::SetSizeLimits(float minWidth, float maxWidth,
|
||||||
float minHeight, float maxHeight){
|
float minHeight, float maxHeight){
|
||||||
|
int32 rCode;
|
||||||
|
|
||||||
if (minWidth > maxWidth)
|
if (minWidth > maxWidth)
|
||||||
return;
|
return;
|
||||||
if (minHeight > maxHeight)
|
if (minHeight > maxHeight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
PortMessage pmsg;
|
session->WriteInt32( AS_SET_SIZE_LIMITS );
|
||||||
|
session->WriteFloat( fMinWindWidth );
|
||||||
fServerLink->Attach<int32>( AS_SET_SIZE_LIMITS );
|
session->WriteFloat( fMaxWindWidth );
|
||||||
fServerLink->Attach<float>( fMinWindWidth );
|
session->WriteFloat( fMinWindHeight );
|
||||||
fServerLink->Attach<float>( fMaxWindWidth );
|
session->WriteFloat( fMaxWindHeight );
|
||||||
fServerLink->Attach<float>( fMinWindHeight );
|
session->Sync();
|
||||||
fServerLink->Attach<float>( fMaxWindHeight );
|
session->ReadInt32( &rCode );
|
||||||
fServerLink->FlushWithReply(&pmsg);
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if (pmsg.Code() == SERVER_TRUE){
|
if (rCode == SERVER_TRUE){
|
||||||
fMinWindHeight = minHeight;
|
fMinWindHeight = minHeight;
|
||||||
fMinWindWidth = minWidth;
|
fMinWindWidth = minWidth;
|
||||||
fMaxWindHeight = maxHeight;
|
fMaxWindHeight = maxHeight;
|
||||||
@@ -1246,9 +1247,9 @@ void BWindow::Activate(bool active){
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_ACTIVATE_WINDOW );
|
session->WriteInt32( AS_ACTIVATE_WINDOW );
|
||||||
fServerLink->Attach<bool>( active );
|
session->WriteBool( active );
|
||||||
fServerLink->Flush();
|
session->Sync( );
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1389,9 +1390,9 @@ void BWindow::SetTitle(const char* title){
|
|||||||
|
|
||||||
// we notify the app_server so we can actually see the change
|
// we notify the app_server so we can actually see the change
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_WINDOW_TITLE );
|
session->WriteInt32( AS_WINDOW_TITLE);
|
||||||
fServerLink->AttachString( fTitle );
|
session->WriteString( fTitle );
|
||||||
fServerLink->Flush();
|
session->Sync( );
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1449,18 +1450,19 @@ status_t BWindow::AddToSubset(BWindow* window){
|
|||||||
if ( !window )
|
if ( !window )
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
PortMessage pmsg;
|
int32 rCode;
|
||||||
|
|
||||||
if (window->Feel() == B_MODAL_SUBSET_WINDOW_FEEL ||
|
if (window->Feel() == B_MODAL_SUBSET_WINDOW_FEEL ||
|
||||||
window->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL){
|
window->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL){
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_ADD_TO_SUBSET );
|
session->WriteInt32( AS_ADD_TO_SUBSET );
|
||||||
fServerLink->Attach<int32>( _get_object_token_(window) );
|
session->WriteInt32( _get_object_token_(window) );
|
||||||
fServerLink->FlushWithReply(&pmsg);
|
session->Sync();
|
||||||
|
session->ReadInt32( &rCode );
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
return (pmsg.Code() == SERVER_TRUE)? B_OK : B_ERROR;
|
return rCode == SERVER_TRUE? B_OK : B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -1472,15 +1474,16 @@ status_t BWindow::RemoveFromSubset(BWindow* window){
|
|||||||
if ( !window )
|
if ( !window )
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
PortMessage pmsg;
|
int32 rCode;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_REM_FROM_SUBSET );
|
session->WriteInt32( AS_REM_FROM_SUBSET );
|
||||||
fServerLink->Attach<int32>( _get_object_token_(window) );
|
session->WriteInt32( _get_object_token_(window) );
|
||||||
fServerLink->FlushWithReply(&pmsg);
|
session->Sync();
|
||||||
|
session->ReadInt32( &rCode );
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
return ( pmsg.Code() == SERVER_TRUE)? B_OK : B_ERROR;
|
return rCode == SERVER_TRUE? B_OK : B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -1493,7 +1496,6 @@ status_t BWindow::Perform(perform_code d, void* arg){
|
|||||||
|
|
||||||
status_t BWindow::SetType(window_type type){
|
status_t BWindow::SetType(window_type type){
|
||||||
decomposeType(type, &fLook, &fFeel);
|
decomposeType(type, &fLook, &fFeel);
|
||||||
|
|
||||||
status_t stat1, stat2;
|
status_t stat1, stat2;
|
||||||
|
|
||||||
stat1=SetLook( fLook );
|
stat1=SetLook( fLook );
|
||||||
@@ -1514,16 +1516,17 @@ window_type BWindow::Type() const{
|
|||||||
|
|
||||||
status_t BWindow::SetLook(window_look look){
|
status_t BWindow::SetLook(window_look look){
|
||||||
|
|
||||||
PortMessage pmsg;
|
int32 rCode;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_SET_LOOK );
|
session->WriteInt32( AS_SET_LOOK );
|
||||||
fServerLink->Attach<window_look>( fLook );
|
session->WriteInt32( (int32)look );
|
||||||
fServerLink->FlushWithReply(&pmsg);
|
session->Sync();
|
||||||
|
session->ReadInt32( &rCode );
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if(pmsg.Code() == SERVER_TRUE){
|
if (rCode == SERVER_TRUE){
|
||||||
fLook = look;
|
fLook = look;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1542,19 +1545,20 @@ status_t BWindow::SetFeel(window_feel feel){
|
|||||||
/* TODO: See what happens when a window that is part of a subset, changes its
|
/* TODO: See what happens when a window that is part of a subset, changes its
|
||||||
feel!? should it be removed from the subset???
|
feel!? should it be removed from the subset???
|
||||||
*/
|
*/
|
||||||
PortMessage pmsg;
|
int32 rCode;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_SET_FEEL );
|
session->WriteInt32( AS_SET_FEEL );
|
||||||
fServerLink->Attach<window_feel>( fFeel );
|
session->WriteInt32( (int32)feel );
|
||||||
fServerLink->FlushWithReply(&pmsg);
|
session->Sync();
|
||||||
|
session->ReadInt32( &rCode );
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if(pmsg.Code() == SERVER_TRUE){
|
if (rCode == SERVER_TRUE){
|
||||||
fFeel = feel;
|
fFeel = feel;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1568,19 +1572,20 @@ window_feel BWindow::Feel() const{
|
|||||||
|
|
||||||
status_t BWindow::SetFlags(uint32 flags){
|
status_t BWindow::SetFlags(uint32 flags){
|
||||||
|
|
||||||
PortMessage pmsg;
|
int32 rCode;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_SET_FLAGS );
|
session->WriteInt32( AS_SET_FLAGS );
|
||||||
fServerLink->Attach<int32>( fFlags );
|
session->WriteUInt32( flags );
|
||||||
fServerLink->FlushWithReply(&pmsg);
|
session->Sync();
|
||||||
|
session->ReadInt32( &rCode );
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if(pmsg.Code() == SERVER_TRUE){
|
if (rCode == SERVER_TRUE){
|
||||||
fFlags = flags;
|
fFlags = flags;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1617,24 +1622,28 @@ status_t BWindow::SetWindowAlignment(window_alignment mode,
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// TODO: test if hOffset = 0 and set it to 1 if true.
|
// TODO: test if hOffset = 0 and set it to 1 if true.
|
||||||
PortMessage pmsg;
|
int32 rCode;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_SET_ALIGNMENT );
|
session->WriteInt32( AS_SET_ALIGNMENT );
|
||||||
|
session->WriteInt32( (int32)mode );
|
||||||
fServerLink->Attach<window_alignment>( mode );
|
session->WriteInt32( h );
|
||||||
fServerLink->Attach<int32>( h );
|
session->WriteInt32( hOffset );
|
||||||
fServerLink->Attach<int32>( hOffset );
|
session->WriteInt32( width );
|
||||||
fServerLink->Attach<int32>( width );
|
session->WriteInt32( widthOffset );
|
||||||
fServerLink->Attach<int32>( widthOffset );
|
session->WriteInt32( v );
|
||||||
fServerLink->Attach<int32>( v );
|
session->WriteInt32( vOffset );
|
||||||
fServerLink->Attach<int32>( vOffset );
|
session->WriteInt32( height );
|
||||||
fServerLink->Attach<int32>( height );
|
session->WriteInt32( heightOffset );
|
||||||
fServerLink->Attach<int32>( heightOffset );
|
session->Sync();
|
||||||
fServerLink->FlushWithReply( &pmsg );
|
session->ReadInt32( &rCode );
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
return ( pmsg.Code() == SERVER_TRUE) ? B_OK : B_ERROR;
|
if ( rCode == SERVER_TRUE){
|
||||||
|
return B_NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -1645,24 +1654,25 @@ status_t BWindow::GetWindowAlignment(window_alignment* mode,
|
|||||||
int32* v, int32* vOffset,
|
int32* v, int32* vOffset,
|
||||||
int32* height, int32* heightOffset) const
|
int32* height, int32* heightOffset) const
|
||||||
{
|
{
|
||||||
PortMessage pmsg;
|
int32 rCode;
|
||||||
|
|
||||||
const_cast<BWindow*>(this)->Lock();
|
const_cast<BWindow*>(this)->Lock();
|
||||||
fServerLink->SetOpCode( AS_GET_ALIGNMENT );
|
session->WriteInt32( AS_GET_ALIGNMENT );
|
||||||
fServerLink->FlushWithReply( &pmsg );
|
session->Sync();
|
||||||
|
session->ReadInt32( &rCode );
|
||||||
|
|
||||||
|
if (rCode == SERVER_TRUE){
|
||||||
|
session->ReadInt32( (int32*)mode );
|
||||||
|
session->ReadInt32( h );
|
||||||
|
session->ReadInt32( hOffset );
|
||||||
|
session->ReadInt32( width );
|
||||||
|
session->ReadInt32( widthOffset );
|
||||||
|
session->ReadInt32( v );
|
||||||
|
session->ReadInt32( hOffset );
|
||||||
|
session->ReadInt32( height );
|
||||||
|
session->ReadInt32( heightOffset );
|
||||||
|
|
||||||
if (pmsg.Code() == SERVER_TRUE){
|
return B_NO_ERROR;
|
||||||
pmsg.Read<window_alignment>( mode );
|
|
||||||
pmsg.Read<int32>( h );
|
|
||||||
pmsg.Read<int32>( hOffset );
|
|
||||||
pmsg.Read<int32>( width );
|
|
||||||
pmsg.Read<int32>( widthOffset );
|
|
||||||
pmsg.Read<int32>( v );
|
|
||||||
pmsg.Read<int32>( hOffset );
|
|
||||||
pmsg.Read<int32>( height );
|
|
||||||
pmsg.Read<int32>( heightOffset );
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
const_cast<BWindow*>(this)->Unlock();
|
const_cast<BWindow*>(this)->Unlock();
|
||||||
|
|
||||||
@@ -1672,16 +1682,13 @@ status_t BWindow::GetWindowAlignment(window_alignment* mode,
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
uint32 BWindow::Workspaces() const{
|
uint32 BWindow::Workspaces() const{
|
||||||
|
uint32 workspaces;
|
||||||
uint32 workspaces;
|
|
||||||
PortMessage pmsg;
|
|
||||||
|
|
||||||
const_cast<BWindow*>(this)->Lock();
|
const_cast<BWindow*>(this)->Lock();
|
||||||
fServerLink->SetOpCode( AS_GET_WORKSPACES );
|
session->WriteInt32( AS_GET_WORKSPACES );
|
||||||
fServerLink->FlushWithReply( &pmsg );
|
session->Sync();
|
||||||
|
session->ReadInt32( (int32*)&workspaces );
|
||||||
const_cast<BWindow*>(this)->Unlock();
|
const_cast<BWindow*>(this)->Unlock();
|
||||||
|
|
||||||
pmsg.Read<uint32>( &workspaces );
|
|
||||||
|
|
||||||
return workspaces;
|
return workspaces;
|
||||||
}
|
}
|
||||||
@@ -1691,9 +1698,9 @@ uint32 BWindow::Workspaces() const{
|
|||||||
void BWindow::SetWorkspaces(uint32 workspaces){
|
void BWindow::SetWorkspaces(uint32 workspaces){
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_SET_WORKSPACES );
|
session->WriteInt32( AS_SET_WORKSPACES );
|
||||||
fServerLink->Attach<uint32>( workspaces );
|
session->WriteInt32( (int32)workspaces );
|
||||||
fServerLink->Flush();
|
session->Sync( );
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1723,10 +1730,10 @@ void BWindow::MoveTo( BPoint point ){
|
|||||||
void BWindow::MoveTo(float x, float y){
|
void BWindow::MoveTo(float x, float y){
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_WINDOW_MOVE );
|
session->WriteInt32( AS_WINDOW_MOVE );
|
||||||
fServerLink->Attach<float>( x );
|
session->WriteFloat( x );
|
||||||
fServerLink->Attach<float>( y );
|
session->WriteFloat( y );
|
||||||
fServerLink->Flush();
|
session->Sync();
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1756,10 +1763,10 @@ void BWindow::ResizeTo(float width, float height){
|
|||||||
height = (height > fMaxWindHeight) ? fMaxWindHeight : height;
|
height = (height > fMaxWindHeight) ? fMaxWindHeight : height;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_WINDOW_RESIZE );
|
session->WriteInt32( AS_WINDOW_RESIZE );
|
||||||
fServerLink->Attach<float>( width );
|
session->WriteFloat( width );
|
||||||
fServerLink->Attach<float>( height );
|
session->WriteFloat( height );
|
||||||
fServerLink->Flush();
|
session->Sync( );
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1772,22 +1779,17 @@ void BWindow::Show(){
|
|||||||
|
|
||||||
if (fShowLevel == 0){
|
if (fShowLevel == 0){
|
||||||
STRACE(("BWindow(%s): sending AS_SHOW_WINDOW message...\n", Name() ));
|
STRACE(("BWindow(%s): sending AS_SHOW_WINDOW message...\n", Name() ));
|
||||||
if ( !isLocked )
|
if ( !isLocked ) Lock();
|
||||||
Lock();
|
session->WriteInt32( AS_SHOW_WINDOW );
|
||||||
|
session->Sync( );
|
||||||
fServerLink->SetOpCode( AS_SHOW_WINDOW );
|
if ( !isLocked) Unlock();
|
||||||
fServerLink->Flush();
|
|
||||||
|
|
||||||
if ( !isLocked)
|
|
||||||
Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it's the fist time Show() is called, start the Looper thread.
|
// if it's the fist time Show() is called... start the Looper thread.
|
||||||
if ( Thread() == B_ERROR )
|
if ( Thread() == B_ERROR )
|
||||||
{
|
{
|
||||||
// normally this won't happen, but I want to be sure!
|
// normaly this won't happen, but I want to be sure!
|
||||||
if ( !isLocked )
|
if ( !isLocked ) Lock();
|
||||||
Lock();
|
|
||||||
Run();
|
Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1798,8 +1800,8 @@ void BWindow::Show(){
|
|||||||
void BWindow::Hide(){
|
void BWindow::Hide(){
|
||||||
if (fShowLevel == 0){
|
if (fShowLevel == 0){
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_HIDE_WINDOW );
|
session->WriteInt32( AS_HIDE_WINDOW );
|
||||||
fServerLink->Flush();
|
session->Sync();
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
fShowLevel++;
|
fShowLevel++;
|
||||||
@@ -1995,28 +1997,43 @@ void BWindow::InitData( BRect frame,
|
|||||||
bool locked = false;
|
bool locked = false;
|
||||||
if ( !(be_app->IsLocked()) )
|
if ( !(be_app->IsLocked()) )
|
||||||
{ be_app->Lock(); locked = true; }
|
{ be_app->Lock(); locked = true; }
|
||||||
|
|
||||||
|
PortMessage pmsg;
|
||||||
|
PortLink link(be_app->fServerFrom);
|
||||||
|
link.SetOpCode(AS_CREATE_WINDOW);
|
||||||
|
|
||||||
|
link.Attach<BRect>( fFrame );
|
||||||
|
link.Attach<int32>( (int32)fLook );
|
||||||
|
link.Attach<int32>( (int32)fFeel );
|
||||||
|
link.Attach<uint32>( fFlags );
|
||||||
|
link.Attach<uint32>( workspace );
|
||||||
|
link.Attach<int32>( _get_object_token_(this) );
|
||||||
|
link.Attach<port_id>( receive_port );
|
||||||
|
link.Attach<port_id>( fMsgPort );
|
||||||
|
link.AttachString( title );
|
||||||
|
link.FlushWithReply(&pmsg);
|
||||||
|
|
||||||
BPrivate::BAppServerLink *serverlink=new BPrivate::BAppServerLink;
|
pmsg.Read<port_id>(&send_port);
|
||||||
PortMessage pmsg;
|
/*
|
||||||
|
session->WriteInt32( AS_CREATE_WINDOW );
|
||||||
serverlink->SetOpCode( AS_CREATE_WINDOW );
|
session->WriteRect( fFrame );
|
||||||
serverlink->Attach<BRect>( fFrame );
|
session->WriteInt32( (int32)fLook );
|
||||||
serverlink->Attach<int32>( (int32)fLook );
|
session->WriteInt32( (int32)fFeel );
|
||||||
serverlink->Attach<int32>( (int32)fFeel );
|
session->WriteUInt32( fFlags );
|
||||||
serverlink->Attach<uint32>( fFlags );
|
session->WriteUInt32( workspace );
|
||||||
serverlink->Attach<uint32>( workspace );
|
session->WriteData( &team, sizeof(team_id));
|
||||||
serverlink->Attach<int32>( _get_object_token_(this) );
|
session->WriteInt32( _get_object_token_(this) );
|
||||||
serverlink->Attach( &receive_port, sizeof(port_id) );
|
session->WriteData( &receive_port, sizeof(port_id) );
|
||||||
serverlink->Attach( &fMsgPort, sizeof(port_id) );
|
session->WriteData( &fMsgPort, sizeof(port_id) );
|
||||||
serverlink->AttachString( title );
|
session->WriteString( title );
|
||||||
serverlink->FlushWithReply(&pmsg);
|
|
||||||
|
printf("look: %ld\n", (int32)fLook);
|
||||||
|
printf("title: %s\n", title);
|
||||||
|
session->Sync();
|
||||||
// The port on witch app_server will listen for us
|
// The port on witch app_server will listen for us
|
||||||
pmsg.Read<port_id>( &send_port );
|
STRACE(("here\n"));
|
||||||
|
session->ReadData( &send_port, sizeof(port_id) );
|
||||||
delete serverlink;
|
*/
|
||||||
|
|
||||||
fServerLink=new PortLink(send_port);
|
|
||||||
|
|
||||||
// unlock, so other threads can do their job.
|
// unlock, so other threads can do their job.
|
||||||
if( locked )
|
if( locked )
|
||||||
be_app->Unlock();
|
be_app->Unlock();
|
||||||
@@ -2047,24 +2064,35 @@ void BWindow::task_looper(){
|
|||||||
// loop: As long as we are not terminating.
|
// loop: As long as we are not terminating.
|
||||||
while (!fTerminating)
|
while (!fTerminating)
|
||||||
{
|
{
|
||||||
// get BMessages from app_server
|
msg = MessageFromPort();
|
||||||
while ( (msg = ReadMessageFromPort(10)) ){
|
|
||||||
|
// Did we get a message?
|
||||||
|
if (msg){
|
||||||
|
// Add to queue
|
||||||
fQueue->Lock();
|
fQueue->Lock();
|
||||||
fQueue->AddMessage(msg);
|
fQueue->AddMessage(msg);
|
||||||
fQueue->Unlock();
|
fQueue->Unlock();
|
||||||
dispatchNextMessage = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get BMessages from BLooper port
|
// Get message count from port
|
||||||
while ( (msg = MessageFromPort(0)) ){
|
int32 msgCount = port_count(fMsgPort);
|
||||||
|
if (msgCount > 0){
|
||||||
fQueue->Lock();
|
fQueue->Lock();
|
||||||
fQueue->AddMessage(msg);
|
for (int32 i = 0; i < msgCount; ++i)
|
||||||
|
{
|
||||||
|
// Read 'count' messages from port (so we will not block)
|
||||||
|
// We use zero as our timeout since we know there is stuff there
|
||||||
|
msg = MessageFromPort(0);
|
||||||
|
// Add messages to queue
|
||||||
|
if (msg)
|
||||||
|
fQueue->AddMessage(msg);
|
||||||
|
}
|
||||||
fQueue->Unlock();
|
fQueue->Unlock();
|
||||||
dispatchNextMessage = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop: As long as there are messages in the queue and
|
// loop: As long as there are messages in the queue and
|
||||||
// and we are not terminating.
|
// and we are not terminating.
|
||||||
|
dispatchNextMessage = true;
|
||||||
while (!fTerminating && dispatchNextMessage)
|
while (!fTerminating && dispatchNextMessage)
|
||||||
{
|
{
|
||||||
fQueue->Lock();
|
fQueue->Lock();
|
||||||
@@ -2072,6 +2100,7 @@ void BWindow::task_looper(){
|
|||||||
fQueue->Unlock();
|
fQueue->Unlock();
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
// TODO: add code for drag & drop
|
// TODO: add code for drag & drop
|
||||||
if (!fLastMessage)
|
if (!fLastMessage)
|
||||||
{
|
{
|
||||||
@@ -2114,13 +2143,20 @@ void BWindow::task_looper(){
|
|||||||
session->Sync();
|
session->Sync();
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
printf("Lock released\n");
|
||||||
// Delete the current message (fLastMessage)
|
// Delete the current message (fLastMessage)
|
||||||
if (fLastMessage)
|
if (fLastMessage)
|
||||||
{
|
{
|
||||||
delete fLastMessage;
|
delete fLastMessage;
|
||||||
fLastMessage = NULL;
|
fLastMessage = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Are any messages on the port?
|
||||||
|
if (port_count(fMsgPort) > 0)
|
||||||
|
{
|
||||||
|
// Do outer loop
|
||||||
|
dispatchNextMessage = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2129,41 +2165,7 @@ void BWindow::task_looper(){
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
BMessage* BWindow::ReadMessageFromPort(bigtime_t tout){
|
BMessage* BWindow::ReadMessageFromPort(bigtime_t tout){
|
||||||
int32 msgCode;
|
// TODO: remove!
|
||||||
BMessage* msg = NULL;
|
|
||||||
|
|
||||||
ssize_t bufferSize;
|
|
||||||
|
|
||||||
// we NEVER have to use B_INFINITE_TIMEOUT
|
|
||||||
if (tout == B_INFINITE_TIMEOUT)
|
|
||||||
tout = 0;
|
|
||||||
|
|
||||||
/* because BSession does not have support for timeout operations
|
|
||||||
We'll use this trick! :-) */
|
|
||||||
bufferSize = port_buffer_size_etc(receive_port, B_TIMEOUT, tout);
|
|
||||||
if (bufferSize == B_TIMED_OUT || bufferSize == B_BAD_PORT_ID ||
|
|
||||||
bufferSize == B_WOULD_BLOCK || bufferSize == B_INTERRUPTED )
|
|
||||||
{
|
|
||||||
msgCode = B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we have something in our port's queue
|
|
||||||
if (bufferSize > 0){
|
|
||||||
/* A rudimentary synchronize mechanism between BWindow and app_server.
|
|
||||||
* Just in case some we do something foolish :-)
|
|
||||||
* It ensures a clean "restart" if I can call it that way.
|
|
||||||
*/
|
|
||||||
if ( session->DropInputBuffer() )
|
|
||||||
printf("***PANIC: BWindow(%s): BSession's input buffer dropped! The buffer WASN'T empty!***\n", Name());
|
|
||||||
|
|
||||||
// read message code
|
|
||||||
session->ReadInt32( &msgCode );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( msgCode != B_ERROR )
|
|
||||||
msg = ConvertToMessage( NULL, msgCode );
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -2264,26 +2266,35 @@ void BWindow::BuildTopView(){
|
|||||||
// and also set its next handler to be this window.
|
// and also set its next handler to be this window.
|
||||||
top_view->setOwner( this );
|
top_view->setOwner( this );
|
||||||
|
|
||||||
|
PortLink link(send_port);
|
||||||
|
link.SetOpCode(AS_LAYER_CREATE_ROOT);
|
||||||
|
link.Attach<int32>(_get_object_token_( top_view ));
|
||||||
|
link.Attach<BRect>(top_view->Frame());
|
||||||
|
link.Attach<int32>(top_view->ResizingMode());
|
||||||
|
link.Attach<int32>(top_view->Flags());
|
||||||
|
link.AttachString(top_view->Name());
|
||||||
|
link.Flush();
|
||||||
|
/*
|
||||||
// send top_view's information to app_server
|
// send top_view's information to app_server
|
||||||
fServerLink->SetOpCode( AS_LAYER_CREATE_ROOT );
|
session->WriteInt32( AS_LAYER_CREATE_ROOT );
|
||||||
fServerLink->Attach<int32>( AS_LAYER_CREATE_ROOT );
|
session->WriteInt32( _get_object_token_( top_view ) );
|
||||||
fServerLink->Attach<int32>( _get_object_token_( top_view ) );
|
session->WriteRect( top_view->Frame() );
|
||||||
fServerLink->Attach<BRect>( top_view->Frame() );
|
session->WriteInt32( top_view->ResizingMode() );
|
||||||
fServerLink->Attach<int32>( top_view->ResizingMode() );
|
session->WriteInt32( top_view->Flags() );
|
||||||
fServerLink->Attach<int32>( top_view->Flags() );
|
session->WriteString( top_view->Name() );
|
||||||
fServerLink->AttachString( top_view->Name() );
|
|
||||||
// we DO NOT send our current state; the server knows the default values!
|
// we DO NOT send our current state; the server knows the default values!
|
||||||
fServerLink->Flush();
|
session->Sync();
|
||||||
|
*/
|
||||||
fLastViewToken = _get_object_token_( top_view );
|
fLastViewToken = _get_object_token_( top_view );
|
||||||
|
STRACE(("BuildTopView ended\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void BWindow::stopConnection(){
|
void BWindow::stopConnection(){
|
||||||
Lock();
|
Lock();
|
||||||
fServerLink->SetOpCode( AS_QUIT_WINDOW );
|
session->WriteInt32( B_QUIT_REQUESTED );
|
||||||
fServerLink->Flush();
|
session->Sync();
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3127,12 +3138,13 @@ void BWindow::drawAllViews(BView* aView){
|
|||||||
session->WriteInt32( AS_UPDATE_IF_NEEDED );
|
session->WriteInt32( AS_UPDATE_IF_NEEDED );
|
||||||
session->Sync();
|
session->Sync();
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
|
// TODO: update!!!!!!!!!!!!!!!!!!!
|
||||||
// process all update messages from receive port queue
|
// process all update messages from receive port queue
|
||||||
bool over = false;
|
bool over = false;
|
||||||
while (!over)
|
while (!over)
|
||||||
{
|
{
|
||||||
msg = ReadMessageFromPort(0);
|
msg = MessageFromPort(0);
|
||||||
if (msg){
|
if (msg){
|
||||||
switch (msg->what){
|
switch (msg->what){
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user