1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/event.hxx>
#include <vcl/window.hxx>
#include <vcl/dockwin.hxx>
#include <vcl/layout.hxx>
#include <vcl/opengl/OpenGLWrapper.hxx>
#include <window.h>
#include <svdata.hxx>
#include <salframe.hxx>
#include <config_features.h>
#include <com/sun/star/awt/MouseEvent.hpp>
#include <com/sun/star/awt/KeyModifier.hpp>
#include <com/sun/star/awt/MouseButton.hpp>
#include <comphelper/scopeguard.hxx>
namespace vcl {
void Window::DataChanged( const DataChangedEvent& )
{
}
void Window::NotifyAllChildren( DataChangedEvent& rDCEvt )
{
CompatDataChanged( rDCEvt );
vcl::Window* pChild = mpWindowImpl->mpFirstChild;
while ( pChild )
{
pChild->NotifyAllChildren( rDCEvt );
pChild = pChild->mpWindowImpl->mpNext;
}
}
bool Window::PreNotify( NotifyEvent& rNEvt )
{
bool bDone = false;
if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
bDone = mpWindowImpl->mpParent->CompatPreNotify( rNEvt );
if ( !bDone )
{
if( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS )
{
bool bCompoundFocusChanged = false;
if ( mpWindowImpl->mbCompoundControl && !mpWindowImpl->mbCompoundControlHasFocus && HasChildPathFocus() )
{
mpWindowImpl->mbCompoundControlHasFocus = true;
bCompoundFocusChanged = true;
}
if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
CallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
}
else if( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS )
{
bool bCompoundFocusChanged = false;
if ( mpWindowImpl->mbCompoundControl && mpWindowImpl->mbCompoundControlHasFocus && !HasChildPathFocus() )
{
mpWindowImpl->mbCompoundControlHasFocus = false ;
bCompoundFocusChanged = true;
}
if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
CallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
}
// #82968# mouse and key events will be notified after processing ( in ImplNotifyKeyMouseCommandEventListeners() )!
// see also ImplHandleMouseEvent(), ImplHandleKey()
}
return bDone;
}
bool Window::Notify( NotifyEvent& rNEvt )
{
bool bRet = false;
if (IsDisposed())
return false;
// check for docking window
// but do nothing if window is docked and locked
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
if( pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ) )
{
if ( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN )
{
const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
if ( pMEvt->IsLeft() )
{
if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
{
// ctrl double click toggles floating mode
pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
return true;
}
else if ( pMEvt->GetClicks() == 1 && bHit)
{
// allow start docking during mouse move
pWrapper->ImplEnableStartDocking();
return true;
}
}
}
else if ( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
{
const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
if ( pMEvt->IsLeft() )
{
// check if a single click initiated this sequence ( ImplStartDockingEnabled() )
// check if window is docked and
if( pWrapper->ImplStartDockingEnabled() && !pWrapper->IsFloatingMode() &&
!pWrapper->IsDocking() && bHit )
{
Point aPos = pMEvt->GetPosPixel();
vcl::Window* pWindow = rNEvt.GetWindow();
if ( pWindow != this )
{
aPos = pWindow->OutputToScreenPixel( aPos );
aPos = ScreenToOutputPixel( aPos );
}
pWrapper->ImplStartDocking( aPos );
}
return true;
}
}
else if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
{
const vcl::KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
rKey.IsShift() && rKey.IsMod1() )
{
pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
/* At this point the floating toolbar frame does not have the
* input focus since these frames don't get the focus per default
* To enable keyboard handling of this toolbar set the input focus
* to the frame. This needs to be done with ToTop since GrabFocus
* would not notice any change since "this" already has the focus.
*/
if( pWrapper->IsFloatingMode() )
ToTop( ToTopFlags::GrabFocusOnly );
return true;
}
}
}
// manage the dialogs
if ( (GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
{
// if the parent also has dialog control activated, the parent takes over control
if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) || (rNEvt.GetType() == MouseNotifyEvent::KEYUP) )
{
if ( ImplIsOverlapWindow() ||
((getNonLayoutRealParent(this)->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) != WB_DIALOGCONTROL) )
{
bRet = ImplDlgCtrl( *rNEvt.GetKeyEvent(), rNEvt.GetType() == MouseNotifyEvent::KEYINPUT );
}
}
else if ( (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS) || (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS) )
{
ImplDlgCtrlFocusChanged( rNEvt.GetWindow(), rNEvt.GetType() == MouseNotifyEvent::GETFOCUS );
if ( (rNEvt.GetWindow() == this) && (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS) &&
!(GetStyle() & WB_TABSTOP) && !(mpWindowImpl->mnDlgCtrlFlags & DialogControlFlags::WantFocus) )
{
sal_uInt16 n = 0;
vcl::Window* pFirstChild = ImplGetDlgWindow( n, GetDlgWindowType::First );
if ( pFirstChild )
pFirstChild->ImplControlFocus();
}
}
}
if ( !bRet )
{
if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
bRet = mpWindowImpl->mpParent->CompatNotify( rNEvt );
}
return bRet;
}
void Window::CallEventListeners( sal_uLong nEvent, void* pData )
{
VclWindowEvent aEvent( this, nEvent, pData );
VclPtr<vcl::Window> xWindow = this;
Application::ImplCallEventListeners( aEvent );
if ( xWindow->IsDisposed() )
return;
if (!mpWindowImpl->maEventListeners.empty())
{
// Copy the list, because this can be destroyed when calling a Link...
std::vector<Link<VclWindowEvent&,void>> aCopy( mpWindowImpl->maEventListeners );
// we use an iterating counter/flag and a set of deleted Link's to avoid O(n^2) behaviour
mpWindowImpl->mnEventListenersIteratingCount++;
auto& rWindowImpl = *mpWindowImpl;
comphelper::ScopeGuard aGuard(
[&rWindowImpl, &xWindow]()
{
if (!xWindow->IsDisposed())
{
rWindowImpl.mnEventListenersIteratingCount--;
if (rWindowImpl.mnEventListenersIteratingCount == 0)
rWindowImpl.maEventListenersDeleted.clear();
}
}
);
for ( Link<VclWindowEvent&,void>& rLink : aCopy )
{
if (xWindow->IsDisposed()) break;
// check this hasn't been removed in some re-enterancy scenario fdo#47368
if( rWindowImpl.maEventListenersDeleted.find(rLink) == rWindowImpl.maEventListenersDeleted.end() )
rLink.Call( aEvent );
}
}
while ( xWindow )
{
if ( xWindow->IsDisposed() )
return;
auto& rWindowImpl = *xWindow->mpWindowImpl;
if (!rWindowImpl.maChildEventListeners.empty())
{
// Copy the list, because this can be destroyed when calling a Link...
std::vector<Link<VclWindowEvent&,void>> aCopy( rWindowImpl.maChildEventListeners );
// we use an iterating counter/flag and a set of deleted Link's to avoid O(n^2) behaviour
rWindowImpl.mnChildEventListenersIteratingCount++;
comphelper::ScopeGuard aGuard(
[&rWindowImpl, &xWindow]()
{
if (!xWindow->IsDisposed())
{
rWindowImpl.mnChildEventListenersIteratingCount--;
if (rWindowImpl.mnChildEventListenersIteratingCount == 0)
rWindowImpl.maChildEventListenersDeleted.clear();
}
}
);
for ( Link<VclWindowEvent&,void>& rLink : aCopy )
{
if (xWindow->IsDisposed())
return;
// Check this hasn't been removed in some re-enterancy scenario fdo#47368.
if( rWindowImpl.maChildEventListenersDeleted.find(rLink) == rWindowImpl.maChildEventListenersDeleted.end() )
rLink.Call( aEvent );
}
}
if ( xWindow->IsDisposed() )
return;
xWindow = xWindow->GetParent();
}
}
void Window::FireVclEvent( VclSimpleEvent& rEvent )
{
Application::ImplCallEventListeners(rEvent);
}
void Window::AddEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
mpWindowImpl->maEventListeners.push_back( rEventListener );
}
void Window::RemoveEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
if (mpWindowImpl)
{
auto& rListeners = mpWindowImpl->maEventListeners;
rListeners.erase( std::remove(rListeners.begin(), rListeners.end(), rEventListener ), rListeners.end() );
if (mpWindowImpl->mnEventListenersIteratingCount)
mpWindowImpl->maEventListenersDeleted.insert(rEventListener);
}
}
void Window::AddChildEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
mpWindowImpl->maChildEventListeners.push_back( rEventListener );
}
void Window::RemoveChildEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
if (mpWindowImpl)
{
auto& rListeners = mpWindowImpl->maChildEventListeners;
rListeners.erase( std::remove(rListeners.begin(), rListeners.end(), rEventListener ), rListeners.end() );
if (mpWindowImpl->mnChildEventListenersIteratingCount)
mpWindowImpl->maChildEventListenersDeleted.insert(rEventListener);
}
}
ImplSVEvent * Window::PostUserEvent( const Link<void*,void>& rLink, void* pCaller, bool bReferenceLink )
{
ImplSVEvent* pSVEvent = new ImplSVEvent;
pSVEvent->mpData = pCaller;
pSVEvent->maLink = rLink;
pSVEvent->mpWindow = this;
pSVEvent->mbCall = true;
if (bReferenceLink)
{
// Double check that this is indeed a vcl::Window instance.
assert(dynamic_cast<vcl::Window *>(
static_cast<vcl::Window *>(rLink.GetInstance())) ==
static_cast<vcl::Window *>(rLink.GetInstance()));
pSVEvent->mpInstanceRef = static_cast<vcl::Window *>(rLink.GetInstance());
}
if ( !mpWindowImpl->mpFrame->PostEvent( pSVEvent ) )
{
delete pSVEvent;
pSVEvent = nullptr;
}
return pSVEvent;
}
void Window::RemoveUserEvent( ImplSVEvent * nUserEvent )
{
SAL_WARN_IF( nUserEvent->mpWindow.get() != this, "vcl",
"Window::RemoveUserEvent(): Event doesn't send to this window or is already removed" );
SAL_WARN_IF( !nUserEvent->mbCall, "vcl",
"Window::RemoveUserEvent(): Event is already removed" );
if ( nUserEvent->mpWindow )
{
nUserEvent->mpWindow = nullptr;
}
nUserEvent->mbCall = false;
}
static MouseEvent ImplTranslateMouseEvent( const MouseEvent& rE, vcl::Window* pSource, vcl::Window* pDest )
{
// the mouse event occurred in a different window, we need to translate the coordinates of
// the mouse cursor within that (source) window to the coordinates the mouse cursor would
// be in the destination window
Point aPos = pSource->OutputToScreenPixel( rE.GetPosPixel() );
return MouseEvent( pDest->ScreenToOutputPixel( aPos ), rE.GetClicks(), rE.GetMode(), rE.GetButtons(), rE.GetModifier() );
}
void Window::ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt )
{
if( rNEvt.GetType() == MouseNotifyEvent::COMMAND )
{
const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
if ( pCEvt->GetCommand() != CommandEventId::ContextMenu )
// non context menu events are not to be notified up the chain
// so we return immediately
return;
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
{
// not interested: The event listeners are already called in ::Command,
// and calling them here a second time doesn't make sense
if ( rNEvt.GetWindow() != this )
{
CommandEvent aCommandEvent;
if ( !pCEvt->IsMouseEvent() )
{
aCommandEvent = *pCEvt;
}
else
{
// the mouse event occurred in a different window, we need to translate the coordinates of
// the mouse cursor within that window to the coordinates the mouse cursor would be in the
// current window
vcl::Window* pSource = rNEvt.GetWindow();
Point aPos = pSource->OutputToScreenPixel( pCEvt->GetMousePosPixel() );
aCommandEvent = CommandEvent( ScreenToOutputPixel( aPos ), pCEvt->GetCommand(), pCEvt->IsMouseEvent(), pCEvt->GetEventData() );
}
CallEventListeners( VCLEVENT_WINDOW_COMMAND, &aCommandEvent );
}
}
}
// #82968# notify event listeners for mouse and key events separately and
// not in PreNotify ( as for focus listeners )
// this allows for processing those events internally first and pass it to
// the toolkit later
VclPtr<vcl::Window> xWindow = this;
if( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
{
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
{
if ( rNEvt.GetWindow() == this )
CallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, const_cast<MouseEvent *>(rNEvt.GetMouseEvent()) );
else
{
MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
CallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, &aMouseEvent );
}
}
}
else if( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONUP )
{
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
{
if ( rNEvt.GetWindow() == this )
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, const_cast<MouseEvent *>(rNEvt.GetMouseEvent()) );
else
{
MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, &aMouseEvent );
}
}
}
else if( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN )
{
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
{
if ( rNEvt.GetWindow() == this )
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, const_cast<MouseEvent *>(rNEvt.GetMouseEvent()) );
else
{
MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, &aMouseEvent );
}
}
}
else if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
{
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
CallEventListeners( VCLEVENT_WINDOW_KEYINPUT, const_cast<KeyEvent *>(rNEvt.GetKeyEvent()) );
}
else if( rNEvt.GetType() == MouseNotifyEvent::KEYUP )
{
if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
CallEventListeners( VCLEVENT_WINDOW_KEYUP, const_cast<KeyEvent *>(rNEvt.GetKeyEvent()) );
}
if ( xWindow->IsDisposed() )
return;
// #106721# check if we're part of a compound control and notify
vcl::Window *pParent = ImplGetParent();
while( pParent )
{
if( pParent->IsCompoundControl() )
{
pParent->ImplNotifyKeyMouseCommandEventListeners( rNEvt );
break;
}
pParent = pParent->ImplGetParent();
}
}
void Window::ImplCallInitShow()
{
mpWindowImpl->mbReallyShown = true;
mpWindowImpl->mbInInitShow = true;
CompatStateChanged( StateChangedType::InitShow );
mpWindowImpl->mbInInitShow = false;
vcl::Window* pWindow = mpWindowImpl->mpFirstOverlap;
while ( pWindow )
{
if ( pWindow->mpWindowImpl->mbVisible )
pWindow->ImplCallInitShow();
pWindow = pWindow->mpWindowImpl->mpNext;
}
pWindow = mpWindowImpl->mpFirstChild;
while ( pWindow )
{
if ( pWindow->mpWindowImpl->mbVisible )
pWindow->ImplCallInitShow();
pWindow = pWindow->mpWindowImpl->mpNext;
}
}
void Window::ImplCallResize()
{
mpWindowImpl->mbCallResize = false;
// OpenGL has a charming feature of black clearing the whole window
// some legacy code eg. the app-menu has the beautiful feature of
// avoiding re-paints when width doesn't change => invalidate all.
#if HAVE_FEATURE_OPENGL
if( OpenGLWrapper::isVCLOpenGLEnabled() )
Invalidate();
// Normally we avoid blanking on re-size unless people might notice:
else
#endif
if( GetBackground().IsGradient() )
Invalidate();
Resize();
// #88419# Most classes don't call the base class in Resize() and Move(),
// => Call ImpleResize/Move instead of Resize/Move directly...
CallEventListeners( VCLEVENT_WINDOW_RESIZE );
}
void Window::ImplCallMove()
{
mpWindowImpl->mbCallMove = false;
if( mpWindowImpl->mbFrame )
{
// update frame position
SalFrame *pParentFrame = nullptr;
vcl::Window *pParent = ImplGetParent();
while( pParent )
{
if( pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame )
{
pParentFrame = pParent->mpWindowImpl->mpFrame;
break;
}
pParent = pParent->GetParent();
}
SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
mpWindowImpl->maPos = Point( g.nX, g.nY );
if( pParentFrame )
{
g = pParentFrame->GetGeometry();
mpWindowImpl->maPos -= Point( g.nX, g.nY );
}
// the client window and all its subclients have the same position as the borderframe
// this is important for floating toolbars where the borderwindow is a floating window
// which has another borderwindow (ie the system floating window)
vcl::Window *pClientWin = mpWindowImpl->mpClientWindow;
while( pClientWin )
{
pClientWin->mpWindowImpl->maPos = mpWindowImpl->maPos;
pClientWin = pClientWin->mpWindowImpl->mpClientWindow;
}
}
Move();
CallEventListeners( VCLEVENT_WINDOW_MOVE );
}
void Window::ImplCallFocusChangeActivate( vcl::Window* pNewOverlapWindow,
vcl::Window* pOldOverlapWindow )
{
ImplSVData* pSVData = ImplGetSVData();
vcl::Window* pNewRealWindow;
vcl::Window* pOldRealWindow;
bool bCallActivate = true;
bool bCallDeactivate = true;
pOldRealWindow = pOldOverlapWindow->ImplGetWindow();
pNewRealWindow = pNewOverlapWindow->ImplGetWindow();
if ( (pOldRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
pOldRealWindow->GetActivateMode() != ActivateModeFlags::NONE )
{
if ( (pNewRealWindow->GetType() == WINDOW_FLOATINGWINDOW) &&
pNewRealWindow->GetActivateMode() == ActivateModeFlags::NONE)
{
pSVData->maWinData.mpLastDeacWin = pOldOverlapWindow;
bCallDeactivate = false;
}
}
else if ( (pNewRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
pNewRealWindow->GetActivateMode() != ActivateModeFlags::NONE )
{
if ( pSVData->maWinData.mpLastDeacWin )
{
if ( pSVData->maWinData.mpLastDeacWin.get() == pNewOverlapWindow )
bCallActivate = false;
else
{
vcl::Window* pLastRealWindow = pSVData->maWinData.mpLastDeacWin->ImplGetWindow();
pSVData->maWinData.mpLastDeacWin->mpWindowImpl->mbActive = false;
pSVData->maWinData.mpLastDeacWin->Deactivate();
if ( pLastRealWindow != pSVData->maWinData.mpLastDeacWin.get() )
{
pLastRealWindow->mpWindowImpl->mbActive = true;
pLastRealWindow->Activate();
}
}
pSVData->maWinData.mpLastDeacWin = nullptr;
}
}
if ( bCallDeactivate )
{
if( pOldOverlapWindow->mpWindowImpl->mbActive )
{
pOldOverlapWindow->mpWindowImpl->mbActive = false;
pOldOverlapWindow->Deactivate();
}
if ( pOldRealWindow != pOldOverlapWindow )
{
if( pOldRealWindow->mpWindowImpl->mbActive )
{
pOldRealWindow->mpWindowImpl->mbActive = false;
pOldRealWindow->Deactivate();
}
}
}
if ( bCallActivate && ! pNewOverlapWindow->mpWindowImpl->mbActive )
{
if( ! pNewOverlapWindow->mpWindowImpl->mbActive )
{
pNewOverlapWindow->mpWindowImpl->mbActive = true;
pNewOverlapWindow->Activate();
}
if ( pNewRealWindow != pNewOverlapWindow )
{
if( ! pNewRealWindow->mpWindowImpl->mbActive )
{
pNewRealWindow->mpWindowImpl->mbActive = true;
pNewRealWindow->Activate();
}
}
}
}
} /* namespace vcl */
NotifyEvent::NotifyEvent( MouseNotifyEvent nEventType, vcl::Window* pWindow,
const void* pEvent )
{
mpWindow = pWindow;
mpData = const_cast<void*>(pEvent);
mnEventType = nEventType;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|