Jacek Caban : conhost: Support window resizing.

Alexandre Julliard julliard at winehq.org
Mon Oct 12 15:20:51 CDT 2020


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Oct 12 18:26:23 2020 +0200

conhost: Support window resizing.

Based on wineconsole.

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

---

 programs/conhost/window.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/programs/conhost/window.c b/programs/conhost/window.c
index 8ab639f329..4b3751e7b5 100644
--- a/programs/conhost/window.c
+++ b/programs/conhost/window.c
@@ -2062,6 +2062,29 @@ static BOOL config_dialog( struct console *console, BOOL current )
     return TRUE;
 }
 
+static void resize_window( struct console *console, int width, int height )
+{
+    struct console_config config;
+
+    current_config( console, &config );
+    config.win_width  = width;
+    config.win_height = height;
+
+    /* auto size screen-buffer if it's now smaller than window */
+    if (config.sb_width < config.win_width)
+        config.sb_width = config.win_width;
+    if (config.sb_height < config.win_height)
+        config.sb_height = config.win_height;
+
+    /* and reset window pos so that we don't display outside of the screen-buffer */
+    if (config.win_pos.X + config.win_width > config.sb_width)
+        config.win_pos.X = config.sb_width - config.win_width;
+    if (config.win_pos.Y + config.win_height > config.sb_height)
+        config.win_pos.Y = config.sb_height - config.win_height;
+
+    apply_config( console, &config );
+}
+
 /* grays / ungrays the menu items according to their state */
 static void set_menu_details( struct console *console, HMENU menu )
 {
@@ -2280,6 +2303,13 @@ static LRESULT WINAPI window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
             DestroyCaret();
         break;
 
+    case WM_SIZE:
+        if (console->window->update_state != UPDATE_BUSY)
+            resize_window( console,
+                           max( LOWORD(lparam) / console->active->font.width, 20 ),
+                           max( HIWORD(lparam) / console->active->font.height, 20 ));
+        break;
+
     case WM_SYSCOMMAND:
         switch (wparam)
         {




More information about the wine-cvs mailing list