From 2b85bf81680e2243ef5a5daf85d9eb04321c7278 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 27 Nov 2001 17:44:08 +0000 Subject: Preliminary commit of my MacOS X work. **** THIS CODE COMPILES BUT DOES NOT WORK. **** TODO: fix event handling - getting blank windows, etc. TODO: re-port OpenGL code. TODO: add support for images with alpha. TODO: add support for more then just beeps in fl_beep(). TODO: other stuff I'm sure... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1765 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_x.cxx | 145 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 73 insertions(+), 72 deletions(-) (limited to 'src/Fl_x.cxx') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index bb0010f8b..5788181d6 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_x.cxx,v 1.24.2.24.2.6 2001/11/22 15:35:01 easysw Exp $" +// "$Id: Fl_x.cxx,v 1.24.2.24.2.7 2001/11/27 17:44:06 easysw Exp $" // // X specific code for the Fast Light Tool Kit (FLTK). // @@ -24,56 +24,57 @@ // #ifdef WIN32 -#include "Fl_win32.cxx" +# include "Fl_win32.cxx" +#elif defined(__APPLE__) +# include "Fl_mac.cxx" #else -#define CONSOLIDATE_MOTION 1 +# define CONSOLIDATE_MOTION 1 /**** Define this if your keyboard lacks a backspace key... ****/ /* #define BACKSPACE_HACK 1 */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include //////////////////////////////////////////////////////////////// // interface to poll/select call: -#if USE_POLL +# if USE_POLL -#include +# include static pollfd *pollfds = 0; -#else - -#if HAVE_SYS_SELECT_H -# include -#endif /* HAVE_SYS_SELECT_H */ +# else +# if HAVE_SYS_SELECT_H +# include +# endif /* HAVE_SYS_SELECT_H */ // The following #define is only needed for HP-UX 9.x and earlier: //#define select(a,b,c,d,e) select((a),(int *)(b),(int *)(c),(int *)(d),(e)) static fd_set fdsets[3]; static int maxfd; -#define POLLIN 1 -#define POLLOUT 4 -#define POLLERR 8 +# define POLLIN 1 +# define POLLOUT 4 +# define POLLERR 8 -#endif /* USE_POLL */ +# endif /* USE_POLL */ static int nfds = 0; static int fd_array_size = 0; struct FD { -#if !USE_POLL +# if !USE_POLL int fd; short events; -#endif +# endif void (*cb)(int, void*); void* arg; }; @@ -93,7 +94,7 @@ void Fl::add_fd(int n, int events, void (*cb)(int, void*), void *v) { if (!temp) return; fd = temp; -#if USE_POLL +# if USE_POLL pollfd *tpoll; if (!pollfds) tpoll = (pollfd*)malloc(fd_array_size*sizeof(pollfd)); @@ -101,21 +102,21 @@ void Fl::add_fd(int n, int events, void (*cb)(int, void*), void *v) { if (!tpoll) return; pollfds = tpoll; -#endif +# endif } fd[i].cb = cb; fd[i].arg = v; -#if USE_POLL +# if USE_POLL pollfds[i].fd = n; pollfds[i].events = events; -#else +# else fd[i].fd = n; fd[i].events = events; if (events & POLLIN) FD_SET(n, &fdsets[0]); if (events & POLLOUT) FD_SET(n, &fdsets[1]); if (events & POLLERR) FD_SET(n, &fdsets[2]); if (n > maxfd) maxfd = n; -#endif +# endif } void Fl::add_fd(int fd, void (*cb)(int, void*), void* v) { @@ -125,57 +126,57 @@ void Fl::add_fd(int fd, void (*cb)(int, void*), void* v) { void Fl::remove_fd(int n, int events) { int i,j; for (i=j=0; i 0) { for (int i=0; ixbutton.x_root; Fl::e_x = fl_xevent->xbutton.x; Fl::e_y_root = fl_xevent->xbutton.y_root; Fl::e_y = fl_xevent->xbutton.y; Fl::e_state = fl_xevent->xbutton.state << 16; fl_event_time = fl_xevent->xbutton.time; -#ifdef __sgi +# ifdef __sgi // get the meta key off PC keyboards: if (fl_key_vector[18]&0x18) Fl::e_state |= FL_META; -#endif +# endif // turn off is_click if enough time or mouse movement has passed: if (abs(Fl::e_x_root-px)+abs(Fl::e_y_root-py) > 3 || fl_event_time >= ptime+1000) @@ -434,12 +435,12 @@ int fl_handle(const XEvent& xevent) case Expose: Fl_X::i(window)->wait_for_expose = 0; -#if 0 +# if 0 // try to keep windows on top even if WM_TRANSIENT_FOR does not work: // opaque move/resize window managers do not like this, so I disabled it. if (Fl::first_window()->non_modal() && window != Fl::first_window()) Fl::first_window()->show(); -#endif +# endif case GraphicsExpose: window->damage(FL_DAMAGE_EXPOSE, xevent.xexpose.x, xevent.xexpose.y, @@ -464,13 +465,13 @@ int fl_handle(const XEvent& xevent) case MotionNotify: set_event_xy(); -#if CONSOLIDATE_MOTION +# if CONSOLIDATE_MOTION send_motion = fl_xmousewin = window; return 0; -#else +# else event = FL_MOVE; break; -#endif +# endif case ButtonRelease: Fl::e_keysym = FL_Button + xevent.xbutton.button; @@ -518,7 +519,7 @@ int fl_handle(const XEvent& xevent) // keyup events just get the unshifted keysym: keysym = XKeycodeToKeysym(fl_display, keycode, 0); } -#ifdef __sgi +# ifdef __sgi // You can plug a microsoft keyboard into an sgi but the extra shift // keys are not translated. Make them translate like XFree86 does: if (!keysym) switch(keycode) { @@ -526,8 +527,8 @@ int fl_handle(const XEvent& xevent) case 148: keysym = FL_Meta_R; break; case 149: keysym = FL_Menu; break; } -#endif -#if BACKSPACE_HACK +# endif +# if BACKSPACE_HACK // Attempt to fix keyboards that send "delete" for the key in the // upper-right corner of the main keyboard. But it appears that // very few of these remain? @@ -536,7 +537,7 @@ int fl_handle(const XEvent& xevent) if (keysym == FL_Delete) keysym = FL_BackSpace; else if (keysym == FL_BackSpace) got_backspace = 1; } -#endif +# endif // We have to get rid of the XK_KP_function keys, because they are // not produced on Windoze and thus case statements tend not to check // for them. There are 15 of these in the range 0xff91 ... 0xff9f @@ -936,5 +937,5 @@ void Fl_Window::make_current() { #endif // -// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.6 2001/11/22 15:35:01 easysw Exp $". +// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.7 2001/11/27 17:44:06 easysw Exp $". // -- cgit v1.2.3