comparison src/X_supp.c @ 693:8b7964869f7a

Update window with XImage through XSHM
author Thinker K.F. Li <thinker@branda.to>
date Mon, 09 Aug 2010 10:03:54 +0800
parents 201cc86720a3
children 7e64e0f70cb6
comparison
equal deleted inserted replaced
692:201cc86720a3 693:8b7964869f7a
66 #ifdef XSHM 66 #ifdef XSHM
67 XImage *ximage; 67 XImage *ximage;
68 XShmSegmentInfo shminfo; 68 XShmSegmentInfo shminfo;
69 #endif 69 #endif
70 }; 70 };
71
72 #ifdef XSHM
73 static void
74 XSHM_update(X_MB_runtime_t *xmb_rt) {
75 GC gc;
76
77 gc = DefaultGC(xmb_rt->display, DefaultScreen(xmb_rt->display));
78 if(xmb_rt->ximage) { /* support XSHM */
79 XShmPutImage(xmb_rt->display,
80 xmb_rt->win,
81 gc,
82 xmb_rt->ximage,
83 0, 0, 0, 0,
84 xmb_rt->w, xmb_rt->h, 0);
85 }
86 }
87 #endif
71 88
72 /*! \defgroup xkb X Keyboard Handling 89 /*! \defgroup xkb X Keyboard Handling
73 * 90 *
74 * Accept keyboard events from X server and delivery it to 91 * Accept keyboard events from X server and delivery it to
75 * application through observer pattern. There is a subject, 92 * application through observer pattern. There is a subject,
341 } 358 }
342 if(eflag) { 359 if(eflag) {
343 rdman_redraw_area(rdman, ex1, ey1, (ex2 - ex1), (ey2 - ey1)); 360 rdman_redraw_area(rdman, ex1, ey1, (ex2 - ex1), (ey2 - ey1));
344 eflag = 0; 361 eflag = 0;
345 } 362 }
363 #ifdef XSHM
364 XSHM_update(rt);
365 #endif
346 XFlush(display); 366 XFlush(display);
347 } 367 }
348 368
349 /*! \brief Handle connection coming data and timeout of timers. 369 /*! \brief Handle connection coming data and timeout of timers.
350 * 370 *
399 419
400 if(r1 == 0) { 420 if(r1 == 0) {
401 get_now(&now); 421 get_now(&now);
402 mb_tman_handle_timeout(tman, &now); 422 mb_tman_handle_timeout(tman, &now);
403 rdman_redraw_changed(rdman); 423 rdman_redraw_changed(rdman);
424 #ifdef XSHM
425 XSHM_update(rt);
426 #endif
404 XFlush(display); 427 XFlush(display);
405 } else if(FD_ISSET(fd, &rfds)){ 428 } else if(FD_ISSET(fd, &rfds)){
406 handle_x_event(rt); 429 handle_x_event(rt);
407 } else { 430 } else {
408 for(i=0;i<rt->n_monitor;i++) { 431 for(i=0;i<rt->n_monitor;i++) {
583 mbe_image_surface_create(MB_IFMT_ARGB32, w, h); 606 mbe_image_surface_create(MB_IFMT_ARGB32, w, h);
584 607
585 xmb_rt->surface_ptn = 608 xmb_rt->surface_ptn =
586 mbe_pattern_create_for_surface(xmb_rt->surface); 609 mbe_pattern_create_for_surface(xmb_rt->surface);
587 610
588 if(xmb_rt->backend_surface != NULL) /* xshm_init() may create one */ 611 if(xmb_rt->backend_surface == NULL) /* xshm_init() may create one */
589 xmb_rt->backend_surface = 612 xmb_rt->backend_surface =
590 mbe_xlib_surface_create(xmb_rt->display, 613 mbe_xlib_surface_create(xmb_rt->display,
591 xmb_rt->win, 614 xmb_rt->win,
592 xmb_rt->visual, 615 xmb_rt->visual,
593 w, h); 616 w, h);
776 } 799 }
777 800
778 /*! \brief Flush buffer for the X connection of a runtime object. 801 /*! \brief Flush buffer for the X connection of a runtime object.
779 */ 802 */
780 int _X_MB_flush_x_conn_for_nodejs(void *rt) { 803 int _X_MB_flush_x_conn_for_nodejs(void *rt) {
781 return XFlush(((X_MB_runtime_t *)rt)->display); 804 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt;
805 #ifdef XSHM
806 XSHM_update(xmb_rt);
807 #endif
808 return XFlush(xmb_rt->display);
782 } 809 }
783 810
784 /* @} */ 811 /* @} */