From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Sergey Trofimov Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Fix fit-frame-to-buffer for multi-monitor setup. Date: Sat, 29 Feb 2020 19:31:26 +0100 Message-ID: References: <91a85405-ca57-096c-bb7e-058580b04577@gmx.at> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="66421"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 29 19:41:53 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j873g-000HBJ-UY for ged-emacs-devel@m.gmane-mx.org; Sat, 29 Feb 2020 19:41:52 +0100 Original-Received: from localhost ([::1]:34898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j873g-0001A6-1u for ged-emacs-devel@m.gmane-mx.org; Sat, 29 Feb 2020 13:41:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37763) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j86uE-0005iK-JX for emacs-devel@gnu.org; Sat, 29 Feb 2020 13:32:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j86uD-0000s4-8r for emacs-devel@gnu.org; Sat, 29 Feb 2020 13:32:06 -0500 Original-Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]:35229) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j86uC-0000oO-N0 for emacs-devel@gnu.org; Sat, 29 Feb 2020 13:32:05 -0500 Original-Received: by mail-ed1-x541.google.com with SMTP id c7so7754439edu.2 for ; Sat, 29 Feb 2020 10:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=GcAnFlpjTAg0hulV9Hs9nVakC1WMxvhHCz7XP5pbyfY=; b=MJ4tXIL0e9PaGvhwufzhEFyerOZMdagXRJMkofCO8vkCCEhsRup/LK/ddb9FUE8Yq7 vfguCqmPUN+cv1ZHlN9AzMydVwlPhrWifWrzvgCnIq+3tGX06xynjBjDRo0Zx3KX1VY0 Ry2F63GbDSaopP0PF6r0udyzVaG5mkOKBv1T0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=GcAnFlpjTAg0hulV9Hs9nVakC1WMxvhHCz7XP5pbyfY=; b=nxh56Tn+9mGmWg0fX502BsG6q7xLlIhr+pWqBG2Ie05hhw45IgnsZthejaI0kVAxkh 7xHcJCK7ut226qH8pKFK161b9EbulMb3qeUwXxNhOaBZnVE/1wnoa+THgXAYmlE7yWEE XlctWnEYgUzZigKAvFI6TmRehTFnvXpzCnYZg3/VKcx8U5CzM24HIyKY124CFdxVcZNO rsLiUWsaaxdSj9VQQv4ForWPNnq9UPc3jIlC77i9r0qxOiK6Sv5ay5NjE9YA3rn6oL6R kFAESPLmRxhRby3l089LnzSOqLcJ1Tksmfz3xrE81aitKFPLXkbItdyb4LVDgvufcNr7 iahg== X-Gm-Message-State: APjAAAVMFDFpsbmIlSmqVRCn2RSGF2oDs2D/W1d844XNOrGmyYArPXS3 hGAfpVyabKeV4Xuvzoy7DSSK9FauMPE+ymrjb9fA34Fc1BtNpA== X-Google-Smtp-Source: APXvYqxB/4RcDY45hDIfA+8x3gBuSWBoNyPaLPWwE9mfXrm1aI1zUMi9C3c5PN9+Qc0NkygGC4czkforNoC0xQqHTDI= X-Received: by 2002:a05:6402:1c87:: with SMTP id cy7mr9947024edb.348.1583001122372; Sat, 29 Feb 2020 10:32:02 -0800 (PST) In-Reply-To: <91a85405-ca57-096c-bb7e-058580b04577@gmx.at> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::541 X-Mailman-Approved-At: Sat, 29 Feb 2020 13:41:20 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245127 Archived-At: On Sat, 29 Feb 2020 at 17:05, martin rudalics wrote: > > > I've noticed `fit-frame-to-buffer` results in incorrect frame position > > when the frame is not a child frame. I've looked into the code and > > seems that there are two issues: first is that frame monitor is > > ignored, always first monitor in `display-monitor-attributes-list` is > > used. > > Good. I never really checked that since I always use only one monitor. > Besides, 'frame-monitor-attributes' should be preferable anyway. > > > Second is that `workarea` and `geometry` are in the form of `(X > > Y WIDTH HEIGHT)` but code treats them as `(X1 Y1 X2 Y2)`. > > I believe the reasoning was to avoid moving the frame whenever it > already appears within its margins and thus constrain it to the region > to the right of and below (X, Y). But my memory may fail. Yes, the intention is correct, but few formulas are written in a wrong assumption of return value of (display-monitor-attributes-list). > Could you provide an example where the original code results in bad placement? I have used this snippet to debug. My setup is: Screen 0: current 1920 x 1980 LVDS-1 connected 1600x900+0+1080 HDMI-1 connected primary 1920x1080+0+0 LVDS-1 is placed under HDMI-1 ;; I'm create a frame on LVDS1 in the upper area of the monitor (setq sarg/frame (posframe-show "*scratch*" :width 20 :height 20 :min-width 20 :background-color "#ff0000" :min-height 20 :position '(100 . 1200) :override-parameters '((parent-frame nil)))) ;; this function works correctly and returns size of LVDS-1 where the frame is shown (frame-monitor-workarea sarg/frame) ;; (0 1080 1600 900) - (X Y W H) ;; notice that the formula for parent-or-display-width ;; (- (nth 3 geometry) (nth 1 geometry)) ;; is producing incorrect value (mapcar (lambda (p) (frame-parameter sarg/frame p)) '(left top width height)) ;; (100 1200 20 20) - frame is sized and placed correctly ;; the buffer contents are slightly bigger, so the frame should be resized accordingly (fit-frame-to-buffer sarg/frame) (mapcar (lambda (p) (frame-parameter sarg/frame p)) '(left top width height)) ;; (100 1004 50 4) ;; new size is correct but the frame jumped on the first monitor, 1004 < 1080 (posframe-delete-all)