Skip to content

Commit 04e91f5

Browse files
committed
tiling: Expose tile 'push' actions that are currently used by
keybindings. ref: linuxmint/cinnamon#11674
1 parent 93fc727 commit 04e91f5

File tree

2 files changed

+63
-6
lines changed

2 files changed

+63
-6
lines changed

src/core/keybindings.c

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,13 +3650,8 @@ can_tile (MetaWindow *window,
36503650
}
36513651

36523652
static void
3653-
handle_tile_action (MetaDisplay *display,
3654-
MetaWindow *window,
3655-
ClutterKeyEvent *event,
3656-
MetaKeyBinding *binding,
3657-
gpointer dummy)
3653+
do_tile_move (MetaWindow *window, MetaTileMode mode)
36583654
{
3659-
MetaTileMode mode = binding->handler->data;
36603655
MetaTileMode new_mode;
36613656

36623657
new_mode = get_new_tile_mode (mode, META_WINDOW_MAXIMIZED (window) ? META_TILE_MAXIMIZED : window->tile_mode);
@@ -3676,6 +3671,65 @@ handle_tile_action (MetaDisplay *display,
36763671
}
36773672
}
36783673

3674+
static void
3675+
handle_tile_action (MetaDisplay *display,
3676+
MetaWindow *window,
3677+
ClutterKeyEvent *event,
3678+
MetaKeyBinding *binding,
3679+
gpointer dummy)
3680+
{
3681+
MetaTileMode mode = binding->handler->data;
3682+
do_tile_move (window, mode);
3683+
}
3684+
3685+
/**
3686+
* meta_display_push_tile:
3687+
* @display: the #MetaDisplay
3688+
* @window: the #MetaWindow to act upon
3689+
* @direction: the #MetaMotionDirection to push the window in.
3690+
*
3691+
* If the window is not yet tiled, tile the window to the portion
3692+
* of the monitor indicated by @direction. If already tiled, perform
3693+
* navigation around the possible tile positions, or untile the
3694+
* window, according to @direction.
3695+
*
3696+
* For example, if @window is left-tiled, and the @direction is
3697+
* #META_MOTION_UP, the window will be upper-left corner tiled. If the
3698+
* @direction is #META_MOTION_RIGHT, the window will be untiled.
3699+
*
3700+
* This logic is identical to the behavior of the tiling keyboard
3701+
* shortcuts.
3702+
**/
3703+
void
3704+
meta_display_push_tile (MetaDisplay *display,
3705+
MetaWindow *window,
3706+
MetaMotionDirection direction)
3707+
{
3708+
g_return_if_fail (META_IS_DISPLAY (display) && META_IS_WINDOW (window));
3709+
3710+
MetaTileMode mode;
3711+
switch (direction)
3712+
{
3713+
case META_MOTION_LEFT:
3714+
mode = META_TILE_LEFT;
3715+
break;
3716+
case META_MOTION_RIGHT:
3717+
mode = META_TILE_RIGHT;
3718+
break;
3719+
case META_MOTION_UP:
3720+
mode = META_TILE_TOP;
3721+
break;
3722+
case META_MOTION_DOWN:
3723+
mode = META_TILE_BOTTOM;
3724+
break;
3725+
default:
3726+
return;
3727+
}
3728+
3729+
do_tile_move (window, mode);
3730+
}
3731+
3732+
36793733
static void
36803734
handle_toggle_maximized (MetaDisplay *display,
36813735
MetaWindow *window,

src/meta/display.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ void meta_display_set_desklets_above (MetaDisplay *display, gboolean above);
357357
META_EXPORT
358358
gboolean meta_display_get_desklets_above (MetaDisplay *display);
359359

360+
META_EXPORT
361+
void meta_display_push_tile (MetaDisplay *display, MetaWindow *window, MetaMotionDirection direction);
362+
360363
#endif
361364

362365

0 commit comments

Comments
 (0)