From: Eunki Hong Date: Sat, 31 May 2025 07:41:17 +0000 (+0900) Subject: Seperate trigger event factory for macos + change file name X-Git-Tag: dali_2.4.22~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f54a848d18819ab6c0454c9201dc08c991cb36c;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Seperate trigger event factory for macos + change file name Change-Id: Ibd674d46fe59c205780704b826bb7e6215712ebd Signed-off-by: Eunki Hong --- diff --git a/dali/internal/system/file.list b/dali/internal/system/file.list index e0bb02656..c6f4c5e8f 100644 --- a/dali/internal/system/file.list +++ b/dali/internal/system/file.list @@ -140,8 +140,8 @@ SET( adaptor_system_windows_src_files ${adaptor_system_dir}/windows/system-factory-win.cpp ${adaptor_system_dir}/windows/system-settings-win.cpp ${adaptor_system_dir}/windows/timer-impl-win.cpp - ${adaptor_system_dir}/windows/trigger-event.cpp - ${adaptor_system_dir}/windows/trigger-event-factory.cpp + ${adaptor_system_dir}/windows/trigger-event-win.cpp + ${adaptor_system_dir}/windows/trigger-event-factory-win.cpp ${adaptor_system_dir}/windows/logging-win.cpp ${adaptor_system_dir}/windows/widget-application-impl-win.cpp ${adaptor_system_dir}/windows/widget-controller-win.cpp @@ -151,14 +151,14 @@ SET( adaptor_system_windows_src_files SET( adaptor_system_macos_src_files ${adaptor_system_dir}/common/shared-file.cpp ${adaptor_system_dir}/common/time-service.cpp - ${adaptor_system_dir}/common/trigger-event-factory.cpp ${adaptor_system_dir}/generic/shared-file-operations-generic.cpp ${adaptor_system_dir}/generic/system-error-print-generic.cpp ${adaptor_system_dir}/macos/file-descriptor-monitor-macos.cpp ${adaptor_system_dir}/macos/system-factory-mac.cpp ${adaptor_system_dir}/macos/system-settings-mac.cpp ${adaptor_system_dir}/macos/timer-impl-mac.cpp - ${adaptor_system_dir}/macos/trigger-event.mm + ${adaptor_system_dir}/macos/trigger-event-factory-mac.cpp + ${adaptor_system_dir}/macos/trigger-event-mac.mm ${adaptor_system_dir}/macos/callback-manager-mac.mm ${adaptor_system_dir}/macos/widget-application-impl-mac.cpp ${adaptor_system_dir}/ubuntu-x11/logging-x.cpp diff --git a/dali/internal/system/macos/trigger-event-factory-mac.cpp b/dali/internal/system/macos/trigger-event-factory-mac.cpp new file mode 100644 index 000000000..d51a75e8e --- /dev/null +++ b/dali/internal/system/macos/trigger-event-factory-mac.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * + * Licensed 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options) +{ + return new Internal::Adaptor::TriggerEvent(callback, options); +} + +void TriggerEventFactory::DestroyTriggerEvent(TriggerEventInterface* triggerEventInterface) +{ + Internal::Adaptor::TriggerEvent* triggerEvent(static_cast(triggerEventInterface)); + delete triggerEvent; +} + +} // namespace Dali diff --git a/dali/internal/system/macos/trigger-event-mac.h b/dali/internal/system/macos/trigger-event-mac.h new file mode 100644 index 000000000..c4abcc155 --- /dev/null +++ b/dali/internal/system/macos/trigger-event-mac.h @@ -0,0 +1,70 @@ +#pragma once + +/* + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * + * Licensed 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include + +#include + +namespace Dali::Internal::Adaptor +{ +class TriggerEvent : public TriggerEventInterface +{ +public: + /** + * Constructor + * Creates an event file descriptor and starts a GSource which reads from the file + * descriptor when there is data. + * + * @param[in] callback The callback to call + * @param[in] options Trigger event options. + * @note The ownership of callback is taken by this class. + */ + TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options); + + /** + * Destructor + */ + ~TriggerEvent(); + + /** + * Triggers the event. + * + * This can be called from one thread in order to wake up another thread. + */ + void Trigger() override; + + struct Impl; + +private: + /** + * @brief Called when our event file descriptor has been written to. + * @param[in] eventBitMask bit mask of events that occured on the file descriptor + */ + void Triggered(); + + std::unique_ptr mCallback; + std::unique_ptr mImpl; +}; + +} // namespace Dali::Internal::Adaptor diff --git a/dali/internal/system/macos/trigger-event-mac.mm b/dali/internal/system/macos/trigger-event-mac.mm new file mode 100644 index 000000000..e183ae9a7 --- /dev/null +++ b/dali/internal/system/macos/trigger-event-mac.mm @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * + * Licensed 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +#include +#include +#include +#include + +#include + +namespace +{ +const char *EventName = "Dali::Internal::Adaptor::Triggerevent_"; +} + +@interface NotificationObserver : NSObject + +-(NotificationObserver *) initTriggerImpl:(Dali::Internal::Adaptor::TriggerEvent::Impl *) impl; + +@end + +namespace Dali::Internal::Adaptor +{ + +struct TriggerEvent::Impl final +{ + std::unique_ptr mCallback; + NotificationObserver *mReceiver; + NSString *mName; + TriggerEventInterface::Options mOptions; + + Impl(CallbackBase *callback, TriggerEventInterface::Options options) + : mCallback(callback), mOptions(options) + { + const auto myId = mNameId.fetch_add(1, std::memory_order_relaxed); + + std::stringstream ss; + ss << EventName << myId; + mName = [NSString stringWithUTF8String:ss.str().c_str()]; + + mReceiver = [[NotificationObserver alloc] initTriggerImpl:this]; + } + + Impl(Impl &&) = delete; + Impl &operator=(Impl &&) = delete; + + ~Impl() + { + auto *center = [NSNotificationCenter defaultCenter]; + [center removeObserver:mReceiver]; + } + + void Trigged() + { + CallbackBase::Execute( *mCallback ); + } + +private: + // This is incremented each time the class is instatiated to guarantee + // an unique notification id + static std::atomic_uint64_t mNameId; +}; + +std::atomic TriggerEvent::Impl::mNameId{0}; + +TriggerEvent::TriggerEvent(CallbackBase *callback, TriggerEventInterface::Options options) + : mCallback(callback), + mImpl(std::make_unique(MakeCallback(this, &TriggerEvent::Triggered), options)) +{ +} + +TriggerEvent::~TriggerEvent() = default; + +void TriggerEvent::Trigger() +{ + auto center = [NSDistributedNotificationCenter defaultCenter]; + + // Post a notification to the notification center + // The run loop will pop the queue and call the notification center + [center postNotificationName:mImpl->mName object:nil]; +} + +void TriggerEvent::Triggered() +{ + CallbackBase::Execute(*mCallback); + + if (mImpl->mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER) + { + delete this; + } +} + +} + +@implementation NotificationObserver +{ + Dali::Internal::Adaptor::TriggerEvent::Impl *mImpl; +} + +-(void) ReceiveNotification: (NSNotification *) aNotification +{ + mImpl->Trigged(); +} + +-(NotificationObserver *) initTriggerImpl:(Dali::Internal::Adaptor::TriggerEvent::Impl *) impl; +{ + self = [super init]; + if (self) + { + mImpl = impl; + auto center = [NSDistributedNotificationCenter defaultCenter]; + [center addObserver:self + selector:@selector(ReceiveNotification:) + name:impl->mName + object:nil + suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; + } + + return self; +} + +@end diff --git a/dali/internal/system/macos/trigger-event.h b/dali/internal/system/macos/trigger-event.h deleted file mode 100644 index a41e0bd60..000000000 --- a/dali/internal/system/macos/trigger-event.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include - -#include - -namespace Dali::Internal::Adaptor -{ -class TriggerEvent : public TriggerEventInterface -{ -public: - /** - * Constructor - * Creates an event file descriptor and starts a GSource which reads from the file - * descriptor when there is data. - * - * @param[in] callback The callback to call - * @param[in] options Trigger event options. - * @note The ownership of callback is taken by this class. - */ - TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options); - - /** - * Triggers the event. - * - * This can be called from one thread in order to wake up another thread. - */ - void Trigger() override; - - struct Impl; - -private: - /** - * @brief Called when our event file descriptor has been written to. - * @param[in] eventBitMask bit mask of events that occured on the file descriptor - */ - void Triggered(); - - std::unique_ptr mCallback; - std::unique_ptr mImpl; -}; - -} // namespace Dali::Internal::Adaptor diff --git a/dali/internal/system/macos/trigger-event.mm b/dali/internal/system/macos/trigger-event.mm deleted file mode 100644 index 89b31d121..000000000 --- a/dali/internal/system/macos/trigger-event.mm +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. - * - * Licensed 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -#include -#include -#include -#include -#include "trigger-event.h" - -namespace -{ -const char *EventName = "Dali::Internal::Adaptor::Triggerevent_"; -} - -@interface NotificationObserver : NSObject - --(NotificationObserver *) initTriggerImpl:(Dali::Internal::Adaptor::TriggerEvent::Impl *) impl; - -@end - -namespace Dali::Internal::Adaptor -{ - -struct TriggerEvent::Impl final -{ - std::unique_ptr mCallback; - NotificationObserver *mReceiver; - NSString *mName; - TriggerEventInterface::Options mOptions; - - Impl(CallbackBase *callback, TriggerEventInterface::Options options) - : mCallback(callback), mOptions(options) - { - const auto myId = mNameId.fetch_add(1, std::memory_order_relaxed); - - std::stringstream ss; - ss << EventName << myId; - mName = [NSString stringWithUTF8String:ss.str().c_str()]; - - mReceiver = [[NotificationObserver alloc] initTriggerImpl:this]; - } - - Impl(Impl &&) = delete; - Impl &operator=(Impl &&) = delete; - - ~Impl() - { - auto *center = [NSNotificationCenter defaultCenter]; - [center removeObserver:mReceiver]; - } - - void Trigged() - { - CallbackBase::Execute( *mCallback ); - } - -private: - // This is incremented each time the class is instatiated to guarantee - // an unique notification id - static std::atomic_uint64_t mNameId; -}; - -std::atomic TriggerEvent::Impl::mNameId{0}; - -TriggerEvent::TriggerEvent(CallbackBase *callback, TriggerEventInterface::Options options) - : mCallback(callback) - , mImpl(std::make_unique(MakeCallback(this, &TriggerEvent::Triggered), options)) -{ -} - -void TriggerEvent::Trigger() -{ - auto center = [NSDistributedNotificationCenter defaultCenter]; - - // Post a notification to the notification center - // The run loop will pop the queue and call the notification center - [center postNotificationName:mImpl->mName object:nil]; -} - -void TriggerEvent::Triggered() -{ - CallbackBase::Execute(*mCallback); - - if (mImpl->mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER) - { - delete this; - } -} - -} - -@implementation NotificationObserver -{ - Dali::Internal::Adaptor::TriggerEvent::Impl *mImpl; -} - --(void) ReceiveNotification: (NSNotification *) aNotification -{ - mImpl->Trigged(); -} - --(NotificationObserver *) initTriggerImpl:(Dali::Internal::Adaptor::TriggerEvent::Impl *) impl; -{ - self = [super init]; - if (self) - { - mImpl = impl; - auto center = [NSDistributedNotificationCenter defaultCenter]; - [center addObserver:self - selector:@selector(ReceiveNotification:) - name:impl->mName - object:nil - suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; - } - - return self; -} - -@end diff --git a/dali/internal/system/windows/trigger-event-factory-win.cpp b/dali/internal/system/windows/trigger-event-factory-win.cpp new file mode 100644 index 000000000..4da90fcd8 --- /dev/null +++ b/dali/internal/system/windows/trigger-event-factory-win.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * + * Licensed 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +namespace Dali +{ +TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options) +{ + return new Internal::Adaptor::TriggerEvent(callback, options); +} + +void TriggerEventFactory::DestroyTriggerEvent(TriggerEventInterface* triggerEventInterface) +{ + Internal::Adaptor::TriggerEvent* triggerEvent(static_cast(triggerEventInterface)); + delete triggerEvent; +} + +} // namespace Dali diff --git a/dali/internal/system/windows/trigger-event-factory.cpp b/dali/internal/system/windows/trigger-event-factory.cpp deleted file mode 100644 index ffda95068..000000000 --- a/dali/internal/system/windows/trigger-event-factory.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ -TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options) -{ - return new Internal::Adaptor::TriggerEvent(callback, options); -} - -void TriggerEventFactory::DestroyTriggerEvent(TriggerEventInterface* triggerEventInterface) -{ - Internal::Adaptor::TriggerEvent* triggerEvent(static_cast(triggerEventInterface)); - delete triggerEvent; -} - -} // namespace Dali diff --git a/dali/internal/system/windows/trigger-event-win.cpp b/dali/internal/system/windows/trigger-event-win.cpp new file mode 100644 index 000000000..929f1529d --- /dev/null +++ b/dali/internal/system/windows/trigger-event-win.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * + * Licensed 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +TriggerEvent::TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options) +: mCallback(callback), + mThreadID(-1), + mOptions(options) +{ + // Create accompanying file descriptor. + mThreadID = WindowsPlatform::GetCurrentThreadId(); + + if(mThreadID < 0) + { + DALI_LOG_ERROR("Unable to create TriggerEvent File descriptor\n"); + } + + mSelfCallback = MakeCallback(this, &TriggerEvent::Triggered); +} + +TriggerEvent::~TriggerEvent() +{ + delete mCallback; + delete mSelfCallback; + + if(mThreadID >= 0) + { + mThreadID = 0; + } +} + +void TriggerEvent::Trigger() +{ + if(mThreadID >= 0) + { + // Increment event counter by 1. + // Writing to the file descriptor triggers the Dispatch() method in the other thread + // (if in multi-threaded environment). + WindowsPlatform::PostWinThreadMessage(WIN_CALLBACK_EVENT, reinterpret_cast(mSelfCallback), 0, mThreadID); + } + else + { + DALI_LOG_ERROR("Attempting to write to an invalid file descriptor\n"); + } +} + +void TriggerEvent::Triggered() +{ + // Call the connected callback + CallbackBase::Execute(*mCallback); + + // check if we should delete ourselves after the trigger + if(mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER) + { + delete this; + } +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/system/windows/trigger-event-win.h b/dali/internal/system/windows/trigger-event-win.h new file mode 100644 index 000000000..57ab55617 --- /dev/null +++ b/dali/internal/system/windows/trigger-event-win.h @@ -0,0 +1,81 @@ +#ifndef DALI_INTERNAL_TRIGGER_EVENT_IMPL_H +#define DALI_INTERNAL_TRIGGER_EVENT_IMPL_H + +/* + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * + * Licensed 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class TriggerEvent : public TriggerEventInterface +{ +public: + /** + * Constructor + * Creates an event file descriptor and starts a GSource which reads from the file + * descriptor when there is data. + * + * @param[in] callback The callback to call + * @param[in] options Trigger event options. + * @note The ownership of callback is taken by this class. + */ + TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options); + + /** + * Destructor + */ + ~TriggerEvent(); + +public: + /** + * Triggers the event. + * + * This can be called from one thread in order to wake up another thread. + */ + void Trigger(); + +private: + /** + * @brief Called when our event file descriptor has been written to. + * @param[in] eventBitMask bit mask of events that occured on the file descriptor + */ + void Triggered(); + +private: + CallbackBase* mCallback; + CallbackBase* mSelfCallback; + int32_t mThreadID; + TriggerEventInterface::Options mOptions; +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_TRIGGER_EVENT_IMPL_H \ No newline at end of file diff --git a/dali/internal/system/windows/trigger-event.cpp b/dali/internal/system/windows/trigger-event.cpp deleted file mode 100644 index f1c9efaab..000000000 --- a/dali/internal/system/windows/trigger-event.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2025 Samsung Electronics Co., Ltd. - * - * Licensed 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include - -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ -namespace Internal -{ -namespace Adaptor -{ -TriggerEvent::TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options) -: mCallback(callback), - mThreadID(-1), - mOptions(options) -{ - // Create accompanying file descriptor. - mThreadID = WindowsPlatform::GetCurrentThreadId(); - - if(mThreadID < 0) - { - DALI_LOG_ERROR("Unable to create TriggerEvent File descriptor\n"); - } - - mSelfCallback = MakeCallback(this, &TriggerEvent::Triggered); -} - -TriggerEvent::~TriggerEvent() -{ - delete mCallback; - delete mSelfCallback; - - if(mThreadID >= 0) - { - mThreadID = 0; - } -} - -void TriggerEvent::Trigger() -{ - if(mThreadID >= 0) - { - // Increment event counter by 1. - // Writing to the file descriptor triggers the Dispatch() method in the other thread - // (if in multi-threaded environment). - WindowsPlatform::PostWinThreadMessage(WIN_CALLBACK_EVENT, reinterpret_cast(mSelfCallback), 0, mThreadID); - } - else - { - DALI_LOG_ERROR("Attempting to write to an invalid file descriptor\n"); - } -} - -void TriggerEvent::Triggered() -{ - // Call the connected callback - CallbackBase::Execute(*mCallback); - - //check if we should delete ourselves after the trigger - if(mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER) - { - delete this; - } -} - -} // namespace Adaptor - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/system/windows/trigger-event.h b/dali/internal/system/windows/trigger-event.h deleted file mode 100644 index 292f0ade4..000000000 --- a/dali/internal/system/windows/trigger-event.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef DALI_INTERNAL_TRIGGER_EVENT_IMPL_H -#define DALI_INTERNAL_TRIGGER_EVENT_IMPL_H - -/* -* Copyright (c) 2021 Samsung Electronics Co., Ltd. -* -* Licensed 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 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ -namespace Internal -{ -namespace Adaptor -{ -class TriggerEvent : public TriggerEventInterface -{ -public: - /** - * Constructor - * Creates an event file descriptor and starts a GSource which reads from the file - * descriptor when there is data. - * - * @param[in] callback The callback to call - * @param[in] options Trigger event options. - * @note The ownership of callback is taken by this class. - */ - TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options); - - /** - * Destructor - */ - ~TriggerEvent(); - -public: - /** - * Triggers the event. - * - * This can be called from one thread in order to wake up another thread. - */ - void Trigger(); - -private: - /** - * @brief Called when our event file descriptor has been written to. - * @param[in] eventBitMask bit mask of events that occured on the file descriptor - */ - void Triggered(); - -private: - CallbackBase* mCallback; - CallbackBase* mSelfCallback; - int32_t mThreadID; - TriggerEventInterface::Options mOptions; -}; - -} // namespace Adaptor - -} // namespace Internal - -} // namespace Dali - -#endif // DALI_INTERNAL_TRIGGER_EVENT_IMPL_H \ No newline at end of file