LCOV - code coverage report
Current view: top level - vcl/source/window - window.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1427 2021 70.6 %
Date: 2015-06-13 12:38:46 Functions: 105 148 70.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <config_features.h>
      21             : #include <rtl/strbuf.hxx>
      22             : #include <tools/rc.h>
      23             : 
      24             : #include <sal/types.h>
      25             : 
      26             : #include <vcl/salgtype.hxx>
      27             : #include <vcl/event.hxx>
      28             : #include <vcl/help.hxx>
      29             : #include <vcl/cursor.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <vcl/window.hxx>
      32             : #include <vcl/syswin.hxx>
      33             : #include <vcl/syschild.hxx>
      34             : #include <vcl/dockwin.hxx>
      35             : #include <vcl/wall.hxx>
      36             : #include <vcl/fixed.hxx>
      37             : #include <vcl/gradient.hxx>
      38             : #include <vcl/button.hxx>
      39             : #include <vcl/taskpanelist.hxx>
      40             : #include <vcl/dialog.hxx>
      41             : #include <vcl/unowrap.hxx>
      42             : #include <vcl/gdimtf.hxx>
      43             : #include <vcl/lazydelete.hxx>
      44             : #include <vcl/virdev.hxx>
      45             : #include <vcl/settings.hxx>
      46             : #include <vcl/sysdata.hxx>
      47             : 
      48             : #include <salframe.hxx>
      49             : #include <salobj.hxx>
      50             : #include <salinst.hxx>
      51             : #include <salgdi.hxx>
      52             : #include <svdata.hxx>
      53             : #include <dbggui.hxx>
      54             : #include <window.h>
      55             : #include <toolbox.h>
      56             : #include <outdev.h>
      57             : #include <brdwin.hxx>
      58             : #include <helpwin.hxx>
      59             : #include <dndlcon.hxx>
      60             : 
      61             : #include <com/sun/star/awt/XTopWindow.hpp>
      62             : #include <com/sun/star/awt/XDisplayConnection.hpp>
      63             : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      64             : #include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
      65             : #include <com/sun/star/rendering/CanvasFactory.hpp>
      66             : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
      67             : #include <comphelper/processfactory.hxx>
      68             : 
      69             : #include <cassert>
      70             : #include <set>
      71             : #include <typeinfo>
      72             : 
      73             : #ifdef WNT // see #140456#
      74             : #include <win/salframe.h>
      75             : #endif
      76             : 
      77             : 
      78             : using namespace ::com::sun::star::uno;
      79             : using namespace ::com::sun::star::lang;
      80             : using namespace ::com::sun::star::datatransfer::clipboard;
      81             : using namespace ::com::sun::star::datatransfer::dnd;
      82             : 
      83             : using ::com::sun::star::awt::XTopWindow;
      84             : 
      85             : namespace vcl {
      86             : 
      87      213774 : Window::Window( WindowType nType )
      88             : {
      89      213774 :     ImplInitWindowData( nType );
      90      213774 : }
      91             : 
      92       54057 : Window::Window( vcl::Window* pParent, WinBits nStyle )
      93             : {
      94             : 
      95       54057 :     ImplInitWindowData( WINDOW_WINDOW );
      96       54057 :     ImplInit( pParent, nStyle, NULL );
      97       54057 : }
      98             : 
      99           9 : Window::Window( vcl::Window* pParent, const ResId& rResId )
     100           9 :     : mpWindowImpl(NULL)
     101             : {
     102           9 :     rResId.SetRT( RSC_WINDOW );
     103           9 :     WinBits nStyle = ImplInitRes( rResId );
     104           9 :     ImplInitWindowData( WINDOW_WINDOW );
     105           9 :     ImplInit( pParent, nStyle, NULL );
     106           9 :     ImplLoadRes( rResId );
     107             : 
     108           9 :     if ( !(nStyle & WB_HIDE) )
     109           1 :         Show();
     110           9 : }
     111             : 
     112             : #if OSL_DEBUG_LEVEL > 0
     113             : namespace
     114             : {
     115             :     OString lcl_createWindowInfo(const vcl::Window& i_rWindow)
     116             :     {
     117             :         // skip border windows, they don't carry information which helps diagnosing the problem
     118             :         const vcl::Window* pWindow( &i_rWindow );
     119             :         while ( pWindow && ( pWindow->GetType() == WINDOW_BORDERWINDOW ) )
     120             :             pWindow = pWindow->GetWindow( GetWindowType::FirstChild );
     121             :         if ( !pWindow )
     122             :             pWindow = &i_rWindow;
     123             : 
     124             :         OStringBuffer aErrorString;
     125             :         aErrorString.append(' ');
     126             :         aErrorString.append(typeid( *pWindow ).name());
     127             :         aErrorString.append(" (");
     128             :         aErrorString.append(OUStringToOString(pWindow->GetText(), RTL_TEXTENCODING_UTF8));
     129             :         aErrorString.append(")");
     130             :         return aErrorString.makeStringAndClear();
     131             :     }
     132             : }
     133             : #endif
     134             : 
     135    68934532 : bool Window::IsDisposed() const
     136             : {
     137    68934532 :     return !mpWindowImpl;
     138             : }
     139             : 
     140      267413 : void Window::dispose()
     141             : {
     142             :     assert( mpWindowImpl );
     143             :     assert( !mpWindowImpl->mbInDispose ); // should only be called from disposeOnce()
     144             :     assert( (!mpWindowImpl->mpParent ||
     145             :             !mpWindowImpl->mpParent->IsDisposed()) &&
     146             :             "vcl::Window child should have its parent disposed first" );
     147             : 
     148             :     // remove Key and Mouse events issued by Application::PostKey/MouseEvent
     149      267413 :     Application::RemoveMouseAndKeyEvents( this );
     150             : 
     151             :     // Dispose of the canvas implementation (which, currently, has an
     152             :     // own wrapper window as a child to this one.
     153      267413 :     Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
     154      267413 :     if( xCanvas.is() )
     155             :     {
     156           0 :         Reference < XComponent > xCanvasComponent( xCanvas, UNO_QUERY );
     157           0 :         if( xCanvasComponent.is() )
     158           0 :             xCanvasComponent->dispose();
     159             :     }
     160             : 
     161      267413 :     mpWindowImpl->mbInDispose = true;
     162             : 
     163      267413 :     CallEventListeners( VCLEVENT_OBJECT_DYING );
     164             : 
     165             :     // do not send child events for frames that were registered as native frames
     166      267413 :     if( !ImplIsAccessibleNativeFrame() && mpWindowImpl->mbReallyVisible )
     167       36470 :         if ( ImplIsAccessibleCandidate() && GetAccessibleParentWindow() )
     168       36468 :             GetAccessibleParentWindow()->CallEventListeners( VCLEVENT_WINDOW_CHILDDESTROYED, this );
     169             : 
     170             :     // remove associated data structures from dockingmanager
     171      267413 :     ImplGetDockingManager()->RemoveWindow( this );
     172             : 
     173             :     // remove ownerdraw decorated windows from list in the top-most frame window
     174      267413 :     if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
     175             :     {
     176           0 :         ::std::vector< VclPtr<vcl::Window> >& rList = ImplGetOwnerDrawList();
     177           0 :         auto p = ::std::find( rList.begin(), rList.end(), VclPtr<vcl::Window>(this) );
     178           0 :         if( p != rList.end() )
     179           0 :             rList.erase( p );
     180             :     }
     181             : 
     182             :     // shutdown drag and drop
     183      534826 :     Reference < XComponent > xDnDComponent( mpWindowImpl->mxDNDListenerContainer, UNO_QUERY );
     184             : 
     185      267413 :     if( xDnDComponent.is() )
     186       23357 :         xDnDComponent->dispose();
     187             : 
     188      267413 :     if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
     189             :     {
     190             :         try
     191             :         {
     192             :             // deregister drop target listener
     193        6922 :             if( mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
     194             :             {
     195             :                 Reference< XDragGestureRecognizer > xDragGestureRecognizer =
     196        1570 :                     Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
     197        1570 :                 if( xDragGestureRecognizer.is() )
     198             :                 {
     199           0 :                     xDragGestureRecognizer->removeDragGestureListener(
     200           0 :                         Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
     201             :                 }
     202             : 
     203        1570 :                 mpWindowImpl->mpFrameData->mxDropTarget->removeDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
     204        1570 :                 mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
     205             :             }
     206             : 
     207             :             // shutdown drag and drop for this frame window
     208        6922 :             Reference< XComponent > xComponent( mpWindowImpl->mpFrameData->mxDropTarget, UNO_QUERY );
     209             : 
     210             :             // DNDEventDispatcher does not hold a reference of the DropTarget,
     211             :             // so it's ok if it does not support XComponent
     212        6922 :             if( xComponent.is() )
     213        1570 :                 xComponent->dispose();
     214             :         }
     215           0 :         catch (const Exception&)
     216             :         {
     217             :             // can be safely ignored here.
     218             :         }
     219             :     }
     220             : 
     221      267413 :     UnoWrapperBase* pWrapper = Application::GetUnoWrapper( false );
     222      267413 :     if ( pWrapper )
     223      267227 :         pWrapper->WindowDestroyed( this );
     224             : 
     225             :     // MT: Must be called after WindowDestroyed!
     226             :     // Otherwise, if the accessible is a VCLXWindow, it will try to destroy this window again!
     227             :     // But accessibility implementations from applications need this dispose.
     228      267413 :     if ( mpWindowImpl->mxAccessible.is() )
     229             :     {
     230         308 :         Reference< XComponent> xC( mpWindowImpl->mxAccessible, UNO_QUERY );
     231         308 :         if ( xC.is() )
     232         291 :             xC->dispose();
     233             :     }
     234             : 
     235      267413 :     ImplSVData* pSVData = ImplGetSVData();
     236             : 
     237      267413 :     if ( pSVData->maHelpData.mpHelpWin && (pSVData->maHelpData.mpHelpWin->GetParent() == this) )
     238           0 :         ImplDestroyHelpWindow( true );
     239             : 
     240             :     DBG_ASSERT( pSVData->maWinData.mpTrackWin.get() != this,
     241             :                 "Window::~Window(): Window is in TrackingMode" );
     242             :     DBG_ASSERT( pSVData->maWinData.mpCaptureWin.get() != this,
     243             :                 "Window::~Window(): Window has the mouse captured" );
     244             : 
     245             :     // due to old compatibility
     246      267413 :     if ( pSVData->maWinData.mpTrackWin == this )
     247           0 :         EndTracking();
     248      267413 :     if ( pSVData->maWinData.mpCaptureWin == this )
     249           0 :         ReleaseMouse();
     250      267413 :     if ( pSVData->maWinData.mpDefDialogParent == this )
     251           0 :         pSVData->maWinData.mpDefDialogParent = NULL;
     252             : 
     253             : #if OSL_DEBUG_LEVEL > 0
     254             :     if ( true ) // always perform these tests in debug builds
     255             :     {
     256             :         OStringBuffer aErrorStr;
     257             :         bool        bError = false;
     258             :         vcl::Window*     pTempWin;
     259             : 
     260             :         if ( mpWindowImpl->mpFirstChild )
     261             :         {
     262             :             OStringBuffer aTempStr("Window (");
     263             :             aTempStr.append(lcl_createWindowInfo(*this));
     264             :             aTempStr.append(") with live children destroyed: ");
     265             :             pTempWin = mpWindowImpl->mpFirstChild;
     266             :             while ( pTempWin )
     267             :             {
     268             :                 aTempStr.append(lcl_createWindowInfo(*pTempWin));
     269             :                 pTempWin = pTempWin->mpWindowImpl->mpNext;
     270             :             }
     271             :             OSL_FAIL( aTempStr.getStr() );
     272             :             Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in debug builds, this must be fixed!
     273             :         }
     274             : 
     275             :         if (mpWindowImpl->mpFrameData != 0)
     276             :         {
     277             :             pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
     278             :             while ( pTempWin )
     279             :             {
     280             :                 if ( ImplIsRealParentPath( pTempWin ) )
     281             :                 {
     282             :                     bError = true;
     283             :                     aErrorStr.append(lcl_createWindowInfo(*pTempWin));
     284             :                 }
     285             :                 pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
     286             :             }
     287             :             if ( bError )
     288             :             {
     289             :                 OStringBuffer aTempStr;
     290             :                 aTempStr.append("Window (");
     291             :                 aTempStr.append(lcl_createWindowInfo(*this));
     292             :                 aTempStr.append(") with live SystemWindows destroyed: ");
     293             :                 aTempStr.append(aErrorStr.toString());
     294             :                 OSL_FAIL(aTempStr.getStr());
     295             :                 // abort in debug builds, must be fixed!
     296             :                 Application::Abort(OStringToOUString(
     297             :                                      aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
     298             :             }
     299             :         }
     300             : 
     301             :         bError = false;
     302             :         pTempWin = pSVData->maWinData.mpFirstFrame;
     303             :         while ( pTempWin )
     304             :         {
     305             :             if ( ImplIsRealParentPath( pTempWin ) )
     306             :             {
     307             :                 bError = true;
     308             :                 aErrorStr.append(lcl_createWindowInfo(*pTempWin));
     309             :             }
     310             :             pTempWin = pTempWin->mpWindowImpl->mpFrameData->mpNextFrame;
     311             :         }
     312             :         if ( bError )
     313             :         {
     314             :             OStringBuffer aTempStr( "Window (" );
     315             :             aTempStr.append(lcl_createWindowInfo(*this));
     316             :             aTempStr.append(") with live SystemWindows destroyed: ");
     317             :             aTempStr.append(aErrorStr.toString());
     318             :             OSL_FAIL( aTempStr.getStr() );
     319             :             Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in debug builds, this must be fixed!
     320             :         }
     321             : 
     322             :         if ( mpWindowImpl->mpFirstOverlap )
     323             :         {
     324             :             OStringBuffer aTempStr("Window (");
     325             :             aTempStr.append(lcl_createWindowInfo(*this));
     326             :             aTempStr.append(") with live SystemWindows destroyed: ");
     327             :             pTempWin = mpWindowImpl->mpFirstOverlap;
     328             :             while ( pTempWin )
     329             :             {
     330             :                 aTempStr.append(lcl_createWindowInfo(*pTempWin));
     331             :                 pTempWin = pTempWin->mpWindowImpl->mpNext;
     332             :             }
     333             :             OSL_FAIL( aTempStr.getStr() );
     334             :             Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in debug builds, this must be fixed!
     335             :         }
     336             : 
     337             :         vcl::Window* pMyParent = GetParent();
     338             :         SystemWindow* pMySysWin = NULL;
     339             : 
     340             :         while ( pMyParent )
     341             :         {
     342             :             if ( pMyParent->IsSystemWindow() )
     343             :             {
     344             :                 pMySysWin = dynamic_cast<SystemWindow *>(pMyParent);
     345             :             }
     346             :             pMyParent = pMyParent->GetParent();
     347             :         }
     348             :         if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
     349             :         {
     350             :             OStringBuffer aTempStr("Window (");
     351             :             aTempStr.append(lcl_createWindowInfo(*this));
     352             :             aTempStr.append(") still in TaskPanelList!");
     353             :             OSL_FAIL( aTempStr.getStr() );
     354             :             Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in debug builds, this must be fixed!
     355             :         }
     356             :     }
     357             : #endif
     358             : 
     359      267413 :     if( mpWindowImpl->mbIsInTaskPaneList )
     360             :     {
     361           0 :         vcl::Window* pMyParent = GetParent();
     362           0 :         SystemWindow* pMySysWin = NULL;
     363             : 
     364           0 :         while ( pMyParent )
     365             :         {
     366           0 :             if ( pMyParent->IsSystemWindow() )
     367             :             {
     368           0 :                 pMySysWin = dynamic_cast<SystemWindow *>(pMyParent);
     369             :             }
     370           0 :             pMyParent = pMyParent->GetParent();
     371             :         }
     372           0 :         if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
     373             :         {
     374           0 :             pMySysWin->GetTaskPaneList()->RemoveWindow( this );
     375             :         }
     376             :         else
     377             :         {
     378           0 :             OStringBuffer aTempStr("Window (");
     379           0 :             aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
     380           0 :             aTempStr.append(") not found in TaskPanelList!");
     381           0 :             OSL_FAIL( aTempStr.getStr() );
     382             :         }
     383             :     }
     384             : 
     385             :     // remove from size-group if necessary
     386      267413 :     remove_from_all_size_groups();
     387             : 
     388             :     // clear mnemonic labels
     389      534826 :     std::vector<VclPtr<FixedText> > aMnemonicLabels(list_mnemonic_labels());
     390      268548 :     for (auto aI = aMnemonicLabels.begin(); aI != aMnemonicLabels.end(); ++aI)
     391             :     {
     392        1135 :         remove_mnemonic_label(*aI);
     393             :     }
     394             : 
     395             :     // hide window in order to trigger the Paint-Handling
     396      267413 :     Hide();
     397             : 
     398             :     // announce the window is to be destroyed
     399             :     {
     400      267413 :         NotifyEvent aNEvt( MouseNotifyEvent::DESTROY, this );
     401      267413 :         CompatNotify( aNEvt );
     402             :     }
     403             : 
     404             :     // EndExtTextInputMode
     405      267413 :     if ( pSVData->maWinData.mpExtTextInputWin == this )
     406             :     {
     407           0 :         EndExtTextInput( EndExtTextInputFlags::Complete );
     408           0 :         if ( pSVData->maWinData.mpExtTextInputWin == this )
     409           0 :             pSVData->maWinData.mpExtTextInputWin = NULL;
     410             :     }
     411             : 
     412             :     // check if the focus window is our child
     413      267413 :     bool bHasFocussedChild = false;
     414      267413 :     if( pSVData->maWinData.mpFocusWin && ImplIsRealParentPath( pSVData->maWinData.mpFocusWin ) )
     415             :     {
     416             :         // #122232#, this must not happen and is an application bug ! but we try some cleanup to hopefully avoid crashes, see below
     417           0 :         bHasFocussedChild = true;
     418             : #if OSL_DEBUG_LEVEL > 0
     419             :         OStringBuffer aTempStr("Window (");
     420             :         aTempStr.append(OUStringToOString(GetText(),
     421             :             RTL_TEXTENCODING_UTF8)).
     422             :                 append(") with focussed child window destroyed ! THIS WILL LEAD TO CRASHES AND MUST BE FIXED !");
     423             :         OSL_FAIL( aTempStr.getStr() );
     424             :         Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ));   // abort in debug build version, this must be fixed!
     425             : #endif
     426             :     }
     427             : 
     428             :     // if we get focus pass focus to another window
     429      267413 :     vcl::Window* pOverlapWindow = ImplGetFirstOverlapWindow();
     430      534826 :     if ( pSVData->maWinData.mpFocusWin == this
     431      267413 :         || bHasFocussedChild )  // #122232#, see above, try some cleanup
     432             :     {
     433        8670 :         if ( mpWindowImpl->mbFrame )
     434             :         {
     435           3 :             pSVData->maWinData.mpFocusWin = NULL;
     436           3 :             pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
     437             :         }
     438             :         else
     439             :         {
     440        8667 :             vcl::Window* pParent = GetParent();
     441        8667 :             vcl::Window* pBorderWindow = mpWindowImpl->mpBorderWindow;
     442             :         // when windows overlap, give focus to the parent
     443             :         // of the next FrameWindow
     444        8667 :             if ( pBorderWindow )
     445             :             {
     446        5689 :                 if ( pBorderWindow->ImplIsOverlapWindow() )
     447        2843 :                     pParent = pBorderWindow->mpWindowImpl->mpOverlapWindow;
     448             :             }
     449        2978 :             else if ( ImplIsOverlapWindow() )
     450           0 :                 pParent = mpWindowImpl->mpOverlapWindow;
     451             : 
     452        8667 :             if ( pParent && pParent->IsEnabled() && pParent->IsInputEnabled() && ! pParent->IsInModalMode() )
     453        8666 :                 pParent->GrabFocus();
     454             :             else
     455           1 :                 mpWindowImpl->mpFrameWindow->GrabFocus();
     456             : 
     457             :             // If the focus was set back to 'this' set it to nothing
     458        8667 :             if ( pSVData->maWinData.mpFocusWin == this )
     459             :             {
     460        2857 :                 pSVData->maWinData.mpFocusWin = NULL;
     461        2857 :                 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
     462             :             }
     463             :         }
     464             :     }
     465             : 
     466      534823 :     if ( pOverlapWindow != 0 &&
     467      267410 :          pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
     468         322 :         pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
     469             : 
     470             :     // reset hint for DefModalDialogParent
     471      267413 :     if( pSVData->maWinData.mpActiveApplicationFrame == this )
     472        2861 :         pSVData->maWinData.mpActiveApplicationFrame = NULL;
     473             : 
     474             :     // reset marked windows
     475      267413 :     if ( mpWindowImpl->mpFrameData != 0 )
     476             :     {
     477      267410 :         if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
     478        3182 :             mpWindowImpl->mpFrameData->mpFocusWin = NULL;
     479      267410 :         if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
     480           0 :             mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
     481      267410 :         if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
     482           0 :             mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
     483             :     }
     484             : 
     485             :     // reset Deactivate-Window
     486      267413 :     if ( pSVData->maWinData.mpLastDeacWin == this )
     487           0 :         pSVData->maWinData.mpLastDeacWin = NULL;
     488             : 
     489      267413 :     if ( mpWindowImpl->mpFrameData )
     490             :     {
     491      267410 :         if ( mpWindowImpl->mpFrameData->mnFocusId )
     492         198 :             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId );
     493      267410 :         mpWindowImpl->mpFrameData->mnFocusId = NULL;
     494      267410 :         if ( mpWindowImpl->mpFrameData->mnMouseMoveId )
     495       60279 :             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId );
     496      267410 :         mpWindowImpl->mpFrameData->mnMouseMoveId = NULL;
     497             :     }
     498             : 
     499             :     // release SalGraphics
     500      267413 :     OutputDevice *pOutDev = GetOutDev();
     501      267413 :     pOutDev->ReleaseGraphics();
     502             : 
     503             :     // notify ImplDelData subscribers of this window about the window deletion
     504      267413 :     ImplDelData* pDelData = mpWindowImpl->mpFirstDel;
     505      534828 :     while ( pDelData )
     506             :     {
     507           2 :         pDelData->mbDel = true;
     508           2 :         pDelData->mpWindow.clear();  // #112873# pDel is not associated with a Window anymore
     509           2 :         pDelData = pDelData->mpNext;
     510             :     }
     511             : 
     512             :     // remove window from the lists
     513      267413 :     ImplRemoveWindow( true );
     514             : 
     515             :     // de-register as "top window child" at our parent, if necessary
     516      267413 :     if ( mpWindowImpl->mbFrame )
     517             :     {
     518        6922 :         bool bIsTopWindow = mpWindowImpl->mpWinData && ( mpWindowImpl->mpWinData->mnIsTopWindow == 1 );
     519        6922 :         if ( mpWindowImpl->mpRealParent && bIsTopWindow )
     520             :         {
     521           4 :             ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData();
     522             : 
     523             :             auto myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
     524           4 :                 pParentWinData->maTopWindowChildren.end(), VclPtr<vcl::Window>(this) );
     525             :             DBG_ASSERT( myPos != pParentWinData->maTopWindowChildren.end(), "Window::~Window: inconsistency in top window chain!" );
     526           4 :             if ( myPos != pParentWinData->maTopWindowChildren.end() )
     527           2 :                 pParentWinData->maTopWindowChildren.erase( myPos );
     528             :         }
     529             :     }
     530             : 
     531             :     // cleanup Extra Window Data, TODO: add and use ImplWinData destructor
     532      267413 :     if ( mpWindowImpl->mpWinData )
     533             :     {
     534      267228 :         delete mpWindowImpl->mpWinData->mpExtOldText;
     535      267228 :         delete mpWindowImpl->mpWinData->mpExtOldAttrAry;
     536      267228 :         delete mpWindowImpl->mpWinData->mpCursorRect;
     537      267228 :         delete[] mpWindowImpl->mpWinData->mpCompositionCharRects;
     538      267228 :         delete mpWindowImpl->mpWinData->mpFocusRect;
     539      267228 :         delete mpWindowImpl->mpWinData->mpTrackRect;
     540      267228 :         delete mpWindowImpl->mpWinData;
     541             :     }
     542             : 
     543             :     // cleanup overlap related window data
     544      267413 :     delete mpWindowImpl->mpOverlapData;
     545             : 
     546             :     // remove BorderWindow or Frame window data
     547      267413 :     mpWindowImpl->mpBorderWindow.disposeAndClear();
     548      267413 :     if ( mpWindowImpl->mbFrame )
     549             :     {
     550        6922 :         if ( pSVData->maWinData.mpFirstFrame == this )
     551        4617 :             pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
     552             :         else
     553             :         {
     554        2305 :             vcl::Window* pSysWin = pSVData->maWinData.mpFirstFrame;
     555       10421 :             while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame.get() != this )
     556        5811 :                 pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame;
     557             : 
     558             :             assert (mpWindowImpl->mpFrameData->mpNextFrame.get() != pSysWin);
     559        2305 :             pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame;
     560             :         }
     561        6922 :         mpWindowImpl->mpFrame->SetCallback( NULL, NULL );
     562        6922 :         pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
     563             :         assert (mpWindowImpl->mpFrameData->mnFocusId == NULL);
     564             :         assert (mpWindowImpl->mpFrameData->mnMouseMoveId == NULL);
     565        6922 :         delete mpWindowImpl->mpFrameData;
     566             :     }
     567             : 
     568             :     // should be the last statements
     569      267413 :     delete mpWindowImpl; mpWindowImpl = NULL;
     570             : 
     571      534826 :     OutputDevice::dispose();
     572      267413 : }
     573             : 
     574      523015 : Window::~Window()
     575             : {
     576             :     // FIXME: we should kill all LazyDeletor usage.
     577      258316 :     vcl::LazyDeletor::Undelete( this );
     578      258316 :     disposeOnce();
     579      264699 : }
     580             : 
     581             : // We will eventually being removing the inheritance of OutputDevice
     582             : // from Window. It will be replaced with a transient relationship such
     583             : // that the OutputDevice is only live for the scope of the Paint method.
     584             : // In the meantime this can help move us towards a Window use an
     585             : // OutputDevice, not being one.
     586             : 
     587      792156 : ::OutputDevice const* Window::GetOutDev() const
     588             : {
     589      792156 :     return this;
     590             : }
     591             : 
     592     1458315 : ::OutputDevice* Window::GetOutDev()
     593             : {
     594     1458315 :     return this;
     595             : }
     596             : 
     597             : } /* namespace vcl */
     598             : 
     599      267840 : WindowImpl::WindowImpl( WindowType nType )
     600             : {
     601      267840 :     maZoom                              = Fraction( 1, 1 );
     602      267840 :     maWinRegion                         = vcl::Region(true);
     603      267840 :     maWinClipRegion                     = vcl::Region(true);
     604      267840 :     mpWinData                           = NULL;                      // Extra Window Data, that we dont need for all windows
     605      267840 :     mpOverlapData                       = NULL;                      // Overlap Data
     606      267840 :     mpFrameData                         = NULL;                      // Frame Data
     607      267840 :     mpFrame                             = NULL;                      // Pointer to frame window
     608      267840 :     mpSysObj                            = NULL;
     609      267840 :     mpFrameWindow                       = NULL;                      // window to top level parent (same as frame window)
     610      267840 :     mpOverlapWindow                     = NULL;                      // first overlap parent
     611      267840 :     mpBorderWindow                      = NULL;                      // Border-Window
     612      267840 :     mpClientWindow                      = NULL;                      // Client-Window of a FrameWindow
     613      267840 :     mpParent                            = NULL;                      // parent (incl. BorderWindow)
     614      267840 :     mpRealParent                        = NULL;                      // real parent (excl. BorderWindow)
     615      267840 :     mpFirstChild                        = NULL;                      // first child window
     616      267840 :     mpLastChild                         = NULL;                      // last child window
     617      267840 :     mpFirstOverlap                      = NULL;                      // first overlap window (only set in overlap windows)
     618      267840 :     mpLastOverlap                       = NULL;                      // last overlap window (only set in overlap windows)
     619      267840 :     mpPrev                              = NULL;                      // prev window
     620      267840 :     mpNext                              = NULL;                      // next window
     621      267840 :     mpNextOverlap                       = NULL;                      // next overlap window of frame
     622      267840 :     mpLastFocusWindow                   = NULL;                      // window for focus restore
     623      267840 :     mpDlgCtrlDownWindow                 = NULL;                      // window for dialog control
     624      267840 :     mpFirstDel                          = NULL;                      // Dtor notification list
     625      267840 :     mpUserData                          = NULL;                      // user data
     626      267840 :     mpCursor                            = NULL;                      // cursor
     627      267840 :     mpControlFont                       = NULL;                      // font properties
     628      267840 :     mpVCLXWindow                        = NULL;
     629      267840 :     mpAccessibleInfos                   = NULL;
     630      267840 :     maControlForeground                 = Color( COL_TRANSPARENT );  // no foreground set
     631      267840 :     maControlBackground                 = Color( COL_TRANSPARENT );  // no background set
     632      267840 :     mnLeftBorder                        = 0;                         // left border
     633      267840 :     mnTopBorder                         = 0;                         // top border
     634      267840 :     mnRightBorder                       = 0;                         // right border
     635      267840 :     mnBottomBorder                      = 0;                         // bottom border
     636      267840 :     mnWidthRequest                      = -1;                        // width request
     637      267840 :     mnHeightRequest                     = -1;                        // height request
     638      267840 :     mnOptimalWidthCache                 = -1;                        // optimal width cache
     639      267840 :     mnOptimalHeightCache                = -1;                        // optimal height cache
     640      267840 :     mnX                                 = 0;                         // X-Position to Parent
     641      267840 :     mnY                                 = 0;                         // Y-Position to Parent
     642      267840 :     mnAbsScreenX                        = 0;                         // absolute X-position on screen, used for RTL window positioning
     643      267840 :     mpChildClipRegion                   = NULL;                      // Child-Clip-Region when ClipChildren
     644      267840 :     mpPaintRegion                       = NULL;                      // Paint-ClipRegion
     645      267840 :     mnStyle                             = 0;                         // style (init in ImplInitWindow)
     646      267840 :     mnPrevStyle                         = 0;                         // prevstyle (set in SetStyle)
     647      267840 :     mnExtendedStyle                     = 0;                         // extended style (init in ImplInitWindow)
     648      267840 :     mnPrevExtendedStyle                 = 0;                         // prevstyle (set in SetExtendedStyle)
     649      267840 :     mnType                              = nType;                     // type
     650      267840 :     mnGetFocusFlags                     = GetFocusFlags::NONE;       // Flags fuer GetFocus()-Aufruf
     651      267840 :     mnWaitCount                         = 0;                         // Wait-Count (>1 == Warte-MousePointer)
     652      267840 :     mnPaintFlags                        = 0;                         // Flags for ImplCallPaint
     653      267840 :     mnParentClipMode                    = ParentClipMode::NONE;      // Flags for Parent-ClipChildren-Mode
     654      267840 :     mnActivateMode                      = ActivateModeFlags::NONE;   // Will be converted in System/Overlap-Windows
     655      267840 :     mnDlgCtrlFlags                      = DialogControlFlags::NONE;  // DialogControl-Flags
     656      267840 :     mnLockCount                         = 0;                         // LockCount
     657      267840 :     meAlwaysInputMode                   = AlwaysInputNone;           // neither AlwaysEnableInput nor AlwaysDisableInput called
     658      267840 :     meHalign                            = VCL_ALIGN_FILL;
     659      267840 :     meValign                            = VCL_ALIGN_FILL;
     660      267840 :     mePackType                          = VCL_PACK_START;
     661      267840 :     mnPadding                           = 0;
     662      267840 :     mnGridHeight                        = 1;
     663      267840 :     mnGridLeftAttach                    = -1;
     664      267840 :     mnGridTopAttach                     = -1;
     665      267840 :     mnGridWidth                         = 1;
     666      267840 :     mnBorderWidth                       = 0;
     667      267840 :     mnMarginLeft                        = 0;
     668      267840 :     mnMarginRight                       = 0;
     669      267840 :     mnMarginTop                         = 0;
     670      267840 :     mnMarginBottom                      = 0;
     671      267840 :     mbFrame                             = false;                     // true: Window is a frame window
     672      267840 :     mbBorderWin                         = false;                     // true: Window is a border window
     673      267840 :     mbOverlapWin                        = false;                     // true: Window is a overlap window
     674      267840 :     mbSysWin                            = false;                     // true: SystemWindow is the base class
     675      267840 :     mbDialog                            = false;                     // true: Dialog is the base class
     676      267840 :     mbDockWin                           = false;                     // true: DockingWindow is the base class
     677      267840 :     mbFloatWin                          = false;                     // true: FloatingWindow is the base class
     678      267840 :     mbPushButton                        = false;                     // true: PushButton is the base class
     679      267840 :     mbToolBox                           = false;                     // true: ToolBox is the base class
     680      267840 :     mbMenuFloatingWindow                = false;                     // true: MenuFloatingWindow is the base class
     681      267840 :     mbToolbarFloatingWindow             = false;                     // true: ImplPopupFloatWin is the base class, used for subtoolbars
     682      267840 :     mbSplitter                          = false;                     // true: Splitter is the base class
     683      267840 :     mbVisible                           = false;                     // true: Show( true ) called
     684      267840 :     mbOverlapVisible                    = false;                     // true: Hide called for visible window from ImplHideAllOverlapWindow()
     685      267840 :     mbDisabled                          = false;                     // true: Enable( false ) called
     686      267840 :     mbInputDisabled                     = false;                     // true: EnableInput( false ) called
     687      267840 :     mbDropDisabled                      = false;                     // true: Drop is enabled
     688      267840 :     mbNoUpdate                          = false;                     // true: SetUpdateMode( false ) called
     689      267840 :     mbNoParentUpdate                    = false;                     // true: SetParentUpdateMode( false ) called
     690      267840 :     mbActive                            = false;                     // true: Window Active
     691      267840 :     mbParentActive                      = false;                     // true: OverlapActive from Parent
     692      267840 :     mbReallyVisible                     = false;                     // true: this and all parents to an overlapped window are visible
     693      267840 :     mbReallyShown                       = false;                     // true: this and all parents to an overlapped window are shown
     694      267840 :     mbInInitShow                        = false;                     // true: we are in InitShow
     695      267840 :     mbChildNotify                       = false;                     // true: ChildNotify
     696      267840 :     mbChildPtrOverwrite                 = false;                     // true: PointerStyle overwrites Child-Pointer
     697      267840 :     mbNoPtrVisible                      = false;                     // true: ShowPointer( false ) called
     698      267840 :     mbMouseMove                         = false;                     // true: BaseMouseMove called
     699      267840 :     mbPaintFrame                        = false;                     // true: Paint is visible, but not painted
     700      267840 :     mbInPaint                           = false;                     // true: Inside PaintHdl
     701      267840 :     mbMouseButtonDown                   = false;                     // true: BaseMouseButtonDown called
     702      267840 :     mbMouseButtonUp                     = false;                     // true: BaseMouseButtonUp called
     703      267840 :     mbKeyInput                          = false;                     // true: BaseKeyInput called
     704      267840 :     mbKeyUp                             = false;                     // true: BaseKeyUp called
     705      267840 :     mbCommand                           = false;                     // true: BaseCommand called
     706      267840 :     mbDefPos                            = true;                      // true: Position is not Set
     707      267840 :     mbDefSize                           = true;                      // true: Size is not Set
     708      267840 :     mbCallMove                          = true;                      // true: Move must be called by Show
     709      267840 :     mbCallResize                        = true;                      // true: Resize must be called by Show
     710      267840 :     mbWaitSystemResize                  = true;                      // true: Wait for System-Resize
     711      267840 :     mbInitWinClipRegion                 = true;                      // true: Calc Window Clip Region
     712      267840 :     mbInitChildRegion                   = false;                     // true: InitChildClipRegion
     713      267840 :     mbWinRegion                         = false;                     // true: Window Region
     714      267840 :     mbClipChildren                      = false;                     // true: Child-window should be clipped
     715      267840 :     mbClipSiblings                      = false;                     // true: Adjacent Child-window should be clipped
     716      267840 :     mbChildTransparent                  = false;                     // true: Child-windows are allowed to switch to transparent (incl. Parent-CLIPCHILDREN)
     717      267840 :     mbPaintTransparent                  = false;                     // true: Paints should be executed on the Parent
     718      267840 :     mbMouseTransparent                  = false;                     // true: Window is transparent for Mouse
     719      267840 :     mbDlgCtrlStart                      = false;                     // true: From here on own Dialog-Control
     720      267840 :     mbFocusVisible                      = false;                     // true: Focus Visible
     721      267840 :     mbUseNativeFocus                    = false;
     722      267840 :     mbNativeFocusVisible                = false;                     // true: native Focus Visible
     723      267840 :     mbInShowFocus                       = false;                     // prevent recursion
     724      267840 :     mbInHideFocus                       = false;                     // prevent recursion
     725      267840 :     mbTrackVisible                      = false;                     // true: Tracking Visible
     726      267840 :     mbControlForeground                 = false;                     // true: Foreground-Property set
     727      267840 :     mbControlBackground                 = false;                     // true: Background-Property set
     728      267840 :     mbAlwaysOnTop                       = false;                     // true: always visible for all others windows
     729      267840 :     mbCompoundControl                   = false;                     // true: Composite Control => Listener...
     730      267840 :     mbCompoundControlHasFocus           = false;                     // true: Composite Control has focus somewhere
     731      267840 :     mbPaintDisabled                     = false;                     // true: Paint should not be executed
     732      267840 :     mbAllResize                         = false;                     // true: Also sent ResizeEvents with 0,0
     733      267840 :     mbInDispose                         = false;                     // true: We're still in Window::dispose()
     734      267840 :     mbExtTextInput                      = false;                     // true: ExtTextInput-Mode is active
     735      267840 :     mbInFocusHdl                        = false;                     // true: Within GetFocus-Handler
     736      267840 :     mbCreatedWithToolkit                = false;
     737      267840 :     mbSuppressAccessibilityEvents       = false;                     // true: do not send any accessibility events
     738      267840 :     mbDrawSelectionBackground           = false;                     // true: draws transparent window background to indicate (toolbox) selection
     739      267840 :     mbIsInTaskPaneList                  = false;                     // true: window was added to the taskpanelist in the topmost system window
     740      267840 :     mnNativeBackground                  = 0;                         // initialize later, depends on type
     741      267840 :     mbCallHandlersDuringInputDisabled   = false;                     // true: call event handlers even if input is disabled
     742      267840 :     mbHelpTextDynamic                   = false;                     // true: append help id in HELP_DEBUG case
     743      267840 :     mbFakeFocusSet                      = false;                     // true: pretend as if the window has focus.
     744      267840 :     mbHexpand                           = false;
     745      267840 :     mbVexpand                           = false;
     746      267840 :     mbExpand                            = false;
     747      267840 :     mbFill                              = true;
     748      267840 :     mbSecondary                         = false;
     749      267840 :     mbNonHomogeneous                    = false;
     750      267840 :     mbDoubleBuffering                   = getenv("VCL_DOUBLEBUFFERING_FORCE_ENABLE"); // when we are not sure, assume it cannot do double-buffering via RenderContext
     751      267840 : }
     752             : 
     753      534826 : WindowImpl::~WindowImpl()
     754             : {
     755      267413 :     delete mpChildClipRegion;
     756      267413 :     delete mpAccessibleInfos;
     757      267413 :     delete mpControlFont;
     758      267413 : }
     759             : 
     760             : namespace vcl {
     761             : 
     762     1751965 : bool Window::AcquireGraphics() const
     763             : {
     764             :     DBG_TESTSOLARMUTEX();
     765             : 
     766     1751965 :     if ( mpGraphics )
     767     1494983 :         return true;
     768             : 
     769      256982 :     mbInitLineColor     = true;
     770      256982 :     mbInitFillColor     = true;
     771      256982 :     mbInitFont          = true;
     772      256982 :     mbInitTextColor     = true;
     773      256982 :     mbInitClipRegion    = true;
     774             : 
     775      256982 :     ImplSVData* pSVData = ImplGetSVData();
     776             : 
     777      256982 :     mpGraphics = mpWindowImpl->mpFrame->AcquireGraphics();
     778             :     // try harder if no wingraphics was available directly
     779      256982 :     if ( !mpGraphics )
     780             :     {
     781             :         // find another output device in the same frame
     782         787 :         OutputDevice* pReleaseOutDev = pSVData->maGDIData.mpLastWinGraphics;
     783        3971 :         while ( pReleaseOutDev )
     784             :         {
     785        3184 :             if ( static_cast<vcl::Window*>(pReleaseOutDev)->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame )
     786         787 :                 break;
     787        2397 :             pReleaseOutDev = pReleaseOutDev->mpPrevGraphics;
     788             :         }
     789             : 
     790         787 :         if ( pReleaseOutDev )
     791             :         {
     792             :             // steal the wingraphics from the other outdev
     793         787 :             mpGraphics = pReleaseOutDev->mpGraphics;
     794         787 :             pReleaseOutDev->ReleaseGraphics( false );
     795             :         }
     796             :         else
     797             :         {
     798             :             // if needed retry after releasing least recently used wingraphics
     799           0 :             while ( !mpGraphics )
     800             :             {
     801           0 :                 if ( !pSVData->maGDIData.mpLastWinGraphics )
     802           0 :                     break;
     803           0 :                 pSVData->maGDIData.mpLastWinGraphics->ReleaseGraphics();
     804           0 :                 mpGraphics = mpWindowImpl->mpFrame->AcquireGraphics();
     805             :             }
     806             :         }
     807             :     }
     808             : 
     809             :     // update global LRU list of wingraphics
     810      256982 :     if ( mpGraphics )
     811             :     {
     812      256982 :         mpNextGraphics = pSVData->maGDIData.mpFirstWinGraphics;
     813      256982 :         pSVData->maGDIData.mpFirstWinGraphics = const_cast<vcl::Window*>(this);
     814      256982 :         if ( mpNextGraphics )
     815      256767 :             mpNextGraphics->mpPrevGraphics = const_cast<vcl::Window*>(this);
     816      256982 :         if ( !pSVData->maGDIData.mpLastWinGraphics )
     817         215 :             pSVData->maGDIData.mpLastWinGraphics = const_cast<vcl::Window*>(this);
     818             :     }
     819             : 
     820      256982 :     if ( mpGraphics )
     821             :     {
     822      256982 :         mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp );
     823      256982 :         mpGraphics->setAntiAliasB2DDraw(bool(mnAntialiasing & AntialiasingFlags::EnableB2dDraw));
     824             :     }
     825             : 
     826      256982 :     return mpGraphics != nullptr;
     827             : }
     828             : 
     829      565323 : void Window::ReleaseGraphics( bool bRelease )
     830             : {
     831             :     DBG_TESTSOLARMUTEX();
     832             : 
     833      565323 :     if ( !mpGraphics )
     834      874028 :         return;
     835             : 
     836             :     // release the fonts of the physically released graphics device
     837      256618 :     if( bRelease )
     838      255831 :         ImplReleaseFonts();
     839             : 
     840      256618 :     ImplSVData* pSVData = ImplGetSVData();
     841             : 
     842      256618 :     vcl::Window* pWindow = this;
     843             : 
     844      256618 :     if ( bRelease )
     845      255831 :         pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
     846             :     // remove from global LRU list of window graphics
     847      256618 :     if ( mpPrevGraphics )
     848      226166 :         mpPrevGraphics->mpNextGraphics = mpNextGraphics;
     849             :     else
     850       30452 :         pSVData->maGDIData.mpFirstWinGraphics = mpNextGraphics;
     851      256618 :     if ( mpNextGraphics )
     852      256335 :         mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
     853             :     else
     854         283 :         pSVData->maGDIData.mpLastWinGraphics = mpPrevGraphics;
     855             : 
     856      256618 :     mpGraphics      = NULL;
     857      256618 :     mpPrevGraphics  = NULL;
     858      256618 :     mpNextGraphics  = NULL;
     859             : }
     860             : 
     861      268216 : static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
     862             : {
     863      268216 :     sal_Int32 nResult = 1;
     864             : 
     865             : #ifndef MACOSX
     866             :     // Setting of HiDPI is unfortunately all only a heuristic; and to add
     867             :     // insult to an injury, the system is constantly lying to us about
     868             :     // the DPI and whatnot
     869             :     // eg. fdo#77059 - set the value from which we do consider the
     870             :     // screen hi-dpi to greater than 168
     871      268216 :     if (nDPI > 168)
     872           0 :         nResult = std::max(sal_Int32(1), (nDPI + 48) / 96);
     873             : #else
     874             :     (void)nDPI;
     875             : #endif
     876             : 
     877      268216 :     return nResult;
     878             : }
     879             : 
     880      267837 : void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
     881             : {
     882             :     DBG_ASSERT( mpWindowImpl->mbFrame || pParent || GetType() == WINDOW_FIXEDIMAGE,
     883             :         "Window::Window(): pParent == NULL" );
     884             : 
     885      267837 :     ImplSVData* pSVData = ImplGetSVData();
     886      267837 :     vcl::Window*     pRealParent = pParent;
     887             : 
     888             :     // inherit 3D look
     889      267837 :     if ( !mpWindowImpl->mbOverlapWin && pParent && (pParent->GetStyle() & WB_3DLOOK) )
     890      171871 :         nStyle |= WB_3DLOOK;
     891             : 
     892             :     // create border window if necessary
     893      796581 :     if ( !mpWindowImpl->mbFrame && !mpWindowImpl->mbBorderWin && !mpWindowImpl->mpBorderWindow
     894      516286 :          && (nStyle & (WB_BORDER | WB_SYSTEMCHILDWINDOW) ) )
     895             :     {
     896       12458 :         sal_uInt16 nBorderTypeStyle = 0;
     897       12458 :         if( (nStyle & WB_SYSTEMCHILDWINDOW) )
     898             :         {
     899             :             // handle WB_SYSTEMCHILDWINDOW
     900             :             // these should be analogous to a top level frame; meaning they
     901             :             // should have a border window with style BORDERWINDOW_STYLE_FRAME
     902             :             // which controls their size
     903           0 :             nBorderTypeStyle |= BORDERWINDOW_STYLE_FRAME;
     904           0 :             nStyle |= WB_BORDER;
     905             :         }
     906       12458 :         VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
     907       12458 :         static_cast<vcl::Window*>(pBorderWin)->mpWindowImpl->mpClientWindow = this;
     908       12458 :         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     909       12458 :         mpWindowImpl->mpBorderWindow  = pBorderWin;
     910       12458 :         pParent = mpWindowImpl->mpBorderWindow;
     911             :     }
     912      255379 :     else if( !mpWindowImpl->mbFrame && ! pParent )
     913             :     {
     914          11 :         mpWindowImpl->mbOverlapWin  = true;
     915          11 :         mpWindowImpl->mbFrame = true;
     916             :     }
     917             : 
     918             :     // insert window in list
     919      267837 :     ImplInsertWindow( pParent );
     920      267837 :     mpWindowImpl->mnStyle = nStyle;
     921             : 
     922             :     // Overlap-Window-Data
     923      267837 :     if ( mpWindowImpl->mbOverlapWin )
     924             :     {
     925        6941 :         mpWindowImpl->mpOverlapData                   = new ImplOverlapData;
     926        6941 :         mpWindowImpl->mpOverlapData->mpSaveBackDev    = NULL;
     927        6941 :         mpWindowImpl->mpOverlapData->mpSaveBackRgn    = NULL;
     928        6941 :         mpWindowImpl->mpOverlapData->mpNextBackWin    = NULL;
     929        6941 :         mpWindowImpl->mpOverlapData->mnSaveBackSize   = 0;
     930        6941 :         mpWindowImpl->mpOverlapData->mbSaveBack       = false;
     931        6941 :         mpWindowImpl->mpOverlapData->mnTopLevel       = 1;
     932             :     }
     933             : 
     934      267837 :     if( pParent && ! mpWindowImpl->mbFrame )
     935      260896 :         mbEnableRTL = AllSettings::GetLayoutRTL();
     936             : 
     937             :     // test for frame creation
     938      267837 :     if ( mpWindowImpl->mbFrame )
     939             :     {
     940             :         // create frame
     941        6941 :         sal_uLong nFrameStyle = 0;
     942             : 
     943        6941 :         if ( nStyle & WB_MOVEABLE )
     944        3430 :             nFrameStyle |= SAL_FRAME_STYLE_MOVEABLE;
     945        6941 :         if ( nStyle & WB_SIZEABLE )
     946        3419 :             nFrameStyle |= SAL_FRAME_STYLE_SIZEABLE;
     947        6941 :         if ( nStyle & WB_CLOSEABLE )
     948        6720 :             nFrameStyle |= SAL_FRAME_STYLE_CLOSEABLE;
     949        6941 :         if ( nStyle & WB_APP )
     950           6 :             nFrameStyle |= SAL_FRAME_STYLE_DEFAULT;
     951             :         // check for undecorated floating window
     952        6941 :         if( // 1. floating windows that are not moveable/sizeable (only closeable allowed)
     953       10452 :             ( !(nFrameStyle & ~SAL_FRAME_STYLE_CLOSEABLE) &&
     954       17393 :             ( mpWindowImpl->mbFloatWin || ((GetType() == WINDOW_BORDERWINDOW) && static_cast<ImplBorderWindow*>(this)->mbFloatWindow) || (nStyle & WB_SYSTEMFLOATWIN) ) ) ||
     955             :             // 2. borderwindows of floaters with ownerdraw decoration
     956        7282 :             ( ((GetType() == WINDOW_BORDERWINDOW) && static_cast<ImplBorderWindow*>(this)->mbFloatWindow && (nStyle & WB_OWNERDRAWDECORATION) ) ) )
     957             :         {
     958        3290 :             nFrameStyle = SAL_FRAME_STYLE_FLOAT;
     959        3290 :             if( nStyle & WB_OWNERDRAWDECORATION )
     960           0 :                 nFrameStyle |= (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_NOSHADOW);
     961        3290 :             if( nStyle & WB_NEEDSFOCUS )
     962           0 :                 nFrameStyle |= SAL_FRAME_STYLE_FLOAT_FOCUSABLE;
     963             :         }
     964        3651 :         else if( mpWindowImpl->mbFloatWin )
     965           0 :             nFrameStyle |= SAL_FRAME_STYLE_TOOLWINDOW;
     966             : 
     967        6941 :         if( nStyle & WB_INTROWIN )
     968           0 :             nFrameStyle |= SAL_FRAME_STYLE_INTRO;
     969        6941 :         if( nStyle & WB_TOOLTIPWIN )
     970           0 :             nFrameStyle |= SAL_FRAME_STYLE_TOOLTIP;
     971             : 
     972        6941 :         if( nStyle & WB_NOSHADOW )
     973        3282 :             nFrameStyle |= SAL_FRAME_STYLE_NOSHADOW;
     974             : 
     975        6941 :         if( nStyle & WB_SYSTEMCHILDWINDOW )
     976           0 :             nFrameStyle |= SAL_FRAME_STYLE_SYSTEMCHILD;
     977             : 
     978        6941 :         switch (mpWindowImpl->mnType)
     979             :         {
     980             :             case WINDOW_DIALOG:
     981             :             case WINDOW_TABDIALOG:
     982             :             case WINDOW_MODALDIALOG:
     983             :             case WINDOW_MODELESSDIALOG:
     984             :             case WINDOW_MESSBOX:
     985             :             case WINDOW_INFOBOX:
     986             :             case WINDOW_WARNINGBOX:
     987             :             case WINDOW_ERRORBOX:
     988             :             case WINDOW_QUERYBOX:
     989           9 :                 nFrameStyle |= SAL_FRAME_STYLE_DIALOG;
     990             :             default:
     991        6941 :                 break;
     992             :         }
     993             : 
     994        6941 :         SalFrame* pParentFrame = NULL;
     995        6941 :         if ( pParent )
     996        3295 :             pParentFrame = pParent->mpWindowImpl->mpFrame;
     997             :         SalFrame* pFrame;
     998        6941 :         if ( pSystemParentData )
     999           0 :             pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG );
    1000             :         else
    1001        6941 :             pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle );
    1002        6941 :         if ( !pFrame )
    1003             :         {
    1004             :             // do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario)
    1005             :             throw RuntimeException(
    1006             :                 "Could not create system window!",
    1007           0 :                 Reference< XInterface >() );
    1008             :         }
    1009             : 
    1010        6941 :         pFrame->SetCallback( this, ImplWindowFrameProc );
    1011             : 
    1012             :         // set window frame data
    1013        6941 :         mpWindowImpl->mpFrameData     = new ImplFrameData;
    1014        6941 :         mpWindowImpl->mpFrame         = pFrame;
    1015        6941 :         mpWindowImpl->mpFrameWindow   = this;
    1016        6941 :         mpWindowImpl->mpOverlapWindow = this;
    1017             : 
    1018             :         // set frame data
    1019             :         assert (pSVData->maWinData.mpFirstFrame.get() != this);
    1020        6941 :         mpWindowImpl->mpFrameData->mpNextFrame        = pSVData->maWinData.mpFirstFrame;
    1021        6941 :         pSVData->maWinData.mpFirstFrame = this;
    1022        6941 :         mpWindowImpl->mpFrameData->mpFirstOverlap     = NULL;
    1023        6941 :         mpWindowImpl->mpFrameData->mpFocusWin         = NULL;
    1024        6941 :         mpWindowImpl->mpFrameData->mpMouseMoveWin     = NULL;
    1025        6941 :         mpWindowImpl->mpFrameData->mpMouseDownWin     = NULL;
    1026        6941 :         mpWindowImpl->mpFrameData->mpFirstBackWin     = NULL;
    1027        6941 :         mpWindowImpl->mpFrameData->mpFontCollection   = pSVData->maGDIData.mpScreenFontList;
    1028        6941 :         mpWindowImpl->mpFrameData->mpFontCache        = pSVData->maGDIData.mpScreenFontCache;
    1029        6941 :         mpWindowImpl->mpFrameData->mnAllSaveBackSize  = 0;
    1030        6941 :         mpWindowImpl->mpFrameData->mnFocusId          = 0;
    1031        6941 :         mpWindowImpl->mpFrameData->mnMouseMoveId      = 0;
    1032        6941 :         mpWindowImpl->mpFrameData->mnLastMouseX       = -1;
    1033        6941 :         mpWindowImpl->mpFrameData->mnLastMouseY       = -1;
    1034        6941 :         mpWindowImpl->mpFrameData->mnBeforeLastMouseX = -1;
    1035        6941 :         mpWindowImpl->mpFrameData->mnBeforeLastMouseY = -1;
    1036        6941 :         mpWindowImpl->mpFrameData->mnFirstMouseX      = -1;
    1037        6941 :         mpWindowImpl->mpFrameData->mnFirstMouseY      = -1;
    1038        6941 :         mpWindowImpl->mpFrameData->mnLastMouseWinX    = -1;
    1039        6941 :         mpWindowImpl->mpFrameData->mnLastMouseWinY    = -1;
    1040        6941 :         mpWindowImpl->mpFrameData->mnModalMode        = 0;
    1041        6941 :         mpWindowImpl->mpFrameData->mnMouseDownTime    = 0;
    1042        6941 :         mpWindowImpl->mpFrameData->mnClickCount       = 0;
    1043        6941 :         mpWindowImpl->mpFrameData->mnFirstMouseCode   = 0;
    1044        6941 :         mpWindowImpl->mpFrameData->mnMouseCode        = 0;
    1045        6941 :         mpWindowImpl->mpFrameData->mnMouseMode        = MouseEventModifiers::NONE;
    1046        6941 :         mpWindowImpl->mpFrameData->meMapUnit          = MAP_PIXEL;
    1047        6941 :         mpWindowImpl->mpFrameData->mbHasFocus         = false;
    1048        6941 :         mpWindowImpl->mpFrameData->mbInMouseMove      = false;
    1049        6941 :         mpWindowImpl->mpFrameData->mbMouseIn          = false;
    1050        6941 :         mpWindowImpl->mpFrameData->mbStartDragCalled  = false;
    1051        6941 :         mpWindowImpl->mpFrameData->mbNeedSysWindow    = false;
    1052        6941 :         mpWindowImpl->mpFrameData->mbMinimized        = false;
    1053        6941 :         mpWindowImpl->mpFrameData->mbStartFocusState  = false;
    1054        6941 :         mpWindowImpl->mpFrameData->mbInSysObjFocusHdl = false;
    1055        6941 :         mpWindowImpl->mpFrameData->mbInSysObjToTopHdl = false;
    1056        6941 :         mpWindowImpl->mpFrameData->mbSysObjFocus      = false;
    1057        6941 :         if (!ImplDoTiledRendering())
    1058             :         {
    1059        6941 :             mpWindowImpl->mpFrameData->maPaintIdle.SetPriority( SchedulerPriority::REPAINT );
    1060        6941 :             mpWindowImpl->mpFrameData->maPaintIdle.SetIdleHdl( LINK( this, Window, ImplHandlePaintHdl ) );
    1061        6941 :             mpWindowImpl->mpFrameData->maPaintIdle.SetDebugName( "vcl::Window maPaintIdle" );
    1062             :         }
    1063        6941 :         mpWindowImpl->mpFrameData->maResizeIdle.SetPriority( SchedulerPriority::RESIZE );
    1064        6941 :         mpWindowImpl->mpFrameData->maResizeIdle.SetIdleHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) );
    1065        6941 :         mpWindowImpl->mpFrameData->maResizeIdle.SetDebugName( "vcl::Window maResizeIdle" );
    1066        6941 :         mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = false;
    1067             : 
    1068        6941 :         if ( pRealParent && IsTopWindow() )
    1069             :         {
    1070           4 :             ImplWinData* pParentWinData = pRealParent->ImplGetWinData();
    1071           4 :             pParentWinData->maTopWindowChildren.push_back( this );
    1072             :         }
    1073             :     }
    1074             : 
    1075             :     // init data
    1076      267837 :     mpWindowImpl->mpRealParent = pRealParent;
    1077             : 
    1078             :     // #99318: make sure fontcache and list is available before call to SetSettings
    1079      267837 :     mpFontCollection      = mpWindowImpl->mpFrameData->mpFontCollection;
    1080      267837 :     mpFontCache     = mpWindowImpl->mpFrameData->mpFontCache;
    1081             : 
    1082      267837 :     if ( mpWindowImpl->mbFrame )
    1083             :     {
    1084        6941 :         if ( pParent )
    1085             :         {
    1086        3295 :             mpWindowImpl->mpFrameData->mnDPIX     = pParent->mpWindowImpl->mpFrameData->mnDPIX;
    1087        3295 :             mpWindowImpl->mpFrameData->mnDPIY     = pParent->mpWindowImpl->mpFrameData->mnDPIY;
    1088             :         }
    1089             :         else
    1090             :         {
    1091        3646 :             OutputDevice *pOutDev = GetOutDev();
    1092        3646 :             if ( pOutDev->AcquireGraphics() )
    1093             :             {
    1094        3646 :                 mpGraphics->GetResolution( mpWindowImpl->mpFrameData->mnDPIX, mpWindowImpl->mpFrameData->mnDPIY );
    1095             :             }
    1096             :         }
    1097             : 
    1098             :         // add ownerdraw decorated frame windows to list in the top-most frame window
    1099             :         // so they can be hidden on lose focus
    1100        6941 :         if( nStyle & WB_OWNERDRAWDECORATION )
    1101           0 :             ImplGetOwnerDrawList().push_back( this );
    1102             : 
    1103             :         // delay settings initialization until first "real" frame
    1104             :         // this relies on the IntroWindow not needing any system settings
    1105        7177 :         if ( !pSVData->maAppData.mbSettingsInit &&
    1106         236 :              ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN))
    1107             :              )
    1108             :         {
    1109             :             // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
    1110          70 :             ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
    1111          70 :             OutputDevice::SetSettings( *pSVData->maAppData.mpSettings );
    1112          70 :             pSVData->maAppData.mbSettingsInit = true;
    1113             :         }
    1114             : 
    1115             :         // If we create a Window with default size, query this
    1116             :         // size directly, because we want resize all Controls to
    1117             :         // the correct size before we display the window
    1118        6941 :         if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) )
    1119        3430 :             mpWindowImpl->mpFrame->GetClientSize( mnOutWidth, mnOutHeight );
    1120             :     }
    1121             :     else
    1122             :     {
    1123      260896 :         if ( pParent )
    1124             :         {
    1125      260896 :             if ( !ImplIsOverlapWindow() )
    1126             :             {
    1127      260896 :                 mpWindowImpl->mbDisabled          = pParent->mpWindowImpl->mbDisabled;
    1128      260896 :                 mpWindowImpl->mbInputDisabled     = pParent->mpWindowImpl->mbInputDisabled;
    1129      260896 :                 mpWindowImpl->meAlwaysInputMode   = pParent->mpWindowImpl->meAlwaysInputMode;
    1130             :             }
    1131             : 
    1132      260896 :             OutputDevice::SetSettings( pParent->GetSettings() );
    1133             :         }
    1134             : 
    1135             :     }
    1136             : 
    1137             :     // setup the scale factor for Hi-DPI displays
    1138      267837 :     mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
    1139             : 
    1140      267837 :     const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
    1141      267837 :     sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
    1142      267837 :     mnDPIX          = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
    1143      267837 :     mnDPIY          = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
    1144      267837 :     maFont          = rStyleSettings.GetAppFont();
    1145             : 
    1146      267837 :     ImplPointToLogic(*this, maFont);
    1147             : 
    1148      267837 :     if ( nStyle & WB_3DLOOK )
    1149             :     {
    1150      218770 :         SetTextColor( rStyleSettings.GetButtonTextColor() );
    1151      218770 :         SetBackground( Wallpaper( rStyleSettings.GetFaceColor() ) );
    1152             :     }
    1153             :     else
    1154             :     {
    1155       49067 :         SetTextColor( rStyleSettings.GetWindowTextColor() );
    1156       49067 :         SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
    1157             :     }
    1158             : 
    1159      267837 :     (void)ImplUpdatePos();
    1160             : 
    1161             :     // calculate app font res (except for the Intro Window or the default window)
    1162      267837 :     if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) )
    1163          70 :         ImplInitAppFontData( this );
    1164             : 
    1165      267837 :     if ( GetAccessibleParentWindow()  && GetParent() != Application::GetDefDialogParent() )
    1166      239223 :         GetAccessibleParentWindow()->CallEventListeners( VCLEVENT_WINDOW_CHILDCREATED, this );
    1167      267837 : }
    1168             : 
    1169         377 : void Window::ImplInitAppFontData( vcl::Window* pWindow )
    1170             : {
    1171         377 :     ImplSVData* pSVData = ImplGetSVData();
    1172         377 :     long nTextHeight = pWindow->GetTextHeight();
    1173         377 :     long nTextWidth = pWindow->approximate_char_width() * 8;
    1174         377 :     long nSymHeight = nTextHeight*4;
    1175             :     // Make the basis wider if the font is too narrow
    1176             :     // such that the dialog looks symmetrical and does not become too narrow.
    1177             :     // Add some extra space when the dialog has the same width,
    1178             :     // as a little more space is better.
    1179         377 :     if ( nSymHeight > nTextWidth )
    1180           0 :         nTextWidth = nSymHeight;
    1181         377 :     else if ( nSymHeight+5 > nTextWidth )
    1182           0 :         nTextWidth = nSymHeight+5;
    1183         377 :     pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
    1184         377 :     pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
    1185             : 
    1186             :     // FIXME: this is currently only on OS X, check with other
    1187             :     // platforms
    1188         377 :     if( pSVData->maNWFData.mbNoFocusRects )
    1189             :     {
    1190             :         // try to find out whether there is a large correction
    1191             :         // of control sizes, if yes, make app font scalings larger
    1192             :         // so dialog positioning is not completely off
    1193           0 :         ImplControlValue aControlValue;
    1194           0 :         Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) );
    1195           0 :         Rectangle aBoundingRgn( aCtrlRegion );
    1196           0 :         Rectangle aContentRgn( aCtrlRegion );
    1197           0 :         if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
    1198             :                                              ControlState::ENABLED, aControlValue, OUString(),
    1199           0 :                                              aBoundingRgn, aContentRgn ) )
    1200             :         {
    1201             :             // comment: the magical +6 is for the extra border in bordered
    1202             :             // (which is the standard) edit fields
    1203           0 :             if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 )
    1204           0 :                 pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10;
    1205           0 :         }
    1206             :     }
    1207             : 
    1208         377 :     pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX;
    1209         377 :     if ( pSVData->maAppData.mnDialogScaleX )
    1210         358 :         pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100;
    1211         377 : }
    1212             : 
    1213      267840 : void Window::ImplInitWindowData( WindowType nType )
    1214             : {
    1215      267840 :     mpWindowImpl = new WindowImpl( nType );
    1216             : 
    1217      267840 :     meOutDevType        = OUTDEV_WINDOW;
    1218             : 
    1219      267840 :     mbEnableRTL         = AllSettings::GetLayoutRTL();         // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
    1220      267840 : }
    1221             : 
    1222           0 : void Window::getFrameDev( const Point& rPt, const Point& rDevPt, const Size& rDevSize, OutputDevice& rDev )
    1223             : {
    1224           0 :     bool bOldMap = mbMap;
    1225           0 :     mbMap = false;
    1226           0 :     rDev.DrawOutDev( rDevPt, rDevSize, rPt, rDevSize, *this );
    1227           0 :     mbMap = bOldMap;
    1228           0 : }
    1229             : 
    1230           0 : void Window::drawFrameDev( const Point& rPt, const Point& rDevPt, const Size& rDevSize,
    1231             :                            const OutputDevice& rOutDev, const vcl::Region& rRegion )
    1232             : {
    1233             : 
    1234           0 :     GDIMetaFile*    pOldMetaFile = mpMetaFile;
    1235           0 :     bool            bOldMap = mbMap;
    1236           0 :     RasterOp        eOldROP = GetRasterOp();
    1237           0 :     mpMetaFile = NULL;
    1238           0 :     mbMap = false;
    1239           0 :     SetRasterOp( ROP_OVERPAINT );
    1240             : 
    1241           0 :     if ( !IsDeviceOutputNecessary() )
    1242           0 :         return;
    1243             : 
    1244           0 :     if ( !mpGraphics )
    1245             :     {
    1246           0 :         if ( !AcquireGraphics() )
    1247           0 :             return;
    1248             :     }
    1249             : 
    1250           0 :     if ( rRegion.IsNull() )
    1251           0 :         mpGraphics->ResetClipRegion();
    1252             :     else
    1253           0 :         SelectClipRegion( rRegion );
    1254             : 
    1255             :     SalTwoRect aPosAry(rDevPt.X(), rDevPt.Y(), rDevSize.Width(), rDevSize.Height(),
    1256           0 :                        rPt.X(), rPt.Y(), rDevSize.Width(), rDevSize.Height());
    1257           0 :     drawOutDevDirect( &rOutDev, aPosAry );
    1258             : 
    1259             :     // Ensure that ClipRegion is recalculated and set
    1260           0 :     mbInitClipRegion = true;
    1261             : 
    1262           0 :     SetRasterOp( eOldROP );
    1263           0 :     mbMap = bOldMap;
    1264           0 :     mpMetaFile = pOldMetaFile;
    1265             : }
    1266             : 
    1267             : 
    1268     1899243 : ImplWinData* Window::ImplGetWinData() const
    1269             : {
    1270     1899243 :     if ( !mpWindowImpl->mpWinData )
    1271             :     {
    1272      267377 :         static const char* pNoNWF = getenv( "SAL_NO_NWF" );
    1273             : 
    1274      267377 :         const_cast<vcl::Window*>(this)->mpWindowImpl->mpWinData = new ImplWinData;
    1275      267377 :         mpWindowImpl->mpWinData->mpExtOldText     = NULL;
    1276      267377 :         mpWindowImpl->mpWinData->mpExtOldAttrAry  = NULL;
    1277      267377 :         mpWindowImpl->mpWinData->mpCursorRect     = NULL;
    1278      267377 :         mpWindowImpl->mpWinData->mnCursorExtWidth = 0;
    1279      267377 :         mpWindowImpl->mpWinData->mpCompositionCharRects = NULL;
    1280      267377 :         mpWindowImpl->mpWinData->mnCompositionCharRects = 0;
    1281      267377 :         mpWindowImpl->mpWinData->mpFocusRect      = NULL;
    1282      267377 :         mpWindowImpl->mpWinData->mpTrackRect      = NULL;
    1283      267377 :         mpWindowImpl->mpWinData->mnTrackFlags     = 0;
    1284      267377 :         mpWindowImpl->mpWinData->mnIsTopWindow  = (sal_uInt16) ~0;  // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow())
    1285      267377 :         mpWindowImpl->mpWinData->mbMouseOver      = false;
    1286      267377 :         mpWindowImpl->mpWinData->mbEnableNativeWidget = !(pNoNWF && *pNoNWF); // true: try to draw this control with native theme API
    1287             :     }
    1288             : 
    1289     1899243 :     return mpWindowImpl->mpWinData;
    1290             : }
    1291             : 
    1292             : 
    1293           0 : void Window::CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate )
    1294             : {
    1295           0 :     if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)
    1296           0 :         return;
    1297             : 
    1298           0 :     if (bWindowInvalidate)
    1299             :     {
    1300             :         const Rectangle aSrcRect(Point(aPosAry.mnSrcX, aPosAry.mnSrcY),
    1301           0 :                 Size(aPosAry.mnSrcWidth, aPosAry.mnSrcHeight));
    1302             : 
    1303             :         ImplMoveAllInvalidateRegions(aSrcRect,
    1304             :                 aPosAry.mnDestX-aPosAry.mnSrcX,
    1305             :                 aPosAry.mnDestY-aPosAry.mnSrcY,
    1306           0 :                 false);
    1307             : 
    1308             :         mpGraphics->CopyArea(aPosAry.mnDestX, aPosAry.mnDestY,
    1309             :                 aPosAry.mnSrcX, aPosAry.mnSrcY,
    1310             :                 aPosAry.mnSrcWidth, aPosAry.mnSrcHeight,
    1311           0 :                 SAL_COPYAREA_WINDOWINVALIDATE, this);
    1312             : 
    1313           0 :         return;
    1314             :     }
    1315             : 
    1316           0 :     OutputDevice::CopyDeviceArea(aPosAry, bWindowInvalidate);
    1317             : }
    1318             : 
    1319         311 : SalGraphics* Window::ImplGetFrameGraphics() const
    1320             : {
    1321         311 :     if ( mpWindowImpl->mpFrameWindow->mpGraphics )
    1322             :     {
    1323         311 :         mpWindowImpl->mpFrameWindow->mbInitClipRegion = true;
    1324             :     }
    1325             :     else
    1326             :     {
    1327           0 :         OutputDevice* pFrameWinOutDev = mpWindowImpl->mpFrameWindow;
    1328           0 :         if ( ! pFrameWinOutDev->AcquireGraphics() )
    1329             :         {
    1330           0 :             return NULL;
    1331             :         }
    1332             :     }
    1333         311 :     mpWindowImpl->mpFrameWindow->mpGraphics->ResetClipRegion();
    1334         311 :     return mpWindowImpl->mpFrameWindow->mpGraphics;
    1335             : }
    1336             : 
    1337      118139 : void Window::ImplSetReallyVisible()
    1338             : {
    1339             :     // #i43594# it is possible that INITSHOW was never send, because the visibility state changed between
    1340             :     // ImplCallInitShow() and ImplSetReallyVisible() when called from Show()
    1341             :     // mbReallyShown is a useful indicator
    1342      118139 :     if( !mpWindowImpl->mbReallyShown )
    1343        2345 :         ImplCallInitShow();
    1344             : 
    1345      118139 :     bool bBecameReallyVisible = !mpWindowImpl->mbReallyVisible;
    1346             : 
    1347      118139 :     mbDevOutput     = true;
    1348      118139 :     mpWindowImpl->mbReallyVisible = true;
    1349      118139 :     mpWindowImpl->mbReallyShown   = true;
    1350             : 
    1351             :     // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge.
    1352             :     // For this, the data member of the event must not be NULL.
    1353             :     // Previously, we did this in Window::Show, but there some events got lost in certain situations. Now
    1354             :     // we're doing it when the visibility really changes
    1355      118139 :     if( bBecameReallyVisible && ImplIsAccessibleCandidate() )
    1356      103017 :         CallEventListeners( VCLEVENT_WINDOW_SHOW, this );
    1357             :         // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_SHOW. Normally, we should
    1358             :         // introduce another event which explicitly triggers the Accessibility implementations.
    1359             : 
    1360      118139 :     vcl::Window* pWindow = mpWindowImpl->mpFirstOverlap;
    1361      236278 :     while ( pWindow )
    1362             :     {
    1363           0 :         if ( pWindow->mpWindowImpl->mbVisible )
    1364           0 :             pWindow->ImplSetReallyVisible();
    1365           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1366             :     }
    1367             : 
    1368      118139 :     pWindow = mpWindowImpl->mpFirstChild;
    1369      345975 :     while ( pWindow )
    1370             :     {
    1371      109697 :         if ( pWindow->mpWindowImpl->mbVisible )
    1372       68252 :             pWindow->ImplSetReallyVisible();
    1373      109697 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1374             :     }
    1375      118139 : }
    1376             : 
    1377    28636183 : void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompatibility ok
    1378             : {
    1379    28636183 :     if ( IsDisposed() )
    1380             :     {
    1381           0 :         pDel->mbDel = true;
    1382    28636183 :         return;
    1383             :     }
    1384             : 
    1385             :     DBG_ASSERT( !pDel->mpWindow, "Window::ImplAddDel(): cannot add ImplDelData twice !" );
    1386    28636183 :     if( !pDel->mpWindow )
    1387             :     {
    1388    28636183 :         pDel->mpWindow = this;  // #112873# store ref to this window, so pDel can remove itself
    1389    28636183 :         pDel->mpNext = mpWindowImpl->mpFirstDel;
    1390    28636183 :         mpWindowImpl->mpFirstDel = pDel;
    1391             :     }
    1392             : }
    1393             : 
    1394    28636181 : void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incompatibility ok
    1395             : {
    1396    28636181 :     pDel->mpWindow = NULL;      // #112873# pDel is not associated with a Window anymore
    1397             : 
    1398    28636181 :     if ( IsDisposed() )
    1399    28636181 :         return;
    1400             : 
    1401    28636181 :     if ( mpWindowImpl->mpFirstDel == pDel )
    1402    28636181 :         mpWindowImpl->mpFirstDel = pDel->mpNext;
    1403             :     else
    1404             :     {
    1405           0 :         ImplDelData* pData = mpWindowImpl->mpFirstDel;
    1406           0 :         while ( pData->mpNext != pDel )
    1407           0 :             pData = pData->mpNext;
    1408           0 :         pData->mpNext = pDel->mpNext;
    1409             :     }
    1410             : }
    1411             : 
    1412       54577 : void Window::ImplInitResolutionSettings()
    1413             : {
    1414             :     // recalculate AppFont-resolution and DPI-resolution
    1415       54577 :     if (mpWindowImpl->mbFrame)
    1416             :     {
    1417         379 :         const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
    1418         379 :         sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
    1419         379 :         mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
    1420         379 :         mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
    1421             : 
    1422             :         // setup the scale factor for Hi-DPI displays
    1423         379 :         mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
    1424         379 :         SetPointFont(*this, rStyleSettings.GetAppFont());
    1425             :     }
    1426       54198 :     else if ( mpWindowImpl->mpParent )
    1427             :     {
    1428       54198 :         mnDPIX  = mpWindowImpl->mpParent->mnDPIX;
    1429       54198 :         mnDPIY  = mpWindowImpl->mpParent->mnDPIY;
    1430       54198 :         mnDPIScaleFactor = mpWindowImpl->mpParent->mnDPIScaleFactor;
    1431             :     }
    1432             : 
    1433             :     // update the recalculated values for logical units
    1434             :     // and also tools belonging to the values
    1435       54577 :     if (IsMapModeEnabled())
    1436             :     {
    1437       43363 :         MapMode aMapMode = GetMapMode();
    1438       43363 :         SetMapMode();
    1439       43363 :         SetMapMode( aMapMode );
    1440             :     }
    1441       54577 : }
    1442             : 
    1443      430293 : void Window::ImplPointToLogic(vcl::RenderContext& rRenderContext, vcl::Font& rFont) const
    1444             : {
    1445      430293 :     Size aSize = rFont.GetSize();
    1446      430293 :     sal_uInt16 nScreenFontZoom = rRenderContext.GetSettings().GetStyleSettings().GetScreenFontZoom();
    1447             : 
    1448      430293 :     if (aSize.Width())
    1449             :     {
    1450        2011 :         aSize.Width() *= mpWindowImpl->mpFrameData->mnDPIX;
    1451        2011 :         aSize.Width() += 72 / 2;
    1452        2011 :         aSize.Width() /= 72;
    1453        2011 :         aSize.Width() *= nScreenFontZoom;
    1454        2011 :         aSize.Width() /= 100;
    1455             :     }
    1456      430293 :     aSize.Height() *= mpWindowImpl->mpFrameData->mnDPIY;
    1457      430293 :     aSize.Height() += 72/2;
    1458      430293 :     aSize.Height() /= 72;
    1459      430293 :     aSize.Height() *= nScreenFontZoom;
    1460      430293 :     aSize.Height() /= 100;
    1461             : 
    1462      430293 :     if (rRenderContext.IsMapModeEnabled())
    1463          32 :         aSize = rRenderContext.PixelToLogic(aSize);
    1464             : 
    1465      430293 :     rFont.SetSize(aSize);
    1466      430293 : }
    1467             : 
    1468           7 : void Window::ImplLogicToPoint(vcl::RenderContext& rRenderContext, vcl::Font& rFont) const
    1469             : {
    1470           7 :     Size aSize = rFont.GetSize();
    1471           7 :     sal_uInt16 nScreenFontZoom = rRenderContext.GetSettings().GetStyleSettings().GetScreenFontZoom();
    1472             : 
    1473           7 :     if (rRenderContext.IsMapModeEnabled())
    1474           0 :         aSize = rRenderContext.LogicToPixel(aSize);
    1475             : 
    1476           7 :     if (aSize.Width())
    1477             :     {
    1478           0 :         aSize.Width() *= 100;
    1479           0 :         aSize.Width() /= nScreenFontZoom;
    1480           0 :         aSize.Width() *= 72;
    1481           0 :         aSize.Width() += mpWindowImpl->mpFrameData->mnDPIX / 2;
    1482           0 :         aSize.Width() /= mpWindowImpl->mpFrameData->mnDPIX;
    1483             :     }
    1484           7 :     aSize.Height() *= 100;
    1485           7 :     aSize.Height() /= nScreenFontZoom;
    1486           7 :     aSize.Height() *= 72;
    1487           7 :     aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY / 2;
    1488           7 :     aSize.Height() /= mpWindowImpl->mpFrameData->mnDPIY;
    1489             : 
    1490           7 :     rFont.SetSize(aSize);
    1491           7 : }
    1492             : 
    1493     2372732 : bool Window::ImplUpdatePos()
    1494             : {
    1495     2372732 :     bool bSysChild = false;
    1496             : 
    1497     2372732 :     if ( ImplIsOverlapWindow() )
    1498             :     {
    1499        6951 :         mnOutOffX  = mpWindowImpl->mnX;
    1500        6951 :         mnOutOffY  = mpWindowImpl->mnY;
    1501             :     }
    1502             :     else
    1503             :     {
    1504     2365781 :         vcl::Window* pParent = ImplGetParent();
    1505             : 
    1506     2365781 :         mnOutOffX  = mpWindowImpl->mnX + pParent->mnOutOffX;
    1507     2365781 :         mnOutOffY  = mpWindowImpl->mnY + pParent->mnOutOffY;
    1508             :     }
    1509             : 
    1510     2372732 :     vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    1511     6460763 :     while ( pChild )
    1512             :     {
    1513     1715299 :         if ( pChild->ImplUpdatePos() )
    1514          79 :             bSysChild = true;
    1515     1715299 :         pChild = pChild->mpWindowImpl->mpNext;
    1516             :     }
    1517             : 
    1518     2372732 :     if ( mpWindowImpl->mpSysObj )
    1519          43 :         bSysChild = true;
    1520             : 
    1521     2372732 :     return bSysChild;
    1522             : }
    1523             : 
    1524         670 : void Window::ImplUpdateSysObjPos()
    1525             : {
    1526         670 :     if ( mpWindowImpl->mpSysObj )
    1527          26 :         mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
    1528             : 
    1529         670 :     vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    1530        1984 :     while ( pChild )
    1531             :     {
    1532         644 :         pChild->ImplUpdateSysObjPos();
    1533         644 :         pChild = pChild->mpWindowImpl->mpNext;
    1534             :     }
    1535         670 : }
    1536             : 
    1537      734024 : void Window::ImplPosSizeWindow( long nX, long nY,
    1538             :                                 long nWidth, long nHeight, PosSizeFlags nFlags )
    1539             : {
    1540      734024 :     bool    bNewPos         = false;
    1541      734024 :     bool    bNewSize        = false;
    1542      734024 :     bool    bCopyBits       = false;
    1543      734024 :     long    nOldOutOffX     = mnOutOffX;
    1544      734024 :     long    nOldOutOffY     = mnOutOffY;
    1545      734024 :     long    nOldOutWidth    = mnOutWidth;
    1546      734024 :     long    nOldOutHeight   = mnOutHeight;
    1547      734024 :     vcl::Region* pOverlapRegion  = NULL;
    1548      734024 :     vcl::Region* pOldRegion      = NULL;
    1549             : 
    1550      734024 :     if ( IsReallyVisible() )
    1551             :     {
    1552      242771 :         if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    1553           0 :             ImplInvalidateAllOverlapBackgrounds();
    1554             : 
    1555             :         Rectangle aOldWinRect( Point( nOldOutOffX, nOldOutOffY ),
    1556      242771 :                                Size( nOldOutWidth, nOldOutHeight ) );
    1557      242771 :         pOldRegion = new vcl::Region( aOldWinRect );
    1558      242771 :         if ( mpWindowImpl->mbWinRegion )
    1559           0 :             pOldRegion->Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    1560             : 
    1561      608958 :         if ( mnOutWidth && mnOutHeight && !mpWindowImpl->mbPaintTransparent &&
    1562      491756 :              !mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() &&
    1563       40078 :              !HasPaintEvent() )
    1564        1404 :             bCopyBits = true;
    1565             :     }
    1566             : 
    1567      734024 :     bool bnXRecycled = false; // avoid duplicate mirroring in RTL case
    1568      734024 :     if ( nFlags & PosSizeFlags::Width )
    1569             :     {
    1570      679788 :         if(!( nFlags & PosSizeFlags::X ))
    1571             :         {
    1572      136133 :             nX = mpWindowImpl->mnX;
    1573      136133 :             nFlags |= PosSizeFlags::X;
    1574      136133 :             bnXRecycled = true; // we're using a mnX which was already mirrored in RTL case
    1575             :         }
    1576             : 
    1577      679788 :         if ( nWidth < 0 )
    1578       40246 :             nWidth = 0;
    1579      679788 :         if ( nWidth != mnOutWidth )
    1580             :         {
    1581      244621 :             mnOutWidth = nWidth;
    1582      244621 :             bNewSize = true;
    1583      244621 :             bCopyBits = false;
    1584             :         }
    1585             :     }
    1586      734024 :     if ( nFlags & PosSizeFlags::Height )
    1587             :     {
    1588      682967 :         if ( nHeight < 0 )
    1589       20098 :             nHeight = 0;
    1590      682967 :         if ( nHeight != mnOutHeight )
    1591             :         {
    1592      280374 :             mnOutHeight = nHeight;
    1593      280374 :             bNewSize = true;
    1594      280374 :             bCopyBits = false;
    1595             :         }
    1596             :     }
    1597             : 
    1598      734024 :     if ( nFlags & PosSizeFlags::X )
    1599             :     {
    1600      730804 :         long nOrgX = nX;
    1601             :         // --- RTL ---  (compare the screen coordinates)
    1602      730804 :         Point aPtDev( Point( nX+mnOutOffX, 0 ) );
    1603      730804 :         OutputDevice *pOutDev = GetOutDev();
    1604      730804 :         if( pOutDev->HasMirroredGraphics() )
    1605             :         {
    1606           0 :             mpGraphics->mirror( aPtDev.X(), this );
    1607             : 
    1608             :             // #106948# always mirror our pos if our parent is not mirroring, even
    1609             :             // if we are also not mirroring
    1610             :             // --- RTL --- check if parent is in different coordinates
    1611           0 :             if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
    1612             :             {
    1613             :                 // --- RTL --- (re-mirror at parent window)
    1614           0 :                 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
    1615             :             }
    1616             :             /* #i99166# An LTR window in RTL UI that gets sized only would be
    1617             :                expected to not moved its upper left point
    1618             :             */
    1619           0 :             if( bnXRecycled )
    1620             :             {
    1621           0 :                 if( ImplIsAntiparallel() )
    1622             :                 {
    1623           0 :                     aPtDev.X() = mpWindowImpl->mnAbsScreenX;
    1624           0 :                     nOrgX = mpWindowImpl->maPos.X();
    1625             :                 }
    1626             :             }
    1627             :         }
    1628      730804 :         else if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
    1629             :         {
    1630             :             // mirrored window in LTR UI
    1631             :             {
    1632             :                 // --- RTL --- (re-mirror at parent window)
    1633        1020 :                 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
    1634             :             }
    1635             :         }
    1636             : 
    1637             :         // check maPos as well, as it could have been changed for client windows (ImplCallMove())
    1638      730804 :         if ( mpWindowImpl->mnAbsScreenX != aPtDev.X() || nX != mpWindowImpl->mnX || nOrgX != mpWindowImpl->maPos.X() )
    1639             :         {
    1640      303207 :             if ( bCopyBits && !pOverlapRegion )
    1641             :             {
    1642          11 :                 pOverlapRegion = new vcl::Region();
    1643             :                 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
    1644             :                                                   Size( mnOutWidth, mnOutHeight ) ),
    1645          11 :                                        *pOverlapRegion, false, true, true );
    1646             :             }
    1647      303207 :             mpWindowImpl->mnX = nX;
    1648      303207 :             mpWindowImpl->maPos.X() = nOrgX;
    1649      303207 :             mpWindowImpl->mnAbsScreenX = aPtDev.X();    // --- RTL --- (store real screen pos)
    1650      303207 :             bNewPos = true;
    1651             :         }
    1652             :     }
    1653      734024 :     if ( nFlags & PosSizeFlags::Y )
    1654             :     {
    1655             :         // check maPos as well, as it could have been changed for client windows (ImplCallMove())
    1656      594689 :         if ( nY != mpWindowImpl->mnY || nY != mpWindowImpl->maPos.Y() )
    1657             :         {
    1658      186589 :             if ( bCopyBits && !pOverlapRegion )
    1659             :             {
    1660           0 :                 pOverlapRegion = new vcl::Region();
    1661             :                 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
    1662             :                                                   Size( mnOutWidth, mnOutHeight ) ),
    1663           0 :                                        *pOverlapRegion, false, true, true );
    1664             :             }
    1665      186589 :             mpWindowImpl->mnY = nY;
    1666      186589 :             mpWindowImpl->maPos.Y() = nY;
    1667      186589 :             bNewPos = true;
    1668             :         }
    1669             :     }
    1670             : 
    1671      734024 :     if ( bNewPos || bNewSize )
    1672             :     {
    1673      522795 :         bool bUpdateSysObjPos = false;
    1674      522795 :         if ( bNewPos )
    1675      367198 :             bUpdateSysObjPos = ImplUpdatePos();
    1676             : 
    1677             :         // the borderwindow always specifies the position for its client window
    1678      522795 :         if ( mpWindowImpl->mpBorderWindow )
    1679       81628 :             mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos;
    1680             : 
    1681      522795 :         if ( mpWindowImpl->mpClientWindow )
    1682             :         {
    1683       28810 :             mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder,
    1684       28810 :                                                mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder,
    1685       28810 :                                                mnOutWidth-mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
    1686       28810 :                                                mnOutHeight-mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
    1687             :                                                PosSizeFlags::X | PosSizeFlags::Y |
    1688      144050 :                                                PosSizeFlags::Width | PosSizeFlags::Height );
    1689             :             // If we have a client window, then this is the position
    1690             :             // of the Application's floating windows
    1691       28810 :             mpWindowImpl->mpClientWindow->mpWindowImpl->maPos = mpWindowImpl->maPos;
    1692       28810 :             if ( bNewPos )
    1693             :             {
    1694       15186 :                 if ( mpWindowImpl->mpClientWindow->IsVisible() )
    1695             :                 {
    1696        9640 :                     mpWindowImpl->mpClientWindow->ImplCallMove();
    1697             :                 }
    1698             :                 else
    1699             :                 {
    1700        5546 :                     mpWindowImpl->mpClientWindow->mpWindowImpl->mbCallMove = true;
    1701             :                 }
    1702             :             }
    1703             :         }
    1704             : 
    1705             :         // Move()/Resize() will be called only for Show(), such that
    1706             :         // at least one is called before Show()
    1707      522795 :         if ( IsVisible() )
    1708             :         {
    1709      322676 :             if ( bNewPos )
    1710             :             {
    1711      236590 :                 ImplCallMove();
    1712             :             }
    1713      322676 :             if ( bNewSize )
    1714             :             {
    1715      209296 :                 ImplCallResize();
    1716             :             }
    1717             :         }
    1718             :         else
    1719             :         {
    1720      200119 :             if ( bNewPos )
    1721      130608 :                 mpWindowImpl->mbCallMove = true;
    1722      200119 :             if ( bNewSize )
    1723      161551 :                 mpWindowImpl->mbCallResize = true;
    1724             :         }
    1725             : 
    1726      522795 :         bool bUpdateSysObjClip = false;
    1727      522795 :         if ( IsReallyVisible() )
    1728             :         {
    1729      152542 :             if ( bNewPos || bNewSize )
    1730             :             {
    1731             :                 // reset background storage
    1732      152542 :                 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
    1733           0 :                     ImplDeleteOverlapBackground();
    1734      152542 :                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    1735           0 :                     ImplInvalidateAllOverlapBackgrounds();
    1736             :                 // set Clip-Flag
    1737      152542 :                 bUpdateSysObjClip = !ImplSetClipFlag( true );
    1738             :             }
    1739             : 
    1740             :             // invalidate window content ?
    1741      152542 :             if ( bNewPos || (mnOutWidth > nOldOutWidth) || (mnOutHeight > nOldOutHeight) )
    1742             :             {
    1743      100029 :                 if ( bNewPos )
    1744             :                 {
    1745       90900 :                     bool bInvalidate = false;
    1746       90900 :                     bool bParentPaint = true;
    1747       90900 :                     if ( !ImplIsOverlapWindow() )
    1748       90900 :                         bParentPaint = mpWindowImpl->mpParent->IsPaintEnabled();
    1749       90900 :                     if ( bCopyBits && bParentPaint && !HasPaintEvent() )
    1750             :                     {
    1751          11 :                         Point aPoint( mnOutOffX, mnOutOffY );
    1752             :                         vcl::Region aRegion( Rectangle( aPoint,
    1753          11 :                                                    Size( mnOutWidth, mnOutHeight ) ) );
    1754          11 :                         if ( mpWindowImpl->mbWinRegion )
    1755           0 :                             aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    1756          11 :                         ImplClipBoundaries( aRegion, false, true );
    1757          11 :                         if ( !pOverlapRegion->IsEmpty() )
    1758             :                         {
    1759           0 :                             pOverlapRegion->Move( mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY );
    1760           0 :                             aRegion.Exclude( *pOverlapRegion );
    1761             :                         }
    1762          11 :                         if ( !aRegion.IsEmpty() )
    1763             :                         {
    1764             :                             // adapt Paint areas
    1765             :                             ImplMoveAllInvalidateRegions( Rectangle( Point( nOldOutOffX, nOldOutOffY ),
    1766             :                                                                      Size( nOldOutWidth, nOldOutHeight ) ),
    1767             :                                                           mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY,
    1768          11 :                                                           true );
    1769          11 :                             SalGraphics* pGraphics = ImplGetFrameGraphics();
    1770          11 :                             if ( pGraphics )
    1771             :                             {
    1772             : 
    1773          11 :                                 OutputDevice *pOutDev = GetOutDev();
    1774          11 :                                 const bool bSelectClipRegion = pOutDev->SelectClipRegion( aRegion, pGraphics );
    1775          11 :                                 if ( bSelectClipRegion )
    1776             :                                 {
    1777             :                                     pGraphics->CopyArea( mnOutOffX, mnOutOffY,
    1778             :                                                          nOldOutOffX, nOldOutOffY,
    1779             :                                                          nOldOutWidth, nOldOutHeight,
    1780          11 :                                                          SAL_COPYAREA_WINDOWINVALIDATE, this );
    1781             :                                 }
    1782             :                                 else
    1783           0 :                                     bInvalidate = true;
    1784             :                             }
    1785             :                             else
    1786           0 :                                 bInvalidate = true;
    1787          11 :                             if ( !bInvalidate )
    1788             :                             {
    1789          11 :                                 if ( !pOverlapRegion->IsEmpty() )
    1790           0 :                                     ImplInvalidateFrameRegion( pOverlapRegion, InvalidateFlags::Children );
    1791             :                             }
    1792             :                         }
    1793             :                         else
    1794           0 :                             bInvalidate = true;
    1795             :                     }
    1796             :                     else
    1797       90889 :                         bInvalidate = true;
    1798       90900 :                     if ( bInvalidate )
    1799       90889 :                         ImplInvalidateFrameRegion( NULL, InvalidateFlags::Children );
    1800             :                 }
    1801             :                 else
    1802             :                 {
    1803        9129 :                     Point aPoint( mnOutOffX, mnOutOffY );
    1804             :                     vcl::Region aRegion( Rectangle( aPoint,
    1805        9129 :                                                Size( mnOutWidth, mnOutHeight ) ) );
    1806        9129 :                     aRegion.Exclude( *pOldRegion );
    1807        9129 :                     if ( mpWindowImpl->mbWinRegion )
    1808           0 :                         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    1809        9129 :                     ImplClipBoundaries( aRegion, false, true );
    1810        9129 :                     if ( !aRegion.IsEmpty() )
    1811        8590 :                         ImplInvalidateFrameRegion( &aRegion, InvalidateFlags::Children );
    1812             :                 }
    1813             :             }
    1814             : 
    1815             :             // invalidate Parent or Overlaps
    1816      214184 :             if ( bNewPos ||
    1817       98486 :                  (mnOutWidth < nOldOutWidth) || (mnOutHeight < nOldOutHeight) )
    1818             :             {
    1819      143603 :                 vcl::Region aRegion( *pOldRegion );
    1820      143603 :                 if ( !mpWindowImpl->mbPaintTransparent )
    1821      142622 :                     ImplExcludeWindowRegion( aRegion );
    1822      143603 :                 ImplClipBoundaries( aRegion, false, true );
    1823      143603 :                 if ( !aRegion.IsEmpty() && !mpWindowImpl->mpBorderWindow )
    1824       45733 :                     ImplInvalidateParentFrameRegion( aRegion );
    1825             :             }
    1826             :         }
    1827             : 
    1828             :         // adapt system objects
    1829      522795 :         if ( bUpdateSysObjClip )
    1830           0 :             ImplUpdateSysObjClip();
    1831      522795 :         if ( bUpdateSysObjPos )
    1832          26 :             ImplUpdateSysObjPos();
    1833      522795 :         if ( bNewSize && mpWindowImpl->mpSysObj )
    1834           0 :             mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
    1835             :     }
    1836             : 
    1837      734024 :     delete pOverlapRegion;
    1838      734024 :     delete pOldRegion;
    1839      734024 : }
    1840             : 
    1841       18804 : void Window::ImplNewInputContext()
    1842             : {
    1843       18804 :     ImplSVData* pSVData = ImplGetSVData();
    1844       18804 :     vcl::Window*     pFocusWin = pSVData->maWinData.mpFocusWin;
    1845       18804 :     if ( !pFocusWin )
    1846       13267 :         return;
    1847             : 
    1848             :     // Is InputContext changed?
    1849       18804 :     const InputContext& rInputContext = pFocusWin->GetInputContext();
    1850       18804 :     if ( rInputContext == pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext )
    1851       13267 :         return;
    1852             : 
    1853        5537 :     pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext = rInputContext;
    1854             : 
    1855             :     SalInputContext         aNewContext;
    1856        5537 :     const vcl::Font&        rFont = rInputContext.GetFont();
    1857        5537 :     const OUString&         rFontName = rFont.GetName();
    1858        5537 :     ImplFontEntry*          pFontEntry = NULL;
    1859        5537 :     aNewContext.mpFont = NULL;
    1860        5537 :     if (!rFontName.isEmpty())
    1861             :     {
    1862         328 :         OutputDevice *pFocusWinOutDev = pFocusWin->GetOutDev();
    1863         328 :         Size aSize = pFocusWinOutDev->ImplLogicToDevicePixel( rFont.GetSize() );
    1864         328 :         if ( !aSize.Height() )
    1865             :         {
    1866             :             // only set default sizes if the font height in logical
    1867             :             // coordinates equals 0
    1868         300 :             if ( rFont.GetSize().Height() )
    1869           0 :                 aSize.Height() = 1;
    1870             :             else
    1871         300 :                 aSize.Height() = (12*pFocusWin->mnDPIY)/72;
    1872             :         }
    1873             :         pFontEntry = pFocusWin->mpFontCache->GetFontEntry( pFocusWin->mpFontCollection,
    1874         328 :                          rFont, aSize, static_cast<float>(aSize.Height()) );
    1875         328 :         if ( pFontEntry )
    1876         328 :             aNewContext.mpFont = &pFontEntry->maFontSelData;
    1877             :     }
    1878        5537 :     aNewContext.meLanguage  = rFont.GetLanguage();
    1879        5537 :     aNewContext.mnOptions   = rInputContext.GetOptions();
    1880        5537 :     pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
    1881             : 
    1882        5537 :     if ( pFontEntry )
    1883         328 :         pFocusWin->mpFontCache->Release( pFontEntry );
    1884             : }
    1885             : 
    1886        9519 : void Window::doLazyDelete()
    1887             : {
    1888        9519 :     SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(this);
    1889        9519 :     DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(this);
    1890        9519 :     if( pSysWin || ( pDockWin && pDockWin->IsFloatingMode() ) )
    1891             :     {
    1892          10 :         Show( false );
    1893          10 :         SetParent( ImplGetDefaultWindow() );
    1894             :     }
    1895        9519 :     vcl::LazyDeletor::Delete( this );
    1896        9519 : }
    1897             : 
    1898           0 : KeyIndicatorState Window::GetIndicatorState() const
    1899             : {
    1900           0 :     return mpWindowImpl->mpFrame->GetIndicatorState();
    1901             : }
    1902             : 
    1903           0 : void Window::SimulateKeyPress( sal_uInt16 nKeyCode ) const
    1904             : {
    1905           0 :     mpWindowImpl->mpFrame->SimulateKeyPress(nKeyCode);
    1906           0 : }
    1907             : 
    1908           0 : void Window::KeyInput( const KeyEvent& rKEvt )
    1909             : {
    1910           0 :     NotifyEvent aNEvt( MouseNotifyEvent::KEYINPUT, this, &rKEvt );
    1911           0 :     if ( !CompatNotify( aNEvt ) )
    1912           0 :         mpWindowImpl->mbKeyInput = true;
    1913           0 : }
    1914             : 
    1915           2 : void Window::KeyUp( const KeyEvent& rKEvt )
    1916             : {
    1917           2 :     NotifyEvent aNEvt( MouseNotifyEvent::KEYUP, this, &rKEvt );
    1918           2 :     if ( !CompatNotify( aNEvt ) )
    1919           2 :         mpWindowImpl->mbKeyUp = true;
    1920           2 : }
    1921             : 
    1922           0 : void Window::Draw( OutputDevice*, const Point&, const Size&, DrawFlags )
    1923             : {
    1924           0 : }
    1925             : 
    1926      413473 : void Window::Move() {}
    1927             : 
    1928      248686 : void Window::Resize() {}
    1929             : 
    1930        9065 : void Window::Activate() {}
    1931             : 
    1932        3681 : void Window::Deactivate() {}
    1933             : 
    1934       11901 : void Window::GetFocus()
    1935             : {
    1936       11901 :     if ( HasFocus() && mpWindowImpl->mpLastFocusWindow && !(mpWindowImpl->mnDlgCtrlFlags & DialogControlFlags::WantFocus) )
    1937             :     {
    1938           3 :         ImplDelData aDogtag( this );
    1939           3 :         mpWindowImpl->mpLastFocusWindow->GrabFocus();
    1940           3 :         if( aDogtag.IsDead() )
    1941       11901 :             return;
    1942             :     }
    1943             : 
    1944       11901 :     NotifyEvent aNEvt( MouseNotifyEvent::GETFOCUS, this );
    1945       11901 :     CompatNotify( aNEvt );
    1946             : }
    1947             : 
    1948       14906 : void Window::LoseFocus()
    1949             : {
    1950       14906 :     NotifyEvent aNEvt( MouseNotifyEvent::LOSEFOCUS, this );
    1951       14906 :     CompatNotify( aNEvt );
    1952       14906 : }
    1953             : 
    1954           0 : void Window::RequestHelp( const HelpEvent& rHEvt )
    1955             : {
    1956             :     // if Balloon-Help is requested, show the balloon
    1957             :     // with help text set
    1958           0 :     if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
    1959             :     {
    1960           0 :         OUString rStr = GetHelpText();
    1961           0 :         if ( rStr.isEmpty() )
    1962           0 :             rStr = GetQuickHelpText();
    1963           0 :         if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
    1964           0 :             ImplGetParent()->RequestHelp( rHEvt );
    1965             :         else
    1966           0 :             Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), rStr );
    1967             :     }
    1968           0 :     else if ( rHEvt.GetMode() & HelpEventMode::QUICK )
    1969             :     {
    1970           0 :         const OUString& rStr = GetQuickHelpText();
    1971           0 :         if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
    1972           0 :             ImplGetParent()->RequestHelp( rHEvt );
    1973             :         else
    1974             :         {
    1975           0 :             Point aPos = GetPosPixel();
    1976           0 :             if ( ImplGetParent() && !ImplIsOverlapWindow() )
    1977           0 :                 aPos = ImplGetParent()->OutputToScreenPixel( aPos );
    1978           0 :             Rectangle   aRect( aPos, GetSizePixel() );
    1979           0 :             OUString      aHelpText;
    1980           0 :             if ( !rStr.isEmpty() )
    1981           0 :                 aHelpText = GetHelpText();
    1982           0 :             Help::ShowQuickHelp( this, aRect, rStr, aHelpText, QuickHelpFlags::CtrlText );
    1983             :         }
    1984             :     }
    1985             :     else
    1986             :     {
    1987           0 :         OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
    1988           0 :         if ( aStrHelpId.isEmpty() && ImplGetParent() )
    1989           0 :             ImplGetParent()->RequestHelp( rHEvt );
    1990             :         else
    1991             :         {
    1992           0 :             Help* pHelp = Application::GetHelp();
    1993           0 :             if ( pHelp )
    1994             :             {
    1995           0 :                 if( !aStrHelpId.isEmpty() )
    1996           0 :                     pHelp->Start( aStrHelpId, this );
    1997             :                 else
    1998           0 :                     pHelp->Start( OUString( OOO_HELP_INDEX  ), this );
    1999             :             }
    2000           0 :         }
    2001             :     }
    2002           0 : }
    2003             : 
    2004           0 : void Window::Command( const CommandEvent& rCEvt )
    2005             : {
    2006           0 :     CallEventListeners( VCLEVENT_WINDOW_COMMAND, const_cast<CommandEvent *>(&rCEvt) );
    2007             : 
    2008           0 :     NotifyEvent aNEvt( MouseNotifyEvent::COMMAND, this, &rCEvt );
    2009           0 :     if ( !CompatNotify( aNEvt ) )
    2010           0 :         mpWindowImpl->mbCommand = true;
    2011           0 : }
    2012             : 
    2013           0 : void Window::Tracking( const TrackingEvent& rTEvt )
    2014             : {
    2015             : 
    2016           0 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
    2017           0 :     if( pWrapper )
    2018           0 :         pWrapper->Tracking( rTEvt );
    2019           0 : }
    2020             : 
    2021     1198036 : void Window::StateChanged(StateChangedType eType)
    2022             : {
    2023     1198036 :     switch (eType)
    2024             :     {
    2025             :         //stuff that doesn't invalidate the layout
    2026             :         case StateChangedType::ControlForeground:
    2027             :         case StateChangedType::ControlBackground:
    2028             :         case StateChangedType::Transparent:
    2029             :         case StateChangedType::UpdateMode:
    2030             :         case StateChangedType::ReadOnly:
    2031             :         case StateChangedType::Enable:
    2032             :         case StateChangedType::State:
    2033             :         case StateChangedType::Data:
    2034             :         case StateChangedType::InitShow:
    2035             :         case StateChangedType::ControlFocus:
    2036      725335 :             break;
    2037             :         //stuff that does invalidate the layout
    2038             :         default:
    2039      472701 :             queue_resize(eType);
    2040      472701 :             break;
    2041             :     }
    2042     1198036 : }
    2043             : 
    2044           0 : bool Window::IsLocked( bool bChildren ) const
    2045             : {
    2046           0 :     if ( mpWindowImpl->mnLockCount != 0 )
    2047           0 :         return true;
    2048             : 
    2049           0 :     if ( bChildren || mpWindowImpl->mbChildNotify )
    2050             :     {
    2051           0 :         vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    2052           0 :         while ( pChild )
    2053             :         {
    2054           0 :             if ( pChild->IsLocked( true ) )
    2055           0 :                 return true;
    2056           0 :             pChild = pChild->mpWindowImpl->mpNext;
    2057             :         }
    2058             :     }
    2059             : 
    2060           0 :     return false;
    2061             : }
    2062             : 
    2063       58783 : void Window::SetStyle( WinBits nStyle )
    2064             : {
    2065       58783 :     if ( mpWindowImpl && mpWindowImpl->mnStyle != nStyle )
    2066             :     {
    2067       29263 :         mpWindowImpl->mnPrevStyle = mpWindowImpl->mnStyle;
    2068       29263 :         mpWindowImpl->mnStyle = nStyle;
    2069       29263 :         CompatStateChanged( StateChangedType::Style );
    2070             :     }
    2071       58783 : }
    2072             : 
    2073       86774 : void Window::SetExtendedStyle( WinBits nExtendedStyle )
    2074             : {
    2075             : 
    2076       86774 :     if ( mpWindowImpl->mnExtendedStyle != nExtendedStyle )
    2077             :     {
    2078        4971 :         vcl::Window* pWindow = ImplGetBorderWindow();
    2079        4971 :         if( ! pWindow )
    2080           0 :             pWindow = this;
    2081        4971 :         if( pWindow->mpWindowImpl->mbFrame )
    2082             :         {
    2083        4971 :             SalExtStyle nExt = 0;
    2084        4971 :             if( (nExtendedStyle & WB_EXT_DOCUMENT) )
    2085        3274 :                 nExt |= SAL_FRAME_EXT_STYLE_DOCUMENT;
    2086        4971 :             if( (nExtendedStyle & WB_EXT_DOCMODIFIED) )
    2087         835 :                 nExt |= SAL_FRAME_EXT_STYLE_DOCMODIFIED;
    2088             : 
    2089        4971 :             pWindow->ImplGetFrame()->SetExtendedFrameStyle( nExt );
    2090             :         }
    2091        4971 :         mpWindowImpl->mnPrevExtendedStyle = mpWindowImpl->mnExtendedStyle;
    2092        4971 :         mpWindowImpl->mnExtendedStyle = nExtendedStyle;
    2093        4971 :         CompatStateChanged( StateChangedType::ExtendedStyle );
    2094             :     }
    2095       86774 : }
    2096             : 
    2097        3662 : void Window::SetBorderStyle( WindowBorderStyle nBorderStyle )
    2098             : {
    2099             : 
    2100        3662 :     if ( mpWindowImpl->mpBorderWindow )
    2101             :     {
    2102        3610 :         if( nBorderStyle == WindowBorderStyle::REMOVEBORDER &&
    2103        3610 :             ! mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
    2104           0 :             mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent
    2105             :             )
    2106             :         {
    2107             :             // this is a little awkward: some controls (e.g. svtools ProgressBar)
    2108             :             // cannot avoid getting constructed with WB_BORDER but want to disable
    2109             :             // borders in case of NWF drawing. So they need a method to remove their border window
    2110           0 :             VclPtr<vcl::Window> pBorderWin = mpWindowImpl->mpBorderWindow;
    2111             :             // remove us as border window's client
    2112           0 :             pBorderWin->mpWindowImpl->mpClientWindow = NULL;
    2113           0 :             mpWindowImpl->mpBorderWindow = NULL;
    2114           0 :             mpWindowImpl->mpRealParent = pBorderWin->mpWindowImpl->mpParent;
    2115             :             // reparent us above the border window
    2116           0 :             SetParent( pBorderWin->mpWindowImpl->mpParent );
    2117             :             // set us to the position and size of our previous border
    2118           0 :             Point aBorderPos( pBorderWin->GetPosPixel() );
    2119           0 :             Size aBorderSize( pBorderWin->GetSizePixel() );
    2120           0 :             setPosSizePixel( aBorderPos.X(), aBorderPos.Y(), aBorderSize.Width(), aBorderSize.Height() );
    2121             :             // release border window
    2122           0 :             pBorderWin.disposeAndClear();
    2123             : 
    2124             :             // set new style bits
    2125           0 :             SetStyle( GetStyle() & (~WB_BORDER) );
    2126             :         }
    2127             :         else
    2128             :         {
    2129        3610 :             if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    2130        3610 :                 static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetBorderStyle( nBorderStyle );
    2131             :             else
    2132           0 :                 mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
    2133             :         }
    2134             :     }
    2135        3662 : }
    2136             : 
    2137           8 : WindowBorderStyle Window::GetBorderStyle() const
    2138             : {
    2139             : 
    2140           8 :     if ( mpWindowImpl->mpBorderWindow )
    2141             :     {
    2142           8 :         if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    2143           8 :             return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorderStyle();
    2144             :         else
    2145           0 :             return mpWindowImpl->mpBorderWindow->GetBorderStyle();
    2146             :     }
    2147             : 
    2148           0 :     return WindowBorderStyle::NONE;
    2149             : }
    2150             : 
    2151           0 : long Window::CalcTitleWidth() const
    2152             : {
    2153             : 
    2154           0 :     if ( mpWindowImpl->mpBorderWindow )
    2155             :     {
    2156           0 :         if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    2157           0 :             return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->CalcTitleWidth();
    2158             :         else
    2159           0 :             return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
    2160             :     }
    2161           0 :     else if ( mpWindowImpl->mbFrame && (mpWindowImpl->mnStyle & WB_MOVEABLE) )
    2162             :     {
    2163             :         // we guess the width for frame windows as we do not know the
    2164             :         // border of external dialogs
    2165           0 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    2166           0 :         vcl::Font aFont = GetFont();
    2167           0 :         const_cast<vcl::Window*>(this)->SetPointFont(*const_cast<Window*>(this), rStyleSettings.GetTitleFont());
    2168           0 :         long nTitleWidth = GetTextWidth( GetText() );
    2169           0 :         const_cast<vcl::Window*>(this)->SetFont( aFont );
    2170           0 :         nTitleWidth += rStyleSettings.GetTitleHeight() * 3;
    2171           0 :         nTitleWidth += rStyleSettings.GetBorderSize() * 2;
    2172           0 :         nTitleWidth += 10;
    2173           0 :         return nTitleWidth;
    2174             :     }
    2175             : 
    2176           0 :     return 0;
    2177             : }
    2178             : 
    2179       10771 : void Window::SetInputContext( const InputContext& rInputContext )
    2180             : {
    2181             : 
    2182       10771 :     mpWindowImpl->maInputContext = rInputContext;
    2183       10771 :     if ( !mpWindowImpl->mbInFocusHdl && HasFocus() )
    2184        1023 :         ImplNewInputContext();
    2185       10771 : }
    2186             : 
    2187           0 : void Window::EndExtTextInput( EndExtTextInputFlags nFlags )
    2188             : {
    2189             : 
    2190           0 :     if ( mpWindowImpl->mbExtTextInput )
    2191           0 :         ImplGetFrame()->EndExtTextInput( nFlags );
    2192           0 : }
    2193             : 
    2194           0 : void Window::SetCursorRect( const Rectangle* pRect, long nExtTextInputWidth )
    2195             : {
    2196             : 
    2197           0 :     ImplWinData* pWinData = ImplGetWinData();
    2198           0 :     if ( pWinData->mpCursorRect )
    2199             :     {
    2200           0 :         if ( pRect )
    2201           0 :             *pWinData->mpCursorRect = *pRect;
    2202             :         else
    2203             :         {
    2204           0 :             delete pWinData->mpCursorRect;
    2205           0 :             pWinData->mpCursorRect = NULL;
    2206             :         }
    2207             :     }
    2208             :     else
    2209             :     {
    2210           0 :         if ( pRect )
    2211           0 :             pWinData->mpCursorRect = new Rectangle( *pRect );
    2212             :     }
    2213             : 
    2214           0 :     pWinData->mnCursorExtWidth = nExtTextInputWidth;
    2215             : 
    2216           0 : }
    2217             : 
    2218           0 : const Rectangle* Window::GetCursorRect() const
    2219             : {
    2220             : 
    2221           0 :     ImplWinData* pWinData = ImplGetWinData();
    2222           0 :     return pWinData->mpCursorRect;
    2223             : }
    2224             : 
    2225           0 : long Window::GetCursorExtTextInputWidth() const
    2226             : {
    2227             : 
    2228           0 :     ImplWinData* pWinData = ImplGetWinData();
    2229           0 :     return pWinData->mnCursorExtWidth;
    2230             : }
    2231             : 
    2232           0 : void Window::SetCompositionCharRect( const Rectangle* pRect, long nCompositionLength, bool bVertical ) {
    2233             : 
    2234           0 :     ImplWinData* pWinData = ImplGetWinData();
    2235           0 :     delete[] pWinData->mpCompositionCharRects;
    2236           0 :     pWinData->mbVertical = bVertical;
    2237           0 :     pWinData->mpCompositionCharRects = NULL;
    2238           0 :     pWinData->mnCompositionCharRects = nCompositionLength;
    2239           0 :     if ( pRect && (nCompositionLength > 0) )
    2240             :     {
    2241           0 :         pWinData->mpCompositionCharRects = new Rectangle[nCompositionLength];
    2242           0 :         for (long i = 0; i < nCompositionLength; ++i)
    2243           0 :             pWinData->mpCompositionCharRects[i] = pRect[i];
    2244             :     }
    2245           0 : }
    2246             : 
    2247           0 : void Window::CollectChildren(::std::vector<vcl::Window *>& rAllChildren )
    2248             : {
    2249           0 :     rAllChildren.push_back( this );
    2250             : 
    2251           0 :     vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    2252           0 :     while ( pChild )
    2253             :     {
    2254           0 :         pChild->CollectChildren( rAllChildren );
    2255           0 :         pChild = pChild->mpWindowImpl->mpNext;
    2256             :     }
    2257           0 : }
    2258             : 
    2259      162456 : void Window::SetPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont)
    2260             : {
    2261      162456 :     vcl::Font aFont = rFont;
    2262      162456 :     ImplPointToLogic(rRenderContext, aFont);
    2263      162456 :     rRenderContext.SetFont(aFont);
    2264      162456 : }
    2265             : 
    2266           7 : vcl::Font Window::GetPointFont(vcl::RenderContext& rRenderContext) const
    2267             : {
    2268           7 :     vcl::Font aFont = rRenderContext.GetFont();
    2269           7 :     ImplLogicToPoint(rRenderContext, aFont);
    2270           7 :     return aFont;
    2271             : }
    2272             : 
    2273      868984 : void Window::Show(bool bVisible, ShowFlags nFlags)
    2274             : {
    2275      868984 :     if ( IsDisposed() || mpWindowImpl->mbVisible == bVisible )
    2276     1010908 :         return;
    2277             : 
    2278      363530 :     ImplDelData aDogTag( this );
    2279             : 
    2280      363530 :     bool bRealVisibilityChanged = false;
    2281      363530 :     mpWindowImpl->mbVisible = bVisible;
    2282             : 
    2283      363530 :     if ( !bVisible )
    2284             :     {
    2285      181652 :         ImplHideAllOverlaps();
    2286      181652 :         if( aDogTag.IsDead() )
    2287           0 :             return;
    2288             : 
    2289      181652 :         if ( mpWindowImpl->mpBorderWindow )
    2290             :         {
    2291       15409 :             bool bOldUpdate = mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate;
    2292       15409 :             if ( mpWindowImpl->mbNoParentUpdate )
    2293           0 :                 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = true;
    2294       15409 :             mpWindowImpl->mpBorderWindow->Show( false, nFlags );
    2295       15409 :             mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = bOldUpdate;
    2296             :         }
    2297      166243 :         else if ( mpWindowImpl->mbFrame )
    2298             :         {
    2299        3188 :             mpWindowImpl->mbSuppressAccessibilityEvents = true;
    2300        3188 :             mpWindowImpl->mpFrame->Show( false, false );
    2301             :         }
    2302             : 
    2303      181652 :         CompatStateChanged( StateChangedType::Visible );
    2304             : 
    2305      181652 :         if ( mpWindowImpl->mbReallyVisible )
    2306             :         {
    2307       68952 :             vcl::Region  aInvRegion;
    2308       68952 :             bool    bSaveBack = false;
    2309             : 
    2310       68952 :             if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
    2311             :             {
    2312           0 :                 if ( ImplRestoreOverlapBackground( aInvRegion ) )
    2313           0 :                     bSaveBack = true;
    2314             :             }
    2315             : 
    2316       68952 :             if ( !bSaveBack )
    2317             :             {
    2318       68952 :                 if ( mpWindowImpl->mbInitWinClipRegion )
    2319       27477 :                     ImplInitWinClipRegion();
    2320       68952 :                 aInvRegion = mpWindowImpl->maWinClipRegion;
    2321             :             }
    2322             : 
    2323       68952 :             if( aDogTag.IsDead() )
    2324           0 :                 return;
    2325             : 
    2326       68952 :             bRealVisibilityChanged = mpWindowImpl->mbReallyVisible;
    2327       68952 :             ImplResetReallyVisible();
    2328       68952 :             ImplSetClipFlag();
    2329             : 
    2330       68952 :             if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
    2331             :             {
    2332             :                 // convert focus
    2333           0 :                 if ( !(nFlags & ShowFlags::NoFocusChange) && HasChildPathFocus() )
    2334             :                 {
    2335           0 :                     if ( mpWindowImpl->mpOverlapWindow->IsEnabled() &&
    2336           0 :                          mpWindowImpl->mpOverlapWindow->IsInputEnabled() &&
    2337           0 :                          ! mpWindowImpl->mpOverlapWindow->IsInModalMode()
    2338             :                          )
    2339           0 :                         mpWindowImpl->mpOverlapWindow->GrabFocus();
    2340             :                 }
    2341             :             }
    2342             : 
    2343       68952 :             if ( !mpWindowImpl->mbFrame )
    2344             :             {
    2345       65764 :                 if( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mbEnableNativeWidget )
    2346             :                 {
    2347             :                     /*
    2348             :                     * #i48371# native theming: some themes draw outside the control
    2349             :                     * area we tell them to (bad thing, but we cannot do much about it ).
    2350             :                     * On hiding these controls they get invalidated with their window rectangle
    2351             :                     * which leads to the parts outside the control area being left and not
    2352             :                     * invalidated. Workaround: invalidate an area on the parent, too
    2353             :                     */
    2354       49477 :                     const int workaround_border = 5;
    2355       49477 :                     Rectangle aBounds( aInvRegion.GetBoundRect() );
    2356       49477 :                     aBounds.Left()      -= workaround_border;
    2357       49477 :                     aBounds.Top()       -= workaround_border;
    2358       49477 :                     aBounds.Right()     += workaround_border;
    2359       49477 :                     aBounds.Bottom()    += workaround_border;
    2360       49477 :                     aInvRegion = aBounds;
    2361             :                 }
    2362       65764 :                 if ( !mpWindowImpl->mbNoParentUpdate && !(nFlags & ShowFlags::NoParentUpdate) )
    2363             :                 {
    2364       65716 :                     if ( !aInvRegion.IsEmpty() )
    2365       62121 :                         ImplInvalidateParentFrameRegion( aInvRegion );
    2366             :                 }
    2367       65764 :                 ImplGenerateMouseMove();
    2368       68952 :             }
    2369             :         }
    2370             :     }
    2371             :     else
    2372             :     {
    2373             :         // inherit native widget flag for form controls
    2374             :         // required here, because frames never show up in the child hierarchy - which should be fixed....
    2375             :         // eg, the drop down of a combobox which is a system floating window
    2376      181882 :         if( mpWindowImpl->mbFrame && GetParent() && GetParent()->IsCompoundControl() &&
    2377           4 :             GetParent()->IsNativeWidgetEnabled() != IsNativeWidgetEnabled() )
    2378             :         {
    2379           0 :             EnableNativeWidget( GetParent()->IsNativeWidgetEnabled() );
    2380             :         }
    2381             : 
    2382      181878 :         if ( mpWindowImpl->mbCallMove )
    2383             :         {
    2384      173757 :             ImplCallMove();
    2385             :         }
    2386      181878 :         if ( mpWindowImpl->mbCallResize )
    2387             :         {
    2388      172886 :             ImplCallResize();
    2389             :         }
    2390             : 
    2391      181878 :         CompatStateChanged( StateChangedType::Visible );
    2392             : 
    2393             :         vcl::Window* pTestParent;
    2394      181878 :         if ( ImplIsOverlapWindow() )
    2395        3195 :             pTestParent = mpWindowImpl->mpOverlapWindow;
    2396             :         else
    2397      178683 :             pTestParent = ImplGetParent();
    2398      181878 :         if ( mpWindowImpl->mbFrame || pTestParent->mpWindowImpl->mbReallyVisible )
    2399             :         {
    2400             :             // if a window becomes visible, send all child windows a StateChange,
    2401             :             // such that these can initialise themselves
    2402       49887 :             ImplCallInitShow();
    2403             : 
    2404             :             // If it is a SystemWindow it automatically pops up on top of
    2405             :             // all other windows if needed.
    2406       49887 :             if ( ImplIsOverlapWindow() && !(nFlags & ShowFlags::NoActivate) )
    2407             :             {
    2408        3183 :                 ImplStartToTop(( nFlags & ShowFlags::ForegroundTask ) ? ToTopFlags::ForegroundTask : ToTopFlags::NONE );
    2409        3183 :                 ImplFocusToTop( ToTopFlags::NONE, false );
    2410             :             }
    2411             : 
    2412             :             // save background
    2413       49887 :             if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mbSaveBack )
    2414           0 :                 ImplSaveOverlapBackground();
    2415             :             // adjust mpWindowImpl->mbReallyVisible
    2416       49887 :             bRealVisibilityChanged = !mpWindowImpl->mbReallyVisible;
    2417       49887 :             ImplSetReallyVisible();
    2418             : 
    2419             :             // assure clip rectangles will be recalculated
    2420       49887 :             ImplSetClipFlag();
    2421             : 
    2422       49887 :             if ( !mpWindowImpl->mbFrame )
    2423             :             {
    2424       46692 :                 InvalidateFlags nInvalidateFlags = InvalidateFlags::Children;
    2425       46692 :                 if( ! IsPaintTransparent() )
    2426       40048 :                     nInvalidateFlags |= InvalidateFlags::NoTransparent;
    2427       46692 :                 ImplInvalidate( NULL, nInvalidateFlags );
    2428       46692 :                 ImplGenerateMouseMove();
    2429             :             }
    2430             :         }
    2431             : 
    2432      181878 :         if ( mpWindowImpl->mpBorderWindow )
    2433       15433 :             mpWindowImpl->mpBorderWindow->Show( true, nFlags );
    2434      166445 :         else if ( mpWindowImpl->mbFrame )
    2435             :         {
    2436             :             // #106431#, hide SplashScreen
    2437        3195 :             ImplSVData* pSVData = ImplGetSVData();
    2438        3195 :             if ( !pSVData->mpIntroWindow )
    2439             :             {
    2440             :                 // The right way would be just to call this (not even in the 'if')
    2441        3195 :                 GetpApp()->InitFinished();
    2442             :             }
    2443           0 :             else if ( !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
    2444             :             {
    2445             :                 // ... but the VCL splash is broken, and it needs this
    2446             :                 // (for ./soffice .uno:NewDoc)
    2447           0 :                 pSVData->mpIntroWindow->Hide();
    2448             :             }
    2449             : 
    2450             :             //DBG_ASSERT( !mpWindowImpl->mbSuppressAccessibilityEvents, "Window::Show() - Frame reactivated");
    2451        3195 :             mpWindowImpl->mbSuppressAccessibilityEvents = false;
    2452             : 
    2453        3195 :             mpWindowImpl->mbPaintFrame = true;
    2454        3195 :             if (!Application::GetSettings().GetMiscSettings().GetPseudoHeadless())
    2455             :             {
    2456        3191 :                 bool bNoActivate(nFlags & (ShowFlags::NoActivate|ShowFlags::NoFocusChange));
    2457        3191 :                 mpWindowImpl->mpFrame->Show( true, bNoActivate );
    2458             :             }
    2459        3195 :             if( aDogTag.IsDead() )
    2460           0 :                 return;
    2461             : 
    2462             :             // Query the correct size of the window, if we are waiting for
    2463             :             // a system resize
    2464        3195 :             if ( mpWindowImpl->mbWaitSystemResize )
    2465             :             {
    2466             :                 long nOutWidth;
    2467             :                 long nOutHeight;
    2468          78 :                 mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight );
    2469          78 :                 ImplHandleResize( this, nOutWidth, nOutHeight );
    2470             :             }
    2471             :         }
    2472             : 
    2473      181878 :         if( aDogTag.IsDead() )
    2474           0 :             return;
    2475             : 
    2476             : #if OSL_DEBUG_LEVEL > 0
    2477             :         if ( IsDialog() || (GetType() == WINDOW_TABPAGE) || (GetType() == WINDOW_DOCKINGWINDOW) )
    2478             :         {
    2479             :             DBG_DIALOGTEST( this );
    2480             :         }
    2481             : #endif
    2482             : 
    2483      181878 :         ImplShowAllOverlaps();
    2484             :     }
    2485             : 
    2486      363530 :     if( aDogTag.IsDead() )
    2487           0 :         return;
    2488             :     // invalidate all saved backgrounds
    2489      363530 :     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    2490           0 :         ImplInvalidateAllOverlapBackgrounds();
    2491             : 
    2492             :     // the SHOW/HIDE events also serve as indicators to send child creation/destroy events to the access bridge
    2493             :     // However, the access bridge only uses this event if the data member is not NULL (it's kind of a hack that
    2494             :     // we re-use the SHOW/HIDE events this way, with this particular semantics).
    2495             :     // Since #104887#, the notifications for the access bridge are done in Impl(Set|Reset)ReallyVisible. Here, we
    2496             :     // now only notify with a NULL data pointer, for all other clients except the access bridge.
    2497      363530 :     if ( !bRealVisibilityChanged )
    2498      244691 :         CallEventListeners( mpWindowImpl->mbVisible ? VCLEVENT_WINDOW_SHOW : VCLEVENT_WINDOW_HIDE, NULL );
    2499      363530 :     if( aDogTag.IsDead() )
    2500           0 :         return;
    2501             : 
    2502             : }
    2503             : 
    2504      883077 : Size Window::GetSizePixel() const
    2505             : {
    2506      883077 :     if (!mpWindowImpl)
    2507             :     {
    2508             :         SAL_WARN("vcl.layout", "WTF no windowimpl");
    2509           0 :         return Size(0,0);
    2510             :     }
    2511             : 
    2512             :     // #i43257# trigger pending resize handler to assure correct window sizes
    2513      883077 :     if( mpWindowImpl->mpFrameData->maResizeIdle.IsActive() )
    2514             :     {
    2515        2558 :         ImplDelData aDogtag( const_cast<Window*>(this) );
    2516        2558 :         mpWindowImpl->mpFrameData->maResizeIdle.Stop();
    2517        2558 :         mpWindowImpl->mpFrameData->maResizeIdle.GetIdleHdl().Call( NULL );
    2518        2558 :         if( aDogtag.IsDead() )
    2519           0 :             return Size(0,0);
    2520             :     }
    2521             : 
    2522      883077 :     return Size( mnOutWidth+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
    2523     1766154 :                  mnOutHeight+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
    2524             : }
    2525             : 
    2526      118969 : void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
    2527             :                                sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
    2528             : {
    2529      118969 :     rLeftBorder     = mpWindowImpl->mnLeftBorder;
    2530      118969 :     rTopBorder      = mpWindowImpl->mnTopBorder;
    2531      118969 :     rRightBorder    = mpWindowImpl->mnRightBorder;
    2532      118969 :     rBottomBorder   = mpWindowImpl->mnBottomBorder;
    2533      118969 : }
    2534             : 
    2535      121970 : void Window::Enable( bool bEnable, bool bChild )
    2536             : {
    2537      121970 :     if ( IsDisposed() )
    2538      121970 :         return;
    2539             : 
    2540      121970 :     if ( !bEnable )
    2541             :     {
    2542             :         // the tracking mode will be stopped or the capture will be stolen
    2543             :         // when a window is disabled,
    2544       48540 :         if ( IsTracking() )
    2545           0 :             EndTracking( TrackingEventFlags::Cancel );
    2546       48540 :         if ( IsMouseCaptured() )
    2547           0 :             ReleaseMouse();
    2548             :         // try to pass focus to the next control
    2549             :         // if the window has focus and is contained in the dialog control
    2550             :         // mpWindowImpl->mbDisabled should only be set after a call of ImplDlgCtrlNextWindow().
    2551             :         // Otherwise ImplDlgCtrlNextWindow() should be used
    2552       48540 :         if ( HasFocus() )
    2553         639 :             ImplDlgCtrlNextWindow();
    2554             :     }
    2555             : 
    2556      121970 :     if ( mpWindowImpl->mpBorderWindow )
    2557             :     {
    2558       12443 :         mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
    2559       24886 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    2560       12443 :              static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
    2561        1382 :             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->Enable( bEnable, true );
    2562             :     }
    2563             : 
    2564             :     // #i56102# restore app focus win in case the
    2565             :     // window was disabled when the frame focus changed
    2566      121970 :     ImplSVData* pSVData = ImplGetSVData();
    2567      195400 :     if( bEnable &&
    2568       94482 :         pSVData->maWinData.mpFocusWin == nullptr &&
    2569      127034 :         mpWindowImpl->mpFrameData->mbHasFocus &&
    2570        5064 :         mpWindowImpl->mpFrameData->mpFocusWin == this )
    2571           0 :         pSVData->maWinData.mpFocusWin = this;
    2572             : 
    2573      121970 :     if ( mpWindowImpl->mbDisabled != !bEnable )
    2574             :     {
    2575       82140 :         mpWindowImpl->mbDisabled = !bEnable;
    2576       82140 :         if ( mpWindowImpl->mpSysObj )
    2577           0 :             mpWindowImpl->mpSysObj->Enable( bEnable && !mpWindowImpl->mbInputDisabled );
    2578       82140 :         CompatStateChanged( StateChangedType::Enable );
    2579             : 
    2580       82140 :         CallEventListeners( bEnable ? VCLEVENT_WINDOW_ENABLED : VCLEVENT_WINDOW_DISABLED );
    2581             :     }
    2582             : 
    2583      121970 :     if ( bChild || mpWindowImpl->mbChildNotify )
    2584             :     {
    2585      108976 :         vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    2586      301414 :         while ( pChild )
    2587             :         {
    2588       83462 :             pChild->Enable( bEnable, bChild );
    2589       83462 :             pChild = pChild->mpWindowImpl->mpNext;
    2590             :         }
    2591             :     }
    2592             : 
    2593      121970 :     if ( IsReallyVisible() )
    2594       54784 :         ImplGenerateMouseMove();
    2595             : }
    2596             : 
    2597         168 : void Window::SetCallHandlersOnInputDisabled( bool bCall )
    2598             : {
    2599         168 :     mpWindowImpl->mbCallHandlersDuringInputDisabled = bCall;
    2600             : 
    2601         168 :     vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    2602         336 :     while ( pChild )
    2603             :     {
    2604           0 :         pChild->SetCallHandlersOnInputDisabled( bCall );
    2605           0 :         pChild = pChild->mpWindowImpl->mpNext;
    2606             :     }
    2607         168 : }
    2608             : 
    2609           0 : bool Window::IsCallHandlersOnInputDisabled() const
    2610             : {
    2611           0 :     return mpWindowImpl->mbCallHandlersDuringInputDisabled;
    2612             : }
    2613             : 
    2614       51887 : void Window::EnableInput( bool bEnable, bool bChild )
    2615             : {
    2616             : 
    2617       51887 :     bool bNotify = (bEnable != mpWindowImpl->mbInputDisabled);
    2618       51887 :     if ( mpWindowImpl->mpBorderWindow )
    2619             :     {
    2620        2086 :         mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
    2621        4172 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    2622        2086 :              static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
    2623          28 :             static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->EnableInput( bEnable, true );
    2624             :     }
    2625             : 
    2626       51887 :     if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||
    2627       27173 :          (  bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled) )
    2628             :     {
    2629             :         // automatically stop the tracking mode or steal capture
    2630             :         // if the window is disabled
    2631       51833 :         if ( !bEnable )
    2632             :         {
    2633       24714 :             if ( IsTracking() )
    2634           0 :                 EndTracking( TrackingEventFlags::Cancel );
    2635       24714 :             if ( IsMouseCaptured() )
    2636           0 :                 ReleaseMouse();
    2637             :         }
    2638             : 
    2639       51833 :         if ( mpWindowImpl->mbInputDisabled != !bEnable )
    2640             :         {
    2641       48453 :             mpWindowImpl->mbInputDisabled = !bEnable;
    2642       48453 :             if ( mpWindowImpl->mpSysObj )
    2643           0 :                 mpWindowImpl->mpSysObj->Enable( !mpWindowImpl->mbDisabled && bEnable );
    2644             :         }
    2645             :     }
    2646             : 
    2647             :     // #i56102# restore app focus win in case the
    2648             :     // window was disabled when the frame focus changed
    2649       51887 :     ImplSVData* pSVData = ImplGetSVData();
    2650       79060 :     if( bEnable &&
    2651       28803 :         pSVData->maWinData.mpFocusWin == nullptr &&
    2652       52263 :         mpWindowImpl->mpFrameData->mbHasFocus &&
    2653         376 :         mpWindowImpl->mpFrameData->mpFocusWin == this )
    2654           0 :         pSVData->maWinData.mpFocusWin = this;
    2655             : 
    2656       51887 :     if ( bChild || mpWindowImpl->mbChildNotify )
    2657             :     {
    2658       49633 :         vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    2659      146961 :         while ( pChild )
    2660             :         {
    2661       47695 :             pChild->EnableInput( bEnable, bChild );
    2662       47695 :             pChild = pChild->mpWindowImpl->mpNext;
    2663             :         }
    2664             :     }
    2665             : 
    2666       51887 :     if ( IsReallyVisible() )
    2667       21926 :         ImplGenerateMouseMove();
    2668             : 
    2669             :     // #104827# notify parent
    2670       51887 :     if ( bNotify )
    2671             :     {
    2672        3380 :         NotifyEvent aNEvt( bEnable ? MouseNotifyEvent::INPUTENABLE : MouseNotifyEvent::INPUTDISABLE, this );
    2673        3380 :         CompatNotify( aNEvt );
    2674             :     }
    2675       51887 : }
    2676             : 
    2677           0 : void Window::EnableInput( bool bEnable, bool bChild, bool bSysWin,
    2678             :                           const vcl::Window* pExcludeWindow )
    2679             : {
    2680             : 
    2681           0 :     EnableInput( bEnable, bChild );
    2682           0 :     if ( bSysWin )
    2683             :     {
    2684             :         // pExcuteWindow is the first Overlap-Frame --> if this
    2685             :         // shouldn't be the case, than this must be changed in dialog.cxx
    2686           0 :         if( pExcludeWindow )
    2687           0 :             pExcludeWindow = pExcludeWindow->ImplGetFirstOverlapWindow();
    2688           0 :         vcl::Window* pSysWin = mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mpFirstOverlap;
    2689           0 :         while ( pSysWin )
    2690             :         {
    2691             :             // Is Window in the path from this window
    2692           0 :             if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pSysWin, true ) )
    2693             :             {
    2694             :                 // Is Window not in the exclude window path or not the
    2695             :                 // exclude window, than change the status
    2696           0 :                 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pSysWin, true ) )
    2697           0 :                     pSysWin->EnableInput( bEnable, bChild );
    2698             :             }
    2699           0 :             pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
    2700             :         }
    2701             : 
    2702             :         // enable/disable floating system windows as well
    2703           0 :         vcl::Window* pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
    2704           0 :         while ( pFrameWin )
    2705             :         {
    2706           0 :             if( pFrameWin->ImplIsFloatingWindow() )
    2707             :             {
    2708             :                 // Is Window in the path from this window
    2709           0 :                 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pFrameWin, true ) )
    2710             :                 {
    2711             :                     // Is Window not in the exclude window path or not the
    2712             :                     // exclude window, than change the status
    2713           0 :                     if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pFrameWin, true ) )
    2714           0 :                         pFrameWin->EnableInput( bEnable, bChild );
    2715             :                 }
    2716             :             }
    2717           0 :             pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
    2718             :         }
    2719             : 
    2720             :         // the same for ownerdraw floating windows
    2721           0 :         if( mpWindowImpl->mbFrame )
    2722             :         {
    2723           0 :             ::std::vector< VclPtr<vcl::Window> >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList;
    2724           0 :             auto p = rList.begin();
    2725           0 :             while( p != rList.end() )
    2726             :             {
    2727             :                 // Is Window in the path from this window
    2728           0 :                 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( (*p), true ) )
    2729             :                 {
    2730             :                     // Is Window not in the exclude window path or not the
    2731             :                     // exclude window, than change the status
    2732           0 :                     if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( (*p), true ) )
    2733           0 :                         (*p)->EnableInput( bEnable, bChild );
    2734             :                 }
    2735           0 :                 ++p;
    2736             :             }
    2737             :         }
    2738             :     }
    2739           0 : }
    2740             : 
    2741           0 : void Window::AlwaysEnableInput( bool bAlways, bool bChild )
    2742             : {
    2743             : 
    2744           0 :     if ( mpWindowImpl->mpBorderWindow )
    2745           0 :         mpWindowImpl->mpBorderWindow->AlwaysEnableInput( bAlways, false );
    2746             : 
    2747           0 :     if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled )
    2748             :     {
    2749           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputEnabled;
    2750             : 
    2751           0 :         if ( bAlways )
    2752           0 :             EnableInput( true, false );
    2753             :     }
    2754           0 :     else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled )
    2755             :     {
    2756           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
    2757             :     }
    2758             : 
    2759           0 :     if ( bChild || mpWindowImpl->mbChildNotify )
    2760             :     {
    2761           0 :         vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    2762           0 :         while ( pChild )
    2763             :         {
    2764           0 :             pChild->AlwaysEnableInput( bAlways, bChild );
    2765           0 :             pChild = pChild->mpWindowImpl->mpNext;
    2766             :         }
    2767             :     }
    2768           0 : }
    2769             : 
    2770         168 : void Window::AlwaysDisableInput( bool bAlways, bool bChild )
    2771             : {
    2772             : 
    2773         168 :     if ( mpWindowImpl->mpBorderWindow )
    2774           0 :         mpWindowImpl->mpBorderWindow->AlwaysDisableInput( bAlways, false );
    2775             : 
    2776         168 :     if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled )
    2777             :     {
    2778         168 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputDisabled;
    2779             : 
    2780         336 :         if ( bAlways )
    2781         168 :             EnableInput( false, false );
    2782             :     }
    2783           0 :     else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled )
    2784             :     {
    2785           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
    2786             :     }
    2787             : 
    2788         168 :     if ( bChild || mpWindowImpl->mbChildNotify )
    2789             :     {
    2790         168 :         vcl::Window* pChild = mpWindowImpl->mpFirstChild;
    2791         336 :         while ( pChild )
    2792             :         {
    2793           0 :             pChild->AlwaysDisableInput( bAlways, bChild );
    2794           0 :             pChild = pChild->mpWindowImpl->mpNext;
    2795             :         }
    2796             :     }
    2797         168 : }
    2798             : 
    2799       13851 : void Window::SetActivateMode( ActivateModeFlags nMode )
    2800             : {
    2801             : 
    2802       13851 :     if ( mpWindowImpl->mpBorderWindow )
    2803        6921 :         mpWindowImpl->mpBorderWindow->SetActivateMode( nMode );
    2804             : 
    2805       13851 :     if ( mpWindowImpl->mnActivateMode != nMode )
    2806             :     {
    2807        6921 :         mpWindowImpl->mnActivateMode = nMode;
    2808             : 
    2809             :         // possibly trigger Decativate/Activate
    2810        6921 :         if ( mpWindowImpl->mnActivateMode != ActivateModeFlags::NONE )
    2811             :         {
    2812        7262 :             if ( (mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW)) &&
    2813        3631 :                  !HasChildPathFocus( true ) )
    2814             :             {
    2815        3631 :                 mpWindowImpl->mbActive = false;
    2816        3631 :                 Deactivate();
    2817             :             }
    2818             :         }
    2819             :         else
    2820             :         {
    2821        3290 :             if ( !mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW) )
    2822             :             {
    2823        3290 :                 mpWindowImpl->mbActive = true;
    2824        3290 :                 Activate();
    2825             :             }
    2826             :         }
    2827             :     }
    2828       13851 : }
    2829             : 
    2830      658439 : void Window::setPosSizePixel( long nX, long nY,
    2831             :                               long nWidth, long nHeight, PosSizeFlags nFlags )
    2832             : {
    2833             : 
    2834      658439 :     bool bHasValidSize = !mpWindowImpl->mbDefSize;
    2835             : 
    2836      658439 :     if ( nFlags & PosSizeFlags::Pos )
    2837      513021 :         mpWindowImpl->mbDefPos = false;
    2838      658439 :     if ( nFlags & PosSizeFlags::Size )
    2839      607387 :         mpWindowImpl->mbDefSize = false;
    2840             : 
    2841             :     // The top BorderWindow is the window which is to be positioned
    2842      658439 :     vcl::Window* pWindow = this;
    2843     1362270 :     while ( pWindow->mpWindowImpl->mpBorderWindow )
    2844       45392 :         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
    2845             : 
    2846      658439 :     if ( pWindow->mpWindowImpl->mbFrame )
    2847             :     {
    2848             :         // Note: if we're positioning a frame, the coordinates are interpreted
    2849             :         // as being the top-left corner of the window's client area and NOT
    2850             :         // as the position of the border ! (due to limitations of several UNIX window managers)
    2851        6111 :         long nOldWidth  = pWindow->mnOutWidth;
    2852             : 
    2853        6111 :         if ( !(nFlags & PosSizeFlags::Width) )
    2854          16 :             nWidth = pWindow->mnOutWidth;
    2855        6111 :         if ( !(nFlags & PosSizeFlags::Height) )
    2856          16 :             nHeight = pWindow->mnOutHeight;
    2857             : 
    2858        6111 :         sal_uInt16 nSysFlags=0;
    2859        6111 :         vcl::Window *pParent = GetParent();
    2860             : 
    2861        6111 :         if( nFlags & PosSizeFlags::Width )
    2862        6095 :             nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
    2863        6111 :         if( nFlags & PosSizeFlags::Height )
    2864        6095 :             nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT;
    2865        6111 :         if( nFlags & PosSizeFlags::X )
    2866             :         {
    2867          28 :             nSysFlags |= SAL_FRAME_POSSIZE_X;
    2868          28 :             if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
    2869             :             {
    2870           0 :                 nX += pParent->mnOutOffX;
    2871             :             }
    2872          28 :             if( pParent && pParent->ImplIsAntiparallel() )
    2873             :             {
    2874             :                 // --- RTL --- (re-mirror at parent window)
    2875           0 :                 Rectangle aRect( Point ( nX, nY ), Size( nWidth, nHeight ) );
    2876           0 :                 const OutputDevice *pParentOutDev = pParent->GetOutDev();
    2877           0 :                 pParentOutDev->ReMirror( aRect );
    2878           0 :                 nX = aRect.Left();
    2879             :             }
    2880             :         }
    2881        6111 :         if( !(nFlags & PosSizeFlags::X) && bHasValidSize && pWindow->mpWindowImpl->mpFrame->maGeometry.nWidth )
    2882             :         {
    2883             :             // --- RTL ---  make sure the old right aligned position is not changed
    2884             :             //              system windows will always grow to the right
    2885        2952 :             if ( pParent )
    2886             :             {
    2887        2951 :                 OutputDevice *pParentOutDev = pParent->GetOutDev();
    2888        2951 :                 if( pParentOutDev->HasMirroredGraphics() )
    2889             :                 {
    2890           0 :                     long myWidth = nOldWidth;
    2891           0 :                     if( !myWidth )
    2892           0 :                         myWidth = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth;
    2893           0 :                     if( !myWidth )
    2894           0 :                         myWidth = nWidth;
    2895           0 :                     nFlags |= PosSizeFlags::X;
    2896           0 :                     nSysFlags |= SAL_FRAME_POSSIZE_X;
    2897           0 :                     nX = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX -
    2898           0 :                         mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration;
    2899           0 :                     nX = pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration +
    2900           0 :                         pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth - myWidth - 1 - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX;
    2901           0 :                     if(!(nFlags & PosSizeFlags::Y))
    2902             :                     {
    2903           0 :                         nFlags |= PosSizeFlags::Y;
    2904           0 :                         nSysFlags |= SAL_FRAME_POSSIZE_Y;
    2905           0 :                         nY = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY - pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY -
    2906           0 :                             mpWindowImpl->mpFrame->GetUnmirroredGeometry().nTopDecoration;
    2907             :                     }
    2908             :                 }
    2909             :             }
    2910             :         }
    2911        6111 :         if( nFlags & PosSizeFlags::Y )
    2912             :         {
    2913          28 :             nSysFlags |= SAL_FRAME_POSSIZE_Y;
    2914          28 :             if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
    2915             :             {
    2916           0 :                 nY += pParent->mnOutOffY;
    2917             :             }
    2918             :         }
    2919             : 
    2920        6111 :         if( nSysFlags & (SAL_FRAME_POSSIZE_WIDTH|SAL_FRAME_POSSIZE_HEIGHT) )
    2921             :         {
    2922             :             // check for min/max client size and adjust size accordingly
    2923             :             // otherwise it may happen that the resize event is ignored, i.e. the old size remains
    2924             :             // unchanged but ImplHandleResize() is called with the wrong size
    2925        6095 :             SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( pWindow );
    2926        6095 :             if( pSystemWindow )
    2927             :             {
    2928          13 :                 Size aMinSize = pSystemWindow->GetMinOutputSizePixel();
    2929          13 :                 Size aMaxSize = pSystemWindow->GetMaxOutputSizePixel();
    2930          13 :                 if( nWidth < aMinSize.Width() )
    2931           0 :                     nWidth = aMinSize.Width();
    2932          13 :                 if( nHeight < aMinSize.Height() )
    2933           0 :                     nHeight = aMinSize.Height();
    2934             : 
    2935          13 :                 if( nWidth > aMaxSize.Width() )
    2936           0 :                     nWidth = aMaxSize.Width();
    2937          13 :                 if( nHeight > aMaxSize.Height() )
    2938           0 :                     nHeight = aMaxSize.Height();
    2939             :             }
    2940             :         }
    2941             : 
    2942        6111 :         pWindow->mpWindowImpl->mpFrame->SetPosSize( nX, nY, nWidth, nHeight, nSysFlags );
    2943             : 
    2944             :         // Resize should be called directly. If we havn't
    2945             :         // set the correct size, we get a second resize from
    2946             :         // the system with the correct size. This can be happened
    2947             :         // if the size is to small or to large.
    2948        6111 :         ImplHandleResize( pWindow, nWidth, nHeight );
    2949             :     }
    2950             :     else
    2951             :     {
    2952      652328 :         pWindow->ImplPosSizeWindow( nX, nY, nWidth, nHeight, nFlags );
    2953      652328 :         if ( IsReallyVisible() )
    2954      221559 :             ImplGenerateMouseMove();
    2955             :     }
    2956      658439 : }
    2957             : 
    2958      398538 : Point Window::GetPosPixel() const
    2959             : {
    2960      398538 :     return mpWindowImpl->maPos;
    2961             : }
    2962             : 
    2963       10571 : Rectangle Window::GetDesktopRectPixel() const
    2964             : {
    2965       10571 :     Rectangle rRect;
    2966       10571 :     mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrame->GetWorkArea( rRect );
    2967       10571 :     return rRect;
    2968             : }
    2969             : 
    2970       27394 : Point Window::OutputToScreenPixel( const Point& rPos ) const
    2971             : {
    2972             :     // relative to top level parent
    2973       27394 :     return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
    2974             : }
    2975             : 
    2976        4462 : Point Window::ScreenToOutputPixel( const Point& rPos ) const
    2977             : {
    2978             :     // relative to top level parent
    2979        4462 :     return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
    2980             : }
    2981             : 
    2982           0 : long Window::ImplGetUnmirroredOutOffX()
    2983             : {
    2984             :     // revert mnOutOffX changes that were potentially made in ImplPosSizeWindow
    2985           0 :     long offx = mnOutOffX;
    2986           0 :     OutputDevice *pOutDev = GetOutDev();
    2987           0 :     if( pOutDev->HasMirroredGraphics() )
    2988             :     {
    2989           0 :         if( mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
    2990             :         {
    2991           0 :             if ( !ImplIsOverlapWindow() )
    2992           0 :                 offx -= mpWindowImpl->mpParent->mnOutOffX;
    2993             : 
    2994           0 :             offx = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - offx;
    2995             : 
    2996           0 :             if ( !ImplIsOverlapWindow() )
    2997           0 :                 offx += mpWindowImpl->mpParent->mnOutOffX;
    2998             : 
    2999             :         }
    3000             :     }
    3001           0 :     return offx;
    3002             : }
    3003             : 
    3004             : // normalized screen pixel are independent of mirroring
    3005           0 : Point Window::OutputToNormalizedScreenPixel( const Point& rPos ) const
    3006             : {
    3007             :     // relative to top level parent
    3008           0 :     long offx = const_cast<vcl::Window*>(this)->ImplGetUnmirroredOutOffX();
    3009           0 :     return Point( rPos.X()+offx, rPos.Y()+mnOutOffY );
    3010             : }
    3011             : 
    3012           0 : Point Window::NormalizedScreenToOutputPixel( const Point& rPos ) const
    3013             : {
    3014             :     // relative to top level parent
    3015           0 :     long offx = const_cast<vcl::Window*>(this)->ImplGetUnmirroredOutOffX();
    3016           0 :     return Point( rPos.X()-offx, rPos.Y()-mnOutOffY );
    3017             : }
    3018             : 
    3019          56 : Point Window::OutputToAbsoluteScreenPixel( const Point& rPos ) const
    3020             : {
    3021             :     // relative to the screen
    3022          56 :     Point p = OutputToScreenPixel( rPos );
    3023          56 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    3024          56 :     p.X() += g.nX;
    3025          56 :     p.Y() += g.nY;
    3026          56 :     return p;
    3027             : }
    3028             : 
    3029        1157 : Point Window::AbsoluteScreenToOutputPixel( const Point& rPos ) const
    3030             : {
    3031             :     // relative to the screen
    3032        1157 :     Point p = ScreenToOutputPixel( rPos );
    3033        1157 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    3034        1157 :     p.X() -= g.nX;
    3035        1157 :     p.Y() -= g.nY;
    3036        1157 :     return p;
    3037             : }
    3038             : 
    3039           0 : Rectangle Window::ImplOutputToUnmirroredAbsoluteScreenPixel( const Rectangle &rRect ) const
    3040             : {
    3041             :     // this method creates unmirrored screen coordinates to be compared with the desktop
    3042             :     // and is used for positioning of RTL popup windows correctly on the screen
    3043           0 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetUnmirroredGeometry();
    3044             : 
    3045           0 :     Point p1 = OutputToScreenPixel( rRect.TopRight() );
    3046           0 :     p1.X() = g.nX+g.nWidth-p1.X();
    3047           0 :     p1.Y() += g.nY;
    3048             : 
    3049           0 :     Point p2 = OutputToScreenPixel( rRect.BottomLeft() );
    3050           0 :     p2.X() = g.nX+g.nWidth-p2.X();
    3051           0 :     p2.Y() += g.nY;
    3052             : 
    3053           0 :     return Rectangle( p1, p2 );
    3054             : }
    3055             : 
    3056       20098 : Rectangle Window::GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const
    3057             : {
    3058             :     // with decoration
    3059       20098 :     return ImplGetWindowExtentsRelative( pRelativeWindow, false );
    3060             : }
    3061             : 
    3062           0 : Rectangle Window::GetClientWindowExtentsRelative( vcl::Window *pRelativeWindow ) const
    3063             : {
    3064             :     // without decoration
    3065           0 :     return ImplGetWindowExtentsRelative( pRelativeWindow, true );
    3066             : }
    3067             : 
    3068       20098 : Rectangle Window::ImplGetWindowExtentsRelative( vcl::Window *pRelativeWindow, bool bClientOnly ) const
    3069             : {
    3070       20098 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    3071             :     // make sure we use the extent of our border window,
    3072             :     // otherwise we miss a few pixels
    3073       20098 :     const vcl::Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this;
    3074             : 
    3075       20098 :     Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) );
    3076       20098 :     aPos.X() += g.nX;
    3077       20098 :     aPos.Y() += g.nY;
    3078       20098 :     Size aSize ( pWin->GetSizePixel() );
    3079             :     // #104088# do not add decoration to the workwindow to be compatible to java accessibility api
    3080       20098 :     if( !bClientOnly && (mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && GetType() != WINDOW_WORKWINDOW)) )
    3081             :     {
    3082        1494 :         aPos.X() -= g.nLeftDecoration;
    3083        1494 :         aPos.Y() -= g.nTopDecoration;
    3084        1494 :         aSize.Width() += g.nLeftDecoration + g.nRightDecoration;
    3085        1494 :         aSize.Height() += g.nTopDecoration + g.nBottomDecoration;
    3086             :     }
    3087       20098 :     if( pRelativeWindow )
    3088             :     {
    3089             :         // #106399# express coordinates relative to borderwindow
    3090        1145 :         vcl::Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow.get() : pRelativeWindow;
    3091        1145 :         aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos );
    3092             :     }
    3093       20098 :     return Rectangle( aPos, aSize );
    3094             : }
    3095             : 
    3096        4148 : void Window::Scroll( long nHorzScroll, long nVertScroll, ScrollFlags nFlags )
    3097             : {
    3098             : 
    3099             :     ImplScroll( Rectangle( Point( mnOutOffX, mnOutOffY ),
    3100             :                            Size( mnOutWidth, mnOutHeight ) ),
    3101        4148 :                 nHorzScroll, nVertScroll, nFlags & ~ScrollFlags::Clip );
    3102        4148 : }
    3103             : 
    3104         658 : void Window::Scroll( long nHorzScroll, long nVertScroll,
    3105             :                      const Rectangle& rRect, ScrollFlags nFlags )
    3106             : {
    3107         658 :     OutputDevice *pOutDev = GetOutDev();
    3108         658 :     Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
    3109         658 :     aRect.Intersection( Rectangle( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ) );
    3110         658 :     if ( !aRect.IsEmpty() )
    3111         629 :         ImplScroll( aRect, nHorzScroll, nVertScroll, nFlags );
    3112         658 : }
    3113             : 
    3114       73437 : void Window::Flush()
    3115             : {
    3116             : 
    3117       73437 :     const Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    3118       73437 :     mpWindowImpl->mpFrame->Flush( aWinRect );
    3119       73437 : }
    3120             : 
    3121           0 : void Window::Sync()
    3122             : {
    3123             : 
    3124           0 :     mpWindowImpl->mpFrame->Sync();
    3125           0 : }
    3126             : 
    3127      265209 : void Window::SetUpdateMode( bool bUpdate )
    3128             : {
    3129      265209 :     mpWindowImpl->mbNoUpdate = !bUpdate;
    3130      265209 :     CompatStateChanged( StateChangedType::UpdateMode );
    3131      265209 : }
    3132             : 
    3133       30151 : void Window::GrabFocus()
    3134             : {
    3135       30151 :     ImplGrabFocus( GetFocusFlags::NONE );
    3136       30151 : }
    3137             : 
    3138      103996 : bool Window::HasFocus() const
    3139             : {
    3140      103996 :     return (this == ImplGetSVData()->maWinData.mpFocusWin);
    3141             : }
    3142             : 
    3143           2 : void Window::GrabFocusToDocument()
    3144             : {
    3145           2 :     ImplGrabFocusToDocument(GetFocusFlags::NONE);
    3146           2 : }
    3147             : 
    3148           0 : void Window::SetFakeFocus( bool bFocus )
    3149             : {
    3150           0 :     ImplGetWindowImpl()->mbFakeFocusSet = bFocus;
    3151           0 : }
    3152             : 
    3153       92793 : bool Window::HasChildPathFocus( bool bSystemWindow ) const
    3154             : {
    3155             : 
    3156       92793 :     vcl::Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
    3157       92793 :     if ( pFocusWin )
    3158       69537 :         return ImplIsWindowOrChild( pFocusWin, bSystemWindow );
    3159       23256 :     return false;
    3160             : }
    3161             : 
    3162       33953 : void Window::SetCursor( vcl::Cursor* pCursor )
    3163             : {
    3164             : 
    3165       33953 :     if ( mpWindowImpl->mpCursor != pCursor )
    3166             :     {
    3167       33948 :         if ( mpWindowImpl->mpCursor )
    3168       16925 :             mpWindowImpl->mpCursor->ImplHide( true );
    3169       33948 :         mpWindowImpl->mpCursor = pCursor;
    3170       33948 :         if ( pCursor )
    3171       17025 :             pCursor->ImplShow();
    3172             :     }
    3173       33953 : }
    3174             : 
    3175       35368 : void Window::SetText( const OUString& rStr )
    3176             : {
    3177       35368 :     if (rStr == mpWindowImpl->maText)
    3178       39431 :         return;
    3179             : 
    3180       31305 :     OUString oldTitle( mpWindowImpl->maText );
    3181       31305 :     mpWindowImpl->maText = rStr;
    3182             : 
    3183       31305 :     if ( mpWindowImpl->mpBorderWindow )
    3184        6832 :         mpWindowImpl->mpBorderWindow->SetText( rStr );
    3185       24473 :     else if ( mpWindowImpl->mbFrame )
    3186        6818 :         mpWindowImpl->mpFrame->SetTitle( rStr );
    3187             : 
    3188       31305 :     CallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
    3189             : 
    3190             :     // #107247# needed for accessibility
    3191             :     // The VCLEVENT_WINDOW_FRAMETITLECHANGED is (mis)used to notify accessible name changes.
    3192             :     // Therefore a window, which is labeled by this window, must also notify an accessible
    3193             :     // name change.
    3194       31305 :     if ( IsReallyVisible() )
    3195             :     {
    3196       11056 :         vcl::Window* pWindow = GetAccessibleRelationLabelFor();
    3197       11056 :         if ( pWindow && pWindow != this )
    3198           0 :             pWindow->CallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
    3199             :     }
    3200             : 
    3201       31305 :     CompatStateChanged( StateChangedType::Text );
    3202             : }
    3203             : 
    3204       55413 : OUString Window::GetText() const
    3205             : {
    3206             : 
    3207       55413 :     return mpWindowImpl->maText;
    3208             : }
    3209             : 
    3210           0 : OUString Window::GetDisplayText() const
    3211             : {
    3212             : 
    3213           0 :     return GetText();
    3214             : }
    3215             : 
    3216        2159 : const Wallpaper& Window::GetDisplayBackground() const
    3217             : {
    3218             :     // FIXME: fix issue 52349, need to fix this really in
    3219             :     // all NWF enabled controls
    3220        2159 :     const ToolBox* pTB = dynamic_cast<const ToolBox*>(this);
    3221        2159 :     if( pTB )
    3222             :     {
    3223        1031 :         if( IsNativeWidgetEnabled() )
    3224        1031 :             return pTB->ImplGetToolBoxPrivateData()->maDisplayBackground;
    3225             :     }
    3226             : 
    3227        1128 :     if( !IsBackground() )
    3228             :     {
    3229           0 :         if( mpWindowImpl->mpParent )
    3230           0 :             return mpWindowImpl->mpParent->GetDisplayBackground();
    3231             :     }
    3232             : 
    3233        1128 :     const Wallpaper& rBack = GetBackground();
    3234        3384 :     if( ! rBack.IsBitmap() &&
    3235        2256 :         ! rBack.IsGradient() &&
    3236        2256 :         rBack.GetColor().GetColor() == COL_TRANSPARENT &&
    3237           0 :         mpWindowImpl->mpParent )
    3238           0 :             return mpWindowImpl->mpParent->GetDisplayBackground();
    3239        1128 :     return rBack;
    3240             : }
    3241             : 
    3242        2407 : const OUString& Window::GetHelpText() const
    3243             : {
    3244        2407 :     OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
    3245        2407 :     bool bStrHelpId = !aStrHelpId.isEmpty();
    3246             : 
    3247        2407 :     if ( !mpWindowImpl->maHelpText.getLength() && bStrHelpId )
    3248             :     {
    3249          54 :         if ( !IsDialog() && (mpWindowImpl->mnType != WINDOW_TABPAGE) && (mpWindowImpl->mnType != WINDOW_FLOATINGWINDOW) )
    3250             :         {
    3251          54 :             Help* pHelp = Application::GetHelp();
    3252          54 :             if ( pHelp )
    3253             :             {
    3254          54 :                 mpWindowImpl->maHelpText = pHelp->GetHelpText(aStrHelpId, this);
    3255          54 :                 mpWindowImpl->mbHelpTextDynamic = false;
    3256             :             }
    3257             :         }
    3258             :     }
    3259        2353 :     else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId )
    3260             :     {
    3261           0 :         static const char* pEnv = getenv( "HELP_DEBUG" );
    3262           0 :         if( pEnv && *pEnv )
    3263             :         {
    3264           0 :             OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.getLength() );
    3265           0 :             aTxt.append( mpWindowImpl->maHelpText );
    3266           0 :             aTxt.appendAscii( "\n------------------\n" );
    3267           0 :             aTxt.append( OUString( aStrHelpId ) );
    3268           0 :             mpWindowImpl->maHelpText = aTxt.makeStringAndClear();
    3269             :         }
    3270           0 :         mpWindowImpl->mbHelpTextDynamic = false;
    3271             :     }
    3272             : 
    3273        2407 :     return mpWindowImpl->maHelpText;
    3274             : }
    3275             : 
    3276      157643 : void Window::SetWindowPeer( Reference< css::awt::XWindowPeer > xPeer, VCLXWindow* pVCLXWindow  )
    3277             : {
    3278             :     // be safe against re-entrance: first clear the old ref, then assign the new one
    3279      157643 :     mpWindowImpl->mxWindowPeer.clear();
    3280      157643 :     mpWindowImpl->mxWindowPeer = xPeer;
    3281             : 
    3282      157643 :     mpWindowImpl->mpVCLXWindow = pVCLXWindow;
    3283      157643 : }
    3284             : 
    3285      514307 : Reference< css::awt::XWindowPeer > Window::GetComponentInterface( bool bCreate )
    3286             : {
    3287      514307 :     if ( !mpWindowImpl->mxWindowPeer.is() && bCreate )
    3288             :     {
    3289       75224 :         UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
    3290       75224 :         if ( pWrapper )
    3291       75224 :             mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this, true );
    3292             :     }
    3293      514307 :     return mpWindowImpl->mxWindowPeer;
    3294             : }
    3295             : 
    3296        3668 : void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > xIFace )
    3297             : {
    3298        3668 :     UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
    3299             :     DBG_ASSERT( pWrapper, "SetComponentInterface: No Wrapper!" );
    3300        3668 :     if ( pWrapper )
    3301        3668 :         pWrapper->SetWindowInterface( this, xIFace );
    3302        3668 : }
    3303             : 
    3304       36256 : void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
    3305             : {
    3306             :     // no deactivation if the newly activated window is my child
    3307       36256 :     if ( !pNew || !ImplIsChild( pNew ) )
    3308             :     {
    3309       21364 :         ImplDelData aDogtag( this );
    3310       21364 :         CallEventListeners( VCLEVENT_WINDOW_DEACTIVATE );
    3311       21364 :         if( aDogtag.IsDead() )
    3312       36256 :             return;
    3313             : 
    3314             :         // #100759#, avoid walking the wrong frame's hierarchy
    3315             :         //           eg, undocked docking windows (ImplDockFloatWin)
    3316       21364 :         if ( ImplGetParent() && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow )
    3317       21339 :             ImplGetParent()->ImplCallDeactivateListeners( pNew );
    3318             :     }
    3319             : }
    3320             : 
    3321       39224 : void Window::ImplCallActivateListeners( vcl::Window *pOld )
    3322             : {
    3323             :     // no activation if the old active window is my child
    3324       39224 :     if ( !pOld || !ImplIsChild( pOld ) )
    3325             :     {
    3326       24332 :         ImplDelData aDogtag( this );
    3327       24332 :         CallEventListeners( VCLEVENT_WINDOW_ACTIVATE, pOld );
    3328       24332 :         if( aDogtag.IsDead() )
    3329       39224 :             return;
    3330             : 
    3331       24332 :         if ( ImplGetParent() )
    3332       21443 :             ImplGetParent()->ImplCallActivateListeners( pOld );
    3333        2889 :         else if( (mpWindowImpl->mnStyle & WB_INTROWIN) == 0 )
    3334             :         {
    3335             :             // top level frame reached: store hint for DefModalDialogParent
    3336        2889 :             ImplGetSVData()->maWinData.mpActiveApplicationFrame = mpWindowImpl->mpFrameWindow;
    3337       24332 :         }
    3338             :     }
    3339             : }
    3340             : 
    3341        6316 : Reference< XClipboard > Window::GetClipboard()
    3342             : {
    3343             : 
    3344        6316 :     if( mpWindowImpl->mpFrameData )
    3345             :     {
    3346        6316 :         if( ! mpWindowImpl->mpFrameData->mxClipboard.is() )
    3347             :         {
    3348             :             try
    3349             :             {
    3350             :                 mpWindowImpl->mpFrameData->mxClipboard
    3351        4431 :                     = css::datatransfer::clipboard::SystemClipboard::create(
    3352        1146 :                         comphelper::getProcessComponentContext());
    3353             :             }
    3354        2139 :             catch (DeploymentException & e)
    3355             :             {
    3356             :                 SAL_WARN(
    3357             :                     "vcl.window",
    3358             :                     "ignoring DeploymentException \"" << e.Message << "\"");
    3359             :             }
    3360             :         }
    3361             : 
    3362        6316 :         return mpWindowImpl->mpFrameData->mxClipboard;
    3363             :     }
    3364             : 
    3365           0 :     return static_cast < XClipboard * > (0);
    3366             : }
    3367             : 
    3368         503 : Reference< XClipboard > Window::GetPrimarySelection()
    3369             : {
    3370             : 
    3371         503 :     if( mpWindowImpl->mpFrameData )
    3372             :     {
    3373         503 :         if( ! mpWindowImpl->mpFrameData->mxSelection.is() )
    3374             :         {
    3375             :             try
    3376             :             {
    3377         386 :                 Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
    3378             : 
    3379             : #if HAVE_FEATURE_X11
    3380             :                 // A hack, making the primary selection available as an instance
    3381             :                 // of the SystemClipboard service on X11:
    3382         772 :                 Sequence< Any > args(1);
    3383         386 :                 args[0] <<= OUString("PRIMARY");
    3384             :                 mpWindowImpl->mpFrameData->mxSelection.set(
    3385         772 :                     (xContext->getServiceManager()->
    3386             :                      createInstanceWithArgumentsAndContext(
    3387             :                          "com.sun.star.datatransfer.clipboard.SystemClipboard",
    3388         386 :                          args, xContext)),
    3389        1130 :                     UNO_QUERY_THROW);
    3390             : #else
    3391             :                 static Reference< XClipboard > s_xSelection(
    3392             :                     xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.datatransfer.clipboard.GenericClipboard", xContext ), UNO_QUERY );
    3393             : 
    3394             :                 mpWindowImpl->mpFrameData->mxSelection = s_xSelection;
    3395             : #endif
    3396             :             }
    3397         358 :             catch (RuntimeException & e)
    3398             :             {
    3399             :                 SAL_WARN(
    3400             :                     "vcl.window",
    3401             :                     "ignoring RuntimeException \"" << e.Message << "\"");
    3402             :             }
    3403             :         }
    3404             : 
    3405         503 :         return mpWindowImpl->mpFrameData->mxSelection;
    3406             :     }
    3407             : 
    3408           0 :     return static_cast < XClipboard * > (0);
    3409             : }
    3410             : 
    3411         205 : void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect )
    3412             : {
    3413             :     assert(mpOutDevData);
    3414         205 :     mpOutDevData->mpRecordLayout = pLayout;
    3415         205 :     mpOutDevData->maRecordRect = rRect;
    3416         205 :     Paint(*this, rRect);
    3417         205 :     mpOutDevData->mpRecordLayout = NULL;
    3418         205 : }
    3419             : 
    3420           0 : void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly )
    3421             : {
    3422           0 :     DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, NULL, NULL );
    3423           0 : }
    3424             : 
    3425           0 : void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly, Color* pSelectionTextColor )
    3426             : {
    3427           0 :     DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, pSelectionTextColor, NULL );
    3428           0 : }
    3429             : 
    3430           0 : void Window::DrawSelectionBackground( const Rectangle& rRect,
    3431             :                                       sal_uInt16 highlight,
    3432             :                                       bool bChecked,
    3433             :                                       bool bDrawBorder,
    3434             :                                       bool bDrawExtBorderOnly,
    3435             :                                       long nCornerRadius,
    3436             :                                       Color* pSelectionTextColor,
    3437             :                                       Color* pPaintColor
    3438             :                                       )
    3439             : {
    3440           0 :     if( rRect.IsEmpty() )
    3441           0 :         return;
    3442             : 
    3443           0 :     bool bRoundEdges = nCornerRadius > 0;
    3444             : 
    3445           0 :     const StyleSettings& rStyles = GetSettings().GetStyleSettings();
    3446             : 
    3447             :     // colors used for item highlighting
    3448           0 :     Color aSelectionBorderCol( pPaintColor ? *pPaintColor : rStyles.GetHighlightColor() );
    3449           0 :     Color aSelectionFillCol( aSelectionBorderCol );
    3450             : 
    3451           0 :     bool bDark = rStyles.GetFaceColor().IsDark();
    3452           0 :     bool bBright = ( rStyles.GetFaceColor() == Color( COL_WHITE ) );
    3453             : 
    3454           0 :     int c1 = aSelectionBorderCol.GetLuminance();
    3455           0 :     int c2 = GetDisplayBackground().GetColor().GetLuminance();
    3456             : 
    3457           0 :     if( !bDark && !bBright && abs( c2-c1 ) < (pPaintColor ? 40 : 75) )
    3458             :     {
    3459             :         // constrast too low
    3460             :         sal_uInt16 h,s,b;
    3461           0 :         aSelectionFillCol.RGBtoHSB( h, s, b );
    3462           0 :         if( b > 50 )    b -= 40;
    3463           0 :         else            b += 40;
    3464           0 :         aSelectionFillCol.SetColor( Color::HSBtoRGB( h, s, b ) );
    3465           0 :         aSelectionBorderCol = aSelectionFillCol;
    3466             :     }
    3467             : 
    3468           0 :     if( bRoundEdges )
    3469             :     {
    3470           0 :         if( aSelectionBorderCol.IsDark() )
    3471           0 :             aSelectionBorderCol.IncreaseLuminance( 128 );
    3472             :         else
    3473           0 :             aSelectionBorderCol.DecreaseLuminance( 128 );
    3474             :     }
    3475             : 
    3476           0 :     Rectangle aRect( rRect );
    3477           0 :     if( bDrawExtBorderOnly )
    3478             :     {
    3479           0 :         --aRect.Left();
    3480           0 :         --aRect.Top();
    3481           0 :         ++aRect.Right();
    3482           0 :         ++aRect.Bottom();
    3483             :     }
    3484           0 :     Color oldFillCol = GetFillColor();
    3485           0 :     Color oldLineCol = GetLineColor();
    3486             : 
    3487           0 :     if( bDrawBorder )
    3488           0 :         SetLineColor( bDark ? Color(COL_WHITE) : ( bBright ? Color(COL_BLACK) : aSelectionBorderCol ) );
    3489             :     else
    3490           0 :         SetLineColor();
    3491             : 
    3492           0 :     sal_uInt16 nPercent = 0;
    3493           0 :     if( !highlight )
    3494             :     {
    3495           0 :         if( bDark )
    3496           0 :             aSelectionFillCol = COL_BLACK;
    3497             :         else
    3498           0 :             nPercent = 80;  // just checked (light)
    3499             :     }
    3500             :     else
    3501             :     {
    3502           0 :         if( bChecked && highlight == 2 )
    3503             :         {
    3504           0 :             if( bDark )
    3505           0 :                 aSelectionFillCol = COL_LIGHTGRAY;
    3506           0 :             else if ( bBright )
    3507             :             {
    3508           0 :                 aSelectionFillCol = COL_BLACK;
    3509           0 :                 SetLineColor( COL_BLACK );
    3510           0 :                 nPercent = 0;
    3511             :             }
    3512             :             else
    3513           0 :                 nPercent = bRoundEdges ? 40 : 20;          // selected, pressed or checked ( very dark )
    3514             :         }
    3515           0 :         else if( bChecked || highlight == 1 )
    3516             :         {
    3517           0 :             if( bDark )
    3518           0 :                 aSelectionFillCol = COL_GRAY;
    3519           0 :             else if ( bBright )
    3520             :             {
    3521           0 :                 aSelectionFillCol = COL_BLACK;
    3522           0 :                 SetLineColor( COL_BLACK );
    3523           0 :                 nPercent = 0;
    3524             :             }
    3525             :             else
    3526           0 :                 nPercent = bRoundEdges ? 60 : 35;          // selected, pressed or checked ( very dark )
    3527             :         }
    3528             :         else
    3529             :         {
    3530           0 :             if( bDark )
    3531           0 :                 aSelectionFillCol = COL_LIGHTGRAY;
    3532           0 :             else if ( bBright )
    3533             :             {
    3534           0 :                 aSelectionFillCol = COL_BLACK;
    3535           0 :                 SetLineColor( COL_BLACK );
    3536           0 :                 if( highlight == 3 )
    3537           0 :                     nPercent = 80;
    3538             :                 else
    3539           0 :                     nPercent = 0;
    3540             :             }
    3541             :             else
    3542           0 :                 nPercent = 70;          // selected ( dark )
    3543             :         }
    3544             :     }
    3545             : 
    3546           0 :     if( bDark && bDrawExtBorderOnly )
    3547             :     {
    3548           0 :         SetFillColor();
    3549           0 :         if( pSelectionTextColor )
    3550           0 :             *pSelectionTextColor = rStyles.GetHighlightTextColor();
    3551             :     }
    3552             :     else
    3553             :     {
    3554           0 :         SetFillColor( aSelectionFillCol );
    3555           0 :         if( pSelectionTextColor )
    3556             :         {
    3557           0 :             Color aTextColor = IsControlBackground() ? GetControlForeground() : rStyles.GetButtonTextColor();
    3558           0 :             Color aHLTextColor = rStyles.GetHighlightTextColor();
    3559           0 :             int nTextDiff = abs(aSelectionFillCol.GetLuminance() - aTextColor.GetLuminance());
    3560           0 :             int nHLDiff = abs(aSelectionFillCol.GetLuminance() - aHLTextColor.GetLuminance());
    3561           0 :             *pSelectionTextColor = (nHLDiff >= nTextDiff) ? aHLTextColor : aTextColor;
    3562             :         }
    3563             :     }
    3564             : 
    3565           0 :     if( bDark )
    3566             :     {
    3567           0 :         DrawRect( aRect );
    3568             :     }
    3569             :     else
    3570             :     {
    3571           0 :         if( bRoundEdges )
    3572             :         {
    3573           0 :             Polygon aPoly( aRect, nCornerRadius, nCornerRadius );
    3574           0 :             tools::PolyPolygon aPolyPoly( aPoly );
    3575           0 :             DrawTransparent( aPolyPoly, nPercent );
    3576             :         }
    3577             :         else
    3578             :         {
    3579           0 :             Polygon aPoly( aRect );
    3580           0 :             tools::PolyPolygon aPolyPoly( aPoly );
    3581           0 :             DrawTransparent( aPolyPoly, nPercent );
    3582             :         }
    3583             :     }
    3584             : 
    3585           0 :     SetFillColor( oldFillCol );
    3586           0 :     SetLineColor( oldLineCol );
    3587             : }
    3588             : 
    3589             : // controls should return the window that gets the
    3590             : // focus by default, so keyevents can be sent to that window directly
    3591           0 : vcl::Window* Window::GetPreferredKeyInputWindow()
    3592             : {
    3593           0 :     return this;
    3594             : }
    3595             : 
    3596        1260 : bool Window::IsScrollable() const
    3597             : {
    3598             :     // check for scrollbars
    3599        1260 :     vcl::Window *pChild = mpWindowImpl->mpFirstChild;
    3600        7224 :     while( pChild )
    3601             :     {
    3602        5408 :         if( pChild->GetType() == WINDOW_SCROLLBAR )
    3603         704 :             return true;
    3604             :         else
    3605        4704 :             pChild = pChild->mpWindowImpl->mpNext;
    3606             :     }
    3607         556 :     return false;
    3608             : }
    3609             : 
    3610           0 : void Window::ImplMirrorFramePos( Point &pt ) const
    3611             : {
    3612           0 :     pt.X() = mpWindowImpl->mpFrame->maGeometry.nWidth-1-pt.X();
    3613           0 : }
    3614             : 
    3615             : // frame based modal counter (dialogs are not modal to the whole application anymore)
    3616       42134 : bool Window::IsInModalMode() const
    3617             : {
    3618       42134 :     return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
    3619             : }
    3620             : 
    3621           0 : void Window::ImplIncModalCount()
    3622             : {
    3623           0 :     vcl::Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
    3624           0 :     vcl::Window* pParent = pFrameWindow;
    3625           0 :     while( pFrameWindow )
    3626             :     {
    3627           0 :         pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode++;
    3628           0 :         while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
    3629             :         {
    3630           0 :             pParent = pParent->GetParent();
    3631             :         }
    3632           0 :         pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow.get() : NULL;
    3633             :     }
    3634           0 : }
    3635           0 : void Window::ImplDecModalCount()
    3636             : {
    3637           0 :     vcl::Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
    3638           0 :     vcl::Window* pParent = pFrameWindow;
    3639           0 :     while( pFrameWindow )
    3640             :     {
    3641           0 :         pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode--;
    3642           0 :         while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
    3643             :         {
    3644           0 :             pParent = pParent->GetParent();
    3645             :         }
    3646           0 :         pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow.get() : NULL;
    3647             :     }
    3648           0 : }
    3649             : 
    3650       40343 : void Window::ImplIsInTaskPaneList( bool mbIsInTaskList )
    3651             : {
    3652       40343 :     mpWindowImpl->mbIsInTaskPaneList = mbIsInTaskList;
    3653       40343 : }
    3654             : 
    3655          16 : void Window::ImplNotifyIconifiedState( bool bIconified )
    3656             : {
    3657          16 :     mpWindowImpl->mpFrameWindow->CallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
    3658             :     // #109206# notify client window as well to have toolkit topwindow listeners notified
    3659          16 :     if( mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow && mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow )
    3660          11 :         mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow->CallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
    3661          16 : }
    3662             : 
    3663          21 : bool Window::HasActiveChildFrame()
    3664             : {
    3665          21 :     bool bRet = false;
    3666          21 :     vcl::Window *pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
    3667         184 :     while( pFrameWin )
    3668             :     {
    3669         142 :         if( pFrameWin != mpWindowImpl->mpFrameWindow )
    3670             :         {
    3671         121 :             bool bDecorated = false;
    3672         121 :             vcl::Window *pChildFrame = pFrameWin->ImplGetWindow();
    3673             :             // #i15285# unfortunately WB_MOVEABLE is the same as WB_TABSTOP which can
    3674             :             // be removed for ToolBoxes to influence the keyboard accessibility
    3675             :             // thus WB_MOVEABLE is no indicator for decoration anymore
    3676             :             // but FloatingWindows carry this information in their TitleType...
    3677             :             // TODO: avoid duplicate WinBits !!!
    3678         121 :             if( pChildFrame && pChildFrame->ImplIsFloatingWindow() )
    3679         100 :                 bDecorated = static_cast<FloatingWindow*>(pChildFrame)->GetTitleType() != FloatWinTitleType::NONE;
    3680         121 :             if( bDecorated || (pFrameWin->mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) )
    3681           0 :                 if( pChildFrame && pChildFrame->IsVisible() && pChildFrame->IsActive() )
    3682             :                 {
    3683           0 :                     if( ImplIsChild( pChildFrame, true ) )
    3684             :                     {
    3685           0 :                         bRet = true;
    3686           0 :                         break;
    3687             :                     }
    3688             :                 }
    3689             :         }
    3690         142 :         pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
    3691             :     }
    3692          21 :     return bRet;
    3693             : }
    3694             : 
    3695        3059 : LanguageType Window::GetInputLanguage() const
    3696             : {
    3697        3059 :     return mpWindowImpl->mpFrame->GetInputLanguage();
    3698             : }
    3699             : 
    3700       26735 : void Window::EnableNativeWidget( bool bEnable )
    3701             : {
    3702       26735 :     static const char* pNoNWF = getenv( "SAL_NO_NWF" );
    3703       26735 :     if( pNoNWF && *pNoNWF )
    3704           0 :         bEnable = false;
    3705             : 
    3706       26735 :     if( bEnable != ImplGetWinData()->mbEnableNativeWidget )
    3707             :     {
    3708       10362 :         ImplGetWinData()->mbEnableNativeWidget = bEnable;
    3709             : 
    3710             :         // send datachanged event to allow for internal changes required for NWF
    3711             :         // like clipmode, transparency, etc.
    3712       10362 :         DataChangedEvent aDCEvt( DataChangedEventType::SETTINGS, mxSettings.get(), AllSettingsFlags::STYLE );
    3713       10362 :         CompatDataChanged( aDCEvt );
    3714             : 
    3715             :         // sometimes the borderwindow is queried, so keep it in sync
    3716       10362 :         if( mpWindowImpl->mpBorderWindow )
    3717        3186 :             mpWindowImpl->mpBorderWindow->ImplGetWinData()->mbEnableNativeWidget = bEnable;
    3718             :     }
    3719             : 
    3720             :     // push down, useful for compound controls
    3721       26735 :     vcl::Window *pChild = mpWindowImpl->mpFirstChild;
    3722       70512 :     while( pChild )
    3723             :     {
    3724       17042 :         pChild->EnableNativeWidget( bEnable );
    3725       17042 :         pChild = pChild->mpWindowImpl->mpNext;
    3726             :     }
    3727       26735 : }
    3728             : 
    3729      977163 : bool Window::IsNativeWidgetEnabled() const
    3730             : {
    3731      977163 :     return ImplGetWinData()->mbEnableNativeWidget;
    3732             : }
    3733             : 
    3734          87 : Reference< css::rendering::XCanvas > Window::ImplGetCanvas( const Size& rFullscreenSize,
    3735             :                                                        bool        bFullscreen,
    3736             :                                                        bool        bSpriteCanvas ) const
    3737             : {
    3738             :     // try to retrieve hard reference from weak member
    3739          87 :     Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
    3740             : 
    3741             :     // canvas still valid? Then we're done.
    3742          87 :     if( xCanvas.is() )
    3743           0 :         return xCanvas;
    3744             : 
    3745         174 :     Sequence< Any > aArg(6);
    3746             : 
    3747             :     // Feed any with operating system's window handle
    3748             : 
    3749             :     // common: first any is VCL pointer to window (for VCL canvas)
    3750          87 :     aArg[ 0 ] = makeAny( reinterpret_cast<sal_Int64>(this) );
    3751             : 
    3752             :     // TODO(Q1): Make GetSystemData method virtual
    3753             : 
    3754             :     // check whether we're a SysChild: have to fetch system data
    3755             :     // directly from SystemChildWindow, because the GetSystemData
    3756             :     // method is unfortunately not virtual
    3757          87 :     const SystemChildWindow* pSysChild = dynamic_cast< const SystemChildWindow* >( this );
    3758          87 :     if( pSysChild )
    3759             :     {
    3760           0 :         aArg[ 1 ] = pSysChild->GetSystemDataAny();
    3761           0 :         aArg[ 5 ] = pSysChild->GetSystemGfxDataAny();
    3762             :     }
    3763             :     else
    3764             :     {
    3765          87 :         aArg[ 1 ] = GetSystemDataAny();
    3766          87 :         aArg[ 5 ] = GetSystemGfxDataAny();
    3767             :     }
    3768             : 
    3769          87 :     if( bFullscreen )
    3770           0 :         aArg[ 2 ] = makeAny( css::awt::Rectangle( 0, 0,
    3771           0 :                                     rFullscreenSize.Width(),
    3772           0 :                                     rFullscreenSize.Height() ) );
    3773             :     else
    3774          87 :         aArg[ 2 ] = makeAny( css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ) );
    3775             : 
    3776          87 :     aArg[ 3 ] = makeAny( mpWindowImpl->mbAlwaysOnTop );
    3777         174 :     aArg[ 4 ] = makeAny( Reference< css::awt::XWindow >(
    3778          87 :                              const_cast<vcl::Window*>(this)->GetComponentInterface(),
    3779          87 :                              UNO_QUERY ));
    3780             : 
    3781         174 :     Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
    3782             : 
    3783             :     // Create canvas instance with window handle
    3784             : 
    3785             :     static vcl::DeleteUnoReferenceOnDeinit<XMultiComponentFactory> xStaticCanvasFactory(
    3786          87 :         css::rendering::CanvasFactory::create( xContext ) );
    3787         174 :     Reference<XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
    3788             : 
    3789          87 :     if(xCanvasFactory.is())
    3790             :     {
    3791             : #ifdef WNT
    3792             :         // see #140456# - if we're running on a multiscreen setup,
    3793             :         // request special, multi-screen safe sprite canvas
    3794             :         // implementation (not DX5 canvas, as it cannot cope with
    3795             :         // surfaces spanning multiple displays). Note: canvas
    3796             :         // (without sprite) stays the same)
    3797             :         const sal_uInt32 nDisplay = static_cast< WinSalFrame* >( mpWindowImpl->mpFrame )->mnDisplay;
    3798             :         if( (nDisplay >= Application::GetScreenCount()) )
    3799             :         {
    3800             :             xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
    3801             :                                  bSpriteCanvas ?
    3802             :                                  OUString( "com.sun.star.rendering.SpriteCanvas.MultiScreen" ) :
    3803             :                                  OUString( "com.sun.star.rendering.Canvas.MultiScreen" ),
    3804             :                                  aArg,
    3805             :                                  xContext ),
    3806             :                              UNO_QUERY );
    3807             : 
    3808             :         }
    3809             :         else
    3810             :         {
    3811             : #endif
    3812          87 :             xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
    3813             :                              bSpriteCanvas ?
    3814             :                              OUString( "com.sun.star.rendering.SpriteCanvas" ) :
    3815             :                              OUString( "com.sun.star.rendering.Canvas" ),
    3816             :                              aArg,
    3817          87 :                              xContext ),
    3818          87 :                          UNO_QUERY );
    3819             : 
    3820             : #ifdef WNT
    3821             :         }
    3822             : #endif
    3823          87 :         mpWindowImpl->mxCanvas = xCanvas;
    3824             :     }
    3825             : 
    3826             :     // no factory??? Empty reference, then.
    3827          87 :     return xCanvas;
    3828             : }
    3829             : 
    3830          87 : Reference< css::rendering::XCanvas > Window::GetCanvas() const
    3831             : {
    3832          87 :     return ImplGetCanvas( Size(), false, false );
    3833             : }
    3834             : 
    3835           0 : Reference< css::rendering::XSpriteCanvas > Window::GetSpriteCanvas() const
    3836             : {
    3837             :     Reference< css::rendering::XSpriteCanvas > xSpriteCanvas(
    3838           0 :         ImplGetCanvas( Size(), false, true ), UNO_QUERY );
    3839           0 :     return xSpriteCanvas;
    3840             : }
    3841             : 
    3842           0 : OUString Window::GetSurroundingText() const
    3843             : {
    3844           0 :   return OUString();
    3845             : }
    3846             : 
    3847           0 : Selection Window::GetSurroundingTextSelection() const
    3848             : {
    3849           0 :   return Selection( 0, 0 );
    3850             : }
    3851             : 
    3852           0 : bool Window::UsePolyPolygonForComplexGradient()
    3853             : {
    3854           0 :     if ( meRasterOp != ROP_OVERPAINT )
    3855           0 :         return true;
    3856             : 
    3857           0 :     return false;
    3858             : }
    3859             : 
    3860       52294 : void Window::ApplySettings(vcl::RenderContext& /*rRenderContext*/)
    3861             : {
    3862       52294 : }
    3863             : 
    3864           0 : void Window::DrawGradientWallpaper(vcl::RenderContext& rRenderContext,
    3865             :                                    long nX, long nY, long nWidth, long nHeight,
    3866             :                                    const Wallpaper& rWallpaper)
    3867             : {
    3868           0 :     Rectangle aBound;
    3869           0 :     GDIMetaFile* pOldMetaFile = mpMetaFile;
    3870           0 :     const bool bOldMap = mbMap;
    3871           0 :     bool bNeedGradient = true;
    3872             : 
    3873           0 :     aBound = Rectangle(Point(nX, nY), Size(nWidth, nHeight));
    3874             : 
    3875           0 :     mpMetaFile = NULL;
    3876           0 :     rRenderContext.EnableMapMode(false);
    3877           0 :     rRenderContext.Push(PushFlags::CLIPREGION);
    3878           0 :     rRenderContext.IntersectClipRegion(Rectangle(Point(nX, nY), Size(nWidth, nHeight)));
    3879             : 
    3880           0 :     if (rWallpaper.GetStyle() == WALLPAPER_APPLICATIONGRADIENT)
    3881             :     {
    3882             :         // limit gradient to useful size, so that it still can be noticed
    3883             :         // in maximized windows
    3884           0 :         long gradientWidth = GetDesktopRectPixel().GetSize().Width();
    3885           0 :         if (gradientWidth > 1024)
    3886           0 :             gradientWidth = 1024;
    3887           0 :         if (mnOutOffX + nWidth > gradientWidth)
    3888           0 :             rRenderContext.DrawColorWallpaper(nX, nY, nWidth, nHeight, rWallpaper.GetGradient().GetEndColor());
    3889           0 :         if (mnOutOffX > gradientWidth)
    3890           0 :             bNeedGradient = false;
    3891             :         else
    3892           0 :             aBound = Rectangle(Point(-mnOutOffX, nY), Size(gradientWidth, nHeight));
    3893             :     }
    3894             : 
    3895           0 :     if (bNeedGradient)
    3896           0 :         rRenderContext.DrawGradient(aBound, rWallpaper.GetGradient());
    3897             : 
    3898           0 :     rRenderContext.Pop();
    3899           0 :     rRenderContext.EnableMapMode(bOldMap);
    3900           0 :     mpMetaFile = pOldMetaFile;
    3901           0 : }
    3902             : 
    3903        8919 : const SystemEnvData* Window::GetSystemData() const
    3904             : {
    3905             : 
    3906        8919 :     return mpWindowImpl->mpFrame ? mpWindowImpl->mpFrame->GetSystemData() : NULL;
    3907             : }
    3908             : 
    3909          87 : Any Window::GetSystemDataAny() const
    3910             : {
    3911          87 :     Any aRet;
    3912          87 :     const SystemEnvData* pSysData = GetSystemData();
    3913          87 :     if( pSysData )
    3914             :     {
    3915          87 :         Sequence< sal_Int8 > aSeq( reinterpret_cast<sal_Int8 const *>(pSysData), pSysData->nSize );
    3916          87 :         aRet <<= aSeq;
    3917             :     }
    3918          87 :     return aRet;
    3919             : }
    3920             : 
    3921           0 : vcl::RenderSettings& Window::GetRenderSettings()
    3922             : {
    3923           0 :     return mpWindowImpl->maRenderSettings;
    3924             : }
    3925             : 
    3926      151942 : bool Window::SupportsDoubleBuffering() const
    3927             : {
    3928      151942 :     return mpWindowImpl->mbDoubleBuffering;
    3929             : }
    3930             : 
    3931           0 : void Window::SetDoubleBuffering(bool bDoubleBuffering)
    3932             : {
    3933           0 :     mpWindowImpl->mbDoubleBuffering = bDoubleBuffering;
    3934           0 : }
    3935             : 
    3936             : /*
    3937             :  * The rational here is that we moved destructors to
    3938             :  * dispose and this altered a lot of code paths, that
    3939             :  * are better left unchanged for now.
    3940             :  */
    3941             : #define COMPAT_BODY(method,args) \
    3942             :     if (!mpWindowImpl || mpWindowImpl->mbInDispose) \
    3943             :         Window::method args; \
    3944             :     else \
    3945             :         method args;
    3946             : 
    3947       17781 : void Window::CompatGetFocus()
    3948             : {
    3949       17781 :     COMPAT_BODY(GetFocus,())
    3950       17781 : }
    3951             : 
    3952       14917 : void Window::CompatLoseFocus()
    3953             : {
    3954       14917 :     COMPAT_BODY(LoseFocus,())
    3955       14917 : }
    3956             : 
    3957     1202644 : void Window::CompatStateChanged( StateChangedType nStateChange )
    3958             : {
    3959     1202644 :     COMPAT_BODY(StateChanged,(nStateChange))
    3960     1202644 : }
    3961             : 
    3962       10362 : void Window::CompatDataChanged( const DataChangedEvent& rDCEvt )
    3963             : {
    3964       10362 :     COMPAT_BODY(DataChanged,(rDCEvt))
    3965       10362 : }
    3966             : 
    3967      132062 : bool Window::CompatPreNotify( NotifyEvent& rNEvt )
    3968             : {
    3969      132062 :     if (!mpWindowImpl || mpWindowImpl->mbInDispose)
    3970        5810 :         return Window::PreNotify( rNEvt );
    3971             :     else
    3972      126252 :         return PreNotify( rNEvt );
    3973             : }
    3974             : 
    3975     1360718 : bool Window::CompatNotify( NotifyEvent& rNEvt )
    3976             : {
    3977     1360718 :     if (!mpWindowImpl || mpWindowImpl->mbInDispose)
    3978      315635 :         return Window::Notify( rNEvt );
    3979             :     else
    3980     1045083 :         return Notify( rNEvt );
    3981             : }
    3982             : 
    3983         801 : } /* namespace vcl */
    3984             : 
    3985             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11