Added Layer functions for mouse transit events and for view cursors

Added app cursor support


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4736 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-09-17 19:28:31 +00:00
parent 1e56330f9a
commit 46ec4904d3
6 changed files with 110 additions and 23 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -28,6 +28,7 @@
#include <List.h>
#include <String.h>
#include <PortLink.h>
#include <SysCursor.h>
#include <Session.h>
@ -50,7 +51,8 @@
#include "LayerData.h"
#include "Utils.h"
//#define DEBUG_SERVERAPP
#define DEBUG_SERVERAPP
#ifdef DEBUG_SERVERAPP
# include <stdio.h>
# 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;
}

View File

@ -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;

View File

@ -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;