Added patch to implement kernel32.GetConsoleFontSize.

This commit is contained in:
Sebastian Lackner 2015-10-31 18:39:31 +01:00
parent 896b3398f1
commit 4be7c872c3
11 changed files with 415 additions and 6 deletions

View File

@ -34,7 +34,7 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [10]:**
**Bug fixes and features included in the next upcoming release [11]:**
* Add stub for SetCoalescableTimer ([Wine Bug #39509](https://bugs.winehq.org/show_bug.cgi?id=39509))
* Add stub for SetConsoleKeyShortcuts ([Wine Bug #35702](https://bugs.winehq.org/show_bug.cgi?id=35702))
@ -44,6 +44,7 @@ Included bug fixes and improvements
* IEnumSTATSTG::Next should zero out returned stats when enumeration ends
* Implement FileNamesInformation class support for NtQueryDirectoryFile
* Implement hal.KeQueryPerformanceCounter ([Wine Bug #39500](https://bugs.winehq.org/show_bug.cgi?id=39500))
* Implement kernel32.GetConsoleFontSize
* Implement stub for ProcessQuotaLimits info class
* Improve INetFwAuthorizedApplication::get_ProcessImageFileName stub

1
debian/changelog vendored
View File

@ -22,6 +22,7 @@ wine-staging (1.7.54) UNRELEASED; urgency=low
of enumeration.
* Added patch to fix multiple issues in widl typelib generation.
* Added patch for SetConsoleKeyShortcuts stub function.
* Added patch to implement kernel32.GetConsoleFontSize.
* Removed patch to implement kernel32.GetPhysicallyInstalledSystemMemory
(accepted upstream).
* Partially removed patches for ws2_32 TransmitFile (accepted upstream).

View File

@ -0,0 +1,41 @@
From 303ff4b8e0235e7501776c15089effb16e02d904 Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Thu, 29 Oct 2015 23:17:17 +1100
Subject: wineconsole: Add if check to determine whether a font attribute has
changed (v3)
This version uses a case insensitive comparison, as requested by Dmitry Timoshkov.
Patches two to six are unchanged.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
programs/wineconsole/wineconsole.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index e1ee55b..eb07f6b 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -27,7 +27,7 @@
#include "winecon_private.h"
#include "winnls.h"
#include "winuser.h"
-
+#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wineconsole);
@@ -421,7 +421,8 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
}
data->curcfg.menu_mask = cfg->menu_mask;
data->curcfg.quick_edit = cfg->quick_edit;
- if (1 /* FIXME: font info has changed */)
+ if (strcmpiW(data->curcfg.face_name, cfg->face_name) || data->curcfg.cell_width != cfg->cell_width ||
+ data->curcfg.cell_height != cfg->cell_height || data->curcfg.font_weight != cfg->font_weight)
{
data->fnSetFont(data, cfg->face_name, cfg->cell_height, cfg->font_weight);
}
--
2.6.1

View File

@ -0,0 +1,120 @@
From 4d1cb95792e3183f1777df839cc5046f5c1395e6 Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Thu, 29 Oct 2015 23:17:18 +1100
Subject: wineconsole: Pass font size information to wineserver
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
programs/wineconsole/wineconsole.c | 9 +++++++++
server/console.c | 16 ++++++++++++++++
server/protocol.def | 5 +++++
3 files changed, 30 insertions(+)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index eb07f6b..d376535 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -425,6 +425,15 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
data->curcfg.cell_height != cfg->cell_height || data->curcfg.font_weight != cfg->font_weight)
{
data->fnSetFont(data, cfg->face_name, cfg->cell_height, cfg->font_weight);
+ SERVER_START_REQ(set_console_output_info)
+ {
+ req->handle = wine_server_obj_handle( data->hConOut );
+ req->mask = SET_CONSOLE_OUTPUT_INFO_FONT;
+ req->font_width = cfg->cell_width;
+ req->font_height = cfg->cell_height;
+ wine_server_call_err( req );
+ }
+ SERVER_END_REQ;
}
if (data->curcfg.def_attr != cfg->def_attr)
{
diff --git a/server/console.c b/server/console.c
index 389547d..a57b2fe 100644
--- a/server/console.c
+++ b/server/console.c
@@ -121,6 +121,12 @@ static const struct object_ops console_input_events_ops =
console_input_events_destroy /* destroy */
};
+struct font_info
+{
+ short int width;
+ short int height;
+};
+
struct screen_buffer
{
struct object obj; /* object header */
@@ -139,6 +145,7 @@ struct screen_buffer
unsigned short attr; /* default attribute for screen buffer */
rectangle_t win; /* current visible window on the screen buffer *
* as seen in wineconsole */
+ struct font_info font; /* console font information */
struct fd *fd; /* for bare console, attached output fd */
};
@@ -411,6 +418,8 @@ static struct screen_buffer *create_console_output( struct console_input *consol
screen_buffer->win.top = 0;
screen_buffer->win.bottom = screen_buffer->max_height - 1;
screen_buffer->data = NULL;
+ screen_buffer->font.width = 0;
+ screen_buffer->font.height = 0;
list_add_head( &screen_buffer_list, &screen_buffer->entry );
if (fd == -1)
@@ -1019,6 +1028,11 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
screen_buffer->max_width = req->max_width;
screen_buffer->max_height = req->max_height;
}
+ if (req->mask & SET_CONSOLE_OUTPUT_INFO_FONT)
+ {
+ screen_buffer->font.width = req->font_width;
+ screen_buffer->font.height = req->font_height;
+ }
return 1;
}
@@ -1676,6 +1690,8 @@ DECL_HANDLER(get_console_output_info)
reply->win_bottom = screen_buffer->win.bottom;
reply->max_width = screen_buffer->max_width;
reply->max_height = screen_buffer->max_height;
+ reply->font_width = screen_buffer->font.width;
+ reply->font_height = screen_buffer->font.height;
release_object( screen_buffer );
}
}
diff --git a/server/protocol.def b/server/protocol.def
index 5b45078..aa37c66 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1495,6 +1495,8 @@ struct console_renderer_event
short int win_bottom;
short int max_width; /* maximum size (width x height) for the window */
short int max_height;
+ short int font_width; /* font size (width x height) */
+ short int font_height;
@END
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM 0x01
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_POS 0x02
@@ -1502,6 +1504,7 @@ struct console_renderer_event
#define SET_CONSOLE_OUTPUT_INFO_ATTR 0x08
#define SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW 0x10
#define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20
+#define SET_CONSOLE_OUTPUT_INFO_FONT 0x40
/* Get info about a console (output only) */
@@ -1521,6 +1524,8 @@ struct console_renderer_event
short int win_bottom;
short int max_width; /* maximum size (width x height) for the window */
short int max_height;
+ short int font_width; /* font size (width x height) */
+ short int font_height;
@END
/* Add input records to a console input queue */
--
2.6.1

View File

@ -0,0 +1,47 @@
From 6047f0c7bc371f229c33bb4d7cefa1b2377c77c1 Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Thu, 29 Oct 2015 23:17:20 +1100
Subject: kernel32: Implement GetNumberOfConsoleFonts (resend)
This function is called by GetConsoleFontSize and its tests.
Note that we only ever have one entry in the console font table.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
dlls/kernel32/console.c | 5 +++++
dlls/kernel32/kernel32.spec | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index c32dc49..67627cc 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -3234,6 +3234,11 @@ BOOL WINAPI SetConsoleIcon(HICON icon)
return FALSE;
}
+DWORD WINAPI GetNumberOfConsoleFonts(void)
+{
+ return 1;
+}
+
BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsole, BOOL maxwindow, LPCONSOLE_FONT_INFO fontinfo)
{
BOOL ret;
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index d7eab83..9b2a131 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -753,7 +753,7 @@
@ stdcall GetNumberFormatA(long long str ptr ptr long)
# @ stub GetNumberFormatEx
@ stdcall GetNumberFormatW(long long wstr ptr ptr long)
-@ stub GetNumberOfConsoleFonts
+@ stdcall GetNumberOfConsoleFonts()
@ stdcall GetNumberOfConsoleInputEvents(long ptr)
@ stdcall GetNumberOfConsoleMouseButtons(ptr)
@ stdcall GetOEMCP()
--
2.6.1

View File

@ -0,0 +1,78 @@
From c311068247c68d5b6351b2384115c590028b0fcb Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Thu, 29 Oct 2015 23:17:21 +1100
Subject: kernel32: Implement GetConsoleFontSize (v2, resend)
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
dlls/kernel32/console.c | 44 ++++++++++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 67627cc..b1f8814 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -3265,32 +3265,44 @@ BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsole, BOOL maxwindow, LPCONSOLE_FON
return ret;
}
+static COORD get_console_font_size(HANDLE hConsole, DWORD index)
+{
+ COORD c = {0,0};
+
+ if (index >= GetNumberOfConsoleFonts())
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return c;
+ }
+
+ SERVER_START_REQ(get_console_output_info)
+ {
+ req->handle = console_handle_unmap(hConsole);
+ if (!wine_server_call_err(req))
+ {
+ c.X = reply->font_width;
+ c.Y = reply->font_height;
+ }
+ }
+ SERVER_END_REQ;
+ return c;
+}
+
#ifdef __i386__
#undef GetConsoleFontSize
-DWORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD font)
+DWORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD index)
{
union {
COORD c;
DWORD w;
} x;
- FIXME(": (%p, %d) stub!\n", hConsole, font);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-
- x.c.X = 0;
- x.c.Y = 0;
+ x.c = get_console_font_size(hConsole, index);
return x.w;
}
-#endif /* defined(__i386__) */
-
-
-#ifndef __i386__
-COORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD font)
+#else /* defined(__i386__) */
+COORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD index)
{
- COORD c;
- c.X = 80;
- c.Y = 24;
- FIXME(": (%p, %d) stub!\n", hConsole, font);
- return c;
+ return get_console_font_size(hConsole, index);
}
#endif /* defined(__i386__) */
--
2.6.1

