Merge lp:~gala-dev/gala/advanced-window-tiling into lp:gala

Proposed by Tom Beckmann
Status: Needs review
Proposed branch: lp:~gala-dev/gala/advanced-window-tiling
Merge into: lp:gala
Diff against target: 132 lines (+115/-0)
1 file modified
src/Plugin.vala (+115/-0)
To merge this branch: bzr merge lp:~gala-dev/gala/advanced-window-tiling
Reviewer Review Type Date Requested Status
Cody Garver (community) Needs Fixing
Review via email: mp+174811@code.launchpad.net

Description of the change

This adds compiz-like window tiling methods overriding the default keyboard handlers for move-to-*. The window's are tiled to a 4/8, then to 3/8 and 2/8, then to 6/8 and 5/8 and finally back to 4/8 of the screen.

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

gala/src/Plugin.vala:333.15-333.95: error: 1 extra arguments for `Meta.Rectangle Meta.Workspace.get_work_area_all_monitors ()'
   var geom = screen.get_active_workspace ().get_work_area_all_monitors (active.get_monitor ());
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
make[2]: *** [src/DBus.c] Error 1
make[1]: *** [CMakeFiles/gala.dir/all] Error 2
make: *** [all] Error 2

review: Needs Fixing
348. By Tom Beckmann

fix build error for systems with mutter < 3.8

Revision history for this message
Tom Beckmann (tombeckmann) wrote :

Fixed it.

Revision history for this message
Cody Garver (codygarver) wrote :

Needs trunk merged in a conflicts resolved

Unmerged revisions

348. By Tom Beckmann

fix build error for systems with mutter < 3.8

347. By Tom Beckmann

plugin: override move_to_* keybindings to provide more advanced tiling options

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Plugin.vala'
--- src/Plugin.vala 2013-07-14 17:20:53 +0000
+++ src/Plugin.vala 2013-07-29 21:16:26 +0000
@@ -191,6 +191,16 @@
191 191
192 KeyBinding.set_custom_handler ("switch-group", () => {});192 KeyBinding.set_custom_handler ("switch-group", () => {});
193 KeyBinding.set_custom_handler ("switch-group-backward", () => {});193 KeyBinding.set_custom_handler ("switch-group-backward", () => {});
194
195 KeyBinding.set_custom_handler ("move-to-corner-nw", () => place_window (KeyBindingAction.MOVE_TO_CORNER_NW) );
196 KeyBinding.set_custom_handler ("move-to-corner-ne", () => place_window (KeyBindingAction.MOVE_TO_CORNER_NE) );
197 KeyBinding.set_custom_handler ("move-to-corner-sw", () => place_window (KeyBindingAction.MOVE_TO_CORNER_SW) );
198 KeyBinding.set_custom_handler ("move-to-corner-se", () => place_window (KeyBindingAction.MOVE_TO_CORNER_SE) );
199 KeyBinding.set_custom_handler ("move-to-side-n", () => place_window (KeyBindingAction.MOVE_TO_SIDE_N) );
200 KeyBinding.set_custom_handler ("move-to-side-s", () => place_window (KeyBindingAction.MOVE_TO_SIDE_S) );
201 KeyBinding.set_custom_handler ("move-to-side-e", () => place_window (KeyBindingAction.MOVE_TO_SIDE_E) );
202 KeyBinding.set_custom_handler ("move-to-side-w", () => place_window (KeyBindingAction.MOVE_TO_SIDE_W) );
203 KeyBinding.set_custom_handler ("move-to-center", () => place_window (KeyBindingAction.MOVE_TO_CENTER) );
194 204
195 /*shadows*/205 /*shadows*/
196 Utils.reload_shadow ();206 Utils.reload_shadow ();
@@ -308,6 +318,111 @@
308 318
309 next.activate_with_focus (window, display.get_current_time ());319 next.activate_with_focus (window, display.get_current_time ());
310 }320 }
321
322 /**
323 * place a window on a place on the screen. If pressed again,
324 * we decrease the space two times by 1/8th and then increase it to 6/8th
325 */
326 void place_window (KeyBindingAction direction)
327 {
328 var screen = get_screen ();
329 var active = screen.get_display ().get_focus_window ();
330#if HAS_MUTTER38
331 var geom = screen.get_active_workspace ().get_work_area_for_monitor (active.get_monitor ());
332#else
333 var geom = screen.get_active_workspace ().get_work_area_all_monitors ();
334#endif
335
336 var current_dim = active.get_outer_rect ();
337 current_dim.x -= geom.x;
338 current_dim.y -= geom.y;
339 Meta.Rectangle dim = {};
340
341 if (active.maximized_horizontally || active.maximized_vertically) {
342 active.unmaximize (MaximizeFlags.HORIZONTAL | MaximizeFlags.VERTICAL);
343 // as we want to have this toggle, we're done here
344 if (direction == KeyBindingAction.MOVE_TO_CENTER)
345 return;
346 }
347
348 switch (direction) {
349 case KeyBindingAction.MOVE_TO_CORNER_NW:
350 dim = {0, 0, geom.width / 2, geom.height / 2};
351 break;
352 case KeyBindingAction.MOVE_TO_CORNER_NE:
353 dim = {geom.width / 2, 0, geom.width / 2, geom.height / 2};
354 break;
355 case KeyBindingAction.MOVE_TO_CORNER_SW:
356 dim = {0, geom.height / 2, geom.width / 2, geom.height / 2};
357 break;
358 case KeyBindingAction.MOVE_TO_CORNER_SE:
359 dim = {geom.width / 2, 0 + geom.height / 2, geom.width / 2, geom.height / 2};
360 break;
361 case KeyBindingAction.MOVE_TO_SIDE_N:
362 dim = {0, 0, geom.width, geom.height / 2};
363 break;
364 case KeyBindingAction.MOVE_TO_SIDE_S:
365 dim = {0, geom.height / 2, geom.width, geom.height / 2};
366 break;
367 case KeyBindingAction.MOVE_TO_SIDE_E:
368 dim = {geom.width / 2, 0, geom.width / 2, geom.height};
369 break;
370 case KeyBindingAction.MOVE_TO_SIDE_W:
371 dim = {0, 0, geom.width / 2, geom.height};
372 break;
373 case KeyBindingAction.MOVE_TO_CENTER:
374 active.maximize (MaximizeFlags.HORIZONTAL | MaximizeFlags.VERTICAL);
375 return;
376 default:
377 assert_not_reached ();
378 }
379
380 var vertical = direction == KeyBindingAction.MOVE_TO_SIDE_N
381 || direction == KeyBindingAction.MOVE_TO_SIDE_S;
382 var opposite = direction == KeyBindingAction.MOVE_TO_CORNER_NE
383 || direction == KeyBindingAction.MOVE_TO_CORNER_SE
384 || direction == KeyBindingAction.MOVE_TO_SIDE_E
385 || direction == KeyBindingAction.MOVE_TO_SIDE_S;
386 dim = get_multiplied (dim, current_dim, vertical, opposite);
387 active.move_resize_frame (true, dim.x + geom.x, dim.y + geom.y, dim.width, dim.height);
388 }
389
390 const double[] MULT_ORDER = {1, 0.75, 0.5, 1.5, 1.25};
391 const double[] MULT_ORDER_OPPOSITE = {1, 1.25, 1.5, 0.5, 0.75};
392 Meta.Rectangle get_multiplied (Meta.Rectangle dest_dim, Meta.Rectangle current_dim,
393 bool vertical, bool opposite)
394 {
395 bool matches = false;
396 int i;
397 var multipliers_pos = opposite ? MULT_ORDER_OPPOSITE : MULT_ORDER;
398 var multipliers_size = MULT_ORDER;
399 for (i = 0; i < multipliers_pos.length; i++) {
400 Meta.Rectangle test_dim = {
401 (int)Math.floor (dest_dim.x * (vertical ? 1 : multipliers_pos[i])),
402 (int)Math.floor (dest_dim.y * (vertical ? multipliers_pos[i] : 1)),
403 (int)Math.floor (dest_dim.width * (vertical ? 1 : multipliers_size[i])),
404 (int)Math.floor (dest_dim.height * (vertical ? multipliers_size[i] : 1))
405 };
406
407 if (test_dim.equal (current_dim)) {
408 matches = true;
409 break;
410 }
411 }
412
413 if (!matches)
414 return dest_dim;
415
416 if (++i >= multipliers_pos.length)
417 i = 0;
418
419 return {
420 (int)Math.floor (dest_dim.x * (vertical ? 1 : multipliers_pos[i])),
421 (int)Math.floor (dest_dim.y * (vertical ? multipliers_pos[i] : 1)),
422 (int)Math.floor (dest_dim.width * (vertical ? 1 : multipliers_size[i])),
423 (int)Math.floor (dest_dim.height * (vertical ? multipliers_size[i] : 1))
424 };
425 }
311 426
312 public new void begin_modal ()427 public new void begin_modal ()
313 {428 {

Subscribers

People subscribed via source and target branches