"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "programs/wineconsole/wineconsole.c" between
wine-5.12.tar.xz and wine-5.13.tar.xz

About: Wine is an Open Source implementation of the MS Windows API on top of X, OpenGL, and Unix. Think of Wine as a compatibility layer for running Windows programs. Development release.

wineconsole.c  (wine-5.12.tar.xz):wineconsole.c  (wine-5.13.tar.xz)
skipping to change at line 176 skipping to change at line 176
SetConsoleMode(hConIn, mode); SetConsoleMode(hConIn, mode);
} }
/****************************************************************** /******************************************************************
* WINECON_GetConsoleTitle * WINECON_GetConsoleTitle
* *
* *
*/ */
BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len) BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len)
{ {
BOOL ret; DWORD size;
if (len < sizeof(WCHAR)) return FALSE; if (!DeviceIoControl(hConIn, IOCTL_CONDRV_GET_TITLE, NULL, 0, buffer, len -
sizeof(WCHAR), &size, NULL))
return FALSE;
SERVER_START_REQ( get_console_input_info ) buffer[size / sizeof(WCHAR)] = 0;
{ return TRUE;
req->handle = wine_server_obj_handle( hConIn );
wine_server_set_reply( req, buffer, len - sizeof(WCHAR) );
if ((ret = !wine_server_call_err( req )))
{
len = wine_server_reply_size( reply );
buffer[len / sizeof(WCHAR)] = 0;
}
}
SERVER_END_REQ;
return ret;
} }
/****************************************************************** /******************************************************************
* WINECON_SetEditionMode * WINECON_SetEditionMode
* *
* *
*/ */
static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode) static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
{ {
BOOL ret; BOOL ret;
skipping to change at line 221 skipping to change at line 212
return ret; return ret;
} }
/****************************************************************** /******************************************************************
* WINECON_SetColors * WINECON_SetColors
* *
* Sets ColorTable and Pop-up menu colors * Sets ColorTable and Pop-up menu colors
*/ */
static void WINECON_SetColors(struct inner_data *data, const struct config_data* cfg) static void WINECON_SetColors(struct inner_data *data, const struct config_data* cfg)
{ {
size_t color_map_size = sizeof(data->curcfg.color_map); struct condrv_output_info_params params =
{ SET_CONSOLE_OUTPUT_INFO_COLORTABLE | SET_CONSOLE_OUTPUT_INFO_POPUP_ATT
R };
memcpy(data->curcfg.color_map, cfg->color_map, color_map_size); memcpy(data->curcfg.color_map, cfg->color_map, sizeof(data->curcfg.color_map ));
data->curcfg.popup_attr = cfg->popup_attr; data->curcfg.popup_attr = cfg->popup_attr;
SERVER_START_REQ( set_console_output_info ) params.info.popup_attr = cfg->popup_attr;
{ memcpy(params.info.color_map, cfg->color_map, sizeof(cfg->color_map));
req->handle = wine_server_obj_handle( data->hConOut ); DeviceIoControl(data->hConOut, IOCTL_CONDRV_SET_OUTPUT_INFO, &params, sizeof
req->mask = SET_CONSOLE_OUTPUT_INFO_COLORTABLE | SET_CONSOLE_OUTPUT_INFO (params), NULL, 0, NULL, NULL);
_POPUP_ATTR;
req->popup_attr = cfg->popup_attr;
wine_server_add_data( req, cfg->color_map, color_map_size );
wine_server_call( req );
}
SERVER_END_REQ;
} }
/****************************************************************** /******************************************************************
* WINECON_GrabChanges * WINECON_GrabChanges
* *
* A change occurs, try to figure out which * A change occurs, try to figure out which
*/ */
void WINECON_GrabChanges(struct inner_data* data) void WINECON_GrabChanges(struct inner_data* data)
{ {
struct console_renderer_event evts[256]; struct condrv_renderer_event *evts = data->events;
int i, num, ev_found; int i, ev_found;
DWORD num;
HANDLE h; HANDLE h;
if (data->in_grab_changes) return; if (data->in_grab_changes) return;
SERVER_START_REQ( get_console_renderer_events ) if (!GetOverlappedResult(data->hSynchro, &data->overlapped, &num, FALSE))
{ {
wine_server_set_reply( req, evts, sizeof(evts) ); ERR( "failed to get renderer events: %u\n", GetLastError() );
req->handle = wine_server_obj_handle( data->hSynchro ); data->dying = TRUE;
if (!wine_server_call_err( req )) num = wine_server_reply_size(reply) / return;
sizeof(evts[0]);
else num = 0;
} }
SERVER_END_REQ; num /= sizeof(data->events[0]);
if (!num) {WINE_WARN("hmm renderer signaled but no events available\n"); ret
urn;}
WINE_TRACE( "got %u events\n", num ); WINE_TRACE( "got %u events\n", num );
/* FIXME: should do some event compression here (cursor pos, update) */ /* FIXME: should do some event compression here (cursor pos, update) */
/* step 1: keep only last cursor pos event */ /* step 1: keep only last cursor pos event */
ev_found = -1; ev_found = -1;
for (i = num - 1; i >= 0; i--) for (i = num - 1; i >= 0; i--)
{ {
if (evts[i].event == CONSOLE_RENDERER_CURSOR_POS_EVENT) if (evts[i].event == CONSOLE_RENDERER_CURSOR_POS_EVENT)
{ {
if (ev_found != -1) if (ev_found != -1)
skipping to change at line 402 skipping to change at line 387
break; break;
case CONSOLE_RENDERER_EXIT_EVENT: case CONSOLE_RENDERER_EXIT_EVENT:
data->dying = TRUE; data->dying = TRUE;
WINE_TRACE("%u/%u: Exit!!\n", i+1, num); WINE_TRACE("%u/%u: Exit!!\n", i+1, num);
return; return;
default: default:
WINE_FIXME("Unknown event type (%d)\n", evts[i].event); WINE_FIXME("Unknown event type (%d)\n", evts[i].event);
} }
} }
data->in_grab_changes = FALSE; data->in_grab_changes = FALSE;
if (!DeviceIoControl(data->hSynchro, IOCTL_CONDRV_GET_RENDERER_EVENTS, NULL,
0, data->events,
sizeof(data->events), NULL, &data->overlapped) && GetLa
stError() != ERROR_IO_PENDING)
{
ERR("failed to get renderer events: %u\n", GetLastError());
data->dying = TRUE;
}
} }
/****************************************************************** /******************************************************************
* WINECON_SetConfig * WINECON_SetConfig
* *
* Apply to data all the configuration elements from cfg. This includes modifica tion * Apply to data all the configuration elements from cfg. This includes modifica tion
* of server side equivalent and visual parts. * of server side equivalent and visual parts.
* If force is FALSE, only the changed items are modified. * If force is FALSE, only the changed items are modified.
*/ */
void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf g) void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf g)
skipping to change at line 451 skipping to change at line 443
{ {
data->curcfg.insert_mode = cfg->insert_mode; data->curcfg.insert_mode = cfg->insert_mode;
WINECON_SetInsertMode(data->hConIn, cfg->insert_mode); WINECON_SetInsertMode(data->hConIn, cfg->insert_mode);
} }
data->curcfg.menu_mask = cfg->menu_mask; data->curcfg.menu_mask = cfg->menu_mask;
data->curcfg.quick_edit = cfg->quick_edit; data->curcfg.quick_edit = cfg->quick_edit;
if (strcmpiW(data->curcfg.face_name, cfg->face_name) || data->curcfg.cell_wi dth != cfg->cell_width || if (strcmpiW(data->curcfg.face_name, cfg->face_name) || data->curcfg.cell_wi dth != cfg->cell_width ||
data->curcfg.cell_height != cfg->cell_height || data->curcfg.font_pitch_ family != cfg->font_pitch_family || data->curcfg.cell_height != cfg->cell_height || data->curcfg.font_pitch_ family != cfg->font_pitch_family ||
data->curcfg.font_weight != cfg->font_weight) data->curcfg.font_weight != cfg->font_weight)
{ {
struct condrv_output_info_params *params;
size_t len = lstrlenW(cfg->face_name);
RECT r; RECT r;
data->fnSetFont(data, cfg->face_name, cfg->cell_height, cfg->font_weight ); data->fnSetFont(data, cfg->face_name, cfg->cell_height, cfg->font_weight );
SystemParametersInfoW(SPI_GETWORKAREA, 0, &r, 0); SystemParametersInfoW(SPI_GETWORKAREA, 0, &r, 0);
SERVER_START_REQ(set_console_output_info) if ((params = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*para ms) + len * sizeof(WCHAR))))
{ {
req->handle = wine_server_obj_handle( data->hConOut ); params->mask = SET_CONSOLE_OUTPUT_INFO_MAX_SIZE | SET_CONSOLE_OUTPUT
req->mask = SET_CONSOLE_OUTPUT_INFO_MAX_SIZE | SET_CONSOLE_OUTPUT_IN _INFO_FONT;
FO_FONT; params->info.max_width = (r.right - r.left) / cfg->cell_width;
req->max_width = (r.right - r.left) / cfg->cell_width; params->info.max_height = (r.bottom - r.top - GetSystemMetrics(SM_CY
req->max_height = (r.bottom - r.top - GetSystemMetrics(SM_CYCAPTION) CAPTION)) / cfg->cell_height;
) / cfg->cell_height; params->info.font_width = cfg->cell_width;
req->font_width = cfg->cell_width; params->info.font_height = cfg->cell_height;
req->font_height = cfg->cell_height; params->info.font_weight = cfg->font_weight;
req->font_weight = cfg->font_weight; params->info.font_pitch_family = cfg->font_pitch_family;
req->font_pitch_family = cfg->font_pitch_family; memcpy(params + 1, cfg->face_name, len * sizeof(WCHAR));
wine_server_add_data( req, cfg->face_name, lstrlenW(cfg->face_name) DeviceIoControl(data->hConOut, IOCTL_CONDRV_SET_OUTPUT_INFO, params,
* sizeof(WCHAR) ); sizeof(*params) + len * sizeof(WCHAR),
wine_server_call( req ); NULL, 0, NULL, NULL);
} }
SERVER_END_REQ;
} }
if (data->curcfg.def_attr != cfg->def_attr) if (data->curcfg.def_attr != cfg->def_attr)
{ {
DWORD screen_size, written; DWORD screen_size, written;
COORD top_left = {0,0}; COORD top_left = {0,0};
data->curcfg.def_attr = cfg->def_attr; data->curcfg.def_attr = cfg->def_attr;
screen_size = cfg->win_width * (cfg->win_height + 1); screen_size = cfg->win_width * (cfg->win_height + 1);
FillConsoleOutputAttribute(data->hConOut, cfg->def_attr, screen_size, to p_left, &written); FillConsoleOutputAttribute(data->hConOut, cfg->def_attr, screen_size, to p_left, &written);
SetConsoleTextAttribute(data->hConOut, cfg->def_attr); SetConsoleTextAttribute(data->hConOut, cfg->def_attr);
skipping to change at line 592 skipping to change at line 585
*/ */
static void WINECON_Delete(struct inner_data* data) static void WINECON_Delete(struct inner_data* data)
{ {
if (!data) return; if (!data) return;
if (data->fnDeleteBackend) data->fnDeleteBackend(data); if (data->fnDeleteBackend) data->fnDeleteBackend(data);
if (data->hConIn) CloseHandle(data->hConIn); if (data->hConIn) CloseHandle(data->hConIn);
if (data->hConOut) CloseHandle(data->hConOut); if (data->hConOut) CloseHandle(data->hConOut);
if (data->hSynchro) CloseHandle(data->hSynchro); if (data->hSynchro) CloseHandle(data->hSynchro);
if (data->hProcess) CloseHandle(data->hProcess); if (data->hProcess) CloseHandle(data->hProcess);
if (data->overlapped.hEvent) CloseHandle(data->overlapped.hEvent);
HeapFree(GetProcessHeap(), 0, data->curcfg.registry); HeapFree(GetProcessHeap(), 0, data->curcfg.registry);
HeapFree(GetProcessHeap(), 0, data->cells); HeapFree(GetProcessHeap(), 0, data->cells);
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
} }
/****************************************************************** /******************************************************************
* WINECON_GetServerConfig * WINECON_GetServerConfig
* *
* Fills data->curcfg with the actual configuration running in the server * Fills data->curcfg with the actual configuration running in the server
* (getting real information on the server, and not relying on cached * (getting real information on the server, and not relying on cached
* information in data) * information in data)
*/ */
static BOOL WINECON_GetServerConfig(struct inner_data* data) static BOOL WINECON_GetServerConfig(struct inner_data* data)
{ {
BOOL ret; struct condrv_input_info input_info;
struct condrv_output_info output_info;
DWORD mode; DWORD mode;
SERVER_START_REQ(get_console_input_info) if (!DeviceIoControl(data->hConIn, IOCTL_CONDRV_GET_INPUT_INFO, NULL, 0,
{ &input_info, sizeof(input_info), NULL, NULL))
req->handle = wine_server_obj_handle( data->hConIn ); return FALSE;
ret = !wine_server_call_err( req ); data->curcfg.history_size = input_info.history_size;
data->curcfg.history_size = reply->history_size; data->curcfg.history_nodup = input_info.history_mode;
data->curcfg.history_nodup = reply->history_mode; data->curcfg.edition_mode = input_info.edition_mode;
data->curcfg.edition_mode = reply->edition_mode;
}
SERVER_END_REQ;
if (!ret) return FALSE;
GetConsoleMode(data->hConIn, &mode); GetConsoleMode(data->hConIn, &mode);
data->curcfg.insert_mode = (mode & (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS )) == data->curcfg.insert_mode = (mode & (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS )) ==
(ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS ); (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS );
SERVER_START_REQ(get_console_output_info) if (!DeviceIoControl(data->hConOut, IOCTL_CONDRV_GET_OUTPUT_INFO, NULL, 0,
{ &output_info, sizeof(output_info), NULL, NULL))
req->handle = wine_server_obj_handle( data->hConOut ); return FALSE;
ret = !wine_server_call_err( req ); data->curcfg.cursor_size = output_info.cursor_size;
data->curcfg.cursor_size = reply->cursor_size; data->curcfg.cursor_visible = output_info.cursor_visible;
data->curcfg.cursor_visible = reply->cursor_visible; data->curcfg.def_attr = output_info.attr;
data->curcfg.def_attr = reply->attr; data->curcfg.sb_width = output_info.width;
data->curcfg.sb_width = reply->width; data->curcfg.sb_height = output_info.height;
data->curcfg.sb_height = reply->height; data->curcfg.win_width = output_info.win_right - output_info.win_left + 1;
data->curcfg.win_width = reply->win_right - reply->win_left + 1; data->curcfg.win_height = output_info.win_bottom - output_info.win_top + 1;
data->curcfg.win_height = reply->win_bottom - reply->win_top + 1;
}
SERVER_END_REQ;
WINECON_DumpConfig("first cfg: ", &data->curcfg);
return ret; WINECON_DumpConfig("first cfg: ", &data->curcfg);
return TRUE;
} }
/****************************************************************** /******************************************************************
* WINECON_Init * WINECON_Init
* *
* Initialisation part I. Creation of server object (console input and * Initialisation part I. Creation of server object (console input and
* active screen buffer) * active screen buffer)
*/ */
static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna me, static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna me,
enum init_return (*backend)(struct inner_ data*), enum init_return (*backend)(struct inner_ data*),
INT nCmdShow) INT nCmdShow)
{ {
OBJECT_ATTRIBUTES attr = {sizeof(attr)};
struct inner_data* data = NULL; struct inner_data* data = NULL;
DWORD ret; DWORD ret;
struct config_data cfg; struct config_data cfg;
STARTUPINFOW si; STARTUPINFOW si;
UNICODE_STRING string;
IO_STATUS_BLOCK io;
condrv_handle_t h;
NTSTATUS status;
static const WCHAR renderer_pathW[] = {'\\','D','e','v','i','c','e','\\','C'
,'o','n','D','r','v',
'\\','R','e','n','d','e','r','e','r',0};
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)); data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
if (!data) return 0; if (!data) return 0;
GetStartupInfoW(&si); GetStartupInfoW(&si);
if (pid == 0) appname = si.lpTitle; if (pid == 0) appname = si.lpTitle;
data->nCmdShow = nCmdShow; data->nCmdShow = nCmdShow;
/* load settings */ /* load settings */
skipping to change at line 681 skipping to change at line 677
if (si.dwFlags & STARTF_USECOUNTCHARS) if (si.dwFlags & STARTF_USECOUNTCHARS)
{ {
cfg.sb_width = si.dwXCountChars; cfg.sb_width = si.dwXCountChars;
cfg.sb_height = si.dwYCountChars; cfg.sb_height = si.dwYCountChars;
} }
if (si.dwFlags & STARTF_USEFILLATTRIBUTE) if (si.dwFlags & STARTF_USEFILLATTRIBUTE)
cfg.def_attr = si.dwFillAttribute; cfg.def_attr = si.dwFillAttribute;
/* should always be defined */ /* should always be defined */
} }
if (!(data->overlapped.hEvent = CreateEventW(NULL, TRUE, TRUE, NULL))) goto
error;
/* the handles here are created without the whistles and bells required by c onsole /* the handles here are created without the whistles and bells required by c onsole
* (mainly because wineconsole doesn't need it) * (mainly because wineconsole doesn't need it)
* - they are not inheritable * - they are not inheritable
* - hConIn is not synchronizable * - hConIn is not synchronizable
*/ */
SERVER_START_REQ(alloc_console) SERVER_START_REQ(alloc_console)
{ {
req->access = GENERIC_READ | GENERIC_WRITE; req->access = GENERIC_READ | GENERIC_WRITE;
req->attributes = 0; req->attributes = 0;
req->pid = pid; req->pid = pid;
req->input_fd = -1; req->input_fd = -1;
ret = !wine_server_call_err( req ); ret = !wine_server_call_err( req );
data->hConIn = wine_server_ptr_handle( reply->handle_in ); data->hConIn = wine_server_ptr_handle( reply->handle_in );
data->hSynchro = wine_server_ptr_handle( reply->event );
} }
SERVER_END_REQ; SERVER_END_REQ;
if (!ret) goto error; if (!ret) goto error;
WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->hSync hro); WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->hSync hro);
RtlInitUnicodeString(&string, renderer_pathW);
attr.ObjectName = &string;
status = NtCreateFile(&data->hSynchro, FILE_READ_DATA | FILE_WRITE_DATA | FI
LE_WRITE_PROPERTIES
| FILE_READ_PROPERTIES | SYNCHRONIZE, &attr, &io, NULL
, FILE_ATTRIBUTE_NORMAL,
0, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0);
if (status) goto error;
h = condrv_handle(data->hConIn);
if (!DeviceIoControl(data->hSynchro, IOCTL_CONDRV_ATTACH_RENDERER, &h, sizeo
f(h), NULL, 0, NULL, NULL))
goto error;
SERVER_START_REQ(create_console_output) SERVER_START_REQ(create_console_output)
{ {
req->handle_in = wine_server_obj_handle( data->hConIn ); req->handle_in = wine_server_obj_handle( data->hConIn );
req->access = GENERIC_WRITE|GENERIC_READ; req->access = GENERIC_WRITE|GENERIC_READ;
req->attributes = 0; req->attributes = 0;
req->share = FILE_SHARE_READ|FILE_SHARE_WRITE; req->share = FILE_SHARE_READ|FILE_SHARE_WRITE;
req->fd = -1; req->fd = -1;
ret = !wine_server_call_err( req ); ret = !wine_server_call_err( req );
data->hConOut = wine_server_ptr_handle( reply->handle_out ); data->hConOut = wine_server_ptr_handle( reply->handle_out );
} }
 End of changes. 25 change blocks. 
79 lines changed or deleted 94 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)