diff --git a/programs/wineconsole/curses.c b/programs/wineconsole/curses.c index 676f1bba822..8c491fd2a63 100644 --- a/programs/wineconsole/curses.c +++ b/programs/wineconsole/curses.c @@ -717,10 +717,10 @@ static int WCCURSES_MainLoop(struct inner_data* data) * Initialisation part II: creation of window. * */ -BOOL WCCURSES_InitBackend(struct inner_data* data) +enum init_return WCCURSES_InitBackend(struct inner_data* data) { data->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct inner_data_curse)); - if (!data->private) return FALSE; + if (!data->private) return init_failed; data->fnMainLoop = WCCURSES_MainLoop; data->fnPosCursor = WCCURSES_PosCursor; @@ -737,7 +737,7 @@ BOOL WCCURSES_InitBackend(struct inner_data* data) (obj_handle_t*)&PRIVATE(data)->hInput)) { WINE_FIXME("Cannot open 0\n"); - return 0; + return init_failed; } /* FIXME: should find a good way to enable buffer scrolling @@ -782,12 +782,12 @@ BOOL WCCURSES_InitBackend(struct inner_data* data) mousemask(0, &PRIVATE(data)->initial_mouse_mask); } - return TRUE; + return init_success; } #else BOOL WCCURSES_InitBackend(struct inner_data* data) { - return FALSE; + return init_not_supported; } #endif diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c index 1c3477dd54d..222fe558383 100644 --- a/programs/wineconsole/user.c +++ b/programs/wineconsole/user.c @@ -1353,14 +1353,14 @@ static int WCUSER_MainLoop(struct inner_data* data) * Initialisation part II: creation of window. * */ -BOOL WCUSER_InitBackend(struct inner_data* data) +enum init_return WCUSER_InitBackend(struct inner_data* data) { static WCHAR wClassName[] = {'W','i','n','e','C','o','n','s','o','l','e','C','l','a','s','s',0}; WNDCLASS wndclass; data->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct inner_data_user)); - if (!data->private) return FALSE; + if (!data->private) return init_failed; data->fnMainLoop = WCUSER_MainLoop; data->fnPosCursor = WCUSER_PosCursor; @@ -1389,7 +1389,7 @@ BOOL WCUSER_InitBackend(struct inner_data* data) CreateWindow(wndclass.lpszClassName, NULL, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_HSCROLL|WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, wndclass.hInstance, data); - if (!PRIVATE(data)->hWnd) return FALSE; + if (!PRIVATE(data)->hWnd) return init_failed; - return TRUE; + return init_success; } diff --git a/programs/wineconsole/winecon_private.h b/programs/wineconsole/winecon_private.h index fbe62d34ec9..81f18c6b123 100644 --- a/programs/wineconsole/winecon_private.h +++ b/programs/wineconsole/winecon_private.h @@ -89,5 +89,8 @@ extern void WINECON_RegSave(const struct config_data* cfg); extern void WINECON_DumpConfig(const char* pfx, const struct config_data* cfg); /* backends... */ -extern BOOL WCUSER_InitBackend(struct inner_data* data); -extern BOOL WCCURSES_InitBackend(struct inner_data* data); +enum init_return { + init_success, init_failed, init_not_supported +}; +extern enum init_return WCUSER_InitBackend(struct inner_data* data); +extern enum init_return WCCURSES_InitBackend(struct inner_data* data); diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 046687e3b76..7d8c6bae28e 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -529,7 +529,7 @@ static void WINECON_Delete(struct inner_data* data) * active screen buffer) */ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appname, - BOOL (*backend)(struct inner_data*)) + enum init_return (*backend)(struct inner_data*)) { struct inner_data* data = NULL; DWORD ret; @@ -605,12 +605,26 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna WINE_TRACE("using hConOut %p\n", data->hConOut); /* filling data->curcfg from cfg */ - if ((*backend)(data)) + retry: + switch ((*backend)(data)) { + case init_success: WINECON_SetConfig(data, &cfg, TRUE); data->curcfg.registry = cfg.registry; WINECON_DumpConfig("fint", &data->curcfg); return data; + case init_failed: + break; + case init_not_supported: + if (backend == WCCURSES_InitBackend) + { + WINE_ERR("(n)curses was not found at configuration time.\n" + "If you want (n)curses support, please install relevant packages.\n" + "Now forcing user backend instead of (n)curses.\n"); + backend = WCUSER_InitBackend; + goto retry; + } + break; } error: @@ -665,10 +679,10 @@ static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine) } struct wc_init { - LPCSTR ptr; + LPCSTR ptr; enum {from_event, from_process_name} mode; - BOOL (*backend)(struct inner_data*); - HANDLE event; + enum init_return (*backend)(struct inner_data*); + HANDLE event; }; /******************************************************************