How to make a window enter split view?

I am trying to create an extension with a function to directly open apps (from the appgrid or search results) in split view.

I couldn’t find the code which is responsible for GNOME’s split view in the js code, so I tried to size the windows myself.

What I did is call app.open_new_window(-1) and then on the window-create signal I call this function (after a short timeout):

tileWindow: function(window) {
		if (window) {
			if (window.get_maximized())
			if (window.allows_resize() && window.allows_move()) {
				let working_space = window.get_work_area_current_monitor()
				let x;
				let y = working_space.y;
				let height = working_space.height;
				let width = working_space.width / 2;
				if (this.windowToTileTo == Meta.Side.LEFT)
					x = working_space.x;

				else if (this.windowToTileTo == Meta.Side.RIGHT) 
					x = working_space.x + width;

				window.move_resize_frame(true, x, y, width, height);
				window.maximize(Meta.MaximizeFlags.VERTICAL); // ----- Problem causer -------
				this.windowToTileTo = undefined;

The problem I have is with window.maximize(Meta.MaximizeFlags.VERTICAL);. Calling this makes the window stick to the Topbar and prevents vertical movement. I can only restore the normal behaviour by using GNOME’s “auto-sizing” function (like maximizing by pushing the window into the topbar or side). Here is a GIF which shows me trying to pull the window from the topbar down.
I don’t understand what is causing this.

Any help is appreciated. Pointing me to the code where GNOME does the split view, might be helpful as well. Thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.