Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid heavy redrawing cursor #1873

Closed
wants to merge 1 commit into from
Closed

Conversation

mattn
Copy link
Member

@mattn mattn commented Jul 24, 2017

No description provided.

@codecov-io
Copy link

codecov-io commented Jul 25, 2017

Codecov Report

Merging #1873 into master will increase coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1873      +/-   ##
==========================================
+ Coverage   75.04%   75.09%   +0.05%     
==========================================
  Files          76       76              
  Lines      125234   125273      +39     
==========================================
+ Hits        93984    94079      +95     
+ Misses      31250    31194      -56
Impacted Files Coverage Δ
src/os_unix.c 57.15% <0%> (-0.34%) ⬇️
src/getchar.c 73.36% <0%> (-0.05%) ⬇️
src/channel.c 83.55% <0%> (-0.05%) ⬇️
src/gui.c 45.58% <0%> (+0.05%) ⬆️
src/gui_gtk_x11.c 47.5% <0%> (+0.15%) ⬆️
src/libvterm/src/screen.c 74.62% <0%> (+0.15%) ⬆️
src/if_xcmdsrv.c 83.51% <0%> (+0.18%) ⬆️
src/ex_cmds.c 77.94% <0%> (+0.22%) ⬆️
src/term.c 52.99% <0%> (+0.23%) ⬆️
src/message.c 68.35% <0%> (+0.25%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c84493...2283a8c. Read the comment docs.

@mattn
Copy link
Member Author

mattn commented Jul 25, 2017

@brammool I found another solution. Which do you like?

diff --git a/src/terminal.c b/src/terminal.c
index 5be51de9f..4ceb57cd9 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -636,7 +636,7 @@ handle_movecursor(
 	}
     }
 
-    if (is_current)
+    if (is_current && visible)
 	update_cursor();
 
     return 1;

@nuko8
Copy link

nuko8 commented Jul 25, 2017

I found an issue with this PR's (original) patch.

For instance, when I do cat userfunc.c on the built-in terminal of a patched Athena, Motif, or GTK+ 2 GUIs, I often see the cursor placed in a wrong position when scrolling is done.

As for the diff that has just posted, I haven't seen the same issue so far.

But, @mattn , I have one thing to make sure about the diff before giving my conclusion: Which HEAD should I apply it to? As no instructions are given, I applied it to the current master (8.0.0701) and tested it. But the line number 636 shown in the diff doesn't look like that the diff was made against the current HEAD, which makes me wonder.

Or, does "another solution" mean that we should apply the diff on top of this PR's own patch?

@mattn
Copy link
Member Author

mattn commented Jul 25, 2017

Did you try my first patch? or second one? The first patch is based on previous revision. Second one is based on master/HEAD.

Additional:
But maybe both fixes issue as same as.

@nuko8
Copy link

nuko8 commented Jul 25, 2017

Did you try my first patch? or second one?

I did try the first patch and found the issue as I wrote.

The first patch is based on previous revision.

Can I have its hash? I have no idea on what you are referring to "previous revision."

Second one is based on master/HEAD.

That's the point of my question. Actually, when I applied the posted patch to my clone repo points to master/HEAD, I got

patching file terminal.c
Hunk #1 succeeded at 625 (offset -11 lines).

It looks to me that the offset indicates that the diff was not made against master/HEAD.

@mattn
Copy link
Member Author

mattn commented Jul 25, 2017

Sorry. I make you confusing. Okay, I'll rebase from master.

@nuko8
Copy link

nuko8 commented Jul 25, 2017

OK, 'cause I have to be AFK for hours, let me leave my conclusion now:

  1. While Patch 8.0.0771 has improved the cursor drawing of the GTK+ 2 GUI much and made its built-in terminal as usable as that of the GTK+ 3 GUI, it has made scrolling of the latter GUI noticeably clumsy.
  2. If we merge @mattn 's second patch into the current master/HEAD (1c84493) with leaving his first patch out, then it not only makes scrolling of the former GUI much smoother but also makes that of the latter GUI as smooth as pre-8.0771 versions.
  3. Even with the second patch included, the Athena and Motif GUIs still needs further improvement on their cursor drawing and movement.

Therefore, though I'm still unsure whether or not the second patch was made against master/HEAD and whether or not the executables resulting from the codebase of his repo which was used to make it are the same as those I have and were tested properly, I vote against the first patch and for the second patch, based on my own test result.

@mattn
Copy link
Member Author

mattn commented Jul 25, 2017

@nuko8 Thanks for your review. As you mentioned about patch 8.0.0771, the cursor had appear in right location immediately. However, when lines are scrolled-up, cursor flicker many times. This patch is the avoid redrawing. To update cursor smooth, it should not call gui_update_cursor in many part. And it call gui_update_cursor at handle_movecursor while visible is true.

@nuko8
Copy link

nuko8 commented Jul 25, 2017

@mattn

Thank you for the clarification. Now I see the issue better and confirm that your second patch works just like you described. I highly appreciate your work on it as well as your recent intensive work on other part of the built-in terminal, helping Bram. Keep up the good work!

@brammool brammool closed this in fc716d7 Jul 25, 2017
@brammool
Copy link
Contributor

brammool commented Jul 25, 2017 via email

@brammool
Copy link
Contributor

brammool commented Jul 25, 2017 via email

dpelle pushed a commit to dpelle/vim that referenced this pull request Jul 31, 2017
Problem:    In a terminal the cursor is updated too often.
Solution:   Only flush when needed. (Yasuhiro Matsumoto).  Remeber whether the
            cursor is visible. (closes vim#1873)
@mattn mattn deleted the heavy-cursor-redraw branch August 11, 2017 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants