From: Daniel Caujolle-B. <f1...@us...> - 2004-06-12 08:57:28
|
Update of /cvsroot/xine/xine-ui/src/xitk/xine-toolkit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9961/xine-toolkit Modified Files: image.c xitk.c xitk.h Log Message: fix problem with ssaver faking key. Fix an hidden problem with shm deletion (ipcs still show it as used, but it was detached...). Index: image.c =================================================================== RCS file: /cvsroot/xine/xine-ui/src/xitk/xine-toolkit/image.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- image.c 31 May 2004 19:13:04 -0000 1.61 +++ image.c 12 Jun 2004 08:57:18 -0000 1.62 @@ -27,6 +27,7 @@ #include <stdio.h> #include <stdarg.h> #include <X11/Xlib.h> +#include <errno.h> #include "_xitk.h" @@ -145,26 +146,32 @@ ABORT_IF_NULL(xpix); XLOCK(xpix->imlibdata->x.disp); + + if(xpix->pixmap != None) + XFreePixmap(xpix->imlibdata->x.disp, xpix->pixmap); + + XFreeGC(xpix->imlibdata->x.disp, xpix->gc); + XSync(xpix->imlibdata->x.disp, False); #ifdef HAVE_SHM - if(xpix->shm) - XShmDetach(xpix->imlibdata->x.disp, xpix->shminfo); + if(xpix->shm) { + XShmSegmentInfo *shminfo = xpix->shminfo; + + XShmDetach(xpix->imlibdata->x.disp, shminfo); + + if(xpix->xim) + XDestroyImage(xpix->xim); - if(xpix->xim) - XDestroyImage(xpix->xim); + if(shmdt(shminfo->shmaddr) < 0) + XITK_WARNING("shmdt() failed: '%s'\n", strerror(errno)); - if(xpix->shm) { - shmdt(xpix->shminfo->shmaddr); - shmctl(xpix->shminfo->shmid, IPC_RMID, 0); - free(xpix->shminfo); + if(shmctl(shminfo->shmid, IPC_RMID, 0) < 0) + XITK_WARNING("shmctl() failed: '%s'\n", strerror(errno)); + + free(shminfo); } #endif - if(xpix->pixmap != None) - XFreePixmap(xpix->imlibdata->x.disp, xpix->pixmap); - - XFreeGC(xpix->imlibdata->x.disp, xpix->gc); - XUNLOCK(xpix->imlibdata->x.disp); XITK_FREE(xpix); @@ -173,8 +180,7 @@ /* * */ -xitk_pixmap_t *xitk_image_create_xitk_pixmap_with_depth(ImlibData *im, - int width, int height, int depth) { +xitk_pixmap_t *xitk_image_create_xitk_pixmap_with_depth(ImlibData *im, int width, int height, int depth) { xitk_pixmap_t *xpix; #ifdef HAVE_SHM XShmSegmentInfo *shminfo; @@ -184,7 +190,7 @@ ABORT_IF_NOT_COND(width > 0); ABORT_IF_NOT_COND(height > 0); - xpix = (xitk_pixmap_t *) xitk_xmalloc(sizeof(xitk_pixmap_t)); + xpix = (xitk_pixmap_t *) xitk_xmalloc(sizeof(xitk_pixmap_t)); xpix->imlibdata = im; xpix->destroy = xitk_image_xitk_pixmap_destroyer; xpix->width = width; @@ -244,10 +250,10 @@ goto __noxshm_pixmap; } - xpix->xim = xim; + xpix->xim = xim; xpix->pixmap = XShmCreatePixmap(im->x.disp, im->x.base_window, shminfo->shmaddr, shminfo, width, height, depth); - + if(!xpix->pixmap) { XITK_WARNING("XShmCreatePixmap() failed.\n"); XShmDetach(xpix->imlibdata->x.disp, xpix->shminfo); @@ -259,17 +265,10 @@ goto __noxshm_pixmap; } else { - xpix->shm = 1; - // XDestroyImage(xim); - xpix->shminfo = shminfo; + xpix->shm = 1; + xpix->shminfo = shminfo; xpix->gcv.graphics_exposures = False; - xpix->gc = XCreateGC(im->x.disp, xpix->pixmap, GCGraphicsExposures, &xpix->gcv); - shmctl(shminfo->shmid, IPC_RMID, 0); - - // XShmPutImage(im->x.disp, xpix->pixmap, xpix->gc, xpix->xim, - // 0, 0, 0, 0, width, height, False); - // XSync(im->x.disp, False); - + xpix->gc = XCreateGC(im->x.disp, xpix->pixmap, GCGraphicsExposures, &xpix->gcv); xitk_uninstall_x_error_handler(); } } Index: xitk.c =================================================================== RCS file: /cvsroot/xine/xine-ui/src/xitk/xine-toolkit/xitk.c,v retrieving revision 1.122 retrieving revision 1.123 diff -u -r1.122 -r1.123 --- xitk.c 27 Apr 2004 20:20:11 -0000 1.122 +++ xitk.c 12 Jun 2004 08:57:18 -0000 1.123 @@ -42,6 +42,7 @@ #include <time.h> #include <sys/types.h> #include <sys/wait.h> +#include <sys/time.h> #include <locale.h> @@ -129,6 +130,8 @@ Window modalw; xitk_widget_t *menu; + + struct timeval keypress; } __xitk_t; static __xitk_t *gXitk; @@ -1161,6 +1164,9 @@ } while(fx) { + + if(event->type == KeyRelease) + gettimeofday(&gXitk->keypress, 0); if(fx->window != None) { @@ -1625,6 +1631,8 @@ gXitk->x_error_handler = NULL; gXitk->modalw = None; + memset(&gXitk->keypress, 0, sizeof(gXitk->keypress)); + pthread_mutex_init (&gXitk->mutex, NULL); snprintf(buffer, sizeof(buffer), "-[ xiTK version %d.%d.%d ", XITK_MAJOR_VERSION, XITK_MINOR_VERSION, XITK_SUB_VERSION); @@ -1968,6 +1976,18 @@ return cur_locale; } + +/* + * + */ +long int xitk_get_last_keypressed_time(void) { + struct timeval tm, tm_diff; + + gettimeofday(&tm, NULL); + timersub(&tm, &gXitk->keypress, &tm_diff); + return tm_diff.tv_sec; +} + /* * Return home directory. */ Index: xitk.h =================================================================== RCS file: /cvsroot/xine/xine-ui/src/xitk/xine-toolkit/xitk.h,v retrieving revision 1.125 retrieving revision 1.126 diff -u -r1.125 -r1.126 --- xitk.h 27 May 2004 22:25:51 -0000 1.125 +++ xitk.h 12 Jun 2004 08:57:18 -0000 1.126 @@ -672,6 +672,11 @@ /* * */ +long int xitk_get_last_keypressed_time(void); + +/* + * + */ int xitk_get_layer_level(void); /* |