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: Sat, 08 Apr 2017 22:40:31 +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 1491684075 14504 195.159.176.226 (8 Apr 2017 20:41:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Apr 2017 20:41:15 +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 Sat Apr 08 22:41:07 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 1cwxAP-0002bT-VO for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Apr 2017 22:41:06 +0200 Original-Received: from localhost ([::1]:56461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwxAV-0003oU-UP for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Apr 2017 16:41:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwxAP-0003oL-Ov for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 16:41:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwxAM-0000Cl-Ky for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 16:41:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cwxAM-0000Cf-G3 for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 16:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cwxAM-0002vp-AW for bug-gnu-emacs@gnu.org; Sat, 08 Apr 2017 16:41:02 -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: Sat, 08 Apr 2017 20:41:02 +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.149168404311232 (code B ref 25818); Sat, 08 Apr 2017 20:41:02 +0000 Original-Received: (at 25818) by debbugs.gnu.org; 8 Apr 2017 20:40:43 +0000 Original-Received: from localhost ([127.0.0.1]:38516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwxA3-0002v5-4z for submit@debbugs.gnu.org; Sat, 08 Apr 2017 16:40:43 -0400 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:51708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwxA1-0002uq-RI for 25818@debbugs.gnu.org; Sat, 08 Apr 2017 16:40:42 -0400 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id CD7DC223D9 for <25818@debbugs.gnu.org>; Sat, 8 Apr 2017 20:36:51 +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= 1491683808; x=1492547809; bh=V3N7VriCKGVFwcAhB+d3W09vNmKOuDso+ID lG23Q4Ic=; b=avNJfhDgjOpLnB29GB1TO2qbqFZXdNnerqihEhEmoqoolbwmwr1 wEkxKjfBmpCEYnBlAMXREeHo/sDjy3Me9O94yiQ+o9mb310SSc76/Ies2AgZcFTD XQ8RVnk695er+SkFMGhgNe/UNfFN27viAVBZUkyQpXnSkbXtOKRmRajY= 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 yrTmPCOhuoSq for <25818@debbugs.gnu.org>; Sat, 8 Apr 2017 20:36:48 +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 A6A462238D; Sat, 8 Apr 2017 20:36:48 +0000 (UTC) In-Reply-To: (Anders Lindgren's message of "Mon, 3 Apr 2017 10:33:04 +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:131386 Archived-At: --=-=-= Content-Type: text/plain Hi Anders, Following your idea, here's an updated patch that works equivalently. Please let me know what you think. > Anyway, I think that we're on the right track and I appreciate that you > have taken time to work on this! My pleasure! > PS. I just found another, unrelated, problem, when comparing the NS and X11 > versions. When passing a negative value to `set-frame-position' it is > supposed to place the frame relative to the right/bottom border of the > display, but in the NS version it doesn't. (The X11 version gets the Y > placement wrong with 48 pixels, but that is another story.) Hm... but what if a second display is in the negative coordinate space? How would you place a frame on it programmatically? In any case I'll try to build the X11 version and see how it does it -- I wasn't aware that it still works on Mac OS. Cheers, Charles >> A quick test on 10.6: >> >> (setq ns-auto-hide-menu-bar t) >> >> ;; Places the frame just above the top of the screen. >> (set-frame-position (selected-frame) 0 -20) >> >> ;; Frame would be completely offscreen; so it's constrained and brought >> ;; back. >> (set-frame-position (selected-frame) 0 -10000) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Constrain-frames-to-visible-area-of-screens-in-OS-X-revised.patch >From 2b95b86f8c50665bbbb62b5faae0d8d610019594 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 | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index ebe29e4..b1429f4 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7846,21 +7846,52 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 // If separate spaces is on, it is like each screen is independent. There is // no spanning of frames across screens. if ([NSScreen screensHaveSeparateSpaces]) { NSTRACE_MSG ("Screens have separate spaces"); frameRect = [super constrainFrameRect:frameRect toScreen: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 intersects at least one + // screen rectangle. If it does not, constrain the frame and + // return it. See bug #25818. + { + 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, [(EmacsView *)[self delegate] isFullscreen]); } - (void)performZoom:(id)sender { NSTRACE ("[EmacsWindow performZoom:]"); -- 1.7.4.4 --=-=-=--