Simplify Fl_Window_Driver::screen_num() member functions.

This commit is contained in:
ManoloFLTK 2022-09-01 11:55:41 +02:00
parent b4686f0e5b
commit b75d7526fd
11 changed files with 11 additions and 53 deletions

View File

@ -43,7 +43,7 @@ class Fl_RGB_Image;
This class is only for internal use by the FLTK library.
When porting FLTK to a new platform, many mothods in this class provide
When porting FLTK to a new platform, many methods in this class provide
a minimal default implementation. Some methods must be overridden to make
sure that the Graphics Driver will draw into the bitmap associated with
this window.
@ -56,6 +56,7 @@ private:
protected:
Fl_Window *pWindow;
int screen_num_; // number of screen where window is mapped
void flush_Fl_Window(); // accessor to protected Fl_Window::flush()
public:
Fl_Window_Driver(Fl_Window *);
@ -65,8 +66,8 @@ public:
static Fl_Window *find(fl_uintptr_t xid);
int wait_for_expose_value;
Fl_Offscreen other_xid; // offscreen bitmap (overlay and double-buffered windows)
virtual int screen_num();
virtual void screen_num(int) {}
int screen_num();
void screen_num(int n) { screen_num_ = n; }
// --- frequently used accessors to public window data

View File

@ -41,6 +41,7 @@ Fl_Window_Driver::Fl_Window_Driver(Fl_Window *win)
: pWindow(win) {
wait_for_expose_value = 0;
other_xid = 0;
screen_num_ = 0;
}
@ -219,8 +220,10 @@ void Fl_Window_Driver::wait_for_expose() {
}
int Fl_Window_Driver::screen_num() {
if (pWindow->parent()) return Fl_Window_Driver::driver(pWindow->top_window())->screen_num();
return Fl::screen_num(x(), y(), w(), h());
if (pWindow->parent()) {
screen_num_ = Fl_Window_Driver::driver(pWindow->top_window())->screen_num();
}
return screen_num_ >= 0 ? screen_num_ : 0;
}
bool Fl_Window_Driver::is_a_rescale_ = false;

View File

@ -2047,6 +2047,8 @@ int fl_handle(const XEvent& thisevent)
}
wd->screen_num(num);
}
#else // ! USE_XFT
Fl_Window_Driver::driver(window)->screen_num( Fl::screen_num(X, Y, W, H) );
#endif // USE_XFT
// tell Fl_Window about it and set flag to prevent echoing:

View File

@ -85,7 +85,6 @@ private:
// stores 3 binary flags: whether window is mapped to retina display; whether resolution just changed;
// whether window's view received the [FLView view_did_resize] message
unsigned window_flags_;
int screen_num_; // number of screen where window is mapped
public:
Fl_Cocoa_Window_Driver(Fl_Window*);
~Fl_Cocoa_Window_Driver();
@ -134,8 +133,6 @@ public:
virtual void size_range();
virtual void iconize();
virtual void decoration_sizes(int *top, int *left, int *right, int *bottom);
virtual int screen_num();
virtual void screen_num(int n);
// --- window cursor stuff
virtual int set_cursor(Fl_Cursor);
virtual int set_cursor(const Fl_RGB_Image*, int, int);

View File

@ -330,15 +330,6 @@ void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl
CGContextRelease(auxgc);
}
void Fl_Cocoa_Window_Driver::screen_num(int n) {
screen_num_ = n;
}
int Fl_Cocoa_Window_Driver::screen_num() {
if (pWindow->parent()) return pWindow->top_window()->screen_num();
else return screen_num_;
}
FLWindow *fl_mac_xid(const Fl_Window *win) {
return (FLWindow*)Fl_Window_Driver::xid(win);

View File

@ -74,8 +74,6 @@ public:
bool busy;
};
static type_for_resize_window_between_screens data_for_resize_window_between_screens_;
int screen_num_;
void screen_num(int n) { screen_num_ = n; }
void decorated_win_size(int &w, int &h);
void shape_bitmap_(Fl_Image* b);
void shape_alpha_(Fl_Image* img, int offset);
@ -88,7 +86,6 @@ public:
static void redraw(struct wld_window *window);
static inline Fl_Wayland_Window_Driver* driver(const Fl_Window *w) {return (Fl_Wayland_Window_Driver*)Fl_Window_Driver::driver(w);}
virtual int screen_num();
static void resize_after_screen_change(void *data);
// --- window data

