Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/03f72abdb3416fd6fd869beafa03f2c4f3803df0
...commit
http://git.netsurf-browser.org/netsurf.git/commit/03f72abdb3416fd6fd869beafa03f2c4f3803df0
...tree
http://git.netsurf-browser.org/netsurf.git/tree/03f72abdb3416fd6fd869beafa03f2c4f3803df0
The branch, master has been updated
via 03f72abdb3416fd6fd869beafa03f2c4f3803df0 (commit)
from 9a02a41cd61d7fa4a58d234e7240ff41205a7e54 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=03f72abdb3416fd6fd869beafa03f2c4f3803df0
commit 03f72abdb3416fd6fd869beafa03f2c4f3803df0
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
fix win32 frontend to allow setting unicode titles
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 05d7a54..2748080 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -59,7 +59,7 @@
static struct gui_window *window_list = NULL;
/** The main window class name */
-static const char windowclassname_main[] = "nswsmainwindow";
+static const LPCWSTR windowclassname_main = L"nswsmainwindow";
/** width of the throbber element */
#define NSWS_THROBBER_WIDTH 24
@@ -143,9 +143,9 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct
gui_window *gw)
NSLOG(netsurf, INFO,
"creating hInstance %p GUI window %p",
hInstance, gw);
- hwnd = CreateWindowEx(0,
+ hwnd = CreateWindowExW(0,
windowclassname_main,
- "NetSurf Browser",
+ L"NetSurf Browser",
WS_OVERLAPPEDWINDOW |
WS_CLIPCHILDREN |
WS_CLIPSIBLINGS |
@@ -1345,7 +1345,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
*/
GetClientRect(hwnd, &rmain);
PostMessage(hwnd, WM_SIZE, 0, MAKELPARAM(rmain.right,
rmain.bottom));
- return DefWindowProc(hwnd, msg, wparam, lparam);
+ return DefWindowProcW(hwnd, msg, wparam, lparam);
}
@@ -1353,7 +1353,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
if (gw == NULL) {
NSLOG(netsurf, INFO,
"Unable to find gui window structure for hwnd %p", hwnd);
- return DefWindowProc(hwnd, msg, wparam, lparam);
+ return DefWindowProcW(hwnd, msg, wparam, lparam);
}
switch (msg) {
@@ -1386,7 +1386,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
}
- return DefWindowProc(hwnd, msg, wparam, lparam);
+ return DefWindowProcW(hwnd, msg, wparam, lparam);
}
@@ -1529,6 +1529,8 @@ static void win32_window_update_extent(struct gui_window
*gw)
static void win32_window_set_title(struct gui_window *w, const char *title)
{
char *fulltitle;
+ int wlen;
+ LPWSTR enctitle;
if (w == NULL) {
return;
@@ -1537,14 +1539,32 @@ static void win32_window_set_title(struct gui_window
*w, const char *title)
NSLOG(netsurf, INFO, "%p, title %s", w, title);
fulltitle = malloc(strlen(title) + SLEN(" - NetSurf") + 1);
if (fulltitle == NULL) {
- win32_warning("NoMemory", 0);
+ NSLOG(netsurf, ERROR, "%s",
+ messages_get_errorcode(NSERROR_NOMEM));
return;
}
strcpy(fulltitle, title);
strcat(fulltitle, " - NetSurf");
- SendMessage(w->main, WM_SETTEXT, 0, (LPARAM)fulltitle);
+ wlen = MultiByteToWideChar(CP_UTF8, 0, fulltitle, -1, NULL, 0);
+ if (wlen == 0) {
+ NSLOG(netsurf, ERROR, "failed encoding \"%s\"", fulltitle);
+ free(fulltitle);
+ return;
+ }
+
+ enctitle = malloc(2 * (wlen + 1));
+ if (enctitle == NULL) {
+ NSLOG(netsurf, ERROR, "%s encoding \"%s\" len %d",
+ messages_get_errorcode(NSERROR_NOMEM), fulltitle, wlen);
+ free(fulltitle);
+ return;
+ }
+
+ MultiByteToWideChar(CP_UTF8, 0, fulltitle, -1, enctitle, wlen);
+ SetWindowTextW(w->main, enctitle);
+ free(enctitle);
free(fulltitle);
}
@@ -1908,7 +1928,7 @@ nserror
nsws_create_main_class(HINSTANCE hinstance)
{
nserror ret = NSERROR_OK;
- WNDCLASSEX wc;
+ WNDCLASSEXW wc;
/* main window */
wc.cbSize = sizeof(WNDCLASSEX);
@@ -1924,7 +1944,7 @@ nsws_create_main_class(HINSTANCE hinstance)
wc.lpszClassName = windowclassname_main;
wc.hIconSm = LoadIcon(hinstance, MAKEINTRESOURCE(IDR_NETSURF_ICON));
- if (RegisterClassEx(&wc) == 0) {
+ if (RegisterClassExW(&wc) == 0) {
win_perror("MainWindowClass");
ret = NSERROR_INIT_FAILED;
}
-----------------------------------------------------------------------
Summary of changes:
frontends/windows/window.c | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 05d7a54..2748080 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -59,7 +59,7 @@
static struct gui_window *window_list = NULL;
/** The main window class name */
-static const char windowclassname_main[] = "nswsmainwindow";
+static const LPCWSTR windowclassname_main = L"nswsmainwindow";
/** width of the throbber element */
#define NSWS_THROBBER_WIDTH 24
@@ -143,9 +143,9 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct
gui_window *gw)
NSLOG(netsurf, INFO,
"creating hInstance %p GUI window %p",
hInstance, gw);
- hwnd = CreateWindowEx(0,
+ hwnd = CreateWindowExW(0,
windowclassname_main,
- "NetSurf Browser",
+ L"NetSurf Browser",
WS_OVERLAPPEDWINDOW |
WS_CLIPCHILDREN |
WS_CLIPSIBLINGS |
@@ -1345,7 +1345,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
*/
GetClientRect(hwnd, &rmain);
PostMessage(hwnd, WM_SIZE, 0, MAKELPARAM(rmain.right,
rmain.bottom));
- return DefWindowProc(hwnd, msg, wparam, lparam);
+ return DefWindowProcW(hwnd, msg, wparam, lparam);
}
@@ -1353,7 +1353,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
if (gw == NULL) {
NSLOG(netsurf, INFO,
"Unable to find gui window structure for hwnd %p", hwnd);
- return DefWindowProc(hwnd, msg, wparam, lparam);
+ return DefWindowProcW(hwnd, msg, wparam, lparam);
}
switch (msg) {
@@ -1386,7 +1386,7 @@ nsws_window_event_callback(HWND hwnd, UINT msg, WPARAM
wparam, LPARAM lparam)
}
- return DefWindowProc(hwnd, msg, wparam, lparam);
+ return DefWindowProcW(hwnd, msg, wparam, lparam);
}
@@ -1529,6 +1529,8 @@ static void win32_window_update_extent(struct gui_window
*gw)
static void win32_window_set_title(struct gui_window *w, const char *title)
{
char *fulltitle;
+ int wlen;
+ LPWSTR enctitle;
if (w == NULL) {
return;
@@ -1537,14 +1539,32 @@ static void win32_window_set_title(struct gui_window
*w, const char *title)
NSLOG(netsurf, INFO, "%p, title %s", w, title);
fulltitle = malloc(strlen(title) + SLEN(" - NetSurf") + 1);
if (fulltitle == NULL) {
- win32_warning("NoMemory", 0);
+ NSLOG(netsurf, ERROR, "%s",
+ messages_get_errorcode(NSERROR_NOMEM));
return;
}
strcpy(fulltitle, title);
strcat(fulltitle, " - NetSurf");
- SendMessage(w->main, WM_SETTEXT, 0, (LPARAM)fulltitle);
+ wlen = MultiByteToWideChar(CP_UTF8, 0, fulltitle, -1, NULL, 0);
+ if (wlen == 0) {
+ NSLOG(netsurf, ERROR, "failed encoding \"%s\"", fulltitle);
+ free(fulltitle);
+ return;
+ }
+
+ enctitle = malloc(2 * (wlen + 1));
+ if (enctitle == NULL) {
+ NSLOG(netsurf, ERROR, "%s encoding \"%s\" len %d",
+ messages_get_errorcode(NSERROR_NOMEM), fulltitle, wlen);
+ free(fulltitle);
+ return;
+ }
+
+ MultiByteToWideChar(CP_UTF8, 0, fulltitle, -1, enctitle, wlen);
+ SetWindowTextW(w->main, enctitle);
+ free(enctitle);
free(fulltitle);
}
@@ -1908,7 +1928,7 @@ nserror
nsws_create_main_class(HINSTANCE hinstance)
{
nserror ret = NSERROR_OK;
- WNDCLASSEX wc;
+ WNDCLASSEXW wc;
/* main window */
wc.cbSize = sizeof(WNDCLASSEX);
@@ -1924,7 +1944,7 @@ nsws_create_main_class(HINSTANCE hinstance)
wc.lpszClassName = windowclassname_main;
wc.hIconSm = LoadIcon(hinstance, MAKEINTRESOURCE(IDR_NETSURF_ICON));
- if (RegisterClassEx(&wc) == 0) {
+ if (RegisterClassExW(&wc) == 0) {
win_perror("MainWindowClass");
ret = NSERROR_INIT_FAILED;
}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org