Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SnapAttraction prefers wrong window #631

Closed
ThomasAdam opened this issue Nov 14, 2021 · 1 comment · Fixed by #641
Closed

SnapAttraction prefers wrong window #631

ThomasAdam opened this issue Nov 14, 2021 · 1 comment · Fixed by #641
Assignees
Labels
type:bug Something's broken!
Milestone

Comments

@ThomasAdam
Copy link
Member

ThomasAdam commented Nov 14, 2021

From @domivogt (via fvwm-workers@):

Snapping to the grid, other windows and screen edges hat a nasty
interaction that has been bugging me for years, but I don't know
how to fix it. Suppose you have this:

Style * SnapAttraction 12 Sametype, SnapGrid 4 4
EdgeResistance 500
Style * EdgeMoveDelay 500, EdgeMoveResistance 128
EdgeScroll 0 0

There's a button bar in the bottom left corner and another window
that is a little shorter than the screen height minus the buttons
height, say, one pixel shorter:

  +---------------------+
  |+--------+           | <--- small gap
  || window |           |
  ||        |           |
  ||        |           |
  ||        |           |
  ||        |           |
  ||        |           |
  |+--------+           |
  |+------------+       |
  || button bar |       |
  +---------------------+

When moving the window with the mouse it's difficult to snap the
window to the top edge of the screen because it prefers to snap to
the button bar instead. Try it out yourself. I just don't know
how to "fix" it.

@ThomasAdam
Copy link
Member Author

The snapping code is really an unmaintainable mess. Some thoughts
on how it might be rewritten:

Situation:

  1. There are three different snapping mechanisms:

a) Snapping to windows or icons.
b) Snapping to screen edges.
c) Snapping to the grid.

Each one has some distance defined at which snapping will occur.
(a) and (b) are set directly, the value for (c) is roughly half
the grid size.

  1. The top border is in the vicinity of some locations it might
    snap to:
  • The bottom border of the next window above it.
  • The bottom border of the next window below it.
  • Possibly it's directly on the bottom border.
  • The top edge of the screen.
  • The grid line above it.
  • The grid line below it.
  1. There needs to be some algorithm to decide to which of these
    coordinates the window should be snapped. The current algorithm
    treats all three mechanisms in separate code which can cause
    confusing interaction of windows jumping around while moving.

The three mechanisms are not equally important. For example, if
you have configured that windows would snap to screen edges at 16
pixels distance, and the grid size is 4, the snap grid should not
override the edge snapping at, say, 10 pixels distance.

  1. The situation gets much more complicated because the bottom
    border of the window has completely different coordinates it can
    snap to.

  2. The top or bottom border of the window may be off screen. The
    window should not snap to objects that are on another page.

--

Idea: At a given window position, gather a list of possible snap
coordinates and attraction distances for the top border (2).
Gather a similar list for the bottom border (4). The list for the
bottom border can actually be recalculated into top border
coordinates (if the bottom coordinate is y, the top coordinate is
(y - window height)).

Now run the algorithm (3) to decide which coordinate shall be used
for snapping. Treat window borders and screen edges as equally
important. Whatever value is closest is chosen. Snap to the grid
only if the window was not snapped to another window, icon or
screen edge.

@ThomasAdam ThomasAdam added the type:bug Something's broken! label Nov 14, 2021
@ThomasAdam ThomasAdam added this to the 1.0.5 milestone Nov 14, 2021
somiaj added a commit that referenced this issue Nov 20, 2021
  Split the snap attract logic into three functions, one for Monitor,
  one for Windows, and one for Grid. This is to allow calling the functions
  in different orders to control which object takes priority when determining
  what to snap to.

  Check for things to snap to in the order Monitor > Window > Grid. Once
  something is found to snap to, bypass future tests and snap to the first
  object found with the highest priority.

  Fixes #631.
