emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set-frame-parameter a child-frame's 'parent-frame error on macOS ?


From: Robert Pluim
Subject: Re: set-frame-parameter a child-frame's 'parent-frame error on macOS ?
Date: Mon, 22 Jan 2018 12:11:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux)

Robert Pluim <address@hidden> writes:

> Dmitry Gutov <address@hidden> 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

>From 3324e5b4d94d5432a13d0d2828f342a8cf3c1398 Mon Sep 17 00:00:00 2001
From: Robert Pluim <address@hidden>
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]