From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.bugs Subject: bug#35464: [PATCH] Refactor update_window_begin and update_window_end hooks Date: Sat, 27 Apr 2019 15:28:49 -0600 Message-ID: <87k1ffnnn2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="238240"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) To: 35464@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 27 23:45:22 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hKV8L-000zqU-Jf for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Apr 2019 23:45:21 +0200 Original-Received: from localhost ([127.0.0.1]:36616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKV8K-0001jZ-JV for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Apr 2019 17:45:20 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKV86-0001i3-AT for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2019 17:45:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hKV84-0003dr-BE for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2019 17:45:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50863) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hKV84-0003di-5g for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2019 17:45:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hKV84-0005HL-1Z for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2019 17:45:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Gramiak Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Apr 2019 21:45:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35464 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.155640150220267 (code B ref -1); Sat, 27 Apr 2019 21:45:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Apr 2019 21:45:02 +0000 Original-Received: from localhost ([127.0.0.1]:36170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hKV81-0005GV-BT for submit@debbugs.gnu.org; Sat, 27 Apr 2019 17:45:02 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47133) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hKV7z-0005GE-Co for submit@debbugs.gnu.org; Sat, 27 Apr 2019 17:45:00 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:38970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hKV7u-0003Pn-5m for submit@debbugs.gnu.org; Sat, 27 Apr 2019 17:44:54 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKV7r-0001RN-VA for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2019 17:44:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hKUt2-0003JS-Ev for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2019 17:29:36 -0400 Original-Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:42131) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hKUt0-0003Ho-NJ for bug-gnu-emacs@gnu.org; Sat, 27 Apr 2019 17:29:32 -0400 Original-Received: by mail-pl1-x630.google.com with SMTP id x15so3185984pln.9 for ; Sat, 27 Apr 2019 14:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=eWqkLT4c18FLbfFUGtceXedzcJsZ/OvLtl3t1pOEHM0=; b=lfDoYlhmnLKywnsPqZsOuFUZQxcqM8dzkVwWbsxl8Bue7mh52BUlisjaH/Mp+JwWJ3 EoiNbACl9NBGxDwNk4uWd77I91uYqW+aekH9XfYclIy9ZbnjVDfdqGIqECzGF0iF0pDi j2SA+We9znxMEmF7sFcRNdpR5Vx/qYX2h0Hj6nus1dCQl/N96Zkeck/r99493csC9jLG 9ZWwxjpkZLghQ3qvRMNOtQiQTi9bnvjSY4h3UKVK4ciCSjKfeCYkAgglF/uXT+HHVdOk HY2uUQUM7J7Tb9J8fSrFQMjmTDgg30JrjhvAMAHndjqERrTbhwpS20OlqzAob0Vnkm9+ LS5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=eWqkLT4c18FLbfFUGtceXedzcJsZ/OvLtl3t1pOEHM0=; b=eoxO6l+Vf4Xm6lkwcHaAlguOYLU66/4kn7PYndKGPKKFBug4hgh8jhKxzJIc9+W/+e S5yLRALVGby9zyNd2oSUEV0AaWukz3+1YGMHR/Oif0Rb4igiaK9S6qN8eNB/nVBJ/Dmt QmMncM9Uut9D39AKF17wTxsniKKx1FIVkcD0o+btI1wu7M83j41Z5lPTrU0ZtkkDp/it sSuc8cXIIwTipCsoBXIDBOXtiqhh/Wznmgz7tMIZ9CVqKsoCBVMIFPqHIQEuiKLLO49x LDI+hbFYcgewdOzZ7Pz4cMutUQov0J1oevlL+HeiHe0tjcEwdGE4p9yoooUgfguUYXYG 2QZg== X-Gm-Message-State: APjAAAVpVg8WUwOoXKoJsjWct3mNI6OBsuqFYtFmEhMMXw3EJ9re3g7W ql26sBocuZgIxe7d+Hy/4gR+sktH X-Google-Smtp-Source: APXvYqxL8O8RH5IWHaQUhRelpJr48oMTLoVBW9jngKgadNbOBRTVoKeoqCDjvHGATyPBzJW/H8mBsQ== X-Received: by 2002:a17:902:6bc2:: with SMTP id m2mr53538400plt.194.1556400568272; Sat, 27 Apr 2019 14:29:28 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id d8sm31611311pgv.34.2019.04.27.14.29.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 27 Apr 2019 14:29:27 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158382 Archived-At: --=-=-= Content-Type: text/plain I have two questions about this: 1) Is it okay to not use reset_mouse_highlight in the generic version (ns_update_window_end still uses it)? See commit 60ae3d09932f for why reset_mouse_highlight was removed in the x/w32 versions. 2) Should the #if 0 section be removed in w32_update_window_begin? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Refactor-update_window_begin-and-update_window_end-h.patch >From ab69f49d4cb1446832e8c6167888435fd71ae356 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Sat, 27 Apr 2019 15:00:13 -0600 Subject: [PATCH] Refactor update_window_begin and update_window_end hooks * src/xdisp.c (gui_update_window_begin, gui_update_window_end): New procedures implementing common functionality. * src/nsterm.m: (ns_update_window_begin, ns_update_window_end): Remove in favor of the generic version. * src/w32term.c: (w32_update_window_begin, w32_update_window_end): Use gui_update_window_begin and gui_update_window_end. * src/xterm.c: (x_update_window_begin, x_update_window_end): Remove in favor of the generic version. --- src/dispextern.h | 3 ++ src/nsterm.m | 78 +++----------------------------------------- src/w32term.c | 40 ++--------------------- src/xdisp.c | 67 ++++++++++++++++++++++++++++++++++++++ src/xterm.c | 84 +++--------------------------------------------- 5 files changed, 80 insertions(+), 192 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index 4d6d0371d3..827eed86f1 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3303,6 +3303,9 @@ extern void gui_update_cursor (struct frame *, bool); extern void gui_clear_cursor (struct window *); extern void gui_draw_vertical_border (struct window *w); extern void gui_draw_right_divider (struct window *w); +extern void gui_update_window_begin (struct window *w); +extern void gui_update_window_end (struct window *w, bool cursor_on_p, + bool mouse_face_overwritten_p); extern int get_glyph_string_clip_rects (struct glyph_string *, NativeRectangle *, int); diff --git a/src/nsterm.m b/src/nsterm.m index cdf1916e71..2a2b8cbaba 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1106,7 +1106,7 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) ns_update_begin (struct frame *f) /* -------------------------------------------------------------------------- Prepare for a grouped sequence of drawing calls - external (RIF) call; whole frame, called before update_window_begin + external (RIF) call; whole frame, called before gui_update_window_begin -------------------------------------------------------------------------- */ { #ifdef NS_IMPL_COCOA @@ -1128,81 +1128,11 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) } -static void -ns_update_window_begin (struct window *w) -/* -------------------------------------------------------------------------- - Prepare for a grouped sequence of drawing calls - external (RIF) call; for one window, called after update_begin - -------------------------------------------------------------------------- */ -{ - struct frame *f = XFRAME (WINDOW_FRAME (w)); - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); - - NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_begin"); - w->output_cursor = w->cursor; - - block_input (); - - if (f == hlinfo->mouse_face_mouse_frame) - { - /* Don't do highlighting for mouse motion during the update. */ - hlinfo->mouse_face_defer = 1; - - /* If the frame needs to be redrawn, - simply forget about any prior mouse highlighting. */ - if (FRAME_GARBAGED_P (f)) - hlinfo->mouse_face_window = Qnil; - - /* (further code for mouse faces ifdef'd out in other terms elided) */ - } - - unblock_input (); -} - - -static void -ns_update_window_end (struct window *w, bool cursor_on_p, - bool mouse_face_overwritten_p) -/* -------------------------------------------------------------------------- - Finished a grouped sequence of drawing calls - external (RIF) call; for one window called before update_end - -------------------------------------------------------------------------- */ -{ - NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_end"); - - /* note: this fn is nearly identical in all terms */ - if (!w->pseudo_window_p) - { - block_input (); - - if (cursor_on_p) - display_and_set_cursor (w, 1, - w->output_cursor.hpos, w->output_cursor.vpos, - w->output_cursor.x, w->output_cursor.y); - - if (draw_window_fringes (w, 1)) - { - if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) - gui_draw_right_divider (w); - else - gui_draw_vertical_border (w); - } - - unblock_input (); - } - - /* If a row with mouse-face was overwritten, arrange for - frame_up_to_date to redisplay the mouse highlight. */ - if (mouse_face_overwritten_p) - reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame))); -} - - static void ns_update_end (struct frame *f) /* -------------------------------------------------------------------------- Finished a grouped sequence of drawing calls - external (RIF) call; for whole frame, called after update_window_end + external (RIF) call; for whole frame, called after gui_update_window_end -------------------------------------------------------------------------- */ { NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_end"); @@ -5166,8 +5096,8 @@ static Lisp_Object ns_string_to_lispmod (const char *s) gui_clear_end_of_line, ns_scroll_run, ns_after_update_window_line, - ns_update_window_begin, - ns_update_window_end, + gui_update_window_begin, + gui_update_window_end, 0, /* flush_display */ gui_clear_window_mouse_face, gui_get_glyph_overhangs, diff --git a/src/w32term.c b/src/w32term.c index 451dd54dd8..8d5f57836c 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -565,19 +565,12 @@ w32_update_window_begin (struct window *w) 0, 6000, NULL); } - w->output_cursor = w->cursor; + gui_update_window_begin (w); block_input (); if (f == hlinfo->mouse_face_mouse_frame) { - /* Don't do highlighting for mouse motion during the update. */ - hlinfo->mouse_face_defer = true; - - /* If F needs to be redrawn, simply forget about any prior mouse - highlighting. */ - if (FRAME_GARBAGED_P (f)) - hlinfo->mouse_face_window = Qnil; #if 0 /* Rows in a current matrix containing glyphs in mouse-face have their mouse_face_p flag set, which means that they are always @@ -696,36 +689,7 @@ static void w32_update_window_end (struct window *w, bool cursor_on_p, bool mouse_face_overwritten_p) { - if (!w->pseudo_window_p) - { - block_input (); - - if (cursor_on_p) - display_and_set_cursor (w, true, - w->output_cursor.hpos, w->output_cursor.vpos, - w->output_cursor.x, w->output_cursor.y); - - if (draw_window_fringes (w, true)) - { - if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) - gui_draw_right_divider (w); - else - gui_draw_vertical_border (w); - } - - unblock_input (); - } - - /* If a row with mouse-face was overwritten, arrange for - XTframe_up_to_date to redisplay the mouse highlight. */ - if (mouse_face_overwritten_p) - { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); - - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } + gui_update_window_end (w, cursor_on_p, mouse_face_overwritten_p); /* Unhide the caret. This won't actually show the cursor, unless it was visible before the corresponding call to HideCaret in diff --git a/src/xdisp.c b/src/xdisp.c index d52d1333a0..dbf34cf3bd 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -32223,6 +32223,73 @@ gui_draw_bottom_divider (struct window *w) } } +/* EXPORT: + Start update of window W. */ + +void +gui_update_window_begin (struct window *w) +{ + struct frame *f = XFRAME (WINDOW_FRAME (w)); + Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); + + w->output_cursor = w->cursor; + + block_input (); + + if (f == hlinfo->mouse_face_mouse_frame) + { + /* Don't do highlighting for mouse motion during the update. */ + hlinfo->mouse_face_defer = true; + + /* If the frame needs to be redrawn, simply forget about any + prior mouse highlighting. */ + if (FRAME_GARBAGED_P (f)) + hlinfo->mouse_face_window = Qnil; + } + + unblock_input (); +} + +/* EXPORT: + End update of window W. + + Draw vertical borders between horizontally adjacent windows, and + display W's cursor if CURSOR_ON_P is non-zero. + + MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing + glyphs in mouse-face were overwritten. In that case we have to + make sure that the mouse-highlight is properly redrawn. */ +void +gui_update_window_end (struct window *w, bool cursor_on_p, + bool mouse_face_overwritten_p) +{ + /* Pseudo windows don't have cursors, so don't display them here. */ + if (!w->pseudo_window_p) + { + block_input (); + + if (cursor_on_p) + display_and_set_cursor (w, true, + w->output_cursor.hpos, w->output_cursor.vpos, + w->output_cursor.x, w->output_cursor.y); + + if (draw_window_fringes (w, true)) + { + if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) + gui_draw_right_divider (w); + else + gui_draw_vertical_border (w); + } + + unblock_input (); + } + + /* If a row with mouse-face was overwritten, arrange for + frame_up_to_date_hook to redisplay the mouse highlight. */ + if (mouse_face_overwritten_p) + reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame))); +} + /* Redraw the part of window W intersection rectangle FR. Pixel coordinates in FR are frame-relative. Call this function with input blocked. Value is true if the exposure overwrites diff --git a/src/xterm.c b/src/xterm.c index dd19b8bde1..b08f5f6a62 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -989,7 +989,7 @@ x_set_frame_alpha (struct frame *f) /* Start an update of frame F. This function is installed as a hook for update_begin, i.e. it is called when update_begin is called. - This function is called prior to calls to x_update_window_begin for + This function is called prior to calls to gui_update_window_begin for each window being updated. Currently, there is nothing to do here because all interesting stuff is done on a window basis. */ @@ -1033,33 +1033,6 @@ x_update_begin (struct frame *f) #endif /* USE_CAIRO */ } -/* Start update of window W. */ - -static void -x_update_window_begin (struct window *w) -{ - struct frame *f = XFRAME (WINDOW_FRAME (w)); - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); - - w->output_cursor = w->cursor; - - block_input (); - - if (f == hlinfo->mouse_face_mouse_frame) - { - /* Don't do highlighting for mouse motion during the update. */ - hlinfo->mouse_face_defer = true; - - /* If F needs to be redrawn, simply forget about any prior mouse - highlighting. */ - if (FRAME_GARBAGED_P (f)) - hlinfo->mouse_face_window = Qnil; - } - - unblock_input (); -} - - /* Draw a vertical window border from (x,y0) to (x,y1) */ static void @@ -1139,55 +1112,6 @@ x_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1) } } -/* End update of window W. - - Draw vertical borders between horizontally adjacent windows, and - display W's cursor if CURSOR_ON_P is non-zero. - - MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing - glyphs in mouse-face were overwritten. In that case we have to - make sure that the mouse-highlight is properly redrawn. - - W may be a menu bar pseudo-window in case we don't have X toolkit - support. Such windows don't have a cursor, so don't display it - here. */ - -static void -x_update_window_end (struct window *w, bool cursor_on_p, - bool mouse_face_overwritten_p) -{ - if (!w->pseudo_window_p) - { - block_input (); - - if (cursor_on_p) - display_and_set_cursor (w, true, - w->output_cursor.hpos, w->output_cursor.vpos, - w->output_cursor.x, w->output_cursor.y); - - if (draw_window_fringes (w, true)) - { - if (WINDOW_RIGHT_DIVIDER_WIDTH (w)) - gui_draw_right_divider (w); - else - gui_draw_vertical_border (w); - } - - unblock_input (); - } - - /* If a row with mouse-face was overwritten, arrange for - XTframe_up_to_date to redisplay the mouse highlight. */ - if (mouse_face_overwritten_p) - { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); - - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } -} - /* Show the frame back buffer. If frame is double-buffered, atomically publish to the user's screen graphics updates made since the last call to show_back_buffer. */ @@ -4306,7 +4230,7 @@ x_scroll_run (struct window *w, struct run *run) block_input (); - /* Cursor off. Will be switched on again in x_update_window_end. */ + /* Cursor off. Will be switched on again in gui_update_window_end. */ gui_clear_cursor (w); #ifdef USE_CAIRO @@ -13145,8 +13069,8 @@ static struct redisplay_interface x_redisplay_interface = gui_clear_end_of_line, x_scroll_run, x_after_update_window_line, - x_update_window_begin, - x_update_window_end, + gui_update_window_begin, + gui_update_window_end, x_flip_and_flush, gui_clear_window_mouse_face, gui_get_glyph_overhangs, -- 2.21.0 --=-=-=--