[cairo-commit] cairo-demo/X11 ChangeLog,1.1,1.2 cairo-knockout.c,1.7,1.8

Carl Worth commit at pdx.freedesktop.org
Wed Nov 19 18:14:43 PST 2003


Committed by: cworth

Update of /cvs/cairo/cairo-demo/X11
In directory pdx:/tmp/cvs-serv10188

Modified Files:
	ChangeLog cairo-knockout.c 
Log Message:

        * cairo-knockout.c: Double buffer everything so expose handling is
        a simple copy operation. Only do redraw after resize. Add more
        window properties so window managers like metacity will decorate
        the window.


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/X11/ChangeLog,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ChangeLog	7 Nov 2003 20:09:14 -0000	1.1
--- ChangeLog	20 Nov 2003 02:14:41 -0000	1.2
***************
*** 1,2 ****
--- 1,9 ----
+ 2003-11-19  Carl Worth  <cworth at isi.edu>
+ 
+ 	* cairo-knockout.c: Double buffer everything so expose handling is
+ 	a simple copy operation. Only do redraw after resize. Add more
+ 	window properties so window managers like metacity will decorate
+ 	the window.
+ 
  2003-11-07  Carl Worth  <cworth at isi.edu>
  

Index: cairo-knockout.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/X11/cairo-knockout.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** cairo-knockout.c	1 Oct 2003 02:04:48 -0000	1.7
--- cairo-knockout.c	20 Nov 2003 02:14:41 -0000	1.8
***************
*** 11,14 ****
--- 11,15 ----
   * v0.4  29 September 2003 - Use cairo_rectangle rather than private rect_path
   *			     Use cairo_arc for oval_path
+  * Keeping log of changes in ChangeLog/CVS now. (2003-11-19) Carl Worth
   */
  #include <X11/Xlib.h>
***************
*** 210,264 ****
  }
  
- static void
- handle_expose (Display *dpy,
-                int      screen,
-                Window   win,
-                int      width,
-                int      height,
-                Region   region)
- {
-     Pixmap p;
-     cairo_t *r;
-     XRectangle clip;
-     GC gc;
- 
-     /* Create an offscreen pixmap of the size of the
-      * area we need to repaint, and a cairo_t object
-      * directed to that pixmap.
-      */
-     XClipBox (region, &clip);
-     p = XCreatePixmap (dpy, win, clip.width, clip.height, DefaultDepth (dpy, screen));
- 
-     r = cairo_create ();
- 
-     cairo_set_target_drawable (r, dpy, p);
- 
-     /* By adding a translation, we hide the partial
-      * pixmap from our drawing routine
-      */
-     cairo_translate (r, -clip.x, -clip.y);
- 
-     /* It would be nice to be able to set 'region' as
-      * clip for our drawing, then only copy that portion
-      * of our drawing, but Cairo doesn't expose the clipping
-      * features of Xrender. So, we redraw the entire
-      * bounding rectangle, even if the area is, e.g., L shaped,
-      * as frequently happens for exposes.x
-      */
- 
-     /* Draw the contents
-      */
-     draw (r, width, height);
- 
-     /* Now copy from our offscreen pixmap to the window
-      */
-     gc = XCreateGC (dpy, p, 0, NULL);
-     XCopyArea (dpy, p, win, gc, 0, 0, clip.width, clip.height, clip.x, clip.y);
-     XFreeGC (dpy, gc);
-     
-     XFreePixmap (dpy, p);
-     cairo_destroy (r);
- }
- 
  int
  main (int argc, char **argv)
--- 211,214 ----
***************
*** 267,277 ****
    int screen;
    Window w;
    char *title = "Knockout Groups";
-   XTextProperty title_prop;
    unsigned int quit_keycode;
    
    int width = 400;
    int height = 400;
-   Region update_region = XCreateRegion ();
    
    dpy = XOpenDisplay (NULL);
--- 217,231 ----
    int screen;
    Window w;
+   Pixmap pixmap;
    char *title = "Knockout Groups";
    unsigned int quit_keycode;
