Merge lp:~gala-dev/gala/hotcorners into lp:gala
- hotcorners
- Merge into trunk
Proposed by
Tom Beckmann
Status: | Merged |
---|---|
Merged at revision: | 180 |
Proposed branch: | lp:~gala-dev/gala/hotcorners |
Merge into: | lp:gala |
Diff against target: |
288 lines (+149/-35) 5 files modified
data/org.pantheon.desktop.gala.gschema.xml (+33/-4) src/Plugin.vala (+85/-15) src/Settings.vala (+6/-1) src/Utils.vala (+24/-14) src/Widgets/WorkspaceView.vala (+1/-1) |
To merge this branch: | bzr merge lp:~gala-dev/gala/hotcorners |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rico Tzschichholz | Approve | ||
Review via email: mp+116837@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
lp:~gala-dev/gala/hotcorners
updated
- 177. By Tom Beckmann
-
Add action system for hot corner configuration
- 178. By Tom Beckmann
-
Remove workspace related actions
- 179. By Rico Tzschichholz
-
Some refactoring and clean up
Revision history for this message
Rico Tzschichholz (ricotz) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/org.pantheon.desktop.gala.gschema.xml' |
2 | --- data/org.pantheon.desktop.gala.gschema.xml 2012-07-26 07:04:03 +0000 |
3 | +++ data/org.pantheon.desktop.gala.gschema.xml 2012-07-28 06:42:17 +0000 |
4 | @@ -1,10 +1,39 @@ |
5 | <?xml version="1.0" encoding="UTF-8"?> |
6 | <schemalist> |
7 | + <enum id="GalaActionType"> |
8 | + <value nick='none' value="0" /> |
9 | + <value nick="show-workspace-view" value="1" /> |
10 | + <value nick="maximize-current" value="2" /> |
11 | + <value nick="minimize-current" value="3" /> |
12 | + <value nick="open-launcher" value="4" /> |
13 | + <value nick="custom-command" value="5" /> |
14 | + </enum> |
15 | + |
16 | <schema path="/org/pantheon/desktop/gala/behavior/" id="org.pantheon.desktop.gala.behavior" gettext-domain="gala"> |
17 | - <key type="b" name="enable-manager-corner"> |
18 | - <default>false</default> |
19 | - <summary>Make the lower right a hot corner to reveal the manager</summary> |
20 | - <description>This turns the lower right corner to a hot corner, showing some icons allowing you to do tasks like window tiling</description> |
21 | + <key enum="GalaActionType" name="hotcorner-topleft"> |
22 | + <default>'none'</default> |
23 | + <summary>Action for the top left corner</summary> |
24 | + <description></description> |
25 | + </key> |
26 | + <key enum="GalaActionType" name="hotcorner-topright"> |
27 | + <default>'none'</default> |
28 | + <summary>Action for the top right corner</summary> |
29 | + <description></description> |
30 | + </key> |
31 | + <key enum="GalaActionType" name="hotcorner-bottomleft"> |
32 | + <default>'none'</default> |
33 | + <summary>Action for the bottom left corner</summary> |
34 | + <description></description> |
35 | + </key> |
36 | + <key enum="GalaActionType" name="hotcorner-bottomright"> |
37 | + <default>'none'</default> |
38 | + <summary>Action for the bottom right corner</summary> |
39 | + <description></description> |
40 | + </key> |
41 | + <key type="s" name="hotcorner-custom-command"> |
42 | + <default>''</default> |
43 | + <summary>The command that will be executed for the hotcorner action 'custom-command'</summary> |
44 | + <description></description> |
45 | </key> |
46 | <key type="b" name="edge-tiling"> |
47 | <default>true</default> |
48 | |
49 | === modified file 'src/Plugin.vala' |
50 | --- src/Plugin.vala 2012-07-26 22:39:40 +0000 |
51 | +++ src/Plugin.vala 2012-07-28 06:42:17 +0000 |
52 | @@ -19,6 +19,22 @@ |
53 | |
54 | namespace Gala |
55 | { |
56 | + public enum ActionType |
57 | + { |
58 | + NONE = 0, |
59 | + SHOW_WORKSPACE_VIEW, |
60 | + MAXIMIZE_CURRENT, |
61 | + MINIMIZE_CURRENT, |
62 | + OPEN_LAUNCHER, |
63 | + CUSTOM_COMMAND |
64 | + } |
65 | + |
66 | + public enum InputArea { |
67 | + NONE, |
68 | + FULLSCREEN, |
69 | + HOT_CORNER |
70 | + } |
71 | + |
72 | public class Plugin : Meta.Plugin |
73 | { |
74 | WindowSwitcher winswitcher; |
75 | @@ -116,38 +132,50 @@ |
76 | Utils.reload_shadow (); |
77 | ShadowSettings.get_default ().notify.connect (Utils.reload_shadow); |
78 | |
79 | - /*hot corner*/ |
80 | + /*hot corner, getting enum values from GraniteServicesSettings did not work, so we use GSettings directly*/ |
81 | var geometry = screen.get_monitor_geometry (screen.get_primary_monitor ()); |
82 | |
83 | - var hot_corner = new Clutter.Rectangle (); |
84 | - hot_corner.x = geometry.x + geometry.width - 1; |
85 | - hot_corner.y = geometry.y + geometry.height - 1; |
86 | + add_hotcorner (geometry.x, geometry.y, "hotcorner-topleft"); |
87 | + add_hotcorner (geometry.x + geometry.width - 1, geometry.y, "hotcorner-topright"); |
88 | + add_hotcorner (geometry.x, geometry.y + geometry.height - 1, "hotcorner-bottomleft"); |
89 | + add_hotcorner (geometry.x + geometry.width - 1, geometry.y + geometry.height - 1, "hotcorner-bottomright"); |
90 | + |
91 | + update_input_area (); |
92 | + |
93 | + BehaviorSettings.get_default ().schema.changed.connect ((key) => update_input_area ()); |
94 | + } |
95 | + |
96 | + void add_hotcorner (float x, float y, string key) |
97 | + { |
98 | + var hot_corner = new Clutter.Actor (); |
99 | + hot_corner.x = x; |
100 | + hot_corner.y = y; |
101 | hot_corner.width = 1; |
102 | hot_corner.height = 1; |
103 | hot_corner.opacity = 0; |
104 | hot_corner.reactive = true; |
105 | |
106 | + Compositor.get_stage_for_screen (get_screen ()).add_child (hot_corner); |
107 | + |
108 | hot_corner.enter_event.connect (() => { |
109 | - workspace_view.show (); |
110 | + perform_action ((ActionType)BehaviorSettings.get_default ().schema.get_enum (key)); |
111 | return false; |
112 | }); |
113 | - |
114 | - stage.add_child (hot_corner); |
115 | - |
116 | - update_input_area (); |
117 | - |
118 | - BehaviorSettings.get_default ().notify["enable-manager-corner"].connect (update_input_area); |
119 | } |
120 | |
121 | public void update_input_area () |
122 | { |
123 | - if (BehaviorSettings.get_default ().enable_manager_corner) |
124 | - Utils.set_input_area (get_screen (), Utils.InputArea.HOT_CORNER); |
125 | + var schema = BehaviorSettings.get_default ().schema; |
126 | + |
127 | + if (schema.get_enum ("hotcorner-topleft") != ActionType.NONE || |
128 | + schema.get_enum ("hotcorner-topright") != ActionType.NONE || |
129 | + schema.get_enum ("hotcorner-bottomleft") != ActionType.NONE || |
130 | + schema.get_enum ("hotcorner-bottomright") != ActionType.NONE) |
131 | + Utils.set_input_area (get_screen (), InputArea.HOT_CORNER); |
132 | else |
133 | - Utils.set_input_area (get_screen (), Utils.InputArea.NONE); |
134 | + Utils.set_input_area (get_screen (), InputArea.NONE); |
135 | } |
136 | |
137 | - |
138 | public void move_window (Window? window, MotionDirection direction) |
139 | { |
140 | if (window == null) |
141 | @@ -213,6 +241,48 @@ |
142 | win.clear_effects ();*/ |
143 | } |
144 | |
145 | + public void perform_action (ActionType type) |
146 | + { |
147 | + var screen = get_screen (); |
148 | + var display = screen.get_display (); |
149 | + var current = display.get_focus_window (); |
150 | + |
151 | + switch (type) { |
152 | + case ActionType.SHOW_WORKSPACE_VIEW: |
153 | + workspace_view.show (); |
154 | + break; |
155 | + case ActionType.MAXIMIZE_CURRENT: |
156 | + if (current == null) |
157 | + break; |
158 | + if (current.get_maximized () == (MaximizeFlags.HORIZONTAL | MaximizeFlags.VERTICAL)) |
159 | + current.unmaximize (MaximizeFlags.HORIZONTAL | MaximizeFlags.VERTICAL); |
160 | + else |
161 | + current.maximize (MaximizeFlags.HORIZONTAL | MaximizeFlags.VERTICAL); |
162 | + break; |
163 | + case ActionType.MINIMIZE_CURRENT: |
164 | + if (current != null) |
165 | + current.minimize (); |
166 | + break; |
167 | + case ActionType.OPEN_LAUNCHER: |
168 | + try { |
169 | + Process.spawn_command_line_async (BehaviorSettings.get_default ().panel_main_menu_action); |
170 | + } catch (Error e) { |
171 | + warning (e.message); |
172 | + } |
173 | + break; |
174 | + case ActionType.CUSTOM_COMMAND: |
175 | + try { |
176 | + Process.spawn_command_line_async (BehaviorSettings.get_default ().hotcorner_custom_command); |
177 | + } catch (Error e) { |
178 | + warning (e.message); |
179 | + } |
180 | + break; |
181 | + default: |
182 | + warning ("Trying to run unknown action"); |
183 | + break; |
184 | + } |
185 | + } |
186 | + |
187 | /* |
188 | * effects |
189 | */ |
190 | |
191 | === modified file 'src/Settings.vala' |
192 | --- src/Settings.vala 2012-07-26 07:04:03 +0000 |
193 | +++ src/Settings.vala 2012-07-28 06:42:17 +0000 |
194 | @@ -23,7 +23,12 @@ |
195 | public string panel_main_menu_action { get; set; } |
196 | public string toggle_recording_action { get; set; } |
197 | public string overlay_action { get; set; } |
198 | - public bool enable_manager_corner { get; set; } |
199 | + public string hotcorner_custom_command { get; set; } |
200 | + |
201 | + public ActionType hotcorner_topleft { get; set; } |
202 | + public ActionType hotcorner_topright { get; set; } |
203 | + public ActionType hotcorner_bottomleft { get; set; } |
204 | + public ActionType hotcorner_bottomright { get; set; } |
205 | |
206 | static BehaviorSettings? instance = null; |
207 | |
208 | |
209 | === modified file 'src/Utils.vala' |
210 | --- src/Utils.vala 2012-07-26 07:04:03 +0000 |
211 | +++ src/Utils.vala 2012-07-28 06:42:17 +0000 |
212 | @@ -1,14 +1,9 @@ |
213 | using Meta; |
214 | |
215 | +using Gala; |
216 | + |
217 | namespace Gala.Utils |
218 | { |
219 | - |
220 | - public enum InputArea { |
221 | - NONE, |
222 | - FULLSCREEN, |
223 | - HOT_CORNER |
224 | - } |
225 | - |
226 | /* |
227 | * Reload shadow settings |
228 | */ |
229 | @@ -105,24 +100,39 @@ |
230 | { |
231 | var display = screen.get_display (); |
232 | |
233 | - X.Xrectangle rect; |
234 | + X.Xrectangle[] rects = {}; |
235 | int width, height; |
236 | screen.get_size (out width, out height); |
237 | var geometry = screen.get_monitor_geometry (screen.get_primary_monitor ()); |
238 | |
239 | switch (area) { |
240 | case InputArea.FULLSCREEN: |
241 | - rect = {0, 0, (ushort)width, (ushort)height}; |
242 | - break; |
243 | - case InputArea.HOT_CORNER: //leave one pix in the bottom left |
244 | - rect = {(short)(geometry.x + geometry.width - 1), (short)(geometry.y + geometry.height - 1), 1, 1}; |
245 | - break; |
246 | + X.Xrectangle rect = {0, 0, (ushort)width, (ushort)height}; |
247 | + rects = {rect}; |
248 | + break; |
249 | + case InputArea.HOT_CORNER: |
250 | + var schema = BehaviorSettings.get_default ().schema; |
251 | + |
252 | + // if ActionType is NONE make it 0 sized |
253 | + ushort tl_size = (schema.get_enum ("hotcorner-topleft") != ActionType.NONE ? 1 : 0); |
254 | + ushort tr_size = (schema.get_enum ("hotcorner-topright") != ActionType.NONE ? 1 : 0); |
255 | + ushort bl_size = (schema.get_enum ("hotcorner-bottomleft") != ActionType.NONE ? 1 : 0); |
256 | + ushort br_size = (schema.get_enum ("hotcorner-bottomright") != ActionType.NONE ? 1 : 0); |
257 | + |
258 | + X.Xrectangle topleft = {(short)geometry.x, (short)geometry.y, tl_size, tl_size}; |
259 | + X.Xrectangle topright = {(short)(geometry.x + geometry.width - 1), (short)geometry.y, tr_size, tr_size}; |
260 | + X.Xrectangle bottomleft = {(short)geometry.x, (short)(geometry.y + geometry.height - 1), bl_size, bl_size}; |
261 | + X.Xrectangle bottomright = {(short)(geometry.x + geometry.width - 1), (short)(geometry.y + geometry.height - 1), br_size, br_size}; |
262 | + |
263 | + rects = {topleft, topright, bottomleft, bottomright}; |
264 | + break; |
265 | + case InputArea.NONE: |
266 | default: |
267 | Util.empty_stage_input_region (screen); |
268 | return; |
269 | } |
270 | |
271 | - var xregion = X.Fixes.create_region (display.get_xdisplay (), {rect}); |
272 | + var xregion = X.Fixes.create_region (display.get_xdisplay (), rects); |
273 | Util.set_stage_input_region (screen, xregion); |
274 | } |
275 | |
276 | |
277 | === modified file 'src/Widgets/WorkspaceView.vala' |
278 | --- src/Widgets/WorkspaceView.vala 2012-07-26 07:04:03 +0000 |
279 | +++ src/Widgets/WorkspaceView.vala 2012-07-28 06:42:17 +0000 |
280 | @@ -294,7 +294,7 @@ |
281 | |
282 | var screen = plugin.get_screen (); |
283 | |
284 | - Utils.set_input_area (screen, Utils.InputArea.FULLSCREEN); |
285 | + Utils.set_input_area (screen, InputArea.FULLSCREEN); |
286 | plugin.begin_modal (); |
287 | |
288 | visible = true; |