Subject: bug#28605: 26.0.60; Part of leftmost character hidden

From: Robert Pluim <[email-masked]>
Date: Wed, 04 Oct 2017 13:56:54 +0200

Ola Nilsson <[email-masked]> writes:

> On Wed, Oct 4, 2017 at 11:05 AM, martin rudalics <[email-masked]> wrote:
>>On Tue, Oct 3, 2017 at 6:58 PM, Ola Nilsson <[email-masked]> wrote:
>>> This works for me:
>>>
>>> @@ -3883,7 +3883,7 @@ xg_update_scrollbar_pos (struct frame *f,
>>>         top /= scale;
>>>         left /= scale;
>>>         height /= scale;
>>> -      left -= (scale - 1) * ((width / scale) >> 1);
>>> +      width /= scale;
>>
>> Deceptively simple.  Whatever was that left rigmarole needed for?
>> What changes with
>>
>>       width /= scale;
>>       left -= (scale - 1) * (width >> 1);
>
> From the top of my head, the vertical scrollbar is placed to far to the left
> overlapping the window to the left and leaving a white band between the
> scroll bar and the left-fringe of the window to the right.
> It does nothing if scale is 1, obviously.

Yes, I think removing the calculation for left is the correct fix (at
least it looks correct here). The horizontal scrollbars need fixing as
well, see below. xg_update_scrollbar_pos and xg_update_horizontal_scrollbar_pos
are now 99% identical apart from the 'hidden' check.

I don't think this will be the final version: I sometimes get the echo
area being the wrong size...

diff --git a/src/gtkutil.c b/src/gtkutil.c
index 0da7039..b41e8f1 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3879,7 +3879,7 @@ xg_update_scrollbar_pos (struct frame *f,
       top /= scale;
       left /= scale;
       height /= scale;
-      left -= (scale - 1) * ((width / scale) >> 1);
+      width /= scale;
 
       /* Clear out old position.  */
       int oldx = -1, oldy = -1, oldw, oldh;
@@ -3955,6 +3955,12 @@ xg_update_horizontal_scrollbar_pos (struct frame *f,
       GtkWidget *wfixed = f->output_data.x->edit_widget;
       GtkWidget *wparent = gtk_widget_get_parent (wscroll);
       gint msl;
+      int scale = xg_get_scale (f);
+
+      top /= scale;
+      left /= scale;
+      height /= scale;
+      width /= scale;
 
       /* Clear out old position.  */
       int oldx = -1, oldy = -1, oldw, oldh;
@@ -3981,8 +3987,12 @@ xg_update_horizontal_scrollbar_pos (struct frame *f,
           gtk_widget_set_size_request (wscroll, width, height);
         }
       if (oldx != -1 && oldw > 0 && oldh > 0)
-        /* Clear under old scroll bar position.  */
-        x_clear_area (f, oldx, oldy, oldw, oldh);
+       {
+         /* Clear under old scroll bar position.  */
+         oldw += (scale - 1) * oldw;
+         oldx -= (scale - 1) * oldw;
+         x_clear_area (f, oldx, oldy, oldw, oldh);
+       }
 
       /* GTK does not redraw until the main loop is entered again, but
          if there are no X events pending we will not enter it.  So we sync