diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index 471f81b61f..6e2325dd68 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -27,6 +27,7 @@ #include #include #include "AppServer.h" +#include "ColorSet.h" #include "Desktop.h" #include "DisplayDriver.h" #include "PortLink.h" @@ -50,6 +51,9 @@ AppServer *app_server=NULL; //! Default background color for workspaces RGBColor workspace_default_color(51,102,160); +//! System-wide GUI color object +ColorSet gui_colorset; + /*! \brief Constructor @@ -91,7 +95,12 @@ AppServer::AppServer(void) printf("Couldn't set fixed to %s, %s %d pt\n",DEFAULT_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE,DEFAULT_FIXED_FONT_SIZE); fontserver->Unlock(); - + + // Get the GUI colors here. For now, we'll just set the defaults + SetDefaultGUIColors(&gui_colorset); + + // TODO: load the GUI colors here and set the global set to the values contained therein + // Set up the Desktop InitDesktop(); @@ -928,10 +937,17 @@ ServerApp *AppServer::FindApp(const char *sig) Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, int32 wflags, DisplayDriver *ddriver) { + Decorator *dec; if(!app_server->make_decorator) - return new DefaultDecorator(rect,wlook,wfeel,wflags); + dec=new DefaultDecorator(rect,wlook,wfeel,wflags); + else + dec=app_server->make_decorator(rect,wlook,wfeel,wflags); + + gui_colorset.Lock(); + dec->SetColors(gui_colorset); + gui_colorset.Unlock(); - return app_server->make_decorator(rect,wlook,wfeel,wflags); + return dec; } /*! diff --git a/src/servers/app/server/ColorSet.cpp b/src/servers/app/server/ColorSet.cpp index 16939959d9..2d6e4d866c 100644 --- a/src/servers/app/server/ColorSet.cpp +++ b/src/servers/app/server/ColorSet.cpp @@ -125,9 +125,7 @@ void ColorSet::SetColors(const ColorSet &cs) inactive_window_tab_text=cs.inactive_window_tab_text; } -/*! - \brief Prints all color set elements to stdout -*/ +//! Prints all color set elements to stdout void ColorSet::PrintToStream(void) { printf("panel_background "); panel_background.PrintToStream(); @@ -164,3 +162,41 @@ void ColorSet::PrintToStream(void) printf("inactive_window_tab "); inactive_window_tab.PrintToStream(); printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream(); } + +/*! + \brief Assigns the default system colors to the passed ColorSet object + \param The ColorSet object to set to defaults +*/ +void SetDefaultGUIColors(ColorSet *set) +{ +#ifdef DEBUG_COLORSET +printf("Initializing color settings to defaults\n"); +#endif + set->panel_background.SetColor(216,216,216); + set->panel_text.SetColor(0,0,0); + set->document_background.SetColor(255,255,255); + set->document_text.SetColor(0,0,0); + set->control_background.SetColor(245,245,245); + set->control_text.SetColor(0,0,0); + set->control_border.SetColor(0,0,0); + set->control_highlight.SetColor(115,120,184); + set->keyboard_navigation_base.SetColor(170,50,184); + set->keyboard_navigation_pulse.SetColor(0,0,0); + set->shine.SetColor(255,255,255); + set->shadow.SetColor(0,0,0); + set->menu_background.SetColor(216,216,216); + set->menu_selected_background.SetColor(115,120,184); + set->menu_text.SetColor(0,0,0); + set->menu_selected_text.SetColor(255,255,255); + set->menu_selected_border.SetColor(0,0,0); + set->tooltip_background.SetColor(255,255,0); + set->tooltip_text.SetColor(0,0,0); + set->success.SetColor(0,255,0); + set->failure.SetColor(255,0,0); + set->window_tab.SetColor(255,203,0); + + // important, but not publically accessible GUI colors + set->window_tab_text.SetColor(0,0,0); + set->inactive_window_tab.SetColor(232,232,232); + set->inactive_window_tab_text.SetColor(80,80,80); +} diff --git a/src/servers/app/server/ColorSet.h b/src/servers/app/server/ColorSet.h index ce08a053eb..cf348df916 100644 --- a/src/servers/app/server/ColorSet.h +++ b/src/servers/app/server/ColorSet.h @@ -28,13 +28,14 @@ #ifndef COLORSET_H_ #define COLORSET_H_ +#include #include "RGBColor.h" /*! \class ColorSet ColorSet.h \brief Encapsulates GUI system colors */ -class ColorSet +class ColorSet : public BLocker { public: ColorSet(void); @@ -70,13 +71,15 @@ public: 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, window_tab_text, inactive_window_tab, inactive_window_tab_text; }; +void SetDefaultGUIColors(ColorSet *set); + #endif diff --git a/src/servers/app/server/DefaultDecorator.cpp b/src/servers/app/server/DefaultDecorator.cpp index db7f7e14ad..6d89ea8df0 100644 --- a/src/servers/app/server/DefaultDecorator.cpp +++ b/src/servers/app/server/DefaultDecorator.cpp @@ -32,6 +32,7 @@ #include "RGBColor.h" //#define DEBUG_DECORATOR +#define USE_VIEW_FILL_HACK #ifdef DEBUG_DECORATOR #include @@ -423,6 +424,10 @@ void DefaultDecorator::_DrawFrame(BRect rect) { // Duh, draws the window frame, I think. ;) +#ifdef USE_VIEW_FILL_HACK +_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh); +#endif + if(_look==B_NO_BORDER_WINDOW_LOOK) return; diff --git a/src/servers/app/server/DisplayDriver.cpp b/src/servers/app/server/DisplayDriver.cpp index 82a1e27bf2..4a637b9613 100644 --- a/src/servers/app/server/DisplayDriver.cpp +++ b/src/servers/app/server/DisplayDriver.cpp @@ -25,6 +25,7 @@ // for the server // //------------------------------------------------------------------------------ +#include #include "DisplayDriver.h" #include "ServerCursor.h" @@ -46,6 +47,8 @@ DisplayDriver::DisplayDriver(void) _is_cursor_hidden=false; _is_cursor_obscured=false; _cursor=NULL; + _dpms_caps=0; + _dpms_state=B_DPMS_ON; } @@ -476,6 +479,15 @@ bool DisplayDriver::DumpToFile(const char *path) return false; } +/*! + \brief Returns a new ServerBitmap containing the contents of the frame buffer + \return A new ServerBitmap containing the contents of the frame buffer or NULL if unsuccessful +*/ +ServerBitmap *DisplayDriver::DumpToBitmap(void) +{ + return NULL; +} + /*! \brief Gets the width of a string in pixels \param string Source null-terminated string @@ -582,6 +594,33 @@ void DisplayDriver::GetTruncatedStrings( const char **instrings, int32 stringcou { } +/*! + \brief Sets the DPMS state of the driver + \param state The new state for the display. See Accelerant.h +*/ +status_t DisplayDriver::SetDPMSState(uint32 state) +{ + return B_OK; +} + +/*! + \brief Returns the current DPMS state + \return The current DPMS state +*/ +uint32 DisplayDriver::GetDPMSState(void) +{ + return _dpms_state; +} + +/*! + \brief Returns the current DPMS capabilities + \return The current DPMS capabilities +*/ +uint32 DisplayDriver::GetDPMSCapabilities(void) +{ + return _dpms_caps; +} + /*! \brief Returns the bit depth for the current screen mode \return Current number of bits per pixel @@ -722,6 +761,31 @@ void DisplayDriver::_SetBytesPerRow(uint32 bpr) _bytes_per_row=bpr; } +/*! + \brief Internal DPMS value-setting function + \param state The new capabilities of the driver + + _SetDPMSState must be called from within any implementation of SetDPMSState. Note that this + does not actually change the state itself; it just updates the state variable used + to talk with the outside world. +*/ +void DisplayDriver::_SetDPMSState(uint32 state) +{ + _dpms_caps=state; +} + +/*! + \brief Internal DPMS value-setting function + \param state The new capabilities of the driver + + _SetDPMSCapabilities must be called at the initialization of the driver so that + GetDPMSCapabilities returns the proper values. +*/ +void DisplayDriver::_SetDPMSCapabilities(uint32 caps) +{ + _dpms_caps=caps; +} + /*! \brief Obtains the current cursor for the driver. \return Pointer to the current cursor object. diff --git a/src/servers/app/server/DisplayDriver.h b/src/servers/app/server/DisplayDriver.h index de13755f2a..98962edbec 100644 --- a/src/servers/app/server/DisplayDriver.h +++ b/src/servers/app/server/DisplayDriver.h @@ -129,6 +129,7 @@ public: virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); virtual void SetMode(int32 mode); virtual bool DumpToFile(const char *path); + virtual ServerBitmap *DumpToBitmap(void); virtual float StringWidth(const char *string, int32 length, LayerData *d); virtual float StringHeight(const char *string, int32 length, LayerData *d); @@ -141,7 +142,10 @@ public: virtual void GetHasGlyphs(const char *string, int32 charcount, bool *hasarray); virtual void GetTruncatedStrings( const char **instrings, int32 stringcount, uint32 mode, float maxwidth, char **outstrings); - + + virtual status_t SetDPMSState(uint32 state); + uint32 GetDPMSState(void); + uint32 GetDPMSCapabilities(void); uint8 GetDepth(void); uint16 GetHeight(void); uint16 GetWidth(void); @@ -157,6 +161,8 @@ protected: void _SetWidth(uint16 w); void _SetMode(int32 m); void _SetBytesPerRow(uint32 bpr); + void _SetDPMSCapabilities(uint32 caps); + void _SetDPMSState(uint32 state); ServerCursor *_GetCursor(void); private: @@ -169,6 +175,8 @@ private: bool _is_cursor_hidden; bool _is_cursor_obscured; ServerCursor *_cursor; + uint32 _dpms_state; + uint32 _dpms_caps; }; #endif diff --git a/src/servers/app/server/Layer.cpp b/src/servers/app/server/Layer.cpp index b7c178167f..f05f891cdf 100644 --- a/src/servers/app/server/Layer.cpp +++ b/src/servers/app/server/Layer.cpp @@ -33,8 +33,9 @@ #include "ServerWindow.h" #include "PortLink.h" #include "TokenHandler.h" +#include "RectUtils.h" -//#define DEBUG_LAYER +#define DEBUG_LAYER //! TokenHandler object used to provide IDs for all Layers and, thus, BViews TokenHandler view_token_handler; @@ -78,6 +79,7 @@ Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWind _hidecount=0; _is_dirty=false; _is_updating=false; + _regions_invalid=false; _level=0; _layerdata=new LayerData; @@ -519,6 +521,78 @@ bool Layer::IsDirty(void) const return (!_invalid)?true:false; } +/*! + \brief Forces a repaint if there are invalid areas + \param force_update Force an update. False by default. +*/ +void Layer::UpdateIfNeeded(bool force_update) +{ +#ifdef DEBUG_LAYER +printf("Layer: %s: UpdateIfNeeded(%s)\n",_name->String(), + force_update?"force update":"don't force update"); +#endif + Layer *child; + + if(IsHidden()) + return; + + if(force_update) + { + if(_invalid) + RequestDraw(_invalid->Frame()); + else + RequestDraw(); + } + else + { + if(_invalid) + RequestDraw(_invalid->Frame()); + } + + for(child=_bottomchild; child!=NULL; child=child->_uppersibling) + child->UpdateIfNeeded(force_update); + _is_dirty=false; +} + +/*! + \brief Marks the layer as needing a region rebuild if intersecting the given rect + \param rect The rectangle for checking to see if the layer needs to be rebuilt +*/ +void Layer::MarkModified(BRect rect) +{ +#ifdef DEBUG_LAYER +printf("Layer: %s: MarkModified(%.1f%.1f,%.1f,%.1f)\n",_name->String(), + rect.left,rect.top,rect.right,rect.bottom); +#endif + if(TestRectIntersection(Bounds(),rect)) + _regions_invalid=true; + + Layer *child; + for(child=_bottomchild; child!=NULL; child=child->_uppersibling) + child->MarkModified(rect.OffsetByCopy(-child->_frame.left,-child->_frame.top)); +} + +/*! + \brief Rebuilds the layer's regions and updates the screen as needed + \param force Force an update +*/ +void Layer::UpdateRegions(bool force) +{ +#ifdef DEBUG_LAYER +printf("Layer: %s: UpdateRegions(%s)\n",_name->String(), + force?"force update":"don't force update"); +#endif + if(force) + { + RebuildRegions(true); +// MoveChildren(); +// InvalidateNewAreas(); + } + + if( (_regions_invalid && (_parent==NULL) && _invalid) || force) + UpdateIfNeeded(force); +} + //! Show the layer. Operates just like the BView call with the same name void Layer::Show(void) { @@ -529,14 +603,23 @@ printf("Layer: %s: Show\n",_name->String()); return; _hidecount--; - if(_hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(_visible)); - _parent->_visible->Exclude(reg); - delete reg; - _is_dirty=true; - } + + if(_hidecount>0) + return; + + BRegion *reg=new BRegion(ConvertToParent(_visible)); + _parent->_visible->Exclude(reg); + delete reg; + _is_dirty=true; + _parent->_is_dirty=true; + Layer *sibling; + for (sibling=_parent->_bottomchild; sibling!=NULL; sibling=sibling->_uppersibling) + { + if(TestRectIntersection(sibling->_frame,_frame)) + sibling->MarkModified(_frame.OffsetByCopy(-sibling->_frame.left,-sibling->_frame.top)); + } + Layer *child; for(child=_topchild; child!=NULL; child=child->_lowersibling) child->Show(); @@ -712,6 +795,7 @@ printf("Layer: %s: Rebuild Regions (%s)\n",_name->String(),include_children?"inc lay->RebuildRegions(true); } } + _regions_invalid=false; } //! Prints all relevant layer data to stdout diff --git a/src/servers/app/server/Layer.h b/src/servers/app/server/Layer.h index 04abbfa2fb..46e01174e4 100644 --- a/src/servers/app/server/Layer.h +++ b/src/servers/app/server/Layer.h @@ -72,6 +72,9 @@ public: virtual void RequestDraw(const BRect &r); virtual void RequestDraw(void); bool IsDirty(void) const; + void UpdateIfNeeded(bool force_update=false); + void MarkModified(BRect rect); + void UpdateRegions(bool force=false); void Show(void); void Hide(void); @@ -99,6 +102,7 @@ public: protected: friend RootLayer; friend WinBorder; + BRect _frame; @@ -121,6 +125,7 @@ protected: uint8 _hidecount; bool _is_dirty; bool _is_updating; + bool _regions_invalid; LayerData *_layerdata; PortLink *_portlink; }; diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 91eae33488..0be0f54513 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -185,7 +185,10 @@ void ServerWindow::Show(void) printf("ServerWindow %s: Show\n",_title->String()); #endif if(_winborder) + { _winborder->Show(); + _winborder->UpdateRegions(true); + } } //! Hides the window's WinBorder diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index 053dbba43a..f51bae2b2f 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -37,7 +37,7 @@ #include "WinBorder.h" #include "AppServer.h" // for new_decorator() -//#define DEBUG_WINBORDER +#define DEBUG_WINBORDER //#define DEBUG_WINBORDER_MOUSE #ifdef DEBUG_WINBORDER @@ -81,6 +81,8 @@ WinBorder::WinBorder(BRect r, const char *name, int32 look, int32 feel, int32 fl _vresizewin=false; _decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver()); + _decorator->SetDriver(GetGfxDriver()); + #ifdef DEBUG_WINBORDER printf("WinBorder %s:\n",_title->String()); printf("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom); @@ -311,20 +313,6 @@ printf("WinBorder %s: MouseUp unimplmented\n",_title->String()); */ } -void WinBorder::Draw(BRect update_rect) -{ -#ifdef DEBUG_WINBORDER -printf("WinBorder %s: Draw\n",_title->String()); -#endif - if(_update && _visible!=NULL) - _is_updating=true; - - _decorator->Draw(update_rect); - - if(_update && _visible!=NULL) - _is_updating=false; -} - void WinBorder::RequestDraw(const BRect &r) { #ifdef DEBUG_WINBORDER @@ -335,18 +323,10 @@ printf("WinBorder %s: RequestDraw\n",_title->String()); void WinBorder::RequestDraw(void) { - +#ifdef DEBUG_WINBORDER printf("WinBorder %s::RequestDraw\n",_title->String()); - if(_invalid) - { -//printf("drew something\n"); -// for(int32 i=0; iCountRects();i++) -// _decorator->Draw(ConvertToTop(invalid->RectAt(i))); - _decorator->Draw(); - delete _invalid; - _invalid=NULL; - _is_dirty=false; - } +#endif + _decorator->Draw(); } void WinBorder::MoveBy(BPoint pt) diff --git a/src/servers/app/server/WinBorder.h b/src/servers/app/server/WinBorder.h index b16f53cc51..769b42fdad 100644 --- a/src/servers/app/server/WinBorder.h +++ b/src/servers/app/server/WinBorder.h @@ -49,7 +49,6 @@ public: void MouseDown(int8 *buffer); void MouseMoved(int8 *buffer); void MouseUp(int8 *buffer); - void Draw(BRect update); void UpdateColors(void); void UpdateDecorator(void); void UpdateFont(void);