Commit Graph

74 Commits

Author SHA1 Message Date
Sergey Vlasov 93c4f369cf awful.placement: Fix no_overlap with unselected tags (#2809)
The awful.placement.no_overlap function always looked at the currently
visible clients when placing a new client.  This produced a confusing
result when using awful.rules or the sn_rules argument of awful.spawn to
place the client on an unselected tag (the client was placed as if it
would be placed on a currently selected tag; if multiple clients were
placed on the same unselected tag, in many cases they were placed at the
same position, overlapping each other).

Make awful.placement.no_overlap check tags of the placed client and
handle the case of placement on an unselected tag in a more useful way:

  - If the client is sticky or at least one of the client tags is
    selected, keep the previous behavior: avoid overlap with all other
    floating clients which are currently visible, and use the currently
    active layout to determine the floating status.

    An explicit check based on `c:tags()` is made instead of using
    `c:isvisible()`, so that the previous behavior is kept even if the
    client is hidden or minimized for some reason.

  - If all client tags are unselected, avoid overlap with all other
    floating clients which either are sticky or share at least one tag
    with the placed client, and use the layout of the first tag of the
    placed client to determine the floating status.

Signed-off-by: Sergey Vlasov <sigprof@gmail.com>
2019-07-04 16:42:15 +03:00
Emmanuel Lepage Vallee b4ece0f053 doc: Use an explicit tag for all static functions.
This way their name doesn't get mangle by the broken magic. It will also
eventually allow to `error()` in the template when the implicit
`@function` is used.

This commit also fixes a large number of issues found while
proof-reading everything.
2019-06-08 18:14:13 -04:00
Emmanuel Lepage Vallee 29d89c5e8a placement: Handle when the preferred position isn't set.
This removes a FIXME from the code.
2019-03-04 15:52:39 -05:00
Emmanuel Lepage Vallee e2f164208c doc: Better document awful.placement.next_to 2018-12-24 21:52:54 -05:00
Emmanuel Lepage Vallee 8bcdd0b794 placement: Add some extra checks to limit the risk of regressions.
Given noone understand this code, this will prevent some semi likely
regressions from going unnoticed. The main risk is the shims not
producing the exact same results as the real implementation and
cause different code paths to be taken.

As of this commit, both the "real" and "shim" implementation were given
the same set of tests with print() at every step of next_to. The
resulting log was then checksummed to ensure both are identical.
2018-12-24 21:52:30 -05:00
Emmanuel Lepage Vallee d8a7782bf4 tests: Add an awful.placement.next_to test
It was overdue
2018-12-24 21:52:30 -05:00
Emmanuel Lepage Vallee 33a39ce38d placement: Make sure `next_to` result is consistent across calls
It depended on a hash `pairs` iteration. This caused an issue only when
the primary position wasn't available.
2018-12-24 21:52:30 -05:00
Emmanuel Lepage Vallee f1145af49d placement: Allow to configure the next_to anchors
They were previously hardcoded to match the classic context menu
behavior. It isn't flexible enough for some popup type.
2018-12-24 21:49:52 -05:00
Emmanuel Lepage Vallee 3fa42f3b1a placement: Fix `border_width` for `next_to`
All previous users used client side borders so the issue went
unnoticed. This code will be unit tested by the `popup` module
in a few commits.
2018-12-24 21:49:52 -05:00
Sergey Vlasov 61cdc40595 awful.placement: Fix no_offscreen when composed with other functions
The awful.placement.no_offscreen function did not work properly when
composed with other placement functions; in particular, the default
configuration (awful.placement.no_overlap+awful.placement.no_offscreen)
was broken.  The compose function sets args.pretend=true and puts the
result of the previous placement function into args.override_geometry
before calling the next placement function, but no_offscreen did not use
args.override_geometry, therefore the result of the previous placement
function was discarded.

All other placement functions use `geometry_common(c, args)` to get the
current client geometry; `area_common(c)` should be used only when
getting geometry of other clients.

This change also fixes the problem with margin handling (adding margins
should not affect the window size, only the window position should
change); the test output which was adjusted in commit 0275d3537d
is adjusted again to account for this change.

Signed-off-by: Sergey Vlasov <sigprof@gmail.com>
2018-09-13 08:23:36 +03:00
Sergey Vlasov db11c7e9da awful.placement: Fix client size corruption in no_overlap
The awful.placement.no_overlap function was adding the window border
width to the client width and height (this is performed in
area_common(), which is called by geometry_common()), but did not
reverse this operation by calling remove_border() before returning the
final geometry; because of this, using no_overlap resulted in increasing
the window width and height by 2*border_width.

The bug was probably introduced in commit ebcc19844e (before
that commit no_overlap changed the window position directly instead of
relying on the new placement infrastructure), but was not noticed
because of other problems (e.g., in the default configuration the result
of no_overlap was overridden by the buggy no_offscreen).

Signed-off-by: Sergey Vlasov <sigprof@gmail.com>
2018-09-13 08:23:36 +03:00
actionless 492d07a9cd fixup! fix(awful: placement: no_offsceen): use new placement infrastructure
doc(awful: placement: no_offscreen): update comment and print deprecation warning
2018-07-25 14:31:51 +02:00
actionless fec8d6aa8f fix(awful: placement: no_offsceen): use new placement infrastructure
fix(tests: examples: awful: placement: no_offscreen): uncomment context

fix(awful: placement): common function to remove border from geometries
2018-07-24 07:38:35 +02:00
Anatolii Aniskovych cbfe8274be awful.placement: Keep client position when no space available in no_overlap() (#2139) 2018-05-19 00:08:19 +03:00
Anatolii Aniskovych dd3658bb1c awful.placement: Ignore fullscreen/maximized clients in no_overlap()
Fullscreen/maximized client takes full workspace area making free space detection logic useless.
2018-05-19 00:08:11 +03:00
Emmanuel Lepage Vallée b2f8c8df89
placement: Check if the stored screen is valid (#2246)
Fixes #2088
2018-04-26 20:47:33 -04:00
Emmanuel Lepage Vallée 19fd21111a
awful.placement: Fix `next_to` logic. (#2130)
Fix #2128
2017-12-03 15:05:19 -05:00
Yauhen Kirylau ebcc19844e fix(awful: placement: no_overlap): use new placement infrastructure (#2032)
Fixes #2030
2017-09-09 16:26:54 -04:00
Uli Schlachter f22a69d54e Fix fullscreen clients with gravity != NorthWest (#1764)
Once upon a time, 4b9584fdb1 already fixed this problem: We have to
set the border width to zero before applying the new geometry to the
client, because changing the border width makes the client move
according to its gravity.

Then came e54387904b and made this code use awful.placement instead
of just fullscreening the client itself (without explaining why in the
commit message!). After this commit, the border width was just ignored
and left as-is. This was then fixed in 0bf8bb6a64 (no idea which
callback the commit message refers to, the old code was basically just
c.border_width=0, c:geometry(screen_geo)). However, now the border width
was again changed after the geometry and the bug that was fixed by
4b9584fdb1 was back.

This commit fixes this regression again by making sure that the border
width is set to zero before the geometry is set. This becomes slightly
more complicated, because now it is also awful.placement's job to
restore the old border width.

This is why this commit adds a new option to awful.placement so that it
sets the border width to zero after creating its memento of the old
border width.

Fixes: https://github.com/awesomeWM/awesome/issues/1607
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-05-13 23:31:14 +02:00
Kevin Zander 7687275607 Move awful.util.deprecate and awful.util.deprecate_class to gears.debug
Change all awful.util function calls to gears.debug function calls
Update all old deprecate calls to have deprecated_in=4
2017-03-15 20:08:22 -05:00
Kevin Zander c3461b535c gears: Move awful.util.table to gears.table (#1641)
* Move table functions out of awful.util into new gears.table

* travis: Use v9999 prefix for full requests

Make sure no newly deprecated functions are used

* Move all `awful.util.table.*` calls to `gears.table.*` calls
Move table test functions from awful/util_spec to new gears/table_spec
Change awful.util.subsets call to gears.math.subsets in awful/key.lua
2017-03-08 15:18:33 -05:00
Emmanuel Lepage Vallee 477df4a35b maximized/fullscreen: Use relative coords when restoring size.
Also apply a copy of the memento instead of mutating the
original.

Fixes #1320
2017-02-07 11:13:15 -05:00
Emmanuel Lepage Vallee 4ea6e133f8 placement: Add some missing `ignore_border_width` checks.
It was done in some places, but not all.
2017-02-07 11:13:15 -05:00
Daniel Hahler aeab2a70e9 Fix whitespace warnings reported by luacheck (#1229) 2016-11-21 22:38:23 +01:00
Uli Schlachter 259c4f716f Remove @release @AWESOME_VERSION@ everywhere (#1157)
It does not provide much value. The version number is already known to
ldoc globally in the "description" variable.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-09 22:36:20 +02:00
Emmanuel Lepage Vallee 8468d06350 placement: Port next_to_mouse to the new API 2016-08-20 16:21:48 -04:00
Emmanuel Lepage Vallee 211907def2 placement: Add `next_to`
This commit add the last placement function imported from the
Radical module.

It allows to place a wibox/client next to another object. It tries
to find the best fit. It also support wibox widgets.

This is intended for tooltips and menus, but can also be used in
`awful.rules` to place the new client as close as possible to the
focused one without overlap.
2016-08-20 16:21:48 -04:00
Emmanuel Lepage Vallee 19d4a3f602 placement.under_mouse: Fix a rounding error.
When object size contains odd numbers, the result was +1px off.
2016-08-12 17:02:33 -04:00
cmertz 4389297b58 restore client.border_width after fullscreen 2016-07-27 09:54:42 +02:00
Uli Schlachter 0857f6f1b5 Lua: Remove calls to add_signal()
The requirement to call add_signal() was added to catch typos. However, this
requirement became increasingly annoying with property::<name> signals and e.g.
gears.object allowing arbitrary properties to be changed.

All of this ended up in a single commit because tests/examples fails if I first
let add_signal() emit a deprecation warning.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-06-04 18:23:48 +02:00
Emmanuel Lepage Vallee aa46b96369 gears.geometry: Add area_remove 2016-05-16 14:03:00 -04:00
Emmanuel Lepage Vallee 50c97ed167 placement: Add a callback to detach the placement function 2016-05-15 17:17:12 -04:00
Emmanuel Lepage Vallee 21c9766aa6 placement: Fix under_mouse
The function stopped actually setting the geometry...

This was missed by tests because of an oversaw elsewhere.
2016-05-15 17:17:12 -04:00
Emmanuel Lepage Vallee 45ff7efce5 placement: Support 'attach' in composited placement functions 2016-05-15 17:17:11 -04:00
Emmanuel Lepage Vallee e78a07574b placement: Do not forward the args in get_parent_geometry
The args are for 'd', not the parent.
2016-05-15 17:17:11 -04:00
Emmanuel Lepage Vallee c490ca3803 placement: Fix margin support
This was only partially implemented. The margins were substracted from
the area too early in the pipeline. Now, they are added when getting
the size and substracted when setting it. This way, the margins will
"survive" when a placement function set an absolute value in one of
the field. Previously, this caused one (or more) of the margins to
be lost.
2016-05-15 17:17:11 -04:00
Emmanuel Lepage Vallee 3945f13fc4 placement: Fix an semi-infinite loop when attaching to geometries
It would add a new connection each time and eventually get very
slow.

An regression test will be published later.
2016-05-04 23:47:44 -04:00
Emmanuel Lepage Vallée dbd0931343 Merge pull request #844 from Elv13/geometry_overhaul_p2
Geometry overhaul part 2.5
2016-04-30 23:29:29 -04:00
Emmanuel Lepage Vallee f0546b900d tests: Improve the placement compositing tests 2016-04-30 04:27:34 -04:00
Emmanuel Lepage Vallee 1802e9e2fe awful.placement: Add a `scale` function 2016-04-30 04:27:34 -04:00
Emmanuel Lepage Vallee c286470c17 awful.placement: Port `under_mouse` to the new argument syntax 2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee 2f819df7f7 awful.placement: Add 'offset' argument 2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee e6a04a5922 awful.placement: Extend the compositing feature
It can now keep the different return values and use them in
later chain nodes.

It also add a "virtual" geometry argument so the geometry is applied
only after the last node is executed.

Finally, it fixes using pretend and a composite chain at the same time.
2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee e93e2913b6 awful.placement: Fix a closest_corner corner case
When the mouse was exactly on the right or bottom edge, there was a
rounding error.
2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee 75af0a24c7 awful.placement: Add a 'pretend' option 2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee 75764108e1 awful.placement: Make all functions return the geometry 2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee 3e7a7f23c2 tests: Test awful.placement.resize_to_mouse 2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee 5f17f1aa83 resize_to_mouse: Support size_hints 2016-04-30 04:27:33 -04:00
Emmanuel Lepage Vallee 604ea15c45 awful.placement: Add a 'resize_to_mouse' function 2016-04-30 03:34:14 -04:00
Daniel Hahler 02b6f9893d awful.placement.no_overlap: use screen.workarea as fallback
When there is a maximized and floating client,
`awful.placement.no_overlap` would end up with an empty list of areas to
place the client into.

This patch fixes it to use the default `screen.workarea` in that case.

Closes https://github.com/awesomeWM/awesome/issues/813.
2016-04-26 00:48:19 +02:00