[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/posframe c18bea7 08/16: New variable: posframe-gtk-resi
From: |
Feng Shu |
Subject: |
[elpa] externals/posframe c18bea7 08/16: New variable: posframe-gtk-resize-child-frames |
Date: |
Thu, 21 May 2020 00:57:31 -0400 (EDT) |
branch: externals/posframe
commit c18bea744541c418d22df44cff4af0c3039439ca
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
New variable: posframe-gtk-resize-child-frames
Allows us to bind x-gtk-resize-child-frames to an appropriate value
requiring no user intervention.
Discussion at https://github.com/tumashu/company-posframe/issues/2.
Fixes #51.
---
posframe.el | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/posframe.el b/posframe.el
index d93c5d3..b769854 100644
--- a/posframe.el
+++ b/posframe.el
@@ -38,13 +38,9 @@
;; NOTE:
;; 1. For MacOS users, posframe needs Emacs version >= 26.0.91
-;; 2. GNOME and MATE users with GTK3 builds should set
-;; `x-gtk-resize-child-frames' to 'resize-mode or 'hide, then
-;; restart emacs.
-
-;; 1. 'resize-mode has better behavior but not future-compatible.
-;; 2. 'hide is more future-proof but will blink the child frame every
-;; time it's resized.
+;; 2. GNOME users with GTK3 builds need Emacs 27 or later.
+;; See variable `posframe-gtk-resize-child-frames'
+;; which auto-detects this configuration.
;; More details:
@@ -212,6 +208,22 @@ frame.")
(defvar-local posframe--initialized-p nil
"Record initialize status of `posframe-show'.")
+(defvar posframe-gtk-resize-child-frames
+ (when (and
+ (> emacs-major-version 26)
+ (string-match-p "GTK3" system-configuration-features)
+ (let ((value (getenv "XDG_CURRENT_DESKTOP")))
+ (and (stringp value)
+ ;; It can be "ubuntu:GNOME".
+ (string-match-p "GNOME" value))))
+ ;; Not future-proof, but we can use it now.
+ 'resize-mode)
+ "Value to bind `x-gtk-resize-child-frames' to.
+
+The value `resize-mode' only has effect on new child frames, so
+if you change it, you might have to create a new posframe, or
+just restart Emacs.")
+
;;;###autoload
(defun posframe-workable-p ()
"Test posframe workable status."
@@ -241,6 +253,7 @@ This posframe's buffer is BUFFER-OR-NAME."
(internal-border-width (or internal-border-width 0))
(buffer (get-buffer-create buffer-or-name))
(after-make-frame-functions nil)
+ (x-gtk-resize-child-frames posframe-gtk-resize-child-frames)
(args (list parent-frame
foreground-color
background-color
@@ -645,11 +658,16 @@ will be removed."
(erase-buffer)
(insert str))))
+(defun posframe--fit-frame-to-buffer (posframe height min-height width
min-width)
+ (let ((x-gtk-resize-child-frames posframe-gtk-resize-child-frames))
+ (fit-frame-to-buffer
+ posframe height min-height width min-width)))
+
(defun posframe--set-frame-size (posframe height min-height width min-width)
"Set POSFRAME's size.
It will set the size by the POSFRAME's HEIGHT, MIN-HEIGHT
WIDTH and MIN-WIDTH."
- (fit-frame-to-buffer
+ (posframe--fit-frame-to-buffer
posframe height min-height width min-width)
(setq-local posframe--last-posframe-size
(list height min-height width min-width)))
@@ -705,7 +723,7 @@ WIDTH and MIN-WIDTH."
#'(lambda (frame height min-height width min-width)
(let ((frame-resize-pixelwise t))
(when (and frame (frame-live-p frame))
- (fit-frame-to-buffer
+ (posframe--fit-frame-to-buffer
frame height min-height width min-width))))
posframe height min-height width min-width)))))
@@ -737,7 +755,7 @@ to do similar job:
(when (or (equal buffer-or-name (car buffer-info))
(equal buffer-or-name (cdr buffer-info)))
(with-current-buffer buffer-or-name
- (apply #'fit-frame-to-buffer
+ (apply #'posframe--fit-frame-to-buffer
frame posframe--last-posframe-size))))))
(defun posframe-hide (buffer-or-name)
@@ -1070,14 +1088,6 @@ bottom center. The structure of INFO can be found in
docstring of
(+ window-top window-height
(- 0 mode-line-height posframe-height)))))
-(defvar x-gtk-resize-child-frames)
-(when (and (string-match-p "GTK3" system-configuration-features)
- (member (getenv "XDG_CURRENT_DESKTOP") '("GNOME"))
- x-gtk-resize-child-frames)
- (if (> emacs-major-version 26)
- (message "Posframe: GNOME+GTK3 may need to set variable
`x-gtk-resize-child-frames' to 'resize-mode or 'hide.")
- (message "Posframe: GNOME+GTK3 have resize bug:
https://lists.gnu.org/archive/html/emacs-devel/2020-01/msg00343.html")))
-
(provide 'posframe)
;;; posframe.el ends here
- [elpa] externals/posframe updated (83b4d39 -> 093b29a), Feng Shu, 2020/05/21
- [elpa] externals/posframe 5dfb91d 03/16: Do not show message when x-get-resize-child-frames non-nil, Feng Shu, 2020/05/21
- [elpa] externals/posframe c18bea7 08/16: New variable: posframe-gtk-resize-child-frames,
Feng Shu <=
- [elpa] externals/posframe d231039 10/16: Mention posframe-delete-all, Feng Shu, 2020/05/21
- [elpa] externals/posframe 05539c1 02/16: Note user when run gnome+gtk3, Feng Shu, 2020/05/21
- [elpa] externals/posframe 9cf47ff 01/16: Add information about x-get-resize-child-frames, Feng Shu, 2020/05/21
- [elpa] externals/posframe b71b530 05/16: Simplify posframe--set-frame-size, Feng Shu, 2020/05/21
- [elpa] externals/posframe 095d744 09/16: Add a comment, Feng Shu, 2020/05/21
- [elpa] externals/posframe d058221 06/16: Improve GNOME/GTK3 info, Feng Shu, 2020/05/21
- [elpa] externals/posframe cb1a09e 04/16: Fix width, height, min-width, min-height doc. #58, Feng Shu, 2020/05/21
- [elpa] externals/posframe 102eb8c 07/16: Use posframe-hack, Feng Shu, 2020/05/21
- [elpa] externals/posframe e24413c 12/16: Merge branch 'master' into posframe-gtk-resize-child-frames, Feng Shu, 2020/05/21
- [elpa] externals/posframe 7c173ee 14/16: Update README, Feng Shu, 2020/05/21