Some cleanup, some removed typos, some unification, some fixes and some added todos. Most of it related to client-server communication. Apps that rely on BFont stuff should work now (StyledEdit, Fonts, Keymap, Menu, ...). Or should not hang/quit at startup at least.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13625 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2005-07-10 21:16:43 +00:00
parent 1de84caa7d
commit 3f319b3346
13 changed files with 267 additions and 291 deletions

View File

@ -8,7 +8,6 @@
#ifndef BITMAP_MANAGER_H_
#define BITMAP_MANAGER_H_
#include <GraphicsDefs.h>
#include <List.h>
#include <OS.h>
@ -32,22 +31,23 @@ class ServerBitmap;
by the BitmapManager lock.
*/
class BitmapManager {
public:
BitmapManager();
virtual ~BitmapManager();
public:
BitmapManager();
virtual ~BitmapManager();
ServerBitmap* CreateBitmap(BRect bounds,
color_space space,
int32 flags,
int32 bytesPerRow = -1,
screen_id screen = B_MAIN_SCREEN_ID);
void DeleteBitmap(ServerBitmap* bitmap);
protected:
BList fBitmapList;
int8* fBuffer;
TokenHandler fTokenizer;
BLocker fLock;
AreaPool fMemPool;
ServerBitmap *CreateBitmap( BRect bounds,
color_space space,
int32 flags,
int32 bytesPerRow = -1,
screen_id screen = B_MAIN_SCREEN_ID);
void DeleteBitmap(ServerBitmap* bitmap);
protected:
BList fBitmapList;
int8 *fBuffer;
TokenHandler fTokenizer;
BLocker fLock;
AreaPool fMemPool;
};
extern BitmapManager *gBitmapManager;

View File

@ -37,69 +37,65 @@
\class ColorSet ColorSet.h
\brief Encapsulates GUI system colors
*/
class ColorSet : public BLocker
{
class ColorSet : public BLocker {
public:
ColorSet(void);
ColorSet(const ColorSet &cs);
ColorSet & operator=(const ColorSet &cs);
void SetColors(const ColorSet &cs);
void PrintToStream(void) const;
bool ConvertToMessage(BMessage *msg) const;
bool ConvertFromMessage(const BMessage *msg);
void SetToDefaults(void);
rgb_color StringToColor(const char *string);
rgb_color AttributeToColor(int32 which);
status_t SetColor(const char *string, rgb_color value);
rgb_color panel_background,
panel_text,
document_background,
document_text,
control_background,
control_text,
control_highlight,
control_border,
tooltip_background,
tooltip_text,
menu_background,
menu_selected_background,
menu_text,
menu_selected_text,
menu_selected_border,
keyboard_navigation_base,
keyboard_navigation_pulse,
success,
failure,
shine,
shadow,
window_tab,
// Not all of these guys don't exist in InterfaceDefs.h,
// but we keep them as part of the color set anyway -
// they're important nonetheless
window_tab_text,
inactive_window_tab,
inactive_window_tab_text;
private:
rgb_color * StringToMember(const char *string);
void PrintMember(const rgb_color &color) const;
};
ColorSet();
ColorSet(const ColorSet &cs);
ColorSet & operator=(const ColorSet &cs);
void SetColors(const ColorSet &cs);
void PrintToStream(void) const;
bool ConvertToMessage(BMessage *msg) const;
bool ConvertFromMessage(const BMessage *msg);
void SetToDefaults(void);
rgb_color StringToColor(const char *string);
rgb_color AttributeToColor(int32 which);
status_t SetColor(const char *string, rgb_color value);
rgb_color panel_background,
panel_text,
document_background,
document_text,
control_background,
control_text,
control_highlight,
control_border,
tooltip_background,
tooltip_text,
menu_background,
menu_selected_background,
menu_text,
menu_selected_text,
menu_selected_border,
keyboard_navigation_base,
keyboard_navigation_pulse,
success,
failure,
shine,
shadow,
window_tab,
// Not all of these guys do exist in InterfaceDefs.h,
// but we keep them as part of the color set anyway -
// they're important nonetheless
window_tab_text,
inactive_window_tab,
inactive_window_tab_text;
private:
rgb_color *StringToMember(const char *string);
void PrintMember(const rgb_color &color) const;
};
status_t LoadColorSet(const char *path, ColorSet *set);
status_t SaveColorSet(const char *path, const ColorSet &set);

