~awn-extras/awn-extras/vector-effects-extras

« back to all changes in this revision

Viewing changes to src/shiny-switcher/shinyswitcherapplet.c

  • Committer: Michal Hruby
  • Date: 2008-09-29 19:42:23 UTC
  • mfrom: (877.1.13 awn-extras)
  • Revision ID: mhr3@zoznam.sk-20080929194223-c2q6qbr7attyuo8o
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
 
197
197
double vp_vscale(Shiny_switcher *shinyswitcher)
198
198
{
199
 
  return (double)wnck_screen_get_height(shinyswitcher->wnck_screen) / (double)wnck_workspace_get_height(wnck_screen_get_active_workspace(shinyswitcher->wnck_screen));
200
 
 
 
199
  static double cached = 1;
 
200
  double result = cached;
 
201
  WnckWorkspace * space =  wnck_screen_get_active_workspace(shinyswitcher->wnck_screen);
 
202
  if (space)
 
203
  {
 
204
    result = (double)wnck_screen_get_height(shinyswitcher->wnck_screen) / (double)wnck_workspace_get_height(space);
 
205
    cached = result;
 
206
  }
 
207
  return result;
201
208
}
202
209
 
203
210
double vp_hscale(Shiny_switcher *shinyswitcher)
204
211
{
205
 
  return (double)wnck_screen_get_width(shinyswitcher->wnck_screen) / (double)wnck_workspace_get_width(wnck_screen_get_active_workspace(shinyswitcher->wnck_screen));
 
212
  static double cached = 1;
 
213
  double result = cached;
 
214
  WnckWorkspace * space = wnck_screen_get_active_workspace(shinyswitcher->wnck_screen);
 
215
  if (space)
 
216
  {
 
217
    result = (double)wnck_screen_get_width(shinyswitcher->wnck_screen) / (double)wnck_workspace_get_width(space);
 
218
    cached = result;
 
219
  }
 
220
  return result;
206
221
 
207
222
}
208
223
 
227
242
  shinyswitcher->mini_work_width = shinyswitcher->mini_work_height * shinyswitcher->applet_scale * scr_ratio *
228
243
                                   (double)wnck_ws_width / (double)wnck_scr_width * vp_vscale(shinyswitcher);
229
244
  shinyswitcher->width = shinyswitcher->mini_work_width * shinyswitcher->cols;
 
245
  g_assert(shinyswitcher->mini_work_height);
 
246
  g_assert(shinyswitcher->mini_work_width);
 
247
  g_assert(shinyswitcher->width);
230
248
}
231
249
 
232
250
 
251
269
 
252
270
  gulong wallpaper_xid = wnck_screen_get_background_pixmap(shinyswitcher->wnck_screen);
253
271
  GdkPixmap* wallpaper = gdk_pixmap_foreign_new(wallpaper_xid);
 
272
  if (!wallpaper)
 
273
  {
 
274
    return;
 
275
  }
254
276
  gdk_drawable_set_colormap(wallpaper, shinyswitcher->rgb_cmap);
255
277
 
256
278
  shinyswitcher->wallpaper_inactive = gdk_pixmap_new(NULL, shinyswitcher->mini_work_width * vp_hscale(shinyswitcher), shinyswitcher->mini_work_height * vp_vscale(shinyswitcher), 32);   //FIXME
258
280
  gtk_widget_set_app_paintable(widget, TRUE);
259
281
  gdk_drawable_set_colormap(shinyswitcher->wallpaper_inactive, shinyswitcher->rgba_cmap);
260
282
  cairo_t * destcr = gdk_cairo_create(shinyswitcher->wallpaper_inactive);
261
 
  cairo_set_operator(destcr, CAIRO_OPERATOR_CLEAR);
262
 
  cairo_paint(destcr);
263
 
  gdk_drawable_get_size(wallpaper, &w, &h);
264
 
  cairo_scale(destcr, shinyswitcher->mini_work_width / (double)w*vp_hscale(shinyswitcher), shinyswitcher->mini_work_height / (double)h*vp_vscale(shinyswitcher));
265
 
  gdk_cairo_set_source_pixmap(destcr, wallpaper, 0, 0);
266
 
  cairo_set_operator(destcr, CAIRO_OPERATOR_OVER);
267
 
  cairo_paint_with_alpha(destcr, shinyswitcher->wallpaper_alpha_inactive);
 
283
  if (destcr)
 
284
  {
 
285
    cairo_set_operator(destcr, CAIRO_OPERATOR_CLEAR);
 
286
    cairo_paint(destcr);
 
287
    gdk_drawable_get_size(wallpaper, &w, &h);
 
288
    cairo_scale(destcr, shinyswitcher->mini_work_width / (double)w*vp_hscale(shinyswitcher), shinyswitcher->mini_work_height / (double)h*vp_vscale(shinyswitcher));
 
289
    gdk_cairo_set_source_pixmap(destcr, wallpaper, 0, 0);
 
290
    cairo_set_operator(destcr, CAIRO_OPERATOR_OVER);
 
291
    cairo_paint_with_alpha(destcr, shinyswitcher->wallpaper_alpha_inactive);
 
292
  }
268
293
  gtk_widget_destroy(widget);
269
294
 
