From 51ada68066085acbc9685cfebf5ab678dc9f324b Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 14 Jul 2021 13:55:36 +0900 Subject: [PATCH] Add auto_popup type to distinguish it from option_popup Change-Id: Ib0fd558ec9fe4bbe6feb335102ef2e2ef49d8459 --- capi/include/cscl-ui-controller.h | 2 +- capi/include/cscl-ui-nui.h | 3 +- capi/include/cscl-ui-window-backend.h | 2 +- capi/src/cscl-ui-controller.cpp | 11 ++++- capi/src/cscl-ui-nui.cpp | 4 +- scl/sclconfig.h | 1 + scl/sclcontroller.cpp | 6 +-- scl/sclresourcecache.cpp | 7 ++- scl/scluibuilder.cpp | 65 +++++++++++++-------------- scl/sclwindowbackendcallback.h | 2 +- scl/sclwindows-nui.cpp | 16 +++---- scl/sclwindows.cpp | 5 ++- 12 files changed, 64 insertions(+), 60 deletions(-) diff --git a/capi/include/cscl-ui-controller.h b/capi/include/cscl-ui-controller.h index 94d2103..a500fb1 100644 --- a/capi/include/cscl-ui-controller.h +++ b/capi/include/cscl-ui-controller.h @@ -21,7 +21,7 @@ extern "C" { #endif -int scl_controller_mouse_press(int x, int y); +int scl_controller_mouse_press(int window_type, int x, int y); int scl_controller_mouse_release(int x, int y); int scl_controller_mouse_move(int x, int y, int touch_id); diff --git a/capi/include/cscl-ui-nui.h b/capi/include/cscl-ui-nui.h index b02c13e..faa4284 100644 --- a/capi/include/cscl-ui-nui.h +++ b/capi/include/cscl-ui-nui.h @@ -49,6 +49,7 @@ typedef enum _WindowType { WINDOW_MAGNIFIER, WINDOW_DIM, WINDOW_POPUP, + WINDOW_AUTO_POPUP, }WindowType; /* graphics backend */ @@ -60,7 +61,7 @@ typedef void (*scl_nui_draw_image_cb)(const char *image_path, int dest_x, int de typedef void (*scl_nui_draw_rectangle_cb)(int pos_x, int pos_y, int width, int height, bool fill, int fill_color_r, int fill_color_g, int fill_color_b, int fill_color_a, SCLWindowType type, void* user_data); /* window backend */ -typedef void (*scl_nui_update_window_cb)(int x, int y, int width, int height, void* user_data); +typedef void (*scl_nui_update_window_cb)(SCLWindowType type, int x, int y, int width, int height, void* user_data); typedef int (*scl_nui_key_click_event_cb)(SclUIEventDesc event_desc); typedef int (*scl_nui_drag_state_changed_cb)(SclUIEventDesc event_desc); typedef int (*scl_nui_event_notification_cb)(SCLUINotiType noti_type, SclNotiDesc *etc_info); diff --git a/capi/include/cscl-ui-window-backend.h b/capi/include/cscl-ui-window-backend.h index e534ec5..bf18b6c 100644 --- a/capi/include/cscl-ui-window-backend.h +++ b/capi/include/cscl-ui-window-backend.h @@ -22,7 +22,7 @@ class CUIWindowBackendCallback : public ISCLUIWindowBackendCallback { public : - void update_window(int x, int y, int width, int height, void* user_data); + void update_window(SCLWindowType type, int x, int y, int width, int height, void* user_data); void update_window_postion(SCLWindowType type, int pos_x, int pos_y, int rot_x, int rot_y); }; diff --git a/capi/src/cscl-ui-controller.cpp b/capi/src/cscl-ui-controller.cpp index ea18a27..363c1df 100644 --- a/capi/src/cscl-ui-controller.cpp +++ b/capi/src/cscl-ui-controller.cpp @@ -28,12 +28,19 @@ using namespace scl; #endif #define LOG_TAG "CSCLUINUI" -EXPORT_API int scl_controller_mouse_press(int x, int y) +EXPORT_API int scl_controller_mouse_press(int window_type, int x, int y) { CSCLController *controller = CSCLController::get_instance(); + CSCLWindows *windows = CSCLWindows::get_instance(); + sclwindow popupwin = windows->get_nth_window_in_Z_order_list(SCL_WINDOW_Z_TOP); + SclWindowContext *popup_window_context = windows->get_window_context(popupwin); + if (controller) { LOGD("mouse down x:%d, y:%d", x, y); - controller->mouse_press(get_main_window(), x, y); + if ((SCLWindowType)window_type == WINDOW_POPUP) + controller->mouse_press(popup_window_context, x, y); + else + controller->mouse_press(get_main_window(), x, y); return 0; } else { diff --git a/capi/src/cscl-ui-nui.cpp b/capi/src/cscl-ui-nui.cpp index ab5ef78..e195e82 100644 --- a/capi/src/cscl-ui-nui.cpp +++ b/capi/src/cscl-ui-nui.cpp @@ -106,11 +106,11 @@ void CUIGraphicsBackendCallback::on_draw_rectangle(int pos_x, int pos_y, int wid } } -void CUIWindowBackendCallback::update_window(int x, int y, int width, int height, void* user_data) +void CUIWindowBackendCallback::update_window(SCLWindowType type, int x, int y, int width, int height, void* user_data) { LOGD("update_window : %p", g_update_window_cb); if (g_update_window_cb) { - g_update_window_cb(x, y, width, height, user_data); + g_update_window_cb(type, x, y, width, height, user_data); } } diff --git a/scl/sclconfig.h b/scl/sclconfig.h index 4f77ea7..bb02887 100644 --- a/scl/sclconfig.h +++ b/scl/sclconfig.h @@ -478,6 +478,7 @@ typedef enum _SCLWindowType { WINDOW_MAGNIFIER, WINDOW_DIM, WINDOW_POPUP, + WINDOW_AUTO_POPUP, }SCLWindowType; } diff --git a/scl/sclcontroller.cpp b/scl/sclcontroller.cpp index 0ad9805..6b261cd 100644 --- a/scl/sclcontroller.cpp +++ b/scl/sclcontroller.cpp @@ -3810,10 +3810,8 @@ void CSCLController::handle_engine_signal(SclInternalSignal signal, sclwindow ta events->destroy_all_timer(); break; case SIGACTION_RECOMPUTE_LAYOUT: { - if (targetWindow != SCLWINDOW_INVALID) { - if (cache) - cache->recompute_layout(targetWindow, type); - } + if (cache) + cache->recompute_layout(targetWindow, type); } break; case SIGACTION_FREE_IMAGES: diff --git a/scl/sclresourcecache.cpp b/scl/sclresourcecache.cpp index 94d5c65..6d907dc 100644 --- a/scl/sclresourcecache.cpp +++ b/scl/sclresourcecache.cpp @@ -963,8 +963,9 @@ CSCLResourceCache::recompute_layout(sclwindow window, SCLWindowType type) popupindex = windows->find_popup_window_index(window); /* Check if the popup index is in valid range */ scl_assert_return_false(popupindex >= 0 && popupindex < MAX_POPUP_WINDOW); - layout = context->get_popup_layout(window); + if (type == WINDOW_AUTO_POPUP) + layout = SCL_LAYOUT_AUTOPOPUP; if (!(sclres_manager->loaded(layout))) { sclres_manager->load(layout); @@ -1104,9 +1105,7 @@ CSCLResourceCache::recompute_layout(sclwindow window, SCLWindowType type) } /* EFL testing */ - if (window) { - windows->update_window(window, 0, 0, 0, 0, type); - } + windows->update_window(window, 0, 0, 0, 0, type); } } diff --git a/scl/scluibuilder.cpp b/scl/scluibuilder.cpp index 2a09b87..2c83232 100644 --- a/scl/scluibuilder.cpp +++ b/scl/scluibuilder.cpp @@ -427,44 +427,41 @@ CSCLUIBuilder::draw_button(const sclwindow window, scldrawctx draw_ctx, const sc need_endpaint = TRUE; } - /* FIXME : There is a case that begin_pain fails. Inspection on the root cause is needed */ - if (draw_ctx) { - SCLShiftState shift_index = context->get_shift_state(); - if (shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF; - - const SclLayout* layout = cache->get_cur_layout(window); - const SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(window, key_index); - - /* 1. drawing the background of the button */ - /* check it according to the following check-list */ - /* check it whether uses SW style button */ - if (layout && coordinate) { - scldrawing background = NULL; - if (layout->use_sw_button) { - /* case 1 (uses Software button) */ - background = draw_button_bg_by_sw(window, draw_ctx, key_index, state, type); - } else { - /* check it whether uses an individual images */ - if (coordinate->bg_image_path[shift_index][state]) { - if (strcmp(coordinate->bg_image_path[shift_index][state], SCL_BACKGROUND_IMAGE_STRING) != 0) { - /* case 2 (uses an individual image) */ - background = draw_button_bg_by_img(window, draw_ctx, key_index, state, shift_index, type); - } else { - /* case 3 (uses the layout background image) */ - background = draw_button_bg_by_layoutimg(window, draw_ctx, key_index, state, shift_index, type); - } - } else if (force_draw_bg) { + SCLShiftState shift_index = context->get_shift_state(); + if (shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF; + + const SclLayout* layout = cache->get_cur_layout(window); + const SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(window, key_index); + + /* 1. drawing the background of the button */ + /* check it according to the following check-list */ + /* check it whether uses SW style button */ + if (layout && coordinate) { + scldrawing background = NULL; + if (layout->use_sw_button) { + /* case 1 (uses Software button) */ + background = draw_button_bg_by_sw(window, draw_ctx, key_index, state, type); + } else { + /* check it whether uses an individual images */ + if (coordinate->bg_image_path[shift_index][state]) { + if (strcmp(coordinate->bg_image_path[shift_index][state], SCL_BACKGROUND_IMAGE_STRING) != 0) { + /* case 2 (uses an individual image) */ + background = draw_button_bg_by_img(window, draw_ctx, key_index, state, shift_index, type); + } else { + /* case 3 (uses the layout background image) */ background = draw_button_bg_by_layoutimg(window, draw_ctx, key_index, state, shift_index, type); } - /* case 4 (don't draw anything for button's background if image_path is NULL) */ + } else if (force_draw_bg) { + background = draw_button_bg_by_layoutimg(window, draw_ctx, key_index, state, shift_index, type); } - - /* 2. displaying the label of the button */ - draw_button_label(window, draw_ctx, key_index, state, shift_index, type); - /* 3. register button as atspi object */ - const sclchar * text = get_button_text_to_read(window, key_index, shift_index); - graphics->register_atspi_object(window, background, text); + /* case 4 (don't draw anything for button's background if image_path is NULL) */ } + + /* 2. displaying the label of the button */ + draw_button_label(window, draw_ctx, key_index, state, shift_index, type); + /* 3. register button as atspi object */ + const sclchar * text = get_button_text_to_read(window, key_index, shift_index); + graphics->register_atspi_object(window, background, text); } /* destroys the cairo surface if the value of the given(parameter) draw_ctx is NULL */ diff --git a/scl/sclwindowbackendcallback.h b/scl/sclwindowbackendcallback.h index 758729d..1c1c188 100644 --- a/scl/sclwindowbackendcallback.h +++ b/scl/sclwindowbackendcallback.h @@ -24,7 +24,7 @@ using namespace scl; /* FIXME : Need to check the dependency cause by the next include statement */ struct ISCLUIWindowBackendCallback { - virtual void update_window(int x, int w, int width, int height, void* user_data) { } + virtual void update_window(SCLWindowType type, int x, int w, int width, int height, void* user_data) { } virtual void update_window_postion(SCLWindowType type, int pos_x, int pos_y, int rot_x, int rot_y) { } }; diff --git a/scl/sclwindows-nui.cpp b/scl/sclwindows-nui.cpp index 73b99bd..021d6be 100644 --- a/scl/sclwindows-nui.cpp +++ b/scl/sclwindows-nui.cpp @@ -737,16 +737,16 @@ CSCLWindowsImplNui::update_window(const sclwindow window, scl16 x, scl16 y, scl1 { SCL_DEBUG(); - if (m_window_backend_callback && type == WINDOW_KEYPAD) { - LOGI("call update_window. x(%d), y(%d), w(%d), h(%d)", x, y, width, height); - m_window_backend_callback->update_window(x, y, width, height, m_window_backend_callback_data); - } - else { - LOGW("### No update window callback ###"); - } + LOGI("call update_window. x(%d), y(%d), w(%d), h(%d)", x, y, width, height); + m_window_backend_callback->update_window(type, x, y, width, height, m_window_backend_callback_data); CSCLUIBuilder *builder = CSCLUIBuilder::get_instance(); - builder->show_layout(window, x, y, width, height, type); + if (window == NULL && type == WINDOW_KEYPAD) { + CSCLWindows *windows = CSCLWindows::get_instance(); + builder->show_layout(windows->get_base_window(), x, y, width, height, type); + } else { + builder->show_layout(window, x, y, width, height, type); + } } /** diff --git a/scl/sclwindows.cpp b/scl/sclwindows.cpp index 42b112e..5492bf6 100644 --- a/scl/sclwindows.cpp +++ b/scl/sclwindows.cpp @@ -144,6 +144,7 @@ CSCLWindows::get_instance() sclwindow CSCLWindows::open_popup(const SclWindowOpener opener, const SclRectangle &geometry, sclshort inputmode, sclshort layout, SCLPopupType popup_type, sclboolean is_virtual, sclboolean use_dim_window, sclint img_offset_x, sclint img_offset_y, sclint timeout) { sclwindow window = SCLWINDOW_INVALID; + SCLWindowType window_type = (popup_type == POPUP_TYPE_AUTO_POPUP) ? WINDOW_AUTO_POPUP : WINDOW_POPUP; CSCLEvents *events = CSCLEvents::get_instance(); CSCLActionState *state = CSCLActionState::get_instance(); @@ -170,7 +171,7 @@ sclwindow CSCLWindows::open_popup(const SclWindowOpener opener, const SclRectang window, geometry.x, geometry.y, geometry.width, geometry.height, layout, popup_type); events->connect_window_events(window, SCL_EVENT_MOUSE | SCL_EVENT_EXPOSE); - controller->handle_engine_signal(SCL_SIG_POPUP_SHOW, window, WINDOW_POPUP); + controller->handle_engine_signal(SCL_SIG_POPUP_SHOW, window, window_type); /* Shows the dim window if it uses the dim_window */ if (use_dim_window) { @@ -270,7 +271,7 @@ sclwindow CSCLWindows::open_popup(const SclWindowOpener opener, const SclRectang }*/ if (windows && coordinate) - windows->update_window(window, coordinate->x, coordinate->y, coordinate->width, coordinate->height, WINDOW_POPUP); + windows->update_window(window, coordinate->x, coordinate->y, coordinate->width, coordinate->height, window_type); } } } -- 2.34.1