os/graphics/windowing/windowserver/nonnga/SERVER/cliwin.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Client window functions
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "W32CLICK.H"
sl@0
    19
#include "server.h"
sl@0
    20
#include "cliwin.h"
sl@0
    21
#include "gc.h"
sl@0
    22
#include "rootwin.h"
sl@0
    23
#include "windowgroup.h"
sl@0
    24
#include "walkwindowtree.h"
sl@0
    25
#include "ScrDev.H"
sl@0
    26
#include "wstop.h"
sl@0
    27
#include "EVQUEUE.H"
sl@0
    28
#include "KEYCLICK.H"
sl@0
    29
#include "panics.h"
sl@0
    30
#include "password.h"
sl@0
    31
#include "pointer.h"
sl@0
    32
#include "EVENT.H"
sl@0
    33
#include "backedupwindow.h"
sl@0
    34
#include "redrawmsgwindow.h"
sl@0
    35
sl@0
    36
TBool CWsClientWindow::iAbsoluteFading = EFalse;
sl@0
    37
sl@0
    38
const TPoint corner1[1]={TPoint(1,1)};
sl@0
    39
const TPoint corner2[2]={TPoint(2,1),TPoint(1,1)};
sl@0
    40
const TPoint corner3[2]={TPoint(3,1),TPoint(1,2)};
sl@0
    41
const TPoint corner5[4]={TPoint(5,1),TPoint(3,1),TPoint(2,1),TPoint(1,2)};
sl@0
    42
sl@0
    43
/*CWsClientWindow*/
sl@0
    44
sl@0
    45
CWsClientWindow::CWsClientWindow(CWsClient* aOwner, CScreen* aScreen) : CWsWindow(aOwner,WS_HANDLE_WINDOW,aScreen)
sl@0
    46
	{
sl@0
    47
	iWinType=EWinTypeClient;
sl@0
    48
	}
sl@0
    49
sl@0
    50
void CWsClientWindow::ConstructL(const TWsClCmdCreateWindow &aCmd, CWsWindowBase *aParent, TBool aScreenDeviceIsInvalid)
sl@0
    51
	{
sl@0
    52
	CWsWindow::Construct();
sl@0
    53
	NewObjL();
sl@0
    54
	if (aCmd.clientHandle==NULL)
sl@0
    55
		OwnerPanic(EWservPanicNullHandle);
sl@0
    56
#if defined(_DEBUG)
sl@0
    57
	if (IsClientHandleInUse(aCmd.clientHandle))
sl@0
    58
		OwnerPanic(EWservPanicDuplicateHandle);
sl@0
    59
#endif
sl@0
    60
	iPointerFilter=EPointerFilterEnterExit|EPointerFilterMove|EPointerFilterDrag;
sl@0
    61
	iClientHandle=aCmd.clientHandle;
sl@0
    62
	CWsWindow* inherit=static_cast<CWsWindow *>(aParent);
sl@0
    63
	if (aParent->WinType()==EWinTypeGroup)
sl@0
    64
		inherit=RootWindow();
sl@0
    65
	SetPointerCursor(aParent->PointerCursor());
sl@0
    66
	iAbs=inherit->Abs();
sl@0
    67
	iOrigin=aParent->Origin();
sl@0
    68
	iRel.iBr.iX=inherit->Rel().iBr.iX-inherit->Rel().iTl.iX;
sl@0
    69
	iRel.iBr.iY=inherit->Rel().iBr.iY-inherit->Rel().iTl.iY;
sl@0
    70
	switch(aCmd.type)
sl@0
    71
		{
sl@0
    72
		case EWinRedraw:
sl@0
    73
			iRedraw=new(ELeave) CWsRedrawMsgWindow(this);
sl@0
    74
			break;
sl@0
    75
		case EWinBackedUp:
sl@0
    76
			iRedraw=new(ELeave) CWsBackedUpWindow(this, aCmd.displayMode);
sl@0
    77
			iAbs.iBr=iAbs.iTl;
sl@0
    78
			iRel.iBr=iRel.iTl;
sl@0
    79
			break;
sl@0
    80
		case EWinBlank:
sl@0
    81
			iRedraw=new(ELeave) CWsBlankWindow(this);
sl@0
    82
			break;
sl@0
    83
		default:
sl@0
    84
			OwnerPanic(EWservPanicRedrawType);
sl@0
    85
		}
sl@0
    86
	ResetHiddenFlag();
sl@0
    87
	CWsWindowBase::ConstructL(aParent);
sl@0
    88
	if (aScreenDeviceIsInvalid)
sl@0
    89
		{
sl@0
    90
		iFlags|=EFlagScreenDeviceInvalid;
sl@0
    91
		ResetHiddenFlag();
sl@0
    92
		}
sl@0
    93
	SetCornerTypeL(EWindowCornerSquare,0);
sl@0
    94
	iRedraw->ConstructL();
sl@0
    95
	}
sl@0
    96
sl@0
    97
void CWsClientWindow::SetClippedBaseArea(RWsRegion &aRegion) const
sl@0
    98
	{
sl@0
    99
	if(iBaseArea)
sl@0
   100
		{
sl@0
   101
		aRegion.Copy(*iBaseArea);
sl@0
   102
		}
sl@0
   103
	aRegion.ClipRect(iAbs);
sl@0
   104
	}
sl@0
   105
sl@0
   106
void CWsClientWindow::SetOpaqueClippedBaseArea(RWsRegion &aRegion) const
sl@0
   107
	{
sl@0
   108
	if (IsTranslucent())
sl@0
   109
		{
sl@0
   110
		if (iUserDefinedOpaqueRegion)
sl@0
   111
			{
sl@0
   112
			aRegion.Copy(*iUserDefinedOpaqueRegion);
sl@0
   113
			aRegion.ClipRect(iAbs);
sl@0
   114
			}
sl@0
   115
		else
sl@0
   116
			{
sl@0
   117
			aRegion.Clear();
sl@0
   118
			}
sl@0
   119
		}
sl@0
   120
	else
sl@0
   121
		{
sl@0
   122
		SetClippedBaseArea(aRegion);
sl@0
   123
		}
sl@0
   124
	}
sl@0
   125
sl@0
   126
void CWsClientWindow::ResetHiddenFlag()
sl@0
   127
//
sl@0
   128
// Reset the status of the hidden flag based on the current states of the active and invisible flags
sl@0
   129
//
sl@0
   130
	{
sl@0
   131
	CWsClientWindow *parent=static_cast<CWsClientWindow*>(iParent);
sl@0
   132
sl@0
   133
	TBool wasHidden = iFlags&EFlagHidden;
sl@0
   134
	TBool nowHidden = (parent==NULL || 
sl@0
   135
		              (parent->WinType()==EWinTypeClient && !parent->IsVisible()) ||
sl@0
   136
	                  !(iFlags&EFlagActive) ||
sl@0
   137
	                  (iFlags&EFlagInvisible) ||
sl@0
   138
			          (iFlags&EFlagScreenDeviceInvalid));
sl@0
   139
sl@0
   140
	if (nowHidden)
sl@0
   141
		{
sl@0
   142
		iFlags|=EFlagHidden;
sl@0
   143
		iFlags&=~EFlagDrawnToScreen;
sl@0
   144
		}
sl@0
   145
	else
sl@0
   146
		{
sl@0
   147
		iFlags&=~EFlagHidden;
sl@0
   148
		}
sl@0
   149
	if ((!nowHidden) != (!wasHidden))
sl@0
   150
		{
sl@0
   151
		// intentionally call the screen directly
sl@0
   152
		iScreen->ScheduleRegionUpdate(&iVisibleRegion);
sl@0
   153
		}
sl@0
   154
	}
