| Date: Wed, 7 Jul 2021 18:22:04 +000 |
| From: 51bcca413901a9bb9fd0c299d01eff09859f67e1 Mon Sep 17 00:00:00 2001 |
| Subject: [PATCH] support for focus events |
| Source: COMCAST |
| Upstream-Status: Pending |
| Signed-off-by: mfiess200 <michael_fiess@cable.comcast.com> |
| |
| |
| --- |
| diff --git a/RDKShell/RDKShell.cpp b/RDKShell/RDKShell.cpp |
| index 6c099e1..93ecb97 100755 |
| --- a/RDKShell/RDKShell.cpp |
| +++ b/RDKShell/RDKShell.cpp |
| @@ -29,6 +29,7 @@ |
| #include <rdkshell/compositorcontroller.h> |
| #include <rdkshell/application.h> |
| #include <rdkshell/logger.h> |
| +#include <interfaces/IFocus.h> |
| #include <interfaces/IMemory.h> |
| #include <interfaces/IBrowser.h> |
| #include <rdkshell/logger.h> |
| @@ -545,6 +546,13 @@ namespace WPEFramework { |
| return exist; |
| } |
| |
| + std::string toLower(const std::string& clientName) |
| + { |
| + std::string displayName = clientName; |
| + std::transform(displayName.begin(), displayName.end(), displayName.begin(), [](unsigned char c){ return std::tolower(c); }); |
| + return displayName; |
| + } |
| + |
| void RDKShell::MonitorClients::StateChange(PluginHost::IShell* service) |
| { |
| if (service) |
| @@ -5320,9 +5328,56 @@ namespace WPEFramework { |
| bool RDKShell::setFocus(const string& client) |
| { |
| bool ret = false; |
| + std::string previousFocusedClient; |
| lockRdkShellMutex(); |
| + CompositorController::getFocused(previousFocusedClient); |
| ret = CompositorController::setFocus(client); |
| gRdkShellMutex.unlock(); |
| + std::string clientLower = toLower(client); |
| + |
| + if (previousFocusedClient != clientLower) |
| + { |
| + std::map<std::string, PluginData> activePluginsData; |
| + gPluginDataMutex.lock(); |
| + activePluginsData = gActivePluginsData; |
| + gPluginDataMutex.unlock(); |
| + |
| + if (!previousFocusedClient.empty()) |
| + { |
| + std::map<std::string, PluginData>::iterator previousFocusedIterator; |
| + |
| + for (previousFocusedIterator = activePluginsData.begin(); previousFocusedIterator != activePluginsData.end(); previousFocusedIterator++) |
| + { |
| + std::string compositorName = toLower(previousFocusedIterator->first); |
| + if (compositorName == previousFocusedClient) |
| + { |
| + std::cout << "setting the focus of " << compositorName << " to false " << std::endl; |
| + Exchange::IFocus *focusedCallsign = mCurrentService->QueryInterfaceByCallsign<Exchange::IFocus>(previousFocusedIterator->first); |
| + if (focusedCallsign != NULL) |
| + { |
| + uint32_t status = focusedCallsign->Focused(false); |
| + std::cout << "result of set focus to false: " << status << std::endl; |
| + focusedCallsign->Release(); |
| + } |
| + break; |
| + } |
| + } |
| + } |
| + |
| + std::map<std::string, PluginData>::iterator focusedEntry = activePluginsData.find(client); |
| + if (focusedEntry != activePluginsData.end()) |
| + { |
| + PluginData& pluginData = focusedEntry->second; |
| + std::cout << "setting the focus of " << client << " to true " << std::endl; |
| + Exchange::IFocus *focusedCallsign = mCurrentService->QueryInterfaceByCallsign<Exchange::IFocus>(client); |
| + if (focusedCallsign != NULL) |
| + { |
| + uint32_t status = focusedCallsign->Focused(true); |
| + focusedCallsign->Release(); |
| + std::cout << "result of set focus to true: " << status << std::endl; |
| + } |
| + } |
| + } |
| return ret; |
| } |