Handle WM_ACTIVATEAPP message under WIN32, using GetAsyncKeyState() for

all of the key and button states in FLTK.

SunOS 4.x changes (check for <sys/stdtypes.h> and don't rely on
realloc(NULL, size) working - this doesn't work on a lot of platforms!)

Fix nesting of #ifdefs in vsnprintf.c - the C++ wrapper stuff wasn't
being included outside the checks for the individual functions...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1444 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2001-04-27 14:39:27 +00:00
parent 36b469928e
commit ff3295f036
6 changed files with 75 additions and 21 deletions

View File

@ -18,6 +18,11 @@ CHANGES SINCE FLTK 1.0.10
- Added support for AIX (static library only).
- Added support for SunOS 4.x
- Now process WIN32 WM_ACTIVATEAPP message to reset the
key and button states in Fl::e_state.
- Fl_has_idle only tested N-1 callbacks and missed one.
- Restored WM_SYNCPAINT handling under WIN32; this fixed

View File

@ -1,5 +1,5 @@
/*
* "$Id: configh.in,v 1.11.2.8 2001/02/12 15:12:14 easysw Exp $"
* "$Id: configh.in,v 1.11.2.9 2001/04/27 14:39:27 easysw Exp $"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
* @configure_input@
@ -137,7 +137,7 @@
#define HAVE_VSPRINTF 0
/*
* String functions...
* String functions and headers...
*/
#define HAVE_STRINGS_H 0
@ -151,6 +151,14 @@
#define HAVE_SYS_SELECT_H 0
/*
* HAVE_SYS_STDTYPES_H:
*
* Whether or not we have the <sys/stdtypes.h> header file.
*/
#define HAVE_SYS_STDTYPES_H 0
/*
* USE_POLL:
*
@ -160,5 +168,5 @@
#define USE_POLL 0
/*
* End of "$Id: configh.in,v 1.11.2.8 2001/02/12 15:12:14 easysw Exp $".
* End of "$Id: configh.in,v 1.11.2.9 2001/04/27 14:39:27 easysw Exp $".
*/

View File

@ -1,7 +1,7 @@
dnl -*- sh -*-
dnl the "configure" script is made from this by running GNU "autoconf"
dnl
dnl "$Id: configure.in,v 1.33.2.27 2001/04/25 13:34:43 easysw Exp $"
dnl "$Id: configure.in,v 1.33.2.28 2001/04/27 14:39:27 easysw Exp $"
dnl
dnl Configuration script for the Fast Light Tool Kit (FLTK).
dnl
@ -136,6 +136,7 @@ fi
AC_HEADER_DIRENT
AC_CHECK_HEADER(sys/select.h)
AC_CHECK_HEADER(sys/stdtypes.h)
AC_CHECK_FUNC(scandir,
if test "$uname" = SunOS -o "$uname" = QNX; then
echo Not using $uname scandir emulation function.
@ -371,5 +372,5 @@ AC_CONFIG_HEADER(config.h:configh.in)
AC_OUTPUT(makeinclude)
dnl
dnl End of "$Id: configure.in,v 1.33.2.27 2001/04/25 13:34:43 easysw Exp $".
dnl End of "$Id: configure.in,v 1.33.2.28 2001/04/27 14:39:27 easysw Exp $".
dnl

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_win32.cxx,v 1.33.2.33 2001/04/22 16:54:23 spitzak Exp $"
// "$Id: Fl_win32.cxx,v 1.33.2.34 2001/04/27 14:39:27 easysw Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
@ -418,8 +418,6 @@ static Fl_Window* resize_bug_fix;
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
#if 1
// Matt: When dragging a full window, MSWindows on 'slow'
// machines can lose track of the window refresh area. It sends some kind
// of panic message to the desktop that in turn sends this message on to
@ -434,7 +432,6 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
cnt = 0;
} else cnt = 1;
} else if (uMsg == WM_PAINT) cnt = 0;
#endif
fl_msg.message = uMsg;
@ -510,6 +507,30 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
}
break;
case WM_ACTIVATEAPP:
// From eric@vfx.sel.sony.com, we should process WM_ACTIVATEAPP
// messages to restore the correct state of the shift/ctrl/alt/lock
// keys... Added control, shift, alt, and meta keys, mouse buttons,
// and changed to use GetAsyncKeyState...
if (!wParam)
{
ulong state = 0;
if (GetAsyncKeyState(VK_CAPITAL)) state |= FL_CAPS_LOCK;
if (GetAsyncKeyState(VK_NUMLOCK)) state |= FL_NUM_LOCK;
if (GetAsyncKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK;
if (GetAsyncKeyState(VK_CONTROL)) state |= FL_CTRL;
if (GetAsyncKeyState(VK_SHIFT)) state |= FL_SHIFT;
if (GetAsyncKeyState(VK_MENU)) state |= FL_ALT;
if (GetAsyncKeyState(VK_LWIN) ||
GetAsyncKeyState(VK_RWIN)) state |= FL_META;
if (GetAsyncKeyState(VK_LBUTTON)) state |= FL_BUTTON1;
if (GetAsyncKeyState(VK_MBUTTON)) state |= FL_BUTTON2;
if (GetAsyncKeyState(VK_RBUTTON)) state |= FL_BUTTON3;
Fl::e_state = state;
return 0;
}
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
@ -955,5 +976,5 @@ void Fl_Window::make_current() {
}
//
// End of "$Id: Fl_win32.cxx,v 1.33.2.33 2001/04/22 16:54:23 spitzak Exp $".
// End of "$Id: Fl_win32.cxx,v 1.33.2.34 2001/04/27 14:39:27 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_x.cxx,v 1.24.2.23 2001/01/22 15:13:40 easysw Exp $"
// "$Id: Fl_x.cxx,v 1.24.2.24 2001/04/27 14:39:27 easysw Exp $"
//
// X specific code for the Fast Light Tool Kit (FLTK).
//
@ -69,23 +69,38 @@ static int maxfd;
static int nfds = 0;
static int fd_array_size = 0;
static struct FD {
struct FD {
#if !USE_POLL
int fd;
short events;
#endif
void (*cb)(int, void*);
void* arg;
} *fd = 0;
};
static FD *fd = 0;
void Fl::add_fd(int n, int events, void (*cb)(int, void*), void *v) {
remove_fd(n,events);
int i = nfds++;
if (i >= fd_array_size) {
FD *temp;
fd_array_size = 2*fd_array_size+1;
fd = (FD*)realloc(fd, fd_array_size*sizeof(FD));
if (!fd) temp = (FD*)malloc(fd_array_size*sizeof(FD));
else temp = (FD*)realloc(fd, fd_array_size*sizeof(FD));
if (!temp) return;
fd = temp;
#if USE_POLL
pollfds = (pollfd*)realloc(pollfds, fd_array_size*sizeof(pollfd));
pollfd *tpoll;
if (!pollfds) tpoll = (pollfd*)malloc(fd_array_size*sizeof(pollfd));
else tpoll = (pollfd*)realloc(pollfds, fd_array_size*sizeof(pollfd));
if (!tpoll) return;
pollfds = tpoll;
#endif
}
fd[i].cb = cb;
@ -903,5 +918,5 @@ void Fl_Window::make_current() {
#endif
//
// End of "$Id: Fl_x.cxx,v 1.24.2.23 2001/01/22 15:13:40 easysw Exp $".
// End of "$Id: Fl_x.cxx,v 1.24.2.24 2001/04/27 14:39:27 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
/*
* "$Id: vsnprintf.c,v 1.3.2.4 2001/01/22 15:13:41 easysw Exp $"
* "$Id: vsnprintf.c,v 1.3.2.5 2001/04/27 14:39:27 easysw Exp $"
*
* vsnprintf() function for the Fast Light Tool Kit (FLTK).
*
@ -41,12 +41,16 @@
#include <stdarg.h>
#include <config.h>
#if !HAVE_VSNPRINTF
#ifdef HAVE_SYS_STDTYPES_H
# include <sys/stdtypes.h>
#endif /* HAVE_SYS_STDTYPES_H */
#ifdef __cplusplus
extern "C" {
#endif
#if !HAVE_VSNPRINTF
int vsnprintf(char* str, size_t size, const char* fmt, va_list ap) {
const char* e = str+size-1;
char* p = str;
@ -124,13 +128,13 @@ int snprintf(char* str, size_t size, const char* fmt, ...) {
return ret;
}
#endif
#ifdef __cplusplus
}
#endif
#endif
/*
* End of "$Id: vsnprintf.c,v 1.3.2.4 2001/01/22 15:13:41 easysw Exp $".
* End of "$Id: vsnprintf.c,v 1.3.2.5 2001/04/27 14:39:27 easysw Exp $".
*/