sl@0
   155
	
sl@0
   156
void CWsClientWindow::ResetHiddenFlags()
sl@0
   157
	{
sl@0
   158
	CWsClientWindow *win=this;
sl@0
   159
	FOREVER
sl@0
   160
		{
sl@0
   161
		TUint oldHiddenFlag=win->iFlags&EFlagHidden;
sl@0
   162
		win->ResetHiddenFlag();
sl@0
   163
		if ((win->iFlags&EFlagHidden)!=oldHiddenFlag)	// If hidden status hasn't changed nothing to do
sl@0
   164
			{
sl@0
   165
			if (win->Child())
sl@0
   166
				{
sl@0
   167
				win=win->Child();
sl@0
   168
				continue;
sl@0
   169
				}
sl@0
   170
			}
sl@0
   171
		if (win==this)
sl@0
   172
			return;
sl@0
   173
		while(!win->NextSibling())
sl@0
   174
			{
sl@0
   175
			win=(CWsClientWindow *)win->BaseParent();
sl@0
   176
			if (win==this)
sl@0
   177
				return;
sl@0
   178
			}
sl@0
   179
		win=win->NextSibling();
sl@0
   180
		}
sl@0
   181
	}
sl@0
   182
sl@0
   183
void CWsClientWindow::OffsetBaseArea(const TPoint &aOffset)
sl@0
   184
	{
sl@0
   185
	iBaseArea->Offset(aOffset);
sl@0
   186
	}
sl@0
   187
sl@0
   188
void CWsClientWindow::CalcBaseArea()
sl@0
   189
//
sl@0
   190
// The windows basic area before any clipping is done
sl@0
   191
//
sl@0
   192
	{
sl@0
   193
	TInt cornerType=iCornerData&ECornerTypeMask;
sl@0
   194
	if (cornerType==EWindowCornerRegion)
sl@0
   195
		iBaseArea->ClipRect(FullRect());
sl@0
   196
	else
sl@0
   197
		{
sl@0
   198
		TSize size=Size();
sl@0
   199
		iBaseArea->Clear();
sl@0
   200
		const TPoint *corners=NULL;
sl@0
   201
		TInt count=0;
sl@0
   202
		switch(cornerType)
sl@0
   203
			{
sl@0
   204
			case EWindowCorner1:
sl@0
   205
				count=sizeof(corner1)/sizeof(TPoint);
sl@0
   206
				corners=corner1;
sl@0
   207
				break;
sl@0
   208
			case EWindowCorner2:
sl@0
   209
				count=sizeof(corner2)/sizeof(TPoint);
sl@0
   210
				corners=corner2;
sl@0
   211
				break;
sl@0
   212
			case EWindowCorner3:
sl@0
   213
				count=sizeof(corner3)/sizeof(TPoint);
sl@0
   214
				corners=corner3;
sl@0
   215
				break;
sl@0
   216
			case EWindowCorner5:
sl@0
   217
				count=sizeof(corner5)/sizeof(TPoint);
sl@0
   218
				corners=corner5;
sl@0
   219
				break;
sl@0
   220
			default:
sl@0
   221
				break;
sl@0
   222
			}
sl@0
   223
		TInt top=0;
sl@0
   224
		TInt bot=size.iHeight;
sl@0
   225
		for(TInt index=0;index<count;index++)
sl@0
   226
			{
sl@0
   227
			TInt xadjust=corners[index].iX;
sl@0
   228
			TInt yadjust=corners[index].iY;
sl@0
   229
			if ((iCornerData&(EWindowCornerNotTL|EWindowCornerNotTR))!=(EWindowCornerNotTL|EWindowCornerNotTR))
sl@0
   230
				{
sl@0
   231
				iBaseArea->AddRect(TRect(iCornerData&EWindowCornerNotTL?0:xadjust,top,
sl@0
   232
										 size.iWidth-(iCornerData&EWindowCornerNotTR?0:xadjust),top+yadjust));
sl@0
   233
				top+=yadjust;
sl@0
   234
				}
sl@0
   235
			if ((iCornerData&(EWindowCornerNotBL|EWindowCornerNotBR))!=(EWindowCornerNotBL|EWindowCornerNotBR))
sl@0
   236
				{
sl@0
   237
				iBaseArea->AddRect(TRect(iCornerData&EWindowCornerNotBL?0:xadjust,bot-yadjust,
sl@0
   238
										 size.iWidth-(iCornerData&EWindowCornerNotBR?0:xadjust),bot));
sl@0
   239
				bot-=yadjust;
sl@0
   240
				}
sl@0
   241
			}
sl@0
   242
		iBaseArea->AddRect(TRect(0,top,size.iWidth,bot));
sl@0
   243
		iBaseArea->Offset(Origin());
sl@0
   244
		iBaseArea->ClipRect(FullRect());
sl@0
   245
		iBaseArea->Sort();
sl@0
   246
		}
sl@0
   247
	}
sl@0
   248
sl@0
   249
void CWsClientWindow::GenerateArea(RWsRegion &aArea, TBool aClipTranslucent) const
sl@0
   250
//
sl@0
   251
// Create the window area list.
sl@0
   252
//
sl@0
   253
	{
sl@0
   254
	aArea.Clear();
sl@0
   255
	if (IsVisible())
sl@0
   256
		{
sl@0
   257
		aArea.Copy(*iBaseArea);
sl@0
   258
		aArea.ClipRect(iAbs);
sl@0
   259
		const CWsClientWindow *win=this;
sl@0
   260
		FOREVER
sl@0
   261
			{
sl@0
   262
			if (win->IsTopClientWindow())
sl@0
   263
				break;
sl@0
   264
			ClipWindows(aArea,(CWsClientWindow *)win->BaseParent()->BaseChild(),win,aClipTranslucent);
sl@0
   265
			win=(CWsClientWindow *)win->iParent;
sl@0
   266
			}
sl@0
   267
		TInt tidyCount=0;
sl@0
   268
		for(const CWsClientWindow *cwin=RootWindow()->FirstTopClientWindow();aArea.Count() && cwin!=win;cwin=cwin->NextSiblingMultiParent())
sl@0
   269
			{
sl@0
   270
			if (!tidyCount--)
sl@0
   271
				{
sl@0
   272
				aArea.Tidy();
sl@0
   273
				tidyCount=ETidyCountSetting;	// Tidy every ETidyCountSetting times around
sl@0
   274
				}
sl@0
   275
			if (cwin->IsVisible())
sl@0
   276
				{
sl@0
   277
				if (cwin->IsTranslucent() && !aClipTranslucent)
sl@0
   278
					{
sl@0
   279
					if (cwin->iUserDefinedOpaqueRegion)
sl@0
   280
						{
sl@0
   281
						aArea.SubRegion(*cwin->iUserDefinedOpaqueRegion);
sl@0
   282
						}
sl@0
   283
					}
sl@0
   284
				else
sl@0
   285
					{
sl@0
   286
					aArea.SubRegion(*cwin->iBaseArea);
sl@0
   287
					}
sl@0
   288
				}
sl@0
   289
			}
sl@0
   290
		aArea.Tidy();
sl@0
   291
		}
sl@0
   292
	}
