All cursor related changes:

* Moved setting the default cursor from ServerScreen to Desktop
* Getting the default cursor is now done using the CursorManager
* Removed outdated setcursor from SysCursor.cpp (we have a new implementation by now)
* Renamed SysCursor.cpp to CursorSet.cpp as that's what it is
* Moved  headers/private/app/SysCursor.h to headers/private/servers/app/CursorSet.h
* Removed some unneeded header includes along the way

There remains {set|get}_syscursor now in CursorSet.cpp. Serverside for these are not implemented
and they are obvious hacks. Do we need to keep them?
Also this commit _would_ break Appearance, but 1) all the related code is currently commented out
with the comment "cursor set management belongs in another app" and 2) it is already broken
because of ColorSet.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13726 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2005-07-18 00:22:08 +00:00
parent a93b45f00f
commit 2213782534
10 changed files with 48 additions and 81 deletions

View File

@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// 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"),
@ -19,13 +19,13 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: SysCursor.h
// File Name: CursorSet.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Private file encapsulating OBOS system cursor API
// Description: Private file encapsulating of the Haiku system cursor API
//
//------------------------------------------------------------------------------
#ifndef SYSCURSOR_H_
#define SYSCURSOR_H_
#ifndef CURSORSET_H_
#define CURSORSET_H_
#include <Bitmap.h>
#include <Cursor.h>
@ -49,33 +49,24 @@ typedef enum
class ServerCursor;
void set_syscursor(cursor_which which, const BCursor *cursor);
void set_syscursor(cursor_which which, const BBitmap *bitmap);
cursor_which get_syscursor(void);
void setcursor(cursor_which which);
const char *CursorWhichToString(cursor_which which);
BBitmap *CursorDataToBitmap(int8 *data);
/*!
\brief Class to manage system cursor sets
*/
class CursorSet : public BMessage
{
class CursorSet : public BMessage {
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);
status_t AddCursor(cursor_which which, int8 *data);
void RemoveCursor(cursor_which which);
status_t FindCursor(cursor_which which, BBitmap **cursor, BPoint *hotspot);
status_t FindCursor(cursor_which which, ServerCursor **cursor);
void SetName(const char *name);
const char *GetName(void);
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);
status_t AddCursor(cursor_which which, int8 *data);
void RemoveCursor(cursor_which which);
status_t FindCursor(cursor_which which, BBitmap **cursor, BPoint *hotspot);
status_t FindCursor(cursor_which which, ServerCursor **cursor);
void SetName(const char *name);
const char *GetName(void);
};
#endif

View File

@ -30,6 +30,7 @@
#include "CursorManager.h"
#include "ServerCursor.h"
#include "ServerConfig.h"
#include "HaikuSystemCursor.h"
//! Initializes the CursorManager
CursorManager::CursorManager()
@ -38,8 +39,16 @@ CursorManager::CursorManager()
fTokenizer.ExcludeValue(B_ERROR);
// Set system cursors to "unassigned"
// ToDo: decide about default cursor
#if 1
fDefaultCursor = new ServerCursor(kHaikuCursorBits, kHaikuCursorWidth,
kHaikuCursorHeight, kHaikuCursorFormat);
// we just happen to know where the hotspot is
fDefaultCursor->SetHotSpot(BPoint(1, 0));
#else
fDefaultCursor = new ServerCursor(default_cursor_data);
AddCursor(fDefaultCursor);
#endif
fTextCursor = new ServerCursor(default_text_data);
AddCursor(fTextCursor);

View File

@ -29,7 +29,7 @@
#include <List.h>
#include <Locker.h>
#include "SysCursor.h"
#include "CursorSet.h"
#include "TokenHandler.h"
class ServerCursor;

