gdk/win32/gdkevents-win32.c Use wide-char API for message and window

2006-09-04  Tor Lillqvist  <tml@novell.com>

	* gdk/win32/gdkevents-win32.c
	* gdk/win32/gdkwindow-win32.c: Use wide-char API for message and
	window handling (PeekMessage, PostMessage, SendMessage,
	DispatchMessage, DefWindowProc, RegisterClassEx,
	CreateWindowEx). (#321597)
This commit is contained in:
Tor Lillqvist 2006-09-03 22:50:00 +00:00 committed by Tor Lillqvist
parent c5fb65575f
commit 25b98a5935
3 changed files with 69 additions and 62 deletions

View File

@ -1,3 +1,11 @@
2006-09-04 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkevents-win32.c
* gdk/win32/gdkwindow-win32.c: Use wide-char API for message and
window handling (PeekMessage, PostMessage, SendMessage,
DispatchMessage, DefWindowProc, RegisterClassEx,
CreateWindowEx). (#321597)
2006-09-03 Kristian Rietveld <kris@imendio.com> 2006-09-03 Kristian Rietveld <kris@imendio.com>
* gtk/gtkfilechooserdefault.c (save_entry_get_info_cb), * gtk/gtkfilechooserdefault.c (save_entry_get_info_cb),

View File

@ -262,15 +262,15 @@ inner_window_procedure (HWND hwnd,
* the window procedure. * the window procedure.
*/ */
if (modal_win32_dialog) if (modal_win32_dialog)
PostMessage (modal_win32_dialog, got_gdk_events_message, PostMessageW (modal_win32_dialog, got_gdk_events_message,
(WPARAM) 1, 0); (WPARAM) 1, 0);
return ret_val; return ret_val;
} }
else else
{ {
/* Otherwise call DefWindowProc(). */ /* Otherwise call DefWindowProcW(). */
GDK_NOTE (EVENTS, g_print (" DefWindowProc")); GDK_NOTE (EVENTS, g_print (" DefWindowProcW"));
return DefWindowProc (hwnd, message, wparam, lparam); return DefWindowProcW (hwnd, message, wparam, lparam);
} }
} }
@ -417,7 +417,7 @@ gdk_events_pending (void)
MSG msg; MSG msg;
return (_gdk_event_queue_find_first (_gdk_display) || return (_gdk_event_queue_find_first (_gdk_display) ||
(modal_win32_dialog == NULL && (modal_win32_dialog == NULL &&
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))); PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
} }
GdkEvent* GdkEvent*
@ -430,7 +430,7 @@ gdk_event_get_graphics_expose (GdkWindow *window)
GDK_NOTE (EVENTS, g_print ("gdk_event_get_graphics_expose\n")); GDK_NOTE (EVENTS, g_print ("gdk_event_get_graphics_expose\n"));
if (PeekMessage (&msg, GDK_WINDOW_HWND (window), WM_PAINT, WM_PAINT, PM_REMOVE)) if (PeekMessageW (&msg, GDK_WINDOW_HWND (window), WM_PAINT, WM_PAINT, PM_REMOVE))
{ {
handle_wm_paint (&msg, window, TRUE, &event); handle_wm_paint (&msg, window, TRUE, &event);
if (event != NULL) if (event != NULL)
@ -2166,7 +2166,7 @@ gdk_event_translate (MSG *msg,
/* If result is GDK_FILTER_CONTINUE, we continue as if nothing /* If result is GDK_FILTER_CONTINUE, we continue as if nothing
* happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE, * happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
* we return TRUE, and DefWindowProc() will not be called. * we return TRUE, and DefWindowProcW() will not be called.
*/ */
if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE) if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
return TRUE; return TRUE;
@ -2194,12 +2194,11 @@ gdk_event_translate (MSG *msg,
*/ */
GDK_NOTE (EVENTS, g_print (" (posted)")); GDK_NOTE (EVENTS, g_print (" (posted)"));
PostMessage (msg->hwnd, msg->message, PostMessageW (msg->hwnd, msg->message, msg->wParam, msg->lParam);
msg->wParam, msg->lParam);
} }
else if (msg->message == WM_CREATE) else if (msg->message == WM_CREATE)
{ {
window = (UNALIGNED GdkWindow*) (((LPCREATESTRUCT) msg->lParam)->lpCreateParams); window = (UNALIGNED GdkWindow*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams);
GDK_WINDOW_HWND (window) = msg->hwnd; GDK_WINDOW_HWND (window) = msg->hwnd;
} }
else else
@ -2453,7 +2452,7 @@ gdk_event_translate (MSG *msg,
case WM_SYSCHAR: case WM_SYSCHAR:
if (msg->wParam != VK_SPACE) if (msg->wParam != VK_SPACE)
{ {
/* To prevent beeps, don't let DefWindowProc() be called */ /* To prevent beeps, don't let DefWindowProcW() be called */
return_val = TRUE; return_val = TRUE;
goto done; goto done;
} }
@ -3310,7 +3309,7 @@ gdk_event_translate (MSG *msg,
if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE)) if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE))
{ {
/* Don't call DefWindowProc() */ /* Don't call DefWindowProcW() */
GDK_NOTE (EVENTS, g_print (" (handled, mintrack:%ldx%ld maxtrack:%ldx%ld " GDK_NOTE (EVENTS, g_print (" (handled, mintrack:%ldx%ld maxtrack:%ldx%ld "
"maxpos:%+ld%+ld maxsize:%ldx%ld)", "maxpos:%+ld%+ld maxsize:%ldx%ld)",
mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y, mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y,
@ -3505,10 +3504,10 @@ _gdk_events_queue (GdkDisplay *display)
return; return;
while (!_gdk_event_queue_find_first (display) && while (!_gdk_event_queue_find_first (display) &&
PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
{ {
TranslateMessage (&msg); TranslateMessage (&msg);
DispatchMessage (&msg); DispatchMessageW (&msg);
} }
} }
@ -3525,7 +3524,7 @@ gdk_event_prepare (GSource *source,
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL || retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
(modal_win32_dialog == NULL && (modal_win32_dialog == NULL &&
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))); PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
GDK_THREADS_LEAVE (); GDK_THREADS_LEAVE ();
@ -3543,7 +3542,7 @@ gdk_event_check (GSource *source)
if (event_poll_fd.revents & G_IO_IN) if (event_poll_fd.revents & G_IO_IN)
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL || retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
(modal_win32_dialog == NULL && (modal_win32_dialog == NULL &&
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))); PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
else else
retval = FALSE; retval = FALSE;
@ -3600,7 +3599,7 @@ gdk_event_send_client_message_for_display (GdkDisplay *display,
{ {
check_for_too_much_data (event); check_for_too_much_data (event);
return PostMessage ((HWND) winid, client_message, return PostMessageW ((HWND) winid, client_message,
(WPARAM) event->client.message_type, (WPARAM) event->client.message_type,
event->client.data.l[0]); event->client.data.l[0]);
} }
@ -3611,7 +3610,7 @@ gdk_screen_broadcast_client_message (GdkScreen *screen,
{ {
check_for_too_much_data (event); check_for_too_much_data (event);
PostMessage (HWND_BROADCAST, client_message, PostMessageW (HWND_BROADCAST, client_message,
(WPARAM) event->client.message_type, (WPARAM) event->client.message_type,
event->client.data.l[0]); event->client.data.l[0]);
} }
@ -3623,10 +3622,10 @@ gdk_flush (void)
MSG msg; MSG msg;
/* Process all messages currently available */ /* Process all messages currently available */
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
{ {
TranslateMessage (&msg); TranslateMessage (&msg);
DispatchMessage (&msg); DispatchMessageW (&msg);
} }
#endif #endif
@ -3641,8 +3640,8 @@ gdk_display_sync (GdkDisplay * display)
g_return_if_fail (display == _gdk_display); g_return_if_fail (display == _gdk_display);
/* Process all messages currently available */ /* Process all messages currently available */
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
DispatchMessage (&msg); DispatchMessageW (&msg);
} }
void void

View File

@ -368,7 +368,7 @@ RegisterGdkClass (GdkWindowType wtype)
static ATOM klassCHILD = 0; static ATOM klassCHILD = 0;
static ATOM klassTEMP = 0; static ATOM klassTEMP = 0;
static HICON hAppIcon = NULL; static HICON hAppIcon = NULL;
static WNDCLASSEX wcl; static WNDCLASSEXW wcl;
ATOM klass = 0; ATOM klass = 0;
wcl.cbSize = sizeof (WNDCLASSEX); wcl.cbSize = sizeof (WNDCLASSEX);
@ -418,10 +418,10 @@ RegisterGdkClass (GdkWindowType wtype)
case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TOPLEVEL:
if (0 == klassTOPLEVEL) if (0 == klassTOPLEVEL)
{ {
wcl.lpszClassName = "gdkWindowToplevel"; wcl.lpszClassName = L"gdkWindowToplevel";
ONCE_PER_CLASS (); ONCE_PER_CLASS ();
klassTOPLEVEL = RegisterClassEx (&wcl); klassTOPLEVEL = RegisterClassExW (&wcl);
} }
klass = klassTOPLEVEL; klass = klassTOPLEVEL;
break; break;
@ -429,11 +429,11 @@ RegisterGdkClass (GdkWindowType wtype)
case GDK_WINDOW_CHILD: case GDK_WINDOW_CHILD:
if (0 == klassCHILD) if (0 == klassCHILD)
{ {
wcl.lpszClassName = "gdkWindowChild"; wcl.lpszClassName = L"gdkWindowChild";
wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */ wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */
ONCE_PER_CLASS (); ONCE_PER_CLASS ();
klassCHILD = RegisterClassEx (&wcl); klassCHILD = RegisterClassExW (&wcl);
} }
klass = klassCHILD; klass = klassCHILD;
break; break;
@ -441,10 +441,10 @@ RegisterGdkClass (GdkWindowType wtype)
case GDK_WINDOW_DIALOG: case GDK_WINDOW_DIALOG:
if (0 == klassDIALOG) if (0 == klassDIALOG)
{ {
wcl.lpszClassName = "gdkWindowDialog"; wcl.lpszClassName = L"gdkWindowDialog";
wcl.style |= CS_SAVEBITS; wcl.style |= CS_SAVEBITS;
ONCE_PER_CLASS (); ONCE_PER_CLASS ();
klassDIALOG = RegisterClassEx (&wcl); klassDIALOG = RegisterClassExW (&wcl);
} }
klass = klassDIALOG; klass = klassDIALOG;
break; break;
@ -452,10 +452,10 @@ RegisterGdkClass (GdkWindowType wtype)
case GDK_WINDOW_TEMP: case GDK_WINDOW_TEMP:
if (0 == klassTEMP) if (0 == klassTEMP)
{ {
wcl.lpszClassName = "gdkWindowTemp"; wcl.lpszClassName = L"gdkWindowTemp";
wcl.style |= CS_SAVEBITS; wcl.style |= CS_SAVEBITS;
ONCE_PER_CLASS (); ONCE_PER_CLASS ();
klassTEMP = RegisterClassEx (&wcl); klassTEMP = RegisterClassExW (&wcl);
} }
klass = klassTEMP; klass = klassTEMP;
break; break;
@ -467,7 +467,7 @@ RegisterGdkClass (GdkWindowType wtype)
if (klass == 0) if (klass == 0)
{ {
WIN32_API_FAILED ("RegisterClassEx"); WIN32_API_FAILED ("RegisterClassExW");
g_error ("That is a fatal error"); g_error ("That is a fatal error");
} }
return klass; return klass;
@ -491,7 +491,7 @@ gdk_window_new_internal (GdkWindow *parent,
GdkDrawableImplWin32 *draw_impl; GdkDrawableImplWin32 *draw_impl;
GdkVisual *visual; GdkVisual *visual;
const gchar *title; const gchar *title;
char *mbtitle; wchar_t *wtitle;
gint window_width, window_height; gint window_width, window_height;
gint offset_x = 0, offset_y = 0; gint offset_x = 0, offset_y = 0;
@ -681,11 +681,11 @@ gdk_window_new_internal (GdkWindow *parent,
klass = RegisterGdkClass (private->window_type); klass = RegisterGdkClass (private->window_type);
mbtitle = g_locale_from_utf8 (title, -1, NULL, NULL, NULL); wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
hwndNew = CreateWindowEx (dwExStyle, hwndNew = CreateWindowExW (dwExStyle,
MAKEINTRESOURCE (klass), MAKEINTRESOURCEW (klass),
mbtitle, wtitle,
dwStyle, dwStyle,
((attributes_mask & GDK_WA_X) ? ((attributes_mask & GDK_WA_X) ?
impl->position_info.x - offset_x : CW_USEDEFAULT), impl->position_info.x - offset_x : CW_USEDEFAULT),
@ -721,7 +721,7 @@ gdk_window_new_internal (GdkWindow *parent,
gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window); gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n", GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n",
mbtitle, title,
window_width, window_height, window_width, window_height,
((attributes_mask & GDK_WA_X) ? ((attributes_mask & GDK_WA_X) ?
impl->position_info.x - offset_x: CW_USEDEFAULT), impl->position_info.x - offset_x: CW_USEDEFAULT),
@ -729,11 +729,11 @@ gdk_window_new_internal (GdkWindow *parent,
hparent, hparent,
GDK_WINDOW_HWND (window))); GDK_WINDOW_HWND (window)));
g_free (mbtitle); g_free (wtitle);
if (draw_impl->handle == NULL) if (draw_impl->handle == NULL)
{ {
WIN32_API_FAILED ("CreateWindowEx"); WIN32_API_FAILED ("CreateWindowExW");
g_object_unref (window); g_object_unref (window);
return NULL; return NULL;
} }
@ -1440,7 +1440,7 @@ _gdk_windowing_window_clear_area (GdkWindow *window,
width, height, x, y)); width, height, x, y));
hdc = GetDC (GDK_WINDOW_HWND (window)); hdc = GetDC (GDK_WINDOW_HWND (window));
IntersectClipRect (hdc, x, y, x + width + 1, y + height + 1); IntersectClipRect (hdc, x, y, x + width + 1, y + height + 1);
SendMessage (GDK_WINDOW_HWND (window), WM_ERASEBKGND, (WPARAM) hdc, 0); SendMessageW (GDK_WINDOW_HWND (window), WM_ERASEBKGND, (WPARAM) hdc, 0);
GDI_CALL (ReleaseDC, (GDK_WINDOW_HWND (window), hdc)); GDI_CALL (ReleaseDC, (GDK_WINDOW_HWND (window), hdc));
} }
} }
@ -2509,9 +2509,9 @@ gdk_window_set_icon_list (GdkWindow *window,
small_hicon = _gdk_win32_pixbuf_to_hicon (small_pixbuf); small_hicon = _gdk_win32_pixbuf_to_hicon (small_pixbuf);
/* Set the icons */ /* Set the icons */
SendMessage (GDK_WINDOW_HWND (window), WM_SETICON, ICON_BIG, SendMessageW (GDK_WINDOW_HWND (window), WM_SETICON, ICON_BIG,
(LPARAM)big_hicon); (LPARAM)big_hicon);
SendMessage (GDK_WINDOW_HWND (window), WM_SETICON, ICON_SMALL, SendMessageW (GDK_WINDOW_HWND (window), WM_SETICON, ICON_SMALL,
(LPARAM)small_hicon); (LPARAM)small_hicon);
/* Store the icons, destroying any previous icons */ /* Store the icons, destroying any previous icons */
@ -2941,7 +2941,7 @@ gdk_window_begin_resize_drag (GdkWindow *window,
break; break;
} }
DefWindowProc (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, winedge, DefWindowProcW (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, winedge,
MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y)); MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
} }
@ -2971,7 +2971,7 @@ gdk_window_begin_move_drag (GdkWindow *window,
*/ */
gdk_display_pointer_ungrab (_gdk_display, 0); gdk_display_pointer_ungrab (_gdk_display, 0);
DefWindowProc (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, HTCAPTION, DefWindowProcW (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, HTCAPTION,
MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y)); MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
} }