[PATCH 3/5] server: Get and set the console ColorTable (v2)
Hugh McMaster
hugh.mcmaster at outlook.com
Tue Aug 9 06:01:01 CDT 2016
All other patches are the same.
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/wineconsole/wineconsole.c | 23 ++++++++++++++++++++++-
server/console.c | 12 ++++++++++++
server/protocol.def | 3 +++
server/trace.c | 13 +++++++++++++--
4 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index e5e2823..c7a5018 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -212,6 +212,27 @@ static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
}
/******************************************************************
+ * WINECON_SetColorTable
+ *
+ *
+ */
+static void WINECON_SetColorTable(struct inner_data *data, const DWORD *color_map)
+{
+ size_t data_size = sizeof(data->curcfg.color_map);
+
+ memcpy(data->curcfg.color_map, color_map, data_size);
+
+ SERVER_START_REQ( set_console_output_info )
+ {
+ req->handle = wine_server_obj_handle( data->hConOut );
+ req->mask = SET_CONSOLE_OUTPUT_INFO_COLORTABLE;
+ wine_server_add_data( req, color_map, data_size );
+ wine_server_call( req );
+ }
+ SERVER_END_REQ;
+}
+
+/******************************************************************
* WINECON_GrabChanges
*
* A change occurs, try to figure out which
@@ -703,7 +724,7 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
/* fall through */
case init_success:
WINECON_GetServerConfig(data);
- memcpy(data->curcfg.color_map, cfg.color_map, sizeof(data->curcfg.color_map));
+ WINECON_SetColorTable(data, cfg.color_map);
data->cells = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO));
if (!data->cells) WINECON_Fatal("OOM\n");
diff --git a/server/console.c b/server/console.c
index 93f785a..af3138b 100644
--- a/server/console.c
+++ b/server/console.c
@@ -147,6 +147,7 @@ struct screen_buffer
int max_height;
char_info_t *data; /* the data for each cell - a width x height matrix */
unsigned short attr; /* default attribute for screen buffer */
+ unsigned int color_map[16]; /* console ColorTable */
rectangle_t win; /* current visible window on the screen buffer *
* as seen in wineconsole */
struct font_info font; /* console font information */
@@ -426,6 +427,7 @@ 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;
+ memset(screen_buffer->color_map, 0, sizeof(screen_buffer->color_map));
list_add_head( &screen_buffer_list, &screen_buffer->entry );
if (fd == -1)
@@ -1032,6 +1034,12 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
screen_buffer->font.width = req->font_width;
screen_buffer->font.height = req->font_height;
}
+ if (req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE)
+ {
+ data_size_t size = min(sizeof(screen_buffer->color_map), get_req_data_size());
+
+ memcpy(screen_buffer->color_map, get_req_data(), size);
+ }
return 1;
}
@@ -1675,6 +1683,8 @@ DECL_HANDLER(get_console_output_info)
if ((screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, req->handle,
FILE_READ_PROPERTIES, &screen_buffer_ops)))
{
+ data_size_t ct_size;
+
reply->cursor_size = screen_buffer->cursor_size;
reply->cursor_visible = screen_buffer->cursor_visible;
reply->cursor_x = screen_buffer->cursor_x;
@@ -1690,6 +1700,8 @@ DECL_HANDLER(get_console_output_info)
reply->max_height = screen_buffer->max_height;
reply->font_width = screen_buffer->font.width;
reply->font_height = screen_buffer->font.height;
+ ct_size = min( sizeof(screen_buffer->color_map), get_reply_max_size() );
+ set_reply_data( screen_buffer->color_map, ct_size );
release_object( screen_buffer );
}
}
diff --git a/server/protocol.def b/server/protocol.def
index 5917212..523e55e 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1537,6 +1537,7 @@ struct console_renderer_event
short int max_height;
short int font_width; /* font size (width x height) */
short int font_height;
+ VARARG(color,unsigned_int); /* ColorTable */
@END
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM 0x01
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_POS 0x02
@@ -1545,6 +1546,7 @@ struct console_renderer_event
#define SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW 0x10
#define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20
#define SET_CONSOLE_OUTPUT_INFO_FONT 0x40
+#define SET_CONSOLE_OUTPUT_INFO_COLORTABLE 0x80
/* Get info about a console (output only) */
@@ -1566,6 +1568,7 @@ struct console_renderer_event
short int max_height;
short int font_width; /* font size (width x height) */
short int font_height;
+ VARARG(color,unsigned_int); /* ColorTable */
@END
/* Add input records to a console input queue */
diff --git a/server/trace.c b/server/trace.c
index 9e64b4c..223f00e 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -58,7 +58,7 @@ static inline void remove_data( data_size_t size )
cur_size -= size;
}
-static void dump_uints( const int *ptr, int len )
+static void dump_uints( const unsigned int *ptr, int len )
{
fputc( '{', stderr );
while (len > 0)
@@ -576,7 +576,7 @@ static void dump_varargs_context( const char *prefix, data_size_t size )
if (ctx.flags & SERVER_CTX_EXTENDED_REGISTERS)
{
fprintf( stderr, ",extended=" );
- dump_uints( (const int *)ctx.ext.i386_regs, sizeof(ctx.ext.i386_regs) / sizeof(int) );
+ dump_uints( (const unsigned int *)ctx.ext.i386_regs, sizeof(ctx.ext.i386_regs) / sizeof(int) );
}
break;
case CPU_x86_64:
@@ -817,6 +817,15 @@ static void dump_varargs_startup_info( const char *prefix, data_size_t size )
remove_data( size );
}
+static void dump_varargs_unsigned_int( const char *prefix, data_size_t size )
+{
+ const unsigned int *data = cur_data;
+
+ fprintf( stderr,"%s", prefix );
+ dump_uints( data, size / sizeof(*data) );
+ remove_data( size );
+}
+
static void dump_varargs_input_records( const char *prefix, data_size_t size )
{
const INPUT_RECORD *rec = cur_data;
--
2.7.4
More information about the wine-patches
mailing list