diff --git a/headers/private/app/SysCursor.h b/headers/private/servers/app/CursorSet.h similarity index 66% rename from headers/private/app/SysCursor.h rename to headers/private/servers/app/CursorSet.h index 1ff2832c5b..6b53a6c2c3 100644 --- a/headers/private/app/SysCursor.h +++ b/headers/private/servers/app/CursorSet.h @@ -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 -// 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 #include @@ -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 diff --git a/src/servers/app/CursorManager.cpp b/src/servers/app/CursorManager.cpp index 6f63935eb7..819f3f9e83 100644 --- a/src/servers/app/CursorManager.cpp +++ b/src/servers/app/CursorManager.cpp @@ -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); diff --git a/src/servers/app/CursorManager.h b/src/servers/app/CursorManager.h index 9815107ad9..8cbb86ec7a 100644 --- a/src/servers/app/CursorManager.h +++ b/src/servers/app/CursorManager.h @@ -29,7 +29,7 @@ #include #include -#include "SysCursor.h" +#include "CursorSet.h" #include "TokenHandler.h" class ServerCursor; diff --git a/src/servers/app/SysCursor.cpp b/src/servers/app/CursorSet.cpp similarity index 92% rename from src/servers/app/SysCursor.cpp rename to src/servers/app/CursorSet.cpp index 1798ec184e..aec3b7ade7 100644 --- a/src/servers/app/SysCursor.cpp +++ b/src/servers/app/CursorSet.cpp @@ -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 // Description: Private file encapsulating OBOS system cursor API // @@ -30,13 +30,13 @@ #include #include #include -#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(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(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 * diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index c565248385..9f0cdf207f 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -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); } diff --git a/src/servers/app/Jamfile b/src/servers/app/Jamfile index 8ad95660a4..e462470683 100644 --- a/src/servers/app/Jamfile +++ b/src/servers/app/Jamfile @@ -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 diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index f586871d77..212a9cc661 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -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" diff --git a/src/servers/app/ServerScreen.cpp b/src/servers/app/ServerScreen.cpp index 2d77f81130..2e1aa1f7b2 100644 --- a/src/servers/app/ServerScreen.cpp +++ b/src/servers/app/ServerScreen.cpp @@ -17,11 +17,8 @@ #include #include -#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; } diff --git a/src/servers/app/drawing/BitmapHWInterface.cpp b/src/servers/app/drawing/BitmapHWInterface.cpp index 5ba6969460..dab070db44 100644 --- a/src/servers/app/drawing/BitmapHWInterface.cpp +++ b/src/servers/app/drawing/BitmapHWInterface.cpp @@ -16,8 +16,6 @@ #include #include -#include - #include "Bitmap.h" #include "BitmapBuffer.h" #include "BBitmapBuffer.h" diff --git a/src/tests/apps/fake_app_server/ServerApp.cpp b/src/tests/apps/fake_app_server/ServerApp.cpp index ec6df44c07..60b01f9b7e 100644 --- a/src/tests/apps/fake_app_server/ServerApp.cpp +++ b/src/tests/apps/fake_app_server/ServerApp.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include