Virtualized add_fd and remove_fd into System Driver

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11668 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2016-04-19 22:45:22 +00:00
parent cd4498021e
commit 769d151a12
17 changed files with 141 additions and 37 deletions

View File

@ -25,7 +25,7 @@
#include <FL/Fl_Export.H>
#include <FL/Fl_System_Driver.H> // for FL_SOCKET
#include <FL/platform_types.h> // for FL_SOCKET
#ifdef FLTK_HAVE_CAIRO
# include <FL/Fl_Cairo.H>
#endif
@ -50,6 +50,7 @@ class Fl_Window;
class Fl_Image;
struct Fl_Label;
class Fl_Screen_Driver;
class Fl_System_Driver;
// Pointers you can use to change FLTK to a foreign language.
// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx

View File

@ -24,8 +24,8 @@
#ifndef FL_SYSTEM_DRIVER_H
#define FL_SYSTEM_DRIVER_H
#include <FL/Fl.H>
#include <FL/Fl_Export.H>
#include <FL/platform_types.h>
#include <FL/filename.H>
#include <FL/Fl_Preferences.H>
#include <stdio.h>
@ -202,6 +202,10 @@ public:
virtual int clipboard_contains(const char *type) {return 0;}
// implement to support paste-from-clipboard
virtual void clipboard_notify_change() {}
virtual void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0);
virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
virtual void remove_fd(int, int when);
virtual void remove_fd(int);
};
#endif // FL_SYSTEM_DRIVER_H

View File

@ -43,19 +43,6 @@ typedef void *Fl_Offscreen;
struct XPoint { int x, y; };
struct XRectangle {int x, y, width, height;};
//typedef float CGFloat;
inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
// write code here
return 0L;
}
inline void XDestroyRegion(Fl_Region r) {
// write code here
}
extern void *fl_default_cursor;
inline void fl_open_callback(void (*)(const char *)) {}
// This object contains all platform-specific stuff about a window:

View File

@ -1939,6 +1939,27 @@ int Fl::clipboard_contains(const char *type)
return Fl::system_driver()->clipboard_contains(type);
}
void Fl::add_fd(int fd, int when, Fl_FD_Handler cb, void *d)
{
Fl::system_driver()->add_fd(fd, when, cb, d);
}
void Fl::add_fd(int fd, Fl_FD_Handler cb, void *d)
{
Fl::system_driver()->add_fd(fd, cb, d);
}
void Fl::remove_fd(int fd, int when)
{
Fl::system_driver()->remove_fd(fd, when);
}
void Fl::remove_fd(int fd)
{
Fl::system_driver()->remove_fd(fd);
}
/**
Enables the system input methods facilities. This is the default.
\see disable_im()

View File

@ -411,6 +411,27 @@ int Fl_System_Driver::file_type(const char *filename)
return Fl_File_Icon::ANY;
}
void Fl_System_Driver::add_fd(int fd, int when, Fl_FD_Handler cb, void *d)
{
// nothing to do, reimplement in driver if needed
}
void Fl_System_Driver::add_fd(int fd, Fl_FD_Handler cb, void *d)
{
// nothing to do, reimplement in driver if needed
}
void Fl_System_Driver::remove_fd(int fd, int when)
{
// nothing to do, reimplement in driver if needed
}
void Fl_System_Driver::remove_fd(int fd)
{
// nothing to do, reimplement in driver if needed
}
//
// End of "$Id$".
//

View File

@ -426,22 +426,22 @@ void DataReady::CancelThread(const char *reason)
DataUnlock();
}
void Fl::add_fd( int n, int events, void (*cb)(int, void*), void *v )
void Fl_Darwin_System_Driver::add_fd( int n, int events, void (*cb)(int, void*), void *v )
{
dataready.AddFD(n, events, cb, v);
}
void Fl::add_fd(int fd, void (*cb)(int, void*), void* v)
void Fl_Darwin_System_Driver::add_fd(int fd, void (*cb)(int, void*), void* v)
{
dataready.AddFD(fd, POLLIN, cb, v);
}
void Fl::remove_fd(int n, int events)
void Fl_Darwin_System_Driver::remove_fd(int n, int events)
{
dataready.RemoveFD(n, events);
}
void Fl::remove_fd(int n)
void Fl_Darwin_System_Driver::remove_fd(int n)
{
dataready.RemoveFD(n, -1);
}

View File

@ -18,15 +18,18 @@
#include "config_lib.h"
#include <FL/Fl.H>
#include <FL/Fl_System_Driver.H>
#include <stdlib.h>
// FIXME: why do we need the lines below?
#if defined(FL_CFG_SYS_POSIX)
#include "drivers/Posix/Fl_Posix_System_Driver.H"
#elif defined(FL_CFG_SYS_WIN32)
#include "drivers/WinAPI/Fl_WinAPI_System_Driver.H"
#endif
/*
From Bill:

View File

@ -294,7 +294,7 @@ void fl_set_status(int x, int y, int w, int h)
{
}
void Fl::add_fd(int n, int events, void (*cb)(FL_SOCKET, void*), void *v) {
void Fl_WinAPI_System_Driver::add_fd(int n, int events, void (*cb)(FL_SOCKET, void*), void *v) {
remove_fd(n,events);
int i = nfds++;
if (i >= fd_array_size) {
@ -312,11 +312,11 @@ void Fl::add_fd(int n, int events, void (*cb)(FL_SOCKET, void*), void *v) {
if (n > maxfd) maxfd = n;
}
void Fl::add_fd(int fd, void (*cb)(FL_SOCKET, void*), void* v) {
void Fl_WinAPI_System_Driver::add_fd(int fd, void (*cb)(FL_SOCKET, void*), void* v) {
Fl::add_fd(fd, FL_READ, cb, v);
}
void Fl::remove_fd(int n, int events) {
void Fl_WinAPI_System_Driver::remove_fd(int n, int events) {
int i,j;
for (i=j=0; i<nfds; i++) {
if (fd[i].fd == n) {
@ -337,7 +337,7 @@ void Fl::remove_fd(int n, int events) {
if (events & FL_EXCEPT) FD_CLR(unsigned(n), &fdsets[2]);
}
void Fl::remove_fd(int n) {
void Fl_WinAPI_System_Driver::remove_fd(int n) {
remove_fd(n, -1);
}

View File

@ -113,7 +113,7 @@ struct FD {
static FD *fd = 0;
void Fl::add_fd(int n, int events, void (*cb)(int, void*), void *v) {
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) {
@ -151,11 +151,11 @@ void Fl::add_fd(int n, int events, void (*cb)(int, void*), void *v) {
# endif
}
void Fl::add_fd(int n, void (*cb)(int, void*), void* v) {
void Fl_X11_System_Driver::add_fd(int n, void (*cb)(int, void*), void* v) {
Fl::add_fd(n, POLLIN, cb, v);
}
void Fl::remove_fd(int n, int events) {
void Fl_X11_System_Driver::remove_fd(int n, int events) {
int i,j;
# if !USE_POLL
maxfd = -1; // recalculate maxfd on the fly
@ -192,7 +192,7 @@ void Fl::remove_fd(int n, int events) {
# endif
}
void Fl::remove_fd(int n) {
void Fl_X11_System_Driver::remove_fd(int n) {
remove_fd(n, -1);
}

View File

@ -72,6 +72,10 @@ public:
virtual void copy(const char *stuff, int len, int clipboard, const char *type);
virtual void paste(Fl_Widget &receiver, int clipboard, const char *type);
virtual int clipboard_contains(const char *type);
virtual void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0);
virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
virtual void remove_fd(int, int when);
virtual void remove_fd(int);
};
#endif // FL_DARWIN_SYSTEM_DRIVER_H

View File

@ -1 +1,38 @@
//
// "$Id: Fl_Pico_System_Driver.H 11017 2016-01-20 21:40:12Z matt $"
//
// Definition of Pico system driver
// for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010-2016 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#ifndef FL_PICO_SYSTEM_DRIVER_H
#define FL_PICO_SYSTEM_DRIVER_H
#include <FL/Fl_System_Driver.H>
class Fl_Pico_System_Driver : public Fl_System_Driver {
public:
Fl_Pico_System_Driver() : Fl_System_Driver() {}
virtual void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0);
virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
virtual void remove_fd(int, int when);
virtual void remove_fd(int);
};
#endif /* FL_PICO_SYSTEM_DRIVER_H */
//
// End of "$Id: Fl_Pico_System_Driver.H 11017 2016-01-20 21:40:12Z matt $".
//

