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:
parent
1e56330f9a
commit
46ec4904d3
@ -151,9 +151,6 @@ STRACE(("\t NULL display driver. OK. We crash now. :P\n"));
|
|||||||
desktop_private::activescreen=s;
|
desktop_private::activescreen=s;
|
||||||
s->SetSpace(0,B_32_BIT_640x480,true);
|
s->SetSpace(0,B_32_BIT_640x480,true);
|
||||||
}
|
}
|
||||||
#ifndef DEBUG_DESKTOP
|
|
||||||
printf("ERROR: NULL display driver\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Shuts down the graphics subsystem
|
//! Shuts down the graphics subsystem
|
||||||
|
@ -31,7 +31,10 @@
|
|||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
|
#include "ServerApp.h"
|
||||||
#include "PortLink.h"
|
#include "PortLink.h"
|
||||||
|
#include "ServerCursor.h"
|
||||||
|
#include "CursorManager.h"
|
||||||
#include "TokenHandler.h"
|
#include "TokenHandler.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
#include "RootLayer.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 );
|
_boundsLeftTop.Set( 0.0f, 0.0f );
|
||||||
|
|
||||||
_name = new BString(name);
|
_name = new BString(name);
|
||||||
|
|
||||||
// Layer does not start out as a part of the tree
|
// Layer does not start out as a part of the tree
|
||||||
_parent = NULL;
|
_parent = NULL;
|
||||||
_uppersibling = NULL;
|
_uppersibling = NULL;
|
||||||
@ -77,8 +81,7 @@ Layer::Layer(BRect frame, const char *name, int32 token, int32 resize,
|
|||||||
_layerdata = new LayerData;
|
_layerdata = new LayerData;
|
||||||
|
|
||||||
_serverwin = win;
|
_serverwin = win;
|
||||||
// what's this needed for?
|
_cursor = NULL;
|
||||||
_portlink = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Destructor frees all allocated heap space
|
//! Destructor frees all allocated heap space
|
||||||
@ -347,6 +350,49 @@ Layer *Layer::FindLayer(int32 token)
|
|||||||
return NULL;
|
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
|
\brief Sets a region as invalid and, thus, needing to be drawn
|
||||||
\param The region to invalidate
|
\param The region to invalidate
|
||||||
|
@ -43,6 +43,7 @@ class PortLink;
|
|||||||
class RootLayer;
|
class RootLayer;
|
||||||
class WinBorder;
|
class WinBorder;
|
||||||
class Screen;
|
class Screen;
|
||||||
|
class ServerCursor;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Layer Layer.h
|
\class Layer Layer.h
|
||||||
@ -73,6 +74,10 @@ public:
|
|||||||
const char *GetName(void) { return (_name)?_name->String():NULL; }
|
const char *GetName(void) { return (_name)?_name->String():NULL; }
|
||||||
LayerData *GetLayerData(void) { return _layerdata; }
|
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(const BRect &rect);
|
||||||
void Invalidate(BRegion& region);
|
void Invalidate(BRegion& region);
|
||||||
void RebuildRegions(bool include_children=true);
|
void RebuildRegions(bool include_children=true);
|
||||||
@ -106,7 +111,7 @@ public:
|
|||||||
void PrintNode(void);
|
void PrintNode(void);
|
||||||
void PruneTree(void);
|
void PruneTree(void);
|
||||||
void PrintTree();
|
void PrintTree();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class RootLayer;
|
friend class RootLayer;
|
||||||
friend class WinBorder;
|
friend class WinBorder;
|
||||||
@ -133,7 +138,7 @@ protected:
|
|||||||
bool _is_updating;
|
bool _is_updating;
|
||||||
bool _regions_invalid;
|
bool _regions_invalid;
|
||||||
LayerData *_layerdata;
|
LayerData *_layerdata;
|
||||||
PortLink *_portlink;
|
ServerCursor *_cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
|
#include <SysCursor.h>
|
||||||
|
|
||||||
#include <Session.h>
|
#include <Session.h>
|
||||||
|
|
||||||
@ -50,7 +51,8 @@
|
|||||||
#include "LayerData.h"
|
#include "LayerData.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
//#define DEBUG_SERVERAPP
|
#define DEBUG_SERVERAPP
|
||||||
|
|
||||||
#ifdef DEBUG_SERVERAPP
|
#ifdef DEBUG_SERVERAPP
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# define STRACE(x) printf x
|
# 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);
|
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
|
\brief The thread function ServerApps use to monitor messages
|
||||||
\param data Pointer to the thread's ServerApp object
|
\param data Pointer to the thread's ServerApp object
|
||||||
@ -233,7 +257,8 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
|
|
||||||
for(;;)
|
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){
|
switch (msgCode){
|
||||||
case AS_QUIT_APP:
|
case AS_QUIT_APP:
|
||||||
{
|
{
|
||||||
@ -381,7 +406,7 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
|
|||||||
w=(ServerWindow*)_winlist->ItemAt(i);
|
w=(ServerWindow*)_winlist->ItemAt(i);
|
||||||
if(w->_token==winid)
|
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);
|
_winlist->RemoveItem(w);
|
||||||
delete w;
|
delete w;
|
||||||
break;
|
break;
|
||||||
@ -566,6 +591,16 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
|
|||||||
}
|
}
|
||||||
case AS_SET_CURSOR_BCURSOR:
|
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:
|
// Attached data:
|
||||||
// 1) port_id reply port
|
// 1) port_id reply port
|
||||||
// 2) 68 bytes of _appcursor data
|
// 2) 68 bytes of _appcursor data
|
||||||
@ -579,15 +614,25 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
|
|||||||
_appcursor=new ServerCursor(cdata);
|
_appcursor=new ServerCursor(cdata);
|
||||||
_appcursor->SetAppSignature(_signature.String());
|
_appcursor->SetAppSignature(_signature.String());
|
||||||
cursormanager->AddCursor(_appcursor);
|
cursormanager->AddCursor(_appcursor);
|
||||||
cursormanager->SetCursor(_appcursor->ID());
|
|
||||||
|
|
||||||
// Synchronous message - BApplication is waiting on the cursor's ID
|
// Synchronous message - BApplication is waiting on the cursor's ID
|
||||||
PortLink replylink(replyport);
|
PortLink replylink(replyport);
|
||||||
replylink.SetOpCode(AS_SET_CURSOR_BCURSOR);
|
replylink.SetOpCode(AS_CREATE_BCURSOR);
|
||||||
replylink.Attach(_appcursor->ID());
|
replylink.Attach(_appcursor->ID());
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
break;
|
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:
|
case AS_GET_SCROLLBAR_INFO:
|
||||||
{
|
{
|
||||||
// Attached data:
|
// Attached data:
|
||||||
@ -674,3 +719,4 @@ ServerBitmap *ServerApp::_FindBitmap(int32 token)
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,16 +61,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool IsActive(void) const { return _isactive; }
|
bool IsActive(void) const { return _isactive; }
|
||||||
|
|
||||||
/*!
|
void Activate(bool value);
|
||||||
\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; }
|
|
||||||
bool PingTarget(void);
|
bool PingTarget(void);
|
||||||
|
|
||||||
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
|
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
|
||||||
|
|
||||||
|
void SetAppCursor(void);
|
||||||
protected:
|
protected:
|
||||||
friend class AppServer;
|
friend class AppServer;
|
||||||
friend class ServerWindow;
|
friend class ServerWindow;
|
||||||
|
@ -98,10 +98,7 @@ public:
|
|||||||
Workspace *GetWorkspace(void);
|
Workspace *GetWorkspace(void);
|
||||||
void SetWorkspace(Workspace *wkspc);
|
void SetWorkspace(Workspace *wkspc);
|
||||||
|
|
||||||
//! Returns the window's title
|
Layer *FindLayer(const Layer* start, int32 token) const;
|
||||||
const char *Title(void) { return _title->String(); }
|
|
||||||
|
|
||||||
Layer* FindLayer(const Layer* start, int32 token) const;
|
|
||||||
protected:
|
protected:
|
||||||
friend class ServerApp;
|
friend class ServerApp;
|
||||||
friend class WinBorder;
|
friend class WinBorder;
|
||||||
|
Loading…
Reference in New Issue
Block a user