server: Get and set the console color table.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2016-08-10 10:01:34 +00:00 committed by Alexandre Julliard
parent adb43b9192
commit 2d7c73d802
5 changed files with 52 additions and 8 deletions

View File

@ -1947,6 +1947,7 @@ struct set_console_output_info_request
short int max_height; short int max_height;
short int font_width; short int font_width;
short int font_height; short int font_height;
/* VARARG(colors,uints); */
char __pad_50[6]; char __pad_50[6];
}; };
struct set_console_output_info_reply struct set_console_output_info_reply
@ -1960,6 +1961,7 @@ struct set_console_output_info_reply
#define SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW 0x10 #define SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW 0x10
#define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20 #define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20
#define SET_CONSOLE_OUTPUT_INFO_FONT 0x40 #define SET_CONSOLE_OUTPUT_INFO_FONT 0x40
#define SET_CONSOLE_OUTPUT_INFO_COLORTABLE 0x80
@ -1986,6 +1988,7 @@ struct get_console_output_info_reply
short int max_height; short int max_height;
short int font_width; short int font_width;
short int font_height; short int font_height;
/* VARARG(colors,uints); */
char __pad_38[2]; char __pad_38[2];
}; };
@ -6245,6 +6248,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply; struct terminate_job_reply terminate_job_reply;
}; };
#define SERVER_PROTOCOL_VERSION 507 #define SERVER_PROTOCOL_VERSION 508
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -211,6 +211,27 @@ static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
return ret; return ret;
} }
/******************************************************************
* WINECON_SetColors
*
*
*/
static void WINECON_SetColors(struct inner_data *data, const struct config_data* cfg)
{
size_t color_map_size = sizeof(data->curcfg.color_map);
memcpy(data->curcfg.color_map, cfg->color_map, color_map_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, cfg->color_map, color_map_size );
wine_server_call( req );
}
SERVER_END_REQ;
}
/****************************************************************** /******************************************************************
* WINECON_GrabChanges * WINECON_GrabChanges
* *
@ -449,6 +470,7 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
FillConsoleOutputAttribute(data->hConOut, cfg->def_attr, screen_size, top_left, &written); FillConsoleOutputAttribute(data->hConOut, cfg->def_attr, screen_size, top_left, &written);
SetConsoleTextAttribute(data->hConOut, cfg->def_attr); SetConsoleTextAttribute(data->hConOut, cfg->def_attr);
} }
WINECON_SetColors(data, cfg);
/* now let's look at the window / sb size changes... /* now let's look at the window / sb size changes...
* since the server checks that sb is always bigger than window, * since the server checks that sb is always bigger than window,
* we have to take care of doing the operations in the right order * we have to take care of doing the operations in the right order
@ -703,7 +725,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
/* fall through */ /* fall through */
case init_success: case init_success:
WINECON_GetServerConfig(data); WINECON_GetServerConfig(data);
memcpy(data->curcfg.color_map, cfg.color_map, sizeof(data->curcfg.color_map));
data->cells = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data->cells = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO)); data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO));
if (!data->cells) WINECON_Fatal("OOM\n"); if (!data->cells) WINECON_Fatal("OOM\n");

View File

@ -147,6 +147,7 @@ struct screen_buffer
int max_height; int max_height;
char_info_t *data; /* the data for each cell - a width x height matrix */ char_info_t *data; /* the data for each cell - a width x height matrix */
unsigned short attr; /* default attribute for screen buffer */ unsigned short attr; /* default attribute for screen buffer */
unsigned int color_map[16]; /* color table */
rectangle_t win; /* current visible window on the screen buffer * rectangle_t win; /* current visible window on the screen buffer *
* as seen in wineconsole */ * as seen in wineconsole */
struct font_info font; /* console font information */ 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->data = NULL;
screen_buffer->font.width = 0; screen_buffer->font.width = 0;
screen_buffer->font.height = 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 ); list_add_head( &screen_buffer_list, &screen_buffer->entry );
if (fd == -1) if (fd == -1)
@ -1032,6 +1034,11 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
screen_buffer->font.width = req->font_width; screen_buffer->font.width = req->font_width;
screen_buffer->font.height = req->font_height; 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() ));
}
return 1; return 1;
} }
@ -1690,6 +1697,8 @@ DECL_HANDLER(get_console_output_info)
reply->max_height = screen_buffer->max_height; reply->max_height = screen_buffer->max_height;
reply->font_width = screen_buffer->font.width; reply->font_width = screen_buffer->font.width;
reply->font_height = screen_buffer->font.height; reply->font_height = screen_buffer->font.height;
set_reply_data( screen_buffer->color_map,
min( sizeof(screen_buffer->color_map), get_reply_max_size() ));
release_object( screen_buffer ); release_object( screen_buffer );
} }
} }

