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