2003-02-15 18:28:22 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// 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: WinBorder.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
2004-01-17 21:37:57 +03:00
|
|
|
// Adi Oanca <adioanca@myrealbox.com>
|
2003-02-15 18:28:22 +03:00
|
|
|
// Description: Layer subclass which handles window management
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2003-02-14 04:53:53 +03:00
|
|
|
#include <Region.h>
|
|
|
|
#include <String.h>
|
|
|
|
#include <Locker.h>
|
|
|
|
#include <Debug.h>
|
2003-09-17 04:03:47 +04:00
|
|
|
#include <TokenSpace.h>
|
2003-02-14 04:53:53 +03:00
|
|
|
#include "View.h" // for mouse button defines
|
|
|
|
#include "ServerWindow.h"
|
|
|
|
#include "Decorator.h"
|
|
|
|
#include "DisplayDriver.h"
|
|
|
|
#include "Desktop.h"
|
|
|
|
#include "WinBorder.h"
|
2003-03-12 21:32:27 +03:00
|
|
|
#include "AppServer.h" // for new_decorator()
|
2003-09-09 02:09:10 +04:00
|
|
|
#include "TokenHandler.h"
|
2004-01-13 03:38:42 +03:00
|
|
|
#include "Globals.h"
|
|
|
|
#include "RootLayer.h"
|
|
|
|
#include "Workspace.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
// TODO: Document this file completely
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// Toggle general function call output
|
|
|
|
//#define DEBUG_WINBORDER
|
|
|
|
|
|
|
|
// toggle
|
2004-02-24 14:56:03 +03:00
|
|
|
#define DEBUG_WINBORDER_MOUSE
|
2004-01-21 05:58:39 +03:00
|
|
|
#define DEBUG_WINBORDER_CLICK
|
2003-03-23 23:52:37 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_WINBORDER
|
2003-09-09 02:09:10 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
2003-03-23 23:52:37 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_WINBORDER_MOUSE
|
2003-09-09 02:09:10 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE_MOUSE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE_MOUSE(x) ;
|
2003-03-23 23:52:37 +03:00
|
|
|
#endif
|
|
|
|
|
2003-04-05 05:51:35 +04:00
|
|
|
#ifdef DEBUG_WINBORDER_CLICK
|
2003-09-09 02:09:10 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE_CLICK(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE_CLICK(x) ;
|
2003-04-05 05:51:35 +04:00
|
|
|
#endif
|
|
|
|
|
2003-09-09 02:09:10 +04:00
|
|
|
//! TokenHandler object used to provide IDs for all WinBorder objects
|
|
|
|
TokenHandler border_token_handler;
|
2003-02-14 04:53:53 +03:00
|
|
|
|
2004-04-05 00:30:20 +04:00
|
|
|
bool gMouseDown = false;
|
|
|
|
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2003-07-24 23:38:24 +04:00
|
|
|
WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
|
2004-02-24 14:56:03 +03:00
|
|
|
const int32 flags, ServerWindow *win, DisplayDriver *driver)
|
|
|
|
: Layer(r, name, B_NULL_TOKEN, B_FOLLOW_NONE, flags, driver)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-02-24 14:56:03 +03:00
|
|
|
// unlike BViews, windows start off as hidden
|
2003-11-14 03:15:29 +03:00
|
|
|
_hidden = true;
|
2004-02-24 14:56:03 +03:00
|
|
|
_serverwin = win;
|
|
|
|
|
|
|
|
fMouseButtons = 0;
|
|
|
|
fKeyModifiers = 0;
|
|
|
|
fMainWinBorder = NULL;
|
|
|
|
fDecorator = NULL;
|
|
|
|
fDecFull = NULL;
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsMoving = false;
|
|
|
|
fIsResizing = false;
|
|
|
|
fIsClosing = false;
|
|
|
|
fIsMinimizing = false;
|
|
|
|
fIsZooming = false;
|
|
|
|
|
2003-11-15 03:29:14 +03:00
|
|
|
fLastMousePosition.Set(-1,-1);
|
2004-01-13 03:38:42 +03:00
|
|
|
SetLevel();
|
2004-05-16 23:27:59 +04:00
|
|
|
fNewTopLayerFrame = &(win->fTopLayer->_frame);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
2004-03-28 18:58:39 +04:00
|
|
|
if (feel == B_NO_BORDER_WINDOW_LOOK){
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-03-28 18:58:39 +04:00
|
|
|
else{
|
2004-02-24 14:56:03 +03:00
|
|
|
fDecorator = new_decorator(r, name, look, feel, flags, fDriver);
|
2003-11-14 03:15:29 +03:00
|
|
|
fDecFull = new BRegion();
|
2004-03-28 18:58:39 +04:00
|
|
|
fDecorator->GetFootprint(fDecFull);
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
|
2004-03-28 18:58:39 +04:00
|
|
|
_full.MakeEmpty();
|
|
|
|
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder %s:\n",GetName()));
|
|
|
|
STRACE(("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom));
|
|
|
|
STRACE(("\tWindow %s\n",win?win->Title():"NULL"));
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2003-02-14 04:53:53 +03:00
|
|
|
WinBorder::~WinBorder(void)
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
STRACE(("WinBorder %s:~WinBorder()\n",GetName()));
|
2004-02-24 14:56:03 +03:00
|
|
|
if (fDecorator) {
|
|
|
|
delete fDecorator;
|
|
|
|
fDecorator = NULL;
|
2003-11-14 03:15:29 +03:00
|
|
|
|
|
|
|
delete fDecFull;
|
|
|
|
fDecFull = NULL;
|
|
|
|
}
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-03-28 18:58:39 +04:00
|
|
|
void WinBorder::RebuildFullRegion(void){
|
2004-05-16 23:27:59 +04:00
|
|
|
BRegion topLayerFull;
|
|
|
|
Layer *topLayer = _serverwin->fTopLayer;
|
|
|
|
topLayerFull.Set( ConvertToTop(*fNewTopLayerFrame) );
|
|
|
|
fNewTopLayerFrame = &(_serverwin->fTopLayer->_frame);
|
|
|
|
|
|
|
|
// TODO: Convert to screen coordinates!
|
|
|
|
LayerData *ld;
|
|
|
|
ld = topLayer->_layerdata;
|
|
|
|
do{
|
|
|
|
// clip to user region
|
2004-05-20 05:31:28 +04:00
|
|
|
if(ld->clipReg)
|
|
|
|
topLayerFull.IntersectWith( ld->clipReg );
|
2004-05-16 23:27:59 +04:00
|
|
|
} while( (ld = ld->prevState) );
|
2004-03-28 18:58:39 +04:00
|
|
|
|
2004-05-16 23:27:59 +04:00
|
|
|
// clip to user picture region
|
|
|
|
if(topLayer->clipToPicture)
|
|
|
|
if(topLayer->clipToPictureInverse) {
|
|
|
|
topLayerFull.Exclude( topLayer->clipToPicture );
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
topLayerFull.IntersectWith( topLayer->clipToPicture );
|
|
|
|
}
|
|
|
|
|
|
|
|
_full.MakeEmpty();
|
|
|
|
_full = topLayerFull;
|
2004-03-28 18:58:39 +04:00
|
|
|
|
|
|
|
if (fDecorator){
|
2004-05-16 23:27:59 +04:00
|
|
|
fDecFull->MakeEmpty();
|
2004-03-28 18:58:39 +04:00
|
|
|
fDecorator->GetFootprint(fDecFull);
|
|
|
|
_full.Include(fDecFull);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
2004-01-21 05:58:39 +03:00
|
|
|
void WinBorder::MouseDown(const BPoint &pt, const int32 &buttons, const int32 &modifiers)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
// this is important to determine how much we should resize or move the Layer(WinBorder)(window)
|
|
|
|
|
|
|
|
// user clicked on WinBorder's visible region, which is in fact decorator's.
|
|
|
|
// so, if true, we find out if the user clicked the decorator.
|
|
|
|
Layer *target = LayerAt(pt);
|
|
|
|
if (target == this){
|
|
|
|
click_type action;
|
|
|
|
// find out where user clicked in Decorator
|
|
|
|
action = fDecorator->Clicked(pt, buttons, modifiers);
|
|
|
|
switch(action){
|
|
|
|
/*
|
|
|
|
TODO: add methods like DrawCloseBtnDown(true/false) to let Decorator draw "down" buttoms
|
|
|
|
for closing and zooming for example. Call them here!
|
|
|
|
*/
|
|
|
|
case DEC_CLOSE:
|
|
|
|
fIsClosing = true;
|
|
|
|
// fDecorator->DrawClosingBtnDown(true);
|
|
|
|
STRACE_CLICK(("===> DEC_CLOSE\n"));
|
|
|
|
break;
|
|
|
|
case DEC_ZOOM:
|
|
|
|
fIsZooming = true;
|
|
|
|
// fDecorator->DrawZoomBtnDown(true);
|
|
|
|
STRACE_CLICK(("===> DEC_ZOOM\n"));
|
|
|
|
break;
|
|
|
|
case DEC_RESIZE:
|
|
|
|
fIsResizing = true;
|
|
|
|
// fDecorator->DrawResizingBtnDown(true);
|
|
|
|
STRACE_CLICK(("===> DEC_RESIZE\n"));
|
|
|
|
break;
|
|
|
|
case DEC_DRAG:
|
|
|
|
fIsMoving = true;
|
|
|
|
// fDecorator->DrawMovingBtnDown(true);
|
|
|
|
STRACE_CLICK(("===> DEC_DRAG\n"));
|
|
|
|
break;
|
|
|
|
case DEC_MOVETOBACK:
|
|
|
|
GetRootLayer()->ActiveWorkspace()->MoveToBack(this);
|
|
|
|
break;
|
|
|
|
case DEC_NONE:
|
|
|
|
debugger("WinBorder::MouseDown - Decorator should NOT return DEC_NONE\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debugger("WinBorder::MouseDown - Decorator returned UNKNOWN code\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
/*
|
|
|
|
TODO: implement!
|
|
|
|
The problem here is that, there is no way to get the required data for the B_MOUSE_DOWN
|
|
|
|
message. There should be a method like BWindow::CurrentMessage() to get the input message
|
|
|
|
parameters. The problem is that Poller currently use PortLink message system, and there
|
|
|
|
is no way to get the paramets we need(e.g. when, noOfClicks).
|
|
|
|
This yelds PortLink messages from input_server to be replaced by regulat BMessages!!!
|
|
|
|
*/
|
|
|
|
/* BMessage msg;
|
|
|
|
msg->what = B_MOUSE_DOWN;
|
|
|
|
msg->AddInt64("when", when);
|
|
|
|
msg->AddPoint("where", where);
|
|
|
|
msg->AddInt32("modifiers", modifiers);
|
|
|
|
msg->AddInt32("buttons", buttons);
|
|
|
|
msg->AddInt32("clicks", noOfClicks);
|
|
|
|
|
|
|
|
msg->AddInt32("token", token); ??? // Have a look into BLooper::task_looper()!!!
|
|
|
|
Window()->SendMessageToClient(msg);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2003-11-15 03:29:14 +03:00
|
|
|
fLastMousePosition = pt;
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-21 05:58:39 +03:00
|
|
|
void WinBorder::MouseMoved(const BPoint &pt, const int32 &buttons)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
if (fIsMoving){
|
|
|
|
STRACE_CLICK(("===> Moving...\n"));
|
|
|
|
BPoint offset = pt;
|
|
|
|
offset -= fLastMousePosition;
|
|
|
|
MoveBy(offset.x, offset.y);
|
|
|
|
goto MMend;
|
|
|
|
}
|
|
|
|
if (fIsResizing){
|
|
|
|
STRACE_CLICK(("===> Resizing...\n"));
|
|
|
|
BPoint offset = pt;
|
|
|
|
offset -= fLastMousePosition;
|
|
|
|
ResizeBy(offset.x, offset.y);
|
|
|
|
goto MMend;
|
|
|
|
}
|
|
|
|
if (fIsZooming){
|
|
|
|
/*
|
|
|
|
TODO: implement!
|
|
|
|
Add what you need to the Decorator API.
|
|
|
|
|
|
|
|
if (fDecorator->GetZoomRegion().Contains(pt)){
|
|
|
|
// do nothing! Mouse still inside the zooming region.
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
fDecorator->DrawZoomBtnDown(false);
|
|
|
|
}
|
|
|
|
goto MMend;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
if (fIsClosing){
|
|
|
|
/*
|
|
|
|
TODO: implement!
|
|
|
|
Add what you need to the Decorator API.
|
|
|
|
|
|
|
|
if (fDecorator->GetZoomRegion().Contains(pt)){
|
|
|
|
// do nothing! Mouse still inside the zooming region.
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
fDecorator->DrawCloseBtnDown(false);
|
|
|
|
}
|
|
|
|
goto MMend;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
MMend:
|
2003-11-15 03:29:14 +03:00
|
|
|
fLastMousePosition = pt;
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2004-01-21 05:58:39 +03:00
|
|
|
void WinBorder::MouseUp(const BPoint &pt, const int32 &modifiers)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
if (fIsMoving){
|
|
|
|
fIsMoving = false;
|
|
|
|
// DrawMovingBtnDown(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fIsResizing){
|
|
|
|
fIsResizing = false;
|
|
|
|
// DrawResisingBtnDown(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fIsZooming){
|
|
|
|
fIsZooming = false;
|
|
|
|
// DrawZoomBtnDown(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fIsClosing){
|
|
|
|
fIsClosing = false;
|
|
|
|
// DrawCloseBtnDown(false);
|
|
|
|
return;
|
|
|
|
}
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void WinBorder::HighlightDecorator(const bool &active)
|
2003-07-24 23:38:24 +04:00
|
|
|
{
|
2004-02-24 14:56:03 +03:00
|
|
|
fDecorator->SetFocus(active);
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2003-11-14 03:15:29 +03:00
|
|
|
void WinBorder::Draw(const BRect &r)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-03-28 18:58:39 +04:00
|
|
|
printf("WinBorder(%s)::Draw()\n", GetName());
|
|
|
|
if(fDecorator){
|
2004-05-16 23:27:59 +04:00
|
|
|
// decorator is allowed to draw in its entire visible region, not just in the update one.
|
|
|
|
fUpdateReg = _visible;
|
|
|
|
fUpdateReg.IntersectWith(fDecFull);
|
2004-04-05 00:30:20 +04:00
|
|
|
// restrict Decorator drawing to the update region only.
|
|
|
|
fDriver->ConstrainClippingRegion(&fUpdateReg);
|
|
|
|
/*
|
2004-03-28 18:58:39 +04:00
|
|
|
fUpdateReg.PrintToStream();
|
2004-04-03 19:06:45 +04:00
|
|
|
RGBColor c(128, 56, 98);
|
2004-05-16 23:27:59 +04:00
|
|
|
//fDriver->FillRect(r, c);
|
|
|
|
fDriver->FillRect(fUpdateReg.Frame(), c);
|
2004-03-28 18:58:39 +04:00
|
|
|
snooze(1000000);
|
2004-04-05 00:30:20 +04:00
|
|
|
*/
|
2004-05-16 23:27:59 +04:00
|
|
|
// TODO: pass 'r' not as you do now!!! Let Decorator object handle update problems
|
|
|
|
fDecorator->Draw(fUpdateReg.Frame());
|
2004-03-28 18:58:39 +04:00
|
|
|
|
2004-04-05 00:30:20 +04:00
|
|
|
// remove the additional clipping region.
|
|
|
|
fDriver->ConstrainClippingRegion(NULL);
|
2004-03-28 18:58:39 +04:00
|
|
|
}
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2003-02-14 04:53:53 +03:00
|
|
|
void WinBorder::MoveBy(float x, float y)
|
|
|
|
{
|
2004-03-28 18:58:39 +04:00
|
|
|
if(fDecorator){
|
|
|
|
fDecorator->MoveBy(x,y);
|
2004-05-16 23:27:59 +04:00
|
|
|
fDecFull->OffsetBy(x,y);
|
2004-03-28 18:58:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Layer::MoveBy(x,y);
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
2003-02-14 04:53:53 +03:00
|
|
|
void WinBorder::ResizeBy(float x, float y)
|
|
|
|
{
|
2004-03-28 18:58:39 +04:00
|
|
|
if(fDecorator){
|
|
|
|
fDecorator->ResizeBy(x,y);
|
|
|
|
}
|
2004-05-16 23:27:59 +04:00
|
|
|
BRect *localRect = new BRect(_serverwin->fTopLayer->_frame);
|
|
|
|
fNewTopLayerFrame = localRect;
|
|
|
|
// force topLayer's frame to resize
|
|
|
|
fNewTopLayerFrame->right += x;
|
|
|
|
fNewTopLayerFrame->bottom += y;
|
|
|
|
|
2004-03-28 18:58:39 +04:00
|
|
|
Layer::ResizeBy(x,y);
|
2004-05-16 23:27:59 +04:00
|
|
|
delete localRect;
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-02-24 14:56:03 +03:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
bool WinBorder::HasPoint(BPoint& pt) const{
|
2004-03-28 18:58:39 +04:00
|
|
|
return _fullVisible.Contains(pt);
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void WinBorder::SetMainWinBorder(WinBorder *newMain){
|
|
|
|
fMainWinBorder = newMain;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
WinBorder* WinBorder::MainWinBorder() const{
|
|
|
|
return fMainWinBorder;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void WinBorder::SetLevel(){
|
2004-03-28 18:58:39 +04:00
|
|
|
switch(_serverwin->Feel()){
|
2004-01-13 03:38:42 +03:00
|
|
|
case B_NORMAL_WINDOW_FEEL:
|
|
|
|
_level = B_NORMAL_FEEL;
|
|
|
|
break;
|
|
|
|
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
|
|
|
_level = B_FLOATING_SUBSET_FEEL;
|
|
|
|
break;
|
|
|
|
case B_FLOATING_APP_WINDOW_FEEL:
|
|
|
|
_level = B_FLOATING_APP_FEEL;
|
|
|
|
break;
|
|
|
|
case B_FLOATING_ALL_WINDOW_FEEL:
|
|
|
|
_level = B_FLOATING_ALL_FEEL;
|
|
|
|
break;
|
|
|
|
case B_MODAL_SUBSET_WINDOW_FEEL:
|
|
|
|
_level = B_MODAL_SUBSET_FEEL;
|
|
|
|
break;
|
|
|
|
case B_MODAL_APP_WINDOW_FEEL:
|
|
|
|
_level = B_MODAL_APP_FEEL;
|
|
|
|
break;
|
|
|
|
case B_MODAL_ALL_WINDOW_FEEL:
|
|
|
|
_level = B_MODAL_ALL_FEEL;
|
|
|
|
break;
|
|
|
|
case B_SYSTEM_LAST:
|
|
|
|
case B_SYSTEM_FIRST:
|
|
|
|
// TODO: uncomment later when this code makes its way into the real server!
|
|
|
|
// if(_win->ServerTeamID() != _win->ClientTeamID())
|
|
|
|
// _win->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
|
|
|
// else
|
2004-03-28 18:58:39 +04:00
|
|
|
_level = _serverwin->Feel();
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
default:
|
2004-03-28 18:58:39 +04:00
|
|
|
_serverwin->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
2004-01-13 03:38:42 +03:00
|
|
|
_level = B_NORMAL_FEEL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void WinBorder::AddToSubsetOf(WinBorder* main){
|
|
|
|
if (!main || (main && !(main->GetRootLayer())))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (main->Window()->fWinFMWList.HasItem(this) || !(desktop->HasWinBorder(this)))
|
|
|
|
return;
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-01-13 03:38:42 +03:00
|
|
|
if (main->Window()->Feel() == B_NORMAL_WINDOW_FEEL
|
|
|
|
&& ( Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL
|
|
|
|
|| Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// if the main window is hidden also hide this one.
|
|
|
|
if(main->IsHidden())
|
|
|
|
_hidden = true;
|
|
|
|
// add to main window's subset
|
|
|
|
main->Window()->fWinFMWList.AddItem(this);
|
|
|
|
// set this member accordingly
|
|
|
|
fMainWinBorder = main;
|
|
|
|
// because this window is in a subset it should appear in the
|
|
|
|
// workspaces its main window appears in.
|
|
|
|
Window()->QuietlySetWorkspaces(main->Window()->Workspaces());
|
2004-01-14 03:26:15 +03:00
|
|
|
// this is a *modal* window, so add it to main windows workspaces.
|
|
|
|
if (Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL){
|
|
|
|
RootLayer *rl = main->GetRootLayer();
|
|
|
|
rl->fMainLock.Lock();
|
|
|
|
rl->AddWinBorderToWorkspaces(this, main->Window()->Workspaces());
|
|
|
|
rl->fMainLock.Unlock();
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
|
|
|
// this a *floating* window so if the main window is 'front',
|
2004-01-14 03:26:15 +03:00
|
|
|
// add it to workspace.
|
2004-01-13 03:38:42 +03:00
|
|
|
if ( !(main->IsHidden()) && Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL){
|
2004-01-14 03:26:15 +03:00
|
|
|
RootLayer *rl = main->GetRootLayer();
|
|
|
|
|
|
|
|
desktop->fGeneralLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - General lock acquired\n", GetName(), main->GetName()));
|
2004-01-14 03:26:15 +03:00
|
|
|
rl->fMainLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - Main lock acquired\n", GetName(), main->GetName()));
|
2004-01-14 18:55:10 +03:00
|
|
|
|
2004-01-14 03:26:15 +03:00
|
|
|
for(int32 i = 0; i < rl->WorkspaceCount(); i++){
|
|
|
|
Workspace *ws = rl->WorkspaceAt(i+1);
|
2004-01-14 18:55:10 +03:00
|
|
|
if(ws->FrontLayer() == main)
|
2004-01-13 03:38:42 +03:00
|
|
|
ws->AddLayerPtr(this);
|
|
|
|
}
|
2004-01-14 18:55:10 +03:00
|
|
|
|
|
|
|
rl->fMainLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - Main lock released\n", GetName(), main->GetName()));
|
2004-01-14 18:55:10 +03:00
|
|
|
desktop->fGeneralLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - General lock released\n", GetName(), main->GetName()));
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void WinBorder::RemoveFromSubsetOf(WinBorder* main){
|
2004-01-17 19:33:22 +03:00
|
|
|
RootLayer *rl = main->GetRootLayer();
|
|
|
|
|
|
|
|
desktop->fGeneralLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock acquired\n", GetName(), main->GetName()));
|
2004-01-17 19:33:22 +03:00
|
|
|
rl->fMainLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock acquired\n", GetName(), main->GetName()));
|
2004-01-13 03:38:42 +03:00
|
|
|
// remove from main window's subset list.
|
|
|
|
if(main->Window()->fWinFMWList.RemoveItem(this)){
|
|
|
|
int32 count = main->GetRootLayer()->WorkspaceCount();
|
|
|
|
for(int32 i=0; i < count; i++){
|
|
|
|
if(main->Window()->Workspaces() & (0x00000001 << i)){
|
|
|
|
Workspace *ws = main->GetRootLayer()->WorkspaceAt(i+1);
|
|
|
|
// if its main window is in 'i' workspaces, remove it from
|
|
|
|
// workspace 'i' if it's in there...
|
|
|
|
ws->RemoveLayerPtr(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fMainWinBorder = NULL;
|
2004-01-17 19:33:22 +03:00
|
|
|
|
|
|
|
rl->fMainLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock released\n", GetName(), main->GetName()));
|
2004-01-17 19:33:22 +03:00
|
|
|
desktop->fGeneralLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock released\n", GetName(), main->GetName()));
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void WinBorder::PrintToStream(){
|
|
|
|
printf("\t%s", GetName());
|
2004-01-14 03:26:15 +03:00
|
|
|
if (_level == B_FLOATING_SUBSET_FEEL)
|
|
|
|
printf("\t%s", "B_FLOATING_SUBSET_WINDOW_FEEL");
|
|
|
|
if (_level == B_FLOATING_APP_FEEL)
|
|
|
|
printf("\t%s", "B_FLOATING_APP_WINDOW_FEEL");
|
|
|
|
if (_level == B_FLOATING_ALL_FEEL)
|
|
|
|
printf("\t%s", "B_FLOATING_ALL_WINDOW_FEEL");
|
|
|
|
if (_level == B_MODAL_SUBSET_FEEL)
|
|
|
|
printf("\t%s", "B_MODAL_SUBSET_WINDOW_FEEL");
|
|
|
|
if (_level == B_MODAL_APP_FEEL)
|
|
|
|
printf("\t%s", "B_MODAL_APP_WINDOW_FEEL");
|
|
|
|
if (_level == B_MODAL_ALL_FEEL)
|
|
|
|
printf("\t%s", "B_MODAL_ALL_WINDOW_FEEL");
|
|
|
|
if (_level == B_NORMAL_FEEL)
|
|
|
|
printf("\t%s", "B_NORMAL_WINDOW_FEEL");
|
2004-01-13 03:38:42 +03:00
|
|
|
|
|
|
|
printf("\t%s\n", _hidden?"hidden" : "not hidden");
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
2003-02-24 18:47:06 +03:00
|
|
|
void WinBorder::UpdateColors(void)
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
STRACE(("WinBorder %s: UpdateColors unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::UpdateDecorator(void)
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
STRACE(("WinBorder %s: UpdateDecorator unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::UpdateFont(void)
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
STRACE(("WinBorder %s: UpdateFont unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::UpdateScreen(void)
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
STRACE(("WinBorder %s: UpdateScreen unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|