Mercurial > dwindows
changeset 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 | d78f476c40f5 |
files | compat.h os2/dirent.c os2/dw.c win/dirent.c win/dw.c |
diffstat | 5 files changed, 100 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/compat.h Tue Mar 23 10:10:27 2004 +0000 +++ b/compat.h Tue Mar 23 11:00:04 2004 +0000 @@ -121,6 +121,11 @@ /* Windows */ #if defined(__WIN32__) || defined(WINNT) + +#if defined(MSVC) && !defined(API) +#define API _cdecl +#endif + #include <windows.h> #include <winsock.h> #include <time.h> @@ -134,10 +139,6 @@ #endif #include <stdarg.h> -#if defined(MSVC) && !defined(API) -#define API _cdecl -#endif - #if defined(__CYGWIN32__) || defined(__MINGW32__) #include <sys/un.h> #endif /* __CYGWIN32__ || __MINGW32__ */
--- a/os2/dirent.c Tue Mar 23 10:10:27 2004 +0000 +++ b/os2/dirent.c Tue Mar 23 11:00:04 2004 +0000 @@ -5,8 +5,7 @@ #define INCL_DOSFILEMGR #define INCL_DOSERRORS -#include "dw.h" -#include "platform/dirent.h" +#include "compat" #include <errno.h> # define FFBUF FILEFINDBUF3
--- a/os2/dw.c Tue Mar 23 10:10:27 2004 +0000 +++ b/os2/dw.c Tue Mar 23 11:00:04 2004 +0000 @@ -7615,6 +7615,18 @@ WinReleasePS(hpssrc); } +/* Run DosBeep() in a separate thread so it doesn't block */ +void _beepthread(void *data) +{ + int *info = (int *)data; + + if(data) + { + DosBeep(info[0], info[1]); + free(data); + } +} + /* * Emits a beep. * Parameters: @@ -7623,7 +7635,15 @@ */ void API dw_beep(int freq, int dur) { - DosBeep(freq, dur); + int *info = malloc(sizeof(int) * 2); + + if(info) + { + info[0] = freq; + info[1] = dur; + + _beginthread(_beepthread, NULL, 100, (void *)info); + } } /* Open a shared library and return a handle.
--- a/win/dirent.c Tue Mar 23 10:10:27 2004 +0000 +++ b/win/dirent.c Tue Mar 23 11:00:04 2004 +0000 @@ -5,7 +5,7 @@ #include <windows.h> -#include "dirent.h" +#include "compat.h" #include <errno.h> #define error(rc) errno = 255 @@ -25,8 +25,7 @@ /* * Return first char of filesystem type, or 0 if unknown. */ -static char -getFSType(const char *path) +static char API getFSType(const char *path) { static char cache[1+26]; char drive[3]; @@ -56,7 +55,7 @@ return cache [unit] = r; } -char *abs_path(const char *name, char *buffer, int len) +char * API abs_path(const char *name, char *buffer, int len) { char *buf; LPTSTR file; @@ -81,7 +80,7 @@ return NULL; } -DIR *openxdir(const char *path, unsigned att_mask) +DIR * API openxdir(const char *path, unsigned att_mask) { DIR *dir; char name[MAXPATHLEN+3]; @@ -127,14 +126,12 @@ return (DIR *)dir; } -DIR * -opendir(const char *pathname) +DIR * API opendir(const char *pathname) { return openxdir(pathname, 0); } -struct dirent * -readdir(DIR *dir) +struct dirent * API readdir(DIR *dir) { static int dummy_ino = 2; @@ -167,14 +164,12 @@ return &dir->entry; } -long -telldir(DIR *dir) +long API telldir(DIR *dir) { return dir->number; } -void -seekdir(DIR *dir, long off) +void API seekdir(DIR *dir, long off) { if (dir->number > off) { char name[MAXPATHLEN+2]; @@ -199,8 +194,7 @@ ; } -void -closedir(DIR *dir) +void API closedir(DIR *dir) { FindClose(dir->handle); free(dir);
--- 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.