From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.devel Subject: Re: recent change to nsterm.m: four pixels where the Dock is hidden Date: Fri, 25 Mar 2016 06:56:33 -0400 Message-ID: <49D19730-400B-4456-AAEC-17CC8F84233D@gmail.com> References: <25AFEF78-9B39-41F1-BC01-0208500E2711@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1458903411 30818 80.91.229.3 (25 Mar 2016 10:56:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Mar 2016 10:56:51 +0000 (UTC) Cc: Emacs-Devel devel To: Anders Lindgren Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 25 11:56:44 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 1ajPQ3-0002Ls-NG for ged-emacs-devel@m.gmane.org; Fri, 25 Mar 2016 11:56:43 +0100 Original-Received: from localhost ([::1]:55465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajPQ2-0004yp-KU for ged-emacs-devel@m.gmane.org; Fri, 25 Mar 2016 06:56:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajPPz-0004yk-2U for emacs-devel@gnu.org; Fri, 25 Mar 2016 06:56:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ajPPv-0006mj-RD for emacs-devel@gnu.org; Fri, 25 Mar 2016 06:56:38 -0400 Original-Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:34105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajPPv-0006mf-LW for emacs-devel@gnu.org; Fri, 25 Mar 2016 06:56:35 -0400 Original-Received: by mail-qk0-x232.google.com with SMTP id p130so30161124qke.1 for ; Fri, 25 Mar 2016 03:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=DpTIpuiyhhMED8hgTnmfP3vmKiZrqEwPxH+iFSMEEsE=; b=RjU+3Wqy4IbpFXvJU0pGsklYdPcSvAV13MNQ0azyxFDBI8xtwBV7dsV+ErTG5OQJlC u1c2u7mk8PjaSzGdcXZGevX270yf7l5MnZ8FvkbIKMckJlIt0Ee6GfR4Nd5O62rBENv1 QJV5ZvuYAXZJmvkpQF4sBmMpmwV49A2TendJ6npd3agADj8T4v+CgxhtbA1rftlstNOn 7jYMOBMlJGqrSg8WB4WCb7U05WXpqjAlC1Xb5YH1XPb6Ovk/ICMnhkVB7JazVnA5mMUJ BX8ZaH0eOjTNmcBh2DLF2VRzsf8y4NlWL166GVumzM2f9gx08nrP8rLOpHYo8RBUkum+ Ihiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=DpTIpuiyhhMED8hgTnmfP3vmKiZrqEwPxH+iFSMEEsE=; b=W3DEMzjdSxpq8R8MXqd2/oVVUfHTiXVTAaM/cTrF5HjAqNmjOH2M7wx9JIRj8xFocq /kAJ0bP2uFQ0Gh5WRfye7At827XzaDSVS7a5DNmRBa90BmVTGXaJB2zP+AO51ynD5yQD PevzHVjZWRaFgo6EzH65dG/npbgGPGL1Wx8uTS8+esiTmsHBZi3xEBrSo6rx3a2V2738 rMvC5hnyJAVSDZqr/BTG1oux7xBCffSNETX0jnEFmsSZ2Wu+GwXH+mMpncra1B9iomu+ oXWN6z449SZh4p6XfSZqLuwYghYyLO+1qd1jV3sMyv1LN+JdnTmEqeRsEW77jpm78AYV gpyg== X-Gm-Message-State: AD7BkJIU88VgnAI0Q8gs9M9D97ap9xtblXsPYczfWbp/uBrmZs1mTa0/ArwF3msdWuw8KA== X-Received: by 10.55.82.137 with SMTP id g131mr16279811qkb.66.1458903395142; Fri, 25 Mar 2016 03:56:35 -0700 (PDT) Original-Received: from [10.0.1.7] (c-71-58-212-112.hsd1.pa.comcast.net. [71.58.212.112]) by smtp.gmail.com with ESMTPSA id g50sm5122657qgg.40.2016.03.25.03.56.33 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2016 03:56:33 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::232 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:202218 Archived-At: Anders, Thanks for the explanation.=20 The original change is difficult to read as it conflates the NSTRACE = code (a lot) with the more meaningful change. I can see that your most = recent change is small. What I find problematic is that you=E2=80=99re trying to micro-manage = the position and size of the frame when the system provides high-level = functions such as [NSScreen visibleFrame] that essentially tell you what = is available. The comment with that commit suggests that you=E2=80=99re = going over the Dock (when it=E2=80=99s not hidden), and if that is = indeed the case, that would be a mistake. [NSScreen visibleFrame] is = documented this way: > This is the rectangle defining the portion of the screen in which it = is currently safe to draw your application content. In the discussion, you wrote: > Zooming and fullscreen are two different concepts. Zooming is a = generic > system, and it's up to the application to decide what to do. Indeed, the documentation on sizing windows gives little guidance [1], = however, I would argue that one shouldn=E2=80=99t draw into a space the = system considers unsafe. DR [1] = https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Win= Panel/Tasks/SizingPlacingWindows.html > On Mar 25, 2016, at 3:05 AM, Anders Lindgren = wrote: >=20 > Hi! >=20 > 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. >=20 > 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. >=20 > 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. >=20 > 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. >=20 > This is the original change: >=20 > = http://git.savannah.gnu.org/cgit/emacs.git/commit/?h=3Demacs-25&id=3Dba24d= 35a3e82cdeba4be5bd794f7f48bbfa5498e >=20 > Discussion: >=20 > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21415 >=20 > -- Anders Lindgren >=20 > On Fri, Mar 25, 2016 at 3:59 AM, David Reitter = wrote: > Anders, >=20 > 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? >=20 > 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 = standard that all applications should adhere to. It=E2=80=99s probably = done for a reason (such as being able to un-hide the Dock and to grab = the lower horizontal edge of the window for resizing). >=20 > 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. >=20 > 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. >=20 > If I=E2=80=99m wrong, please excuse me. Could you explain if there is = some deeper reasoning that I=E2=80=99m missing? >=20 > Thanks, > David >=20 >=20 > > 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. > > >=20