1
/* ccm-story-board.c generated by valac, the Vala compiler
2
* generated from ccm-story-board.vala, do not modify */
4
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
7
* Copyright (C) Nicolas Bruguier 2008 <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-screen.h>
32
#include <ccm-window.h>
33
#include <ccm-window-plugin.h>
34
#include <ccm-display.h>
36
#include <X11/Xatom.h>
37
#include <X11/Xutil.h>
38
#include <X11/Xregion.h>
41
#include <ccm-debug.h>
44
#define CCM_TYPE_STORY_BOARD (ccm_story_board_get_type ())
45
#define CCM_STORY_BOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_STORY_BOARD, CCMStoryBoard))
46
#define CCM_STORY_BOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_STORY_BOARD, CCMStoryBoardClass))
47
#define CCM_IS_STORY_BOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_STORY_BOARD))
48
#define CCM_IS_STORY_BOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_STORY_BOARD))
49
#define CCM_STORY_BOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_STORY_BOARD, CCMStoryBoardClass))
51
typedef struct _CCMStoryBoard CCMStoryBoard;
52
typedef struct _CCMStoryBoardClass CCMStoryBoardClass;
53
typedef struct _CCMStoryBoardPrivate CCMStoryBoardPrivate;
55
#define CCM_TYPE_ACTION (ccm_action_get_type ())
56
#define CCM_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_ACTION, CCMAction))
57
#define CCM_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_ACTION, CCMActionClass))
58
#define CCM_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_ACTION))
59
#define CCM_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_ACTION))
60
#define CCM_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_ACTION, CCMActionClass))
62
typedef struct _CCMAction CCMAction;
63
typedef struct _CCMActionClass CCMActionClass;
64
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
65
#define _g_free0(var) (var = (g_free (var), NULL))
66
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
67
#define __g_list_free_g_object_unref0(var) ((var == NULL) ? NULL : (var = (_g_list_free_g_object_unref (var), NULL)))
69
#define CCM_TYPE_ACTION_POINTER (ccm_action_pointer_get_type ())
70
#define CCM_ACTION_POINTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_ACTION_POINTER, CCMActionPointer))
71
#define CCM_ACTION_POINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_ACTION_POINTER, CCMActionPointerClass))
72
#define CCM_IS_ACTION_POINTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_ACTION_POINTER))
73
#define CCM_IS_ACTION_POINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_ACTION_POINTER))
74
#define CCM_ACTION_POINTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_ACTION_POINTER, CCMActionPointerClass))
76
typedef struct _CCMActionPointer CCMActionPointer;
77
typedef struct _CCMActionPointerClass CCMActionPointerClass;
79
#define CCM_TYPE_ACTION_POINTER_MOTION (ccm_action_pointer_motion_get_type ())
80
#define CCM_ACTION_POINTER_MOTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_ACTION_POINTER_MOTION, CCMActionPointerMotion))
81
#define CCM_ACTION_POINTER_MOTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_ACTION_POINTER_MOTION, CCMActionPointerMotionClass))
82
#define CCM_IS_ACTION_POINTER_MOTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_ACTION_POINTER_MOTION))
83
#define CCM_IS_ACTION_POINTER_MOTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_ACTION_POINTER_MOTION))
84
#define CCM_ACTION_POINTER_MOTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_ACTION_POINTER_MOTION, CCMActionPointerMotionClass))
86
typedef struct _CCMActionPointerMotion CCMActionPointerMotion;
87
typedef struct _CCMActionPointerMotionClass CCMActionPointerMotionClass;
89
#define CCM_TYPE_ACTION_POINTER_PRESS (ccm_action_pointer_press_get_type ())
90
#define CCM_ACTION_POINTER_PRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_ACTION_POINTER_PRESS, CCMActionPointerPress))
91
#define CCM_ACTION_POINTER_PRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_ACTION_POINTER_PRESS, CCMActionPointerPressClass))
92
#define CCM_IS_ACTION_POINTER_PRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_ACTION_POINTER_PRESS))
93
#define CCM_IS_ACTION_POINTER_PRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_ACTION_POINTER_PRESS))
94
#define CCM_ACTION_POINTER_PRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_ACTION_POINTER_PRESS, CCMActionPointerPressClass))
96
typedef struct _CCMActionPointerPress CCMActionPointerPress;
97
typedef struct _CCMActionPointerPressClass CCMActionPointerPressClass;
98
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
100
#define CCM_TYPE_ACTION_POINTER_RELEASE (ccm_action_pointer_release_get_type ())
101
#define CCM_ACTION_POINTER_RELEASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CCM_TYPE_ACTION_POINTER_RELEASE, CCMActionPointerRelease))
102
#define CCM_ACTION_POINTER_RELEASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CCM_TYPE_ACTION_POINTER_RELEASE, CCMActionPointerReleaseClass))
103
#define CCM_IS_ACTION_POINTER_RELEASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CCM_TYPE_ACTION_POINTER_RELEASE))
104
#define CCM_IS_ACTION_POINTER_RELEASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CCM_TYPE_ACTION_POINTER_RELEASE))
105
#define CCM_ACTION_POINTER_RELEASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CCM_TYPE_ACTION_POINTER_RELEASE, CCMActionPointerReleaseClass))
107
typedef struct _CCMActionPointerRelease CCMActionPointerRelease;
108
typedef struct _CCMActionPointerReleaseClass CCMActionPointerReleaseClass;
110
struct _CCMStoryBoard {
111
GObject parent_instance;
112
CCMStoryBoardPrivate * priv;
115
struct _CCMStoryBoardClass {
116
GObjectClass parent_class;
119
struct _CCMStoryBoardPrivate {
120
gboolean _hint_motion;
129
CCM_ACTION_ERROR_WINDOW_IGNORE,
130
CCM_ACTION_ERROR_WINDOW_NOT_FOUND
132
#define CCM_ACTION_ERROR ccm_action_error_quark ()
134
static gpointer ccm_story_board_parent_class = NULL;
135
static GType ccm_story_board_type_id = 0;
137
GType ccm_story_board_get_type (void);
138
GType ccm_story_board_register_type (GTypeModule * module);
139
GType ccm_action_get_type (void);
140
GType ccm_action_register_type (GTypeModule * module);
141
#define CCM_STORY_BOARD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CCM_TYPE_STORY_BOARD, CCMStoryBoardPrivate))
143
CCM_STORY_BOARD_DUMMY_PROPERTY,
144
CCM_STORY_BOARD_HINT_MOTION
146
static void _g_list_free_g_object_unref (GList* self);
147
void ccm_story_board_set_hint_motion (CCMStoryBoard* self, gboolean value);
148
static void ccm_story_board_on_event (CCMStoryBoard* self, CCMDisplay* display, XEvent* event);
149
static void _ccm_story_board_on_event_ccm_display_event (CCMDisplay* _sender, XEvent* event, gpointer self);
150
CCMStoryBoard* ccm_story_board_new (CCMScreen* screen, const char* name, GList* ignore);
151
CCMStoryBoard* ccm_story_board_construct (GType object_type, CCMScreen* screen, const char* name, GList* ignore);
152
gboolean ccm_story_board_get_hint_motion (CCMStoryBoard* self);
153
GType ccm_action_pointer_get_type (void);
154
GType ccm_action_pointer_register_type (GTypeModule * module);
155
GType ccm_action_pointer_motion_get_type (void);
156
GType ccm_action_pointer_motion_register_type (GTypeModule * module);
157
void ccm_action_pointer_motion_set_event (CCMActionPointerMotion* self, XEvent* value);
158
void ccm_action_set_time (CCMAction* self, glong value);
159
CCMActionPointerMotion* ccm_action_pointer_motion_new (CCMScreen* screen, XEvent* event, glong time);
160
CCMActionPointerMotion* ccm_action_pointer_motion_construct (GType object_type, CCMScreen* screen, XEvent* event, glong time);
161
GQuark ccm_action_error_quark (void);
162
CCMActionPointerPress* ccm_action_pointer_press_new (CCMScreen* screen, XEvent* event, glong time, GList* ignore, GError** error);
163
CCMActionPointerPress* ccm_action_pointer_press_construct (GType object_type, CCMScreen* screen, XEvent* event, glong time, GList* ignore, GError** error);
164
GType ccm_action_pointer_press_get_type (void);
165
GType ccm_action_pointer_press_register_type (GTypeModule * module);
166
CCMActionPointerRelease* ccm_action_pointer_release_new (CCMScreen* screen, XEvent* event, glong time, GList* ignore, GError** error);
167
CCMActionPointerRelease* ccm_action_pointer_release_construct (GType object_type, CCMScreen* screen, XEvent* event, glong time, GList* ignore, GError** error);
168
GType ccm_action_pointer_release_get_type (void);
169
GType ccm_action_pointer_release_register_type (GTypeModule * module);
170
char* ccm_action_to_string (CCMAction* self, const char* format);
171
char* ccm_story_board_to_string (CCMStoryBoard* self, const char* format);
172
static void ccm_story_board_finalize (GObject* obj);
173
static void ccm_story_board_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
174
static void ccm_story_board_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
178
static void _g_list_free_g_object_unref (GList* self) {
179
g_list_foreach (self, (GFunc) g_object_unref, NULL);
184
static gpointer _g_object_ref0 (gpointer self) {
185
return self ? g_object_ref (self) : NULL;
189
static void _ccm_story_board_on_event_ccm_display_event (CCMDisplay* _sender, XEvent* event, gpointer self) {
190
ccm_story_board_on_event (self, _sender, event);
194
CCMStoryBoard* ccm_story_board_construct (GType object_type, CCMScreen* screen, const char* name, GList* ignore) {
195
CCMStoryBoard * self;
199
GTimeVal _tmp3_ = {0};
202
g_return_val_if_fail (screen != NULL, NULL);
203
g_return_val_if_fail (name != NULL, NULL);
204
self = (CCMStoryBoard*) g_object_new (object_type, NULL);
205
ccm_story_board_set_hint_motion (self, FALSE);
206
self->priv->screen = (_tmp0_ = _g_object_ref0 (screen), _g_object_unref0 (self->priv->screen), _tmp0_);
207
self->priv->name = (_tmp1_ = g_strdup (name), _g_free0 (self->priv->name), _tmp1_);
208
self->priv->actions = (_tmp2_ = NULL, __g_list_free_g_object_unref0 (self->priv->actions), _tmp2_);
209
self->priv->time = (g_get_current_time (&_tmp3_), _tmp3_);
210
self->priv->ignore = (_tmp4_ = g_list_copy (ignore), _g_list_free0 (self->priv->ignore), _tmp4_);
211
display = _g_object_ref0 (ccm_screen_get_display (screen));
212
g_signal_connect_object (display, "event", (GCallback) _ccm_story_board_on_event_ccm_display_event, self, 0);
213
_g_object_unref0 (display);
218
CCMStoryBoard* ccm_story_board_new (CCMScreen* screen, const char* name, GList* ignore) {
219
return ccm_story_board_construct (CCM_TYPE_STORY_BOARD, screen, name, ignore);
223
static void ccm_story_board_on_event (CCMStoryBoard* self, CCMDisplay* display, XEvent* event) {
224
GError * _inner_error_;
225
GTimeVal _tmp0_ = {0};
228
g_return_if_fail (self != NULL);
229
g_return_if_fail (display != NULL);
230
_inner_error_ = NULL;
231
current = (g_get_current_time (&_tmp0_), _tmp0_);
232
diff = ((current.tv_sec * 1000000) + current.tv_usec) - ((self->priv->time.tv_sec * 1000000) + self->priv->time.tv_usec);
233
if ((*event).type == MotionNotify) {
237
gboolean _tmp2_ = FALSE;
239
if (g_list_last (self->priv->actions) != NULL) {
240
_tmp1_ = (CCMAction*) g_list_last (self->priv->actions)->data;
244
action = _g_object_ref0 (_tmp1_);
246
if (self->priv->_hint_motion) {
247
_tmp2_ = action != NULL;
252
if (CCM_IS_ACTION_POINTER_MOTION (action)) {
253
ccm_action_pointer_motion_set_event (CCM_ACTION_POINTER_MOTION (action), event);
254
ccm_action_set_time ((CCMAction*) CCM_ACTION_POINTER_MOTION (action), (glong) ((gint) (((double) diff) / ((double) 1000))));
260
action = (_tmp3_ = (CCMAction*) ccm_action_pointer_motion_new (self->priv->screen, event, diff), _g_object_unref0 (action), _tmp3_);
261
self->priv->actions = g_list_append (self->priv->actions, _g_object_ref0 (action));
263
_g_object_unref0 (action);
265
if ((*event).type == ButtonPress) {
267
CCMActionPointerPress* action;
268
action = ccm_action_pointer_press_new (self->priv->screen, event, diff, self->priv->ignore, &_inner_error_);
269
if (_inner_error_ != NULL) {
270
if (_inner_error_->domain == CCM_ACTION_ERROR) {
271
goto __catch0_ccm_action_error;
273
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
274
g_clear_error (&_inner_error_);
277
self->priv->actions = g_list_append (self->priv->actions, _g_object_ref0 ((CCMAction*) action));
278
_g_object_unref0 (action);
281
__catch0_ccm_action_error:
285
_inner_error_ = NULL;
287
ccm_debug (ex->message, NULL);
292
if (_inner_error_ != NULL) {
293
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
294
g_clear_error (&_inner_error_);
298
if ((*event).type == ButtonRelease) {
300
CCMActionPointerRelease* action;
301
action = ccm_action_pointer_release_new (self->priv->screen, event, diff, self->priv->ignore, &_inner_error_);
302
if (_inner_error_ != NULL) {
303
if (_inner_error_->domain == CCM_ACTION_ERROR) {
304
goto __catch1_ccm_action_error;
306
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
307
g_clear_error (&_inner_error_);
310
self->priv->actions = g_list_append (self->priv->actions, _g_object_ref0 ((CCMAction*) action));
311
_g_object_unref0 (action);
314
__catch1_ccm_action_error:
318
_inner_error_ = NULL;
320
ccm_debug (ex->message, NULL);
325
if (_inner_error_ != NULL) {
326
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
327
g_clear_error (&_inner_error_);
333
self->priv->time = current;
337
char* ccm_story_board_to_string (CCMStoryBoard* self, const char* format) {
341
g_return_val_if_fail (self != NULL, NULL);
342
g_return_val_if_fail (format != NULL, NULL);
343
val = g_strdup ("<story-board>\n");
345
GList* action_collection;
347
action_collection = self->priv->actions;
348
for (action_it = action_collection; action_it != NULL; action_it = action_it->next) {
350
action = _g_object_ref0 ((CCMAction*) action_it->data);
356
val = (_tmp3_ = g_strconcat (val, _tmp2_ = g_strconcat (_tmp1_ = g_strconcat (" ", _tmp0_ = ccm_action_to_string (action, "%ccma"), NULL), "\n", NULL), NULL), _g_free0 (val), _tmp3_);
360
_g_object_unref0 (action);
364
val = (_tmp4_ = g_strconcat (val, "</story-board>\n", NULL), _g_free0 (val), _tmp4_);
370
gboolean ccm_story_board_get_hint_motion (CCMStoryBoard* self) {
372
g_return_val_if_fail (self != NULL, FALSE);
373
result = self->priv->_hint_motion;
378
void ccm_story_board_set_hint_motion (CCMStoryBoard* self, gboolean value) {
379
g_return_if_fail (self != NULL);
380
self->priv->_hint_motion = value;
381
g_object_notify ((GObject *) self, "hint-motion");
385
static void ccm_story_board_class_init (CCMStoryBoardClass * klass) {
386
ccm_story_board_parent_class = g_type_class_peek_parent (klass);
387
g_type_class_add_private (klass, sizeof (CCMStoryBoardPrivate));
388
G_OBJECT_CLASS (klass)->get_property = ccm_story_board_get_property;
389
G_OBJECT_CLASS (klass)->set_property = ccm_story_board_set_property;
390
G_OBJECT_CLASS (klass)->finalize = ccm_story_board_finalize;
391
g_object_class_install_property (G_OBJECT_CLASS (klass), CCM_STORY_BOARD_HINT_MOTION, g_param_spec_boolean ("hint-motion", "hint-motion", "hint-motion", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
395
static void ccm_story_board_instance_init (CCMStoryBoard * self) {
396
self->priv = CCM_STORY_BOARD_GET_PRIVATE (self);
400
static void ccm_story_board_finalize (GObject* obj) {
401
CCMStoryBoard * self;
402
self = CCM_STORY_BOARD (obj);
403
_g_object_unref0 (self->priv->screen);
404
_g_free0 (self->priv->name);
405
_g_list_free0 (self->priv->ignore);
406
__g_list_free_g_object_unref0 (self->priv->actions);
407
G_OBJECT_CLASS (ccm_story_board_parent_class)->finalize (obj);
411
GType ccm_story_board_get_type (void) {
412
return ccm_story_board_type_id;
416
GType ccm_story_board_register_type (GTypeModule * module) {
417
static const GTypeInfo g_define_type_info = { sizeof (CCMStoryBoardClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ccm_story_board_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CCMStoryBoard), 0, (GInstanceInitFunc) ccm_story_board_instance_init, NULL };
418
ccm_story_board_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "CCMStoryBoard", &g_define_type_info, 0);
419
return ccm_story_board_type_id;
423
static void ccm_story_board_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
424
CCMStoryBoard * self;
425
self = CCM_STORY_BOARD (object);
426
switch (property_id) {
427
case CCM_STORY_BOARD_HINT_MOTION:
428
g_value_set_boolean (value, ccm_story_board_get_hint_motion (self));
431
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
437
static void ccm_story_board_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
438
CCMStoryBoard * self;
439
self = CCM_STORY_BOARD (object);
440
switch (property_id) {
441
case CCM_STORY_BOARD_HINT_MOTION:
442
ccm_story_board_set_hint_motion (self, g_value_get_boolean (value));
445
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);