From 591e9457e6065c42f9354f04ccedeea6cbf5e8a2 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 13 Mar 2019 11:04:22 +0100 Subject: [PATCH] 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 --- repos/gems/src/app/window_layouter/assign.h | 24 ++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/repos/gems/src/app/window_layouter/assign.h b/repos/gems/src/app/window_layouter/assign.h index 5160f3b07f..badb7ab2eb 100644 --- a/repos/gems/src/app/window_layouter/assign.h +++ b/repos/gems/src/app/window_layouter/assign.h @@ -101,16 +101,34 @@ class Window_layouter::Assign : public List_model::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());