Skip to content

hycontrol-move-frame: frame jumps to right edge if you attempt to move past left edge #883

@Bodertz

Description

@Bodertz

Same is true for attempting to move up when already at the top: the frame will jump to the bottom.

This is the case because hycontrol-move-frame does not ensure that X and Y are positive when passed to set-frame-position, and set-frame-position interprets negative X or negative Y as the right-most edge or top-most edge.

I have the following advice which fixes it, but it does that by replacing the entire function:

(define-advice hycontrol-move-frame
    (:override (arrow pixels &rest r) ensure-positive-position)
  "Ensure the position passed to `set-frame-position' is positive."
  (let ((x (car (frame-position)))
        (y (cdr (frame-position))))
    (pcase arrow
      ('up    (set-frame-position nil x (max 0 (- y pixels))))
      ('down  (set-frame-position nil x (max 0 (+ y pixels))))
      ('left  (set-frame-position nil (max 0 (- x pixels)) y))
      ('right (set-frame-position nil (max 0 (+ x pixels)) y)))))

This ensure that x and y can't go below 0. I imagine that isn't needed for moving right or down, but I added it there anyway.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions