1
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
4
* Copyright (C) Nicolas Bruguier 2007-2010 <gandalfn@club-internet.fr>
6
* cairo-compmgr is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* cairo-compmgr is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with cairo-compmgr. If not, write to:
18
* The Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor
20
* Boston, MA 02110-1301, USA.
35
class ValaWindowOptions : PluginOptions
37
public bool enabled = false;
40
changed(CCM.Config config)
44
enabled = config.get_boolean ();
46
catch (GLib.Error err)
53
private class ValaWindowPlugin : CCM.Plugin, CCM.WindowPlugin
55
const string[] options_key = {
59
weak CCM.Window window;
65
type_options = typeof (ValaWindowOptions);
74
option_changed (int index)
76
if (!((ValaWindowOptions) get_option ()).enabled)
77
window.get_screen ().damage_all ();
81
* Implement load_options window plugin interface
84
window_load_options (CCM.Window window)
88
options_load ("vala-window-plugin", options_key,
89
(PluginOptionsChangedFunc)option_changed);
91
/* Chain call to next plugin */
92
((CCM.WindowPlugin) parent).window_load_options (window);
96
* Implement paint window plugin interface
99
window_paint (CCM.Window window, Cairo.Context ctx,
100
Cairo.Surface surface, bool y_invert)
104
/* Chain call to next plugin */
105
ret = ((CCM.WindowPlugin) parent).window_paint (window, ctx,
108
/* Paint damaged area */
109
if (((ValaWindowOptions) get_option ()).enabled)
111
weak CCM.Region damaged = window.damaged;
115
unowned Cairo.Rectangle[] rectangles;
117
damaged.get_rectangles (out rectangles);
122
ctx.set_source_rgba (1, 0, 0, 0.5);
125
ctx.set_source_rgba (0, 1, 0, 0.5);
128
ctx.set_source_rgba (0, 0, 1, 0.5);
136
foreach (Cairo.Rectangle rectangle in rectangles)
138
ctx.rectangle (rectangle.x, rectangle.y,
139
rectangle.width, rectangle.height);
142
rectangles_free (rectangles);
156
ccm_vala_window_plugin_get_plugin_type (TypeModule module)
158
return typeof (ValaWindowPlugin);