Added CursorManager and BitmapManager to startup procedures

Work on cursor support.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2784 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-02-20 20:14:57 +00:00
parent e9318266f9
commit a8224b9257
8 changed files with 113 additions and 3 deletions

View File

@ -30,10 +30,13 @@
#include "DisplayDriver.h"
#include "PortLink.h"
#include "ServerApp.h"
#include "ServerCursor.h"
#include "ServerProtocol.h"
#include "ServerWindow.h"
#include "DefaultDecorator.h"
#include "RGBColor.h"
#include "BitmapManager.h"
#include "CursorManager.h"
// Globals
@ -85,6 +88,23 @@ AppServer::AppServer(void)
// Set up the Desktop
InitDesktop();
// Create the cursor manager. Object declared in CursorManager.cpp
cursormanager=new CursorManager();
// Default cursor data stored in CursorData.cpp
// TODO: fix the cursor display
// extern int8 default_cursor_data[];
// ServerCursor *sc=new ServerCursor(default_cursor_data);
extern int8 cross_cursor[];
ServerCursor *sc=new ServerCursor(cross_cursor);
cursormanager->AddCursor(sc);
cursormanager->ChangeCursor(B_CURSOR_DEFAULT, sc->ID());
cursormanager->SetCursor(B_CURSOR_DEFAULT);
// Create the bitmap allocator. Object declared in BitmapManager.cpp
bitmapmanager=new BitmapManager();
// This is necessary to mediate access between the Poller and app_server threads
_active_lock=create_sem(1,"app_server_active_sem");
@ -134,6 +154,9 @@ AppServer::~AppServer(void)
delete _applist;
release_sem(_applist_lock);
delete bitmapmanager;
delete cursormanager;
ShutdownDesktop();
// If these threads are still running, kill them - after this, if exit_poller

View File

@ -13,6 +13,8 @@ class Layer;
class BMessage;
class ServerApp;
class DisplayDriver;
class CursorManager;
class BitmapManager;
/*!
\class AppServer AppServer.h
@ -61,4 +63,8 @@ private:
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
int32 wflags, DisplayDriver *ddriver);
extern CursorManager *cursormanager;
extern BitmapManager *bitmapmanager;
#endif

View File

@ -28,6 +28,9 @@
#include "ServerBitmap.h"
#include <stdio.h>
//! The bitmap allocator for the server. Memory is allocated/freed by the AppServer class
BitmapManager *bitmapmanager=NULL;
//! BGET function calls - defined here because of C++ name mangling causing link problems
typedef long bufsize;
extern "C" void bpool(void *buffer, bufsize len);

View File

@ -59,4 +59,6 @@ protected:
sem_id lock;
};
extern BitmapManager *bitmapmanager;
#endif

View File

@ -0,0 +1,73 @@
#include <SupportDefs.h>
/*
The first four bytes of cursor data give information about the cursor:
Byte 1: Size in pixels-per-side. Cursors are always square; currently, only 16-by-16
cursors are allowed.
Byte 2: Color depth in bits-per-pixel. Currently, only one-bit monochrome is allowed.
Bytes 3&4: Hot spot coordinates. Given in "cursor coordinates" where (0,0) is the upper
left corner of the cursor grid, byte 3 is the hot spot's y coordinate, and byte 4 is its x
coordinate. The hot spot is a single pixel that's "activated" when the user clicks the mouse.
To push a button, for example, the hot spot must be within the button's bounds.
Next comes an array of pixel color data. Pixels are specified from left to right in rows starting at
the top of the image and working downward. The size of an array element is the depth of the
image. In one-bit depth...
the 16x16 array fits in 32 bytes.
1 is black and 0 is white.
Then comes the pixel transparency bitmask, given left-to-right and top-to-bottom. 1 is opaque, 0 is
transparent. Transparency only applies to white pixelsblack pixels are always opaque.
*/
// Impressive ASCII art, eh?
int8 default_cursor_data[] = {
16,1,0,0,
255,224, // ***********-----
128,16, // *----------*----
128,16, // *----------*----
128,96, // *--------**-----
128,16, // *----------*----
128,8, // *-----------*---
128,8, // *-----------*---
128,16, // *----------*----
128,32, // *---------*-----
144,64, // *--*-----*------
144,128, // *--*----*-------
105,0, // -**-*--*--------
0,6, // -----**---------
0,0, // ----------------
0,0, // ----------------
0,0, // ----------------
// default_cursor mask - black pixels are always opaque
0,0,
255,224,
255,224,
255,128,
255,224,
255,240,
255,240,
255,224,
255,128,
255,0,
255,0,
255,0,
0,0,
0,0,
0,0,
0,0
};
// known good cursor data for testing rest of system
int8 cross_cursor[] = {16,1,5,5,
14,0,4,0,4,0,4,0,128,32,241,224,128,32,4,0,
4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0,
14,0,4,0,4,0,4,0,128,32,245,224,128,32,4,0,
4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0
};

View File

@ -10,6 +10,7 @@ Server app_server :
areafunc.c
Angle.cpp
bget.c
CursorData.cpp
TokenHandler.cpp
PatternHandler.cpp

View File

@ -413,11 +413,11 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
// otherwise be easy to crash the server by calling SetCursor a
// sufficient number of times
if(_appcursor)
cursormanager->DeleteCursor(_appcursor->_token);
cursormanager->DeleteCursor(_appcursor->ID());
_appcursor=new ServerCursor(cdata);
cursormanager->AddCursor(_appcursor);
cursormanager->SetCursor(_appcursor->_token);
cursormanager->SetCursor(_appcursor->ID());
break;
}
case SET_CURSOR_BCURSOR:

View File

@ -54,8 +54,10 @@ public:
BPoint GetHotSpot(void);
void SetHotSpot(BPoint pt);
const char *GetAppSignature(void) { return _app_signature; }
//! Returns the cursor's ID
int32 ID(void) { return _token; }
private:
friend ServerApp;
friend CursorManager;
BPoint _hotspot;