Sawfish
Browse all patches

Author

Fernando Carmona Varo

Synopsis

If you have ever tried to use the keyboard when moving/resizing windows (by means of the move-window-interactively command) and you have set a bigger mouse-cursor-increment value to move faster (what is a need if you have not a low resolution display). You probably noticed that the window is not responsive at all, and it doesn't move when the mouse cursor does move.

This patch is intended to fix that bug. If applied, windows will follow the mouse the way it should be.

UPDATE: I was asked by Christopher to write a smooth-warp-cursor function too. I think this could be a good idea to be used for other purposes in next patches (like showing how the mouse moves when using the command warp-cursor-to-window).


Patch testing

  1. Copy/paste the patch listed below into some file, eg. TEST.diff.
  2. If you don't have sawfish sources yet, have one, as described get it from GIT repo.
  3. Go into the directory where sawfish sources reside, eg. cd sawfish
  4. Test if the patch applies cleanly with this command:
    patch -p1 --ignore-whitespace --dry-run < TEST.diff
    in case of problems try also: -p0 or -p2
  5. If it applies cleanly, then remove the --dry-run from above command and run it again, otherwise ask on the mailing list.
  6. Compile sawfish: ./autogen.sh && make
  7. Install it for testing, but it depends on your linux distribution.
    1. It is always better to install sawfish as your distribution package, but it is different for each distribution.
    2. So you may try make install, which will install sawifish in /usr/local/share/sawfish/ (if you have write access). But then make sure that you run the correct version and delete it from that directory afterwards, to avoid any conflicts.
  8. Se also

PS: edit this template if you feel that those instructions can be improved.

Patch

Index: lisp/sawfish/wm/commands/move-cursor.jl
===================================================================
--- lisp/sawfish/wm/commands/move-cursor.jl	(revision 4269)
+++ lisp/sawfish/wm/commands/move-cursor.jl	(working copy)
@@ -34,10 +34,39 @@
     :group misc
     :type (number 1))
 
-  (define (move-cursor right down)
+  (defvar move-cursor-steps 20
+    "Number of steps for moving smoothly the mouse cursor by `move-cursor' and
+ `smooth-warp-cursor' commands.")
+
+  (define (move-cursor right down #!optional (steps move-cursor-steps))
+    "Moves the cursor the given right and down number of pixels relative to
+the current position of the cursor. 
+A third optional argument will define the number of steps for performing the
+movement this number must be greater than zero.
+If the argument is omitted the function will use the value of 
+`move-cursor-steps'."
+    (let* ((coords (query-pointer))
+          (old-x (car coords))
+          (old-y (cdr coords)))
+      (do ((xstep (floor (/ right steps)))
+           (ystep (floor (/ down steps)))
+           (i 1 (1+ i)))
+          ((= i steps))
+        (warp-cursor (+ old-x (* xstep i)) (+ old-y (* ystep i))))
+      ;; Do the last step directly, to be sure it's done right
+      (warp-cursor (+ old-x right) (+ old-y down))))
+
+  (define (smooth-warp-cursor x y #!optional (steps move-cursor-steps))
+    "Warp the cursor to the given X Y coordinates relative to root window.
+The movement is performed smoothly, in short increments of a number of steps
+given by the third optional argument. The number of steps must be greater than
+zero.
+If the argument is omitted the function will use the value of 
+`move-cursor-steps'."
     (let ((coords (query-pointer)))
-      (warp-cursor (+ (car coords) right) (+ (cdr coords) down))))
+      (move-cursor (- x (car coords)) (- y (cdr coords)) steps)))
 
   (define (move-cursor-left)
     "Move the cursor `move-cursor-increment' pixels to the left."
     (move-cursor (- move-cursor-increment) 0))

Community's reasons for inclusion or rejection

Patch submitters, please vote also! Yes, obviosuly your vote will be positive, but it's the place to give your explanation why this patch is good for all Sawfish users, and why it is correct - good reasons for inclusion.

When voting anonymously please write your name, so that it can be associated with your posts on the mailing list. If you are logged in you can sign yourself by typing four tilda characters: ~~~~.

  • Please vote with: vote: yes., vote: no. or vote: pondering. or with wait for next release. if you propose the patch to wait for next release.
  • vote: yes. The bug was really annoying, in my opinion. I never used sawfish keyboard moving for this reason. -Ferk(talk!) 07:35, 8 August 2008 (UTC)
can you also make a patch for smoother warp-pointer? would be really cool. Flashrider [Christopher Bratusek] 07:58, 8 August 2008 (UTC)
I think warp-cursor is "hard coded" in C, better not touch it. Warping the pointer smoothly could already be done using this same function, no need for another one, just use relative coordinates instead of absolute. But what do you want it for? hmm.. do you mean to have the animation when the mouse is warped to a focused window? that in fact could be cool. It would be a smooth "warp-cursor-to-window". Should the number of steps for mouse movement be a global variable then? -Ferk(talk!) 08:46, 8 August 2008 (UTC)
Done. -Ferk(talk!) 09:36, 8 August 2008 (UTC)
After more testing, the smooth-warping doesn't seem work very well.. also this is not a totally smooth movement (it seems that the refreshing is too fast), it just avoids the bug of the move/resize functions. I'm considering reverting the patch to the previous version (without smooth-warp-cursor). -Ferk(talk!) 09:58, 8 August 2008 (UTC)