From 3718effc431f5622a23c55b254153efdfe4e72c4 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 4 Mar 2022 15:40:29 +0100 Subject: Add the Wayland platform to FLTK 1.4 --- src/Fl_x.cxx | 281 ++--------------------------------------------------------- 1 file changed, 6 insertions(+), 275 deletions(-) (limited to 'src/Fl_x.cxx') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 34528a0b2..40c0e02ea 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -78,155 +78,16 @@ static bool have_xfixes = false; # include # endif -extern Fl_Widget *fl_selection_requestor; - -static void open_display_i(Display *d); // open display (internal) - -//////////////////////////////////////////////////////////////// - -// Hack to speed up bg box drawing - aka "boxcheat": -// If the boxtype of a window is a filled rectangle, we can make the -// redisplay *look* faster by using X's background pixel erasing. -// This is done by setting a flag when the window is shown for the first time. - -// Note to FLTK devs: -// This can cause unexpected behavior, for instance if the box() or -// color() of a window is changed after show(), and it does presumably not -// have much effect on current systems (compared to 1998). -// It is also fragile WRT checking the box type if any other scheme than -// the default scheme is loaded. -// Hence this is disabled since FLTK 1.4.0 (AlbrechtS Feb 02, 2022) - -// Note to FLTK users: -// You may define ENABLE_BOXCHEAT to use it anyway but please tell the -// FLTK devs why you believe that you need it. Should we re-enable it? - -#ifdef ENABLE_BOXCHEAT -static int fl_background_pixel = -1; -static inline int can_boxcheat(Fl_Boxtype b) { - return (b == 1 || ((b & 2) && b <= 15)); -} -#endif // (ENABLE_BOXCHEAT) - -//////////////////////////////////////////////////////////////// -// interface to poll/select call: - # if USE_POLL - # include -static pollfd *pollfds = 0; - # 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 - # endif /* USE_POLL */ -static int nfds = 0; -static int fd_array_size = 0; -struct FD { -# if !USE_POLL - int fd; - short events; -# endif - void (*cb)(int, void*); - void* arg; -}; - -static FD *fd = 0; - -void Fl_X11_System_Driver::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; - - 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 - 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; - fd[i].arg = v; -# if USE_POLL - pollfds[i].fd = n; - pollfds[i].events = events; -# 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 -} - -void Fl_X11_System_Driver::add_fd(int n, void (*cb)(int, void*), void* v) { - add_fd(n, POLLIN, cb, v); -} +extern Fl_Widget *fl_selection_requestor; -void Fl_X11_System_Driver::remove_fd(int n, int events) { - int i,j; -# if !USE_POLL - maxfd = -1; // recalculate maxfd on the fly -# endif - for (i=j=0; i maxfd) maxfd = fd[i].fd; -# endif - // move it down in the array if necessary: - if (j 0) { - for (int i=0; i= 0; i--) { - char *s = bmp + i * R; - for (int j = 0; j < w; j++) { - *p++=s[2]; - *p++=s[1]; - *p++=s[0]; - s+=3; - } - } - Fl_RGB_Image *img = new Fl_RGB_Image(data, w, h, 3); - img->alloc_array = 1; - return img; -} // Call this when a "paste" operation happens: void Fl_X11_Screen_Driver::paste(Fl_Widget &receiver, int clipboard, const char *type) { @@ -918,7 +697,7 @@ void Fl_X11_Screen_Driver::paste(Fl_Widget &receiver, int clipboard, const char Fl::e_length = fl_selection_length[clipboard]; if (!Fl::e_text) Fl::e_text = (char *)""; } else if (clipboard == 1 && type == Fl::clipboard_image && fl_selection_type[1] == type) { - Fl::e_clipboard_data = own_bmp_to_RGB(fl_selection_buffer[1]); + Fl::e_clipboard_data = Fl_Unix_System_Driver::own_bmp_to_RGB(fl_selection_buffer[1]); Fl::e_clipboard_type = Fl::clipboard_image; } else return; int retval = receiver.handle(FL_PASTE); @@ -1074,53 +853,12 @@ static void write_int(unsigned char **cp, int i) { *cp = c; } -static unsigned char *create_bmp(const unsigned char *data, int W, int H, int *return_size){ - int R=(3*W+3)/4 * 4; // the number of bytes per row, rounded up to multiple of 4 - int s=H*R; - int fs=14+40+s; - unsigned char *b=new unsigned char[fs]; - unsigned char *c=b; - // BMP header - *c++='B'; - *c++='M'; - write_int(&c,fs); - write_int(&c,0); - write_int(&c,14+40); - // DIB header: - write_int(&c,40); - write_int(&c,W); - write_int(&c,H); - write_short(&c,1); - write_short(&c,24);//bits ber pixel - write_int(&c,0);//RGB - write_int(&c,s); - write_int(&c,0);// horizontal resolution - write_int(&c,0);// vertical resolution - write_int(&c,0);//number of colors. 0 -> 1<