From f26a9b64624c91e7632a7683338932952483e924 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 28 Nov 2016 21:56:24 +0900 Subject: [PATCH 2/8] Initial commit - screen_connector_watcher - screen_connector_watcher_evas Change-Id: I884dcd1139825dc67a5b3a18e7cbe18d92cc150d Signed-off-by: Hyunho Kang --- CMakeLists.txt | 7 + LICENSE | 204 ++++++ packaging/libscreen_connector.spec | 143 ++++ packaging/libscreen_connector_provider.manifest | 5 + packaging/libscreen_connector_watcher.manifest | 5 + .../libscreen_connector_watcher_evas.manifest | 5 + screen_connector_provider/CMakeLists.txt | 47 ++ screen_connector_provider/LICENSE | 204 ++++++ .../include/screen_connector_provider.h | 33 + .../screen_connector_provider.pc.in | 11 + .../src/screen_connector_provider.c | 191 +++++ screen_connector_watcher/CMakeLists.txt | 47 ++ screen_connector_watcher/LICENSE | 204 ++++++ .../include/screen_connector_watcher.h | 61 ++ .../screen_connector_watcher.pc.in | 11 + .../src/screen_connector_watcher.c | 790 +++++++++++++++++++++ screen_connector_watcher_evas/CMakeLists.txt | 44 ++ screen_connector_watcher_evas/LICENSE | 204 ++++++ .../include/screen_connector_watcher_evas.h | 69 ++ .../screen_connector_watcher_evas.pc.in | 12 + .../src/screen_connector_watcher_evas.c | 129 ++++ 21 files changed, 2426 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 packaging/libscreen_connector.spec create mode 100644 packaging/libscreen_connector_provider.manifest create mode 100644 packaging/libscreen_connector_watcher.manifest create mode 100644 packaging/libscreen_connector_watcher_evas.manifest create mode 100644 screen_connector_provider/CMakeLists.txt create mode 100644 screen_connector_provider/LICENSE create mode 100644 screen_connector_provider/include/screen_connector_provider.h create mode 100644 screen_connector_provider/screen_connector_provider.pc.in create mode 100644 screen_connector_provider/src/screen_connector_provider.c create mode 100644 screen_connector_watcher/CMakeLists.txt create mode 100644 screen_connector_watcher/LICENSE create mode 100644 screen_connector_watcher/include/screen_connector_watcher.h create mode 100644 screen_connector_watcher/screen_connector_watcher.pc.in create mode 100644 screen_connector_watcher/src/screen_connector_watcher.c create mode 100644 screen_connector_watcher_evas/CMakeLists.txt create mode 100644 screen_connector_watcher_evas/LICENSE create mode 100644 screen_connector_watcher_evas/include/screen_connector_watcher_evas.h create mode 100644 screen_connector_watcher_evas/screen_connector_watcher_evas.pc.in create mode 100644 screen_connector_watcher_evas/src/screen_connector_watcher_evas.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8d5a8a9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +ADD_SUBDIRECTORY(screen_connector_provider) +ADD_SUBDIRECTORY(screen_connector_watcher) +ADD_SUBDIRECTORY(screen_connector_watcher_evas) + +ADD_DEPENDENCIES(screen_connector_watcher_evas screen_connector_watcher) \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c13a9b --- /dev/null +++ b/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/packaging/libscreen_connector.spec b/packaging/libscreen_connector.spec new file mode 100644 index 0000000..c419aa0 --- /dev/null +++ b/packaging/libscreen_connector.spec @@ -0,0 +1,143 @@ +Name: libscreen_connector +Summary: Library for developing the application +Version: 1.0 +Release: 1 +Group: Applications/Core Applications +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +Source1001: %{name}_watcher.manifest +Source1002: %{name}_watcher_evas.manifest +Source1003: %{name}_provider.manifest +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(wayland-tbm-client) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(wayland-client) +BuildRequires: pkgconfig(ecore-wayland) + +%description +API for creating a new instance of the widget and managing its life-cycle. + +%package devel +Summary: Development Library for widget Viewer Application (dev) +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Header and package configuration files for the widget viewer development + +%prep +%setup -q +cp %{SOURCE1001} . +cp %{SOURCE1002} . +cp %{SOURCE1003} . + +%build +%cmake . -DTZ_SYS_SHARE=/usr/share +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + + +################################################# +# libscreen_connector_watcher +################################################# +%package -n %{name}_watcher +Summary: Library for developing the screen connector watcher +Group: Applications/Core Applications +License: Apache-2.0 + +%description -n %{name}_watcher +Provider APIs to develop the screen connector watcher application. + +%package -n %{name}_watcher-devel +Summary: Screen connector watcher application development library (dev) +Group: Development/Libraries +Requires: %{name}_watcher + +%description -n %{name}_watcher-devel +Header & package configuration files to support development of the widget viewer applications. + +%post -n %{name}_watcher -p /sbin/ldconfig +%postun -n %{name}_watcher -p /sbin/ldconfig + +%files -n %{name}_watcher +%manifest %{name}_watcher.manifest +%attr(0644,root,root) %{_libdir}/%{name}_watcher.so* +%{_datarootdir}/license/%{name}_watcher + +%files -n %{name}_watcher-devel +%{_includedir}/screen_connector_watcher/*.h +%{_libdir}/pkgconfig/screen_connector_watcher.pc + + +################################################# +# libscreen_connector_provider +################################################# +%package -n %{name}_provider +Summary: Library for developing the screen connector provider +Group: Applications/Core Applications +License: Apache-2.0 + +%description -n %{name}_provider +Provider APIs to develop the screen connector provider application. + +%package -n %{name}_provider-devel +Summary: Screen connector provider application development library (dev) +Group: Development/Libraries +Requires: %{name}_provider + +%description -n %{name}_provider-devel +Header & package configuration files to support development of the widget viewer applications. + +%post -n %{name}_provider -p /sbin/ldconfig +%postun -n %{name}_provider -p /sbin/ldconfig + +%files -n %{name}_provider +%manifest %{name}_provider.manifest +%attr(0644,root,root) %{_libdir}/%{name}_provider.so* +%{_datarootdir}/license/%{name}_provider + +%files -n %{name}_provider-devel +%{_includedir}/screen_connector_provider/*.h +%{_libdir}/pkgconfig/screen_connector_provider.pc + + +################################################# +# libscreen_connector_watcher_evas +################################################# +%package -n %{name}_watcher_evas +Summary: Library for developing the screen connector watcher evas +Group: Applications/Core Applications +License: Apache-2.0 + +%description -n %{name}_watcher_evas +Provider APIs to develop the widget viewer EFL application. + +%package -n %{name}_watcher_evas-devel +Summary: Screen connector watcher evas application development library (dev) +Group: Development/Libraries +Requires: %{name}_watcher_evas + +%description -n %{name}_watcher_evas-devel +Header & package configuration files to support development of the widget viewer applications. + +%post -n %{name}_watcher_evas -p /sbin/ldconfig +%postun -n %{name}_watcher_evas -p /sbin/ldconfig + +%files -n %{name}_watcher_evas +%manifest %{name}_watcher_evas.manifest +%attr(0644,root,root) %{_libdir}/%{name}_watcher_evas.so* +%{_datarootdir}/license/%{name}_watcher_evas + +%files -n %{name}_watcher_evas-devel +%{_includedir}/screen_connector_watcher_evas/*.h +%{_libdir}/pkgconfig/screen_connector_watcher_evas.pc + + +# End of a file \ No newline at end of file diff --git a/packaging/libscreen_connector_provider.manifest b/packaging/libscreen_connector_provider.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libscreen_connector_provider.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libscreen_connector_watcher.manifest b/packaging/libscreen_connector_watcher.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libscreen_connector_watcher.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libscreen_connector_watcher_evas.manifest b/packaging/libscreen_connector_watcher_evas.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libscreen_connector_watcher_evas.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/screen_connector_provider/CMakeLists.txt b/screen_connector_provider/CMakeLists.txt new file mode 100644 index 0000000..d509838 --- /dev/null +++ b/screen_connector_provider/CMakeLists.txt @@ -0,0 +1,47 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(screen_connector_provider C) + +SET(PREFIX "${CMAKE_INSTALL_PREFIX}") +SET(PROJECT_NAME "${PROJECT_NAME}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") +SET(VERSION_MAJOR 1) +SET(VERSION "${VERSION_MAJOR}.0.0") + +INCLUDE(FindPkgConfig) +pkg_check_modules(screen_connector_provider REQUIRED + dlog + aul + wayland-tbm-client + elementary + wayland-client + ecore-wayland + tizen-remote-surface-client +) + +FOREACH(flag ${screen_connector_provider_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +AUX_SOURCE_DIRECTORY(src SOURCES) +ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES}) + +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${screen_connector_provider_LDFLAGS} "-lpthread") + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h") +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}") diff --git a/screen_connector_provider/LICENSE b/screen_connector_provider/LICENSE new file mode 100644 index 0000000..9c13a9b --- /dev/null +++ b/screen_connector_provider/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/screen_connector_provider/include/screen_connector_provider.h b/screen_connector_provider/include/screen_connector_provider.h new file mode 100644 index 0000000..4f3dab6 --- /dev/null +++ b/screen_connector_provider/include/screen_connector_provider.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __SCREEN_CONNECTOR_PROVIDER_H__ +#define __SCREEN_CONNECTOR_PROVIDER_H__ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +int screen_connector_provider_remote_enable(const char *id, struct wl_surface *surface); +int screen_connector_provider_init(); +int screen_connector_provider_fini(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/screen_connector_provider/screen_connector_provider.pc.in b/screen_connector_provider/screen_connector_provider.pc.in new file mode 100644 index 0000000..31589fe --- /dev/null +++ b/screen_connector_provider/screen_connector_provider.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: screen_connector_provider +Description: Support development of the Screen Connector Provider library +Version: @VERSION@ +Libs: -L${libdir} -lscreen_connector_provider +Cflags: -I${includedir} +cppflags: -I${includedir} diff --git a/screen_connector_provider/src/screen_connector_provider.c b/screen_connector_provider/src/screen_connector_provider.c new file mode 100644 index 0000000..26575fe --- /dev/null +++ b/screen_connector_provider/src/screen_connector_provider.c @@ -0,0 +1,191 @@ +/* + * Screen Connector Watcher + * Copyright (c) 2016 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. + */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "screen_connector_provider.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SC_PROVIDER" + +static int __init_count; +static struct tizen_remote_surface_manager *__rsm; + +struct __remote_surface_s { + struct wl_surface *surface; + struct tizen_remote_surface_provider *rsp; + char *id; + Ecore_Wl_Window *win; +}; + +static void __rsp_resource_id_cb(void *data, struct tizen_remote_surface_provider *provider, uint32_t res_id) +{ + + LOGE("add app screen : %d", res_id); + aul_screen_connector_add_app_screen(res_id); +} + +static void __rsp_visibility_cb(void *data, struct tizen_remote_surface_provider *provider, uint32_t visibility) +{ + struct __remote_surface_s *remote = (struct __remote_surface_s *)data; + Ecore_Wl_Event_Window_Visibility_Change *ev; + + ev = calloc(1, sizeof(Ecore_Wl_Event_Window_Visibility_Change)); + if (!ev) { + LOGE("out of memory"); + return; + } + + ev->win = ecore_wl_window_id_get(remote->win); + + if (visibility == TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE) + ev->fully_obscured = 0; + else + ev->fully_obscured = 1; + + LOGD("visibility changed:%d", visibility); + + ecore_event_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, ev, NULL, NULL); +} + +static const struct tizen_remote_surface_provider_listener __rsp_listener = { + __rsp_resource_id_cb, + __rsp_visibility_cb, +}; + +EXPORT_API int screen_connector_provider_remote_enable(const char *id, struct wl_surface *surface) +{ + struct __remote_surface_s *remote; + struct wl_display *display; + + if (!__rsm) { + LOGE("__rsm is not ready"); + return -1; + } + + if (!surface || !id) { + LOGE("invalid parameter"); + return -1; + } + + display = ecore_wl_display_get(); + if (!display) { + LOGE("Fail to get"); + return -1; + } + + remote = (struct __remote_surface_s *)malloc(sizeof(struct __remote_surface_s)); + if (!remote) { + LOGE("out of memory"); + return -1; + } + + remote->surface = surface; + remote->win = ecore_wl_window_surface_find(surface); + if (!remote->win) { + LOGE("failed to find win"); + free(remote); + return -1; + } + + remote->rsp = tizen_remote_surface_manager_create_provider(__rsm, surface); + if (!remote->rsp) { + LOGE("failed to create provider"); + free(remote); + return -1; + } + + remote->id = strdup(id); + if (!remote->id) { + free(remote); + LOGE("out of memory"); + return -1; + } + + tizen_remote_surface_provider_add_listener(remote->rsp, &__rsp_listener, remote); + + wl_display_roundtrip(display); + LOGD("%d surface remote enable"); + + return 0; +} + +EXPORT_API int screen_connector_provider_init() +{ + int ret = 0; + struct wl_registry *registry; + Ecore_Wl_Global *global; + Eina_Inlist *globals; + + if (__init_count > 0) { + return 0; + } + ecore_wl_init(NULL); + + registry = ecore_wl_registry_get(); + globals = ecore_wl_globals_get(); + + if (!registry || !globals) { + LOGE("could not get registry(%p) or global list(%p)", registry, + globals); + return -1; + } + + EINA_INLIST_FOREACH(globals, global) { + if (!strcmp(global->interface, "tizen_remote_surface_manager")) { + __rsm = wl_registry_bind(registry, global->id, + &tizen_remote_surface_manager_interface, 1); + } + } + + if (!__rsm) { + LOGE("could not get remote surface manager"); + return -1; + } + __init_count++; + + return ret; +} + +EXPORT_API int screen_connector_provider_fini() +{ + int ret = 0; + + if (__init_count > 1) + return 0; + + if (__rsm) + tizen_remote_surface_manager_destroy(__rsm); + + ecore_wl_shutdown(); + + __init_count--; + return ret; +} diff --git a/screen_connector_watcher/CMakeLists.txt b/screen_connector_watcher/CMakeLists.txt new file mode 100644 index 0000000..56ac0a4 --- /dev/null +++ b/screen_connector_watcher/CMakeLists.txt @@ -0,0 +1,47 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(screen_connector_watcher C) + +SET(PREFIX "${CMAKE_INSTALL_PREFIX}") +SET(PROJECT_NAME "${PROJECT_NAME}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") +SET(VERSION_MAJOR 1) +SET(VERSION "${VERSION_MAJOR}.0.0") + +INCLUDE(FindPkgConfig) +pkg_check_modules(screen_connector_watcher REQUIRED + dlog + aul + wayland-tbm-client + elementary + wayland-client + ecore-wayland + tizen-remote-surface-client +) + +FOREACH(flag ${screen_connector_watcher_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +AUX_SOURCE_DIRECTORY(src SOURCES) +ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES}) + +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${screen_connector_watcher_LDFLAGS} "-lpthread") + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h") +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}") diff --git a/screen_connector_watcher/LICENSE b/screen_connector_watcher/LICENSE new file mode 100644 index 0000000..9c13a9b --- /dev/null +++ b/screen_connector_watcher/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/screen_connector_watcher/include/screen_connector_watcher.h b/screen_connector_watcher/include/screen_connector_watcher.h new file mode 100644 index 0000000..7179bad --- /dev/null +++ b/screen_connector_watcher/include/screen_connector_watcher.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __SCREEN_CONNECTOR_WATCHER_H__ +#define __SCREEN_CONNECTOR_WATCHER_H__ + +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + VISIBILITY_TYPE_UNOBSCURED = 0, + VISIBILITY_TYPE_PARTIALLY_OBSCURED, + VISIBILITY_TYPE_FULLY_OBSCURED, +} visibility_type; + +typedef void (*screen_connector_watcher_added_cb)(const char *appid, Evas_Object *image, void *data); +typedef void (*screen_connector_watcher_removed_cb)(const char *appid, void *data); +typedef void (*screen_connector_watcher_updated_cb)(const char *appid, Evas_Object *image, void *data); + +typedef struct _screen_connector_watcher_ops { + screen_connector_watcher_added_cb added; + screen_connector_watcher_removed_cb removed; + screen_connector_watcher_updated_cb updated; +} screen_connector_watcher_ops; + +typedef struct _screen_connector_watcher_h *screen_connector_watcher_h; + +int screen_connector_watcher_init(Evas_Object *win); +int screen_connector_watcher_fini(); +screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data); +int screen_connector_watcher_remove(screen_connector_watcher_h h); +int screen_connector_watcher_update(const char *appid); + +int screen_connector_watcher_start_visibility_notify(); +int screen_connector_watcher_stop_visibility_notify(); +int screen_connector_watcher_freeze_visibility(Evas_Object *obj, visibility_type type); +int screen_connector_watcher_thaw_visibility(Evas_Object *obj); +int screen_connector_watcher_send_mouse_up(Evas_Object *obj); +int screen_connector_watcher_send_touch_cancel(Evas_Object *obj); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/screen_connector_watcher/screen_connector_watcher.pc.in b/screen_connector_watcher/screen_connector_watcher.pc.in new file mode 100644 index 0000000..fdc9a3d --- /dev/null +++ b/screen_connector_watcher/screen_connector_watcher.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: screen_connector_watcher +Description: Support development of the Screen Connector Watcher library +Version: @VERSION@ +Libs: -L${libdir} -lscreen_connector_watcher +Cflags: -I${includedir} +cppflags: -I${includedir} diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c new file mode 100644 index 0000000..8a6ce7a --- /dev/null +++ b/screen_connector_watcher/src/screen_connector_watcher.c @@ -0,0 +1,790 @@ +/* + * Screen Connector Watcher + * Copyright (c) 2016 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. + */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "screen_connector_watcher.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SC_WATCHER" + +struct _screen_connector_watcher_h{ + void *surface_info; +}; + +typedef struct _screen_connector_surface_info { + int pid; + int surface_id; + char *appid; + struct tizen_remote_surface *surface; + int freeze; + bool is_init; + bool cancel_touch; + Evas_Object *img_tbm; + Evas_Object *img_file; + screen_connector_watcher_ops *ops; + void *data; +}screen_connector_surface_info; + +static Ecore_Event_Handler *__visibility_listener; +static struct tizen_remote_surface_manager *__rsm; +static struct wayland_tbm_client *__tbm_client; +static struct wl_tbm *__tbm; +static int __init_count; +static Evas_Object *__viewer_win; +static GHashTable *__surface_tbl; +static GList *__surface_list; +static GList *__pending_surface_list; +static aul_screen_viewer_handler __aul_cbs; + +static bool __obj_is_visible(Evas_Object *obj) +{ + int x, y, w, h; + Ecore_Wl_Window *window = NULL; + int window_x, window_y, window_w, window_h; + int rotation; + + window = elm_win_wl_window_get(__viewer_win); + ecore_wl_window_geometry_get(window, &window_x, &window_y, &window_w, &window_h); + evas_object_geometry_get(obj, &x, &y, &w, &h); + rotation = ecore_wl_window_rotation_get(window); + + if (x >= 0 && x < window_w && + y >= 0 && y < window_h && + (rotation == 0 || rotation == 180)) { + LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", + x, y, w, h, window_w, window_h, rotation); + return true; + } else if (x >= 0 && x < window_h && + y >= 0 && y < window_w && + (rotation == 90 || rotation == 270)) { + LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", + x, y, w, h, window_w, window_h, rotation); + return true; + } + return false; +} + +static int __set_visibility(screen_connector_surface_info *surface_info, visibility_type type) +{ + int obscured; + + if (!surface_info) { + LOGE("obj not found"); + return -1; + } + + switch (type) { + case VISIBILITY_TYPE_UNOBSCURED: + case VISIBILITY_TYPE_PARTIALLY_OBSCURED: + obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE; + break; + case VISIBILITY_TYPE_FULLY_OBSCURED: + obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE; + break; + default: + return -1; + } + + if (surface_info->surface) + tizen_remote_surface_transfer_visibility(surface_info->surface, obscured); + + return 0; +} + +static void __obj_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; + + if (!surface_info->is_init) { + surface_info->is_init = true; + return; + } + + if (__obj_is_visible(obj)) + __set_visibility(surface_info, VISIBILITY_TYPE_UNOBSCURED); + else + __set_visibility(surface_info, VISIBILITY_TYPE_FULLY_OBSCURED); +} + +static void __rs_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; + Evas_Event_Mouse_Down *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + int x; + int y; + int w; + int h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + LOGD("mouse down: %d %d", ev->canvas.x - x, ev->canvas.y - y); + + if (desc == NULL) + desc = ""; + + tizen_remote_surface_transfer_mouse_event(surface_info->surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_DOWN, + 0, + ev->button, + ev->canvas.x - x, + ev->canvas.y - y, + wl_fixed_from_double(ev->radius_x), + wl_fixed_from_double(ev->radius_y), + wl_fixed_from_double(ev->pressure), + wl_fixed_from_double(ev->angle), + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); +} + +static void __rs_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; + Evas_Event_Mouse_Up *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + int x; + int y; + int w; + int h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + LOGD("mouse up: %d %d", ev->canvas.x - x, ev->canvas.y - y); + + if (desc == NULL) + desc = ""; + + tizen_remote_surface_transfer_mouse_event(surface_info->surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, + 0, + ev->button, + ev->canvas.x - x, + ev->canvas.y - y, + wl_fixed_from_double(ev->radius_x), + wl_fixed_from_double(ev->radius_y), + wl_fixed_from_double(ev->pressure), + wl_fixed_from_double(ev->angle), + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); + +} + +static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; + Evas_Event_Mouse_Move *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + int x; + int y; + int w; + int h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + LOGD("mouse move: %d %d", ev->cur.canvas.x - x, ev->cur.canvas.y - y); + + if (desc == NULL) + desc = ""; + + tizen_remote_surface_transfer_mouse_event(surface_info->surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE, + 0, + 0, + ev->cur.canvas.x - x, + ev->cur.canvas.y - y, + wl_fixed_from_double(ev->radius_x), + wl_fixed_from_double(ev->radius_y), + wl_fixed_from_double(ev->pressure), + wl_fixed_from_double(ev->angle), + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); + +} + +static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; + Evas_Event_Mouse_Wheel *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + + LOGD("mouse wheel"); + + if (desc == NULL) + desc = ""; + + tizen_remote_surface_transfer_mouse_wheel(surface_info->surface, + ev->direction, + ev->z, + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); + +} + +static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("show"); +} + +static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("hide"); +} + +static void __buffer_changed(void *data, struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys) +{ + screen_connector_surface_info *surface_info; + bool is_added = false; + Evas_Native_Surface ns; + tbm_surface_h tbm_surface; + int width, height; + char *map; + char format[] = "png"; + char plug_id[256]; + + surface_info = (screen_connector_surface_info *)data; + if (surface_info->img_tbm == NULL) { + + LOGD("first added !!!! %d, %d %s", (surface_info->img_tbm == NULL), type, surface_info->appid); + surface_info->img_tbm = evas_object_image_filled_add( + evas_object_evas_get(__viewer_win)); + + /* Image alpha set */ + evas_object_image_alpha_set(surface_info->img_tbm, 1); + + evas_object_event_callback_add(surface_info->img_tbm, + EVAS_CALLBACK_MOUSE_DOWN, + __rs_cb_mouse_down, surface_info); + evas_object_event_callback_add(surface_info->img_tbm, + EVAS_CALLBACK_MOUSE_UP, + __rs_cb_mouse_up, surface_info); + evas_object_event_callback_add(surface_info->img_tbm, + EVAS_CALLBACK_MOUSE_MOVE, + __rs_cb_mouse_move, surface_info); + evas_object_event_callback_add(surface_info->img_tbm, + EVAS_CALLBACK_MOUSE_WHEEL, + __rs_cb_mouse_wheel, surface_info); + evas_object_event_callback_add(surface_info->img_tbm, + EVAS_CALLBACK_SHOW, + __rs_cb_show, surface_info); + evas_object_event_callback_add(surface_info->img_tbm, + EVAS_CALLBACK_HIDE, + __rs_cb_hide, surface_info); + + /* Store surface_info */ + g_hash_table_insert(__surface_tbl, surface_info->img_tbm, surface_info); + + /* Set data to use in accessibility */ + snprintf(plug_id, sizeof(plug_id), "%s:%d", surface_info->appid, surface_info->pid); + evas_object_data_set(surface_info->img_tbm, "___PLUGID", strdup(plug_id)); + evas_object_event_callback_add(surface_info->img_tbm, + EVAS_CALLBACK_MOVE, __obj_move_cb, surface_info); + + is_added = true; + } + + /* check type of given buffer */ + if (type == 0) {//if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) { + + /* get tbm surface from buffer */ + tbm_surface = wl_buffer_get_user_data(tbm); + width = tbm_surface_get_width(tbm_surface); + height = tbm_surface_get_height(tbm_surface); + + memset(&ns, 0, sizeof(Evas_Native_Surface)); + ns.version = EVAS_NATIVE_SURFACE_VERSION; + ns.type = EVAS_NATIVE_SURFACE_TBM; + ns.data.tbm.buffer = tbm_surface; + + evas_object_resize(surface_info->img_tbm, width, height); + evas_object_image_size_set(surface_info->img_tbm, width, height); + evas_object_image_native_surface_set(surface_info->img_tbm, &ns); /* set native surface */ + evas_object_image_pixels_dirty_set(surface_info->img_tbm, EINA_TRUE); /* set dirty for image updating */ + + //evas_object_del(surface_info->img_file); /* delete previous object for the image file type */ + + } else if (type == 1) {//} else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) { + + if (!surface_info->img_file) { + surface_info->img_file = evas_object_image_filled_add( + evas_object_evas_get(__viewer_win)); + } + + map = mmap(NULL, img_file_size, PROT_READ, MAP_SHARED, img_file_fd, 0); + evas_object_image_memfile_set(surface_info->img_file, map, img_file_size, format, NULL); + evas_object_image_size_get(surface_info->img_tbm, &width, &height); + evas_object_image_fill_set(surface_info->img_file, 0, 0, width, height); + evas_object_resize(surface_info->img_file, width, height); + munmap(map, img_file_size); + close(img_file_fd); /* close passed fd */ + + evas_object_image_native_surface_set(surface_info->img_tbm, NULL); /* set null to previous object for the tbm type */ + } + + if (is_added) { + LOGD("call added !!!! %s", surface_info->appid); + surface_info->ops->added(surface_info->appid, surface_info->img_tbm, + surface_info->data); + } else { + LOGD("call updated !!!! %s", surface_info->appid); + surface_info->ops->updated(surface_info->appid, surface_info->img_tbm, + surface_info->data); + } + +} + +static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time) +{ + __buffer_changed(data, trs, 0, buffer, 0, 0, 0, NULL); +} + +static void __free_surface_info(screen_connector_surface_info *surface_info) +{ + if (!surface_info) + return; + + if (surface_info->appid) + free(surface_info->appid); + + if (surface_info->img_tbm) { + evas_object_del(surface_info->img_tbm); + surface_info->img_tbm = NULL; + } + + if (surface_info->ops) + free(surface_info->ops); + + free(surface_info); +} + +static void __buffer_missing(void *data, struct tizen_remote_surface *trs) +{ + screen_connector_surface_info *surface_info; + char *plug_id; + + LOGD("missing"); + surface_info = (screen_connector_surface_info *)data; + if (!surface_info) { + LOGE("Null surface_info"); + return; + } + + g_hash_table_remove(__surface_tbl, surface_info->img_tbm); + + /* Remove data used in accessibility */ + plug_id = evas_object_data_del(surface_info->img_tbm, "___PLUGID"); + free(plug_id); + + surface_info->ops->removed(surface_info->appid, surface_info->data); + __free_surface_info(surface_info); +} + +#if 0 +static const struct tizen_remote_surface_listener __rs_listener = { + __buffer_updated, + __buffer_missing, + __buffer_changed, +}; +#else +static const struct tizen_remote_surface_listener __rs_listener = { + __buffer_updated, + __buffer_missing, +}; +#endif + + +static void __app_removed(const char *appid, const int pid, void *data) +{ +} + +static void __redirect_surface(screen_connector_surface_info *surface_info) +{ + surface_info->surface = + tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)surface_info->surface_id, __tbm); + tizen_remote_surface_add_listener(surface_info->surface, &__rs_listener, + surface_info); + tizen_remote_surface_redirect(surface_info->surface); + +} + +static screen_connector_surface_info *__create_surface_info(char *appid) +{ + screen_connector_surface_info *surface_info = NULL; + surface_info = (screen_connector_surface_info *)calloc(1, sizeof(screen_connector_surface_info)); + if (surface_info == NULL) { + LOGE("surface_info calloc fail"); + return NULL; + } + + surface_info->img_file = NULL; + surface_info->img_tbm = NULL; + surface_info->appid = strdup(appid); + + return surface_info; +} + +static void __app_added(const char *appid, const int pid, const unsigned int surface_id, void *data) +{ + LOGD("__app_added pid: %d, surface_id: %d, appid: %s", pid, surface_id, appid); + screen_connector_surface_info *surface_info = NULL; + screen_connector_surface_info *cur_info = NULL; + GList *surface_list = __surface_list; + + for (; surface_list != NULL; surface_list = surface_list->next) { + cur_info = (screen_connector_surface_info *)surface_list->data; + if (strcmp(cur_info->appid, appid) == 0) { + surface_info = cur_info; + __surface_list = g_list_remove(__surface_list, cur_info); + break; + } + } + + if (surface_info == NULL) { + surface_info = __create_surface_info((char *)appid); + surface_info->pid = pid; + surface_info->surface_id = surface_id; + __pending_surface_list = g_list_append(__pending_surface_list, surface_info); + return; + } + + surface_info->surface_id = surface_id; + surface_info->pid = pid; + if (surface_id > 0) + __redirect_surface(surface_info); + else + LOGE("bad tbm message received. missing arguments"); + +} + +static void __send_visibility(gpointer key, gpointer value, gpointer user_data) +{ + screen_connector_surface_info *surface_info = (screen_connector_surface_info *)value; + Evas_Object *evas_obj = (Evas_Object *)key; + unsigned int event = GPOINTER_TO_INT(user_data); + int ret; + visibility_type type; + + if (surface_info->freeze) + return; + + if (!__obj_is_visible(evas_obj)) + return; + + if (event) + type = VISIBILITY_TYPE_FULLY_OBSCURED; + else + type = VISIBILITY_TYPE_UNOBSCURED; + + ret = __set_visibility(surface_info, type); + if (ret == -1) + LOGE("failed to set object visibility set %p to %d", evas_obj, type); +} + +static Eina_Bool __visibility_cb(void *data, int type, void *event) +{ + Ecore_Wl_Event_Window_Visibility_Change *ev = event; + + LOGD("visibility change: %d %d", (unsigned int)ev->win, + (unsigned int)ev->fully_obscured); + + if (!__surface_tbl) + return ECORE_CALLBACK_RENEW; + + g_hash_table_foreach(__surface_tbl, __send_visibility, + GINT_TO_POINTER(ev->fully_obscured)); + + return ECORE_CALLBACK_RENEW; +} + +EXPORT_API int screen_connector_watcher_start_visibility_notify() +{ + if (__visibility_listener) + return 0; + + __visibility_listener = ecore_event_handler_add( + ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL); + + return 0; +} + + +EXPORT_API int screen_connector_watcher_stop_visibility_notify() +{ + if (!__visibility_listener) + return 0; + + ecore_event_handler_del(__visibility_listener); + __visibility_listener = NULL; + + return 0; +} + +EXPORT_API int screen_connector_watcher_freeze_visibility(Evas_Object *obj, visibility_type type) +{ + screen_connector_surface_info *surface_info; + + surface_info = (screen_connector_surface_info *)g_hash_table_lookup(__surface_tbl, obj); + if (!surface_info) { + LOGE("obj not found"); + return -1; + } + surface_info->freeze = 1; + + return __set_visibility(surface_info, type); +} + +EXPORT_API int screen_connector_watcher_thaw_visibility(Evas_Object *obj) +{ + screen_connector_surface_info *surface_info; + + surface_info = (screen_connector_surface_info *)g_hash_table_lookup(__surface_tbl, obj); + if (!surface_info) { + LOGE("obj not found"); + return -1; + } + surface_info->freeze = 0; + + return 0; +} + +EXPORT_API int screen_connector_watcher_send_mouse_up(Evas_Object *obj) +{ + screen_connector_surface_info *surface_info; + int x; + int y; + int w; + int h; + unsigned int timestamp; + + surface_info = g_hash_table_lookup(__surface_tbl, obj); + if (!surface_info) { + LOGE("unknown object. not widget object."); + return -1; + } + + if (!surface_info->img_tbm) { + LOGE("surface not yet initialized."); + return -1; + } + + evas_object_geometry_get(obj, &x, &y, &w, &h); + timestamp = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); + tizen_remote_surface_transfer_mouse_event(surface_info->surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, + 0, + 1, + w / 2, + h / 2, + 0, + 0, + 0, + 0, + TIZEN_INPUT_DEVICE_CLAS_MOUSE, + TIZEN_INPUT_DEVICE_SUBCLAS_NONE, + "", + timestamp); + + return 0; +} + +EXPORT_API int screen_connector_watcher_send_touch_cancel(Evas_Object *obj) +{ + screen_connector_surface_info *surface_info; + + surface_info = g_hash_table_lookup(__surface_tbl, obj); + if (!surface_info) { + LOGE("unknown object. not widget object."); + return -1; + } + + if (surface_info->img_tbm) { + tizen_remote_surface_transfer_touch_cancel(surface_info->surface); + surface_info->cancel_touch = true; + } else { + LOGE("surface not yet initialized."); + return -1; + } + + return 0; +} + +EXPORT_API int screen_connector_watcher_init(Evas_Object *win) +{ + int ret = 0; + struct wl_registry *registry; + Ecore_Wl_Global *global; + Eina_Inlist *globals; + + __viewer_win = win; + + if (__init_count > 0) { + return 0; + } + ecore_wl_init(NULL); + + registry = ecore_wl_registry_get(); + globals = ecore_wl_globals_get(); + + if (!registry || !globals) { + LOGE("could not get registry(%p) or global list(%p)", registry, + globals); + return -1; + } + + EINA_INLIST_FOREACH(globals, global) { + if (!strcmp(global->interface, "tizen_remote_surface_manager")) { + __rsm = wl_registry_bind(registry, global->id, + &tizen_remote_surface_manager_interface, 1); + } + } + + if (!__rsm) { + LOGE("could not get remote surface manager"); + return -1; + } + + __tbm_client = (struct wayland_tbm_client *)wayland_tbm_client_init(ecore_wl_display_get()); + if (!__tbm_client) { + LOGE("could not get tbm client"); + return -1; + } + + __tbm = (struct wl_tbm *)wayland_tbm_client_get_wl_tbm(__tbm_client); + if (!__tbm) { + LOGE("could not get tbm"); + return -1; + } + + __surface_tbl = g_hash_table_new(g_direct_hash, g_direct_equal); + if (!__surface_tbl) { + LOGE("failed to create table"); + return -1; + } + + __aul_cbs.app_added = __app_added; + __aul_cbs.app_removed = __app_removed; + aul_screen_connector_add_screen_viewer(&__aul_cbs, NULL); + + __init_count++; + + return ret; +} + +EXPORT_API int screen_connector_watcher_fini() +{ + int ret = 0; + + if (__init_count > 1) + return 0; + + if (__tbm_client) + wayland_tbm_client_deinit(__tbm_client); + + if (__rsm) + tizen_remote_surface_manager_destroy(__rsm); + + if (__surface_tbl) + g_hash_table_destroy(__surface_tbl); + + ecore_wl_shutdown(); + + __init_count--; + return ret; +} + +EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data) +{ + + screen_connector_watcher_h w_handle; + screen_connector_watcher_ops *watcher_ops; + screen_connector_surface_info *surface_info = NULL; + screen_connector_surface_info *cur_info = NULL; + GList *surface_list = __pending_surface_list; + + watcher_ops = (screen_connector_watcher_ops *)calloc(1, sizeof(screen_connector_watcher_ops *)); + if (watcher_ops == NULL) { + LOGE("watcher_ops calloc fail"); + return NULL; + } + + watcher_ops->added = ops->added; + watcher_ops->removed = ops->removed; + watcher_ops->updated = ops->updated; + + w_handle = (screen_connector_watcher_h)calloc(1, sizeof(struct _screen_connector_watcher_h)); + if (watcher_ops == NULL) { + LOGE("w_handle calloc fail"); + return NULL; + } + + for (; surface_list != NULL; surface_list = surface_list->next) { + cur_info = (screen_connector_surface_info *)surface_list->data; + if (strcmp(cur_info->appid, id) == 0) { + surface_info = cur_info; + __pending_surface_list = g_list_remove(__pending_surface_list, cur_info); + break; + } + } + + if (surface_info != NULL) { + surface_info->ops = watcher_ops; + surface_info->data = data; + __redirect_surface(surface_info); + } else { + surface_info = __create_surface_info(id); + surface_info->ops = watcher_ops; + surface_info->data = data; + __surface_list = g_list_append(__surface_list, surface_info); + } + + w_handle->surface_info = surface_info; + return w_handle; +} + +EXPORT_API int screen_connector_watcher_remove(screen_connector_watcher_h h) +{ + int ret = 0; + return ret; +} + +EXPORT_API int screen_connector_watcher_update(const char *appid) +{ + int ret = 0; + return ret; +} diff --git a/screen_connector_watcher_evas/CMakeLists.txt b/screen_connector_watcher_evas/CMakeLists.txt new file mode 100644 index 0000000..bb8e182 --- /dev/null +++ b/screen_connector_watcher_evas/CMakeLists.txt @@ -0,0 +1,44 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(screen_connector_watcher_evas C) + +SET(PREFIX "${CMAKE_INSTALL_PREFIX}") +SET(PROJECT_NAME "${PROJECT_NAME}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") +SET(VERSION_MAJOR 1) +SET(VERSION "${VERSION_MAJOR}.0.0") + +INCLUDE(FindPkgConfig) +pkg_check_modules(screen_connector_watcher_evas REQUIRED + elementary + dlog + aul +) + +FOREACH(flag ${screen_connector_watcher_evas_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../screen_connector_watcher/include) + +AUX_SOURCE_DIRECTORY(src SOURCES) +ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES}) + +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${screen_connector_watcher_evas_LDFLAGS} "-lpthread") + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h") +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}") diff --git a/screen_connector_watcher_evas/LICENSE b/screen_connector_watcher_evas/LICENSE new file mode 100644 index 0000000..a06208b --- /dev/null +++ b/screen_connector_watcher_evas/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h new file mode 100644 index 0000000..06ebdf7 --- /dev/null +++ b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __SCREEN_CONNECTOR_WATCHER_EVAS_H +#define __SCREEN_CONNECTOR_WATCHER_EVAS_H + +#include +#include +#include + +#include "screen_connector_watcher.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file screen_connector_watcher_evas.h + * @brief This file declares API of libscreen_connector library + * @since_tizen 3.0 + */ + +/** + * @addtogroup CAPI_SCREEN_CONNECTOR_WATCHER_EVAS_MODULE + * @{ + */ + +typedef void (*screen_connector_watcher_evas_added_cb)(const char *appid, Evas_Object *image, void *data); +typedef void (*screen_connector_watcher_evas_removed_cb)(const char *appid, void *data); +typedef void (*screen_connector_watcher_evas_updated_cb)(const char *appid, Evas_Object *image, void *data); + +typedef struct _screen_connector_watcher_evas_ops { + screen_connector_watcher_evas_added_cb added; + screen_connector_watcher_evas_removed_cb removed; + screen_connector_watcher_evas_updated_cb updated; +}screen_connector_watcher_evas_ops; + +typedef struct _screen_connector_watcher_evas_h *screen_connector_watcher_evas_h; + +int screen_connector_watcher_evas_init(Evas_Object *win); +int screen_connector_watcher_evas_fini(); +screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, char *id, void *data); +int screen_connector_watcher_evas_remove(screen_connector_watcher_evas_h handle); +int screen_connector_watcher_evas_update(const char *appid); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif + +/* End of a file */ diff --git a/screen_connector_watcher_evas/screen_connector_watcher_evas.pc.in b/screen_connector_watcher_evas/screen_connector_watcher_evas.pc.in new file mode 100644 index 0000000..a86b8a4 --- /dev/null +++ b/screen_connector_watcher_evas/screen_connector_watcher_evas.pc.in @@ -0,0 +1,12 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: screen_connector_watcher_evas +Description: Support development of the screen connector watcher EVAS library +Version: @VERSION@ +Requires: screen_connector_watcher +Libs: -L${libdir} -lscreen_connector_watcher_evas -lscreen_connector_watcher +Cflags: -I${includedir} +cppflags: -I${includedir} diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c new file mode 100644 index 0000000..ffd1589 --- /dev/null +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -0,0 +1,129 @@ +/* + * Screen Connector Watcher Evas + * Copyright (c) 2016 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. + */ + +#include +#include +#include + +#include + +#include "screen_connector_watcher.h" +#include "screen_connector_watcher_evas.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SC_WATCHER_EVAS" + +struct _screen_connector_watcher_evas_h { + screen_connector_watcher_evas_ops *ops; + screen_connector_watcher_h watcher_h; + void *data; +}; + +static void __destroy_watcher_evas_handle(screen_connector_watcher_evas_h h) +{ + if (!h) + return; + free(h->ops); + free(h); +} + +EXPORT_API int screen_connector_watcher_evas_init(Evas_Object *win) +{ + int ret = 0; + ret = screen_connector_watcher_init(win); + return ret; +} + +EXPORT_API int screen_connector_watcher_evas_fini() +{ + int ret = 0; + ret = screen_connector_watcher_fini(); + return ret; +} + +static void __watcher_added_cb(const char *appid, Evas_Object *image, void *data) +{ + screen_connector_watcher_evas_h handle; + + handle = (screen_connector_watcher_evas_h)data; + handle->ops->added(appid, image, handle->data); +} + +static void __watcher_removed_cb(const char *appid, void *data) +{ + screen_connector_watcher_evas_h handle; + + handle = (screen_connector_watcher_evas_h)data; + handle->ops->removed(appid, handle->data); +} + +static void __watcher_updated_cb(const char *appid, Evas_Object *image, void *data) +{ + screen_connector_watcher_evas_h handle; + + handle = (screen_connector_watcher_evas_h)data; + handle->ops->updated(appid, image, handle->data); +} + +EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, char *id, void *data) +{ + screen_connector_watcher_evas_h handle; + screen_connector_watcher_evas_ops *evas_ops; + screen_connector_watcher_ops *watcher_ops; + + watcher_ops = (screen_connector_watcher_ops *)calloc(1, sizeof(screen_connector_watcher_ops)); + watcher_ops->added = __watcher_added_cb; + watcher_ops->removed = __watcher_removed_cb; + watcher_ops->updated = __watcher_updated_cb; + + evas_ops = (screen_connector_watcher_evas_ops *)calloc(1, sizeof(screen_connector_watcher_evas_ops)); + if (evas_ops == NULL) { + LOGE("evas_ops calloc fail"); + return NULL; + } + + memcpy(evas_ops, ops, sizeof(screen_connector_watcher_evas_ops)); + handle = (screen_connector_watcher_evas_h)calloc(1, sizeof(struct _screen_connector_watcher_evas_h)); + if (handle == NULL) { + LOGE("handle calloc fail"); + return NULL; + } + handle->ops = evas_ops; + handle->data = data; + handle->watcher_h = screen_connector_watcher_add(watcher_ops, id, handle); + + return handle; +} + +EXPORT_API int screen_connector_watcher_evas_remove(screen_connector_watcher_evas_h handle) +{ + int ret = 0; + ret = screen_connector_watcher_remove(handle->watcher_h); + __destroy_watcher_evas_handle(handle); + return ret; +} + +EXPORT_API int screen_connector_watcher_evas_update(const char *appid) +{ + int ret = 0; + ret = screen_connector_watcher_update(appid); + return ret; +} +/* End of a file */ -- 2.7.4 From dc26810390cdae597c70952c6a9a05b80e078747 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 12 Dec 2016 21:36:56 +0900 Subject: [PATCH 3/8] Fix remove callback remove callback have to pass object to keep consistancy of old version. Change-Id: I40001484188a983092d1bcd6e10f658249c38420 Signed-off-by: Hyunho Kang --- screen_connector_provider/include/screen_connector_provider.h | 1 - screen_connector_provider/src/screen_connector_provider.c | 2 ++ screen_connector_watcher/include/screen_connector_watcher.h | 3 ++- screen_connector_watcher/src/screen_connector_watcher.c | 6 +++++- .../include/screen_connector_watcher_evas.h | 2 +- screen_connector_watcher_evas/src/screen_connector_watcher_evas.c | 4 ++-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/screen_connector_provider/include/screen_connector_provider.h b/screen_connector_provider/include/screen_connector_provider.h index 4f3dab6..f937c50 100644 --- a/screen_connector_provider/include/screen_connector_provider.h +++ b/screen_connector_provider/include/screen_connector_provider.h @@ -17,7 +17,6 @@ #ifndef __SCREEN_CONNECTOR_PROVIDER_H__ #define __SCREEN_CONNECTOR_PROVIDER_H__ #include -#include #ifdef __cplusplus extern "C" { diff --git a/screen_connector_provider/src/screen_connector_provider.c b/screen_connector_provider/src/screen_connector_provider.c index 26575fe..7834f69 100644 --- a/screen_connector_provider/src/screen_connector_provider.c +++ b/screen_connector_provider/src/screen_connector_provider.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include + #include "screen_connector_provider.h" #ifdef LOG_TAG diff --git a/screen_connector_watcher/include/screen_connector_watcher.h b/screen_connector_watcher/include/screen_connector_watcher.h index 7179bad..24aa3c4 100644 --- a/screen_connector_watcher/include/screen_connector_watcher.h +++ b/screen_connector_watcher/include/screen_connector_watcher.h @@ -18,6 +18,7 @@ #define __SCREEN_CONNECTOR_WATCHER_H__ #include +#include #include #ifdef __cplusplus extern "C" { @@ -30,7 +31,7 @@ typedef enum { } visibility_type; typedef void (*screen_connector_watcher_added_cb)(const char *appid, Evas_Object *image, void *data); -typedef void (*screen_connector_watcher_removed_cb)(const char *appid, void *data); +typedef void (*screen_connector_watcher_removed_cb)(const char *appid, Evas_Object *image, void *data); typedef void (*screen_connector_watcher_updated_cb)(const char *appid, Evas_Object *image, void *data); typedef struct _screen_connector_watcher_ops { diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c index 8a6ce7a..a22e5f8 100644 --- a/screen_connector_watcher/src/screen_connector_watcher.c +++ b/screen_connector_watcher/src/screen_connector_watcher.c @@ -411,7 +411,7 @@ static void __buffer_missing(void *data, struct tizen_remote_surface *trs) plug_id = evas_object_data_del(surface_info->img_tbm, "___PLUGID"); free(plug_id); - surface_info->ops->removed(surface_info->appid, surface_info->data); + surface_info->ops->removed(surface_info->appid, surface_info->img_tbm, surface_info->data); __free_surface_info(surface_info); } @@ -437,6 +437,8 @@ static void __redirect_surface(screen_connector_surface_info *surface_info) { surface_info->surface = tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)surface_info->surface_id, __tbm); + + LOGD("surface_id : %d, (%p)", surface_info->surface_id, surface_info->surface); tizen_remote_surface_add_listener(surface_info->surface, &__rs_listener, surface_info); tizen_remote_surface_redirect(surface_info->surface); @@ -480,6 +482,8 @@ static void __app_added(const char *appid, const int pid, const unsigned int sur surface_info->pid = pid; surface_info->surface_id = surface_id; __pending_surface_list = g_list_append(__pending_surface_list, surface_info); + + LOGD("add pending list: %d, surface_id: %d, appid: %s", pid, surface_id, appid); return; } diff --git a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h index 06ebdf7..9407fee 100644 --- a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h @@ -39,7 +39,7 @@ extern "C" { */ typedef void (*screen_connector_watcher_evas_added_cb)(const char *appid, Evas_Object *image, void *data); -typedef void (*screen_connector_watcher_evas_removed_cb)(const char *appid, void *data); +typedef void (*screen_connector_watcher_evas_removed_cb)(const char *appid, Evas_Object *image, void *data); typedef void (*screen_connector_watcher_evas_updated_cb)(const char *appid, Evas_Object *image, void *data); typedef struct _screen_connector_watcher_evas_ops { diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index ffd1589..3c97241 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -66,12 +66,12 @@ static void __watcher_added_cb(const char *appid, Evas_Object *image, void *data handle->ops->added(appid, image, handle->data); } -static void __watcher_removed_cb(const char *appid, void *data) +static void __watcher_removed_cb(const char *appid, Evas_Object *image, void *data) { screen_connector_watcher_evas_h handle; handle = (screen_connector_watcher_evas_h)data; - handle->ops->removed(appid, handle->data); + handle->ops->removed(appid, image, handle->data); } static void __watcher_updated_cb(const char *appid, Evas_Object *image, void *data) -- 2.7.4 From 741ccffd461cc26a02e67dcc408ee4c5bd1c7a67 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Tue, 13 Dec 2016 20:03:06 +0900 Subject: [PATCH 4/8] Add APIs and divide Evas dependant APIs Added APIs - _compositor_set_handler_by_rid -> screen_connector_watcher_evas_add_by_rid - _compositor_get_rid -> screen_connector_watcher_evas_get_rid - _compositor_get_pid -> screen_connector_watcher_evas_get_pid Evas dependant APIs should be devided for none evas APIs like dali. Change-Id: I5806013d68262becc1b6d69bbccdffea757cfaf0 Signed-off-by: Hyunho Kang --- .../include/screen_connector_watcher.h | 35 +- .../src/screen_connector_watcher.c | 758 ++++----------------- .../include/screen_connector_watcher_evas.h | 18 +- .../src/screen_connector_watcher_evas.c | 637 ++++++++++++++++- 4 files changed, 797 insertions(+), 651 deletions(-) diff --git a/screen_connector_watcher/include/screen_connector_watcher.h b/screen_connector_watcher/include/screen_connector_watcher.h index 24aa3c4..0bfde94 100644 --- a/screen_connector_watcher/include/screen_connector_watcher.h +++ b/screen_connector_watcher/include/screen_connector_watcher.h @@ -17,43 +17,36 @@ #ifndef __SCREEN_CONNECTOR_WATCHER_H__ #define __SCREEN_CONNECTOR_WATCHER_H__ -#include #include #include #ifdef __cplusplus extern "C" { #endif -typedef enum { - VISIBILITY_TYPE_UNOBSCURED = 0, - VISIBILITY_TYPE_PARTIALLY_OBSCURED, - VISIBILITY_TYPE_FULLY_OBSCURED, -} visibility_type; - -typedef void (*screen_connector_watcher_added_cb)(const char *appid, Evas_Object *image, void *data); -typedef void (*screen_connector_watcher_removed_cb)(const char *appid, Evas_Object *image, void *data); -typedef void (*screen_connector_watcher_updated_cb)(const char *appid, Evas_Object *image, void *data); +typedef void (*screen_connector_watcher_update_cb)(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data); +typedef void (*screen_connector_watcher_missing_cb)(struct tizen_remote_surface *trs, void *data); +typedef void (*screen_connector_watcher_change_cb)(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data); typedef struct _screen_connector_watcher_ops { - screen_connector_watcher_added_cb added; - screen_connector_watcher_removed_cb removed; - screen_connector_watcher_updated_cb updated; + screen_connector_watcher_update_cb update_cb; + screen_connector_watcher_missing_cb missing_cb; + screen_connector_watcher_change_cb change_cb; } screen_connector_watcher_ops; typedef struct _screen_connector_watcher_h *screen_connector_watcher_h; -int screen_connector_watcher_init(Evas_Object *win); +int screen_connector_watcher_init(); int screen_connector_watcher_fini(); screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data); int screen_connector_watcher_remove(screen_connector_watcher_h h); int screen_connector_watcher_update(const char *appid); - -int screen_connector_watcher_start_visibility_notify(); -int screen_connector_watcher_stop_visibility_notify(); -int screen_connector_watcher_freeze_visibility(Evas_Object *obj, visibility_type type); -int screen_connector_watcher_thaw_visibility(Evas_Object *obj); -int screen_connector_watcher_send_mouse_up(Evas_Object *obj); -int screen_connector_watcher_send_touch_cancel(Evas_Object *obj); +char *screen_connector_watcher_get_appid(screen_connector_watcher_h h); +int screen_connector_watcher_get_pid(screen_connector_watcher_h h); +int screen_connector_watcher_get_resource_id(screen_connector_watcher_h h); +struct tizen_remote_surface *screen_connector_watcher_get_trs(screen_connector_watcher_h h); +screen_connector_watcher_h screen_connector_watcher_create_handle(char *id, int pid, screen_connector_watcher_ops *ops, void *data); +void screen_connector_watcher_redirect_surface(screen_connector_watcher_h watcher_h); #ifdef __cplusplus } diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c index a22e5f8..02210c6 100644 --- a/screen_connector_watcher/src/screen_connector_watcher.c +++ b/screen_connector_watcher/src/screen_connector_watcher.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -35,387 +34,51 @@ #define LOG_TAG "SC_WATCHER" -struct _screen_connector_watcher_h{ - void *surface_info; -}; - -typedef struct _screen_connector_surface_info { - int pid; - int surface_id; +struct _screen_connector_watcher_h { char *appid; - struct tizen_remote_surface *surface; - int freeze; - bool is_init; - bool cancel_touch; - Evas_Object *img_tbm; - Evas_Object *img_file; - screen_connector_watcher_ops *ops; + int pid; + void (*update_cb)(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data); + void (*missing_cb)(struct tizen_remote_surface *trs, void *data); + void (*change_cb)(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data); void *data; -}screen_connector_surface_info; + struct tizen_remote_surface *surface; + int resource_id; +}; + +typedef struct _screen_connector_watcher_h *screen_connector_watcher_h; -static Ecore_Event_Handler *__visibility_listener; static struct tizen_remote_surface_manager *__rsm; static struct wayland_tbm_client *__tbm_client; static struct wl_tbm *__tbm; -static int __init_count; -static Evas_Object *__viewer_win; -static GHashTable *__surface_tbl; -static GList *__surface_list; -static GList *__pending_surface_list; +static bool __is_init = false; +static GList *__watcher_list; +static GList *__pending_watcher_list; static aul_screen_viewer_handler __aul_cbs; -static bool __obj_is_visible(Evas_Object *obj) -{ - int x, y, w, h; - Ecore_Wl_Window *window = NULL; - int window_x, window_y, window_w, window_h; - int rotation; - - window = elm_win_wl_window_get(__viewer_win); - ecore_wl_window_geometry_get(window, &window_x, &window_y, &window_w, &window_h); - evas_object_geometry_get(obj, &x, &y, &w, &h); - rotation = ecore_wl_window_rotation_get(window); - - if (x >= 0 && x < window_w && - y >= 0 && y < window_h && - (rotation == 0 || rotation == 180)) { - LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", - x, y, w, h, window_w, window_h, rotation); - return true; - } else if (x >= 0 && x < window_h && - y >= 0 && y < window_w && - (rotation == 90 || rotation == 270)) { - LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", - x, y, w, h, window_w, window_h, rotation); - return true; - } - return false; -} - -static int __set_visibility(screen_connector_surface_info *surface_info, visibility_type type) -{ - int obscured; - - if (!surface_info) { - LOGE("obj not found"); - return -1; - } - - switch (type) { - case VISIBILITY_TYPE_UNOBSCURED: - case VISIBILITY_TYPE_PARTIALLY_OBSCURED: - obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE; - break; - case VISIBILITY_TYPE_FULLY_OBSCURED: - obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE; - break; - default: - return -1; - } - - if (surface_info->surface) - tizen_remote_surface_transfer_visibility(surface_info->surface, obscured); - - return 0; -} - -static void __obj_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; - - if (!surface_info->is_init) { - surface_info->is_init = true; - return; - } - - if (__obj_is_visible(obj)) - __set_visibility(surface_info, VISIBILITY_TYPE_UNOBSCURED); - else - __set_visibility(surface_info, VISIBILITY_TYPE_FULLY_OBSCURED); -} - -static void __rs_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; - Evas_Event_Mouse_Down *ev = event_info; - const char *desc = evas_device_description_get(ev->dev); - int x; - int y; - int w; - int h; - - evas_object_geometry_get(obj, &x, &y, &w, &h); - - LOGD("mouse down: %d %d", ev->canvas.x - x, ev->canvas.y - y); - - if (desc == NULL) - desc = ""; - - tizen_remote_surface_transfer_mouse_event(surface_info->surface, - TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_DOWN, - 0, - ev->button, - ev->canvas.x - x, - ev->canvas.y - y, - wl_fixed_from_double(ev->radius_x), - wl_fixed_from_double(ev->radius_y), - wl_fixed_from_double(ev->pressure), - wl_fixed_from_double(ev->angle), - evas_device_class_get(ev->dev), - evas_device_subclass_get(ev->dev), - desc, - ev->timestamp); -} - -static void __rs_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; - Evas_Event_Mouse_Up *ev = event_info; - const char *desc = evas_device_description_get(ev->dev); - int x; - int y; - int w; - int h; - - evas_object_geometry_get(obj, &x, &y, &w, &h); - - LOGD("mouse up: %d %d", ev->canvas.x - x, ev->canvas.y - y); - - if (desc == NULL) - desc = ""; - - tizen_remote_surface_transfer_mouse_event(surface_info->surface, - TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, - 0, - ev->button, - ev->canvas.x - x, - ev->canvas.y - y, - wl_fixed_from_double(ev->radius_x), - wl_fixed_from_double(ev->radius_y), - wl_fixed_from_double(ev->pressure), - wl_fixed_from_double(ev->angle), - evas_device_class_get(ev->dev), - evas_device_subclass_get(ev->dev), - desc, - ev->timestamp); - -} - -static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; - Evas_Event_Mouse_Move *ev = event_info; - const char *desc = evas_device_description_get(ev->dev); - int x; - int y; - int w; - int h; - - evas_object_geometry_get(obj, &x, &y, &w, &h); - - LOGD("mouse move: %d %d", ev->cur.canvas.x - x, ev->cur.canvas.y - y); - - if (desc == NULL) - desc = ""; - - tizen_remote_surface_transfer_mouse_event(surface_info->surface, - TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE, - 0, - 0, - ev->cur.canvas.x - x, - ev->cur.canvas.y - y, - wl_fixed_from_double(ev->radius_x), - wl_fixed_from_double(ev->radius_y), - wl_fixed_from_double(ev->pressure), - wl_fixed_from_double(ev->angle), - evas_device_class_get(ev->dev), - evas_device_subclass_get(ev->dev), - desc, - ev->timestamp); - -} - -static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - screen_connector_surface_info *surface_info = (screen_connector_surface_info *)data; - Evas_Event_Mouse_Wheel *ev = event_info; - const char *desc = evas_device_description_get(ev->dev); - - LOGD("mouse wheel"); - - if (desc == NULL) - desc = ""; - - tizen_remote_surface_transfer_mouse_wheel(surface_info->surface, - ev->direction, - ev->z, - evas_device_class_get(ev->dev), - evas_device_subclass_get(ev->dev), - desc, - ev->timestamp); - -} - -static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info) +static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time) { - LOGD("show"); + screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data; + if (watcher_h) + watcher_h->update_cb(trs, buffer, time, watcher_h->data); } -static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info) +static void __buffer_missing(void *data, struct tizen_remote_surface *trs) { - LOGD("hide"); + screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data; + if (watcher_h) + watcher_h->missing_cb(trs, watcher_h->data); } +#if 0 static void __buffer_changed(void *data, struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys) { - screen_connector_surface_info *surface_info; - bool is_added = false; - Evas_Native_Surface ns; - tbm_surface_h tbm_surface; - int width, height; - char *map; - char format[] = "png"; - char plug_id[256]; - - surface_info = (screen_connector_surface_info *)data; - if (surface_info->img_tbm == NULL) { - - LOGD("first added !!!! %d, %d %s", (surface_info->img_tbm == NULL), type, surface_info->appid); - surface_info->img_tbm = evas_object_image_filled_add( - evas_object_evas_get(__viewer_win)); - - /* Image alpha set */ - evas_object_image_alpha_set(surface_info->img_tbm, 1); - - evas_object_event_callback_add(surface_info->img_tbm, - EVAS_CALLBACK_MOUSE_DOWN, - __rs_cb_mouse_down, surface_info); - evas_object_event_callback_add(surface_info->img_tbm, - EVAS_CALLBACK_MOUSE_UP, - __rs_cb_mouse_up, surface_info); - evas_object_event_callback_add(surface_info->img_tbm, - EVAS_CALLBACK_MOUSE_MOVE, - __rs_cb_mouse_move, surface_info); - evas_object_event_callback_add(surface_info->img_tbm, - EVAS_CALLBACK_MOUSE_WHEEL, - __rs_cb_mouse_wheel, surface_info); - evas_object_event_callback_add(surface_info->img_tbm, - EVAS_CALLBACK_SHOW, - __rs_cb_show, surface_info); - evas_object_event_callback_add(surface_info->img_tbm, - EVAS_CALLBACK_HIDE, - __rs_cb_hide, surface_info); - - /* Store surface_info */ - g_hash_table_insert(__surface_tbl, surface_info->img_tbm, surface_info); - - /* Set data to use in accessibility */ - snprintf(plug_id, sizeof(plug_id), "%s:%d", surface_info->appid, surface_info->pid); - evas_object_data_set(surface_info->img_tbm, "___PLUGID", strdup(plug_id)); - evas_object_event_callback_add(surface_info->img_tbm, - EVAS_CALLBACK_MOVE, __obj_move_cb, surface_info); - - is_added = true; - } - - /* check type of given buffer */ - if (type == 0) {//if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) { - - /* get tbm surface from buffer */ - tbm_surface = wl_buffer_get_user_data(tbm); - width = tbm_surface_get_width(tbm_surface); - height = tbm_surface_get_height(tbm_surface); - - memset(&ns, 0, sizeof(Evas_Native_Surface)); - ns.version = EVAS_NATIVE_SURFACE_VERSION; - ns.type = EVAS_NATIVE_SURFACE_TBM; - ns.data.tbm.buffer = tbm_surface; - - evas_object_resize(surface_info->img_tbm, width, height); - evas_object_image_size_set(surface_info->img_tbm, width, height); - evas_object_image_native_surface_set(surface_info->img_tbm, &ns); /* set native surface */ - evas_object_image_pixels_dirty_set(surface_info->img_tbm, EINA_TRUE); /* set dirty for image updating */ - - //evas_object_del(surface_info->img_file); /* delete previous object for the image file type */ - - } else if (type == 1) {//} else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) { - - if (!surface_info->img_file) { - surface_info->img_file = evas_object_image_filled_add( - evas_object_evas_get(__viewer_win)); - } - - map = mmap(NULL, img_file_size, PROT_READ, MAP_SHARED, img_file_fd, 0); - evas_object_image_memfile_set(surface_info->img_file, map, img_file_size, format, NULL); - evas_object_image_size_get(surface_info->img_tbm, &width, &height); - evas_object_image_fill_set(surface_info->img_file, 0, 0, width, height); - evas_object_resize(surface_info->img_file, width, height); - munmap(map, img_file_size); - close(img_file_fd); /* close passed fd */ - - evas_object_image_native_surface_set(surface_info->img_tbm, NULL); /* set null to previous object for the tbm type */ - } - - if (is_added) { - LOGD("call added !!!! %s", surface_info->appid); - surface_info->ops->added(surface_info->appid, surface_info->img_tbm, - surface_info->data); - } else { - LOGD("call updated !!!! %s", surface_info->appid); - surface_info->ops->updated(surface_info->appid, surface_info->img_tbm, - surface_info->data); - } - + screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data; + if (watcher_h) + watcher_h->change_cb(trs, type, tbm, img_file_fd, img_file_size, time, keys, watcher_h->data); } -static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time) -{ - __buffer_changed(data, trs, 0, buffer, 0, 0, 0, NULL); -} - -static void __free_surface_info(screen_connector_surface_info *surface_info) -{ - if (!surface_info) - return; - - if (surface_info->appid) - free(surface_info->appid); - - if (surface_info->img_tbm) { - evas_object_del(surface_info->img_tbm); - surface_info->img_tbm = NULL; - } - - if (surface_info->ops) - free(surface_info->ops); - - free(surface_info); -} - -static void __buffer_missing(void *data, struct tizen_remote_surface *trs) -{ - screen_connector_surface_info *surface_info; - char *plug_id; - - LOGD("missing"); - surface_info = (screen_connector_surface_info *)data; - if (!surface_info) { - LOGE("Null surface_info"); - return; - } - - g_hash_table_remove(__surface_tbl, surface_info->img_tbm); - - /* Remove data used in accessibility */ - plug_id = evas_object_data_del(surface_info->img_tbm, "___PLUGID"); - free(plug_id); - - surface_info->ops->removed(surface_info->appid, surface_info->img_tbm, surface_info->data); - __free_surface_info(surface_info); -} - -#if 0 static const struct tizen_remote_surface_listener __rs_listener = { __buffer_updated, __buffer_missing, @@ -428,238 +91,79 @@ static const struct tizen_remote_surface_listener __rs_listener = { }; #endif - static void __app_removed(const char *appid, const int pid, void *data) { } -static void __redirect_surface(screen_connector_surface_info *surface_info) +EXPORT_API void screen_connector_watcher_redirect_surface(screen_connector_watcher_h watcher_h) { - surface_info->surface = - tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)surface_info->surface_id, __tbm); - - LOGD("surface_id : %d, (%p)", surface_info->surface_id, surface_info->surface); - tizen_remote_surface_add_listener(surface_info->surface, &__rs_listener, - surface_info); - tizen_remote_surface_redirect(surface_info->surface); + watcher_h->surface = + tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)watcher_h->resource_id, __tbm); + LOGD("resource_id : %d, (%p)", watcher_h->resource_id, watcher_h->surface); + tizen_remote_surface_add_listener(watcher_h->surface, &__rs_listener, + watcher_h); + tizen_remote_surface_redirect(watcher_h->surface); } -static screen_connector_surface_info *__create_surface_info(char *appid) +static screen_connector_watcher_h __create_watcher_handle_info(char *appid) { - screen_connector_surface_info *surface_info = NULL; - surface_info = (screen_connector_surface_info *)calloc(1, sizeof(screen_connector_surface_info)); - if (surface_info == NULL) { - LOGE("surface_info calloc fail"); + screen_connector_watcher_h watcher_h = NULL; + watcher_h = (screen_connector_watcher_h)calloc(1, sizeof(struct _screen_connector_watcher_h)); + if (watcher_h == NULL) { + LOGE("watcher_h calloc fail"); return NULL; } + watcher_h->appid = strdup(appid); - surface_info->img_file = NULL; - surface_info->img_tbm = NULL; - surface_info->appid = strdup(appid); - - return surface_info; + return watcher_h; } -static void __app_added(const char *appid, const int pid, const unsigned int surface_id, void *data) +static void __app_added(const char *appid, const int pid, const unsigned int resource_id, void *data) { - LOGD("__app_added pid: %d, surface_id: %d, appid: %s", pid, surface_id, appid); - screen_connector_surface_info *surface_info = NULL; - screen_connector_surface_info *cur_info = NULL; - GList *surface_list = __surface_list; - - for (; surface_list != NULL; surface_list = surface_list->next) { - cur_info = (screen_connector_surface_info *)surface_list->data; - if (strcmp(cur_info->appid, appid) == 0) { - surface_info = cur_info; - __surface_list = g_list_remove(__surface_list, cur_info); + LOGD("__app_added pid: %d, resource_id: %d, appid: %s", pid, resource_id, appid); + screen_connector_watcher_h watcher_h = NULL; + screen_connector_watcher_h cur_h = NULL; + GList *watcher_list = __watcher_list; + + for (; watcher_list != NULL; watcher_list = watcher_list->next) { + cur_h = (screen_connector_watcher_h)watcher_list->data; + if (strcmp(cur_h->appid, appid) == 0) { + watcher_h = cur_h; + __watcher_list = g_list_remove(__watcher_list, cur_h); break; } } - if (surface_info == NULL) { - surface_info = __create_surface_info((char *)appid); - surface_info->pid = pid; - surface_info->surface_id = surface_id; - __pending_surface_list = g_list_append(__pending_surface_list, surface_info); + if (watcher_h == NULL) { + watcher_h = __create_watcher_handle_info((char *)appid); + watcher_h->pid = pid; + watcher_h->resource_id = resource_id; + __pending_watcher_list = g_list_append(__pending_watcher_list, watcher_h); - LOGD("add pending list: %d, surface_id: %d, appid: %s", pid, surface_id, appid); + LOGD("add pending list: %d, resource_id: %d, appid: %s", pid, resource_id, appid); return; } - surface_info->surface_id = surface_id; - surface_info->pid = pid; - if (surface_id > 0) - __redirect_surface(surface_info); + watcher_h->resource_id = resource_id; + watcher_h->pid = pid; + if (resource_id > 0) + screen_connector_watcher_redirect_surface(watcher_h); else LOGE("bad tbm message received. missing arguments"); } -static void __send_visibility(gpointer key, gpointer value, gpointer user_data) -{ - screen_connector_surface_info *surface_info = (screen_connector_surface_info *)value; - Evas_Object *evas_obj = (Evas_Object *)key; - unsigned int event = GPOINTER_TO_INT(user_data); - int ret; - visibility_type type; - - if (surface_info->freeze) - return; - - if (!__obj_is_visible(evas_obj)) - return; - - if (event) - type = VISIBILITY_TYPE_FULLY_OBSCURED; - else - type = VISIBILITY_TYPE_UNOBSCURED; - - ret = __set_visibility(surface_info, type); - if (ret == -1) - LOGE("failed to set object visibility set %p to %d", evas_obj, type); -} - -static Eina_Bool __visibility_cb(void *data, int type, void *event) -{ - Ecore_Wl_Event_Window_Visibility_Change *ev = event; - - LOGD("visibility change: %d %d", (unsigned int)ev->win, - (unsigned int)ev->fully_obscured); - - if (!__surface_tbl) - return ECORE_CALLBACK_RENEW; - - g_hash_table_foreach(__surface_tbl, __send_visibility, - GINT_TO_POINTER(ev->fully_obscured)); - - return ECORE_CALLBACK_RENEW; -} - -EXPORT_API int screen_connector_watcher_start_visibility_notify() -{ - if (__visibility_listener) - return 0; - - __visibility_listener = ecore_event_handler_add( - ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL); - - return 0; -} - - -EXPORT_API int screen_connector_watcher_stop_visibility_notify() -{ - if (!__visibility_listener) - return 0; - - ecore_event_handler_del(__visibility_listener); - __visibility_listener = NULL; - - return 0; -} - -EXPORT_API int screen_connector_watcher_freeze_visibility(Evas_Object *obj, visibility_type type) -{ - screen_connector_surface_info *surface_info; - - surface_info = (screen_connector_surface_info *)g_hash_table_lookup(__surface_tbl, obj); - if (!surface_info) { - LOGE("obj not found"); - return -1; - } - surface_info->freeze = 1; - - return __set_visibility(surface_info, type); -} - -EXPORT_API int screen_connector_watcher_thaw_visibility(Evas_Object *obj) -{ - screen_connector_surface_info *surface_info; - - surface_info = (screen_connector_surface_info *)g_hash_table_lookup(__surface_tbl, obj); - if (!surface_info) { - LOGE("obj not found"); - return -1; - } - surface_info->freeze = 0; - - return 0; -} - -EXPORT_API int screen_connector_watcher_send_mouse_up(Evas_Object *obj) -{ - screen_connector_surface_info *surface_info; - int x; - int y; - int w; - int h; - unsigned int timestamp; - - surface_info = g_hash_table_lookup(__surface_tbl, obj); - if (!surface_info) { - LOGE("unknown object. not widget object."); - return -1; - } - - if (!surface_info->img_tbm) { - LOGE("surface not yet initialized."); - return -1; - } - - evas_object_geometry_get(obj, &x, &y, &w, &h); - timestamp = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); - tizen_remote_surface_transfer_mouse_event(surface_info->surface, - TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, - 0, - 1, - w / 2, - h / 2, - 0, - 0, - 0, - 0, - TIZEN_INPUT_DEVICE_CLAS_MOUSE, - TIZEN_INPUT_DEVICE_SUBCLAS_NONE, - "", - timestamp); - - return 0; -} - -EXPORT_API int screen_connector_watcher_send_touch_cancel(Evas_Object *obj) -{ - screen_connector_surface_info *surface_info; - - surface_info = g_hash_table_lookup(__surface_tbl, obj); - if (!surface_info) { - LOGE("unknown object. not widget object."); - return -1; - } - - if (surface_info->img_tbm) { - tizen_remote_surface_transfer_touch_cancel(surface_info->surface); - surface_info->cancel_touch = true; - } else { - LOGE("surface not yet initialized."); - return -1; - } - - return 0; -} - -EXPORT_API int screen_connector_watcher_init(Evas_Object *win) +EXPORT_API int screen_connector_watcher_init() { int ret = 0; struct wl_registry *registry; Ecore_Wl_Global *global; Eina_Inlist *globals; - __viewer_win = win; - - if (__init_count > 0) { + if (__is_init) return 0; - } + ecore_wl_init(NULL); registry = ecore_wl_registry_get(); @@ -695,100 +199,136 @@ EXPORT_API int screen_connector_watcher_init(Evas_Object *win) return -1; } - __surface_tbl = g_hash_table_new(g_direct_hash, g_direct_equal); - if (!__surface_tbl) { - LOGE("failed to create table"); - return -1; - } - __aul_cbs.app_added = __app_added; __aul_cbs.app_removed = __app_removed; aul_screen_connector_add_screen_viewer(&__aul_cbs, NULL); - __init_count++; + __is_init = true; return ret; } EXPORT_API int screen_connector_watcher_fini() { - int ret = 0; - - if (__init_count > 1) + if (!__is_init) return 0; + if (aul_screen_connector_remove_app_screen() != 0) + return -1; + if (__tbm_client) wayland_tbm_client_deinit(__tbm_client); if (__rsm) tizen_remote_surface_manager_destroy(__rsm); - if (__surface_tbl) - g_hash_table_destroy(__surface_tbl); - ecore_wl_shutdown(); - __init_count--; - return ret; + __is_init = false; + return 0; } -EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data) +static void __destroy_watcher_h(screen_connector_watcher_h handle) { + if (!handle) + return; - screen_connector_watcher_h w_handle; - screen_connector_watcher_ops *watcher_ops; - screen_connector_surface_info *surface_info = NULL; - screen_connector_surface_info *cur_info = NULL; - GList *surface_list = __pending_surface_list; + if (handle->appid) + free(handle->appid); - watcher_ops = (screen_connector_watcher_ops *)calloc(1, sizeof(screen_connector_watcher_ops *)); - if (watcher_ops == NULL) { - LOGE("watcher_ops calloc fail"); - return NULL; - } + free(handle); +} - watcher_ops->added = ops->added; - watcher_ops->removed = ops->removed; - watcher_ops->updated = ops->updated; +EXPORT_API screen_connector_watcher_h screen_connector_watcher_create_handle(char *id, int pid, screen_connector_watcher_ops *ops, void *data) +{ + screen_connector_watcher_h watcher_h = NULL; - w_handle = (screen_connector_watcher_h)calloc(1, sizeof(struct _screen_connector_watcher_h)); - if (watcher_ops == NULL) { - LOGE("w_handle calloc fail"); - return NULL; - } + watcher_h = __create_watcher_handle_info(id); + watcher_h->update_cb = ops->update_cb; + watcher_h->change_cb = ops->change_cb; + watcher_h->missing_cb = ops->missing_cb; + watcher_h->pid = pid; + watcher_h->data = data; - for (; surface_list != NULL; surface_list = surface_list->next) { - cur_info = (screen_connector_surface_info *)surface_list->data; - if (strcmp(cur_info->appid, id) == 0) { - surface_info = cur_info; - __pending_surface_list = g_list_remove(__pending_surface_list, cur_info); + return watcher_h; +} + +EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data) +{ + + screen_connector_watcher_h watcher_h = NULL; + screen_connector_watcher_h cur_h = NULL; + GList *watcher_list = __pending_watcher_list; + + for (; watcher_list != NULL; watcher_list = watcher_list->next) { + cur_h = (screen_connector_watcher_h)watcher_list->data; + if (strcmp(cur_h->appid, id) == 0) { + watcher_h = cur_h; + __pending_watcher_list = g_list_remove(__pending_watcher_list, cur_h); break; } } - if (surface_info != NULL) { - surface_info->ops = watcher_ops; - surface_info->data = data; - __redirect_surface(surface_info); + if (watcher_h != NULL) { + watcher_h->update_cb = ops->update_cb; + watcher_h->change_cb = ops->change_cb; + watcher_h->missing_cb = ops->missing_cb; + watcher_h->data = data; + screen_connector_watcher_redirect_surface(watcher_h); } else { - surface_info = __create_surface_info(id); - surface_info->ops = watcher_ops; - surface_info->data = data; - __surface_list = g_list_append(__surface_list, surface_info); + watcher_h = __create_watcher_handle_info(id); + watcher_h->update_cb = ops->update_cb; + watcher_h->change_cb = ops->change_cb; + watcher_h->missing_cb = ops->missing_cb; + watcher_h->data = data; + __watcher_list = g_list_append(__watcher_list, watcher_h); } - w_handle->surface_info = surface_info; - return w_handle; + return watcher_h; } EXPORT_API int screen_connector_watcher_remove(screen_connector_watcher_h h) { int ret = 0; + __destroy_watcher_h(h); return ret; } EXPORT_API int screen_connector_watcher_update(const char *appid) { int ret = 0; + ret = aul_screen_connector_update_app_screen(appid); return ret; } + +EXPORT_API char *screen_connector_watcher_get_appid(screen_connector_watcher_h h) +{ + if (h == NULL) + return NULL; + + return h->appid; +} + +EXPORT_API int screen_connector_watcher_get_pid(screen_connector_watcher_h h) +{ + if (h == NULL) + return -1; + + return h->pid; +} + +EXPORT_API int screen_connector_watcher_get_resource_id(screen_connector_watcher_h h) +{ + if (h == NULL) + return -1; + + return h->resource_id; +} + +EXPORT_API struct tizen_remote_surface *screen_connector_watcher_get_trs(screen_connector_watcher_h h) +{ + if (h == NULL) + return NULL; + + return h->surface; +} diff --git a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h index 9407fee..efbe06a 100644 --- a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h @@ -21,8 +21,6 @@ #include #include -#include "screen_connector_watcher.h" - #ifdef __cplusplus extern "C" { #endif @@ -38,6 +36,12 @@ extern "C" { * @{ */ +typedef enum { + VISIBILITY_TYPE_UNOBSCURED = 0, + VISIBILITY_TYPE_PARTIALLY_OBSCURED, + VISIBILITY_TYPE_FULLY_OBSCURED, +} visibility_type; + typedef void (*screen_connector_watcher_evas_added_cb)(const char *appid, Evas_Object *image, void *data); typedef void (*screen_connector_watcher_evas_removed_cb)(const char *appid, Evas_Object *image, void *data); typedef void (*screen_connector_watcher_evas_updated_cb)(const char *appid, Evas_Object *image, void *data); @@ -56,6 +60,16 @@ screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connect int screen_connector_watcher_evas_remove(screen_connector_watcher_evas_h handle); int screen_connector_watcher_evas_update(const char *appid); +int screen_connector_watcher_evas_start_visibility_notify(); +int screen_connector_watcher_evas_stop_visibility_notify(); +int screen_connector_watcher_evas_freeze_visibility(Evas_Object *obj, visibility_type type); +int screen_connector_watcher_evas_thaw_visibility(Evas_Object *obj); +int screen_connector_watcher_evas_send_mouse_up(Evas_Object *obj); +int screen_connector_watcher_evas_send_touch_cancel(Evas_Object *obj); +int screen_connector_watcher_evas_get_pid(Evas_Object *obj, int *pid); +int screen_connector_watcher_evas_add_by_rid(screen_connector_watcher_evas_ops *ops, int res_id, void *data); +int screen_connector_watcher_evas_get_rid(Evas_Object *obj, int *resource_id); + /** * @} */ diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index 3c97241..8f36025 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -18,8 +18,13 @@ #include #include #include +#include #include +#include +#include +#include +#include #include "screen_connector_watcher.h" #include "screen_connector_watcher_evas.h" @@ -33,8 +38,16 @@ struct _screen_connector_watcher_evas_h { screen_connector_watcher_evas_ops *ops; screen_connector_watcher_h watcher_h; + int freeze; + bool is_init; + bool cancel_touch; + Evas_Object *img_tbm; + Evas_Object *img_file; void *data; }; +static Evas_Object *__viewer_win; +static Ecore_Event_Handler *__visibility_listener; +static GHashTable *__watcher_tbl; static void __destroy_watcher_evas_handle(screen_connector_watcher_evas_h h) { @@ -47,51 +60,407 @@ static void __destroy_watcher_evas_handle(screen_connector_watcher_evas_h h) EXPORT_API int screen_connector_watcher_evas_init(Evas_Object *win) { int ret = 0; - ret = screen_connector_watcher_init(win); + __viewer_win = win; + + __watcher_tbl = g_hash_table_new(g_direct_hash, g_direct_equal); + if (!__watcher_tbl) { + LOGE("failed to create table"); + return -1; + } + + ret = screen_connector_watcher_init(); return ret; } EXPORT_API int screen_connector_watcher_evas_fini() { int ret = 0; + + if (__watcher_tbl) + g_hash_table_destroy(__watcher_tbl); + ret = screen_connector_watcher_fini(); return ret; } -static void __watcher_added_cb(const char *appid, Evas_Object *image, void *data) +static bool __obj_is_visible(Evas_Object *obj) { - screen_connector_watcher_evas_h handle; + int x, y, w, h; + Ecore_Wl_Window *window = NULL; + int window_x, window_y, window_w, window_h; + int rotation; - handle = (screen_connector_watcher_evas_h)data; - handle->ops->added(appid, image, handle->data); + window = elm_win_wl_window_get(__viewer_win); + ecore_wl_window_geometry_get(window, &window_x, &window_y, &window_w, &window_h); + evas_object_geometry_get(obj, &x, &y, &w, &h); + rotation = ecore_wl_window_rotation_get(window); + + if (x >= 0 && x < window_w && + y >= 0 && y < window_h && + (rotation == 0 || rotation == 180)) { + LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", + x, y, w, h, window_w, window_h, rotation); + return true; + } else if (x >= 0 && x < window_h && + y >= 0 && y < window_w && + (rotation == 90 || rotation == 270)) { + LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", + x, y, w, h, window_w, window_h, rotation); + return true; + } + return false; } -static void __watcher_removed_cb(const char *appid, Evas_Object *image, void *data) +static int __set_visibility(screen_connector_watcher_evas_h watcher_evas_h, visibility_type type) { - screen_connector_watcher_evas_h handle; + int obscured; + struct tizen_remote_surface *surface; + + if (!watcher_evas_h) { + LOGE("obj not found"); + return -1; + } + + switch (type) { + case VISIBILITY_TYPE_UNOBSCURED: + case VISIBILITY_TYPE_PARTIALLY_OBSCURED: + obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE; + break; + case VISIBILITY_TYPE_FULLY_OBSCURED: + obscured = TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE; + break; + default: + return -1; + } + + surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h); + if (surface) + tizen_remote_surface_transfer_visibility(surface, obscured); - handle = (screen_connector_watcher_evas_h)data; - handle->ops->removed(appid, image, handle->data); + return 0; } -static void __watcher_updated_cb(const char *appid, Evas_Object *image, void *data) +static void __obj_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - screen_connector_watcher_evas_h handle; + screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data; + + if (!watcher_evas_h->is_init) { + watcher_evas_h->is_init = true; + return; + } + + if (__obj_is_visible(obj)) + __set_visibility(watcher_evas_h, VISIBILITY_TYPE_UNOBSCURED); + else + __set_visibility(watcher_evas_h, VISIBILITY_TYPE_FULLY_OBSCURED); +} + +static void __rs_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data; + Evas_Event_Mouse_Down *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + int x; + int y; + int w; + int h; + struct tizen_remote_surface *surface; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + LOGD("mouse down: %d %d", ev->canvas.x - x, ev->canvas.y - y); + + if (desc == NULL) + desc = ""; + + surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h); + tizen_remote_surface_transfer_mouse_event(surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_DOWN, + 0, + ev->button, + ev->canvas.x - x, + ev->canvas.y - y, + wl_fixed_from_double(ev->radius_x), + wl_fixed_from_double(ev->radius_y), + wl_fixed_from_double(ev->pressure), + wl_fixed_from_double(ev->angle), + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); +} + +static void __rs_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data; + Evas_Event_Mouse_Up *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + int x; + int y; + int w; + int h; + struct tizen_remote_surface *surface; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + LOGD("mouse up: %d %d", ev->canvas.x - x, ev->canvas.y - y); + + if (desc == NULL) + desc = ""; + + surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h); + tizen_remote_surface_transfer_mouse_event(surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, + 0, + ev->button, + ev->canvas.x - x, + ev->canvas.y - y, + wl_fixed_from_double(ev->radius_x), + wl_fixed_from_double(ev->radius_y), + wl_fixed_from_double(ev->pressure), + wl_fixed_from_double(ev->angle), + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); + +} + +static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data; + Evas_Event_Mouse_Move *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + int x; + int y; + int w; + int h; + struct tizen_remote_surface *surface; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + + LOGD("mouse move: %d %d", ev->cur.canvas.x - x, ev->cur.canvas.y - y); + + if (desc == NULL) + desc = ""; + + surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h); + tizen_remote_surface_transfer_mouse_event(surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE, + 0, + 0, + ev->cur.canvas.x - x, + ev->cur.canvas.y - y, + wl_fixed_from_double(ev->radius_x), + wl_fixed_from_double(ev->radius_y), + wl_fixed_from_double(ev->pressure), + wl_fixed_from_double(ev->angle), + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); + +} + +static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data; + Evas_Event_Mouse_Wheel *ev = event_info; + const char *desc = evas_device_description_get(ev->dev); + struct tizen_remote_surface *surface; + + LOGD("mouse wheel"); + + if (desc == NULL) + desc = ""; + + surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h); + tizen_remote_surface_transfer_mouse_wheel(surface, + ev->direction, + ev->z, + evas_device_class_get(ev->dev), + evas_device_subclass_get(ev->dev), + desc, + ev->timestamp); - handle = (screen_connector_watcher_evas_h)data; - handle->ops->updated(appid, image, handle->data); } +static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("show"); +} + +static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("hide"); +} + +static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data) +{ + + bool is_added = false; + Evas_Native_Surface ns; + tbm_surface_h tbm_surface; + int width, height; + char *map; + char format[] = "png"; + char plug_id[256]; + screen_connector_watcher_evas_h watcher_evas_h; + char *appid; + char pid; + + watcher_evas_h = (screen_connector_watcher_evas_h)data; + appid = screen_connector_watcher_get_appid(watcher_evas_h->watcher_h); + pid = screen_connector_watcher_get_pid(watcher_evas_h->watcher_h); + if (watcher_evas_h->img_tbm == NULL) { + + LOGD("first added !!!! %d, %d %s", (watcher_evas_h->img_tbm == NULL), type, appid); + watcher_evas_h->img_tbm = evas_object_image_filled_add( + evas_object_evas_get(__viewer_win)); + + /* Image alpha set */ + evas_object_image_alpha_set(watcher_evas_h->img_tbm, 1); + + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_DOWN, + __rs_cb_mouse_down, watcher_evas_h); + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_UP, + __rs_cb_mouse_up, watcher_evas_h); + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_MOVE, + __rs_cb_mouse_move, watcher_evas_h); + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_WHEEL, + __rs_cb_mouse_wheel, watcher_evas_h); + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_SHOW, + __rs_cb_show, watcher_evas_h); + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_HIDE, + __rs_cb_hide, watcher_evas_h); + + /* Store watcher_evas_h */ + g_hash_table_insert(__watcher_tbl, watcher_evas_h->img_tbm, watcher_evas_h); + + /* Set data to use in accessibility */ + snprintf(plug_id, sizeof(plug_id), "%s:%d", appid, pid); + evas_object_data_set(watcher_evas_h->img_tbm, "___PLUGID", strdup(plug_id)); + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_MOVE, __obj_move_cb, watcher_evas_h); + + is_added = true; + } + + /* check type of given buffer */ + if (type == 0) {//if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) { + + /* get tbm surface from buffer */ + tbm_surface = wl_buffer_get_user_data(tbm); + width = tbm_surface_get_width(tbm_surface); + height = tbm_surface_get_height(tbm_surface); + + memset(&ns, 0, sizeof(Evas_Native_Surface)); + ns.version = EVAS_NATIVE_SURFACE_VERSION; + ns.type = EVAS_NATIVE_SURFACE_TBM; + ns.data.tbm.buffer = tbm_surface; + + evas_object_resize(watcher_evas_h->img_tbm, width, height); + evas_object_image_size_set(watcher_evas_h->img_tbm, width, height); + evas_object_image_native_surface_set(watcher_evas_h->img_tbm, &ns); /* set native surface */ + evas_object_image_pixels_dirty_set(watcher_evas_h->img_tbm, EINA_TRUE); /* set dirty for image updating */ + + //evas_object_del(watcher_evas_h->img_file); /* delete previous object for the image file type */ + + } else if (type == 1) {//} else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) { + + if (!watcher_evas_h->img_file) { + watcher_evas_h->img_file = evas_object_image_filled_add( + evas_object_evas_get(__viewer_win)); + } + + map = mmap(NULL, img_file_size, PROT_READ, MAP_SHARED, img_file_fd, 0); + evas_object_image_memfile_set(watcher_evas_h->img_file, map, img_file_size, format, NULL); + evas_object_image_size_get(watcher_evas_h->img_tbm, &width, &height); + evas_object_image_fill_set(watcher_evas_h->img_file, 0, 0, width, height); + evas_object_resize(watcher_evas_h->img_file, width, height); + munmap(map, img_file_size); + close(img_file_fd); /* close passed fd */ + + evas_object_image_native_surface_set(watcher_evas_h->img_tbm, NULL); /* set null to previous object for the tbm type */ + } + + if (is_added) { + LOGD("call added !!!! %s", appid); + watcher_evas_h->ops->added(appid, watcher_evas_h->img_tbm, + watcher_evas_h->data); + } else { + LOGD("call updated !!!! %s", appid); + watcher_evas_h->ops->updated(appid, watcher_evas_h->img_tbm, + watcher_evas_h->data); + } + +} + +static void __watcher_update_cb(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data) +{ + __watcher_change_cb(trs, 0, buffer, 0, 0, 0, NULL, data); +} + +static void __free_watcher_evas_h(screen_connector_watcher_evas_h watcher_evas_h) +{ + if (!watcher_evas_h) + return; + + if (watcher_evas_h->watcher_h) + screen_connector_watcher_remove(watcher_evas_h->watcher_h); + + if (watcher_evas_h->img_tbm) { + evas_object_del(watcher_evas_h->img_tbm); + watcher_evas_h->img_tbm = NULL; + } + + if (watcher_evas_h->ops) + free(watcher_evas_h->ops); + + free(watcher_evas_h); +} + +static void __watcher_missing_cb(struct tizen_remote_surface *trs, void *data) +{ + screen_connector_watcher_evas_h watcher_evas_h; + char *plug_id; + char *appid; + + LOGD("missing"); + watcher_evas_h = (screen_connector_watcher_evas_h)data; + if (!watcher_evas_h) { + LOGE("Null watcher_evas_h"); + return; + } + + g_hash_table_remove(__watcher_tbl, watcher_evas_h->img_tbm); + + /* Remove data used in accessibility */ + plug_id = evas_object_data_del(watcher_evas_h->img_tbm, "___PLUGID"); + free(plug_id); + + appid = screen_connector_watcher_get_appid(watcher_evas_h->watcher_h); + watcher_evas_h->ops->removed(appid, watcher_evas_h->img_tbm, watcher_evas_h->data); + __free_watcher_evas_h(watcher_evas_h); +} + + EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, char *id, void *data) { screen_connector_watcher_evas_h handle; screen_connector_watcher_evas_ops *evas_ops; - screen_connector_watcher_ops *watcher_ops; + screen_connector_watcher_ops watcher_ops; - watcher_ops = (screen_connector_watcher_ops *)calloc(1, sizeof(screen_connector_watcher_ops)); - watcher_ops->added = __watcher_added_cb; - watcher_ops->removed = __watcher_removed_cb; - watcher_ops->updated = __watcher_updated_cb; + watcher_ops.change_cb = __watcher_change_cb; + watcher_ops.missing_cb = __watcher_missing_cb; + watcher_ops.update_cb = __watcher_update_cb; evas_ops = (screen_connector_watcher_evas_ops *)calloc(1, sizeof(screen_connector_watcher_evas_ops)); if (evas_ops == NULL) { @@ -107,7 +476,7 @@ EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(scr } handle->ops = evas_ops; handle->data = data; - handle->watcher_h = screen_connector_watcher_add(watcher_ops, id, handle); + handle->watcher_h = screen_connector_watcher_add(&watcher_ops, id, handle); return handle; } @@ -126,4 +495,234 @@ EXPORT_API int screen_connector_watcher_evas_update(const char *appid) ret = screen_connector_watcher_update(appid); return ret; } + + +static void __send_visibility(gpointer key, gpointer value, gpointer user_data) +{ + screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)value; + Evas_Object *evas_obj = (Evas_Object *)key; + unsigned int event = GPOINTER_TO_INT(user_data); + int ret; + visibility_type type; + + if (watcher_evas_h->freeze) + return; + + if (!__obj_is_visible(evas_obj)) + return; + + if (event) + type = VISIBILITY_TYPE_FULLY_OBSCURED; + else + type = VISIBILITY_TYPE_UNOBSCURED; + + ret = __set_visibility(watcher_evas_h, type); + if (ret == -1) + LOGE("failed to set object visibility set %p to %d", evas_obj, type); +} + +static Eina_Bool __visibility_cb(void *data, int type, void *event) +{ + Ecore_Wl_Event_Window_Visibility_Change *ev = event; + + LOGD("visibility change: %d %d", (unsigned int)ev->win, + (unsigned int)ev->fully_obscured); + + if (!__watcher_tbl) + return ECORE_CALLBACK_RENEW; + + g_hash_table_foreach(__watcher_tbl, __send_visibility, + GINT_TO_POINTER(ev->fully_obscured)); + + return ECORE_CALLBACK_RENEW; +} + +EXPORT_API int screen_connector_watcher_evas_start_visibility_notify() +{ + if (__visibility_listener) + return 0; + + __visibility_listener = ecore_event_handler_add( + ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL); + + return 0; +} + + +EXPORT_API int screen_connector_watcher_evas_stop_visibility_notify() +{ + if (!__visibility_listener) + return 0; + + ecore_event_handler_del(__visibility_listener); + __visibility_listener = NULL; + + return 0; +} + +EXPORT_API int screen_connector_watcher_evas_freeze_visibility(Evas_Object *obj, visibility_type type) +{ + screen_connector_watcher_evas_h watcher_evas_h; + + watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj); + if (!watcher_evas_h) { + LOGE("obj not found"); + return -1; + } + watcher_evas_h->freeze = 1; + + return __set_visibility(watcher_evas_h, type); +} + +EXPORT_API int screen_connector_watcher_evas_thaw_visibility(Evas_Object *obj) +{ + screen_connector_watcher_evas_h watcher_evas_h; + + watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj); + if (!watcher_evas_h) { + LOGE("obj not found"); + return -1; + } + watcher_evas_h->freeze = 0; + + return 0; +} + +EXPORT_API int screen_connector_watcher_evas_send_mouse_up(Evas_Object *obj) +{ + screen_connector_watcher_evas_h watcher_evas_h; + int x; + int y; + int w; + int h; + unsigned int timestamp; + struct tizen_remote_surface *surface; + + watcher_evas_h = g_hash_table_lookup(__watcher_tbl, obj); + if (!watcher_evas_h) { + LOGE("unknown object. not widget object."); + return -1; + } + + if (!watcher_evas_h->img_tbm) { + LOGE("surface not yet initialized."); + return -1; + } + + surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h); + evas_object_geometry_get(obj, &x, &y, &w, &h); + timestamp = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); + tizen_remote_surface_transfer_mouse_event(surface, + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, + 0, + 1, + w / 2, + h / 2, + 0, + 0, + 0, + 0, + TIZEN_INPUT_DEVICE_CLAS_MOUSE, + TIZEN_INPUT_DEVICE_SUBCLAS_NONE, + "", + timestamp); + + return 0; +} + +EXPORT_API int screen_connector_watcher_evas_send_touch_cancel(Evas_Object *obj) +{ + screen_connector_watcher_evas_h watcher_evas_h; + struct tizen_remote_surface *surface; + + watcher_evas_h = g_hash_table_lookup(__watcher_tbl, obj); + if (!watcher_evas_h) { + LOGE("unknown object. not widget object."); + return -1; + } + + if (watcher_evas_h->img_tbm) { + surface = screen_connector_watcher_get_trs(watcher_evas_h->watcher_h); + tizen_remote_surface_transfer_touch_cancel(surface); + watcher_evas_h->cancel_touch = true; + } else { + LOGE("surface not yet initialized."); + return -1; + } + + return 0; +} + +EXPORT_API int screen_connector_watcher_evas_add_by_rid(screen_connector_watcher_evas_ops *ops, int res_id, void *data) +{ + GHashTableIter iter; + gpointer key, value; + screen_connector_watcher_evas_h watcher_evas_h; + screen_connector_watcher_evas_h cur_h = NULL; + screen_connector_watcher_evas_ops *evas_ops; + char *appid = NULL; + int pid = 0; + screen_connector_watcher_ops watcher_ops; + + watcher_ops.change_cb = __watcher_change_cb; + watcher_ops.missing_cb = __watcher_missing_cb; + watcher_ops.update_cb = __watcher_update_cb; + + g_hash_table_iter_init(&iter, __watcher_tbl); + while (g_hash_table_iter_next(&iter, &key, &value)) { + cur_h = (screen_connector_watcher_evas_h)value; + if (screen_connector_watcher_get_resource_id(cur_h->watcher_h) == res_id) { + appid = screen_connector_watcher_get_appid(cur_h->watcher_h); + pid = screen_connector_watcher_get_pid(cur_h->watcher_h); + break; + } + } + + evas_ops = (screen_connector_watcher_evas_ops *)calloc(1, sizeof(screen_connector_watcher_evas_ops)); + if (evas_ops == NULL) { + LOGE("evas_ops calloc fail"); + return -1; + } + + memcpy(evas_ops, ops, sizeof(screen_connector_watcher_evas_ops)); + watcher_evas_h = (screen_connector_watcher_evas_h)calloc(1, sizeof(struct _screen_connector_watcher_evas_h)); + if (watcher_evas_h == NULL) { + LOGE("handle calloc fail"); + return -1; + } + watcher_evas_h->ops = evas_ops; + watcher_evas_h->data = data; + watcher_evas_h->watcher_h = screen_connector_watcher_create_handle(appid, pid, &watcher_ops, watcher_evas_h); + screen_connector_watcher_redirect_surface(watcher_evas_h->watcher_h); + return 0; +} + +EXPORT_API int screen_connector_watcher_evas_get_rid(Evas_Object *obj, int *resource_id) +{ + + screen_connector_watcher_evas_h watcher_evas_h; + + watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj); + if (!watcher_evas_h) { + LOGE("unknown object. not widget object"); + return -1; + } + + return screen_connector_watcher_get_resource_id(watcher_evas_h->watcher_h); +} + + +EXPORT_API int screen_connector_watcher_evas_get_pid(Evas_Object *obj, int *pid) +{ + screen_connector_watcher_evas_h watcher_evas_h; + + watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj); + if (!watcher_evas_h) { + LOGE("unknown object. not widget object"); + return -1; + } + + return screen_connector_watcher_get_pid(watcher_evas_h->watcher_h); +} + /* End of a file */ -- 2.7.4 From 22997e40e765466572e97942b1b13c7c37626f03 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 19 Dec 2016 16:37:05 +0900 Subject: [PATCH 5/8] tizen_remote_surface version up tizen_remote_surface manager version 1 has bug. tizen_remote_surface_release protocol is added. Change-Id: I23e4d6533451b78e2c88e0ab330d2af3485581f4 Signed-off-by: Hyunho Kang --- screen_connector_watcher/src/screen_connector_watcher.c | 3 ++- .../src/screen_connector_watcher_evas.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c index 02210c6..acf1e07 100644 --- a/screen_connector_watcher/src/screen_connector_watcher.c +++ b/screen_connector_watcher/src/screen_connector_watcher.c @@ -178,7 +178,8 @@ EXPORT_API int screen_connector_watcher_init() EINA_INLIST_FOREACH(globals, global) { if (!strcmp(global->interface, "tizen_remote_surface_manager")) { __rsm = wl_registry_bind(registry, global->id, - &tizen_remote_surface_manager_interface, 1); + &tizen_remote_surface_manager_interface, + global->version < 2 ? global->version : 2); } } diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index 8f36025..3bfebd0 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -43,6 +43,7 @@ struct _screen_connector_watcher_evas_h { bool cancel_touch; Evas_Object *img_tbm; Evas_Object *img_file; + struct wl_buffer *pre_buffer; void *data; }; static Evas_Object *__viewer_win; @@ -313,6 +314,7 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, watcher_evas_h = (screen_connector_watcher_evas_h)data; appid = screen_connector_watcher_get_appid(watcher_evas_h->watcher_h); pid = screen_connector_watcher_get_pid(watcher_evas_h->watcher_h); + if (watcher_evas_h->img_tbm == NULL) { LOGD("first added !!!! %d, %d %s", (watcher_evas_h->img_tbm == NULL), type, appid); @@ -391,6 +393,13 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, evas_object_image_native_surface_set(watcher_evas_h->img_tbm, NULL); /* set null to previous object for the tbm type */ } + if (watcher_evas_h->pre_buffer) { + if (tizen_remote_surface_get_version(trs) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION) + tizen_remote_surface_release(trs, watcher_evas_h->pre_buffer); + } + watcher_evas_h->pre_buffer = tbm; + + if (is_added) { LOGD("call added !!!! %s", appid); watcher_evas_h->ops->added(appid, watcher_evas_h->img_tbm, -- 2.7.4 From 4b6bb12caf18806f949d8d1814607de22e536031 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 20 Dec 2016 14:01:54 +0900 Subject: [PATCH 6/8] Adjust coding style Change-Id: Ia8eae134aac2f04a82e8402f93b194bfbe43b932 Signed-off-by: Hwankyu Jhun --- .../include/screen_connector_provider.h | 6 +- .../src/screen_connector_provider.c | 24 ++-- .../include/screen_connector_watcher.h | 8 +- .../src/screen_connector_watcher.c | 59 +++++----- .../include/screen_connector_watcher_evas.h | 25 ++--- .../src/screen_connector_watcher_evas.c | 123 ++++++++------------- 6 files changed, 109 insertions(+), 136 deletions(-) diff --git a/screen_connector_provider/include/screen_connector_provider.h b/screen_connector_provider/include/screen_connector_provider.h index f937c50..05d20ed 100644 --- a/screen_connector_provider/include/screen_connector_provider.h +++ b/screen_connector_provider/include/screen_connector_provider.h @@ -22,11 +22,11 @@ extern "C" { #endif int screen_connector_provider_remote_enable(const char *id, struct wl_surface *surface); -int screen_connector_provider_init(); -int screen_connector_provider_fini(); +int screen_connector_provider_init(void); +int screen_connector_provider_fini(void); #ifdef __cplusplus } #endif -#endif +#endif /* __SCREEN_CONNECTOR_PROVIDER_H__ */ diff --git a/screen_connector_provider/src/screen_connector_provider.c b/screen_connector_provider/src/screen_connector_provider.c index 7834f69..288804b 100644 --- a/screen_connector_provider/src/screen_connector_provider.c +++ b/screen_connector_provider/src/screen_connector_provider.c @@ -1,5 +1,4 @@ /* - * Screen Connector Watcher * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); @@ -14,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #include #include #include - #include #include #include @@ -28,7 +27,6 @@ #include #include - #include "screen_connector_provider.h" #ifdef LOG_TAG @@ -49,7 +47,6 @@ struct __remote_surface_s { static void __rsp_resource_id_cb(void *data, struct tizen_remote_surface_provider *provider, uint32_t res_id) { - LOGE("add app screen : %d", res_id); aul_screen_connector_add_app_screen(res_id); } @@ -139,16 +136,15 @@ EXPORT_API int screen_connector_provider_remote_enable(const char *id, struct wl return 0; } -EXPORT_API int screen_connector_provider_init() +EXPORT_API int screen_connector_provider_init(void) { - int ret = 0; struct wl_registry *registry; Ecore_Wl_Global *global; Eina_Inlist *globals; - if (__init_count > 0) { + if (__init_count > 0) return 0; - } + ecore_wl_init(NULL); registry = ecore_wl_registry_get(); @@ -156,14 +152,14 @@ EXPORT_API int screen_connector_provider_init() if (!registry || !globals) { LOGE("could not get registry(%p) or global list(%p)", registry, - globals); + globals); return -1; } EINA_INLIST_FOREACH(globals, global) { if (!strcmp(global->interface, "tizen_remote_surface_manager")) { __rsm = wl_registry_bind(registry, global->id, - &tizen_remote_surface_manager_interface, 1); + &tizen_remote_surface_manager_interface, 1); } } @@ -173,13 +169,11 @@ EXPORT_API int screen_connector_provider_init() } __init_count++; - return ret; + return 0; } -EXPORT_API int screen_connector_provider_fini() +EXPORT_API int screen_connector_provider_fini(void) { - int ret = 0; - if (__init_count > 1) return 0; @@ -189,5 +183,5 @@ EXPORT_API int screen_connector_provider_fini() ecore_wl_shutdown(); __init_count--; - return ret; + return 0; } diff --git a/screen_connector_watcher/include/screen_connector_watcher.h b/screen_connector_watcher/include/screen_connector_watcher.h index 0bfde94..b1cfed7 100644 --- a/screen_connector_watcher/include/screen_connector_watcher.h +++ b/screen_connector_watcher/include/screen_connector_watcher.h @@ -26,7 +26,7 @@ extern "C" { typedef void (*screen_connector_watcher_update_cb)(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data); typedef void (*screen_connector_watcher_missing_cb)(struct tizen_remote_surface *trs, void *data); typedef void (*screen_connector_watcher_change_cb)(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, - int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data); + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data); typedef struct _screen_connector_watcher_ops { screen_connector_watcher_update_cb update_cb; @@ -36,8 +36,8 @@ typedef struct _screen_connector_watcher_ops { typedef struct _screen_connector_watcher_h *screen_connector_watcher_h; -int screen_connector_watcher_init(); -int screen_connector_watcher_fini(); +int screen_connector_watcher_init(void); +int screen_connector_watcher_fini(void); screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data); int screen_connector_watcher_remove(screen_connector_watcher_h h); int screen_connector_watcher_update(const char *appid); @@ -52,4 +52,4 @@ void screen_connector_watcher_redirect_surface(screen_connector_watcher_h watche } #endif -#endif +#endif /* __SCREEN_CONNECTOR_WATCHER_H__ */ diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c index acf1e07..c1bcfb1 100644 --- a/screen_connector_watcher/src/screen_connector_watcher.c +++ b/screen_connector_watcher/src/screen_connector_watcher.c @@ -1,5 +1,4 @@ /* - * Screen Connector Watcher * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); @@ -14,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #include #include - #include #include #include @@ -40,7 +39,7 @@ struct _screen_connector_watcher_h { void (*update_cb)(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data); void (*missing_cb)(struct tizen_remote_surface *trs, void *data); void (*change_cb)(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, - int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data); + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data); void *data; struct tizen_remote_surface *surface; int resource_id; @@ -51,7 +50,7 @@ typedef struct _screen_connector_watcher_h *screen_connector_watcher_h; static struct tizen_remote_surface_manager *__rsm; static struct wayland_tbm_client *__tbm_client; static struct wl_tbm *__tbm; -static bool __is_init = false; +static bool __is_init; static GList *__watcher_list; static GList *__pending_watcher_list; static aul_screen_viewer_handler __aul_cbs; @@ -59,6 +58,7 @@ static aul_screen_viewer_handler __aul_cbs; static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time) { screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data; + if (watcher_h) watcher_h->update_cb(trs, buffer, time, watcher_h->data); } @@ -66,15 +66,17 @@ static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struc static void __buffer_missing(void *data, struct tizen_remote_surface *trs) { screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data; + if (watcher_h) watcher_h->missing_cb(trs, watcher_h->data); } #if 0 static void __buffer_changed(void *data, struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, - int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys) + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys) { screen_connector_watcher_h watcher_h = (screen_connector_watcher_h)data; + if (watcher_h) watcher_h->change_cb(trs, type, tbm, img_file_fd, img_file_size, time, keys, watcher_h->data); } @@ -97,35 +99,43 @@ static void __app_removed(const char *appid, const int pid, void *data) EXPORT_API void screen_connector_watcher_redirect_surface(screen_connector_watcher_h watcher_h) { - watcher_h->surface = - tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)watcher_h->resource_id, __tbm); + if (watcher_h == NULL) + return; + + watcher_h->surface = tizen_remote_surface_manager_create_surface(__rsm, (uint32_t)watcher_h->resource_id, __tbm); LOGD("resource_id : %d, (%p)", watcher_h->resource_id, watcher_h->surface); - tizen_remote_surface_add_listener(watcher_h->surface, &__rs_listener, - watcher_h); + tizen_remote_surface_add_listener(watcher_h->surface, &__rs_listener, watcher_h); tizen_remote_surface_redirect(watcher_h->surface); } static screen_connector_watcher_h __create_watcher_handle_info(char *appid) { - screen_connector_watcher_h watcher_h = NULL; + screen_connector_watcher_h watcher_h; + watcher_h = (screen_connector_watcher_h)calloc(1, sizeof(struct _screen_connector_watcher_h)); if (watcher_h == NULL) { LOGE("watcher_h calloc fail"); return NULL; } + watcher_h->appid = strdup(appid); + if (watcher_h->appid == NULL) { + LOGE("out of memory"); + free(watcher_h); + return NULL; + } return watcher_h; } static void __app_added(const char *appid, const int pid, const unsigned int resource_id, void *data) { - LOGD("__app_added pid: %d, resource_id: %d, appid: %s", pid, resource_id, appid); screen_connector_watcher_h watcher_h = NULL; - screen_connector_watcher_h cur_h = NULL; + screen_connector_watcher_h cur_h; GList *watcher_list = __watcher_list; + LOGD("__app_added pid: %d, resource_id: %d, appid: %s", pid, resource_id, appid); for (; watcher_list != NULL; watcher_list = watcher_list->next) { cur_h = (screen_connector_watcher_h)watcher_list->data; if (strcmp(cur_h->appid, appid) == 0) { @@ -151,10 +161,9 @@ static void __app_added(const char *appid, const int pid, const unsigned int res screen_connector_watcher_redirect_surface(watcher_h); else LOGE("bad tbm message received. missing arguments"); - } -EXPORT_API int screen_connector_watcher_init() +EXPORT_API int screen_connector_watcher_init(void) { int ret = 0; struct wl_registry *registry; @@ -171,15 +180,15 @@ EXPORT_API int screen_connector_watcher_init() if (!registry || !globals) { LOGE("could not get registry(%p) or global list(%p)", registry, - globals); + globals); return -1; } EINA_INLIST_FOREACH(globals, global) { if (!strcmp(global->interface, "tizen_remote_surface_manager")) { __rsm = wl_registry_bind(registry, global->id, - &tizen_remote_surface_manager_interface, - global->version < 2 ? global->version : 2); + &tizen_remote_surface_manager_interface, + global->version < 2 ? global->version : 2); } } @@ -209,7 +218,7 @@ EXPORT_API int screen_connector_watcher_init() return ret; } -EXPORT_API int screen_connector_watcher_fini() +EXPORT_API int screen_connector_watcher_fini(void) { if (!__is_init) return 0; @@ -245,6 +254,9 @@ EXPORT_API screen_connector_watcher_h screen_connector_watcher_create_handle(cha screen_connector_watcher_h watcher_h = NULL; watcher_h = __create_watcher_handle_info(id); + if (watcher_h == NULL) + return NULL; + watcher_h->update_cb = ops->update_cb; watcher_h->change_cb = ops->change_cb; watcher_h->missing_cb = ops->missing_cb; @@ -256,9 +268,8 @@ EXPORT_API screen_connector_watcher_h screen_connector_watcher_create_handle(cha EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connector_watcher_ops *ops, char *id, void *data) { - screen_connector_watcher_h watcher_h = NULL; - screen_connector_watcher_h cur_h = NULL; + screen_connector_watcher_h cur_h; GList *watcher_list = __pending_watcher_list; for (; watcher_list != NULL; watcher_list = watcher_list->next) { @@ -290,16 +301,14 @@ EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connec EXPORT_API int screen_connector_watcher_remove(screen_connector_watcher_h h) { - int ret = 0; __destroy_watcher_h(h); - return ret; + + return 0; } EXPORT_API int screen_connector_watcher_update(const char *appid) { - int ret = 0; - ret = aul_screen_connector_update_app_screen(appid); - return ret; + return aul_screen_connector_update_app_screen(appid); } EXPORT_API char *screen_connector_watcher_get_appid(screen_connector_watcher_h h) diff --git a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h index efbe06a..117fea5 100644 --- a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __SCREEN_CONNECTOR_WATCHER_EVAS_H -#define __SCREEN_CONNECTOR_WATCHER_EVAS_H +#ifndef __SCREEN_CONNECTOR_WATCHER_EVAS_H__ +#define __SCREEN_CONNECTOR_WATCHER_EVAS_H__ #include #include @@ -37,7 +37,7 @@ extern "C" { */ typedef enum { - VISIBILITY_TYPE_UNOBSCURED = 0, + VISIBILITY_TYPE_UNOBSCURED, VISIBILITY_TYPE_PARTIALLY_OBSCURED, VISIBILITY_TYPE_FULLY_OBSCURED, } visibility_type; @@ -47,21 +47,20 @@ typedef void (*screen_connector_watcher_evas_removed_cb)(const char *appid, Evas typedef void (*screen_connector_watcher_evas_updated_cb)(const char *appid, Evas_Object *image, void *data); typedef struct _screen_connector_watcher_evas_ops { - screen_connector_watcher_evas_added_cb added; - screen_connector_watcher_evas_removed_cb removed; - screen_connector_watcher_evas_updated_cb updated; -}screen_connector_watcher_evas_ops; + screen_connector_watcher_evas_added_cb added; + screen_connector_watcher_evas_removed_cb removed; + screen_connector_watcher_evas_updated_cb updated; +} screen_connector_watcher_evas_ops; typedef struct _screen_connector_watcher_evas_h *screen_connector_watcher_evas_h; int screen_connector_watcher_evas_init(Evas_Object *win); -int screen_connector_watcher_evas_fini(); +int screen_connector_watcher_evas_fini(void); screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, char *id, void *data); int screen_connector_watcher_evas_remove(screen_connector_watcher_evas_h handle); int screen_connector_watcher_evas_update(const char *appid); - -int screen_connector_watcher_evas_start_visibility_notify(); -int screen_connector_watcher_evas_stop_visibility_notify(); +int screen_connector_watcher_evas_start_visibility_notify(void); +int screen_connector_watcher_evas_stop_visibility_notify(void); int screen_connector_watcher_evas_freeze_visibility(Evas_Object *obj, visibility_type type); int screen_connector_watcher_evas_thaw_visibility(Evas_Object *obj); int screen_connector_watcher_evas_send_mouse_up(Evas_Object *obj); @@ -78,6 +77,4 @@ int screen_connector_watcher_evas_get_rid(Evas_Object *obj, int *resource_id); } #endif -#endif - -/* End of a file */ +#endif /* __SCREEN_CONNECTOR_WATCHER_EVAS_H__ */ diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index 3bfebd0..9152610 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -1,5 +1,4 @@ /* - * Screen Connector Watcher Evas * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the License); @@ -19,7 +18,6 @@ #include #include #include - #include #include #include @@ -46,6 +44,7 @@ struct _screen_connector_watcher_evas_h { struct wl_buffer *pre_buffer; void *data; }; + static Evas_Object *__viewer_win; static Ecore_Event_Handler *__visibility_listener; static GHashTable *__watcher_tbl; @@ -60,7 +59,6 @@ static void __destroy_watcher_evas_handle(screen_connector_watcher_evas_h h) EXPORT_API int screen_connector_watcher_evas_init(Evas_Object *win) { - int ret = 0; __viewer_win = win; __watcher_tbl = g_hash_table_new(g_direct_hash, g_direct_equal); @@ -69,19 +67,15 @@ EXPORT_API int screen_connector_watcher_evas_init(Evas_Object *win) return -1; } - ret = screen_connector_watcher_init(); - return ret; + return screen_connector_watcher_init(); } -EXPORT_API int screen_connector_watcher_evas_fini() +EXPORT_API int screen_connector_watcher_evas_fini(void) { - int ret = 0; - if (__watcher_tbl) g_hash_table_destroy(__watcher_tbl); - ret = screen_connector_watcher_fini(); - return ret; + return screen_connector_watcher_fini(); } static bool __obj_is_visible(Evas_Object *obj) @@ -100,15 +94,16 @@ static bool __obj_is_visible(Evas_Object *obj) y >= 0 && y < window_h && (rotation == 0 || rotation == 180)) { LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", - x, y, w, h, window_w, window_h, rotation); + x, y, w, h, window_w, window_h, rotation); return true; } else if (x >= 0 && x < window_h && y >= 0 && y < window_w && (rotation == 90 || rotation == 270)) { LOGD("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d", - x, y, w, h, window_w, window_h, rotation); + x, y, w, h, window_w, window_h, rotation); return true; } + return false; } @@ -224,7 +219,6 @@ static void __rs_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_ evas_device_subclass_get(ev->dev), desc, ev->timestamp); - } static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info) @@ -260,7 +254,6 @@ static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *even evas_device_subclass_get(ev->dev), desc, ev->timestamp); - } static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info) @@ -283,7 +276,6 @@ static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *eve evas_device_subclass_get(ev->dev), desc, ev->timestamp); - } static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info) @@ -297,9 +289,8 @@ static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info } static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, - int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data) + int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data) { - bool is_added = false; Evas_Native_Surface ns; tbm_surface_h tbm_surface; @@ -316,32 +307,31 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, pid = screen_connector_watcher_get_pid(watcher_evas_h->watcher_h); if (watcher_evas_h->img_tbm == NULL) { - LOGD("first added !!!! %d, %d %s", (watcher_evas_h->img_tbm == NULL), type, appid); watcher_evas_h->img_tbm = evas_object_image_filled_add( - evas_object_evas_get(__viewer_win)); + evas_object_evas_get(__viewer_win)); /* Image alpha set */ evas_object_image_alpha_set(watcher_evas_h->img_tbm, 1); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_MOUSE_DOWN, - __rs_cb_mouse_down, watcher_evas_h); + EVAS_CALLBACK_MOUSE_DOWN, + __rs_cb_mouse_down, watcher_evas_h); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_MOUSE_UP, - __rs_cb_mouse_up, watcher_evas_h); + EVAS_CALLBACK_MOUSE_UP, + __rs_cb_mouse_up, watcher_evas_h); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_MOUSE_MOVE, - __rs_cb_mouse_move, watcher_evas_h); + EVAS_CALLBACK_MOUSE_MOVE, + __rs_cb_mouse_move, watcher_evas_h); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_MOUSE_WHEEL, - __rs_cb_mouse_wheel, watcher_evas_h); + EVAS_CALLBACK_MOUSE_WHEEL, + __rs_cb_mouse_wheel, watcher_evas_h); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_SHOW, - __rs_cb_show, watcher_evas_h); + EVAS_CALLBACK_SHOW, + __rs_cb_show, watcher_evas_h); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_HIDE, - __rs_cb_hide, watcher_evas_h); + EVAS_CALLBACK_HIDE, + __rs_cb_hide, watcher_evas_h); /* Store watcher_evas_h */ g_hash_table_insert(__watcher_tbl, watcher_evas_h->img_tbm, watcher_evas_h); @@ -350,14 +340,13 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, snprintf(plug_id, sizeof(plug_id), "%s:%d", appid, pid); evas_object_data_set(watcher_evas_h->img_tbm, "___PLUGID", strdup(plug_id)); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_MOVE, __obj_move_cb, watcher_evas_h); + EVAS_CALLBACK_MOVE, __obj_move_cb, watcher_evas_h); is_added = true; } /* check type of given buffer */ - if (type == 0) {//if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) { - + if (type == 0) { /* get tbm surface from buffer */ tbm_surface = wl_buffer_get_user_data(tbm); width = tbm_surface_get_width(tbm_surface); @@ -372,15 +361,9 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, evas_object_image_size_set(watcher_evas_h->img_tbm, width, height); evas_object_image_native_surface_set(watcher_evas_h->img_tbm, &ns); /* set native surface */ evas_object_image_pixels_dirty_set(watcher_evas_h->img_tbm, EINA_TRUE); /* set dirty for image updating */ - - //evas_object_del(watcher_evas_h->img_file); /* delete previous object for the image file type */ - - } else if (type == 1) {//} else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) { - - if (!watcher_evas_h->img_file) { - watcher_evas_h->img_file = evas_object_image_filled_add( - evas_object_evas_get(__viewer_win)); - } + } else if (type == 1) { + if (!watcher_evas_h->img_file) + watcher_evas_h->img_file = evas_object_image_filled_add(evas_object_evas_get(__viewer_win)); map = mmap(NULL, img_file_size, PROT_READ, MAP_SHARED, img_file_fd, 0); evas_object_image_memfile_set(watcher_evas_h->img_file, map, img_file_size, format, NULL); @@ -399,7 +382,6 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, } watcher_evas_h->pre_buffer = tbm; - if (is_added) { LOGD("call added !!!! %s", appid); watcher_evas_h->ops->added(appid, watcher_evas_h->img_tbm, @@ -409,7 +391,6 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, watcher_evas_h->ops->updated(appid, watcher_evas_h->img_tbm, watcher_evas_h->data); } - } static void __watcher_update_cb(struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time, void *data) @@ -460,7 +441,6 @@ static void __watcher_missing_cb(struct tizen_remote_surface *trs, void *data) __free_watcher_evas_h(watcher_evas_h); } - EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, char *id, void *data) { screen_connector_watcher_evas_h handle; @@ -492,7 +472,8 @@ EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(scr EXPORT_API int screen_connector_watcher_evas_remove(screen_connector_watcher_evas_h handle) { - int ret = 0; + int ret; + ret = screen_connector_watcher_remove(handle->watcher_h); __destroy_watcher_evas_handle(handle); return ret; @@ -500,12 +481,9 @@ EXPORT_API int screen_connector_watcher_evas_remove(screen_connector_watcher_eva EXPORT_API int screen_connector_watcher_evas_update(const char *appid) { - int ret = 0; - ret = screen_connector_watcher_update(appid); - return ret; + return screen_connector_watcher_update(appid); } - static void __send_visibility(gpointer key, gpointer value, gpointer user_data) { screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)value; @@ -535,30 +513,28 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event) Ecore_Wl_Event_Window_Visibility_Change *ev = event; LOGD("visibility change: %d %d", (unsigned int)ev->win, - (unsigned int)ev->fully_obscured); + (unsigned int)ev->fully_obscured); if (!__watcher_tbl) return ECORE_CALLBACK_RENEW; g_hash_table_foreach(__watcher_tbl, __send_visibility, - GINT_TO_POINTER(ev->fully_obscured)); + GINT_TO_POINTER(ev->fully_obscured)); return ECORE_CALLBACK_RENEW; } -EXPORT_API int screen_connector_watcher_evas_start_visibility_notify() +EXPORT_API int screen_connector_watcher_evas_start_visibility_notify(void) { if (__visibility_listener) return 0; - __visibility_listener = ecore_event_handler_add( - ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL); + __visibility_listener = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL); return 0; } - -EXPORT_API int screen_connector_watcher_evas_stop_visibility_notify() +EXPORT_API int screen_connector_watcher_evas_stop_visibility_notify(void) { if (!__visibility_listener) return 0; @@ -622,19 +598,19 @@ EXPORT_API int screen_connector_watcher_evas_send_mouse_up(Evas_Object *obj) evas_object_geometry_get(obj, &x, &y, &w, &h); timestamp = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff); tizen_remote_surface_transfer_mouse_event(surface, - TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, - 0, - 1, - w / 2, - h / 2, - 0, - 0, - 0, - 0, - TIZEN_INPUT_DEVICE_CLAS_MOUSE, - TIZEN_INPUT_DEVICE_SUBCLAS_NONE, - "", - timestamp); + TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP, + 0, + 1, + w / 2, + h / 2, + 0, + 0, + 0, + 0, + TIZEN_INPUT_DEVICE_CLAS_MOUSE, + TIZEN_INPUT_DEVICE_SUBCLAS_NONE, + "", + timestamp); return 0; } @@ -703,12 +679,12 @@ EXPORT_API int screen_connector_watcher_evas_add_by_rid(screen_connector_watcher watcher_evas_h->data = data; watcher_evas_h->watcher_h = screen_connector_watcher_create_handle(appid, pid, &watcher_ops, watcher_evas_h); screen_connector_watcher_redirect_surface(watcher_evas_h->watcher_h); + return 0; } EXPORT_API int screen_connector_watcher_evas_get_rid(Evas_Object *obj, int *resource_id) { - screen_connector_watcher_evas_h watcher_evas_h; watcher_evas_h = (screen_connector_watcher_evas_h)g_hash_table_lookup(__watcher_tbl, obj); @@ -720,7 +696,6 @@ EXPORT_API int screen_connector_watcher_evas_get_rid(Evas_Object *obj, int *reso return screen_connector_watcher_get_resource_id(watcher_evas_h->watcher_h); } - EXPORT_API int screen_connector_watcher_evas_get_pid(Evas_Object *obj, int *pid) { screen_connector_watcher_evas_h watcher_evas_h; @@ -733,5 +708,3 @@ EXPORT_API int screen_connector_watcher_evas_get_pid(Evas_Object *obj, int *pid) return screen_connector_watcher_get_pid(watcher_evas_h->watcher_h); } - -/* End of a file */ -- 2.7.4 From ffa0de1e1fa558b8649f868d6fce9ac1bf93e591 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Fri, 23 Dec 2016 09:21:19 +0900 Subject: [PATCH 7/8] Fix fail to get object pid Change-Id: I4cfff44f1628e9bd4467d437a446e3445de9c51f Signed-off-by: Hyunho Kang --- screen_connector_watcher_evas/src/screen_connector_watcher_evas.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index 9152610..e560334 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -705,6 +705,7 @@ EXPORT_API int screen_connector_watcher_evas_get_pid(Evas_Object *obj, int *pid) LOGE("unknown object. not widget object"); return -1; } + *pid = screen_connector_watcher_get_pid(watcher_evas_h->watcher_h); - return screen_connector_watcher_get_pid(watcher_evas_h->watcher_h); + return 0; } -- 2.7.4 From a6feb4b93fb290802d392a5bfd5998fefa2bdff9 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Wed, 28 Dec 2016 14:01:47 +0900 Subject: [PATCH 8/8] Call visibility update in show,resize callback We need to update initial visibility value for the object when it is shown or resized. If we skip it, the display server sets its own visibility state value for the object as invisible one. Change-Id: I75782a77f1cabadafabf560965e34e634816d702 Signed-off-by: Semun Lee --- .../src/screen_connector_watcher_evas.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index e560334..9cb94d4 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -136,7 +136,7 @@ static int __set_visibility(screen_connector_watcher_evas_h watcher_evas_h, visi return 0; } -static void __obj_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +static void __obj_update_visibility(void *data, Evas *e, Evas_Object *obj, void *event_info) { screen_connector_watcher_evas_h watcher_evas_h = (screen_connector_watcher_evas_h)data; @@ -281,6 +281,7 @@ static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *eve static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info) { LOGD("show"); + __obj_update_visibility(data, e, obj, event_info); } static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info) @@ -288,6 +289,12 @@ static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info LOGD("hide"); } +static void __rs_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("resize"); + __obj_update_visibility(data, e, obj, event_info); +} + static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data) { @@ -332,6 +339,9 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, evas_object_event_callback_add(watcher_evas_h->img_tbm, EVAS_CALLBACK_HIDE, __rs_cb_hide, watcher_evas_h); + evas_object_event_callback_add(watcher_evas_h->img_tbm, + EVAS_CALLBACK_RESIZE, + __rs_cb_resize, watcher_evas_h); /* Store watcher_evas_h */ g_hash_table_insert(__watcher_tbl, watcher_evas_h->img_tbm, watcher_evas_h); @@ -340,7 +350,7 @@ static void __watcher_change_cb(struct tizen_remote_surface *trs, uint32_t type, snprintf(plug_id, sizeof(plug_id), "%s:%d", appid, pid); evas_object_data_set(watcher_evas_h->img_tbm, "___PLUGID", strdup(plug_id)); evas_object_event_callback_add(watcher_evas_h->img_tbm, - EVAS_CALLBACK_MOVE, __obj_move_cb, watcher_evas_h); + EVAS_CALLBACK_MOVE, __obj_update_visibility, watcher_evas_h); is_added = true; } -- 2.7.4