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