Code review comment for lp:~mc-return/compiz/compiz.merge-fix1166195-fix1166196-fix116245-resizeinfo-fixes

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

179 - int height = RESIZE_POPUP_HEIGHT;
180 - int width = RESIZE_POPUP_WIDTH;
181 float r, g, b, a;
182
183 INFO_SCREEN (screen);
184 @@ -197,7 +199,9 @@
185 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
186
187 /* Setup Gradient */
188 - pattern = cairo_pattern_create_linear (0, 0, width, height);
189 + pattern = cairo_pattern_create_linear (0, 0,
190 + RESIZE_POPUP_WIDTH,
191 + RESIZE_POPUP_HEIGHT);
192
193 r = is->optionGetGradient1Red () / (float)0xffff;
194 g = is->optionGetGradient1Green () / (float)0xffff;
195 @@ -220,10 +224,14 @@
196
197 /* Rounded Rectangle! */
198 cairo_arc (cr, border, border, border, PI, 1.5f * PI);
199 - cairo_arc (cr, border + width - 2 * border, border, border,
200 + cairo_arc (cr, border + RESIZE_POPUP_WIDTH - 2 * border,
201 + border, border,
202 1.5f * PI, 2.0 * PI);
203 - cairo_arc (cr, width - border, height - border, border, 0, PI / 2.0f);
204 - cairo_arc (cr, border, height - border, border, PI / 2.0f, PI);
205 + cairo_arc (cr, RESIZE_POPUP_WIDTH - border,
206 + RESIZE_POPUP_HEIGHT - border,
207 + border, 0, PI / 2.0f);
208 + cairo_arc (cr, border, RESIZE_POPUP_HEIGHT - border,
209 + border, PI / 2.0f, PI);

Instead of removing the declarations of width and height, it might be better to change their purpose. We seem to be doing a lot of this:

RESIZE_POPUP_WIDTH - border ... RESIZE_POPUP_HEIGHT - border etc

Why not change the declaration to

unsigned int widthWithoutBorder = RESIZE_POPUP_WIDTH - border;
unsigned int heightWithoutBorder = RESIZE_POPUP_HEIGHT - border;

Then you can just do:

cairo_arc (cr, widthWithoutBorder,
206 + heightWithoutBorder,
207 + border, 0, PI / 2.0f);

etc

« Back to merge proposal