From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joakim@verona.se Newsgroups: gmane.emacs.devel Subject: Re: About x_draw_xwidget_glyph_string Date: Sat, 09 Apr 2016 13:22:52 +0200 Message-ID: References: <83oac93bnr.fsf@gnu.org> <83shyvi64r.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1460201018 1411 80.91.229.3 (9 Apr 2016 11:23:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Apr 2016 11:23:38 +0000 (UTC) Cc: mituharu@math.s.chiba-u.ac.jp, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 09 13:23:37 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aoqzI-0003FB-Ps for ged-emacs-devel@m.gmane.org; Sat, 09 Apr 2016 13:23:37 +0200 Original-Received: from localhost ([::1]:60060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoqzE-0001dR-Qh for ged-emacs-devel@m.gmane.org; Sat, 09 Apr 2016 07:23:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoqzA-0001aG-9z for emacs-devel@gnu.org; Sat, 09 Apr 2016 07:23:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoqz9-0003rX-6l for emacs-devel@gnu.org; Sat, 09 Apr 2016 07:23:28 -0400 Original-Received: from mx2.bahnhof.se ([213.80.101.12]:52667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoqz5-0003qy-7M; Sat, 09 Apr 2016 07:23:23 -0400 Original-Received: from localhost (mf.bahnhof.se [213.80.101.20]) by mx2-reinject (Postfix) with ESMTP id 93EF140906; Sat, 9 Apr 2016 13:23:21 +0200 (CEST) X-Virus-Scanned: by amavisd-new using ClamAV at bahnhof.se (MF4) Original-Received: from mf4.bahnhof.se ([127.0.0.1]) by localhost (mf4.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TNZPtrlmXg1n; Sat, 9 Apr 2016 13:23:15 +0200 (CEST) Original-Received: from mta.verona.se (h-235-62.a149.priv.bahnhof.se [85.24.235.62]) by mf4.bahnhof.se (Postfix) with ESMTP id 022D43D77DA; Sat, 9 Apr 2016 13:23:12 +0200 (CEST) Original-Received: from localhost (unknown [127.0.0.1]) by mta.verona.se (Postfix) with ESMTP id 1DE594EF0A5; Sat, 9 Apr 2016 11:23:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at verona.se Original-Received: from mta.verona.se ([127.0.0.1]) by localhost (exodia.verona.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1cN9L2p_aqWe; Sat, 9 Apr 2016 13:22:52 +0200 (CEST) Original-Received: from exodia.verona.se (www.verona.se [192.168.200.15]) by mta.verona.se (Postfix) with ESMTP id DE3C44EF0A3; Sat, 9 Apr 2016 13:22:52 +0200 (CEST) In-Reply-To: <83shyvi64r.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 09 Apr 2016 10:38:28 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.12 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:202825 Archived-At: Eli Zaretskii writes: >> From: joakim@verona.se >> Cc: YAMAMOTO Mitsuharu , emacs-devel@gnu.org >> Date: Fri, 08 Apr 2016 17:35:23 +0200 >> >> Eli Zaretskii writes: >> >> >> Date: Mon, 25 Jan 2016 11:07:16 +0900 >> >> From: YAMAMOTO Mitsuharu >> >> >> >> 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