bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21480: 25.0.50; Frame width gets set to 16 pixels wider than the pro


From: Kaushal Modi
Subject: bug#21480: 25.0.50; Frame width gets set to 16 pixels wider than the provided width in the args
Date: Mon, 14 Sep 2015 21:21:59 +0000

I messed up the parentheses in the example code. Here is the code again:

(defvar bkp--frame-height-px nil)
(defvar bkp--frame-width-px nil)

(defun modi/toggle-menu-bar ()
  "Toggle the menu bar.
Also restore the original frame size when disabling the menu bar."
  (interactive)
  (let ((frame-resize-pixelwise t))
    ;; If the menu bar is hidden currently, take a backup of the frame height.
    (when (null menu-bar-mode)
      (setq bkp--frame-height-px (frame-pixel-height))
      (setq bkp--frame-width-px  (frame-pixel-width))
      ;; `frame-pixel-width' is returning a value higher by 16 pixels compared
      ;; to that set using `set-frame-size'. So the below adjustment has to be made.
      ;; (setq bkp--frame-width-px  (- (frame-pixel-width) 16))
      )
    (menu-bar-mode 'toggle)
    ;; Restore frame size if menu bar is hidden after toggle
    (when (null menu-bar-mode)
      (set-frame-size nil bkp--frame-width-px bkp--frame-height-px :pixelwise))))

(global-set-key (kbd "<f2>") #'modi/toggle-menu-bar)

I noticed one more thing.. In my emacs setup, I need the adjustment of 16 pixels (as shown in the code above).
But in an emacs -Q session, I need an adj of 32 pixels. That might probably help narrow down the problem.

Does it have to do with the fonts I use? Because emacs -Q starts with Dejavu Sans Mono font. Whereas my configured emacs uses PragmataPro font.

On Mon, Sep 14, 2015 at 5:13 PM Kaushal Modi <kaushal.modi@gmail.com> wrote:
Hi,

I have been using a hack to deal with this bug for over a year now. I believe I am seeing this problem ever since I starting understanding more and more of elisp, around emacs 24.3.

Problem: 
- I save the frame width using `frame-pixel-width' to a defvar.
- I then set the frame size using `set-frame-size' with that defvar as one of the args
- I notice that the frame had got wider! When I do a readback using `frame-pixel-width', it is exactly 16 pixels wider than expected.

I have seen this problem on emacsen built earlier on RHEL 5 and now on RHEL 6 too.

Evaluate the below code in the scratch buffer in an emacs -Q session. Then when you keep on hitting F2, you will see that the frame keeps on getting wider. 

Now if you uncomment the line with the "<-- HACK" comment, reeval the code and then keep on hitting F2, the frame width will stay the same (which was the end goal of the below code).



(defvar bkp--frame-height-px nil)
(defvar bkp--frame-width-px nil)

(defun modi/toggle-menu-bar ()
  "Toggle the menu bar.
Also restore the original frame size when disabling the menu bar."
  (interactive)
  (let ((frame-resize-pixelwise t))
    ;; If the menu bar is hidden currently, take a backup of the frame height.
    (when (null menu-bar-mode)
      (setq bkp--frame-height-px (frame-pixel-height))
      (setq bkp--frame-width-px  (frame-pixel-width))

      ;; ;; `frame-pixel-width' is returning a value higher by 16 pixels compared
      ;; ;; to that set using `set-frame-size'. So the below adjustment has to be made.
      ;; (setq bkp--frame-width-px  (- (frame-pixel-width) 16))) ; <-- HACK

    (menu-bar-mode 'toggle)
    ;; Restore frame size if menu bar is hidden after toggle
    (when (null menu-bar-mode)
      (set-frame-size nil bkp--frame-width-px bkp--frame-height-px :pixelwise))))

(global-set-key (kbd "<f2>") #'modi/toggle-menu-bar)



-----------------------------------------------------------------------------------------------------


In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23)
 of 2015-09-14
Repository revision: 1ee47d477ddb9c567eaf63154f78fad5d5826b78
Windowing system distributor 'The X.Org Foundation', version 11.0.60900000
System Description: Red Hat Enterprise Linux Workstation release 6.6 (Santiago)

Configured using:
 'configure --prefix=/home/kmodi/usr_local/apps/6/emacs/master
 'CPPFLAGS=-fgnu89-inline -I/home/kmodi/usr_local/6/include
 -I/usr/include/freetype2 -I/usr/include'
 'LDFLAGS=-L/home/kmodi/usr_local/6/lib
 -L/home/kmodi/usr_local/6/lib64''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark activated
next-line: End of buffer

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns help-mode easymenu mail-prsvr mail-utils edmacro kmacro
cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 82449 9769)
 (symbols 48 19499 0)
 (miscs 40 49 185)
 (strings 32 13474 4382)
 (string-bytes 1 404277)
 (vectors 16 10887)
 (vector-slots 8 418983 6570)
 (floats 8 131 201)
 (intervals 56 356 10)
 (buffers 976 11)
 (heap 1024 30054 843))


--
Kaushal Modi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]