int main(int argc, char** argv) { struct arg_arr* aarr; struct arcan_shmif_cont cont = arcan_shmif_open( SEGID_APPLICATION, SHMIF_ACQUIRE_FATALFAIL, &aarr); arcan_event ev = { .ext.kind = ARCAN_EVENT(CLOCKREQ), .ext.clock.rate = 2, .ext.clock.dynamic = (argc > 1 && strcmp(argv[1], "dynamic") == 0) }; arcan_shmif_enqueue(&cont, &ev); ev.ext.clock.dynamic = false; int tbl[] = {20, 40, 42, 44, 60, 80, 86, 88, 100, 120}; int step = 0; for (size_t i=0; i < sizeof(tbl)/sizeof(tbl[0]); i++){ ev.ext.clock.once = true; ev.ext.clock.rate = tbl[i]; ev.ext.clock.id = i + 2; /* 0 index and 1 is reserved */ arcan_shmif_enqueue(&cont, &ev); } while(arcan_shmif_wait(&cont, &ev) != 0){ if (ev.category == EVENT_TARGET) switch(ev.tgt.kind){ case TARGET_COMMAND_STEPFRAME: printf("step: %d, source: %d\n", ev.tgt.ioevs[0].iv, ev.tgt.ioevs[1].iv); if (ev.tgt.ioevs[1].iv > 1){ if (step == ev.tgt.ioevs[1].iv-2) printf("custom timer %d OK\n", step); else printf("timer out of synch, expected %d got %d\n", step, ev.tgt.ioevs[1].iv-2); step++; } break; case TARGET_COMMAND_EXIT: goto done; /* break(1), please */ default: break; } } done: arcan_shmif_drop(&cont); return EXIT_SUCCESS; }
static bool subcomp_defer_handler( struct surface_request* req, struct arcan_shmif_cont* con) { if (!con){ trace(TRACE_SHELL, "reqfail"); wl_resource_post_no_memory(req->target); return false; } struct wl_resource* subsurf = wl_resource_create(req->client->client, &wl_subsurface_interface, wl_resource_get_version(req->target), req->id); if (!subsurf){ trace(TRACE_SHELL, "reqfail"); wl_resource_post_no_memory(req->target); return false; } struct comp_surf* surf = wl_resource_get_user_data(req->target); wl_resource_set_implementation(subsurf, &subsurf_if, surf, NULL); if (!surf){ trace(TRACE_SHELL, "reqfail"); wl_resource_post_no_memory(req->target); return false; } surf->acon = *con; surf->cookie = 0xfeedface; surf->shell_res = subsurf; surf->dispatch = subsurf_shmifev_handler; surf->sub_parent_res = req->parent; snprintf(surf->tracetag, SURF_TAGLEN, "subsurf"); if (req->parent){ struct comp_surf* psurf = wl_resource_get_user_data(req->parent); if (!psurf->acon.addr){ trace(TRACE_ALLOC, "bad subsurface, broken parent"); return false; } surf->viewport.ext.kind = ARCAN_EVENT(VIEWPORT); surf->viewport.ext.viewport.parent = psurf->acon.segment_token; arcan_shmif_enqueue(&surf->acon, &surf->viewport); } trace(TRACE_ALLOC, "subsurface"); return true; }
static void apply_positioner( struct positioner* pos, struct arcan_event* ev) { if (!pos || !ev) return; ev->category = EVENT_EXTERNAL; ev->ext.kind = ARCAN_EVENT(VIEWPORT); ev->ext.viewport.y = pos->ofs_y; ev->ext.viewport.x = pos->ofs_x; ev->ext.viewport.w = pos->width; ev->ext.viewport.h = pos->height; if (pos->anchor & XDG_POSITIONER_ANCHOR_TOP) ev->ext.viewport.y += pos->anchor_y; else if (pos->anchor & XDG_POSITIONER_ANCHOR_BOTTOM) ev->ext.viewport.y += pos->anchor_y + pos->anchor_height; else ev->ext.viewport.y += pos->anchor_y + (pos->anchor_height >> 1); if (pos->anchor & XDG_POSITIONER_ANCHOR_LEFT) ev->ext.viewport.x += pos->anchor_x; else if (pos->anchor & XDG_POSITIONER_ANCHOR_RIGHT) ev->ext.viewport.x += pos->anchor_x + pos->anchor_width; else ev->ext.viewport.x += pos->anchor_x + (pos->anchor_width >> 1); if (pos->gravity & XDG_POSITIONER_GRAVITY_TOP) ev->ext.viewport.y -= pos->height; else if (pos->gravity & XDG_POSITIONER_GRAVITY_BOTTOM) ; else ev->ext.viewport.y -= pos->height >> 1; /* * uncertain what to do about the constraint adjustment at this stage */ }
static void got_icon(struct arcan_shmif_cont* cont) { char buf[256]; arcan_shmif_enqueue(cont, &(arcan_event){ .ext.kind = ARCAN_EVENT(CLOCKREQ), .ext.clock.rate = 20});