somiaj added a commit that referenced this issue Nov 21, 2021
  Split the snap attract logic into three functions, one for Monitor,
  one for Windows, and one for Grid. This is to allow calling the functions
  in different orders to control which object takes priority when determining
  what to snap to.

  First checks for Monitor edges and window edges and snaps to closest.
  If no monitor or window edge found, snap to SnapGrid.

  Update EdgeMoveResistance to use the same function for Monitor snapping.

  Fixes #631.
somiaj added a commit that referenced this issue Nov 21, 2021
  Split the snap attract logic into three functions, one for Monitor,
  one for Windows, and one for Grid. This is to allow calling the functions
  in different orders to control which object takes priority when determining
  what to snap to.

  First checks for Monitor edges and window edges and snaps to closest.
  If no monitor or window edge found, snap to SnapGrid.

  Update EdgeMoveResistance to use the same function for Monitor snapping.

  Fixes #631.
somiaj added a commit that referenced this issue Nov 22, 2021
  Split the snap attract logic into three functions, one for Monitor,
  one for Windows, and one for Grid. Clean up SnapAttract code.

  Logic now first checks for Monitor edges and window edges and snaps to
  closest. If no monitor or window edge found, snap to SnapGrid.

  Update EdgeMoveResistance to use the same function for Monitor snapping.

  Fixes #631.
somiaj added a commit that referenced this issue Nov 22, 2021
  Split the snap attract logic into three functions, one for Monitor,
  one for Windows, and one for Grid. Clean up SnapAttract code.

  Logic now first checks for Monitor edges and window edges and snaps to
  closest. If no monitor or window edge found, snap to SnapGrid.

  Update EdgeMoveResistance to use the same function for Monitor snapping.

  Fixes #631.
ThomasAdam pushed a commit that referenced this issue Nov 22, 2021
  Split the snap attract logic into three functions, one for Monitor,
  one for Windows, and one for Grid. Clean up SnapAttract code.

  Logic now first checks for Monitor edges and window edges and snaps to
  closest. If no monitor or window edge found, snap to SnapGrid.

  Update EdgeMoveResistance to use the same function for Monitor snapping.

  Fixes #631.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 19, 2022
(One of the more significant changes is that locking issues with libX11
1.8.1 are fixed.)

## [1.0.5](https://github.com/fvwmorg/fvwm3/tree/1.0.5) (2022-09-28)

[Full Changelog](fvwmorg/fvwm3@1.0.4...1.0.5)

**Breaking changes:**