View File

@ -1123,14 +1123,6 @@ void Fl_Wayland_Window_Driver::resize_after_screen_change(void *data) {
}
int Fl_Wayland_Window_Driver::screen_num() {
if (pWindow->parent()) {
screen_num_ = Fl_Window_Driver::driver(pWindow->top_window())->screen_num();
}
return screen_num_ >= 0 ? screen_num_ : 0;
}
int Fl_Wayland_Window_Driver::set_cursor(Fl_Cursor c) {
Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver();

View File

@ -58,7 +58,6 @@ class Fl_WinAPI_Window_Driver : public Fl_Window_Driver
Fl_Image* shape_; ///< shape image
Fl_Bitmap *effective_bitmap_; ///< auxiliary bitmap image
} *shape_data_;
int screen_num_;
private:
void shape_bitmap_(Fl_Image* b);
void shape_alpha_(Fl_Image* img, int offset);
@ -68,8 +67,6 @@ public:
static inline Fl_WinAPI_Window_Driver* driver(const Fl_Window *w) {return (Fl_WinAPI_Window_Driver*)Fl_Window_Driver::driver(w);}
HDC private_dc; // used for OpenGL
RECT border_width_title_bar_height(int &bx, int &by, int &bt);
virtual void screen_num(int n);
virtual int screen_num();
struct icon_data *icon_;
HCURSOR cursor;

View File

@ -55,20 +55,9 @@ Fl_WinAPI_Window_Driver::~Fl_WinAPI_Window_Driver()
delete icon_;
}
int Fl_WinAPI_Window_Driver::screen_num() {
if (pWindow->parent()) {
screen_num_ = Fl_Window_Driver::driver(pWindow->top_window())->screen_num();
}
return screen_num_ >= 0 ? screen_num_ : 0;
}
//FILE*LOG=fopen("log.log","w");
void Fl_WinAPI_Window_Driver::screen_num(int n) {
//fprintf(LOG, "screen_num setter old=%d new=%d\n",screen_num_, n);fflush(LOG);
screen_num_ = n;
}
RECT // frame of the decorated window in screen coordinates
Fl_WinAPI_Window_Driver::border_width_title_bar_height(

View File

@ -73,8 +73,6 @@ private:
bool busy;
};
static type_for_resize_window_between_screens data_for_resize_window_between_screens_;
int screen_num_;
void screen_num(int n) { screen_num_ = n; }
#endif // USE_XFT
#if FLTK_USE_CAIRO
cairo_t *cairo_;
@ -92,7 +90,6 @@ public:
virtual ~Fl_X11_Window_Driver();
static inline Fl_X11_Window_Driver* driver(const Fl_Window *w) {return (Fl_X11_Window_Driver*)Fl_Window_Driver::driver(w);}
#if USE_XFT
virtual int screen_num();
static void resize_after_screen_change(void *data);
#endif // USE_XFT

View File

@ -572,14 +572,6 @@ void Fl_X11_Window_Driver::resize_after_screen_change(void *data) {
data_for_resize_window_between_screens_.busy = false;
}
int Fl_X11_Window_Driver::screen_num() {
if (pWindow->parent()) {
screen_num_ = Fl_Window_Driver::driver(pWindow->top_window())->screen_num();
}
return screen_num_ >= 0 ? screen_num_ : 0;
}
#endif // USE_XFT
fl_uintptr_t Fl_X11_Window_Driver::os_id() {