# HG changeset patch # User darius # Date 1119964359 0 # Node ID 8b6b46a1261d8e919c56b9b89084a0b0ea0c93f6 # Parent 8f7cda8e4af8c21ddeaf9beb11075730eaf21a15 - Move to 5.x+ includes - XFree the Xv image - Ask the WM to keep the window aspect 4:3 diff -r 8f7cda8e4af8 -r 8b6b46a1261d simpletv.c --- a/simpletv.c Tue Jan 04 05:21:07 2005 +0000 +++ b/simpletv.c Tue Jun 28 13:12:39 2005 +0000 @@ -46,8 +46,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -147,10 +147,7 @@ geo.frames = 1; #ifdef USE_XVIMAGES /* Should be YUV_12, but 422 actually gives a synced picture. Though */ - - /* geo.oformat = METEOR_GEO_YUV_12; */ geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12; - /* geo.oformat = METEOR_GEO_YUV_12; */ #else geo.oformat = METEOR_GEO_RGB24; #endif @@ -359,7 +356,8 @@ int num_vis; XPixmapFormatValues *pf; int num_pf , pfi, i, j; - + XSizeHints sz_hint; + disp = XOpenDisplay(NULL); if (!disp) { fprintf(stderr, "X-Error: unable to connect to display\n"); @@ -385,6 +383,18 @@ XMapWindow(disp, win); cmap = DefaultColormap(disp, scr); + + sz_hint.flags = PAspect; + sz_hint.min_aspect.x = width; + sz_hint.min_aspect.y = height; + sz_hint.max_aspect.x = width; + sz_hint.max_aspect.y = height; + + /* set min height/width to 4 to avoid off by one errors */ + sz_hint.min_width = sz_hint.min_height = 4; + sz_hint.flags |= PMinSize; + XSetWMNormalHints(disp, win, &sz_hint); + XSync(disp, False); /* Setup with Xv extension */ @@ -416,8 +426,8 @@ /* Create an image to captured frames */ #ifdef USE_XVIMAGES - yuv_im age = XvShmCreateImage(disp, xv_adaptors[xv_adaptor].base_id, - xv_format_id, 0, w, h, &shminfo); + yuv_image = XvShmCreateImage(disp, xv_adaptors[xv_adaptor].base_id, + xv_format_id, 0, w, h, &shminfo); if (!yuv_image) fprintf(stderr, "X-Error: unable to create XvShm XImage\n"); @@ -426,6 +436,7 @@ fprintf(stderr, "SharedMemory Error: unable to get identifier\n"); shminfo.shmaddr = yuv_image->data = shmat(shminfo.shmid, 0, 0); + yuv_image->data = shminfo.shmaddr; #else rgb_image = XShmCreateImage(disp, vis, depth, ZPixmap, NULL, &shminfo, w, h); if (!rgb_image) @@ -469,9 +480,11 @@ void X_Shutdown() { +#ifdef USE_XVIMAGES XShmDetach(disp, &shminfo); -#ifdef USE_XVIMAGES -#warning How do we destroy an XvImage? + shmctl(shminfo.shmid, IPC_RMID, 0); + shmdt(shminfo.shmaddr); + XFree(yuv_image); #else XDestroyImage(rgb_image); #endif