Jacek Caban : conhost: Delay window refresh on output update.

Alexandre Julliard julliard at winehq.org
Wed Mar 31 15:55:13 CDT 2021


Module: wine
Branch: master
Commit: 8ccf24ccb0a4362c407aea61927e604e60d41f6e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8ccf24ccb0a4362c407aea61927e604e60d41f6e

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Mar 30 21:28:01 2021 +0200

conhost: Delay window refresh on output update.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/conhost/conhost.c |  8 ++++----
 programs/conhost/conhost.h |  2 +-
 programs/conhost/window.c  | 15 +++++++++++----
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c
index fbee37d9c01..39544fb8a9d 100644
--- a/programs/conhost/conhost.c
+++ b/programs/conhost/conhost.c
@@ -1211,7 +1211,7 @@ static void update_read_output( struct console *console )
     if (console->is_unix)
         set_tty_cursor_relative( screen_buffer->console, screen_buffer->cursor_x, screen_buffer->cursor_y );
     tty_sync( screen_buffer->console );
-    update_window_config( screen_buffer->console );
+    update_window_config( screen_buffer->console, TRUE );
 }
 
 static NTSTATUS process_console_input( struct console *console )
@@ -1703,7 +1703,7 @@ static NTSTATUS screen_buffer_activate( struct screen_buffer *screen_buffer )
     SetRect( &update_rect, 0, 0, screen_buffer->width - 1, screen_buffer->height - 1 );
     update_output( screen_buffer, &update_rect );
     tty_sync( screen_buffer->console );
-    update_window_config( screen_buffer->console );
+    update_window_config( screen_buffer->console, FALSE );
     return STATUS_SUCCESS;
 }
 
@@ -1896,7 +1896,7 @@ static NTSTATUS set_output_info( struct screen_buffer *screen_buffer,
     if (is_active( screen_buffer ))
     {
         tty_sync( screen_buffer->console );
-        update_window_config( screen_buffer->console );
+        update_window_config( screen_buffer->console, FALSE );
     }
     return STATUS_SUCCESS;
 }
@@ -1955,7 +1955,7 @@ static NTSTATUS write_console( struct screen_buffer *screen_buffer, const WCHAR
     scroll_to_cursor( screen_buffer );
     update_output( screen_buffer, &update_rect );
     tty_sync( screen_buffer->console );
-    update_window_config( screen_buffer->console );
+    update_window_config( screen_buffer->console, TRUE );
     return STATUS_SUCCESS;
 }
 
diff --git a/programs/conhost/conhost.h b/programs/conhost/conhost.h
index 6f3985352e2..6446cd1d767 100644
--- a/programs/conhost/conhost.h
+++ b/programs/conhost/conhost.h
@@ -132,7 +132,7 @@ struct screen_buffer
 
 BOOL init_window( struct console *console );
 void update_window_region( struct console *console, const RECT *update );
-void update_window_config( struct console *console );
+void update_window_config( struct console *console, BOOL delay );
 
 NTSTATUS write_console_input( struct console *console, const INPUT_RECORD *records,
                               unsigned int count, BOOL flush );
diff --git a/programs/conhost/window.c b/programs/conhost/window.c
index a665cbb84d4..0ea929df943 100644
--- a/programs/conhost/window.c
+++ b/programs/conhost/window.c
@@ -2170,8 +2170,10 @@ static LRESULT WINAPI window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
         PostQuitMessage( 0 );
         break;
 
+    case WM_TIMER:
     case WM_UPDATE_CONFIG:
-        update_window( console );
+        if (console->window->update_state == UPDATE_PENDING)
+            update_window( console );
         break;
 
     case WM_PAINT:
@@ -2457,11 +2459,16 @@ static LRESULT WINAPI window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
     return 0;
 }
 
-void update_window_config( struct console *console )
+void update_window_config( struct console *console, BOOL delay )
 {
+    const int delay_timeout = 50;
+
     if (!console->win || console->window->update_state != UPDATE_NONE) return;
     console->window->update_state = UPDATE_PENDING;
-    PostMessageW( console->win, WM_UPDATE_CONFIG, 0, 0 );
+    if (delay)
+        SetTimer( console->win, 1, delay_timeout, NULL );
+    else
+        PostMessageW( console->win, WM_UPDATE_CONFIG, 0, 0 );
 }
 
 void update_window_region( struct console *console, const RECT *update )
@@ -2471,7 +2478,7 @@ void update_window_region( struct console *console, const RECT *update )
     window_rect->top    = min( window_rect->top,    update->top );
     window_rect->right  = max( window_rect->right,  update->right );
     window_rect->bottom = max( window_rect->bottom, update->bottom );
-    update_window_config( console );
+    update_window_config( console, TRUE );
 }
 
 BOOL init_window( struct console *console )




More information about the wine-cvs mailing list