- Function parser rewrite & Repeat command deprecation [\#642](fvwmorg/fvwm3#642)
- MapRequest: don't fake map/unmap events [\#703](fvwmorg/fvwm3#703) ([ThomasAdam](https://github.com/ThomasAdam))
- Rewrite function parser and remove the Repeat command [\#643](fvwmorg/fvwm3#643) ([ThomasAdam](https://github.com/ThomasAdam))
- Update and cleanup SnapAttract code. [\#641](fvwmorg/fvwm3#641) ([somiaj](https://github.com/somiaj))
- Doc: split manpages into sections [\#637](fvwmorg/fvwm3#637) ([ThomasAdam](https://github.com/ThomasAdam))
- Remove Efence and Dmalloc support [\#635](fvwmorg/fvwm3#635) ([ThomasAdam](https://github.com/ThomasAdam))

**Implemented enhancements:**

- A better ManualPlacement that allows drawing the geometry of the new window. [\#674](fvwmorg/fvwm3#674)
- expand: add monitor.prev variable [\#699](fvwmorg/fvwm3#699) ([ThomasAdam](https://github.com/ThomasAdam))
- Add AnyScreen to conditional in IconManClick [\#696](fvwmorg/fvwm3#696) ([somiaj](https://github.com/somiaj))
- \_NET\_WM\_NAME: update to fvwm3 [\#609](fvwmorg/fvwm3#609) ([ThomasAdam](https://github.com/ThomasAdam))

**Fixed bugs:**

- Style \* Icon cause Fvwm3 stuck in loading when restart. [\#681](fvwmorg/fvwm3#681)
- Recaptured windows can have a negative offset away from the page they should be on [\#678](fvwmorg/fvwm3#678)
- VLC still decorates its transient window even when explicitly given the NakedTransient style [\#673](fvwmorg/fvwm3#673)
- configuring with `--disable-png` causes builds to fail [\#669](fvwmorg/fvwm3#669)
- Emoji in window titles make FvwmIconMan stop showing window names. [\#654](fvwmorg/fvwm3#654)
- Unable to initialize RandR [\#650](fvwmorg/fvwm3#650)
- PipeRead when called from a function cannot grab pointer [\#610](fvwmorg/fvwm3#610)
- Man Pages Cleanup [\#554](fvwmorg/fvwm3#554)
- Windows from various pages are moved to page 0 0 on fvwm3 restart [\#694](fvwmorg/fvwm3#694)
- Separator in menu gets focus [\#675](fvwmorg/fvwm3#675)
- Unshading a window with WindowShade function sometimes makes the window lose "true input focus". [\#671](fvwmorg/fvwm3#671)
- When configured with `--disable-xft` fvwm3 fails to build. [\#667](fvwmorg/fvwm3#667)
- my fvwm config does not work with recent chromium [\#663](fvwmorg/fvwm3#663)
- FvwmEvent event new\_desk gets triggered multiple times in multi-monitor shared setup [\#655](fvwmorg/fvwm3#655)
- Windows with style "PositionPlacement Center" split between monitors [\#648](fvwmorg/fvwm3#648)
- FVWM branch dv/pager-noaspect crashes with core dump [\#647](fvwmorg/fvwm3#647)
- SnapAttraction prefers wrong window [\#631](fvwmorg/fvwm3#631)
- FvwmPrompt is installed unstripped [\#618](fvwmorg/fvwm3#618)
- DesktopName fails to set desktop name under described circumstances [\#606](fvwmorg/fvwm3#606)
- FvwmEvent event monitor\_focus broken in FVWM3 1.0.4 [\#604](fvwmorg/fvwm3#604)
- Building FvwmPrompt disables FvwmConsole, but still installs manual page. [\#597](fvwmorg/fvwm3#597)
- Wait command in configuration file can cause unexpected issues with GeometryWindow. [\#590](fvwmorg/fvwm3#590)
- "GeometryWindow Hide" doesn't work [\#589](fvwmorg/fvwm3#589)
- Special characters \(umlauts\) are sometimes not displayed correctly in the window title [\#482](fvwmorg/fvwm3#482)
- FvwmEvent: handle previous\_monitor and no longer passthrough ID  [\#701](fvwmorg/fvwm3#701) ([ThomasAdam](https://github.com/ThomasAdam))
- doc: don't build FvwmConsole.1 if FvwmPrompt enabled [\#700](fvwmorg/fvwm3#700) ([ThomasAdam](https://github.com/ThomasAdam))
- DesktopConfiguration shared: keep windows in-situ [\#697](fvwmorg/fvwm3#697) ([ThomasAdam](https://github.com/ThomasAdam))
- desk\_add: fix starting desk/monitor [\#689](fvwmorg/fvwm3#689) ([ThomasAdam](https://github.com/ThomasAdam))
- shared: fix flagging of new\_desk [\#687](fvwmorg/fvwm3#687) ([ThomasAdam](https://github.com/ThomasAdam))
- Fix for lock recusion in handle\_all\_expose\(\) [\#683](fvwmorg/fvwm3#683) ([mherrb](https://github.com/mherrb))
- Asciidoc fixes [\#676](fvwmorg/fvwm3#676) ([topcat001](https://github.com/topcat001))
- grow: ignore transient windows [\#627](fvwmorg/fvwm3#627) ([ThomasAdam](https://github.com/ThomasAdam))
- MoveToScreen: fix NULL-dereference [\#605](fvwmorg/fvwm3#605) ([ThomasAdam](https://github.com/ThomasAdam))
- Bugfix: fvwm-menu-desktop --get-menus [\#593](fvwmorg/fvwm3#593) ([somiaj](https://github.com/somiaj))

**Closed issues:**

- Code Cleanup: Codacy issues list [\#107](fvwmorg/fvwm3#107)

**Merged pull requests:**

- avoid sprintf\(%n\) [\#653](fvwmorg/fvwm3#653) ([omar-polo](https://github.com/omar-polo))
- FvwmPrompt: add GOFLAGS to build stripped [\#619](fvwmorg/fvwm3#619) ([Zirias](https://github.com/Zirias))
- Wait: don't run until windows are captured [\#592](fvwmorg/fvwm3#592) ([ThomasAdam](https://github.com/ThomasAdam))
- CMD\_GeometryWindow: Move NULL check. [\#591](fvwmorg/fvwm3#591) ([somiaj](https://github.com/somiaj))
- cleanup: address warnings [\#705](fvwmorg/fvwm3#705) ([ThomasAdam](https://github.com/ThomasAdam))
- modconf: disable debug [\#698](fvwmorg/fvwm3#698) ([ThomasAdam](https://github.com/ThomasAdam))
- GotoDesk: avoid over-eager matching [\#695](fvwmorg/fvwm3#695) ([ThomasAdam](https://github.com/ThomasAdam))
- update\_fvwm\_monitor: cosmetic change [\#692](fvwmorg/fvwm3#692) ([ThomasAdam](https://github.com/ThomasAdam))
- menuitem: set selectable when not a separator [\#690](fvwmorg/fvwm3#690) ([ThomasAdam](https://github.com/ThomasAdam))
- Windowshade: explicitly set input focus [\#672](fvwmorg/fvwm3#672) ([ThomasAdam](https://github.com/ThomasAdam))
- FvwmPrompt: update core modules [\#665](fvwmorg/fvwm3#665) ([ThomasAdam](https://github.com/ThomasAdam))
- FvwmPrompt: update vendor deps [\#664](fvwmorg/fvwm3#664) ([ThomasAdam](https://github.com/ThomasAdam))
- Fix selectable flag for the Resize window operation menu item [\#656](fvwmorg/fvwm3#656) ([topcat001](https://github.com/topcat001))
- Fix ExitFunction [\#651](fvwmorg/fvwm3#651) ([pghvlaans](https://github.com/pghvlaans))
- DisplayPosition: fix segfault [\#645](fvwmorg/fvwm3#645) ([ThomasAdam](https://github.com/ThomasAdam))
- convert UPDATE\_FVWM\_SCREEN from macro to function [\#644](fvwmorg/fvwm3#644) ([ThomasAdam](https://github.com/ThomasAdam))
- ta/dv logfile [\#640](fvwmorg/fvwm3#640) ([ThomasAdam](https://github.com/ThomasAdam))
- Resize: fix resize bounds [\#638](fvwmorg/fvwm3#638) ([ThomasAdam](https://github.com/ThomasAdam))
- ta/dv2 [\#636](fvwmorg/fvwm3#636) ([ThomasAdam](https://github.com/ThomasAdam))
- ta/dv misc [\#634](fvwmorg/fvwm3#634) ([ThomasAdam](https://github.com/ThomasAdam))
- Reject out of range windows for Move and Resize commands. [\#633](fvwmorg/fvwm3#633) ([ThomasAdam](https://github.com/ThomasAdam))
- FVWMMFL: ignore SIGPIPE [\#632](fvwmorg/fvwm3#632) ([ThomasAdam](https://github.com/ThomasAdam))
- ta/dv ifdev [\#630](fvwmorg/fvwm3#630) ([ThomasAdam](https://github.com/ThomasAdam))
- ta/from dv [\#629](fvwmorg/fvwm3#629) ([ThomasAdam](https://github.com/ThomasAdam))
- DesktopName: don't duplicate entries with same name [\#607](fvwmorg/fvwm3#607) ([ThomasAdam](https://github.com/ThomasAdam))
- Patches from Debian [\#599](fvwmorg/fvwm3#599) ([ThomasAdam](https://github.com/ThomasAdam))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something's broken!
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants