unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: 21480@debbugs.gnu.org
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	[thread overview]
Message-ID: <CAFyQvY2xQF4mQK1UbH_j1o0kAbyK2PcthDza59iT9Gt_eFKjYA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY2CVa1YwZHFtZhzgpjAHRxBFJm-7O+bAMCdiMzMBVz_-w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6679 bytes --]

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
>

[-- Attachment #2: Type: text/html, Size: 15406 bytes --]

  reply	other threads:[~2015-09-14 21:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14 21:13 bug#21480: 25.0.50; Frame width gets set to 16 pixels wider than the provided width in the args Kaushal Modi
2015-09-14 21:21 ` Kaushal Modi [this message]
2015-09-15  8:29   ` martin rudalics
2015-09-15  8:27 ` martin rudalics
2015-09-15  8:33   ` martin rudalics
2015-09-15 13:39     ` Kaushal Modi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY2xQF4mQK1UbH_j1o0kAbyK2PcthDza59iT9Gt_eFKjYA@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=21480@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).