Browse Source

Merge d78bdde484 into 69a4213235

pull/75/merge
Steve Lhomme GitHub 1 month ago
parent
commit
6e3b24e2bd
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 2 deletions
  1. +8
    -0
      caca/canvas.c
  2. +16
    -2
      caca/driver/win32.c

+ 8
- 0
caca/canvas.c View File

@@ -27,6 +27,10 @@
# include <unistd.h> # include <unistd.h>
# endif # endif
#endif #endif
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif


#include "caca.h" #include "caca.h"
#include "caca_internals.h" #include "caca_internals.h"
@@ -351,7 +355,11 @@ int caca_rand(int min, int max)


if(need_init) if(need_init)
{ {
#ifdef _WIN32
srand(GetCurrentProcessId() + _caca_getticks(&timer));
#else
srand(getpid() + _caca_getticks(&timer)); srand(getpid() + _caca_getticks(&timer));
#endif
need_init = 0; need_init = 0;
} }




+ 16
- 2
caca/driver/win32.c View File

@@ -19,11 +19,13 @@


#if defined(USE_WIN32) #if defined(USE_WIN32)


#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x500 /* _WIN32_WINNT_WIN2K */
#define _WIN32_WINNT 0x500 /* Require WinXP or later */ #define _WIN32_WINNT 0x500 /* Require WinXP or later */
#endif
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>


#ifdef __MINGW32__
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
/* This is missing from the MinGW headers. */ /* This is missing from the MinGW headers. */
# if (_WIN32_WINNT >= 0x0500) # if (_WIN32_WINNT >= 0x0500)
BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsoleOutput, BOOL bMaximumWindow, BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsoleOutput, BOOL bMaximumWindow,
@@ -102,6 +104,9 @@ static int win32_init_graphics(caca_display_t *dp)
CONSOLE_CURSOR_INFO cci_screen; CONSOLE_CURSOR_INFO cci_screen;
SMALL_RECT rect; SMALL_RECT rect;
COORD size; COORD size;
#if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
CREATEFILE2_EXTENDED_PARAMETERS createExParams;
#endif


dp->drv.p = malloc(sizeof(struct driver_private)); dp->drv.p = malloc(sizeof(struct driver_private));


@@ -109,9 +114,18 @@ static int win32_init_graphics(caca_display_t *dp)
dp->drv.p->new_console = AllocConsole(); dp->drv.p->new_console = AllocConsole();


dp->drv.p->hin = GetStdHandle(STD_INPUT_HANDLE); dp->drv.p->hin = GetStdHandle(STD_INPUT_HANDLE);
#if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
ZeroMemory(&createExParams, sizeof(createExParams));
createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
createExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
dp->drv.p->hout = CreateFile2(L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
OPEN_EXISTING, &createExParams);
#else
dp->drv.p->hout = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE, dp->drv.p->hout = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif
if(dp->drv.p->hout == INVALID_HANDLE_VALUE) if(dp->drv.p->hout == INVALID_HANDLE_VALUE)
return -1; return -1;


@@ -194,7 +208,7 @@ static int win32_end_graphics(caca_display_t *dp)


static int win32_set_display_title(caca_display_t *dp, char const *title) static int win32_set_display_title(caca_display_t *dp, char const *title)
{ {
SetConsoleTitle(title);
SetConsoleTitleA(title);
return 0; return 0;
} }




Loading…
Cancel
Save