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