View File

@ -0,0 +1,84 @@
From a366dabe15b06c31edebf966c81d5e981b1d6e7d Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Thu, 29 Oct 2015 23:17:22 +1100
Subject: kernel32/tests: Add tests for GetConsoleFontSize (v2, resend)
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
dlls/kernel32/tests/console.c | 55 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 454f963..240d9d8 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2627,6 +2627,60 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
"got %d, expected %d\n", cfi.dwFontSize.Y, height);
}
+static void test_GetConsoleFontSize(HANDLE std_output)
+{
+ COORD c;
+ DWORD index = 0;
+ CONSOLE_FONT_INFO cfi;
+ RECT r;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ LONG font_width, font_height;
+ HMODULE hmod;
+ DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
+
+ memset(&c, 10, sizeof(COORD));
+ SetLastError(0xdeadbeef);
+ c = GetConsoleFontSize(NULL, index);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+ ok(!c.X, "got %d, expected 0\n", c.X);
+ ok(!c.Y, "got %d, expected 0\n", c.Y);
+
+ memset(&c, 10, sizeof(COORD));
+ SetLastError(0xdeadbeef);
+ c = GetConsoleFontSize(GetStdHandle(STD_INPUT_HANDLE), index);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+ ok(!c.X, "got %d, expected 0\n", c.X);
+ ok(!c.Y, "got %d, expected 0\n", c.Y);
+
+ GetCurrentConsoleFont(std_output, FALSE, &cfi);
+ memset(&c, 10, sizeof(COORD));
+ SetLastError(0xdeadbeef);
+ c = GetConsoleFontSize(std_output, cfi.nFont);
+ ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+ GetClientRect(GetConsoleWindow(), &r);
+ GetConsoleScreenBufferInfo(std_output, &csbi);
+ font_width = (r.right - r.left + 1) / csbi.srWindow.Right;
+ font_height = (r.bottom - r.top + 1) / csbi.srWindow.Bottom;
+ ok(c.X == font_width, "got %d, expected %d\n", c.X, font_width);
+ ok(c.Y == font_height, "got %d, expected %d\n", c.Y, font_height);
+
+ hmod = GetModuleHandleA("kernel32.dll");
+ pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
+ if (!pGetNumberOfConsoleFonts)
+ {
+ win_skip("GetNumberOfConsoleFonts is not available\n");
+ return;
+ }
+ index = pGetNumberOfConsoleFonts();
+
+ memset(&c, 10, sizeof(COORD));
+ SetLastError(0xdeadbeef);
+ c = GetConsoleFontSize(std_output, index);
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+ ok(!c.X, "got %d, expected 0\n", c.X);
+ ok(!c.Y, "got %d, expected 0\n", c.Y);
+}
+
START_TEST(console)
{
static const char font_name[] = "Lucida Console";
@@ -2760,4 +2814,5 @@ START_TEST(console)
test_ReadConsoleOutputCharacterW(hConOut);
test_ReadConsoleOutputAttribute(hConOut);
test_GetCurrentConsoleFont(hConOut);
+ test_GetConsoleFontSize(hConOut);
}
--
2.6.1

View File

@ -0,0 +1 @@
Fixes: Implement kernel32.GetConsoleFontSize

View File

@ -1,4 +1,4 @@
From 43143be970d430122d341eb08dc2828f9d901978 Mon Sep 17 00:00:00 2001
From 8249417355479b858302aa7f8b319c248a65a0b1 Mon Sep 17 00:00:00 2001
From: Austin English <austinenglish@gmail.com>
Date: Wed, 28 Oct 2015 10:37:27 -0500
Subject: kernel32: add SetConsoleKeyShortcuts stub (resend)
@ -10,11 +10,11 @@ Signed-off-by: Austin English <austinenglish@gmail.com>
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index c32dc49..aa89e65 100644
index b1f8814..1e07d02 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -3234,6 +3234,15 @@ BOOL WINAPI SetConsoleIcon(HICON icon)
return FALSE;
@@ -3239,6 +3239,15 @@ DWORD WINAPI GetNumberOfConsoleFonts(void)
return 1;
}
+
@ -30,7 +30,7 @@ index c32dc49..aa89e65 100644
{
BOOL ret;
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index d7eab83..793f616 100644
index 9b2a131..8d7d699 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -1350,7 +1350,7 @@

View File

@ -1 +1,2 @@
Fixes: [35702] Add stub for SetConsoleKeyShortcuts
Depends: kernel32-GetConsoleFontSize

View File

@ -153,6 +153,7 @@ patch_enable_all ()
enable_kernel32_CompareStringEx="$1"
enable_kernel32_CopyFileEx="$1"
enable_kernel32_Cwd_Startup_Info="$1"
enable_kernel32_GetConsoleFontSize="$1"
enable_kernel32_GetFinalPathNameByHandle="$1"
enable_kernel32_GetLogicalProcessorInformationEx="$1"
enable_kernel32_LocaleNameToLCID="$1"
@ -560,6 +561,9 @@ patch_enable ()
kernel32-Cwd_Startup_Info)
enable_kernel32_Cwd_Startup_Info="$2"
;;
kernel32-GetConsoleFontSize)
enable_kernel32_GetConsoleFontSize="$2"
;;
kernel32-GetFinalPathNameByHandle)
enable_kernel32_GetFinalPathNameByHandle="$2"
;;
@ -1934,6 +1938,13 @@ if test "$enable_ntdll_CLI_Images" -eq 1; then
enable_mscoree_CorValidateImage=1
fi
if test "$enable_kernel32_SetConsoleKeyShortcuts" -eq 1; then
if test "$enable_kernel32_GetConsoleFontSize" -gt 1; then
abort "Patchset kernel32-GetConsoleFontSize disabled, but kernel32-SetConsoleKeyShortcuts depends on that."
fi
enable_kernel32_GetConsoleFontSize=1
fi
if test "$enable_kernel32_Named_Pipe" -eq 1; then
if test "$enable_rpcrt4_Pipe_Transport" -gt 1; then
abort "Patchset rpcrt4-Pipe_Transport disabled, but kernel32-Named_Pipe depends on that."
@ -3396,6 +3407,27 @@ if test "$enable_kernel32_Cwd_Startup_Info" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-GetConsoleFontSize
# |
# | Modified files:
# | * dlls/kernel32/console.c, dlls/kernel32/kernel32.spec, dlls/kernel32/tests/console.c, programs/wineconsole/wineconsole.c,
# | server/console.c, server/protocol.def
# |
if test "$enable_kernel32_GetConsoleFontSize" -eq 1; then
patch_apply kernel32-GetConsoleFontSize/0001-wineconsole-Add-if-check-to-determine-whether-a-font.patch
patch_apply kernel32-GetConsoleFontSize/0002-wineconsole-Pass-font-size-information-to-wineserver.patch
patch_apply kernel32-GetConsoleFontSize/0003-kernel32-Implement-GetNumberOfConsoleFonts-resend.patch
patch_apply kernel32-GetConsoleFontSize/0004-kernel32-Implement-GetConsoleFontSize-v2-resend.patch
patch_apply kernel32-GetConsoleFontSize/0005-kernel32-tests-Add-tests-for-GetConsoleFontSize-v2-r.patch
(
echo '+ { "Hugh McMaster", "wineconsole: Add if check to determine whether a font attribute has changed.", 3 },';
echo '+ { "Hugh McMaster", "wineconsole: Pass font size information to wineserver.", 1 },';
echo '+ { "Hugh McMaster", "kernel32: Implement GetNumberOfConsoleFonts.", 1 },';
echo '+ { "Hugh McMaster", "kernel32: Implement GetConsoleFontSize (v2, resend).", 1 },';
echo '+ { "Hugh McMaster", "kernel32/tests: Add tests for GetConsoleFontSize (v2, resend).", 1 },';
) >> "$patchlist"
fi
# Patchset kernel32-GetFinalPathNameByHandle
# |
# | This patchset fixes the following Wine bugs:
@ -3552,6 +3584,9 @@ fi
# Patchset kernel32-SetConsoleKeyShortcuts
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * kernel32-GetConsoleFontSize
# |
# | This patchset fixes the following Wine bugs:
# | * [#35702] Add stub for SetConsoleKeyShortcuts
# |