First public contribution.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Client window functions
23 #include "windowgroup.h"
24 #include "walkwindowtree.h"
33 #include "backedupwindow.h"
34 #include "redrawmsgwindow.h"
36 TBool CWsClientWindow::iAbsoluteFading = EFalse;
38 const TPoint corner1[1]={TPoint(1,1)};
39 const TPoint corner2[2]={TPoint(2,1),TPoint(1,1)};
40 const TPoint corner3[2]={TPoint(3,1),TPoint(1,2)};
41 const TPoint corner5[4]={TPoint(5,1),TPoint(3,1),TPoint(2,1),TPoint(1,2)};
45 CWsClientWindow::CWsClientWindow(CWsClient* aOwner, CScreen* aScreen) : CWsWindow(aOwner,WS_HANDLE_WINDOW,aScreen)
47 iWinType=EWinTypeClient;
50 void CWsClientWindow::ConstructL(const TWsClCmdCreateWindow &aCmd, CWsWindowBase *aParent, TBool aScreenDeviceIsInvalid)
52 CWsWindow::Construct();
54 if (aCmd.clientHandle==NULL)
55 OwnerPanic(EWservPanicNullHandle);
57 if (IsClientHandleInUse(aCmd.clientHandle))
58 OwnerPanic(EWservPanicDuplicateHandle);
60 iPointerFilter=EPointerFilterEnterExit|EPointerFilterMove|EPointerFilterDrag;
61 iClientHandle=aCmd.clientHandle;
62 CWsWindow* inherit=static_cast<CWsWindow *>(aParent);
63 if (aParent->WinType()==EWinTypeGroup)
65 SetPointerCursor(aParent->PointerCursor());
67 iOrigin=aParent->Origin();
68 iRel.iBr.iX=inherit->Rel().iBr.iX-inherit->Rel().iTl.iX;
69 iRel.iBr.iY=inherit->Rel().iBr.iY-inherit->Rel().iTl.iY;
73 iRedraw=new(ELeave) CWsRedrawMsgWindow(this);
76 iRedraw=new(ELeave) CWsBackedUpWindow(this, aCmd.displayMode);
81 iRedraw=new(ELeave) CWsBlankWindow(this);
84 OwnerPanic(EWservPanicRedrawType);
87 CWsWindowBase::ConstructL(aParent);
88 if (aScreenDeviceIsInvalid)
90 iFlags|=EFlagScreenDeviceInvalid;
93 SetCornerTypeL(EWindowCornerSquare,0);
94 iRedraw->ConstructL();
97 void CWsClientWindow::SetClippedBaseArea(RWsRegion &aRegion) const
101 aRegion.Copy(*iBaseArea);
103 aRegion.ClipRect(iAbs);
106 void CWsClientWindow::SetOpaqueClippedBaseArea(RWsRegion &aRegion) const
110 if (iUserDefinedOpaqueRegion)
112 aRegion.Copy(*iUserDefinedOpaqueRegion);
113 aRegion.ClipRect(iAbs);
122 SetClippedBaseArea(aRegion);
126 void CWsClientWindow::ResetHiddenFlag()
128 // Reset the status of the hidden flag based on the current states of the active and invisible flags
131 CWsClientWindow *parent=static_cast<CWsClientWindow*>(iParent);
133 TBool wasHidden = iFlags&EFlagHidden;
134 TBool nowHidden = (parent==NULL ||
135 (parent->WinType()==EWinTypeClient && !parent->IsVisible()) ||
136 !(iFlags&EFlagActive) ||
137 (iFlags&EFlagInvisible) ||
138 (iFlags&EFlagScreenDeviceInvalid));
143 iFlags&=~EFlagDrawnToScreen;
147 iFlags&=~EFlagHidden;
149 if ((!nowHidden) != (!wasHidden))
151 // intentionally call the screen directly
152 iScreen->ScheduleRegionUpdate(&iVisibleRegion);
156 void CWsClientWindow::ResetHiddenFlags()
158 CWsClientWindow *win=this;
161 TUint oldHiddenFlag=win->iFlags&EFlagHidden;
162 win->ResetHiddenFlag();
163 if ((win->iFlags&EFlagHidden)!=oldHiddenFlag) // If hidden status hasn't changed nothing to do
173 while(!win->NextSibling())
175 win=(CWsClientWindow *)win->BaseParent();
179 win=win->NextSibling();
183 void CWsClientWindow::OffsetBaseArea(const TPoint &aOffset)
185 iBaseArea->Offset(aOffset);
188 void CWsClientWindow::CalcBaseArea()
190 // The windows basic area before any clipping is done
193 TInt cornerType=iCornerData&ECornerTypeMask;
194 if (cornerType==EWindowCornerRegion)
195 iBaseArea->ClipRect(FullRect());
200 const TPoint *corners=NULL;
205 count=sizeof(corner1)/sizeof(TPoint);
209 count=sizeof(corner2)/sizeof(TPoint);
213 count=sizeof(corner3)/sizeof(TPoint);
217 count=sizeof(corner5)/sizeof(TPoint);
224 TInt bot=size.iHeight;
225 for(TInt index=0;index<count;index++)
227 TInt xadjust=corners[index].iX;
228 TInt yadjust=corners[index].iY;
229 if ((iCornerData&(EWindowCornerNotTL|EWindowCornerNotTR))!=(EWindowCornerNotTL|EWindowCornerNotTR))
231 iBaseArea->AddRect(TRect(iCornerData&EWindowCornerNotTL?0:xadjust,top,
232 size.iWidth-(iCornerData&EWindowCornerNotTR?0:xadjust),top+yadjust));
235 if ((iCornerData&(EWindowCornerNotBL|EWindowCornerNotBR))!=(EWindowCornerNotBL|EWindowCornerNotBR))
237 iBaseArea->AddRect(TRect(iCornerData&EWindowCornerNotBL?0:xadjust,bot-yadjust,
238 size.iWidth-(iCornerData&EWindowCornerNotBR?0:xadjust),bot));
242 iBaseArea->AddRect(TRect(0,top,size.iWidth,bot));
243 iBaseArea->Offset(Origin());
244 iBaseArea->ClipRect(FullRect());
249 void CWsClientWindow::GenerateArea(RWsRegion &aArea, TBool aClipTranslucent) const
251 // Create the window area list.
257 aArea.Copy(*iBaseArea);
258 aArea.ClipRect(iAbs);
259 const CWsClientWindow *win=this;
262 if (win->IsTopClientWindow())
264 ClipWindows(aArea,(CWsClientWindow *)win->BaseParent()->BaseChild(),win,aClipTranslucent);
265 win=(CWsClientWindow *)win->iParent;
268 for(const CWsClientWindow *cwin=RootWindow()->FirstTopClientWindow();aArea.Count() && cwin!=win;cwin=cwin->NextSiblingMultiParent())
273 tidyCount=ETidyCountSetting; // Tidy every ETidyCountSetting times around
275 if (cwin->IsVisible())
277 if (cwin->IsTranslucent() && !aClipTranslucent)
279 if (cwin->iUserDefinedOpaqueRegion)
281 aArea.SubRegion(*cwin->iUserDefinedOpaqueRegion);
286 aArea.SubRegion(*cwin->iBaseArea);
294 void CWsClientWindow::ClipWindows(TRegion ®ion,const CWsClientWindow *start, const CWsClientWindow *end, TBool aClipTranslucent)
296 // Remove out of the region the opaque part of the abs rect of all the windows starting from 'start'
297 // along the sibling list to (and not including) the end window.
300 for(const CWsClientWindow *win=start;region.Count() && win!=end;win=win->NextSibling())
302 if (win->IsVisible())
304 if (win->IsTranslucent() && !aClipTranslucent)
306 if (win->iUserDefinedOpaqueRegion)
308 region.SubRegion(*win->iUserDefinedOpaqueRegion);
313 region.SubRegion(*win->iBaseArea);
319 void CWsClientWindow::GenerateTopRegion(RWsRegion& aRegion) const
321 GenerateArea(aRegion,ETrue);
323 ClipWindows(aRegion,Child(),NULL,ETrue);
326 void CWsClientWindow::GenerateWindowRegion(RWsRegion &aRegion) const
328 // Calculate the windows clipping region without using the usual stored iArea or iRegion fields
329 // this function is used by the screen backup code to calculate "what if" regions to work out
330 // whether something would be visible if the backed up window didn't exist, on this basis we
331 // don't want to modify the existing copies of iArea & iRegion.
334 GenerateArea(aRegion,EFalse);
336 ClipWindows(aRegion,Child(),NULL,EFalse);
339 void CWsClientWindow::RecalcChildAbs(const TPoint *aOffset)
341 CWsClientWindow *win=this;
346 win->SetAbsFromRel();
348 win->OffsetBaseArea(*aOffset);
349 if (win->Child()==NULL)
357 if (win->NextSibling()!=NULL)
359 win=win->NextSibling();
362 win=(CWsClientWindow *)win->iParent; // The cast is safe as the loop is aborted when win==this
367 void CWsClientWindow::SetAbsFromRel()
369 iOrigin=iRel.iTl+iParent->Origin();
371 iAbs.Move(iParent->Origin());
372 iAbs.Intersection(iParent->AbsRect());
375 void CWsClientWindow::SetExtentL(const TPoint *aPos,const TSize *aSize)
378 OwnerPanic(EWservPanicParentDeleted);
379 TPoint offset = TPoint(0,0);
382 TBool sizeChanged = EFalse;
383 TBool posChanged = EFalse;
387 offset = *aPos+iParent->Origin()-iOrigin;
388 if (offset.iX != 0 || offset.iY != 0)
396 TWalkWindowTreeScheduleRedraws wwt;
397 WalkWindowTree(wwt, EWalkChildren);
403 if (newSize.iWidth<0)
405 if (newSize.iHeight<0)
407 // This should be the only part of resizing that can fail
408 // and it can only fail for backedup windows.
409 iRedraw->PrepareForResizeL(newSize,oldSize);
410 sizeChanged = *aSize != iRel.Size();
416 RecalcChildAbs(&offset);
417 TWalkWindowTreeOffsetTransparentRegions offsetTransparent(offset);
418 WalkWindowTree(offsetTransparent, EWalkChildren);
423 iRel.SetSize(newSize);
424 RecalcChildAbs(NULL);
426 iRedraw->Resize(newSize,oldSize);
429 if (posChanged || sizeChanged)
431 iRedraw->ClipInvalidRegion(TRect(iRel.Size()));
433 ScheduleRegionUpdate(NULL);
434 TWalkWindowTreeRecalcOpaque recalcOpaque;
435 WalkWindowTree(recalcOpaque, EWalkChildren);
439 void CWsClientWindow::Scroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect)
442 OwnerPanic(EWservPanicParentDeleted);
444 iRedraw->Scroll(aClipRect, aOffset,aRect);
446 CWsTop::TriggerRedraws(RootWindow());
449 void CWsClientWindow::DeleteBaseArea()
451 WS_ASSERT_DEBUG(iBaseArea!=&nullRegion, EWsPanicRegionNull);
452 if ((iCornerData&ECornerTypeMask)==EWindowCornerRegion)
453 ((RWsRegion *)iBaseArea)->Destroy();
458 CWsClientWindow::~CWsClientWindow()
460 iFlags|=EFlagShutDownInProgress;
461 if (CClick::IsHandler())
463 TWindowCloseData params;
464 params.iClientHandle=iClientHandle;
465 //if parent already shutdown (or disconnected) send 0
466 params.iWindowGroupId=iParent ? WinGroup()->Identifier():0;
467 CClick::OtherEvent(EEventWindowClose,¶ms);
471 iWinGcList->Deactivate();
473 iFlags|=EFlagInvisible; // First make it invisble
474 if (iParent) // In case window wasn't fully constructed
477 CWsWindow::Shutdown(); // Two phase destruction
480 CWsPointerBuffer::Disconnect(this);
481 iFlags&=~EFlagShutDownInProgress;
482 SetUserTransparentRegion(0);
483 CWsPassword::WindowDestroyed(this);
486 void CWsClientWindow::Activate()
488 if (iFlags&EFlagActive)
489 OwnerPanic(EWservPanicWindowActive);
495 void CWsClientWindow::SetCornerTypeL(TCornerType aCornerType, TInt aCornerFlags, TRegion *aNewBaseArea)
497 TRegion *baseArea=NULL;
498 if (aCornerFlags&ECornerTypeMask)
499 OwnerPanic(EWservPanicCornerParams);
502 case EWindowCornerSquare:
503 baseArea=new(ELeave) TRegionFix<1>();
506 baseArea=new(ELeave) TRegionFix<3>();
510 baseArea=new(ELeave) TRegionFix<5>();
513 baseArea=new(ELeave) TRegionFix<9>();
515 case EWindowCornerRegion:
516 User::LeaveIfNull(baseArea=aNewBaseArea);
517 baseArea->Offset(Origin());
520 OwnerPanic(EWservPanicCornerParams);
523 iCornerData=aCornerType;
524 iCornerData|=aCornerFlags;
527 ScheduleRegionUpdate(NULL);
530 void CWsClientWindow::SetVisible(TBool aState)
535 OwnerPanic(EWservPanicParentDeleted);
536 if (!(iFlags&EFlagInvisible)) // Already visible
538 iFlags&=~EFlagInvisible;
543 if (iFlags&EFlagInvisible || !iParent) // Already invisible or parent has been deleted
545 TWalkWindowTreePurgeEvents wwt;
546 WalkWindowTree(wwt,EWalkChildren); // Destroy all events on this and all children
547 iFlags|=EFlagInvisible;
552 void CWsClientWindow::CommandL(TInt aOpcode, const TAny *aCmdData)
555 // Save root window for performing CheckTree at the end of this func.
556 // When aOpcode is EWsWinOpFree, this object would've been destroyed
557 // and a call to RootWindow() in that case would be impossible
558 CWsRootWindow* rootWindow=RootWindow();
560 TWsWinCmdUnion pData;
562 if (CWsWindowBase::CommandL(aOpcode,pData)==EFalse)
566 case EWsWinOpActivate:
570 SetExtentL(pData.pos,NULL);
572 case EWsWinOpSetExtent:
573 case EWsWinOpSetExtentErr:
574 SetExtentL(&pData.SetEx->pos,&pData.SetEx->size);
576 case EWsWinOpSetSize:
577 case EWsWinOpSetSizeErr:
578 SetExtentL(NULL,pData.size);
580 case EWsWinOpInquireOffset:
581 CWsClient::ReplyPoint(InquireOffset(*pData.UInt));
583 case EWsWinOpPosition:
584 CWsClient::ReplyPoint(iRel.iTl);
586 case EWsWinOpAbsPosition:
587 CWsClient::ReplyPoint(iOrigin);
590 CWsClient::ReplySize(iRel.Size());
592 case EWsWinOpTestInvariant:
595 case EWsWinOpPointerFilter:
597 TUint old=iPointerFilter;
598 iPointerFilter&=~pData.PointerFilter->mask;
599 iPointerFilter|=pData.PointerFilter->mask&pData.PointerFilter->flags;
600 if (old&EPointerFilterEnterExit)
601 WsPointer::ReLogWindow(this);
604 case EWsWinOpSetPointerGrab:
605 if (*pData.Bool==EFalse)
606 iFlags&=~EFlagPointerGrab;
608 iFlags|=EFlagPointerGrab;
610 case EWsWinOpClaimPointerGrab:
612 OwnerPanic(EWservPanicParentDeleted);
613 WsPointer::ClaimGrab(this,*pData.Bool);
615 case EWsWinOpSetPointerCapture:
616 iFlags&=~(EFlagPointerCaptured|EFlagPointerCaptureDragDrop|EFlagPointerCaptureAllGroups);
617 if ((*pData.UInt)&RWindowBase::TCaptureFlagEnabled)
619 iFlags|=EFlagPointerCaptured;
620 if ((*pData.UInt)&RWindowBase::TCaptureFlagDragDrop)
621 iFlags|=EFlagPointerCaptureDragDrop;
622 if ((*pData.UInt)&RWindowBase::TCaptureFlagAllGroups)
623 iFlags|=EFlagPointerCaptureAllGroups;
626 WsPointer::ReLogCurrentWindow();
628 case EWsWinOpSetPointerCapturePriority:
629 iPointerCapturePriority=*pData.Int;
631 case EWsWinOpGetPointerCapturePriority:
632 SetReply(iPointerCapturePriority);
634 case EWsWinOpSetVisible:
635 SetVisible(*pData.Bool);
640 TRect src(TRect(origin,iRel.Size()));
641 src.Move(-pData.ScrollRect->offset);
642 Scroll(TRect(TPoint(0,0),iRel.Size()),pData.ScrollRect->offset,src);
645 case EWsWinOpScrollClip:
648 TRect src(TRect(origin,iRel.Size()));
649 src.Move(-pData.ScrollRect->offset);
650 TRect clip(pData.ScrollRect->clip);
651 Scroll(clip,pData.ScrollRect->offset,src);
654 case EWsWinOpScrollRect:
656 TRect src(pData.ScrollRect->rect);
657 Scroll(TRect(TPoint(0,0),iRel.Size()),pData.ScrollRect->offset,src);
660 case EWsWinOpScrollClipRect:
662 TRect src(pData.ScrollRect->rect);
663 TRect clip(pData.ScrollRect->clip);
664 Scroll(clip, pData.ScrollRect->offset,src);
667 case EWsWinOpSetOrdinalPositionPri:
668 iOrdinalPriority=pData.OrdinalPos->ordinalPriority;
669 SetOrdinalPosition(pData.OrdinalPos->pos);
671 case EWsWinOpSetShadowHeight:
673 OwnerPanic(EWservPanicNegativeShadowHeight);
675 case EWsWinOpShadowDisabled:
677 case EWsWinOpSetCornerType:
678 SetCornerTypeL(pData.SetCornerType->type, pData.SetCornerType->flags);
680 case EWsWinOpSetShape:
681 SetCornerTypeL(EWindowCornerRegion,0,GetRegionFromClientL(iWsOwner, *pData.Int));
683 case EWsWinOpRequiredDisplayMode:
685 OwnerPanic(EWservPanicBackupDisplayMode);
686 SetReply(DisplayMode());
688 case EWsWinOpGetDisplayMode:
689 SetReply(DisplayMode());
691 case EWsWinOpRequestPointerRepeatEvent:
693 OwnerPanic(EWservPanicParentDeleted);
694 WsPointer::RequestPointerRepeatEvent(this,pData.RequestPointerRepeatEvent->time,pData.RequestPointerRepeatEvent->rect);
696 case EWsWinOpCancelPointerRepeatEventRequest:
697 WsPointer::CancelPointerRepeatEventRequest();
699 case EWsWinOpAllocPointerMoveBuffer:
700 CWsPointerBuffer::ConnectL(this,pData.AllocPointerMoveBuffer->maxNumPoints,pData.AllocPointerMoveBuffer->flags);
701 iFlags|=EFlagUsingPointerBuffer|EFlagHasPointerBuffer;
703 case EWsWinOpFreePointerMoveBuffer:
704 CWsPointerBuffer::Disconnect(this);
705 iFlags&=~(EFlagUsingPointerBuffer|EFlagHasPointerBuffer);
707 case EWsWinOpRetrievePointerMoveBuffer:
708 CWsPointerBuffer::RetrievePointerMoveBuffer(this,*pData.Int);
710 case EWsWinOpEnablePointerMoveBuffer:
711 if (!(iFlags&EFlagHasPointerBuffer))
712 OwnerPanic(EWservPanicNoPointerBuffer);
713 iFlags|=EFlagUsingPointerBuffer;
715 case EWsWinOpDisablePointerMoveBuffer:
716 iFlags&=~EFlagUsingPointerBuffer;
718 case EWsWinOpDiscardPointerMoveBuffer:
719 CWsPointerBuffer::DiscardPointerMoveBuffer(this);
721 case EWsWinOpAddKeyRect:
722 AddKeyRectL(pData.AddKeyRect->rect, pData.AddKeyRect->scanCode, pData.AddKeyRect->activatedByPointerSwitchOn);
724 case EWsWinOpRemoveAllKeyRects:
727 case EWsWinOpPasswordWindow:
729 OwnerPanic(EWservPanicParentDeleted);
730 CWsPassword::SetPasswordWindowL(this, *pData.PasswordMode);
732 case EWsWinOpEnableBackup:
734 OwnerPanic(EWservPanicParentDeleted);
736 iBackupsRequested|=EWindowBackupAreaBehind; //For backwards compatibility
738 iBackupsRequested|=*pData.UInt;
740 case EWsWinOpFadeBehind:
743 OwnerPanic(EWservPanicParentDeleted);
746 iScreen->GetFadingParams(blackMap,whiteMap);
747 SetFadeBehind(*pData.Bool);
748 TWalkWindowTreeSetFaded wwt(*pData.Bool,this,blackMap,whiteMap);
749 WalkWindowTree(wwt,EWalkBehind);
750 if (CWsTop::IsFadeEnabled())
752 Screen()->AcceptFadeRequest( this, *pData.Bool, ETrue, EFalse );
756 case EWsWinOpGetIsFaded:
757 SetReply(iFadeCount);
759 case EWsWinOpGetIsNonFading:
760 SetReply(iFlags&EFlagNonFadingWindow);
762 case EWsWinOpMoveToGroup:
764 OwnerPanic(EWservPanicParentDeleted);
765 if (iParent->WinType()!=EWinTypeGroup)
766 OwnerPanic(EWservPanicNotTopClient);
767 DoMoveWindowToGroupL(*pData.Int);
769 case EWsWinOpTestLowPriorityRedraw:
771 // This is purely for testing purposes
772 // Returns the redraw priority
774 TPckgBuf<TUint> priBuf;
775 priority=WsOwner()->RedrawQueue()->RedrawPriority((CWsWindowRedraw*)this->iRedraw);
777 CWsClient::ReplyBuf(priBuf);
780 case EWsWinOpEnableVisibilityChangeEvents:
781 iFlags |= EFlagGeneratesVisibilityEvents;
782 if (iFlags&EFlagActive)
784 iScreen->DoRedrawNow();
785 PossibleVisibilityChangedEvent(ETrue);
788 case EWsWinOpDisableVisibilityChangeEvents:
789 iFlags &= ~EFlagGeneratesVisibilityEvents;
791 case EWsWinOpSetTransparentRegion:
795 TInt recs=*pData.Int;
796 RWsRegion* reg=recs>0? GetRegionFromClientL(iWsOwner,recs) : new(ELeave) RWsRegion;
797 SetUserTransparentRegion(reg);
802 OwnerPanic(EWservPanicTransparencyObjNotCreated);
806 case EWsWinOpSetTransparencyPolicy:
811 OwnerPanic(EWservPanicTransparencyObjNotCreated);
814 case EWsWinOpSetTransparencyAlphaChannel:
816 iFlags |= static_cast<TUint>(EFlagHasAlpha);
821 if (iRedraw->CommandL(aOpcode,pData)==EFalse)
823 OwnerPanic(EWservPanicOpcode);
828 rootWindow->CheckTree();
832 void CWsClientWindow::GcActivated(CWsGc *aGc)
834 aGc->SetNextWinGc(iWinGcList);
838 void CWsClientWindow::GcDeactivated(CWsGc *aGc)
841 iWinGcList=aGc->NextWinGc();
844 CWsGc *gc=iWinGcList;
848 next=gc->NextWinGc();
849 WS_ASSERT_DEBUG(next!=NULL, EWsPanicBadActiveGcList);
852 gc->SetNextWinGc(next->NextWinGc());
858 aGc->SetNextWinGc(NULL);
861 void CWsClientWindow::ReactivateGcs()
863 for (CWsGc * gc = iWinGcList; gc; gc = gc->NextWinGc())
869 void CWsClientWindow::OffsetUserTransparentRegion(const TPoint& aOffset)
871 if (iUserDefinedTransparentRegion)
873 iUserDefinedTransparentRegion->Offset(aOffset);
877 void CWsClientWindow::SetUserTransparentRegion(RWsRegion* aRegion)
879 if (iUserDefinedTransparentRegion)
881 iUserDefinedTransparentRegion->Close();
882 delete iUserDefinedTransparentRegion;
883 iUserDefinedTransparentRegion = 0;
888 aRegion->Offset(iOrigin);
889 iUserDefinedTransparentRegion=aRegion;
892 SetUserOpaqueRegion();
895 void CWsClientWindow::SetUserOpaqueRegion()
897 if (iUserDefinedOpaqueRegion)
899 iUserDefinedOpaqueRegion->Close();
900 delete iUserDefinedOpaqueRegion;
901 iUserDefinedOpaqueRegion = 0;
903 if (iUserDefinedTransparentRegion)
905 iUserDefinedOpaqueRegion=new RWsRegion;
906 if (iUserDefinedOpaqueRegion)
908 iUserDefinedOpaqueRegion->Copy(*iBaseArea);
909 iUserDefinedOpaqueRegion->SubRegion(*iUserDefinedTransparentRegion);
910 if (iUserDefinedOpaqueRegion->CheckError() || iUserDefinedOpaqueRegion->Count() == 0)
912 iUserDefinedOpaqueRegion->Close();
913 delete iUserDefinedOpaqueRegion;
914 iUserDefinedOpaqueRegion = 0;
920 TUint CWsClientWindow::RedrawPriority(TInt *aShift) const
922 if (IsTopClientWindow())
924 TUint ordinalPos=OrdinalPosition(EFalse);
925 if (ordinalPos>KWinRedrawPriMaxOrdinal) // Algorithm only works for upto KWinRedrawPriMaxOrdinal windows,
926 ordinalPos=KWinRedrawPriMaxOrdinal; // make all windows after this equal in priority
928 *aShift=KWinRedrawPriMaxLevel;
929 return(ordinalPos<<(KWinRedrawPriMaxLevel*KWinRedrawPriBitsPerLevel));
933 TUint ordinalPos=OrdinalPosition(EFalse)+1;
934 if (ordinalPos>KWinRedrawPriMaxOrdinal) // Algorithm only works upto 15 , make all windows after 15 equal in priority
935 ordinalPos=KWinRedrawPriMaxOrdinal;
937 TUint parent=((CWsClientWindow *)iParent)->RedrawPriority(&shift);
942 return(parent+(ordinalPos<<(shift*KWinRedrawPriBitsPerLevel)));
946 TDblQue<TPointerKeyList> *CWsClientWindow::PointerKeyList() const
948 return(iPointerKeyList);
951 void CWsClientWindow::AddKeyRectL(const TRect &aRect, TInt aScanCode, TBool aActivatedByPointerSwitchOn)
953 if (!iPointerKeyList)
954 iPointerKeyList=new(ELeave) TDblQue<TPointerKeyList>(_FOFF(TPointerKeyList,iQue));
955 TPointerKeyList *pkl=new(ELeave) TPointerKeyList();
956 iPointerKeyList->AddLast(*pkl);
958 pkl->iScanCode=aScanCode;
959 pkl->iActivatedByPointerSwitchOn=aActivatedByPointerSwitchOn;
962 void CWsClientWindow::RemoveAllKeyRects()
966 TPointerKeyList *pkl=NULL;
967 for(TDblQueIter<TPointerKeyList> iter(*iPointerKeyList);(pkl=iter++)!=NULL;)
972 delete iPointerKeyList;
973 iPointerKeyList=NULL;
977 TBool CWsClientWindow::IsHidden()
979 return (!IsVisible()) || VisibleRegion().IsEmpty();
982 void CWsClientWindow::SetFaded(TBool aFade,TUint8 aBlackMap,TUint8 aWhiteMap)
1003 else if (iFadeCount > 0)
1010 void CWsClientWindow::ResetHiddenFlagsInParentAndChildren()
1013 for(CWsClientWindow* child=Child();child;child=child->NextSibling())
1015 child->ResetHiddenFlagsInParentAndChildren();
1019 const TRegion& CWsClientWindow::WindowArea() const
1024 void CWsClientWindow::Invalidate(const TRect * aRect)
1026 iRedraw->Invalidate(aRect);
1029 void CWsClientWindow::ScheduleRegionUpdate(const TRegion* aDefinitelyDirty)
1033 iScreen->ScheduleRegionUpdate(aDefinitelyDirty);
1037 TBool CWsClientWindow::IsDSAHost() const
1039 TBool res = CWsWindow::IsDSAHost();
1041 { // check for grace period when DSA is being restarted (after aborting but before client started DSA again)
1042 res = Screen()->IsDSAClientWindow( this );
1046 void CWsClientWindow::SetScreenDeviceValidState(TBool aState)
1048 if (SetScreenDeviceValidStateFlag(aState))
1052 TBool CWsClientWindow::SetScreenDeviceValidStateFlag(TBool aState)
1054 TBool isSet=iFlags&EFlagScreenDeviceInvalid;
1055 if (!isSet==!aState)
1058 iFlags&=~EFlagScreenDeviceInvalid;
1060 iFlags|=EFlagScreenDeviceInvalid;
1066 void CWsClientWindow::DoMoveWindowToGroupL(TInt aIdentifier)
1068 CWsWindowGroup* group=CWsWindowGroup::WindowGroupFromIdentifierL(aIdentifier);
1071 if (group->WsOwner()!=WsOwner())
1072 User::Leave(KErrNotFound);
1073 ChangeWindowPosition(0, group);
1074 CWsTop::TriggerRedraws(RootWindow());
1077 void CWsClientWindow::SetInactive()
1079 iFlags&=~EFlagActive;