[compiz] [PATCH] dbus terminate action
David Reveman
davidr at novell.com
Tue Oct 10 07:56:19 PDT 2006
Looks OK. I've fixed the indention and change the deactivate parameter
to be an activate parameter instead as I didn't like the double
negation. I've pushed out the changes, you can compare your diff to the
one I pushed out to see how the indention was wrong.
-David
On Tue, 2006-10-10 at 03:29 +0100, Mike Dransfield wrote:
> I was always annoyed that you couldn't terminate an action with dbus so
> I have
> written this patch which fixes that. Hopefully this can be included.
>
> I wrote the patch trying to repeat as little code as possible so I just
> added a boolean
> parameter to the dbusHandleActivateMessage and changed the name to
> dbusHandleActivateDeactivateMessage. You could probably change the
> deactivate
> parameter to activate depending on how your mind works.
>
> I have also updated the comments to show this as well as to change it so
> that the
> examples work with COW.
>
>
> plain text document attachment (dbus-deactivate-method_dbus.c.diff)
> diff --git a/plugins/dbus.c b/plugins/dbus.c
> index 46a7bcf..4892df4 100644
> --- a/plugins/dbus.c
> +++ b/plugins/dbus.c
> @@ -34,6 +34,7 @@ #include <compiz.h>
>
> #define COMPIZ_DBUS_SERVICE_NAME "org.freedesktop.compiz"
> #define COMPIZ_DBUS_ACTIVATE_MEMBER_NAME "activate"
> +#define COMPIZ_DBUS_DEACTIVATE_MEMBER_NAME "deactivate"
> #define COMPIZ_DBUS_SET_MEMBER_NAME "set"
> #define COMPIZ_DBUS_GET_MEMBER_NAME "get"
>
> @@ -126,13 +127,34 @@ dbusGetOptionsFromPath (CompDisplay *d,
> * dbus-send --type=method_call --dest=org.freedesktop.compiz \
> * /org/freedesktop/compiz/rotate/allscreens/rotate_to \
> * org.freedesktop.compiz.activate \
> - * string:'root' int32:0x52 string:'face' int32:1
> + * string:'root' \
> + * int32:`xwininfo -root | grep id: | awk '{ print $4 }'` \
> + * string:'face' int32:1
> + *
> + *
> + * You can also call the terminate function
> + *
> + * Example unfold and refold cube:
> + * dbus-send --type=method_call --dest=org.freedesktop.compiz \
> + * /org/freedesktop/compiz/cube/allscreens/unfold \
> + * org.freedesktop.compiz.activate \
> + * string:'root' \
> + * int32:`xwininfo -root | grep id: | awk '{ print $4 }'` \
> + * string:'face' int32:1
> + *
> + * dbus-send --type=method_call --dest=org.freedesktop.compiz \
> + * /org/freedesktop/compiz/cube/allscreens/unfold \
> + * org.freedesktop.compiz.deactivate \
> + * string:'root' \
> + * int32:`xwininfo -root | grep id: | awk '{ print $4 }'` \
> + * string:'face' int32:1
> */
> static Bool
> -dbusHandleActivateMessage (DBusConnection *connection,
> +dbusHandleActivateDeactivateMessage (DBusConnection *connection,
> DBusMessage *message,
> CompDisplay *d,
> - char **path)
> + char **path,
> + Bool deactivate)
> {
> CompOption *option;
> int nOption;
> @@ -152,8 +174,15 @@ dbusHandleActivateMessage (DBusConnectio
> if (option->type != CompOptionTypeAction)
> return FALSE;
>
> - if (!option->value.action.initiate)
> - return FALSE;
> + if (!deactivate)
> + {
> + if (!option->value.action.initiate)
> + return FALSE;
> + }
> + else {
> + if (!option->value.action.terminate)
> + return FALSE;
> + }
>
> if (dbus_message_iter_init (message, &iter))
> {
> @@ -238,10 +267,20 @@ dbusHandleActivateMessage (DBusConnectio
> } while (dbus_message_iter_has_next (&iter));
> }
>
> - (*option->value.action.initiate) (d,
> + if (!deactivate)
> + {
> + (*option->value.action.initiate) (d,
> + &option->value.action,
> + 0,
> + argument, nArgument);
> + }
> + else
> + {
> + (*option->value.action.terminate) (d,
> &option->value.action,
> 0,
> argument, nArgument);
> + }
>
> if (argument)
> free (argument);
> @@ -682,7 +721,11 @@ dbusHandleMessage (DBusConnection *conne
>
> if (dbus_message_has_member (message, COMPIZ_DBUS_ACTIVATE_MEMBER_NAME))
> {
> - status = dbusHandleActivateMessage (connection, message, d, &path[3]);
> + status = dbusHandleActivateDeactivateMessage (connection, message, d, &path[3], FALSE);
> + }
> + else if (dbus_message_has_member (message, COMPIZ_DBUS_DEACTIVATE_MEMBER_NAME))
> + {
> + status = dbusHandleActivateDeactivateMessage (connection, message, d, &path[3], TRUE);
> }
> else if (dbus_message_has_member (message, COMPIZ_DBUS_SET_MEMBER_NAME))
> {
> _______________________________________________
> compiz mailing list
> compiz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/compiz
More information about the compiz
mailing list