From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.devel Subject: Re: recent change to nsterm.m: four pixels where the Dock is hidden Date: Fri, 25 Mar 2016 08:05:54 +0100 Message-ID: References: <25AFEF78-9B39-41F1-BC01-0208500E2711@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11438ee8a64a4e052eda3109 X-Trace: ger.gmane.org 1458889568 21007 80.91.229.3 (25 Mar 2016 07:06:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Mar 2016 07:06:08 +0000 (UTC) Cc: Emacs-Devel devel To: David Reitter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 25 08:06:04 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ajLop-00058Y-DR for ged-emacs-devel@m.gmane.org; Fri, 25 Mar 2016 08:06:03 +0100 Original-Received: from localhost ([::1]:54385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajLoo-0002kQ-BJ for ged-emacs-devel@m.gmane.org; Fri, 25 Mar 2016 03:06:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajLoj-0002kJ-SY for emacs-devel@gnu.org; Fri, 25 Mar 2016 03:05:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ajLoi-0004yH-Ar for emacs-devel@gnu.org; Fri, 25 Mar 2016 03:05:57 -0400 Original-Received: from mail-vk0-x22d.google.com ([2607:f8b0:400c:c05::22d]:34083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajLoi-0004xz-3n for emacs-devel@gnu.org; Fri, 25 Mar 2016 03:05:56 -0400 Original-Received: by mail-vk0-x22d.google.com with SMTP id e185so83762882vkb.1 for ; Fri, 25 Mar 2016 00:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=IH54y7iLsL8BQvhN/Ry/+wA/8wW6q5/u487z5P+qkq8=; b=WgbXED/ZlMWyXRov6PD0wWApCqqh3ftDZTHR95H/7d6u2++pfYOJFKckSULNc8mYzs 7SQQMgvcrhbZHGzOQTBlVvpWO3AnJZfvu7bWReXnueEH3R0MsmliKOAgx9xEhUBMPtoj 7kjZmcImPB1By4MpdlRqJPoyR/N8N03mLPNu2dmp3S5SiPNtg/U73BLgWTTDZI9xm142 kBaTr/Pi1FqroVd9ujbPjbm29uyLIQhbSmIZ1Uu9fbmJ7Dk8Kp3s1Kakv8Ge+xGd+xg/ EIffFeIchCF9EYidelalEF4aG2Y6niiyI03siVzf8OuPSSLhVVOKG7a96GMUSq6gDW+i 0dIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=IH54y7iLsL8BQvhN/Ry/+wA/8wW6q5/u487z5P+qkq8=; b=CCL2OmfuJjcyOLRaDaQNelSUjTPQRhAZVfmYcQxMIj59iEUskBPe8AH041PIxl047Q NOI6K83Gl9iJDV0wUVmBcKwnD2qIpWwDp9rKRQQhCuxADWBGq31b1rQJWK0I1gmIXbHN vRJq3XZtqFDkPbWCJC1kVXCJlemI5ZqUlQ/L8tAYXlbn5oOgtGWIA8Qd7WgzdnRG3dPa xsFkZ0EtNN3znsCj+onngg2KfCgjJzXhRwU0dtMz0MQbGlzo8o9KT7lCdqD4YjbmJQo7 F2zq/AIVylTBVjU5uJ1LBUSG8k9vkGn7xb92xW59DPj6mZFczQqXxMBaHIfusjAtycZA 3hPA== X-Gm-Message-State: AD7BkJK0+0Z6g+MpCvtvJ46jplXDuIdZ63lPvSbWUTEBGfIus0leNgRzjtgs/sVPbpheNgl4rYPzvnuBVSSh0Q== X-Received: by 10.31.54.134 with SMTP id d128mr5973080vka.26.1458889554281; Fri, 25 Mar 2016 00:05:54 -0700 (PDT) Original-Received: by 10.31.214.131 with HTTP; Fri, 25 Mar 2016 00:05:54 -0700 (PDT) In-Reply-To: <25AFEF78-9B39-41F1-BC01-0208500E2711@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c05::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:202211 Archived-At: --001a11438ee8a64a4e052eda3109 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi! The change to make `toggle-frame-maximized' cover the entire screen (when the dock was hidden) was done much earlier, in 2015-10-23 (see link to commit below), after a discussion that started in bug 21415 (see link). At the time, everybody involved in the discussion thought that it was a good idea for Emacs to cover the full height of the screen, when the dock was hidden. When the pretest was released, a user reported that the code didn't work properly when the dock was visible. Effectively, the dock would cover parts of Emacs. The commit you referred to is a fix for that problem. When investigating how an application could check if the dock was hidden, it turned out that there is no standard API for this, but the normal way this is checked is to compare the result of [screen frame] (i.e. the size of a display) with [screen visibleFrame] (i.e. the size, excluding the parts occupied by the OS). The OS reserves four pixels at the edge where a hidden dock resides, my code use six as a break-off value in case this is changed in future OS versions. I don't consider this a big change -- the fact that the change is 50 lines is that I prefer a style where each logical step is isolated, well documented, and there is a natural place for trace output. In this case I decided to represent the margins using a new struct, and place the margin calculation into two functions `ns_screen_margins' and `ns_screen_margins_ignoring_hidden_dock'. Of course, I could easily have written the code in a very condensed manner, inlining all calculations, but that wouldn't have been maintainable. This is the original change: http://git.savannah.gnu.org/cgit/emacs.git/commit/?h=3Demacs-25&id=3Dba24d3= 5a3e82cdeba4be5bd794f7f48bbfa5498e Discussion: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21415 -- Anders Lindgren On Fri, Mar 25, 2016 at 3:59 AM, David Reitter wrote: > Anders, > > I appreciate your work on the NS/OSX port. > Reviewing a recent change, I can=E2=80=99t help but wonder: Do we really= need 50 > lines of a hack to counteract design decisions made at the system level? > > If [NSScreen visibleFrame] tells us not to occupy certain space on the > screen - four pixels where the Dock is hidden - then that=E2=80=99s a sta= ndard that > all applications should adhere to. It=E2=80=99s probably done for a reas= on (such > as being able to un-hide the Dock and to grab the lower horizontal edge o= f > the window for resizing). > > ns_screen_margins_ignoring_hidden_dock is, excuse my bluntness, ugly as i= t > hardcodes some numbers that can change any time with a new OS version. It= =E2=80=99s > a burden for future maintenance. > > If this is what #22988 really was about, then it=E2=80=99s not a bug and = we > shouldn=E2=80=99t mess with it. Also not in 25.1. > > If I=E2=80=99m wrong, please excuse me. Could you explain if there is so= me deeper > reasoning that I=E2=80=99m missing? > > Thanks, > David > > > > Author: Anders Lindgren > > Date: Tue Mar 22 20:18:33 2016 +0100 > > > > Make `toggle-frame-maximized' respect the dock on OS X (bug#22988). > > > > * src/nsterm.m (ns_screen_margins): New function. > > (ns_screen_margins_ignoring_hidden_dock): New function. > > (ns_menu_bar_height): Reimplement in terms of `ns_screen_margins'. > > ([EmacsWindow zoom:]): Take all screen margins (except those > > originating from a hidden dock) into account. > > > --001a11438ee8a64a4e052eda3109 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi!

The change to make `toggle-frame-ma= ximized' cover the entire screen (when the dock was hidden) was done mu= ch earlier, in 2015-10-23 (see link to commit below), after a discussion th= at started in bug 21415 (see link). At the time, everybody involved in the = discussion thought that it was a good idea for Emacs to cover the full heig= ht of the screen, when the dock was hidden.

When t= he pretest was released, a user reported that the code didn't work prop= erly when the dock was visible. Effectively, the dock would cover parts of = Emacs. The commit you referred to is a fix for that problem.

=
When investigating how an application could check if the dock wa= s hidden, it turned out that there is no standard API for this, but the nor= mal way this is checked is to compare the result of [screen frame] (i.e. th= e size of a display) with [screen visibleFrame] (i.e. the size, excluding t= he parts occupied by the OS). The OS reserves four pixels at the edge where= a hidden dock resides, my code use six as a break-off value in case this i= s changed in future OS versions.

I don't consi= der this a big change -- the fact that the change is 50 lines is that I pre= fer a style where each logical step is isolated, well documented, and there= is a natural place for trace output. In this case I decided to represent t= he margins using a new struct, and place the margin calculation into two fu= nctions `ns_screen_margins' and `ns_screen_margins_ignoring_hidden_dock= '. Of course, I could easily have written the code in a very condensed = manner, inlining all calculations, but that wouldn't have been maintain= able.

This is the original change:

On Fri, Mar 25, 2016 at 3:59 AM, David Reitter <d= avid.reitter@gmail.com> wrote:
Anders,

I appreciate your work on the NS/OSX port.
Reviewing a recent change, I can=E2=80=99t help but wonder:=C2=A0 Do we rea= lly need 50 lines of a hack to counteract design decisions made at the syst= em level?

If [NSScreen visibleFrame] tells us not to occupy certain space on the scre= en - four pixels where the Dock is hidden - then that=E2=80=99s a standard = that all applications should adhere to.=C2=A0 It=E2=80=99s probably done fo= r a reason (such as being able to un-hide the Dock and to grab the lower ho= rizontal edge of the window for resizing).

ns_screen_margins_ignoring_hidden_dock is, excuse my bluntness, ugly as it = hardcodes some numbers that can change any time with a new OS version. It= =E2=80=99s a burden for future maintenance.

If this is what #22988 really was about, then it=E2=80=99s not a bug and we= shouldn=E2=80=99t mess with it.=C2=A0 Also not in 25.1.

If I=E2=80=99m wrong, please excuse me.=C2=A0 Could you explain if there is= some deeper reasoning that I=E2=80=99m missing?

Thanks,
David


> Author: Anders Lindgren <andli= nd@gmail.com>
> Date:=C2=A0 =C2=A0Tue Mar 22 20:18:33 2016 +0100
>
>=C2=A0 =C2=A0 =C2=A0Make `toggle-frame-maximized' respect the dock = on OS X (bug#22988).
>
>=C2=A0 =C2=A0 =C2=A0* src/nsterm.m (ns_screen_margins): New function. >=C2=A0 =C2=A0 =C2=A0(ns_screen_margins_ignoring_hidden_dock): New funct= ion.
>=C2=A0 =C2=A0 =C2=A0(ns_menu_bar_height): Reimplement in terms of `ns_s= creen_margins'.
>=C2=A0 =C2=A0 =C2=A0([EmacsWindow zoom:]): Take all screen margins (exc= ept those
>=C2=A0 =C2=A0 =C2=A0originating from a hidden dock) into account.
>

--001a11438ee8a64a4e052eda3109--