Some work on cursors:

* Fixed a myriad of bugs all over the place, ranging from locking errors to
  deleting objects that don't belong to the one deleting them (hello HWInterface!)
* Almost all ServerWindow cursor stuff was broken; I've replaced all commands
  to set a cursor with a single one AS_SET_CURSOR.
* Renamed some cursor commands.
* Changed the (broken) way ServerApp::fAppCursor was maintained - the application
  cursor is now NULL as long as possible.
* Removed superfluous ServerCursor app signature stuff.
* The BApplication will no longer duplicate the default/I-beam cursors, it will
  just reuse the default ones which now have fixed tokens.
* As a result, changing the cursor is now working as expected, closing bug #102.
* Rewrote Cursor.h, renamed private members to match our style guide.
* Minor cleanup.

What's still left to be done is reference counting the cursor objects to make them
work right and reliable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16237 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-02-05 18:14:14 +00:00
parent 73b3ea3cd7
commit aa1f543799
18 changed files with 333 additions and 482 deletions
+22 -64
View File
@@ -1,82 +1,40 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Cursor.h
// Author: Frans van Nispen ([email protected])
// Description: BCursor describes a view-wide or application-wide cursor.
//------------------------------------------------------------------------------
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CURSOR_H
#define _CURSOR_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <Archivable.h>
#include <BeBuild.h>
#include <InterfaceDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BCursor class ---------------------------------------------------------------
class BCursor : BArchivable {
public:
BCursor(const void* cursorData);
BCursor(BMessage* data);
virtual ~BCursor();
public:
BCursor(const void* cursorData);
BCursor(BMessage* data);
virtual ~BCursor();
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* archive, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
virtual status_t Perform(perform_code d, void* arg);
private:
virtual void _ReservedCursor1();
virtual void _ReservedCursor2();
virtual void _ReservedCursor3();
virtual void _ReservedCursor4();
virtual void _ReservedCursor1();
virtual void _ReservedCursor2();
virtual void _ReservedCursor3();
virtual void _ReservedCursor4();
private:
friend class BApplication;
friend class BView;
friend class BApplication;
friend class BView;
int32 fServerToken;
bool fNeedToFree;
int32 m_serverToken;
int32 m_needToFree;
uint32 _reserved[6];
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _CURSOR_H
/*
* $Log $
*
* $Id $
*
*/
+10 -18
View File
@@ -1,13 +1,14 @@
/*
* Copyright 2001-2005, Haiku.
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Jérôme Duval, [email protected]
* Axel Dörfler, [email protected]
*/
#ifndef _APP_SERVER_PROTOCOL_H_
#define _APP_SERVER_PROTOCOL_H_
#ifndef APP_SERVER_PROTOCOL_H
#define APP_SERVER_PROTOCOL_H
#include <SupportDefs.h>
@@ -54,25 +55,16 @@ enum {
AS_RELEASE_SERVERMEM,
AS_AREA_MESSAGE,
// Cursor definitions
AS_SET_CURSOR_DATA,
AS_SET_CURSOR_BCURSOR,
AS_SET_CURSOR_BBITMAP,
AS_SET_CURSOR_SYSTEM,
AS_SET_SYSCURSOR_DATA,
AS_SET_SYSCURSOR_BCURSOR,
AS_SET_SYSCURSOR_BBITMAP,
AS_SET_SYSCURSOR_DEFAULTS,
AS_GET_SYSCURSOR,
// Cursor commands
AS_SET_CURSOR,
AS_SHOW_CURSOR,
AS_HIDE_CURSOR,
AS_OBSCURE_CURSOR,
AS_QUERY_CURSOR_HIDDEN,
AS_CREATE_BCURSOR,
AS_DELETE_BCURSOR,
AS_CREATE_CURSOR,
AS_DELETE_CURSOR,
AS_BEGIN_RECT_TRACKING,
AS_END_RECT_TRACKING,
@@ -260,7 +252,7 @@ enum {
AS_LAYER_SET_ORIGIN,
AS_LAYER_GET_ORIGIN,
AS_LAYER_RESIZE_MODE,
AS_LAYER_CURSOR,
AS_LAYER_SET_CURSOR,
AS_LAYER_BEGIN_RECT_TRACK,
AS_LAYER_END_RECT_TRACK,
AS_LAYER_DRAG_RECT,
@@ -320,4 +312,4 @@ enum {
AS_LAST_CODE
};
#endif // _APP_SERVER_PROTOCOL_H_
#endif // APP_SERVER_PROTOCOL_H
+21 -36
View File
@@ -1,39 +1,21 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2005, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: CursorSet.h
// Author: DarkWyrm <[email protected]>
// Description: Private file encapsulating of the Haiku system cursor API
//
//------------------------------------------------------------------------------
#ifndef CURSORSET_H_
#define CURSORSET_H_
/*
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
*/
#ifndef CURSOR_SET_H
#define CURSOR_SET_H
#include <Bitmap.h>
#include <Cursor.h>
#include <Message.h>
typedef enum
{
B_CURSOR_DEFAULT=0,
typedef enum {
B_CURSOR_DEFAULT = 1,
B_CURSOR_TEXT,
B_CURSOR_MOVE,
B_CURSOR_DRAG,
@@ -49,15 +31,14 @@ typedef enum
class ServerCursor;
const char *CursorWhichToString(cursor_which which);
BBitmap *CursorDataToBitmap(int8 *data);
/*!
\brief Class to manage system cursor sets
*/
class CursorSet : public BMessage {
public:
CursorSet(const char *name);
public:
CursorSet(const char *name);
status_t Save(const char *path,int32 saveflags=0);
status_t Load(const char *path);
status_t AddCursor(cursor_which which,const BBitmap *cursor, const BPoint &hotspot);
@@ -67,6 +48,10 @@ public:
status_t FindCursor(cursor_which which, ServerCursor **cursor);
void SetName(const char *name);
const char *GetName(void);
private:
const char *_CursorWhichToString(cursor_which which);
BBitmap *_CursorDataToBitmap(int8 *data);
};
#endif
#endif // CURSOR_SET_H
+13 -28
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2005, Haiku.
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -26,51 +26,34 @@ class BitmapManager;
*/
class ServerBitmap {
public:
inline bool IsValid() const
{ return fInitialized; }
void Acquire();
/*!
\brief Returns the area in which the buffer resides
\return
- \c B_ERROR if the buffer is not allocated in an area
- area_id for the buffer
*/
inline area_id Area() const
{ return fArea; }
// Returns the offset of the bitmap in its area
inline int32 AreaOffset() const
{ return fOffset; }
//! Returns the bitmap's buffer
inline uint8* Bits() const
{ return fBuffer; }
inline uint32 BitsLength() const
{ return (uint32)(fBytesPerRow * fHeight); }
inline BRect Bounds() const
{ return BRect(0, 0, fWidth - 1, fHeight - 1); }
//! Returns the number of bytes in each row, including padding
inline int32 BytesPerRow() const
{ return fBytesPerRow; }
inline uint8 BitsPerPixel() const
{ return fBitsPerPixel; }
inline color_space ColorSpace() const
{ return fSpace; }
//! Returns the bitmap's width in pixels per row
inline int32 Width() const
{ return fWidth; }
//! Returns the bitmap's row count
inline int32 Height() const
{ return fHeight; }
inline bool IsValid() const
{ return fInitialized; }
inline int32 BytesPerRow() const
{ return fBytesPerRow; }
inline uint8 BitsPerPixel() const
{ return fBitsPerPixel; }
inline color_space ColorSpace() const
{ return fSpace; }
//! Returns the identifier token for the bitmap
inline int32 Token() const
@@ -79,6 +62,8 @@ class ServerBitmap {
//! Does a shallow copy of the bitmap passed to it
inline void ShallowCopy(const ServerBitmap *from);
void PrintToStream();
protected:
friend class BitmapManager;
friend class PicturePlayer;
@@ -86,7 +71,7 @@ protected:
ServerBitmap(BRect rect,
color_space space,
int32 flags,
int32 bytesperline = -1,
int32 bytesPerRow = -1,
screen_id screen = B_MAIN_SCREEN_ID);
ServerBitmap(const ServerBitmap* bmp);
virtual ~ServerBitmap();
+18 -49
View File
@@ -1,50 +1,25 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ServerCursor.h
// Author: DarkWyrm <[email protected]>
// Stephan Aßmus <[email protected]>
// Description: Glorified ServerBitmap used for cursor work.
//
//------------------------------------------------------------------------------
#ifndef SERVERCURSOR_H_
#define SERVERCURSOR_H_
/*
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Stephan Aßmus <[email protected]>
* Axel Dörfler, [email protected]e
*/
#ifndef SERVER_CURSOR_H
#define SERVER_CURSOR_H
#include "ServerBitmap.h"
#include <Point.h>
#include <String.h>
#include "ServerBitmap.h"
class ServerApp;
class CursorManager;
/*!
\class ServerCursor ServerCursor.h
\brief Class to handle all cursor capabilities for the system
Although descended from ServerBitmaps, ServerCursors are not handled by
the BitmapManager - they are allocated like any other object. Unlike BeOS
R5, cursors can be any size or color space, and this class accomodates and
expands the R5 API.
*/
class ServerCursor : public ServerBitmap {
public:
ServerCursor(BRect r, color_space space,
@@ -64,24 +39,18 @@ class ServerCursor : public ServerBitmap {
BPoint GetHotSpot() const
{ return fHotSpot; }
void SetAppSignature(const char* signature);
const char* GetAppSignature() const
{ return fAppSignature.String(); }
void SetOwningTeam(team_id tid)
{ fOwningTeam = tid; }
team_id OwningTeam() const
{ return fOwningTeam; }
//! Returns the cursor's ID
int32 ID() const
int32 Token() const
{ return fToken; }
private:
friend class CursorManager;
BPoint fHotSpot;
team_id fOwningTeam;
BString fAppSignature;
};
#endif // SERVERCURSOR_H_
#endif // SERVER_CURSOR_H