Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- h src/win/wdispsw.c | 15 +++++++++++----
- src/win/wwnd.c | 54 ++++++++++++++++++++++++++++++++----------------------
- 2 files changed, 43 insertions(+), 26 deletions(-)
- diff --git a/src/win/wdispsw.c b/src/win/wdispsw.c
- index 8707ea1a8..375a6789a 100644
- --- a/src/win/wdispsw.c
- +++ b/src/win/wdispsw.c
- @@ -111,6 +111,8 @@ void _win_switch_in(void)
- _TRACE(PREFIX_I "switch in\n");
- + _enter_gfx_critical();
- +
- _win_app_foreground = TRUE;
- key_dinput_acquire();
- @@ -132,6 +134,7 @@ void _win_switch_in(void)
- }
- _switch_in();
- + _exit_gfx_critical();
- }
- @@ -145,6 +148,10 @@ void _win_switch_out(void)
- _TRACE(PREFIX_I "switch out\n");
- + _enter_gfx_critical();
- +
- + _switch_out();
- +
- _win_app_foreground = FALSE;
- key_dinput_unacquire();
- @@ -165,11 +172,11 @@ void _win_switch_out(void)
- /* if the thread doesn't stop, lower its priority only if another window is active */
- allegro_thread_priority = GetThreadPriority(allegro_thread);
- - if ((HINSTANCE)GetWindowLongPtr(GetForegroundWindow(), GWLP_HINSTANCE) != allegro_inst)
- - SetThreadPriority(allegro_thread, THREAD_PRIORITY_LOWEST);
- + if ((HINSTANCE)GetWindowLong(GetForegroundWindow(), GWL_HINSTANCE) != allegro_inst)
- + SetThreadPriority(allegro_thread, THREAD_PRIORITY_LOWEST);
- }
- -
- - _switch_out();
- +
- + _exit_gfx_critical();
- }
- diff --git a/src/win/wwnd.c b/src/win/wwnd.c
- index f5eccaae1..6bb342d9e 100644
- --- a/src/win/wwnd.c
- +++ b/src/win/wwnd.c
- @@ -1,6 +1,6 @@
- -/* ______ ___ ___
- - * /\ _ \ /\_ \ /\_ \
- - * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
- +/* ______ ___ ___
- + * /\ _ \ /\_ \ /\_ \
- + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
- * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
- * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
- * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
- @@ -19,6 +19,7 @@
- #include "allegro.h"
- #include "allegro/internal/aintern.h"
- #include "allegro/platform/aintwin.h"
- +#include "wddraw.h"
- #ifndef SCAN_DEPEND
- #include <string.h>
- @@ -189,7 +190,7 @@ static void exit_window_modules(struct WINDOW_MODULES *wm)
- */
- int wnd_call_proc(int (*proc) (void))
- {
- - return SendMessage(allegro_wnd, msg_call_proc, (WPARAM)proc, (LPARAM)0);
- + return SendMessage(allegro_wnd, msg_call_proc, (DWORD) proc, 0);
- }
- @@ -200,7 +201,7 @@ int wnd_call_proc(int (*proc) (void))
- */
- void wnd_schedule_proc(int (*proc) (void))
- {
- - PostMessage(allegro_wnd, msg_call_proc, (WPARAM)proc, (LPARAM)0);
- + PostMessage(allegro_wnd, msg_call_proc, (DWORD) proc, 0);
- }
- @@ -213,7 +214,7 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
- PAINTSTRUCT ps;
- if (message == msg_call_proc)
- - return ( ( LRESULT(*)( void ) )wparam ) ( );
- + return ((int (*)(void))wparam) ();
- if (message == msg_suicide) {
- DestroyWindow(wnd);
- @@ -224,7 +225,7 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
- if (wnd_msg_pre_proc){
- int retval = 0;
- if (wnd_msg_pre_proc(wnd, message, wparam, lparam, &retval) == 0)
- - return (LRESULT)retval;
- + return retval;
- }
- /* See get_reverse_mapping() in wkeybd.c to see what this is for. */
- @@ -373,7 +374,7 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
- case WM_MENUCHAR :
- return (MNC_CLOSE<<16)|(wparam&0xffff);
- -
- +
- case WM_CLOSE:
- if (!user_wnd_proc) {
- if (user_close_proc)
- @@ -381,6 +382,14 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
- return 0;
- }
- break;
- +
- + case WM_QUERYNEWPALETTE:
- + case WM_PALETTECHANGED:
- + if ((HWND)wparam != wnd && gfx_directx_primary_surface) {
- + IDirectDrawSurface2_SetPalette(gfx_directx_primary_surface->id, ddpalette);
- + InvalidateRect(wnd, NULL, 1);
- + }
- + return 1;
- }
- /* pass message to default window proc */
- @@ -442,6 +451,7 @@ static HWND create_directx_window(void)
- return NULL;
- }
- + SetSystemPaletteUse(GetDC(wnd), SYSPAL_NOSTATIC256);
- ShowWindow(wnd, SW_SHOWNORMAL);
- SetForegroundWindow(wnd);
- UpdateWindow(wnd);
- @@ -456,7 +466,7 @@ static HWND create_directx_window(void)
- */
- static void wnd_thread_proc(HANDLE setup_event)
- {
- - DWORD result;
- + int result;
- MSG msg;
- _win_thread_init();
- @@ -477,7 +487,7 @@ static void wnd_thread_proc(HANDLE setup_event)
- /* message loop */
- while (TRUE) {
- result = MsgWaitForMultipleObjects(_win_input_events, _win_input_event_id, FALSE, INFINITE, QS_ALLINPUT);
- - if ((result >= WAIT_OBJECT_0) && (result < (int)(WAIT_OBJECT_0 + _win_input_events))) {
- + if ((result >= WAIT_OBJECT_0) && (result < WAIT_OBJECT_0 + _win_input_events)) {
- /* one of the registered events is in signaled state */
- (*_win_input_event_handler[result - WAIT_OBJECT_0])();
- }
- @@ -518,12 +528,15 @@ int init_directx_window(void)
- msg_call_proc = RegisterWindowMessage("Allegro call proc");
- msg_suicide = RegisterWindowMessage("Allegro window suicide");
- + /* initialize gfx critical section */
- + InitializeCriticalSection(&gfx_crit_sect);
- +
- if (user_wnd) {
- /* initializes input module and requests dedicated thread */
- _win_input_init(TRUE);
- /* hook the user window */
- - user_wnd_proc = (WNDPROC) SetWindowLongPtr(user_wnd, GWLP_WNDPROC, (LONG_PTR)directx_wnd_proc);
- + user_wnd_proc = (WNDPROC) SetWindowLong(user_wnd, GWL_WNDPROC, (long)directx_wnd_proc);
- if (!user_wnd_proc)
- return -1;
- @@ -557,12 +570,9 @@ int init_directx_window(void)
- default: /* thread failed to create window */
- return -1;
- - }
- + }
- }
- - /* initialize gfx critical section */
- - InitializeCriticalSection(&gfx_crit_sect);
- -
- /* save window style */
- old_style = GetWindowLong(allegro_wnd, GWL_STYLE);
- @@ -579,7 +589,7 @@ void exit_directx_window(void)
- {
- if (user_wnd) {
- /* restore old window proc */
- - SetWindowLongPtr(user_wnd, GWLP_WNDPROC, (LONG_PTR)user_wnd_proc);
- + SetWindowLong(user_wnd, GWL_WNDPROC, (long)user_wnd_proc);
- user_wnd_proc = NULL;
- user_wnd = NULL;
- allegro_wnd = NULL;
- @@ -598,7 +608,7 @@ void exit_directx_window(void)
- DeleteCriticalSection(&gfx_crit_sect);
- _win_input_exit();
- -
- +
- window_is_initialized = FALSE;
- }
- @@ -651,11 +661,11 @@ int adjust_window(int w, int h)
- }
- if (!user32_handle || !get_title_bar_info)
- tb_height = GetSystemMetrics(SM_CYSIZE);
- -
- +
- /* try to center the window relative to its last position */
- last_wnd_x += (last_w - w)/2;
- last_wnd_y += (last_h - h)/2;
- -
- +
- if (last_wnd_x + w >= working_area.right)
- last_wnd_x = working_area.right - w;
- if (last_wnd_y + h >= working_area.bottom)
- @@ -680,7 +690,7 @@ int adjust_window(int w, int h)
- /* retrieve the size of the decorated window */
- AdjustWindowRect(&win_size, GetWindowLong(allegro_wnd, GWL_STYLE), FALSE);
- -
- +
- /* display the window */
- MoveWindow(allegro_wnd, win_size.left, win_size.top,
- win_size.right - win_size.left, win_size.bottom - win_size.top, TRUE);
- @@ -702,7 +712,7 @@ int adjust_window(int w, int h)
- /* save_window_pos:
- - * Stores the position of the current window before closing it so that
- + * Stores the position of the current window before closing it so that
- * it can be used as the initial position for the next window.
- */
- void save_window_pos(void)
- @@ -746,7 +756,7 @@ void win_set_window(HWND wnd)
- init_directx_window();
- init_window_modules(&wm);
- }
- -
- +
- window_is_initialized = TRUE;
- }
Add Comment
Please, Sign In to add comment