From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: set-frame-parameter a child-frame's 'parent-frame error on macOS ? Date: Mon, 22 Jan 2018 12:11:26 +0100 Message-ID: <87k1wakv1d.fsf@gmail.com> References: <3341a4c3.36ca.160e851bdbd.Coremail.tumashu@163.com> <5A5876A3.10402@gmx.at> <87fu7b6zsj.fsf@163.com> <5A5902D9.9070801@gmx.at> <16191b19.1392.160ed773bef.Coremail.tumashu@163.com> <5A59C872.1010900@gmx.at> <87tvvqxcxr.fsf@163.com> <5A59F476.1060806@gmx.at> <87mv1hcnw8.fsf@163.com> <5A5B1D46.6000608@gmx.at> <731a3868-e589-978b-ee34-ab72cf5c5aff@yandex.ru> <4d250ebc-7979-3229-b9ea-6e57089d02df@yandex.ru> <5A5C76AC.60308@gmx.at> <53c55d98-dbf6-7e6d-eaa5-66e565f93581@yandex.ru> <87d12agitl.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1516619439 25883 195.159.176.226 (22 Jan 2018 11:10:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 22 Jan 2018 11:10:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux) Cc: martin rudalics , emacs-devel@gnu.org, Feng Shu To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 22 12:10:34 2018 Return-path: Envelope-to: ged-emacs-devel@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 1edZzT-0005GT-Dl for ged-emacs-devel@m.gmane.org; Mon, 22 Jan 2018 12:10:15 +0100 Original-Received: from localhost ([::1]:35530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eda1R-0006ov-UJ for ged-emacs-devel@m.gmane.org; Mon, 22 Jan 2018 06:12:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eda0k-0006oF-BZ for emacs-devel@gnu.org; Mon, 22 Jan 2018 06:11:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eda0h-0006hG-5o for emacs-devel@gnu.org; Mon, 22 Jan 2018 06:11:34 -0500 Original-Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:46119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eda0g-0006g4-Rw for emacs-devel@gnu.org; Mon, 22 Jan 2018 06:11:31 -0500 Original-Received: by mail-wr0-x22b.google.com with SMTP id g21so8169916wrb.13 for ; Mon, 22 Jan 2018 03:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=jVDKKCIYiTi5K5M3CuNunD8iQyYtC2Ic6y0fOreyusA=; b=k+O+T1IEpKFHAfVHZzyzU4CPeZtxMl8LFHZehrKb2dfg3tHdo+T0NsZlpJvcoQHZMW NBlqCumkq6xqBacYP502cHKLtya3BaMqguk0E+WYwRyxjJV5bWT0gc2hqi6PZt3gW1wN ONS1uPjp3yGgMRs/r/TSJFt7nVr0HC5Du6uE+iKkfhyLITywFJ3aZxJwByiu6IKyQYvR UNbKH1Y1eodrOtKU65CYl8nzXCm5PFVIc+PJ6lwnF2OiowZUQkKTz0gFa50dy39rjDae 03Ljhu6n/vVOeLTZGvJc/BDLzwRoPlDVui1mtT6Xf3PUlOWG64rEVtGaenLf0E2f+sGr Vm9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=jVDKKCIYiTi5K5M3CuNunD8iQyYtC2Ic6y0fOreyusA=; b=ZaapwnhzGIICiyAV8G34VQJ9M1lbwl5Shd81n/vI0NLrRrt+xp0fNSQbsq4Gb8qaqr s/wVdIJaGSmQ15XNOHk795U6dKwZ8cipObG157rbHKdD5Rki6wexKCObZtkru3XX6vMY wIYbSgt10pmwguxsrKpSEE0WgT1lYL75M7zT/B4Q69HUHxXR7nCSNDk72NEYWIj0ZV9y hMoXbogNvmCPoYcWwW1dSrs9HP2UeRo+LgjsVPYK0rIYAUloMqgd78OmacjDCMMlQCmZ ONsu9udtyN8GWvebMmNHAsiejq0XaLbBG4TF1oU6qRig18+dhcvaz5KLdiByox1z+PAs /jtQ== X-Gm-Message-State: AKwxytd0t3uCNju3yIJnQSOA00FwNVQMlGNV1UGQnzOWCAiEohkJV57T Bosh4BxZWiECg3kXQ5mEAKvBWRuT X-Google-Smtp-Source: AH8x2244xBZHOtdsJwii4Ba4umZwM//D9wvf4koyIFyhe6OS9RM4w33aWD3q1ragNX9aYQfbGQa2Rw== X-Received: by 10.223.199.14 with SMTP id k14mr5481114wrg.276.1516619489495; Mon, 22 Jan 2018 03:11:29 -0800 (PST) Original-Received: from rpluim-ubuntu ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id k69sm6938550wmg.8.2018.01.22.03.11.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 03:11:27 -0800 (PST) In-Reply-To: <87d12agitl.fsf@gmail.com> (Robert Pluim's message of "Tue, 16 Jan 2018 12:10:46 +0100") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:222136 Archived-At: --=-=-= Content-Type: text/plain Robert Pluim writes: > Dmitry Gutov writes: > >> That is the description of my experience with Robert's patch >> applied. Without it applied, the "bad frame" appears last (at position >> 40-100, approximately). >> >> Feng Shu has changed his code since to call set-frame-position much >> less often, and it seems to work correctly *without* Robert's >> patch. Quite weird. > > Yes. I have an improved version of the patch on the way, which should > also fix `frameset-restore' and a few other cases of incorrect frame > positioning. Hopefully by the end of the week. frameset-restore turned out to be a completely separate fix. The attached fixes the cases that I could track down where we weren't applying scaling properly. All Emacs pixel coordinates remain unscaled after this, the values are just scaled when passing them into GTK. The xwidget code almost certainly requires the same type of adjustments. Strongly recommended for emacs-26. People who don't use scaling will see no side-effects. Robert --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Use-scaled-coordinates-when-calling-into-GTK.patch >From 3324e5b4d94d5432a13d0d2828f342a8cf3c1398 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 19 Jan 2018 11:38:07 +0100 Subject: [PATCH] Use scaled coordinates when calling into GTK * src/gtkutil.c (xg_set_geometry): Scale down the coordinates that we pass to gtk_window_move and to gtk_window_parse_geometry. * src/xterm.c (x_set_offset): Likewise. --- src/gtkutil.c | 9 ++++++--- src/xterm.c | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index 123236f5f0..83b306a730 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -823,6 +823,7 @@ xg_set_geometry (struct frame *f) { if (f->size_hint_flags & (USPosition | PPosition)) { + int scale = xg_get_scale (f); #if ! GTK_CHECK_VERSION (3, 22, 0) if (x_gtk_use_window_move) { @@ -838,8 +839,9 @@ xg_set_geometry (struct frame *f) f->top_pos = (x_display_pixel_height (FRAME_DISPLAY_INFO (f)) - FRAME_PIXEL_HEIGHT (f) + f->top_pos); + /* GTK works in scaled pixels, so convert from X pixels. */ gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - f->left_pos, f->top_pos); + f->left_pos / scale, f->top_pos / scale); /* Reset size hint flags. */ f->size_hint_flags &= ~ (XNegative | YNegative); @@ -847,9 +849,10 @@ xg_set_geometry (struct frame *f) } else { - int left = f->left_pos; + /* GTK works in scaled pixels, so convert from X pixels. */ + int left = f->left_pos / scale; int xneg = f->size_hint_flags & XNegative; - int top = f->top_pos; + int top = f->top_pos / scale; int yneg = f->size_hint_flags & YNegative; char geom_str[sizeof "=x--" + 4 * INT_STRLEN_BOUND (int)]; guint id; diff --git a/src/xterm.c b/src/xterm.c index f771631daf..f05ac6147e 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10310,6 +10310,7 @@ void x_set_offset (struct frame *f, register int xoff, register int yoff, int change_gravity) { int modified_top, modified_left; + int scale = xg_get_scale (f); if (change_gravity > 0) { @@ -10332,11 +10333,12 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_ if (x_gtk_use_window_move) { /* When a position change was requested and the outer GTK widget - has been realized already, leave it to gtk_window_move to DTRT - and return. Used for Bug#25851 and Bug#25943. */ + has been realized already, leave it to gtk_window_move to + DTRT and return. Used for Bug#25851 and Bug#25943. Convert + from X pixels to GTK scaled pixels. */ if (change_gravity != 0 && FRAME_GTK_OUTER_WIDGET (f)) gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - f->left_pos, f->top_pos); + f->left_pos / scale, f->top_pos / scale); unblock_input (); return; } @@ -10355,8 +10357,9 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_ } #ifdef USE_GTK + /* Make sure we adjust for possible scaling. */ gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - modified_left, modified_top); + modified_left / scale, modified_top / scale); #else XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), modified_left, modified_top); -- 2.16.0.rc1 --=-=-=--