From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: charles@aurox.ch (Charles A. Roelli) Newsgroups: gmane.emacs.bugs Subject: bug#25818: 25.2; frame moved off display does not return (OS X) Date: Mon, 10 Apr 2017 21:54:48 +0200 Message-ID: References: <58AEA232.4000708@gmx.at> <58B30634.1090904@gmx.at> <58B3DDBA.6060003@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1491854173 13685 195.159.176.226 (10 Apr 2017 19:56:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Apr 2017 19:56:13 +0000 (UTC) Cc: 25818@debbugs.gnu.org To: Anders Lindgren Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 10 21:56:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxfPy-0003Pg-O9 for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Apr 2017 21:56:07 +0200 Original-Received: from localhost ([::1]:36013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxfQ4-0001e8-Du for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Apr 2017 15:56:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxfPx-0001e2-NT for bug-gnu-emacs@gnu.org; Mon, 10 Apr 2017 15:56:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxfPu-0006QH-IE for bug-gnu-emacs@gnu.org; Mon, 10 Apr 2017 15:56:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxfPu-0006PY-Bk for bug-gnu-emacs@gnu.org; Mon, 10 Apr 2017 15:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cxfPt-0000yr-Sb for bug-gnu-emacs@gnu.org; Mon, 10 Apr 2017 15:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: charles@aurox.ch (Charles A. Roelli) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Apr 2017 19:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25818 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25818-submit@debbugs.gnu.org id=B25818.14918541043698 (code B ref 25818); Mon, 10 Apr 2017 19:56:01 +0000 Original-Received: (at 25818) by debbugs.gnu.org; 10 Apr 2017 19:55:04 +0000 Original-Received: from localhost ([127.0.0.1]:41560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxfOx-0000xa-QW for submit@debbugs.gnu.org; Mon, 10 Apr 2017 15:55:04 -0400 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:52819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxfOv-0000wz-C9 for 25818@debbugs.gnu.org; Mon, 10 Apr 2017 15:55:02 -0400 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id D1DBA223E3 for <25818@debbugs.gnu.org>; Mon, 10 Apr 2017 19:51:07 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= content-type:content-type:mime-version:message-id:in-reply-to :date:date:references:subject:subject:to:from:from; s=dkim; t= 1491853866; x=1492717867; bh=YtJmfqM9eUU+icgd3nnbSFt45FjplEpgRg1 +RnCK8kY=; b=ReNWuWMjC/Y6mRk00sdYk/Tv3GQ2DLChSDxGeKxJnbODqhY2F+e skc5UsBQ9VxrLhDrHeTBrChG+uhteD9g5bTED5SKun8e3wY2PM4LMf13D0BVQbSq emWjKRIV0w19Sgh+tSd5FwkZeqjz+HgwI2cvk1IrR9+6E++lSDgTyEVc= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Original-Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LPLl5Qa9M8Jr for <25818@debbugs.gnu.org>; Mon, 10 Apr 2017 19:51:06 +0000 (UTC) Original-Received: from gray (237.73.127.176.dynamic.wline.res.cust.swisscom.ch [176.127.73.237]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id 85D452238D; Mon, 10 Apr 2017 19:51:03 +0000 (UTC) In-Reply-To: (Anders Lindgren's message of "Sun, 9 Apr 2017 21:13:08 +0200") 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: 208.118.235.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:131450 Archived-At: --=-=-= Content-Type: text/plain Hi Anders, > Also, I'm sure it will work with L-shaped layouts as well, > even though I haven't tried it. I gave it a try and it worked as expected. > I've got two minor comments. And when I say "minor" they really are minor, > feel free to disregard them if you like: > > * The nsterm.m file is (almost) tab free, so I would appreciate if you > would untabify the code. > > * Replace the comment with something like the following: > > // Check that the proposed frame placement is visible in at least > // one screen. If it is not, ask the system to reposition it. > > If someone doesn't understand what the code does and why, the original > comment doesn't help as it only repeats the algorithm of the code. Also, I > don't see the need to refer to a bug number in the comment, except under > very special circumstances -- that information is available in the git > commit message. Good points, I've made these fixes in the attached patch. >> Hm... but what if a second display is in the negative coordinate space? >> How would you place a frame on it programmatically? > > You can set the `left' and `top' frame parameters. If they are assigned an > integer they act like `set-frame-position' is supposed to work. However, if > they are assigned `(+ INTEGER)' or `(- INTEGER)' the value is specified > relative to the left (top) or right (bottom) edge of the display, > respectively. This allows a frame to be placed anywhere. I see now, thanks for this explanation. I tried building Emacs with X (--with-x --with-ns=no) and the configuring step picked up my installed version of GTK3, then later failed at the linking stage for temacs due to some GDK-related symbols not being present. Have you seen similar errors? Cheers, Charles --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Constrain-frames-to-visible-area-of-screens-in-OS-X-v2.patch >From a32609425f3aba89e1171e2dd1139876cc84051b Mon Sep 17 00:00:00 2001 From: Charles A. Roelli Date: Sat, 8 Apr 2017 22:15:17 +0200 Subject: [PATCH] Constrain frames to visible area of screens in OS X * nsterm.m (constrainFrameRect:toScreen:): Constrain frames in OS X, if they would otherwise go offscreen. Fixes: debbugs:25818 --- src/nsterm.m | 32 +++++++++++++++++++++++++++++++- 1 files changed, 31 insertions(+), 1 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index ebe29e4..66c9d50 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7853,7 +7853,37 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen NSTRACE_RETURN_RECT (frameRect); return frameRect; } -#endif + else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 */ + // Check that the proposed frameRect is visible in at least one + // screen. If it is not, ask the system to reposition it. + { + NSArray *screens = [NSScreen screens]; + NSUInteger nr_screens = [screens count]; + + int i; + BOOL frame_on_screen = NO; + + for (i = 0; i < nr_screens; ++i) + { + NSScreen *s = [screens objectAtIndex: i]; + NSRect scrRect = [s frame]; + + if (NSIntersectsRect(frameRect, scrRect)) + { + frame_on_screen = YES; + break; + } + } + + if (!frame_on_screen) + { + NSTRACE_MSG ("Frame outside screens; constraining"); + frameRect = [super constrainFrameRect:frameRect toScreen:screen]; + NSTRACE_RETURN_RECT (frameRect); + return frameRect; + } + } #endif return constrain_frame_rect(frameRect, -- 1.7.4.4 --=-=-=--