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