sl@0
   293
sl@0
   294
void CWsClientWindow::ClipWindows(TRegion &region,const CWsClientWindow *start, const CWsClientWindow *end, TBool aClipTranslucent)
sl@0
   295
//
sl@0
   296
// Remove out of the region the opaque part of the abs rect of all the windows starting from 'start'
sl@0
   297
// along the sibling list to (and not including) the end window.
sl@0
   298
//
sl@0
   299
	{
sl@0
   300
	for(const CWsClientWindow *win=start;region.Count() && win!=end;win=win->NextSibling())
sl@0
   301
		{
sl@0
   302
		if (win->IsVisible())
sl@0
   303
			{
sl@0
   304
			if (win->IsTranslucent() && !aClipTranslucent)
sl@0
   305
				{
sl@0
   306
				if (win->iUserDefinedOpaqueRegion)
sl@0
   307
					{
sl@0
   308
					region.SubRegion(*win->iUserDefinedOpaqueRegion);
sl@0
   309
					}
sl@0
   310
				}
sl@0
   311
			else
sl@0
   312
				{
sl@0
   313
				region.SubRegion(*win->iBaseArea);
sl@0
   314
				}
sl@0
   315
			}
sl@0
   316
		}
sl@0
   317
	}
sl@0
   318
sl@0
   319
void CWsClientWindow::GenerateTopRegion(RWsRegion& aRegion) const
sl@0
   320
	{
sl@0
   321
	GenerateArea(aRegion,ETrue);
sl@0
   322
	if (iChild)
sl@0
   323
		ClipWindows(aRegion,Child(),NULL,ETrue);
sl@0
   324
	}
sl@0
   325
sl@0
   326
void CWsClientWindow::GenerateWindowRegion(RWsRegion &aRegion) const
sl@0
   327
//
sl@0
   328
// Calculate the windows clipping region without using the usual stored iArea or iRegion fields
sl@0
   329
// this function is used by the screen backup code to calculate "what if" regions to work out
sl@0
   330
// whether something would be visible if the backed up window didn't exist, on this basis we
sl@0
   331
// don't want to modify the existing copies of iArea & iRegion.
sl@0
   332
//
sl@0
   333
	{
sl@0
   334
	GenerateArea(aRegion,EFalse);
sl@0
   335
	if (iChild)
sl@0
   336
		ClipWindows(aRegion,Child(),NULL,EFalse);
sl@0
   337
	}
sl@0
   338
sl@0
   339
void CWsClientWindow::RecalcChildAbs(const TPoint *aOffset)
sl@0
   340
	{
sl@0
   341
	CWsClientWindow *win=this;
sl@0
   342
	FOREVER
sl@0
   343
		{
sl@0
   344
		FOREVER
sl@0
   345
			{
sl@0
   346
			win->SetAbsFromRel();
sl@0
   347
			if (aOffset)
sl@0
   348
				win->OffsetBaseArea(*aOffset);
sl@0
   349
			if (win->Child()==NULL)
sl@0
   350
				break;
sl@0
   351
			win=win->Child();
sl@0
   352
			}
sl@0
   353
		FOREVER
sl@0
   354
			{
sl@0
   355
			if (win==this)
sl@0
   356
				return;
sl@0
   357
			if (win->NextSibling()!=NULL)
sl@0
   358
				{
sl@0
   359
				win=win->NextSibling();
sl@0
   360
				break;
sl@0
   361
				}
sl@0
   362
			win=(CWsClientWindow *)win->iParent;	// The cast is safe as the loop is aborted when win==this
sl@0
   363
			}
sl@0
   364
		}
sl@0
   365
	}
sl@0
   366
sl@0
   367
void CWsClientWindow::SetAbsFromRel()
sl@0
   368
	{
sl@0
   369
	iOrigin=iRel.iTl+iParent->Origin();
sl@0
   370
	iAbs=iRel;
sl@0
   371
	iAbs.Move(iParent->Origin());
sl@0
   372
	iAbs.Intersection(iParent->AbsRect());
sl@0
   373
	}
sl@0
   374
sl@0
   375
void CWsClientWindow::SetExtentL(const TPoint *aPos,const TSize *aSize)
sl@0
   376
	{
sl@0
   377
	if (iParent==NULL)
sl@0
   378
		OwnerPanic(EWservPanicParentDeleted);
sl@0
   379
	TPoint offset = TPoint(0,0);
sl@0
   380
	TSize oldSize;
sl@0
   381
	TSize newSize;
sl@0
   382
	TBool sizeChanged = EFalse;
sl@0
   383
	TBool posChanged = EFalse;
sl@0
   384
	
sl@0
   385
	if (aPos)
sl@0
   386
		{
sl@0
   387
		offset = *aPos+iParent->Origin()-iOrigin;
sl@0
   388
		if (offset.iX != 0 || offset.iY != 0)
sl@0
   389
			{
sl@0
   390
			posChanged = ETrue;
sl@0
   391
			}
sl@0
   392
		}
sl@0
   393
		
sl@0
   394
	if (posChanged)
sl@0
   395
		{
sl@0
   396
		TWalkWindowTreeScheduleRedraws wwt;
sl@0
   397
		WalkWindowTree(wwt, EWalkChildren);
sl@0
   398
		}
sl@0
   399
	
sl@0
   400
	if (aSize)
sl@0
   401
		{
sl@0
   402
		newSize=*aSize;
sl@0
   403
		if (newSize.iWidth<0)
sl@0
   404
			newSize.iWidth=0;
sl@0
   405
		if (newSize.iHeight<0)
sl@0
   406
			newSize.iHeight=0;
sl@0
   407
		// This should be the only part of resizing that can fail
sl@0
   408
		// and it can only fail for backedup windows.
sl@0
   409
		iRedraw->PrepareForResizeL(newSize,oldSize);
sl@0
   410
		sizeChanged = *aSize != iRel.Size();
sl@0
   411
		}
sl@0
   412
sl@0
   413
	if (posChanged)
sl@0
   414
		{
sl@0
   415
		iRel.Move(offset);
sl@0
   416
		RecalcChildAbs(&offset);
sl@0
   417
		TWalkWindowTreeOffsetTransparentRegions offsetTransparent(offset);
sl@0
   418
		WalkWindowTree(offsetTransparent, EWalkChildren);
sl@0
   419
		}
sl@0
   420
sl@0
   421
	if (sizeChanged)
sl@0
   422
		{
sl@0
   423
		iRel.SetSize(newSize);
sl@0
   424
		RecalcChildAbs(NULL);
sl@0
   425
		CalcBaseArea();
sl@0
   426
		iRedraw->Resize(newSize,oldSize);
sl@0
   427
		}
sl@0
   428
sl@0
   429
	if (posChanged || sizeChanged)
sl@0
   430
		{
sl@0
   431
		iRedraw->ClipInvalidRegion(TRect(iRel.Size()));
sl@0
   432
		iRedraw->Moved();
sl@0
   433
		ScheduleRegionUpdate(NULL);
sl@0
   434
		TWalkWindowTreeRecalcOpaque recalcOpaque;
sl@0
   435
		WalkWindowTree(recalcOpaque, EWalkChildren);
sl@0
   436
		}
sl@0
   437
	}
