abo-abo / hydra

make Emacs bindings that stick around
1.85k stars 113 forks source link

posframe size (width/height) issue #363

Open dlyr opened 4 years ago

dlyr commented 4 years ago

When I invoke an hydra menu, it has the frame size of the previously invoked one (and also the border/color ... for instance border appears only after the second launch). Here is a minimal test to reproduce. Invoke hydra-moretest1/body, then switch to hydra-moretest2/body with "a", then quit. When you invoke hydra-moretest1/body again, the posframe has the size of hydra-moretest2/body and the other way round (so in this other case, it misses some heads). Maybe I miss something simple, i'm new to hydra writing.

;; try some paramters if you want
;(setq hydra-posframe-show-params
;      '(:poshandler posframe-poshandler-frame-bottom-center))

;; setup load dirs
(let ((default-directory  "~/.emacs.d/elpa/"))
  (normal-top-level-add-subdirs-to-load-path))
(require 'hydra)

;; use posframe
(setq hydra-hint-display-type 'posframe)

(defhydra hydra-moretest1  (:hint nil :color amaranth)
"Test1"
  ("a" hydra-moretest2/body  "a" :color blue)
  ("m" (message "hello 0")   "message 0")
  ("q" nil "quit" :color blue)
)

(defhydra hydra-moretest2 (:hint nil :color amaranth )
  "Test2"
("a"  hydra-moretest1/body     "a" :color blue)
("b" (message "hello 1")   "message 1")
("n" (message "hello 2")   "message 2")
("m" (message "hello 3")   "message 3")
("q" nil "quit" :color blue)
) 

System uptodate debian testing, GNU Emacs 26.1 hydra-20191125.955 lv-20200122.1200 posframe-20200226.241

dlyr commented 4 years ago

I have a possible hack which is to add

 :pre (posframe-delete " *hydra-posframe*")

in the body. It assumes you use a posframe hydra, but at least work for my example.

abo-abo commented 4 years ago

Can't reproduce the issue on Linux and Emacs 26.3.

dlyr commented 4 years ago

I just try with emacs 26.3 ... still the same issue. Here is a video showing the behavior. The first time there is no red borders, then the size of the posframe sometimes is the big one while the small one is supposed to be displayed (as shown by the border) sometimes the other way round, as the hydra heads are cropped. To switch hydra's I use 'a' ... Hope this helps to identify the issue.

video

abo-abo commented 4 years ago

I tried to reproduce with make run and this code on 26.3:

(add-to-list 'load-path "/home/oleh/.emacs.d/straight/repos/posframe/")

(setq hydra-hint-display-type 'posframe)

(defhydra hydra-moretest1 (:hint nil :color amaranth)
  "Test1"
  ("a" hydra-moretest2/body "a" :color blue)
  ("m" (message "hello 0") "message 0")
  ("q" nil "quit" :color blue))

(defhydra hydra-moretest2 (:hint nil :color amaranth)
  "Test2"
  ("a" hydra-moretest1/body "a" :color blue)
  ("b" (message "hello 1") "message 1")
  ("n" (message "hello 2") "message 2")
  ("m" (message "hello 3") "message 3")
  ("q" nil "quit" :color blue))

(global-set-key (kbd "C-c t") 'hydra-moretest1/body)

(setq hydra-posframe-show-params
     '(:poshandler posframe-poshandler-frame-bottom-center))

Pressing C-c t a q C-c t, everything works as expected.

dlyr commented 4 years ago

I updated to the last git master version of hydra and posframe, using GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.13) of 2020-02-27 Still have the issue :( I don't know how to debug. I use you test code, with emacs -Q test.el, I had to add (require 'hydra) after the load-path, but you may have used your init.el right ? So I have only loaded hydra (lv) and posframe , with an empty .emacs.d

C-c t brings Test1 hydra in a posframe then a switch to Test2, but not all the options are displayed, the posframe do not change, while it's position do (it goes to the right) q quits as expected C-c t bring Test1 but with a too wide posframe (it covers the right fringe in white). It looks like a new invocation to hydra uses the size of the previously closed hydra, and hydra's switch do not change posframe change. It's even more visible with a colored border.

I don't know how it can be related, but here is the used libs

emacs-26.3/build/src]$ ldd ./emacs linux-vdso.so.1 (0x00007fff247d1000) libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f59009fd000) libjpeg.so.62 => /usr/lib/x86_64-linux-gnu/libjpeg.so.62 (0x00007f5900794000) libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f590075b000) libgif.so.7 => /usr/lib/x86_64-linux-gnu/libgif.so.7 (0x00007f5900750000) libXpm.so.4 => /usr/lib/x86_64-linux-gnu/libXpm.so.4 (0x00007f590053e000) libgtk-3.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 (0x00007f58ffe42000) libgdk-3.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-3.so.0 (0x00007f58ffd41000) libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f58ffcf6000) libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f58ffbd6000) libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f58ffbaf000) libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f58ff9dd000) libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f58ff981000) libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f58ff85a000) libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007f58ff84f000) libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007f58ff632000) libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f58ff4f0000) libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f58ff2e6000) libXft.so.2 => /usr/lib/x86_64-linux-gnu/libXft.so.2 (0x00007f58ff0d0000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f58ff0c3000) libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f58ff070000) libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f58fee6a000) libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f58fec58000) libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f58fea9a000) libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f58fea6b000) libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f58fea3e000) libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f58fe97f000) libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f58fe939000) libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f58fe761000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f58fe740000) libanl.so.1 => /lib/x86_64-linux-gnu/libanl.so.1 (0x00007f58fe73a000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f58fe5f3000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f58fe5d6000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f58fe416000) libwebp.so.6 => /usr/lib/x86_64-linux-gnu/libwebp.so.6 (0x00007f58fe3ab000) libzstd.so.1 => /usr/lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f58fe301000) liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f58fe2d8000) libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f58fe0c8000) libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f58fe0c2000) libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f58fe0b2000) libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f58fdea2000) libcairo-gobject.so.2 => /usr/lib/x86_64-linux-gnu/libcairo-gobject.so.2 (0x00007f58fde96000) libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007f58fde6d000) libatk-bridge-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0 (0x00007f58fde35000) libepoxy.so.0 => /usr/lib/x86_64-linux-gnu/libepoxy.so.0 (0x00007f58fdd06000) libfribidi.so.0 => /usr/lib/x86_64-linux-gnu/libfribidi.so.0 (0x00007f58fdcea000) libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f58fdbe5000) libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f58fdbcc000) libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f58fdbc5000) libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f58fd9ba000) libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f58fd9ad000) libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007f58fd7aa000) libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f58fd7a5000) libxkbcommon.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f58fd762000) libwayland-cursor.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f58fd759000) libwayland-egl.so.1 => /usr/lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f58fd752000) libwayland-client.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f58fd741000) libthai.so.0 => /usr/lib/x86_64-linux-gnu/libthai.so.0 (0x00007f58fd736000) libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f58fd690000) libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f58fd68b000) libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f58fd65f000) libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f58fd650000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f58fd64b000) libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007f58fd5ea000) libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f58fd5d2000) libffi.so.7 => /usr/lib/x86_64-linux-gnu/libffi.so.7 (0x00007f58fd5c4000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f58fd550000) libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f58fd547000) libbsd.so.0 => /usr/lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f58fd52d000) libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f58fd485000) libicuuc.so.63 => /usr/lib/x86_64-linux-gnu/libicuuc.so.63 (0x00007f58fd2b3000) libpcre2-8.so.0 => /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f58fd223000) /lib64/ld-linux-x86-64.so.2 (0x00007f5900ab8000) libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f58fd1f6000) libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f58fd0c6000) libidn2.so.0 => /usr/lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f58fd0a6000) libunistring.so.2 => /usr/lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f58fcf24000) libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f58fcf0c000) libnettle.so.7 => /usr/lib/x86_64-linux-gnu/libnettle.so.7 (0x00007f58fced1000) libhogweed.so.5 => /usr/lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007f58fce98000) libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f58fce15000) libatspi.so.0 => /usr/lib/x86_64-linux-gnu/libatspi.so.0 (0x00007f58fcddf000) libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f58fcdb1000) libdatrie.so.1 => /usr/lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007f58fcda7000) libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f58fcba3000) libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f58fc99d000) libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f58fc947000) liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f58fc923000) libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f58fc806000) libicudata.so.63 => /usr/lib/x86_64-linux-gnu/libicudata.so.63 (0x00007f58fae15000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f58fac49000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f58fac2f000) libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f58fac0a000)