55#include " tizen_window_elementary.h"
66
77#include < efl_extension.h>
8+ #include < eom.h>
89#include < ui/efl_util.h>
910
1011#include " flutter/shell/platform/tizen/logger.h"
@@ -34,11 +35,20 @@ uint32_t EvasModifierToEcoreEventModifiers(const Evas_Modifier* evas_modifier) {
3435
3536} // namespace
3637
37- TizenWindowElementary::TizenWindowElementary (TizenGeometry geometry,
38- bool transparent,
39- bool focusable,
40- bool top_level)
41- : TizenWindow(geometry, transparent, focusable, top_level) {
38+ TizenWindowElementary::TizenWindowElementary (
39+ TizenGeometry geometry,
40+ bool transparent,
41+ bool focusable,
42+ bool top_level,
43+ FlutterDesktopExternalOutputType external_output_type)
44+ : TizenWindow(geometry, transparent, focusable, top_level),
45+ external_output_type_ (external_output_type) {
46+ if (external_output_type_ != FlutterDesktopExternalOutputType::kNone &&
47+ !InitializeExternalOutputManager ()) {
48+ FT_LOG (Error) << " Failed to initialize the External Output Manager." ;
49+ return ;
50+ }
51+
4252 if (!CreateWindow ()) {
4353 FT_LOG (Error) << " Failed to create a platform window." ;
4454 return ;
@@ -51,6 +61,9 @@ TizenWindowElementary::TizenWindowElementary(TizenGeometry geometry,
5161}
5262
5363TizenWindowElementary::~TizenWindowElementary () {
64+ if (external_output_type_ != FlutterDesktopExternalOutputType::kNone ) {
65+ DestroyExternalOutputManager ();
66+ }
5467 UnregisterEventHandlers ();
5568 DestroyWindow ();
5669}
@@ -69,11 +82,15 @@ bool TizenWindowElementary::CreateWindow() {
6982 elm_win_aux_hint_add (elm_win_, " wm.policy.win.user.geometry" , " 1" );
7083#endif
7184
72- Ecore_Evas* ecore_evas =
73- ecore_evas_ecore_evas_get (evas_object_evas_get (elm_win_));
74-
75- int32_t width, height;
76- ecore_evas_screen_geometry_get (ecore_evas, nullptr , nullptr , &width, &height);
85+ int32_t width = 0 , height = 0 ;
86+ if (external_output_type_ != FlutterDesktopExternalOutputType::kNone ) {
87+ eom_get_output_resolution (external_output_id_, &width, &height);
88+ } else {
89+ Ecore_Evas* ecore_evas =
90+ ecore_evas_ecore_evas_get (evas_object_evas_get (elm_win_));
91+ ecore_evas_screen_geometry_get (ecore_evas, nullptr , nullptr , &width,
92+ &height);
93+ }
7794 if (width == 0 || height == 0 ) {
7895 FT_LOG (Error) << " Invalid screen size: " << width << " x " << height;
7996 return false ;
@@ -99,6 +116,14 @@ bool TizenWindowElementary::CreateWindow() {
99116 evas_object_image_alpha_set (image_, EINA_TRUE);
100117 elm_win_resize_object_add (elm_win_, image_);
101118
119+ if (external_output_type_ != FlutterDesktopExternalOutputType::kNone ) {
120+ if (eom_set_output_window (external_output_id_, elm_win_) !=
121+ EOM_ERROR_NONE) {
122+ FT_LOG (Error) << " eom_set_output_window() failed." ;
123+ return false ;
124+ }
125+ }
126+
102127 return elm_win_ && image_;
103128}
104129
@@ -403,4 +428,54 @@ void TizenWindowElementary::PrepareInputMethod() {
403428 [this ](std::string str) { view_delegate_->OnCommit (str); });
404429}
405430
431+ int32_t TizenWindowElementary::GetExternalOutputId () {
432+ int32_t num_ids = 0 ;
433+ eom_output_id* output_ids = eom_get_eom_output_ids (&num_ids);
434+ if (!output_ids || num_ids == 0 ) {
435+ FT_LOG (Error) << " No external output found." ;
436+ return 0 ;
437+ }
438+
439+ eom_output_id output_id = 0 ;
440+ for (int32_t i = 0 ; i < num_ids; i++) {
441+ eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
442+ eom_get_output_type (output_ids[i], &output_type);
443+
444+ if (external_output_type_ == FlutterDesktopExternalOutputType::kHDMI &&
445+ (output_type == EOM_OUTPUT_TYPE_HDMIA ||
446+ output_type == EOM_OUTPUT_TYPE_HDMIB)) {
447+ output_id = output_ids[i];
448+ break ;
449+ }
450+ }
451+ free (output_ids);
452+ return output_id;
453+ }
454+
455+ bool TizenWindowElementary::InitializeExternalOutputManager () {
456+ if (eom_init ()) {
457+ FT_LOG (Error) << " eom_init() failed." ;
458+ return false ;
459+ }
460+
461+ external_output_id_ = GetExternalOutputId ();
462+ if (external_output_id_ == 0 ) {
463+ FT_LOG (Error) << " Invalid external output ID." ;
464+ return false ;
465+ }
466+
467+ int ret = eom_set_output_attribute (external_output_id_,
468+ EOM_OUTPUT_ATTRIBUTE_NORMAL);
469+ if (ret != EOM_ERROR_NONE) {
470+ FT_LOG (Error)
471+ << " eom_set_output_attribute() failed. Cannot use external output." ;
472+ return false ;
473+ }
474+ return true ;
475+ }
476+
477+ void TizenWindowElementary::DestroyExternalOutputManager () {
478+ eom_deinit ();
479+ }
480+
406481} // namespace flutter
0 commit comments