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