+   int needs_redraw;
+   GC gc;
+   XWMHints *wmhints;
+   XSizeHints *normalhints;
+   XClassHint *classhint;
    
    int width = 400;
    int height = 400;
    
    dpy = XOpenDisplay (NULL);
***************
*** 282,289 ****
  			   BlackPixel (dpy, screen), WhitePixel (dpy, screen));
  
!   if (XStringListToTextProperty (&title, 1, &title_prop)) {
!       XSetWMName (dpy, w, &title_prop);
!       XFree (title_prop.value);
!   }
  
    quit_keycode = XKeysymToKeycode(dpy, XStringToKeysym("Q"));
--- 236,262 ----
  			   BlackPixel (dpy, screen), WhitePixel (dpy, screen));
  
!   normalhints = XAllocSizeHints ();
!   normalhints->flags = 0;
!   normalhints->x = 0;
!   normalhints->y = 0;
!   normalhints->width = width;
!   normalhints->height = height;
! 
!   classhint = XAllocClassHint ();
!   classhint->res_name = "cairo-knockout";
!   classhint->res_class = "Cairo-knockout";
!     
!   wmhints = XAllocWMHints ();
!   wmhints->flags = InputHint;
!   wmhints->input = True;
!     
!   Xutf8SetWMProperties (dpy, w, title, "cairo-knockout", 0, 0, 
!                         normalhints, wmhints, classhint);
!   XFree (wmhints);
!   XFree (classhint);
!   XFree (normalhints);
! 
!   pixmap = XCreatePixmap (dpy, w, width, height, DefaultDepth (dpy, screen));
!   gc = XCreateGC (dpy, pixmap, 0, NULL);
  
    quit_keycode = XKeysymToKeycode(dpy, XStringToKeysym("Q"));
***************
*** 292,295 ****
--- 265,270 ----
    XMapWindow (dpy, w);
    
+   needs_redraw = 1;
+ 
    while (1) {
        XEvent xev;
***************
*** 300,309 ****
         * over needlessly.
         */
!       if (!XPending (dpy) && !XEmptyRegion (update_region)) {
!           handle_expose (dpy, screen, w,
!                          width, height,
!                          update_region);
!           XDestroyRegion (update_region);
!           update_region = XCreateRegion ();
        }
        
--- 275,293 ----
         * over needlessly.
         */
!       if (!XPending (dpy) && needs_redraw) {
!           cairo_t *r = cairo_create ();
! 
!           cairo_set_target_drawable (r, dpy, pixmap);
! 
!           draw (r, width, height);
! 
!           cairo_destroy (r);
! 
!           XCopyArea (dpy, pixmap, w, gc,
!                      0, 0,
!                      width, height,
!                      0, 0);
! 
!           needs_redraw = 0;
        }
        
***************
*** 321,337 ****
  	  width = xev.xconfigure.width;
  	  height = xev.xconfigure.height;
  	  break;
        case Expose:
!           /* Accumulate area that needs redraw */
!           {
!               XRectangle r;
!               
!               r.x = xev.xexpose.x;
!               r.y = xev.xexpose.y;
!               r.width = xev.xexpose.width;
!               r.height = xev.xexpose.height;
!               
!               XUnionRectWithRegion (&r, update_region, update_region);
!           }
  	  break;
        }
--- 305,317 ----
  	  width = xev.xconfigure.width;
  	  height = xev.xconfigure.height;
+           XFreePixmap (dpy, pixmap);
+           pixmap = XCreatePixmap (dpy, w, width, height, DefaultDepth (dpy, screen));
+           needs_redraw = 1;
  	  break;
        case Expose:
!           XCopyArea (dpy, pixmap, w, gc,
!                      xev.xexpose.x, xev.xexpose.y,
!                      xev.xexpose.width, xev.xexpose.height,
!                      xev.xexpose.x, xev.xexpose.y);
  	  break;
        }
***************
*** 339,343 ****
    DONE:
  
!   XDestroyRegion (update_region);
    XCloseDisplay (dpy);
  
--- 319,323 ----
    DONE:
  
!   XFreeGC (dpy, gc);
    XCloseDisplay (dpy);
  





More information about the cairo-commit mailing list