[compiz] Flat file backend (ini)
David Reveman
davidr at novell.com
Mon Mar 5 04:57:39 PST 2007
On Sun, 2007-03-04 at 22:47 +0100, Gerd Kohlberger wrote:
> David Reveman schrieb:
> > hm, you're currently suppose to use different call-back functions for
> > this.
> >
> > e.g. if you want to know the difference between move or delete do:
> >
> > addFileWatch (d, path, NOTIFY_MOVE_MASK, fileMovedCallBackFunc, (void *) data);
> > addFileWatch (d, path, NOTIFY_DELETE_MASK, fileDeleteCallBackFunc, (void *) data);
> >
> > instead of:
> >
> > addFileWatch (d, path, NOTIFY_MOVE_MASK | NOTIFY_DELETE_MASK, fileRemovedCallBackFunc, (void *) data);
> >
> >> Currently the name variable in the callback sends the event->name of the inotify struct,
> >> but that's not very useful. eg. if you watch two files directly, there is no way to distinguish
> >> between them in the callback, because event->name will be empty.
> >
> > if you want to watch two different files you should currently use two
> > different call-back functions. The name variable is intended for when
> > you're watching directories.
> >
> >> So the new CompNotifyEvent will send the watch path if a file is watched,
> >> or the relative filename if a directory is watched.
> >>
> >> I think this can be very useful for the ini plugin and for other plugins as well.
> >
> > I'm not sure we want to do these changes as unless I'm misunderstanding
> > something the current interface provides the same functionality. What
> > are the advantages of changing this way?
>
> Yes the functionality is already there, but with this patch it's just more convenient
> to monitor more than just 2 or 3 files.
> I modified inotify while playing around with the ini plugin and do doing it with the
> current interface will get you lots of callback functions which isn't really necessary.
>
> e.g if you listen for 3 different events in 5 files, you would need 15 callbacks in a plugin.
Well if you need to handle all those cases differently, you need to
dispatch into 15 different segments of code and whether that is done in
the file watch interface or in your plugin shouldn't matter much. One
call back can be convenient when you're doing almost the same thing for
all those 15 cases and it makes it easy to share code. You can share
just as much code the other way too, you just have to use more
functions. If you want to use only one call back function and do the
dispatch in your plugin then that's easily done by providing dispatch
details in the user-data parameter.
I like the current interface because it's simple but still efficient.
Reporting exactly what caused the file watch to trigger might be trivial
in the inotify plugin but it might make another file watch handler
unnecessarily complex.
>
> You don't have to include the patch, i just thought it might be useful, but it seems Mike has
> already an ini version which works with the current interface.
OK, good. If I'm presented with an example where the current interface
definitely cause more trouble than necessary, then I'm of course
interested in changing the interface.
- David
More information about the compiz
mailing list