From 7d09d0620c21e9d0830ff62cb1062dc5b18b54ee Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Wed, 14 Jan 2004 00:54:45 +0000 Subject: [PATCH] Removed a couple of warnings from Accelerant, Screen, and BitmapDrivers Beginning style changes to resemble OpenTracker guidelines Added header to some files Removed temporary code from ViewDriver and re-enabled cursor movement in Desktopmouse message handler git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6069 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/AccelerantDriver.cpp | 11 +- src/servers/app/server/AccelerantDriver.h | 1 + src/servers/app/server/Angle.cpp | 66 +++++----- src/servers/app/server/Angle.h | 2 +- src/servers/app/server/AppServer.h | 81 ++++++------ src/servers/app/server/BitmapDriver.cpp | 6 + src/servers/app/server/BitmapDriver.h | 1 + src/servers/app/server/CursorManager.cpp | 31 ++--- src/servers/app/server/Desktop.cpp | 18 ++- src/servers/app/server/Desktop.h | 4 +- src/servers/app/server/FMWList.cpp | 115 +++++++++++++----- src/servers/app/server/FMWList.h | 58 ++++++--- src/servers/app/server/PNGDump.cpp | 26 ++++ src/servers/app/server/PNGDump.h | 26 ++++ src/servers/app/server/ScreenDriver.cpp | 39 ++++++ src/servers/app/server/ScreenDriver.h | 1 + .../app/server/SessionStreamReader.cpp | 62 +++++----- src/servers/app/server/SessionStreamReader.h | 9 +- src/servers/app/server/ViewDriver.cpp | 28 ++--- 19 files changed, 385 insertions(+), 200 deletions(-) diff --git a/src/servers/app/server/AccelerantDriver.cpp b/src/servers/app/server/AccelerantDriver.cpp index bc9bfeb2e5..121367302b 100644 --- a/src/servers/app/server/AccelerantDriver.cpp +++ b/src/servers/app/server/AccelerantDriver.cpp @@ -180,8 +180,9 @@ bool AccelerantDriver::Initialize(void) accShowCursor = (show_cursor)accelerant_hook(B_SHOW_CURSOR,NULL); #ifdef DRAW_TEST - RGBColor red(255,0,0,0); - RGBColor green(0,255,0,0); + // Commented out to remove a couple warnings +// RGBColor red(255,0,0,0); +// RGBColor green(0,255,0,0); RGBColor blue(0,0,255,0); FillRect(BRect(0,0,1024,768),blue); #endif @@ -1055,6 +1056,12 @@ void AccelerantDriver::SetMode(int32 mode) Unlock(); } +void AccelerantDriver::SetMode(const display_mode &mode) +{ + // TODO: Implement + +} + /*! \brief Dumps the contents of the frame buffer to a file. \param path Path and leaf of the file to be created without an extension diff --git a/src/servers/app/server/AccelerantDriver.h b/src/servers/app/server/AccelerantDriver.h index 61cb49ca4e..6e8e7b09a6 100644 --- a/src/servers/app/server/AccelerantDriver.h +++ b/src/servers/app/server/AccelerantDriver.h @@ -94,6 +94,7 @@ public: virtual void SetCursor(ServerCursor *csr); virtual void SetMode(int32 mode); + virtual void SetMode(const display_mode &mode); virtual bool DumpToFile(const char *path); float StringWidth(const char *string, int32 length, LayerData *d); float StringHeight(const char *string, int32 length, LayerData *d); diff --git a/src/servers/app/server/Angle.cpp b/src/servers/app/server/Angle.cpp index f76ea4966e..d1138ed440 100644 --- a/src/servers/app/server/Angle.cpp +++ b/src/servers/app/server/Angle.cpp @@ -40,7 +40,7 @@ float sintable[360], costable[360], tantable[360]; */ Angle::Angle(float angle) { - angle_value=angle; + fAngleValue=angle; if(tables_initialized==false) { InitTrigTables(); @@ -51,7 +51,7 @@ Angle::Angle(float angle) //! Constructor Angle::Angle(void) { - angle_value=0; + fAngleValue=0; if(tables_initialized==false) { InitTrigTables(); @@ -70,16 +70,16 @@ void Angle::Normalize(void) // if the value of the angle is >=360 or <0, make it so that it is // within those bounds - if(angle_value>359) + if(fAngleValue>359) { - while(angle_value>359) - angle_value-=360; + while(fAngleValue>359) + fAngleValue-=360; return; } - if(angle_value<0) + if(fAngleValue<0) { - while(angle_value<0) - angle_value+=360; + while(fAngleValue<0) + fAngleValue+=360; } } @@ -89,7 +89,7 @@ void Angle::Normalize(void) */ float Angle::Sine(void) { - return sintable[(int)angle_value]; + return sintable[(int)fAngleValue]; } /*! @@ -128,7 +128,7 @@ Angle Angle::InvSine(float value) */ float Angle::Cosine(void) { - return costable[(int)angle_value]; + return costable[(int)fAngleValue]; } /*! @@ -166,14 +166,14 @@ Angle Angle::InvCosine(float value) */ float Angle::Tangent(int *status) { - if(angle_value==90 || angle_value==270) + if(fAngleValue==90 || fAngleValue==270) { if(status) *status=0; return 0.0; } - return tantable[(int)angle_value]; + return tantable[(int)fAngleValue]; } /*! @@ -213,13 +213,13 @@ uint8 Angle::Quadrant(void) { // We can get away with not doing extra value checks because of the order in // which the checks are done. - if(angle_value < 90) + if(fAngleValue < 90) return 1; - if(angle_value < 180) + if(fAngleValue < 180) return 2; - if(angle_value < 270) + if(fAngleValue < 270) return 3; return 4; @@ -232,10 +232,10 @@ uint8 Angle::Quadrant(void) Angle Angle::Constrain180(void) { // Constrains angle to 0 <= angle < 180 - float val=angle_value; + float val=fAngleValue; - if(angle_value<180) - return Angle(angle_value); + if(fAngleValue<180) + return Angle(fAngleValue); while(!(val<180)) val-=90; @@ -249,10 +249,10 @@ Angle Angle::Constrain180(void) Angle Angle::Constrain90(void) { // Constrains angle to 0 <= angle < 90 - float val=angle_value; + float val=fAngleValue; - if(angle_value<90) - return Angle(angle_value); + if(fAngleValue<90) + return Angle(fAngleValue); while(!(val<90)) val-=90; @@ -265,7 +265,7 @@ Angle Angle::Constrain90(void) */ void Angle::SetValue(float angle) { - angle_value=angle; + fAngleValue=angle; Normalize(); } @@ -275,7 +275,7 @@ void Angle::SetValue(float angle) */ float Angle::Value(void) const { - return angle_value; + return fAngleValue; } //! Initializes the global trig tables @@ -319,7 +319,7 @@ void Angle::InitTrigTables(void) */ Angle & Angle::operator=(const Angle &from) { - angle_value=from.angle_value; + fAngleValue=from.fAngleValue; return *this; } @@ -330,7 +330,7 @@ Angle & Angle::operator=(const Angle &from) */ Angle & Angle::operator=(const float &from) { - angle_value=from; + fAngleValue=from; return *this; } @@ -341,7 +341,7 @@ Angle & Angle::operator=(const float &from) */ Angle & Angle::operator=(const long &from) { - angle_value=(float)from; + fAngleValue=(float)from; return *this; } @@ -352,7 +352,7 @@ Angle & Angle::operator=(const long &from) */ Angle & Angle::operator=(const int &from) { - angle_value=(float)from; + fAngleValue=(float)from; return *this; } @@ -363,7 +363,7 @@ Angle & Angle::operator=(const int &from) */ bool Angle::operator==(const Angle &from) { - return (angle_value==from.angle_value)?true:false; + return (fAngleValue==from.fAngleValue)?true:false; } /*! @@ -373,7 +373,7 @@ bool Angle::operator==(const Angle &from) */ bool Angle::operator!=(const Angle &from) { - return (angle_value!=from.angle_value)?true:false; + return (fAngleValue!=from.fAngleValue)?true:false; } /*! @@ -383,7 +383,7 @@ bool Angle::operator!=(const Angle &from) */ bool Angle::operator>(const Angle &from) { - return (angle_value>from.angle_value)?true:false; + return (fAngleValue>from.fAngleValue)?true:false; } /*! @@ -393,7 +393,7 @@ bool Angle::operator>(const Angle &from) */ bool Angle::operator<(const Angle &from) { - return (angle_value=(const Angle &from) { - return (angle_value>=from.angle_value)?true:false; + return (fAngleValue>=from.fAngleValue)?true:false; } /*! @@ -413,5 +413,5 @@ bool Angle::operator>=(const Angle &from) */ bool Angle::operator<=(const Angle &from) { - return (angle_value<=from.angle_value)?true:false; + return (fAngleValue<=from.fAngleValue)?true:false; } diff --git a/src/servers/app/server/Angle.h b/src/servers/app/server/Angle.h index 8506b6fc0a..5a7435911b 100644 --- a/src/servers/app/server/Angle.h +++ b/src/servers/app/server/Angle.h @@ -69,7 +69,7 @@ public: bool operator<=(const Angle &from); protected: - float angle_value; + float fAngleValue; void InitTrigTables(void); }; diff --git a/src/servers/app/server/AppServer.h b/src/servers/app/server/AppServer.h index 8e17ab8ad8..d7a75241db 100644 --- a/src/servers/app/server/AppServer.h +++ b/src/servers/app/server/AppServer.h @@ -34,52 +34,53 @@ class AppServer : public BApplication #endif { public: - AppServer(void); - ~AppServer(void); + AppServer(void); + ~AppServer(void); - 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); + + bool LoadDecorator(const char *path); + void InitDecorators(void); + + void DispatchMessage(PortMessage *msg); + void Broadcast(int32 code); - bool LoadDecorator(const char *path); - void InitDecorators(void); - - void DispatchMessage(PortMessage *msg); - void Broadcast(int32 code); // TODO: remove shortly! - void HandleKeyMessage(int32 code, int8 *buffer); - - ServerApp* FindApp(const char *sig); + void HandleKeyMessage(int32 code, int8 *buffer); + + ServerApp* FindApp(const char *sig); private: - friend Decorator* new_decorator(BRect rect, const char *title, - int32 wlook, int32 wfeel, - int32 wflags, DisplayDriver *ddriver); + friend Decorator* new_decorator(BRect rect, const char *title, + int32 wlook, int32 wfeel, int32 wflags, DisplayDriver *ddriver); - create_decorator *make_decorator; // global function pointer - - port_id _messageport, - _mouseport; - - image_id _decorator_id; - - BString decorator_name; - - bool _quitting_server, - _exit_poller; - - BList *_applist; - thread_id _poller_id, - _picasso_id; - - sem_id _active_lock, - _applist_lock, - _decor_lock; - - DisplayDriver *_driver; - - int32 _ssindex; + // global function pointer + create_decorator *make_decorator; + + port_id _messageport, + _mouseport; + + image_id _decorator_id; + + BString decorator_name; + + bool _quitting_server, + _exit_poller; + + BList *_applist; + thread_id _poller_id, + _picasso_id; + + sem_id _active_lock, + _applist_lock, + _decor_lock; + + DisplayDriver *_driver; + + int32 _ssindex; }; Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, diff --git a/src/servers/app/server/BitmapDriver.cpp b/src/servers/app/server/BitmapDriver.cpp index 5696912676..a92845a0b4 100644 --- a/src/servers/app/server/BitmapDriver.cpp +++ b/src/servers/app/server/BitmapDriver.cpp @@ -499,6 +499,12 @@ void BitmapDriver::SetMode(int32 space) // No need to reset a bitmap's color space } +//! Empty +void BitmapDriver::SetMode(const display_mode &mode) +{ + // No need to reset a bitmap's color space +} + //! Empty void BitmapDriver::HideCursor(void) { diff --git a/src/servers/app/server/BitmapDriver.h b/src/servers/app/server/BitmapDriver.h index fbdf8d3090..322562ae14 100644 --- a/src/servers/app/server/BitmapDriver.h +++ b/src/servers/app/server/BitmapDriver.h @@ -122,6 +122,7 @@ virtual void FillArc(const BRect r, float angle, float span, RGBColor& color); virtual void SetCursor(ServerCursor *cursor); virtual void SetMode(int32 mode); + virtual void SetMode(const display_mode &mode); float StringWidth(const char *string, int32 length, LayerData *d); float StringHeight(const char *string, int32 length, LayerData *d); // virtual bool DumpToFile(const char *path); diff --git a/src/servers/app/server/CursorManager.cpp b/src/servers/app/server/CursorManager.cpp index 4218e4fb64..1d6a80c998 100644 --- a/src/servers/app/server/CursorManager.cpp +++ b/src/servers/app/server/CursorManager.cpp @@ -29,6 +29,7 @@ #include "CursorManager.h" #include "ServerCursor.h" #include "CursorData.h" +#include "ServerScreen.h" #include "ServerConfig.h" #include #include @@ -177,37 +178,31 @@ void CursorManager::RemoveAppCursors(const char *signature) //! Wrapper around the DisplayDriver ShowCursor call void CursorManager::ShowCursor(void) { - // TODO: Fix -/* Lock(); + Lock(); - DisplayDriver *driver = desktop->CursorScreen()->DDriver(); + DisplayDriver *driver = desktop->ActiveScreen()->DDriver(); driver->ShowCursor(); Unlock(); -*/ } //! Wrapper around the DisplayDriver HideCursor call void CursorManager::HideCursor(void) { - // TODO: Fix -/* Lock(); + Lock(); - DisplayDriver *driver = desktop->CursorScreen()->DDriver(); + DisplayDriver *driver = desktop->ActiveScreen()->DDriver(); driver->HideCursor(); Unlock(); -*/ } //! Wrapper around the DisplayDriver ObscureCursor call void CursorManager::ObscureCursor(void) { - // TODO: Fix -/* Lock(); + Lock(); - DisplayDriver *driver = desktop->CursorScreen()->DDriver(); + DisplayDriver *driver = desktop->ActiveScreen()->DDriver(); driver->ObscureCursor(); Unlock(); -*/ } /*! @@ -216,25 +211,22 @@ void CursorManager::ObscureCursor(void) */ void CursorManager::SetCursor(int32 token) { - // TODO: Fix -/* Lock(); + Lock(); ServerCursor *c=_FindCursor(token); if(c) { - DisplayDriver *driver = desktop->CursorScreen()->DDriver(); + DisplayDriver *driver = desktop->ActiveScreen()->DDriver(); driver->SetCursor(c); _current_which=B_CURSOR_OTHER; } Unlock(); -*/ } void CursorManager::SetCursor(cursor_which which) { - // TODO: Fix -/* Lock(); + Lock(); - DisplayDriver *driver = desktop->CursorScreen()->DDriver(); + DisplayDriver *driver = desktop->ActiveScreen()->DDriver(); switch(which) { case B_CURSOR_DEFAULT: @@ -296,7 +288,6 @@ void CursorManager::SetCursor(cursor_which which) } Unlock(); -*/ } /*! diff --git a/src/servers/app/server/Desktop.cpp b/src/servers/app/server/Desktop.cpp index a11fd25ab9..cc4f26d25a 100644 --- a/src/servers/app/server/Desktop.cpp +++ b/src/servers/app/server/Desktop.cpp @@ -24,7 +24,7 @@ Desktop::Desktop(void){ fActiveRootLayer = NULL; fFrontWinBorder = NULL; fFocusWinBorder = NULL; - fCursorScreen = NULL; + fActiveScreen = NULL; } //--------------------------------------------------------------------------- Desktop::~Desktop(void){ @@ -92,7 +92,7 @@ void Desktop::Init(void){ //--------------------------------------------------------------------------- void Desktop::InitMode(void){ // this is init mode for n-SS. - fCursorScreen = fScreenList.ItemAt(0)? (Screen*)fScreenList.ItemAt(0): NULL; + fActiveScreen = fScreenList.ItemAt(0)? (Screen*)fScreenList.ItemAt(0): NULL; for (int32 i=0; iRead(&dummy); + msg->Read(&x); + msg->Read(&y); + + // We need this so that we can see the cursor on the screen + if(fActiveScreen) + fActiveScreen->DDriver()->MoveCursorTo(x,y); break; } case B_MOUSE_WHEEL_CHANGED:{ diff --git a/src/servers/app/server/Desktop.h b/src/servers/app/server/Desktop.h index 117e4f46cd..d537ad2e88 100644 --- a/src/servers/app/server/Desktop.h +++ b/src/servers/app/server/Desktop.h @@ -26,7 +26,7 @@ public: // Methods for multiple monitors. Screen* ScreenAt(int32 index) const; int32 ScreenCount() const; - Screen* CursorScreen() const; + Screen* ActiveScreen() const; void SetActiveRootLayerByIndex(int32 listIndex); void SetActiveRootLayer(RootLayer* rl); @@ -91,7 +91,7 @@ private: BList fScreenList; int32 fScreenMode; // '1' or 'n' Screen(s). Not sure it's needed though. - Screen* fCursorScreen; + Screen* fActiveScreen; scroll_bar_info fScrollBarInfo; menu_info fMenuInfo; diff --git a/src/servers/app/server/FMWList.cpp b/src/servers/app/server/FMWList.cpp index 926fb55675..055bd46103 100644 --- a/src/servers/app/server/FMWList.cpp +++ b/src/servers/app/server/FMWList.cpp @@ -1,4 +1,29 @@ - +//------------------------------------------------------------------------------ +// 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: FMWList.cpp +// Author: Adi Oanca +// Description: List class for something or other (according to DW) +// +//------------------------------------------------------------------------------ #include #include @@ -6,24 +31,29 @@ #include "WinBorder.h" #include "ServerWindow.h" -FMWList::FMWList(){ +FMWList::FMWList(void) +{ } -FMWList::~FMWList(){ -//printf("~FMWList()\n"); +FMWList::~FMWList(void) +{ +// printf("~FMWList()\n"); // if (fList.CountItems() > 0) // printf("SERVER: WARNING: FMWList NOT empty in destructor!\n"); } -void FMWList::AddItem(void* item){ - int32 feelItem = ((WinBorder*)item)->Window()->Feel();; - int32 feelTemp = 0; - int32 location = 0; +void FMWList::AddItem(void *item) +{ + int32 feelItem = ((WinBorder*)item)->Window()->Feel();; + int32 feelTemp = 0; + int32 location = 0; - for(int32 i=0; iWindow()->Feel(); - // in short: if 'item' is a floating window + + // in short: if 'item' is a floating window if( (feelItem == B_FLOATING_SUBSET_WINDOW_FEEL || feelItem == B_FLOATING_APP_WINDOW_FEEL || feelItem == B_FLOATING_ALL_WINDOW_FEEL) @@ -32,44 +62,56 @@ void FMWList::AddItem(void* item){ feelTemp == B_MODAL_APP_WINDOW_FEEL || feelTemp == B_MODAL_ALL_WINDOW_FEEL) ) - // means we found the place for our window('wb') - { location--; break; } + // means we found the place for our window('wb') + { + location--; + break; + } } fList.AddItem(item, location); } -bool FMWList::HasItem(void* item) const{ +bool FMWList::HasItem(void *item) const +{ return fList.HasItem(item); } -bool FMWList::RemoveItem(void* item){ +bool FMWList::RemoveItem(void *item) +{ return fList.RemoveItem(item); } -void* FMWList::ItemAt(int32 i) const{ +void *FMWList::ItemAt(int32 i) const +{ return fList.ItemAt(i); } -int32 FMWList::CountItems() const{ +int32 FMWList::CountItems() const +{ return fList.CountItems(); } -void* FMWList::LastItem() const{ +void *FMWList::LastItem() const +{ return fList.LastItem(); } -void* FMWList::FirstItem() const{ +void *FMWList::FirstItem() const +{ return fList.FirstItem(); } -int32 FMWList::IndexOf(void *item){ +int32 FMWList::IndexOf(void *item) +{ return fList.IndexOf(item); } -void FMWList::AddFMWList(FMWList *list){ - int32 i = 0; - for(i=0; iWindow()->Feel(); +void FMWList::AddFMWList(FMWList *list) +{ + int32 i=0; + for(i=0; iWindow()->Feel(); if(feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_MODAL_APP_WINDOW_FEEL || feel == B_MODAL_ALL_WINDOW_FEEL) @@ -79,42 +121,53 @@ void FMWList::AddFMWList(FMWList *list){ } int32 j = 0; - for(j=0; jCountItems(); j++){ - void *item = list->ItemAt(j); - int32 feel = ((WinBorder*)item)->Window()->Feel(); + for(j=0; jCountItems(); j++) + { + void *item = list->ItemAt(j); + int32 feel = ((WinBorder*)item)->Window()->Feel(); if(feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_MODAL_APP_WINDOW_FEEL || feel == B_MODAL_ALL_WINDOW_FEEL) { fList.AddItem(item, fList.CountItems()); } - else{ + else + { fList.AddItem(item, i); i++; } } } -void FMWList::PrintToStream() const{ +void FMWList::PrintToStream() const +{ printf("Floating and modal windows list:\n"); WinBorder *wb = NULL; - for (int32 i=0; iGetName()); + if (wb->Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL) printf("\t%s\n", "B_FLOATING_SUBSET_WINDOW_FEEL"); + if (wb->Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL) printf("\t%s\n", "B_FLOATING_APP_WINDOW_FEEL"); + if (wb->Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL) printf("\t%s\n", "B_FLOATING_ALL_WINDOW_FEEL"); + if (wb->Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL) printf("\t%s\n", "B_MODAL_SUBSET_WINDOW_FEEL"); + if (wb->Window()->Feel() == B_MODAL_APP_WINDOW_FEEL) printf("\t%s\n", "B_MODAL_APP_WINDOW_FEEL"); + if (wb->Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL) printf("\t%s\n", "B_MODAL_ALL_WINDOW_FEEL"); - // this should NOT happen + // this should NOT happen if (wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL) printf("\t%s\n", "B_NORMAL_WINDOW_FEEL"); } diff --git a/src/servers/app/server/FMWList.h b/src/servers/app/server/FMWList.h index f054e302de..9dd6d4d57d 100644 --- a/src/servers/app/server/FMWList.h +++ b/src/servers/app/server/FMWList.h @@ -1,29 +1,57 @@ +//------------------------------------------------------------------------------ +// 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: FMWList.h +// Author: Adi Oanca +// Description: List class for something or other (according to DW) +// +//------------------------------------------------------------------------------ #ifndef _FMWLIST_H_ #define _FMWLIST_H_ #include #include -class FMWList{ +class FMWList +{ public: - FMWList(); - virtual ~FMWList(); - void AddItem(void* item); - bool HasItem(void* item) const; - bool RemoveItem(void* item); - void* ItemAt(int32 i) const; - int32 CountItems() const; - void* LastItem() const; - void* FirstItem() const; - int32 IndexOf(void *item); + FMWList(void); + virtual ~FMWList(void); + void AddItem(void *item); + bool HasItem(void *item) const; + bool RemoveItem(void* item); + void *ItemAt(int32 i) const; + int32 CountItems(void) const; + void *LastItem(void) const; + void *FirstItem(void) const; + int32 IndexOf(void *item); + // special - void AddFMWList(FMWList *list); + void AddFMWList(FMWList *list); + // debugging methods - void PrintToStream() const; + void PrintToStream() const; private: - - BList fList; + BList fList; }; #endif diff --git a/src/servers/app/server/PNGDump.cpp b/src/servers/app/server/PNGDump.cpp index fd633bf2a7..51ed7aa724 100644 --- a/src/servers/app/server/PNGDump.cpp +++ b/src/servers/app/server/PNGDump.cpp @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// 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: PNGDump.cpp +// Author: DarkWyrm +// Description: Function for saving a generic framebuffer to a PNG file +// +//------------------------------------------------------------------------------ #include #include #include diff --git a/src/servers/app/server/PNGDump.h b/src/servers/app/server/PNGDump.h index 17b4adaf5a..abfc736276 100644 --- a/src/servers/app/server/PNGDump.h +++ b/src/servers/app/server/PNGDump.h @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// 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: PNGDump.H +// Author: DarkWyrm +// Description: Function for saving a generic framebuffer to a PNG file +// +//------------------------------------------------------------------------------ #ifndef PNGDUMP_H #define PNGDUMP_H diff --git a/src/servers/app/server/ScreenDriver.cpp b/src/servers/app/server/ScreenDriver.cpp index ac53c29062..e85eb05a91 100644 --- a/src/servers/app/server/ScreenDriver.cpp +++ b/src/servers/app/server/ScreenDriver.cpp @@ -365,6 +365,45 @@ void ScreenDriver::Shutdown(void) Unlock(); } +void ScreenDriver::SetMode(const display_mode &mode) +{ + screenwin->Lock(); + int16 w=mode.virtual_width,h=mode.virtual_height; + color_space s=(color_space)mode.space; + + screenwin->ResizeTo(w-1,h-1); + + // Clear the invalid flag so that there is no danger of a crash + while(screenwin->invalidflag>0) + atomic_add(&screenwin->invalidflag,-1); + + delete framebuffer; + + // don't forget to update the internal vars! + _SetWidth(w); + _SetHeight(h); + _SetMode(s); + + screenwin->SetSpace((uint32)s); + + screenwin->viewbmp=new BBitmap(screenwin->Bounds(),s,true); + framebuffer=screenwin->viewbmp; + drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); + framebuffer->AddChild(drawview); + + framebuffer->Lock(); + drawview->SetHighColor(workspace_default_color.GetColor32()); + drawview->FillRect(drawview->Bounds()); + drawview->Sync(); + framebuffer->Unlock(); + + screenwin->Invalidate(framebuffer->Bounds()); + + _SetBytesPerRow(framebuffer->BytesPerRow()); + atomic_add(&screenwin->invalidflag,1); + screenwin->Unlock(); +} + void ScreenDriver::SetMode(int32 space) { screenwin->Lock(); diff --git a/src/servers/app/server/ScreenDriver.h b/src/servers/app/server/ScreenDriver.h index b404226486..b0464e3546 100644 --- a/src/servers/app/server/ScreenDriver.h +++ b/src/servers/app/server/ScreenDriver.h @@ -177,6 +177,7 @@ public: // void StrokeShape(SShape *sh, LayerData *d, const Pattern &pat); void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, const Pattern &pat); void SetMode(int32 mode); + void SetMode(const display_mode &mode); float StringWidth(const char *string, int32 length, LayerData *d); float StringHeight(const char *string, int32 length, LayerData *d); bool DumpToFile(const char *path); diff --git a/src/servers/app/server/SessionStreamReader.cpp b/src/servers/app/server/SessionStreamReader.cpp index 048e3e0c52..d12ed1a6e3 100644 --- a/src/servers/app/server/SessionStreamReader.cpp +++ b/src/servers/app/server/SessionStreamReader.cpp @@ -23,9 +23,7 @@ // Author: DarkWyrm // Description: Reader for BSession message streams // -// //------------------------------------------------------------------------------ - #include #include "SessionStreamReader.h" @@ -52,26 +50,26 @@ void SessionMessage::SetData(const int32 &code, void *buffer, size_t buffersize) SessionStreamReader::SessionStreamReader(msg_dispatcher_func *func) { - _buffer=NULL; - _dispatcher=func; - _msgsize=0; - _msgcode=0; - _currentbuffersize=0; + fBuffer=NULL; + fDispatcherFunc=func; + fMsgSize=0; + fMsgCode=0; + fCurrentBufferSize=0; } SessionStreamReader::~SessionStreamReader(void) { - if(_buffer) + if(fBuffer) { printf("DEBUG: Deleting non-empty SessionStreamReader!\n"); - delete _buffer; + delete fBuffer; } } void SessionStreamReader::DispatchMessages(void *msgbuffer, size_t buffersize) { // This is the main functionality of the stream reader - it takes a BSession message buffer - // and reads as much as it can. The entire function centers around _buffer. If _buffer is + // and reads as much as it can. The entire function centers around fBuffer. If fBuffer is // NULL, then the stream reader is not waiting on the completion of a message. if(!msgbuffer || buffersize==0) @@ -82,34 +80,34 @@ void SessionStreamReader::DispatchMessages(void *msgbuffer, size_t buffersize) // do we have a message waiting to be completed? while(index<((int8*)msgbuffer+buffersize)) { - if(_buffer) + if(fBuffer) { // We need to see if the data we have received in this call // will complete the message or not - if(_currentbuffersize+buffersize>_msgsize) + if(fCurrentBufferSize+buffersize>fMsgSize) { // It will, so copy the data to the current location in the buffer (indicated by - // _currentbuffersize), call the Dispatch function, make the SSR empty, and iterate + // fCurrentBufferSize), call the Dispatch function, make the SSR empty, and iterate - memcpy(_buffer+_currentbuffersize, msgbuffer, _msgsize-_currentbuffersize); - index+=_msgsize-_currentbuffersize; + memcpy(fBuffer+fCurrentBufferSize, msgbuffer, fMsgSize-fCurrentBufferSize); + index+=fMsgSize-fCurrentBufferSize; - _msg.SetData(_msgcode,_buffer,_msgsize); - (*_dispatcher)(&_msg); + fSessionMessage.SetData(fMsgCode,fBuffer,fMsgSize); + (*fDispatcherFunc)(&fSessionMessage); - delete _buffer; - _buffer=NULL; - _currentbuffersize=0; - _msgsize=0; - _msgcode=0; + delete fBuffer; + fBuffer=NULL; + fCurrentBufferSize=0; + fMsgSize=0; + fMsgCode=0; continue; } else { // We will not be completing the message here, so simply copy the buffer and exit - memcpy(_buffer+_currentbuffersize, msgbuffer, buffersize); - _currentbuffersize+=buffersize; + memcpy(fBuffer+fCurrentBufferSize, msgbuffer, buffersize); + fCurrentBufferSize+=buffersize; break; } @@ -117,16 +115,16 @@ void SessionStreamReader::DispatchMessages(void *msgbuffer, size_t buffersize) else { // Get basic message data - _msgcode=*((int32*)index); index+=sizeof(int32); - _msgsize=*((int32*)index); index+=sizeof(int32); + fMsgCode=*((int32*)index); index+=sizeof(int32); + fMsgSize=*((int32*)index); index+=sizeof(int32); // Now that we have basic stuff for the message, let's see if it is complete - if((index+_msgsize)>((int8*)msgbuffer+buffersize)) + if((index+fMsgSize)>((int8*)msgbuffer+buffersize)) { // We have an incomplete message. Allocate a buffer to contain all attached // data, copy it over, and exit - _buffer=new int8[_msgsize]; - memcpy(_buffer, msgbuffer, ((int8*)msgbuffer+buffersize)-index); + fBuffer=new int8[fMsgSize]; + memcpy(fBuffer, msgbuffer, ((int8*)msgbuffer+buffersize)-index); break; } else @@ -134,9 +132,9 @@ void SessionStreamReader::DispatchMessages(void *msgbuffer, size_t buffersize) // This message is complete, so set the appropriate SessionMessage data and // call the Dispatch function - _msg.SetData(_msgcode,index,_msgsize); - (*_dispatcher)(&_msg); - index+=_msgsize; + fSessionMessage.SetData(fMsgCode,index,fMsgSize); + (*fDispatcherFunc)(&fSessionMessage); + index+=fMsgSize; } } } diff --git a/src/servers/app/server/SessionStreamReader.h b/src/servers/app/server/SessionStreamReader.h index 7d1a143002..a89733d87a 100644 --- a/src/servers/app/server/SessionStreamReader.h +++ b/src/servers/app/server/SessionStreamReader.h @@ -47,11 +47,12 @@ public: SessionStreamReader(msg_dispatcher_func *func); ~SessionStreamReader(void); void DispatchMessages(void *msgbuffer, size_t buffersize); + protected: - int8 *_buffer; - uint32 _msgsize,_msgcode, _currentbuffersize; - msg_dispatcher_func *_dispatcher; - SessionMessage _msg; + int8 *fBuffer; + uint32 fMsgSize,fMsgCode, fCurrentBufferSize; + msg_dispatcher_func *fDispatcherFunc; + SessionMessage fSessionMessage; }; #endif diff --git a/src/servers/app/server/ViewDriver.cpp b/src/servers/app/server/ViewDriver.cpp index d58384e4e3..094d296d15 100644 --- a/src/servers/app/server/ViewDriver.cpp +++ b/src/servers/app/server/ViewDriver.cpp @@ -52,10 +52,6 @@ #include "LayerData.h" #include "PNGDump.h" -// TODO: remove later!!!!!!! -#include -#include "CursorData.h" - #ifdef DEBUG_DRIVER_MODULE # include # define STRACE(x) printf x @@ -74,8 +70,6 @@ VDWIN_MOVECURSOR, VDWIN_SETCURSOR, }; -//ViewDriver *viewdriver_global; - extern RGBColor workspace_default_color; @@ -86,9 +80,7 @@ VDView::VDView(BRect bounds) viewbmp=new BBitmap(bounds,B_CMAP8,true); // This link for sending mouse messages to the OBAppServer. - // This is only to take the place of the Input Server. I suppose I could write - // an addon filter to be more like the Input Server, but then I wouldn't be working - // on this thing! :P + // This is only to take the place of the Input Server. serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); // Create a cursor which isn't just a box @@ -512,14 +504,11 @@ bool VDWindow::QuitRequested(void) void VDWindow::WindowActivated(bool active) { // This is just to hide the regular system cursor so we can see our own -// TODO: REactivate later!!!! -/* if(active) + + if(active) be_app->HideCursor(); else be_app->ShowCursor(); -*/ - BCursor cursor(default_cursor_data); - view->SetViewCursor(&cursor, true); } //----------------------------------------------------------------------- @@ -534,7 +523,6 @@ void VDWindow::WindowActivated(bool active) ViewDriver::ViewDriver(void) { -// viewdriver_global=this; screenwin=new VDWindow(); framebuffer=screenwin->view->viewbmp; serverlink=screenwin->view->serverlink; @@ -544,6 +532,16 @@ ViewDriver::ViewDriver(void) _SetDepth(8); _SetMode(B_8_BIT_640x480); _SetBytesPerRow(framebuffer->BytesPerRow()); + + // We add this because if we see the default workspace color, then we have at least + // a reasonable idea that everything is kosher. + framebuffer->Lock(); + drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); + framebuffer->AddChild(drawview); + drawview->SetHighColor(workspace_default_color.GetColor32()); + drawview->FillRect(drawview->Bounds()); + drawview->Sync(); + framebuffer->Unlock(); } ViewDriver::~ViewDriver(void)