Mercurial > dwindows
diff win/dw.c @ 527:e0ea29c3d1eb
Fixed dw_window_pointer() so it works on Windows. Tried to fix the
timer problems on Windows, but only managed to reduce the problem and
eliminate obsolete timer code. Fixed a calling convention problem
caused by incorrect placement of the definition of API in the compat.h
header. Make dw_beep() not block on OS/2 and Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 23 Mar 2004 11:00:04 +0000 |
parents | d3ce0afa6cf5 |
children | 79696a852401 |
line wrap: on
line diff
--- a/win/dw.c Tue Mar 23 10:10:27 2004 +0000 +++ b/win/dw.c Tue Mar 23 11:00:04 2004 +0000 @@ -21,7 +21,7 @@ #include <time.h> #include "dw.h" -HWND popup = (HWND)NULL, hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL; +HWND popup = (HWND)NULL, hwndBubble = (HWND)NULL, DW_HWND_OBJECT = (HWND)NULL; HINSTANCE DWInstance = NULL; @@ -1430,17 +1430,20 @@ switch(msg) { case WM_TIMER: - { - int (*timerfunc)(void *) = tmp->signalfunction; - if(tmp->id == (int)mp1) { - if(!timerfunc(tmp->data)) - dw_timer_disconnect(tmp->id); - tmp = NULL; + if(!hWnd) + { + int (*timerfunc)(void *) = tmp->signalfunction; + if(tmp->id == (int)mp1) + { + if(!timerfunc(tmp->data)) + dw_timer_disconnect(tmp->id); + tmp = NULL; + } + } + result = 0; } - result = 0; - } - break; + break; case WM_SETFOCUS: { int (*setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; @@ -1942,6 +1945,17 @@ EnumChildWindows(hWnd, _free_window_memory, 0); } break; + case WM_MOUSEMOVE: + { + HCURSOR cursor; + + if((cursor = (HCURSOR)dw_window_get_data(hWnd, "_dw_cursor")) || + (cursor = (HCURSOR)dw_window_get_data(_toplevel_window(hWnd), "_dw_cursor"))) + { + SetCursor(cursor); + } + } + break; case WM_CTLCOLORSTATIC: case WM_CTLCOLORLISTBOX: case WM_CTLCOLORBTN: @@ -2034,6 +2048,7 @@ break; case WM_COMMAND: case WM_NOTIFY: + case WM_MOUSEMOVE: _wndproc(hWnd, msg, mp1, mp2); break; #if 0 @@ -2150,6 +2165,9 @@ cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); + if(msg == WM_MOUSEMOVE) + _wndproc(hWnd, msg, mp1, mp2); + if(cinfo) { switch( msg ) @@ -2295,6 +2313,9 @@ if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) cinfo = &(((Box *)cinfo)->cinfo); + if(msg == WM_MOUSEMOVE) + _wndproc(hWnd, msg, mp1, mp2); + if(cinfo) { pOldProc = cinfo->pOldProc; @@ -2504,6 +2525,7 @@ { case WM_COMMAND: case WM_NOTIFY: + case WM_MOUSEMOVE: _wndproc(hWnd, msg, mp1, mp2); break; case WM_LBUTTONDBLCLK: @@ -2619,6 +2641,9 @@ switch( msg ) { + case WM_MOUSEMOVE: + _wndproc(hWnd, msg, mp1, mp2); + break; case WM_CHAR: if(LOWORD(mp1) == '\t') { @@ -2825,6 +2850,9 @@ { switch (msg) { + case WM_MOUSEMOVE: + _wndproc(hwnd, msg, mp1, mp2); + break; case WM_SETTEXT: { /* Make sure the control redraws when there is a text change */ @@ -2976,16 +3004,6 @@ if(mp1 == VK_RIGHT || mp1 == VK_DOWN) _shift_focus(hwnd); break; - case WM_TIMER: - if (hwndBubble) - { - _free_window_memory(hwndBubble, 0); - DestroyWindow(hwndBubble); - hwndBubble = 0; - KillTimer(hwnd, 1); - } - break; - case WM_MOUSEMOVE: GetCursorPos(&point); GetWindowRect(hwnd, &rect); @@ -3007,7 +3025,6 @@ _free_window_memory(hwndBubble, 0); DestroyWindow(hwndBubble); hwndBubble = 0; - KillTimer(hwndBubbleLast, 1); } if(!hwndBubble) @@ -3039,8 +3056,6 @@ dw_window_set_font(hwndBubble, DefaultFont); dw_window_set_color(hwndBubble, DW_CLR_BLACK, DW_CLR_YELLOW); - hwndBubbleLast = hwnd; - SetTimer(hwnd, 1, 3000, NULL); hFont = (HFONT)SendMessage(hwndBubble, WM_GETFONT, 0, 0); @@ -3083,9 +3098,9 @@ _free_window_memory(hwndBubble, 0); DestroyWindow(hwndBubble); hwndBubble = 0; - KillTimer(hwndBubbleLast, 1); } } + _wndproc(hwnd, msg, mp1, mp2); break; case WM_CAPTURECHANGED: /* This message means we are losing the capture for some reason @@ -3098,7 +3113,6 @@ _free_window_memory(hwndBubble, 0); DestroyWindow(hwndBubble); hwndBubble = 0; - KillTimer(hwndBubbleLast, 1); } break; } @@ -3747,14 +3761,10 @@ */ void API dw_window_set_pointer(HWND handle, int pointertype) { -/* - if(pointertype == DW_POINTER_ARROW) - SetClassLong( handle, GCL_HCURSOR, LoadCursor( NULL, IDC_ARROW)); - else if(pointertype == DW_POINTER_CLOCK) - SetClassLong( handle, GCL_HCURSOR, LoadCursor( NULL, IDC_WAIT)); - else -*/ - SetCursor(pointertype < 65536 ? LoadCursor(NULL, MAKEINTRESOURCE(pointertype)) : (HCURSOR)pointertype); + HCURSOR cursor = pointertype < 65536 ? LoadCursor(NULL, MAKEINTRESOURCE(pointertype)) : (HCURSOR)pointertype; + + dw_window_set_data(handle, "_dw_cursor", (void *)cursor); + SetCursor(cursor); } /* @@ -7606,6 +7616,18 @@ ReleaseDC(src, hdcsrc); } +/* Run Beep() in a separate thread so it doesn't block */ +void _beepthread(void *data) +{ + int *info = (int *)data; + + if(data) + { + Beep(info[0], info[1]); + free(data); + } +} + /* * Emits a beep. * Parameters: @@ -7614,7 +7636,15 @@ */ void API dw_beep(int freq, int dur) { - Beep(freq, dur); + int *info = malloc(sizeof(int) * 2); + + if(info) + { + info[0] = freq; + info[1] = dur; + + _beginthread(_beepthread, 100, (void *)info); + } } /* Open a shared library and return a handle.