Implemented new_decorator()

Documented most Desktop functions and implemented some of them


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2705 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-02-14 11:04:01 +00:00
parent 843571810d
commit 3469d49d54
3 changed files with 237 additions and 11 deletions
+11 -3
View File
@@ -33,6 +33,9 @@
#include "ServerConfig.h"
#include "ServerProtocol.h"
#include "ServerWindow.h"
#include "DefaultDecorator.h"
AppServer *app_server=NULL;
/*!
\brief Constructor
@@ -99,7 +102,7 @@ AppServer::AppServer(void)
_active_app=-1;
_p_active_app=NULL;
make_decorator=NULL;
make_decorator=NULL;
}
/*!
@@ -751,12 +754,17 @@ ServerApp *AppServer::FindApp(const char *sig)
\param wlook Window look type. See Window.h
\param wfeel Window feel type. See Window.h
\param wflags Window flags. See Window.h
If a decorator has not been set, we use the default one packaged in with the app_server
being that we can't do anything with a window without one.
*/
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
int32 wflags, DisplayDriver *ddriver)
{
if(!app_server->make_decorator)
return new DefaultDecorator(rect,wlook,wfeel,wflags);
return NULL;
return app_server->make_decorator(rect,wlook,wfeel,wflags);
}
/*!
@@ -771,7 +779,7 @@ int main( int argc, char** argv )
if(find_port(SERVER_PORT_NAME)!=B_NAME_NOT_FOUND)
return -1;
AppServer *app_server = new AppServer();
app_server=new AppServer();
app_server->Run();
delete app_server;
return 0;
+224 -6
View File
@@ -26,6 +26,7 @@
//------------------------------------------------------------------------------
#include "DisplayDriver.h"
#include "Desktop.h"
#include "DesktopClasses.h"
#include "ViewDriver.h"
@@ -41,19 +42,26 @@
//! This namespace encapsulates all globals specifically for the desktop
namespace desktop_private {
int8 *dragmessage;
int32 dragmessagesize;
int8 *dragmessage=NULL;
int32 dragmessagesize=0;
BLocker draglock,
layerlock,
workspacelock;
BList *screenlist;
BList *desktop_private::screenlist=NULL;
Screen *activescreen=NULL;
}
//! locks layer access
void lock_layers(void) { desktop_private::layerlock.Lock(); }
//! unlocks layer access
void unlock_layers(void) { desktop_private::layerlock.Unlock(); }
//! locks access to drag and drop data
void lock_dragdata(void) { desktop_private::draglock.Lock(); }
//! unlocks access to drag and drop data
void unlock_dragdata(void) { desktop_private::draglock.Unlock(); }
//! locks access to the workspace list
void lock_workspaces(void) { desktop_private::workspacelock.Lock(); }
//! unlocks access to the workspace list
void unlock_workspaces(void) { desktop_private::workspacelock.Unlock(); }
/*!
@@ -64,58 +72,239 @@ void unlock_workspaces(void) { desktop_private::workspacelock.Unlock(); }
*/
void InitDesktop(void)
{
desktop_private::screenlist=new BList(0);
DisplayDriver *tdriver;
Screen *s=NULL;
#if DISPLAYDRIVER == HWDRIVER
// If we're using the AccelerantDriver for rendering, eventually we will loop through
// drivers until one can't initialize in order to support multiple monitors. For now,
// we'll just load one and be done with it.
tdriver=new AccelerantDriver;
if(tdriver->Initialize())
{
// TODO: figure out how to load the workspace data and do it here.
// For now, we'll just use 3 workspaces.
s=new Screen(tdriver,3);
desktop_private::screenlist->AddItem(s);
}
else
{
// Uh-oh. We don't have a video card. This would be a *bad* thing. Seeing how
// we can't see anything, we can't do anything, either. It's time to crash now. ;)
tdriver->Shutdown();
delete tdriver;
tdriver=NULL;
}
#endif
#if DISPLAYDRIVER == SCREENDRIVER
tdriver=new ScreenDriver;
#else
tdriver=new ViewDriver;
#endif
if(tdriver->Initialize())
{
// TODO: figure out how to load the workspace data and do it here.
// For now, we'll just use 3 workspaces.
Screen *s=new Screen(tdriver,3);
desktop_private::screenlist->AddItem(s);
}
else
{
// Uh-oh. We don't have a video card. This would be a *bad* thing. Seeing how
// we can't see anything, we can't do anything, either. It's time to crash now. ;)
tdriver->Shutdown();
delete tdriver;
tdriver=NULL;
}
// Once we utilize multiple monitors, we'll make Screen 0 the active one.
if(tdriver)
{
s->Activate();
desktop_private::activescreen=s;
}
}
//! Shuts down the graphics subsystem
void ShutdownDesktop(void)
{
Screen *s;
for(int32 i=0;i<desktop_private::screenlist->CountItems();i++)
{
s=(Screen*)desktop_private::screenlist->ItemAt(i);
if(s)
delete s;
}
if(!desktop_private::dragmessage)
{
delete desktop_private::dragmessage;
desktop_private::dragmessage=NULL;
desktop_private::dragmessagesize=0;
}
}
/*!
\brief Add a workspace to the desktop
\param index Place in the workspace list to add the new one.
The default location to add a workspace is at the end of the list. If index
is less than 0 or greater than the current workspace count, AddWorkspace will place
the workspace at the list's end. Note that it is possible to insert a workspace
in the list simply by specifying an index.
*/
void AddWorkspace(int32 index=-1)
{
lock_workspaces();
lock_layers();
Screen *s;
for(int32 i=0;i<desktop_private::screenlist->CountItems();i++)
{
s=(Screen*)desktop_private::screenlist->ItemAt(i);
if(s)
s->AddWorkspace(index);
}
unlock_layers();
unlock_workspaces();
}
/*!
\brief Deletes a workspace
\param index The index to delete
If the workspace specified by index does not refer to a valid workspace, this function
will fail. Should the workspace to be deleted be the active one, the previous
workspace in the list will be chosen or workspace 0 if workspace 0 is being deleted.
This function will fail if there is only 1 workspace used.
*/
void DeleteWorkspace(int32 index)
{
lock_workspaces();
lock_layers();
Screen *s;
for(int32 i=0;i<desktop_private::screenlist->CountItems();i++)
{
s=(Screen*)desktop_private::screenlist->ItemAt(i);
if(s)
s->DeleteWorkspace(index);
}
unlock_layers();
unlock_workspaces();
}
/*!
\brief Returns the number of workspaces available
\return the number of workspaces available
*/
int32 CountWorkspaces(void)
{
return 0;
lock_workspaces();
lock_layers();
int32 count=desktop_private::activescreen->CountWorkspaces();
unlock_layers();
unlock_workspaces();
return count;
}
/*!
\brief Sets the number of workspaces available
\param count The new number of available workspaces
This function will fail if count is less than 1 or greater than 32. The limit of 32 was
set by BeOS. Making the limit higher will cause unreachable workspaces because of the
API interface used to access them. Were this to change, the only limiting factor for
workspace count would be the hardware itself.
*/
void SetWorkspaceCount(int32 count)
{
}
int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID)
/*!
\brief Returns the index of the active workspace
\return the index of the active workspace
*/
int32 CurrentWorkspace(void)
{
return 0;
}
void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID)
/*!
\brief Sets the active workspace
\param workspace Index of the workspace to activate
This function will do nothing if passed an index which does not refer to a valid
workspace.
*/
void SetWorkspace(int32 workspace)
{
}
/*!
\brief Sets the active screen. Currently unused.
\param id ID of the screen to activate.
*/
void SetScreen(screen_id id)
{
}
/*!
\brief Returns the number of screens available. Currently unused.
\return the number of screens available.
*/
int32 CountScreens(void)
{
return 0;
}
/*!
\brief Returns the index of the active screen. Currently unused.
\return the index of the active screen
*/
screen_id ActiveScreen(void)
{
return B_MAIN_SCREEN_ID;
}
/*!
\brief Obtains the DisplayDriver object used for the specified screen.
\param screen ID of the screen to get the DisplayDriver for.
\return The DisplayDriver or NULL if not available for that screen ID
Like the other multiscreen functions, this is unused. Because multiple screens are
not utilized, specifying an ID other than B_MAIN_SCREEN_ID will return NULL
*/
DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)
{
return NULL;
}
/*!
\brief Sets the video parameters of the specified workspace
\param index The workspace to change
\param res Resolution constant from GraphicsDefs.h
\param stick If false, resolution will revert to its old value on next boot
\param screen ID of the screen to change
\return B_OK if successful, B_ERROR if not.
Because of the lack of outside multimonitor support, the screen ID is ignored for now.
*/
status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)
{
return B_ERROR;
@@ -138,20 +327,49 @@ void SetActiveWindow(ServerWindow *win)
{
}
/*!
\brief Returns the root layer for the specified workspace
\param workspace Index of the workspace to use
\param screen Index of the screen to use
\return The root layer or NULL if there was an invalid parameter.
*/
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
{
return NULL;
}
/*!
\brief Assigns a flattened BMessage to the global drag data.
\param size Size of the data buffer
\param flattened Flattened BMessage data buffer
This assigns a BMessage in its flattened state to the internal storage. Only
one message can be stored at a time. Once an assignment is made, another cannot
be made until the current one is emptied. If additional calls are made while
there is a drag message assigned, the function will fail and the new assignment
will not be made. Note that this merely passes a pointer around. No copies are
made and the caller is responsible for freeing any allocated objects from the heap.
*/
void set_drag_message(int32 size, int8 *flattened)
{
}
/*!
\brief Gets the current drag data
\param size Receives the size of the drag data buffer
\return the drag data buffer or NULL if size is NULL
Retrieve the current drag message in use. This function will fail if a NULL pointer
is passed to it. Note that this does not free the current drag message from use.
The size of the flattened message is stored in the size parameter. Also, note that if
there is no message in use, it will return NULL and set size to 0.
*/
int8 *get_drag_message(int32 *size)
{
return NULL;
}
//! Empties current drag data and allows for new data to be assigned
void empty_drag_message(void)
{
}
+2 -2
View File
@@ -41,8 +41,8 @@ void AddWorkspace(int32 index=-1);
void DeleteWorkspace(int32 index);
int32 CountWorkspaces(void);
void SetWorkspaceCount(int32 count);
int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID);
void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID);
int32 CurrentWorkspace(void);
void SetWorkspace(int32 workspace);
void SetScreen(screen_id id);
int32 CountScreens(void);