Added print debug code to a number of classes

SendMessage allows for target specification
Included BMessage friend classes to allow building whilst they are absent from BMessage.cpp
More window-related code added


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3004 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-03-23 20:52:37 +00:00
parent dc4e96ca20
commit 8374297262
11 changed files with 551 additions and 38 deletions

View File

@ -52,9 +52,10 @@ RGBColor workspace_default_color(51,102,160);
This loads the default fonts, allocates all the major global variables, spawns the main housekeeping
threads, loads user preferences for the UI and decorator, and allocates various locks.
*/
AppServer::AppServer(void)
#if DISPLAYDRIVER != HWDRIVER
: BApplication (SERVER_SIGNATURE)
AppServer::AppServer(void) : BApplication (SERVER_SIGNATURE)
#else
AppServer::AppServer(void)
#endif
{
_mouseport=create_port(100,SERVER_INPUT_PORT);

View File

@ -31,17 +31,22 @@
#include "DefaultDecorator.h"
#include "RGBColor.h"
//#define DEBUG_DECORATOR
#ifdef DEBUG_DECORATOR
#include <stdio.h>
#endif
DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
: Decorator(rect,wlook,wfeel,wflags)
{
taboffset=0;
// These hard-coded assignments will go bye-bye when the system _colors
// API is implemented
// commented these out because they are taken care of by the SetFocus() call
SetFocus(false);
// These hard-coded assignments will go bye-bye when the system _colors
// API is implemented
frame_highercol.SetColor(216,216,216);
frame_lowercol.SetColor(110,110,110);
@ -60,14 +65,68 @@ DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 w
tab_highcol=_colors->window_tab;
tab_lowcol=_colors->window_tab;
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator:\n");
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom);
#endif
}
DefaultDecorator::~DefaultDecorator(void)
{
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator: ~DefaultDecorator()\n");
#endif
}
click_type DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Clicked\n");
printf("\tPoint: (%.1f,%.1f)\n",pt.x,pt.y);
printf("\tButtons:\n");
if(buttons==0)
printf("\t\tNone\n");
else
{
if(buttons & B_PRIMARY_MOUSE_BUTTON)
printf("\t\tPrimary\n");
if(buttons & B_SECONDARY_MOUSE_BUTTON)
printf("\t\tSecondary\n");
if(buttons & B_TERTIARY_MOUSE_BUTTON)
printf("\t\tTertiary\n");
}
printf("\tNodifiers:\n");
if(modifiers==0)
printf("\t\tNone\n");
else
{
if(modifiers & B_CAPS_LOCK)
printf("\t\tCaps Lock\n");
if(modifiers & B_NUM_LOCK)
printf("\t\tNum Lock\n");
if(modifiers & B_SCROLL_LOCK)
printf("\t\tScroll Lock\n");
if(modifiers & B_LEFT_COMMAND_KEY)
printf("\t\t Left Command\n");
if(modifiers & B_RIGHT_COMMAND_KEY)
printf("\t\t Right Command\n");
if(modifiers & B_LEFT_CONTROL_KEY)
printf("\t\tLeft Control\n");
if(modifiers & B_RIGHT_CONTROL_KEY)
printf("\t\tRight Control\n");
if(modifiers & B_LEFT_OPTION_KEY)
printf("\t\tLeft Option\n");
if(modifiers & B_RIGHT_OPTION_KEY)
printf("\t\tRight Option\n");
if(modifiers & B_LEFT_SHIFT_KEY)
printf("\t\tLeft Shift\n");
if(modifiers & B_RIGHT_SHIFT_KEY)
printf("\t\tRight Shift\n");
if(modifiers & B_MENU_KEY)
printf("\t\tMenu\n");
}
#endif
if(_closerect.Contains(pt))
return CLICK_CLOSE;
@ -106,6 +165,9 @@ click_type DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
void DefaultDecorator::_DoLayout(void)
{
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Do Layout\n");
#endif
// Here we determine the size of every rectangle that we use
// internally when we are given the size of the client rectangle.
@ -159,6 +221,9 @@ void DefaultDecorator::MoveBy(float x, float y)
void DefaultDecorator::MoveBy(BPoint pt)
{
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y);
#endif
// Move all internal rectangles the appropriate amount
_frame.OffsetBy(pt);
_closerect.OffsetBy(pt);
@ -170,6 +235,9 @@ void DefaultDecorator::MoveBy(BPoint pt)
BRegion * DefaultDecorator::GetFootprint(void)
{
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Get Footprint\n");
#endif
// This function calculates the decorator's footprint in coordinates
// relative to the layer. This is most often used to set a WinBorder
// object's visible region.
@ -219,6 +287,9 @@ void DefaultDecorator::_SetFocus(void)
void DefaultDecorator::Draw(BRect update)
{
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,update.right,update.bottom);
#endif
// We need to draw a few things: the tab, the resize thumb, the borders,
// and the buttons

View File

@ -395,6 +395,7 @@ void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE,
Workspace *w=desktop_private::activescreen->GetActiveWorkspace();
win->SetWorkspace(w);
desktop_private::activescreen->AddWindow(win,workspace);
desktop_private::layerlock.Unlock();
desktop_private::workspacelock.Unlock();
@ -410,6 +411,7 @@ void RemoveWindowFromDesktop(ServerWindow *win)
lock_layers();
win->SetWorkspace(NULL);
desktop_private::activescreen->RemoveWindow(win);
unlock_layers();
unlock_workspaces();

View File

@ -27,6 +27,8 @@
//------------------------------------------------------------------------------
#include "DesktopClasses.h"
#include "TokenHandler.h"
#include "ServerWindow.h"
#include "WinBorder.h"
// Defined and initialized in AppServer.cpp
extern RGBColor workspace_default_color;
@ -330,23 +332,27 @@ status_t Screen::SetSpace(int32 index, int32 res,bool stick)
*/
void Screen::AddWindow(ServerWindow *win, int32 workspace)
{
//TODO: Implement
if(!win)
if(!win || !win->_winborder)
return;
Layer *rl=GetRootLayer(workspace);
if(rl)
rl->AddChild(win->_winborder);
}
/*!
\brief Removes a Window from the desktop
\param win The window to remove
If the window does not belong to this screen or has not been added to the desktop,
this function will fail.
The window will remove itself from whatever screen it has been added to, or if it has not been
added to the desktop, it will do nothing.
*/
void Screen::RemoveWindow(ServerWindow *win)
{
//TODO: Implement
if(!win)
if(!win || !win->_winborder)
return;
win->_winborder->RemoveSelf();
}
/*!

View File

@ -34,6 +34,8 @@
#include "PortLink.h"
#include "TokenHandler.h"
//#define DEBUG_LAYER
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
TokenHandler view_token_handler;
@ -64,7 +66,7 @@ Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWind
_visible=new BRegion(Bounds());
_full=new BRegion(Bounds());
_invalid=NULL;
_invalid=new BRegion(Bounds());
_serverwin=win;
@ -79,11 +81,19 @@ Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWind
_level=0;
_layerdata=new LayerData;
#ifdef DEBUG_LAYER
printf("Layer: %s\n",name);
printf("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",frame.left,frame.top,frame.right,frame.bottom);
printf("\tWindow: %s\n",win?win->Title():"NULL");
#endif
}
//! Destructor frees all allocated heap space
Layer::~Layer(void)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: ~Layer()\n",_name->String());
#endif
if(_visible)
{
delete _visible;
@ -119,6 +129,10 @@ Layer::~Layer(void)
*/
void Layer::AddChild(Layer *layer, Layer *before=NULL, bool rebuild)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Add Child (%s, %s, %s) - Incomplete\n",_name->String(),layer?layer->_name->String():"NULL",
before?before->_name->String():"NULL",rebuild?"rebuild":"no rebuild");
#endif
// TODO: Add before support
if(layer->_parent!=NULL)
@ -181,6 +195,10 @@ void Layer::AddChild(Layer *layer, Layer *before=NULL, bool rebuild)
*/
void Layer::RemoveChild(Layer *layer, bool rebuild)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Remove Child (%s,%s)\n",_name->String(),layer?layer->_name->String():"NULL",
rebuild?"rebuild":"no rebuild");
#endif
if(layer->_parent==NULL)
{
printf("ERROR: RemoveChild(): Layer doesn't have a _parent\n");
@ -224,6 +242,9 @@ void Layer::RemoveChild(Layer *layer, bool rebuild)
*/
void Layer::RemoveSelf(bool rebuild)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: RemoveSelf(%s)\n",_name->String(),rebuild?"rebuild":"no rebuild");
#endif
// A Layer removes itself from the tree (duh)
if(_parent==NULL)
{
@ -251,6 +272,9 @@ void Layer::RemoveSelf(bool rebuild)
*/
Layer *Layer::GetChildAt(BPoint pt, bool recursive=false)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Get Child At (%.1f,%.1f)\n",_name->String(),pt.x,pt.y);
#endif
Layer *child;
if(recursive)
{
@ -304,6 +328,9 @@ BRect Layer::Frame(void)
*/
void Layer::PruneTree(void)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Prune Tree\n",_name->String());
#endif
Layer *lay,*nextlay;
lay=_topchild;
@ -329,6 +356,9 @@ void Layer::PruneTree(void)
*/
Layer *Layer::FindLayer(int32 token)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Find Layer (%ld)\n",_name->String(),token);
#endif
// recursive search for a layer based on its view token
Layer *lay, *trylay;
@ -360,6 +390,10 @@ Layer *Layer::FindLayer(int32 token)
*/
void Layer::Invalidate(BRegion region)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Invalidate(BRegion)\n",_name->String());
region.PrintToStream();
#endif
int32 i;
BRect r;
@ -406,6 +440,10 @@ void Layer::Invalidate(BRegion region)
*/
void Layer::Invalidate(BRect rect)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Invalidate(%.1f,%.1f,%.1f,%.1f)\n",_name->String(),rect.left,rect.top,rect.right,
rect.bottom);
#endif
// Make our own section dirty and pass it on to any children, if necessary....
// YES, WE ARE SHARING DIRT! Mudpies anyone? :D
if(TestRectIntersection(Frame(),rect))
@ -441,6 +479,10 @@ void Layer::Invalidate(BRect rect)
*/
void Layer::RequestDraw(const BRect &r)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: RequestDraw(%.1f,%.1f,%.1f,%.1f) - unimplemented\n",
_name->String(),r.left,r.top,r.right,r.bottom);
#endif
// TODO: Implement and fix
/* if(_visible==NULL || _hidecount>0)
return;
@ -480,6 +522,9 @@ bool Layer::IsDirty(void) const
//! Show the layer. Operates just like the BView call with the same name
void Layer::Show(void)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Show\n",_name->String());
#endif
if(_hidecount==0)
return;
@ -500,6 +545,9 @@ void Layer::Show(void)
//! Hide the layer. Operates just like the BView call with the same name
void Layer::Hide(void)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Hide\n",_name->String());
#endif
if(_hidecount==0)
{
BRegion *reg=new BRegion(ConvertToParent(_visible));
@ -547,6 +595,9 @@ uint32 Layer::CountChildren(void)
*/
void Layer::MoveBy(float x, float y)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Move By (%.1f,%.1f)\n",_name->String(),x,y);
#endif
BRect oldframe(_frame);
_frame.OffsetBy(x,y);
@ -573,6 +624,9 @@ void Layer::MoveBy(float x, float y)
*/
void Layer::ResizeBy(float x, float y)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Rezize By (%.1f,%.1f) - Incomplete\n",_name->String(),x,y);
#endif
// TODO: Implement and test child resizing based on flags
BRect oldframe=_frame;
@ -596,6 +650,10 @@ void Layer::ResizeBy(float x, float y)
*/
void Layer::RebuildRegions(bool include_children=true)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: Rebuild Regions (%s)\n",_name->String(),include_children?"include children":
"no child inclusion");
#endif
BRegion *reg,*reg2;
if(_full)
_full->Include(Bounds());

