diff --git a/src/servers/app/server/ColorSet.h b/headers/private/servers/app/ColorSet.h similarity index 100% rename from src/servers/app/server/ColorSet.h rename to headers/private/servers/app/ColorSet.h diff --git a/src/servers/app/server/Decorator.h b/headers/private/servers/app/Decorator.h similarity index 100% rename from src/servers/app/server/Decorator.h rename to headers/private/servers/app/Decorator.h diff --git a/src/servers/app/server/DisplayDriver.h b/headers/private/servers/app/DisplayDriver.h similarity index 100% rename from src/servers/app/server/DisplayDriver.h rename to headers/private/servers/app/DisplayDriver.h diff --git a/src/servers/app/server/FontFamily.h b/headers/private/servers/app/FontFamily.h similarity index 100% rename from src/servers/app/server/FontFamily.h rename to headers/private/servers/app/FontFamily.h diff --git a/src/servers/app/server/LayerData.h b/headers/private/servers/app/LayerData.h similarity index 91% rename from src/servers/app/server/LayerData.h rename to headers/private/servers/app/LayerData.h index 9f6522f75c..b0719768ca 100644 --- a/src/servers/app/server/LayerData.h +++ b/headers/private/servers/app/LayerData.h @@ -4,7 +4,7 @@ #include #include #include "RGBColor.h" -#include "FontServer.h" +//#include "FontServer.h" #include "ServerFont.h" class ServerBitmap; @@ -24,7 +24,8 @@ public: highcolor.SetColor(0,0,0,255); lowcolor.SetColor(255,255,255,255); viewcolor.SetColor(255,255,255,255); - font=fontserver->GetSystemPlain(); +// font=fontserver->GetSystemPlain(); + font=NULL; scale=1.0; edelta.space=0; edelta.nonspace=0; diff --git a/src/servers/app/server/PatternHandler.h b/headers/private/servers/app/PatternHandler.h similarity index 100% rename from src/servers/app/server/PatternHandler.h rename to headers/private/servers/app/PatternHandler.h diff --git a/src/servers/app/server/RGBColor.h b/headers/private/servers/app/RGBColor.h similarity index 100% rename from src/servers/app/server/RGBColor.h rename to headers/private/servers/app/RGBColor.h diff --git a/src/servers/app/server/RectUtils.h b/headers/private/servers/app/RectUtils.h similarity index 100% rename from src/servers/app/server/RectUtils.h rename to headers/private/servers/app/RectUtils.h diff --git a/src/servers/app/server/ServerBitmap.h b/headers/private/servers/app/ServerBitmap.h similarity index 100% rename from src/servers/app/server/ServerBitmap.h rename to headers/private/servers/app/ServerBitmap.h diff --git a/headers/private/servers/app/ServerConfig.h b/headers/private/servers/app/ServerConfig.h new file mode 100644 index 0000000000..b58a2ecde6 --- /dev/null +++ b/headers/private/servers/app/ServerConfig.h @@ -0,0 +1,82 @@ +#ifndef _APPSERVER_CONFIG_H +#define _APPSERVER_CONFIG_H + +// This is defined to place the server in test mode, which modifies certain things like +// system keyboard shortcuts. Note that it is possible, though senseless, to place it in +// regular mode and still use a display driver which depends on the R5 app_server +#define TEST_MODE + +// The ViewDriver is a BView/BWindow combination. Plenty of functionality, +// but dog-slow. +#define VIEWDRIVER 0 + +// The ScreenDriver utilizes a BWindowScreen to directly access the video +// hardware. +#define SCREENDRIVER 1 + +// The SecondDriver allows the server to make use of a second video card while +// still running as a regular BeOS application. You could say it's training +// wheels for the HWDriver +#define SECONDDRIVER 2 + +// The HWDriver is the real thing - loads all the graphics hardware and +// literally takes over the system as the app_server is supposed to. This +// one can be used only when the app_server is running as *the* app_server +// and not in testing mode like the other drivers are for. +#define HWDRIVER 3 + +// Display driver to be used by the server. +#define DISPLAYDRIVER VIEWDRIVER + +// Uncomment this if the DisplayDriver should only rely on drawing functions implemented +// in software even though hardware-accelerated functions are available +//#define DISABLE_HARDWARE_ACCELERATION + +// Define this for a quick hack to test some of the drawing functions +//#define DISPLAYDRIVER_TEST_HACK + +// Define this if you want the display driver to emulate the input server. +// Comment this out if DISPLAYDRIVER is defined as HWDRIVER. +#define ENABLE_INPUT_SERVER_EMULATION + +// This is the application signature of our app_server when running as a +// regular application. When running as the app_server, this is not used. +#define SERVER_SIGNATURE "application/x-vnd.obe-OBAppServer" + +// Directory for all app_server-related settings. Must include ending slash. +#define SERVER_SETTINGS_DIR "/boot/home/config/settings/app_server/" + +// Flattened list of usable fonts maintained by the server. The file is a +// flattened BMessage which is used for caching the names when obtained +// by the various font functions. +#define SERVER_FONT_LIST "/boot/home/config/settings/app_server/fontlist" + +// folder used to keep saved color sets for the UI - tab color, etc. +#define COLOR_SET_DIR "/boot/home/config/settings/color_sets/" + +// name of the file containing the current UI color settings +#define COLOR_SETTINGS_NAME "system_colors" + +// name of the file containing the config data for the desktop +#define WORKSPACE_SETTINGS_NAME "workspace_data" + +// Folder for additional window decorators +#define DECORATORS_DIR "/boot/home/config/add-ons/decorators/" + +// These definitions provide the server something to use for default +// system fonts. +#define DEFAULT_PLAIN_FONT_FAMILY "Swis721 BT" +#define DEFAULT_PLAIN_FONT_STYLE "Roman" +#define DEFAULT_PLAIN_FONT_SIZE 12 +#define DEFAULT_BOLD_FONT_FAMILY "Swis721 BT" +#define DEFAULT_BOLD_FONT_STYLE "Bold" +#define DEFAULT_BOLD_FONT_SIZE 12 +#define DEFAULT_FIXED_FONT_FAMILY "Courier10 BT" +#define DEFAULT_FIXED_FONT_STYLE "Roman" +#define DEFAULT_FIXED_FONT_SIZE 12 + +// This is the port capacity for all monitoring objects - ServerApps +// and ServerWindows +#define DEFAULT_MONITOR_PORT_SIZE 30 + +#endif diff --git a/src/servers/app/server/ServerCursor.h b/headers/private/servers/app/ServerCursor.h similarity index 100% rename from src/servers/app/server/ServerCursor.h rename to headers/private/servers/app/ServerCursor.h diff --git a/src/servers/app/server/ServerFont.h b/headers/private/servers/app/ServerFont.h similarity index 100% rename from src/servers/app/server/ServerFont.h rename to headers/private/servers/app/ServerFont.h diff --git a/headers/private/servers/app/SharedObject.h b/headers/private/servers/app/SharedObject.h new file mode 100644 index 0000000000..4057a609a4 --- /dev/null +++ b/headers/private/servers/app/SharedObject.h @@ -0,0 +1,55 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: SharedObject.h +// Author: DarkWyrm +// Description: This class is used as a base class for other objects which +// must be shared. By using this, objects which depend on its +// existence can be somewhat sure that the shared object will +// not be deleted until nothing depends on it. +// +//------------------------------------------------------------------------------ +#ifndef SHAREDOBJ_H_ +#define SHAREDOBJ_H_ + +#include + +/*! + \class SharedObject SharedObject.h + \brief Base class for shared objects + + SharedObjects track dependencies upon a particular object. In this way, is is + possible to ensure that a shared resource is not deleted if something else + needs it. How the dependency tracking is done largely depends on the child class. +*/ +class SharedObject +{ +public: + SharedObject(void) { dependents=0; } + virtual ~SharedObject(void){} + virtual void AddDependent(void) { dependents++; } + virtual void RemoveDependent(void) { dependents--; } + virtual bool HasDependents(void) { return (dependents>0)?true:false; } +private: + uint32 dependents; +}; + +#endif diff --git a/src/servers/app/server/SystemPalette.h b/headers/private/servers/app/SystemPalette.h similarity index 100% rename from src/servers/app/server/SystemPalette.h rename to headers/private/servers/app/SystemPalette.h diff --git a/src/servers/app/server/AccelerantDriver.cpp b/src/servers/app/server/AccelerantDriver.cpp index 7e5e524135..1f05736e0a 100644 --- a/src/servers/app/server/AccelerantDriver.cpp +++ b/src/servers/app/server/AccelerantDriver.cpp @@ -38,6 +38,7 @@ #include #include + #define RUN_UNDER_R5 #define CLIP_X(a) ( (a < 0) ? 0 : ((a > mDisplayMode.virtual_width-1) ? \ diff --git a/src/servers/app/server/AccelerantDriver.h b/src/servers/app/server/AccelerantDriver.h index 871f7a1314..bbee280e81 100644 --- a/src/servers/app/server/AccelerantDriver.h +++ b/src/servers/app/server/AccelerantDriver.h @@ -42,10 +42,10 @@ #include #include "DisplayDriver.h" #include "PatternHandler.h" -#include -#include FT_FREETYPE_H -#include FT_GLYPH_H - +//#include +//#include FT_FREETYPE_H +//#include FT_GLYPH_H +#include "FontServer.h" #if 0 class VDWindow; class RGBColor; diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index 63e8e30913..52b343a1da 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -45,6 +45,7 @@ #include "BitmapManager.h" #include "CursorManager.h" #include "Utils.h" +#include "FontServer.h" //#define DEBUG_KEYHANDLING @@ -497,7 +498,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer) PortLink *replylink=new PortLink(reply_port); replylink->SetOpCode(AS_SET_SERVER_PORT); - replylink->Attach((int32)newapp->_receiver); + replylink->Attach(newapp->_receiver); replylink->Flush(); delete replylink; @@ -601,9 +602,9 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer) PortLink *replylink=new PortLink(*((port_id*)index)); replylink->SetOpCode(AS_GET_SCREEN_MODE); - replylink->Attach((int16)_driver->GetWidth()); - replylink->Attach((int16)_driver->GetHeight()); - replylink->Attach((int16)_driver->GetDepth()); + replylink->Attach(_driver->GetWidth()); + replylink->Attach(_driver->GetHeight()); + replylink->Attach(_driver->GetDepth()); replylink->Flush(); delete replylink; break; @@ -981,7 +982,6 @@ ServerApp *AppServer::FindApp(const char *sig) Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, int32 wflags, DisplayDriver *ddriver) { -debugger(""); Decorator *dec=NULL; if(!app_server->make_decorator) dec=new DefaultDecorator(rect,wlook,wfeel,wflags); diff --git a/src/servers/app/server/BitmapDriver.h b/src/servers/app/server/BitmapDriver.h index 1953e3e268..54a91fc3f0 100644 --- a/src/servers/app/server/BitmapDriver.h +++ b/src/servers/app/server/BitmapDriver.h @@ -38,9 +38,10 @@ #include #include #include "DisplayDriver.h" -#include -#include FT_FREETYPE_H -#include FT_GLYPH_H +//#include +//#include FT_FREETYPE_H +//#include FT_GLYPH_H +#include "FontServer.h" class ServerCursor; class ServerBitmap; diff --git a/src/servers/app/server/ColorUtils.cc b/src/servers/app/server/ColorUtils.cc deleted file mode 100644 index 5a0af34ec8..0000000000 --- a/src/servers/app/server/ColorUtils.cc +++ /dev/null @@ -1,210 +0,0 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: ColorUtils.cc -// Author: DarkWyrm -// Description: Miscellaneous useful functions for working with colors -// -// -//------------------------------------------------------------------------------ -#include "ColorUtils.h" -#include - -/*! - \brief An approximation of 31/255, which is needed for converting from 32-bit - colors to 16-bit. -*/ -#define RATIO_32_TO_16_BIT .121568627451 - -/*! - \brief An approximation of 255/31, which is needed for converting from 16-bit - colors to 32-bit. -*/ -#define RATIO_16_TO_32_BIT 8.225806451613 - -/*! - \brief Function for easy assignment of values to rgb_color objects - \param Pointer to an rgb_color - \param red value - \param green value - \param blue value - \param alpha value, defaults to 255 - - This function will do nothing if given a NULL color pointer. -*/ -void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a) -{ - if(col) - { - col->red=r; - col->green=g; - col->blue=b; - col->alpha=a; - } -} - -/*! - \brief Function for easy conversion of 16-bit colors to 32-bit - \param Pointer to an rgb_color. - \param RGBA16 color - - This function will do nothing if passed a NULL 32-bit color. -*/ -void SetRGBColor(rgb_color *col,uint16 color) -{ - if(!col) - return; - - uint16 r16,g16,b16; - - // alpha's the easy part - col->alpha=(color & 0x8000)?255:0; - - r16= (color >> 15) & 31; - g16= (color >> 10) & 31; - b16= color & 31; - - col->red=uint8(r16 * RATIO_16_TO_32_BIT); - col->green=uint8(g16 * RATIO_16_TO_32_BIT); - col->blue=uint8(b16 * RATIO_16_TO_32_BIT); -} - -/*! - \brief Finds the index of the closest matching color in a rgb_color palette array - \param Array of 256 rgb_color objects - \param Color to match - \return Index of the closest matching color - - Note that passing a NULL palette will always return 0 and passing an array of less - than 256 rgb_colors will cause a crash. -*/ -uint8 FindClosestColor(rgb_color *palette, rgb_color color) -{ - if(!palette) - return 0; - - uint16 cindex=0,cdelta=765,delta=765; - rgb_color *c; - - for(uint16 i=0;i<256;i++) - { - c=&(palette[i]); - delta=abs(c->red-color.red)+abs(c->green-color.green)+ - abs(c->blue-color.blue); - - if(delta==0) - { - cindex=i; - break; - } - - if(delta127)?0x8000:0; - - color16 |= r16 << 15; - color16 |= g16 << 10; - color16 |= b16; - - return color16; -} - -// Function which could be used to . Position is -// Any number outside -// this range will cause the function to fail and return the color (0,0,0,0) -// Alpha components are included in the calculations. 0 yields color #1 -// and 1 yields color #2. - -/*! - \brief Function mostly for calculating gradient colors - \param Start color - \param End color - \param A floating point number such that 0.0 <= position <= 1.0. 0.0 results in the - start color and 1.0 results in the end color. - \return The blended color. If an invalid position was given, {0,0,0,0} is returned. -*/ -rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position) -{ - rgb_color newcol={0,0,0,0}; - float mod=0; - int16 delta; - if(position<0 || position>1) - return newcol; - - delta=int16(col2.red)-int16(col.red); - mod=col.red + (position * delta); - newcol.red=uint8(mod); - if(mod>255 ) - newcol.red=255; - if(mod<0 ) - newcol.red=0; - - delta=int16(col2.green)-int16(col.green); - mod=col.green + (position * delta); - newcol.green=uint8(mod); - if(mod>255 ) - newcol.green=255; - if(mod<0 ) - newcol.green=0; - - delta=int16(col2.blue)-int16(col.blue); - mod=col.blue + (position * delta); - newcol.blue=uint8(mod); - if(mod>255 ) - newcol.blue=255; - if(mod<0 ) - newcol.blue=0; - - delta=int8(col2.alpha)-int8(col.alpha); - mod=col.alpha + (position * delta); - newcol.alpha=uint8(mod); - if(mod>255 ) - newcol.alpha=255; - if(mod<0 ) - newcol.alpha=0; - - return newcol; -} diff --git a/src/servers/app/server/CursorData.cpp b/src/servers/app/server/CursorData.cpp index 2c18fe0cc8..008adcaefe 100644 --- a/src/servers/app/server/CursorData.cpp +++ b/src/servers/app/server/CursorData.cpp @@ -38,8 +38,8 @@ int8 default_cursor_data[] = { 144,64, // *--*-----*------ 144,128, // *--*----*------- 105,0, // -**-*--*-------- - 6,0, // -----**--------- + 0,0, // ---------------- 0,0, // ---------------- 0,0, // ---------------- @@ -56,9 +56,9 @@ int8 default_cursor_data[] = { 255,224, 255,192, 255,128, -105,0, +111,0, +6,0, -0,0, 0,0, 0,0, 0,0 diff --git a/src/servers/app/server/FontFamily.cpp b/src/servers/app/server/FontFamily.cpp index a81081d547..c1e671ec02 100644 --- a/src/servers/app/server/FontFamily.cpp +++ b/src/servers/app/server/FontFamily.cpp @@ -28,7 +28,8 @@ #include "ServerFont.h" #include FT_CACHE_H -extern FTC_Manager ftmanager; +FTC_Manager ftmanager; +FT_Library ftlib; /*! \brief Constructor diff --git a/src/servers/app/server/FontServer.cpp b/src/servers/app/server/FontServer.cpp index fcbc29b130..6ae638eced 100644 --- a/src/servers/app/server/FontServer.cpp +++ b/src/servers/app/server/FontServer.cpp @@ -27,18 +27,16 @@ #include #include #include -#include +#include // specified to be able to build under Dano #include #include #include -#include "FontFamily.h" #include "FontServer.h" +#include "FontFamily.h" #include "ServerFont.h" #include "ServerConfig.h" -FTC_Manager ftmanager; -FT_Library ftlib; FontServer *fontserver; /*! diff --git a/src/servers/app/server/Jamfile b/src/servers/app/server/Jamfile index 0126205361..ce4744b7d8 100644 --- a/src/servers/app/server/Jamfile +++ b/src/servers/app/server/Jamfile @@ -3,9 +3,27 @@ SubDir OBOS_TOP src servers app server ; AddResources app_server : app_server.rsrc ; UseLibraryHeaders png zlib ; -UsePrivateHeaders app interface ; +UsePrivateHeaders app interface [ FDirName servers app ] ; UseFreeTypeHeaders ; +SharedLibrary appserver : + ColorSet.cpp + Decorator.cpp + DisplayDriver.cpp + FontFamily.cpp + PatternHandler.cpp + RectUtils.cpp + RGBColor.cpp + ServerBitmap.cpp + ServerCursor.cpp + ServerFont.cpp + SystemPalette.cpp +; + +LinkSharedOSLibs libappserver.so : root be + libopenbeos.so + libfreetype.so ; + Server app_server : # Misc. Sources areafunc.c @@ -13,14 +31,9 @@ Server app_server : bget.c CursorData.cpp TokenHandler.cpp - PatternHandler.cpp PicturePlayer.cpp - ColorSet.cpp PNGDump.cpp - RectUtils.cpp - RGBColor.cpp - SystemPalette.cpp Utils.cpp # Manager Classes @@ -33,21 +46,15 @@ Server app_server : ServerWindow.cpp # Font Classes - FontFamily.cpp FontServer.cpp - ServerFont.cpp # Display Classes AccelerantDriver.cpp - Decorator.cpp DefaultDecorator.cpp DesktopClasses.cpp - DisplayDriver.cpp Layer.cpp RootLayer.cpp ScreenDriver.cpp - ServerBitmap.cpp - ServerCursor.cpp ServerPicture.cpp ViewDriver.cpp WinBorder.cpp @@ -56,7 +63,7 @@ Server app_server : LINKFLAGS on app_server ?= $(LINKFLAGS) ; LINKFLAGS on app_server += -lbe ; -LinkSharedOSLibs app_server : root game translation libz.so libpng.so +LinkSharedOSLibs app_server : root game translation libz.so libpng.so libappserver.so libopenbeos.so libfreetype.so ; diff --git a/src/servers/app/server/PicturePlayer.cpp b/src/servers/app/server/PicturePlayer.cpp index 7e7c79eaf9..63dc8e9677 100644 --- a/src/servers/app/server/PicturePlayer.cpp +++ b/src/servers/app/server/PicturePlayer.cpp @@ -27,8 +27,9 @@ //------------------------------------------------------------------------------ #include "PicturePlayer.h" -#include +#include "PictureProtocol.h" #include "DisplayDriver.h" +#include PicturePlayer::PicturePlayer(DisplayDriver *d,void *data, int32 size) : fData(data, size) diff --git a/src/servers/app/server/RectUtils.cpp b/src/servers/app/server/RectUtils.cpp index d36c2c8a22..6d7a88d0fb 100644 --- a/src/servers/app/server/RectUtils.cpp +++ b/src/servers/app/server/RectUtils.cpp @@ -1,5 +1,42 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: RectUtils.cpp +// Author: DarkWyrm +// Description: Utilities for work around R5 Interface Kit bugs +// +//------------------------------------------------------------------------------ #include "RectUtils.h" +/*! + \brief Checks for the intersection of two rectangles. Works properly, + unlike BRect::Intersects + + \param r First rectangle + \param r2 Second rectangle + \return True if they intersect, false if they don't. + + The two rectangles intersect if they are equal, one contains the other, + or if any edge intersects any edge of the other rectangle. +*/ bool TestRectIntersection(const BRect &r,const BRect &r2) { return TestLineIntersection(r, r2.left, r2.top, r2.left, r2.bottom) || @@ -10,6 +47,16 @@ bool TestRectIntersection(const BRect &r,const BRect &r2) r2.Contains(r); } +/*! + \brief Checks to see if a region intersects with a particular rectangle + + \param r Region + \param r2 Rectangle to check intersection with + \return True if they intersect, false if they don't. + + The two intersect if they the rectangle intersects any one rectangle in the + region. +*/ bool TestRegionIntersection(BRegion *r,const BRect &r2) { for(int32 i=0; iCountRects(); i++) @@ -18,6 +65,12 @@ bool TestRegionIntersection(BRegion *r,const BRect &r2) return false; } +/*! + \brief Modifies the region to intersect with the rectangle given + + \param r Region + \param r2 Rectangle to intersect with +*/ void IntersectRegionWith(BRegion *r,const BRect &r2) { // We have three conditions: @@ -35,6 +88,17 @@ void IntersectRegionWith(BRegion *r,const BRect &r2) r->MakeEmpty(); } +/*! + \brief Checks for the intersection of a line with a rectangle + + \param r Rectangle + \param x1 starting x of line + \param y1 starting y of line + \param x2 ending x of line + \param y2 ending y of line + \param vertical Test for vertical intersection + \return true if they intersect, false if not +*/ bool TestLineIntersection(const BRect& r, float x1, float y1, float x2, float y2, bool vertical) { @@ -52,6 +116,10 @@ bool TestLineIntersection(const BRect& r, float x1, float y1, float x2, float y2 } } +/*! + \brief Ensures that a BRect's IsValid() member returns true + \param rect BRect to validate +*/ void ValidateRect(BRect *rect) { float l,r,t,b; diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index 9f4a7b6a4a..aebb34dfb4 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -76,18 +76,20 @@ void RootLayer::RequestDraw(void) low.type64=0LL; // Redraw the base - for(int32 i=0; _invalid->CountRects();i++) + if(_invalid) { - if(_invalid->RectAt(i).IsValid()) - _driver->FillRect(_invalid->RectAt(i),_layerdata, (int8*)low.type8); - else - break; + for(int32 i=0; _invalid->CountRects();i++) + { + if(_invalid->RectAt(i).IsValid()) + _driver->FillRect(_invalid->RectAt(i),_layerdata, (int8*)low.type8); + else + break; + } + + delete _invalid; + _invalid=NULL; } - delete _invalid; - _invalid=NULL; - _is_dirty=false; - // force redraw of all dirty windows for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling) { @@ -95,6 +97,7 @@ void RootLayer::RequestDraw(void) lay->RequestDraw(lay->Bounds()); } + _is_dirty=false; #ifdef DISPLAYDRIVER_TEST_HACK int8 pattern[8]; int8 pattern2[8]; diff --git a/src/servers/app/server/ScreenDriver.h b/src/servers/app/server/ScreenDriver.h index 5b8899b2d1..ea8b54e00d 100644 --- a/src/servers/app/server/ScreenDriver.h +++ b/src/servers/app/server/ScreenDriver.h @@ -38,9 +38,10 @@ #include #include #include "DisplayDriver.h" -#include +//#include #include -#include FT_FREETYPE_H +//#include FT_FREETYPE_H +#include "FontServer.h" class BBitmap; class PortLink; diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index 50974ff08a..f867013861 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -370,8 +370,8 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer) // ServerWindow's message port PortLink *replylink=new PortLink(reply_port); replylink->SetOpCode(AS_SET_SERVER_PORT); - replylink->Attach((int32)newwin->_receiver); - replylink->Attach((int32)newwin->_token); + replylink->Attach(newwin->_receiver); + replylink->Attach(newwin->_token); replylink->Flush(); delete replylink; diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index cea8a87332..ec0cabf179 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -285,8 +285,8 @@ void ServerWindow::WorkspaceActivated(int32 workspace, bool active) printf("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",_title->String(),workspace,(active)?"active":"inactive"); #endif _winlink->SetOpCode(AS_WORKSPACE_ACTIVATED); - _winlink->Attach(workspace); - _winlink->Attach(active); + _winlink->Attach(workspace); + _winlink->Attach(active); _winlink->Flush(); } @@ -301,8 +301,8 @@ void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone) printf("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",_title->String(),oldone,newone); #endif _winlink->SetOpCode(AS_WORKSPACES_CHANGED); - _winlink->Attach(oldone); - _winlink->Attach(newone); + _winlink->Attach(oldone); + _winlink->Attach(newone); _winlink->Flush(); } @@ -316,7 +316,7 @@ void ServerWindow::WindowActivated(bool active) printf("ServerWindow %s: WindowActivated(%s)\n",_title->String(),(active)?"active":"inactive"); #endif _winlink->SetOpCode(AS_WINDOW_ACTIVATED); - _winlink->Attach(active); + _winlink->Attach(active); _winlink->Flush(); } @@ -331,7 +331,7 @@ void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace printf("ServerWindow %s: ScreenModeChanged\n",_title->String()); #endif _winlink->SetOpCode(AS_SCREENMODE_CHANGED); - _winlink->Attach(frame); + _winlink->Attach(frame); _winlink->Attach(&cspace,sizeof(color_space)); _winlink->Flush(); } @@ -1202,7 +1202,7 @@ int32 ServerWindow::MonitorWin(void *data) // Our BWindow sent us this message when it quit. // We need to ask its ServerApp to delete our monitor win->_applink->SetOpCode(AS_DELETE_WINDOW); - win->_applink->Attach((int32)win->_token); + win->_applink->Attach(win->_token); win->_applink->Flush(); break; } @@ -1271,9 +1271,9 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) float x; float y; int64 dummy; - msg->Read(&dummy); - msg->Read(&x); - msg->Read(&y); + msg->Read(&dummy); + msg->Read(&x); + msg->Read(&y); BPoint pt(x,y); // If we have clicked on a window, diff --git a/src/servers/app/server/ViewDriver.h b/src/servers/app/server/ViewDriver.h index 0ddeaf3d04..14531c9751 100644 --- a/src/servers/app/server/ViewDriver.h +++ b/src/servers/app/server/ViewDriver.h @@ -37,8 +37,9 @@ #include #include #include "DisplayDriver.h" -#include -#include FT_FREETYPE_H +//#include +//#include FT_FREETYPE_H +#include "FontServer.h" class BBitmap; class PortLink;