~voldyman/gala/scale-large-notification-icon

« back to all changes in this revision

Viewing changes to lib/Utils.vala

  • Committer: RabbitBot
  • Author(s): Rico Tzschichholz, Tom Beckmann
  • Date: 2015-03-12 10:20:34 UTC
  • mfrom: (441.1.5 gala-unmaximize)
  • Revision ID: rabbitbot-20150312102034-7xyxf6h4kdw5wdpa
Implement smooth (un)maximize

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
                }
226
226
 
227
227
                /**
 
228
                 * Creates an actor showing the current contents of the given WindowActor.
 
229
                 *
 
230
                 * @param actor          The actor from which to create a shnapshot
 
231
                 * @param inner_rect The inner (actually visible) rectangle of the window
 
232
                 * @param outer_rect The outer (input region) rectangle of the window
 
233
                 *
 
234
                 * @return           A copy of the actor at that time or %NULL
 
235
                 */
 
236
                public static Clutter.Actor? get_window_actor_snapshot (Meta.WindowActor actor, Meta.Rectangle inner_rect, Meta.Rectangle outer_rect)
 
237
                {
 
238
                        var texture = actor.get_texture () as Meta.ShapedTexture;
 
239
 
 
240
                        if (texture == null)
 
241
                                return null;
 
242
 
 
243
                        var surface = texture.get_image ({
 
244
                                inner_rect.x - outer_rect.x,
 
245
                                inner_rect.y - outer_rect.y,
 
246
                                inner_rect.width,
 
247
                                inner_rect.height
 
248
                        });
 
249
 
 
250
                        if (surface == null)
 
251
                                return null;
 
252
 
 
253
                        var canvas = new Clutter.Canvas ();
 
254
                        var handler = canvas.draw.connect ((cr) => {
 
255
                                cr.set_source_surface (surface, 0, 0);
 
256
                                cr.paint ();
 
257
                                return false;
 
258
                        });
 
259
                        canvas.set_size (inner_rect.width, inner_rect.height);
 
260
                        SignalHandler.disconnect (canvas, handler);
 
261
 
 
262
                        var container = new Clutter.Actor ();
 
263
                        container.set_size (inner_rect.width, inner_rect.height);
 
264
                        container.content = canvas;
 
265
 
 
266
                        return container;
 
267
                }
 
268
 
 
269
                /**
228
270
                 * Ring the system bell, will most likely emit a <beep> error sound or, if the
229
271
                 * audible bell is disabled, flash the screen
230
272
                 *