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