1
From: Danny Baumann <dannybaumann@web.de>
2
Date: Tue, 7 Oct 2008 06:32:46 +0000 (+0200)
3
Subject: Added options for making scale's key and button bindings adding as toggle switches.
4
X-Git-Url: http://gitweb.compiz-fusion.org/?p=compiz;a=commitdiff_plain;h=d2bd7d5f1adb93481fcb8917b5e480e45bce4d48;hp=46793cb5f3f21a3153d41aaf6b6e54c6379641d9
6
Added options for making scale's key and button bindings adding as toggle switches.
9
diff --git a/include/compiz-scale.h b/include/compiz-scale.h
10
index 528bfa8..603612f 100644
11
--- a/include/compiz-scale.h
12
+++ b/include/compiz-scale.h
17
-#define SCALE_ABIVERSION 20080301
18
+#define SCALE_ABIVERSION 20081007
20
#define SCALE_STATE_NONE 0
21
#define SCALE_STATE_OUT 1
22
@@ -73,7 +73,9 @@ typedef struct _SlotArea {
23
#define SCALE_DISPLAY_OPTION_INITIATE_OUTPUT_KEY 13
24
#define SCALE_DISPLAY_OPTION_SHOW_DESKTOP 14
25
#define SCALE_DISPLAY_OPTION_RELAYOUT 15
26
-#define SCALE_DISPLAY_OPTION_NUM 16
27
+#define SCALE_DISPLAY_OPTION_KEY_BINDINGS_TOGGLE 16
28
+#define SCALE_DISPLAY_OPTION_BUTTON_BINDINGS_TOGGLE 17
29
+#define SCALE_DISPLAY_OPTION_NUM 18
31
typedef struct _ScaleDisplay {
32
int screenPrivateIndex;
33
diff --git a/metadata/scale.xml.in b/metadata/scale.xml.in
34
index c551aa3..c8b574a 100644
35
--- a/metadata/scale.xml.in
36
+++ b/metadata/scale.xml.in
39
<allowed edgednd="true"/>
41
+ <option name="key_bindings_toggle" type="bool">
42
+ <_short>Key Bindings Toggle Scale Mode</_short>
43
+ <_long>Key bindings toggle scale mode instead of enabling it when pressed and disabling it when released.</_long>
44
+ <default>false</default>
46
+ <option name="button_bindings_toggle" type="bool">
47
+ <_short>Button Bindings Toggle Scale Mode</_short>
48
+ <_long>Button bindings toggle scale mode instead of enabling it when pressed and disabling it when released.</_long>
49
+ <default>false</default>
51
<option name="initiate_key" type="key">
52
<_short>Initiate Window Picker</_short>
53
<_long>Layout and start transforming windows</_long>
54
diff --git a/plugins/scale.c b/plugins/scale.c
55
index aea2ead..8488c75 100644
58
@@ -1019,20 +1019,32 @@ scaleTerminate (CompDisplay *d,
62
+ Bool terminate = TRUE;
66
- xid = getIntOptionNamed (option, nOption, "root", 0);
67
+ if (action->state & CompActionStateTermKey)
68
+ if (sd->opt[SCALE_DISPLAY_OPTION_KEY_BINDINGS_TOGGLE].value.b)
71
- for (s = d->screens; s; s = s->next)
74
+ if (action->state & CompActionStateTermButton)
75
+ if (sd->opt[SCALE_DISPLAY_OPTION_BUTTON_BINDINGS_TOGGLE].value.b)
78
- if (xid && s->root != xid)
82
+ xid = getIntOptionNamed (option, nOption, "root", 0);
85
+ for (s = d->screens; s; s = s->next)
89
+ if (xid && s->root != xid)
97
removeScreenGrab (s, ss->grabIndex, 0);
98
@@ -1196,6 +1208,26 @@ scaleInitiateCommon (CompScreen *s,
102
+scaleInitiateShouldTerminate (CompDisplay *d,
103
+ CompActionState state)
107
+ if (state & EDGE_STATE)
110
+ if (state & CompActionStateInitKey)
111
+ if (sd->opt[SCALE_DISPLAY_OPTION_KEY_BINDINGS_TOGGLE].value.b)
114
+ if (state & CompActionStateInitButton)
115
+ if (sd->opt[SCALE_DISPLAY_OPTION_BUTTON_BINDINGS_TOGGLE].value.b)
122
scaleInitiate (CompDisplay *d,
124
CompActionState state,
125
@@ -1217,7 +1249,7 @@ scaleInitiate (CompDisplay *d,
126
ss->type = ScaleTypeNormal;
127
return scaleInitiateCommon (s, action, state, option, nOption);
129
- else if (state & EDGE_STATE)
130
+ else if (scaleInitiateShouldTerminate (d, state))
132
if (ss->type == ScaleTypeNormal)
133
return scaleTerminate (s->display, action,
134
@@ -1250,7 +1282,7 @@ scaleInitiateAll (CompDisplay *d,
135
ss->type = ScaleTypeAll;
136
return scaleInitiateCommon (s, action, state, option, nOption);
138
- else if (state & EDGE_STATE)
139
+ else if (scaleInitiateShouldTerminate (d, state))
141
if (ss->type == ScaleTypeAll)
142
return scaleTerminate (s->display, action,
143
@@ -1292,7 +1324,7 @@ scaleInitiateGroup (CompDisplay *d,
144
return scaleInitiateCommon (s, action, state, option, nOption);
147
- else if (state & EDGE_STATE)
148
+ else if (scaleInitiateShouldTerminate (d, state))
150
if (ss->type == ScaleTypeGroup)
151
return scaleTerminate (s->display, action,
152
@@ -1325,7 +1357,7 @@ scaleInitiateOutput (CompDisplay *d,
153
ss->type = ScaleTypeOutput;
154
return scaleInitiateCommon (s, action, state, option, nOption);
156
- else if (state & EDGE_STATE)
157
+ else if (scaleInitiateShouldTerminate (d, state))
159
if (ss->type == ScaleTypeOutput)
160
return scaleTerminate (s->display, action,
161
@@ -1933,7 +1965,9 @@ static const CompMetadataOptionInfo scaleDisplayOptionInfo[] = {
162
scaleInitiateOutput, scaleTerminate },
163
{ "initiate_output_key", "key", 0, scaleInitiateOutput, scaleTerminate },
164
{ "show_desktop", "bool", 0, 0, 0 },
165
- { "relayout_slots", "action", 0, scaleRelayoutSlots, 0 }
166
+ { "relayout_slots", "action", 0, scaleRelayoutSlots, 0 },
167
+ { "key_bindings_toggle", "bool", 0, 0, 0 },
168
+ { "button_bindings_toggle", "bool", 0, 0, 0 }