sl@0
   438
sl@0
   439
void CWsClientWindow::Scroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect)
sl@0
   440
	{
sl@0
   441
	if (iParent==NULL)
sl@0
   442
		OwnerPanic(EWservPanicParentDeleted);
sl@0
   443
//
sl@0
   444
	iRedraw->Scroll(aClipRect, aOffset,aRect);
sl@0
   445
//
sl@0
   446
	CWsTop::TriggerRedraws(RootWindow());
sl@0
   447
	}
sl@0
   448
sl@0
   449
void CWsClientWindow::DeleteBaseArea()
sl@0
   450
	{
sl@0
   451
	WS_ASSERT_DEBUG(iBaseArea!=&nullRegion, EWsPanicRegionNull);
sl@0
   452
 	if ((iCornerData&ECornerTypeMask)==EWindowCornerRegion)
sl@0
   453
		((RWsRegion *)iBaseArea)->Destroy();
sl@0
   454
	else
sl@0
   455
		delete iBaseArea;
sl@0
   456
	}
sl@0
   457
sl@0
   458
CWsClientWindow::~CWsClientWindow()
sl@0
   459
	{
sl@0
   460
	iFlags|=EFlagShutDownInProgress;
sl@0
   461
	if (CClick::IsHandler())
sl@0
   462
		{
sl@0
   463
		TWindowCloseData params;
sl@0
   464
		params.iClientHandle=iClientHandle;
sl@0
   465
		//if parent already shutdown (or disconnected) send 0
sl@0
   466
		params.iWindowGroupId=iParent ? WinGroup()->Identifier():0;
sl@0
   467
		CClick::OtherEvent(EEventWindowClose,&params);
sl@0
   468
		}
sl@0
   469
	RemoveAllKeyRects();
sl@0
   470
	while(iWinGcList)
sl@0
   471
		iWinGcList->Deactivate();
sl@0
   472
//
sl@0
   473
	iFlags|=EFlagInvisible;		// First make it invisble
sl@0
   474
	if (iParent)				// In case window wasn't fully constructed
sl@0
   475
		ResetHiddenFlags();
sl@0
   476
//
sl@0
   477
	CWsWindow::Shutdown();      // Two phase destruction
sl@0
   478
sl@0
   479
	DeleteBaseArea();
sl@0
   480
	CWsPointerBuffer::Disconnect(this);
sl@0
   481
	iFlags&=~EFlagShutDownInProgress;
sl@0
   482
	SetUserTransparentRegion(0);
sl@0
   483
	CWsPassword::WindowDestroyed(this);
sl@0
   484
	}
sl@0
   485
sl@0
   486
void CWsClientWindow::Activate()
sl@0
   487
	{
sl@0
   488
	if (iFlags&EFlagActive)
sl@0
   489
		OwnerPanic(EWservPanicWindowActive);
sl@0
   490
	iFlags|=EFlagActive;
sl@0
   491
sl@0
   492
	ResetHiddenFlags();
sl@0
   493
	}
sl@0
   494
sl@0
   495
void CWsClientWindow::SetCornerTypeL(TCornerType aCornerType, TInt aCornerFlags, TRegion *aNewBaseArea)
sl@0
   496
	{
sl@0
   497
	TRegion *baseArea=NULL;
sl@0
   498
	if (aCornerFlags&ECornerTypeMask)
sl@0
   499
		OwnerPanic(EWservPanicCornerParams);
sl@0
   500
 	switch (aCornerType)
sl@0
   501
		{
sl@0
   502
		case EWindowCornerSquare:
sl@0
   503
			baseArea=new(ELeave) TRegionFix<1>();
sl@0
   504
			break;
sl@0
   505
		case EWindowCorner1:
sl@0
   506
			baseArea=new(ELeave) TRegionFix<3>();
sl@0
   507
			break;
sl@0
   508
		case EWindowCorner2:
sl@0
   509
		case EWindowCorner3:
sl@0
   510
			baseArea=new(ELeave) TRegionFix<5>();
sl@0
   511
			break;
sl@0
   512
		case EWindowCorner5:
sl@0
   513
			baseArea=new(ELeave) TRegionFix<9>();
sl@0
   514
			break;
sl@0
   515
		case EWindowCornerRegion:
sl@0
   516
			User::LeaveIfNull(baseArea=aNewBaseArea);
sl@0
   517
			baseArea->Offset(Origin());
sl@0
   518
			break;
sl@0
   519
		default:
sl@0
   520
			OwnerPanic(EWservPanicCornerParams);
sl@0
   521
		}
sl@0
   522
	DeleteBaseArea();
sl@0
   523
	iCornerData=aCornerType;
sl@0
   524
	iCornerData|=aCornerFlags;
sl@0
   525
	iBaseArea=baseArea;
sl@0
   526
	CalcBaseArea();
sl@0
   527
	ScheduleRegionUpdate(NULL);
sl@0
   528
	}
sl@0
   529
sl@0
   530
void CWsClientWindow::SetVisible(TBool aState)
sl@0
   531
	{
sl@0
   532
	if (aState)
sl@0
   533
		{
sl@0
   534
		if (iParent==NULL)
sl@0
   535
			OwnerPanic(EWservPanicParentDeleted);
sl@0
   536
		if (!(iFlags&EFlagInvisible))	// Already visible
sl@0
   537
			return;
sl@0
   538
		iFlags&=~EFlagInvisible;
sl@0
   539
		ResetHiddenFlags();
sl@0
   540
		}
sl@0
   541
	else
sl@0
   542
		{
sl@0
   543
		if (iFlags&EFlagInvisible || !iParent)	// Already invisible or parent has been deleted
sl@0
   544
			return;
sl@0
   545
		TWalkWindowTreePurgeEvents wwt;
sl@0
   546
		WalkWindowTree(wwt,EWalkChildren);		// Destroy all events on this and all children
sl@0
   547
		iFlags|=EFlagInvisible;
sl@0
   548
		ResetHiddenFlags();
sl@0
   549
		}
sl@0
   550
	}
sl@0
   551
sl@0
   552