View File

@ -258,8 +258,18 @@ printf("ServerApp %s:Server shutdown notification received\n",app->_signature.St
// because the server was asked to quit. Thus, we
// ask all apps to quit. This is NOT the same as system
// shutdown and will happen only in testing
// BMessage *shutdown=new BMessage(B_QUIT_REQUESTED);
// For now, it seems that we can't seem to try to play nice and tell
// an application to quit, so we'll just have to go postal. XD
// BMessage *shutdown=new BMessage(_QUIT_);
// SendMessage(app->_sender,shutdown);
// DIE! DIE! DIE! :P
port_info pi;
get_port_info(app->_sender,&pi);
kill_team(pi.team);
app->PostMessage(B_QUIT_REQUESTED);
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s:Sent server shutdown message to BApp\n",app->_signature.String());
#endif
@ -321,6 +331,9 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
{
case AS_UPDATED_CLIENT_FONTLIST:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Client font list update confirmed\n",_signature.String());
#endif
// received when the client-side global font list has been
// refreshed
fontserver->Lock();
@ -358,6 +371,11 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
winlook, winfeel, winflags,this,win_port,workspace,htoken);
_winlist->AddItem(newwin);
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
_signature.String(),(const char *)index,rect.left,rect.top,rect.right,rect.bottom);
#endif
// Window looper is waiting for our reply. Send back the
// ServerWindow's message port
PortLink *replylink=new PortLink(reply_port);
@ -383,6 +401,9 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
w=(ServerWindow*)_winlist->ItemAt(i);
if(w->_token==winid)
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Deleting window %s\n",_signature.String(),w->Title());
#endif
_winlist->RemoveItem(w);
delete w;
break;
@ -419,6 +440,10 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
s.id=*((int32*)index);
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
_signature.String(),r.left,r.top,r.right,r.bottom);
#endif
if(sbmp)
{
// list for doing faster lookups for a bitmap than what the BitmapManager
@ -453,6 +478,9 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
ServerBitmap *sbmp=_FindBitmap(*((int32*)index));
if(sbmp)
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Deleting Bitmap %ld\n",_signature.String(),*((int32*)index));
#endif
_bmplist->RemoveItem(sbmp);
bitmapmanager->DeleteBitmap(sbmp);
write_port(replyport,SERVER_TRUE,NULL,0);
@ -464,18 +492,34 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
}
case AS_CREATE_PICTURE:
{
// TODO: Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Create Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_DELETE_PICTURE:
{
// TODO: Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Delete Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_CLONE_PICTURE:
{
// TODO: Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Clone Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_DOWNLOAD_PICTURE:
{
// TODO; Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Download Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_SET_SCREEN_MODE:
@ -487,6 +531,9 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
int32 workspace=*((int32*)index); index+=sizeof(int32);
uint32 mode=*((uint32*)index); index+=sizeof(uint32);
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: SetScreenMode: workspace %ld, mode %lu\n",_signature.String(), workspace, mode);
#endif
SetSpace(workspace,mode,*((bool*)index));
break;
@ -505,23 +552,35 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
// call the CursorManager's version to allow for future expansion
case AS_SHOW_CURSOR:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Show Cursor\n",_signature.String());
#endif
cursormanager->ShowCursor();
_cursorhidden=false;
break;
}
case AS_HIDE_CURSOR:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Hide Cursor\n",_signature.String());
#endif
cursormanager->HideCursor();
_cursorhidden=true;
break;
}
case AS_OBSCURE_CURSOR:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Obscure Cursor\n",_signature.String());
#endif
cursormanager->ObscureCursor();
break;
}
case AS_QUERY_CURSOR_HIDDEN:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Query Cursor Hidden\n",_signature.String());
#endif
// Attached data
// 1) int32 port to reply to
write_port(*((port_id*)index),(_cursorhidden)?SERVER_TRUE:SERVER_FALSE,NULL,0);
@ -529,6 +588,9 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
}
case AS_SET_CURSOR_DATA:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: SetCursor(cursor data *)\n",_signature.String());
#endif
// Attached data: 68 bytes of _appcursor data
int8 cdata[68];
@ -549,6 +611,9 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
}
case AS_SET_CURSOR_BCURSOR:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: SetCursor(BCursor)\n",_signature.String());
#endif
// Attached data:
// 1) port_id reply port
// 2) 68 bytes of _appcursor data
@ -573,8 +638,9 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
}
default:
{
printf("ServerApp %s received unhandled message code %lx\n",
_signature.String(),code);
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s received unhandled message code %lx\n",_signature.String(),code);
#endif
break;
}
}

