emacs-devel
[Top][All Lists]
Advanced

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

Re: About x_draw_xwidget_glyph_string


From: joakim
Subject: Re: About x_draw_xwidget_glyph_string
Date: Sat, 09 Apr 2016 13:22:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: address@hidden
>> Cc: YAMAMOTO Mitsuharu <address@hidden>,  address@hidden
>> Date: Fri, 08 Apr 2016 17:35:23 +0200
>> 
>> Eli Zaretskii <address@hidden> writes:
>> 
>> >> Date: Mon, 25 Jan 2016 11:07:16 +0900
>> >> From: YAMAMOTO Mitsuharu <address@hidden>
>> >> 
>> >> 2. Comment on clipping.
>> >> 
>> >>    578      /* Calculate clipping, which is used for all manner of 
>> >> onscreen
>> >>    579         xwidget views.  Each widget border can get clipped by 
>> >> other emacs
>> >>    580         objects so there are four clipping variables.  */
>> >>    581      clip_right =
>> >>    582        min (xww->width,
>> >>    583             WINDOW_RIGHT_EDGE_X (s->w) - x -
>> >>    584             WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (s->w) -
>> >>    585             WINDOW_RIGHT_FRINGE_WIDTH (s->w));
>> >>    586      clip_left =
>> >>    587        max (0,
>> >>    588             WINDOW_LEFT_EDGE_X (s->w) - x +
>> >>    589             WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (s->w) +
>> >>    590             WINDOW_LEFT_FRINGE_WIDTH (s->w));
>> >>    591    
>> >>    592      clip_bottom =
>> >>    593        min (xww->height,
>> >>    594             WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT 
>> >> (s->w) - y);
>> >>    595      clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y);
>> >> 
>> >> I think the calculation of clipping should use the function window_box
>> >> rather than manual calculation with various window macros.  Otherwise,
>> >> xwidget views will cover horizontal scroll bars, for example.
>> >
>> > I agree.
>> >
>> > Thanks.
>> >
>> 
>> I tried to do this, but I'm doing something wrong. How is window_box
>> meant to be used?
>> 
>> This is my attempt to replace the code above:
>> 
>>   //JAVE work in progressing, suggested by YAMAMOTO Mitsuharu
>>   int text_area_x, text_area_y, text_area_width, text_area_height;
>>   
>>   window_box (s->w,
>>               ANY_AREA, //also tried TEXT_AREA
>
> You should use TEXT_AREA here.
>
>>               &text_area_x,
>>               &text_area_y,
>>               &text_area_width,
>>               &text_area_height);
>>   clip_right =
>>     min (xww->width,
>>          text_area_width);
>>   clip_left =
>>     max (0,
>>          text_area_x);
>> 
>>   clip_bottom =
>>     min (xww->height,
>>          text_area_y);
>>   clip_top = max (0, text_area_height);
>
> I think clip_top should use text_area_y and clip_bottom should use
> text_area_height.
>
> Other than those two issues, what other problems do you see?

Well, I saw nothing at all :)

This patch seems to work during some brief testing. 

diff --git a/src/xwidget.c b/src/xwidget.c
index 8ff4c23..fa61f57 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -578,25 +578,24 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
      other time to know things like window placement etc.  */
   xv = xwidget_init_view (xww, s, x, y);
 
-  /* Calculate clipping, which is used for all manner of onscreen
-     xwidget views.  Each widget border can get clipped by other emacs
-     objects so there are four clipping variables.  */
-  clip_right =
-    min (xww->width,
-         WINDOW_RIGHT_EDGE_X (s->w) - x -
-         WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (s->w) -
-         WINDOW_RIGHT_FRINGE_WIDTH (s->w));
-  clip_left =
-    max (0,
-         WINDOW_LEFT_EDGE_X (s->w) - x +
-         WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (s->w) +
-         WINDOW_LEFT_FRINGE_WIDTH (s->w));
-
-  clip_bottom =
-    min (xww->height,
-         WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y);
-  clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y);
-
+  int text_area_x, text_area_y, text_area_width, text_area_height;
+  
+  window_box (s->w,
+              ANY_AREA,
+              &text_area_x,
+              &text_area_y,
+              &text_area_width,
+              &text_area_height);
+  clip_right = min (xww->width,
+                    text_area_width);
+  clip_left = max (0,
+                   text_area_x);
+
+  clip_bottom = min (xww->height,
+                     text_area_height);
+  clip_top = max (0, text_area_y);
+
+  
   /* We are concerned with movement of the onscreen area.  The area
      might sit still when the widget actually moves.  This happens
      when an Emacs window border moves across a widget window.  So, if


-- 
Joakim Verona



reply via email to

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