server loads (but not utilizes) decorators now

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3957 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-07-11 22:30:55 +00:00
parent 36535a1728
commit 44df48e0a1
3 changed files with 50 additions and 10 deletions
+48 -8
View File
@@ -27,12 +27,15 @@
#include <AppDefs.h>
#include <PortMessage.h>
#include <Entry.h>
#include <Directory.h>
#include <PortMessage.h>
#include <PortLink.h>
#include <File.h>
#include <Message.h>
#include "AppServer.h"
#include "ColorSet.h"
#include "Desktop.h"
#include "DisplayDriver.h"
#include "PortLink.h"
#include "ServerApp.h"
#include "ServerCursor.h"
#include "ServerProtocol.h"
@@ -75,6 +78,7 @@ AppServer::AppServer(void)
_quitting_server=false;
_exit_poller=false;
_ssindex=1;
make_decorator=NULL;
// Create the font server and scan the proper directories.
fontserver=new FontServer;
@@ -103,7 +107,9 @@ AppServer::AppServer(void)
// is not possible, set colors to the defaults
if(!LoadGUIColors(&gui_colorset))
SetDefaultGUIColors(&gui_colorset);
InitDecorators();
// Set up the Desktop
InitDesktop();
@@ -147,8 +153,6 @@ AppServer::AppServer(void)
_active_app=-1;
_p_active_app=NULL;
make_decorator=NULL;
}
/*!
@@ -384,13 +388,13 @@ bool AppServer::LoadDecorator(const char *path)
// Loads a window decorator based on the supplied path and forces a decorator update.
// If it cannot load the specified decorator, it will retain the current one and
// return false.
create_decorator *pcreatefunc=NULL;
get_version *pversionfunc=NULL;
status_t stat;
image_id addon;
addon=load_add_on(path);
if(addon<0)
return false;
// As of now, we do nothing with decorator versions, but the possibility exists
// that the API will change even though I cannot forsee any reason to do so. If
@@ -398,12 +402,13 @@ bool AppServer::LoadDecorator(const char *path)
// go here.
// Get the instantiation function
stat=get_image_symbol(addon, "instantiate_decorator", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc);
stat=get_image_symbol(addon, "instantiate_decorator", B_SYMBOL_TYPE_TEXT, (void**)&pcreatefunc);
if(stat!=B_OK)
{
unload_add_on(addon);
return false;
}
acquire_sem(_decor_lock);
make_decorator=pcreatefunc;
_decorator_id=addon;
@@ -411,6 +416,40 @@ bool AppServer::LoadDecorator(const char *path)
return true;
}
//! Loads decorator settings on disk or the default if settings are invalid
void AppServer::InitDecorators(void)
{
BMessage settings;
BDirectory dir,newdir;
if(dir.SetTo(SERVER_SETTINGS_DIR)==B_ENTRY_NOT_FOUND)
create_directory(SERVER_SETTINGS_DIR,0777);
BString path(SERVER_SETTINGS_DIR);
path+="DecoratorSettings";
BFile file(path.String(),B_READ_ONLY);
if(file.InitCheck()==B_OK)
{
if(settings.Unflatten(&file)==B_OK)
{
BString itemtext;
if(settings.FindString("decorator",&itemtext)==B_OK)
{
path.SetTo(DECORATORS_DIR);
path+=itemtext;
if(LoadDecorator(path.String()))
return;
}
}
}
// We got this far, so something must have gone wrong. We set make_decorator
// to NULL so that the decorator allocation routine knows to utilize the included
// default decorator instead of an addon.
make_decorator=NULL;
}
/*!
\brief Message handling function for all messages sent to the app_server
\param code ID of the message sent
@@ -942,7 +981,8 @@ ServerApp *AppServer::FindApp(const char *sig)
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
int32 wflags, DisplayDriver *ddriver)
{
Decorator *dec;
debugger("");
Decorator *dec=NULL;
if(!app_server->make_decorator)
dec=new DefaultDecorator(rect,wlook,wfeel,wflags);
else
+1
View File
@@ -39,6 +39,7 @@ public:
thread_id Run(void);
void MainLoop(void);
bool LoadDecorator(const char *path);
void InitDecorators(void);
void DispatchMessage(int32 code, int8 *buffer);
void Broadcast(int32 code);
void HandleKeyMessage(int32 code, int8 *buffer);
+1 -2
View File
@@ -1183,9 +1183,8 @@ int32 ServerWindow::MonitorWin(void *data)
PortMessage msg;
int32 msgstat;
int32 msgcode;
int8 *msgbuffer=NULL;
ssize_t buffersize,bytesread;
ssize_t buffersize;
for(;;)
{