Merge lp:~smspillaz/compiz-core/compiz-core.drop-legacy-2 into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 2952
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.drop-legacy-2
Merge into: lp:compiz-core/0.9.5
Diff against target: 6380 lines (+0/-6315)
13 files modified
legacy/compiz-cube.h (+0/-230)
legacy/compiz-cube.pc.in (+0/-13)
legacy/fs.xml.in (+0/-13)
legacy/fuse.cpp (+0/-1442)
legacy/gconf.cpp (+0/-848)
legacy/gconf.xml.in (+0/-18)
legacy/metadata.cpp (+0/-1160)
legacy/metadata.h (+0/-106)
legacy/minimize.cpp (+0/-1059)
legacy/minimize.xml.in (+0/-43)
legacy/privatemetadata.h (+0/-40)
legacy/video.cpp (+0/-1329)
legacy/video.xml.in (+0/-14)
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.drop-legacy-2
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+89754@code.launchpad.net

Description of the change

Drop /legacy

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Sounds fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'legacy'
2=== removed file 'legacy/compiz-cube.h'
3--- legacy/compiz-cube.h 2009-03-15 23:00:03 +0000
4+++ legacy/compiz-cube.h 1970-01-01 00:00:00 +0000
5@@ -1,230 +0,0 @@
6-/*
7- * Copyright © 2007 Novell, Inc.
8- *
9- * Permission to use, copy, modify, distribute, and sell this software
10- * and its documentation for any purpose is hereby granted without
11- * fee, provided that the above copyright notice appear in all copies
12- * and that both that copyright notice and this permission notice
13- * appear in supporting documentation, and that the name of
14- * Novell, Inc. not be used in advertising or publicity pertaining to
15- * distribution of the software without specific, written prior permission.
16- * Novell, Inc. makes no representations about the suitability of this
17- * software for any purpose. It is provided "as is" without express or
18- * implied warranty.
19- *
20- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
21- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
22- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
23- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
24- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
25- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
26- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27- *
28- * Author: David Reveman <davidr@novell.com>
29- */
30-
31-#ifndef _COMPIZ_CUBE_H
32-#define _COMPIZ_CUBE_H
33-
34-#include <compiz-core.h>
35-
36-COMPIZ_BEGIN_DECLS
37-
38-#define CUBE_ABIVERSION 20080424
39-
40-typedef struct _CubeCore {
41- SetOptionForPluginProc setOptionForPlugin;
42-} CubeCore;
43-
44-#define CUBE_MOMODE_AUTO 0
45-#define CUBE_MOMODE_MULTI 1
46-#define CUBE_MOMODE_ONE 2
47-#define CUBE_MOMODE_LAST CUBE_MOMODE_ONE
48-
49-#define CUBE_DISPLAY_OPTION_ABI 0
50-#define CUBE_DISPLAY_OPTION_INDEX 1
51-#define CUBE_DISPLAY_OPTION_UNFOLD_KEY 2
52-#define CUBE_DISPLAY_OPTION_NEXT_KEY 3
53-#define CUBE_DISPLAY_OPTION_PREV_KEY 4
54-#define CUBE_DISPLAY_OPTION_NUM 5
55-
56-typedef struct _CubeDisplay {
57- int screenPrivateIndex;
58-
59- CompOption opt[CUBE_DISPLAY_OPTION_NUM];
60-} CubeDisplay;
61-
62-#define CUBE_SCREEN_OPTION_COLOR 0
63-#define CUBE_SCREEN_OPTION_IN 1
64-#define CUBE_SCREEN_OPTION_SCALE_IMAGE 2
65-#define CUBE_SCREEN_OPTION_IMAGES 3
66-#define CUBE_SCREEN_OPTION_SKYDOME 4
67-#define CUBE_SCREEN_OPTION_SKYDOME_IMG 5
68-#define CUBE_SCREEN_OPTION_SKYDOME_ANIM 6
69-#define CUBE_SCREEN_OPTION_SKYDOME_GRAD_START 7
70-#define CUBE_SCREEN_OPTION_SKYDOME_GRAD_END 8
71-#define CUBE_SCREEN_OPTION_ACCELERATION 9
72-#define CUBE_SCREEN_OPTION_SPEED 10
73-#define CUBE_SCREEN_OPTION_TIMESTEP 11
74-#define CUBE_SCREEN_OPTION_MIPMAP 12
75-#define CUBE_SCREEN_OPTION_ADJUST_IMAGE 13
76-#define CUBE_SCREEN_OPTION_ACTIVE_OPACITY 14
77-#define CUBE_SCREEN_OPTION_INACTIVE_OPACITY 15
78-#define CUBE_SCREEN_OPTION_TRANSPARENT_MANUAL_ONLY 16
79-#define CUBE_SCREEN_OPTION_MULTIOUTPUT_MODE 17
80-#define CUBE_SCREEN_OPTION_NUM 18
81-
82-typedef enum _PaintOrder {
83- BTF = 0,
84- FTB
85-} PaintOrder;
86-
87-typedef enum _RotationState {
88- RotationNone = 0,
89- RotationChange,
90- RotationManual
91-} RotationState;
92-
93-typedef void (*CubeGetRotationProc) (CompScreen *s,
94- float *x,
95- float *v,
96- float *progress);
97-
98-typedef void (*CubeClearTargetOutputProc) (CompScreen *s,
99- float xRotate,
100- float vRotate);
101-
102-typedef void (*CubePaintTopProc) (CompScreen *s,
103- const ScreenPaintAttrib *sAttrib,
104- const CompTransform *transform,
105- CompOutput *output,
106- int size);
107-
108-typedef void (*CubePaintBottomProc) (CompScreen *s,
109- const ScreenPaintAttrib *sAttrib,
110- const CompTransform *transform,
111- CompOutput *output,
112- int size);
113-
114-typedef void (*CubePaintInsideProc) (CompScreen *s,
115- const ScreenPaintAttrib *sAttrib,
116- const CompTransform *transform,
117- CompOutput *output,
118- int size);
119-
120-typedef Bool (*CubeCheckOrientationProc) (CompScreen *s,
121- const ScreenPaintAttrib *sAttrib,
122- const CompTransform *transform,
123- CompOutput *output,
124- CompVector *points);
125-
126-typedef void (*CubePaintViewportProc) (CompScreen *s,
127- const ScreenPaintAttrib *sAttrib,
128- const CompTransform *transform,
129- Region region,
130- CompOutput *output,
131- unsigned int mask);
132-
133-typedef Bool (*CubeShouldPaintViewportProc) (CompScreen *s,
134- const ScreenPaintAttrib *sAttrib,
135- const CompTransform *transform,
136- CompOutput *output,
137- PaintOrder order);
138-
139-typedef struct _CubeScreen {
140- PreparePaintScreenProc preparePaintScreen;
141- DonePaintScreenProc donePaintScreen;
142- PaintScreenProc paintScreen;
143- PaintOutputProc paintOutput;
144- PaintTransformedOutputProc paintTransformedOutput;
145- EnableOutputClippingProc enableOutputClipping;
146- PaintWindowProc paintWindow;
147- ApplyScreenTransformProc applyScreenTransform;
148- OutputChangeNotifyProc outputChangeNotify;
149- InitWindowWalkerProc initWindowWalker;
150-
151- CubeGetRotationProc getRotation;
152- CubeClearTargetOutputProc clearTargetOutput;
153- CubePaintTopProc paintTop;
154- CubePaintBottomProc paintBottom;
155- CubePaintInsideProc paintInside;
156- CubeCheckOrientationProc checkOrientation;
157- CubePaintViewportProc paintViewport;
158- CubeShouldPaintViewportProc shouldPaintViewport;
159-
160- CompOption opt[CUBE_SCREEN_OPTION_NUM];
161-
162- int invert;
163- int xRotations;
164- PaintOrder paintOrder;
165-
166- RotationState rotationState;
167-
168- Bool paintAllViewports;
169-
170- GLfloat distance;
171- GLushort color[3];
172- GLfloat tc[12];
173-
174- int grabIndex;
175-
176- int srcOutput;
177-
178- Bool unfolded;
179- GLfloat unfold, unfoldVelocity;
180-
181- GLfloat *vertices;
182- int nVertices;
183-
184- GLuint skyListId;
185-
186- int pw, ph;
187- unsigned int skyW, skyH;
188- CompTexture texture, sky;
189-
190- int imgCurFile;
191-
192- int nOutput;
193- int output[64];
194- int outputMask[64];
195-
196- Bool cleared[64];
197-
198- Bool capsPainted[64];
199-
200- Bool fullscreenOutput;
201-
202- float outputXScale;
203- float outputYScale;
204- float outputXOffset;
205- float outputYOffset;
206-
207- float desktopOpacity;
208- float toOpacity;
209- int lastOpacityIndex;
210-
211- int moMode;
212- Bool recalcOutput;
213-} CubeScreen;
214-
215-#define GET_CUBE_CORE(c) \
216- ((CubeCore *) (c)->base.privates[cubeCorePrivateIndex].ptr)
217-
218-#define CUBE_CORE(c) \
219- CubeCore *cc = GET_CUBE_CORE (c)
220-
221-#define GET_CUBE_DISPLAY(d) \
222- ((CubeDisplay *) (d)->base.privates[cubeDisplayPrivateIndex].ptr)
223-
224-#define CUBE_DISPLAY(d) \
225- CubeDisplay *cd = GET_CUBE_DISPLAY (d)
226-
227-#define GET_CUBE_SCREEN(s, cd) \
228- ((CubeScreen *) (s)->base.privates[(cd)->screenPrivateIndex].ptr)
229-
230-#define CUBE_SCREEN(s) \
231- CubeScreen *cs = GET_CUBE_SCREEN (s, GET_CUBE_DISPLAY (s->display))
232-
233-COMPIZ_END_DECLS
234-
235-#endif
236
237=== removed file 'legacy/compiz-cube.pc.in'
238--- legacy/compiz-cube.pc.in 2009-03-15 05:15:26 +0000
239+++ legacy/compiz-cube.pc.in 1970-01-01 00:00:00 +0000
240@@ -1,13 +0,0 @@
241-prefix=@prefix@
242-exec_prefix=@exec_prefix@
243-libdir=@libdir@
244-includedir=@includedir@
245-
246-Name: compiz-cube
247-Description: Cube plugin for compiz
248-Version: @VERSION@
249-
250-Requires: compiz
251-Libs:
252-Cflags: @COMPIZ_CFLAGS@ @GL_CFLAGS@ -I${includedir}/compiz
253-
254
255=== removed file 'legacy/fs.xml.in'
256--- legacy/fs.xml.in 2009-03-15 05:15:26 +0000
257+++ legacy/fs.xml.in 1970-01-01 00:00:00 +0000
258@@ -1,13 +0,0 @@
259-<compiz>
260- <plugin name="fs">
261- <_short>Userspace File System</_short>
262- <_long>Userspace file system</_long>
263- <display>
264- <option name="mount_point" type="string">
265- <_short>Mount Point</_short>
266- <_long>Mount point</_long>
267- <default>compiz</default>
268- </option>
269- </display>
270- </plugin>
271-</compiz>
272
273=== removed file 'legacy/fuse.cpp'
274--- legacy/fuse.cpp 2009-03-15 05:15:26 +0000
275+++ legacy/fuse.cpp 1970-01-01 00:00:00 +0000
276@@ -1,1442 +0,0 @@
277-/*
278- * Copyright © 2007 David Reveman
279- *
280- * Permission to use, copy, modify, distribute, and sell this software
281- * and its documentation for any purpose is hereby granted without
282- * fee, provided that the above copyright notice appear in all copies
283- * and that both that copyright notice and this permission notice
284- * appear in supporting documentation, and that the name of
285- * David Reveman not be used in advertising or publicity pertaining to
286- * distribution of the software without specific, written prior permission.
287- * David Reveman makes no representations about the suitability of this
288- * software for any purpose. It is provided "as is" without express or
289- * implied warranty.
290- *
291- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
292- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
293- * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
294- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
295- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
296- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
297- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
298- *
299- * Author: David Reveman <davidr@novell.com>
300- */
301-
302-#include <stdlib.h>
303-#include <string.h>
304-#include <errno.h>
305-#include <poll.h>
306-#include <signal.h>
307-#include <sys/mount.h>
308-#include <fuse.h>
309-#include <fuse_lowlevel.h>
310-
311-#include <compiz-core.h>
312-
313-static CompMetadata fuseMetadata;
314-
315-#define FUSE_INODE_TYPE_ROOT (1 << 0)
316-#define FUSE_INODE_TYPE_PLUGIN (1 << 1)
317-#define FUSE_INODE_TYPE_SCREEN (1 << 2)
318-#define FUSE_INODE_TYPE_DISPLAY (1 << 3)
319-#define FUSE_INODE_TYPE_OPTION (1 << 4)
320-#define FUSE_INODE_TYPE_TYPE (1 << 5)
321-#define FUSE_INODE_TYPE_VALUE (1 << 6)
322-#define FUSE_INODE_TYPE_ITEM_COUNT (1 << 7)
323-#define FUSE_INODE_TYPE_ITEM_TYPE (1 << 8)
324-#define FUSE_INODE_TYPE_ITEMS (1 << 9)
325-#define FUSE_INODE_TYPE_ITEM_VALUE (1 << 10)
326-#define FUSE_INODE_TYPE_MIN (1 << 11)
327-#define FUSE_INODE_TYPE_MAX (1 << 12)
328-#define FUSE_INODE_TYPE_PRECISION (1 << 13)
329-
330-#define DIR_MASK (FUSE_INODE_TYPE_ROOT | \
331- FUSE_INODE_TYPE_PLUGIN | \
332- FUSE_INODE_TYPE_SCREEN | \
333- FUSE_INODE_TYPE_DISPLAY | \
334- FUSE_INODE_TYPE_OPTION | \
335- FUSE_INODE_TYPE_ITEMS)
336-
337-#define CONST_DIR_MASK (FUSE_INODE_TYPE_PLUGIN | \
338- FUSE_INODE_TYPE_SCREEN | \
339- FUSE_INODE_TYPE_DISPLAY | \
340- FUSE_INODE_TYPE_OPTION)
341-
342-#define WRITE_MASK (FUSE_INODE_TYPE_VALUE | \
343- FUSE_INODE_TYPE_ITEM_VALUE)
344-
345-#define FUSE_INODE_FLAG_TRUNC (1 << 0)
346-
347-typedef struct _FuseInode {
348- struct _FuseInode *parent;
349- struct _FuseInode *child;
350- struct _FuseInode *sibling;
351-
352- int type;
353- int flags;
354- fuse_ino_t ino;
355- char *name;
356-} FuseInode;
357-
358-typedef struct _FuseWriteBuffer {
359- char *data;
360- int size;
361- Bool dirty;
362-} FuseWriteBuffer;
363-
364-static int displayPrivateIndex;
365-
366-#define FUSE_DISPLAY_OPTION_MOUNT_POINT 0
367-#define FUSE_DISPLAY_OPTION_NUM 1
368-
369-typedef struct _FuseDisplay {
370- CompOption opt[FUSE_DISPLAY_OPTION_NUM];
371-
372- struct fuse_session *session;
373- struct fuse_chan *channel;
374- char *mountPoint;
375- CompWatchFdHandle watchFdHandle;
376- char *buffer;
377-} FuseDisplay;
378-
379-#define GET_FUSE_DISPLAY(d) \
380- ((FuseDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
381-
382-#define FUSE_DISPLAY(d) \
383- FuseDisplay *fd = GET_FUSE_DISPLAY (d)
384-
385-#define NUM_OPTIONS(d) (sizeof ((d)->opt) / sizeof (CompOption))
386-
387-static fuse_ino_t nextIno = 1;
388-static FuseInode *inodes = NULL;
389-
390-static FuseInode *
391-fuseAddInode (FuseInode *parent,
392- int type,
393- const char *name)
394-{
395- FuseInode *inode;
396-
397- inode = malloc (sizeof (FuseInode));
398- if (!inode)
399- return NULL;
400-
401- inode->parent = parent;
402- inode->sibling = NULL;
403- inode->child = NULL;
404- inode->type = type;
405- inode->flags = 0;
406- inode->ino = nextIno++;
407- inode->name = strdup (name);
408-
409- if (parent)
410- {
411- if (parent->child)
412- inode->sibling = parent->child;
413-
414- parent->child = inode;
415- }
416-
417- return inode;
418-}
419-
420-static void
421-fuseRemoveInode (FuseInode *parent,
422- FuseInode *inode)
423-{
424- while (inode->child)
425- fuseRemoveInode (inode, inode->child);
426-
427- if (parent)
428- {
429- FuseInode *s, *prev = NULL;
430-
431- for (s = parent->child; s; s = s->sibling)
432- {
433- if (s == inode)
434- break;
435-
436- prev = s;
437- }
438-
439- if (prev)
440- prev->sibling = inode->sibling;
441- else
442- parent->child = NULL;
443- }
444-
445- if (inode->name)
446- free (inode->name);
447-
448- free (inode);
449-}
450-
451-static FuseInode *
452-fuseFindInode (FuseInode *inode,
453- fuse_ino_t ino,
454- int mask)
455-{
456- if (inode->ino != ino)
457- {
458- FuseInode *c = inode->child;
459-
460- inode = NULL;
461- while (c)
462- {
463- inode = fuseFindInode (c, ino, ~0);
464- if (inode)
465- break;
466-
467- c = c->sibling;
468- }
469- }
470-
471- if (inode && (inode->type & mask))
472- return inode;
473-
474- return NULL;
475-}
476-
477-static FuseInode *
478-fuseLookupChild (FuseInode *inode,
479- const char *name)
480-{
481- FuseInode *c;
482-
483- for (c = inode->child; c; c = c->sibling)
484- if (strcmp (c->name, name) == 0)
485- return c;
486-
487- return NULL;
488-}
489-
490-/* MULTIDPYERROR: only works with one or less displays present */
491-/* OBJECTOPTION: only display and screen options are supported */
492-static CompObject *
493-fuseGetObjectFromInode (FuseInode *inode)
494-{
495- CompObject *object;
496-
497- object = compObjectFind (&core.base, COMP_OBJECT_TYPE_DISPLAY, NULL);
498- if (!object)
499- return NULL;
500-
501- if (inode->type & FUSE_INODE_TYPE_SCREEN)
502- {
503- return compObjectFind (object, COMP_OBJECT_TYPE_SCREEN,
504- inode->name + 6);
505- }
506- else if (inode->type & FUSE_INODE_TYPE_DISPLAY)
507- {
508- return object;
509- }
510-
511- return NULL;
512-}
513-
514-static CompOption *
515-fuseGetOptionsFromInode (CompObject *object,
516- FuseInode *inode,
517- int *nOption)
518-{
519- CompOption *option = NULL;
520-
521- if (inode->type & FUSE_INODE_TYPE_PLUGIN)
522- {
523- CompPlugin *p;
524-
525- p = findActivePlugin (inode->name);
526- if (p && p->vTable->getObjectOptions)
527- option = (*p->vTable->getObjectOptions) (p, object, nOption);
528- }
529-
530- return option;
531-}
532-
533-static CompOption *
534-fuseGetOptionFromInode (FuseInode *inode)
535-{
536- if (inode->type & (FUSE_INODE_TYPE_OPTION |
537- FUSE_INODE_TYPE_ITEMS))
538- {
539- CompObject *object;
540- CompOption *option;
541- int nOption;
542-
543- if (inode->type & FUSE_INODE_TYPE_ITEMS)
544- inode = inode->parent;
545-
546- object = fuseGetObjectFromInode (inode);
547- if (!object)
548- return NULL;
549-
550- option = fuseGetOptionsFromInode (object, inode->parent, &nOption);
551- if (option)
552- {
553- while (nOption--)
554- {
555- if (strcmp (inode->name, option->name) == 0)
556- return option;
557-
558- option++;
559- }
560- }
561- }
562-
563- return NULL;
564-}
565-
566-/* MULTIDPYERROR: only works with one or less displays present */
567-static char *
568-fuseGetStringFromInode (FuseInode *inode)
569-{
570- CompOption *option;
571- char str[256];
572-
573- if (!inode->parent)
574- return NULL;
575-
576- option = fuseGetOptionFromInode (inode->parent);
577- if (!option)
578- return NULL;
579-
580- if (inode->flags & FUSE_INODE_FLAG_TRUNC)
581- return strdup ("");
582-
583- if (inode->type & FUSE_INODE_TYPE_TYPE)
584- {
585- return strdup (optionTypeToString (option->type));
586- }
587- else if (inode->type & (FUSE_INODE_TYPE_VALUE | FUSE_INODE_TYPE_ITEM_VALUE))
588- {
589- CompOptionValue *value = NULL;
590- CompOptionType type;
591-
592- if (inode->type & FUSE_INODE_TYPE_ITEM_VALUE)
593- {
594- int i;
595-
596- if (sscanf (inode->name, "value%d", &i))
597- {
598- if (i < option->value.list.nValue)
599- {
600- value = &option->value.list.value[i];
601- type = option->value.list.type;
602- }
603- }
604- }
605- else
606- {
607- value = &option->value;
608- type = option->type;
609- }
610-
611- if (value)
612- {
613- switch (type) {
614- case CompOptionTypeBool:
615- return strdup (value->b ? "true" : "false");
616- case CompOptionTypeInt:
617- snprintf (str, 256, "%d", value->i);
618- return strdup (str);
619- case CompOptionTypeFloat:
620- snprintf (str, 256, "%f", value->f);
621- return strdup (str);
622- case CompOptionTypeString:
623- return strdup (value->s);
624- case CompOptionTypeColor:
625- return colorToString (value->c);
626- case CompOptionTypeKey:
627- if (core.displays)
628- return keyActionToString (core.displays, &value->action);
629- case CompOptionTypeButton:
630- if (core.displays)
631- return buttonActionToString (core.displays,
632- &value->action);
633- case CompOptionTypeEdge:
634- return edgeMaskToString (value->action.edgeMask);
635- case CompOptionTypeBell:
636- return strdup (value->action.bell ? "true" : "false");
637- case CompOptionTypeMatch:
638- return matchToString (&value->match);
639- default:
640- break;
641- }
642- }
643- }
644- else if (inode->type & FUSE_INODE_TYPE_MIN)
645- {
646- if (option->type == CompOptionTypeInt)
647- snprintf (str, 256, "%d", option->rest.i.min);
648- else
649- snprintf (str, 256, "%f", option->rest.f.min);
650-
651- return strdup (str);
652- }
653- else if (inode->type & FUSE_INODE_TYPE_MAX)
654- {
655- if (option->type == CompOptionTypeInt)
656- snprintf (str, 256, "%d", option->rest.i.max);
657- else
658- snprintf (str, 256, "%f", option->rest.f.max);
659-
660- return strdup (str);
661- }
662- else if (inode->type & FUSE_INODE_TYPE_PRECISION)
663- {
664- snprintf (str, 256, "%f", option->rest.f.precision);
665- return strdup (str);
666- }
667- else if (inode->type & FUSE_INODE_TYPE_ITEM_COUNT)
668- {
669- snprintf (str, 256, "%d", option->value.list.nValue);
670- return strdup (str);
671- }
672- else if (inode->type & FUSE_INODE_TYPE_ITEM_TYPE)
673- {
674- return strdup (optionTypeToString (option->value.list.type));
675- }
676-
677- return NULL;
678-}
679-
680-static void
681-fuseUpdateInode (CompDisplay *d,
682- FuseInode *inode)
683-{
684- CompScreen *s;
685- CompPlugin *p;
686- CompOption *option;
687- char str[256];
688-
689- if (inode->type & FUSE_INODE_TYPE_ROOT)
690- {
691- FuseInode *c;
692-
693- for (c = inode->child; c; c = c->sibling)
694- {
695- if (!findActivePlugin (c->name))
696- fuseRemoveInode (inode, c);
697- }
698-
699- for (p = getPlugins (); p; p = p->next)
700- if (!fuseLookupChild (inode, p->vTable->name))
701- fuseAddInode (inode, FUSE_INODE_TYPE_PLUGIN,
702- p->vTable->name);
703- }
704- else if (inode->type & FUSE_INODE_TYPE_PLUGIN)
705- {
706- int n;
707-
708- if (fuseGetOptionsFromInode (&d->base, inode, &n))
709- fuseAddInode (inode, FUSE_INODE_TYPE_DISPLAY, "allscreens");
710-
711- for (s = d->screens; s; s = s->next)
712- {
713- if (fuseGetOptionsFromInode (&s->base, inode, &n))
714- {
715- sprintf (str, "screen%d", s->screenNum);
716- fuseAddInode (inode, FUSE_INODE_TYPE_SCREEN, str);
717- }
718- }
719- }
720- else if (inode->type & (FUSE_INODE_TYPE_DISPLAY | FUSE_INODE_TYPE_SCREEN))
721- {
722- CompObject *object;
723-
724- object = fuseGetObjectFromInode (inode);
725- if (object)
726- {
727- int nOption;
728-
729- option = fuseGetOptionsFromInode (object, inode->parent, &nOption);
730- if (option)
731- {
732- while (nOption--)
733- {
734- fuseAddInode (inode, FUSE_INODE_TYPE_OPTION, option->name);
735-
736- option++;
737- }
738- }
739- }
740- }
741- else if (inode->type & FUSE_INODE_TYPE_OPTION)
742- {
743- option = fuseGetOptionFromInode (inode);
744- if (option)
745- {
746- fuseAddInode (inode, FUSE_INODE_TYPE_TYPE, "type");
747-
748- switch (option->type) {
749- case CompOptionTypeFloat:
750- fuseAddInode (inode, FUSE_INODE_TYPE_PRECISION, "precision");
751- /* fall-through */
752- case CompOptionTypeInt:
753- fuseAddInode (inode, FUSE_INODE_TYPE_MIN, "min");
754- fuseAddInode (inode, FUSE_INODE_TYPE_MAX, "max");
755- /* fall-through */
756- case CompOptionTypeBool:
757- case CompOptionTypeString:
758- case CompOptionTypeColor:
759- case CompOptionTypeKey:
760- case CompOptionTypeButton:
761- case CompOptionTypeEdge:
762- case CompOptionTypeBell:
763- case CompOptionTypeMatch:
764- fuseAddInode (inode, FUSE_INODE_TYPE_VALUE, "value");
765- break;
766- case CompOptionTypeList:
767- fuseAddInode (inode, FUSE_INODE_TYPE_ITEMS, "items");
768- fuseAddInode (inode, FUSE_INODE_TYPE_ITEM_COUNT,
769- "number_of_items");
770- fuseAddInode (inode, FUSE_INODE_TYPE_ITEM_TYPE, "item_type");
771- default:
772- break;
773- }
774- }
775- }
776- else if (inode->type & FUSE_INODE_TYPE_ITEMS)
777- {
778- option = fuseGetOptionFromInode (inode->parent);
779- if (option && option->type == CompOptionTypeList)
780- {
781- FuseInode *c, *next;
782- int i, nValue = option->value.list.nValue;
783-
784- for (i = 0; i < option->value.list.nValue; i++)
785- {
786- sprintf (str, "value%d", i);
787- if (!fuseLookupChild (inode, str))
788- fuseAddInode (inode, FUSE_INODE_TYPE_ITEM_VALUE, str);
789- }
790-
791- for (c = inode->child; c; c = next)
792- {
793- next = c->sibling;
794-
795- if (sscanf (c->name, "value%d", &i) == 0 || i >= nValue)
796- fuseRemoveInode (inode, c);
797- }
798- }
799- }
800-}
801-
802-static void
803-fuseInodeStat (CompDisplay *d,
804- FuseInode *inode,
805- struct stat *stbuf)
806-{
807- stbuf->st_ino = inode->ino;
808-
809- if (inode->type & DIR_MASK)
810- {
811- stbuf->st_mode = S_IFDIR | 0755;
812- stbuf->st_nlink = 2;
813- }
814- else
815- {
816- char *str;
817-
818- if (inode->type & WRITE_MASK)
819- stbuf->st_mode = S_IFREG | 0666;
820- else
821- stbuf->st_mode = S_IFREG | 0444;
822-
823- stbuf->st_nlink = 1;
824- stbuf->st_size = 0;
825-
826- str = fuseGetStringFromInode (inode);
827- if (str)
828- {
829- stbuf->st_size = strlen (str);
830- free (str);
831- }
832- }
833-}
834-
835-static Bool
836-fuseInitValue (CompOptionValue *value,
837- CompOptionType type,
838- CompOptionValue *src)
839-{
840- switch (type) {
841- case CompOptionTypeBool:
842- value->b = src->b;
843- break;
844- case CompOptionTypeInt:
845- value->i = src->i;
846- break;
847- case CompOptionTypeFloat:
848- value->f = src->f;
849- break;
850- case CompOptionTypeString:
851- value->s = strdup (src->s);
852- break;
853- case CompOptionTypeColor:
854- memcpy (value->c, src->c, sizeof (*src->c));
855- break;
856- case CompOptionTypeKey:
857- case CompOptionTypeButton:
858- case CompOptionTypeEdge:
859- case CompOptionTypeBell:
860- value->action = src->action;
861- break;
862- case CompOptionTypeMatch:
863- matchInit (&value->match);
864- matchCopy (&value->match, &src->match);
865- break;
866- default:
867- return FALSE;
868- }
869-
870- return TRUE;
871-}
872-
873-static Bool
874-fuseInitValueFromString (CompObject *object,
875- CompOptionValue *value,
876- CompOptionType type,
877- char *str)
878-{
879- switch (type) {
880- case CompOptionTypeBool:
881- value->b = strcmp (str, "true") ? FALSE : TRUE;
882- break;
883- case CompOptionTypeInt:
884- value->i = atoi (str);
885- break;
886- case CompOptionTypeFloat:
887- value->f = strtod (str, NULL);
888- break;
889- case CompOptionTypeString:
890- value->s = strdup (str);
891- break;
892- case CompOptionTypeColor:
893- if (!stringToColor (str, value->c))
894- return FALSE;
895- break;
896- case CompOptionTypeKey:
897- while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
898- object = object->parent;
899-
900- if (!object)
901- return FALSE;
902-
903- stringToKeyAction (GET_CORE_DISPLAY (object), str, &value->action);
904- break;
905- case CompOptionTypeButton:
906- while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
907- object = object->parent;
908-
909- if (!object)
910- return FALSE;
911-
912- stringToButtonAction (GET_CORE_DISPLAY (object), str, &value->action);
913- break;
914- case CompOptionTypeEdge:
915- value->action.edgeMask = stringToEdgeMask (str);
916- break;
917- case CompOptionTypeBell:
918- value->action.bell = strcmp (str, "true") ? FALSE : TRUE;
919- break;
920- case CompOptionTypeMatch:
921- matchInit (&value->match);
922- matchAddFromString (&value->match, str);
923- break;
924- default:
925- return FALSE;
926- }
927-
928- return TRUE;
929-}
930-
931-static void
932-fuseSetInodeOptionUsingString (FuseInode *inode,
933- char *str)
934-{
935- CompOption *option;
936-
937- option = fuseGetOptionFromInode (inode->parent);
938- if (option)
939- {
940- CompOptionValue value;
941- CompObject *object;
942- const char *pluginName;
943-
944- if (inode->type & FUSE_INODE_TYPE_VALUE)
945- {
946- object = fuseGetObjectFromInode (inode->parent->parent);
947- if (!object)
948- return;
949-
950- if (!fuseInitValueFromString (object, &value, option->type, str))
951- return;
952-
953- pluginName = inode->parent->parent->parent->name;
954- }
955- else if (inode->type & FUSE_INODE_TYPE_ITEM_VALUE)
956- {
957- int i, item, nValue = option->value.list.nValue;
958-
959- if (!sscanf (inode->name, "value%d", &item))
960- return;
961-
962- if (item >= nValue)
963- return;
964-
965- object = fuseGetObjectFromInode (inode->parent->parent->parent);
966- if (!object)
967- return;
968-
969- value.list.value = malloc (sizeof (CompOptionValue) * nValue);
970- if (!value.list.value)
971- return;
972-
973- value.list.type = option->value.list.type;
974- value.list.nValue = 0;
975-
976- for (i = 0; i < nValue; i++)
977- {
978- if (i == item)
979- {
980- if (!fuseInitValueFromString (object,
981- &value.list.value[i],
982- value.list.type,
983- str))
984- break;
985- }
986- else
987- {
988- if (!fuseInitValue (&value.list.value[i],
989- value.list.type,
990- &option->value.list.value[i]))
991- break;
992- }
993-
994- value.list.nValue++;
995- }
996-
997- /* failed */
998- if (value.list.nValue < nValue)
999- {
1000- compFiniOptionValue (&value, option->type);
1001- return;
1002- }
1003-
1004- pluginName = inode->parent->parent->parent->parent->name;
1005- }
1006- else
1007- {
1008- return;
1009- }
1010-
1011- (*core.setOptionForPlugin) (object, pluginName, option->name, &value);
1012-
1013- compFiniOptionValue (&value, option->type);
1014- }
1015-}
1016-
1017-static void
1018-compiz_getattr (fuse_req_t req,
1019- fuse_ino_t ino,
1020- struct fuse_file_info *fi)
1021-{
1022- CompDisplay *d = (CompDisplay *) fuse_req_userdata (req);
1023- FuseInode *inode;
1024-
1025- inode = fuseFindInode (inodes, ino, ~0);
1026- if (inode)
1027- {
1028- struct stat stbuf;
1029-
1030- memset (&stbuf, 0, sizeof (stbuf));
1031-
1032- fuseInodeStat (d, inode, &stbuf);
1033-
1034- fuse_reply_attr (req, &stbuf, 1.0);
1035- }
1036- else
1037- {
1038- fuse_reply_err (req, ENOENT);
1039- }
1040-}
1041-
1042-static void
1043-compiz_setattr (fuse_req_t req,
1044- fuse_ino_t ino,
1045- struct stat *attr,
1046- int to_set,
1047- struct fuse_file_info *fi)
1048-{
1049- CompDisplay *d = (CompDisplay *) fuse_req_userdata (req);
1050- FuseInode *inode;
1051-
1052- inode = fuseFindInode (inodes, ino, WRITE_MASK);
1053- if (inode)
1054- {
1055- struct stat stbuf;
1056-
1057- if ((to_set & FUSE_SET_ATTR_SIZE) != FUSE_SET_ATTR_SIZE)
1058- {
1059- fuse_reply_err (req, EACCES);
1060- return;
1061- }
1062-
1063- if (attr->st_size != 0)
1064- {
1065- fuse_reply_err (req, EACCES);
1066- return;
1067- }
1068-
1069- inode->flags |= FUSE_INODE_FLAG_TRUNC;
1070-
1071- memset (&stbuf, 0, sizeof (stbuf));
1072-
1073- fuseInodeStat (d, inode, &stbuf);
1074-
1075- fuse_reply_attr (req, &stbuf, 1.0);
1076- }
1077- else
1078- {
1079- fuse_reply_err (req, ENOENT);
1080- }
1081-}
1082-
1083-static void
1084-compiz_lookup (fuse_req_t req,
1085- fuse_ino_t parent,
1086- const char *name)
1087-{
1088- CompDisplay *d = (CompDisplay *) fuse_req_userdata (req);
1089- FuseInode *inode;
1090- struct fuse_entry_param e;
1091-
1092- inode = fuseFindInode (inodes, parent, DIR_MASK);
1093- if (!inode)
1094- {
1095- fuse_reply_err (req, ENOENT);
1096- return;
1097- }
1098-
1099- if (!inode->child || !(inode->type & CONST_DIR_MASK))
1100- fuseUpdateInode (d, inode);
1101-
1102- inode = fuseLookupChild (inode, name);
1103- if (!inode)
1104- {
1105- fuse_reply_err (req, ENOENT);
1106- return;
1107- }
1108-
1109- memset (&e, 0, sizeof (e));
1110-
1111- e.attr_timeout = 1.0;
1112- e.entry_timeout = 1.0;
1113- e.ino = inode->ino;
1114-
1115- fuseInodeStat (d, inode, &e.attr);
1116-
1117- fuse_reply_entry (req, &e);
1118-}
1119-
1120-struct dirbuf {
1121- char *p;
1122- size_t size;
1123-};
1124-
1125-static void
1126-dirbuf_add (fuse_req_t req,
1127- struct dirbuf *b,
1128- const char *name,
1129- fuse_ino_t ino)
1130-{
1131- struct stat stbuf;
1132- size_t oldSize = b->size;
1133-
1134- b->size += fuse_add_direntry (req, NULL, 0, name, NULL, 0);
1135- b->p = (char *) realloc (b->p, b->size);
1136-
1137- memset (&stbuf, 0, sizeof (stbuf));
1138-
1139- stbuf.st_ino = ino;
1140-
1141- fuse_add_direntry (req, b->p + oldSize, b->size - oldSize, name, &stbuf,
1142- b->size);
1143-}
1144-
1145-static int
1146-reply_buf_limited (fuse_req_t req,
1147- const char *buf,
1148- size_t bufsize,
1149- off_t off,
1150- size_t maxsize)
1151-{
1152- if (off < bufsize)
1153- return fuse_reply_buf (req, buf + off, MIN (bufsize - off, maxsize));
1154- else
1155- return fuse_reply_buf (req, NULL, 0);
1156-}
1157-
1158-static void
1159-compiz_readdir (fuse_req_t req,
1160- fuse_ino_t ino,
1161- size_t size,
1162- off_t off,
1163- struct fuse_file_info *fi)
1164-{
1165- CompDisplay *d = (CompDisplay *) fuse_req_userdata (req);
1166- FuseInode *inode, *c;
1167- struct dirbuf b;
1168-
1169- inode = fuseFindInode (inodes, ino, DIR_MASK);
1170- if (!inode)
1171- {
1172- fuse_reply_err (req, ENOTDIR);
1173- return;
1174- }
1175-
1176- memset (&b, 0, sizeof (b));
1177-
1178- dirbuf_add (req, &b, ".", ino);
1179- dirbuf_add (req, &b, "..", inode->parent ? inode->parent->ino : ino);
1180-
1181- if (!inode->child || !(inode->type & CONST_DIR_MASK))
1182- fuseUpdateInode (d, inode);
1183-
1184- for (c = inode->child; c; c = c->sibling)
1185- dirbuf_add (req, &b, c->name, c->ino);
1186-
1187- reply_buf_limited (req, b.p, b.size, off, size);
1188-
1189- free (b.p);
1190-}
1191-
1192-static void
1193-compiz_open (fuse_req_t req,
1194- fuse_ino_t ino,
1195- struct fuse_file_info *fi)
1196-{
1197- FuseInode *inode;
1198-
1199- inode = fuseFindInode (inodes, ino, ~0);
1200- if (!inode)
1201- {
1202- fuse_reply_err (req, ENOENT);
1203- return;
1204- }
1205-
1206- fi->fh = 0;
1207-
1208- if (inode->type & DIR_MASK)
1209- {
1210- fuse_reply_err (req, EISDIR);
1211- }
1212- else if (inode->type & WRITE_MASK)
1213- {
1214- if ((fi->flags & 3) != O_RDONLY)
1215- {
1216- char *data;
1217-
1218- if (fi->flags & O_TRUNC)
1219- data = strdup ("");
1220- else
1221- data = fuseGetStringFromInode (inode);
1222-
1223- if (data)
1224- {
1225- FuseWriteBuffer *wb;
1226-
1227- wb = malloc (sizeof (FuseWriteBuffer));
1228- if (wb)
1229- {
1230- wb->data = data;
1231- wb->size = strlen (wb->data);
1232- wb->dirty = TRUE;
1233-
1234- fi->fh = (unsigned long) wb;
1235- }
1236- else
1237- {
1238- free (data);
1239- }
1240- }
1241- }
1242-
1243- fuse_reply_open (req, fi);
1244- }
1245- else if ((fi->flags & 3) != O_RDONLY)
1246- {
1247- fuse_reply_err (req, EACCES);
1248- }
1249- else
1250- {
1251- fuse_reply_open (req, fi);
1252- }
1253-}
1254-
1255-static void
1256-compiz_read (fuse_req_t req,
1257- fuse_ino_t ino,
1258- size_t size,
1259- off_t off,
1260- struct fuse_file_info *fi)
1261-{
1262- FuseInode *inode;
1263- char *str = NULL;
1264-
1265- inode = fuseFindInode (inodes, ino, ~0);
1266- if (inode)
1267- str = fuseGetStringFromInode (inode);
1268-
1269- if (str)
1270- {
1271- reply_buf_limited (req, str, strlen (str), off, size);
1272- free (str);
1273- }
1274- else
1275- {
1276- reply_buf_limited (req, NULL, 0, off, size);
1277- }
1278-}
1279-
1280-static void
1281-compiz_write (fuse_req_t req,
1282- fuse_ino_t ino,
1283- const char *buf,
1284- size_t size,
1285- off_t off,
1286- struct fuse_file_info *fi)
1287-{
1288- FuseInode *inode;
1289-
1290- inode = fuseFindInode (inodes, ino, WRITE_MASK);
1291- if (inode && fi->fh)
1292- {
1293- FuseWriteBuffer *wb = (FuseWriteBuffer *) (uintptr_t) fi->fh;
1294-
1295- if (off + size > wb->size)
1296- {
1297- char *data;
1298-
1299- data = realloc (wb->data, off + size + 1);
1300- if (!data)
1301- {
1302- fuse_reply_err (req, ENOBUFS);
1303- return;
1304- }
1305-
1306- data[off + size] = '\0';
1307-
1308- wb->data = data;
1309- wb->size = off + size;
1310- }
1311-
1312- memcpy (wb->data + off, buf, size);
1313-
1314- wb->dirty = TRUE;
1315-
1316- fuse_reply_write (req, size);
1317- }
1318- else
1319- {
1320- fuse_reply_err (req, ENOENT);
1321- }
1322-}
1323-
1324-static void
1325-compiz_release (fuse_req_t req,
1326- fuse_ino_t ino,
1327- struct fuse_file_info *fi)
1328-{
1329- if (fi->fh)
1330- {
1331- FuseWriteBuffer *wb = (FuseWriteBuffer *) (uintptr_t) fi->fh;
1332- FuseInode *inode;
1333-
1334- inode = fuseFindInode (inodes, ino, WRITE_MASK);
1335- if (inode && wb->dirty)
1336- {
1337- fuseSetInodeOptionUsingString (inode, wb->data);
1338-
1339- inode->flags &= ~FUSE_INODE_FLAG_TRUNC;
1340- }
1341-
1342- free (wb->data);
1343- free (wb);
1344- }
1345-
1346- fuse_reply_err (req, 0);
1347-}
1348-
1349-static void
1350-compiz_fsync (fuse_req_t req,
1351- fuse_ino_t ino,
1352- int datasync,
1353- struct fuse_file_info *fi)
1354-{
1355- if (fi->fh)
1356- {
1357- FuseWriteBuffer *wb = (FuseWriteBuffer *) (uintptr_t) fi->fh;
1358- FuseInode *inode;
1359-
1360- inode = fuseFindInode (inodes, ino, WRITE_MASK);
1361- if (inode && wb->dirty)
1362- {
1363- fuseSetInodeOptionUsingString (inode, wb->data);
1364-
1365- inode->flags &= ~FUSE_INODE_FLAG_TRUNC;
1366-
1367- wb->dirty = FALSE;
1368- }
1369- }
1370-
1371- fuse_reply_err (req, 0);
1372-}
1373-
1374-static struct fuse_lowlevel_ops compiz_ll_oper = {
1375- .lookup = compiz_lookup,
1376- .getattr = compiz_getattr,
1377- .setattr = compiz_setattr,
1378- .readdir = compiz_readdir,
1379- .open = compiz_open,
1380- .read = compiz_read,
1381- .write = compiz_write,
1382- .release = compiz_release,
1383- .fsync = compiz_fsync
1384-};
1385-
1386-static void
1387-fuseUnmount (CompDisplay *d)
1388-{
1389- FUSE_DISPLAY (d);
1390-
1391- if (fd->watchFdHandle)
1392- {
1393- compRemoveWatchFd (fd->watchFdHandle);
1394- fd->watchFdHandle = 0;
1395- }
1396-
1397- if (fd->mountPoint)
1398- {
1399- /* unmount will destroy the channel */
1400- fuse_unmount (fd->mountPoint, fd->channel);
1401- free (fd->mountPoint);
1402- fd->mountPoint = NULL;
1403- fd->channel = NULL;
1404- }
1405-
1406- if (fd->buffer)
1407- {
1408- free (fd->buffer);
1409- fd->buffer = NULL;
1410- }
1411-}
1412-
1413-static Bool
1414-fuseProcessMessages (void *data)
1415-{
1416- CompDisplay *d = (CompDisplay *) data;
1417- struct fuse_chan *channel;
1418- size_t bufferSize;
1419- int res = 0;
1420-
1421- FUSE_DISPLAY (d);
1422-
1423- channel = fuse_session_next_chan (fd->session, NULL);
1424- bufferSize = fuse_chan_bufsize (channel);
1425-
1426- if (fuse_session_exited (fd->session))
1427- return FALSE;
1428-
1429- for (;;)
1430- {
1431- struct fuse_chan *tmpch = channel;
1432-
1433- res = fuse_chan_recv (&tmpch, fd->buffer, bufferSize);
1434- if (res == -EINTR)
1435- continue;
1436-
1437- if (res > 0)
1438- fuse_session_process (fd->session, fd->buffer, res, tmpch);
1439-
1440- break;
1441- }
1442-
1443- return TRUE;
1444-}
1445-
1446-static void
1447-fuseMount (CompDisplay *d)
1448-{
1449- char *mountPoint;
1450- struct fuse_args args = FUSE_ARGS_INIT (0, NULL);
1451-
1452- FUSE_DISPLAY (d);
1453-
1454- mountPoint = strdup (fd->opt[FUSE_DISPLAY_OPTION_MOUNT_POINT].value.s);
1455- if (!mountPoint)
1456- return;
1457-
1458- fuse_opt_add_arg (&args, "");
1459- fuse_opt_add_arg (&args, "-o");
1460- fuse_opt_add_arg (&args, "allow_root");
1461-
1462- fd->channel = fuse_mount (mountPoint, &args);
1463- if (!fd->channel)
1464- {
1465- fuse_opt_free_args (&args);
1466- free (mountPoint);
1467- return;
1468- }
1469-
1470- fuse_opt_free_args (&args);
1471-
1472- fd->buffer = malloc (fuse_chan_bufsize (fd->channel));
1473- if (!fd->buffer)
1474- {
1475- fuse_unmount (mountPoint, fd->channel);
1476- free (mountPoint);
1477- fd->channel = NULL;
1478- return;
1479- }
1480-
1481- fd->mountPoint = mountPoint;
1482-
1483- fuse_session_add_chan (fd->session, fd->channel);
1484-
1485- fd->watchFdHandle = compAddWatchFd (fuse_chan_fd (fd->channel),
1486- POLLIN | POLLPRI | POLLHUP | POLLERR,
1487- fuseProcessMessages,
1488- d);
1489-}
1490-
1491-static CompOption *
1492-fuseGetDisplayOptions (CompPlugin *plugin,
1493- CompDisplay *display,
1494- int *count)
1495-{
1496- FUSE_DISPLAY (display);
1497-
1498- *count = NUM_OPTIONS (fd);
1499- return fd->opt;
1500-}
1501-
1502-static Bool
1503-fuseSetDisplayOption (CompPlugin *plugin,
1504- CompDisplay *display,
1505- const char *name,
1506- CompOptionValue *value)
1507-{
1508- CompOption *o;
1509- int index;
1510-
1511- FUSE_DISPLAY (display);
1512-
1513- o = compFindOption (fd->opt, NUM_OPTIONS (fd), name, &index);
1514- if (!o)
1515- return FALSE;
1516-
1517- switch (index) {
1518- case FUSE_DISPLAY_OPTION_MOUNT_POINT:
1519- if (compSetStringOption (o, value))
1520- {
1521- fuseUnmount (display);
1522- fuseMount (display);
1523- return TRUE;
1524- }
1525- default:
1526- break;
1527- }
1528-
1529- return FALSE;
1530-}
1531-
1532-static const CompMetadataOptionInfo fuseDisplayOptionInfo[] = {
1533- { "mount_point", "string", 0, 0, 0 }
1534-};
1535-
1536-static Bool
1537-fuseInitDisplay (CompPlugin *p,
1538- CompDisplay *d)
1539-{
1540- FuseDisplay *fd;
1541- struct sigaction sa;
1542-
1543- if (!checkPluginABI ("core", CORE_ABIVERSION))
1544- return FALSE;
1545-
1546- memset (&sa, 0, sizeof (struct sigaction));
1547-
1548- sa.sa_handler = SIG_IGN;
1549- sigemptyset (&sa.sa_mask);
1550- sa.sa_flags = 0;
1551-
1552- if (sigaction (SIGPIPE, &sa, NULL) == -1)
1553- return FALSE;
1554-
1555- fd = malloc (sizeof (FuseDisplay));
1556- if (!fd)
1557- return FALSE;
1558-
1559- if (!compInitDisplayOptionsFromMetadata (d,
1560- &fuseMetadata,
1561- fuseDisplayOptionInfo,
1562- fd->opt,
1563- FUSE_DISPLAY_OPTION_NUM))
1564- {
1565- free (fd);
1566- return FALSE;
1567- }
1568-
1569- fd->session = fuse_lowlevel_new (NULL,
1570- &compiz_ll_oper, sizeof (compiz_ll_oper),
1571- (void *) d);
1572- if (!fd->session)
1573- {
1574- compFiniDisplayOptions (d, fd->opt, FUSE_DISPLAY_OPTION_NUM);
1575- free (fd);
1576- return FALSE;
1577- }
1578-
1579- fd->watchFdHandle = 0;
1580- fd->channel = NULL;
1581- fd->buffer = NULL;
1582- fd->mountPoint = NULL;
1583-
1584- d->base.privates[displayPrivateIndex].ptr = fd;
1585-
1586- fuseMount (d);
1587-
1588- return TRUE;
1589-}
1590-
1591-static void
1592-fuseFiniDisplay (CompPlugin *p,
1593- CompDisplay *d)
1594-{
1595- FUSE_DISPLAY (d);
1596-
1597- fuseUnmount (d);
1598-
1599- fuse_session_destroy (fd->session);
1600-
1601- compFiniDisplayOptions (d, fd->opt, FUSE_DISPLAY_OPTION_NUM);
1602-
1603- free (fd);
1604-}
1605-
1606-static Bool
1607-fuseInit (CompPlugin *p)
1608-{
1609- if (!compInitPluginMetadataFromInfo (&fuseMetadata,
1610- p->vTable->name,
1611- fuseDisplayOptionInfo,
1612- FUSE_DISPLAY_OPTION_NUM,
1613- 0, 0))
1614- return FALSE;
1615-
1616- inodes = fuseAddInode (NULL, FUSE_INODE_TYPE_ROOT, ".");
1617- if (!inodes)
1618- {
1619- compFiniMetadata (&fuseMetadata);
1620- return FALSE;
1621- }
1622-
1623- displayPrivateIndex = allocateDisplayPrivateIndex ();
1624- if (displayPrivateIndex < 0)
1625- {
1626- fuseRemoveInode (NULL, inodes);
1627- compFiniMetadata (&fuseMetadata);
1628- return FALSE;
1629- }
1630-
1631- compAddMetadataFromFile (&fuseMetadata, p->vTable->name);
1632-
1633- return TRUE;
1634-}
1635-
1636-static CompBool
1637-fuseInitObject (CompPlugin *p,
1638- CompObject *o)
1639-{
1640- static InitPluginObjectProc dispTab[] = {
1641- (InitPluginObjectProc) 0, /* InitCore */
1642- (InitPluginObjectProc) fuseInitDisplay
1643- };
1644-
1645- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
1646-}
1647-
1648-static void
1649-fuseFiniObject (CompPlugin *p,
1650- CompObject *o)
1651-{
1652- static FiniPluginObjectProc dispTab[] = {
1653- (FiniPluginObjectProc) 0, /* FiniCore */
1654- (FiniPluginObjectProc) fuseFiniDisplay
1655- };
1656-
1657- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
1658-}
1659-
1660-static CompOption *
1661-fuseGetObjectOptions (CompPlugin *plugin,
1662- CompObject *object,
1663- int *count)
1664-{
1665- static GetPluginObjectOptionsProc dispTab[] = {
1666- (GetPluginObjectOptionsProc) 0, /* GetCoreOptions */
1667- (GetPluginObjectOptionsProc) fuseGetDisplayOptions
1668- };
1669-
1670- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
1671- (void *) (*count = 0), (plugin, object, count));
1672-}
1673-
1674-static CompBool
1675-fuseSetObjectOption (CompPlugin *plugin,
1676- CompObject *object,
1677- const char *name,
1678- CompOptionValue *value)
1679-{
1680- static SetPluginObjectOptionProc dispTab[] = {
1681- (SetPluginObjectOptionProc) 0, /* SetCoreOption */
1682- (SetPluginObjectOptionProc) fuseSetDisplayOption
1683- };
1684-
1685- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), FALSE,
1686- (plugin, object, name, value));
1687-}
1688-
1689-static void
1690-fuseFini (CompPlugin *p)
1691-{
1692- fuseRemoveInode (NULL, inodes);
1693- freeDisplayPrivateIndex (displayPrivateIndex);
1694- compFiniMetadata (&fuseMetadata);
1695-}
1696-
1697-static CompMetadata *
1698-fuseGetMetadata (CompPlugin *plugin)
1699-{
1700- return &fuseMetadata;
1701-}
1702-
1703-CompPluginVTable fuseVTable = {
1704- "fs",
1705- fuseGetMetadata,
1706- fuseInit,
1707- fuseFini,
1708- fuseInitObject,
1709- fuseFiniObject,
1710- fuseGetObjectOptions,
1711- fuseSetObjectOption
1712-};
1713-
1714-CompPluginVTable *
1715-getCompPluginInfo20070830 (void)
1716-{
1717- return &fuseVTable;
1718-}
1719
1720=== removed file 'legacy/gconf.cpp'
1721--- legacy/gconf.cpp 2009-03-15 05:15:26 +0000
1722+++ legacy/gconf.cpp 1970-01-01 00:00:00 +0000
1723@@ -1,848 +0,0 @@
1724-/*
1725- * Copyright © 2005 Novell, Inc.
1726- *
1727- * Permission to use, copy, modify, distribute, and sell this software
1728- * and its documentation for any purpose is hereby granted without
1729- * fee, provided that the above copyright notice appear in all copies
1730- * and that both that copyright notice and this permission notice
1731- * appear in supporting documentation, and that the name of
1732- * Novell, Inc. not be used in advertising or publicity pertaining to
1733- * distribution of the software without specific, written prior permission.
1734- * Novell, Inc. makes no representations about the suitability of this
1735- * software for any purpose. It is provided "as is" without express or
1736- * implied warranty.
1737- *
1738- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1739- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1740- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1741- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1742- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1743- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1744- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1745- *
1746- * Author: David Reveman <davidr@novell.com>
1747- */
1748-
1749-#define _GNU_SOURCE
1750-#include <string.h>
1751-#include <stdio.h>
1752-#include <stdlib.h>
1753-#include <ctype.h>
1754-
1755-#include <glib.h>
1756-#include <glib/gprintf.h>
1757-#include <gconf/gconf-client.h>
1758-
1759-#include <compiz-core.h>
1760-
1761-static CompMetadata gconfMetadata;
1762-
1763-#define APP_NAME "compiz"
1764-
1765-/* From gconf-internal.h. Bleah. */
1766-int gconf_value_compare (const GConfValue *value_a,
1767- const GConfValue *value_b);
1768-
1769-static int corePrivateIndex;
1770-
1771-typedef struct _GConfCore {
1772- GConfClient *client;
1773- guint cnxn;
1774-
1775- CompTimeoutHandle reloadHandle;
1776-
1777- InitPluginForObjectProc initPluginForObject;
1778- SetOptionForPluginProc setOptionForPlugin;
1779-} GConfCore;
1780-
1781-#define GET_GCONF_CORE(c) \
1782- ((GConfCore *) (c)->base.privates[corePrivateIndex].ptr)
1783-
1784-#define GCONF_CORE(c) \
1785- GConfCore *gc = GET_GCONF_CORE (c)
1786-
1787-
1788-static gchar *
1789-gconfGetKey (CompObject *object,
1790- const gchar *plugin,
1791- const gchar *option)
1792-{
1793- const gchar *type;
1794- gchar *key, *name, *objectName;
1795-
1796- type = compObjectTypeName (object->type);
1797- if (strcmp (type, "display") == 0)
1798- type = "allscreens";
1799-
1800- name = compObjectName (object);
1801- if (name)
1802- {
1803- objectName = g_strdup_printf ("%s%s", type, name);
1804- free (name);
1805- }
1806- else
1807- objectName = g_strdup (type);
1808-
1809- if (strcmp (plugin, "core") == 0)
1810- key = g_strjoin ("/", "/apps", APP_NAME, "general", objectName,
1811- "options", option, NULL);
1812- else
1813- key = g_strjoin ("/", "/apps", APP_NAME, "plugins", plugin, objectName,
1814- "options", option, NULL);
1815-
1816- g_free (objectName);
1817-
1818- return key;
1819-}
1820-
1821-static GConfValueType
1822-gconfTypeFromCompType (CompOptionType type)
1823-{
1824- switch (type) {
1825- case CompOptionTypeBool:
1826- case CompOptionTypeBell:
1827- return GCONF_VALUE_BOOL;
1828- case CompOptionTypeInt:
1829- return GCONF_VALUE_INT;
1830- case CompOptionTypeFloat:
1831- return GCONF_VALUE_FLOAT;
1832- case CompOptionTypeString:
1833- case CompOptionTypeColor:
1834- case CompOptionTypeKey:
1835- case CompOptionTypeButton:
1836- case CompOptionTypeEdge:
1837- case CompOptionTypeMatch:
1838- return GCONF_VALUE_STRING;
1839- case CompOptionTypeList:
1840- return GCONF_VALUE_LIST;
1841- default:
1842- break;
1843- }
1844-
1845- return GCONF_VALUE_INVALID;
1846-}
1847-
1848-static void
1849-gconfSetValue (CompObject *object,
1850- CompOptionValue *value,
1851- CompOptionType type,
1852- GConfValue *gvalue)
1853-{
1854- switch (type) {
1855- case CompOptionTypeBool:
1856- gconf_value_set_bool (gvalue, value->b);
1857- break;
1858- case CompOptionTypeInt:
1859- gconf_value_set_int (gvalue, value->i);
1860- break;
1861- case CompOptionTypeFloat:
1862- gconf_value_set_float (gvalue, value->f);
1863- break;
1864- case CompOptionTypeString:
1865- gconf_value_set_string (gvalue, value->s);
1866- break;
1867- case CompOptionTypeColor: {
1868- gchar *color;
1869-
1870- color = colorToString (value->c);
1871- gconf_value_set_string (gvalue, color);
1872-
1873- free (color);
1874- } break;
1875- case CompOptionTypeKey: {
1876- gchar *action;
1877-
1878- while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
1879- object = object->parent;
1880-
1881- if (!object)
1882- return;
1883-
1884- action = keyActionToString (GET_CORE_DISPLAY (object), &value->action);
1885- gconf_value_set_string (gvalue, action);
1886-
1887- free (action);
1888- } break;
1889- case CompOptionTypeButton: {
1890- gchar *action;
1891-
1892- while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
1893- object = object->parent;
1894-
1895- if (!object)
1896- return;
1897-
1898- action = buttonActionToString (GET_CORE_DISPLAY (object),
1899- &value->action);
1900- gconf_value_set_string (gvalue, action);
1901-
1902- free (action);
1903- } break;
1904- case CompOptionTypeEdge: {
1905- gchar *edge;
1906-
1907- edge = edgeMaskToString (value->action.edgeMask);
1908- gconf_value_set_string (gvalue, edge);
1909-
1910- free (edge);
1911- } break;
1912- case CompOptionTypeBell:
1913- gconf_value_set_bool (gvalue, value->action.bell);
1914- break;
1915- case CompOptionTypeMatch: {
1916- gchar *match;
1917-
1918- match = matchToString (&value->match);
1919- gconf_value_set_string (gvalue, match);
1920-
1921- free (match);
1922- } break;
1923- default:
1924- break;
1925- }
1926-}
1927-
1928-static void
1929-gconfSetOption (CompObject *object,
1930- CompOption *o,
1931- const gchar *plugin)
1932-{
1933- GConfValueType type = gconfTypeFromCompType (o->type);
1934- GConfValue *gvalue, *existingValue = NULL;
1935- gchar *key;
1936-
1937- GCONF_CORE (&core);
1938-
1939- if (type == GCONF_VALUE_INVALID)
1940- return;
1941-
1942- key = gconfGetKey (object, plugin, o->name);
1943-
1944- existingValue = gconf_client_get (gc->client, key, NULL);
1945- gvalue = gconf_value_new (type);
1946-
1947- if (o->type == CompOptionTypeList)
1948- {
1949- GSList *node, *list = NULL;
1950- GConfValue *gv;
1951- int i;
1952-
1953- type = gconfTypeFromCompType (o->value.list.type);
1954-
1955- for (i = 0; i < o->value.list.nValue; i++)
1956- {
1957- gv = gconf_value_new (type);
1958- gconfSetValue (object, &o->value.list.value[i],
1959- o->value.list.type, gv);
1960- list = g_slist_append (list, gv);
1961- }
1962-
1963- gconf_value_set_list_type (gvalue, type);
1964- gconf_value_set_list (gvalue, list);
1965-
1966- if (!existingValue || gconf_value_compare (existingValue, gvalue))
1967- gconf_client_set (gc->client, key, gvalue, NULL);
1968-
1969- for (node = list; node; node = node->next)
1970- gconf_value_free ((GConfValue *) node->data);
1971-
1972- g_slist_free (list);
1973- }
1974- else
1975- {
1976- gconfSetValue (object, &o->value, o->type, gvalue);
1977-
1978- if (!existingValue || gconf_value_compare (existingValue, gvalue))
1979- gconf_client_set (gc->client, key, gvalue, NULL);
1980- }
1981-
1982- gconf_value_free (gvalue);
1983-
1984- if (existingValue)
1985- gconf_value_free (existingValue);
1986-
1987- g_free (key);
1988-}
1989-
1990-static Bool
1991-gconfGetValue (CompObject *object,
1992- CompOptionValue *value,
1993- CompOptionType type,
1994- GConfValue *gvalue)
1995-
1996-{
1997- if (type == CompOptionTypeBool &&
1998- gvalue->type == GCONF_VALUE_BOOL)
1999- {
2000- value->b = gconf_value_get_bool (gvalue);
2001- return TRUE;
2002- }
2003- else if (type == CompOptionTypeInt &&
2004- gvalue->type == GCONF_VALUE_INT)
2005- {
2006- value->i = gconf_value_get_int (gvalue);
2007- return TRUE;
2008- }
2009- else if (type == CompOptionTypeFloat &&
2010- gvalue->type == GCONF_VALUE_FLOAT)
2011- {
2012- value->f = gconf_value_get_float (gvalue);
2013- return TRUE;
2014- }
2015- else if (type == CompOptionTypeString &&
2016- gvalue->type == GCONF_VALUE_STRING)
2017- {
2018- const char *str;
2019-
2020- str = gconf_value_get_string (gvalue);
2021- if (str)
2022- {
2023- value->s = strdup (str);
2024- if (value->s)
2025- return TRUE;
2026- }
2027- }
2028- else if (type == CompOptionTypeColor &&
2029- gvalue->type == GCONF_VALUE_STRING)
2030- {
2031- const gchar *color;
2032-
2033- color = gconf_value_get_string (gvalue);
2034-
2035- if (stringToColor (color, value->c))
2036- return TRUE;
2037- }
2038- else if (type == CompOptionTypeKey &&
2039- gvalue->type == GCONF_VALUE_STRING)
2040- {
2041- const gchar *action;
2042-
2043- action = gconf_value_get_string (gvalue);
2044-
2045- while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
2046- object = object->parent;
2047-
2048- if (!object)
2049- return FALSE;
2050-
2051- stringToKeyAction (GET_CORE_DISPLAY (object), action, &value->action);
2052- return TRUE;
2053- }
2054- else if (type == CompOptionTypeButton &&
2055- gvalue->type == GCONF_VALUE_STRING)
2056- {
2057- const gchar *action;
2058-
2059- action = gconf_value_get_string (gvalue);
2060-
2061- while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
2062- object = object->parent;
2063-
2064- if (!object)
2065- return FALSE;
2066-
2067- stringToButtonAction (GET_CORE_DISPLAY (object), action,
2068- &value->action);
2069- return TRUE;
2070- }
2071- else if (type == CompOptionTypeEdge &&
2072- gvalue->type == GCONF_VALUE_STRING)
2073- {
2074- const gchar *edge;
2075-
2076- edge = gconf_value_get_string (gvalue);
2077-
2078- value->action.edgeMask = stringToEdgeMask (edge);
2079- return TRUE;
2080- }
2081- else if (type == CompOptionTypeBell &&
2082- gvalue->type == GCONF_VALUE_BOOL)
2083- {
2084- value->action.bell = gconf_value_get_bool (gvalue);
2085- return TRUE;
2086- }
2087- else if (type == CompOptionTypeMatch &&
2088- gvalue->type == GCONF_VALUE_STRING)
2089- {
2090- const gchar *match;
2091-
2092- match = gconf_value_get_string (gvalue);
2093-
2094- matchInit (&value->match);
2095- matchAddFromString (&value->match, match);
2096- return TRUE;
2097- }
2098-
2099- return FALSE;
2100-}
2101-
2102-static Bool
2103-gconfReadOptionValue (CompObject *object,
2104- GConfEntry *entry,
2105- CompOption *o,
2106- CompOptionValue *value)
2107-{
2108- GConfValue *gvalue;
2109-
2110- gvalue = gconf_entry_get_value (entry);
2111- if (!gvalue)
2112- return FALSE;
2113-
2114- compInitOptionValue (value);
2115-
2116- if (o->type == CompOptionTypeList &&
2117- gvalue->type == GCONF_VALUE_LIST)
2118- {
2119- GConfValueType type;
2120- GSList *list;
2121- int i, n;
2122-
2123- type = gconf_value_get_list_type (gvalue);
2124- if (gconfTypeFromCompType (o->value.list.type) != type)
2125- return FALSE;
2126-
2127- list = gconf_value_get_list (gvalue);
2128- n = g_slist_length (list);
2129-
2130- value->list.value = NULL;
2131- value->list.nValue = 0;
2132- value->list.type = o->value.list.type;
2133-
2134- if (n)
2135- {
2136- value->list.value = (CompOptionValue *) malloc (sizeof (CompOptionValue) * n);
2137- if (value->list.value)
2138- {
2139- for (i = 0; i < n; i++)
2140- {
2141- if (!gconfGetValue (object,
2142- &value->list.value[i],
2143- o->value.list.type,
2144- (GConfValue *) list->data))
2145- break;
2146-
2147- value->list.nValue++;
2148-
2149- list = g_slist_next (list);
2150- }
2151-
2152- if (value->list.nValue != n)
2153- {
2154- compFiniOptionValue (value, o->type);
2155- return FALSE;
2156- }
2157- }
2158- }
2159- }
2160- else
2161- {
2162- if (!gconfGetValue (object, value, o->type, gvalue))
2163- return FALSE;
2164- }
2165-
2166- return TRUE;
2167-}
2168-
2169-static void
2170-gconfGetOption (CompObject *object,
2171- CompOption *o,
2172- const char *plugin)
2173-{
2174- GConfEntry *entry;
2175- gchar *key;
2176-
2177- GCONF_CORE (&core);
2178-
2179- key = gconfGetKey (object, plugin, o->name);
2180-
2181- entry = gconf_client_get_entry (gc->client, key, NULL, TRUE, NULL);
2182- if (entry)
2183- {
2184- CompOptionValue value;
2185-
2186- if (gconfReadOptionValue (object, entry, o, &value))
2187- {
2188- (*core.setOptionForPlugin) (object, plugin, o->name, &value);
2189- compFiniOptionValue (&value, o->type);
2190- }
2191- else
2192- {
2193- gconfSetOption (object, o, plugin);
2194- }
2195-
2196- gconf_entry_free (entry);
2197- }
2198-
2199- g_free (key);
2200-}
2201-
2202-static CompBool
2203-gconfReloadObjectTree (CompObject *object,
2204- void *closure);
2205-
2206-static CompBool
2207-gconfReloadObjectsWithType (CompObjectType type,
2208- CompObject *parent,
2209- void *closure)
2210-{
2211- compObjectForEach (parent, type, gconfReloadObjectTree, closure);
2212-
2213- return TRUE;
2214-}
2215-
2216-static CompBool
2217-gconfReloadObjectTree (CompObject *object,
2218- void *closure)
2219-{
2220- CompPlugin *p = (CompPlugin *) closure;
2221- CompOption *option;
2222- int nOption;
2223-
2224- option = (*p->vTable->getObjectOptions) (p, object, &nOption);
2225- while (nOption--)
2226- gconfGetOption (object, option++, p->vTable->name);
2227-
2228- compObjectForEachType (object, gconfReloadObjectsWithType, closure);
2229-
2230- return TRUE;
2231-}
2232-
2233-static Bool
2234-gconfReload (void *closure)
2235-{
2236- CompPlugin *p;
2237-
2238- GCONF_CORE (&core);
2239-
2240- for (p = getPlugins (); p; p = p->next)
2241- {
2242- if (!p->vTable->getObjectOptions)
2243- continue;
2244-
2245- gconfReloadObjectTree (&core.base, (void *) p);
2246- }
2247-
2248- gc->reloadHandle = 0;
2249-
2250- return FALSE;
2251-}
2252-
2253-static Bool
2254-gconfSetOptionForPlugin (CompObject *object,
2255- const char *plugin,
2256- const char *name,
2257- CompOptionValue *value)
2258-{
2259- CompBool status;
2260-
2261- GCONF_CORE (&core);
2262-
2263- UNWRAP (gc, &core, setOptionForPlugin);
2264- status = (*core.setOptionForPlugin) (object, plugin, name, value);
2265- WRAP (gc, &core, setOptionForPlugin, gconfSetOptionForPlugin);
2266-
2267- if (status && !gc->reloadHandle)
2268- {
2269- CompPlugin *p;
2270-
2271- p = findActivePlugin (plugin);
2272- if (p && p->vTable->getObjectOptions)
2273- {
2274- CompOption *option;
2275- int nOption;
2276-
2277- option = (*p->vTable->getObjectOptions) (p, object, &nOption);
2278- option = compFindOption (option, nOption, name, 0);
2279- if (option)
2280- gconfSetOption (object, option, p->vTable->name);
2281- }
2282- }
2283-
2284- return status;
2285-}
2286-
2287-static CompBool
2288-gconfInitPluginForObject (CompPlugin *p,
2289- CompObject *o)
2290-{
2291- CompBool status;
2292-
2293- GCONF_CORE (&core);
2294-
2295- UNWRAP (gc, &core, initPluginForObject);
2296- status = (*core.initPluginForObject) (p, o);
2297- WRAP (gc, &core, initPluginForObject, gconfInitPluginForObject);
2298-
2299- if (status && p->vTable->getObjectOptions)
2300- {
2301- CompOption *option;
2302- int nOption;
2303-
2304- option = (*p->vTable->getObjectOptions) (p, o, &nOption);
2305- while (nOption--)
2306- gconfGetOption (o, option++, p->vTable->name);
2307- }
2308-
2309- return status;
2310-}
2311-
2312-/* MULTIDPYERROR: only works with one or less displays present */
2313-static void
2314-gconfKeyChanged (GConfClient *client,
2315- guint cnxn_id,
2316- GConfEntry *entry,
2317- gpointer user_data)
2318-{
2319- CompPlugin *plugin;
2320- CompObject *object;
2321- CompOption *option = NULL;
2322- int nOption = 0;
2323- gchar **token;
2324- int objectIndex = 4;
2325-
2326- token = g_strsplit (entry->key, "/", 8);
2327-
2328- if (g_strv_length (token) < 7)
2329- {
2330- g_strfreev (token);
2331- return;
2332- }
2333-
2334- if (strcmp (token[0], "") != 0 ||
2335- strcmp (token[1], "apps") != 0 ||
2336- strcmp (token[2], APP_NAME) != 0)
2337- {
2338- g_strfreev (token);
2339- return;
2340- }
2341-
2342- if (strcmp (token[3], "general") == 0)
2343- {
2344- plugin = findActivePlugin ("core");
2345- }
2346- else
2347- {
2348- if (strcmp (token[3], "plugins") != 0 || g_strv_length (token) < 8)
2349- {
2350- g_strfreev (token);
2351- return;
2352- }
2353-
2354- objectIndex = 5;
2355- plugin = findActivePlugin (token[4]);
2356- }
2357-
2358- if (!plugin)
2359- {
2360- g_strfreev (token);
2361- return;
2362- }
2363-
2364- object = compObjectFind (&core.base, COMP_OBJECT_TYPE_DISPLAY, NULL);
2365- if (!object)
2366- {
2367- g_strfreev (token);
2368- return;
2369- }
2370-
2371- if (strncmp (token[objectIndex], "screen", 6) == 0)
2372- {
2373- object = compObjectFind (object, COMP_OBJECT_TYPE_SCREEN,
2374- token[objectIndex] + 6);
2375- if (!object)
2376- {
2377- g_strfreev (token);
2378- return;
2379- }
2380- }
2381- else if (strcmp (token[objectIndex], "allscreens") != 0)
2382- {
2383- g_strfreev (token);
2384- return;
2385- }
2386-
2387- if (strcmp (token[objectIndex + 1], "options") != 0)
2388- {
2389- g_strfreev (token);
2390- return;
2391- }
2392-
2393- if (plugin->vTable->getObjectOptions)
2394- option = (*plugin->vTable->getObjectOptions) (plugin, object,
2395- &nOption);
2396-
2397- option = compFindOption (option, nOption, token[objectIndex + 2], 0);
2398- if (option)
2399- {
2400- CompOptionValue value;
2401-
2402- if (gconfReadOptionValue (object, entry, option, &value))
2403- {
2404- (*core.setOptionForPlugin) (object,
2405- plugin->vTable->name,
2406- option->name,
2407- &value);
2408-
2409- compFiniOptionValue (&value, option->type);
2410- }
2411- }
2412-
2413- g_strfreev (token);
2414-}
2415-
2416-static void
2417-gconfSendGLibNotify (CompDisplay *d)
2418-{
2419- Display *dpy = d->display;
2420- XEvent xev;
2421-
2422- xev.xclient.type = ClientMessage;
2423- xev.xclient.display = dpy;
2424- xev.xclient.format = 32;
2425-
2426- xev.xclient.message_type = XInternAtom (dpy, "_COMPIZ_GLIB_NOTIFY", 0);
2427- xev.xclient.window = d->screens->root;
2428-
2429- memset (xev.xclient.data.l, 0, sizeof (xev.xclient.data.l));
2430-
2431- XSendEvent (dpy,
2432- d->screens->root,
2433- FALSE,
2434- SubstructureRedirectMask | SubstructureNotifyMask,
2435- &xev);
2436-}
2437-
2438-static Bool
2439-gconfInitCore (CompPlugin *p,
2440- CompCore *c)
2441-{
2442- GConfCore *gc;
2443-
2444- if (!checkPluginABI ("core", CORE_ABIVERSION))
2445- return FALSE;
2446-
2447- gc = (GConfCore *) malloc (sizeof (GConfCore));
2448- if (!gc)
2449- return FALSE;
2450-
2451- g_type_init ();
2452-
2453- gc->client = gconf_client_get_default ();
2454-
2455- gconf_client_add_dir (gc->client, "/apps/" APP_NAME,
2456- GCONF_CLIENT_PRELOAD_NONE, NULL);
2457-
2458- gc->reloadHandle = compAddTimeout (0, 0, gconfReload, 0);
2459-
2460- gc->cnxn = gconf_client_notify_add (gc->client, "/apps/" APP_NAME,
2461- gconfKeyChanged, c, NULL, NULL);
2462-
2463- WRAP (gc, c, initPluginForObject, gconfInitPluginForObject);
2464- WRAP (gc, c, setOptionForPlugin, gconfSetOptionForPlugin);
2465-
2466- c->base.privates[corePrivateIndex].ptr = gc;
2467-
2468- return TRUE;
2469-}
2470-
2471-static void
2472-gconfFiniCore (CompPlugin *p,
2473- CompCore *c)
2474-{
2475- GCONF_CORE (c);
2476-
2477- UNWRAP (gc, c, initPluginForObject);
2478- UNWRAP (gc, c, setOptionForPlugin);
2479-
2480- if (gc->reloadHandle)
2481- compRemoveTimeout (gc->reloadHandle);
2482-
2483- if (gc->cnxn)
2484- gconf_client_notify_remove (gc->client, gc->cnxn);
2485-
2486- gconf_client_remove_dir (gc->client, "/apps/" APP_NAME, NULL);
2487- gconf_client_clear_cache (gc->client);
2488-
2489- free (gc);
2490-}
2491-
2492-static Bool
2493-gconfInitDisplay (CompPlugin *p,
2494- CompDisplay *d)
2495-{
2496- gconfSendGLibNotify (d);
2497-
2498- return TRUE;
2499-}
2500-
2501-static CompBool
2502-gconfInitObject (CompPlugin *p,
2503- CompObject *o)
2504-{
2505- static InitPluginObjectProc dispTab[] = {
2506- (InitPluginObjectProc) gconfInitCore,
2507- (InitPluginObjectProc) gconfInitDisplay
2508- };
2509-
2510- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
2511-}
2512-
2513-static void
2514-gconfFiniObject (CompPlugin *p,
2515- CompObject *o)
2516-{
2517- static FiniPluginObjectProc dispTab[] = {
2518- (FiniPluginObjectProc) gconfFiniCore
2519- };
2520-
2521- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
2522-}
2523-
2524-static Bool
2525-gconfInit (CompPlugin *p)
2526-{
2527- if (!compInitPluginMetadataFromInfo (&gconfMetadata, p->vTable->name,
2528- 0, 0, 0, 0))
2529- return FALSE;
2530-
2531- corePrivateIndex = allocateCorePrivateIndex ();
2532- if (corePrivateIndex < 0)
2533- {
2534- compFiniMetadata (&gconfMetadata);
2535- return FALSE;
2536- }
2537-
2538- compAddMetadataFromFile (&gconfMetadata, p->vTable->name);
2539-
2540- return TRUE;
2541-}
2542-
2543-static void
2544-gconfFini (CompPlugin *p)
2545-{
2546- freeCorePrivateIndex (corePrivateIndex);
2547- compFiniMetadata (&gconfMetadata);
2548-}
2549-
2550-static CompMetadata *
2551-gconfGetMetadata (CompPlugin *plugin)
2552-{
2553- return &gconfMetadata;
2554-}
2555-
2556-CompPluginVTable gconfVTable = {
2557- "gconf",
2558- gconfGetMetadata,
2559- gconfInit,
2560- gconfFini,
2561- gconfInitObject,
2562- gconfFiniObject,
2563- 0, /* GetObjectOptions */
2564- 0 /* SetObjectOption */
2565-};
2566-
2567-CompPluginVTable *
2568-getCompPluginInfo20070830 (void)
2569-{
2570- return &gconfVTable;
2571-}
2572
2573=== removed file 'legacy/gconf.xml.in'
2574--- legacy/gconf.xml.in 2009-03-15 05:15:26 +0000
2575+++ legacy/gconf.xml.in 1970-01-01 00:00:00 +0000
2576@@ -1,18 +0,0 @@
2577-<compiz>
2578- <plugin name="gconf">
2579- <_short>GConf</_short>
2580- <_long>GConf Control Backend</_long>
2581- <deps>
2582- <relation type="after">
2583- <plugin>glib</plugin>
2584- </relation>
2585- <relation type="before">
2586- <plugin>decoration</plugin>
2587- <plugin>wobbly</plugin>
2588- <plugin>fade</plugin>
2589- <plugin>cube</plugin>
2590- <plugin>scale</plugin>
2591- </relation>
2592- </deps>
2593- </plugin>
2594-</compiz>
2595
2596=== removed file 'legacy/metadata.cpp'
2597--- legacy/metadata.cpp 2009-03-15 23:01:28 +0000
2598+++ legacy/metadata.cpp 1970-01-01 00:00:00 +0000
2599@@ -1,1160 +0,0 @@
2600-/*
2601- * Copyright © 2008 Dennis Kasprzyk
2602- * Copyright © 2007 Novell, Inc.
2603- *
2604- * Permission to use, copy, modify, distribute, and sell this software
2605- * and its documentation for any purpose is hereby granted without
2606- * fee, provided that the above copyright notice appear in all copies
2607- * and that both that copyright notice and this permission notice
2608- * appear in supporting documentation, and that the name of
2609- * Dennis Kasprzyk not be used in advertising or publicity pertaining to
2610- * distribution of the software without specific, written prior permission.
2611- * Dennis Kasprzyk makes no representations about the suitability of this
2612- * software for any purpose. It is provided "as is" without express or
2613- * implied warranty.
2614- *
2615- * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2616- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2617- * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2618- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2619- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2620- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2621- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2622- *
2623- * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
2624- * David Reveman <davidr@novell.com>
2625- */
2626-
2627-#include <string.h>
2628-#include <libxml/tree.h>
2629-#include <libxml/xpath.h>
2630-#include <libxml/xpathInternals.h>
2631-#include <locale.h>
2632-
2633-#include <boost/foreach.hpp>
2634-#define foreach BOOST_FOREACH
2635-
2636-#include <compiz.h>
2637-#include <core/metadata.h>
2638-#include <core/screen.h>
2639-#include "privatescreen.h"
2640-#include "privatemetadata.h"
2641-
2642-#define HOME_METADATADIR ".compiz/metadata"
2643-#define EXTENSION ".xml"
2644-
2645-static xmlDoc *
2646-readXmlFile (CompString name,
2647- CompString path = "")
2648-{
2649- CompString file;
2650- xmlDoc *doc = NULL;
2651- FILE *fp;
2652-
2653- if (path.size ())
2654- file = compPrintf ("%s/%s%s", path.c_str (), name.c_str (), EXTENSION);
2655- else
2656- file = compPrintf ("%s%s", name.c_str (), EXTENSION);
2657-
2658- fp = fopen (file.c_str (), "r");
2659- if (!fp)
2660- {
2661- return NULL;
2662- }
2663-
2664- fclose (fp);
2665-
2666- doc = xmlReadFile (file.c_str (), NULL, 0);
2667-
2668- return doc;
2669-}
2670-
2671-typedef struct _CompIOCtx {
2672- unsigned int offset;
2673- const char *name;
2674- const CompMetadata::OptionInfo *oInfo;
2675- unsigned int nOInfo;
2676-} CompIOCtx;
2677-
2678-typedef struct _CompXPath {
2679- xmlXPathObjectPtr obj;
2680- xmlXPathContextPtr ctx;
2681- xmlDocPtr doc;
2682-} CompXPath;
2683-
2684-
2685-static int
2686-readPluginXmlCallback (void *context,
2687- char *buffer,
2688- int length)
2689-{
2690- CompIOCtx *ctx = (CompIOCtx *) context;
2691- unsigned int offset = ctx->offset;
2692- unsigned int i, j;
2693-
2694- i = CompMetadata::readXmlChunk ("<compiz><plugin name=\"", &offset,
2695- buffer, length);
2696- i += CompMetadata::readXmlChunk (ctx->name, &offset, buffer + i,
2697- length - i);
2698- i += CompMetadata::readXmlChunk ("\">", &offset, buffer + i, length - i);
2699-
2700- if (ctx->nOInfo)
2701- {
2702- i += CompMetadata::readXmlChunk ("<options>", &offset, buffer + i,
2703- length - i);
2704-
2705- for (j = 0; j < ctx->nOInfo; j++)
2706- i += CompMetadata::readXmlChunkFromOptionInfo (
2707- &ctx->oInfo[j], &offset, buffer + i, length - i);
2708-
2709- i += CompMetadata::readXmlChunk ("</options>", &offset, buffer + i,
2710- length - i);
2711- }
2712-
2713- i += CompMetadata::readXmlChunk ("</plugin></compiz>", &offset, buffer + i,
2714- length - i);
2715-
2716- if (!offset && length > (int)i)
2717- buffer[i++] = '\0';
2718-
2719- ctx->offset += i;
2720-
2721- return i;
2722-}
2723-
2724-static bool
2725-initXPathFromMetadataPath (CompXPath *xPath,
2726- CompMetadata *metadata,
2727- const xmlChar *path)
2728-{
2729- xmlXPathObjectPtr obj;
2730- xmlXPathContextPtr ctx;
2731-
2732- foreach (xmlDoc *doc, metadata->doc ())
2733- {
2734- ctx = xmlXPathNewContext (doc);
2735- if (ctx)
2736- {
2737- obj = xmlXPathEvalExpression (path, ctx);
2738- if (obj)
2739- {
2740- if (obj->nodesetval && obj->nodesetval->nodeNr)
2741- {
2742- xPath->ctx = ctx;
2743- xPath->obj = obj;
2744- xPath->doc = doc;
2745-
2746- return true;
2747- }
2748-
2749- xmlXPathFreeObject (obj);
2750- }
2751-
2752- xmlXPathFreeContext (ctx);
2753- }
2754- }
2755-
2756- return false;
2757-}
2758-
2759-static bool
2760-initXPathFromMetadataPathElement (CompXPath *xPath,
2761- CompMetadata *metadata,
2762- const xmlChar *path,
2763- const xmlChar *element)
2764-{
2765- char str[1024];
2766-
2767- snprintf (str, 1024, "%s/%s", path, element);
2768-
2769- return initXPathFromMetadataPath (xPath, metadata, BAD_CAST str);
2770-}
2771-
2772-static void
2773-finiXPath (CompXPath *xPath)
2774-{
2775- xmlXPathFreeObject (xPath->obj);
2776- xmlXPathFreeContext (xPath->ctx);
2777-}
2778-
2779-static CompOption::Type
2780-getOptionType (const char *name)
2781-{
2782- static struct _TypeMap {
2783- const char *name;
2784- CompOption::Type type;
2785- } map[] = {
2786- { "int", CompOption::TypeInt },
2787- { "float", CompOption::TypeFloat },
2788- { "string", CompOption::TypeString },
2789- { "color", CompOption::TypeColor },
2790- { "action", CompOption::TypeAction },
2791- { "key", CompOption::TypeKey },
2792- { "button", CompOption::TypeButton },
2793- { "edge", CompOption::TypeEdge },
2794- { "bell", CompOption::TypeBell },
2795- { "match", CompOption::TypeMatch },
2796- { "list", CompOption::TypeList }
2797- };
2798- unsigned int i;
2799-
2800- for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
2801- if (strcasecmp (name, map[i].name) == 0)
2802- return map[i].type;
2803-
2804- return CompOption::TypeBool;
2805-}
2806-
2807-static void
2808-initBoolValue (CompOption::Value &v,
2809- xmlDocPtr doc,
2810- xmlNodePtr node)
2811-{
2812- xmlChar *value;
2813-
2814- v.set (false);
2815-
2816- if (!doc)
2817- return;
2818-
2819- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
2820- if (value)
2821- {
2822- if (strcasecmp ((char *) value, "true") == 0)
2823- v.set (true);
2824-
2825- xmlFree (value);
2826- }
2827-}
2828-
2829-static void
2830-initIntValue (CompOption::Value &v,
2831- CompOption::Restriction &r,
2832- xmlDocPtr doc,
2833- xmlNodePtr node)
2834-{
2835- xmlChar *value;
2836-
2837- v.set ((r.iMin () + r.iMax ()) / 2);
2838-
2839- if (!doc)
2840- return;
2841-
2842- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
2843- if (value)
2844- {
2845- int i = strtol ((char *) value, NULL, 0);
2846-
2847- if (r.inRange (i))
2848- v.set (i);
2849-
2850- xmlFree (value);
2851- }
2852-}
2853-
2854-static void
2855-initFloatValue (CompOption::Value &v,
2856- CompOption::Restriction &r,
2857- xmlDocPtr doc,
2858- xmlNodePtr node)
2859-{
2860- xmlChar *value;
2861- char *loc;
2862-
2863- v.set ((r.fMin () + r.fMax ()) / 2);
2864-
2865- if (!doc)
2866- return;
2867-
2868- loc = setlocale (LC_NUMERIC, NULL);
2869- setlocale (LC_NUMERIC, "C");
2870- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
2871- if (value)
2872- {
2873- float f = strtod ((char *) value, NULL);
2874-
2875- if (r.inRange (f))
2876- v.set (f);
2877-
2878- xmlFree (value);
2879- }
2880- setlocale (LC_NUMERIC, loc);
2881-}
2882-
2883-static void
2884-initStringValue (CompOption::Value &v,
2885- CompOption::Restriction &r,
2886- xmlDocPtr doc,
2887- xmlNodePtr node)
2888-{
2889- xmlChar *value;
2890-
2891- v.set ("");
2892-
2893- if (!doc)
2894- return;
2895-
2896- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
2897- if (value)
2898- {
2899- v.set (CompString ((char *) value));
2900- xmlFree (value);
2901- }
2902-}
2903-
2904-static void
2905-initColorValue (CompOption::Value &v,
2906- xmlDocPtr doc,
2907- xmlNodePtr node)
2908-{
2909- xmlNodePtr child;
2910-
2911- unsigned short c[4] = { 0x0000, 0x0000, 0x0000, 0xffff};
2912- v.set (c);
2913-
2914- if (!doc)
2915- return;
2916-
2917- for (child = node->xmlChildrenNode; child; child = child->next)
2918- {
2919- xmlChar *value;
2920- int index;
2921-
2922- if (!xmlStrcmp (child->name, BAD_CAST "red"))
2923- index = 0;
2924- else if (!xmlStrcmp (child->name, BAD_CAST "green"))
2925- index = 1;
2926- else if (!xmlStrcmp (child->name, BAD_CAST "blue"))
2927- index = 2;
2928- else if (!xmlStrcmp (child->name, BAD_CAST "alpha"))
2929- index = 3;
2930- else
2931- continue;
2932-
2933- value = xmlNodeListGetString (child->doc, child->xmlChildrenNode, 1);
2934- if (value)
2935- {
2936- int color = strtol ((char *) value, NULL , 0);
2937-
2938- c[index] = MAX (0, MIN (0xffff, color));
2939-
2940- xmlFree (value);
2941- }
2942- }
2943- v.set (c);
2944-}
2945-
2946-static void
2947-initActionValue (CompOption::Value &v,
2948- CompAction::State state,
2949- xmlDocPtr doc,
2950- xmlNodePtr node)
2951-{
2952- v.set (CompAction ());
2953- v.action ().setState (state);
2954-}
2955-
2956-static void
2957-initKeyValue (CompOption::Value &v,
2958- CompAction::State state,
2959- xmlDocPtr doc,
2960- xmlNodePtr node)
2961-{
2962- xmlChar *value;
2963- CompAction action;
2964-
2965- action.setState (state | CompAction::StateInitKey);
2966-
2967- if (doc)
2968- {
2969- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
2970- if (value)
2971- {
2972- char *binding = (char *) value;
2973-
2974- if (strcasecmp (binding, "disabled") && *binding)
2975- action.keyFromString (binding);
2976-
2977- xmlFree (value);
2978- }
2979-
2980- v.set (action);
2981-
2982- if (state & CompAction::StateAutoGrab)
2983- screen->addAction (&v.action ());
2984- }
2985- else
2986- v.set (action);
2987-}
2988-
2989-static void
2990-initButtonValue (CompOption::Value &v,
2991- CompAction::State state,
2992- xmlDocPtr doc,
2993- xmlNodePtr node)
2994-{
2995- xmlChar *value;
2996- CompAction action;
2997-
2998- action.setState (state | CompAction::StateInitButton |
2999- CompAction::StateInitEdge);
3000-
3001- if (doc)
3002- {
3003- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
3004- if (value)
3005- {
3006- char *binding = (char *) value;
3007-
3008- if (strcasecmp (binding, "disabled") && *binding)
3009- action.buttonFromString (binding);
3010-
3011- xmlFree (value);
3012- }
3013-
3014- v.set (action);
3015-
3016- if (state & CompAction::StateAutoGrab)
3017- screen->addAction (&v.action ());
3018- }
3019- else
3020- v.set (action);
3021-}
3022-
3023-static void
3024-initEdgeValue (CompOption::Value &v,
3025- CompAction::State state,
3026- xmlDocPtr doc,
3027- xmlNodePtr node)
3028-{
3029- xmlNodePtr child;
3030- xmlChar *value;
3031- CompAction action;
3032- unsigned int edge = 0;
3033-
3034- action.setState (state | CompAction::StateInitEdge);
3035-
3036- if (doc)
3037- {
3038- for (child = node->xmlChildrenNode; child; child = child->next)
3039- {
3040- value = xmlGetProp (child, BAD_CAST "name");
3041- if (value)
3042- {
3043- int i;
3044-
3045- for (i = 0; i < SCREEN_EDGE_NUM; i++)
3046- if (strcasecmp ((char *) value,
3047- CompAction::edgeToString (i).c_str ()) == 0)
3048- edge |= (1 << i);
3049-
3050- xmlFree (value);
3051- }
3052- }
3053-
3054- action.setEdgeMask (edge);
3055- v.set (action);
3056-
3057- if (state & CompAction::StateAutoGrab)
3058- screen->addAction (&v.action ());
3059- }
3060- else
3061- {
3062- action.setEdgeMask (edge);
3063- v.set (action);
3064- }
3065-}
3066-
3067-static void
3068-initBellValue (CompOption::Value &v,
3069- CompAction::State state,
3070- xmlDocPtr doc,
3071- xmlNodePtr node)
3072-{
3073- xmlChar *value;
3074- CompAction action;
3075-
3076- action.setState (state | CompAction::StateInitBell);
3077-
3078- if (doc)
3079- {
3080- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
3081- if (value)
3082- {
3083- if (strcasecmp ((char *) value, "true") == 0)
3084- action.setBell (true);
3085-
3086- xmlFree (value);
3087- }
3088- }
3089- v.set (action);
3090-}
3091-
3092-static void
3093-initMatchValue (CompOption::Value &v,
3094- bool helper,
3095- xmlDocPtr doc,
3096- xmlNodePtr node)
3097-{
3098- xmlChar *value;
3099-
3100- v.set (CompMatch ());
3101-
3102- if (!doc)
3103- return;
3104-
3105- value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
3106- if (value)
3107- {
3108- v.match () = (char *) value;
3109- xmlFree (value);
3110- }
3111-
3112- if (!helper)
3113- v.match ().update ();
3114-}
3115-
3116-static void
3117-initListValue (CompOption::Value &v,
3118- CompOption::Restriction &r,
3119- CompAction::State state,
3120- bool helper,
3121- xmlDocPtr doc,
3122- xmlNodePtr node)
3123-{
3124- xmlNodePtr child;
3125-
3126- v.list ().clear ();
3127-
3128- if (!doc)
3129- return;
3130-
3131- for (child = node->xmlChildrenNode; child; child = child->next)
3132- {
3133- CompOption::Value value;
3134-
3135- if (xmlStrcmp (child->name, BAD_CAST "value"))
3136- continue;
3137-
3138- switch (v.listType ()) {
3139- case CompOption::TypeBool:
3140- initBoolValue (value, doc, child);
3141- break;
3142- case CompOption::TypeInt:
3143- initIntValue (value, r, doc, child);
3144- break;
3145- case CompOption::TypeFloat:
3146- initFloatValue (value, r, doc, child);
3147- break;
3148- case CompOption::TypeString:
3149- initStringValue (value, r, doc, child);
3150- break;
3151- case CompOption::TypeColor:
3152- initColorValue (value, doc, child);
3153- break;
3154- case CompOption::TypeAction:
3155- initActionValue (value, state, doc, child);
3156- break;
3157- case CompOption::TypeKey:
3158- initKeyValue (value, state, doc, child);
3159- break;
3160- case CompOption::TypeButton:
3161- initButtonValue (value, state, doc, child);
3162- break;
3163- case CompOption::TypeEdge:
3164- initEdgeValue (value, state, doc, child);
3165- break;
3166- case CompOption::TypeBell:
3167- initBellValue (value, state, doc, child);
3168- break;
3169- case CompOption::TypeMatch:
3170- initMatchValue (value, helper, doc, child);
3171- default:
3172- break;
3173- }
3174-
3175- v.list ().push_back (value);
3176- }
3177-}
3178-
3179-static CompString
3180-stringFromMetadataPathElement (CompMetadata *metadata,
3181- const char *path,
3182- const char *element)
3183-{
3184- return metadata->getStringFromPath (compPrintf ("%s/%s", path, element));
3185-}
3186-
3187-static Bool
3188-boolFromMetadataPathElement (CompMetadata *metadata,
3189- const char *path,
3190- const char *element,
3191- Bool defaultValue)
3192-{
3193- Bool value = FALSE;
3194- CompString str;
3195-
3196- str = stringFromMetadataPathElement (metadata, path, element);
3197-
3198- if (strcasecmp (str.c_str (), "true") == 0)
3199- value = TRUE;
3200-
3201- return value;
3202-}
3203-
3204-static void
3205-initIntRestriction (CompMetadata *metadata,
3206- CompOption::Restriction &r,
3207- const char *path)
3208-{
3209- CompString value;
3210- int min = MINSHORT, max = MAXSHORT;
3211-
3212- value = stringFromMetadataPathElement (metadata, path, "min");
3213- if (!value.empty ())
3214- min = strtol (value.c_str (), NULL, 0);
3215-
3216- value = stringFromMetadataPathElement (metadata, path, "max");
3217- if (!value.empty ())
3218- max = strtol (value.c_str (), NULL, 0);
3219-
3220- r.set (min, max);
3221-}
3222-
3223-static void
3224-initFloatRestriction (CompMetadata *metadata,
3225- CompOption::Restriction &r,
3226- const char *path)
3227-{
3228- CompString value;
3229- char *loc;
3230-
3231- float min = MINSHORT;
3232- float max = MAXSHORT;
3233- float precision = 0.1f;
3234-
3235- loc = setlocale (LC_NUMERIC, NULL);
3236- setlocale (LC_NUMERIC, "C");
3237- value = stringFromMetadataPathElement (metadata, path, "min");
3238- if (!value.empty ())
3239- min = strtod (value.c_str (), NULL);
3240-
3241- value = stringFromMetadataPathElement (metadata, path, "max");
3242- if (!value.empty ())
3243- max = strtod (value.c_str (), NULL);
3244-
3245- value = stringFromMetadataPathElement (metadata, path, "precision");
3246- if (!value.empty ())
3247- precision = strtod (value.c_str (), NULL);
3248-
3249- r.set (min, max, precision);
3250-
3251- setlocale (LC_NUMERIC, loc);
3252-}
3253-
3254-static void
3255-initActionState (CompMetadata *metadata,
3256- CompOption::Type type,
3257- CompAction::State *state,
3258- const char *path)
3259-{
3260- static struct _StateMap {
3261- const char *name;
3262- CompAction::State state;
3263- } map[] = {
3264- { "key", CompAction::StateInitKey },
3265- { "button", CompAction::StateInitButton },
3266- { "bell", CompAction::StateInitBell },
3267- { "edge", CompAction::StateInitEdge },
3268- { "edgednd", CompAction::StateInitEdgeDnd }
3269- };
3270-
3271- CompXPath xPath;
3272- CompString value;
3273-
3274- *state = CompAction::StateAutoGrab;
3275-
3276- value = stringFromMetadataPathElement (metadata, path, "passive_grab");
3277- if (!value.empty ())
3278- if (value == "false")
3279- *state = 0;
3280-
3281- if (type == CompOption::TypeEdge)
3282- {
3283- value = stringFromMetadataPathElement (metadata, path, "nodelay");
3284- if (!value.empty ())
3285- if (value == "true")
3286- *state |= CompAction::StateNoEdgeDelay;
3287- }
3288-
3289- if (!initXPathFromMetadataPathElement (&xPath, metadata, BAD_CAST path,
3290- BAD_CAST "allowed"))
3291- return;
3292-
3293- for (unsigned int i = 0; i < sizeof (map) / sizeof (map[0]); i++)
3294- {
3295- xmlChar *value;
3296-
3297- value = xmlGetProp (*xPath.obj->nodesetval->nodeTab,
3298- BAD_CAST map[i].name);
3299- if (value)
3300- {
3301- if (xmlStrcmp (value, BAD_CAST "true") == 0)
3302- *state |= map[i].state;
3303- xmlFree (value);
3304- }
3305- }
3306-
3307- finiXPath (&xPath);
3308-}
3309-
3310-static bool
3311-initOptionFromMetadataPath (CompMetadata *metadata,
3312- CompOption *option,
3313- const xmlChar *path)
3314-{
3315- CompXPath xPath, xDefaultPath;
3316- xmlNodePtr node, defaultNode;
3317- xmlDocPtr defaultDoc;
3318- xmlChar *name, *type;
3319- CompString value;
3320- CompAction::State state = 0;
3321- bool helper = false;
3322- CompOption::Type oType = CompOption::TypeBool;
3323-
3324- CompOption::Value::Vector emptyList (0);
3325-
3326- if (!initXPathFromMetadataPath (&xPath, metadata, path))
3327- return FALSE;
3328-
3329- node = *xPath.obj->nodesetval->nodeTab;
3330-
3331- type = xmlGetProp (node, BAD_CAST "type");
3332- if (type)
3333- {
3334- oType = getOptionType ((char *) type);
3335- xmlFree (type);
3336- }
3337-
3338- name = xmlGetProp (node, BAD_CAST "name");
3339- option->setName ((char *) name, oType);
3340- xmlFree (name);
3341-
3342- if (initXPathFromMetadataPathElement (&xDefaultPath, metadata, path,
3343- BAD_CAST "default"))
3344- {
3345- defaultDoc = xDefaultPath.doc;
3346- defaultNode = *xDefaultPath.obj->nodesetval->nodeTab;
3347- }
3348- else
3349- {
3350- defaultDoc = NULL;
3351- defaultNode = NULL;
3352- }
3353-
3354- switch (option->type ()) {
3355- case CompOption::TypeBool:
3356- initBoolValue (option->value (), defaultDoc, defaultNode);
3357- break;
3358- case CompOption::TypeInt:
3359- initIntRestriction (metadata, option->rest (), (char *) path);
3360- initIntValue (option->value (), option->rest (),
3361- defaultDoc, defaultNode);
3362- break;
3363- case CompOption::TypeFloat:
3364- initFloatRestriction (metadata, option->rest (), (char *) path);
3365- initFloatValue (option->value (), option->rest (),
3366- defaultDoc, defaultNode);
3367- break;
3368- case CompOption::TypeString:
3369- initStringValue (option->value (), option->rest (),
3370- defaultDoc, defaultNode);
3371- break;
3372- case CompOption::TypeColor:
3373- initColorValue (option->value (), defaultDoc, defaultNode);
3374- break;
3375- case CompOption::TypeAction:
3376- initActionState (metadata, option->type (), &state, (char *) path);
3377- initActionValue (option->value (), state,
3378- defaultDoc, defaultNode);
3379- break;
3380- case CompOption::TypeKey:
3381- initActionState (metadata, option->type (), &state, (char *) path);
3382- initKeyValue (option->value (), state,
3383- defaultDoc, defaultNode);
3384- break;
3385- case CompOption::TypeButton:
3386- initActionState (metadata, option->type (), &state, (char *) path);
3387- initButtonValue (option->value (), state,
3388- defaultDoc, defaultNode);
3389- break;
3390- case CompOption::TypeEdge:
3391- initActionState (metadata, option->type (), &state, (char *) path);
3392- initEdgeValue (option->value (), state,
3393- defaultDoc, defaultNode);
3394- break;
3395- case CompOption::TypeBell:
3396- initActionState (metadata, option->type (), &state, (char *) path);
3397- initBellValue (option->value (), state,
3398- defaultDoc, defaultNode);
3399- break;
3400- case CompOption::TypeMatch:
3401- helper = boolFromMetadataPathElement (metadata, (char *) path,
3402- "helper", false);
3403- initMatchValue (option->value (), helper,
3404- defaultDoc, defaultNode);
3405- break;
3406- case CompOption::TypeList:
3407- value = stringFromMetadataPathElement (metadata, (char *) path,
3408- "type");
3409- if (!value.empty ())
3410- option->value ().set (getOptionType (value.c_str ()), emptyList);
3411- else
3412- option->value ().set (CompOption::TypeBool, emptyList);
3413-
3414- switch (option->value ().listType ()) {
3415- case CompOption::TypeInt:
3416- initIntRestriction (metadata, option->rest (),
3417- (char *) path);
3418- break;
3419- case CompOption::TypeFloat:
3420- initFloatRestriction (metadata, option->rest (),
3421- (char *) path);
3422- break;
3423- case CompOption::TypeAction:
3424- case CompOption::TypeKey:
3425- case CompOption::TypeButton:
3426- case CompOption::TypeEdge:
3427- case CompOption::TypeBell:
3428- initActionState (metadata, option->value ().listType (),
3429- &state, (char *) path);
3430- break;
3431- case CompOption::TypeMatch:
3432- helper = boolFromMetadataPathElement (metadata,
3433- (char *) path,
3434- "helper", false);
3435- default:
3436- break;
3437- }
3438-
3439- initListValue (option->value (), option->rest (), state, helper,
3440- defaultDoc, defaultNode);
3441- break;
3442- }
3443-
3444- if (defaultDoc)
3445- finiXPath (&xDefaultPath);
3446-
3447- finiXPath (&xPath);
3448-
3449- return TRUE;
3450-}
3451-
3452-CompMetadata::CompMetadata (CompString plugin,
3453- const OptionInfo *optionInfo,
3454- unsigned int nOptionInfo)
3455-{
3456- priv = new PrivateMetadata (plugin, compPrintf ("plugin[@name=\"%s\"]",
3457- plugin.c_str ()));
3458- if (nOptionInfo)
3459- {
3460- CompIOCtx ctx;
3461-
3462- ctx.offset = 0;
3463- ctx.name = plugin.c_str ();
3464- ctx.oInfo = optionInfo;
3465- ctx.nOInfo = nOptionInfo;
3466-
3467- addFromIO (readPluginXmlCallback, NULL, (void *) &ctx);
3468- }
3469-}
3470-
3471-CompMetadata::~CompMetadata ()
3472-{
3473- delete priv;
3474-}
3475-
3476-std::vector<xmlDoc *> &
3477-CompMetadata::doc ()
3478-{
3479- return priv->mDoc;
3480-}
3481-
3482-
3483-bool
3484-CompMetadata::addFromFile (CompString file, bool prepend)
3485-{
3486- xmlDoc *doc;
3487- CompString home (getenv ("HOME"));
3488- bool status = false;
3489-
3490- home = getenv ("HOME");
3491- if (home.size ())
3492- {
3493- CompString path = compPrintf ("%s/%s", home.c_str (), HOME_METADATADIR);
3494- doc = readXmlFile (file, path);
3495- if (doc)
3496- {
3497- if (prepend)
3498- priv->mDoc.insert (priv->mDoc.begin (), doc);
3499- else
3500- priv->mDoc.push_back (doc);
3501-
3502- status = true;
3503- }
3504- }
3505-
3506- doc = readXmlFile (file, CompString (METADATADIR));
3507- if (doc)
3508- {
3509- if (prepend)
3510- priv->mDoc.insert (priv->mDoc.begin (), doc);
3511- else
3512- priv->mDoc.push_back (doc);
3513-
3514- status |= true;
3515- }
3516-
3517- if (!status)
3518- {
3519- compLogMessage ("core", CompLogLevelWarn,
3520- "Unable to parse XML metadata from file \"%s%s\"",
3521- file.c_str (), EXTENSION);
3522-
3523- return false;
3524- }
3525-
3526- return true;
3527-}
3528-
3529-bool
3530-CompMetadata::addFromString (CompString string, bool prepend)
3531-{
3532- xmlDoc *doc;
3533-
3534- doc = xmlReadMemory (string.c_str (), string.size (), NULL, NULL, 0);
3535- if (!doc)
3536- {
3537- compLogMessage ("core", CompLogLevelWarn,
3538- "Unable to parse XML metadata");
3539-
3540- return false;
3541- }
3542-
3543- if (prepend)
3544- priv->mDoc.insert (priv->mDoc.begin (), doc);
3545- else
3546- priv->mDoc.push_back (doc);
3547-
3548- return true;
3549-}
3550-
3551-bool
3552-CompMetadata::addFromIO (xmlInputReadCallback ioread,
3553- xmlInputCloseCallback ioclose,
3554- void *ioctx,
3555- bool prepend)
3556-{
3557- xmlDoc *doc;
3558-
3559- doc = xmlReadIO (ioread, ioclose, ioctx, NULL, NULL, 0);
3560- if (!doc)
3561- {
3562- compLogMessage ("core", CompLogLevelWarn,
3563- "Unable to parse XML metadata");
3564-
3565- return false;
3566- }
3567-
3568- if (prepend)
3569- priv->mDoc.insert (priv->mDoc.begin (), doc);
3570- else
3571- priv->mDoc.push_back (doc);
3572-
3573- return true;
3574-}
3575-
3576-bool
3577-CompMetadata::addFromOptionInfo (const OptionInfo *optionInfo,
3578- unsigned int nOptionInfo,
3579- bool prepend)
3580-{
3581- if (nOptionInfo)
3582- {
3583- CompIOCtx ctx;
3584-
3585- ctx.offset = 0;
3586- ctx.name = priv->mPlugin.c_str ();
3587- ctx.oInfo = optionInfo;
3588- ctx.nOInfo = nOptionInfo;
3589-
3590- return addFromIO (readPluginXmlCallback, NULL, (void *) &ctx, prepend);
3591- }
3592- else
3593- return false;
3594-}
3595-
3596-bool
3597-CompMetadata::initOption (CompOption *option,
3598- CompString name)
3599-{
3600- char str[1024];
3601-
3602- sprintf (str, "/compiz/%s/options//option[@name=\"%s\"]",
3603- priv->mPath.c_str (), name.c_str ());
3604-
3605- return initOptionFromMetadataPath (this, option, BAD_CAST str);
3606-}
3607-
3608-bool
3609-CompMetadata::initOptions (const OptionInfo *info,
3610- unsigned int nOptions,
3611- CompOption::Vector &opt)
3612-{
3613- if (opt.size () < nOptions)
3614- opt.resize (nOptions);
3615-
3616- for (unsigned int i = 0; i < nOptions; i++)
3617- {
3618- if (!initOption (&opt[i], info[i].name))
3619- {
3620- return false;
3621- }
3622-
3623- if (info[i].initiate)
3624- opt[i].value ().action ().setInitiate (info[i].initiate);
3625-
3626- if (info[i].terminate)
3627- opt[i].value ().action ().setTerminate (info[i].terminate);
3628- }
3629-
3630- return true;
3631-}
3632-
3633-CompString
3634-CompMetadata::getShortPluginDescription ()
3635-{
3636- return getStringFromPath (
3637- compPrintf ("/compiz/%s/short/child::text()", priv->mPath.c_str ()));
3638-}
3639-
3640-CompString
3641-CompMetadata::getLongPluginDescription ()
3642-{
3643- return getStringFromPath (
3644- compPrintf ("/compiz/%s/long/child::text()", priv->mPath.c_str ()));
3645-}
3646-
3647-CompString
3648-CompMetadata::getShortOptionDescription (CompOption *option)
3649-{
3650- return getStringFromPath (
3651- compPrintf (
3652- "/compiz/%s/options//option[@name=\"%s\"]/short/child::text()",
3653- priv->mPath.c_str (), option->name ().c_str ()));
3654-}
3655-
3656-CompString
3657-CompMetadata::getLongOptionDescription (CompOption *option)
3658-{
3659- return getStringFromPath (
3660- compPrintf (
3661- "/compiz/%s/options//option[@name=\"%s\"]/long/child::text()",
3662- priv->mPath.c_str (), option->name ().c_str ()));
3663-}
3664-
3665-
3666-
3667-CompString
3668-CompMetadata::getStringFromPath (CompString path)
3669-{
3670- CompXPath xPath;
3671- CompString v = "";
3672-
3673- if (!initXPathFromMetadataPath (&xPath, this, BAD_CAST path.c_str ()))
3674- return "";
3675-
3676- xPath.obj = xmlXPathConvertString (xPath.obj);
3677-
3678- if (xPath.obj->type == XPATH_STRING && xPath.obj->stringval)
3679- v = (char *) xPath.obj->stringval;
3680-
3681- finiXPath (&xPath);
3682-
3683- return v;
3684-}
3685-
3686-unsigned int
3687-CompMetadata::readXmlChunk (const char *src,
3688- unsigned int *offset,
3689- char *buffer,
3690- unsigned int length)
3691-{
3692- unsigned int srcLength = strlen (src);
3693- unsigned int srcOffset = *offset;
3694-
3695- if (srcOffset > srcLength)
3696- srcOffset = srcLength;
3697-
3698- *offset -= srcOffset;
3699-
3700- src += srcOffset;
3701- srcLength -= srcOffset;
3702-
3703- if (srcLength > 0 && length > 0)
3704- {
3705- if (srcLength < length)
3706- length = srcLength;
3707-
3708- memcpy (buffer, src, length);
3709-
3710- return length;
3711- }
3712-
3713- return 0;
3714-}
3715-
3716-unsigned int
3717-CompMetadata::readXmlChunkFromOptionInfo (const CompMetadata::OptionInfo *info,
3718- unsigned int *offset,
3719- char *buffer,
3720- unsigned int length)
3721-{
3722- unsigned int i;
3723-
3724- i = readXmlChunk ("<option name=\"", offset, buffer, length);
3725- i += readXmlChunk (info->name, offset, buffer + i, length - i);
3726-
3727- if (info->type)
3728- {
3729- i += readXmlChunk ("\" type=\"", offset, buffer + i, length - i);
3730- i += readXmlChunk (info->type, offset, buffer + i, length - i);
3731- }
3732-
3733- if (info->data)
3734- {
3735- i += readXmlChunk ("\">", offset, buffer + i, length - i);
3736- i += readXmlChunk (info->data, offset, buffer + i, length - i);
3737- i += readXmlChunk ("</option>", offset, buffer + i, length - i);
3738- }
3739- else
3740- {
3741- i += readXmlChunk ("\"/>", offset, buffer + i, length - i);
3742- }
3743-
3744- return i;
3745-}
3746-
3747-PrivateMetadata::PrivateMetadata (CompString plugin, CompString path) :
3748- mPlugin (plugin),
3749- mPath (path),
3750- mDoc (0)
3751-{
3752-}
3753-
3754-PrivateMetadata::~PrivateMetadata ()
3755-{
3756- foreach (xmlDoc *d, mDoc)
3757- xmlFreeDoc (d);
3758-}
3759-
3760
3761=== removed file 'legacy/metadata.h'
3762--- legacy/metadata.h 2009-03-15 23:01:28 +0000
3763+++ legacy/metadata.h 1970-01-01 00:00:00 +0000
3764@@ -1,106 +0,0 @@
3765-/*
3766- * Copyright © 2008 Dennis Kasprzyk
3767- * Copyright © 2007 Novell, Inc.
3768- *
3769- * Permission to use, copy, modify, distribute, and sell this software
3770- * and its documentation for any purpose is hereby granted without
3771- * fee, provided that the above copyright notice appear in all copies
3772- * and that both that copyright notice and this permission notice
3773- * appear in supporting documentation, and that the name of
3774- * Dennis Kasprzyk not be used in advertising or publicity pertaining to
3775- * distribution of the software without specific, written prior permission.
3776- * Dennis Kasprzyk makes no representations about the suitability of this
3777- * software for any purpose. It is provided "as is" without express or
3778- * implied warranty.
3779- *
3780- * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
3781- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
3782- * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
3783- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
3784- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
3785- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3786- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3787- *
3788- * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
3789- * David Reveman <davidr@novell.com>
3790- */
3791-
3792-#ifndef _COMPMETADATA_H
3793-#define _COMPMETADATA_H
3794-
3795-#include <vector>
3796-
3797-#include <libxml/parser.h>
3798-
3799-#include <core/action.h>
3800-
3801-#define STRINGIFY(x) #x
3802-#define TOSTRING(x) STRINGIFY (x)
3803-#define MINTOSTRING(x) "<min>" TOSTRING (x) "</min>"
3804-#define MAXTOSTRING(x) "<max>" TOSTRING (x) "</max>"
3805-#define RESTOSTRING(min, max) MINTOSTRING (min) MAXTOSTRING (max)
3806-
3807-class PrivateMetadata;
3808-
3809-class CompMetadata {
3810- public:
3811- struct OptionInfo {
3812- const char *name;
3813- const char *type;
3814- const char *data;
3815- CompAction::CallBack initiate;
3816- CompAction::CallBack terminate;
3817- };
3818- public:
3819- CompMetadata (CompString plugin = "core",
3820- const OptionInfo *optionInfo = NULL,
3821- unsigned int nOptionInfo = 0);
3822- ~CompMetadata ();
3823-
3824- std::vector<xmlDoc *> &doc ();
3825-
3826- bool addFromFile (CompString file, bool prepend = false);
3827- bool addFromString (CompString string, bool prepend = false);
3828- bool addFromIO (xmlInputReadCallback ioread,
3829- xmlInputCloseCallback ioclose,
3830- void *ioctx,
3831- bool prepend = false);
3832- bool addFromOptionInfo (const OptionInfo *optionInfo,
3833- unsigned int nOptionInfo,
3834- bool prepend = false);
3835-
3836- bool initOption (CompOption *option,
3837- CompString name);
3838-
3839- bool initOptions (const OptionInfo *info,
3840- unsigned int nOptions,
3841- CompOption::Vector &options);
3842-
3843-
3844-
3845- CompString getShortPluginDescription ();
3846-
3847- CompString getLongPluginDescription ();
3848-
3849- CompString getShortOptionDescription (CompOption *option);
3850-
3851- CompString getLongOptionDescription (CompOption *option);
3852-
3853- CompString getStringFromPath (CompString path);
3854-
3855- static unsigned int readXmlChunk (const char *src,
3856- unsigned int *offset,
3857- char *buffer,
3858- unsigned int length);
3859-
3860- static unsigned int
3861- readXmlChunkFromOptionInfo (const CompMetadata::OptionInfo *info,
3862- unsigned int *offset,
3863- char *buffer,
3864- unsigned int length);
3865-
3866- private:
3867- PrivateMetadata *priv;
3868-};
3869-
3870-#endif
3871
3872=== removed file 'legacy/minimize.cpp'
3873--- legacy/minimize.cpp 2009-03-15 05:15:26 +0000
3874+++ legacy/minimize.cpp 1970-01-01 00:00:00 +0000
3875@@ -1,1059 +0,0 @@
3876-/*
3877- * Copyright © 2005 Novell, Inc.
3878- *
3879- * Permission to use, copy, modify, distribute, and sell this software
3880- * and its documentation for any purpose is hereby granted without
3881- * fee, provided that the above copyright notice appear in all copies
3882- * and that both that copyright notice and this permission notice
3883- * appear in supporting documentation, and that the name of
3884- * Novell, Inc. not be used in advertising or publicity pertaining to
3885- * distribution of the software without specific, written prior permission.
3886- * Novell, Inc. makes no representations about the suitability of this
3887- * software for any purpose. It is provided "as is" without express or
3888- * implied warranty.
3889- *
3890- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
3891- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
3892- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
3893- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
3894- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
3895- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3896- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3897- *
3898- * Author: David Reveman <davidr@novell.com>
3899- */
3900-
3901-#include <X11/Xatom.h>
3902-
3903-#include <stdlib.h>
3904-#include <string.h>
3905-#include <math.h>
3906-
3907-#include <compiz-core.h>
3908-
3909-static CompMetadata minMetadata;
3910-
3911-static int displayPrivateIndex;
3912-
3913-typedef struct _MinDisplay {
3914- int screenPrivateIndex;
3915- HandleEventProc handleEvent;
3916- Atom winChangeStateAtom;
3917-} MinDisplay;
3918-
3919-#define MIN_SCREEN_OPTION_SPEED 0
3920-#define MIN_SCREEN_OPTION_TIMESTEP 1
3921-#define MIN_SCREEN_OPTION_WINDOW_MATCH 2
3922-#define MIN_SCREEN_OPTION_SHADE_RESISTANCE 3
3923-#define MIN_SCREEN_OPTION_NUM 4
3924-
3925-typedef struct _MinScreen {
3926- int windowPrivateIndex;
3927-
3928- CompOption opt[MIN_SCREEN_OPTION_NUM];
3929-
3930- PreparePaintScreenProc preparePaintScreen;
3931- DonePaintScreenProc donePaintScreen;
3932- PaintOutputProc paintOutput;
3933- PaintWindowProc paintWindow;
3934- DamageWindowRectProc damageWindowRect;
3935- FocusWindowProc focusWindow;
3936-
3937- int shadeStep;
3938- int moreAdjust;
3939-} MinScreen;
3940-
3941-typedef struct _MinWindow {
3942- GLfloat xVelocity, yVelocity, xScaleVelocity, yScaleVelocity;
3943- GLfloat xScale, yScale;
3944- GLfloat tx, ty;
3945-
3946- Bool adjust;
3947-
3948- int state, newState;
3949-
3950- int shade;
3951- Region region;
3952-
3953- int unmapCnt;
3954-
3955- Bool ignoreDamage;
3956-} MinWindow;
3957-
3958-#define GET_MIN_DISPLAY(d) \
3959- ((MinDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
3960-
3961-#define MIN_DISPLAY(d) \
3962- MinDisplay *md = GET_MIN_DISPLAY (d)
3963-
3964-#define GET_MIN_SCREEN(s, md) \
3965- ((MinScreen *) (s)->base.privates[(md)->screenPrivateIndex].ptr)
3966-
3967-#define MIN_SCREEN(s) \
3968- MinScreen *ms = GET_MIN_SCREEN (s, GET_MIN_DISPLAY (s->display))
3969-
3970-#define GET_MIN_WINDOW(w, ms) \
3971- ((MinWindow *) (w)->base.privates[(ms)->windowPrivateIndex].ptr)
3972-
3973-#define MIN_WINDOW(w) \
3974- MinWindow *mw = GET_MIN_WINDOW (w, \
3975- GET_MIN_SCREEN (w->screen, \
3976- GET_MIN_DISPLAY (w->screen->display)))
3977-
3978-#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
3979-
3980-static CompOption *
3981-minGetScreenOptions (CompPlugin *plugin,
3982- CompScreen *screen,
3983- int *count)
3984-{
3985- MIN_SCREEN (screen);
3986-
3987- *count = NUM_OPTIONS (ms);
3988- return ms->opt;
3989-}
3990-
3991-static Bool
3992-minSetScreenOption (CompPlugin *plugin,
3993- CompScreen *screen,
3994- const char *name,
3995- CompOptionValue *value)
3996-{
3997- CompOption *o;
3998- int index;
3999-
4000- MIN_SCREEN (screen);
4001-
4002- o = compFindOption (ms->opt, NUM_OPTIONS (ms), name, &index);
4003- if (!o)
4004- return FALSE;
4005-
4006- switch (index) {
4007- case MIN_SCREEN_OPTION_SHADE_RESISTANCE:
4008- if (compSetIntOption (o, value))
4009- {
4010- if (o->value.i)
4011- ms->shadeStep = o->rest.i.max - o->value.i + 1;
4012- else
4013- ms->shadeStep = 0;
4014-
4015- return TRUE;
4016- }
4017- break;
4018- default:
4019- if (compSetOption (o, value))
4020- return TRUE;
4021- break;
4022- }
4023-
4024- return FALSE;
4025-}
4026-
4027-static void
4028-minSetShade (CompWindow *w,
4029- int shade)
4030-{
4031- REGION rect;
4032- int h = w->attrib.height + w->attrib.border_width * 2;
4033-
4034- MIN_WINDOW (w);
4035-
4036- EMPTY_REGION (w->region);
4037-
4038- rect.rects = &rect.extents;
4039- rect.numRects = rect.size = 1;
4040-
4041- w->height = shade;
4042-
4043- rect.extents.x1 = 0;
4044- rect.extents.y1 = h - shade;
4045- rect.extents.x2 = w->width;
4046- rect.extents.y2 = h;
4047-
4048- XIntersectRegion (mw->region, &rect, w->region);
4049- XOffsetRegion (w->region, w->attrib.x, w->attrib.y - (h - shade));
4050-
4051- w->matrix = w->texture->matrix;
4052- w->matrix.x0 -= (w->attrib.x * w->matrix.xx);
4053- w->matrix.y0 -= ((w->attrib.y - (h - shade)) * w->matrix.yy);
4054-
4055- (*w->screen->windowResizeNotify) (w, 0, 0, 0, 0);
4056-}
4057-
4058-static int
4059-minGetWindowState (CompWindow *w)
4060-{
4061- Atom actual;
4062- int result, format;
4063- unsigned long n, left;
4064- unsigned char *data;
4065-
4066- result = XGetWindowProperty (w->screen->display->display, w->id,
4067- w->screen->display->wmStateAtom, 0L, 1L, FALSE,
4068- w->screen->display->wmStateAtom,
4069- &actual, &format, &n, &left, &data);
4070-
4071- if (result == Success && n && data)
4072- {
4073- int state;
4074-
4075- memcpy (&state, data, sizeof (int));
4076- XFree ((void *) data);
4077-
4078- return state;
4079- }
4080-
4081- return WithdrawnState;
4082-}
4083-
4084-static int
4085-adjustMinVelocity (CompWindow *w)
4086-{
4087- float dx, dy, dxs, dys, adjust, amount;
4088- float x1, y1, xScale, yScale;
4089-
4090- MIN_WINDOW (w);
4091-
4092- if (mw->newState == IconicState)
4093- {
4094- x1 = w->iconGeometry.x;
4095- y1 = w->iconGeometry.y;
4096- xScale = (float) w->iconGeometry.width / w->width;
4097- yScale = (float) w->iconGeometry.height / w->height;
4098- }
4099- else
4100- {
4101- x1 = w->serverX;
4102- y1 = w->serverY;
4103- xScale = yScale = 1.0f;
4104- }
4105-
4106- dx = x1 - (w->attrib.x + mw->tx);
4107-
4108- adjust = dx * 0.15f;
4109- amount = fabs (dx) * 1.5f;
4110- if (amount < 0.5f)
4111- amount = 0.5f;
4112- else if (amount > 5.0f)
4113- amount = 5.0f;
4114-
4115- mw->xVelocity = (amount * mw->xVelocity + adjust) / (amount + 1.0f);
4116-
4117- dy = y1 - (w->attrib.y + mw->ty);
4118-
4119- adjust = dy * 0.15f;
4120- amount = fabs (dy) * 1.5f;
4121- if (amount < 0.5f)
4122- amount = 0.5f;
4123- else if (amount > 5.0f)
4124- amount = 5.0f;
4125-
4126- mw->yVelocity = (amount * mw->yVelocity + adjust) / (amount + 1.0f);
4127-
4128- dxs = xScale - mw->xScale;
4129-
4130- adjust = dxs * 0.15f;
4131- amount = fabs (dxs) * 10.0f;
4132- if (amount < 0.01f)
4133- amount = 0.01f;
4134- else if (amount > 0.15f)
4135- amount = 0.15f;
4136-
4137- mw->xScaleVelocity = (amount * mw->xScaleVelocity + adjust) /
4138- (amount + 1.0f);
4139-
4140- dys = yScale - mw->yScale;
4141-
4142- adjust = dys * 0.15f;
4143- amount = fabs (dys) * 10.0f;
4144- if (amount < 0.01f)
4145- amount = 0.01f;
4146- else if (amount > 0.15f)
4147- amount = 0.15f;
4148-
4149- mw->yScaleVelocity = (amount * mw->yScaleVelocity + adjust) /
4150- (amount + 1.0f);
4151-
4152- if (fabs (dx) < 0.1f && fabs (mw->xVelocity) < 0.2f &&
4153- fabs (dy) < 0.1f && fabs (mw->yVelocity) < 0.2f &&
4154- fabs (dxs) < 0.001f && fabs (mw->xScaleVelocity) < 0.002f &&
4155- fabs (dys) < 0.001f && fabs (mw->yScaleVelocity) < 0.002f)
4156- {
4157- mw->xVelocity = mw->yVelocity = mw->xScaleVelocity =
4158- mw->yScaleVelocity = 0.0f;
4159- mw->tx = x1 - w->attrib.x;
4160- mw->ty = y1 - w->attrib.y;
4161- mw->xScale = xScale;
4162- mw->yScale = yScale;
4163-
4164- return 0;
4165- }
4166-
4167- return 1;
4168-}
4169-
4170-static void
4171-minPreparePaintScreen (CompScreen *s,
4172- int msSinceLastPaint)
4173-{
4174- MIN_SCREEN (s);
4175-
4176- if (ms->moreAdjust)
4177- {
4178- CompWindow *w;
4179- int steps, h;
4180- float amount, chunk;
4181-
4182- amount = msSinceLastPaint * 0.05f *
4183- ms->opt[MIN_SCREEN_OPTION_SPEED].value.f;
4184- steps = amount / (0.5f * ms->opt[MIN_SCREEN_OPTION_TIMESTEP].value.f);
4185- if (!steps) steps = 1;
4186- chunk = amount / (float) steps;
4187-
4188- while (steps--)
4189- {
4190- ms->moreAdjust = 0;
4191-
4192- for (w = s->windows; w; w = w->next)
4193- {
4194- MIN_WINDOW (w);
4195-
4196- if (mw->adjust)
4197- {
4198- mw->adjust = adjustMinVelocity (w);
4199-
4200- ms->moreAdjust |= mw->adjust;
4201-
4202- mw->tx += mw->xVelocity * chunk;
4203- mw->ty += mw->yVelocity * chunk;
4204- mw->xScale += mw->xScaleVelocity * chunk;
4205- mw->yScale += mw->yScaleVelocity * chunk;
4206-
4207- if (!mw->adjust)
4208- {
4209- mw->state = mw->newState;
4210-
4211- mw->ignoreDamage = TRUE;
4212- while (mw->unmapCnt)
4213- {
4214- unmapWindow (w);
4215- mw->unmapCnt--;
4216- }
4217- mw->ignoreDamage = FALSE;
4218- }
4219- }
4220- else if (mw->region && w->damaged)
4221- {
4222- if (w->shaded)
4223- {
4224- if (mw->shade > 0)
4225- {
4226- mw->shade -= (chunk * ms->shadeStep) + 1;
4227-
4228- if (mw->shade > 0)
4229- {
4230- ms->moreAdjust = TRUE;
4231- }
4232- else
4233- {
4234- mw->shade = 0;
4235-
4236- mw->ignoreDamage = TRUE;
4237- while (mw->unmapCnt)
4238- {
4239- unmapWindow (w);
4240- mw->unmapCnt--;
4241- }
4242- mw->ignoreDamage = FALSE;
4243- }
4244- }
4245- }
4246- else
4247- {
4248- h = w->attrib.height + w->attrib.border_width * 2;
4249- if (mw->shade < h)
4250- {
4251- mw->shade += (chunk * ms->shadeStep) + 1;
4252-
4253- if (mw->shade < h)
4254- {
4255- ms->moreAdjust = TRUE;
4256- }
4257- else
4258- {
4259- mw->shade = MAXSHORT;
4260-
4261- minSetShade (w, h);
4262-
4263- XDestroyRegion (mw->region);
4264- mw->region = NULL;
4265-
4266- addWindowDamage (w);
4267- }
4268- }
4269- }
4270- }
4271- }
4272-
4273- if (!ms->moreAdjust)
4274- break;
4275- }
4276-
4277- if (ms->moreAdjust)
4278- {
4279- for (w = s->windows; w; w = w->next)
4280- {
4281- MIN_WINDOW (w);
4282-
4283- if (mw->adjust)
4284- {
4285- addWindowDamage (w);
4286- }
4287- else if (mw->region && w->damaged)
4288- {
4289- h = w->attrib.height + w->attrib.border_width * 2;
4290- if (mw->shade && mw->shade < h)
4291- {
4292- minSetShade (w, mw->shade);
4293- addWindowDamage (w);
4294- }
4295- }
4296- }
4297- }
4298- }
4299-
4300- UNWRAP (ms, s, preparePaintScreen);
4301- (*s->preparePaintScreen) (s, msSinceLastPaint);
4302- WRAP (ms, s, preparePaintScreen, minPreparePaintScreen);
4303-}
4304-
4305-static void
4306-minDonePaintScreen (CompScreen *s)
4307-{
4308- MIN_SCREEN (s);
4309-
4310- if (ms->moreAdjust)
4311- {
4312- CompWindow *w;
4313- int h;
4314-
4315- for (w = s->windows; w; w = w->next)
4316- {
4317- MIN_WINDOW (w);
4318-
4319- if (mw->adjust)
4320- {
4321- addWindowDamage (w);
4322- }
4323- else if (mw->region)
4324- {
4325- h = w->attrib.height + w->attrib.border_width * 2;
4326- if (mw->shade && mw->shade < h)
4327- addWindowDamage (w);
4328- }
4329- }
4330- }
4331-
4332- UNWRAP (ms, s, donePaintScreen);
4333- (*s->donePaintScreen) (s);
4334- WRAP (ms, s, donePaintScreen, minDonePaintScreen);
4335-}
4336-
4337-static Bool
4338-minPaintOutput (CompScreen *s,
4339- const ScreenPaintAttrib *sAttrib,
4340- const CompTransform *transform,
4341- Region region,
4342- CompOutput *output,
4343- unsigned int mask)
4344-{
4345- Bool status;
4346-
4347- MIN_SCREEN (s);
4348-
4349- if (ms->moreAdjust)
4350- mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
4351-
4352- UNWRAP (ms, s, paintOutput);
4353- status = (*s->paintOutput) (s, sAttrib, transform, region, output, mask);
4354- WRAP (ms, s, paintOutput, minPaintOutput);
4355-
4356- return status;
4357-}
4358-
4359-static Bool
4360-minPaintWindow (CompWindow *w,
4361- const WindowPaintAttrib *attrib,
4362- const CompTransform *transform,
4363- Region region,
4364- unsigned int mask)
4365-{
4366- CompScreen *s = w->screen;
4367- Bool status;
4368-
4369- MIN_SCREEN (s);
4370- MIN_WINDOW (w);
4371-
4372- if (mw->adjust)
4373- {
4374- FragmentAttrib fragment;
4375- CompTransform wTransform = *transform;
4376-
4377- if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
4378- return FALSE;
4379-
4380- UNWRAP (ms, s, paintWindow);
4381- status = (*s->paintWindow) (w, attrib, transform, region,
4382- mask | PAINT_WINDOW_NO_CORE_INSTANCE_MASK);
4383- WRAP (ms, s, paintWindow, minPaintWindow);
4384-
4385- initFragmentAttrib (&fragment, &w->lastPaint);
4386-
4387- if (w->alpha || fragment.opacity != OPAQUE)
4388- mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
4389-
4390- matrixTranslate (&wTransform, w->attrib.x, w->attrib.y, 0.0f);
4391- matrixScale (&wTransform, mw->xScale, mw->yScale, 1.0f);
4392- matrixTranslate (&wTransform,
4393- mw->tx / mw->xScale - w->attrib.x,
4394- mw->ty / mw->yScale - w->attrib.y,
4395- 0.0f);
4396-
4397- glPushMatrix ();
4398- glLoadMatrixf (wTransform.m);
4399-
4400- (*s->drawWindow) (w, &wTransform, &fragment, region,
4401- mask | PAINT_WINDOW_TRANSFORMED_MASK);
4402-
4403- glPopMatrix ();
4404- }
4405- else
4406- {
4407- /* no core instance from windows that have been animated */
4408- if (mw->state == IconicState)
4409- mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
4410-
4411- UNWRAP (ms, s, paintWindow);
4412- status = (*s->paintWindow) (w, attrib, transform, region, mask);
4413- WRAP (ms, s, paintWindow, minPaintWindow);
4414- }
4415-
4416- return status;
4417-}
4418-
4419-static void
4420-minHandleEvent (CompDisplay *d,
4421- XEvent *event)
4422-{
4423- CompWindow *w;
4424-
4425- MIN_DISPLAY (d);
4426-
4427- switch (event->type) {
4428- case MapNotify:
4429- w = findWindowAtDisplay (d, event->xmap.window);
4430- if (w)
4431- {
4432- MIN_WINDOW (w);
4433-
4434- if (mw->adjust)
4435- mw->state = mw->newState;
4436-
4437- if (mw->region)
4438- w->height = 0;
4439-
4440- mw->ignoreDamage = TRUE;
4441- while (mw->unmapCnt)
4442- {
4443- unmapWindow (w);
4444- mw->unmapCnt--;
4445- }
4446- mw->ignoreDamage = FALSE;
4447- }
4448- break;
4449- case UnmapNotify:
4450- w = findWindowAtDisplay (d, event->xunmap.window);
4451- if (w)
4452- {
4453- MIN_SCREEN (w->screen);
4454-
4455- if (w->pendingUnmaps && onCurrentDesktop (w)) /* Normal -> Iconic */
4456- {
4457- CompMatch *match =
4458- &ms->opt[MIN_SCREEN_OPTION_WINDOW_MATCH].value.match;
4459-
4460- MIN_WINDOW (w);
4461-
4462- if (w->shaded)
4463- {
4464- if (!mw->region)
4465- mw->region = XCreateRegion ();
4466-
4467- if (mw->region && ms->shadeStep)
4468- {
4469- XSubtractRegion (w->region, &emptyRegion, mw->region);
4470- XOffsetRegion (mw->region, -w->attrib.x,
4471- w->attrib.height +
4472- w->attrib.border_width * 2 -
4473- w->height - w->attrib.y);
4474-
4475- mw->shade = w->height;
4476-
4477- mw->adjust = FALSE;
4478- ms->moreAdjust = TRUE;
4479-
4480- mw->unmapCnt++;
4481- w->unmapRefCnt++;
4482-
4483- addWindowDamage (w);
4484- }
4485- }
4486- else if (!w->invisible && matchEval (match, w))
4487- {
4488- if (w->iconGeometrySet)
4489- {
4490- mw->newState = IconicState;
4491-
4492- mw->xScale = w->paint.xScale;
4493- mw->yScale = w->paint.yScale;
4494- mw->tx = w->attrib.x - w->serverX;
4495- mw->ty = w->attrib.y - w->serverY;
4496-
4497- if (mw->region)
4498- {
4499- XDestroyRegion (mw->region);
4500- mw->region = NULL;
4501- }
4502-
4503- mw->shade = MAXSHORT;
4504-
4505- mw->adjust = TRUE;
4506- ms->moreAdjust = TRUE;
4507-
4508- mw->unmapCnt++;
4509- w->unmapRefCnt++;
4510-
4511- addWindowDamage (w);
4512- }
4513- }
4514- }
4515- else /* X -> Withdrawn */
4516- {
4517- MIN_WINDOW (w);
4518-
4519- if (mw->adjust)
4520- {
4521- mw->adjust = FALSE;
4522- mw->xScale = mw->yScale = 1.0f;
4523- mw->tx = mw->ty = 0.0f;
4524- mw->xVelocity = mw->yVelocity = 0.0f;
4525- mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;
4526- mw->shade = MAXSHORT;
4527-
4528- if (mw->region)
4529- {
4530- XDestroyRegion (mw->region);
4531- mw->region = NULL;
4532- }
4533- }
4534-
4535- mw->state = NormalState;
4536- }
4537- }
4538- default:
4539- break;
4540- }
4541-
4542- UNWRAP (md, d, handleEvent);
4543- (*d->handleEvent) (d, event);
4544- WRAP (md, d, handleEvent, minHandleEvent);
4545-}
4546-
4547-static Bool
4548-minDamageWindowRect (CompWindow *w,
4549- Bool initial,
4550- BoxPtr rect)
4551-{
4552- Bool status = FALSE;
4553-
4554- MIN_SCREEN (w->screen);
4555- MIN_WINDOW (w);
4556-
4557- if (mw->ignoreDamage)
4558- return TRUE;
4559-
4560- if (initial)
4561- {
4562- if (mw->state == IconicState)
4563- {
4564- CompMatch *match =
4565- &ms->opt[MIN_SCREEN_OPTION_WINDOW_MATCH].value.match;
4566-
4567- mw->state = NormalState;
4568-
4569- if (!w->invisible &&
4570- w->iconGeometrySet &&
4571- matchEval (match, w))
4572- {
4573- if (!mw->adjust)
4574- {
4575- mw->adjust = TRUE;
4576- ms->moreAdjust = TRUE;
4577-
4578- mw->tx = w->iconGeometry.x - w->serverX;
4579- mw->ty = w->iconGeometry.y - w->serverY;
4580- mw->xScale = (float) w->iconGeometry.width / w->width;
4581- mw->yScale = (float) w->iconGeometry.height / w->height;
4582-
4583- addWindowDamage (w);
4584- }
4585- }
4586- }
4587- else if (mw->region && mw->shade < w->height)
4588- {
4589- if (ms->shadeStep && !w->invisible)
4590- {
4591- XSubtractRegion (w->region, &emptyRegion, mw->region);
4592- XOffsetRegion (mw->region, -w->attrib.x, -w->attrib.y);
4593-
4594- /* bind pixmap here so we have something to unshade with */
4595- if (!w->texture->pixmap && !w->bindFailed)
4596- bindWindow (w);
4597-
4598- ms->moreAdjust = TRUE;
4599- }
4600- else
4601- {
4602- mw->shade = MAXSHORT;
4603- }
4604- }
4605-
4606- mw->newState = NormalState;
4607- }
4608- else if (mw->adjust)
4609- {
4610- damageTransformedWindowRect (w,
4611- mw->xScale,
4612- mw->yScale,
4613- mw->tx,
4614- mw->ty,
4615- rect);
4616-
4617- status = TRUE;
4618- }
4619-
4620- UNWRAP (ms, w->screen, damageWindowRect);
4621- status |= (*w->screen->damageWindowRect) (w, initial, rect);
4622- WRAP (ms, w->screen, damageWindowRect, minDamageWindowRect);
4623-
4624- return status;
4625-}
4626-
4627-static Bool
4628-minFocusWindow (CompWindow *w)
4629-{
4630- Bool status;
4631-
4632- MIN_SCREEN (w->screen);
4633- MIN_WINDOW (w);
4634-
4635- if (mw->unmapCnt)
4636- return FALSE;
4637-
4638- UNWRAP (ms, w->screen, focusWindow);
4639- status = (*w->screen->focusWindow) (w);
4640- WRAP (ms, w->screen, focusWindow, minFocusWindow);
4641-
4642- return status;
4643-}
4644-
4645-static Bool
4646-minInitDisplay (CompPlugin *p,
4647- CompDisplay *d)
4648-{
4649- MinDisplay *md;
4650-
4651- if (!checkPluginABI ("core", CORE_ABIVERSION))
4652- return FALSE;
4653-
4654- md = malloc (sizeof (MinDisplay));
4655- if (!md)
4656- return FALSE;
4657-
4658- md->screenPrivateIndex = allocateScreenPrivateIndex (d);
4659- if (md->screenPrivateIndex < 0)
4660- {
4661- free (md);
4662- return FALSE;
4663- }
4664-
4665- md->winChangeStateAtom = XInternAtom (d->display, "WM_CHANGE_STATE", 0);
4666-
4667- WRAP (md, d, handleEvent, minHandleEvent);
4668-
4669- d->base.privates[displayPrivateIndex].ptr = md;
4670-
4671- return TRUE;
4672-}
4673-
4674-static void
4675-minFiniDisplay (CompPlugin *p,
4676- CompDisplay *d)
4677-{
4678- MIN_DISPLAY (d);
4679-
4680- freeScreenPrivateIndex (d, md->screenPrivateIndex);
4681-
4682- UNWRAP (md, d, handleEvent);
4683-
4684- free (md);
4685-}
4686-
4687-static const CompMetadataOptionInfo minScreenOptionInfo[] = {
4688- { "speed", "float", "<min>0.1</min>", 0, 0 },
4689- { "timestep", "float", "<min>0.1</min>", 0, 0 },
4690- { "window_match", "match", 0, 0, 0 },
4691- { "shade_resistance", "int", "<min>0</min><max>100</max>", 0, 0 }
4692-};
4693-
4694-static Bool
4695-minInitScreen (CompPlugin *p,
4696- CompScreen *s)
4697-{
4698- MinScreen *ms;
4699-
4700- MIN_DISPLAY (s->display);
4701-
4702- ms = malloc (sizeof (MinScreen));
4703- if (!ms)
4704- return FALSE;
4705-
4706- if (!compInitScreenOptionsFromMetadata (s,
4707- &minMetadata,
4708- minScreenOptionInfo,
4709- ms->opt,
4710- MIN_SCREEN_OPTION_NUM))
4711- {
4712- free (ms);
4713- return FALSE;
4714- }
4715-
4716- ms->windowPrivateIndex = allocateWindowPrivateIndex (s);
4717- if (ms->windowPrivateIndex < 0)
4718- {
4719- compFiniScreenOptions (s, ms->opt, MIN_SCREEN_OPTION_NUM);
4720- free (ms);
4721- return FALSE;
4722- }
4723-
4724- ms->moreAdjust = FALSE;
4725- ms->shadeStep = ms->opt[MIN_SCREEN_OPTION_SHADE_RESISTANCE].rest.i.max -
4726- ms->opt[MIN_SCREEN_OPTION_SHADE_RESISTANCE].value.i + 1;
4727-
4728- WRAP (ms, s, preparePaintScreen, minPreparePaintScreen);
4729- WRAP (ms, s, donePaintScreen, minDonePaintScreen);
4730- WRAP (ms, s, paintOutput, minPaintOutput);
4731- WRAP (ms, s, paintWindow, minPaintWindow);
4732- WRAP (ms, s, damageWindowRect, minDamageWindowRect);
4733- WRAP (ms, s, focusWindow, minFocusWindow);
4734-
4735- s->base.privates[md->screenPrivateIndex].ptr = ms;
4736-
4737- return TRUE;
4738-}
4739-
4740-static void
4741-minFiniScreen (CompPlugin *p,
4742- CompScreen *s)
4743-{
4744- MIN_SCREEN (s);
4745-
4746- freeWindowPrivateIndex (s, ms->windowPrivateIndex);
4747-
4748- UNWRAP (ms, s, preparePaintScreen);
4749- UNWRAP (ms, s, donePaintScreen);
4750- UNWRAP (ms, s, paintOutput);
4751- UNWRAP (ms, s, paintWindow);
4752- UNWRAP (ms, s, damageWindowRect);
4753- UNWRAP (ms, s, focusWindow);
4754-
4755- compFiniScreenOptions (s, ms->opt, MIN_SCREEN_OPTION_NUM);
4756-
4757- free (ms);
4758-}
4759-
4760-static Bool
4761-minInitWindow (CompPlugin *p,
4762- CompWindow *w)
4763-{
4764- MinWindow *mw;
4765-
4766- MIN_SCREEN (w->screen);
4767-
4768- mw = malloc (sizeof (MinWindow));
4769- if (!mw)
4770- return FALSE;
4771-
4772- mw->xScale = mw->yScale = 1.0f;
4773- mw->tx = mw->ty = 0.0f;
4774- mw->adjust = FALSE;
4775- mw->xVelocity = mw->yVelocity = 0.0f;
4776- mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;
4777-
4778- mw->unmapCnt = 0;
4779-
4780- mw->ignoreDamage = FALSE;
4781-
4782- if (w->state & CompWindowStateHiddenMask)
4783- {
4784- if (w->shaded)
4785- {
4786- mw->state = mw->newState = NormalState;
4787- mw->shade = 0;
4788- mw->region = XCreateRegion ();
4789- }
4790- else
4791- {
4792- mw->state = mw->newState = minGetWindowState (w);
4793- mw->shade = MAXSHORT;
4794- mw->region = NULL;
4795- }
4796- }
4797- else
4798- {
4799- mw->state = mw->newState = NormalState;
4800- mw->shade = MAXSHORT;
4801- mw->region = NULL;
4802- }
4803-
4804- w->base.privates[ms->windowPrivateIndex].ptr = mw;
4805-
4806- return TRUE;
4807-}
4808-
4809-static void
4810-minFiniWindow (CompPlugin *p,
4811- CompWindow *w)
4812-{
4813- MIN_WINDOW (w);
4814-
4815- mw->ignoreDamage = TRUE;
4816- while (mw->unmapCnt--)
4817- unmapWindow (w);
4818- mw->ignoreDamage = FALSE;
4819-
4820- if (mw->region)
4821- XDestroyRegion (mw->region);
4822-
4823- free (mw);
4824-}
4825-
4826-static CompBool
4827-minInitObject (CompPlugin *p,
4828- CompObject *o)
4829-{
4830- static InitPluginObjectProc dispTab[] = {
4831- (InitPluginObjectProc) 0, /* InitCore */
4832- (InitPluginObjectProc) minInitDisplay,
4833- (InitPluginObjectProc) minInitScreen,
4834- (InitPluginObjectProc) minInitWindow
4835- };
4836-
4837- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
4838-}
4839-
4840-static void
4841-minFiniObject (CompPlugin *p,
4842- CompObject *o)
4843-{
4844- static FiniPluginObjectProc dispTab[] = {
4845- (FiniPluginObjectProc) 0, /* FiniCore */
4846- (FiniPluginObjectProc) minFiniDisplay,
4847- (FiniPluginObjectProc) minFiniScreen,
4848- (FiniPluginObjectProc) minFiniWindow
4849- };
4850-
4851- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
4852-}
4853-
4854-static CompOption *
4855-minGetObjectOptions (CompPlugin *plugin,
4856- CompObject *object,
4857- int *count)
4858-{
4859- static GetPluginObjectOptionsProc dispTab[] = {
4860- (GetPluginObjectOptionsProc) 0, /* GetCoreOptions */
4861- (GetPluginObjectOptionsProc) 0, /* GetDisplayOptions */
4862- (GetPluginObjectOptionsProc) minGetScreenOptions
4863- };
4864-
4865- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
4866- (void *) (*count = 0), (plugin, object, count));
4867-}
4868-
4869-static CompBool
4870-minSetObjectOption (CompPlugin *plugin,
4871- CompObject *object,
4872- const char *name,
4873- CompOptionValue *value)
4874-{
4875- static SetPluginObjectOptionProc dispTab[] = {
4876- (SetPluginObjectOptionProc) 0, /* SetCoreOption */
4877- (SetPluginObjectOptionProc) 0, /* SetDisplayOption */
4878- (SetPluginObjectOptionProc) minSetScreenOption
4879- };
4880-
4881- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), FALSE,
4882- (plugin, object, name, value));
4883-}
4884-
4885-static Bool
4886-minInit (CompPlugin *p)
4887-{
4888- if (!compInitPluginMetadataFromInfo (&minMetadata,
4889- p->vTable->name, 0, 0,
4890- minScreenOptionInfo,
4891- MIN_SCREEN_OPTION_NUM))
4892- return FALSE;
4893-
4894- displayPrivateIndex = allocateDisplayPrivateIndex ();
4895- if (displayPrivateIndex < 0)
4896- {
4897- compFiniMetadata (&minMetadata);
4898- return FALSE;
4899- }
4900-
4901- compAddMetadataFromFile (&minMetadata, p->vTable->name);
4902-
4903- return TRUE;
4904-}
4905-
4906-static void
4907-minFini (CompPlugin *p)
4908-{
4909- freeDisplayPrivateIndex (displayPrivateIndex);
4910- compFiniMetadata (&minMetadata);
4911-}
4912-
4913-static CompMetadata *
4914-minGetMetadata (CompPlugin *plugin)
4915-{
4916- return &minMetadata;
4917-}
4918-
4919-static CompPluginVTable minVTable = {
4920- "minimize",
4921- minGetMetadata,
4922- minInit,
4923- minFini,
4924- minInitObject,
4925- minFiniObject,
4926- minGetObjectOptions,
4927- minSetObjectOption
4928-};
4929-
4930-CompPluginVTable *
4931-getCompPluginInfo20070830 (void)
4932-{
4933- return &minVTable;
4934-}
4935
4936=== removed file 'legacy/minimize.xml.in'
4937--- legacy/minimize.xml.in 2009-03-15 05:15:26 +0000
4938+++ legacy/minimize.xml.in 1970-01-01 00:00:00 +0000
4939@@ -1,43 +0,0 @@
4940-<compiz>
4941- <plugin name="minimize">
4942- <_short>Minimize Effect</_short>
4943- <_long>Transform windows when they are minimized and unminimized</_long>
4944- <feature>windowanimations</feature>
4945- <deps>
4946- <relation type="before">
4947- <plugin>cube</plugin>
4948- <plugin>scale</plugin>
4949- </relation>
4950- </deps>
4951- <screen>
4952- <option name="speed" type="float">
4953- <_short>Speed</_short>
4954- <_long>Minimize speed</_long>
4955- <default>1.5</default>
4956- <min>0.1</min>
4957- <max>50.0</max>
4958- <precision>0.1</precision>
4959- </option>
4960- <option name="timestep" type="float">
4961- <_short>Timestep</_short>
4962- <_long>Minimize timestep</_long>
4963- <default>0.5</default>
4964- <min>0.1</min>
4965- <max>50.0</max>
4966- <precision>0.1</precision>
4967- </option>
4968- <option name="window_match" type="match">
4969- <_short>Minimize Windows</_short>
4970- <_long>Windows that should be transformed when minimized</_long>
4971- <default>toolbar | utility | dialog | normal</default>
4972- </option>
4973- <option name="shade_resistance" type="int">
4974- <_short>Shade Resistance</_short>
4975- <_long>Shade resistance</_long>
4976- <default>75</default>
4977- <min>0</min>
4978- <max>100</max>
4979- </option>
4980- </screen>
4981- </plugin>
4982-</compiz>
4983
4984=== removed file 'legacy/privatemetadata.h'
4985--- legacy/privatemetadata.h 2009-03-15 23:01:28 +0000
4986+++ legacy/privatemetadata.h 1970-01-01 00:00:00 +0000
4987@@ -1,40 +0,0 @@
4988-/*
4989- * Copyright © 2008 Dennis Kasprzyk
4990- *
4991- * Permission to use, copy, modify, distribute, and sell this software
4992- * and its documentation for any purpose is hereby granted without
4993- * fee, provided that the above copyright notice appear in all copies
4994- * and that both that copyright notice and this permission notice
4995- * appear in supporting documentation, and that the name of
4996- * Dennis Kasprzyk not be used in advertising or publicity pertaining to
4997- * distribution of the software without specific, written prior permission.
4998- * Dennis Kasprzyk makes no representations about the suitability of this
4999- * software for any purpose. It is provided "as is" without express or
5000- * implied warranty.
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches