Commit 340a6617 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wineconsole: Use OVERLAPPED to wait for console events.

parent 378ce9e6
...@@ -1020,7 +1020,7 @@ static int WCCURSES_MainLoop(struct inner_data* data) ...@@ -1020,7 +1020,7 @@ static int WCCURSES_MainLoop(struct inner_data* data)
if (pipe( PRIVATE(data)->sync_pipe ) == -1) return 1; if (pipe( PRIVATE(data)->sync_pipe ) == -1) return 1;
PRIVATE(data)->input_thread = CreateThread( NULL, 0, input_thread, data, 0, &id ); PRIVATE(data)->input_thread = CreateThread( NULL, 0, input_thread, data, 0, &id );
while (!data->dying && WaitForSingleObject(data->hSynchro, INFINITE) == WAIT_OBJECT_0) while (!data->dying && WaitForSingleObject(data->overlapped.hEvent, INFINITE) == WAIT_OBJECT_0)
{ {
EnterCriticalSection(&PRIVATE(data)->lock); EnterCriticalSection(&PRIVATE(data)->lock);
WINECON_GrabChanges(data); WINECON_GrabChanges(data);
......
...@@ -1365,7 +1365,7 @@ static int WCUSER_MainLoop(struct inner_data* data) ...@@ -1365,7 +1365,7 @@ static int WCUSER_MainLoop(struct inner_data* data)
ShowWindow(data->hWnd, data->nCmdShow); ShowWindow(data->hWnd, data->nCmdShow);
while (!data->dying || !data->curcfg.exit_on_die) while (!data->dying || !data->curcfg.exit_on_die)
{ {
switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT)) switch (MsgWaitForMultipleObjects(1, &data->overlapped.hEvent, FALSE, INFINITE, QS_ALLINPUT))
{ {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
WINECON_GrabChanges(data); WINECON_GrabChanges(data);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <windef.h> #include <windef.h>
#include <winbase.h> #include <winbase.h>
#include <wincon.h> #include <wincon.h>
#include <wine/condrv.h>
#include "wineconsole_res.h" #include "wineconsole_res.h"
...@@ -69,6 +70,9 @@ struct inner_data { ...@@ -69,6 +70,9 @@ struct inner_data {
BOOL in_grab_changes;/* to handle re-entrant calls to WINECON_GrabChanges */ BOOL in_grab_changes;/* to handle re-entrant calls to WINECON_GrabChanges */
BOOL dying; /* to TRUE when we've been notified by server that child has died */ BOOL dying; /* to TRUE when we've been notified by server that child has died */
OVERLAPPED overlapped;
struct condrv_renderer_event events[256];
int (*fnMainLoop)(struct inner_data* data); int (*fnMainLoop)(struct inner_data* data);
void (*fnPosCursor)(const struct inner_data* data); void (*fnPosCursor)(const struct inner_data* data);
void (*fnShapeCursor)(struct inner_data* data, int size, int vis, BOOL force); void (*fnShapeCursor)(struct inner_data* data, int size, int vis, BOOL force);
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "winecon_private.h" #include "winecon_private.h"
#include "winnls.h" #include "winnls.h"
#include "winuser.h" #include "winuser.h"
#include "wine/condrv.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -242,21 +241,20 @@ static void WINECON_SetColors(struct inner_data *data, const struct config_data* ...@@ -242,21 +241,20 @@ static void WINECON_SetColors(struct inner_data *data, const struct config_data*
*/ */
void WINECON_GrabChanges(struct inner_data* data) void WINECON_GrabChanges(struct inner_data* data)
{ {
struct condrv_renderer_event evts[256]; struct condrv_renderer_event *evts = data->events;
int i, ev_found; int i, ev_found;
DWORD num; DWORD num;
HANDLE h; HANDLE h;
if (data->in_grab_changes) return; if (data->in_grab_changes) return;
if (!DeviceIoControl( data->hSynchro, IOCTL_CONDRV_GET_RENDERER_EVENTS, NULL, 0, evts, if (!GetOverlappedResult(data->hSynchro, &data->overlapped, &num, FALSE))
sizeof(evts), &num, NULL ) || !num)
{ {
ERR( "failed to get renderer events: %u\n", GetLastError() ); ERR( "failed to get renderer events: %u\n", GetLastError() );
data->dying = TRUE; data->dying = TRUE;
return; return;
} }
num /= sizeof(*evts); num /= sizeof(data->events[0]);
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) */
...@@ -400,6 +398,13 @@ void WINECON_GrabChanges(struct inner_data* data) ...@@ -400,6 +398,13 @@ void WINECON_GrabChanges(struct inner_data* data)
} }
} }
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) && GetLastError() != ERROR_IO_PENDING)
{
ERR("failed to get renderer events: %u\n", GetLastError());
data->dying = TRUE;
}
} }
/****************************************************************** /******************************************************************
...@@ -590,6 +595,7 @@ static void WINECON_Delete(struct inner_data* data) ...@@ -590,6 +595,7 @@ static void WINECON_Delete(struct inner_data* data)
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);
...@@ -676,6 +682,8 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna ...@@ -676,6 +682,8 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
/* 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 console /* the handles here are created without the whistles and bells required by console
* (mainly because wineconsole doesn't need it) * (mainly because wineconsole doesn't need it)
* - they are not inheritable * - they are not inheritable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment