From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#38705: 26.3; set-frame-size pixelwise makes frame larger Date: Wed, 25 Dec 2019 10:49:34 +0100 Message-ID: References: <86lfr1al4s.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------677284A934E76CC14E9BE75A" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="26407"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38705@debbugs.gnu.org To: ynyaaa@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 25 10:51:29 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ik3KB-0006il-FX for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2019 10:51:27 +0100 Original-Received: from localhost ([::1]:45164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ik3KA-0003vN-4d for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2019 04:51:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53164) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ik3Jn-0003u3-FB for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 04:51:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ik3Jm-0001tF-3R for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 04:51:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47331) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ik3Jl-0001rp-QB for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 04:51:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ik3Jl-0000YS-Ov for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 04:51:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Dec 2019 09:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38705 X-GNU-PR-Package: emacs Original-Received: via spool by 38705-submit@debbugs.gnu.org id=B38705.15772674382098 (code B ref 38705); Wed, 25 Dec 2019 09:51:01 +0000 Original-Received: (at 38705) by debbugs.gnu.org; 25 Dec 2019 09:50:38 +0000 Original-Received: from localhost ([127.0.0.1]:53304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ik3JO-0000Xl-8x for submit@debbugs.gnu.org; Wed, 25 Dec 2019 04:50:38 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:50087) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ik3JL-0000XR-DH for 38705@debbugs.gnu.org; Wed, 25 Dec 2019 04:50:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1577267428; bh=7DpWKwPMtCThNaNfNLz0WehKKyeAauOV1hIlSCOGbjM=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=c66kOGGy6q9mQqy9X6mctEfHc2ei7UYU+4V7o4f+tTW4mqZBijeEnIOwXgvejxdf+ GRAVEiJbIAZuqlY7rgREH5qzeQekoljyxtrGKnZ8lArFUNNI5N0No8F0Mqq7otss6X gzQnTcpaPLtRQsKR3gF0tWxSuSqS0FGOs30PLrfQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.101] ([212.95.5.162]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mr9Bk-1jX5hi1fjq-00oIPt; Wed, 25 Dec 2019 10:50:28 +0100 In-Reply-To: <86lfr1al4s.fsf@gmail.com> Content-Language: de-AT X-Provags-ID: V03:K1:NvB36Ps4P1Zq1hwXOWdCwF3WGciouHzb5NapIm2ld+KDf7J4Mhx 6U24k7R8BW3IuVnUV7qd+nNV0GSGTG1oHoza/+bWmzjtzI55cElGLJpGU+DaCrG0hThWrqj wExoATqlmh6TX1bM+PoI1sA1b+m2IIrDvGtF8ngcrCZwGIb13ypt8JT7q0K/ad0ZGsjuBKj d3ztfJvJwwPGAK7ZBGVNA== X-UI-Out-Filterresults: notjunk:1;V03:K0:Xu/nnEoQUDE=:qI83sL7UHNXlOKVz0wjP0j 3iBt1IptadK/SnWhGSz0cs2okxPan+LxsqnZerQkoPO350/Ue9Mmt0r0RCzqVGjewHk9BH6w1 QE5bSEm7Rts7DIuSI1C0cTBUU5C/6q/2hNMSJlwOu4MGLTucg28vbo8Y6+Zdb/ERDLpYZ6Z8m 4GozdRGzMQfEhzk6dnG6dXUwxriXvjtouNaqdpfO73chiln298Z3gU62/x2av5swKeEdnR5Ve j2HfcDawTuZAYMbJ4p9NpVdl41PB2DigFqjpVWJzNC3EGyvTebHDOVzYm84udnm5UliZLujqs aRjFc3WE1/QgLWM9bUTVsSkT7LOhz3p0vqzp/Sd0aMw7wQluc5bqNPnpTbsHgVPitfmBMoF48 opCamdU+/hFH2Kgi+mOi6XU+lbwJsqMUHKYKtDm8vnX1nGd1fJRtCkXJXLKrPxYRTdTC+Xj9t W1X8v8DAVPlDLyqvXMYDyNr2BXWDLR6OJZ3pzXEa6hWDIkRL8zlUeyCg6DwNVfR3qud5WHXtF /60XuR0v+YQA4HEafgvOWCZsWWEmp5HagUq+/MZp05GtszQOVaBbRDXY+Pk7L6H+D6DWq6RPg /ZUrHHSgszVrAkflavKuRLWoYXgqaaR/NBAx5rtHITmMt5KbZiE/XfsCJUcHnZYPN/kImmPNd 9xQsRugoMIRBOwKTdIslqL58IoMa0Jstmxja+LnsaxouPLzIpJMHpkjbyQb+I1V+vji34bzAT 5mMYwE501MeSkd077IPk77xPUxaAy2xpPch6HM0UwZ1v7P1dcF7QfzppHslzlgORLFwYrJw2 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173739 Archived-At: This is a multi-part message in MIME format. --------------677284A934E76CC14E9BE75A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > I tried to set up the frame outer size like below. > ;;; sample ~/.emacs.d/init.el > (defun test-set-frame-outer-size (frame width height) > (set-frame-size frame width height t) > (set-frame-size frame > (- width (- (frame-outer-width frame) width)) > (- height (- (frame-outer-height frame) height)) > t)) > (setq frame-inhibit-implied-resize t) > (test-set-frame-outer-size nil 500 500) > ;;; sample ~/.emacs.d/init.el end > > But the function does not work well inside init.el. > After emacs started, the size is: > (list (frame-outer-width) (frame-outer-height)) > =>(500 502) > When user input is allowed, evaluating > (test-set-frame-outer-size nil 500 500) > works as expected. Look up the function 'frame-geometry'. If its return value for something like the 'external-border-size' differs for a frame before and after "user input is allowed" then it's because that something has not been specified before the frame was "mapped" and so Emacs won't know it. If you are sure that your decorations won't change from one emacs session to the next, you can try to remember them from the last session and apply them manually. However, in general, calling 'frame-outer-width/-height' from init.el is not a good idea. > About another point. > If the frame has no menu-bar, tool-bar, scroll-bar nor fringes, > frame-pixel-width and frame-pixel-height can be set by set-frame-size. > But if the frame is undecorated, the outer size is as large as the size > of non-undecorated frame regardless of the value of > frame-inhibit-implied-resize. > The inner size is enlarged to the outer size after redisplay. > The size can not be set as expected. > (let ((width 500) (height 500) > (params '((undecorated . t) > (menu-bar-lines . 0) > (tool-bar-lines . 0) > (horizontal-scroll-bars . nil) > (vertical-scroll-bars . nil) > (left-fringe . 0) > (right-fringe . 0))) > (f (lambda () (list (list (frame-outer-width) > (frame-inner-width)) > (list (frame-outer-height) > (frame-inner-height)))))) > (setq frame-inhibit-implied-resize t) > (modify-frame-parameters nil params) > (set-frame-size nil width height t) > (list (funcall f) > (progn (redisplay) (funcall f)))) > =>(((516 500) (539 500)) ((516 516) (539 539))) > > If the form above is evaluated twice, the frame outer size stays > 516x539 pixels and the inner size shrinks to 500x500 pixels. Please note again that the values you pass to 'set-frame-size' are the values later reported by 'frame-text-width' and 'frame-text-height'. These are fictive values and neither inner, nor outer or native sizes might match these. > The inner text area is displayed at the top-left, > and there are blank areas at the right and the bottom. This is the result of a bug that made frame resizing incorrect for undecorated frames on Windows ever since. To explain why this bug usually goes unnoticed note that 'set-frame-size' causes three things to happen: (1) it asks the window manager to resize the frame's (window system) window. (2) it "prematurely" resizes the frame's windows because in their code some users want to know the new window sizes right away. Now if (1) eventually results in a frame size different from the one expected in (2), the corresponding message from the window manager will cause Emacs to (3) re-resize the frame's windows if they don't match and everything should go well. Usually, the sizes returned by the window manager match those expected by (2) and in (3) no such re-resizing is needed. But in your scenario the first (set-frame-size nil 500 500 t) call will, due to the bug, pass incorrect values to the window manager, which makes the values eventually returned by the window manager differ from those calculated in (2). (3) will fix this. But the subsequent calls will cause the window manager do nothing in (1) because it is supplied the old values again and thus will decide that no resizing is needed. Yet Emacs will perform (2) with the values it expects and these values will never be corrected because (3) will never happen. Please try the attached patch. I will install it on Emacs-27 as soon as I have upgraded my working environment, something which may happen in a couple of days only. Many thanks again for reporting these obscure behaviors, martin --------------677284A934E76CC14E9BE75A Content-Type: text/plain; charset=UTF-8; name="w32fns.c.diffs" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="w32fns.c.diffs" ZGlmZiAtLWdpdCBhL3NyYy93MzJmbnMuYyBiL3NyYy93MzJmbnMuYwppbmRleCBiZjJhN2Ez ZTU0Li44MTQ1YjgyNDE2IDEwMDY0NAotLS0gYS9zcmMvdzMyZm5zLmMKKysrIGIvc3JjL3cz MmZucy5jCkBAIC0yMTQ2LDYgKzIxNDYsOSBAQCB3MzJfc2V0X3VuZGVjb3JhdGVkIChzdHJ1 Y3QgZnJhbWUgKmYsIExpc3BfT2JqZWN0IG5ld192YWx1ZSwgTGlzcF9PYmplY3Qgb2xkX3Zh bAogCQkgICAgfCBTV1BfRlJBTUVDSEFOR0VEKTsKICAgICAgIEZSQU1FX1VOREVDT1JBVEVE IChmKSA9IGZhbHNlOwogICAgIH0KKworICBmLT5vdXRwdXRfZGF0YS53MzItPmR3U3R5bGUg PSBHZXRXaW5kb3dMb25nIChod25kLCBHV0xfU1RZTEUpOworCiAgIHVuYmxvY2tfaW5wdXQg KCk7CiB9CiAKCg== --------------677284A934E76CC14E9BE75A--