View File

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: SysCursor.cpp
// File Name: CursorSet.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Private file encapsulating OBOS system cursor API
//
@ -30,13 +30,13 @@
#include <OS.h>
#include <String.h>
#include <File.h>
#include "SysCursor.h"
#include "CursorSet.h"
#include "ServerCursor.h"
/*!
\brief Sets a system cursor
\param which System cursor specifier defined in SysCursor.h
\param cursor The new cursor
\brief Sets a system cursor
\param which System cursor specifier defined in CursorSet.h
\param cursor The new cursor
*/
void
set_syscursor(cursor_which which, const BCursor *cursor)
@ -48,7 +48,7 @@ set_syscursor(cursor_which which, const BCursor *cursor)
BPrivate::PortLink link(server);
link.StartMessage(AS_SET_SYSCURSOR_BCURSOR);
link.Attach<cursor_which>(which);
// The easy (and clean) way for us to access the cursor's token
// would be to make it a friend function of the BCursor class. One problem:
// we couldn't build this under R5. For R1, we'll use a hack which we can
@ -62,7 +62,7 @@ set_syscursor(cursor_which which, const BCursor *cursor)
/*!
\brief Sets a system cursor
\param which System cursor specifier defined in SysCursor.h
\param which System cursor specifier defined in CursorSet.h
\param bitmap BBitmap to represent the new cursor. Size should be 48x48 or less.
*/
void
@ -75,7 +75,7 @@ set_syscursor(cursor_which which, const BBitmap *bitmap)
BPrivate::PortLink link(server);
link.StartMessage(AS_SET_SYSCURSOR_BBITMAP);
link.Attach<cursor_which>(which);
// Just like the BCursor version, we will use a hack until R1.
int32 *hack=(int32*)bitmap;
hack+=(sizeof(int32)*4)+sizeof(color_space)+sizeof(BRect);
@ -86,7 +86,7 @@ set_syscursor(cursor_which which, const BBitmap *bitmap)
/*!
\brief Returns the cursor specifier currently shown
\return Returns B_CURSOR_OTHER if an application-set cursor. Otherwise, see SysCursor.h
\return Returns B_CURSOR_OTHER if an application-set cursor. Otherwise, see CursorSet.h
*/
cursor_which
get_syscursor(void)
@ -107,25 +107,6 @@ get_syscursor(void)
return B_CURSOR_INVALID;
}
/*!
\brief Changes the application cursor to the specified cursor
\param which System cursor specifier defined in SysCursor.h
*/
void
setcursor(cursor_which which)
{
port_id server = find_port(SERVER_PORT_NAME);
if (server < B_OK)
return;
BPrivate::PortLink link(server);
link.StartMessage(AS_SET_CURSOR_SYSTEM);
link.Flush();
}
// #pragma mark -
/*!
\brief Constructor
@ -184,7 +165,7 @@ CursorSet::Load(const char *path)
/*!
\brief Adds the cursor to the set and replaces any existing entry for the given specifier
\param which System cursor specifier defined in SysCursor.h
\param which System cursor specifier defined in CursorSet.h
\param cursor BBitmap to represent the new cursor. Size should be 48x48 or less.
\param hotspot The recipient of the hotspot for the cursor
\return B_BAD_VALUE if cursor is NULL, otherwise B_OK
@ -216,7 +197,7 @@ CursorSet::AddCursor(cursor_which which, const BBitmap *cursor, const BPoint &ho
/*!
\brief Adds the cursor to the set and replaces any existing entry for the given specifier
\param which System cursor specifier defined in SysCursor.h
\param which System cursor specifier defined in CursorSet.h
\param data R5 cursor data pointer
\return B_BAD_VALUE if data is NULL, otherwise B_OK
@ -242,7 +223,7 @@ CursorSet::AddCursor(cursor_which which, int8 *data)
/*!
\brief Removes the data associated with the specifier from the cursor set
\param which System cursor specifier defined in SysCursor.h
\param which System cursor specifier defined in CursorSet.h
*/
void
CursorSet::RemoveCursor(cursor_which which)
@ -252,7 +233,7 @@ CursorSet::RemoveCursor(cursor_which which)
/*!
\brief Retrieves a cursor from the set.
\param which System cursor specifier defined in SysCursor.h
\param which System cursor specifier defined in CursorSet.h
\param cursor Bitmap** to receive a newly-allocated BBitmap containing the appropriate data
\param hotspot The recipient of the hotspot for the cursor
\return
@ -301,7 +282,7 @@ CursorSet::FindCursor(cursor_which which, BBitmap **cursor, BPoint *hotspot)
/*!
\brief Retrieves a cursor from the set.
\param which System cursor specifier defined in SysCursor.h
\param which System cursor specifier defined in CursorSet.h
\param cursor ServerCursor** to receive a newly-allocated ServerCursor containing the appropriate data
\return
- \c B_OK: Success
@ -376,7 +357,7 @@ CursorSet::SetName(const char *name)
/*!
\brief Returns a string for the specified cursor attribute
\param which System cursor specifier defined in SysCursor.h
\param which System cursor specifier defined in CursorSet.h
\return Name for the cursor specifier
*/
const char *