View File

@ -174,7 +174,7 @@ count_font_styles(font_family name)
link.StartMessage(AS_COUNT_FONT_STYLES);
if (link.FlushWithReply(code) != B_OK
&& code != SERVER_TRUE)
|| code != SERVER_TRUE)
return -1;
link.Read<int32>(&count);
@ -186,7 +186,7 @@ count_font_styles(font_family name)
\brief Retrieves the family name at the specified index
\param index Unique font identifier code.
\param name font_family string to receive the name of the family
\param flags iF non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned
\param flags if non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned
\return B_ERROR if the index does not correspond to a font family
*/
@ -209,8 +209,10 @@ get_font_family(int32 index, font_family *name, uint32 *flags)
link.Read<font_family>(name);
uint32 value;
link.Read<uint32>(&value);
if (flags)
link.Read<uint32>(flags);
*flags = value;
return B_OK;
}
@ -220,7 +222,7 @@ get_font_family(int32 index, font_family *name, uint32 *flags)
\brief Retrieves the family name at the specified index
\param index Unique font identifier code.
\param name font_family string to receive the name of the family
\param flags iF non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned
\param flags if non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned
\return B_ERROR if the index does not correspond to a font style
*/
@ -235,19 +237,24 @@ get_font_style(font_family family, int32 index, font_style *name,
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_STYLE_NAME);
link.Attach(family,sizeof(font_family));
link.Attach(family, sizeof(font_family));
link.Attach<int32>(index);
if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
return B_ERROR;
link.Read<font_style>(name);
if (flags) {
uint16 face;
link.Read<uint16>(&face);
link.Read<uint32>(flags);
}
font_style style;
link.Read<font_style>(&style);
if (name)
strcpy(*name, style);
uint32 value;
link.Read<uint32>(&value); // face - unused
link.Read<uint32>(&value); // flags
if (flags)
*flags = value;
return B_OK;
}

View File

@ -939,7 +939,7 @@ get_system_colors(ColorSet *colors)
link.StartMessage(AS_GET_UI_COLORS);
int32 code;
if (link.FlushWithReply(code) == B_OK)
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<ColorSet>(colors);
}

View File

@ -218,7 +218,7 @@ BPrivateScreen::DesktopColor(uint32 workspace)
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_DESKTOP_COLOR);
link.Attach<int32>(workspace);
link.Attach<uint32>(workspace);
int32 code;
if (link.FlushWithReply(code) == B_OK

View File

@ -2061,7 +2061,7 @@ BWindow::InitData(BRect frame, const char* title, window_look look,
locked = true;
}
// let app_server to know that a window has been created.
// let app_server know that a window has been created.
fLink = new BPrivate::PortLink(
BApplication::Private::ServerLink()->SenderPort(), receivePort);
@ -2073,8 +2073,8 @@ BWindow::InitData(BRect frame, const char* title, window_look look,
}
fLink->Attach<BRect>(fFrame);
fLink->Attach<int32>((int32)fLook);
fLink->Attach<int32>((int32)fFeel);
fLink->Attach<uint32>((uint32)fLook);
fLink->Attach<uint32>((uint32)fFeel);
fLink->Attach<uint32>(fFlags);
fLink->Attach<uint32>(workspace);
fLink->Attach<int32>(_get_object_token_(this));

View File

@ -49,7 +49,7 @@ Angle::Angle(float angle)
}
//! Constructor
Angle::Angle(void)
Angle::Angle()
{
fAngleValue=0;
if(tables_initialized==false)
@ -60,7 +60,7 @@ Angle::Angle(void)
}
//! Empty destructor
Angle::~Angle(void)
Angle::~Angle()
{
}
@ -116,7 +116,7 @@ Angle Angle::InvSine(float value)
// current sintable[i] is less than value. Pick the degree value which is closer
// to the passed value
if( (value - sintable[i]) > (sintable[i+1] - value) )
return (i+1);
return Angle(i+1);
return Angle(i); // value is closer to previous
}
@ -155,7 +155,7 @@ Angle Angle::InvCosine(float value)
// current costable[i] is less than value. Pick the degree value which is closer
// to the passed value
if( (value - costable[i]) < (costable[i+1] - value) )
return (i+1);
return Angle(i+1);
return Angle(i); // value is closer to previous
}
@ -196,7 +196,7 @@ Angle Angle::InvTangent(float value)
i--;
if( (value - tantable[i]) < (tantable[i+1] - value) )
return (i+1);
return Angle(i+1);
return Angle(i); // value is closer to previous
}