void CWsClientWindow::CommandL(TInt aOpcode, const TAny *aCmdData)
sl@0
   553
	{
sl@0
   554
#ifdef _DEBUG
sl@0
   555
	// Save root window for performing CheckTree at the end of this func.
sl@0
   556
	// When aOpcode is EWsWinOpFree, this object would've been destroyed
sl@0
   557
	// and a call to RootWindow() in that case would be impossible
sl@0
   558
	CWsRootWindow* rootWindow=RootWindow();
sl@0
   559
#endif
sl@0
   560
	TWsWinCmdUnion pData;
sl@0
   561
	pData.any=aCmdData;
sl@0
   562
	if (CWsWindowBase::CommandL(aOpcode,pData)==EFalse)
sl@0
   563
		{
sl@0
   564
		switch(aOpcode)
sl@0
   565
			{
sl@0
   566
			case EWsWinOpActivate:
sl@0
   567
				Activate();
sl@0
   568
				break;
sl@0
   569
			case EWsWinOpSetPos:
sl@0
   570
				SetExtentL(pData.pos,NULL);
sl@0
   571
				break;
sl@0
   572
			case EWsWinOpSetExtent:
sl@0
   573
			case EWsWinOpSetExtentErr:
sl@0
   574
				SetExtentL(&pData.SetEx->pos,&pData.SetEx->size);
sl@0
   575
				break;
sl@0
   576
			case EWsWinOpSetSize:
sl@0
   577
			case EWsWinOpSetSizeErr:
sl@0
   578
				SetExtentL(NULL,pData.size);
sl@0
   579
				break;
sl@0
   580
			case EWsWinOpInquireOffset:
sl@0
   581
				CWsClient::ReplyPoint(InquireOffset(*pData.UInt));
sl@0
   582
				break;
sl@0
   583
			case EWsWinOpPosition:
sl@0
   584
				CWsClient::ReplyPoint(iRel.iTl);
sl@0
   585
				break; 
sl@0
   586
			case EWsWinOpAbsPosition:
sl@0
   587
				CWsClient::ReplyPoint(iOrigin);
sl@0
   588
				break;
sl@0
   589
			case EWsWinOpSize:
sl@0
   590
				CWsClient::ReplySize(iRel.Size());
sl@0
   591
				break;
sl@0
   592
			case EWsWinOpTestInvariant:
sl@0
   593
				SetReply(EFalse);
sl@0
   594
				break;
sl@0
   595
			case EWsWinOpPointerFilter:
sl@0
   596
				{
sl@0
   597
				TUint old=iPointerFilter;
sl@0
   598
				iPointerFilter&=~pData.PointerFilter->mask;
sl@0
   599
				iPointerFilter|=pData.PointerFilter->mask&pData.PointerFilter->flags;
sl@0
   600
				if (old&EPointerFilterEnterExit)
sl@0
   601
					WsPointer::ReLogWindow(this);
sl@0
   602
				}
sl@0
   603
				break;
sl@0
   604
			case EWsWinOpSetPointerGrab:
sl@0
   605
				if (*pData.Bool==EFalse)
sl@0
   606
					iFlags&=~EFlagPointerGrab;
sl@0
   607
				else
sl@0
   608
					iFlags|=EFlagPointerGrab;
sl@0
   609
				break;
sl@0
   610
			case EWsWinOpClaimPointerGrab:
sl@0
   611
				if (!iParent)
sl@0
   612
					OwnerPanic(EWservPanicParentDeleted);
sl@0
   613
				WsPointer::ClaimGrab(this,*pData.Bool);
sl@0
   614
				break;
sl@0
   615
			case EWsWinOpSetPointerCapture:
sl@0
   616
				iFlags&=~(EFlagPointerCaptured|EFlagPointerCaptureDragDrop|EFlagPointerCaptureAllGroups);
sl@0
   617
				if ((*pData.UInt)&RWindowBase::TCaptureFlagEnabled)
sl@0
   618
					{
sl@0
   619
					iFlags|=EFlagPointerCaptured;
sl@0
   620
					if ((*pData.UInt)&RWindowBase::TCaptureFlagDragDrop)
sl@0
   621
						iFlags|=EFlagPointerCaptureDragDrop;
sl@0
   622
					if ((*pData.UInt)&RWindowBase::TCaptureFlagAllGroups)
sl@0
   623
						iFlags|=EFlagPointerCaptureAllGroups;
sl@0
   624
					
sl@0
   625
					}
sl@0
   626
				WsPointer::ReLogCurrentWindow();
sl@0
   627
				break;
sl@0
   628
			case EWsWinOpSetPointerCapturePriority:
sl@0
   629
				iPointerCapturePriority=*pData.Int;
sl@0
   630
				break;
sl@0
   631
			case EWsWinOpGetPointerCapturePriority:
sl@0
   632
				SetReply(iPointerCapturePriority);
sl@0
   633
				break;
sl@0
   634
			case EWsWinOpSetVisible:
sl@0
   635
				SetVisible(*pData.Bool);
sl@0
   636
				break;
sl@0
   637
			case EWsWinOpScroll:
sl@0
   638
				{
sl@0
   639
				TPoint origin(0,0);
sl@0
   640
				TRect src(TRect(origin,iRel.Size()));
sl@0
   641
				src.Move(-pData.ScrollRect->offset);
sl@0
   642
				Scroll(TRect(TPoint(0,0),iRel.Size()),pData.ScrollRect->offset,src);
sl@0
   643
				}
sl@0
   644
				break;
sl@0
   645
			case EWsWinOpScrollClip:
sl@0
   646
				{
sl@0
   647
				TPoint origin(0,0);
sl@0
   648
				TRect src(TRect(origin,iRel.Size()));
sl@0
   649
				src.Move(-pData.ScrollRect->offset);
sl@0
   650
				TRect clip(pData.ScrollRect->clip);
sl@0
   651
				Scroll(clip,pData.ScrollRect->offset,src);
sl@0
   652
				}
sl@0
   653
				break;
sl@0
   654
			case EWsWinOpScrollRect:
sl@0
   655
				{
sl@0
   656
				TRect src(pData.ScrollRect->rect);
sl@0
   657
				Scroll(TRect(TPoint(0,0),iRel.Size()),pData.ScrollRect->offset,src);
sl@0
   658
				}
sl@0
   659
				break;
sl@0
   660
			case EWsWinOpScrollClipRect:
sl@0
   661
				{
sl@0
   662
				TRect src(pData.ScrollRect->rect);
sl@0
   663
				TRect clip(pData.ScrollRect->clip);
sl@0
   664
				Scroll(clip, pData.ScrollRect->offset,src);
sl@0
   665
				}
sl@0
   666
				break;
sl@0
   667
			case EWsWinOpSetOrdinalPositionPri:
sl@0
   668
				iOrdinalPriority=pData.OrdinalPos->ordinalPriority;
sl@0
   669
				SetOrdinalPosition(pData.OrdinalPos->pos);
sl@0
   670
				break;
sl@0
   671
			case EWsWinOpSetShadowHeight:
sl@0
   672
				if ((*pData.Int)<0)
sl@0
   673
					OwnerPanic(EWservPanicNegativeShadowHeight);
sl@0
   674
				break;
sl@0
   675
			case EWsWinOpShadowDisabled:
sl@0
   676
				break;
sl@0
   677
			case EWsWinOpSetCornerType:
sl@0
   678
				SetCornerTypeL(pData.SetCornerType->type, pData.SetCornerType->flags);
sl@0
   679
				break;
sl@0
   680
			case EWsWinOpSetShape:
sl@0
   681
				SetCornerTypeL(EWindowCornerRegion,0,GetRegionFromClientL(iWsOwner, *pData.Int));
sl@0
   682
				break;
sl@0
   683
			case EWsWinOpRequiredDisplayMode:
sl@0
   684
				if (Backup()!=NULL)
sl@0
   685
					OwnerPanic(EWservPanicBackupDisplayMode);
sl@0
   686
				SetReply(DisplayMode());
sl@0
   687
				break;
sl@0
   688
			case EWsWinOpGetDisplayMode:
sl@0
   689
				SetReply(DisplayMode());
sl@0
   690
				break;
sl@0
   691
			case EWsWinOpRequestPointerRepeatEvent:
sl@0
   692
				if (!iParent)
sl@0
   693
					OwnerPanic(EWservPanicParentDeleted);
sl@0
   694
				WsPointer::RequestPointerRepeatEvent(this,pData.RequestPointerRepeatEvent->time,pData.RequestPointerRepeatEvent->rect);
sl@0
   695
				break;
sl@0
   696
			case EWsWinOpCancelPointerRepeatEventRequest:
sl@0
   697
				WsPointer::CancelPointerRepeatEventRequest();
sl@0
   698
				break;
sl@0
   699
			case EWsWinOpAllocPointerMoveBuffer:
sl@0
   700
				CWsPointerBuffer::ConnectL(this,pData.AllocPointerMoveBuffer->maxNumPoints,pData.AllocPointerMoveBuffer->flags);
sl@0
   701
				iFlags|=EFlagUsingPointerBuffer|EFlagHasPointerBuffer;
sl@0
   702
				break;
sl@0
   703
			case EWsWinOpFreePointerMoveBuffer:
sl@0
   704
				CWsPointerBuffer::Disconnect(this);
sl@0
   705
				iFlags&=~(EFlagUsingPointerBuffer|EFlagHasPointerBuffer);
sl@0
   706
				break;
sl@0
   707
			case EWsWinOpRetrievePointerMoveBuffer:
sl@0
   708
				CWsPointerBuffer::RetrievePointerMoveBuffer(this,*pData.Int);
sl@0
   709
				break;
sl@0
   710
			case EWsWinOpEnablePointerMoveBuffer:
sl@0
   711
				if (!(iFlags&EFlagHasPointerBuffer))
sl@0
   712
					OwnerPanic(EWservPanicNoPointerBuffer);
sl@0
   713
				iFlags|=EFlagUsingPointerBuffer;
sl@0
   714
				break;
sl@0
   715
			case EWsWinOpDisablePointerMoveBuffer:
sl@0
   716
				iFlags&=~EFlagUsingPointerBuffer; 
sl@0
   717
				/*Fall Through*/
sl@0
   718
			case EWsWinOpDiscardPointerMoveBuffer:	
sl@0
   719
				CWsPointerBuffer::DiscardPointerMoveBuffer(this);
sl@0
   720
				break;
sl@0
   721
			case EWsWinOpAddKeyRect:
sl@0
   722
				AddKeyRectL(pData.AddKeyRect->rect, pData.AddKeyRect->scanCode, pData.AddKeyRect->activatedByPointerSwitchOn);
sl@0
   723
				break;
sl@0
   724
			case EWsWinOpRemoveAllKeyRects:
sl@0
   725
				RemoveAllKeyRects();
sl@0
   726
				break;
sl@0
   727
			case EWsWinOpPasswordWindow:
sl@0
   728
				if (!iParent)
sl@0
   729
					OwnerPanic(EWservPanicParentDeleted);
sl@0
   730
				CWsPassword::SetPasswordWindowL(this, *pData.PasswordMode);
sl@0
   731
				break;
sl@0
   732
			case EWsWinOpEnableBackup:
sl@0
   733
				if (!iParent)
sl@0
   734
					OwnerPanic(EWservPanicParentDeleted);
sl@0
   735
				if (*pData.UInt==0)
sl@0
   736
					iBackupsRequested|=EWindowBackupAreaBehind;		//For backwards compatibility
sl@0
   737
				else
sl@0
   738
					iBackupsRequested|=*pData.UInt;
sl@0
   739
				break;
sl@0
   740
			case EWsWinOpFadeBehind:
sl@0
   741
				{
sl@0
   742
				if (!iParent)
sl@0
   743
					OwnerPanic(EWservPanicParentDeleted);
sl@0
   744
				TUint8 blackMap;
sl@0
   745
				TUint8 whiteMap;
sl@0
   746
				iScreen->GetFadingParams(blackMap,whiteMap);
sl@0
   747
				SetFadeBehind(*pData.Bool);
sl@0
   748
				TWalkWindowTreeSetFaded wwt(*pData.Bool,this,blackMap,whiteMap);
sl@0
   749
				WalkWindowTree(wwt,EWalkBehind);
sl@0
   750
				if (CWsTop::IsFadeEnabled()) 
sl@0
   751
					{
sl@0
   752
					Screen()->AcceptFadeRequest( this, *pData.Bool, ETrue, EFalse  );
sl@0
   753
					}
sl@0
   754
				}
sl@0
   755
				break;
sl@0
   756
			case EWsWinOpGetIsFaded:
sl@0
   757
				SetReply(iFadeCount);
sl@0
   758
				break;
sl@0
   759
			case EWsWinOpGetIsNonFading:
sl@0
   760
				SetReply(iFlags&EFlagNonFadingWindow);
sl@0
   761
				break;
sl@0
   762
			case EWsWinOpMoveToGroup:
sl@0
   763
				if (!iParent)
sl@0
   764
					OwnerPanic(EWservPanicParentDeleted);
sl@0
   765
				if (iParent->WinType()!=EWinTypeGroup)
sl@0
   766
					OwnerPanic(EWservPanicNotTopClient);
sl@0
   767
				DoMoveWindowToGroupL(*pData.Int);
sl@0
   768
				break;
sl@0
   769
			case EWsWinOpTestLowPriorityRedraw:
sl@0
   770
				{
sl@0
   771
				// This is purely for testing purposes
sl@0
   772
				// Returns the redraw priority
sl@0
   773
				TUint priority=0;
sl@0
   774
				TPckgBuf<TUint> priBuf;
sl@0
   775
				priority=WsOwner()->RedrawQueue()->RedrawPriority((CWsWindowRedraw*)this->iRedraw);
sl@0
   776
				priBuf()=priority;
sl@0
   777
				CWsClient::ReplyBuf(priBuf);
sl@0
   778
				}
sl@0
   779
				break;
sl@0
   780
			case EWsWinOpEnableVisibilityChangeEvents:
sl@0
   781
				iFlags |= EFlagGeneratesVisibilityEvents;
sl@0
   782
				if (iFlags&EFlagActive)
sl@0
   783
					{
sl@0
   784
					iScreen->DoRedrawNow();
sl@0
   785
					PossibleVisibilityChangedEvent(ETrue);
sl@0
   786
					}
sl@0
   787
				break;
sl@0
   788
			case EWsWinOpDisableVisibilityChangeEvents:
sl@0
   789
				iFlags &= ~EFlagGeneratesVisibilityEvents;
sl@0
   790
				break;
sl@0
   791
			case EWsWinOpSetTransparentRegion:
sl@0
   792
				{
sl@0
   793
				if (IsTranslucent())
sl@0
   794
					{
sl@0
   795
					TInt recs=*pData.Int;
sl@0
   796
	 				RWsRegion* reg=recs>0? GetRegionFromClientL(iWsOwner,recs) : new(ELeave) RWsRegion;
sl@0
   797
	 				SetUserTransparentRegion(reg);
sl@0
   798
					SetReply(KErrNone);
sl@0
   799
					}
sl@0
   800
				else
sl@0
   801
					{
sl@0
   802
					OwnerPanic(EWservPanicTransparencyObjNotCreated);	
sl@0
   803
					}				
sl@0
   804
				}
sl@0
   805
				break;
sl@0
   806
			case EWsWinOpSetTransparencyPolicy:
sl@0
   807
				{
sl@0
   808
				if (IsTranslucent())
sl@0
   809
					SetReply(KErrNone);
sl@0
   810
				else
sl@0
   811
					OwnerPanic(EWservPanicTransparencyObjNotCreated);
sl@0
   812
				}
sl@0
   813
				break;
sl@0
   814
			case EWsWinOpSetTransparencyAlphaChannel:
sl@0
   815
				{
sl@0
   816
				iFlags |= static_cast<TUint>(EFlagHasAlpha);
sl@0
   817
				SetReply(KErrNone);
sl@0
   818
				break;
sl@0
   819
				}
sl@0
   820
			default:
sl@0
   821
				if (iRedraw->CommandL(aOpcode,pData)==EFalse)
sl@0
   822
					{
sl@0
   823
					OwnerPanic(EWservPanicOpcode);
sl@0
   824
					}
sl@0
   825
			}
sl@0
   826
		}
sl@0
   827
#if defined(_DEBUG)
sl@0
   828
	rootWindow->CheckTree();
sl@0
   829
#endif
sl@0
   830
	}
