#include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif int WmSendMessage(PtConnectionClient_t *client, WmMsg_t *request, WmReply_t *reply, unsigned int reply_len); #ifdef __cplusplus } #endif int main(int argc, char *argv[]) { PhRid_t rId; PhRect_t rect; PhRegion_t region; PhWindowInfo_t info; WmMsg_t request; WmReply_t reply; PhRect_t insets; PhAttach(NULL, NULL); memset(®ion, 0, sizeof(region)); memset(&info, 0, sizeof(info)); region.events_opaque = Ph_EV_PTR_ALL | Ph_EV_DRAW | Ph_EV_EXPOSE; region.origin.x = region.origin.y = 10; region.parent = Ph_ROOT_RID; region.data_len = sizeof(info); rect.ul.x = 0; rect.ul.y = 0; rect.lr.x = 110; rect.lr.y = 110; info.fields = Ph_WM_SET_TITLE | Ph_WM_SET_FRAME_ATTRIB | Ph_WM_SET_STATE; info.frame_active_color = PgRGB(0x76, 0xa2, 0xcc); info.frame_inactive_color = Pg_GREY; strncpy(info.title, "Inset Test", 63); rId = PhWindowOpen(Ph_REGION_PARENT | Ph_REGION_EV_SENSE | Ph_REGION_EV_OPAQUE | Ph_REGION_ORIGIN | Ph_REGION_RECT | Ph_REGION_DATA, ®ion, &rect, &info); if (rId != -1) { PgSetRegion(rId); PgSetFillColor(Pg_WHITE); PgDrawRect(&rect, Pg_DRAW_FILL); PgFlush(); memset(&request, 0, sizeof(WmMsg_t)); request.hdr.type = WM_REQUEST_FRAME_SIZE; request.hdr.rid = rId; fprintf(stderr, "*** preparing to call WmSendMessage.\n"); if( -1 == WmSendMessage(NULL, &request, &reply, sizeof(WmReply_t) ) ) { fprintf(stderr, "*** error with WmSendMessage\n"); } else { fprintf(stderr, "*** preparing to copy the data to the insets struct.\n"); memcpy(&insets, &(reply.data.frame.borders), sizeof(PhRect_t)); fprintf(stderr, "*** insets rect for %d ul.x=%d, ul.y=%d, lr.x=%d, lr.y=%d\n", rId, insets.ul.x, insets.ul.y, insets.lr.x, insets.lr.y); } while (1) { sleep(1); } } return 0; }