View File

@ -89,6 +89,11 @@ Desktop::Init()
fRootLayer = new RootLayer(name, 4, this, GetDisplayDriver());
fRootLayer->RunThread();
// take care of setting the default cursor
ServerCursor *cursor = fRootLayer->GetCursorManager().GetCursor(B_CURSOR_DEFAULT);
if (cursor)
fVirtualScreen.HWInterface()->SetCursor(cursor);
}

View File

@ -49,6 +49,7 @@ SharedLibrary appserver :
BitmapManager.cpp
ColorSet.cpp
CursorData.cpp
CursorSet.cpp
Decorator.cpp
FontFamily.cpp
IPoint.cpp
@ -58,7 +59,6 @@ SharedLibrary appserver :
ServerCursor.cpp
ServerFont.cpp
FontServer.cpp
SysCursor.cpp
SystemPalette.cpp
TokenHandler.cpp
Utils.cpp

View File

@ -27,6 +27,7 @@
#include "BGet++.h"
#include "BitmapManager.h"
#include "CursorManager.h"
#include "CursorSet.h"
#include "Desktop.h"
#include "DecorManager.h"
#include "DisplayDriver.h"
@ -42,7 +43,6 @@
#include "ServerPicture.h"
#include "ServerScreen.h"
#include "ServerWindow.h"
#include "SysCursor.h"
#include "SystemPalette.h"
#include "Utils.h"
#include "WinBorder.h"

View File

@ -17,11 +17,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "CursorData.h"
#include "DisplayDriverPainter.h"
#include "HaikuSystemCursor.h"
#include "HWInterface.h"
#include "ServerCursor.h"
#include "ServerScreen.h"
@ -56,19 +53,6 @@ Screen::Initialize()
if (fDriver) {
// this will also init the graphics hardware the driver is attached to
ret = fDriver->Initialize();
if (ret >= B_OK) {
// take care of setting the cursor on this screen
// SetCursor(new ServerCursor(default_cursor_data));
// TODO: some temporary goofing arround
ServerCursor* cursor = new ServerCursor(kHaikuCursorBits,
kHaikuCursorWidth,
kHaikuCursorHeight,
kHaikuCursorFormat);
// we just happen to know where the hotspot is
cursor->SetHotSpot(BPoint(1, 0));
fHWInterface->SetCursor(cursor);
}
}
return ret;
}

View File

@ -16,8 +16,6 @@
#include <stdio.h>
#include <string.h>
#include <Cursor.h>
#include "Bitmap.h"
#include "BitmapBuffer.h"
#include "BBitmapBuffer.h"

View File

@ -14,7 +14,6 @@
#include <AppDefs.h>
#include <List.h>
#include <String.h>
#include <SysCursor.h>
#include <ColorSet.h>
#include <RGBColor.h>
#include <stdio.h>