sl@0
   831
sl@0
   832
void CWsClientWindow::GcActivated(CWsGc *aGc)
sl@0
   833
	{
sl@0
   834
	aGc->SetNextWinGc(iWinGcList);
sl@0
   835
	iWinGcList=aGc;
sl@0
   836
	}
sl@0
   837
sl@0
   838
void CWsClientWindow::GcDeactivated(CWsGc *aGc)
sl@0
   839
	{
sl@0
   840
	if (aGc==iWinGcList)
sl@0
   841
		iWinGcList=aGc->NextWinGc();
sl@0
   842
	else
sl@0
   843
		{
sl@0
   844
		CWsGc *gc=iWinGcList;
sl@0
   845
		CWsGc *next;
sl@0
   846
		FOREVER
sl@0
   847
			{
sl@0
   848
			next=gc->NextWinGc();
sl@0
   849
			WS_ASSERT_DEBUG(next!=NULL, EWsPanicBadActiveGcList);
sl@0
   850
			if (next==aGc)
sl@0
   851
				{
sl@0
   852
				gc->SetNextWinGc(next->NextWinGc());
sl@0
   853
				break;
sl@0
   854
				}
sl@0
   855
			gc=next;
sl@0
   856
			}
sl@0
   857
		}
sl@0
   858
	aGc->SetNextWinGc(NULL);
sl@0
   859
	}
