headless_debug: add topvwins feature implementation 08/207208/1 accepted/tizen/unified/20190602.221747 submit/tizen/20190530.092249
authorSung-Jin Park <sj76.park@samsung.com>
Wed, 29 May 2019 04:39:36 +0000 (13:39 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 30 May 2019 08:35:09 +0000 (17:35 +0900)
Change-Id: Ibc88582108406f6d92db21036cecc3ac6399f555
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/bin/headless/debug/debug.c
src/bin/headless/headless_server.h
src/bin/headless/shell/shell.c

index 3360903..6996a87 100644 (file)
@@ -46,6 +46,9 @@ typedef struct
 {
        pepper_compositor_t *compositor;
        pepper_inotify_t *inotify;
+
+       pepper_view_t *top_mapped;
+       pepper_view_t *focus;
 } headless_debug_t;
 
 typedef void (*headless_debug_action_cb_t)(headless_debug_t *hd, void *data);
@@ -226,6 +229,55 @@ _headless_debug_NOT_supported(headless_debug_t *hdebug, void *data)
        PEPPER_TRACE("NOT SUPPORTED. WILL BE IMPLEMENTED SOON.\n");
 }
 
+static void
+_headless_debug_topvwins(headless_debug_t *hdebug, void *data)
+{
+       (void) data;
+
+       int cnt = 0;
+       int w, h;
+       double x, y;
+       pid_t pid;
+
+       pepper_list_t *l;
+       const pepper_list_t *list;
+       pepper_view_t *view;
+       pepper_surface_t *surface;
+       pepper_view_t *top_visible = NULL;
+
+       PEPPER_CHECK(hdebug, return, "[%s] Invalid headless debug !\n", __FUNCTION__);
+
+       PEPPER_TRACE("No. WinID      RscID       PID     w    h    x    y   Mapped Visible Top Top_Visible Focus\n");
+       PEPPER_TRACE("==========================================================================================\n");
+
+       list = pepper_compositor_get_view_list(hdebug->compositor);
+
+       pepper_list_for_each_list(l,  list) {
+               view = (pepper_view_t *)l->item;
+               PEPPER_CHECK(view, continue, "[%s] Invalid object view:%p\n", __FUNCTION__, view);
+
+               surface = pepper_view_get_surface(view);
+               PEPPER_CHECK(surface, continue, "[%s] Invalid object surface:%p\n", __FUNCTION__, surface);
+
+               cnt++;
+               pepper_view_get_position(view, &x, &y);
+               pepper_view_get_size(view, &w, &h);
+               wl_client_get_credentials(wl_resource_get_client(pepper_surface_get_resource(surface)), &pid, NULL, NULL);
+               if (!top_visible && pepper_surface_get_buffer(surface))
+                       top_visible = view;
+
+               pepper_log("DEBUG", PEPPER_LOG_LEVEL_DEBUG, "%3d 0x%08x 0x%08x %5d %4d %4d %4.0f %4.0f     %s       %s     %s       %s       %s\n",
+                                       cnt, surface, pepper_surface_get_resource(surface), pid, w, h, x, y,
+                                       pepper_view_is_mapped(view) ? "O" : "X",
+                                       pepper_view_is_visible(view) ? "O" : "X",
+                                       (hdebug->top_mapped == view) ? "O" : "X",
+                                       (top_visible == view) ? "O" : "X",
+                                       (hdebug->focus == view) ? "O" : "X");
+       }
+
+       PEPPER_TRACE("==========================================================================================\n");
+}
+
 static const headless_debug_action_t debug_actions[] =
 {
        { STDOUT_REDIR,  _headless_debug_redir_stdout, NULL },
@@ -233,7 +285,7 @@ static const headless_debug_action_t debug_actions[] =
        { PROTOCOL_TRACE_ON,  _headless_debug_protocol_trace_on, _headless_debug_protocol_trace_off },
        { PROTOCOL_TRACE_OFF, _headless_debug_protocol_trace_off, NULL },
        { KEYGRAB_STATUS, _headless_debug_NOT_supported, NULL },
-       { TOPVWINS, _headless_debug_NOT_supported, NULL },
+       { TOPVWINS, _headless_debug_topvwins, NULL },
        { CONNECTED_CLIENTS, _headless_debug_connected_clients, NULL },
        { CLIENT_RESOURCES, _headless_debug_connected_clients, NULL },
        { HELP_MSG, _headless_debug_dummy, NULL },
@@ -296,6 +348,34 @@ _trace_cb_handle_inotify_event(uint32_t type, pepper_inotify_event_t *ev, void *
 }
 
 PEPPER_API void
+headless_debug_set_focus_view(pepper_compositor_t *compositor, pepper_view_t *focus_view)
+{
+       headless_debug_t *hdebug = NULL;
+
+       hdebug = (headless_debug_t *)pepper_object_get_user_data((pepper_object_t *) compositor, &KEY_DEBUG);
+       PEPPER_CHECK(hdebug, return, "Invalid headless debug.\n");
+
+       if (hdebug->focus != focus_view) {
+               PEPPER_TRACE("[DEBUG] Focus view has been changed to 0x%x (from 0x%x)\n", focus_view, hdebug->focus);
+               hdebug->focus = focus_view;
+       }
+}
+
+PEPPER_API void
+headless_debug_set_top_view(void *compositor, pepper_view_t *top_view)
+{
+       headless_debug_t *hdebug = NULL;
+
+       hdebug = (headless_debug_t *)pepper_object_get_user_data((pepper_object_t *) compositor, &KEY_DEBUG);
+       PEPPER_CHECK(hdebug, return, "Invalid headless debug.\n");
+
+       if (hdebug->top_mapped != top_view) {
+               PEPPER_TRACE("[DEBUG] Top view has been changed to 0x%x (from 0x%x)\n", top_view, hdebug->top_mapped);
+               hdebug->top_mapped = top_view;
+       }
+}
+
+PEPPER_API void
 headless_debug_deinit(pepper_compositor_t * compositor)
 {
        headless_debug_t *hdebug = NULL;
index 42f28ef..79c6f1b 100644 (file)
@@ -47,6 +47,8 @@ PEPPER_API void headless_input_set_top_view(pepper_compositor_t *compositor, pep
 /* APIs for headless_debug */
 PEPPER_API pepper_bool_t headless_debug_init(pepper_compositor_t *compositor);
 PEPPER_API void headless_debug_deinit(pepper_compositor_t *compositor);
+PEPPER_API void headless_debug_set_focus_view(pepper_compositor_t *compositor, pepper_view_t *view);
+PEPPER_API void headless_debug_set_top_view(pepper_compositor_t *compositor, pepper_view_t *view);
 
 #ifdef __cplusplus
 }
index 2f37512..ca55518 100644 (file)
@@ -1098,6 +1098,7 @@ headless_shell_cb_idle(void *data)
                PEPPER_TRACE("[SHELL] IDLE : top-view change: %p to %p\n", hs_shell->top_mapped , top);
                hs_shell->top_mapped = top;
                headless_input_set_top_view(hs_shell->compositor, hs_shell->top_mapped);
+               headless_debug_set_top_view(hs_shell->compositor, hs_shell->top_mapped);
 
                /*Force update the output*/
                l = pepper_compositor_get_output_list(hs_shell->compositor);
@@ -1110,6 +1111,7 @@ headless_shell_cb_idle(void *data)
                PEPPER_TRACE("[SHELL] IDLE : focus-view change: %p to %p\n", hs_shell->focus , focus);
                hs_shell->focus = focus;
                headless_input_set_focus_view(hs_shell->compositor, hs_shell->focus);
+               headless_debug_set_focus_view(hs_shell->compositor, hs_shell->focus);
        }
 
        if (top_visible != hs_shell->top_visible) {