window layouter: allow floating apps to resize

This patch gives applications the ability to control the size of their
window whenever the window is floating, not tiled or maximized. See the
comment in the code for the rationale.

Fixes #3200
This commit is contained in:
Norman Feske 2019-03-13 11:04:22 +01:00 committed by Christian Helmuth
parent 1f3f7282f3
commit 591e9457e6
1 changed files with 21 additions and 3 deletions

View File

@ -101,16 +101,34 @@ class Window_layouter::Assign : public List_model<Assign>::Element
Rect window_geometry(unsigned win_id, Area client_size, Rect target_geometry,
Decorator_margins const &decorator_margins) const
{
if (_maximized || !_pos_defined)
bool const floating = !_maximized && _pos_defined;
if (!floating)
return target_geometry;
/*
* Position floating window
*
* In contrast to a tiled or maximized window that is hard
* constrained by the size of the target geometry even if the
* client requests a larger size, floating windows respect the size
* defined by the client.
*
* This way, while floating, applications are able to resize their
* window according to the application's state. For example, a
* bottom-right resize corner of a Qt application is handled by the
* application, not the window manager, but it should still work as
* expected by the user. Note that the ability of the application
* to influence the layout is restricted to its window size. The
* window position cannot be influenced. This limits the ability of
* an application to impersonate other applications.
*/
Point const any_pos(150*win_id % 800, 30 + (100*win_id % 500));
Point const pos(_xpos_any ? any_pos.x() : _pos.x(),
_ypos_any ? any_pos.y() : _pos.y());
/* floating non-maximized window */
Rect const inner(pos, _size_defined ? _size : client_size);
Rect const inner(pos, client_size);
Rect const outer = decorator_margins.outer_geometry(inner);
return Rect(outer.p1() + target_geometry.p1(), outer.area());