[PATCH v2 1/4] server: Add support for additional fields in set_console_output_info.

Gijs Vermeulen gijsvrm at codeweavers.com
Tue Nov 19 13:54:12 CST 2019


Signed-off-by: Gijs Vermeulen <gijsvrm at codeweavers.com>
---
 programs/wineconsole/wineconsole.c |  3 +++
 server/console.c                   | 34 +++++++++++++++++++++++++-----
 server/protocol.def                | 33 ++++++++++++++++-------------
 3 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index 439099c37a..ebcfce1011 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -458,6 +458,9 @@ void     WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
             req->max_height = (r.bottom - r.top - GetSystemMetrics(SM_CYCAPTION)) / cfg->cell_height;
             req->font_width = cfg->cell_width;
             req->font_height = cfg->cell_height;
+            req->font_weight = cfg->font_weight;
+            req->font_pitch_family = FIXED_PITCH | FF_DONTCARE;
+            wine_server_add_data( req, cfg->face_name, lstrlenW(cfg->face_name) * sizeof(WCHAR) );
             wine_server_call( req );
         }
         SERVER_END_REQ;
diff --git a/server/console.c b/server/console.c
index 7d1fc5d268..a5f4063b72 100644
--- a/server/console.c
+++ b/server/console.c
@@ -131,6 +131,9 @@ struct font_info
 {
     short int width;
     short int height;
+    short int weight;
+    short int pitch_family;
+    struct unicode_str face_name;
 };
 
 struct screen_buffer
@@ -433,6 +436,10 @@ static struct screen_buffer *create_console_output( struct console_input *consol
     screen_buffer->data           = NULL;
     screen_buffer->font.width     = 0;
     screen_buffer->font.height    = 0;
+    screen_buffer->font.weight    = 400;
+    screen_buffer->font.pitch_family  = 1;
+    screen_buffer->font.face_name.str = NULL;
+    screen_buffer->font.face_name.len = 0;
     memset( screen_buffer->color_map, 0, sizeof(screen_buffer->color_map) );
     list_add_head( &screen_buffer_list, &screen_buffer->entry );
 
@@ -896,6 +903,8 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
                                     const struct set_console_output_info_request *req )
 {
     struct console_renderer_event evt;
+    data_size_t font_name_len, offset;
+    WCHAR *font_name;
 
     memset(&evt.u, 0, sizeof(evt.u));
     if (req->mask & SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM)
@@ -1039,15 +1048,29 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
 	screen_buffer->max_width  = req->max_width;
 	screen_buffer->max_height = req->max_height;
     }
+    if (req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE)
+    {
+        memcpy( screen_buffer->color_map, get_req_data(), min( get_req_data_size(), sizeof(screen_buffer->color_map) ));
+    }
     if (req->mask & SET_CONSOLE_OUTPUT_INFO_FONT)
     {
         screen_buffer->font.width  = req->font_width;
         screen_buffer->font.height = req->font_height;
-    }
-    if (req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE)
-    {
-        memcpy( screen_buffer->color_map, get_req_data(),
-                min( sizeof(screen_buffer->color_map), get_req_data_size() ));
+        screen_buffer->font.weight = req->font_weight;
+        screen_buffer->font.pitch_family = req->font_pitch_family;
+        offset = req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE ? sizeof(screen_buffer->color_map) : 0;
+        if (get_req_data_size() > offset)
+        {
+            font_name_len = (get_req_data_size() - offset) / sizeof(WCHAR) * sizeof(WCHAR);
+            font_name = mem_alloc( font_name_len );
+            if (font_name)
+            {
+                memcpy( font_name, (char*)get_req_data() + offset, font_name_len );
+                free( (WCHAR *)screen_buffer->font.face_name.str );
+                screen_buffer->font.face_name.str = font_name;
+                screen_buffer->font.face_name.len = font_name_len;
+            }
+        }
     }
 
     return 1;
@@ -1183,6 +1206,7 @@ static void screen_buffer_destroy( struct object *obj )
     }
     if (screen_buffer->fd) release_object( screen_buffer->fd );
     free( screen_buffer->data );
+    free( (WCHAR *)screen_buffer->font.face_name.str );
 }
 
 static struct fd *screen_buffer_get_fd( struct object *obj )
diff --git a/server/protocol.def b/server/protocol.def
index 3a0df20bdb..4dc9a278ad 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1615,25 +1615,28 @@ struct console_renderer_event
 
 /* Set info about a console (output only) */
 @REQ(set_console_output_info)
-    obj_handle_t handle;        /* handle to the console */
-    int          mask;          /* setting mask (see below) */
-    short int    cursor_size;   /* size of cursor (percentage filled) */
-    short int    cursor_visible;/* cursor visibility flag */
-    short int    cursor_x;      /* position of cursor (x, y) */
+    obj_handle_t handle;            /* handle to the console */
+    int          mask;              /* setting mask (see below) */
+    short int    cursor_size;       /* size of cursor (percentage filled) */
+    short int    cursor_visible;    /* cursor visibility flag */
+    short int    cursor_x;          /* position of cursor (x, y) */
     short int    cursor_y;
-    short int    width;         /* width of the screen buffer */
-    short int    height;        /* height of the screen buffer */
-    short int    attr;          /* default fill attributes (screen colors) */
-    short int    popup_attr;    /* pop-up color attributes */
-    short int    win_left;      /* window actually displayed by renderer */
-    short int    win_top;       /* the rect area is expressed within the */
-    short int    win_right;     /* boundaries of the screen buffer */
+    short int    width;             /* width of the screen buffer */
+    short int    height;            /* height of the screen buffer */
+    short int    attr;              /* default fill attributes (screen colors) */
+    short int    popup_attr;        /* pop-up color attributes */
+    short int    win_left;          /* window actually displayed by renderer */
+    short int    win_top;           /* the rect area is expressed within the */
+    short int    win_right;         /* boundaries of the screen buffer */
     short int    win_bottom;
-    short int    max_width;     /* maximum size (width x height) for the window */
+    short int    max_width;         /* maximum size (width x height) for the window */
     short int    max_height;
-    short int    font_width;    /* font size (width x height) */
+    short int    font_width;        /* font size (width x height) */
     short int    font_height;
-    VARARG(colors,uints);       /* color table */
+    short int    font_weight;       /* font weight */
+    short int    font_pitch_family; /* font pitch & family */
+    VARARG(colors,uints);           /* color table */
+    VARARG(face_name,unicode_str);  /* font face name */
 @END
 #define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM     0x0001
 #define SET_CONSOLE_OUTPUT_INFO_CURSOR_POS      0x0002
-- 
2.24.0




More information about the wine-devel mailing list