LibreOffice Module vcl (master)  1
winproc.cxx
Go to the documentation of this file.
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 <sal/config.h>
21 
22 #include <o3tl/safeint.hxx>
23 #include <tools/debug.hxx>
24 #include <tools/time.hxx>
25 #include <sal/log.hxx>
26 
28 
29 #include <comphelper/lok.hxx>
30 #include <vcl/QueueInfo.hxx>
31 #include <vcl/timer.hxx>
32 #include <vcl/event.hxx>
33 #include <vcl/GestureEvent.hxx>
34 #include <vcl/settings.hxx>
35 #include <vcl/svapp.hxx>
36 #include <vcl/cursor.hxx>
37 #include <vcl/wrkwin.hxx>
38 #include <vcl/floatwin.hxx>
39 #include <vcl/toolkit/dialog.hxx>
40 #include <vcl/toolkit/edit.hxx>
41 #include <vcl/help.hxx>
42 #include <vcl/dockwin.hxx>
43 #include <vcl/menu.hxx>
44 #include <vcl/virdev.hxx>
45 #include <vcl/uitest/logger.hxx>
46 #include <vcl/ptrstyle.hxx>
47 
48 #include <svdata.hxx>
49 #include <salwtype.hxx>
50 #include <salframe.hxx>
51 #include <accmgr.hxx>
52 #include <print.h>
53 #include <window.h>
54 #include <helpwin.hxx>
55 #include <brdwin.hxx>
56 #include <dndlistenercontainer.hxx>
57 
58 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
59 #include <com/sun/star/awt/MouseEvent.hpp>
60 
61 #define IMPL_MIN_NEEDSYSWIN 49
62 
64 {
65  return rEvt.GetWindow()->CompatPreNotify( rEvt );
66 }
67 
68 static bool ImplHandleMouseFloatMode( vcl::Window* pChild, const Point& rMousePos,
69  sal_uInt16 nCode, MouseNotifyEvent nSVEvent,
70  bool bMouseLeave )
71 {
72  ImplSVData* pSVData = ImplGetSVData();
73 
74  if (pSVData->mpWinData->mpFirstFloat && !pSVData->mpWinData->mpCaptureWin
75  && !pSVData->mpWinData->mpFirstFloat->ImplIsFloatPopupModeWindow(pChild))
76  {
77  /*
78  * #93895# since floats are system windows, coordinates have
79  * to be converted to float relative for the hittest
80  */
81  bool bHitTestInsideRect = false;
82  FloatingWindow* pFloat = pSVData->mpWinData->mpFirstFloat->ImplFloatHitTest( pChild, rMousePos, bHitTestInsideRect );
83  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
84  {
85  if ( bMouseLeave )
86  return true;
87 
88  if ( !pFloat || bHitTestInsideRect )
89  {
90  if ( ImplGetSVHelpData().mpHelpWin && !ImplGetSVHelpData().mbKeyboardHelp )
91  ImplDestroyHelpWindow( true );
93  return true;
94  }
95  }
96  else
97  {
98  if ( nCode & MOUSE_LEFT )
99  {
100  if ( nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN )
101  {
102  if ( !pFloat )
103  {
104  FloatingWindow* pLastLevelFloat = pSVData->mpWinData->mpFirstFloat->ImplFindLastLevelFloat();
106  return true;
107  }
108  else if ( bHitTestInsideRect )
109  {
110  pFloat->ImplSetMouseDown();
111  return true;
112  }
113  }
114  else
115  {
116  if ( pFloat )
117  {
118  if ( bHitTestInsideRect )
119  {
120  if ( pFloat->ImplIsMouseDown() )
122  return true;
123  }
124  }
125  else
126  {
127  FloatingWindow* pLastLevelFloat = pSVData->mpWinData->mpFirstFloat->ImplFindLastLevelFloat();
128  FloatWinPopupFlags nPopupFlags = pLastLevelFloat->GetPopupModeFlags();
129  if ( !(nPopupFlags & FloatWinPopupFlags::NoMouseUpClose) )
130  {
132  return true;
133  }
134  }
135  }
136  }
137  else
138  {
139  if ( !pFloat )
140  {
141  FloatingWindow* pLastLevelFloat = pSVData->mpWinData->mpFirstFloat->ImplFindLastLevelFloat();
142  FloatWinPopupFlags nPopupFlags = pLastLevelFloat->GetPopupModeFlags();
143  if ( nPopupFlags & FloatWinPopupFlags::AllMouseButtonClose )
144  {
145  if ( (nPopupFlags & FloatWinPopupFlags::NoMouseUpClose) &&
146  (nSVEvent == MouseNotifyEvent::MOUSEBUTTONUP) )
147  return true;
149  return true;
150  }
151  else
152  return true;
153  }
154  }
155  }
156  }
157 
158  return false;
159 }
160 
161 static void ImplHandleMouseHelpRequest( vcl::Window* pChild, const Point& rMousePos )
162 {
163  ImplSVHelpData& aHelpData = ImplGetSVHelpData();
164  if ( aHelpData.mpHelpWin &&
165  ( aHelpData.mpHelpWin->IsWindowOrChild( pChild ) ||
166  pChild->IsWindowOrChild( aHelpData.mpHelpWin ) ))
167  return;
168 
170  if ( aHelpData.mbQuickHelp )
171  nHelpMode = HelpEventMode::QUICK;
172  if ( aHelpData.mbBalloonHelp )
173  nHelpMode |= HelpEventMode::BALLOON;
174  if ( !(bool(nHelpMode)) )
175  return;
176 
177  if ( pChild->IsInputEnabled() && !pChild->IsInModalMode() )
178  {
179  HelpEvent aHelpEvent( rMousePos, nHelpMode );
180  aHelpData.mbRequestingHelp = true;
181  pChild->RequestHelp( aHelpEvent );
182  aHelpData.mbRequestingHelp = false;
183  }
184  // #104172# do not kill keyboard activated tooltips
185  else if ( aHelpData.mpHelpWin && !aHelpData.mbKeyboardHelp)
186  {
187  ImplDestroyHelpWindow( true );
188  }
189 }
190 
191 static void ImplSetMousePointer( vcl::Window const * pChild )
192 {
193  if ( ImplGetSVHelpData().mbExtHelpMode )
195  else
196  pChild->ImplGetFrame()->SetPointer( pChild->ImplGetMousePointer() );
197 }
198 
199 static bool ImplCallCommand( const VclPtr<vcl::Window>& pChild, CommandEventId nEvt, void const * pData = nullptr,
200  bool bMouse = false, Point const * pPos = nullptr )
201 {
202  Point aPos;
203  if ( pPos )
204  aPos = *pPos;
205  else
206  {
207  if( bMouse )
208  aPos = pChild->GetPointerPosPixel();
209  else
210  {
211  // simulate mouseposition at center of window
212  Size aSize( pChild->GetOutputSizePixel() );
213  aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
214  }
215  }
216 
217  CommandEvent aCEvt( aPos, nEvt, bMouse, pData );
218  NotifyEvent aNCmdEvt( MouseNotifyEvent::COMMAND, pChild, &aCEvt );
219  bool bPreNotify = ImplCallPreNotify( aNCmdEvt );
220  if ( pChild->IsDisposed() )
221  return false;
222  if ( !bPreNotify )
223  {
224  pChild->ImplGetWindowImpl()->mbCommand = false;
225  pChild->Command( aCEvt );
226 
227  if( pChild->IsDisposed() )
228  return false;
229  pChild->ImplNotifyKeyMouseCommandEventListeners( aNCmdEvt );
230  if ( pChild->IsDisposed() )
231  return false;
232  if ( pChild->ImplGetWindowImpl()->mbCommand )
233  return true;
234  }
235 
236  return false;
237 }
238 
239 /* #i34277# delayed context menu activation;
240 * necessary if there already was a popup menu running.
241 */
242 
243 namespace {
244 
245 struct ContextMenuEvent
246 {
247  VclPtr<vcl::Window> pWindow;
248  Point aChildPos;
249 };
250 
251 }
252 
253 static void ContextMenuEventLink( void* pCEvent, void* )
254 {
255  ContextMenuEvent* pEv = static_cast<ContextMenuEvent*>(pCEvent);
256 
257  if( ! pEv->pWindow->IsDisposed() )
258  {
259  ImplCallCommand( pEv->pWindow, CommandEventId::ContextMenu, nullptr, true, &pEv->aChildPos );
260  }
261  delete pEv;
262 }
263 
264 bool ImplHandleMouseEvent( const VclPtr<vcl::Window>& xWindow, MouseNotifyEvent nSVEvent, bool bMouseLeave,
265  tools::Long nX, tools::Long nY, sal_uInt64 nMsgTime,
266  sal_uInt16 nCode, MouseEventModifiers nMode )
267 {
268  ImplSVHelpData& aHelpData = ImplGetSVHelpData();
269  ImplSVData* pSVData = ImplGetSVData();
270  Point aMousePos( nX, nY );
271  VclPtr<vcl::Window> pChild;
272  bool bRet(false);
273  sal_uInt16 nClicks(0);
274  ImplFrameData* pWinFrameData = xWindow->ImplGetFrameData();
275  sal_uInt16 nOldCode = pWinFrameData->mnMouseCode;
276 
277  // we need a mousemove event, before we get a mousebuttondown or a
278  // mousebuttonup event
279  if ( (nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN) || (nSVEvent == MouseNotifyEvent::MOUSEBUTTONUP) )
280  {
281  if ( (nSVEvent == MouseNotifyEvent::MOUSEBUTTONUP) && aHelpData.mbExtHelpMode )
283  if ( aHelpData.mpHelpWin )
284  {
285  if( xWindow->ImplGetWindow() == aHelpData.mpHelpWin )
286  {
287  ImplDestroyHelpWindow( false );
288  return true; // xWindow is dead now - avoid crash!
289  }
290  else
291  ImplDestroyHelpWindow( true );
292  }
293 
294  if ( (pWinFrameData->mnLastMouseX != nX) ||
295  (pWinFrameData->mnLastMouseY != nY) )
296  {
297  sal_uInt16 nMoveCode = nCode & ~(MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE);
298  ImplHandleMouseEvent(xWindow, MouseNotifyEvent::MOUSEMOVE, false, nX, nY, nMsgTime, nMoveCode, nMode);
299  }
300  }
301 
302  // update frame data
303  pWinFrameData->mnBeforeLastMouseX = pWinFrameData->mnLastMouseX;
304  pWinFrameData->mnBeforeLastMouseY = pWinFrameData->mnLastMouseY;
305  pWinFrameData->mnLastMouseX = nX;
306  pWinFrameData->mnLastMouseY = nY;
307  pWinFrameData->mnMouseCode = nCode;
309  pWinFrameData->mnMouseMode = nMode & ~nTmpMask;
310  if ( bMouseLeave )
311  {
312  pWinFrameData->mbMouseIn = false;
313  if ( ImplGetSVHelpData().mpHelpWin && !ImplGetSVHelpData().mbKeyboardHelp )
314  {
315  ImplDestroyHelpWindow( true );
316 
317  if ( xWindow->IsDisposed() )
318  return true; // xWindow is dead now - avoid crash! (#122045#)
319  }
320  }
321  else
322  pWinFrameData->mbMouseIn = true;
323 
324  DBG_ASSERT(!pSVData->mpWinData->mpTrackWin
325  || (pSVData->mpWinData->mpTrackWin == pSVData->mpWinData->mpCaptureWin),
326  "ImplHandleMouseEvent: TrackWin != CaptureWin");
327 
328  // AutoScrollMode
329  if (pSVData->mpWinData->mpAutoScrollWin && (nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN))
330  {
332  return true;
333  }
334 
335  // find mouse window
336  if (pSVData->mpWinData->mpCaptureWin)
337  {
338  pChild = pSVData->mpWinData->mpCaptureWin;
339 
340  SAL_WARN_IF( xWindow != pChild->ImplGetFrameWindow(), "vcl",
341  "ImplHandleMouseEvent: mouse event is not sent to capture window" );
342 
343  // java client cannot capture mouse correctly
344  if ( xWindow != pChild->ImplGetFrameWindow() )
345  return false;
346 
347  if ( bMouseLeave )
348  return false;
349  }
350  else
351  {
352  if ( bMouseLeave )
353  pChild = nullptr;
354  else
355  pChild = xWindow->ImplFindWindow( aMousePos );
356  }
357 
358  // test this because mouse events are buffered in the remote version
359  // and size may not be in sync
360  if ( !pChild && !bMouseLeave )
361  return false;
362 
363  // execute a few tests and catch the message or implement the status
364  if ( pChild )
365  {
366  if( pChild->ImplIsAntiparallel() )
367  {
368  // re-mirror frame pos at pChild
369  const OutputDevice *pChildWinOutDev = pChild->GetOutDev();
370  pChildWinOutDev->ReMirror( aMousePos );
371  }
372 
373  // no mouse messages to disabled windows
374  // #106845# if the window was disabled during capturing we have to pass the mouse events to release capturing
375  if (pSVData->mpWinData->mpCaptureWin.get() != pChild
376  && (!pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalMode()))
377  {
378  ImplHandleMouseFloatMode( pChild, aMousePos, nCode, nSVEvent, bMouseLeave );
379  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
380  {
381  ImplHandleMouseHelpRequest( pChild, aMousePos );
382  if( pWinFrameData->mpMouseMoveWin.get() != pChild )
384  }
385 
386  // Call the hook also, if Window is disabled
387  Point aChildPos = pChild->ImplFrameToOutput( aMousePos );
388  MouseEvent aMEvt( aChildPos, pWinFrameData->mnClickCount, nMode, nCode, nCode );
389  NotifyEvent aNEvt( nSVEvent, pChild, &aMEvt );
390 
391  if ( nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN )
392  return true;
393  else
394  {
395  // Set normal MousePointer for disabled windows
396  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
397  ImplSetMousePointer( pChild );
398 
399  return false;
400  }
401  }
402 
403  // End ExtTextInput-Mode, if the user click in the same TopLevel Window
404  if (pSVData->mpWinData->mpExtTextInputWin
405  && ((nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN)
406  || (nSVEvent == MouseNotifyEvent::MOUSEBUTTONUP)))
408  }
409 
410  // determine mouse event data
411  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
412  {
413  // check if MouseMove belongs to same window and if the
414  // status did not change
415  if ( pChild )
416  {
417  Point aChildMousePos = pChild->ImplFrameToOutput( aMousePos );
418  if ( !bMouseLeave &&
419  (pChild == pWinFrameData->mpMouseMoveWin) &&
420  (aChildMousePos.X() == pWinFrameData->mnLastMouseWinX) &&
421  (aChildMousePos.Y() == pWinFrameData->mnLastMouseWinY) &&
422  (nOldCode == pWinFrameData->mnMouseCode) )
423  {
424  // set mouse pointer anew, as it could have changed
425  // due to the mode switch
426  ImplSetMousePointer( pChild );
427  return false;
428  }
429 
430  pWinFrameData->mnLastMouseWinX = aChildMousePos.X();
431  pWinFrameData->mnLastMouseWinY = aChildMousePos.Y();
432  }
433 
434  // mouse click
435  nClicks = pWinFrameData->mnClickCount;
436 
437  // call Start-Drag handler if required
438  // Warning: should be called before Move, as otherwise during
439  // fast mouse movements the applications move to the selection state
440  vcl::Window* pMouseDownWin = pWinFrameData->mpMouseDownWin;
441  if ( pMouseDownWin )
442  {
443  // check for matching StartDrag mode. We only compare
444  // the status of the mouse buttons, such that e. g. Mod1 can
445  // change immediately to the copy mode
446  const MouseSettings& rMSettings = pMouseDownWin->GetSettings().GetMouseSettings();
447  if ( (nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) ==
449  {
450  if ( !pMouseDownWin->ImplGetFrameData()->mbStartDragCalled )
451  {
452  tools::Long nDragW = rMSettings.GetStartDragWidth();
453  tools::Long nDragH = rMSettings.GetStartDragHeight();
454  //long nMouseX = nX;
455  //long nMouseY = nY;
456  tools::Long nMouseX = aMousePos.X(); // #106074# use the possibly re-mirrored coordinates (RTL) ! nX,nY are unmodified !
457  tools::Long nMouseY = aMousePos.Y();
458  if ( (((nMouseX-nDragW) > pMouseDownWin->ImplGetFrameData()->mnFirstMouseX) ||
459  ((nMouseX+nDragW) < pMouseDownWin->ImplGetFrameData()->mnFirstMouseX)) ||
460  (((nMouseY-nDragH) > pMouseDownWin->ImplGetFrameData()->mnFirstMouseY) ||
461  ((nMouseY+nDragH) < pMouseDownWin->ImplGetFrameData()->mnFirstMouseY)) )
462  {
463  pMouseDownWin->ImplGetFrameData()->mbStartDragCalled = true;
464 
465  // Check if drag source provides its own recognizer
466  if( pMouseDownWin->ImplGetFrameData()->mbInternalDragGestureRecognizer )
467  {
468  // query DropTarget from child window
469  css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > xDragGestureRecognizer(
470  pMouseDownWin->ImplGetWindowImpl()->mxDNDListenerContainer,
471  css::uno::UNO_QUERY );
472 
473  if( xDragGestureRecognizer.is() )
474  {
475  // retrieve mouse position relative to mouse down window
476  Point relLoc = pMouseDownWin->ImplFrameToOutput( Point(
477  pMouseDownWin->ImplGetFrameData()->mnFirstMouseX,
478  pMouseDownWin->ImplGetFrameData()->mnFirstMouseY ) );
479 
480  // create a UNO mouse event out of the available data
481  css::awt::MouseEvent aMouseEvent( static_cast < css::uno::XInterface * > ( nullptr ),
482 #ifdef MACOSX
483  nCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3),
484 #else
485  nCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2),
486 #endif
487  nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE),
488  nMouseX,
489  nMouseY,
490  nClicks,
491  false );
492 
493  SolarMutexReleaser aReleaser;
494 
495  // FIXME: where do I get Action from ?
496  css::uno::Reference< css::datatransfer::dnd::XDragSource > xDragSource = pMouseDownWin->GetDragSource();
497 
498  if( xDragSource.is() )
499  {
500  static_cast < DNDListenerContainer * > ( xDragGestureRecognizer.get() )->fireDragGestureEvent( 0,
501  relLoc.X(), relLoc.Y(), xDragSource, css::uno::makeAny( aMouseEvent ) );
502  }
503  }
504  }
505  }
506  }
507  }
508  else
509  pMouseDownWin->ImplGetFrameData()->mbStartDragCalled = true;
510  }
511 
512  // test for mouseleave and mouseenter
513  VclPtr<vcl::Window> pMouseMoveWin = pWinFrameData->mpMouseMoveWin;
514  if ( pChild != pMouseMoveWin )
515  {
516  if ( pMouseMoveWin )
517  {
518  Point aLeaveMousePos = pMouseMoveWin->ImplFrameToOutput( aMousePos );
519  MouseEvent aMLeaveEvt( aLeaveMousePos, nClicks, nMode | MouseEventModifiers::LEAVEWINDOW, nCode, nCode );
520  NotifyEvent aNLeaveEvt( MouseNotifyEvent::MOUSEMOVE, pMouseMoveWin, &aMLeaveEvt );
521  pWinFrameData->mbInMouseMove = true;
522  pMouseMoveWin->ImplGetWinData()->mbMouseOver = false;
523 
524  // A MouseLeave can destroy this window
525  if ( !ImplCallPreNotify( aNLeaveEvt ) )
526  {
527  pMouseMoveWin->MouseMove( aMLeaveEvt );
528  if( !pMouseMoveWin->IsDisposed() )
529  aNLeaveEvt.GetWindow()->ImplNotifyKeyMouseCommandEventListeners( aNLeaveEvt );
530  }
531 
532  pWinFrameData->mpMouseMoveWin = nullptr;
533  pWinFrameData->mbInMouseMove = false;
534 
535  if ( pChild && pChild->IsDisposed() )
536  pChild = nullptr;
537  if ( pMouseMoveWin->IsDisposed() )
538  return true;
539  }
540 
542  }
543  pWinFrameData->mpMouseMoveWin = pChild;
544  if( pChild )
545  pChild->ImplGetWinData()->mbMouseOver = true;
546 
547  // MouseLeave
548  if ( !pChild )
549  return false;
550  }
551  else
552  {
553  if (pChild)
554  {
555  // mouse click
556  if ( nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN )
557  {
558  const MouseSettings& rMSettings = pChild->GetSettings().GetMouseSettings();
559  sal_uInt64 nDblClkTime = rMSettings.GetDoubleClickTime();
560  tools::Long nDblClkW = rMSettings.GetDoubleClickWidth();
561  tools::Long nDblClkH = rMSettings.GetDoubleClickHeight();
562  //long nMouseX = nX;
563  //long nMouseY = nY;
564  tools::Long nMouseX = aMousePos.X(); // #106074# use the possibly re-mirrored coordinates (RTL) ! nX,nY are unmodified !
565  tools::Long nMouseY = aMousePos.Y();
566 
567  if ( (pChild == pChild->ImplGetFrameData()->mpMouseDownWin) &&
568  (nCode == pChild->ImplGetFrameData()->mnFirstMouseCode) &&
569  ((nMsgTime-pChild->ImplGetFrameData()->mnMouseDownTime) < nDblClkTime) &&
570  ((nMouseX-nDblClkW) <= pChild->ImplGetFrameData()->mnFirstMouseX) &&
571  ((nMouseX+nDblClkW) >= pChild->ImplGetFrameData()->mnFirstMouseX) &&
572  ((nMouseY-nDblClkH) <= pChild->ImplGetFrameData()->mnFirstMouseY) &&
573  ((nMouseY+nDblClkH) >= pChild->ImplGetFrameData()->mnFirstMouseY) )
574  {
575  pChild->ImplGetFrameData()->mnClickCount++;
576  pChild->ImplGetFrameData()->mbStartDragCalled = true;
577  }
578  else
579  {
580  pChild->ImplGetFrameData()->mpMouseDownWin = pChild;
581  pChild->ImplGetFrameData()->mnClickCount = 1;
582  pChild->ImplGetFrameData()->mnFirstMouseX = nMouseX;
583  pChild->ImplGetFrameData()->mnFirstMouseY = nMouseY;
584  pChild->ImplGetFrameData()->mnFirstMouseCode = nCode;
587  }
588  pChild->ImplGetFrameData()->mnMouseDownTime = nMsgTime;
589  }
590  nClicks = pChild->ImplGetFrameData()->mnClickCount;
591  }
592 
594  }
595 
596  SAL_WARN_IF( !pChild, "vcl", "ImplHandleMouseEvent: pChild == NULL" );
597 
598  if (!pChild)
599  return false;
600 
601  // create mouse event
602  Point aChildPos = pChild->ImplFrameToOutput( aMousePos );
603  MouseEvent aMEvt( aChildPos, nClicks, nMode, nCode, nCode );
604 
605 
606  // tracking window gets the mouse events
607  if (pSVData->mpWinData->mpTrackWin)
608  pChild = pSVData->mpWinData->mpTrackWin;
609 
610  // handle FloatingMode
611  if (!pSVData->mpWinData->mpTrackWin && pSVData->mpWinData->mpFirstFloat)
612  {
613  if ( ImplHandleMouseFloatMode( pChild, aMousePos, nCode, nSVEvent, bMouseLeave ) )
614  {
615  if ( !pChild->IsDisposed() )
616  {
617  pChild->ImplGetFrameData()->mbStartDragCalled = true;
618  }
619  return true;
620  }
621  }
622 
623  // call handler
624  bool bCallHelpRequest = true;
625  SAL_WARN_IF( !pChild, "vcl", "ImplHandleMouseEvent: pChild is NULL" );
626 
627  if (!pChild)
628  return false;
629 
630  NotifyEvent aNEvt( nSVEvent, pChild, &aMEvt );
631  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
632  pChild->ImplGetFrameData()->mbInMouseMove = true;
633 
634  // bring window into foreground on mouseclick
635  if ( nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN )
636  {
637  if (!pSVData->mpWinData->mpFirstFloat
638  && // totop for floating windows in popup would change the focus and would close them immediately
639  !(pChild->ImplGetFrameWindow()->GetStyle()
640  & WB_OWNERDRAWDECORATION)) // ownerdrawdecorated windows must never grab focus
641  pChild->ToTop();
642  if ( pChild->IsDisposed() )
643  return true;
644  }
645 
646  if ( ImplCallPreNotify( aNEvt ) || pChild->IsDisposed() )
647  bRet = true;
648  else
649  {
650  bRet = false;
651  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
652  {
653  if (pSVData->mpWinData->mpTrackWin)
654  {
655  TrackingEvent aTEvt( aMEvt );
656  pChild->Tracking( aTEvt );
657  if ( !pChild->IsDisposed() )
658  {
659  // When ScrollRepeat, we restart the timer
660  if (pSVData->mpWinData->mpTrackTimer
662  pSVData->mpWinData->mpTrackTimer->Start();
663  }
664  bCallHelpRequest = false;
665  bRet = true;
666  }
667  else
668  {
669  // Auto-ToTop
670  if (!pSVData->mpWinData->mpCaptureWin
671  && (pChild->GetSettings().GetMouseSettings().GetOptions()
673  pChild->ToTop( ToTopFlags::NoGrabFocus );
674 
675  if( pChild->IsDisposed() )
676  bCallHelpRequest = false;
677  else
678  {
679  // if the MouseMove handler changes the help window's visibility
680  // the HelpRequest handler should not be called anymore
681  vcl::Window* pOldHelpTextWin = ImplGetSVHelpData().mpHelpWin;
682  pChild->MouseMove( aMEvt );
683  if ( pOldHelpTextWin != ImplGetSVHelpData().mpHelpWin )
684  bCallHelpRequest = false;
685  }
686  }
687  }
688  else if ( nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN )
689  {
690  if ( pSVData->mpWinData->mpTrackWin )
691  bRet = true;
692  else
693  {
694  pChild->ImplGetWindowImpl()->mbMouseButtonDown = false;
695  pChild->MouseButtonDown( aMEvt );
696  }
697  }
698  else
699  {
700  if (pSVData->mpWinData->mpTrackWin)
701  {
702  pChild->EndTracking();
703  bRet = true;
704  }
705  else
706  {
707  pChild->ImplGetWindowImpl()->mbMouseButtonUp = false;
708  pChild->MouseButtonUp( aMEvt );
709  }
710  }
711 
712  assert(aNEvt.GetWindow() == pChild);
713 
714  if (!pChild->IsDisposed())
716  }
717 
718  if (pChild->IsDisposed())
719  return true;
720 
721  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
722  pChild->ImplGetWindowImpl()->mpFrameData->mbInMouseMove = false;
723 
724  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
725  {
726  if ( bCallHelpRequest && !ImplGetSVHelpData().mbKeyboardHelp )
727  ImplHandleMouseHelpRequest( pChild, pChild->OutputToScreenPixel( aMEvt.GetPosPixel() ) );
728  bRet = true;
729  }
730  else if ( !bRet )
731  {
732  if ( nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN )
733  {
734  if ( !pChild->ImplGetWindowImpl()->mbMouseButtonDown )
735  bRet = true;
736  }
737  else
738  {
739  if ( !pChild->ImplGetWindowImpl()->mbMouseButtonUp )
740  bRet = true;
741  }
742  }
743 
744  if ( nSVEvent == MouseNotifyEvent::MOUSEMOVE )
745  {
746  // set new mouse pointer
747  if ( !bMouseLeave )
748  ImplSetMousePointer( pChild );
749  }
750  else if ( (nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN) || (nSVEvent == MouseNotifyEvent::MOUSEBUTTONUP) )
751  {
752  // Command-Events
753  if ( (nClicks == 1) && (nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN) &&
754  (nCode == MOUSE_MIDDLE) )
755  {
757  if ( nMiddleAction == MouseMiddleButtonAction::AutoScroll )
758  bRet = !ImplCallCommand( pChild, CommandEventId::StartAutoScroll, nullptr, true, &aChildPos );
759  else if ( nMiddleAction == MouseMiddleButtonAction::PasteSelection )
760  bRet = !ImplCallCommand( pChild, CommandEventId::PasteSelection, nullptr, true, &aChildPos );
761  }
762  else
763  {
764  // ContextMenu
765  if ( (nCode == MouseSettings::GetContextMenuCode()) &&
766  (nClicks == MouseSettings::GetContextMenuClicks()) )
767  {
768  bool bContextMenu = (nSVEvent == MouseNotifyEvent::MOUSEBUTTONDOWN);
769  if ( bContextMenu )
770  {
771  if( pSVData->maAppData.mpActivePopupMenu )
772  {
773  /* #i34277# there already is a context menu open
774  * that was probably just closed with EndPopupMode.
775  * We need to give the eventual corresponding
776  * PopupMenu::Execute a chance to end properly.
777  * Therefore delay context menu command and
778  * issue only after popping one frame of the
779  * Yield stack.
780  */
781  ContextMenuEvent* pEv = new ContextMenuEvent;
782  pEv->pWindow = pChild;
783  pEv->aChildPos = aChildPos;
785  }
786  else
787  bRet = ! ImplCallCommand( pChild, CommandEventId::ContextMenu, nullptr, true, &aChildPos );
788  }
789  }
790  }
791  }
792 
793  return bRet;
794 }
795 
797 {
798  ImplSVData* pSVData = ImplGetSVData();
799 
800  // determine last input time
802 
803  // #127104# workaround for destroyed windows
804  if( pWindow->ImplGetWindowImpl() == nullptr )
805  return nullptr;
806 
807  // find window - is every time the window which has currently the
808  // focus or the last time the focus.
809 
810  // the first floating window always has the focus, try it, or any parent floating windows, first
811  vcl::Window* pChild = pSVData->mpWinData->mpFirstFloat;
812  while (pChild)
813  {
814  if (pChild->ImplGetWindowImpl()->mbFloatWin)
815  {
816  if (static_cast<FloatingWindow *>(pChild)->GrabsFocus())
817  break;
818  }
819  else if (pChild->ImplGetWindowImpl()->mbDockWin)
820  {
821  vcl::Window* pParent = pChild->GetWindow(GetWindowType::RealParent);
822  if (pParent && pParent->ImplGetWindowImpl()->mbFloatWin &&
823  static_cast<FloatingWindow *>(pParent)->GrabsFocus())
824  break;
825  }
826  pChild = pChild->GetParent();
827  }
828 
829  if (!pChild)
830  pChild = pWindow;
831 
832  pChild = pChild->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
833 
834  // no child - then no input
835  if ( !pChild )
836  return nullptr;
837 
838  // We call also KeyInput if we haven't the focus, because on Unix
839  // system this is often the case when a Lookup Choice Window has
840  // the focus - because this windows send the KeyInput directly to
841  // the window without resetting the focus
842 
843  // no keyinput to disabled windows
844  if ( !pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalMode() )
845  return nullptr;
846 
847  return pChild;
848 }
849 
850 static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent,
851  sal_uInt16 nKeyCode, sal_uInt16 nCharCode, sal_uInt16 nRepeat, bool bForward )
852 {
853  ImplSVData* pSVData = ImplGetSVData();
854  vcl::KeyCode aKeyCode( nKeyCode, nKeyCode );
855  sal_uInt16 nEvCode = aKeyCode.GetCode();
856 
857  // allow application key listeners to remove the key event
858  // but make sure we're not forwarding external KeyEvents, (ie where bForward is false)
859  // because those are coming back from the listener itself and MUST be processed
860  if( bForward )
861  {
862  VclEventId nVCLEvent;
863  switch( nSVEvent )
864  {
866  nVCLEvent = VclEventId::WindowKeyInput;
867  break;
869  nVCLEvent = VclEventId::WindowKeyUp;
870  break;
871  default:
872  nVCLEvent = VclEventId::NONE;
873  break;
874  }
875  KeyEvent aKeyEvent(static_cast<sal_Unicode>(nCharCode), aKeyCode, nRepeat);
876  if (nVCLEvent != VclEventId::NONE && Application::HandleKey(nVCLEvent, pWindow, &aKeyEvent))
877  return true;
878  }
879 
880  bool bCtrlF6 = (aKeyCode.GetCode() == KEY_F6) && aKeyCode.IsMod1();
881 
882  // determine last input time
884 
885  // handle tracking window
886  if ( nSVEvent == MouseNotifyEvent::KEYINPUT )
887  {
888  if ( ImplGetSVHelpData().mbExtHelpMode )
889  {
891  if ( nEvCode == KEY_ESCAPE )
892  return true;
893  }
894  if ( ImplGetSVHelpData().mpHelpWin )
895  ImplDestroyHelpWindow( false );
896 
897  // AutoScrollMode
898  if (pSVData->mpWinData->mpAutoScrollWin)
899  {
901  if ( nEvCode == KEY_ESCAPE )
902  return true;
903  }
904 
905  if (pSVData->mpWinData->mpTrackWin)
906  {
907  sal_uInt16 nOrigCode = aKeyCode.GetCode();
908 
909  if ( nOrigCode == KEY_ESCAPE )
910  {
912  if (pSVData->mpWinData->mpFirstFloat)
913  {
914  FloatingWindow* pLastLevelFloat = pSVData->mpWinData->mpFirstFloat->ImplFindLastLevelFloat();
915  if ( !(pLastLevelFloat->GetPopupModeFlags() & FloatWinPopupFlags::NoKeyClose) )
916  {
917  sal_uInt16 nEscCode = aKeyCode.GetCode();
918 
919  if ( nEscCode == KEY_ESCAPE )
921  }
922  }
923  return true;
924  }
925  else if ( nOrigCode == KEY_RETURN )
926  {
928  return true;
929  }
930  else
931  return true;
932  }
933 
934  // handle FloatingMode
935  if (pSVData->mpWinData->mpFirstFloat)
936  {
937  FloatingWindow* pLastLevelFloat = pSVData->mpWinData->mpFirstFloat->ImplFindLastLevelFloat();
938  if ( !(pLastLevelFloat->GetPopupModeFlags() & FloatWinPopupFlags::NoKeyClose) )
939  {
940  sal_uInt16 nCode = aKeyCode.GetCode();
941 
942  if ( (nCode == KEY_ESCAPE) || bCtrlF6)
943  {
945  if( !bCtrlF6 )
946  return true;
947  }
948  }
949  }
950 
951  // test for accel
952  if ( pSVData->maAppData.mpAccelMgr )
953  {
954  if ( pSVData->maAppData.mpAccelMgr->IsAccelKey( aKeyCode ) )
955  return true;
956  }
957  }
958 
959  // find window
960  VclPtr<vcl::Window> pChild = ImplGetKeyInputWindow( pWindow );
961  if ( !pChild )
962  return false;
963 
964  // #i1820# use locale specific decimal separator
965  if (nEvCode == KEY_DECIMAL)
966  {
967  // tdf#138932: don't modify the meaning of the key for password box
968  bool bPass = false;
969  if (auto pEdit = dynamic_cast<Edit*>(pChild.get()))
970  bPass = pEdit->IsPassword();
971  if (!bPass && Application::GetSettings().GetMiscSettings().GetEnableLocalizedDecimalSep())
972  {
973  OUString aSep(pWindow->GetSettings().GetLocaleDataWrapper().getNumDecimalSep());
974  nCharCode = static_cast<sal_uInt16>(aSep[0]);
975  }
976  }
977 
978  // RTL: mirror cursor keys
979  const OutputDevice *pChildOutDev = pChild->GetOutDev();
980  if( (aKeyCode.GetCode() == KEY_LEFT || aKeyCode.GetCode() == KEY_RIGHT) &&
981  pChildOutDev->HasMirroredGraphics() && pChild->IsRTLEnabled() )
982  aKeyCode = vcl::KeyCode( aKeyCode.GetCode() == KEY_LEFT ? KEY_RIGHT : KEY_LEFT, aKeyCode.GetModifier() );
983 
984  KeyEvent aKeyEvt( static_cast<sal_Unicode>(nCharCode), aKeyCode, nRepeat );
985  NotifyEvent aNotifyEvt( nSVEvent, pChild, &aKeyEvt );
986  bool bKeyPreNotify = ImplCallPreNotify( aNotifyEvt );
987  bool bRet = true;
988 
989  if ( !bKeyPreNotify && !pChild->IsDisposed() )
990  {
991  if ( nSVEvent == MouseNotifyEvent::KEYINPUT )
992  {
993  UITestLogger::getInstance().logKeyInput(pChild, aKeyEvt);
994  pChild->ImplGetWindowImpl()->mbKeyInput = false;
995  pChild->KeyInput( aKeyEvt );
996  }
997  else
998  {
999  pChild->ImplGetWindowImpl()->mbKeyUp = false;
1000  pChild->KeyUp( aKeyEvt );
1001  }
1002  if( !pChild->IsDisposed() )
1003  aNotifyEvt.GetWindow()->ImplNotifyKeyMouseCommandEventListeners( aNotifyEvt );
1004  }
1005 
1006  if ( pChild->IsDisposed() )
1007  return true;
1008 
1009  if ( nSVEvent == MouseNotifyEvent::KEYINPUT )
1010  {
1011  if ( !bKeyPreNotify && pChild->ImplGetWindowImpl()->mbKeyInput )
1012  {
1013  sal_uInt16 nCode = aKeyCode.GetCode();
1014 
1015  // #101999# is focus in or below toolbox
1016  bool bToolboxFocus=false;
1017  if( (nCode == KEY_F1) && aKeyCode.IsShift() )
1018  {
1019  vcl::Window *pWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
1020  while( pWin )
1021  {
1022  if( pWin->ImplGetWindowImpl()->mbToolBox )
1023  {
1024  bToolboxFocus = true;
1025  break;
1026  }
1027  else
1028  pWin = pWin->GetParent();
1029  }
1030  }
1031 
1032  // ContextMenu
1033  if ( (nCode == KEY_CONTEXTMENU) || ((nCode == KEY_F10) && aKeyCode.IsShift() && !aKeyCode.IsMod1() && !aKeyCode.IsMod2() ) )
1034  bRet = !ImplCallCommand( pChild, CommandEventId::ContextMenu );
1035  else if ( ( (nCode == KEY_F2) && aKeyCode.IsShift() ) || ( (nCode == KEY_F1) && aKeyCode.IsMod1() ) ||
1036  // #101999# no active help when focus in toolbox, simulate BalloonHelp instead
1037  ( (nCode == KEY_F1) && aKeyCode.IsShift() && bToolboxFocus ) )
1038  {
1039  // TipHelp via Keyboard (Shift-F2 or Ctrl-F1)
1040  // simulate mouseposition at center of window
1041 
1042  Size aSize = pChild->GetOutputSize();
1043  Point aPos( aSize.getWidth()/2, aSize.getHeight()/2 );
1044  aPos = pChild->OutputToScreenPixel( aPos );
1045 
1046  HelpEvent aHelpEvent( aPos, HelpEventMode::BALLOON );
1047  aHelpEvent.SetKeyboardActivated( true );
1049  pChild->RequestHelp( aHelpEvent );
1051  }
1052  else if ( (nCode == KEY_F1) || (nCode == KEY_HELP) )
1053  {
1054  if ( !aKeyCode.GetModifier() )
1055  {
1057  {
1058  Point aMousePos = pChild->OutputToScreenPixel( pChild->GetPointerPosPixel() );
1059  HelpEvent aHelpEvent( aMousePos, HelpEventMode::CONTEXT );
1060  pChild->RequestHelp( aHelpEvent );
1061  }
1062  else
1063  bRet = false;
1064  }
1065  else if ( aKeyCode.IsShift() )
1066  {
1067  if ( ImplGetSVHelpData().mbExtHelp )
1069  else
1070  bRet = false;
1071  }
1072  }
1073  else
1074  bRet = false;
1075  }
1076  }
1077  else
1078  {
1079  if ( !bKeyPreNotify && pChild->ImplGetWindowImpl()->mbKeyUp )
1080  bRet = false;
1081  }
1082 
1083  // #105591# send keyinput to parent if we are a floating window and the key was not processed yet
1084  if( !bRet && pWindow->ImplGetWindowImpl() && pWindow->ImplGetWindowImpl()->mbFloatWin && pWindow->GetParent() && (pWindow->ImplGetWindowImpl()->mpFrame != pWindow->GetParent()->ImplGetWindowImpl()->mpFrame) )
1085  {
1086  pChild = pWindow->GetParent();
1087 
1088  // call handler
1089  NotifyEvent aNEvt( nSVEvent, pChild, &aKeyEvt );
1090  bool bPreNotify = ImplCallPreNotify( aNEvt );
1091  if ( pChild->IsDisposed() )
1092  return true;
1093 
1094  if ( !bPreNotify )
1095  {
1096  if ( nSVEvent == MouseNotifyEvent::KEYINPUT )
1097  {
1098  pChild->ImplGetWindowImpl()->mbKeyInput = false;
1099  pChild->KeyInput( aKeyEvt );
1100  }
1101  else
1102  {
1103  pChild->ImplGetWindowImpl()->mbKeyUp = false;
1104  pChild->KeyUp( aKeyEvt );
1105  }
1106 
1107  if( !pChild->IsDisposed() )
1109  if ( pChild->IsDisposed() )
1110  return true;
1111  }
1112 
1113  if( bPreNotify || !pChild->ImplGetWindowImpl()->mbKeyInput )
1114  bRet = true;
1115  }
1116 
1117  return bRet;
1118 }
1119 
1120 static bool ImplHandleExtTextInput( vcl::Window* pWindow,
1121  const OUString& rText,
1122  const ExtTextInputAttr* pTextAttr,
1123  sal_Int32 nCursorPos, sal_uInt16 nCursorFlags )
1124 {
1125  ImplSVData* pSVData = ImplGetSVData();
1126  vcl::Window* pChild = nullptr;
1127 
1128  int nTries = 200;
1129  while( nTries-- )
1130  {
1131  pChild = pSVData->mpWinData->mpExtTextInputWin;
1132  if ( !pChild )
1133  {
1134  pChild = ImplGetKeyInputWindow( pWindow );
1135  if ( !pChild )
1136  return false;
1137  }
1138  if( !pChild->ImplGetWindowImpl()->mpFrameData->mnFocusId )
1139  break;
1140 
1142  {
1143  SAL_WARN("vcl", "Failed to get ext text input context");
1144  break;
1145  }
1147  }
1148 
1149  // If it is the first ExtTextInput call, we inform the information
1150  // and allocate the data, which we must store in this mode
1151  ImplWinData* pWinData = pChild->ImplGetWinData();
1152  if ( !pChild->ImplGetWindowImpl()->mbExtTextInput )
1153  {
1154  pChild->ImplGetWindowImpl()->mbExtTextInput = true;
1155  pWinData->mpExtOldText = OUString();
1156  pWinData->mpExtOldAttrAry.reset();
1157  pSVData->mpWinData->mpExtTextInputWin = pChild;
1159  }
1160 
1161  // be aware of being recursively called in StartExtTextInput
1162  if ( !pChild->ImplGetWindowImpl()->mbExtTextInput )
1163  return false;
1164 
1165  // Test for changes
1166  bool bOnlyCursor = false;
1167  sal_Int32 nMinLen = std::min( pWinData->mpExtOldText->getLength(), rText.getLength() );
1168  sal_Int32 nDeltaStart = 0;
1169  while ( nDeltaStart < nMinLen )
1170  {
1171  if ( (*pWinData->mpExtOldText)[nDeltaStart] != rText[nDeltaStart] )
1172  break;
1173  nDeltaStart++;
1174  }
1175  if ( pWinData->mpExtOldAttrAry || pTextAttr )
1176  {
1177  if ( !pWinData->mpExtOldAttrAry || !pTextAttr )
1178  nDeltaStart = 0;
1179  else
1180  {
1181  sal_Int32 i = 0;
1182  while ( i < nDeltaStart )
1183  {
1184  if ( pWinData->mpExtOldAttrAry[i] != pTextAttr[i] )
1185  {
1186  nDeltaStart = i;
1187  break;
1188  }
1189  i++;
1190  }
1191  }
1192  }
1193  if ( (nDeltaStart >= nMinLen) &&
1194  (pWinData->mpExtOldText->getLength() == rText.getLength()) )
1195  bOnlyCursor = true;
1196 
1197  // Call Event and store the information
1198  CommandExtTextInputData aData( rText, pTextAttr,
1199  nCursorPos, nCursorFlags,
1200  bOnlyCursor );
1201  *pWinData->mpExtOldText = rText;
1202  pWinData->mpExtOldAttrAry.reset();
1203  if ( pTextAttr )
1204  {
1205  pWinData->mpExtOldAttrAry.reset( new ExtTextInputAttr[rText.getLength()] );
1206  memcpy( pWinData->mpExtOldAttrAry.get(), pTextAttr, rText.getLength()*sizeof( ExtTextInputAttr ) );
1207  }
1208  return !ImplCallCommand( pChild, CommandEventId::ExtTextInput, &aData );
1209 }
1210 
1212 {
1213  ImplSVData* pSVData = ImplGetSVData();
1214  vcl::Window* pChild = pSVData->mpWinData->mpExtTextInputWin;
1215  bool bRet = false;
1216 
1217  if ( pChild )
1218  {
1219  pChild->ImplGetWindowImpl()->mbExtTextInput = false;
1220  pSVData->mpWinData->mpExtTextInputWin = nullptr;
1221  ImplWinData* pWinData = pChild->ImplGetWinData();
1222  pWinData->mpExtOldText.reset();
1223  pWinData->mpExtOldAttrAry.reset();
1225  }
1226 
1227  return bRet;
1228 }
1229 
1231  tools::Rectangle& rRect, tools::Long& rInputWidth,
1232  bool * pVertical )
1233 {
1234  ImplSVData* pSVData = ImplGetSVData();
1235  vcl::Window* pChild = pSVData->mpWinData->mpExtTextInputWin;
1236 
1237  if ( !pChild )
1238  pChild = ImplGetKeyInputWindow( pWindow );
1239  else
1240  {
1241  // Test, if the Window is related to the frame
1242  if ( !pWindow->ImplIsWindowOrChild( pChild ) )
1243  pChild = ImplGetKeyInputWindow( pWindow );
1244  }
1245 
1246  if ( pChild )
1247  {
1248  const OutputDevice *pChildOutDev = pChild->GetOutDev();
1250  const tools::Rectangle* pRect = pChild->GetCursorRect();
1251  if ( pRect )
1252  rRect = pChildOutDev->ImplLogicToDevicePixel( *pRect );
1253  else
1254  {
1255  vcl::Cursor* pCursor = pChild->GetCursor();
1256  if ( pCursor )
1257  {
1258  Point aPos = pChildOutDev->ImplLogicToDevicePixel( pCursor->GetPos() );
1259  Size aSize = pChild->LogicToPixel( pCursor->GetSize() );
1260  if ( !aSize.Width() )
1261  aSize.setWidth( pChild->GetSettings().GetStyleSettings().GetCursorSize() );
1262  rRect = tools::Rectangle( aPos, aSize );
1263  }
1264  else
1265  rRect = tools::Rectangle( Point( pChild->GetOutOffXPixel(), pChild->GetOutOffYPixel() ), Size() );
1266  }
1267  rInputWidth = pChild->ImplLogicWidthToDevicePixel( pChild->GetCursorExtTextInputWidth() );
1268  if ( !rInputWidth )
1269  rInputWidth = rRect.GetWidth();
1270  }
1271  if (pVertical != nullptr)
1272  *pVertical
1273  = pChild != nullptr && pChild->GetInputContext().GetFont().IsVertical();
1274 }
1275 
1277 {
1278  vcl::Window* pChild = ImplGetKeyInputWindow( pWindow );
1280  return !ImplCallCommand( pChild, CommandEventId::InputContextChange, &aData );
1281 }
1282 
1283 static bool ImplCallWheelCommand( const VclPtr<vcl::Window>& pWindow, const Point& rPos,
1284  const CommandWheelData* pWheelData )
1285 {
1286  Point aCmdMousePos = pWindow->ImplFrameToOutput( rPos );
1287  CommandEvent aCEvt( aCmdMousePos, CommandEventId::Wheel, true, pWheelData );
1288  NotifyEvent aNCmdEvt( MouseNotifyEvent::COMMAND, pWindow, &aCEvt );
1289  bool bPreNotify = ImplCallPreNotify( aNCmdEvt );
1290  if ( pWindow->IsDisposed() )
1291  return false;
1292  if ( !bPreNotify )
1293  {
1294  pWindow->ImplGetWindowImpl()->mbCommand = false;
1295  pWindow->Command( aCEvt );
1296  if ( pWindow->IsDisposed() )
1297  return false;
1298  if ( pWindow->ImplGetWindowImpl()->mbCommand )
1299  return true;
1300  }
1301  return false;
1302 }
1303 
1304 static bool acceptableWheelScrollTarget(const vcl::Window *pMouseWindow)
1305 {
1306  return (pMouseWindow && !pMouseWindow->isDisposed() && pMouseWindow->IsInputEnabled() && !pMouseWindow->IsInModalMode());
1307 }
1308 
1309 //If the last event at the same absolute screen position was handled by a
1310 //different window then reuse that window if the event occurs within 1/2 a
1311 //second, i.e. so scrolling down something like the calc sidebar that contains
1312 //widgets that respond to wheel events will continue to send the event to the
1313 //scrolling widget in favour of the widget that happens to end up under the
1314 //mouse.
1316 {
1317  return (rEvt.mnX == rPrevEvt.mnX && rEvt.mnY == rPrevEvt.mnY && rEvt.mnTime-rPrevEvt.mnTime < 500/*ms*/);
1318 }
1319 
1320 namespace {
1321 
1322 class HandleGestureEventBase
1323 {
1324 protected:
1325  ImplSVData* m_pSVData;
1326  VclPtr<vcl::Window> m_pWindow;
1327  Point m_aMousePos;
1328 
1329 public:
1330  HandleGestureEventBase(vcl::Window *pWindow, const Point &rMousePos)
1331  : m_pSVData(ImplGetSVData())
1332  , m_pWindow(pWindow)
1333  , m_aMousePos(rMousePos)
1334  {
1335  }
1336  bool Setup();
1337  vcl::Window* FindTarget();
1338  vcl::Window* Dispatch(vcl::Window* pTarget);
1339  virtual bool CallCommand(vcl::Window *pWindow, const Point &rMousePos) = 0;
1340  virtual ~HandleGestureEventBase() {}
1341 };
1342 
1343 }
1344 
1345 bool HandleGestureEventBase::Setup()
1346 {
1347 
1348  if (m_pSVData->mpWinData->mpAutoScrollWin)
1349  m_pSVData->mpWinData->mpAutoScrollWin->EndAutoScroll();
1350  if (ImplGetSVHelpData().mpHelpWin)
1351  ImplDestroyHelpWindow( true );
1352  return !m_pWindow->IsDisposed();
1353 }
1354 
1355 vcl::Window* HandleGestureEventBase::FindTarget()
1356 {
1357  // first check any floating window ( eg. drop down listboxes)
1358  vcl::Window *pMouseWindow = nullptr;
1359 
1360  if (m_pSVData->mpWinData->mpFirstFloat && !m_pSVData->mpWinData->mpCaptureWin &&
1361  !m_pSVData->mpWinData->mpFirstFloat->ImplIsFloatPopupModeWindow( m_pWindow ) )
1362  {
1363  bool bHitTestInsideRect = false;
1364  pMouseWindow = m_pSVData->mpWinData->mpFirstFloat->ImplFloatHitTest( m_pWindow, m_aMousePos, bHitTestInsideRect );
1365  if (!pMouseWindow)
1366  pMouseWindow = m_pSVData->mpWinData->mpFirstFloat;
1367  }
1368  // then try the window directly beneath the mouse
1369  if( !pMouseWindow )
1370  {
1371  pMouseWindow = m_pWindow->ImplFindWindow( m_aMousePos );
1372  }
1373  else
1374  {
1375  // transform coordinates to float window frame coordinates
1376  pMouseWindow = pMouseWindow->ImplFindWindow(
1377  pMouseWindow->OutputToScreenPixel(
1378  pMouseWindow->AbsoluteScreenToOutputPixel(
1379  m_pWindow->OutputToAbsoluteScreenPixel(
1380  m_pWindow->ScreenToOutputPixel( m_aMousePos ) ) ) ) );
1381  }
1382 
1383  while (acceptableWheelScrollTarget(pMouseWindow))
1384  {
1385  if (pMouseWindow->IsEnabled())
1386  break;
1387  //try the parent if this one is disabled
1388  pMouseWindow = pMouseWindow->GetParent();
1389  }
1390 
1391  return pMouseWindow;
1392 }
1393 
1394 vcl::Window *HandleGestureEventBase::Dispatch(vcl::Window* pMouseWindow)
1395 {
1396  vcl::Window *pDispatchedTo = nullptr;
1397 
1398  if (acceptableWheelScrollTarget(pMouseWindow) && pMouseWindow->IsEnabled())
1399  {
1400  // transform coordinates to float window frame coordinates
1401  Point aRelMousePos( pMouseWindow->OutputToScreenPixel(
1402  pMouseWindow->AbsoluteScreenToOutputPixel(
1403  m_pWindow->OutputToAbsoluteScreenPixel(
1404  m_pWindow->ScreenToOutputPixel( m_aMousePos ) ) ) ) );
1405  bool bPropogate = CallCommand(pMouseWindow, aRelMousePos);
1406  if (!bPropogate)
1407  pDispatchedTo = pMouseWindow;
1408  }
1409 
1410  // if the command was not handled try the focus window
1411  if (!pDispatchedTo)
1412  {
1413  vcl::Window* pFocusWindow = m_pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
1414  if ( pFocusWindow && (pFocusWindow != pMouseWindow) &&
1415  (pFocusWindow == m_pSVData->mpWinData->mpFocusWin) )
1416  {
1417  // no wheel-messages to disabled windows
1418  if ( pFocusWindow->IsEnabled() && pFocusWindow->IsInputEnabled() && ! pFocusWindow->IsInModalMode() )
1419  {
1420  // transform coordinates to focus window frame coordinates
1421  Point aRelMousePos( pFocusWindow->OutputToScreenPixel(
1422  pFocusWindow->AbsoluteScreenToOutputPixel(
1423  m_pWindow->OutputToAbsoluteScreenPixel(
1424  m_pWindow->ScreenToOutputPixel( m_aMousePos ) ) ) ) );
1425  bool bPropogate = CallCommand(pFocusWindow, aRelMousePos);
1426  if (!bPropogate)
1427  pDispatchedTo = pMouseWindow;
1428  }
1429  }
1430  }
1431  return pDispatchedTo;
1432 }
1433 
1434 namespace {
1435 
1436 class HandleWheelEvent : public HandleGestureEventBase
1437 {
1438 private:
1439  CommandWheelData m_aWheelData;
1440 public:
1441  HandleWheelEvent(vcl::Window *pWindow, const SalWheelMouseEvent& rEvt)
1442  : HandleGestureEventBase(pWindow, Point(rEvt.mnX, rEvt.mnY))
1443  {
1444  CommandWheelMode nMode;
1445  sal_uInt16 nCode = rEvt.mnCode;
1446  bool bHorz = rEvt.mbHorz;
1447  bool bPixel = rEvt.mbDeltaIsPixel;
1448  if ( nCode & KEY_MOD1 )
1449  nMode = CommandWheelMode::ZOOM;
1450  else if ( nCode & KEY_MOD2 )
1452  else
1453  {
1454  nMode = CommandWheelMode::SCROLL;
1455  // #i85450# interpret shift-wheel as horizontal wheel action
1456  if( (nCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)) == KEY_SHIFT )
1457  bHorz = true;
1458  }
1459 
1460  m_aWheelData = CommandWheelData(rEvt.mnDelta, rEvt.mnNotchDelta, rEvt.mnScrollLines, nMode, nCode, bHorz, bPixel);
1461 
1462  }
1463  virtual bool CallCommand(vcl::Window *pWindow, const Point &rMousePos) override
1464  {
1465  return ImplCallWheelCommand(pWindow, rMousePos, &m_aWheelData);
1466  }
1467  bool HandleEvent(const SalWheelMouseEvent& rEvt);
1468 };
1469 
1470 }
1471 
1472 bool HandleWheelEvent::HandleEvent(const SalWheelMouseEvent& rEvt)
1473 {
1474  if (!Setup())
1475  return false;
1476 
1477  VclPtr<vcl::Window> xMouseWindow = FindTarget();
1478 
1479  ImplSVData* pSVData = ImplGetSVData();
1480 
1481  // avoid the problem that scrolling via wheel to this point brings a widget
1482  // under the mouse that also accepts wheel commands, so stick with the old
1483  // widget if the time gap is very small
1486  {
1487  xMouseWindow = pSVData->mpWinData->mpLastWheelWindow;
1488  }
1489 
1490  pSVData->mpWinData->maLastWheelEvent = rEvt;
1491 
1492  pSVData->mpWinData->mpLastWheelWindow = Dispatch(xMouseWindow);
1493 
1494  return pSVData->mpWinData->mpLastWheelWindow;
1495 }
1496 
1497 namespace {
1498 
1499 class HandleGestureEvent : public HandleGestureEventBase
1500 {
1501 public:
1502  HandleGestureEvent(vcl::Window *pWindow, const Point &rMousePos)
1503  : HandleGestureEventBase(pWindow, rMousePos)
1504  {
1505  }
1506  bool HandleEvent();
1507 };
1508 
1509 }
1510 
1511 bool HandleGestureEvent::HandleEvent()
1512 {
1513  if (!Setup())
1514  return false;
1515 
1516  vcl::Window *pTarget = FindTarget();
1517 
1518  bool bHandled = Dispatch(pTarget) != nullptr;
1519  return bHandled;
1520 }
1521 
1522 static bool ImplHandleWheelEvent(vcl::Window* pWindow, const SalWheelMouseEvent& rEvt)
1523 {
1524  HandleWheelEvent aHandler(pWindow, rEvt);
1525  return aHandler.HandleEvent(rEvt);
1526 }
1527 
1528 namespace {
1529 
1530 class HandleSwipeEvent : public HandleGestureEvent
1531 {
1532 private:
1533  CommandSwipeData m_aSwipeData;
1534 public:
1535  HandleSwipeEvent(vcl::Window *pWindow, const SalSwipeEvent& rEvt)
1536  : HandleGestureEvent(pWindow, Point(rEvt.mnX, rEvt.mnY)),
1537  m_aSwipeData(rEvt.mnVelocityX)
1538  {
1539  }
1540  virtual bool CallCommand(vcl::Window *pWindow, const Point &/*rMousePos*/) override
1541  {
1542  return ImplCallCommand(pWindow, CommandEventId::Swipe, &m_aSwipeData);
1543  }
1544 };
1545 
1546 }
1547 
1548 static bool ImplHandleSwipe(vcl::Window *pWindow, const SalSwipeEvent& rEvt)
1549 {
1550  HandleSwipeEvent aHandler(pWindow, rEvt);
1551  return aHandler.HandleEvent();
1552 }
1553 
1554 namespace {
1555 
1556 class HandleLongPressEvent : public HandleGestureEvent
1557 {
1558 private:
1559  CommandLongPressData m_aLongPressData;
1560 public:
1561  HandleLongPressEvent(vcl::Window *pWindow, const SalLongPressEvent& rEvt)
1562  : HandleGestureEvent(pWindow, Point(rEvt.mnX, rEvt.mnY)),
1563  m_aLongPressData(rEvt.mnX, rEvt.mnY)
1564  {
1565  }
1566  virtual bool CallCommand(vcl::Window *pWindow, const Point &/*rMousePos*/) override
1567  {
1568  return ImplCallCommand(pWindow, CommandEventId::LongPress, &m_aLongPressData);
1569  }
1570 };
1571 
1572 }
1573 
1574 static bool ImplHandleLongPress(vcl::Window *pWindow, const SalLongPressEvent& rEvt)
1575 {
1576  HandleLongPressEvent aHandler(pWindow, rEvt);
1577  return aHandler.HandleEvent();
1578 }
1579 
1580 namespace {
1581 
1582 class HandleGeneralGestureEvent : public HandleGestureEvent
1583 {
1584 private:
1585  CommandGestureData m_aGestureData;
1586 
1587 public:
1588  HandleGeneralGestureEvent(vcl::Window* pWindow, const SalGestureEvent& rEvent)
1589  : HandleGestureEvent(pWindow, Point(rEvent.mnX, rEvent.mnY))
1590  , m_aGestureData(rEvent.mnX, rEvent.mnY, rEvent.meEventType, rEvent.mfOffset, rEvent.meOrientation)
1591  {
1592  }
1593 
1594  virtual bool CallCommand(vcl::Window* pWindow, const Point& /*rMousePos*/) override
1595  {
1596  return ImplCallCommand(pWindow, CommandEventId::Gesture, &m_aGestureData);
1597  }
1598 };
1599 
1600 }
1601 
1602 static bool ImplHandleGestureEvent(vcl::Window* pWindow, const SalGestureEvent& rEvent)
1603 {
1604  HandleGeneralGestureEvent aHandler(pWindow, rEvent);
1605  return aHandler.HandleEvent();
1606 }
1607 
1608 static void ImplHandlePaint( vcl::Window* pWindow, const tools::Rectangle& rBoundRect, bool bImmediateUpdate )
1609 {
1610  // system paint events must be checked for re-mirroring
1612 
1613  // trigger paint for all windows that live in the new paint region
1614  vcl::Region aRegion( rBoundRect );
1615  pWindow->ImplInvalidateOverlapFrameRegion( aRegion );
1616  if( bImmediateUpdate )
1617  {
1618  // #i87663# trigger possible pending resize notifications
1619  // (GetSizePixel does that for us)
1620  pWindow->GetSizePixel();
1621  // force drawing immediately
1622  pWindow->PaintImmediately();
1623  }
1624 }
1625 
1626 static void KillOwnPopups( vcl::Window const * pWindow )
1627 {
1628  ImplSVData* pSVData = ImplGetSVData();
1629  vcl::Window *pParent = pWindow->ImplGetWindowImpl()->mpFrameWindow;
1630  vcl::Window *pChild = pSVData->mpWinData->mpFirstFloat;
1631  if ( pChild && pParent->ImplIsWindowOrChild( pChild, true ) )
1632  {
1633  if (!(pSVData->mpWinData->mpFirstFloat->GetPopupModeFlags()
1637  }
1638 }
1639 
1640 void ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long nNewHeight )
1641 {
1642  const bool bChanged = (nNewWidth != pWindow->GetOutputWidthPixel()) || (nNewHeight != pWindow->GetOutputHeightPixel());
1643  if (bChanged && pWindow->GetStyle() & (WB_MOVEABLE|WB_SIZEABLE))
1644  {
1645  KillOwnPopups( pWindow );
1646  if( pWindow->ImplGetWindow() != ImplGetSVHelpData().mpHelpWin )
1647  ImplDestroyHelpWindow( true );
1648  }
1649 
1650  if (
1651  (nNewWidth > 0 && nNewHeight > 0) ||
1653  )
1654  {
1655  if (bChanged)
1656  {
1657  pWindow->mnOutWidth = nNewWidth;
1658  pWindow->mnOutHeight = nNewHeight;
1659  pWindow->ImplGetWindowImpl()->mbWaitSystemResize = false;
1660  if ( pWindow->IsReallyVisible() )
1661  pWindow->ImplSetClipFlag();
1662  if ( pWindow->IsVisible() || pWindow->ImplGetWindow()->ImplGetWindowImpl()->mbAllResize ||
1663  ( pWindow->ImplGetWindowImpl()->mbFrame && pWindow->ImplGetWindowImpl()->mpClientWindow ) ) // propagate resize for system border windows
1664  {
1665  bool bStartTimer = true;
1666  // use resize buffering for user resizes
1667  // ownerdraw decorated windows and floating windows can be resized immediately (i.e. synchronously)
1668  if( pWindow->ImplGetWindowImpl()->mbFrame && (pWindow->GetStyle() & WB_SIZEABLE)
1669  && !(pWindow->GetStyle() & WB_OWNERDRAWDECORATION) // synchronous resize for ownerdraw decorated windows (toolbars)
1670  && !pWindow->ImplGetWindowImpl()->mbFloatWin ) // synchronous resize for floating windows, #i43799#
1671  {
1672  if( pWindow->ImplGetWindowImpl()->mpClientWindow )
1673  {
1674  // #i42750# presentation wants to be informed about resize
1675  // as early as possible
1676  WorkWindow* pWorkWindow = dynamic_cast<WorkWindow*>(pWindow->ImplGetWindowImpl()->mpClientWindow.get());
1677  if( ! pWorkWindow || pWorkWindow->IsPresentationMode() )
1678  bStartTimer = false;
1679  }
1680  else
1681  {
1682  WorkWindow* pWorkWindow = dynamic_cast<WorkWindow*>(pWindow);
1683  if( ! pWorkWindow || pWorkWindow->IsPresentationMode() )
1684  bStartTimer = false;
1685  }
1686  }
1687  else
1688  bStartTimer = false;
1689 
1690  if( bStartTimer )
1692  else
1693  pWindow->ImplCallResize(); // otherwise menus cannot be positioned
1694  }
1695  else
1696  pWindow->ImplGetWindowImpl()->mbCallResize = true;
1697 
1698  if (pWindow->SupportsDoubleBuffering() && pWindow->ImplGetWindowImpl()->mbFrame)
1699  {
1700  // Propagate resize for the frame's buffer.
1702  }
1703  }
1704  }
1705 
1706  pWindow->ImplGetWindowImpl()->mpFrameData->mbNeedSysWindow = (nNewWidth < IMPL_MIN_NEEDSYSWIN) ||
1707  (nNewHeight < IMPL_MIN_NEEDSYSWIN);
1708  bool bMinimized = (nNewWidth <= 0) || (nNewHeight <= 0);
1709  if( bMinimized != pWindow->ImplGetWindowImpl()->mpFrameData->mbMinimized )
1710  pWindow->ImplGetWindowImpl()->mpFrameWindow->ImplNotifyIconifiedState( bMinimized );
1711  pWindow->ImplGetWindowImpl()->mpFrameData->mbMinimized = bMinimized;
1712 }
1713 
1714 static void ImplHandleMove( vcl::Window* pWindow )
1715 {
1716  if( pWindow->ImplGetWindowImpl()->mbFrame && pWindow->ImplIsFloatingWindow() && pWindow->IsReallyVisible() )
1717  {
1718  static_cast<FloatingWindow*>(pWindow)->EndPopupMode( FloatWinPopupEndFlags::TearOff );
1719  pWindow->ImplCallMove();
1720  }
1721 
1722  if( pWindow->GetStyle() & (WB_MOVEABLE|WB_SIZEABLE) )
1723  {
1724  KillOwnPopups( pWindow );
1725  if( pWindow->ImplGetWindow() != ImplGetSVHelpData().mpHelpWin )
1726  ImplDestroyHelpWindow( true );
1727  }
1728 
1729  if ( pWindow->IsVisible() )
1730  pWindow->ImplCallMove();
1731  else
1732  pWindow->ImplGetWindowImpl()->mbCallMove = true; // make sure the framepos will be updated on the next Show()
1733 
1734  if ( pWindow->ImplGetWindowImpl()->mbFrame && pWindow->ImplGetWindowImpl()->mpClientWindow )
1735  pWindow->ImplGetWindowImpl()->mpClientWindow->ImplCallMove(); // notify client to update geometry
1736 
1737 }
1738 
1739 static void ImplHandleMoveResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long nNewHeight )
1740 {
1741  ImplHandleMove( pWindow );
1742  ImplHandleResize( pWindow, nNewWidth, nNewHeight );
1743 }
1744 
1745 static void ImplActivateFloatingWindows( vcl::Window const * pWindow, bool bActive )
1746 {
1747  // First check all overlapping windows
1748  vcl::Window* pTempWindow = pWindow->ImplGetWindowImpl()->mpFirstOverlap;
1749  while ( pTempWindow )
1750  {
1751  if ( pTempWindow->GetActivateMode() == ActivateModeFlags::NONE )
1752  {
1753  if ( (pTempWindow->GetType() == WindowType::BORDERWINDOW) &&
1754  (pTempWindow->ImplGetWindow()->GetType() == WindowType::FLOATINGWINDOW) )
1755  static_cast<ImplBorderWindow*>(pTempWindow)->SetDisplayActive( bActive );
1756  }
1757 
1758  ImplActivateFloatingWindows( pTempWindow, bActive );
1759  pTempWindow = pTempWindow->ImplGetWindowImpl()->mpNext;
1760  }
1761 }
1762 
1763 IMPL_LINK_NOARG(vcl::Window, ImplAsyncFocusHdl, void*, void)
1764 {
1765  ImplGetWindowImpl()->mpFrameData->mnFocusId = nullptr;
1766 
1767  // If the status has been preserved, because we got back the focus
1768  // in the meantime, we do nothing
1769  bool bHasFocus = ImplGetWindowImpl()->mpFrameData->mbHasFocus || ImplGetWindowImpl()->mpFrameData->mbSysObjFocus;
1770 
1771  // next execute the delayed functions
1772  if ( bHasFocus )
1773  {
1774  // redraw all floating windows inactive
1775  if ( ImplGetWindowImpl()->mpFrameData->mbStartFocusState != bHasFocus )
1776  ImplActivateFloatingWindows( this, bHasFocus );
1777 
1778  if ( ImplGetWindowImpl()->mpFrameData->mpFocusWin )
1779  {
1780  bool bHandled = false;
1781  if ( ImplGetWindowImpl()->mpFrameData->mpFocusWin->IsInputEnabled() &&
1782  ! ImplGetWindowImpl()->mpFrameData->mpFocusWin->IsInModalMode() )
1783  {
1784  if ( ImplGetWindowImpl()->mpFrameData->mpFocusWin->IsEnabled() )
1785  {
1786  ImplGetWindowImpl()->mpFrameData->mpFocusWin->GrabFocus();
1787  bHandled = true;
1788  }
1789  else if( ImplGetWindowImpl()->mpFrameData->mpFocusWin->ImplHasDlgCtrl() )
1790  {
1791  // #109094# if the focus is restored to a disabled dialog control (was disabled meanwhile)
1792  // try to move it to the next control
1793  ImplGetWindowImpl()->mpFrameData->mpFocusWin->ImplDlgCtrlNextWindow();
1794  bHandled = true;
1795  }
1796  }
1797  if ( !bHandled )
1798  {
1799  ImplSVData* pSVData = ImplGetSVData();
1800  vcl::Window* pTopLevelWindow = ImplGetWindowImpl()->mpFrameData->mpFocusWin->ImplGetFirstOverlapWindow();
1801 
1802  if ((!pTopLevelWindow->IsInputEnabled() || pTopLevelWindow->IsInModalMode())
1803  && !pSVData->mpWinData->mpExecuteDialogs.empty())
1805  else
1806  pTopLevelWindow->GrabFocus();
1807  }
1808  }
1809  else
1810  GrabFocus();
1811  }
1812  else
1813  {
1814  vcl::Window* pFocusWin = ImplGetWindowImpl()->mpFrameData->mpFocusWin;
1815  if ( pFocusWin )
1816  {
1817  ImplSVData* pSVData = ImplGetSVData();
1818 
1819  if (pSVData->mpWinData->mpFocusWin == pFocusWin)
1820  {
1821  // transfer the FocusWindow
1822  vcl::Window* pOverlapWindow = pFocusWin->ImplGetFirstOverlapWindow();
1823  pOverlapWindow->ImplGetWindowImpl()->mpLastFocusWindow = pFocusWin;
1824  pSVData->mpWinData->mpFocusWin = nullptr;
1825 
1826  if ( pFocusWin->ImplGetWindowImpl()->mpCursor )
1827  pFocusWin->ImplGetWindowImpl()->mpCursor->ImplHide();
1828 
1829  // call the Deactivate
1830  vcl::Window* pOldOverlapWindow = pFocusWin->ImplGetFirstOverlapWindow();
1831  vcl::Window* pOldRealWindow = pOldOverlapWindow->ImplGetWindow();
1832 
1833  pOldOverlapWindow->ImplGetWindowImpl()->mbActive = false;
1834  pOldOverlapWindow->Deactivate();
1835  if ( pOldRealWindow != pOldOverlapWindow )
1836  {
1837  pOldRealWindow->ImplGetWindowImpl()->mbActive = false;
1838  pOldRealWindow->Deactivate();
1839  }
1840 
1841  // TrackingMode is ended in ImplHandleLoseFocus
1842 #ifdef _WIN32
1843  // To avoid problems with the Unix IME
1844  pFocusWin->EndExtTextInput();
1845 #endif
1846 
1847  NotifyEvent aNEvt(MouseNotifyEvent::LOSEFOCUS, pFocusWin);
1848  if (!ImplCallPreNotify(aNEvt))
1849  pFocusWin->CompatLoseFocus();
1850  pFocusWin->ImplCallDeactivateListeners(nullptr);
1851  }
1852  }
1853 
1854  // Redraw all floating window inactive
1855  if ( ImplGetWindowImpl()->mpFrameData->mbStartFocusState != bHasFocus )
1856  ImplActivateFloatingWindows( this, bHasFocus );
1857  }
1858 }
1859 
1860 static void ImplHandleGetFocus( vcl::Window* pWindow )
1861 {
1862  pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus = true;
1863 
1864  // execute Focus-Events after a delay, such that SystemChildWindows
1865  // do not blink when they receive focus
1866  if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
1867  {
1869  pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId = Application::PostUserEvent( LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ), nullptr, true);
1870  vcl::Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
1871  if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor )
1872  pFocusWin->ImplGetWindowImpl()->mpCursor->ImplShow();
1873  }
1874 }
1875 
1876 static void ImplHandleLoseFocus( vcl::Window* pWindow )
1877 {
1878  ImplSVData* pSVData = ImplGetSVData();
1879 
1880  // Abort the autoscroll if the frame loses focus
1881  if (pSVData->mpWinData->mpAutoScrollWin)
1883 
1884  // Abort tracking if the frame loses focus
1885  if (pSVData->mpWinData->mpTrackWin)
1886  {
1887  if (pSVData->mpWinData->mpTrackWin->ImplGetWindowImpl()->mpFrameWindow == pWindow)
1889  }
1890 
1891  pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus = false;
1892 
1893  // execute Focus-Events after a delay, such that SystemChildWindows
1894  // do not flicker when they receive focus
1895  if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
1896  {
1898  pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId = Application::PostUserEvent( LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ), nullptr, true );
1899  }
1900 
1901  vcl::Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
1902  if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor )
1903  pFocusWin->ImplGetWindowImpl()->mpCursor->ImplHide();
1904 
1905  // Make sure that no menu is visible when a toplevel window loses focus.
1906  VclPtr<FloatingWindow> pFirstFloat = pSVData->mpWinData->mpFirstFloat;
1907  if (pFirstFloat && !pWindow->GetParent())
1909 }
1910 
1911 namespace {
1912 
1913 struct DelayedCloseEvent
1914 {
1915  VclPtr<vcl::Window> pWindow;
1916 };
1917 
1918 }
1919 
1920 static void DelayedCloseEventLink( void* pCEvent, void* )
1921 {
1922  DelayedCloseEvent* pEv = static_cast<DelayedCloseEvent*>(pCEvent);
1923 
1924  if( ! pEv->pWindow->IsDisposed() )
1925  {
1926  // dispatch to correct window type
1927  if( pEv->pWindow->IsSystemWindow() )
1928  static_cast<SystemWindow*>(pEv->pWindow.get())->Close();
1929  else if( pEv->pWindow->IsDockingWindow() )
1930  static_cast<DockingWindow*>(pEv->pWindow.get())->Close();
1931  }
1932  delete pEv;
1933 }
1934 
1935 static void ImplHandleClose( const vcl::Window* pWindow )
1936 {
1937  ImplSVData* pSVData = ImplGetSVData();
1938 
1939  bool bWasPopup = false;
1940  if( pWindow->ImplIsFloatingWindow() &&
1941  static_cast<const FloatingWindow*>(pWindow)->ImplIsInPrivatePopupMode() )
1942  {
1943  bWasPopup = true;
1944  }
1945 
1946  // on Close stop all floating modes and end popups
1947  if (pSVData->mpWinData->mpFirstFloat)
1948  {
1949  FloatingWindow* pLastLevelFloat;
1950  pLastLevelFloat = pSVData->mpWinData->mpFirstFloat->ImplFindLastLevelFloat();
1952  }
1953  if ( ImplGetSVHelpData().mbExtHelpMode )
1954  Help::EndExtHelp();
1955  if ( ImplGetSVHelpData().mpHelpWin )
1956  ImplDestroyHelpWindow( false );
1957  // AutoScrollMode
1958  if (pSVData->mpWinData->mpAutoScrollWin)
1960 
1961  if (pSVData->mpWinData->mpTrackWin)
1963 
1964  if (bWasPopup)
1965  return;
1966 
1967  vcl::Window *pWin = pWindow->ImplGetWindow();
1968  SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(pWin);
1969  if (pSysWin)
1970  {
1971  // See if the custom close handler is set.
1972  const Link<SystemWindow&,void>& rLink = pSysWin->GetCloseHdl();
1973  if (rLink.IsSet())
1974  {
1975  rLink.Call(*pSysWin);
1976  return;
1977  }
1978  }
1979 
1980  // check whether close is allowed
1981  if ( pWin->IsEnabled() && pWin->IsInputEnabled() && !pWin->IsInModalMode() )
1982  {
1983  DelayedCloseEvent* pEv = new DelayedCloseEvent;
1984  pEv->pWindow = pWin;
1986  }
1987 }
1988 
1989 static void ImplHandleUserEvent( ImplSVEvent* pSVEvent )
1990 {
1991  if ( pSVEvent )
1992  {
1993  if ( pSVEvent->mbCall )
1994  {
1995  pSVEvent->maLink.Call( pSVEvent->mpData );
1996  }
1997 
1998  delete pSVEvent;
1999  }
2000 }
2001 
2003 {
2005  if ( !pEvent->mnCode )
2007  if ( (pEvent->mnCode & MOUSE_LEFT) && !(pEvent->mnCode & KEY_MOD1) )
2009  if ( (pEvent->mnCode & MOUSE_LEFT) && (pEvent->mnCode & KEY_MOD1) )
2011  return nMode;
2012 }
2013 
2015 {
2017  if ( pEvent->mnButton == MOUSE_LEFT )
2019  if ( (pEvent->mnButton == MOUSE_LEFT) && !(pEvent->mnCode & (MOUSE_MIDDLE | MOUSE_RIGHT)) )
2020  nMode |= MouseEventModifiers::SELECT;
2021  if ( (pEvent->mnButton == MOUSE_LEFT) && (pEvent->mnCode & KEY_MOD1) &&
2022  !(pEvent->mnCode & (MOUSE_MIDDLE | MOUSE_RIGHT | KEY_SHIFT)) )
2024  if ( (pEvent->mnButton == MOUSE_LEFT) && (pEvent->mnCode & KEY_SHIFT) &&
2025  !(pEvent->mnCode & (MOUSE_MIDDLE | MOUSE_RIGHT | KEY_MOD1)) )
2027  return nMode;
2028 }
2029 
2030 static bool ImplHandleSalMouseLeave( vcl::Window* pWindow, SalMouseEvent const * pEvent )
2031 {
2032  return ImplHandleMouseEvent( pWindow, MouseNotifyEvent::MOUSEMOVE, true,
2033  pEvent->mnX, pEvent->mnY,
2034  pEvent->mnTime, pEvent->mnCode,
2035  ImplGetMouseMoveMode( pEvent ) );
2036 }
2037 
2038 static bool ImplHandleSalMouseMove( vcl::Window* pWindow, SalMouseEvent const * pEvent )
2039 {
2040  return ImplHandleMouseEvent( pWindow, MouseNotifyEvent::MOUSEMOVE, false,
2041  pEvent->mnX, pEvent->mnY,
2042  pEvent->mnTime, pEvent->mnCode,
2043  ImplGetMouseMoveMode( pEvent ) );
2044 }
2045 
2046 static bool ImplHandleSalMouseButtonDown( vcl::Window* pWindow, SalMouseEvent const * pEvent )
2047 {
2049  pEvent->mnX, pEvent->mnY,
2050  pEvent->mnTime,
2051 #ifdef MACOSX
2052  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)),
2053 #else
2054  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)),
2055 #endif
2056  ImplGetMouseButtonMode( pEvent ) );
2057 }
2058 
2059 static bool ImplHandleSalMouseButtonUp( vcl::Window* pWindow, SalMouseEvent const * pEvent )
2060 {
2061  return ImplHandleMouseEvent( pWindow, MouseNotifyEvent::MOUSEBUTTONUP, false,
2062  pEvent->mnX, pEvent->mnY,
2063  pEvent->mnTime,
2064 #ifdef MACOSX
2065  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)),
2066 #else
2067  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)),
2068 #endif
2069  ImplGetMouseButtonMode( pEvent ) );
2070 }
2071 
2072 static bool ImplHandleMenuEvent( vcl::Window const * pWindow, SalMenuEvent* pEvent, SalEvent nEvent )
2073 {
2074  // Find SystemWindow and its Menubar and let it dispatch the command
2075  bool bRet = false;
2076  vcl::Window *pWin = pWindow->ImplGetWindowImpl()->mpFirstChild;
2077  while ( pWin )
2078  {
2079  if ( pWin->ImplGetWindowImpl()->mbSysWin )
2080  break;
2081  pWin = pWin->ImplGetWindowImpl()->mpNext;
2082  }
2083  if( pWin )
2084  {
2085  MenuBar *pMenuBar = static_cast<SystemWindow*>(pWin)->GetMenuBar();
2086  if( pMenuBar )
2087  {
2088  switch( nEvent )
2089  {
2091  pMenuBar->HandleMenuActivateEvent( static_cast<Menu*>(pEvent->mpMenu) );
2092  bRet = true;
2093  break;
2095  pMenuBar->HandleMenuDeActivateEvent( static_cast<Menu*>(pEvent->mpMenu) );
2096  bRet = true;
2097  break;
2099  bRet = pMenuBar->HandleMenuHighlightEvent( static_cast<Menu*>(pEvent->mpMenu), pEvent->mnId );
2100  break;
2102  bRet = pMenuBar->HandleMenuButtonEvent( pEvent->mnId );
2103  break;
2104  case SalEvent::MenuCommand:
2105  bRet = pMenuBar->HandleMenuCommandEvent( static_cast<Menu*>(pEvent->mpMenu), pEvent->mnId );
2106  break;
2107  default:
2108  break;
2109  }
2110  }
2111  }
2112  return bRet;
2113 }
2114 
2115 static void ImplHandleSalKeyMod( vcl::Window* pWindow, SalKeyModEvent const * pEvent )
2116 {
2117  ImplSVData* pSVData = ImplGetSVData();
2118  vcl::Window* pTrackWin = pSVData->mpWinData->mpTrackWin;
2119  if ( pTrackWin )
2120  pWindow = pTrackWin;
2121 #ifdef MACOSX
2122  sal_uInt16 nOldCode = pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3);
2123 #else
2124  sal_uInt16 nOldCode = pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2);
2125 #endif
2126  sal_uInt16 nNewCode = pEvent->mnCode;
2127  if ( nOldCode != nNewCode )
2128  {
2129 #ifdef MACOSX
2130  nNewCode |= pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3);
2131 #else
2132  nNewCode |= pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2);
2133 #endif
2134  pWindow->ImplGetWindowImpl()->mpFrameWindow->ImplCallMouseMove( nNewCode, true );
2135  }
2136 
2137  // #105224# send commandevent to allow special treatment of Ctrl-LeftShift/Ctrl-RightShift etc.
2138  // + auto-accelerator feature, tdf#92630
2139 
2140  // try to find a key input window...
2141  vcl::Window* pChild = ImplGetKeyInputWindow( pWindow );
2142  //...otherwise fail safe...
2143  if (!pChild)
2144  pChild = pWindow;
2145 
2146  CommandModKeyData data( pEvent->mnModKeyCode, pEvent->mbDown );
2148 }
2149 
2151 {
2152  // find window
2153  vcl::Window* pChild = ImplGetKeyInputWindow( pWindow );
2154  if ( !pChild )
2155  return;
2156 
2158 }
2159 
2160 static void ImplHandleSalSettings( SalEvent nEvent )
2161 {
2162  Application* pApp = GetpApp();
2163  if ( !pApp )
2164  return;
2165 
2166  if ( nEvent == SalEvent::SettingsChanged )
2167  {
2168  AllSettings aSettings = Application::GetSettings();
2169  Application::MergeSystemSettings( aSettings );
2170  pApp->OverrideSystemSettings( aSettings );
2171  Application::SetSettings( aSettings );
2172  }
2173  else
2174  {
2176  switch ( nEvent )
2177  {
2181  break;
2184  break;
2185  case SalEvent::FontChanged:
2188  break;
2189  default:
2191  break;
2192  }
2193 
2194  if ( nType != DataChangedEventType::NONE )
2195  {
2196  DataChangedEvent aDCEvt( nType );
2199  }
2200  }
2201 }
2202 
2204 {
2205  tools::Rectangle aCursorRect;
2206  ImplHandleExtTextInputPos( pWindow, aCursorRect, pEvt->mnExtWidth, &pEvt->mbVertical );
2207  if ( aCursorRect.IsEmpty() )
2208  {
2209  pEvt->mnX = -1;
2210  pEvt->mnY = -1;
2211  pEvt->mnWidth = -1;
2212  pEvt->mnHeight = -1;
2213  }
2214  else
2215  {
2216  pEvt->mnX = aCursorRect.Left();
2217  pEvt->mnY = aCursorRect.Top();
2218  pEvt->mnWidth = aCursorRect.GetWidth();
2219  pEvt->mnHeight = aCursorRect.GetHeight();
2220  }
2221 }
2222 
2223 static bool ImplHandleShowDialog( vcl::Window* pWindow, ShowDialogId nDialogId )
2224 {
2225  if( ! pWindow )
2226  return false;
2227 
2228  if( pWindow->GetType() == WindowType::BORDERWINDOW )
2229  {
2230  vcl::Window* pWrkWin = pWindow->GetWindow( GetWindowType::Client );
2231  if( pWrkWin )
2232  pWindow = pWrkWin;
2233  }
2234  CommandDialogData aCmdData( nDialogId );
2235  return ImplCallCommand( pWindow, CommandEventId::ShowDialog, &aCmdData );
2236 }
2237 
2239  OUString& rText,
2240  Selection &rSelRange )
2241 {
2242  vcl::Window* pChild = ImplGetKeyInputWindow( pWindow );
2243 
2244  if ( !pChild )
2245  {
2246  rText.clear();
2247  rSelRange.setMin( 0 );
2248  rSelRange.setMax( 0 );
2249  }
2250  else
2251  {
2252  rText = pChild->GetSurroundingText();
2253  Selection aSel = pChild->GetSurroundingTextSelection();
2254  rSelRange.setMin( aSel.Min() );
2255  rSelRange.setMax( aSel.Max() );
2256  }
2257 }
2258 
2261 {
2262  Selection aSelRange;
2263  ImplHandleSurroundingTextRequest( pWindow, pEvt->maText, aSelRange );
2264 
2265  aSelRange.Justify();
2266 
2267  if( aSelRange.Min() < 0 )
2268  pEvt->mnStart = 0;
2269  else if( aSelRange.Min() > pEvt->maText.getLength() )
2270  pEvt->mnStart = pEvt->maText.getLength();
2271  else
2272  pEvt->mnStart = aSelRange.Min();
2273 
2274  if( aSelRange.Max() < 0 )
2275  pEvt->mnStart = 0;
2276  else if( aSelRange.Max() > pEvt->maText.getLength() )
2277  pEvt->mnEnd = pEvt->maText.getLength();
2278  else
2279  pEvt->mnEnd = aSelRange.Max();
2280 }
2281 
2284 {
2285  vcl::Window* pChild = ImplGetKeyInputWindow( pWindow );
2286 
2287  Selection aSelection(pEvt->mnStart, pEvt->mnEnd);
2288  if (pChild && pChild->DeleteSurroundingText(aSelection))
2289  {
2290  pEvt->mnStart = aSelection.Min();
2291  pEvt->mnEnd = aSelection.Max();
2292  }
2293  else
2294  {
2295  pEvt->mnStart = pEvt->mnEnd = SAL_MAX_UINT32;
2296  }
2297 }
2298 
2300  sal_uLong nStart,
2301  sal_uLong nEnd )
2302 {
2303  vcl::Window* pChild = ImplGetKeyInputWindow( pWindow );
2304  if( pChild )
2305  {
2306  CommandSelectionChangeData data( nStart, nEnd );
2308  }
2309 }
2310 
2312 {
2313  vcl::Window* pChild = ImplGetKeyInputWindow( pWindow );
2314  if( pChild )
2316 }
2317 
2320 {
2321  pEvt->mbValid = false;
2322  pEvt->mbVertical = false;
2323  pEvt->mnCursorBoundX = 0;
2324  pEvt->mnCursorBoundY = 0;
2325  pEvt->mnCursorBoundWidth = 0;
2326  pEvt->mnCursorBoundHeight = 0;
2327 
2328  ImplSVData* pSVData = ImplGetSVData();
2329  vcl::Window* pChild = pSVData->mpWinData->mpExtTextInputWin;
2330 
2331  if ( !pChild )
2332  pChild = ImplGetKeyInputWindow( pWindow );
2333  else
2334  {
2335  // Test, if the Window is related to the frame
2336  if ( !pWindow->ImplIsWindowOrChild( pChild ) )
2337  pChild = ImplGetKeyInputWindow( pWindow );
2338  }
2339 
2340  if( !pChild )
2341  return;
2342 
2344 
2345  ImplWinData* pWinData = pChild->ImplGetWinData();
2346  if ( !(pWinData->mpCompositionCharRects && pEvt->mnCharPos < o3tl::make_unsigned( pWinData->mnCompositionCharRects )) )
2347  return;
2348 
2349  const OutputDevice *pChildOutDev = pChild->GetOutDev();
2350  const tools::Rectangle& aRect = pWinData->mpCompositionCharRects[ pEvt->mnCharPos ];
2351  tools::Rectangle aDeviceRect = pChildOutDev->ImplLogicToDevicePixel( aRect );
2352  Point aAbsScreenPos = pChild->OutputToAbsoluteScreenPixel( pChild->ScreenToOutputPixel(aDeviceRect.TopLeft()) );
2353  pEvt->mnCursorBoundX = aAbsScreenPos.X();
2354  pEvt->mnCursorBoundY = aAbsScreenPos.Y();
2355  pEvt->mnCursorBoundWidth = aDeviceRect.GetWidth();
2356  pEvt->mnCursorBoundHeight = aDeviceRect.GetHeight();
2357  pEvt->mbVertical = pWinData->mbVertical;
2358  pEvt->mbValid = true;
2359 }
2360 
2361 bool ImplWindowFrameProc( vcl::Window* _pWindow, SalEvent nEvent, const void* pEvent )
2362 {
2364 
2365  // Ensure the window survives during this method.
2366  VclPtr<vcl::Window> pWindow( _pWindow );
2367 
2368  bool bRet = false;
2369 
2370  // #119709# for some unknown reason it is possible to receive events (in this case key events)
2371  // although the corresponding VCL window must have been destroyed already
2372  // at least ImplGetWindowImpl() was NULL in these cases, so check this here
2373  if( pWindow->ImplGetWindowImpl() == nullptr )
2374  return false;
2375 
2376  switch ( nEvent )
2377  {
2378  case SalEvent::MouseMove:
2379  bRet = ImplHandleSalMouseMove( pWindow, static_cast<SalMouseEvent const *>(pEvent) );
2380  break;
2382  {
2383  MouseEvent const * pMouseEvt = static_cast<MouseEvent const *>(pEvent);
2384  SalMouseEvent aSalMouseEvent;
2385 
2386  aSalMouseEvent.mnTime = tools::Time::GetSystemTicks();
2387  aSalMouseEvent.mnX = pMouseEvt->GetPosPixel().X();
2388  aSalMouseEvent.mnY = pMouseEvt->GetPosPixel().Y();
2389  aSalMouseEvent.mnButton = 0;
2390  aSalMouseEvent.mnCode = pMouseEvt->GetButtons() | pMouseEvt->GetModifier();
2391 
2392  bRet = ImplHandleSalMouseMove( pWindow, &aSalMouseEvent );
2393  }
2394  break;
2395  case SalEvent::MouseLeave:
2396  bRet = ImplHandleSalMouseLeave( pWindow, static_cast<SalMouseEvent const *>(pEvent) );
2397  break;
2399  bRet = ImplHandleSalMouseButtonDown( pWindow, static_cast<SalMouseEvent const *>(pEvent) );
2400  break;
2402  {
2403  MouseEvent const * pMouseEvt = static_cast<MouseEvent const *>(pEvent);
2404  SalMouseEvent aSalMouseEvent;
2405 
2406  aSalMouseEvent.mnTime = tools::Time::GetSystemTicks();
2407  aSalMouseEvent.mnX = pMouseEvt->GetPosPixel().X();
2408  aSalMouseEvent.mnY = pMouseEvt->GetPosPixel().Y();
2409  aSalMouseEvent.mnButton = pMouseEvt->GetButtons();
2410  aSalMouseEvent.mnCode = pMouseEvt->GetButtons() | pMouseEvt->GetModifier();
2411 
2412  bRet = ImplHandleSalMouseButtonDown( pWindow, &aSalMouseEvent );
2413  }
2414  break;
2416  bRet = ImplHandleSalMouseButtonUp( pWindow, static_cast<SalMouseEvent const *>(pEvent) );
2417  break;
2419  {
2420  MouseEvent const * pMouseEvt = static_cast<MouseEvent const *>(pEvent);
2421  SalMouseEvent aSalMouseEvent;
2422 
2423  aSalMouseEvent.mnTime = tools::Time::GetSystemTicks();
2424  aSalMouseEvent.mnX = pMouseEvt->GetPosPixel().X();
2425  aSalMouseEvent.mnY = pMouseEvt->GetPosPixel().Y();
2426  aSalMouseEvent.mnButton = pMouseEvt->GetButtons();
2427  aSalMouseEvent.mnCode = pMouseEvt->GetButtons() | pMouseEvt->GetModifier();
2428 
2429  bRet = ImplHandleSalMouseButtonUp( pWindow, &aSalMouseEvent );
2430  }
2431  break;
2433  bRet = false;
2434  break;
2435  case SalEvent::KeyInput:
2436  {
2437  SalKeyEvent const * pKeyEvt = static_cast<SalKeyEvent const *>(pEvent);
2438  bRet = ImplHandleKey( pWindow, MouseNotifyEvent::KEYINPUT,
2439  pKeyEvt->mnCode, pKeyEvt->mnCharCode, pKeyEvt->mnRepeat, true );
2440  }
2441  break;
2443  {
2444  KeyEvent const * pKeyEvt = static_cast<KeyEvent const *>(pEvent);
2445  bRet = ImplHandleKey( pWindow, MouseNotifyEvent::KEYINPUT,
2446  pKeyEvt->GetKeyCode().GetFullCode(), pKeyEvt->GetCharCode(), pKeyEvt->GetRepeat(), false );
2447  }
2448  break;
2449  case SalEvent::KeyUp:
2450  {
2451  SalKeyEvent const * pKeyEvt = static_cast<SalKeyEvent const *>(pEvent);
2452  bRet = ImplHandleKey( pWindow, MouseNotifyEvent::KEYUP,
2453  pKeyEvt->mnCode, pKeyEvt->mnCharCode, pKeyEvt->mnRepeat, true );
2454  }
2455  break;
2457  {
2458  KeyEvent const * pKeyEvt = static_cast<KeyEvent const *>(pEvent);
2459  bRet = ImplHandleKey( pWindow, MouseNotifyEvent::KEYUP,
2460  pKeyEvt->GetKeyCode().GetFullCode(), pKeyEvt->GetCharCode(), pKeyEvt->GetRepeat(), false );
2461  }
2462  break;
2464  ImplHandleSalKeyMod( pWindow, static_cast<SalKeyModEvent const *>(pEvent) );
2465  break;
2466 
2468  ImplHandleInputLanguageChange( pWindow );
2469  break;
2470 
2474  case SalEvent::MenuCommand:
2476  bRet = ImplHandleMenuEvent( pWindow, const_cast<SalMenuEvent *>(static_cast<SalMenuEvent const *>(pEvent)), nEvent );
2477  break;
2478 
2479  case SalEvent::WheelMouse:
2480  bRet = ImplHandleWheelEvent( pWindow, *static_cast<const SalWheelMouseEvent*>(pEvent));
2481  break;
2482 
2483  case SalEvent::Paint:
2484  {
2485  SalPaintEvent const * pPaintEvt = static_cast<SalPaintEvent const *>(pEvent);
2486 
2488  {
2489  SalFrame* pSalFrame = pWindow->ImplGetWindowImpl()->mpFrame;
2490  const_cast<SalPaintEvent *>(pPaintEvt)->mnBoundX = pSalFrame->maGeometry.nWidth-pPaintEvt->mnBoundWidth-pPaintEvt->mnBoundX;
2491  }
2492 
2493  tools::Rectangle aBoundRect( Point( pPaintEvt->mnBoundX, pPaintEvt->mnBoundY ),
2494  Size( pPaintEvt->mnBoundWidth, pPaintEvt->mnBoundHeight ) );
2495  ImplHandlePaint( pWindow, aBoundRect, pPaintEvt->mbImmediateUpdate );
2496  }
2497  break;
2498 
2499  case SalEvent::Move:
2500  ImplHandleMove( pWindow );
2501  break;
2502 
2503  case SalEvent::Resize:
2504  {
2505  tools::Long nNewWidth;
2506  tools::Long nNewHeight;
2507  pWindow->ImplGetWindowImpl()->mpFrame->GetClientSize( nNewWidth, nNewHeight );
2508  ImplHandleResize( pWindow, nNewWidth, nNewHeight );
2509  }
2510  break;
2511 
2512  case SalEvent::MoveResize:
2513  {
2515  ImplHandleMoveResize( pWindow, g.nWidth, g.nHeight );
2516  }
2517  break;
2518 
2519  case SalEvent::ClosePopups:
2520  {
2521  KillOwnPopups( pWindow );
2522  }
2523  break;
2524 
2525  case SalEvent::GetFocus:
2526  ImplHandleGetFocus( pWindow );
2527  break;
2528  case SalEvent::LoseFocus:
2529  ImplHandleLoseFocus( pWindow );
2530  break;
2531 
2532  case SalEvent::Close:
2533  ImplHandleClose( pWindow );
2534  break;
2535 
2536  case SalEvent::Shutdown:
2537  {
2538  static bool bInQueryExit = false;
2539  if( !bInQueryExit )
2540  {
2541  bInQueryExit = true;
2542  if ( GetpApp()->QueryExit() )
2543  {
2544  // end the message loop
2546  return false;
2547  }
2548  else
2549  {
2550  bInQueryExit = false;
2551  return true;
2552  }
2553  }
2554  return false;
2555  }
2556 
2560  case SalEvent::FontChanged:
2561  ImplHandleSalSettings( nEvent );
2562  break;
2563 
2564  case SalEvent::UserEvent:
2565  ImplHandleUserEvent( const_cast<ImplSVEvent *>(static_cast<ImplSVEvent const *>(pEvent)) );
2566  break;
2567 
2569  {
2570  SalExtTextInputEvent const * pEvt = static_cast<SalExtTextInputEvent const *>(pEvent);
2571  bRet = ImplHandleExtTextInput( pWindow,
2572  pEvt->maText, pEvt->mpTextAttr,
2573  pEvt->mnCursorPos, pEvt->mnCursorFlags );
2574  }
2575  break;
2577  bRet = ImplHandleEndExtTextInput();
2578  break;
2580  ImplHandleSalExtTextInputPos( pWindow, const_cast<SalExtTextInputPosEvent *>(static_cast<SalExtTextInputPosEvent const *>(pEvent)) );
2581  break;
2583  bRet = ImplHandleInputContextChange( pWindow );
2584  break;
2585  case SalEvent::ShowDialog:
2586  {
2587  ShowDialogId nLOKWindowId = static_cast<ShowDialogId>(reinterpret_cast<sal_IntPtr>(pEvent));
2588  bRet = ImplHandleShowDialog( pWindow, nLOKWindowId );
2589  }
2590  break;
2592  ImplHandleSalSurroundingTextRequest( pWindow, const_cast<SalSurroundingTextRequestEvent *>(static_cast<SalSurroundingTextRequestEvent const *>(pEvent)) );
2593  break;
2595  ImplHandleSalDeleteSurroundingTextRequest( pWindow, const_cast<SalSurroundingTextSelectionChangeEvent *>(static_cast<SalSurroundingTextSelectionChangeEvent const *>(pEvent)) );
2596  break;
2598  {
2600  = static_cast<SalSurroundingTextSelectionChangeEvent const *>(pEvent);
2602  pEvt->mnStart,
2603  pEvt->mnEnd );
2604  [[fallthrough]]; // TODO: Fallthrough really intended?
2605  }
2607  ImplHandleStartReconversion( pWindow );
2608  break;
2609 
2611  ImplHandleSalQueryCharPosition( pWindow, const_cast<SalQueryCharPositionEvent *>(static_cast<SalQueryCharPositionEvent const *>(pEvent)) );
2612  break;
2613 
2614  case SalEvent::Swipe:
2615  bRet = ImplHandleSwipe(pWindow, *static_cast<const SalSwipeEvent*>(pEvent));
2616  break;
2617 
2618  case SalEvent::LongPress:
2619  bRet = ImplHandleLongPress(pWindow, *static_cast<const SalLongPressEvent*>(pEvent));
2620  break;
2621 
2623  {
2624  auto const * pGestureEvent = static_cast<GestureEvent const *>(pEvent);
2625 
2626  SalGestureEvent aSalGestureEvent;
2627  aSalGestureEvent.mfOffset = pGestureEvent->mnOffset;
2628  aSalGestureEvent.mnX = pGestureEvent->mnX;
2629  aSalGestureEvent.mnY = pGestureEvent->mnY;
2630  aSalGestureEvent.meEventType = pGestureEvent->meEventType;
2631  aSalGestureEvent.meOrientation = pGestureEvent->meOrientation;
2632 
2633  bRet = ImplHandleGestureEvent(pWindow, aSalGestureEvent);
2634  }
2635  break;
2636  case SalEvent::Gesture:
2637  {
2638  auto const * aSalGestureEvent = static_cast<SalGestureEvent const *>(pEvent);
2639  bRet = ImplHandleGestureEvent(pWindow, *aSalGestureEvent);
2640  }
2641  break;
2642  default:
2643  SAL_WARN( "vcl.layout", "ImplWindowFrameProc(): unknown event (" << static_cast<int>(nEvent) << ")" );
2644  break;
2645  }
2646 
2647  return bRet;
2648 }
2649 
2650 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long Max() const
ImplSVHelpData & ImplGetSVHelpData()
Definition: svdata.cxx:462
bool mbNeedSysWindow
Definition: window.h:162
Point TopLeft() const
tools::Long GetStartDragWidth() const
SAL_DLLPRIVATE vcl::Window * ImplFindWindow(const Point &rFramePos)
Definition: stacking.cxx:632
bool IsWindowOrChild(const vcl::Window *pWindow, bool bSystemWindow=false) const
Definition: stacking.cxx:1127
void EndExtTextInput()
Definition: window.cxx:2105
bool IsInputEnabled() const
Definition: window2.cxx:1127
tools::Long mnBoundY
Definition: salwtype.hxx:145
MouseEventModifiers mnMouseMode
Definition: window.h:157
bool HandleMenuButtonEvent(sal_uInt16 nEventId)
Definition: menu.cxx:2689
vcl::Window * ImplGetWindow() const
if this is a proxy return the client, otherwise itself
Definition: window2.cxx:835
VclPtr< HelpTextWindow > mpHelpWin
Definition: svdata.hxx:300
css::uno::Reference< css::datatransfer::dnd::XDragSource > GetDragSource()
Definition: mouse.cxx:719
Point GetPointerPosPixel()
Definition: mouse.cxx:550
ActivateModeFlags GetActivateMode() const
Definition: window2.cxx:1137
const LocaleDataWrapper & GetLocaleDataWrapper() const
std::optional< OUString > mpExtOldText
Definition: window.h:102
tools::Long mnFirstMouseX
Definition: window.h:148
SAL_DLLPRIVATE void ImplCallResize()
Definition: event.cxx:514
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:248
#define IMPL_MIN_NEEDSYSWIN
Definition: winproc.cxx:61
void EndAutoScroll()
Definition: window2.cxx:332
SAL_DLLPRIVATE bool ImplIsFloatingWindow() const
Definition: window2.cxx:911
constexpr sal_uInt16 KEY_MOD1
Definition: keycodes.hxx:31
bool ImplCallPreNotify(NotifyEvent &rEvt)
Definition: winproc.cxx:63
sal_uInt64 GetDoubleClickTime() const
bool mbMouseButtonUp
Definition: window.h:317
vcl::Cursor * mpCursor
Definition: window.h:256
void setWidth(tools::Long nWidth)
CommandEventId
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
static void NotifyAllWindows(DataChangedEvent &rDCEvt)
Notify all windows that the application has changed data.
Definition: svapp.cxx:751
static void ImplHandleClose(const vcl::Window *pWindow)
Definition: winproc.cxx:1935
static void ImplHandleInputLanguageChange(vcl::Window *pWindow)
Definition: winproc.cxx:2150
void ImplHandleResize(vcl::Window *pWindow, tools::Long nNewWidth, tools::Long nNewHeight)
Definition: winproc.cxx:1640
SalFrameGeometry GetGeometry() const
void CompatLoseFocus()
Definition: window.cxx:3899
std::unique_ptr< ContentProperties > pData
static bool ImplHandleExtTextInput(vcl::Window *pWindow, const OUString &rText, const ExtTextInputAttr *pTextAttr, sal_Int32 nCursorPos, sal_uInt16 nCursorFlags)
Definition: winproc.cxx:1120
const Link< SystemWindow &, void > & GetCloseHdl() const
Definition: syswin.cxx:1036
tools::Long getWidth() const
ImplSVAppData maAppData
Definition: svdata.hxx:391
SAL_DLLPRIVATE void ImplCallMouseMove(sal_uInt16 nMouseCode, bool bModChanged=false)
Definition: mouse.cxx:135
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2860
static bool StartExtHelp()
Definition: help.cxx:107
sal_uIntPtr sal_uLong
long Long
static void ImplHandleSalSurroundingTextRequest(vcl::Window *pWindow, SalSurroundingTextRequestEvent *pEvt)
Definition: winproc.cxx:2259
bool ImplWindowFrameProc(vcl::Window *_pWindow, SalEvent nEvent, const void *pEvent)
Definition: winproc.cxx:2361
const StyleSettings & GetStyleSettings() const
static bool ImplHandleSalMouseButtonUp(vcl::Window *pWindow, SalMouseEvent const *pEvent)
Definition: winproc.cxx:2059
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:724
VclPtr< PopupMenu > mpActivePopupMenu
Definition: svdata.hxx:145
static void ImplHandleSalKeyMod(vcl::Window *pWindow, SalKeyModEvent const *pEvent)
Definition: winproc.cxx:2115
bool mbStartFocusState
Definition: window.h:164
tools::Long GetOutOffXPixel() const
Definition: outdev.hxx:445
SAL_DLLPRIVATE void ImplCallMove()
Definition: event.cxx:529
static void ImplHandleExtTextInputPos(vcl::Window *pWindow, tools::Rectangle &rRect, tools::Long &rInputWidth, bool *pVertical)
Definition: winproc.cxx:1230
virtual Size GetSizePixel() const
Definition: window.cxx:2400
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:901
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:563
tools::Long mnBoundHeight
Definition: salwtype.hxx:147
static MouseEventModifiers ImplGetMouseButtonMode(SalMouseEvent const *pEvent)
Definition: winproc.cxx:2014
sal_uInt16 mnButton
Definition: salwtype.hxx:110
static void ImplHandleMoveResize(vcl::Window *pWindow, tools::Long nNewWidth, tools::Long nNewHeight)
Definition: winproc.cxx:1739
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Post a user event to the default window.
Definition: svapp.cxx:1016
sal_uInt16 GetCode() const
Definition: keycod.hxx:51
virtual void Deactivate()
Definition: window.cxx:1838
tools::Long GetWidth() const
bool mbRequestingHelp
Definition: svdata.hxx:299
bool mbHasFocus
Definition: window.h:158
constexpr sal_uInt16 KEY_F6
Definition: keycodes.hxx:88
bool HandleMenuHighlightEvent(Menu *pMenu, sal_uInt16 nEventId) const
Definition: menu.cxx:2620
static bool ImplHandleInputContextChange(vcl::Window *pWindow)
Definition: winproc.cxx:1276
void PaintImmediately()
Definition: paint.cxx:1288
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:421
VclPtr< VirtualDevice > mpBuffer
Buffer for the double-buffering.
Definition: window.h:177
constexpr sal_uInt16 KEY_DECIMAL
Definition: keycodes.hxx:150
sal_uInt16 mnCode
Definition: salwtype.hxx:138
MouseEventModifiers
Definition: event.hxx:76
bool mbMouseIn
Definition: window.h:160
bool mbMinimized
Definition: window.h:163
sal_uInt16 mnCode
Definition: salwtype.hxx:118
bool mbExtHelpMode
Definition: svdata.hxx:293
SAL_DLLPRIVATE ImplWinData * ImplGetWinData() const
Definition: window.cxx:1211
bool mbCommand
Definition: window.h:317
constexpr sal_uInt16 KEY_F1
Definition: keycodes.hxx:83
bool IsEmpty() const
#define SAL_MAX_UINT32
static UITestLogger & getInstance()
Definition: logger.cxx:616
static bool ImplCallWheelCommand(const VclPtr< vcl::Window > &pWindow, const Point &rPos, const CommandWheelData *pWheelData)
Definition: winproc.cxx:1283
WinBits const WB_OWNERDRAWDECORATION
const Size & GetSize() const
Definition: cursor.hxx:85
vcl::Window * GetWindow() const
Definition: event.hxx:303
HelpEventMode
Definition: event.hxx:182
static void ImplCallEventListenersApplicationDataChanged(void *pData)
Send event to all VCL application event listeners.
Definition: svapp.cxx:770
GestureEventType meEventType
Definition: salwtype.hxx:270
bool IsVertical() const
Definition: font/font.cxx:689
static void ImplHandleMouseHelpRequest(vcl::Window *pChild, const Point &rMousePos)
Definition: winproc.cxx:161
sal_uInt16 GetButtons() const
Definition: event.hxx:144
bool mbInternalDragGestureRecognizer
Definition: window.h:176
SAL_DLLPRIVATE void ReMirror(Point &rPoint) const
Definition: outdev.cxx:603
tools::Long Left() const
static void Yield()
Process the next event.
Definition: svapp.cxx:526
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool mbSetKeyboardHelp
Definition: svdata.hxx:297
VclPtr< vcl::Window > mpMouseMoveWin
Definition: window.h:135
A helper class that calls Application::ReleaseSolarMutex() in its constructor and restores the mutex ...
Definition: svapp.hxx:1416
bool mbImmediateUpdate
Definition: salwtype.hxx:148
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:272
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1931
static void ImplHandleSalExtTextInputPos(vcl::Window *pWindow, SalExtTextInputPosEvent *pEvt)
Definition: winproc.cxx:2203
MouseSettingsOptions GetOptions() const
sal_uInt16 mnMouseCode
Definition: window.h:156
constexpr sal_uInt16 KEY_F2
Definition: keycodes.hxx:84
virtual void Start() override
Activates the timer task.
Definition: idle.cxx:34
VclEventId
Definition: vclevent.hxx:37
bool mbKeyInput
Definition: window.h:317
bool mbFloatWin
Definition: window.h:317
static void ContextMenuEventLink(void *pCEvent, void *)
Definition: winproc.cxx:253
DataChangedEventType
Definition: event.hxx:335
static void Quit()
Quit the program.
Definition: svapp.cxx:536
sal_uInt16 GetModifier() const
Definition: keycod.hxx:54
FloatWinPopupFlags GetPopupModeFlags() const
Definition: floatwin.hxx:147
static MouseEventModifiers ImplGetMouseMoveMode(SalMouseEvent const *pEvent)
Definition: winproc.cxx:2002
Application * GetpApp()
Definition: svapp.cxx:149
AutoTimer * mpTrackTimer
Definition: svdata.hxx:255
static sal_uInt16 GetStartDragCode()
sal_uInt16 nCode
const tools::Rectangle * GetCursorRect() const
Definition: window.cxx:2132
tools::Long mnY
Definition: salwtype.hxx:274
bool mbSysWin
Definition: window.h:317
SAL_DLLPRIVATE PointerStyle ImplGetMousePointer() const
Definition: mouse.cxx:93
#define MOUSE_LEFT
Definition: event.hxx:99
virtual Selection GetSurroundingTextSelection() const
Definition: window.cxx:3791
const vcl::Font & GetFont() const
Definition: inputctx.hxx:55
CommandWheelMode
tools::Long mnExtWidth
Definition: salwtype.hxx:185
static bool ImplHandleKey(vcl::Window *pWindow, MouseNotifyEvent nSVEvent, sal_uInt16 nKeyCode, sal_uInt16 nCharCode, sal_uInt16 nRepeat, bool bForward)
Definition: winproc.cxx:850
constexpr OUStringLiteral aData
constexpr sal_uInt16 KEY_CONTEXTMENU
Definition: keycodes.hxx:146
const Point & GetPos() const
Definition: cursor.hxx:82
static void KillOwnPopups(vcl::Window const *pWindow)
Definition: winproc.cxx:1626
static bool ImplHandleSalMouseLeave(vcl::Window *pWindow, SalMouseEvent const *pEvent)
Definition: winproc.cxx:2030
bool CompatPreNotify(NotifyEvent &rNEvt)
Definition: window.cxx:3923
const InputContext & GetInputContext() const
Definition: window2.cxx:1062
tools::Long getHeight() const
bool mbFrame
Definition: window.h:317
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:73
const OUString & getNumDecimalSep() const
static void ImplHandleUserEvent(ImplSVEvent *pSVEvent)
Definition: winproc.cxx:1989
std::vector< VclPtr< Dialog > > mpExecuteDialogs
Stack of dialogs that are Execute()'d - the last one is the top most one.
Definition: svdata.hxx:252
void Justify()
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight)=0
virtual void SetPointer(PointerStyle ePointerStyle)=0
virtual bool DeleteSurroundingText(const Selection &rSelection)
Definition: window.cxx:3820
VclPtr< vcl::Window > mpCaptureWin
Definition: svdata.hxx:249
bool IsRTLEnabled() const
Definition: outdev.hxx:1360
bool mbCall
Definition: svdata.hxx:456
tools::Long GetStartDragHeight() const
VclPtr< vcl::Window > mpLastFocusWindow
Definition: window.h:241
#define DBG_ASSERT(sCon, aError)
int i
sal_uInt64 mnLastInputTime
Definition: svdata.hxx:147
virtual OUString GetSurroundingText() const
Definition: window.cxx:3786
tools::Long mnBoundWidth
Definition: salwtype.hxx:146
tools::Long mnLastMouseY
Definition: window.h:145
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
Definition: stacking.cxx:420
tools::Long mnLastMouseWinY
Definition: window.h:151
MouseMiddleButtonAction GetMiddleButtonAction() const
tools::Long GetOutputHeightPixel() const
Definition: outdev.hxx:444
bool HandleMenuDeActivateEvent(Menu *pMenu) const
Definition: menu.cxx:2605
bool mbQuickHelp
Definition: svdata.hxx:296
bool mbExtHelp
Definition: svdata.hxx:292
bool IsAccelKey(const vcl::KeyCode &rKeyCode)
Definition: accmgr.cxx:91
tools::Long mnCursorBoundWidth
Definition: salwtype.hxx:222
SAL_DLLPRIVATE void ImplSetMouseDown()
Definition: floatwin.hxx:113
SAL_DLLPRIVATE void ImplHide()
Definition: cursor.cxx:291
bool IsPresentationMode() const
Definition: wrkwin.hxx:89
static void SetSettings(const AllSettings &rSettings)
Sets the application's settings and notifies all windows of the change.
Definition: svapp.cxx:630
std::unique_ptr< tools::Rectangle[]> mpCompositionCharRects
Definition: window.h:110
sal_Int32 mnCursorPos
Definition: salwtype.hxx:175
Link< void *, void > maLink
Definition: svdata.hxx:453
VclPtr< vcl::Window > mpLastWheelWindow
Definition: svdata.hxx:258
static void DelayedCloseEventLink(void *pCEvent, void *)
Definition: winproc.cxx:1920
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
Definition: virdev.cxx:407
static bool ImplHandleSalMouseButtonDown(vcl::Window *pWindow, SalMouseEvent const *pEvent)
Definition: winproc.cxx:2046
SAL_DLLPRIVATE bool ImplIsAntiparallel() const
Definition: outdev.cxx:587
Size GetOutputSize() const
Definition: outdev.hxx:450
SAL_DLLPRIVATE void ImplNotifyKeyMouseCommandEventListeners(NotifyEvent &rNEvt)
Definition: event.cxx:379
static void ImplHandleSalSettings(SalEvent nEvent)
Definition: winproc.cxx:2160
tools::Long mnCursorBoundHeight
Definition: salwtype.hxx:223
static void ImplActivateFloatingWindows(vcl::Window const *pWindow, bool bActive)
Definition: winproc.cxx:1745
void logKeyInput(VclPtr< vcl::Window > const &xUIElement, const KeyEvent &rEvent)
Definition: logger.cxx:195
virtual bool HasMirroredGraphics() const
Definition: outdev.cxx:635
bool mbInMouseMove
Definition: window.h:159
static void ImplHandleSalQueryCharPosition(vcl::Window *pWindow, SalQueryCharPositionEvent *pEvt)
Definition: winproc.cxx:2318
bool HandleMenuActivateEvent(Menu *pMenu) const
Definition: menu.cxx:2589
tools::Long Width() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel(tools::Long nWidth) const
Convert a logical width to a width in units of device pixels.
Definition: map.cxx:344
tools::Long mnBeforeLastMouseY
Definition: window.h:147
tools::Long mnDelta
Definition: salwtype.hxx:160
SAL_DLLPRIVATE bool ImplIsMouseDown() const
Definition: floatwin.hxx:114
static bool GetLayoutRTL()
bool IsInModalMode() const
A window is in modal mode if one of its children or subchildren is a running modal window (a modal di...
Definition: window.cxx:3587
virtual void Start() override
Activates the timer task.
Definition: timer.cxx:83
SalFrameGeometry maGeometry
absolute, unmirrored values
Definition: salframe.hxx:127
tools::Long mnBoundX
Definition: salwtype.hxx:144
SAL_DLLPRIVATE void ImplShow()
Definition: cursor.cxx:286
tools::Long GetDoubleClickHeight() const
static bool ImplHandleMouseFloatMode(vcl::Window *pChild, const Point &rMousePos, sal_uInt16 nCode, MouseNotifyEvent nSVEvent, bool bMouseLeave)
Definition: winproc.cxx:68
static bool EndExtHelp()
Definition: help.cxx:125
vcl::Cursor * GetCursor() const
Definition: window2.cxx:1203
tools::Long mnCompositionCharRects
Definition: window.h:111
static bool HandleKey(VclEventId nEvent, vcl::Window *pWin, KeyEvent *pKeyEvent)
Handle keypress event.
Definition: svapp.cxx:809
bool mbDockWin
Definition: window.h:317
bool mbMouseOver
Definition: window.h:118
SAL_DLLPRIVATE FloatingWindow * ImplFindLastLevelFloat()
Definition: floatwin.cxx:594
tools::Long mnLastMouseWinX
Definition: window.h:150
const AllSettings & GetSettings() const
Definition: outdev.hxx:418
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
constexpr sal_uInt16 KEY_HELP
Definition: keycodes.hxx:148
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:232
VclPtr< vcl::Window > mpClientWindow
Definition: window.h:231
static bool ImplHandleShowDialog(vcl::Window *pWindow, ShowDialogId nDialogId)
Definition: winproc.cxx:2223
SAL_DLLPRIVATE bool ImplIsFloatPopupModeWindow(const vcl::Window *pWindow)
Definition: floatwin.cxx:611
sal_uInt16 mnCharCode
Definition: salwtype.hxx:119
sal_uInt16 GetModifier() const
Definition: event.hxx:153
tools::Long Top() const
constexpr sal_uInt16 KEY_MOD2
Definition: keycodes.hxx:32
bool mbContextHelp
Definition: svdata.hxx:291
sal_uInt16 mnClickCount
Definition: window.h:154
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2807
FloatWinPopupFlags
Definition: floatwin.hxx:31
void GrabFocus()
Definition: window.cxx:2978
constexpr sal_uInt16 KEY_F10
Definition: keycodes.hxx:92
vcl::Window * GetParent() const
Definition: window2.cxx:1097
VclPtr< vcl::Window > mpTrackWin
Definition: svdata.hxx:254
VclPtr< vcl::Window > mpFirstOverlap
Definition: window.h:236
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
Definition: window.cxx:2850
bool mbVertical
Definition: window.h:108
static void ImplHandleLoseFocus(vcl::Window *pWindow)
Definition: winproc.cxx:1876
SalFrame * mpFrame
Definition: window.h:226
SAL_DLLPRIVATE void ImplCallDeactivateListeners(vcl::Window *)
Definition: window.cxx:3385
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
exports com.sun.star.chart2. data
std::unique_ptr< ExtTextInputAttr[]> mpExtOldAttrAry
Definition: window.h:104
SalEvent
Definition: salwtype.hxx:41
tools::ULong nWidth
Definition: salgeom.hxx:32
tools::Long GetOutOffYPixel() const
Definition: outdev.hxx:446
static void ImplHandleSurroundingTextRequest(vcl::Window *pWindow, OUString &rText, Selection &rSelRange)
Definition: winproc.cxx:2238
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1039
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
static void MergeSystemSettings(AllSettings &rSettings)
Set the settings object to the platform/desktop environment system settings.
Definition: svapp.cxx:611
VclPtr< vcl::Window > mpNext
Definition: window.h:239
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:828
static bool acceptableWheelScrollTarget(const vcl::Window *pMouseWindow)
Definition: winproc.cxx:1304
static void ImplHandleGetFocus(vcl::Window *pWindow)
Definition: winproc.cxx:1860
bool ImplHandleMouseEvent(const VclPtr< vcl::Window > &xWindow, MouseNotifyEvent nSVEvent, bool bMouseLeave, tools::Long nX, tools::Long nY, sal_uInt64 nMsgTime, sal_uInt16 nCode, MouseEventModifiers nMode)
Definition: winproc.cxx:264
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1804
bool mbToolBox
Definition: window.h:317
tools::Long mnBeforeLastMouseX
Definition: window.h:146
WinBits const WB_SIZEABLE
static bool ImplHandleLongPress(vcl::Window *pWindow, const SalLongPressEvent &rEvt)
Definition: winproc.cxx:1574
SAL_DLLPRIVATE vcl::Window * ImplGetFirstOverlapWindow()
Definition: window2.cxx:880
bool mbMouseButtonDown
Definition: window.h:317
Idle maResizeIdle
Definition: window.h:130
bool mbWaitSystemResize
Definition: window.h:317
static sal_uInt16 GetContextMenuCode()
ShowDialogId
bool mbExtTextInput
Definition: window.h:317
SalFrame * ImplGetFrame() const
Definition: window2.cxx:848
SalWheelMouseEvent maLastWheelEvent
Definition: svdata.hxx:259
static bool ImplHandleSwipe(vcl::Window *pWindow, const SalSwipeEvent &rEvt)
Definition: winproc.cxx:1548
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
static void ImplHandlePaint(vcl::Window *pWindow, const tools::Rectangle &rBoundRect, bool bImmediateUpdate)
Definition: winproc.cxx:1608
bool mbCallMove
Definition: window.h:317
static bool shouldReusePreviousMouseWindow(const SalWheelMouseEvent &rPrevEvt, const SalWheelMouseEvent &rEvt)
Definition: winproc.cxx:1315
bool IsShift() const
Definition: keycod.hxx:56
tools::Long mnLastMouseX
Definition: window.h:144
VclPtr< vcl::Window > mpExtTextInputWin
Definition: svdata.hxx:253
void * mpData
Definition: svdata.hxx:452
bool mbBalloonHelp
Definition: svdata.hxx:295
VclPtr< vcl::Window > mpMouseDownWin
Definition: window.h:136
IMPL_LINK_NOARG(vcl::Window, ImplAsyncFocusHdl, void *, void)
Definition: winproc.cxx:1763
#define SAL_WARN_IF(condition, area, stream)
bool mbActive
Definition: window.h:317
static void ImplHandleSurroundingTextSelectionChange(vcl::Window *pWindow, sal_uLong nStart, sal_uLong nEnd)
Definition: winproc.cxx:2299
static bool ImplHandleSalMouseMove(vcl::Window *pWindow, SalMouseEvent const *pEvent)
Definition: winproc.cxx:2038
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
SAL_DLLPRIVATE void ImplInvalidateOverlapFrameRegion(const vcl::Region &rRegion)
Definition: paint.cxx:747
bool mbAllResize
Definition: window.h:317
tools::Long Min() const
static bool ImplCallCommand(const VclPtr< vcl::Window > &pChild, CommandEventId nEvt, void const *pData=nullptr, bool bMouse=false, Point const *pPos=nullptr)
Definition: winproc.cxx:199
bool IsVisible() const
Definition: window2.cxx:1102
ImplSVEvent * mnFocusId
Definition: window.h:142
VclPtr< vcl::Window > mpAutoScrollWin
Definition: svdata.hxx:257
sal_uInt64 mnMouseDownTime
Definition: window.h:153
bool mbStartDragCalled
Definition: window.h:161
::OutputDevice const * GetOutDev() const
Definition: window.cxx:578
sal_Unicode GetCharCode() const
Definition: event.hxx:53
bool IsMod1() const
Definition: keycod.hxx:58
bool mbKeyUp
Definition: window.h:317
tools::Long GetCursorSize() const
tools::Long mnCursorBoundY
Definition: salwtype.hxx:221
SAL_DLLPRIVATE void ImplNotifyIconifiedState(bool bIconified)
Definition: window.cxx:3626
SAL_DLLPRIVATE Point ImplFrameToOutput(const Point &rPos)
Definition: window2.cxx:942
PanningOrientation meOrientation
Definition: salwtype.hxx:271
static vcl::Window * ImplGetKeyInputWindow(vcl::Window *pWindow)
Definition: winproc.cxx:796
const MouseSettings & GetMouseSettings() const
QPRO_FUNC_TYPE nType
tools::ULong nHeight
Definition: salgeom.hxx:32
const Point & GetPosPixel() const
Definition: event.hxx:120
static SAL_DLLPRIVATE void ImplUpdateAllFontData(bool bNewFontLists)
virtual void OverrideSystemSettings(AllSettings &rSettings)
Sets user settings in settings object to override system settings.
Definition: svapp.cxx:607
static sal_uInt64 GetSystemTicks()
tools::Long mnNotchDelta
Definition: salwtype.hxx:161
SAL_DLLPRIVATE bool ImplIsWindowOrChild(const vcl::Window *pWindow, bool bSystemWindow=false) const
Definition: stacking.cxx:703
VclPtr< vcl::Window > mpFirstChild
Definition: window.h:234
SAL_DLLPRIVATE bool ImplSetClipFlag(bool bSysObjOnlySmaller=false)
sal_uInt16 GetFullCode() const
Definition: keycod.hxx:48
virtual void KeyUp(const KeyEvent &rKEvt)
Definition: window.cxx:1821
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:251
static void ImplHandleMove(vcl::Window *pWindow)
Definition: winproc.cxx:1714
sal_uInt16 mnId
Definition: salwtype.hxx:126
sal_uInt16 GetRepeat() const
Definition: event.hxx:55
bool IsDisposed() const
Definition: window.cxx:142
sal_uInt16 mnRepeat
Definition: salwtype.hxx:120
SAL_DLLPRIVATE FloatingWindow * ImplFloatHitTest(vcl::Window *pReference, const Point &rPos, bool &rbHitTestInsideRect)
Definition: floatwin.cxx:553
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
Definition: map.cxx:406
tools::Long GetHeight() const
static void ImplSetMousePointer(vcl::Window const *pChild)
Definition: winproc.cxx:191
WindowType GetType() const
Definition: window2.cxx:974
sal_uInt8 mnCursorFlags
Definition: salwtype.hxx:176
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
bool IsEnabled() const
Definition: window2.cxx:1122
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:408
tools::Long mnCursorBoundX
Definition: salwtype.hxx:220
#define SAL_WARN(area, stream)
static void ImplHandleSalDeleteSurroundingTextRequest(vcl::Window *pWindow, SalSurroundingTextSelectionChangeEvent *pEvt)
Definition: winproc.cxx:2282
ImplAccelManager * mpAccelMgr
Definition: svdata.hxx:139
ExtTextInputAttr
WinBits GetStyle() const
Definition: window2.cxx:953
tools::Long GetCursorExtTextInputWidth() const
Definition: window.cxx:2139
#define DBG_TESTSOLARMUTEX()
static void ImplHandleStartReconversion(vcl::Window *pWindow)
Definition: winproc.cxx:2311
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2801
#define MOUSE_MIDDLE
Definition: event.hxx:100
ModKeyFlags mnModKeyCode
Definition: salwtype.hxx:139
WinBits const WB_MOVEABLE
bool mbCallResize
Definition: window.h:317
static bool ImplHandleEndExtTextInput()
Definition: winproc.cxx:1211
constexpr sal_uInt16 KEY_MOD3
Definition: keycodes.hxx:33
StartTrackingFlags mnTrackFlags
Definition: svdata.hxx:261
bool HandleMenuCommandEvent(Menu *pMenu, sal_uInt16 nEventId) const
Definition: menu.cxx:2645
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1922
constexpr sal_uInt16 KEY_SHIFT
Definition: keycodes.hxx:30
bool IsReallyVisible() const
Definition: window2.cxx:1107
static bool ImplHandleMenuEvent(vcl::Window const *pWindow, SalMenuEvent *pEvent, SalEvent nEvent)
Definition: winproc.cxx:2072
static sal_uInt16 GetContextMenuClicks()
ImplPaintFlags mnPaintFlags
Definition: window.h:298
VclPtr< vcl::Window > mpFocusWin
Definition: window.h:134
SAL_DLLPRIVATE ImplFrameData * ImplGetFrameData()
Definition: window2.cxx:843
css::uno::Reference< css::uno::XInterface > mxDNDListenerContainer
Definition: window.h:392
void * mpMenu
Definition: salwtype.hxx:127
ImplFrameData * mpFrameData
Definition: window.h:225
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly...
Definition: window.cxx:3869
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1868
#define MOUSE_RIGHT
Definition: event.hxx:101
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:950
MouseNotifyEvent
Definition: event.hxx:277
static bool ImplHandleWheelEvent(vcl::Window *pWindow, const SalWheelMouseEvent &rEvt)
Definition: winproc.cxx:1522
const ExtTextInputAttr * mpTextAttr
Definition: salwtype.hxx:174
tools::Long GetOutputWidthPixel() const
Definition: outdev.hxx:443
bool isDisposed() const
VclPtr< vcl::Window > mpFrameWindow
Definition: window.h:228
bool mbKeyboardHelp
Definition: svdata.hxx:298
void setMin(tools::Long nMin)
static bool ImplHandleGestureEvent(vcl::Window *pWindow, const SalGestureEvent &rEvent)
Definition: winproc.cxx:1602
sal_uInt16 mnFirstMouseCode
Definition: window.h:155
tools::Long mnX
Definition: salwtype.hxx:273
tools::Long GetDoubleClickWidth() const
void ImplDestroyHelpWindow(bool bUpdateHideTime)
Definition: help.cxx:551
MouseMiddleButtonAction
Definition: settings.hxx:75
tools::Long mnFirstMouseY
Definition: window.h:149
ImplSVWinData * mpWinData
Definition: svdata.hxx:394
void setMax(tools::Long nMax)
bool IsMod2() const
Definition: keycod.hxx:60
void SetKeyboardActivated(bool bKeyboard)
Definition: event.hxx:207