1
/* ccm-clone.c generated by valac, the Vala compiler
2
* generated from ccm-clone.vala, do not modify */
4
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
7
* Copyright (C) Nicolas Bruguier 2007-2010 <gandalfn@club-internet.fr>
9
* cairo-compmgr is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
14
* cairo-compmgr is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with cairo-compmgr. If not, write to:
21
* The Free Software Foundation, Inc.,
22
* 51 Franklin Street, Fifth Floor
23
* Boston, MA 02110-1301, USA.
27
#include <glib-object.h>
29
#include <ccm-window.h>
30
#include <ccm-window-plugin.h>
31
#include <ccm-pixmap.h>
32
#include <ccm-screen.h>
34
#include <X11/Xatom.h>
35
#include <X11/Xutil.h>
36
#include <X11/Xregion.h>
37
#include <ccm-plugin.h>
38
#include <ccm-screen-plugin.h>
40
#include <ccm-debug.h>
41
#include <ccm-drawable.h>
42
#include <ccm-display.h>
47
#include <gobject/gvaluecollector.h>
50
#define CCM_TYPE_OUTPUT (ccm_output_get_type ())
51
#define CCM_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_OUTPUT, CCMOutput))
52
#define CCM_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_OUTPUT, CCMOutputClass))
53
#define CCM_IS_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_OUTPUT))
54
#define CCM_IS_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_OUTPUT))
55
#define CCM_OUTPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_OUTPUT, CCMOutputClass))
57
typedef struct _CCMOutput CCMOutput;
58
typedef struct _CCMOutputClass CCMOutputClass;
59
typedef struct _CCMOutputPrivate CCMOutputPrivate;
60
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
61
typedef struct _CCMParamSpecOutput CCMParamSpecOutput;
63
#define CCM_TYPE_CLONE (ccm_clone_get_type ())
64
#define CCM_CLONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_CLONE, CCMClone))
65
#define CCM_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_CLONE, CCMCloneClass))
66
#define CCM_IS_CLONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_CLONE))
67
#define CCM_IS_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_CLONE))
68
#define CCM_CLONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_CLONE, CCMCloneClass))
70
typedef struct _CCMClone CCMClone;
71
typedef struct _CCMCloneClass CCMCloneClass;
72
typedef struct _CCMClonePrivate CCMClonePrivate;
73
typedef struct _CCMCloneClassPrivate CCMCloneClassPrivate;
74
static GQuark _vala_ccm_clone_class_private_quark = 0;
75
#define _vala_collection_object_unref0(var) ((var == NULL) ? NULL : (var = (vala_collection_object_unref (var), NULL)))
76
#define _ccm_output_unref0(var) ((var == NULL) ? NULL : (var = (ccm_output_unref (var), NULL)))
77
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
80
GTypeInstance parent_instance;
81
volatile int ref_count;
82
CCMOutputPrivate * priv;
87
struct _CCMOutputClass {
88
GTypeClass parent_class;
89
void (*finalize) (CCMOutput *self);
92
struct _CCMParamSpecOutput {
93
GParamSpec parent_instance;
97
CCMPlugin parent_instance;
98
CCMClonePrivate * priv;
101
struct _CCMCloneClass {
102
CCMPluginClass parent_class;
105
struct _CCMClonePrivate {
107
ValaArrayList* screen_outputs;
108
ValaArrayList* window_outputs;
112
static gpointer ccm_output_parent_class = NULL;
113
static GType ccm_output_type_id = 0;
114
static gpointer ccm_clone_parent_class = NULL;
115
static CCMScreenPluginIface* ccm_clone_ccm_screen_plugin_parent_iface = NULL;
116
static CCMWindowPluginIface* ccm_clone_ccm_window_plugin_parent_iface = NULL;
117
static GType ccm_clone_type_id = 0;
119
gpointer ccm_output_ref (gpointer instance);
120
void ccm_output_unref (gpointer instance);
121
GParamSpec* ccm_param_spec_output (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
122
void ccm_value_set_output (GValue* value, gpointer v_object);
123
gpointer ccm_value_get_output (const GValue* value);
124
GType ccm_output_get_type (void);
125
GType ccm_output_register_type (GTypeModule * module);
127
CCM_OUTPUT_DUMMY_PROPERTY
129
CCMOutput* ccm_output_new (CCMScreen* screen, CCMWindow* window, Pixmap xpixmap, gint depth);
130
CCMOutput* ccm_output_construct (GType object_type, CCMScreen* screen, CCMWindow* window, Pixmap xpixmap, gint depth);
131
static void ccm_output_finalize (CCMOutput* obj);
132
GType ccm_clone_get_type (void);
133
GType ccm_clone_register_type (GTypeModule * module);
134
#define CCM_CLONE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CCM_TYPE_CLONE, CCMClonePrivate))
135
struct _CCMCloneClassPrivate {
136
Atom screen_enable_atom;
137
Atom screen_disable_atom;
142
#define CCM_CLONE_GET_CLASS_PRIVATE(type) ((CCMCloneClassPrivate *) g_type_get_qdata (type, _vala_ccm_clone_class_private_quark))
144
CCM_CLONE_DUMMY_PROPERTY
146
static void ccm_clone_add_screen_output (CCMClone* self, CCMOutput* output);
147
static void ccm_clone_remove_screen_output (CCMClone* self, CCMOutput* output);
148
static void ccm_clone_on_composite_message (CCMClone* self, CCMWindow* client, CCMWindow* window, glong l1, glong l2, glong l3);
149
static void _ccm_clone_on_composite_message_ccm_screen_composite_message (CCMScreen* _sender, CCMWindow* client, CCMWindow* window, glong l1, glong l2, glong l3, gpointer self);
150
static void ccm_clone_real_screen_load_options (CCMScreenPlugin* base, CCMScreen* screen);
151
static gboolean ccm_clone_real_window_paint (CCMWindowPlugin* base, CCMWindow* window, cairo_t* context, cairo_surface_t* surface, gboolean y_invert);
152
CCMClone* ccm_clone_new (void);
153
CCMClone* ccm_clone_construct (GType object_type);
154
static void ccm_clone_base_finalize (CCMCloneClass * klass);
155
static void ccm_clone_finalize (GObject* obj);
156
GType ccm_clone_get_plugin_type (GTypeModule* module);
160
CCMOutput* ccm_output_construct (GType object_type, CCMScreen* screen, CCMWindow* window, Pixmap xpixmap, gint depth) {
164
g_return_val_if_fail (screen != NULL, NULL);
165
g_return_val_if_fail (window != NULL, NULL);
166
self = (CCMOutput*) g_type_create_instance (object_type);
167
visual = ccm_screen_get_visual_for_depth (screen, depth);
168
self->window = window;
169
self->pixmap = (_tmp0_ = ccm_pixmap_new_from_visual (screen, visual, xpixmap), _g_object_unref0 (self->pixmap), _tmp0_);
170
ccm_pixmap_set_foreign (self->pixmap, TRUE);
175
CCMOutput* ccm_output_new (CCMScreen* screen, CCMWindow* window, Pixmap xpixmap, gint depth) {
176
return ccm_output_construct (CCM_TYPE_OUTPUT, screen, window, xpixmap, depth);
180
static void ccm_value_output_init (GValue* value) {
181
value->data[0].v_pointer = NULL;
185
static void ccm_value_output_free_value (GValue* value) {
186
if (value->data[0].v_pointer) {
187
ccm_output_unref (value->data[0].v_pointer);
192
static void ccm_value_output_copy_value (const GValue* src_value, GValue* dest_value) {
193
if (src_value->data[0].v_pointer) {
194
dest_value->data[0].v_pointer = ccm_output_ref (src_value->data[0].v_pointer);
196
dest_value->data[0].v_pointer = NULL;
201
static gpointer ccm_value_output_peek_pointer (const GValue* value) {
202
return value->data[0].v_pointer;
206
static gchar* ccm_value_output_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
207
if (collect_values[0].v_pointer) {
209
object = collect_values[0].v_pointer;
210
if (object->parent_instance.g_class == NULL) {
211
return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
212
} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
213
return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
215
value->data[0].v_pointer = ccm_output_ref (object);
217
value->data[0].v_pointer = NULL;
223
static gchar* ccm_value_output_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
224
CCMOutput** object_p;
225
object_p = collect_values[0].v_pointer;
227
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
229
if (!value->data[0].v_pointer) {
231
} else if (collect_flags && G_VALUE_NOCOPY_CONTENTS) {
232
*object_p = value->data[0].v_pointer;
234
*object_p = ccm_output_ref (value->data[0].v_pointer);
240
GParamSpec* ccm_param_spec_output (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
241
CCMParamSpecOutput* spec;
242
g_return_val_if_fail (g_type_is_a (object_type, CCM_TYPE_OUTPUT), NULL);
243
spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
244
G_PARAM_SPEC (spec)->value_type = object_type;
245
return G_PARAM_SPEC (spec);
249
gpointer ccm_value_get_output (const GValue* value) {
250
g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CCM_TYPE_OUTPUT), NULL);
251
return value->data[0].v_pointer;
255
void ccm_value_set_output (GValue* value, gpointer v_object) {
257
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CCM_TYPE_OUTPUT));
258
old = value->data[0].v_pointer;
260
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, CCM_TYPE_OUTPUT));
261
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
262
value->data[0].v_pointer = v_object;
263
ccm_output_ref (value->data[0].v_pointer);
265
value->data[0].v_pointer = NULL;
268
ccm_output_unref (old);
273
static void ccm_output_class_init (CCMOutputClass * klass) {
274
ccm_output_parent_class = g_type_class_peek_parent (klass);
275
CCM_OUTPUT_CLASS (klass)->finalize = ccm_output_finalize;
279
static void ccm_output_instance_init (CCMOutput * self) {
284
static void ccm_output_finalize (CCMOutput* obj) {
286
self = CCM_OUTPUT (obj);
287
_g_object_unref0 (self->pixmap);
291
GType ccm_output_get_type (void) {
292
return ccm_output_type_id;
296
GType ccm_output_register_type (GTypeModule * module) {
297
static const GTypeValueTable g_define_type_value_table = { ccm_value_output_init, ccm_value_output_free_value, ccm_value_output_copy_value, ccm_value_output_peek_pointer, "p", ccm_value_output_collect_value, "p", ccm_value_output_lcopy_value };
298
static const GTypeInfo g_define_type_info = { sizeof (CCMOutputClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ccm_output_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CCMOutput), 0, (GInstanceInitFunc) ccm_output_instance_init, &g_define_type_value_table };
299
static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
300
ccm_output_type_id = g_type_register_fundamental (g_type_fundamental_next (), "CCMOutput", &g_define_type_info, &g_define_type_fundamental_info, 0);
301
return ccm_output_type_id;
305
gpointer ccm_output_ref (gpointer instance) {
308
g_atomic_int_inc (&self->ref_count);
313
void ccm_output_unref (gpointer instance) {
316
if (g_atomic_int_dec_and_test (&self->ref_count)) {
317
CCM_OUTPUT_GET_CLASS (self)->finalize (self);
318
g_type_free_instance ((GTypeInstance *) self);
323
static gpointer _g_object_ref0 (gpointer self) {
324
return self ? g_object_ref (self) : NULL;
328
static void ccm_clone_add_screen_output (CCMClone* self, CCMOutput* output) {
329
g_return_if_fail (self != NULL);
330
g_return_if_fail (output != NULL);
331
if (self->priv->screen_outputs == NULL) {
332
ValaArrayList* _tmp0_;
333
self->priv->screen_outputs = (_tmp0_ = vala_array_list_new (CCM_TYPE_OUTPUT, (GBoxedCopyFunc) ccm_output_ref, ccm_output_unref, g_direct_equal), _vala_collection_object_unref0 (self->priv->screen_outputs), _tmp0_);
335
vala_collection_add ((ValaCollection*) self->priv->screen_outputs, output);
337
GList* window_collection;
339
window_collection = ccm_screen_get_windows (self->priv->screen);
340
for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
342
window = _g_object_ref0 ((CCMWindow*) window_it->data);
344
if (window != output->window) {
346
clone = _g_object_ref0 (CCM_CLONE (_ccm_window_get_plugin (window, CCM_TYPE_CLONE)));
347
if (clone->priv->screen_outputs == NULL) {
348
ValaArrayList* _tmp1_;
349
clone->priv->screen_outputs = (_tmp1_ = vala_array_list_new (CCM_TYPE_OUTPUT, (GBoxedCopyFunc) ccm_output_ref, ccm_output_unref, g_direct_equal), _vala_collection_object_unref0 (clone->priv->screen_outputs), _tmp1_);
351
vala_collection_add ((ValaCollection*) clone->priv->screen_outputs, output);
352
_g_object_unref0 (clone);
354
_g_object_unref0 (window);
361
static void ccm_clone_remove_screen_output (CCMClone* self, CCMOutput* output) {
362
g_return_if_fail (self != NULL);
363
g_return_if_fail (output != NULL);
364
vala_collection_remove ((ValaCollection*) self->priv->screen_outputs, output);
366
GList* window_collection;
368
window_collection = ccm_screen_get_windows (self->priv->screen);
369
for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
371
window = _g_object_ref0 ((CCMWindow*) window_it->data);
374
clone = _g_object_ref0 (CCM_CLONE (_ccm_window_get_plugin (window, CCM_TYPE_CLONE)));
375
vala_collection_remove ((ValaCollection*) clone->priv->screen_outputs, output);
376
_g_object_unref0 (window);
377
_g_object_unref0 (clone);
384
static void ccm_clone_on_composite_message (CCMClone* self, CCMWindow* client, CCMWindow* window, glong l1, glong l2, glong l3) {
388
g_return_if_fail (self != NULL);
389
g_return_if_fail (client != NULL);
390
g_return_if_fail (window != NULL);
392
xpixmap = (Pixmap) l2;
394
if (atom == CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->enable_atom) {
397
ccm_log ("ENABLE CLONE", NULL);
398
clone = _g_object_ref0 (CCM_CLONE (_ccm_window_get_plugin (window, CCM_TYPE_CLONE)));
399
output = ccm_output_new (ccm_drawable_get_screen ((CCMDrawable*) window), window, xpixmap, depth);
400
if (clone->priv->window_outputs == NULL) {
401
ValaArrayList* _tmp0_;
402
clone->priv->window_outputs = (_tmp0_ = vala_array_list_new (CCM_TYPE_OUTPUT, (GBoxedCopyFunc) ccm_output_ref, ccm_output_unref, g_direct_equal), _vala_collection_object_unref0 (clone->priv->window_outputs), _tmp0_);
404
vala_collection_add ((ValaCollection*) clone->priv->window_outputs, output);
405
ccm_window_set_no_undamage_sibling (client, TRUE);
406
ccm_drawable_damage ((CCMDrawable*) window);
407
_g_object_unref0 (clone);
408
_ccm_output_unref0 (output);
410
if (atom == CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->disable_atom) {
412
ccm_log ("DISABLE CLONE", NULL);
413
clone = _g_object_ref0 (CCM_CLONE (_ccm_window_get_plugin (window, CCM_TYPE_CLONE)));
414
ccm_window_set_no_undamage_sibling (client, FALSE);
416
ValaIterator* _output_it;
417
_output_it = vala_iterable_iterator ((ValaIterable*) clone->priv->window_outputs);
420
if (!vala_iterator_next (_output_it)) {
423
output = (CCMOutput*) vala_iterator_get (_output_it);
424
if (ccm_drawable_get_xid ((CCMDrawable*) output->pixmap) == ((XID) xpixmap)) {
425
vala_collection_remove ((ValaCollection*) clone->priv->window_outputs, output);
426
_ccm_output_unref0 (output);
429
_ccm_output_unref0 (output);
431
_vala_collection_object_unref0 (_output_it);
433
_g_object_unref0 (clone);
435
if (atom == CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->screen_enable_atom) {
437
ccm_log ("ENABLE SCREEN CLONE", NULL);
438
output = ccm_output_new (ccm_drawable_get_screen ((CCMDrawable*) window), window, xpixmap, depth);
439
ccm_window_set_no_undamage_sibling (window, TRUE);
440
ccm_clone_add_screen_output (self, output);
441
_ccm_output_unref0 (output);
443
if (atom == CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->screen_disable_atom) {
444
ccm_log ("DISABLE SCREEN CLONE", NULL);
446
ValaIterator* _output_it;
447
_output_it = vala_iterable_iterator ((ValaIterable*) self->priv->screen_outputs);
450
if (!vala_iterator_next (_output_it)) {
453
output = (CCMOutput*) vala_iterator_get (_output_it);
454
if (ccm_drawable_get_xid ((CCMDrawable*) output->pixmap) == ((XID) xpixmap)) {
455
ccm_window_set_no_undamage_sibling (output->window, FALSE);
456
ccm_clone_remove_screen_output (self, output);
457
_ccm_output_unref0 (output);
460
_ccm_output_unref0 (output);
462
_vala_collection_object_unref0 (_output_it);
471
static void _ccm_clone_on_composite_message_ccm_screen_composite_message (CCMScreen* _sender, CCMWindow* client, CCMWindow* window, glong l1, glong l2, glong l3, gpointer self) {
472
ccm_clone_on_composite_message (self, client, window, l1, l2, l3);
476
static void ccm_clone_real_screen_load_options (CCMScreenPlugin* base, CCMScreen* screen) {
478
self = (CCMClone*) base;
479
g_return_if_fail (screen != NULL);
480
self->priv->screen = screen;
481
g_signal_connect_object (self->priv->screen, "composite-message", (GCallback) _ccm_clone_on_composite_message_ccm_screen_composite_message, self, 0);
482
if (CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->screen_enable_atom == 0) {
483
CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->screen_enable_atom = XInternAtom (ccm_display_get_xdisplay (ccm_screen_get_display (screen)), "_CCM_CLONE_SCREEN_ENABLE", FALSE);
484
CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->screen_disable_atom = XInternAtom (ccm_display_get_xdisplay (ccm_screen_get_display (screen)), "_CCM_CLONE_SCREEN_DISABLE", FALSE);
485
CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->enable_atom = XInternAtom (ccm_display_get_xdisplay (ccm_screen_get_display (screen)), "_CCM_CLONE_ENABLE", FALSE);
486
CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (CCM_CLONE_CLASS (G_OBJECT_GET_CLASS (self))))->disable_atom = XInternAtom (ccm_display_get_xdisplay (ccm_screen_get_display (screen)), "_CCM_CLONE_DISABLE", FALSE);
488
ccm_screen_plugin_load_options (CCM_SCREEN_PLUGIN (ccm_plugin_get_parent ((CCMPlugin*) self)), screen);
492
static gboolean ccm_clone_real_window_paint (CCMWindowPlugin* base, CCMWindow* window, cairo_t* context, cairo_surface_t* surface, gboolean y_invert) {
496
gboolean _tmp0_ = FALSE;
497
gboolean _tmp1_ = FALSE;
498
gboolean _tmp2_ = FALSE;
499
self = (CCMClone*) base;
500
g_return_val_if_fail (window != NULL, FALSE);
501
g_return_val_if_fail (context != NULL, FALSE);
502
g_return_val_if_fail (surface != NULL, FALSE);
504
ret = ccm_window_plugin_paint (CCM_WINDOW_PLUGIN (ccm_plugin_get_parent ((CCMPlugin*) self)), window, context, surface, y_invert);
505
if (self->priv->window_outputs != NULL) {
506
_tmp2_ = vala_collection_get_size ((ValaCollection*) self->priv->window_outputs) > 0;
513
gboolean _tmp3_ = FALSE;
514
if (self->priv->screen_outputs != NULL) {
515
_tmp3_ = vala_collection_get_size ((ValaCollection*) self->priv->screen_outputs) > 0;
527
cairo_rectangle_t* area;
528
cairo_rectangle_t _tmp4_ = {0};
529
cairo_rectangle_t geometry;
530
gboolean _tmp5_ = FALSE;
531
area = ccm_window_get_area (window);
532
geometry = (memset (&_tmp4_, 0, sizeof (cairo_rectangle_t)), _tmp4_);
534
_tmp5_ = ccm_drawable_get_device_geometry_clipbox ((CCMDrawable*) window, &geometry);
539
if (self->priv->window_outputs != NULL) {
541
ValaIterator* _output_it;
542
_output_it = vala_iterable_iterator ((ValaIterable*) self->priv->window_outputs);
545
cairo_rectangle_t _tmp6_ = {0};
546
cairo_rectangle_t clipbox;
547
if (!vala_iterator_next (_output_it)) {
550
output = (CCMOutput*) vala_iterator_get (_output_it);
551
clipbox = (memset (&_tmp6_, 0, sizeof (cairo_rectangle_t)), _tmp6_);
552
if (ccm_drawable_get_device_geometry_clipbox ((CCMDrawable*) output->pixmap, &clipbox)) {
554
ctx = ccm_drawable_create_context ((CCMDrawable*) output->pixmap);
556
cairo_scale (ctx, clipbox.width / (*area).width, clipbox.height / (*area).height);
557
cairo_translate (ctx, -(*area).x, -(*area).y);
558
ccm_drawable_get_damage_path ((CCMDrawable*) window, ctx);
560
cairo_translate (ctx, (*area).x, (*area).y);
561
cairo_set_source_surface (ctx, surface, (-(geometry.width - (*area).width)) / 2.0, (-(geometry.height - (*area).height)) / 2.0);
564
_cairo_destroy0 (ctx);
566
_ccm_output_unref0 (output);
568
_vala_collection_object_unref0 (_output_it);
571
if (self->priv->screen_outputs != NULL) {
573
ValaIterator* _output_it;
574
_output_it = vala_iterable_iterator ((ValaIterable*) self->priv->screen_outputs);
577
cairo_rectangle_t _tmp7_ = {0};
578
cairo_rectangle_t clipbox;
581
gboolean _tmp8_ = FALSE;
582
if (!vala_iterator_next (_output_it)) {
585
output = (CCMOutput*) vala_iterator_get (_output_it);
586
clipbox = (memset (&_tmp7_, 0, sizeof (cairo_rectangle_t)), _tmp7_);
587
width = ccm_screen_get_xscreen (ccm_drawable_get_screen ((CCMDrawable*) window))->width;
588
height = ccm_screen_get_xscreen (ccm_drawable_get_screen ((CCMDrawable*) window))->height;
589
if (output->window != window) {
590
_tmp8_ = ccm_drawable_get_device_geometry_clipbox ((CCMDrawable*) output->pixmap, &clipbox);
596
ctx = ccm_drawable_create_context ((CCMDrawable*) output->pixmap);
598
cairo_matrix_t matrix = {0};
599
cairo_matrix_t _tmp9_ = {0};
600
matrix = (cairo_matrix_init (&_tmp9_, clipbox.width / width, (double) 0, (double) 0, clipbox.height / height, (-geometry.x) * (1 - (clipbox.width / width)), (-geometry.y) * (1 - (clipbox.height / height))), _tmp9_);
601
cairo_set_matrix (ctx, &matrix);
602
ccm_drawable_get_damage_path ((CCMDrawable*) window, ctx);
604
cairo_identity_matrix (ctx);
605
ccm_drawable_push_matrix ((CCMDrawable*) window, "CCMClone", &matrix);
606
ccm_window_plugin_paint (CCM_WINDOW_PLUGIN (ccm_plugin_get_parent ((CCMPlugin*) self)), window, ctx, surface, y_invert);
607
ccm_drawable_pop_matrix ((CCMDrawable*) window, "CCMClone");
609
_cairo_destroy0 (ctx);
611
_ccm_output_unref0 (output);
613
_vala_collection_object_unref0 (_output_it);
623
CCMClone* ccm_clone_construct (GType object_type) {
625
self = g_object_newv (object_type, 0, NULL);
630
CCMClone* ccm_clone_new (void) {
631
return ccm_clone_construct (CCM_TYPE_CLONE);
635
static void ccm_clone_base_init (CCMCloneClass * klass) {
637
CCMCloneClassPrivate * priv;
638
CCMCloneClassPrivate * parent_priv;
641
parent_type = g_type_parent (G_TYPE_FROM_CLASS (klass));
643
parent_priv = CCM_CLONE_GET_CLASS_PRIVATE (parent_type);
645
priv = g_slice_new0 (CCMCloneClassPrivate);
647
memcpy (priv, parent_priv, sizeof (CCMCloneClassPrivate));
649
g_type_set_qdata (G_TYPE_FROM_CLASS (klass), _vala_ccm_clone_class_private_quark, priv);
654
static void ccm_clone_class_init (CCMCloneClass * klass) {
655
ccm_clone_parent_class = g_type_class_peek_parent (klass);
656
g_type_class_add_private (klass, sizeof (CCMClonePrivate));
657
G_OBJECT_CLASS (klass)->finalize = ccm_clone_finalize;
661
static void ccm_clone_base_finalize (CCMCloneClass * klass) {
663
CCMCloneClassPrivate * priv;
664
priv = CCM_CLONE_GET_CLASS_PRIVATE (G_TYPE_FROM_CLASS (klass));
665
g_slice_free (CCMCloneClassPrivate, priv);
670
static void ccm_clone_ccm_screen_plugin_interface_init (CCMScreenPluginIface * iface) {
671
ccm_clone_ccm_screen_plugin_parent_iface = g_type_interface_peek_parent (iface);
672
iface->load_options = ccm_clone_real_screen_load_options;
676
static void ccm_clone_ccm_window_plugin_interface_init (CCMWindowPluginIface * iface) {
677
ccm_clone_ccm_window_plugin_parent_iface = g_type_interface_peek_parent (iface);
678
iface->paint = ccm_clone_real_window_paint;
682
static void ccm_clone_instance_init (CCMClone * self) {
683
self->priv = CCM_CLONE_GET_PRIVATE (self);
684
self->priv->screen_outputs = NULL;
685
self->priv->window_outputs = NULL;
689
static void ccm_clone_finalize (GObject* obj) {
691
self = CCM_CLONE (obj);
692
_vala_collection_object_unref0 (self->priv->screen_outputs);
693
_vala_collection_object_unref0 (self->priv->window_outputs);
694
G_OBJECT_CLASS (ccm_clone_parent_class)->finalize (obj);
698
GType ccm_clone_get_type (void) {
699
return ccm_clone_type_id;
703
GType ccm_clone_register_type (GTypeModule * module) {
704
static const GTypeInfo g_define_type_info = { sizeof (CCMCloneClass), (GBaseInitFunc) ccm_clone_base_init, (GBaseFinalizeFunc) ccm_clone_base_finalize, (GClassInitFunc) ccm_clone_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CCMClone), 0, (GInstanceInitFunc) ccm_clone_instance_init, NULL };
705
static const GInterfaceInfo ccm_screen_plugin_info = { (GInterfaceInitFunc) ccm_clone_ccm_screen_plugin_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
706
static const GInterfaceInfo ccm_window_plugin_info = { (GInterfaceInitFunc) ccm_clone_ccm_window_plugin_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
707
_vala_ccm_clone_class_private_quark = g_quark_from_string ("ValaCCMCloneClassPrivate");
708
ccm_clone_type_id = g_type_module_register_type (module, CCM_TYPE_PLUGIN, "CCMClone", &g_define_type_info, 0);
709
g_type_module_add_interface (module, ccm_clone_type_id, CCM_TYPE_SCREEN_PLUGIN, &ccm_screen_plugin_info);
710
g_type_module_add_interface (module, ccm_clone_type_id, CCM_TYPE_WINDOW_PLUGIN, &ccm_window_plugin_info);
711
return ccm_clone_type_id;
715
GType ccm_clone_get_plugin_type (GTypeModule* module) {
717
g_return_val_if_fail (module != NULL, 0UL);
718
ccm_output_register_type (module);
719
ccm_clone_register_type (module);
720
result = CCM_TYPE_CLONE;