sl@0
   860
sl@0
   861
void CWsClientWindow::ReactivateGcs()
sl@0
   862
	{
sl@0
   863
	for (CWsGc * gc = iWinGcList; gc; gc = gc->NextWinGc())
sl@0
   864
		{
sl@0
   865
		gc->Reactivate();
sl@0
   866
		}
sl@0
   867
	}
sl@0
   868
sl@0
   869
void CWsClientWindow::OffsetUserTransparentRegion(const TPoint& aOffset)
sl@0
   870
	{
sl@0
   871
	if (iUserDefinedTransparentRegion)
sl@0
   872
		{
sl@0
   873
		iUserDefinedTransparentRegion->Offset(aOffset);
sl@0
   874
		}	
sl@0
   875
	}
sl@0
   876
sl@0
   877
void CWsClientWindow::SetUserTransparentRegion(RWsRegion* aRegion)
sl@0
   878
	{
sl@0
   879
	if (iUserDefinedTransparentRegion)
sl@0
   880
		{
sl@0
   881
		iUserDefinedTransparentRegion->Close();
sl@0
   882
		delete iUserDefinedTransparentRegion;
sl@0
   883
		iUserDefinedTransparentRegion = 0;
sl@0
   884
		}
sl@0
   885
		
sl@0
   886
	if (aRegion)
sl@0
   887
		{		
sl@0
   888
		aRegion->Offset(iOrigin);
sl@0
   889
		iUserDefinedTransparentRegion=aRegion;
sl@0
   890
		}
sl@0
   891
		
sl@0
   892
	SetUserOpaqueRegion();
sl@0
   893
	}
sl@0
   894
sl@0
   895
void CWsClientWindow::SetUserOpaqueRegion()
sl@0
   896
	{
sl@0
   897
	if (iUserDefinedOpaqueRegion)
sl@0
   898
		{
sl@0
   899
		iUserDefinedOpaqueRegion->Close();
sl@0
   900
		delete iUserDefinedOpaqueRegion;
sl@0
   901
		iUserDefinedOpaqueRegion = 0;
sl@0
   902
		}
sl@0
   903
	if (iUserDefinedTransparentRegion)
sl@0
   904
		{
sl@0
   905
		iUserDefinedOpaqueRegion=new RWsRegion;
sl@0
   906
		if (iUserDefinedOpaqueRegion)
sl@0
   907
			{
sl@0
   908
			iUserDefinedOpaqueRegion->Copy(*iBaseArea);
sl@0
   909
			iUserDefinedOpaqueRegion->SubRegion(*iUserDefinedTransparentRegion);
sl@0
   910
			if (iUserDefinedOpaqueRegion->CheckError() || iUserDefinedOpaqueRegion->Count() == 0)
sl@0
   911
				{
sl@0
   912
				iUserDefinedOpaqueRegion->Close();
sl@0
   913
				delete iUserDefinedOpaqueRegion;
sl@0
   914
				iUserDefinedOpaqueRegion = 0;
sl@0
   915
				}
sl@0
   916
			}
sl@0
   917
		}
sl@0
   918
	}
sl@0
   919
sl@0
   920
TUint CWsClientWindow::RedrawPriority(TInt *aShift) const
sl@0
   921
	{
sl@0
   922
	if (IsTopClientWindow())
sl@0
   923
		{
sl@0
   924
		TUint ordinalPos=OrdinalPosition(EFalse);
sl@0
   925
		if (ordinalPos>KWinRedrawPriMaxOrdinal)	// Algorithm only works for upto KWinRedrawPriMaxOrdinal windows,
sl@0
   926
			ordinalPos=KWinRedrawPriMaxOrdinal;	// make all windows after this equal in priority
sl@0
   927
		if (aShift)
sl@0
   928
			*aShift=KWinRedrawPriMaxLevel;
sl@0
   929
		return(ordinalPos<<(KWinRedrawPriMaxLevel*KWinRedrawPriBitsPerLevel));
sl@0
   930
		}
sl@0
   931
	else
sl@0
   932
		{
sl@0
   933
		TUint ordinalPos=OrdinalPosition(EFalse)+1;
sl@0
   934
		if (ordinalPos>KWinRedrawPriMaxOrdinal)	// Algorithm only works upto 15 , make all windows after 15 equal in priority
sl@0
   935
			ordinalPos=KWinRedrawPriMaxOrdinal;
sl@0
   936
		TInt shift;
sl@0
   937
		TUint parent=((CWsClientWindow *)iParent)->RedrawPriority(&shift);
sl@0
   938
		if (shift>0)
sl@0
   939
			shift--;
sl@0
   940
		if (aShift)
sl@0
   941
			*aShift=shift;
sl@0
   942
		return(parent+(ordinalPos<<(shift*KWinRedrawPriBitsPerLevel)));
sl@0
   943
		}
sl@0
   944
	}
