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