How to Tile Windows

I have a function like bellow:

_move_windows_side_by_side = function (winid1, winid2) {
   let win1 = this._get_window_by_wid(winid1);
   let win2 = this._get_window_by_wid(winid2);

    let work_area = win1.get_work_area_current_monitor();

   //check if both are in current workspace
   //check if both are in same monitor

    let work_area_width = work_area.width;
    let work_area_height = work_area.height;

    let window_height = work_area_height;
    let window_width = work_area_width / 2;

    GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
        win1.move_resize_frame(1, 0, 0, window_width, window_height);
        return GLib.SOURCE_REMOVE;
    });

    GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
        win2.move_resize_frame(1, window_width, 0, window_width, window_height);
        return GLib.SOURCE_REMOVE;
    });

}

I was assuming that these will be tiled as DevDocs says:

Returns the matching tiled window on the same monitor as this. This is

the topmost tiled window in a complementary tile mode that is:

on the same monitor;
on the same workspace;
spanning the remaining monitor width;
there is no 3rd window stacked between both tiled windows that's
partially visible in the common edge.

In my case get_tile_match() does not return the other Meta.Window.

What do I need to do that when i call _move_windows_side_by_side = function (winid1, winid2), winid1 will have matching tile winid2 and vice versa.

get_tile_match() only returns a tile match when the window (and the other window) are actually in one of the tiled modes. I don’t think it is possible to change that mode from JS though.

1 Like

How does window managers tile windows? There are some extensions that do it. I went through their code but could not understand what they are actually doing.

I found that Meta.KeyBindingAction has TOGGLE_TILED_LEFT and TOGGLE_TILED_RIGHT.

Can I invoke these on selected windows?

The window manager is written in C and has access to the private API used for tiling.

I would assume that those extensions implement the whole tiling logic themselves and just end up calling move_resize themselves according to their own tiling logic.

1 Like

Thank you very much. This answers my query.

It would be great if we could get functions like tile_left() and tile_right() in Meta.Window. This is just a request if anyone could pass to the appropriate authority.