sl@0
   945
sl@0
   946
TDblQue<TPointerKeyList> *CWsClientWindow::PointerKeyList() const
sl@0
   947
	{
sl@0
   948
	return(iPointerKeyList);
sl@0
   949
	}
sl@0
   950
sl@0
   951
void CWsClientWindow::AddKeyRectL(const TRect &aRect, TInt aScanCode, TBool aActivatedByPointerSwitchOn)
sl@0
   952
	{
sl@0
   953
	if (!iPointerKeyList)
sl@0
   954
		iPointerKeyList=new(ELeave) TDblQue<TPointerKeyList>(_FOFF(TPointerKeyList,iQue));
sl@0
   955
	TPointerKeyList *pkl=new(ELeave) TPointerKeyList();
sl@0
   956
	iPointerKeyList->AddLast(*pkl);
sl@0
   957
	pkl->iRect=aRect;
sl@0
   958
	pkl->iScanCode=aScanCode;
sl@0
   959
	pkl->iActivatedByPointerSwitchOn=aActivatedByPointerSwitchOn;
sl@0
   960
	}
sl@0
   961
sl@0
   962
void CWsClientWindow::RemoveAllKeyRects()
sl@0
   963
	{
sl@0
   964
	if (iPointerKeyList)
sl@0
   965
		{
sl@0
   966
		TPointerKeyList *pkl=NULL;
sl@0
   967
		for(TDblQueIter<TPointerKeyList> iter(*iPointerKeyList);(pkl=iter++)!=NULL;)
sl@0
   968
			{
sl@0
   969
			pkl->iQue.Deque();
sl@0
   970
			delete pkl;
sl@0
   971
			}
sl@0
   972
		delete iPointerKeyList;
sl@0
   973
		iPointerKeyList=NULL;
sl@0
   974
		}
sl@0
   975
	}
sl@0
   976
sl@0
   977
TBool CWsClientWindow::IsHidden()
sl@0
   978
	{
sl@0
   979
	return (!IsVisible()) || VisibleRegion().IsEmpty();
sl@0
   980
	}
sl@0
   981
sl@0
   982
void CWsClientWindow::SetFaded(TBool aFade,TUint8 aBlackMap,TUint8 aWhiteMap)
sl@0
   983
	{
sl@0
   984
	iBlackMap=aBlackMap;
sl@0
   985
	iWhiteMap=aWhiteMap;
sl@0
   986
	if (iAbsoluteFading) 
sl@0
   987
		{ 
sl@0
   988
		if (aFade) 
sl@0
   989
			{ 
sl@0
   990
			iFadeCount = 1; 
sl@0
   991
			} 
sl@0
   992
		else 
sl@0
   993
			{ 
sl@0
   994
			iFadeCount = 0; 
sl@0
   995
			} 
sl@0
   996
		} 
sl@0
   997
	else 
sl@0
   998
		{ 
sl@0
   999
		if (aFade) 
sl@0
  1000
			{ 
sl@0
  1001
			++iFadeCount; 
sl@0
  1002
			} 
sl@0
  1003
		else if (iFadeCount > 0) 
sl@0
  1004
			{ 
sl@0
  1005
			--iFadeCount; 
sl@0
  1006
			} 
sl@0
  1007
		} 
sl@0
  1008
	}
sl@0
  1009
sl@0
  1010
void CWsClientWindow::ResetHiddenFlagsInParentAndChildren()
sl@0
  1011
	{
sl@0
  1012
	ResetHiddenFlag();
sl@0
  1013
	for(CWsClientWindow* child=Child();child;child=child->NextSibling())
sl@0
  1014
		{
sl@0
  1015
		child->ResetHiddenFlagsInParentAndChildren();
sl@0
  1016
		}
sl@0
  1017
	}
sl@0
  1018
sl@0
  1019
const TRegion& CWsClientWindow::WindowArea() const
sl@0
  1020
	{
sl@0
  1021
	return *iBaseArea;
sl@0
  1022
	}
sl@0
  1023
sl@0
  1024
void CWsClientWindow::Invalidate(const TRect * aRect)
sl@0
  1025
	{
sl@0
  1026
	iRedraw->Invalidate(aRect);
sl@0
  1027
	}
sl@0
  1028
sl@0
  1029
void CWsClientWindow::ScheduleRegionUpdate(const TRegion* aDefinitelyDirty)
sl@0
  1030
	{
sl@0
  1031
	if (IsVisible())
sl@0
  1032
		{
sl@0
  1033
		iScreen->ScheduleRegionUpdate(aDefinitelyDirty);
sl@0
  1034
		}
sl@0
  1035
	}
sl@0
  1036
	
sl@0
  1037
TBool CWsClientWindow::IsDSAHost() const
sl@0
  1038
	{
sl@0
  1039
	TBool res = CWsWindow::IsDSAHost();
sl@0
  1040
	if ( !res )
sl@0
  1041
		{ // check for grace period when DSA is being restarted (after aborting but before client started DSA again)
sl@0
  1042
		res = Screen()->IsDSAClientWindow( this );
sl@0
  1043
		}
sl@0
  1044
	return res;
sl@0
  1045
	}
sl@0
  1046
void CWsClientWindow::SetScreenDeviceValidState(TBool aState)
sl@0
  1047
	{
sl@0
  1048
	if (SetScreenDeviceValidStateFlag(aState))
sl@0
  1049
		ResetHiddenFlags();
sl@0
  1050
	}
sl@0
  1051
sl@0
  1052
TBool CWsClientWindow::SetScreenDeviceValidStateFlag(TBool aState)
sl@0
  1053
	{
sl@0
  1054
	TBool isSet=iFlags&EFlagScreenDeviceInvalid;
sl@0
  1055
	if (!isSet==!aState)
sl@0
  1056
		{
sl@0
  1057
		if (aState)
sl@0
  1058
			iFlags&=~EFlagScreenDeviceInvalid;
sl@0
  1059
		else
sl@0
  1060
			iFlags|=EFlagScreenDeviceInvalid;
sl@0
  1061
		return ETrue;
sl@0
  1062
		}
sl@0
  1063
	return EFalse;
sl@0
  1064
	}
sl@0
  1065
sl@0
  1066
void CWsClientWindow::DoMoveWindowToGroupL(TInt aIdentifier)
sl@0
  1067
	{
sl@0
  1068
	CWsWindowGroup* group=CWsWindowGroup::WindowGroupFromIdentifierL(aIdentifier);
sl@0
  1069
	if (group==iParent)
sl@0
  1070
		return;
sl@0
  1071
	if (group->WsOwner()!=WsOwner())
sl@0
  1072
		User::Leave(KErrNotFound);
sl@0
  1073
	ChangeWindowPosition(0, group);
sl@0
  1074
	CWsTop::TriggerRedraws(RootWindow());
sl@0
  1075
	}
sl@0
  1076
sl@0
  1077
void CWsClientWindow::SetInactive()
sl@0
  1078
	{
sl@0
  1079
	iFlags&=~EFlagActive;
sl@0
  1080
	ResetHiddenFlags();
sl@0
  1081
	}
sl@0
  1082