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:
@@ -27,12 +27,15 @@
|
|||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <PortMessage.h>
|
#include <PortMessage.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <Directory.h>
|
||||||
#include <PortMessage.h>
|
#include <PortMessage.h>
|
||||||
|
#include <PortLink.h>
|
||||||
|
#include <File.h>
|
||||||
|
#include <Message.h>
|
||||||
#include "AppServer.h"
|
#include "AppServer.h"
|
||||||
#include "ColorSet.h"
|
#include "ColorSet.h"
|
||||||
#include "Desktop.h"
|
#include "Desktop.h"
|
||||||
#include "DisplayDriver.h"
|
#include "DisplayDriver.h"
|
||||||
#include "PortLink.h"
|
|
||||||
#include "ServerApp.h"
|
#include "ServerApp.h"
|
||||||
#include "ServerCursor.h"
|
#include "ServerCursor.h"
|
||||||
#include "ServerProtocol.h"
|
#include "ServerProtocol.h"
|
||||||
@@ -75,6 +78,7 @@ AppServer::AppServer(void)
|
|||||||
_quitting_server=false;
|
_quitting_server=false;
|
||||||
_exit_poller=false;
|
_exit_poller=false;
|
||||||
_ssindex=1;
|
_ssindex=1;
|
||||||
|
make_decorator=NULL;
|
||||||
|
|
||||||
// Create the font server and scan the proper directories.
|
// Create the font server and scan the proper directories.
|
||||||
fontserver=new FontServer;
|
fontserver=new FontServer;
|
||||||
@@ -103,7 +107,9 @@ AppServer::AppServer(void)
|
|||||||
// is not possible, set colors to the defaults
|
// is not possible, set colors to the defaults
|
||||||
if(!LoadGUIColors(&gui_colorset))
|
if(!LoadGUIColors(&gui_colorset))
|
||||||
SetDefaultGUIColors(&gui_colorset);
|
SetDefaultGUIColors(&gui_colorset);
|
||||||
|
|
||||||
|
InitDecorators();
|
||||||
|
|
||||||
// Set up the Desktop
|
// Set up the Desktop
|
||||||
InitDesktop();
|
InitDesktop();
|
||||||
|
|
||||||
@@ -147,8 +153,6 @@ AppServer::AppServer(void)
|
|||||||
|
|
||||||
_active_app=-1;
|
_active_app=-1;
|
||||||
_p_active_app=NULL;
|
_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.
|
// 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
|
// If it cannot load the specified decorator, it will retain the current one and
|
||||||
// return false.
|
// return false.
|
||||||
|
|
||||||
create_decorator *pcreatefunc=NULL;
|
create_decorator *pcreatefunc=NULL;
|
||||||
get_version *pversionfunc=NULL;
|
|
||||||
status_t stat;
|
status_t stat;
|
||||||
image_id addon;
|
image_id addon;
|
||||||
|
|
||||||
addon=load_add_on(path);
|
addon=load_add_on(path);
|
||||||
|
if(addon<0)
|
||||||
|
return false;
|
||||||
|
|
||||||
// As of now, we do nothing with decorator versions, but the possibility exists
|
// 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
|
// 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.
|
// go here.
|
||||||
|
|
||||||
// Get the instantiation function
|
// 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)
|
if(stat!=B_OK)
|
||||||
{
|
{
|
||||||
unload_add_on(addon);
|
unload_add_on(addon);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
acquire_sem(_decor_lock);
|
acquire_sem(_decor_lock);
|
||||||
make_decorator=pcreatefunc;
|
make_decorator=pcreatefunc;
|
||||||
_decorator_id=addon;
|
_decorator_id=addon;
|
||||||
@@ -411,6 +416,40 @@ bool AppServer::LoadDecorator(const char *path)
|
|||||||
return true;
|
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
|
\brief Message handling function for all messages sent to the app_server
|
||||||
\param code ID of the message sent
|
\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,
|
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||||
int32 wflags, DisplayDriver *ddriver)
|
int32 wflags, DisplayDriver *ddriver)
|
||||||
{
|
{
|
||||||
Decorator *dec;
|
debugger("");
|
||||||
|
Decorator *dec=NULL;
|
||||||
if(!app_server->make_decorator)
|
if(!app_server->make_decorator)
|
||||||
dec=new DefaultDecorator(rect,wlook,wfeel,wflags);
|
dec=new DefaultDecorator(rect,wlook,wfeel,wflags);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
thread_id Run(void);
|
thread_id Run(void);
|
||||||
void MainLoop(void);
|
void MainLoop(void);
|
||||||
bool LoadDecorator(const char *path);
|
bool LoadDecorator(const char *path);
|
||||||
|
void InitDecorators(void);
|
||||||
void DispatchMessage(int32 code, int8 *buffer);
|
void DispatchMessage(int32 code, int8 *buffer);
|
||||||
void Broadcast(int32 code);
|
void Broadcast(int32 code);
|
||||||
void HandleKeyMessage(int32 code, int8 *buffer);
|
void HandleKeyMessage(int32 code, int8 *buffer);
|
||||||
|
|||||||
@@ -1183,9 +1183,8 @@ int32 ServerWindow::MonitorWin(void *data)
|
|||||||
PortMessage msg;
|
PortMessage msg;
|
||||||
int32 msgstat;
|
int32 msgstat;
|
||||||
|
|
||||||
int32 msgcode;
|
|
||||||
int8 *msgbuffer=NULL;
|
int8 *msgbuffer=NULL;
|
||||||
ssize_t buffersize,bytesread;
|
ssize_t buffersize;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user