13#include "kddockwidgets/KDDockWidgets.h"
17#include "views/View.h"
18#include "core/Platform_p.h"
19#include "core/Logging_p.h"
20#include "core/ObjectGuard_p.h"
23#include "kddockwidgets/core/MainWindow.h"
33class flutter::Platform::Private
36 std::shared_ptr<Core::View> m_focusedView;
37 std::optional<int> m_testsResult;
57 return d->m_focusedView;
62 KDDW_WARN(
"Platform::windows: Not implemented");
68 KDDW_WARN(
"Platform::sendEvent: Not implemented");
73 KDDW_WARN(
"Platform::name: Not implemented");
89 KDDW_WARN(
"Platform::windowAt: Not implemented");
95 KDDW_WARN(
"Platform::screenNumberFor: Not implemented");
101 KDDW_WARN(
"Platform::screenNumberFor: Not implemented");
107 KDDW_WARN(
"Platform::isProcessingAppQuitEven: Not implemented");
120 KDDW_WARN(
"Platform::setMouseCursor: Not implemented");
125 KDDW_WARN(
"Platform::restoreMouseCursor: Not implemented");
136 KDDW_WARN(
"Platform::isLeftMouseButtonPressed: Not implemented");
142 KDDW_WARN(
"Platform::screenSizeFor: Not implemented");
148 KDDW_WARN(
"Platform::createView: Not implemented");
164 KDDW_WARN(
"Platform::ungrabMouse: Not implemented");
175 return std::make_shared<flutter::Screen>();
180 KDDW_WARN(
"Platform::onFloatingWindowCreated: Implemented in dart");
185 KDDW_WARN(
"Platform::onFloatingWindowDestroyed: Implemented in dart");
190 KDDW_WARN(
"Platform::onMainWindowCreated: Implemented in dart");
195 KDDW_WARN(
"Platform::onMainWindowDestroyed: Implemented in dart");
200 KDDW_WARN(
"Platform::onDropIndicatorOverlayCreated: Implemented in dart");
205 KDDW_WARN(
"Platform::onDropIndicatorOverlayDestroyed: Implemented in dart");
210 KDDW_WARN(
"Platform::rebuildWindowOverlay: Implemented in dart");
225 KDDW_WARN(
"Platform::setCursorPos: Not implemented");
229#ifdef DOCKS_TESTING_METHODS
231void Platform::installMessageHandler()
235void Platform::uninstallMessageHandler()
239void Platform::pauseForDebugger()
241 pauseForDartDebugger();
250 explicit TestView_flutter(Core::CreateViewOptions opts,
Core::View *)
258 Size maxSizeHint()
const override
264 Core::CreateViewOptions m_opts;
270 explicit FocusableTestView_flutter(Core::CreateViewOptions opts,
Core::View *)
276 ~FocusableTestView_flutter();
278 Size maxSizeHint()
const override
284 Core::CreateViewOptions m_opts;
290 explicit NonClosableTestView_flutter(
Core::View *)
295 ~NonClosableTestView_flutter();
298TestView_flutter::~TestView_flutter() =
default;
299NonClosableTestView_flutter::~NonClosableTestView_flutter() =
default;
300FocusableTestView_flutter::~FocusableTestView_flutter() =
default;
305void Platform::runTests()
307#ifdef KDDW_FLUTTER_HAS_COROUTINES
309 assert(s_runTestsFunc);
313 s_runTestsFunc().then([
this](
auto result) {
314 std::lock_guard<std::mutex> locker(
m_mutex);
315 assert(!
d->m_testsResult.has_value());
316 d->m_testsResult = result ? 0 : 1;
321void Platform::resumeCoRoutines()
323#ifdef KDDW_FLUTTER_HAS_COROUTINES
324 m_coRoutines.resume();
328void Platform::scheduleResumeCoRoutines(
int)
const
330 KDDW_WARN(
"Platform::scheduleResumeCoRoutines: Implemented in dart instead");
333std::optional<int> Platform::testsResult()
const
335 std::lock_guard<std::mutex> locker(
m_mutex);
336 return d->m_testsResult;
339void Platform::tests_initPlatform_impl()
343void Platform::tests_deinitPlatform_impl()
353Core::View *Platform::tests_createFocusableView(Core::CreateViewOptions opts,
Core::View *parent)
356 return tests_createView(opts, parent);
362 return tests_createView({ .isVisible =
true }, parent);
378 d->m_focusedView = view;
381#ifdef KDDW_FLUTTER_HAS_COROUTINES
383Platform::RunTestsFunc Platform::s_runTestsFunc =
nullptr;
385KDDW_QCORO_TASK Platform::tests_waitForWindowActive(std::shared_ptr<Core::Window>,
int)
const
387 co_return co_await tests_wait(1000);
390KDDW_QCORO_TASK Platform::tests_waitForEvent(Core::Object *, Event::Type,
int)
const
392 co_return co_await tests_wait(1000);
395KDDW_QCORO_TASK Platform::tests_waitForEvent(
Core::View *, Event::Type,
int)
const
397 co_return co_await tests_wait(1000);
400KDDW_QCORO_TASK Platform::tests_waitForEvent(std::shared_ptr<Core::Window>, Event::Type,
403 co_return co_await tests_wait(1000);
406KDDW_QCORO_TASK Platform::tests_wait(
int ms)
const
409 scheduleResumeCoRoutines(ms);
412 co_await m_coRoutines.suspend();
417KDDW_QCORO_TASK Platform::tests_waitForResize(
Core::View *,
int)
const
419 co_return co_await tests_wait(1000);
424 co_return co_await tests_wait(1000);
427KDDW_QCORO_TASK Platform::tests_waitForDeleted(
Core::Controller *obj,
int timeout)
const
432 Core::ObjectGuard<Core::Controller> guard = obj;
434 const int step = 100;
436 while (guard && elapsed < timeout) {
437 co_await tests_wait(step);
441 co_return guard.isNull();
444KDDW_QCORO_TASK Platform::tests_waitForDeleted(
Core::View *view,
int timeout)
const
452 const int step = 100;
454 while (guard && elapsed < timeout) {
455 co_await tests_wait(step);
459 co_return guard.isNull();
462std::shared_ptr<Core::Window> Platform::tests_createWindow()
464 auto window =
new flutter::Window(tests_createView({},
nullptr)->asWrapper());
465 return std::shared_ptr<Core::Window>(window);
468void Platform::tests_doubleClickOn(Point,
Core::View *)
470 KDDW_WARN(
"Platform::tests_doubleClickOn: Not implemented yet");
473void Platform::tests_doubleClickOn(Point, std::shared_ptr<Core::Window>)
475 KDDW_WARN(
"Platform::tests_doubleClickOn: Not implemented yet");
481void Platform::tests_pressOn(Point globalPos,
Core::View *)
483 kddw_fakeMouseButton(globalPos,
true);
486void Platform::tests_pressOn(Point globalPos, std::shared_ptr<Core::Window>)
488 kddw_fakeMouseButton(globalPos,
true);
491KDDW_QCORO_TASK Platform::tests_releaseOn(Point globalPos,
Core::View *)
493 co_await kddw_fakeMouseButton(globalPos,
false);
497KDDW_QCORO_TASK Platform::tests_mouseMove(Point globalPos,
Core::View *)
499 co_await kddw_fakeMouseMove(globalPos);
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
An asynchronously executed task.