clients/window.c |   44 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 9 deletions(-)
From 202d2c7ddd3503fc9bf015375ff7344c89dfadee Mon Sep 17 00:00:00 2001
From: Chris Morgan <[email protected]>
Date: Sun, 6 Feb 2011 23:12:45 -0500
Subject: [PATCH] Move window frame surface dimensions into struct display and begin using them in place of hardcoded values

---
 clients/window.c |   44 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 4563edf..446c44d 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -75,7 +75,17 @@ struct display {
 	struct wl_list window_list;
 	struct wl_list input_list;
 	char *device_name;
+
+	// pre-rendered fixed-size surfaces that are copied/scaled
+	// to draw the appropriate frame
 	cairo_surface_t *active_frame, *inactive_frame, *shadow;
+
+	// width and height in pixels of the active, inactive and shadow surfaces
+	int frameWidth, frameHeight;
+
+	// width of the frame region of the window
+	int borderWidth;
+
 	struct xkb_desc *xkb;
 	cairo_surface_t **pointer_surfaces;
 
@@ -755,8 +765,8 @@ window_draw_decorations(struct window *window)
 	cairo_set_source_rgba(cr, 0, 0, 0, 0.6);
 	tile_mask(cr, window->display->shadow,
 		  shadow_dx, shadow_dy, width, height,
-		  window->margin + 10 - shadow_dx,
-		  window->margin + 10 - shadow_dy);
+		  window->margin + window->display->borderWidth - shadow_dx,
+		  window->margin + window->display->borderWidth - shadow_dy);
 
 	if (window->keyboard_device)
 		frame = window->display->active_frame;
@@ -764,7 +774,7 @@ window_draw_decorations(struct window *window)
 		frame = window->display->inactive_frame;
 
 	tile_source(cr, frame, 0, 0, width, height,
-		    window->margin + 10, window->margin + 50);
+		    window->margin + window->display->borderWidth, window->margin + 50);
 
 	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
 	cairo_set_font_size(cr, 14);
@@ -1591,30 +1601,46 @@ display_render_frame(struct display *d)
 	int radius = 8;
 	cairo_t *cr;
 
-	d->shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128);
+	d->frameWidth = 128;
+	d->frameHeight = 128;
+	d->borderWidth = 10;
+
+	d->shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+						d->frameWidth, d->frameHeight);
 	cr = cairo_create(d->shadow);
 	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
 	cairo_set_source_rgba(cr, 0, 0, 0, 1);
-	rounded_rect(cr, 16, 16, 112, 112, radius);
+	rounded_rect(cr, 16, 16,
+		     d->frameWidth - 16,
+		     d->frameHeight - 16,
+		     radius);
 	cairo_fill(cr);
 	cairo_destroy(cr);
 	blur_surface(d->shadow, 64);
 
 	d->active_frame =
-		cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128);
+		cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+					    d->frameWidth, d->frameHeight);
 	cr = cairo_create(d->active_frame);
 	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
 	cairo_set_source_rgba(cr, 0.8, 0.8, 0.4, 1);
-	rounded_rect(cr, 16, 16, 112, 112, radius);
+	rounded_rect(cr, 16, 16,
+		     d->frameWidth - 16,
+		     d->frameHeight - 16,
+		     radius);
 	cairo_fill(cr);
 	cairo_destroy(cr);
 
 	d->inactive_frame =
-		cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128);
+		cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+					    d->frameWidth, d->frameHeight);
 	cr = cairo_create(d->inactive_frame);
 	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
 	cairo_set_source_rgba(cr, 0.6, 0.6, 0.6, 1);
-	rounded_rect(cr, 16, 16, 112, 112, radius);
+	rounded_rect(cr, 16, 16,
+		     d->frameWidth - 16,
+		     d->frameHeight - 16,
+		     radius);
 	cairo_fill(cr);
 	cairo_destroy(cr);
 }
-- 
1.7.1

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to