Jacek Caban : conhost: Support painting screen buffer.

Alexandre Julliard julliard at winehq.org
Thu Oct 8 15:20:06 CDT 2020


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Oct  8 17:30:57 2020 +0200

conhost: Support painting screen buffer.

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

---

 programs/conhost/conhost.c | 12 ++++++++++--
 programs/conhost/conhost.h |  1 +
 programs/conhost/window.c  | 26 ++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c
index ac7508ed8e..68e27f74b8 100644
--- a/programs/conhost/conhost.c
+++ b/programs/conhost/conhost.c
@@ -318,10 +318,18 @@ static void update_output( struct screen_buffer *screen_buffer, RECT *rect )
     char_info_t *ch;
     char buf[8];
 
-    if (!is_active( screen_buffer ) || !screen_buffer->console->tty_output) return;
-    if (rect->top > rect->bottom || rect->right < rect->left) return;
+    if (!is_active( screen_buffer ) || rect->top > rect->bottom || rect->right < rect->left)
+        return;
+
     TRACE( "%s\n", wine_dbgstr_rect( rect ));
 
+    if (screen_buffer->console->win)
+    {
+        update_window_region( screen_buffer->console, rect );
+        return;
+    }
+    if (!screen_buffer->console->tty_output) return;
+
     hide_tty_cursor( screen_buffer->console );
 
     for (y = rect->top; y <= rect->bottom; y++)
diff --git a/programs/conhost/conhost.h b/programs/conhost/conhost.h
index 690472dcc7..c47253a755 100644
--- a/programs/conhost/conhost.h
+++ b/programs/conhost/conhost.h
@@ -131,6 +131,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 );
 
 NTSTATUS change_screen_buffer_size( struct screen_buffer *screen_buffer, int new_width, int new_height );
diff --git a/programs/conhost/window.c b/programs/conhost/window.c
index 7d9b416e25..2e94eb5969 100644
--- a/programs/conhost/window.c
+++ b/programs/conhost/window.c
@@ -933,6 +933,22 @@ static LRESULT WINAPI window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
         update_window( console );
         break;
 
+    case WM_PAINT:
+        {
+            PAINTSTRUCT ps;
+
+            BeginPaint( console->win, &ps );
+            BitBlt( ps.hdc, 0, 0,
+                    (console->active->win.right - console->active->win.left + 1) * console->active->font.width,
+                    (console->active->win.bottom - console->active->win.top + 1) * console->active->font.height,
+                    console->window->mem_dc,
+                    console->active->win.left * console->active->font.width,
+                    console->active->win.top  * console->active->font.height,
+                    SRCCOPY );
+            EndPaint( console->win, &ps );
+            break;
+        }
+
     default:
         return DefWindowProcW( hwnd, msg, wparam, lparam );
     }
@@ -947,6 +963,16 @@ void update_window_config( struct console *console )
     PostMessageW( console->win, WM_UPDATE_CONFIG, 0, 0 );
 }
 
+void update_window_region( struct console *console, const RECT *update )
+{
+    RECT *window_rect = &console->window->update;
+    window_rect->left   = min( window_rect->left,   update->left );
+    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 );
+}
+
 BOOL init_window( struct console *console )
 {
     struct console_config config;




More information about the wine-cvs mailing list