From 2e6e0b9c36fbf92d0d551aca077580e7a57c266a Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 3 Feb 2022 07:03:26 +0100 Subject: Reorganize classes Fl_System_Driver and Fl_Screen_Driver These virtual members are moved from Fl_Screen_Driver to Fl_System_Driver - wait(double) - ready() These virtual members are moved from Fl_System_Driver to Fl_Screen_Driver - copy(const char *stuff, int len, int clipboard, const char *type) - void paste(Fl_Widget &widget, int clipboard, const char *type) - clipboard_contains(const char *type) - clipboard_notify_change() These members are moved from Fl_X11_Screen_Driver to Fl_X11_System_Driver - poll_or_select_with_delay(double time_to_wait) - poll_or_select() and are made virtual in preparation for the introduction of class Fl_Unix_System_Driver. --- src/Fl.cxx | 16 ++++++++-------- src/Fl_Screen_Driver.H | 10 ++++++++-- src/Fl_System_Driver.H | 10 ++-------- src/Fl_cocoa.mm | 10 +++++----- src/Fl_win32.cxx | 14 +++++++------- src/Fl_x.cxx | 14 +++++++------- src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H | 5 +++-- src/drivers/Darwin/Fl_Darwin_System_Driver.H | 5 ++--- src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H | 10 ++++++++-- src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 10 ++-------- src/drivers/X11/Fl_X11_Screen_Driver.H | 12 ++++++++---- src/drivers/X11/Fl_X11_Screen_Driver.cxx | 28 ---------------------------- src/drivers/X11/Fl_X11_System_Driver.H | 13 +++++-------- src/drivers/X11/Fl_X11_System_Driver.cxx | 27 +++++++++++++++++++++++++++ 14 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/Fl.cxx b/src/Fl.cxx index a37e1a137..28fc04c5f 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -389,7 +389,7 @@ void Fl::add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data) { clip_notify_list = node; - Fl::system_driver()->clipboard_notify_change(); + Fl::screen_driver()->clipboard_notify_change(); } void Fl::remove_clipboard_notify(Fl_Clipboard_Notify_Handler h) { @@ -402,7 +402,7 @@ void Fl::remove_clipboard_notify(Fl_Clipboard_Notify_Handler h) { *prev = node->next; delete node; - Fl::system_driver()->clipboard_notify_change(); + Fl::screen_driver()->clipboard_notify_change(); return; } @@ -502,7 +502,7 @@ double Fl::wait(double time_to_wait) { // platform dependent part: - return screen_driver()->wait(time_to_wait); + return system_driver()->wait(time_to_wait); } #define FOREVER 1e20 @@ -589,7 +589,7 @@ int Fl::check() { */ int Fl::ready() { - return screen_driver()->ready(); + return system_driver()->ready(); } int Fl::program_should_quit_ = 0; @@ -1444,12 +1444,12 @@ void Fl::selection(Fl_Widget &owner, const char* text, int len) { \see Fl::paste(Fl_Widget &receiver, int clipboard, const char* type) */ void Fl::paste(Fl_Widget &receiver) { - Fl::system_driver()->paste(receiver, 0, Fl::clipboard_plain_text); + Fl::screen_driver()->paste(receiver, 0, Fl::clipboard_plain_text); } void Fl::paste(Fl_Widget &receiver, int clipboard, const char *type) { - Fl::system_driver()->paste(receiver, clipboard, type); + Fl::screen_driver()->paste(receiver, clipboard, type); } //////////////////////////////////////////////////////////////// @@ -1958,12 +1958,12 @@ const char * fl_filename_name(const char *name) { } void Fl::copy(const char *stuff, int len, int clipboard, const char *type) { - Fl::system_driver()->copy(stuff, len, clipboard, type); + Fl::screen_driver()->copy(stuff, len, clipboard, type); } int Fl::clipboard_contains(const char *type) { - return Fl::system_driver()->clipboard_contains(type); + return Fl::screen_driver()->clipboard_contains(type); } diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H index fae5b0ff2..e7a64b542 100644 --- a/src/Fl_Screen_Driver.H +++ b/src/Fl_Screen_Driver.H @@ -105,8 +105,6 @@ public: virtual void beep(int) {} // --- global events virtual void flush() {} // must override - virtual double wait(double) { return 0.0; } // must override - virtual int ready() { return 0; } // must override virtual void grab(Fl_Window *) {} // --- global colors /* the default implementation of parse_color() may be enough */ @@ -203,6 +201,14 @@ public: virtual void default_icons(const Fl_RGB_Image *icons[], int count); // this one is implemented in print_button.cxx static int print_or_copy_window(Fl_Window*, bool, int); + // implement to support copy-to-clipboard + virtual void copy(const char */*stuff*/, int /*len*/, int /*clipboard*/, const char */*type*/) {} + // implement to support paste-from-clipboard + virtual void paste(Fl_Widget &, int /*clipboard*/, const char */*type*/) {} + // implement to support paste-from-clipboard + virtual int clipboard_contains(const char */*type*/) {return 0;} + // implement to support paste-from-clipboard + virtual void clipboard_notify_change() {} }; #endif // !FL_SCREEN_DRIVER_H diff --git a/src/Fl_System_Driver.H b/src/Fl_System_Driver.H index 37b5486fa..e010212fe 100644 --- a/src/Fl_System_Driver.H +++ b/src/Fl_System_Driver.H @@ -225,14 +225,6 @@ public: static const char * const tree_close_xpm[]; // used by tree_closepixmap() // the default implementation of tree_connector_style() is in Fl_Tree_Prefs.cxx and can be enough virtual int tree_connector_style(); - // implement to support copy-to-clipboard - virtual void copy(const char */*stuff*/, int /*len*/, int /*clipboard*/, const char */*type*/) {} - // implement to support paste-from-clipboard - virtual void paste(Fl_Widget &, int /*clipboard*/, const char */*type*/) {} - // implement to support paste-from-clipboard - 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); @@ -249,6 +241,8 @@ public: virtual Fl_Sys_Menu_Bar_Driver *sys_menu_bar_driver() { return NULL; } virtual void lock_ring() {} virtual void unlock_ring() {} + virtual double wait(double) { return 0.0; } // must override + virtual int ready() { return 0; } // must override }; #endif // FL_SYSTEM_DRIVER_H diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index d4a155af0..1b86fd4f7 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -439,7 +439,7 @@ void Fl_Darwin_System_Driver::remove_fd(int n) /* * Check if there is actually a message pending */ -int Fl_Cocoa_Screen_Driver::ready() +int Fl_Darwin_System_Driver::ready() { NSEvent *retval = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0] @@ -773,7 +773,7 @@ static int do_queued_events( double time = 0.0 ) return got_events; } -double Fl_Cocoa_Screen_Driver::wait(double time_to_wait) +double Fl_Darwin_System_Driver::wait(double time_to_wait) { if (dropped_files_list) { // when the list of dropped files is not empty, open one and remove it from list drain_dropped_files_list(); @@ -3597,7 +3597,7 @@ static void resize_selection_buffer(int len, int clipboard) { * len: size of selected data * type: always "plain/text" for now */ -void Fl_Darwin_System_Driver::copy(const char *stuff, int len, int clipboard, const char *type) { +void Fl_Cocoa_Screen_Driver::copy(const char *stuff, int len, int clipboard, const char *type) { if (!stuff || len<0) return; if (clipboard >= 2) clipboard = 1; // Only on X11 do multiple clipboards make sense. @@ -3695,7 +3695,7 @@ static Fl_RGB_Image* get_image_from_clipboard(Fl_Widget *receiver) } // Call this when a "paste" operation happens: -void Fl_Darwin_System_Driver::paste(Fl_Widget &receiver, int clipboard, const char *type) { +void Fl_Cocoa_Screen_Driver::paste(Fl_Widget &receiver, int clipboard, const char *type) { if (type[0] == 0) type = Fl::clipboard_plain_text; if (clipboard) { Fl::e_clipboard_type = ""; @@ -3723,7 +3723,7 @@ void Fl_Darwin_System_Driver::paste(Fl_Widget &receiver, int clipboard, const ch receiver.handle(FL_PASTE); } -int Fl_Darwin_System_Driver::clipboard_contains(const char *type) { +int Fl_Cocoa_Screen_Driver::clipboard_contains(const char *type) { NSString *found = nil; if (strcmp(type, Fl::clipboard_plain_text) == 0) { found = [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObjects:UTF8_pasteboard_type, @"public.utf16-plain-text", @"com.apple.traditional-mac-plain-text", nil]]; diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index b57b81a1c..cb477d95f 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -414,7 +414,7 @@ static void process_awake_handler_requests(void) { // It *should* return negative on error, 0 if nothing happens before // timeout, and >0 if any callbacks were done. This version // always returns 1. -double Fl_WinAPI_Screen_Driver::wait(double time_to_wait) { +double Fl_WinAPI_System_Driver::wait(double time_to_wait) { int have_message = 0; @@ -518,8 +518,8 @@ double Fl_WinAPI_Screen_Driver::wait(double time_to_wait) { return 1; } -// just like Fl_WinAPI_Screen_Driver::wait(0.0) except no callbacks are done: -int Fl_WinAPI_Screen_Driver::ready() { +// just like Fl_WinAPI_System_Driver::wait(0.0) except no callbacks are done: +int Fl_WinAPI_System_Driver::ready() { if (PeekMessage(&fl_msg, NULL, 0, 0, PM_NOREMOVE)) return 1; if (!nfds) @@ -764,7 +764,7 @@ void fl_update_clipboard(void) { } // call this when you create a selection: -void Fl_WinAPI_System_Driver::copy(const char *stuff, int len, int clipboard, const char *type) { +void Fl_WinAPI_Screen_Driver::copy(const char *stuff, int len, int clipboard, const char *type) { if (!stuff || len < 0) return; if (clipboard >= 2) @@ -789,7 +789,7 @@ void Fl_WinAPI_System_Driver::copy(const char *stuff, int len, int clipboard, co } // Call this when a "paste" operation happens: -void Fl_WinAPI_System_Driver::paste(Fl_Widget &receiver, int clipboard, const char *type) { +void Fl_WinAPI_Screen_Driver::paste(Fl_Widget &receiver, int clipboard, const char *type) { if (!clipboard || (fl_i_own_selection[clipboard] && strcmp(type, Fl::clipboard_plain_text) == 0)) { // We already have it, do it quickly without window server. // Notice that the text is clobbered if set_selection is @@ -940,7 +940,7 @@ void Fl_WinAPI_System_Driver::paste(Fl_Widget &receiver, int clipboard, const ch } } -int Fl_WinAPI_System_Driver::clipboard_contains(const char *type) { +int Fl_WinAPI_Screen_Driver::clipboard_contains(const char *type) { int retval = 0; if (!OpenClipboard(NULL)) return 0; @@ -1008,7 +1008,7 @@ void fl_clipboard_notify_retarget(HWND wnd) { fl_clipboard_notify_target(fl_xid(Fl::first_window())); } -void Fl_WinAPI_System_Driver::clipboard_notify_change() { +void Fl_WinAPI_Screen_Driver::clipboard_notify_change() { // untarget clipboard monitor if no handlers are registered if (clipboard_wnd != NULL && fl_clipboard_notify_empty()) { fl_clipboard_notify_untarget(clipboard_wnd); diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index ff48df4f6..abbc27a5d 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -235,7 +235,7 @@ void (*fl_unlock_function)() = nothing; // This is never called with time_to_wait < 0.0: // It should return negative on error, 0 if nothing happens before // timeout, and >0 if any callbacks were done. -int Fl_X11_Screen_Driver::poll_or_select_with_delay(double time_to_wait) { +int Fl_X11_System_Driver::poll_or_select_with_delay(double time_to_wait) { // OpenGL and other broken libraries call XEventsQueued // unnecessarily and thus cause the file descriptor to not be ready, @@ -288,8 +288,8 @@ int Fl_X11_Screen_Driver::poll_or_select_with_delay(double time_to_wait) { return n; } -// just like Fl_X11_Screen_Driver::poll_or_select_with_delay(0.0) except no callbacks are done: -int Fl_X11_Screen_Driver::poll_or_select() { +// just like Fl_X11_System_Driver::poll_or_select_with_delay(0.0) except no callbacks are done: +int Fl_X11_System_Driver::poll_or_select() { if (XQLength(fl_display)) return 1; if (!nfds) return 0; // nothing to select or poll # if USE_POLL @@ -879,7 +879,7 @@ static Fl_RGB_Image *own_bmp_to_RGB(char *bmp) { } // Call this when a "paste" operation happens: -void Fl_X11_System_Driver::paste(Fl_Widget &receiver, int clipboard, const char *type) { +void Fl_X11_Screen_Driver::paste(Fl_Widget &receiver, int clipboard, const char *type) { if (fl_i_own_selection[clipboard]) { // We already have it, do it quickly without window server. if (type == Fl::clipboard_plain_text && fl_selection_type[clipboard] == type) { @@ -908,7 +908,7 @@ void Fl_X11_System_Driver::paste(Fl_Widget &receiver, int clipboard, const char fl_xid(Fl::first_window()), fl_event_time); } -int Fl_X11_System_Driver::clipboard_contains(const char *type) +int Fl_X11_Screen_Driver::clipboard_contains(const char *type) { if (fl_i_own_selection[1]) { return fl_selection_type[1] == type; @@ -1007,7 +1007,7 @@ static int get_xwinprop(Window wnd, Atom prop, long max_length, //////////////////////////////////////////////////////////////// // Code for copying to clipboard and DnD out of the program: -void Fl_X11_System_Driver::copy(const char *stuff, int len, int clipboard, const char *type) { +void Fl_X11_Screen_Driver::copy(const char *stuff, int len, int clipboard, const char *type) { if (!stuff || len<0) return; if (clipboard >= 2) { @@ -1182,7 +1182,7 @@ static void handle_clipboard_timestamp(int clipboard, Time time) fl_trigger_clipboard_notify(clipboard); } -void Fl_X11_System_Driver::clipboard_notify_change() { +void Fl_X11_Screen_Driver::clipboard_notify_change() { // Reset the timestamps if we've going idle so that you don't // get a bogus immediate trigger next time they're activated. if (fl_clipboard_notify_empty()) { diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H index 7dd6fc14a..74e1a8123 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H @@ -75,8 +75,6 @@ public: // --- audible output virtual void beep(int type); // --- global events - virtual double wait(double time_to_wait); - virtual int ready(); virtual void grab(Fl_Window* win); // --- global colors virtual void get_system_colors(); @@ -99,6 +97,9 @@ public: virtual void scale(int /*nscreen*/, float f) { scale_ = f;} virtual Fl_RGB_Image *read_win_rectangle(int X, int Y, int w, int h, Fl_Window *win, bool may_capture_subwins, bool *did_capture_subwins); virtual void default_icons(const Fl_RGB_Image *icons[], int count); + 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); private: float scale_; }; diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H index 8a2e3b7f6..19b4dab2d 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H @@ -73,9 +73,6 @@ public: static const char * const tree_close_xpm_darwin[]; // used by tree_closepixmap() virtual int tree_connector_style(); virtual const char *filename_name(const char *buf); - 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); @@ -86,6 +83,8 @@ public: virtual const char *alt_name(); virtual const char *control_name(); virtual Fl_Sys_Menu_Bar_Driver *sys_menu_bar_driver(); + virtual double wait(double time_to_wait); + virtual int ready(); }; #endif // FL_DARWIN_SYSTEM_DRIVER_H diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H index c621f7e5e..6754396ff 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H @@ -61,8 +61,6 @@ public: virtual void beep(int type); // --- global events virtual void flush(); - virtual double wait(double time_to_wait); - virtual int ready(); virtual void grab(Fl_Window* win); // --- global colors virtual void get_system_colors(); @@ -86,6 +84,14 @@ public: } virtual void desktop_scale_factor(); virtual void default_icons(const Fl_RGB_Image *icons[], int count); + // this one is implemented in Fl_win32.cxx + virtual void copy(const char *stuff, int len, int clipboard, const char *type); + // this one is implemented in Fl_win32.cxx + virtual void paste(Fl_Widget &receiver, int clipboard, const char *type); + // this one is implemented in Fl_win32.cxx + virtual int clipboard_contains(const char *type); + // this one is implemented in Fl_win32.cxx + virtual void clipboard_notify_change(); }; diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index 60dca9d17..3e6a86648 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -107,14 +107,6 @@ public: virtual int case_insensitive_filenames() {return 1;} // this one is implemented in Fl_win32.cxx virtual const char *filename_name(const char *buf); - // this one is implemented in Fl_win32.cxx - virtual void copy(const char *stuff, int len, int clipboard, const char *type); - // this one is implemented in Fl_win32.cxx - virtual void paste(Fl_Widget &receiver, int clipboard, const char *type); - // this one is implemented in Fl_win32.cxx - 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); @@ -123,6 +115,8 @@ public: virtual char* strdup(const char *s) { return ::_strdup(s); } virtual void lock_ring(); virtual void unlock_ring(); + virtual double wait(double time_to_wait); + virtual int ready(); }; #endif // FL_WINAPI_SYSTEM_DRIVER_H diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.H b/src/drivers/X11/Fl_X11_Screen_Driver.H index c8676f347..4b877c937 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.H +++ b/src/drivers/X11/Fl_X11_Screen_Driver.H @@ -45,8 +45,6 @@ protected: } FLScreenInfo; FLScreenInfo screens[MAX_SCREENS]; float dpi[MAX_SCREENS][2]; - int poll_or_select(); - int poll_or_select_with_delay(double time_to_wait); int get_mouse_unscaled(int &xx, int &yy); public: @@ -78,8 +76,6 @@ public: virtual void beep(int type); // --- global events virtual void flush(); - virtual double wait(double time_to_wait); - virtual int ready(); virtual void grab(Fl_Window* win); // --- global colors virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b); @@ -98,6 +94,14 @@ public: // --- compute dimensions of an Fl_Offscreen virtual void offscreen_size(Fl_Offscreen o, int &width, int &height); virtual void default_icons(const Fl_RGB_Image *icons[], int count); + // this one is in Fl_x.cxx + virtual void copy(const char *stuff, int len, int clipboard, const char *type); + // this one is in Fl_x.cxx + virtual void paste(Fl_Widget &receiver, int clipboard, const char *type); + // this one is in Fl_x.cxx + virtual int clipboard_contains(const char *type); + // this one is in Fl_x.cxx + virtual void clipboard_notify_change(); }; diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index 3e7edf872..d033f4cb7 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -365,34 +365,6 @@ void Fl_X11_Screen_Driver::flush() } -double Fl_X11_Screen_Driver::wait(double time_to_wait) -{ - if (time_to_wait <= 0.0) { - // do flush second so that the results of events are visible: - int ret = this->poll_or_select_with_delay(0.0); - Fl::flush(); - return ret; - } else { - // do flush first so that user sees the display: - Fl::flush(); - if (Fl::idle) // 'idle' may have been set within flush() - time_to_wait = 0.0; - else { - Fl_Timeout::elapse_timeouts(); - time_to_wait = Fl_Timeout::time_to_wait(time_to_wait); - } - return this->poll_or_select_with_delay(time_to_wait); - } -} - - -int Fl_X11_Screen_Driver::ready() { - Fl_Timeout::elapse_timeouts(); - if (Fl_Timeout::time_to_wait(1.0) <= 0.0) return 1; - return this->poll_or_select(); -} - - extern void fl_fix_focus(); // in Fl.cxx diff --git a/src/drivers/X11/Fl_X11_System_Driver.H b/src/drivers/X11/Fl_X11_System_Driver.H index 891c14d16..e39f40706 100644 --- a/src/drivers/X11/Fl_X11_System_Driver.H +++ b/src/drivers/X11/Fl_X11_System_Driver.H @@ -54,18 +54,15 @@ public: virtual void own_colormap(); // this one is in Fl_x.cxx virtual const char *filename_name(const char *buf); - // this one is in Fl_x.cxx - virtual void copy(const char *stuff, int len, int clipboard, const char *type); - // this one is in Fl_x.cxx - virtual void paste(Fl_Widget &receiver, int clipboard, const char *type); - // this one is in Fl_x.cxx - 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); + virtual double wait(double time_to_wait); + virtual int ready(); + // 2 additional virtual members + virtual int poll_or_select(); + virtual int poll_or_select_with_delay(double time_to_wait); }; #endif /* FL_X11_SYSTEM_DRIVER_H */ diff --git a/src/drivers/X11/Fl_X11_System_Driver.cxx b/src/drivers/X11/Fl_X11_System_Driver.cxx index 71becad49..64cac3779 100644 --- a/src/drivers/X11/Fl_X11_System_Driver.cxx +++ b/src/drivers/X11/Fl_X11_System_Driver.cxx @@ -20,6 +20,7 @@ #include // fl_strdup #include #include "../../flstring.h" +#include "../../Fl_Timeout.h" #include #include @@ -694,4 +695,30 @@ void Fl_X11_System_Driver::own_colormap() { #endif // USE_COLORMAP } +int Fl_X11_System_Driver::ready() { + Fl_Timeout::elapse_timeouts(); + if (Fl_Timeout::time_to_wait(1.0) <= 0.0) return 1; + return this->poll_or_select(); +} + +double Fl_X11_System_Driver::wait(double time_to_wait) +{ + if (time_to_wait <= 0.0) { + // do flush second so that the results of events are visible: + int ret = this->poll_or_select_with_delay(0.0); + Fl::flush(); + return ret; + } else { + // do flush first so that user sees the display: + Fl::flush(); + if (Fl::idle) // 'idle' may have been set within flush() + time_to_wait = 0.0; + else { + Fl_Timeout::elapse_timeouts(); + time_to_wait = Fl_Timeout::time_to_wait(time_to_wait); + } + return this->poll_or_select_with_delay(time_to_wait); + } +} + #endif // !defined(FL_DOXYGEN) -- cgit v1.2.3