]> git.cworth.org Git - grrobot/blobdiff - src/grr_icon.c
Fixed select handling. Added two of Richard's fancy logos.
[grrobot] / src / grr_icon.c
index 405dfb08e7ff11469491190f600a6e1987dfda3d..bf9a29a850f8342f3c8ce63e47c8d34680fc45c2 100644 (file)
@@ -129,6 +129,10 @@ _grr_icon_init (grr_icon_t *icon, char *name)
     char *file, *buf;
     int buflen;
 
+    icon->surface = NULL;
+    icon->surface_width = 0;
+    icon->surface_height = 0;
+
     status = xsvg_create (&icon->xsvg);
     if (status)
        return RR_STATUS_NO_MEMORY;
@@ -151,9 +155,6 @@ _grr_icon_init (grr_icon_t *icon, char *name)
        fprintf (stderr, "Error parsing built-in SVG icon for: %s\n", name);
        return RR_STATUS_PARSE_ERROR;
     }
-
-    icon->surface = NULL;
-
     return RR_STATUS_SUCCESS;
 }
 
@@ -220,7 +221,7 @@ grr_icon_target_name (rr_target_t target)
 }
 
 void
-grr_icon_draw (grr_icon_t *icon, XrState *xrs)
+grr_icon_draw (grr_icon_t *icon, cairo_t *xrs)
 {
     xsvg_status_t status;
 
@@ -232,27 +233,27 @@ grr_icon_draw (grr_icon_t *icon, XrState *xrs)
 }
 
 void
-grr_icon_predraw (grr_icon_t *icon, XrState *xrs, int width, int height)
+grr_icon_predraw (grr_icon_t *icon, cairo_t *xrs, int width, int height)
 {
     if (icon->surface_width != width || icon->surface_height != height) {
        if (icon->surface)
-           XrSurfaceDestroy (icon->surface);
+           cairo_surface_destroy (icon->surface);
        icon->surface_width = width;
        icon->surface_height = height;
-       icon->surface = XrSurfaceCreateNextTo (XrGetTargetSurface (xrs),
-                                              XrFormatARGB32,
-                                              width, height);
+       icon->surface = cairo_surface_create_similar (cairo_get_target_surface (xrs),
+                                                     CAIRO_FORMAT_ARGB32,
+                                                     width, height);
     }
 
-    XrSave (xrs);
-    XrSetTargetSurface (xrs, icon->surface);
+    cairo_save (xrs);
+    cairo_set_target_surface (xrs, icon->surface);
     grr_icon_draw (icon, xrs);
-    XrRestore (xrs);
+    cairo_restore (xrs);
 }
 
 void
-grr_icon_draw_predrawn (grr_icon_t *icon, XrState *xrs)
+grr_icon_draw_predrawn (grr_icon_t *icon, cairo_t *xrs)
 {
     if (icon->surface)
-       XrShowSurface (xrs, icon->surface, icon->surface_width, icon->surface_height);
+       cairo_show_surface (xrs, icon->surface, icon->surface_width, icon->surface_height);
 }