View File

@ -40,6 +40,14 @@
#include "DesktopClasses.h"
#include "TokenHandler.h"
//#define DEBUG_SERVERWINDOW
//#define DEBUG_SERVERWINDOW_MOUSE
//#define DEBUG_SERVERWINDOW_KEYBOARD
#ifdef DEBUG_SERVERWINDOW
#include <stdio.h>
#endif
//! Handler to get BWindow tokens from
TokenHandler win_token_handler;
@ -85,11 +93,20 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
_token=win_token_handler.GetToken();
AddWindowToDesktop(this,index);
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s:\n",_title->String());
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom);
printf("\tPort: %ld\n",_receiver);
printf("\tWorkspace: %ld\n",index);
#endif
}
//!Tears down all connections with the user application, kills the monitoring thread.
ServerWindow::~ServerWindow(void)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s:~ServerWindow()\n",_title->String());
#endif
RemoveWindowFromDesktop(this);
if(_applink)
{
@ -110,6 +127,9 @@ ServerWindow::~ServerWindow(void)
*/
void ServerWindow::RequestDraw(BRect rect)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Request Draw\n",_title->String());
#endif
_winlink->SetOpCode(AS_LAYER_DRAW);
_winlink->Attach(&rect,sizeof(BRect));
_winlink->Flush();
@ -124,12 +144,18 @@ void ServerWindow::RequestDraw(void)
//! Forces the window border to update its decorator
void ServerWindow::ReplaceDecorator(void)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Replace Decorator\n",_title->String());
#endif
_winborder->UpdateDecorator();
}
//! Requests that the ServerWindow's BWindow quit
void ServerWindow::Quit(void)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Quit\n",_title->String());
#endif
_winlink->SetOpCode(B_QUIT_REQUESTED);
_winlink->Flush();
}
@ -155,6 +181,9 @@ ServerApp *ServerWindow::GetApp(void)
//! Shows the window's WinBorder
void ServerWindow::Show(void)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Show\n",_title->String());
#endif
if(_winborder)
_winborder->Show();
}
@ -162,6 +191,9 @@ void ServerWindow::Show(void)
//! Hides the window's WinBorder
void ServerWindow::Hide(void)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Hide\n",_title->String());
#endif
if(_winborder)
_winborder->Hide();
}
@ -184,6 +216,9 @@ bool ServerWindow::IsHidden(void)
*/
void ServerWindow::SetFocus(bool value)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Set Focus to %s\n",_title->String(),value?"true":"false");
#endif
if(_active!=value)
{
_active=value;
@ -207,6 +242,9 @@ bool ServerWindow::HasFocus(void)
*/
void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: WorkspaceActivated unimplemented\n",_title->String());
#endif
// TODO: implement
}
@ -217,6 +255,9 @@ void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
*/
void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: WorkspaceChanged unimplemented\n",_title->String());
#endif
// TODO: implement
}
@ -226,6 +267,9 @@ void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
*/
void ServerWindow::WindowActivated(bool active)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: WindowActivated unimplemented\n",_title->String());
#endif
// TODO: implement
}
@ -236,6 +280,9 @@ void ServerWindow::WindowActivated(bool active)
*/
void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: ScreenModeChanged unimplemented\n",_title->String());
#endif
// TODO: implement
}
@ -245,6 +292,10 @@ void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace
*/
void ServerWindow::SetFrame(const BRect &rect)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Set Frame to (%.1f,%.1f,%.1f,%.1f)\n",_title->String(),
rect.left,rect.top,rect.right,rect.bottom);
#endif
_frame=rect;
}
@ -263,12 +314,18 @@ BRect ServerWindow::Frame(void)
*/
status_t ServerWindow::Lock(void)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Lock\n",_title->String());
#endif
return (_locker.Lock())?B_OK:B_ERROR;
}
//! Unlocks the window
void ServerWindow::Unlock(void)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Unlock\n",_title->String());
#endif
_locker.Unlock();
}
@ -303,6 +360,9 @@ void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
// so the BView can identify itself
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Create_Layer unimplemented\n",_title->String());
#endif
break;
}
@ -317,6 +377,9 @@ void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
// 1) (int32) id of the removed view
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Delete_Layer unimplemented\n",_title->String());
#endif
break;
}
@ -331,27 +394,173 @@ void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
break;
}
case AS_SEND_BEHIND:
case AS_ENABLE_UPDATES:
case AS_DISABLE_UPDATES:
case AS_NEEDS_UPDATE:
case AS_WINDOW_TITLE:
case AS_ADD_TO_SUBSET:
case AS_REM_FROM_SUBSET:
case AS_SET_LOOK:
case AS_SET_FLAGS:
case AS_SET_FEEL:
case AS_SET_ALIGNMENT:
case AS_GET_ALIGNMENT:
case AS_GET_WORKSPACES:
case AS_SET_WORKSPACES:
case AS_WINDOW_RESIZEBY:
case AS_WINDOW_RESIZETO:
case B_MINIMIZE:
case B_WINDOW_ACTIVATED:
case B_ZOOM:
case B_WINDOW_MOVE_TO:
case B_WINDOW_MOVE_BY:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Send_Behind unimplemented\n",_title->String());
#endif
break;
}
case AS_ENABLE_UPDATES:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Enable_Updates unimplemented\n",_title->String());
#endif
break;
}
case AS_DISABLE_UPDATES:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Disable_Updates unimplemented\n",_title->String());
#endif
break;
}
case AS_NEEDS_UPDATE:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Needs_Update unimplemented\n",_title->String());
#endif
break;
}
case AS_WINDOW_TITLE:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Set_Title unimplemented\n",_title->String());
#endif
break;
}
case AS_ADD_TO_SUBSET:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Add_To_Subset unimplemented\n",_title->String());
#endif
break;
}
case AS_REM_FROM_SUBSET:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Remove_From_Subset unimplemented\n",_title->String());
#endif
break;
}
case AS_SET_LOOK:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Set_Look unimplemented\n",_title->String());
#endif
break;
}
case AS_SET_FLAGS:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Set_Flags unimplemented\n",_title->String());
#endif
break;
}
case AS_SET_FEEL:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Set_Feel unimplemented\n",_title->String());
#endif
break;
}
case AS_SET_ALIGNMENT:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Set_Alignment unimplemented\n",_title->String());
#endif
break;
}
case AS_GET_ALIGNMENT:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Get_Alignment unimplemented\n",_title->String());
#endif
break;
}
case AS_GET_WORKSPACES:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Get_Workspaces unimplemented\n",_title->String());
#endif
break;
}
case AS_SET_WORKSPACES:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Set_Workspaces unimplemented\n",_title->String());
#endif
break;
}
case AS_WINDOW_RESIZEBY:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Resize_By unimplemented\n",_title->String());
#endif
break;
}
case AS_WINDOW_RESIZETO:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Resize_To unimplemented\n",_title->String());
#endif
break;
}
case B_MINIMIZE:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Minimize unimplemented\n",_title->String());
#endif
break;
}
case B_WINDOW_ACTIVATED:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Window_Activated unimplemented\n",_title->String());
#endif
break;
}
case B_ZOOM:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Zoom unimplemented\n",_title->String());
#endif
break;
}
case B_WINDOW_MOVE_TO:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Move_To unimplemented\n",_title->String());
#endif
break;
}
case B_WINDOW_MOVE_BY:
{
// TODO: Implement
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Message Move_By unimplemented\n",_title->String());
#endif
break;
}
default:
{
printf("ServerWindow %s received unexpected code %lx",_title->String(),code);
@ -403,6 +612,9 @@ int32 ServerWindow::MonitorWin(void *data)
{
case B_QUIT_REQUESTED:
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s received Quit request\n",win->Title());
#endif
// Our BWindow sent us this message when it quit.
// We need to ask its ServerApp to delete our monitor
win->_applink->SetOpCode(AS_DELETE_WINDOW);
@ -440,6 +652,9 @@ int32 ServerWindow::MonitorWin(void *data)
*/
void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
{
#ifdef DEBUG_SERVERWINDOW_MOUSE
printf("ServerWindow::HandleMouseEvent unimplemented\n");
#endif
/* ServerWindow *mousewin=NULL;
int8 *index=buffer;
@ -563,6 +778,9 @@ void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
*/
void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer)
{
#ifdef DEBUG_SERVERWINDOW_KEYBOARD
printf("ServerWindow::HandleKeyEvent unimplemented\n");
#endif
/* ServerWindow *keywin=NULL;
int8 *index=buffer;
@ -589,6 +807,9 @@ Workspace *ServerWindow::GetWorkspace(void)
*/
void ServerWindow::SetWorkspace(Workspace *wkspc)
{
#ifdef DEBUG_SERVERWINDOW
printf("ServerWindow %s: Set Workspace\n",_title->String());
#endif
_workspace=wkspc;
}
@ -597,6 +818,9 @@ void ServerWindow::SetWorkspace(Workspace *wkspc)
*/
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin)
{
#ifdef DEBUG_SERVERWINDOW
printf("ActivateWindow: old=%s, new=%s\n",oldwin?oldwin->Title():"NULL",newwin?newwin->Title():"NULL");
#endif
if(oldwin==newwin)
return;

View File

@ -95,9 +95,12 @@ public:
Workspace *GetWorkspace(void);
void SetWorkspace(Workspace *wkspc);
//! Returns the window's title
const char *Title(void) { return _title->String(); }
protected:
friend ServerApp;
friend WinBorder;
friend class Screen;
BString *_title;
int32 _look, _feel, _flags;

View File

@ -8,10 +8,15 @@
This SendMessage takes ownership of the message sent, so deleting them after this
call is unnecessary. Passing an invalid port will have unpredictable results.
*/
void SendMessage(port_id port, BMessage *message)
void SendMessage(port_id port, BMessage *message, int32 target)
{
if(!message)
return;
if(target==-1)
_set_message_target_(message,target,true);
else
_set_message_target_(message,target,false);
ssize_t flatsize=message->FlattenedSize();
char *buffer=new char[flatsize];
@ -22,3 +27,34 @@ void SendMessage(port_id port, BMessage *message)
delete buffer;
delete message;
}
/*
Below are friend functions for BMessage which currently are not in the Message.cpp
that we need to send messages to BLoopers and such. Placed here to allow compilation.
*/
void _set_message_target_(BMessage *msg, int32 target, bool preferred)
{
if (preferred)
{
msg->fTarget = -1;
msg->fPreferred = true;
}
else
{
msg->fTarget = target;
msg->fPreferred = false;
}
}
int32 _get_message_target_(BMessage *msg)
{
if (msg->fPreferred)
return -1;
else
return msg->fTarget;
}
bool _use_preferred_target_(BMessage *msg)
{
return msg->fPreferred;
}

View File

@ -4,6 +4,6 @@
#include <Message.h>
#include <OS.h>
void SendMessage(port_id port, BMessage *message);
void SendMessage(port_id port, BMessage *message, int32 target=-1);
#endif

View File

@ -37,6 +37,17 @@
#include "WinBorder.h"
#include "AppServer.h" // for new_decorator()
//#define DEBUG_WINBORDER
//#define DEBUG_WINBORDER_MOUSE
#ifdef DEBUG_WINBORDER
#include <stdio.h>
#endif
#ifdef DEBUG_WINBORDER_MOUSE
#include <stdio.h>
#endif
namespace winborder_private
{
bool is_moving_window=false;
@ -55,7 +66,7 @@ WinBorder * get_active_winborder(void) { return winborder_private::active_winbor
void set_active_winborder(WinBorder *win) { winborder_private::active_winborder=win; }
WinBorder::WinBorder(BRect r, const char *name, int32 look, int32 feel, int32 flags, ServerWindow *win)
: Layer(r,name,0,flags,win)
: Layer(r,name,B_FOLLOW_NONE,flags,win)
{
_mbuttons=0;
_win=win;
@ -70,15 +81,26 @@ WinBorder::WinBorder(BRect r, const char *name, int32 look, int32 feel, int32 fl
_vresizewin=false;
_decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver());
#ifdef DEBUG_WINBORDER
printf("WinBorder %s:\n",_title->String());
printf("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom);
printf("\tWindow %s\n",win?win->Title():"NULL");
#endif
}
WinBorder::~WinBorder(void)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s:~WinBorder()\n",_title->String());
#endif
delete _title;
}
void WinBorder::MouseDown(int8 *buffer)
{
#ifdef DEBUG_WINBORDER_MOUSE
printf("WinBorder %s: MouseDown unimplemented\n",_title->String());
#endif
/* _mbuttons=buttons;
kmodifiers=modifiers;
click_type click=_decorator->Clicked(pt, _mbuttons, kmodifiers);
@ -150,6 +172,9 @@ void WinBorder::MouseDown(int8 *buffer)
void WinBorder::MouseMoved(int8 *buffer)
{
#ifdef DEBUG_WINBORDER_MOUSE
printf("WinBorder %s: MouseMoved unimplemented\n",_title->String());
#endif
/* _mbuttons=buttons;
kmodifiers=modifiers;
click_type click=_decorator->Clicked(pt, _mbuttons, kmodifiers);
@ -238,6 +263,9 @@ void WinBorder::MouseMoved(int8 *buffer)
void WinBorder::MouseUp(int8 *buffer)
{
#ifdef DEBUG_WINBORDER_MOUSE
printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
#endif
/*
_mbuttons=buttons;
kmodifiers=modifiers;
@ -285,6 +313,9 @@ void WinBorder::MouseUp(int8 *buffer)
void WinBorder::Draw(BRect update_rect)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s: Draw\n",_title->String());
#endif
if(_update && _visible!=NULL)
_is_updating=true;
@ -296,6 +327,9 @@ void WinBorder::Draw(BRect update_rect)
void WinBorder::RequestDraw(const BRect &r)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s: RequestDraw\n",_title->String());
#endif
_decorator->Draw(r);
}
@ -333,16 +367,28 @@ void WinBorder::ResizeBy(float x, float y)
void WinBorder::UpdateColors(void)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s: UpdateColors\n",_title->String());
#endif
}
void WinBorder::UpdateDecorator(void)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s: UpdateDecorator\n",_title->String());
#endif
}
void WinBorder::UpdateFont(void)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s: UpdateFont\n",_title->String());
#endif
}
void WinBorder::UpdateScreen(void)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s: UpdateScreen\n",_title->String());
#endif
}