View File

@ -33,44 +33,45 @@
\class Angle Angle.h
\brief Class for speeding up trig functions. Works in degrees only.
*/
class Angle
{
class Angle {
public:
Angle(float angle);
Angle(void);
virtual ~Angle(void);
Angle(float angle);
Angle();
virtual ~Angle();
void Normalize(void);
void Normalize();
float Sine(void);
Angle InvSine(float value);
float Sine(void);
Angle InvSine(float value);
float Cosine(void);
Angle InvCosine(float value);
float Cosine(void);
Angle InvCosine(float value);
float Tangent(int *status=NULL);
Angle InvTangent(float value);
uint8 Quadrant(void);
Angle Constrain180(void);
Angle Constrain90(void);
void SetValue(float angle);
float Value(void) const;
Angle &operator=(const Angle &from);
Angle &operator=(const float &from);
Angle &operator=(const long &from);
Angle &operator=(const int &from);
bool operator==(const Angle &from);
bool operator!=(const Angle &from);
bool operator<(const Angle &from);
bool operator>(const Angle &from);
bool operator>=(const Angle &from);
bool operator<=(const Angle &from);
float Tangent(int *status=NULL);
Angle InvTangent(float value);
uint8 Quadrant(void);
Angle Constrain180(void);
Angle Constrain90(void);
void SetValue(float angle);
float Value(void) const;
Angle &operator=(const Angle &from);
Angle &operator=(const float &from);
Angle &operator=(const long &from);
Angle &operator=(const int &from);
bool operator==(const Angle &from);
bool operator!=(const Angle &from);
bool operator<(const Angle &from);
bool operator>(const Angle &from);
bool operator>=(const Angle &from);
bool operator<=(const Angle &from);
protected:
float fAngleValue;
void InitTrigTables(void);
float fAngleValue;
void InitTrigTables(void);
};
#endif

View File

@ -81,9 +81,9 @@ ColorSet gGUIColorSet;
threads, loads user preferences for the UI and decorator, and allocates various locks.
*/
#if TEST_MODE
AppServer::AppServer(void) : BApplication (SERVER_SIGNATURE),
AppServer::AppServer() : BApplication (SERVER_SIGNATURE),
#else
AppServer::AppServer(void) :
AppServer::AppServer() :
#endif
fAppListLock("application list"),
fCursorSem(-1),
@ -419,7 +419,7 @@ AppServer::DispatchMessage(int32 code, BPrivate::PortLink &msg)
// Attached data:
// 1) port_id - receiver port of a regular app
// 2) port_id - client looper port - for send messages to the client
// 2) port_id - client looper port - for sending messages to the client
// 2) team_id - app's team ID
// 3) int32 - handler token of the regular app
// 4) char * - signature of the regular app

View File

@ -4,6 +4,7 @@
*
* Author: DarkWyrm <bpmagic@columbus.rr.com>
*/
#ifndef _HAIKU_APP_SERVER_H_
#define _HAIKU_APP_SERVER_H_
@ -16,13 +17,8 @@
#include "ServerConfig.h"
class Layer;
class BMessage;
class ServerApp;
class DisplayDriver;
class CursorManager;
class BitmapManager;
class DecorManager;
class ColorSet;
namespace BPrivate {
@ -44,48 +40,46 @@ class AppServer
#endif
{
public:
AppServer(void);
~AppServer(void);
AppServer();
~AppServer();
static int32 PollerThread(void *data);
static int32 PicassoThread(void *data);
thread_id Run(void);
void MainLoop(void);
static int32 PollerThread(void *data);
static int32 PicassoThread(void *data);
thread_id Run(void);
void MainLoop(void);
void PostMessage(int32 code);
void DispatchMessage(int32 code, BPrivate::PortLink &link);
ServerApp* FindApp(const char *sig);
void PostMessage(int32 code);
void DispatchMessage(int32 code, BPrivate::PortLink &link);
ServerApp* FindApp(const char *sig);
private:
friend void BroadcastToAllApps(const int32 &code);
void LaunchCursorThread();
void LaunchInputServer();
static int32 CursorThread(void *data);
friend void BroadcastToAllApps(const int32 &code);
port_id fMessagePort;
port_id fServerInputPort;
void LaunchCursorThread();
void LaunchInputServer();
static int32 CursorThread(void *data);
volatile bool fQuitting;
port_id fMessagePort;
port_id fServerInputPort;
BLocker fAppListLock;
BList fAppList;
volatile bool fQuitting;
thread_id fPicassoThreadID;
BLocker fAppListLock;
BList fAppList;
thread_id fISThreadID;
thread_id fCursorThreadID;
sem_id fCursorSem;
area_id fCursorArea;
uint32 *fCursorAddr;
thread_id fPicassoThreadID;
port_id fISASPort;
port_id fISPort;
thread_id fISThreadID;
thread_id fCursorThreadID;
sem_id fCursorSem;
area_id fCursorArea;
uint32 *fCursorAddr;
sem_id fShutdownSemaphore;
int32 fShutdownCount;
port_id fISASPort;
port_id fISPort;
DisplayDriver *fDriver;
sem_id fShutdownSemaphore;
int32 fShutdownCount;
};
extern BitmapManager *gBitmapManager;

View File

@ -35,10 +35,8 @@
#include "ColorSet.h"
#include "ServerConfig.h"
//! Constructor which does nothing
ColorSet::ColorSet(void)
ColorSet::ColorSet()
{
}
@ -56,7 +54,8 @@ ColorSet::ColorSet(const ColorSet &cs)
\param cs Color set to copy from
\return The new values assigned to the color set
*/
ColorSet & ColorSet::operator=(const ColorSet &cs)
ColorSet &
ColorSet::operator=(const ColorSet &cs)
{
SetColors(cs);
return *this;
@ -67,7 +66,8 @@ ColorSet & ColorSet::operator=(const ColorSet &cs)
and, yes, *IT EVEN MAKES french fries!!*
\param cs Color set to copy from
*/
void ColorSet::SetColors(const ColorSet &cs)
void
ColorSet::SetColors(const ColorSet &cs)
{
panel_background=cs.panel_background;
panel_text=cs.panel_text;
@ -104,7 +104,8 @@ void ColorSet::SetColors(const ColorSet &cs)
}
//! Prints all color set elements to stdout
void ColorSet::PrintToStream(void) const
void
ColorSet::PrintToStream(void) const
{
printf("panel_background "); PrintMember(panel_background);
printf("panel_text "); PrintMember(panel_text);
@ -145,7 +146,8 @@ void ColorSet::PrintToStream(void) const
\brief Assigns the default system colors to the passed ColorSet object
\param set The ColorSet object to set to defaults
*/
void ColorSet::SetToDefaults(void)
void
ColorSet::SetToDefaults(void)
{
#ifdef DEBUG_COLORSET
printf("Initializing color settings to defaults\n");
@ -182,7 +184,8 @@ printf("Initializing color settings to defaults\n");
\brief Attaches the color set's members as data to the given BMessage
\param msg The message to receive the attributes
*/
bool ColorSet::ConvertToMessage(BMessage *msg) const
bool
ColorSet::ConvertToMessage(BMessage *msg) const
{
if(!msg)
return false;
@ -236,7 +239,8 @@ bool ColorSet::ConvertToMessage(BMessage *msg) const
\param msg The message containing the data for the color set's colors
*/
bool ColorSet::ConvertFromMessage(const BMessage *msg)
bool
ColorSet::ConvertFromMessage(const BMessage *msg)
{
if(!msg)
return false;
@ -304,7 +308,8 @@ bool ColorSet::ConvertFromMessage(const BMessage *msg)
\param string name of the color to receive the value
\param value An rgb_color which is the new value of the member
*/
status_t ColorSet::SetColor(const char *string, rgb_color value)
status_t
ColorSet::SetColor(const char *string, rgb_color value)
{
if(!string)
return B_BAD_VALUE;
@ -321,7 +326,8 @@ status_t ColorSet::SetColor(const char *string, rgb_color value)
\param string name of the color to obtain
\return The set's color or (0,0,0,0) if not found
*/
rgb_color ColorSet::StringToColor(const char *string)
rgb_color
ColorSet::StringToColor(const char *string)
{
rgb_color *col=StringToMember(string);
if(!col)
@ -338,7 +344,8 @@ rgb_color ColorSet::StringToColor(const char *string)
\param string name of the color member to obtain
\return An RGBColor pointer or NULL if not found
*/
rgb_color *ColorSet::StringToMember(const char *string)
rgb_color *
ColorSet::StringToMember(const char *string)
{
if(!string)
return NULL;
@ -398,7 +405,8 @@ rgb_color *ColorSet::StringToMember(const char *string)
}
rgb_color ColorSet::AttributeToColor(int32 which)
rgb_color
ColorSet::AttributeToColor(int32 which)
{
switch(which)
{
@ -541,7 +549,8 @@ rgb_color ColorSet::AttributeToColor(int32 which)
}
}
void ColorSet::PrintMember(const rgb_color &color) const
void
ColorSet::PrintMember(const rgb_color &color) const
{
printf("rgb_color(%d, %d, %d, %d)", color.red,color.green,color.blue,color.alpha);
}
@ -551,7 +560,8 @@ void ColorSet::PrintMember(const rgb_color &color) const
\param set the set to receive the system colors
\return B_OK if successful. See BFile for other error codes
*/
status_t LoadColorSet(const char *path, ColorSet *set)
status_t
LoadColorSet(const char *path, ColorSet *set)
{
BFile file(path,B_READ_ONLY);
if(file.InitCheck()!=B_OK)
@ -573,7 +583,8 @@ status_t LoadColorSet(const char *path, ColorSet *set)
\param set ColorSet containing the colors to save
\return B_OK if successful. See BFile for other error codes
*/
status_t SaveColorSet(const char *path, const ColorSet &set)
status_t
SaveColorSet(const char *path, const ColorSet &set)
{
// TODO: Move this check to the app_server
BEntry entry(SERVER_SETTINGS_DIR);
@ -591,4 +602,3 @@ status_t SaveColorSet(const char *path, const ColorSet &set)
msg.Flatten(&file);
return B_OK;
}

View File

@ -420,13 +420,14 @@ ServerApp::_MessageLooper()
// Go ahead and fix if you have an idea for unification...
// Attached data:
// 2) BRect window frame
// 3) uint32 window look
// 4) uint32 window feel
// 5) uint32 window flags
// 6) uint32 workspace index
// 7) int32 BHandler token of the window
// 8) port_id window's message port
// 1) BRect window frame
// 2) uint32 window look
// 3) uint32 window feel
// 4) uint32 window flags
// 5) uint32 workspace index
// 6) int32 BHandler token of the window
// 7) port_id window's reply port
// 8) port_id window's looper port
// 9) const char * title
BRect frame;
@ -488,14 +489,16 @@ ServerApp::_MessageLooper()
// NOTE/TODO: Code duplication in part to above case.
// Attached data:
// 1) int32 bitmap token
// 2) BRect window frame
// 3) uint32 window look
// 4) uint32 window feel
// 5) uint32 window flags
// 6) uint32 workspace index
// 7) int32 BHandler token of the window
// 8) port_id window's message port
// 9) const char * title
// 8) port_id window's reply port
// 9) port_id window's looper port
// 10) const char * title
BRect frame;
int32 bitmapToken;
@ -842,7 +845,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
STRACE(("ServerApp %s: Received BBitmap creation request\n", Signature()));
// Allocate a bitmap for an application
// Attached Data:
// Attached Data:
// 1) BRect bounds
// 2) color_space space
// 3) int32 bitmap_flags
@ -878,7 +881,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
if (bitmap && fBitmapList.AddItem((void*)bitmap)) {
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<int32>(bitmap->Token());
fLink.Attach<int32>(bitmap->Area());
fLink.Attach<area_id>(bitmap->Area());
fLink.Attach<int32>(bitmap->AreaOffset());
} else {
// alternatively, if something went wrong, we reply with SERVER_FALSE
@ -896,7 +899,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// Attached Data:
// 1) int32 token
// 2) int32 reply port
// Reply Code: SERVER_TRUE if successful,
// SERVER_FALSE if the buffer was already deleted or was not found
int32 id;
@ -1013,8 +1016,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_QUERY_CURSOR_HIDDEN:
{
STRACE(("ServerApp %s: Received IsCursorHidden request\n", Signature()));
// Attached data
// 1) int32 port to reply to
fLink.StartMessage(fCursorHidden ? SERVER_TRUE : SERVER_FALSE);
fLink.Flush();
break;
@ -1131,6 +1132,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
scroll_bar_info info;
if (link.Read<scroll_bar_info>(&info) == B_OK)
gDesktop->SetScrollBarInfo(info);
fLink.StartMessage(SERVER_TRUE);
fLink.Flush();
break;
}
case AS_FOCUS_FOLLOWS_MOUSE:
@ -1145,7 +1149,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_SET_FOCUS_FOLLOWS_MOUSE:
{
STRACE(("ServerApp %s: Set Focus Follows Mouse in use\n", Signature()));
// ToDo: implement me!
bool follow;
if (link.Read<bool>(&follow) == B_OK)
gDesktop->UseFFMouse(follow);
break;
}
case AS_SET_MOUSE_MODE:
@ -1172,8 +1178,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{
// Client application is asking for all the system colors at once
// using a ColorSet object
gGUIColorSet.Lock();
fLink.StartMessage(SERVER_TRUE);
@ -1181,7 +1185,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
fLink.Flush();
gGUIColorSet.Unlock();
break;
}
case AS_SET_UI_COLORS:
@ -1191,7 +1194,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// Attached data:
// 1) ColorSet new colors to use
gGUIColorSet.Lock();
link.Read<ColorSet>(&gGUIColorSet);
gGUIColorSet.Unlock();
@ -1239,6 +1241,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// if just checking, just give an answer,
// if not and needs updated,
// sync the font list and return true else return false
// TODO: actually do the above...
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
break;
@ -1259,9 +1262,11 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
FontFamily *ffamily = gFontServer->GetFamily(id);
if (ffamily) {
font_family fam;
strcpy(fam, ffamily->Name());
strncpy(fam, ffamily->Name(), sizeof(font_family) - 1);
fam[sizeof(font_family) - 1] = 0;
fLink.StartMessage(SERVER_TRUE);
fLink.Attach(fam, sizeof(font_family));
fLink.Attach<int32>(ffamily->GetFlags());
fLink.Attach<uint32>(ffamily->GetFlags());
} else
fLink.StartMessage(SERVER_FALSE);
@ -1281,25 +1286,26 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// 2) uint16 - appropriate face values
// 3) uint32 - flags of font style (B_IS_FIXED || B_HAS_TUNED_FONT)
int32 styid;
int32 styleid;
font_family fam;
link.Read(fam,sizeof(font_family));
link.Read<int32>(&styid);
link.Read(fam, sizeof(font_family));
link.Read<int32>(&styleid);
gFontServer->Lock();
FontStyle *fstyle = gFontServer->GetStyle(fam, styid);
FontStyle *fstyle = gFontServer->GetStyle(fam, styleid);
if (fstyle) {
font_family sty;
strcpy(sty, fstyle->Name());
font_style style;
strncpy(style, fstyle->Name(), sizeof(font_style) - 1);
style[sizeof(font_style) - 1] = 0;
fLink.StartMessage(SERVER_TRUE);
fLink.Attach(sty,sizeof(font_style));
fLink.Attach<int32>(fstyle->GetFace());
fLink.Attach<int32>(fstyle->GetFlags());
fLink.Attach(style, sizeof(font_style));
fLink.Attach<uint32>(fstyle->GetFace());
fLink.Attach<uint32>(fstyle->GetFlags());
} else
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
fLink.Flush();
gFontServer->Unlock();
break;
}
@ -1323,8 +1329,10 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
gFontServer->Lock();
FontStyle *fstyle = gFontServer->GetStyle(famid, styid);
if (fstyle) {
strcpy(fam, fstyle->Family()->Name());
strcpy(sty, fstyle->Name());
strncpy(fam, fstyle->Family()->Name(), sizeof(font_family) - 1);
strncpy(sty, fstyle->Name(), sizeof(font_style) - 1);
fam[sizeof(font_family) - 1] = 0;
sty[sizeof(font_style) - 1] = 0;
fLink.StartMessage(SERVER_TRUE);
fLink.Attach(fam, sizeof(font_family));
@ -1350,7 +1358,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// NOTE: While this may be unimplemented, we can safely return
// SERVER_FALSE. This will force the BFont code to default to
// B_LEFT_TO_RIGHT, which is what the vast majority of fonts will be.
// This will be fixed later.
// TODO: This will be fixed later.
int32 famid, styid;
link.Read<int32>(&famid);
link.Read<int32>(&styid);
@ -1642,6 +1650,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
break;
}
case AS_SET_SYSFONT_PLAIN:
case AS_SET_SYSFONT_BOLD:
case AS_SET_SYSFONT_FIXED:
{
FTRACE(("ServerApp %s: AS_SET_SYSFONT_PLAIN\n", Signature()));
// Returns:
@ -1652,7 +1662,14 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// 5) uint32 - font flags
gFontServer->Lock();
ServerFont *sf = gFontServer->GetSystemPlain();
ServerFont *sf = NULL;
switch (code) {
case AS_SET_SYSFONT_PLAIN: sf = gFontServer->GetSystemPlain(); break;
case AS_SET_SYSFONT_BOLD: sf = gFontServer->GetSystemBold(); break;
case AS_SET_SYSFONT_FIXED: sf = gFontServer->GetSystemFixed(); break;
}
if (sf) {
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<uint16>(sf->FamilyID());
@ -1692,58 +1709,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
gFontServer->Unlock();
break;
}
case AS_SET_SYSFONT_BOLD:
{
FTRACE(("ServerApp %s: AS_SET_SYSFONT_BOLD\n", Signature()));
// Returns:
// 1) uint16 - family ID
// 2) uint16 - style ID
// 3) float - size in points
// 4) uint16 - face flags
// 5) uint32 - font flags
gFontServer->Lock();
ServerFont *sf = gFontServer->GetSystemBold();
if (sf) {
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<uint16>(sf->FamilyID());
fLink.Attach<uint16>(sf->StyleID());
fLink.Attach<float>(sf->Size());
fLink.Attach<uint16>(sf->Face());
fLink.Attach<uint32>(sf->Flags());
} else
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
gFontServer->Unlock();
break;
}
case AS_SET_SYSFONT_FIXED:
{
FTRACE(("ServerApp %s: AS_SET_SYSFONT_FIXED\n", Signature()));
// Returns:
// 1) uint16 - family ID
// 2) uint16 - style ID
// 3) float - size in points
// 4) uint16 - face flags
// 5) uint32 - font flags
gFontServer->Lock();
ServerFont *sf = gFontServer->GetSystemFixed();
if (sf) {
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<uint16>(sf->FamilyID());
fLink.Attach<uint16>(sf->StyleID());
fLink.Attach<float>(sf->Size());
fLink.Attach<uint16>(sf->Face());
fLink.Attach<uint32>(sf->Flags());
} else
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
gFontServer->Unlock();
break;
}
case AS_GET_GLYPH_SHAPES:
{
FTRACE(("ServerApp %s: AS_GET_GLYPH_SHAPES\n", Signature()));
@ -1776,8 +1741,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<int32>(&numChars);
char charArray[numChars];
for (int32 i = 0; i < numChars; i++)
link.Read<char>(&charArray[i]);
link.Read(&charArray, numChars);
ServerFont font;
if (font.SetFamilyAndStyle(famid, styid) == B_OK) {
@ -1935,9 +1899,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{
STRACE(("ServerApp %s: AS_SCREEN_GET_MODE\n", Signature()));
// Attached data
// 1) int32 port to reply to
// 2) screen_id
// 3) workspace index
// 1) screen_id screen
// 2) uint32 workspace index
screen_id id;
link.Read<screen_id>(&id);
uint32 workspace;
@ -1962,11 +1925,10 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{
STRACE(("ServerApp %s: AS_SCREEN_SET_MODE\n", Signature()));
// Attached data
// 1) int32 port to reply to
// 2) screen_id
// 3) workspace index
// 4) display_mode to set
// 5) 'makedefault' boolean
// 1) screen_id
// 2) workspace index
// 3) display_mode to set
// 4) 'makedefault' boolean
// TODO: See above: workspaces support, etc.
screen_id id;
@ -1984,7 +1946,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// TODO: lock RootLayer, set mode and tell it to update it's frame and all clipping
// optionally put this into a message and let the root layer thread handle it.
// status_t ret = gDesktop->ScreenAt(0)->SetMode(mode);
status_t ret = B_ERROR;
status_t ret = B_ERROR;
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<status_t>(ret);
@ -2015,6 +1977,10 @@ status_t ret = B_ERROR;
case AS_GET_MODE_LIST:
{
screen_id id;
link.Read<screen_id>(&id);
// TODO: use this screen id
display_mode* modeList;
uint32 count;
if (gDesktop->GetHWInterface()->GetModeList(&modeList, &count) == B_OK) {
@ -2052,8 +2018,8 @@ status_t ret = B_ERROR;
{
STRACE(("ServerApp %s: get desktop color\n", Signature()));
int32 workspaceIndex = 0;
link.Read<int32>(&workspaceIndex);
uint32 workspaceIndex = 0;
link.Read<uint32>(&workspaceIndex);
// ToDo: for some reason, we currently get "1" as no. of workspace
workspaceIndex = 0;
@ -2066,7 +2032,6 @@ status_t ret = B_ERROR;
Workspace *workspace = root->WorkspaceAt(workspaceIndex);
if (workspace != NULL) {
fLink.StartMessage(SERVER_TRUE);
//rgb_color color;
fLink.Attach<rgb_color>(workspace->BGColor().GetColor32());
} else
fLink.StartMessage(SERVER_FALSE);
@ -2093,7 +2058,6 @@ status_t ret = B_ERROR;
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
break;
}
@ -2109,7 +2073,6 @@ status_t ret = B_ERROR;
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<sem_id>(semaphore);
fLink.Flush();
break;
}
@ -2119,6 +2082,7 @@ status_t ret = B_ERROR;
// We aren't using the screen_id for now...
screen_id id;
link.Read<screen_id>(&id);
display_timing_constraints constraints;
if (gDesktop->GetHWInterface()->GetTimingConstraints(&constraints) == B_OK) {
fLink.StartMessage(SERVER_TRUE);
@ -2127,7 +2091,6 @@ status_t ret = B_ERROR;
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
break;
}
@ -2149,7 +2112,6 @@ status_t ret = B_ERROR;
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
break;
}
@ -2168,7 +2130,6 @@ status_t ret = B_ERROR;
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
break;
}
@ -2183,7 +2144,6 @@ status_t ret = B_ERROR;
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<uint32>(state);
fLink.Flush();
break;
}

View File

@ -1088,13 +1088,21 @@ myRootLayer->Unlock();
fLink.Flush();
} else {
// TODO: Watch out for the coordinate system in AS_LAYER_GET_CLIP_REGION
#ifndef NEW_CLIPPING
int32 rectCount = fCurrentLayer->fVisible.CountRects();
#else
int32 rectCount = fCurrentLayer->fVisible2.CountRects();
#endif
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<int32>(rectCount);
for (int32 i = 0; i < rectCount; i++)
#ifndef NEW_CLIPPING
fLink.Attach<BRect>(fCurrentLayer->ConvertFromTop(fCurrentLayer->fVisible.RectAt(i)));
#else
fLink.Attach<BRect>(fCurrentLayer->ConvertFromTop(fCurrentLayer->fVisible2.RectAt(i)));
#endif
fLink.Flush();
}