270
295
  shinyswitcher->wallpaper_active = gdk_pixmap_new(NULL, shinyswitcher->mini_work_width * vp_hscale(shinyswitcher), shinyswitcher->mini_work_height * vp_vscale(shinyswitcher), 32);   //FIXME
272
297
  gtk_widget_set_app_paintable(widget, TRUE);
273
298
  gdk_drawable_set_colormap(shinyswitcher->wallpaper_active, shinyswitcher->rgba_cmap);
274
299
  destcr = gdk_cairo_create(shinyswitcher->wallpaper_active);
275
 
  cairo_set_operator(destcr, CAIRO_OPERATOR_CLEAR);
276
 
  cairo_paint(destcr);
277
 
  cairo_scale(destcr, shinyswitcher->mini_work_width / (double)w*vp_hscale(shinyswitcher), shinyswitcher->mini_work_height / (double)h*vp_vscale(shinyswitcher));
278
 
  gdk_cairo_set_source_pixmap(destcr, wallpaper, 0, 0);
279
 
  cairo_set_operator(destcr, CAIRO_OPERATOR_OVER);
280
 
  cairo_paint_with_alpha(destcr, shinyswitcher->wallpaper_alpha_active);
 
300
  if (destcr)
 
301
  {
 
302
    cairo_set_operator(destcr, CAIRO_OPERATOR_CLEAR);
 
303
    cairo_paint(destcr);
 
304
    cairo_scale(destcr, shinyswitcher->mini_work_width / (double)w*vp_hscale(shinyswitcher), shinyswitcher->mini_work_height / (double)h*vp_vscale(shinyswitcher));
 
305
    gdk_cairo_set_source_pixmap(destcr, wallpaper, 0, 0);
 
306
    cairo_set_operator(destcr, CAIRO_OPERATOR_OVER);
 
307
    cairo_paint_with_alpha(destcr, shinyswitcher->wallpaper_alpha_active);
 
308
    cairo_destroy(destcr);    
 
309
  }
281
310
  gtk_widget_destroy(widget);
282
 
  cairo_destroy(destcr);
283
311
}
284
312
 
285
313
 
299
327
    widget = gtk_image_new_from_pixmap(shinyswitcher->wallpaper_inactive, NULL);
300
328
    gtk_widget_set_app_paintable(widget, TRUE);
301
329
    cr = gdk_cairo_create(shinyswitcher->wallpaper_inactive);
302
 
    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
303
 
    cairo_paint(cr);
304
 
    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
305
 
    cairo_set_source_rgba(cr, shinyswitcher->desktop_colour.red, shinyswitcher->desktop_colour.green,
306
 
                          shinyswitcher->desktop_colour.blue, shinyswitcher->desktop_colour.alpha);
307
 
    cairo_paint_with_alpha(cr, shinyswitcher->wallpaper_alpha_inactive);
308
 
    gtk_widget_destroy(widget);
309
 
    cairo_destroy(cr);
310
 
 
 
330
    if (cr)
 
331
    {
 
332
      cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
 
333
      cairo_paint(cr);
 
334
      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
 
335
      cairo_set_source_rgba(cr, shinyswitcher->desktop_colour.red, shinyswitcher->desktop_colour.green,
 
336
                            shinyswitcher->desktop_colour.blue, shinyswitcher->desktop_colour.alpha);
 
337
      cairo_paint_with_alpha(cr, shinyswitcher->wallpaper_alpha_inactive);
 
338
      gtk_widget_destroy(widget);
 
339
      cairo_destroy(cr);
 
340
    }
311
341
    shinyswitcher->wallpaper_active = gdk_pixmap_new(NULL, shinyswitcher->mini_work_width * vp_hscale(shinyswitcher), shinyswitcher->mini_work_height * vp_vscale(shinyswitcher), 32);   //FIXME
312
342
    gdk_drawable_set_colormap(shinyswitcher->wallpaper_active, shinyswitcher->rgba_cmap);
313
343
    widget = gtk_image_new_from_pixmap(shinyswitcher->wallpaper_active, NULL);
314
344
    gtk_widget_set_app_paintable(widget, TRUE);
315
345
    cr = gdk_cairo_create(shinyswitcher->wallpaper_active);
316
 
    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
317
 
    cairo_paint(cr);
318
 
    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
319
 
    cairo_set_source_rgba(cr, shinyswitcher->desktop_colour.red, shinyswitcher->desktop_colour.green,
320
 
                          shinyswitcher->desktop_colour.blue, shinyswitcher->desktop_colour.alpha);
321
 
    cairo_paint_with_alpha(cr, shinyswitcher->wallpaper_alpha_active);
 
346
    if (cr)
 
347
    {
 
348
      cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
 
349
      cairo_paint(cr);
 
350
      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
 
351
      cairo_set_source_rgba(cr, shinyswitcher->desktop_colour.red, shinyswitcher->desktop_colour.green,
 
352
                            shinyswitcher->desktop_colour.blue, shinyswitcher->desktop_colour.alpha);
 
353
      cairo_paint_with_alpha(cr, shinyswitcher->wallpaper_alpha_active);
 
354
      cairo_destroy(cr);      
 
355
    }
322
356
    gtk_widget_destroy(widget);
323
 
    cairo_destroy(cr);
324
 
 
325
357
  }
326
358
}
327
359