View File

@ -1537,6 +1537,7 @@ struct console_renderer_event
short int max_height; 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; short int font_height;
VARARG(colors,uints); /* color table */
@END @END
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM 0x01 #define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM 0x01
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_POS 0x02 #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_DISPLAY_WINDOW 0x10
#define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20 #define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20
#define SET_CONSOLE_OUTPUT_INFO_FONT 0x40 #define SET_CONSOLE_OUTPUT_INFO_FONT 0x40
#define SET_CONSOLE_OUTPUT_INFO_COLORTABLE 0x80
/* Get info about a console (output only) */ /* Get info about a console (output only) */
@ -1566,6 +1568,7 @@ struct console_renderer_event
short int max_height; 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; short int font_height;
VARARG(colors,uints); /* color table */
@END @END
/* Add input records to a console input queue */ /* Add input records to a console input queue */

View File

@ -58,9 +58,9 @@ static inline void remove_data( data_size_t size )
cur_size -= size; cur_size -= size;
} }
static void dump_uints( const int *ptr, int len ) static void dump_uints( const char *prefix, const unsigned int *ptr, int len )
{ {
fputc( '{', stderr ); fprintf( stderr, "%s{", prefix );
while (len > 0) while (len > 0)
{ {
fprintf( stderr, "%08x", *ptr++ ); fprintf( stderr, "%08x", *ptr++ );
@ -407,6 +407,14 @@ static void dump_varargs_ints( const char *prefix, data_size_t size )
remove_data( size ); remove_data( size );
} }
static void dump_varargs_uints( const char *prefix, data_size_t size )
{
const unsigned int *data = cur_data;
dump_uints( prefix, data, size / sizeof(*data) );
remove_data( size );
}
static void dump_varargs_uints64( const char *prefix, data_size_t size ) static void dump_varargs_uints64( const char *prefix, data_size_t size )
{ {
const unsigned __int64 *data = cur_data; const unsigned __int64 *data = cur_data;
@ -574,10 +582,8 @@ static void dump_varargs_context( const char *prefix, data_size_t size )
} }
} }
if (ctx.flags & SERVER_CTX_EXTENDED_REGISTERS) if (ctx.flags & SERVER_CTX_EXTENDED_REGISTERS)
{ dump_uints( ",extended=", (const unsigned int *)ctx.ext.i386_regs,
fprintf( stderr, ",extended=" ); sizeof(ctx.ext.i386_regs) / sizeof(int) );
dump_uints( (const int *)ctx.ext.i386_regs, sizeof(ctx.ext.i386_regs) / sizeof(int) );
}
break; break;
case CPU_x86_64: case CPU_x86_64:
if (ctx.flags & SERVER_CTX_CONTROL) if (ctx.flags & SERVER_CTX_CONTROL)
@ -2035,6 +2041,7 @@ static void dump_set_console_output_info_request( const struct set_console_outpu
fprintf( stderr, ", max_height=%d", req->max_height ); fprintf( stderr, ", max_height=%d", req->max_height );
fprintf( stderr, ", font_width=%d", req->font_width ); fprintf( stderr, ", font_width=%d", req->font_width );
fprintf( stderr, ", font_height=%d", req->font_height ); fprintf( stderr, ", font_height=%d", req->font_height );
dump_varargs_uints( ", colors=", cur_size );
} }
static void dump_get_console_output_info_request( const struct get_console_output_info_request *req ) static void dump_get_console_output_info_request( const struct get_console_output_info_request *req )
@ -2059,6 +2066,7 @@ static void dump_get_console_output_info_reply( const struct get_console_output_
fprintf( stderr, ", max_height=%d", req->max_height ); fprintf( stderr, ", max_height=%d", req->max_height );
fprintf( stderr, ", font_width=%d", req->font_width ); fprintf( stderr, ", font_width=%d", req->font_width );
fprintf( stderr, ", font_height=%d", req->font_height ); fprintf( stderr, ", font_height=%d", req->font_height );
dump_varargs_uints( ", colors=", cur_size );
} }
static void dump_write_console_input_request( const struct write_console_input_request *req ) static void dump_write_console_input_request( const struct write_console_input_request *req )