xdg_getsurf(struct wl_client * client,struct wl_resource * res,uint32_t id,struct wl_resource * surf_res)1 static void xdg_getsurf(struct wl_client* client,
2 	struct wl_resource* res, uint32_t id, struct wl_resource* surf_res)
3 {
4 	trace(TRACE_SHELL, "get xdg-shell surface");
5 	struct comp_surf* surf = wl_resource_get_user_data(surf_res);
6 	struct wl_resource* xdgsurf_res = wl_resource_create(client,
7 		&xdg_surface_interface, wl_resource_get_version(res), id);
8 
9 	if (!xdgsurf_res){
10 		wl_resource_post_no_memory(res);
11 		return;
12 	}
13 
14 	snprintf(surf->tracetag, 16, "xdg_surf");
15 	surf->surf_res = xdgsurf_res;
16 	wl_resource_set_implementation(xdgsurf_res, &xdgsurf_if, surf, NULL);
17 /*
18  * used to be here, deferred to until we actually set a role
19  * xdg_surface_send_configure(xdgsurf_res, wl_display_next_serial(wl.disp));
20  */
21 }
22 
xdg_pong(struct wl_client * client,struct wl_resource * res,uint32_t serial)23 static void xdg_pong(
24 	struct wl_client* client, struct wl_resource* res, uint32_t serial)
25 {
26 	trace(TRACE_SHELL, "xdg_pong(%PRIu32)", serial);
27 }
28 
xdg_createpos(struct wl_client * client,struct wl_resource * res,uint32_t id)29 static void xdg_createpos(
30 	struct wl_client* client, struct wl_resource* res, uint32_t id)
31 {
32 	trace(TRACE_SHELL, "%"PRIu32, id);
33 
34 	struct positioner* new_pos = malloc(sizeof(struct positioner));
35 	if (!new_pos){
36 		wl_resource_post_no_memory(res);
37 		return;
38 	}
39 	*new_pos = (struct positioner){};
40 	struct wl_resource* pos = wl_resource_create(client,
41 		&xdg_positioner_interface, wl_resource_get_version(res), id);
42 
43 	if (!pos){
44 		free(new_pos);
45 		wl_resource_post_no_memory(pos);
46 		return;
47 	}
48 
49 	wl_resource_set_implementation(pos, &xdgpos_if, new_pos, NULL);
50 }
51 
xdg_destroy(struct wl_client * client,struct wl_resource * res)52 static void xdg_destroy(
53 	struct wl_client* client, struct wl_resource* res)
54 {
55 	trace(TRACE_ALLOC, "xdg_destroy");
56 }
57 
58