LibreOffice Module vcl (master)  1
svapp.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 <config_features.h>
21 
22 #include <osl/file.hxx>
23 #include <osl/thread.hxx>
24 #include <osl/module.hxx>
25 #include <rtl/ustrbuf.hxx>
26 
27 #include <sal/log.hxx>
28 
29 #include <tools/debug.hxx>
30 #include <tools/time.hxx>
31 #include <tools/stream.hxx>
32 
33 #include <unotools/configmgr.hxx>
34 #include <unotools/resmgr.hxx>
35 #include <unotools/syslocale.hxx>
37 
38 #include <vcl/toolkit/dialog.hxx>
39 #include <vcl/dialoghelper.hxx>
40 #include <vcl/lok.hxx>
41 #include <vcl/toolkit/floatwin.hxx>
42 #include <vcl/settings.hxx>
43 #include <vcl/keycod.hxx>
44 #include <vcl/event.hxx>
45 #include <vcl/vclevent.hxx>
46 #include <vcl/virdev.hxx>
47 #include <vcl/wrkwin.hxx>
48 #include <vcl/svapp.hxx>
49 #include <vcl/cvtgrf.hxx>
50 #include <vcl/toolkit/unowrap.hxx>
51 #include <vcl/timer.hxx>
52 #include <vcl/scheduler.hxx>
53 #include <vcl/skia/SkiaHelper.hxx>
54 
55 #include <salinst.hxx>
56 #include <salframe.hxx>
57 #include <salsys.hxx>
58 #include <svdata.hxx>
60 #include <window.h>
61 #include <accmgr.hxx>
62 #include <strings.hrc>
63 #include <strings.hxx>
64 #if OSL_DEBUG_LEVEL > 0
65 #include <schedulerimpl.hxx>
66 #endif
67 
68 #include <com/sun/star/uno/Reference.h>
69 #include <com/sun/star/awt/XToolkit.hpp>
70 #include <comphelper/lok.hxx>
72 #include <osl/process.h>
73 
74 #include <cassert>
75 #include <limits>
76 #include <string_view>
77 #include <utility>
78 #include <thread>
79 
80 using namespace ::com::sun::star;
81 using namespace ::com::sun::star::uno;
82 
83 namespace {
84 void InitSettings(ImplSVData* pSVData);
85 }
86 
87 // keycodes handled internally by VCL
88 vcl::KeyCode const ReservedKeys[]
89 {
90  vcl::KeyCode(KEY_F1,0) ,
97  vcl::KeyCode(KEY_F6,0) ,
102 #ifdef UNX
103  ,
115 #endif
116 };
117 
118 extern "C" {
119  typedef UnoWrapperBase* (*FN_TkCreateUnoWrapper)();
120 }
121 
123 {
130 
131  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const KeyEvent& rKeyEvent)
132  : mpWin(pWin)
133  , mnEventId(nullptr)
134  , mnEvent(nEvent)
135  , maKeyEvent(rKeyEvent)
136  {}
137  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const MouseEvent& rMouseEvent)
138  : mpWin(pWin)
139  , mnEventId(nullptr)
140  , maMouseEvent(rMouseEvent)
141  , mnEvent(nEvent)
142  {}
143  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const GestureEvent& rGestureEvent)
144  : mpWin(pWin)
145  , mnEventId(nullptr)
146  , mnEvent(nEvent)
147  , maGestureEvent(rGestureEvent)
148  {}
149 };
150 
152 {
153  ImplSVData* pSVData = ImplGetSVData();
154  if ( !pSVData )
155  return nullptr;
156  return pSVData->mpApp;
157 }
158 
160 {
161  // useful for themes at least, perhaps extensions too
162  OUString aVar("LIBO_VERSION"), aValue(LIBO_VERSION_DOTTED);
163  osl_setEnvironment(aVar.pData, aValue.pData);
164 
165  ImplGetSVData()->mpApp = this;
166  m_pCallbackData = nullptr;
167  m_pCallback = nullptr;
168 }
169 
171 {
173  ImplGetSVData()->mpApp = nullptr;
174 }
175 
177 {
178  SAL_WARN("vcl", "Application is a base class and should be overridden.");
179  return EXIT_SUCCESS;
180 }
181 
183 {
185 
186  // call the close handler of the application window
187  if ( pAppWin )
188  return pAppWin->Close();
189  else
190  return true;
191 }
192 
194 {
195 }
196 
198 {
199 }
200 
202 {
203 }
204 
206 {
207 }
208 
210 {
211  return static_cast<sal_uInt16>(osl_getCommandArgCount());
212 }
213 
215 {
216  OUString aParam;
217  osl_getCommandArg( nParam, &aParam.pData );
218  return aParam;
219 }
220 
222 {
223  ImplSVData* pSVData = ImplGetSVData();
224  SAL_WARN_IF( !pSVData->maAppData.mxAppFileName, "vcl", "AppFileName should be set to something after SVMain!" );
225  if ( pSVData->maAppData.mxAppFileName )
226  return *pSVData->maAppData.mxAppFileName;
227 
228  /*
229  * provide a fallback for people without initialized vcl here (like setup
230  * in responsefile mode)
231  */
232  OUString aAppFileName;
233  OUString aExeFileName;
234  osl_getExecutableFile(&aExeFileName.pData);
235 
236  // convert path to native file format
237  osl::FileBase::getSystemPathFromFileURL(aExeFileName, aAppFileName);
238 
239  return aAppFileName;
240 }
241 
243 {
244  switch ( nCategory )
245  {
246  // System has precedence (so do nothing)
249  break;
250  default:
251  Abort("Unknown Error");
252  break;
253  }
254 }
255 
256 void Application::Abort( const OUString& rErrorText )
257 {
258  //HACK: Dump core iff --norestore command line argument is given (assuming
259  // this process is run by developers who are interested in cores, vs. end
260  // users who are not):
261 #if OSL_DEBUG_LEVEL > 0
262  bool dumpCore = true;
263 #else
264  bool dumpCore = false;
265  sal_uInt16 n = GetCommandLineParamCount();
266  for (sal_uInt16 i = 0; i != n; ++i) {
267  if (GetCommandLineParam(i) == "--norestore") {
268  dumpCore = true;
269  break;
270  }
271  }
272 #endif
273 
274  SalAbort( rErrorText, dumpCore );
275 }
276 
278 {
279  return SAL_N_ELEMENTS(ReservedKeys);
280 }
281 
283 {
284  if( i >= GetReservedKeyCodeCount() )
285  return nullptr;
286  else
287  return &ReservedKeys[i];
288 }
289 
290 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplEndAllPopupsMsg, void*, void )
291 {
292  ImplSVData* pSVData = ImplGetSVData();
293  while (pSVData->mpWinData->mpFirstFloat)
295 }
296 
297 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplEndAllDialogsMsg, void*, void )
298 {
300  while (pAppWindow)
301  {
302  vcl::EndAllDialogs(pAppWindow);
303  pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
304  }
305 }
306 
308 {
309  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllDialogsMsg ) );
310 }
311 
313 {
314  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllPopupsMsg ) );
315 }
316 
318  const OUString& /*rAction*/,
319  const std::vector<vcl::LOKPayloadItem>& /*rPayload = std::vector<LOKPayloadItem>()*/) const
320 {
321 }
322 
323 void Application::libreOfficeKitViewCallback(int nType, const char* pPayload) const
324 {
326  return;
327 
328  if (m_pCallback)
329  {
330  m_pCallback(nType, pPayload, m_pCallbackData);
331  }
332 }
333 
334 
335 namespace
336 {
337  VclPtr<vcl::Window> GetEventWindow()
338  {
340  while (xWin)
341  {
342  if (xWin->IsVisible())
343  break;
344  xWin.reset(Application::GetNextTopLevelWindow(xWin));
345  }
346  return xWin;
347  }
348 
349  bool InjectKeyEvent(SvStream& rStream)
350  {
351  VclPtr<vcl::Window> xWin(GetEventWindow());
352  if (!xWin)
353  return false;
354 
355  // skip the first available cycle and insert on the next one when we
356  // are trying the initial event, flagged by a triggered but undeleted
357  // mpEventTestingIdle
358  ImplSVData* pSVData = ImplGetSVData();
359  if (pSVData->maAppData.mpEventTestingIdle)
360  {
361  delete pSVData->maAppData.mpEventTestingIdle;
362  pSVData->maAppData.mpEventTestingIdle = nullptr;
363  return false;
364  }
365 
366  sal_uInt16 nCode, nCharCode;
367  rStream.ReadUInt16(nCode);
368  rStream.ReadUInt16(nCharCode);
369  if (!rStream.good())
370  return false;
371 
372  KeyEvent aVCLKeyEvt(nCharCode, nCode);
373  Application::PostKeyEvent(VclEventId::WindowKeyInput, xWin.get(), &aVCLKeyEvt);
374  Application::PostKeyEvent(VclEventId::WindowKeyUp, xWin.get(), &aVCLKeyEvt);
375  return true;
376  }
377 
378  void CloseDialogsAndQuit()
379  {
382  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplPrepareExitMsg ) );
383  }
384 }
385 
386 IMPL_LINK_NOARG(ImplSVAppData, VclEventTestingHdl, Timer *, void)
387 {
388  if (Application::AnyInput())
389  {
390  mpEventTestingIdle->Start();
391  }
392  else
393  {
394  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
395  }
396 }
397 
398 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplVclEventTestingHdl, void*, void )
399 {
400  ImplSVData* pSVData = ImplGetSVData();
401  SAL_INFO("vcl.eventtesting", "EventTestLimit is " << pSVData->maAppData.mnEventTestLimit);
402  if (pSVData->maAppData.mnEventTestLimit == 0)
403  {
404  delete pSVData->maAppData.mpEventTestInput;
405  SAL_INFO("vcl.eventtesting", "Event Limit reached, exiting" << pSVData->maAppData.mnEventTestLimit);
406  CloseDialogsAndQuit();
407  }
408  else
409  {
410  if (InjectKeyEvent(*pSVData->maAppData.mpEventTestInput))
411  --pSVData->maAppData.mnEventTestLimit;
412  if (!pSVData->maAppData.mpEventTestInput->good())
413  {
414  SAL_INFO("vcl.eventtesting", "Event Input exhausted, exit next cycle");
415  pSVData->maAppData.mnEventTestLimit = 0;
416  }
417  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
418  }
419 }
420 
421 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplPrepareExitMsg, void*, void )
422 {
423  //now close top level frames
424  (void)GetpApp()->QueryExit();
425 }
426 
428 {
429  ImplSVData* pSVData = ImplGetSVData();
430  pSVData->maAppData.mbInAppExecute = true;
431  pSVData->maAppData.mbAppQuit = false;
432 
434  {
435  pSVData->maAppData.mnEventTestLimit = 50;
436  pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting");
437  pSVData->maAppData.mpEventTestingIdle->SetInvokeHandler(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl));
439  pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ);
440  pSVData->maAppData.mpEventTestingIdle->Start();
441  }
442 
443  int nExitCode = 0;
444  if (!pSVData->mpDefInst->DoExecute(nExitCode))
445  {
447  {
448  SAL_WARN("vcl.schedule", "Can't omit DoExecute when running on system event loop!");
449  std::abort();
450  }
451  while (!pSVData->maAppData.mbAppQuit)
453  }
454 
455  pSVData->maAppData.mbInAppExecute = false;
456 
457  GetpApp()->Shutdown();
458 }
459 
460 static bool ImplYield(bool i_bWait, bool i_bAllEvents)
461 {
462  ImplSVData* pSVData = ImplGetSVData();
463 
464  SAL_INFO("vcl.schedule", "Enter ImplYield: " << (i_bWait ? "wait" : "no wait") <<
465  ": " << (i_bAllEvents ? "all events" : "one event"));
466 
467  // there's a data race here on WNT only because ImplYield may be
468  // called without SolarMutex; but the only remaining use of mnDispatchLevel
469  // is in OSX specific code
470  pSVData->maAppData.mnDispatchLevel++;
471 
472  // do not wait for events if application was already quit; in that
473  // case only dispatch events already available
474  bool bProcessedEvent = pSVData->mpDefInst->DoYield(
475  i_bWait && !pSVData->maAppData.mbAppQuit, i_bAllEvents );
476 
477  pSVData->maAppData.mnDispatchLevel--;
478 
479  DBG_TESTSOLARMUTEX(); // must be locked on return from Yield
480 
481  SAL_INFO("vcl.schedule", "Leave ImplYield with return " << bProcessedEvent );
482  return bProcessedEvent;
483 }
484 
485 bool Application::Reschedule( bool i_bAllEvents )
486 {
487  static const bool bAbort = Application::IsOnSystemEventLoop();
488  if (bAbort)
489  {
490  SAL_WARN("vcl.schedule", "Application::Reschedule(" << i_bAllEvents << ")");
491  std::abort();
492  }
493  return ImplYield(false, i_bAllEvents);
494 }
495 
497 {
499 }
500 
502 {
503  int nSanity = 1;
504  while (ImplYield(false, true))
505  {
506  if (0 == ++nSanity % 1000)
507  {
508  SAL_WARN("vcl.schedule", "ProcessEventsToIdle: " << nSanity);
509  }
510  }
511 #if OSL_DEBUG_LEVEL > 0
512  // If we yield from a non-main thread we just can guarantee that all idle
513  // events were processed at some point, but our check can't prevent further
514  // processing in the main thread, which may add new events, so skip it.
515  const ImplSVData* pSVData = ImplGetSVData();
516  if ( !pSVData->mpDefInst->IsMainThread() )
517  return;
518  for (int nTaskPriority = 0; nTaskPriority < PRIO_COUNT; ++nTaskPriority)
519  {
520  const ImplSchedulerData* pSchedulerData = pSVData->maSchedCtx.mpFirstSchedulerData[nTaskPriority];
521  while (pSchedulerData)
522  {
523  assert(!pSchedulerData->mbInScheduler);
524  if (pSchedulerData->mpTask)
525  {
526  Idle *pIdle = dynamic_cast<Idle*>(pSchedulerData->mpTask);
527  if (pIdle && pIdle->IsActive())
528  {
529  SAL_WARN("vcl.schedule",
530  "Unprocessed Idle: "
531  << pIdle << " "
532  << (pIdle->GetDebugName() ? pIdle->GetDebugName() : "(nullptr)"));
533  }
534  }
535  pSchedulerData = pSchedulerData->mpNext;
536  }
537  }
538 #endif
539 }
540 
541 extern "C" {
543 SAL_DLLPUBLIC_EXPORT void unit_lok_process_events_to_idle()
544 {
545  const SolarMutexGuard aGuard;
547 }
548 }
549 
551 {
552  static const bool bAbort = Application::IsOnSystemEventLoop();
553  if (bAbort)
554  {
555  SAL_WARN("vcl.schedule", "Application::Yield()");
556  std::abort();
557  }
558  ImplYield(true, false);
559 }
560 
561 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplQuitMsg, void*, void )
562 {
563  assert(ImplGetSVData()->maAppData.mbAppQuit);
565 }
566 
568 {
570  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplQuitMsg ) );
571 }
572 
574 {
575  ImplSVData* pSVData = ImplGetSVData();
576  return *(pSVData->mpDefInst->GetYieldMutex());
577 }
578 
580 {
581  return ImplGetSVData()->mnMainThreadId == osl::Thread::getCurrentIdentifier();
582 }
583 
585 {
586  ImplSVData* pSVData = ImplGetSVData();
587  return pSVData->mpDefInst->ReleaseYieldMutexAll();
588 }
589 
590 void Application::AcquireSolarMutex( sal_uInt32 nCount )
591 {
592  ImplSVData* pSVData = ImplGetSVData();
593  pSVData->mpDefInst->AcquireYieldMutex( nCount );
594 }
595 
597 {
598  ImplSVData* pSVData = ImplGetSVData();
599  return pSVData && pSVData->maAppData.mbInAppMain;
600 }
601 
603 {
605 }
606 
608 {
610 }
611 
613 {
614  return (ImplGetSVData()->maAppData.mnModalMode != 0);
615 }
616 
618 {
620 }
621 
623 {
624  return ImplGetSVData()->mpDefInst->AnyInput( nType );
625 }
626 
628 {
629  return (tools::Time::GetSystemTicks()-ImplGetSVData()->maAppData.mnLastInputTime);
630 }
631 
633 {
634  ImplSVData* pSVData = ImplGetSVData();
635 
636  // If mouse was captured, or if in tracking- or in select-mode of a floatingwindow (e.g. menus
637  // or pulldown toolboxes) another window should be created
638  // D&D active !!!
639  return pSVData->mpWinData->mpCaptureWin || pSVData->mpWinData->mpTrackWin
640  || pSVData->mpWinData->mpFirstFloat || nImplSysDialog;
641 }
642 
644 {
645 }
646 
648 {
650  if( ! pWindow )
651  pWindow = ImplGetDefaultWindow();
652  if( pWindow )
653  {
654  ImplSVData* pSVData = ImplGetSVData();
655  if ( !pSVData->maAppData.mbSettingsInit )
656  {
657  // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
658  pWindow->ImplUpdateGlobalSettings( *pSVData->maAppData.mxSettings );
659  pSVData->maAppData.mbSettingsInit = true;
660  }
661  // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
662  pWindow->ImplUpdateGlobalSettings( rSettings, false );
663  }
664 }
665 
666 void Application::SetSettings( const AllSettings& rSettings )
667 {
668  const SolarMutexGuard aGuard;
669 
670  ImplSVData* pSVData = ImplGetSVData();
671  if ( !pSVData->maAppData.mxSettings )
672  {
673  InitSettings(pSVData);
674  *pSVData->maAppData.mxSettings = rSettings;
675  }
676  else
677  {
678  AllSettings aOldSettings = *pSVData->maAppData.mxSettings;
679  if (aOldSettings.GetUILanguageTag().getLanguageType() != rSettings.GetUILanguageTag().getLanguageType() &&
680  pSVData->mbResLocaleSet)
681  {
682  pSVData->mbResLocaleSet = false;
683  }
684  *pSVData->maAppData.mxSettings = rSettings;
685  AllSettingsFlags nChangeFlags = aOldSettings.GetChangeFlags( *pSVData->maAppData.mxSettings );
686  if ( bool(nChangeFlags) )
687  {
688  DataChangedEvent aDCEvt( DataChangedEventType::SETTINGS, &aOldSettings, nChangeFlags );
689 
690  // notify data change handler
692 
693  // Update all windows
694  vcl::Window* pFirstFrame = pSVData->maFrameData.mpFirstFrame;
695  // Reset data that needs to be re-calculated
696  tools::Long nOldDPIX = 0;
697  tools::Long nOldDPIY = 0;
698  if ( pFirstFrame )
699  {
700  nOldDPIX = pFirstFrame->GetOutDev()->GetDPIX();
701  nOldDPIY = pFirstFrame->GetOutDev()->GetDPIY();
703  }
704  vcl::Window* pFrame = pFirstFrame;
705  while ( pFrame )
706  {
707  // call UpdateSettings from ClientWindow in order to prevent updating data twice
708  vcl::Window* pClientWin = pFrame;
709  while ( pClientWin->ImplGetClientWindow() )
710  pClientWin = pClientWin->ImplGetClientWindow();
711  pClientWin->UpdateSettings( rSettings, true );
712 
713  vcl::Window* pTempWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
714  while ( pTempWin )
715  {
716  // call UpdateSettings from ClientWindow in order to prevent updating data twice
717  pClientWin = pTempWin;
718  while ( pClientWin->ImplGetClientWindow() )
719  pClientWin = pClientWin->ImplGetClientWindow();
720  pClientWin->UpdateSettings( rSettings, true );
721  pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
722  }
723 
724  pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
725  }
726 
727  // if DPI resolution for screen output was changed set the new resolution for all
728  // screen compatible VirDev's
729  pFirstFrame = pSVData->maFrameData.mpFirstFrame;
730  if ( pFirstFrame )
731  {
732  if ( (pFirstFrame->GetOutDev()->GetDPIX() != nOldDPIX) ||
733  (pFirstFrame->GetOutDev()->GetDPIY() != nOldDPIY) )
734  {
735  VirtualDevice* pVirDev = pSVData->maGDIData.mpFirstVirDev;
736  while ( pVirDev )
737  {
738  if ( pVirDev->mbScreenComp &&
739  (pVirDev->GetDPIX() == nOldDPIX) &&
740  (pVirDev->GetDPIY() == nOldDPIY) )
741  {
742  pVirDev->SetDPIX( pFirstFrame->GetOutDev()->GetDPIX() );
743  pVirDev->SetDPIY( pFirstFrame->GetOutDev()->GetDPIY() );
744  if ( pVirDev->IsMapModeEnabled() )
745  {
746  MapMode aMapMode = pVirDev->GetMapMode();
747  pVirDev->SetMapMode();
748  pVirDev->SetMapMode( aMapMode );
749  }
750  }
751 
752  pVirDev = pVirDev->mpNext;
753  }
754  }
755  }
756  }
757  }
758 }
759 
761 {
762  ImplSVData* pSVData = ImplGetSVData();
763  if ( !pSVData->maAppData.mxSettings )
764  {
765  InitSettings(pSVData);
766  }
767 
768  return *(pSVData->maAppData.mxSettings);
769 }
770 
771 namespace {
772 
773 void InitSettings(ImplSVData* pSVData)
774 {
775  assert(!pSVData->maAppData.mxSettings && "initialization should not happen twice!");
776 
777  pSVData->maAppData.mxSettings.emplace();
779  {
781  pSVData->maAppData.mxSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener );
782  }
783 }
784 
785 }
786 
788 {
789  ImplSVData* pSVData = ImplGetSVData();
790  vcl::Window* pFrame = pSVData->maFrameData.mpFirstFrame;
791  while ( pFrame )
792  {
793  pFrame->NotifyAllChildren( rDCEvt );
794 
795  vcl::Window* pSysWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
796  while ( pSysWin )
797  {
798  pSysWin->NotifyAllChildren( rDCEvt );
799  pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
800  }
801 
802  pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
803  }
804 }
805 
807 {
808  ImplSVData* pSVData = ImplGetSVData();
810 
811  pSVData->maAppData.maEventListeners.Call( aEvent );
812 }
813 
815 {
816  ImplSVData* pSVData = ImplGetSVData();
817  pSVData->maAppData.maEventListeners.Call( rEvent );
818 }
819 
821 {
822  ImplSVData* pSVData = ImplGetSVData();
823  pSVData->maAppData.maEventListeners.addListener( rEventListener );
824 }
825 
827 {
828  ImplSVData* pSVData = ImplGetSVData();
829  pSVData->maAppData.maEventListeners.removeListener( rEventListener );
830 }
831 
833 {
834  ImplSVData* pSVData = ImplGetSVData();
835  pSVData->maAppData.maKeyListeners.push_back( rKeyListener );
836 }
837 
839 {
840  ImplSVData* pSVData = ImplGetSVData();
841  auto & rVec = pSVData->maAppData.maKeyListeners;
842  rVec.erase( std::remove(rVec.begin(), rVec.end(), rKeyListener ), rVec.end() );
843 }
844 
845 bool Application::HandleKey( VclEventId nEvent, vcl::Window *pWin, KeyEvent* pKeyEvent )
846 {
847  // let listeners process the key event
848  VclWindowEvent aEvent( pWin, nEvent, static_cast<void *>(pKeyEvent) );
849 
850  ImplSVData* pSVData = ImplGetSVData();
851 
852  if ( pSVData->maAppData.maKeyListeners.empty() )
853  return false;
854 
855  bool bProcessed = false;
856  // Copy the list, because this can be destroyed when calling a Link...
857  std::vector<Link<VclWindowEvent&,bool>> aCopy( pSVData->maAppData.maKeyListeners );
858  for ( const Link<VclWindowEvent&,bool>& rLink : aCopy )
859  {
860  if( rLink.Call( aEvent ) )
861  {
862  bProcessed = true;
863  break;
864  }
865  }
866  return bProcessed;
867 }
868 
870 {
871  const SolarMutexGuard aGuard;
872  ImplSVEvent * nEventId = nullptr;
873 
874  if( pWin && pKeyEvent )
875  {
876  std::unique_ptr<ImplPostEventData> pPostEventData(new ImplPostEventData( nEvent, pWin, *pKeyEvent ));
877 
878  nEventId = PostUserEvent(
879  LINK( nullptr, Application, PostEventHandler ),
880  pPostEventData.get() );
881 
882  if( nEventId )
883  {
884  pPostEventData->mnEventId = nEventId;
885  ImplGetSVData()->maAppData.maPostedEventList.emplace_back( pWin, pPostEventData.release() );
886  }
887  }
888 
889  return nEventId;
890 }
891 
893 {
894  const SolarMutexGuard aGuard;
895  ImplSVEvent * nEventId = nullptr;
896 
897  if (pWin && pGestureEvent)
898  {
899  Point aTransformedPosition(pGestureEvent->mnX, pGestureEvent->mnY);
900 
901  aTransformedPosition.AdjustX(pWin->GetOutOffXPixel());
902  aTransformedPosition.AdjustY(pWin->GetOutOffYPixel());
903 
904  const GestureEvent aGestureEvent(
905  sal_Int32(aTransformedPosition.X()),
906  sal_Int32(aTransformedPosition.Y()),
907  pGestureEvent->meEventType,
908  pGestureEvent->mnOffset,
909  pGestureEvent->meOrientation
910  );
911 
912  std::unique_ptr<ImplPostEventData> pPostEventData(new ImplPostEventData(nEvent, pWin, aGestureEvent));
913 
914  nEventId = PostUserEvent(
915  LINK( nullptr, Application, PostEventHandler ),
916  pPostEventData.get());
917 
918  if (nEventId)
919  {
920  pPostEventData->mnEventId = nEventId;
921  ImplGetSVData()->maAppData.maPostedEventList.emplace_back(pWin, pPostEventData.release());
922  }
923  }
924 
925  return nEventId;
926 }
927 
929 {
930  bool bSuccess = false;
931  SalMouseEvent aMouseEvent;
932 
933  if (!pWindow)
934  return false;
935 
936  if (!pEvent)
937  return false;
938 
939  aMouseEvent.mnTime = tools::Time::GetSystemTicks();
940  aMouseEvent.mnX = pEvent->GetPosPixel().X();
941  aMouseEvent.mnY = pEvent->GetPosPixel().Y();
942  aMouseEvent.mnCode = pEvent->GetButtons() | pEvent->GetModifier();
943 
944  switch (nEvent)
945  {
947  aMouseEvent.mnButton = 0;
948  bSuccess = ImplLOKHandleMouseEvent(pWindow, MouseNotifyEvent::MOUSEMOVE, false,
949  aMouseEvent.mnX, aMouseEvent.mnY,
950  aMouseEvent.mnTime, aMouseEvent.mnCode,
951  ImplGetMouseMoveMode(&aMouseEvent),
952  pEvent->GetClicks());
953  break;
954 
956  aMouseEvent.mnButton = pEvent->GetButtons();
958  aMouseEvent.mnX, aMouseEvent.mnY,
959  aMouseEvent.mnTime,
960 #ifdef MACOSX
961  aMouseEvent.mnButton |
962  (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)),
963 #else
964  aMouseEvent.mnButton |
965  (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)),
966 #endif
967  ImplGetMouseButtonMode(&aMouseEvent),
968  pEvent->GetClicks());
969  break;
970 
972  aMouseEvent.mnButton = pEvent->GetButtons();
973  bSuccess = ImplLOKHandleMouseEvent(pWindow, MouseNotifyEvent::MOUSEBUTTONUP, false,
974  aMouseEvent.mnX, aMouseEvent.mnY,
975  aMouseEvent.mnTime,
976 #ifdef MACOSX
977  aMouseEvent.mnButton |
978  (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)),
979 #else
980  aMouseEvent.mnButton |
981  (aMouseEvent.mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)),
982 #endif
983  ImplGetMouseButtonMode(&aMouseEvent),
984  pEvent->GetClicks());
985  break;
986 
987  default:
988  SAL_WARN( "vcl.layout", "Application::HandleMouseEvent unknown event (" << static_cast<int>(nEvent) << ")" );
989  break;
990  }
991 
992  return bSuccess;
993 }
994 
995 
997 {
998  const SolarMutexGuard aGuard;
999  ImplSVEvent * nEventId = nullptr;
1000 
1001  if( pWin && pMouseEvent )
1002  {
1003  Point aTransformedPos( pMouseEvent->GetPosPixel() );
1004 
1005  // LOK uses (0, 0) as the origin of all windows; don't offset.
1007  {
1008  aTransformedPos.AdjustX(pWin->GetOutOffXPixel());
1009  aTransformedPos.AdjustY(pWin->GetOutOffYPixel());
1010  }
1011 
1012  const MouseEvent aTransformedEvent( aTransformedPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(),
1013  pMouseEvent->GetButtons(), pMouseEvent->GetModifier() );
1014 
1015  std::unique_ptr<ImplPostEventData> pPostEventData(new ImplPostEventData( nEvent, pWin, aTransformedEvent ));
1016 
1017  nEventId = PostUserEvent(
1018  LINK( nullptr, Application, PostEventHandler ),
1019  pPostEventData.get() );
1020 
1021  if( nEventId )
1022  {
1023  pPostEventData->mnEventId = nEventId;
1024  ImplGetSVData()->maAppData.maPostedEventList.emplace_back( pWin, pPostEventData.release() );
1025  }
1026  }
1027 
1028  return nEventId;
1029 }
1030 
1031 
1032 IMPL_STATIC_LINK( Application, PostEventHandler, void*, pCallData, void )
1033 {
1034  const SolarMutexGuard aGuard;
1035  ImplPostEventData* pData = static_cast< ImplPostEventData * >( pCallData );
1036  const void* pEventData;
1037  SalEvent nEvent;
1038  ImplSVEvent * const nEventId = pData->mnEventId;
1039 
1040  switch( pData->mnEvent )
1041  {
1043  nEvent = SalEvent::ExternalMouseMove;
1044  pEventData = &pData->maMouseEvent;
1045  break;
1046 
1049  pEventData = &pData->maMouseEvent;
1050  break;
1051 
1054  pEventData = &pData->maMouseEvent;
1055  break;
1056 
1058  nEvent = SalEvent::ExternalKeyInput;
1059  pEventData = &pData->maKeyEvent;
1060  break;
1061 
1063  nEvent = SalEvent::ExternalKeyUp;
1064  pEventData = &pData->maKeyEvent;
1065  break;
1066 
1068  nEvent = SalEvent::ExternalGesture;
1069  pEventData = &pData->maGestureEvent;
1070  break;
1071 
1072  default:
1073  nEvent = SalEvent::NONE;
1074  pEventData = nullptr;
1075  break;
1076  }
1077 
1078  if( pData->mpWin && pData->mpWin->mpWindowImpl->mpFrameWindow && pEventData )
1079  ImplWindowFrameProc( pData->mpWin->mpWindowImpl->mpFrameWindow.get(), nEvent, pEventData );
1080 
1081  // remove this event from list of posted events, watch for destruction of internal data
1082  auto svdata = ImplGetSVData();
1083  ::std::vector< ImplPostEventPair >::iterator aIter( svdata->maAppData.maPostedEventList.begin() );
1084 
1085  while( aIter != svdata->maAppData.maPostedEventList.end() )
1086  {
1087  if( nEventId == (*aIter).second->mnEventId )
1088  {
1089  delete (*aIter).second;
1090  aIter = svdata->maAppData.maPostedEventList.erase( aIter );
1091  }
1092  else
1093  ++aIter;
1094  }
1095 }
1096 
1098 {
1099  const SolarMutexGuard aGuard;
1100 
1101  // remove all events for specific window, watch for destruction of internal data
1102  auto svdata = ImplGetSVData();
1103  ::std::vector< ImplPostEventPair >::iterator aIter( svdata->maAppData.maPostedEventList.begin() );
1104 
1105  while( aIter != svdata->maAppData.maPostedEventList.end() )
1106  {
1107  if( pWin == (*aIter).first )
1108  {
1109  if( (*aIter).second->mnEventId )
1110  RemoveUserEvent( (*aIter).second->mnEventId );
1111 
1112  delete (*aIter).second;
1113  aIter = svdata->maAppData.maPostedEventList.erase( aIter );
1114  }
1115  else
1116  ++aIter;
1117  }
1118 }
1119 
1121  bool bReferenceLink )
1122 {
1123  vcl::Window* pDefWindow = ImplGetDefaultWindow();
1124  if ( pDefWindow == nullptr )
1125  return nullptr;
1126 
1127  std::unique_ptr<ImplSVEvent> pSVEvent(new ImplSVEvent);
1128  pSVEvent->mpData = pCaller;
1129  pSVEvent->maLink = rLink;
1130  pSVEvent->mpWindow = nullptr;
1131  pSVEvent->mbCall = true;
1132  if (bReferenceLink)
1133  {
1134  SolarMutexGuard aGuard;
1135  pSVEvent->mpInstanceRef = static_cast<vcl::Window *>(rLink.GetInstance());
1136  }
1137 
1138  auto pTmpEvent = pSVEvent.get();
1139  if (!pDefWindow->ImplGetFrame()->PostEvent( std::move(pSVEvent) ))
1140  return nullptr;
1141  return pTmpEvent;
1142 }
1143 
1145 {
1146  if(nUserEvent)
1147  {
1148  SAL_WARN_IF( nUserEvent->mpWindow, "vcl",
1149  "Application::RemoveUserEvent(): Event is send to a window" );
1150  SAL_WARN_IF( !nUserEvent->mbCall, "vcl",
1151  "Application::RemoveUserEvent(): Event is already removed" );
1152 
1153  nUserEvent->mpWindow.clear();
1154  nUserEvent->mpInstanceRef.clear();
1155  nUserEvent->mbCall = false;
1156  }
1157 }
1158 
1160 {
1161  return ImplGetSVData()->mpWinData->mpFocusWin;
1162 }
1163 
1165 {
1166  return ImplGetDefaultWindow()->GetOutDev();
1167 }
1168 
1170 {
1171  ImplSVData* pSVData = ImplGetSVData();
1172  return pSVData->maFrameData.mpFirstFrame;
1173 }
1174 
1176 {
1177  return pWindow->mpWindowImpl->mpFrameData->mpNextFrame;
1178 }
1179 
1181 {
1182  tools::Long nRet = 0;
1183  ImplSVData* pSVData = ImplGetSVData();
1184  vcl::Window *pWin = pSVData ? pSVData->maFrameData.mpFirstFrame.get() : nullptr;
1185  while( pWin )
1186  {
1187  if( pWin->ImplGetWindow()->IsTopWindow() )
1188  nRet++;
1189  pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1190  }
1191  return nRet;
1192 }
1193 
1195 {
1196  tools::Long nIdx = 0;
1197  ImplSVData* pSVData = ImplGetSVData();
1198  vcl::Window *pWin = pSVData ? pSVData->maFrameData.mpFirstFrame.get() : nullptr;
1199  while( pWin )
1200  {
1201  if( pWin->ImplGetWindow()->IsTopWindow() )
1202  {
1203  if( nIdx == nIndex )
1204  return pWin->ImplGetWindow();
1205  else
1206  nIdx++;
1207  }
1208  pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1209  }
1210  return nullptr;
1211 }
1212 
1214 {
1216  while( pWin )
1217  {
1218  if( pWin->IsTopWindow() )
1219  return pWin;
1220  pWin = pWin->mpWindowImpl->mpParent;
1221  }
1222  return nullptr;
1223 }
1224 
1225 void Application::SetAppName( const OUString& rUniqueName )
1226 {
1227  ImplSVData* pSVData = ImplGetSVData();
1228  pSVData->maAppData.mxAppName = rUniqueName;
1229 }
1230 
1232 {
1233  ImplSVData* pSVData = ImplGetSVData();
1234  if ( pSVData->maAppData.mxAppName )
1235  return *(pSVData->maAppData.mxAppName);
1236  else
1237  return OUString();
1238 }
1239 
1240 enum {hwAll=0, hwEnv=1, hwUI=2};
1241 
1242 static OUString Localize(TranslateId aId, const bool bLocalize)
1243 {
1244  if (bLocalize)
1245  return VclResId(aId);
1246  else
1247  return Translate::get(aId, Translate::Create("vcl", LanguageTag("en-US")));
1248 }
1249 
1251 {
1252  ImplSVData* pSVData = ImplGetSVData();
1253  OUString aVersion;
1254  if (pSVData && pSVData->mpDefInst)
1255  aVersion = pSVData->mpDefInst->getOSVersion();
1256  else
1257  aVersion = "-";
1258  return aVersion;
1259 }
1260 
1261 OUString Application::GetHWOSConfInfo(const int bSelection, const bool bLocalize)
1262 {
1263  OUStringBuffer aDetails;
1264 
1265  const auto appendDetails = [&aDetails](std::u16string_view sep, auto&& val) {
1266  if (!aDetails.isEmpty() && !sep.empty())
1267  aDetails.append(sep);
1268  aDetails.append(std::move(val));
1269  };
1270 
1271  if (bSelection != hwUI) {
1272  appendDetails(u"; ", Localize(SV_APP_CPUTHREADS, bLocalize)
1273  + OUString::number(std::thread::hardware_concurrency()));
1274 
1275  OUString aVersion = GetOSVersion();
1276 
1277  appendDetails(u"; ", Localize(SV_APP_OSVERSION, bLocalize) + aVersion);
1278  }
1279 
1280  if (bSelection != hwEnv) {
1281  appendDetails(u"; ", Localize(SV_APP_UIRENDER, bLocalize));
1282 #if HAVE_FEATURE_SKIA
1284  {
1285  switch(SkiaHelper::renderMethodToUse())
1286  {
1287  case SkiaHelper::RenderVulkan:
1288  appendDetails(u"", Localize(SV_APP_SKIA_VULKAN, bLocalize));
1289  break;
1290  case SkiaHelper::RenderMetal:
1291  appendDetails(u"", Localize(SV_APP_SKIA_METAL, bLocalize));
1292  break;
1293  case SkiaHelper::RenderRaster:
1294  appendDetails(u"", Localize(SV_APP_SKIA_RASTER, bLocalize));
1295  break;
1296  }
1297  }
1298  else
1299 #endif
1300  appendDetails(u"", Localize(SV_APP_DEFAULT, bLocalize));
1301 
1302 #if (defined LINUX || defined _WIN32 || defined MACOSX || defined __FreeBSD__ || defined EMSCRIPTEN)
1303  appendDetails(u"; ", SV_APP_VCLBACKEND + GetToolkitName());
1304 #endif
1305  }
1306 
1307  return aDetails.makeStringAndClear();
1308 }
1309 
1310 void Application::SetDisplayName( const OUString& rName )
1311 {
1312  ImplSVData* pSVData = ImplGetSVData();
1313  pSVData->maAppData.mxDisplayName = rName;
1314 }
1315 
1317 {
1318  ImplSVData* pSVData = ImplGetSVData();
1319  if ( pSVData->maAppData.mxDisplayName )
1320  return *(pSVData->maAppData.mxDisplayName);
1321  else if (pSVData->maFrameData.mpAppWin)
1322  return pSVData->maFrameData.mpAppWin->GetText();
1323  else
1324  return OUString();
1325 }
1326 
1328 {
1329  SalSystem* pSys = ImplGetSalSystem();
1330  return pSys ? pSys->GetDisplayScreenCount() : 0;
1331 }
1332 
1334 {
1335  SalSystem* pSys = ImplGetSalSystem();
1336  return pSys == nullptr || pSys->IsUnifiedDisplay();
1337 }
1338 
1340 {
1341  SalSystem* pSys = ImplGetSalSystem();
1342  return pSys ? pSys->GetDisplayBuiltInScreen() : 0;
1343 }
1344 
1346 {
1347  // This is really unpleasant, in theory we could have multiple
1348  // external displays etc.
1349  int nExternal(0);
1350  switch (GetDisplayBuiltInScreen())
1351  {
1352  case 0:
1353  nExternal = 1;
1354  break;
1355  case 1:
1356  nExternal = 0;
1357  break;
1358  default:
1359  // When the built-in display is neither 0 nor 1
1360  // then place the full-screen presentation on the
1361  // first available screen.
1362  nExternal = 0;
1363  break;
1364  }
1365  return nExternal;
1366 }
1367 
1369 {
1370  SalSystem* pSys = ImplGetSalSystem();
1371  if (!pSys)
1372  {
1373  SAL_WARN("vcl", "Requesting screen size/pos for screen #" << nScreen << " failed");
1374  assert(false);
1375  return tools::Rectangle();
1376  }
1377  tools::Rectangle aRect = pSys->GetDisplayScreenPosSizePixel(nScreen);
1378  if (aRect.getHeight() == 0)
1379  SAL_WARN("vcl", "Requesting screen size/pos for screen #" << nScreen << " returned 0 height.");
1380  return aRect;
1381 }
1382 
1383 namespace {
1384 tools::Long calcDistSquare( const Point& i_rPoint, const tools::Rectangle& i_rRect )
1385 {
1386  const Point aRectCenter( (i_rRect.Left() + i_rRect.Right())/2,
1387  (i_rRect.Top() + i_rRect.Bottom())/ 2 );
1388  const tools::Long nDX = aRectCenter.X() - i_rPoint.X();
1389  const tools::Long nDY = aRectCenter.Y() - i_rPoint.Y();
1390  return nDX*nDX + nDY*nDY;
1391 }
1392 }
1393 
1394 unsigned int Application::GetBestScreen( const tools::Rectangle& i_rRect )
1395 {
1396  if( !IsUnifiedDisplay() )
1397  return GetDisplayBuiltInScreen();
1398 
1399  const unsigned int nScreens = GetScreenCount();
1400  unsigned int nBestMatchScreen = 0;
1401  unsigned long nOverlap = 0;
1402  for( unsigned int i = 0; i < nScreens; i++ )
1403  {
1404  const tools::Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1405  // if a screen contains the rectangle completely it is obviously the best screen
1406  if( aCurScreenRect.Contains( i_rRect ) )
1407  return i;
1408  // next the screen which contains most of the area of the rect is the best
1409  tools::Rectangle aIntersection( aCurScreenRect.GetIntersection( i_rRect ) );
1410  if( ! aIntersection.IsEmpty() )
1411  {
1412  const unsigned long nCurOverlap( aIntersection.GetWidth() * aIntersection.GetHeight() );
1413  if( nCurOverlap > nOverlap )
1414  {
1415  nOverlap = nCurOverlap;
1416  nBestMatchScreen = i;
1417  }
1418  }
1419  }
1420  if( nOverlap > 0 )
1421  return nBestMatchScreen;
1422 
1423  // finally the screen which center is nearest to the rect is the best
1424  const Point aCenter( (i_rRect.Left() + i_rRect.Right())/2,
1425  (i_rRect.Top() + i_rRect.Bottom())/2 );
1426  tools::Long nDist = std::numeric_limits<tools::Long>::max();
1427  for( unsigned int i = 0; i < nScreens; i++ )
1428  {
1429  const tools::Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1430  const tools::Long nCurDist( calcDistSquare( aCenter, aCurScreenRect ) );
1431  if( nCurDist < nDist )
1432  {
1433  nBestMatchScreen = i;
1434  nDist = nCurDist;
1435  }
1436  }
1437  return nBestMatchScreen;
1438 }
1439 
1441 {
1442  ImplSVData* pSVData = ImplGetSVData();
1443 
1444  if ( !pSVData->maAppData.mpAccelMgr )
1445  pSVData->maAppData.mpAccelMgr = new ImplAccelManager();
1446  return pSVData->maAppData.mpAccelMgr->InsertAccel( pAccel );
1447 }
1448 
1450 {
1451  ImplSVData* pSVData = ImplGetSVData();
1452 
1453  if ( pSVData->maAppData.mpAccelMgr )
1454  pSVData->maAppData.mpAccelMgr->RemoveAccel( pAccel );
1455 }
1456 
1458 {
1459  ImplGetSVData()->maAppData.mpHelp = pHelp;
1460 }
1461 
1463 {
1464  ImplSVData* pSVData = ImplGetSVData();
1465  if (pSVData && pSVData->mpDefInst)
1466  pSVData->mpDefInst->updateMainThread();
1467 }
1468 
1470 {
1471  return ImplGetSVData()->maAppData.mpHelp;
1472 }
1473 
1475 {
1476  ImplSVData* pSVData = ImplGetSVData();
1477  if ( pSVData->maAppData.mxToolkitName )
1478  return *(pSVData->maAppData.mxToolkitName);
1479  else
1480  return OUString();
1481 }
1482 
1484 {
1485  ImplSVData* pSVData = ImplGetSVData();
1486  // find some useful dialog parent
1487 
1488  // always use the topmost parent of the candidate
1489  // window to avoid using dialogs or floaters
1490  // as DefDialogParent
1491 
1492  // current focus frame
1493  vcl::Window *pWin = pSVData->mpWinData->mpFocusWin;
1494  if (pWin && !pWin->IsMenuFloatingWindow())
1495  {
1496  while (pWin->mpWindowImpl && pWin->mpWindowImpl->mpParent)
1497  pWin = pWin->mpWindowImpl->mpParent;
1498 
1499  // check for corrupted window hierarchy, #122232#, may be we now crash somewhere else
1500  if (!pWin->mpWindowImpl)
1501  {
1502  OSL_FAIL( "Window hierarchy corrupted!" );
1503  pSVData->mpWinData->mpFocusWin = nullptr; // avoid further access
1504  return nullptr;
1505  }
1506 
1507  if ((pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0)
1508  {
1509  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1510  }
1511  }
1512 
1513  // last active application frame
1514  pWin = pSVData->maFrameData.mpActiveApplicationFrame;
1515  if (pWin)
1516  {
1517  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1518  }
1519 
1520  // first visible top window (may be totally wrong...)
1521  pWin = pSVData->maFrameData.mpFirstFrame;
1522  while (pWin)
1523  {
1524  if( pWin->ImplGetWindow()->IsTopWindow() &&
1525  pWin->mpWindowImpl->mbReallyVisible &&
1526  (pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0
1527  )
1528  {
1529  while( pWin->mpWindowImpl->mpParent )
1530  pWin = pWin->mpWindowImpl->mpParent;
1531  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1532  }
1533  pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1534  }
1535 
1536  // use the desktop
1537  return nullptr;
1538 }
1539 
1541 {
1543  return pWindow ? pWindow->GetFrameWeld() : nullptr;
1544 }
1545 
1547 {
1549 }
1550 
1552 {
1554 }
1555 
1557 {
1559 }
1560 
1562 {
1564 }
1565 
1567 {
1569 }
1570 
1571 css::uno::Reference< css::awt::XToolkit > Application::GetVCLToolkit()
1572 {
1573  css::uno::Reference< css::awt::XToolkit > xT;
1575  if ( pWrapper )
1576  xT = pWrapper->GetVCLToolkit();
1577  return xT;
1578 }
1579 
1580 #ifdef DISABLE_DYNLOADING
1581 
1582 extern "C" { UnoWrapperBase* CreateUnoWrapper(); }
1583 
1584 #else
1585 
1586 extern "C" { static void thisModule() {} }
1587 
1588 #endif
1589 
1591 {
1592  ImplSVData* pSVData = ImplGetSVData();
1593  static bool bAlreadyTriedToCreate = false;
1594  if ( !pSVData->mpUnoWrapper && bCreateIfNotExist && !bAlreadyTriedToCreate )
1595  {
1596 #ifndef DISABLE_DYNLOADING
1597  osl::Module aTkLib;
1598  aTkLib.loadRelative(&thisModule, TK_DLL_NAME);
1599  if (aTkLib.is())
1600  {
1601  FN_TkCreateUnoWrapper fnCreateWrapper = reinterpret_cast<FN_TkCreateUnoWrapper>(aTkLib.getFunctionSymbol("CreateUnoWrapper"));
1602  if ( fnCreateWrapper )
1603  {
1604  pSVData->mpUnoWrapper = fnCreateWrapper();
1605  }
1606  aTkLib.release();
1607  }
1608  SAL_WARN_IF( !pSVData->mpUnoWrapper, "vcl", "UnoWrapper could not be created!" );
1609 #else
1610  pSVData->mpUnoWrapper = CreateUnoWrapper();
1611 #endif
1612  bAlreadyTriedToCreate = true;
1613  }
1614  return pSVData->mpUnoWrapper;
1615 }
1616 
1618 {
1619  ImplSVData* pSVData = ImplGetSVData();
1620  SAL_WARN_IF( pSVData->mpUnoWrapper, "vcl", "SetUnoWrapper: Wrapper already exists" );
1621  pSVData->mpUnoWrapper = pWrapper;
1622 }
1623 
1624 css::uno::Reference< css::awt::XDisplayConnection > Application::GetDisplayConnection()
1625 {
1626  ImplSVData* pSVData = ImplGetSVData();
1627 
1628  if( !pSVData->mxDisplayConnection.is() )
1629  {
1631  pSVData->mxDisplayConnection->start();
1632  }
1633 
1634  return pSVData->mxDisplayConnection;
1635 }
1636 
1638 {
1639  ImplGetSVData()->maGDIData.mxGrfConverter->SetFilterHdl( rLink );
1640 }
1641 
1643 {
1644  return GetSettings().GetLocaleDataWrapper();
1645 }
1646 
1647 void Application::EnableHeadlessMode( bool dialogsAreFatal )
1648 {
1649  DialogCancelMode eNewMode = dialogsAreFatal ? DialogCancelMode::Fatal : DialogCancelMode::Silent;
1651  assert(eOldMode == DialogCancelMode::Off || GetDialogCancelMode() == eNewMode);
1652  if (eOldMode != eNewMode)
1653  SetDialogCancelMode( eNewMode );
1654 }
1655 
1657 {
1659 }
1660 
1662 {
1664 }
1665 
1667 {
1669 }
1670 
1672 {
1673  EnableHeadlessMode(true);
1675 }
1676 
1677 static bool bEventTestingMode = false;
1678 
1680 {
1681  return bEventTestingMode;
1682 }
1683 
1685 {
1686  bEventTestingMode = true;
1687 }
1688 
1689 static bool bSafeMode = false;
1690 
1692 {
1693  return bSafeMode;
1694 }
1695 
1697 {
1698  bSafeMode = true;
1699 }
1700 
1701 void Application::ShowNativeErrorBox(const OUString& sTitle ,
1702  const OUString& sMessage)
1703 {
1705  sTitle,
1706  sMessage);
1707  if (btn != SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK) {
1708  SAL_WARN( "vcl", "ShowNativeMessageBox returned " << btn);
1709  }
1710 }
1711 
1713 {
1714  if (IsHeadlessModeEnabled())
1715  {
1716  static const OUString aNone("none");
1717  return aNone;
1718  }
1719  else
1720  return SalGetDesktopEnvironment();
1721 }
1722 
1723 void Application::AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService)
1724 {
1725  ImplSVData* pSVData = ImplGetSVData();
1726  pSVData->mpDefInst->AddToRecentDocumentList(rFileUrl, rMimeType, rDocumentService);
1727 }
1728 
1730 {
1731 // Disable MSAA bridge on UNIX
1732 #if defined UNX
1733  return true;
1734 #else
1735  bool bRet = ImplInitAccessBridge();
1736 
1737  if( !bRet )
1738  {
1739  // disable accessibility if the user chooses to continue
1740  AllSettings aSettings = Application::GetSettings();
1741  MiscSettings aMisc = aSettings.GetMiscSettings();
1742  aMisc.SetEnableATToolSupport( false );
1743  aSettings.SetMiscSettings( aMisc );
1744  Application::SetSettings( aSettings );
1745  }
1746  return bRet;
1747 #endif // !UNX
1748 }
1749 
1750 // MT: AppEvent was in oldsv.cxx, but is still needed...
1751 void Application::AppEvent( const ApplicationEvent& /*rAppEvent*/ )
1752 {
1753 }
1754 
1756 {
1757  ImplSVData* pSVData = ImplGetSVData();
1758  return pSVData->mpDefInst->hasNativeFileSelection();
1759 }
1760 
1761 Reference< ui::dialogs::XFilePicker2 >
1763 {
1764  ImplSVData* pSVData = ImplGetSVData();
1765  return pSVData->mpDefInst->createFilePicker( xSM );
1766 }
1767 
1768 Reference< ui::dialogs::XFolderPicker2 >
1770 {
1771  ImplSVData* pSVData = ImplGetSVData();
1772  return pSVData->mpDefInst->createFolderPicker( xSM );
1773 }
1774 
1776  ImplSVData * pSVData = ImplGetSVData();
1777  assert(!pSVData->maDeInitHook.IsSet());
1778  pSVData->maDeInitHook = hook;
1779  // Fake this for VCLXToolkit ctor instantiated from
1780  // postprocess/CppunitTest_services.mk:
1781  pSVData->maAppData.mbInAppMain = true;
1782 }
1783 
1784 namespace vcl::lok {
1785 
1787  LibreOfficeKitPollCallback pPollCallback,
1788  LibreOfficeKitWakeCallback pWakeCallback,
1789  void *pData) {
1790 
1791  ImplSVData * pSVData = ImplGetSVData();
1792  if (pSVData)
1793  {
1794  pSVData->mpPollCallback = pPollCallback;
1795  pSVData->mpWakeCallback = pWakeCallback;
1796  pSVData->mpPollClosure = pData;
1797  }
1798 }
1799 
1801 {
1802  ImplSVData * pSVData = ImplGetSVData();
1803  if (!pSVData)
1804  return;
1805 
1806  // Not hyper-elegant - but in the case of Android & unipoll we need to detach
1807  // this thread from the JVM's clutches to avoid a crash closing document
1808  if (pSVData->mpPollClosure && pSVData->mpDefInst)
1809  pSVData->mpDefInst->releaseMainThread();
1810 
1811  // Just set mpPollClosure to null as that is what calling this means, that the callback data
1812  // points to an object that no longer exists. In particular, don't set
1813  // pSVData->mpPollCallback to nullptr as that is used to detect whether Unipoll is in use in
1814  // isUnipoll().
1815  pSVData->mpPollClosure = nullptr;
1816 }
1817 
1819 {
1820  ImplSVData * pSVData = ImplGetSVData();
1821  return pSVData && pSVData->mpPollCallback != nullptr;
1822 }
1823 
1824 void numberOfViewsChanged(int count)
1825 {
1826  ImplSVData * pSVData = ImplGetSVData();
1827  auto& rCache = pSVData->maGDIData.maScaleCache;
1828  // Normally the cache size is set to 10, scale according to the number of users.
1829  rCache.setMaxSize(count * 10);
1830 }
1831 
1832 } // namespace lok, namespace vcl
1833 
1834 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static vcl::Window * GetTopWindow(tools::Long nIndex)
Get the nth top window.
Definition: svapp.cxx:1194
static OUString GetDisplayName()
Get the default name of the application for message dialogs and printing.
Definition: svapp.cxx:1316
do not automatically cancel dialogs
constexpr sal_uInt16 KEY_4
Definition: keycodes.hxx:49
const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:409
tools::Long GetOutOffYPixel() const
Definition: window3.cxx:124
virtual void Shutdown()
Definition: svapp.cxx:193
static bool bEventTestingMode
Definition: svapp.cxx:1677
static OUString GetAppName()
Get the application's name.
Definition: svapp.cxx:1231
vcl::Window * ImplGetWindow() const
if this is a proxy return the client, otherwise itself
Definition: window2.cxx:853
const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK
Definition: salsys.hxx:28
const LocaleDataWrapper & GetLocaleDataWrapper() const
constexpr sal_uInt16 KEY_7
Definition: keycodes.hxx:52
static void AcquireSolarMutex(sal_uInt32 nCount)
Acquire Solar Mutex(es) for this thread.
Definition: svapp.cxx:590
oslThreadIdentifier mnMainThreadId
Definition: svdata.hxx:410
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:255
Application()
Default constructor for Application class.
Definition: svapp.cxx:159
constexpr sal_uInt16 KEY_MOD1
Definition: keycodes.hxx:31
static comphelper::SolarMutex & GetSolarMutex()
Get the Solar Mutex for this thread.
Definition: svapp.cxx:573
static bool IsUICaptured()
Definition: svapp.cxx:632
static bool IsMainThread()
Queries whether we are in main thread.
Definition: svapp.cxx:579
static bool IsInExecute()
Queries whether the application is in the event loop.
Definition: svapp.cxx:602
std::optional< OUString > mxToolkitName
Definition: svdata.hxx:149
Link< LinkParamNone *, void > maDeInitHook
Definition: svdata.hxx:424
static void NotifyAllWindows(DataChangedEvent &rDCEvt)
Notify all windows that the application has changed data.
Definition: svapp.cxx:787
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_Int32 mnX
Help * mpHelp
Definition: svdata.hxx:150
const LanguageTag & GetUILanguageTag() const
bool m_bUseSystemLoop
Definition: svdata.hxx:163
VclPtr< VirtualDevice > mpNext
Definition: virdev.hxx:50
static bool IsBitmapRendering()
Determines if bitmap rendering is enabled.
Definition: svapp.cxx:1666
void NotifyAllChildren(DataChangedEvent &rDCEvt)
Definition: event.cxx:40
static sal_uInt16 GetDispatchLevel()
Return how many events are being dispatched.
Definition: svapp.cxx:617
virtual void InitFinished()
Finish initialization of the application.
Definition: svapp.cxx:201
constexpr tools::Long Left() const
constexpr sal_uInt16 KEY_2
Definition: keycodes.hxx:47
Definition: help.hxx:60
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1469
static tools::Long GetTopWindowCount()
Return the number of top-level windows being used by the application.
Definition: svapp.cxx:1180
ImplPostEventData(VclEventId nEvent, vcl::Window *pWin, const GestureEvent &rGestureEvent)
Definition: svapp.cxx:143
static SAL_DLLPRIVATE void ImplInitAppFontData(vcl::Window const *pWindow)
Definition: window.cxx:1183
LanguageType getLanguageType(bool bResolveSystem=true) const
bool Contains(const Point &rPOINT) const
std::unique_ptr< sal_Int32[]> pData
ImplSVAppData maAppData
Definition: svdata.hxx:398
virtual bool DoExecute(int &nExitCode)
Definition: salvtables.cxx:148
static void RemoveEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
Remove a VCL event listener from the application.
Definition: svapp.cxx:826
void SetMiscSettings(const MiscSettings &rSet)
MouseEventModifiers GetMode() const
Definition: event.hxx:124
long Long
static size_t GetReservedKeyCodeCount()
Get the number of reserved key codes used by the application.
Definition: svapp.cxx:277
std::unique_ptr< GraphicConverter > mxGrfConverter
Definition: svdata.hxx:233
KeyEvent maKeyEvent
Definition: svapp.cxx:128
bool ImplWindowFrameProc(vcl::Window *_pWindow, SalEvent nEvent, const void *pEvent)
Definition: winproc.cxx:2595
void * mpPollClosure
Definition: svdata.hxx:429
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:760
constexpr sal_uInt16 KEY_0
Definition: keycodes.hxx:45
virtual bool IsMainThread() const =0
static ImplSVEvent * PostGestureEvent(VclEventId nEvent, vcl::Window *pWin, GestureEvent const *pGestureEvent)
Definition: svapp.cxx:892
#define PRIO_COUNT
Definition: task.hxx:40
virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:191
SAL_DLLPRIVATE void SetDPIX(sal_Int32 nDPIX)
Definition: outdev.hxx:400
bool IsMapModeEnabled() const
Definition: outdev.hxx:1566
Important idle events to be run before processing drawing events.
sal_Int64 n
ImplPostEventData(VclEventId nEvent, vcl::Window *pWin, const KeyEvent &rKeyEvent)
Definition: svapp.cxx:131
IMPL_STATIC_LINK_NOARG(ImplSVAppData, ImplEndAllPopupsMsg, void *, void)
Definition: svapp.cxx:290
constexpr sal_uInt16 KEY_F4
Definition: keycodes.hxx:86
sal_uInt16 mnButton
Definition: salwtype.hxx:110
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
const MapMode & GetMapMode() const
Definition: outdev.hxx:1572
static void EndAllPopups()
Cancel all open popups.
Definition: svapp.cxx:312
static OUString Localize(TranslateId aId, const bool bLocalize)
Definition: svapp.cxx:1242
static bool IsUnifiedDisplay()
Determines if the screens that make up a display are separate or form one large display area...
Definition: svapp.cxx:1333
virtual int ShowNativeMessageBox(const OUString &rTitle, const OUString &rMessage)=0
Idle * mpEventTestingIdle
Definition: svdata.hxx:166
static OUString GetHWOSConfInfo(const int bSelection=0, bool bLocalize=true)
Get useful OS, Hardware and configuration information, cf.
Definition: svapp.cxx:1261
static void EnableSafeMode()
Set safe mode to enabled.
Definition: svapp.cxx:1696
constexpr sal_uInt16 KEY_F6
Definition: keycodes.hxx:88
static void EndAllDialogs()
Cancel all open dialogs.
Definition: svapp.cxx:307
bool InitAccessBridge()
Definition: svapp.cxx:1729
virtual unsigned int GetDisplayBuiltInScreen()
Definition: salsys.hxx:55
constexpr sal_uInt16 KEY_ADD
Definition: keycodes.hxx:127
std::vector< Link< VclWindowEvent &, bool > > maKeyListeners
Definition: svdata.hxx:143
virtual void Exception(ExceptionCategory nCategory)
Handles an error.
Definition: svapp.cxx:242
virtual bool AnyInput(VclInputFlags nType)=0
An application can be notified of a number of different events:
Definition: svapp.hxx:115
static void AddEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
Add a VCL event listener to the application.
Definition: svapp.cxx:820
ImplSchedulerData * mpFirstSchedulerData[PRIO_COUNT]
list of all active tasks per priority
Definition: svdata.hxx:373
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:193
static bool ImplYield(bool i_bWait, bool i_bAllEvents)
Definition: svapp.cxx:460
void SetMapMode()
Definition: map.cxx:649
static void EnableConsoleOnly()
Enable Console Only mode.
Definition: svapp.cxx:1671
ImplSVGDIData maGDIData
Definition: svdata.hxx:399
std::optional< OUString > mxAppFileName
Definition: svdata.hxx:147
bool mbInAppExecute
Definition: svdata.hxx:158
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:189
static const OUString & GetDesktopEnvironment()
Get the desktop environment the process is currently running in.
Definition: svapp.cxx:1712
static OUString GetCommandLineParam(sal_uInt16 nParam)
Gets a particular command line parameter.
Definition: svapp.cxx:214
VclInputFlags
Definition: inputtypes.hxx:25
static css::uno::Reference< css::awt::XDisplayConnection > GetDisplayConnection()
Definition: svapp.cxx:1624
GestureEventType meEventType
static bool IsSafeModeEnabled()
Determines if safe mode is enabled.
Definition: svapp.cxx:1691
constexpr sal_uInt16 KEY_F1
Definition: keycodes.hxx:83
bool mbResLocaleSet
Definition: svdata.hxx:395
bool IsActive() const
Definition: task.hxx:101
AllSettingsFlags
Definition: settings.hxx:662
static OUString GetOSVersion()
Get the OS version based on the OS specific implementation.
Definition: svapp.cxx:1250
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1164
constexpr sal_uInt16 KEY_9
Definition: keycodes.hxx:54
tools::Long getHeight() const
weld::Window * GetFrameWeld() const
Definition: window2.cxx:871
virtual tools::Rectangle GetDisplayScreenPosSizePixel(unsigned int nScreen)=0
sal_uInt16 GetClicks() const
Definition: event.hxx:126
void * m_pCallbackData
Definition: svapp.hxx:1351
static SAL_DLLPRIVATE vcl::Window * GetDefDialogParent()
Definition: svapp.cxx:1483
bool mbSettingsInit
Definition: svdata.hxx:160
static void ImplCallEventListenersApplicationDataChanged(void *pData)
Send event to all VCL application event listeners.
Definition: svapp.cxx:806
std::vector< ImplPostEventPair > maPostedEventList
Definition: svdata.hxx:144
virtual bool Close() override
Definition: wrkwin.cxx:241
void AcquireYieldMutex(sal_uInt32 nCount=1)
Definition: salvtables.cxx:125
LibreOfficeKitPollCallback mpPollCallback
Definition: svdata.hxx:427
static void SetFilterHdl(const Link< ConvertData &, bool > &rLink)
Setup a new graphics filter.
Definition: svapp.cxx:1637
virtual unsigned int GetDisplayScreenCount()=0
UnoWrapperBase *(* FN_TkCreateUnoWrapper)()
Definition: svapp.cxx:119
sal_uInt16 GetButtons() const
Definition: event.hxx:147
static weld::Window * GetDefDialogParent()
Get the default parent window for dialog boxes.
Definition: svapp.cxx:1540
static unsigned int GetDisplayExternalScreen()
Get the display's external screen.
Definition: svapp.cxx:1345
static void Yield()
Process the next event.
Definition: svapp.cxx:550
void removeListener(const Link< VclSimpleEvent &, void > &rListener)
Definition: vclevent.cxx:68
constexpr sal_uInt16 KEY_1
Definition: keycodes.hxx:46
static bool IsFuzzing()
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:368
constexpr sal_uInt16 KEY_F2
Definition: keycodes.hxx:84
static void RemoveKeyListener(const Link< VclWindowEvent &, bool > &rKeyListener)
Remove a keypress listener from the application.
Definition: svapp.cxx:838
void numberOfViewsChanged(int count)
Definition: svapp.cxx:1824
VclEventId
Definition: vclevent.hxx:37
bool IsTopWindow() const
Definition: stacking.cxx:608
bool mbScreenComp
Definition: virdev.hxx:52
#define SV_APP_VCLBACKEND
Definition: strings.hxx:13
static void SetAppName(const OUString &rUniqueName)
Set the application's name.
Definition: svapp.cxx:1225
static void Quit()
Quit the program.
Definition: svapp.cxx:567
VclPtr< VirtualDevice > mpFirstVirDev
Definition: svdata.hxx:225
ImplSchedulerData * mpNext
Pointer to the next element in list.
tools::Rectangle GetIntersection(const tools::Rectangle &rRect) const
static SystemWindowFlags GetSystemWindowMode()
Get the system window mode of dialogs.
Definition: svapp.cxx:1566
Application * GetpApp()
Definition: svapp.cxx:151
ExceptionCategory
virtual void updateMainThread()
Set the app's (somewhat) magic/main-thread to this one.
Definition: salinst.hxx:202
sal_uInt16 nCode
MouseEvent maMouseEvent
Definition: svapp.cxx:126
void Call(VclSimpleEvent &rEvent) const
Definition: vclevent.cxx:26
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
void registerPollCallbacks(LibreOfficeKitPollCallback pPollCallback, LibreOfficeKitWakeCallback pWakeCallback, void *pData)
Definition: svapp.cxx:1786
static void ImplCallEventListeners(VclSimpleEvent &rEvent)
Send event to all VCL application event listeners.
Definition: svapp.cxx:814
OUString VclResId(TranslateId aId)
Definition: svdata.cxx:260
static bool IsDialogCancelEnabled()
Determines if dialog cancel mode is enabled.
Definition: svapp.cxx:1556
#define SAL_N_ELEMENTS(arr)
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
virtual css::uno::Reference< css::awt::XToolkit > GetVCLToolkit()=0
WinBits const WB_INTROWIN
LibreOfficeKitWakeCallback mpWakeCallback
Definition: svdata.hxx:428
static ImplSVEvent * PostMouseEvent(VclEventId nEvent, vcl::Window *pWin, MouseEvent const *pMouseEvent)
Send mouse event.
Definition: svapp.cxx:996
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
Remove user event based on event ID.
Definition: svapp.cxx:1144
static vcl::Window * GetFirstTopLevelWindow()
Get the first top-level window of the application.
Definition: svapp.cxx:1169
static bool IsEventTestingModeEnabled()
Determines if event testing mode is enabled.
Definition: svapp.cxx:1679
constexpr sal_uInt16 KEY_5
Definition: keycodes.hxx:50
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76
static bool bSafeMode
Definition: svapp.cxx:1689
void clear()
Definition: vclptr.hxx:190
void RemoveAccel(Accelerator const *pAccel)
Definition: accmgr.cxx:46
SalSystem * ImplGetSalSystem()
Definition: svdata.cxx:80
static tools::Rectangle GetScreenPosSizePixel(unsigned int nScreen)
Get a screen's rectangular area.
Definition: svapp.cxx:1368
VclPtr< vcl::Window > mpCaptureWin
Definition: svdata.hxx:256
bool mbCall
Definition: svdata.hxx:464
static bool Reschedule(bool bHandleAllCurrentEvents=false)
Attempt to process current pending event(s)
Definition: svapp.cxx:485
silently cancel any dialogs
static void ShowNativeErrorBox(const OUString &sTitle, const OUString &sMessage)
Definition: svapp.cxx:1701
SvFileStream * mpEventTestInput
Definition: svdata.hxx:165
comphelper::SolarMutex * GetYieldMutex()
Definition: salvtables.cxx:121
ImplPostEventData(VclEventId nEvent, vcl::Window *pWin, const MouseEvent &rMouseEvent)
Definition: svapp.cxx:137
int i
void unregisterPollCallbacks()
Definition: svapp.cxx:1800
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData)=0
virtual void releaseMainThread()
Disconnect that - good for detaching from the JavaVM on Android.
Definition: salinst.hxx:204
VclPtr< vcl::Window > mpInstanceRef
Definition: svdata.hxx:462
void EndAllDialogs(vcl::Window const *pParent)
Definition: dialog.cxx:1191
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
Determine if there are any pending input events.
Definition: svapp.cxx:622
static const LocaleDataWrapper & GetAppLocaleDataWrapper()
Get the application's locale data wrapper.
Definition: svapp.cxx:1642
static void SetSystemWindowMode(SystemWindowFlags nMode)
Make a dialog box a system window or not.
Definition: svapp.cxx:1561
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:207
static void SetSettings(const AllSettings &rSettings)
Sets the application's settings and notifies all windows of the change.
Definition: svapp.cxx:666
Definition: svapp.cxx:1240
static bool InsertAccel(Accelerator *pAccel)
Insert accelerator.
Definition: svapp.cxx:1440
Task * mpTask
Pointer to VCL Task instance.
virtual void DoQuit()
Definition: salvtables.cxx:156
static css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker(const css::uno::Reference< css::uno::XComponentContext > &rServiceManager)
Create a platform specific file picker, if one is available, otherwise return an empty reference...
Definition: svapp.cxx:1762
SystemWindowFlags
Definition: svapp.hxx:87
static void EnableEventTestingMode()
Enables event testing mode.
Definition: svapp.cxx:1684
static void UpdateMainThread()
Update main thread identifier.
Definition: svapp.cxx:1462
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:247
sal_uInt16 & nParam
bool IsMenuFloatingWindow() const
Definition: window2.cxx:1030
SystemWindowFlags mnSysWinMode
Definition: svdata.hxx:156
constexpr tools::Long Right() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
static OUString GetToolkitName()
Get the toolkit's name.
Definition: svapp.cxx:1474
float u
static ImplSVEvent * PostKeyEvent(VclEventId nEvent, vcl::Window *pWin, KeyEvent const *pKeyEvent)
Send keypress event.
Definition: svapp.cxx:869
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:483
constexpr sal_uInt16 KEY_3
Definition: keycodes.hxx:48
LocaleConfigurationListener * mpCfgListener
Definition: svdata.hxx:140
OUString get(TranslateId sContextAndId, const std::locale &loc)
constexpr tools::Long Top() const
static sal_uInt64 GetLastInputInterval()
The interval from the last time that input was received.
Definition: svapp.cxx:627
VclPtr< vcl::Window > mpWin
Definition: svapp.cxx:124
MouseEventModifiers ImplGetMouseMoveMode(SalMouseEvent const *pEvent)
Definition: winproc.cxx:2236
static bool HandleKey(VclEventId nEvent, vcl::Window *pWin, KeyEvent *pKeyEvent)
Handle keypress event.
Definition: svapp.cxx:845
std::optional< AllSettings > mxSettings
Definition: svdata.hxx:139
IMPL_STATIC_LINK(Application, PostEventHandler, void *, pCallData, void)
Definition: svapp.cxx:1032
static bool IsOnSystemEventLoop()
Returns true, if the VCL plugin runs on the system event loop.
Definition: svapp.cxx:496
sal_uInt32 ReleaseYieldMutexAll()
Definition: salvtables.cxx:123
GestureEvent maGestureEvent
Definition: svapp.cxx:129
static unsigned int GetScreenCount()
Get the number of screens available for the display.
Definition: svapp.cxx:1327
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:233
static SAL_DLLPRIVATE unsigned int GetBestScreen(const tools::Rectangle &)
Get the "best" screen.
Definition: svapp.cxx:1394
sal_uInt16 GetModifier() const
Definition: event.hxx:156
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
Definition: svapp.cxx:323
constexpr sal_uInt16 KEY_MOD2
Definition: keycodes.hxx:32
virtual void AppEvent(const ApplicationEvent &rAppEvent)
Definition: svapp.cxx:1751
constexpr sal_uInt16 KEY_F10
Definition: keycodes.hxx:92
VclPtr< vcl::Window > mpTrackWin
Definition: svdata.hxx:261
SAL_DLLPRIVATE vcl::Window * ImplGetClientWindow() const
Definition: window2.cxx:888
static DialogCancelMode GetDialogCancelMode()
Gets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1546
static vcl::Window * GetActiveTopWindow()
Get the "active" top window.
Definition: svapp.cxx:1213
virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString &rAction, const std::vector< vcl::LOKPayloadItem > &rPayload=std::vector< vcl::LOKPayloadItem >()) const override
Definition: svapp.cxx:317
constexpr sal_uInt16 KEY_6
Definition: keycodes.hxx:51
static bool IsInMain()
Queries whether the application is in "main", i.e.
Definition: svapp.cxx:596
SalEvent
Definition: salwtype.hxx:41
ImplSchedulerContext maSchedCtx
Definition: svdata.hxx:397
sal_Int32 mnOffset
static void MergeSystemSettings(AllSettings &rSettings)
Set the settings object to the platform/desktop environment system settings.
Definition: svapp.cxx:647
sal_uInt32 LOKWindowId
constexpr tools::Long Bottom() const
static sal_uInt16 GetCommandLineParamCount()
Gets the number of command line parameters passed to the application.
Definition: svapp.cxx:209
SalFrame * ImplGetFrame() const
Definition: window2.cxx:866
virtual void Init()
Initialize the application itself.
Definition: svapp.cxx:197
virtual bool IsUnifiedDisplay()
Definition: salsys.hxx:48
static void SetDialogCancelMode(DialogCancelMode mode)
Sets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1551
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1159
static void AddToRecentDocumentList(const OUString &rFileUrl, const OUString &rMimeType, const OUString &rDocumentService)
Add a file to the system shells recent document list if there is any.
Definition: svapp.cxx:1723
static void setDeInitHook(Link< LinkParamNone *, void > const &hook)
Definition: svapp.cxx:1775
VCL_DLLPUBLIC bool isVCLSkiaEnabled()
static bool IsInModalMode()
Queries whether application has a modal dialog active.
Definition: svapp.cxx:612
constexpr sal_uInt16 KEY_8
Definition: keycodes.hxx:53
LibreOfficeKitCallback m_pCallback
Definition: svapp.hxx:1352
static sal_uInt32 ReleaseSolarMutex()
Release Solar Mutex(es) for this thread.
Definition: svapp.cxx:584
static void Abort(const OUString &rErrorText)
Ends the program prematurely with an error message.
Definition: svapp.cxx:256
ImplSVEvent * mnEventId
Definition: svapp.cxx:125
static vcl::Window * GetNextTopLevelWindow(vcl::Window const *pWindow)
Get the next top level window.
Definition: svapp.cxx:1175
static bool IsHeadlessModeEnabled()
Determines if headless mode is enabled.
Definition: svapp.cxx:1656
#define SAL_WARN_IF(condition, area, stream)
void ImplDeInitSVData()
Definition: svdata.cxx:88
static void SetUnoWrapper(UnoWrapperBase *pWrapper)
Sets the application's UNO Wrapper object.
Definition: svapp.cxx:1617
bool isUnipoll()
Definition: svapp.cxx:1818
sal_Int32 mnY
ImplSVFrameData maFrameData
Definition: svdata.hxx:400
virtual OUString GetText() const override
Definition: syswin.cxx:1063
static void SetHelp(Help *pHelp=nullptr)
Sets up help.
Definition: svapp.cxx:1457
#define SAL_INFO(area, stream)
static css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rServiceManager)
Create a platform specific folder picker, if one is available, otherwise return an empty reference...
Definition: svapp.cxx:1769
VclPtr< vcl::Window > mpActiveApplicationFrame
Definition: svdata.hxx:246
TOOLKIT_DLLPUBLIC UnoWrapperBase * CreateUnoWrapper()
::OutputDevice const * GetOutDev() const
Definition: window.cxx:567
static void EnableBitmapRendering()
Enable software-only bitmap rendering.
Definition: svapp.cxx:1661
virtual void AddToRecentDocumentList(const OUString &rFileUrl, const OUString &rMimeType, const OUString &rDocumentService)=0
sal_uInt16 mnDispatchLevel
Definition: svdata.hxx:154
IMPL_LINK_NOARG(ImplSVAppData, VclEventTestingHdl, Timer *, void)
Definition: svapp.cxx:386
SAL_DLLPUBLIC_EXPORT void unit_lok_process_events_to_idle()
used by unit tests that test only via the LOK API
Definition: svapp.cxx:543
PanningOrientation meOrientation
VclEventId mnEvent
Definition: svapp.cxx:127
VclEventListeners maEventListeners
Definition: svdata.hxx:141
cancel any dialogs by std::abort
static bool LOKHandleMouseEvent(VclEventId nEvent, vcl::Window *pWin, const MouseEvent *pEvent)
Definition: svapp.cxx:928
void release() const
static void ProcessEventsToIdle()
Process all events until none is pending.
Definition: svapp.cxx:501
static css::uno::Reference< css::awt::XToolkit > GetVCLToolkit()
Gets the VCL toolkit.
Definition: svapp.cxx:1571
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
SAL_DLLPRIVATE void SetDPIY(sal_Int32 nDPIY)
Definition: outdev.hxx:401
virtual bool QueryExit()
Exit from the application.
Definition: svapp.cxx:182
const Point & GetPosPixel() const
Definition: event.hxx:123
virtual void OverrideSystemSettings(AllSettings &rSettings)
Sets user settings in settings object to override system settings.
Definition: svapp.cxx:643
static sal_uInt64 GetSystemTicks()
static void EnableHeadlessMode(bool dialogsAreFatal)
Enables headless mode.
Definition: svapp.cxx:1647
void setMaxSize(size_t nMaxSize)
SAL_DLLPRIVATE void ImplUpdateGlobalSettings(AllSettings &rSettings, bool bCallHdl=true) const
MouseEventModifiers ImplGetMouseButtonMode(SalMouseEvent const *pEvent)
Definition: winproc.cxx:2248
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:258
VclPtr< vcl::Window > mpWindow
Definition: svdata.hxx:463
bool good() const
virtual void DeInit()
Deinitialized the application itself.
Definition: svapp.cxx:205
virtual void Start(bool bStartTimer=true) override
Schedules the task for execution.
Definition: idle.cxx:34
DialogCancelMode meDialogCancel
Definition: svdata.hxx:161
static void RemoveMouseAndKeyEvents(vcl::Window *pWin)
Remove mouse and keypress events from a window...
Definition: svapp.cxx:1097
bool mbRenderToBitmaps
Definition: svdata.hxx:162
const MiscSettings & GetMiscSettings() const
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
VclPtr< vcl::Window > mpFirstFrame
Definition: svdata.hxx:245
Application * mpApp
Definition: svdata.hxx:391
#define SAL_WARN(area, stream)
ImplAccelManager * mpAccelMgr
Definition: svdata.hxx:145
Definition: timer.hxx:26
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:597
static unsigned int GetDisplayBuiltInScreen()
Get the built-in screen.
Definition: svapp.cxx:1339
virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents)=0
Wait for the next event (if bWait) and dispatch it, includes posted events, and timers.
#define DBG_TESTSOLARMUTEX()
std::optional< OUString > mxDisplayName
Definition: svdata.hxx:148
static UnoWrapperBase * GetUnoWrapper(bool bCreateIfNotExists=true)
Get the application's UNO wrapper object.
Definition: svapp.cxx:1590
std::optional< OUString > mxAppName
Definition: svdata.hxx:146
DialogCancelMode
Definition: svapp.hxx:212
lru_scale_cache maScaleCache
Definition: svdata.hxx:231
static const vcl::KeyCode * GetReservedKeyCode(size_t i)
Get the reserved key code.
Definition: svapp.cxx:282
rtl::Reference< vcl::DisplayConnectionDispatch > mxDisplayConnection
Definition: svdata.hxx:411
volatile bool mbAppQuit
Definition: svdata.hxx:159
constexpr sal_uInt16 KEY_MOD3
Definition: keycodes.hxx:33
constexpr sal_uInt16 KEY_SHIFT
Definition: keycodes.hxx:30
bool InsertAccel(Accelerator *pAccel)
Definition: accmgr.cxx:30
virtual ~Application()
Virtual destructor for Application class.
Definition: svapp.cxx:170
tools::Long GetOutOffXPixel() const
Definition: window3.cxx:123
UnoWrapperBase * mpUnoWrapper
Definition: svdata.hxx:405
vcl::Window * ImplGetDefaultWindow()
Returns either the application window, or the default GL context window.
Definition: svdata.cxx:211
static OUString GetAppFileName()
Get the name of the file used to start the application.
Definition: svapp.cxx:221
const char * GetDebugName() const
Definition: task.hxx:82
bool mbInAppMain
Definition: svdata.hxx:157
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
Definition: outdev.hxx:398
SAL_DLLPRIVATE AllSettingsFlags GetChangeFlags(const AllSettings &rSettings) const
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:949
static void thisModule()
Definition: svapp.cxx:1586
int mnEventTestLimit
Definition: svdata.hxx:167
static void RemoveAccel(Accelerator const *pAccel)
Remove accelerator.
Definition: svapp.cxx:1449
AnyEventRef aEvent
SalInstance * mpDefInst
Definition: svdata.hxx:390
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
Get the output device's DPI x-axis value.
Definition: outdev.hxx:392
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
bool mbInScheduler
Is the Task currently processed / on the stack?
ImplSVWinData * mpWinData
Definition: svdata.hxx:401
static bool IsQuit()
Has Quit() been called?
Definition: svapp.cxx:607
static void SetDisplayName(const OUString &rDisplayName)
Set the default name of the application for message dialogs and printing.
Definition: svapp.cxx:1310
void addListener(const Link< VclSimpleEvent &, void > &rListener)
Definition: vclevent.cxx:62
void UpdateSettings(const AllSettings &rSettings, bool bChild=false)
static void Execute()
Run the main event processing loop until it is quit by Quit().
Definition: svapp.cxx:427
static bool hasNativeFileSelection()
Do we have a native / system file selector available?
Definition: svapp.cxx:1755
static void AddKeyListener(const Link< VclWindowEvent &, bool > &rKeyListener)
Add a keypress listener to the application.
Definition: svapp.cxx:832
virtual int Main()
Pure virtual entrypoint to the application.
Definition: svapp.cxx:176
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo