1 #include <stdio.h>
2 #include <string.h>
3 #include <weston.h>
4 #include <screen-info-server-protocol.h>
5 #include <ivi-layout-export.h>
6 #include <ivi-layout-private.h>
7 #include "ivi-controller.h"
8 #include "screen-info.h"
9
10 #define LOG(fmt, ...) weston_log("test-screen-info " fmt "\n", ##__VA_ARGS__)
11
screen_info_module_get(struct wl_client * client,struct wl_resource * resource)12 void screen_info_module_get(struct wl_client* client, struct wl_resource* resource)
13 {
14 struct screen_info **screens = get_screens_info();
15 for (int i = 0; screens[i]; i++) {
16 struct screen_info *iscreen = screens[i];
17
18 LOG("screen %d (0x%x)", iscreen->screen_id, iscreen->screen_id);
19 LOG("---------------------------------------");
20 LOG("- connector name: %s", iscreen->connector_name);
21 LOG("- resolution: w=%d, h=%d",
22 iscreen->width, iscreen->height);
23 static char buffer[256] = {};
24 for (int j = 0; j < iscreen->nlayers; j++) {
25 struct layer_info *ilayer = iscreen->layers[j];
26 sprintf(buffer + strlen(buffer), "%d(0x%x)%s",
27 ilayer->layer_id, ilayer->layer_id,
28 i != iscreen->nlayers - 1 ? "," : "");
29 }
30 LOG("- layer render order: %s", buffer);
31 LOG("");
32
33 for (int j = 0; j < iscreen->nlayers; j++) {
34 struct layer_info *ilayer = iscreen->layers[j];
35
36 LOG(" layer %d (0x%x)", ilayer->layer_id, ilayer->layer_id);
37 LOG(" ---------------------------------------");
38 LOG(" - destination region: x=%d, y=%d, w=%d, h=%d",
39 ilayer->dst_x, ilayer->dst_y, ilayer->dst_w, ilayer->dst_h);
40 LOG(" - source region: x=%d, y=%d, w=%d, h=%d",
41 ilayer->src_x, ilayer->src_y, ilayer->src_w, ilayer->src_h);
42 LOG(" - opacity: %lf", ilayer->opacity);
43 LOG(" - visibility: %d", ilayer->visibility);
44
45 static char buffer[256] = {};
46 for (int k = 0; k < ilayer->nsurfaces; k++) {
47 struct surface_info *isurface = ilayer->surfaces[k];
48 sprintf(buffer + strlen(buffer), "%d(0x%x)%s",
49 isurface->surface_id, isurface->surface_id,
50 i != ilayer->nsurfaces - 1 ? "," : "");
51 }
52 LOG(" - surface render order: %s", buffer);
53 LOG(" - on screen: %d(0x%x)",
54 ilayer->on_screen_id, ilayer->on_screen_id);
55 LOG("");
56
57 for (int k = 0; k < ilayer->nsurfaces; k++) {
58 struct surface_info *isurface = ilayer->surfaces[k];
59
60 LOG(" surface %d (0x%x)",
61 isurface->surface_id, isurface->surface_id);
62 LOG(" ---------------------------------------");
63 LOG(" - destination region: x=%d, y=%d, w=%d, h=%d",
64 isurface->dst_x, isurface->dst_y,
65 isurface->dst_w, isurface->dst_h);
66 LOG(" - source region: x=%d, y=%d, w=%d, h=%d",
67 isurface->src_x, isurface->src_y,
68 isurface->src_w, isurface->src_h);
69 LOG(" - opacity: %lf", isurface->opacity);
70 LOG(" - visibility: %d", isurface->visibility);
71 LOG(" - on layer: %d(0x%x)",
72 isurface->on_layer_id, isurface->on_layer_id);
73 LOG("");
74 }
75 }
76 }
77 free_screens_info(screens);
78
79 // here send to client result
80 screen_info_module_send_info(resource, 666);
81 }
82
83 // screen_info module interface implementation
84 static const
85 struct screen_info_module_interface screen_info_module_ii = {
86 screen_info_module_get
87 };
88
89 static void
bind_screen_info_module(struct wl_client * client,void * data,uint32_t version,uint32_t id)90 bind_screen_info_module(struct wl_client *client, void *data,
91 uint32_t version, uint32_t id)
92 {
93 struct ivishell *shell = data;
94 struct wl_resource *resource;
95
96 resource = wl_resource_create(client, &screen_info_module_interface, version, id);
97 if (resource == NULL) {
98 LOG("bind_screen_info_module: wl_resource_create failed");
99 return;
100 }
101
102 wl_resource_set_implementation(resource, &screen_info_module_ii, shell, NULL);
103 }
104
105 static void
on_property_change()106 on_property_change()
107 {
108 LOG("property changed");
109 }
110
111 WL_EXPORT int
ivishell_module_init(struct ivishell * shell)112 ivishell_module_init(struct ivishell *shell)
113 {
114 LOG("loading test-screen-info-module");
115 if (!wl_global_create(shell->compositor->wl_display,
116 &screen_info_module_interface, 1, shell, bind_screen_info_module)) {
117 LOG("test-screen-info-module: wl_global_create failed");
118 return 1;
119 }
120 LOG("loaded test-screen-info-module");
121
122 set_screen_listener(on_property_change);
123 return 0;
124 }
125