View File

@ -1 +1,26 @@
//
// "$Id: Fl_Pico_System_Driver.cxx 11017 2016-01-20 21:40:12Z matt $"
//
// Definition of Pico system driver
// for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010-2016 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#include "Fl_Pico_System_Driver.H"
#include "../../flstring.h"
//
// End of "$Id: Fl_Pico_System_Driver.H 11017 2016-01-20 21:40:12Z matt $".
//

View File

@ -63,7 +63,7 @@ double Fl_PicoSDL_Screen_Driver::wait(double time_to_wait)
Fl_X *i = Fl_X::i(Fl::first_window());
wd->wait_for_expose_value = 0;
if ( i->region ) {
XDestroyRegion(i->region);
fl_graphics_driver->XDestroyRegion(i->region);
i->region = 0;
}
window->clear_damage(FL_DAMAGE_ALL);
@ -155,16 +155,8 @@ Fl_X* Fl_X::make(Fl_Window *w)
return w->driver()->makeWindow();
}
char fl_show_iconic;
Window fl_window;
void Fl::add_fd(int, Fl_FD_Handler, void*)
{
}
void Fl::remove_fd(int)
{
}
//
// End of "$Id: Fl_PicoSDL_Screen_Driver.cxx 11253 2016-03-01 00:54:21Z matt $".

View File

@ -112,6 +112,10 @@ public:
virtual int clipboard_contains(const char *type);
// this one is implemented in Fl_win32.cxx
virtual void clipboard_notify_change();
virtual void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0);
virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
virtual void remove_fd(int, int when);
virtual void remove_fd(int);
};
#endif // FL_WINAPI_SYSTEM_DRIVER_H

View File

@ -55,6 +55,10 @@ public:
virtual int clipboard_contains(const char *type);
// this one is in Fl_x.cxx
virtual void clipboard_notify_change();
virtual void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0);
virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
virtual void remove_fd(int, int when);
virtual void remove_fd(int);
};
#endif /* FL_X11_SYSTEM_DRIVER_H */

View File

@ -20,7 +20,7 @@
#include <FL/filename.H>
#include <FL/Fl.H>
#include <FL/platform_types.h>
#include <FL/Fl_System_Driver.H>
#include <FL/fl_utf8.h>
#include "flstring.h"
#include <stdlib.h>

View File

@ -27,6 +27,7 @@
#include "config_lib.h"
#include <FL/filename.H>
#include <FL/Fl.H>
#include <FL/Fl_System_Driver.H>
#include <stdio.h>
#include <stdlib.h>
#include "flstring.h"