[compiz] Edge + Mouse button draft patches
Mike Dransfield
mike at blueroot.co.uk
Thu Oct 19 10:51:11 PDT 2006
> (AnyButton is 0, which it might make sense to support, in which case we
> can just make edgeButton signed and a negative value will give the usual
> behavior.)
>
Adding the edgeButton to the CompAction structure was easy, I have been
having
major problems convincing gconf to not disable the button action.
Attached is my patch for gconf.c, I think there might be a bug in the
code which
means that bell, edge and edgebutton values are being reverted when
compiz is
restarted.
In the function gconfSetOption look at the CompOptionTypeAction part of the
case statement. If the action is a key or button then the
gconfSetActionValue
function is called which actually sets the internal option value as well as
checking its validity.
If the action is a bell, edge or edgebutton then the internal option
value does not
get set and the code reverts the gconf stored value to the internal
value. I can
confirm that bells get unset when using an unpatched compiz.
I fixed the edge button part by adding this line after the existing
value is
retreived
o->value.action.edgeButton = gconf_value_get_int(existingValue);
Is it a problem with gconf or am I doing something wrong?
-------------- next part --------------
diff --git a/plugins/gconf.c b/plugins/gconf.c
index ea68ce3..0d3f199 100644
--- a/plugins/gconf.c
+++ b/plugins/gconf.c
@@ -163,6 +163,8 @@ gconfSetActionValue (CompDisplay *d,
{
if (value->action.type & CompBindingTypeButton)
binding = buttonBindingToString (d, &value->action.button);
+ if (!binding)
+ value->action.button.button = -1;
}
if (!binding)
@@ -209,7 +211,7 @@ gconfSetOption (CompDisplay *d,
gconf_value_free (gvalue);
break;
case CompOptionTypeAction: {
- gchar *key1, *key2, *key3, *key4;
+ gchar *key1, *key2, *key3, *key4, *key5;
GSList *node, *list = NULL;
GConfValue *gv;
int i;
@@ -218,6 +220,7 @@ gconfSetOption (CompDisplay *d,
key2 = g_strdup_printf ("%s_%s", key, "button");
key3 = g_strdup_printf ("%s_%s", key, "bell");
key4 = g_strdup_printf ("%s_%s", key, "edge");
+ key5 = g_strdup_printf ("%s_%s", key, "edge_button");
gvalue = gconf_value_new (GCONF_VALUE_STRING);
@@ -243,6 +246,8 @@ gconfSetOption (CompDisplay *d,
gconf_value_free (gvalue);
+
+
gvalue = gconf_value_new (GCONF_VALUE_BOOL);
gconf_value_set_bool (gvalue, o->value.action.bell);
existingValue = gconf_client_get (gd->client, key3, NULL);
@@ -254,6 +259,9 @@ gconfSetOption (CompDisplay *d,
gconf_value_free (gvalue);
+
+
+
existingValue = gconf_client_get (gd->client, key4, NULL);
gvalue = gconf_value_new (GCONF_VALUE_LIST);
@@ -279,10 +287,21 @@ gconfSetOption (CompDisplay *d,
g_slist_free (list);
gconf_value_free (gvalue);
+
+ existingValue = gconf_client_get (gd->client, key5, NULL);
+ o->value.action.edgeButton = gconf_value_get_int(existingValue);
+ gvalue = gconf_value_new (GCONF_VALUE_INT);
+ gconf_value_set_int (gvalue, o->value.action.edgeButton);
+ if (!existingValue || gconf_value_compare (existingValue, gvalue))
+ gconf_client_set (gd->client, key5, gvalue, NULL);
+
+ gconf_value_free (gvalue);
+
g_free (key1);
g_free (key2);
g_free (key3);
g_free (key4);
+ g_free (key5);
} break;
case CompOptionTypeList: {
GConfValueType type;
@@ -455,11 +474,14 @@ gconfGetOptionValue (CompDisplay *d,
}
optionName = g_strdup (ptr);
-
o = compFindOption (option, nOption, optionName, 0);
if (!o)
{
- static int tail[] = { 4, 5, 7 };
+ /* tail is a list of the lengths of the extra text added to each action
+ eg key (4), bell (5), button (7), edge_button (12). If we are here
+ then we didnt find an option so it might be one of the action group
+ we are loooking for */
+ static int tail[] = { 4, 5, 7, 12 };
int i = 0;
while (i < sizeof (tail) / sizeof (tail[0]) && strlen (ptr) > tail[i])
@@ -556,7 +578,9 @@ gconfGetOptionValue (CompDisplay *d,
{
if (strcasecmp (binding, "disabled") == 0 || !*binding)
{
- value.action.type &= ~CompBindingTypeButton;
+ if (value.action.edgeButton == -1){
+ value.action.type &= ~CompBindingTypeButton;
+ }
status = TRUE;
}
else
@@ -575,6 +599,14 @@ gconfGetOptionValue (CompDisplay *d,
status = TRUE;
}
else if (o->type == CompOptionTypeAction &&
+ gvalue->type == GCONF_VALUE_INT)
+ {
+ value = o->value;
+ value.action.edgeButton = gconf_value_get_int (gvalue);
+ value.action.type |= CompBindingTypeButton;
+ status = TRUE;
+ }
+ else if (o->type == CompOptionTypeAction &&
gvalue->type == GCONF_VALUE_LIST)
{
if (gconf_value_get_list_type (gvalue) == GCONF_VALUE_STRING)
@@ -677,15 +709,15 @@ gconfInitOption (CompDisplay *d,
if (o->type == CompOptionTypeAction)
{
- static gchar *tail[] = { "key", "button", "bell", "edge" };
+ static gchar *tail[] = { "key", "button", "bell", "edge", "edge_button" };
gchar *key1;
int i;
for (i = 0; i < sizeof (tail) / sizeof (tail[0]); i++)
{
key1 = g_strdup_printf ("%s_%s", key, tail[i]);
-
- entry = gconf_client_get_entry (gd->client, key1, NULL, TRUE, NULL);
+ entry = gconf_client_get_entry (gd->client, key1, NULL, TRUE,
+NULL);
if (entry)
{
gconfGetOptionValue (d, entry);
More information about the compiz
mailing list