diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index 71887b6baf..b81caa9423 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -30,6 +30,9 @@ #include #include #include + +#include + #include #include #include "AppServer.h" @@ -88,10 +91,10 @@ AppServer::AppServer(void) // Used for testing purposes // TODO: Uncomment when actually put to use. Commented out for speed -// fontserver->ScanDirectory("/boot/beos/etc/fonts/ttfonts/"); + fontserver->ScanDirectory("/boot/beos/etc/fonts/ttfonts/"); // fontserver->ScanDirectory("/boot/beos/etc/fonts/PS-Type1/"); - fontserver->ScanDirectory("/boot/home/config/fonts/ttfonts/"); - fontserver->ScanDirectory("/boot/home/config/fonts/psfonts/"); +// fontserver->ScanDirectory("/boot/home/config/fonts/ttfonts/"); +// fontserver->ScanDirectory("/boot/home/config/fonts/psfonts/"); fontserver->SaveList(); if(!fontserver->SetSystemPlain(DEFAULT_PLAIN_FONT_FAMILY,DEFAULT_PLAIN_FONT_STYLE,DEFAULT_PLAIN_FONT_SIZE)) @@ -641,6 +644,10 @@ void AppServer::Broadcast(int32 code) { int32 i; ServerApp *app; + + int32 buffer[2]; + buffer[0] = 8; // 4 for buffer size + 4 for our message + buffer[1] = AS_QUIT_APP; acquire_sem(_applist_lock); for(i=0;i<_applist->CountItems(); i++) @@ -648,7 +655,8 @@ void AppServer::Broadcast(int32 code) app=(ServerApp*)_applist->ItemAt(i); if(!app) continue; - app->PostMessage(code); + //app->PostMessage(code); + app->PostMessage(AS_SESSION_MSG, 2*sizeof(int32), (int8*)&buffer); } release_sem(_applist_lock); } diff --git a/src/servers/app/server/Decorator.cpp b/src/servers/app/server/Decorator.cpp index 134df22592..e7a9398b32 100644 --- a/src/servers/app/server/Decorator.cpp +++ b/src/servers/app/server/Decorator.cpp @@ -29,6 +29,8 @@ #include "Decorator.h" #include "DisplayDriver.h" +#include + /*! \brief Constructor \param rect Size of client area @@ -48,12 +50,20 @@ Decorator::Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags) _title_string=new BString; _driver=NULL; - _closerect.Set(0,0,1,1); - _zoomrect.Set(0,0,1,1); - _minimizerect.Set(0,0,1,1); - _resizerect.Set(0,0,1,1); + /// xxx.Set(0,0,1,1) produces a rectangle 2 pixels wide, that + // WILL be drawn on screen. We so not want that... so... + // [ A BRect when instantiated is made invalid, so, no need for: ] +/* _closerect.Set( 0, 0, -1, -1); + _zoomrect.Set( 0, 0, -1, -1); + _minimizerect.Set( 0, 0, -1, -1); + _resizerect.Set( 0, 0, -1, -1); +*/ _frame=rect; - _tabrect.Set(rect.left,rect.top,rect.right, rect.top+((rect.bottom-rect.top)/4)); + // !!! rect rectangle MUST remain intact - it is top_view's area !!! + // Decorator drawing MUST be done arround that area !!! + //_tabrect.Set(rect.left,rect.top,rect.right, rect.top+((rect.bottom-rect.top)/4)); + // [ A BRect when instantiated is made invalid, so, no need for: ] +/* _tabrect.Set( 0, 0, -1, -1 ); */ _look=wlook; _feel=wfeel; @@ -260,6 +270,24 @@ const char *Decorator::GetTitle(void) return _title_string->String(); } +/*! + \brief Returns the decorator's border rectangle + \return the decorator's border rectangle +*/ + +BRect Decorator::GetBorderRect(void){ + return _borderrect; +} + +/*! + \brief Returns the decorator's tab rectangle + \return the decorator's tab rectangle +*/ + +BRect Decorator::GetTabRect(void){ + return _tabrect; +} + /*! \brief Changes the focus value of the decorator \param is_active True if active, false if not @@ -284,13 +312,15 @@ int32 Decorator::_ClipTitle(float width) { int32 strlength=_title_string->CountChars(); float pixwidth=_driver->StringWidth(_title_string->String(),strlength,&_layerdata); - +// printf("Initial width = %f\n", width ); +// printf("DEC: strlen = %ld\t pixwidth = %f\n", strlength, pixwidth); while(strlength>=0) { if(pixwidthStringWidth(_title_string->String(),strlength,&_layerdata); +// printf("DEC: strlen = %ld\t pixwidth = %f\n", strlength, pixwidth); } return strlength; diff --git a/src/servers/app/server/DefaultDecorator.cpp b/src/servers/app/server/DefaultDecorator.cpp index 5db23eb899..dbff476e3f 100644 --- a/src/servers/app/server/DefaultDecorator.cpp +++ b/src/servers/app/server/DefaultDecorator.cpp @@ -37,6 +37,8 @@ #define USE_VIEW_FILL_HACK +//#define DEBUG_DECORATOR + #ifdef DEBUG_DECORATOR #include #endif @@ -171,16 +173,7 @@ printf("DefaultDecorator: Do Layout\n"); #endif // Here we determine the size of every rectangle that we use // internally when we are given the size of the client rectangle. - - // Current version simply makes everything fit inside the rect - // instead of building around it. This will change. - - _tabrect=_frame; - _resizerect=_frame; - _borderrect=_frame; - _closerect=_frame; - switch(GetLook()) { case B_FLOATING_WINDOW_LOOK: @@ -194,11 +187,98 @@ printf("DefaultDecorator: Do Layout\n"); case B_BORDERED_WINDOW_LOOK: case B_TITLED_WINDOW_LOOK: case B_DOCUMENT_WINDOW_LOOK: - borderwidth=5; + borderwidth = 5; break; default: - borderwidth=0; + borderwidth = 0; } + + // Current version simply makes everything fit inside the rect + // instead of building around it. This will change. + + // IT did :-) + // distance from one item of the tab bar to another. In this case the text and close/zoom rects + textoffset = (_look==B_FLOATING_WINDOW_LOOK) ? 7 : 10; + + // calculate or tab rect + _tabrect.Set( _frame.left - borderwidth, + _frame.top - borderwidth - 19.0, + ((_frame.right - _frame.left) < 35.0 ? + _frame.left + 35.0 : _frame.right) + borderwidth, + _frame.top - (borderwidth-1) ); + + // make it text width sensitive + if(strlen(GetTitle())>1) + { + if(_driver) + titlepixelwidth=_driver->StringWidth(GetTitle(),_TitleWidth(), &_layerdata); + else + titlepixelwidth=10; + + int32 tabLength = 14 + // _closerect width + textoffset + titlepixelwidth + textoffset + + 14 + // _zoomrect width + 8; // margins + int32 tabWidth = (int32)_tabrect.Width(); + if ( tabLength < tabWidth ) + _tabrect.right = _tabrect.left + tabLength; + } + else + _tabrect.right = _tabrect.left + _tabrect.Width()/2; + + // calculate left/top/right/bottom borders + if ( borderwidth != 0 ){ + _borderrect = _frame.InsetByCopy( -borderwidth, -borderwidth ); + leftborder.Set( _borderrect.left, _frame.top - borderwidth, + _frame.left, _frame.bottom + borderwidth ); + rightborder.Set( _frame.right, _frame.top - borderwidth, + _borderrect.right, _frame.bottom + borderwidth ); + topborder.Set( _borderrect.left, _borderrect.top, + _borderrect.right, _frame.top ); + bottomborder.Set( _borderrect.left, _frame.bottom, + _borderrect.right, _borderrect.bottom ); + } + else{ + // no border ... (?) useful when displaying windows that are just images + _borderrect = _frame; + leftborder.Set( 0.0, 0.0, -1.0, -1.0 ); + rightborder.Set( 0.0, 0.0, -1.0, -1.0 ); + topborder.Set( 0.0, 0.0, -1.0, -1.0 ); + bottomborder.Set( 0.0, 0.0, -1.0, -1.0 ); + } + + // calculate resize rect + _resizerect.Set( _borderrect.right - 19.0, _borderrect.bottom - 19.0, + _borderrect.right, _borderrect.bottom); + + // format tab rect for a floating window - make te rect smaller + if ( _look == B_FLOATING_WINDOW_LOOK ){ + _tabrect.InsetBy( 0, 2 ); + _tabrect.OffsetBy( 0, 2 ); + } + + // calulate close rect based on the tab rectangle + _closerect.Set( _tabrect.left + 4.0, _tabrect.top + 4.0, + _tabrect.left + 4.0 + 13.0, _tabrect.top + 4.0 + 13.0 ); + + // calulate zoom rect based on the tab rectangle + _zoomrect.Set( _tabrect.right - 4.0 - 13.0, _tabrect.top + 4.0, + _tabrect.right - 4.0, _tabrect.top + 4.0 + 13.0 ); + + // fromat close and zoom rects for a floating window - make rectangles smaller + if ( _look == B_FLOATING_WINDOW_LOOK ){ + _closerect.InsetBy( 1, 1 ); + _zoomrect.InsetBy( 1, 1 ); + _closerect.OffsetBy( 0, -2 ); + _zoomrect.OffsetBy( 0, -2 ); + } +// Old version... +/* + _tabrect=_frame; + _resizerect=_frame; + _borderrect=_frame; + _closerect=_frame; + textoffset=(_look==B_FLOATING_WINDOW_LOOK)?5:7; @@ -249,7 +329,7 @@ printf("DefaultDecorator: Do Layout\n"); _zoomrect.bottom-=4; _zoomrect.left=_zoomrect.right-10; _zoomrect.bottom=_zoomrect.top+10; - +*/ } void DefaultDecorator::MoveBy(float x, float y) @@ -269,6 +349,13 @@ printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y); _resizerect.OffsetBy(pt); _borderrect.OffsetBy(pt); _zoomrect.OffsetBy(pt); + + leftborder.OffsetBy(pt); + rightborder.OffsetBy(pt); + topborder.OffsetBy(pt); + bottomborder.OffsetBy(pt); + + Draw( _borderrect ); } BRegion * DefaultDecorator::GetFootprint(void) @@ -287,13 +374,15 @@ printf("DefaultDecorator: Get Footprint\n"); void DefaultDecorator::_DrawTitle(BRect r) { +printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom); // Designed simply to redraw the title when it has changed on // the client side. _layerdata.highcolor=_colors->window_tab_text; _layerdata.lowcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab; - int32 titlecount=_ClipTitle((_zoomrect.left-5)-(_closerect.right+textoffset)); - BString titlestr=GetTitle(); + int32 titlecount=_ClipTitle((_zoomrect.left-textoffset)-(_closerect.right+textoffset)); + BString titlestr( GetTitle() ); + if(titlecountDrawString(titlestr.String(),titlecount, - BPoint(_closerect.right+textoffset,_closerect.bottom+1),&_layerdata); + BPoint(_closerect.right+textoffset,_closerect.bottom-1),&_layerdata); } void DefaultDecorator::_SetFocus(void) @@ -311,14 +400,20 @@ void DefaultDecorator::_SetFocus(void) if(GetFocus()) { - button_highcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_LIGHTEN_2_TINT)); - button_lowcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_DARKEN_2_TINT)); +// ADI: a temporary hack - the colors were TOO dark +// button_highcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_LIGHTEN_2_TINT)); +// button_lowcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_DARKEN_2_TINT)); + button_highcol.SetColor( RGBColor( 255, 255, 0 ) ); + button_lowcol.SetColor( RGBColor( 234, 181, 0) ); textcol=_colors->window_tab_text; } else { - button_highcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_LIGHTEN_2_TINT)); - button_lowcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_DARKEN_2_TINT)); +// ADI: a temporary hack - the colors were TOO dark +// button_highcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_LIGHTEN_2_TINT)); +// button_lowcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_DARKEN_2_TINT)); + button_highcol.SetColor( RGBColor(234, 181, 0) ); + button_lowcol.SetColor( RGBColor( 255, 255, 0 ) ); textcol=_colors->inactive_window_tab_text; } } @@ -331,16 +426,14 @@ printf("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,up // We need to draw a few things: the tab, the resize thumb, the borders, // and the buttons - _DrawTab(update); - // Draw the top view's client area - just a hack :) _layerdata.highcolor=_colors->document_background; - +/* if(_borderrect.Intersects(update)) _driver->FillRect(_borderrect & update,&_layerdata,pat_solidhigh); - +*/ _DrawFrame(update); - + _DrawTab(update); } void DefaultDecorator::Draw(void) @@ -360,24 +453,31 @@ void DefaultDecorator::Draw(void) void DefaultDecorator::_DrawZoom(BRect r) { +printf("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom); // If this has been implemented, then the decorator has a Zoom button // which should be drawn based on the state of the member zoomstate - BRect zr=r; - zr.left+=zr.Width()/3; - zr.top+=zr.Height()/3; - - DrawBlendedRect(zr,GetZoom()); - DrawBlendedRect(zr.OffsetToCopy(r.LeftTop()),GetZoom()); + BRect zr( r ); + + zr.left += 3.0; + zr.top += 3.0; + DrawBlendedRect( zr, GetZoom() ); + + zr = r; + zr.right -= 5.0; + zr.bottom -= 5.0; + DrawBlendedRect( zr, GetZoom() ); } void DefaultDecorator::_DrawClose(BRect r) { +printf("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom); // Just like DrawZoom, but for a close button - DrawBlendedRect(r,GetClose()); + DrawBlendedRect( r, GetClose()); } void DefaultDecorator::_DrawTab(BRect r) { +printf("_DrawTab(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom); // If a window has a tab, this will draw it and any buttons which are // in it. if(_look==B_NO_BORDER_WINDOW_LOOK) @@ -385,8 +485,30 @@ void DefaultDecorator::_DrawTab(BRect r) _layerdata.highcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab; _driver->FillRect(_tabrect,&_layerdata,pat_solidhigh); - _layerdata.highcolor=framecolors[3]; - _driver->StrokeLine(_tabrect.LeftBottom(),_tabrect.RightBottom(),&_layerdata,pat_solidhigh); + + _layerdata.highcolor=framecolors[2]; + _driver->StrokeLine(_tabrect.LeftTop(),_tabrect.LeftBottom(),&_layerdata,pat_solidhigh); + _driver->StrokeLine(_tabrect.LeftTop(),_tabrect.RightTop(),&_layerdata,pat_solidhigh); + _layerdata.highcolor=framecolors[4]; + _driver->StrokeLine(_tabrect.RightTop(),_tabrect.RightBottom(),&_layerdata,pat_solidhigh); + _layerdata.highcolor=framecolors[1]; + _driver->StrokeLine( BPoint( _tabrect.left + 2, _tabrect.bottom ), + BPoint( _tabrect.right - 2, _tabrect.bottom ), + &_layerdata,pat_solidhigh); + + _layerdata.highcolor = RGBColor( 255, 255, 0 ); + _driver->StrokeLine( BPoint( _tabrect.left + 1, _tabrect.top + 1), + BPoint( _tabrect.left + 1, _tabrect.bottom), + &_layerdata, pat_solidhigh); + _driver->StrokeLine( BPoint( _tabrect.left + 1, _tabrect.top + 1), + BPoint( _tabrect.right - 1, _tabrect.top + 1), + &_layerdata, pat_solidhigh); + + _layerdata.highcolor = RGBColor( 175, 123, 0 ); + _driver->StrokeLine( BPoint( _tabrect.right - 1, _tabrect.top + 2), + BPoint( _tabrect.right - 1, _tabrect.bottom), + &_layerdata, pat_solidhigh); + _DrawTitle(_tabrect); @@ -408,7 +530,28 @@ void DefaultDecorator::DrawBlendedRect(BRect r, bool down) // Note that it is not part of the Decorator API - it's specific // to just the DefaultDecorator. Called by DrawZoom and DrawClose - // Actually just draws a blended square + _layerdata.highcolor = RGBColor( 175, 123, 0 ); + _driver->StrokeLine( r.LeftTop(), + BPoint( r.left, r.bottom - 1 ), + &_layerdata, pat_solidhigh); + _driver->StrokeLine( r.LeftTop(), + BPoint( r.right - 1, r.top ), + &_layerdata, pat_solidhigh); + _driver->StrokeLine( BPoint( r.right - 1, r.top + 2), + BPoint( r.right - 1, r.bottom - 1), + &_layerdata, pat_solidhigh); + _driver->StrokeLine( BPoint( r.left + 2, r.bottom -1), + BPoint( r.right - 2, r.bottom - 1), + &_layerdata, pat_solidhigh); + + _layerdata.highcolor = RGBColor( 255, 255, 0 ); + _driver->StrokeRect( BRect( r.left + 1, r.top + 1, + r.right, r.bottom), + &_layerdata, pat_solidhigh); + + r.InsetBy( 2, 2 ); + + int32 w=r.IntegerWidth(), h=r.IntegerHeight(); rgb_color tmpcol,halfcol, startcol, endcol; @@ -449,13 +592,7 @@ void DefaultDecorator::DrawBlendedRect(BRect r, bool down) _layerdata.highcolor=tmpcol; _driver->StrokeLine(BPoint(r.left+steps,r.top+i), BPoint(r.left+i,r.top+steps),&_layerdata,pat_solidhigh); - } - -// _layerdata.highcolor=startcol; -// _driver->FillRect(r,&_layerdata,pat_solidhigh); - _layerdata.highcolor=framecolors[3]; - _driver->StrokeRect(r,&_layerdata,pat_solidhigh); } void DefaultDecorator::_DrawFrame(BRect invalid) @@ -465,11 +602,12 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // we must clip the lines drawn by this function to the invalid rectangle we are given #ifdef USE_VIEW_FILL_HACK - _driver->FillRect(_borderrect,&_layerdata,pat_solidhigh); + _driver->FillRect(_frame,&_layerdata,pat_solidhigh); #endif - if(!borderwidth) + if(!borderwidth){ return; + } // Data specifically for the StrokeLineArray call. int32 numlines=0, maxlines=20; @@ -523,7 +661,6 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // Right side if(TestRectIntersection(rightborder,invalid)) { - // We may not have to redraw the entire width of the frame itself. Rare case, but // it must be accounted for. startx=(int32) MAX(invalid.left,rightborder.left); @@ -574,7 +711,6 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // Left side if(TestRectIntersection(leftborder,invalid)) { - // We may not have to redraw the entire width of the frame itself. Rare case, but // it must be accounted for. startx=(int32) MAX(invalid.left,leftborder.left); @@ -625,7 +761,6 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // Top side if(TestRectIntersection(topborder,invalid)) { - // We may not have to redraw the entire width of the frame itself. Rare case, but // it must be accounted for. starty=(int32) MAX(invalid.top,topborder.top); @@ -681,7 +816,6 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // Bottom side if(TestRectIntersection(bottomborder,invalid)) { - // We may not have to redraw the entire width of the frame itself. Rare case, but // it must be accounted for. starty=(int32) MAX(invalid.top,bottomborder.top); @@ -743,7 +877,6 @@ void DefaultDecorator::_DrawFrame(BRect invalid) if(!(_flags & B_NOT_RESIZABLE)) { r=_resizerect; - // int32 w=r.IntegerWidth(), h=r.IntegerHeight(); // This code is strictly for B_DOCUMENT_WINDOW looks @@ -813,10 +946,10 @@ void DefaultDecorator::_DrawFrame(BRect invalid) } else { - _layerdata.highcolor=framecolors[4]; - _driver->StrokeLine(BPoint(r.right,r.top),BPoint(r.right-3,r.top), + _layerdata.highcolor=framecolors[2]; + _driver->StrokeLine(BPoint(r.right-4,r.top),BPoint(r.right-2,r.top), &_layerdata,pat_solidhigh); - _driver->StrokeLine(BPoint(r.left,r.bottom),BPoint(r.left,r.bottom-3), + _driver->StrokeLine(BPoint(r.left,r.bottom-4),BPoint(r.left,r.bottom-2), &_layerdata,pat_solidhigh); } } diff --git a/src/servers/app/server/Desktop.cpp b/src/servers/app/server/Desktop.cpp index 52f29e6bec..bca459e73c 100644 --- a/src/servers/app/server/Desktop.cpp +++ b/src/servers/app/server/Desktop.cpp @@ -462,6 +462,23 @@ printf("Desktop: AddWindowToDesktop(%s,%ld,%ld)\n",win?win->GetTitle():"NULL", desktop_private::workspacelock.Unlock(); } +WinBorder* WindowContainsPoint( BPoint pt ){ +#ifdef DEBUG_DESKTOP +printf("Desktop: WindowContainsPoint(%s,%f,%f)\n",win?win->GetTitle():"NULL", + pt.x, pt.y); +#endif + WinBorder *wb; + + desktop_private::workspacelock.Lock(); + desktop_private::layerlock.Lock(); + + wb = desktop_private::activescreen->GetWindowAt( pt ); + + desktop_private::layerlock.Unlock(); + desktop_private::workspacelock.Unlock(); + + return wb; +} /*! \brief Removes a window from the desktop \param win Window to remove diff --git a/src/servers/app/server/Desktop.h b/src/servers/app/server/Desktop.h index e7911422b7..ff988f0cd0 100644 --- a/src/servers/app/server/Desktop.h +++ b/src/servers/app/server/Desktop.h @@ -32,11 +32,13 @@ #include #include #include +//#include "WinBorder.h" class ServerWindow; class Screen; class DisplayDriver; class Layer; +class WinBorder; void InitDesktop(void); void ShutdownDesktop(void); @@ -57,6 +59,7 @@ status_t SetSpace(int32 index, int32 res, screen_id screen, bool stick=true); void AddWindowToDesktop(ServerWindow *win, int32 workspace, screen_id screen); void RemoveWindowFromDesktop(ServerWindow *win); +WinBorder* WindowContainsPoint( BPoint pt ); ServerWindow *GetActiveWindow(void); void SetActiveWindow(ServerWindow *win); Layer *GetRootLayer(int32 workspace, screen_id screen); diff --git a/src/servers/app/server/DesktopClasses.cpp b/src/servers/app/server/DesktopClasses.cpp index 54ea5fd079..ba19575542 100644 --- a/src/servers/app/server/DesktopClasses.cpp +++ b/src/servers/app/server/DesktopClasses.cpp @@ -33,7 +33,11 @@ #include "TokenHandler.h" #include "ServerWindow.h" #include "WinBorder.h" +#include "RootLayer.h" #include "Desktop.h" +#include "DisplayDriver.h" +#include "Decorator.h" + //#define DEBUG_WORKSPACE //#define DEBUG_SCREEN @@ -443,6 +447,26 @@ printf("Screen::RemoveWindow(%s)\n",win?win->GetTitle():"NULL"); win->_winborder->RemoveSelf(); } +/*! + \brief Returns the WinBorder taht contains the point + \param The point + \return The WinBorder that contains the point +*/ +WinBorder* Screen::GetWindowAt( BPoint pt ){ + WinBorder *wb; + Layer *rl = GetRootLayer(); + Layer *child; + for(child = rl->_bottomchild; child!=NULL; child = child->_uppersibling) + { + if(child->_hidecount>0) + continue; + wb = dynamic_cast( child ); + if (wb) + if(wb->GetDecorator()->GetFootprint()->Contains(pt)) + return wb; + } + return NULL; +} /*! \brief Returns the active window in the current workspace diff --git a/src/servers/app/server/DesktopClasses.h b/src/servers/app/server/DesktopClasses.h index 874a20123b..a9462b440c 100644 --- a/src/servers/app/server/DesktopClasses.h +++ b/src/servers/app/server/DesktopClasses.h @@ -33,12 +33,14 @@ #include #include #include // for workspace defs -#include "RootLayer.h" class DisplayDriver; class ServerWindow; class RGBColor; class Screen; +class WinBorder; +class RootLayer; +class Layer; /*! \class Workspace DesktopClasses.h @@ -103,9 +105,10 @@ public: status_t SetSpace(int32 index, int32 res,bool stick=true); void AddWindow(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE); void RemoveWindow(ServerWindow *win); + WinBorder* GetWindowAt( BPoint pt ); ServerWindow *ActiveWindow(void); void SetActiveWindow(ServerWindow *win); - Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE); + Layer* GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE); bool IsInitialized(void); Workspace *GetWorkspace(int32 index); Workspace *GetActiveWorkspace(void); diff --git a/src/servers/app/server/Layer.cpp b/src/servers/app/server/Layer.cpp index f978e362bc..bd99d168b0 100644 --- a/src/servers/app/server/Layer.cpp +++ b/src/servers/app/server/Layer.cpp @@ -470,10 +470,10 @@ bool Layer::IsDirty(void) const */ void Layer::UpdateIfNeeded(bool force_update) { - Layer *child; - if(IsHidden()) return; + + Layer *child; if(force_update) { @@ -535,27 +535,33 @@ void Layer::Show(void) if(_hidecount>0) return; - BRegion *reg=new BRegion(ConvertToParent(_visible)); - _parent->_visible->Exclude(reg); - delete reg; + if( _parent ){ + BRegion *reg=new BRegion(ConvertToParent(_visible)); + _parent->_visible->Exclude(reg); + delete reg; + _parent->_is_dirty=true; + } _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)); + + if( _parent ){ + 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(); - if(_parent) + if(_parent){ _parent->RebuildRegions(true); + _parent->UpdateIfNeeded(); + } - _parent->UpdateIfNeeded(); + UpdateIfNeeded(); } //! Hide the layer. Operates just like the BView call with the same name diff --git a/src/servers/app/server/Layer.h b/src/servers/app/server/Layer.h index 70751acf20..1c5bd11006 100644 --- a/src/servers/app/server/Layer.h +++ b/src/servers/app/server/Layer.h @@ -35,11 +35,13 @@ #include #include #include "LayerData.h" +#include "DesktopClasses.h" class ServerWindow; class PortLink; class RootLayer; class WinBorder; +class Screen; /*! \class Layer Layer.h @@ -106,6 +108,7 @@ public: protected: friend class RootLayer; friend class WinBorder; + friend class Screen; BRect _frame; diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index 9682be740a..c4c910e4d2 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -26,6 +26,8 @@ // //------------------------------------------------------------------------------ #include +#include "DisplayDriver.h" +#include "Layer.h" #include "RootLayer.h" #include "Desktop.h" #include "PatternHandler.h" // for pattern_union diff --git a/src/servers/app/server/RootLayer.h b/src/servers/app/server/RootLayer.h index 0cd9b2db9d..19a050d40f 100644 --- a/src/servers/app/server/RootLayer.h +++ b/src/servers/app/server/RootLayer.h @@ -28,8 +28,9 @@ #ifndef _ROOTLAYER_H_ #define _ROOTLAYER_H_ -#include "DisplayDriver.h" -#include "Layer.h" +class DisplayDriver; +class RGBColor; +class Layer; /*! \class RootLayer RootLayer.h diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index cef8e49bfa..40fac6caf3 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -28,6 +28,9 @@ #include #include #include + +#include + #include #include #include @@ -136,6 +139,10 @@ ServerApp::~ServerApp(void) _piclist->MakeEmpty(); delete _piclist; +// ADI: + delete ses; + ses = NULL; + delete _applink; _applink=NULL; if(_appcursor) @@ -218,27 +225,14 @@ int32 ServerApp::MonitorApp(void *data) ServerApp *app=(ServerApp *)data; // Message-dispatching loop for the ServerApp - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; + int32 msgCode; + + app->ses = new BSession( app->_receiver, 0L ); for(;;) { - buffersize=port_buffer_size(app->_receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(app->_receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(app->_receiver,&msgcode,NULL,0); - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { + if ( app->ses->ReadInt32( &msgCode ) != B_BAD_PORT_ID ){ + switch (msgCode){ case AS_QUIT_APP: { #ifdef DEBUG_SERVERAPP @@ -268,7 +262,7 @@ int32 ServerApp::MonitorApp(void *data) } break; } - + case B_QUIT_REQUESTED: { // Our BApplication sent us this message when it quit. @@ -287,19 +281,15 @@ int32 ServerApp::MonitorApp(void *data) } default: { - app->_DispatchMessage(msgcode, msgbuffer); + #ifdef DEBUG_SERVERAPP + printf("ServerApp %s: Got a Message to dispatch\n",app->_signature.String()); + #endif + app->_DispatchMessage(msgCode, NULL); break; } - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } + } // switch + } // if + } // for exit_thread(0); return 0; @@ -335,48 +325,51 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer) // Create the ServerWindow to node monitor a new OBWindow // Attached data: - // 1) port_id reply port // 2) BRect window frame // 3) uint32 window look // 4) uint32 window feel // 5) uint32 window flags - // 6) port_id window's message port - // 7) uint32 workspace index - // 8) int32 BHandler token of the window + // 6) uint32 workspace index + // 7) int32 BHandler token of the window + // 8) port_id window's message port // 9) const char * title - // Find the necessary data - port_id reply_port=*((port_id*)index); index+=sizeof(port_id); - BRect rect=*((BRect*)index); index+=sizeof(BRect); + BRect frame; + uint32 look; + uint32 feel; + uint32 flags; + uint32 wkspaces; + int32 token; + port_id sendPort; + char *title; + + ses->ReadRect( &frame ); + ses->ReadInt32( (int32*)&look ); + ses->ReadInt32( (int32*)&feel ); + ses->ReadInt32( (int32*)&flags ); + ses->ReadInt32( (int32*)&wkspaces ); + ses->ReadInt32( &token ); + ses->ReadData( &sendPort, sizeof(port_id) ); + title = ses->ReadString(); - uint32 winlook=*((uint32*)index); index+=sizeof(uint32); - uint32 winfeel=*((uint32*)index); index+=sizeof(uint32); - uint32 winflags=*((uint32*)index); index+=sizeof(uint32); + #ifdef DEBUG_SERVERAPP + printf("ServerApp %s: Got 'New Window' message, trying to do smething...\n"); + #endif - port_id win_port=*((port_id*)index); index+=sizeof(port_id); - int32 htoken=*((int32*)index); index+=sizeof(int32); - uint32 workspace=*((uint32*)index); index+=sizeof(uint32); - - // Create the ServerWindow object for this window - ServerWindow *newwin=new ServerWindow(rect,(const char *)index, - winlook, winfeel, winflags,this,win_port,workspace,htoken); - _winlist->AddItem(newwin); - AddWindowToDesktop(newwin,workspace,ActiveScreen()); + // ServerWindow constructor will reply with port_id of a newly created port + ServerWindow *newwin = new ServerWindow( frame, title, + look, feel, flags, this, sendPort, wkspaces, token); + _winlist->AddItem( newwin ); + //AddWindowToDesktop( newwin, workspace, ActiveScreen() ); + #ifdef DEBUG_SERVERAPP printf("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n", - _signature.String(),(const char *)index,rect.left,rect.top,rect.right,rect.bottom); + _signature.String(),title,frame.left,frame.top,frame.right,frame.bottom); #endif + + delete title; - // Window looper is waiting for our reply. Send back the - // ServerWindow's message port - PortLink *replylink=new PortLink(reply_port); - replylink->SetOpCode(AS_SET_SERVER_PORT); - replylink->Attach(newwin->_receiver); - replylink->Attach(newwin->_token); - replylink->Flush(); - - delete replylink; break; } case AS_DELETE_WINDOW: diff --git a/src/servers/app/server/ServerApp.h b/src/servers/app/server/ServerApp.h index 51583e553e..7d04630137 100644 --- a/src/servers/app/server/ServerApp.h +++ b/src/servers/app/server/ServerApp.h @@ -29,6 +29,9 @@ #include #include + +#include + class AppServer; class BMessage; class PortLink; @@ -86,6 +89,8 @@ protected: bool _cursorhidden; bool _isactive; int32 _handlertoken; +// ADI: + BSession *ses; }; #endif diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 6a1d116a02..983d30ab7c 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -32,6 +32,7 @@ #include #include "AppServer.h" #include "Layer.h" +#include "RootLayer.h" #include "ServerWindow.h" #include "ServerApp.h" #include "ServerProtocol.h" @@ -40,6 +41,7 @@ #include "DesktopClasses.h" #include "TokenHandler.h" #include "Utils.h" +#include "DisplayDriver.h" //#define DEBUG_SERVERWINDOW //#define DEBUG_SERVERWINDOW_MOUSE @@ -109,12 +111,18 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, // _sender is the monitored window's event port _sender=winport; - _winlink=new PortLink(_sender); + _winlink=new PortLink(_sender); _applink= (winapp)? new PortLink(winapp->_receiver) : NULL; // _receiver is the port to which the app sends messages for the server _receiver=create_port(30,_title->String()); + + + ses = new BSession( _receiver, _sender ); + // Send a reply to our window - it is expecting _receiver port. + ses->WriteData( &_receiver, sizeof(port_id) ); + ses->Sync(); _active=false; @@ -151,6 +159,10 @@ ServerWindow::~ServerWindow(void) delete _title; delete _winlink; delete _winborder; + + + delete ses; + ses = NULL; } kill_thread(_monitorthread); } @@ -390,9 +402,9 @@ bool ServerWindow::IsLocked(void) return _locker.IsLocked(); } -void ServerWindow::DispatchMessage(PortMessage *msg) +void ServerWindow::DispatchMessage( int32 code ) { - switch(msg->Code()) + switch( code ) { case AS_LAYER_CREATE: { @@ -459,6 +471,9 @@ void ServerWindow::DispatchMessage(PortMessage *msg) } case AS_SHOW_WINDOW: { + #ifdef DEBUG_SERVERWINDOW + printf("ServerWindow %s: Message AS_SHOW\n",_title->String()); + #endif Show(); break; } @@ -629,7 +644,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg) } default: { - printf("ServerWindow %s received unexpected code - message offset %lx\n",_title->String(),msg->Code()-SERVER_TRUE); + printf("ServerWindow %s received unexpected code - message offset %lx\n",_title->String(), code - SERVER_TRUE); break; } } @@ -1181,23 +1196,17 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) */ int32 ServerWindow::MonitorWin(void *data) { - ServerWindow *win=(ServerWindow *)data; - PortMessage msg; - int32 msgstat; - - int8 *msgbuffer=NULL; - ssize_t buffersize; + ServerWindow *win = (ServerWindow *)data; + status_t rv; + int32 code; for(;;) { - msgstat=msg.ReadFromPort(win->_receiver); + rv = win->ses->ReadInt32( &code ); - if(msgstat==B_OK) - { - switch(msg.Code()) - { - case B_QUIT_REQUESTED: - { + if ( rv != B_BAD_PORT_ID ){ + switch( code ){ + case B_QUIT_REQUESTED:{ #ifdef DEBUG_SERVERWINDOW printf("ServerWindow %s received Quit request\n",win->Title()); #endif @@ -1208,20 +1217,18 @@ int32 ServerWindow::MonitorWin(void *data) win->_applink->Flush(); break; } - case AS_BEGIN_UPDATE: - { - win->DispatchGraphicsMessage(buffersize,msgbuffer); + default:{ + win->DispatchMessage( code ); break; } - default: -// win->DispatchMessage(msgcode,msgbuffer); - win->DispatchMessage(&msg); - break; } - + } + else{ + exit_thread(1); + return 1; } - if(msg.Code()==B_QUIT_REQUESTED) + if( code == B_QUIT_REQUESTED ) break; } @@ -1279,11 +1286,10 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) BPoint pt(x,y); // If we have clicked on a window, - active_winborder=_winborder=(WinBorder*)root->GetChildAt(pt); + active_winborder = _winborder = WindowContainsPoint(pt); if(_winborder) { mousewin=_winborder->Window(); -// _winborder->MouseDown(buffer); _winborder->MouseDown((int8*)msg->Buffer()); } break; @@ -1311,7 +1317,7 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) set_is_sliding_tab(false); set_is_moving_window(false); set_is_resizing_window(false); - _winborder=(WinBorder*)root->GetChildAt(pt); + _winborder = WindowContainsPoint(pt); active_winborder=NULL; if(_winborder) { @@ -1319,7 +1325,6 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) // Eventually, we will build in MouseUp messages with buttons specified // For now, we just "assume" no mouse specification with a 0. -// _winborder->MouseUp(buffer); _winborder->MouseUp((int8*)msg->Buffer()); } break; @@ -1345,16 +1350,14 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) if(is_moving_window() || is_resizing_window() || is_sliding_tab()) { -// active_winborder->MouseMoved(buffer); active_winborder->MouseMoved((int8*)msg->Buffer()); } else { - _winborder=(WinBorder*)root->GetChildAt(pt); + _winborder = WindowContainsPoint(pt); if(_winborder) { mousewin=_winborder->Window(); -// _winborder->MouseMoved(buffer); _winborder->MouseMoved((int8*)msg->Buffer()); } } diff --git a/src/servers/app/server/ServerWindow.h b/src/servers/app/server/ServerWindow.h index 78606cea0d..45aa0560fa 100644 --- a/src/servers/app/server/ServerWindow.h +++ b/src/servers/app/server/ServerWindow.h @@ -36,6 +36,8 @@ #include #include +#include + class BString; class BMessenger; class BPoint; @@ -85,7 +87,7 @@ public: void Unlock(void); bool IsLocked(void); - void DispatchMessage(PortMessage *msg); + void DispatchMessage( int32 code ); void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer); static int32 MonitorWin(void *data); static void HandleMouseEvent(PortMessage *msg); @@ -120,6 +122,9 @@ protected: BRect _frame; uint32 _token; int32 _handlertoken; + +// ADI: + BSession *ses; }; void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin); diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index 8b609a3b86..075133cc90 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -41,7 +41,7 @@ //#define DEBUG_WINBORDER //#define DEBUG_WINBORDER_MOUSE -//#define DEBUG_WINBORDER_CLICK +#define DEBUG_WINBORDER_CLICK #ifdef DEBUG_WINBORDER #include @@ -84,8 +84,6 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i _mbuttons=0; _kmodifiers=0; _win=win; - if(_win) - _frame=_win->_frame; _mousepos.Set(0,0); _update=false; @@ -95,6 +93,13 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i _vresizewin=false; _driver=GetGfxDriver(ActiveScreen()); _decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver(ActiveScreen())); + // WinBorder must also include the right/left/top/bottom Decorator' + // rects - given by _decorator::GetBorderRect() - to be able to draw the borders + _frame = _decorator->GetBorderRect(); + _visible->Set( _frame ); + _full->Set( _frame ); + _invalid->Set( _frame ); + _decorator->SetDriver(_driver); _decorator->SetTitle(name); @@ -296,23 +301,28 @@ printf("ClickMove: Drag\n"); { BRect oldmoveframe=_win->_frame; _clientframe.OffsetBy(pt); - + _win->Lock(); _win->_frame.OffsetBy(dx,dy); _win->Unlock(); - + lock_layers(); BRegion *reg=_decorator->GetFootprint(); - _driver->CopyRegion(reg,_win->_frame.LeftTop()); - - BRegion reg2(oldmoveframe); - MoveBy(dx,dy); + // TODO: we get an error here!!! - this method is untested + //_driver->CopyRegion(reg,_win->_frame.LeftTop()); + _decorator->MoveBy(BPoint(dx, dy)); + + MoveBy(dx,dy); + + // ADI: what do those do??? + BRegion reg2(oldmoveframe); reg->OffsetBy((int32)dx, (int32)dy); reg2.Exclude(reg); + _parent->RebuildRegions(); _parent->RequestDraw(); - + delete reg; unlock_layers(); } diff --git a/src/servers/app/server/WinBorder.h b/src/servers/app/server/WinBorder.h index 5843c52c3b..73ffe1e536 100644 --- a/src/servers/app/server/WinBorder.h +++ b/src/servers/app/server/WinBorder.h @@ -63,7 +63,9 @@ protected: BString *_title; Decorator *_decorator; int32 _flags; - BRect _frame, _clientframe; + // !!! HERE we do have a problem... _frame is also defined in Layer.h +// BRect _frame, _clientframe; + BRect _clientframe; int32 _mbuttons,_kmodifiers; BPoint _mousepos; bool _update;