From 88a189f96403db4687d7ff191cbeccc86cc294ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Pi=C5=A1l?= Date: Mon, 1 Feb 2021 18:29:16 +0100 Subject: [PATCH] conhost: Improve notification when resizing window. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roman Pišl Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard (cherry picked from commit 2ca86d3b597c6a16988468ee83ff9f2abf0c2571) Signed-off-by: Michael Stefaniuc --- programs/conhost/conhost.c | 21 +++++++++++++-------- programs/conhost/conhost.h | 2 ++ programs/conhost/window.c | 2 ++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 0ac1c5f507b..dd22636be6a 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -1735,6 +1735,18 @@ static NTSTATUS get_output_info( struct screen_buffer *screen_buffer, size_t *ou return STATUS_SUCCESS; } +void notify_screen_buffer_size( struct screen_buffer *screen_buffer ) +{ + if (is_active( screen_buffer ) && screen_buffer->console->mode & ENABLE_WINDOW_INPUT) + { + INPUT_RECORD ir; + ir.EventType = WINDOW_BUFFER_SIZE_EVENT; + ir.Event.WindowBufferSizeEvent.dwSize.X = screen_buffer->width; + ir.Event.WindowBufferSizeEvent.dwSize.Y = screen_buffer->height; + write_console_input( screen_buffer->console, &ir, 1, TRUE ); + } +} + NTSTATUS change_screen_buffer_size( struct screen_buffer *screen_buffer, int new_width, int new_height ) { int i, old_width, old_height, copy_width, copy_height; @@ -1839,14 +1851,7 @@ static NTSTATUS set_output_info( struct screen_buffer *screen_buffer, if (screen_buffer->cursor_x >= info->width) screen_buffer->cursor_x = info->width - 1; if (screen_buffer->cursor_y >= info->height) screen_buffer->cursor_y = info->height - 1; - if (is_active( screen_buffer ) && screen_buffer->console->mode & ENABLE_WINDOW_INPUT) - { - INPUT_RECORD ir; - ir.EventType = WINDOW_BUFFER_SIZE_EVENT; - ir.Event.WindowBufferSizeEvent.dwSize.X = info->width; - ir.Event.WindowBufferSizeEvent.dwSize.Y = info->height; - write_console_input( screen_buffer->console, &ir, 1, TRUE ); - } + notify_screen_buffer_size( screen_buffer ); } if (params->mask & SET_CONSOLE_OUTPUT_INFO_ATTR) { diff --git a/programs/conhost/conhost.h b/programs/conhost/conhost.h index 3094fd6e5f0..6f3985352e2 100644 --- a/programs/conhost/conhost.h +++ b/programs/conhost/conhost.h @@ -136,6 +136,8 @@ void update_window_config( struct console *console ); NTSTATUS write_console_input( struct console *console, const INPUT_RECORD *records, unsigned int count, BOOL flush ); + +void notify_screen_buffer_size( struct screen_buffer *screen_buffer ); NTSTATUS change_screen_buffer_size( struct screen_buffer *screen_buffer, int new_width, int new_height ); static inline void empty_update_rect( struct screen_buffer *screen_buffer, RECT *rect ) diff --git a/programs/conhost/window.c b/programs/conhost/window.c index 5e94a1d454e..01917ee8b67 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -1901,6 +1901,8 @@ static void apply_config( struct console *console, const struct console_config * } update_window( console ); + + notify_screen_buffer_size( console->active ); } static void current_config( struct console *console, struct console_config *config )