diff --git a/src/servers/app/server/Desktop.cpp b/src/servers/app/server/Desktop.cpp index 44b654c5be..0e6bed99eb 100644 --- a/src/servers/app/server/Desktop.cpp +++ b/src/servers/app/server/Desktop.cpp @@ -151,9 +151,6 @@ STRACE(("\t NULL display driver. OK. We crash now. :P\n")); desktop_private::activescreen=s; s->SetSpace(0,B_32_BIT_640x480,true); } -#ifndef DEBUG_DESKTOP -printf("ERROR: NULL display driver\n"); -#endif } //! Shuts down the graphics subsystem diff --git a/src/servers/app/server/Layer.cpp b/src/servers/app/server/Layer.cpp index c506d83d85..06da3d2cad 100644 --- a/src/servers/app/server/Layer.cpp +++ b/src/servers/app/server/Layer.cpp @@ -31,7 +31,10 @@ #include "Layer.h" #include "RectUtils.h" #include "ServerWindow.h" +#include "ServerApp.h" #include "PortLink.h" +#include "ServerCursor.h" +#include "CursorManager.h" #include "TokenHandler.h" #include "RectUtils.h" #include "RootLayer.h" @@ -56,6 +59,7 @@ Layer::Layer(BRect frame, const char *name, int32 token, int32 resize, _boundsLeftTop.Set( 0.0f, 0.0f ); _name = new BString(name); + // Layer does not start out as a part of the tree _parent = NULL; _uppersibling = NULL; @@ -77,8 +81,7 @@ Layer::Layer(BRect frame, const char *name, int32 token, int32 resize, _layerdata = new LayerData; _serverwin = win; - // what's this needed for? - _portlink = NULL; + _cursor = NULL; } //! Destructor frees all allocated heap space @@ -347,6 +350,49 @@ Layer *Layer::FindLayer(int32 token) return NULL; } +/*! + \brief Sets the layer's personal cursor. See BView::SetViewCursor + \return The cursor associated with this layer. + +*/ +void Layer::SetLayerCursor(ServerCursor *csr) +{ + _cursor=csr; +} + +/*! + \brief Returns the layer's personal cursor. See BView::SetViewCursor + \return The cursor associated with this layer. + +*/ +ServerCursor *Layer::GetLayerCursor(void) const +{ + return _cursor; +} + +/*! + \brief Hook function for handling pointer transitions, much like BView::MouseMoved + \param transit The type of event which occurred. + + The default version of this function changes the cursor to the view's cursor, if there + is one. If there isn't one, the default cursor is chosen +*/ +void Layer::MouseTransit(uint32 transit) +{ + if(transit==B_ENTERED_VIEW) + { + if(_cursor) + cursormanager->SetCursor(_cursor->ID()); + else + { + if(_serverwin) + _serverwin->GetApp()->SetAppCursor(); + else + cursormanager->SetCursor(B_CURSOR_DEFAULT); + } + } +} + /*! \brief Sets a region as invalid and, thus, needing to be drawn \param The region to invalidate diff --git a/src/servers/app/server/Layer.h b/src/servers/app/server/Layer.h index 504cc7b91c..675c7dbb29 100644 --- a/src/servers/app/server/Layer.h +++ b/src/servers/app/server/Layer.h @@ -43,6 +43,7 @@ class PortLink; class RootLayer; class WinBorder; class Screen; +class ServerCursor; /*! \class Layer Layer.h @@ -73,6 +74,10 @@ public: const char *GetName(void) { return (_name)?_name->String():NULL; } LayerData *GetLayerData(void) { return _layerdata; } + void SetLayerCursor(ServerCursor *csr); + ServerCursor *GetLayerCursor(void) const; + virtual void MouseTransit(uint32 transit); + void Invalidate(const BRect &rect); void Invalidate(BRegion& region); void RebuildRegions(bool include_children=true); @@ -106,7 +111,7 @@ public: void PrintNode(void); void PruneTree(void); void PrintTree(); - + protected: friend class RootLayer; friend class WinBorder; @@ -133,7 +138,7 @@ protected: bool _is_updating; bool _regions_invalid; LayerData *_layerdata; - PortLink *_portlink; + ServerCursor *_cursor; }; #endif diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index b18d93ed84..8369f6bd41 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -50,7 +51,8 @@ #include "LayerData.h" #include "Utils.h" -//#define DEBUG_SERVERAPP +#define DEBUG_SERVERAPP + #ifdef DEBUG_SERVERAPP # include # define STRACE(x) printf x @@ -217,6 +219,28 @@ void ServerApp::PostMessage(int32 code, size_t size, int8 *buffer) write_port(_receiver,code, buffer, size); } +/*! + \brief Sets the ServerApp's active status + \param value The new status of the ServerApp. + + This changes an internal flag and also sets the current cursor to the one specified by + the application +*/ +void ServerApp::Activate(bool value) +{ + _isactive=value; + SetAppCursor(); +} + +//! Sets the cursor to the application cursor, if any. +void ServerApp::SetAppCursor(void) +{ + if(_appcursor) + cursormanager->SetCursor(_appcursor->ID()); + else + cursormanager->SetCursor(B_CURSOR_DEFAULT); +} + /*! \brief The thread function ServerApps use to monitor messages \param data Pointer to the thread's ServerApp object @@ -233,7 +257,8 @@ int32 ServerApp::MonitorApp(void *data) for(;;) { - if ( app->ses->ReadInt32( &msgCode ) != B_BAD_PORT_ID ){ + if(app->ses->ReadInt32(&msgCode)!= B_BAD_PORT_ID ){ + printf("Received message %ld\n",msgCode); switch (msgCode){ case AS_QUIT_APP: { @@ -381,7 +406,7 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer) w=(ServerWindow*)_winlist->ItemAt(i); if(w->_token==winid) { - STRACE(("ServerApp %s: Deleting window %s\n",_signature.String(),w->Title())); + STRACE(("ServerApp %s: Deleting window %s\n",_signature.String(),w->GetTitle())); _winlist->RemoveItem(w); delete w; break; @@ -566,6 +591,16 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer) } case AS_SET_CURSOR_BCURSOR: { + // Attached data: + // 1) int32 token ID of the cursor to set + + if(!index) + cursormanager->SetCursor(*((int32*)index)); + break; + } + case AS_CREATE_BCURSOR: + { +printf("Create BCursor\n"); // Attached data: // 1) port_id reply port // 2) 68 bytes of _appcursor data @@ -579,15 +614,25 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer) _appcursor=new ServerCursor(cdata); _appcursor->SetAppSignature(_signature.String()); cursormanager->AddCursor(_appcursor); - cursormanager->SetCursor(_appcursor->ID()); // Synchronous message - BApplication is waiting on the cursor's ID PortLink replylink(replyport); - replylink.SetOpCode(AS_SET_CURSOR_BCURSOR); + replylink.SetOpCode(AS_CREATE_BCURSOR); replylink.Attach(_appcursor->ID()); replylink.Flush(); break; } + case AS_DELETE_BCURSOR: + { + // Attached data: + // 1) int32 token ID of the cursor to delete + if(_appcursor && _appcursor->ID()==*((int32*)index)) + _appcursor=NULL; + + if(!index) + cursormanager->DeleteCursor(*((int32*)index)); + break; + } case AS_GET_SCROLLBAR_INFO: { // Attached data: @@ -674,3 +719,4 @@ ServerBitmap *ServerApp::_FindBitmap(int32 token) } return NULL; } + diff --git a/src/servers/app/server/ServerApp.h b/src/servers/app/server/ServerApp.h index 7d04630137..d8b7e44abd 100644 --- a/src/servers/app/server/ServerApp.h +++ b/src/servers/app/server/ServerApp.h @@ -61,16 +61,12 @@ public: */ bool IsActive(void) const { return _isactive; } - /*! - \brief Sets the ServerApp's active status - \param value The new status of the ServerApp. - - Note that this function only changes a flag. - */ - void Activate(bool value) { _isactive=value; } + void Activate(bool value); bool PingTarget(void); void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL); + + void SetAppCursor(void); protected: friend class AppServer; friend class ServerWindow; diff --git a/src/servers/app/server/ServerWindow.h b/src/servers/app/server/ServerWindow.h index 61ec4be8cd..933ba107cd 100644 --- a/src/servers/app/server/ServerWindow.h +++ b/src/servers/app/server/ServerWindow.h @@ -98,10 +98,7 @@ public: Workspace *GetWorkspace(void); void SetWorkspace(Workspace *wkspc); - //! Returns the window's title - const char *Title(void) { return _title->String(); } - - Layer* FindLayer(const Layer* start, int32 token) const; + Layer *FindLayer(const Layer* start, int32 token) const; protected: friend class ServerApp; friend class WinBorder;