Rewrite Fl_Window_Driver::resize_after_scale_change() removing calls to Fl_Window::hide() and Fl_Window::show().

Windows are now rescaled with a call to Fl_Window::resize() which has been slightly modified.
Static member variable bool Fl_Window_Driver::in_resize_after_scale_change is created,
and is true if and only if Fl_Window::resize() is called by Fl_Window_Driver::resize_after_scale_change().
This new flag allows Fl_Window::resize() to perform correctly the rescaling of the window.
Fl_Gl_Window::resize() and Fl_Double_Window::resize() also consult the value of
the Fl_Window_Driver::in_resize_after_scale_change flag.
The platform-specific Fl_WinAPI_Window_Driver::resize() and Fl_X11_Window_Driver::resize()
also use  the Fl_Window_Driver::in_resize_after_scale_change flag.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12349 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2017-07-25 10:57:24 +00:00
parent 2b529dc25d
commit 225c3d6da3
7 changed files with 25 additions and 20 deletions

View File

@ -44,13 +44,16 @@ class FL_EXPORT Fl_Window_Driver
{
friend class Fl_Window;
friend class Fl_X;
friend class Fl_Group;
friend class Fl_Gl_Window;
friend class Fl_Double_Window;
protected:
Fl_Window *pWindow;
struct shape_data_type;
shape_data_type *shape_data_; ///< non-null means the window has a non-rectangular shape
void flush_Fl_Window(); // accessor to protected Fl_Window::flush()
static bool in_resize_after_scale_change;
public:
Fl_Window_Driver(Fl_Window *);
virtual ~Fl_Window_Driver();

View File

@ -55,7 +55,7 @@ void Fl_Double_Window::resize(int X,int Y,int W,int H) {
int oh = h();
Fl_Window::resize(X,Y,W,H);
Fl_X *myi = Fl_X::i(this);
if (myi && driver()->other_xid && (ow < w() || oh < h()))
if (myi && driver()->other_xid && (ow < w() || oh < h() || Fl_Window_Driver::in_resize_after_scale_change))
driver()->destroy_double_buffer();
}

View File

@ -24,6 +24,7 @@ extern int fl_gl_load_plugin;
#include <FL/gl.h>
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Gl_Window_Driver.H>
#include <FL/Fl_Window_Driver.H>
#include <stdlib.h>
#include <FL/fl_utf8.h>
# if (HAVE_DLSYM && HAVE_DLFCN_H)
@ -260,7 +261,7 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
// printf("Fl_Gl_Window::resize(X=%d, Y=%d, W=%d, H=%d)\n", X, Y, W, H);
// printf("current: x()=%d, y()=%d, w()=%d, h()=%d\n", x(), y(), w(), h());
int is_a_resize = (W != Fl_Widget::w() || H != Fl_Widget::h());
int is_a_resize = (W != Fl_Widget::w() || H != Fl_Widget::h() || Fl_Window_Driver::in_resize_after_scale_change);
if (is_a_resize) valid(0);
pGlWindowDriver->resize(is_a_resize, W, H);
Fl_Window::resize(X,Y,W,H);

View File

@ -25,6 +25,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Window_Driver.H>
#include <FL/fl_draw.H>
#include <stdlib.h>
@ -699,7 +700,7 @@ void Fl_Group::resize(int X, int Y, int W, int H) {
Fl_Widget::resize(X,Y,W,H); // make new xywh values visible for children
if (!resizable() || (dw==0 && dh==0) ) {
if ((!resizable() || (dw==0 && dh==0 )) && !Fl_Window_Driver::in_resize_after_scale_change) {
if (!as_window()) {
Fl_Widget*const* a = array();

View File

@ -260,21 +260,21 @@ int Fl_Window_Driver::screen_num() {
return Fl::screen_num(x(), y(), w(), h());
}
bool Fl_Window_Driver::in_resize_after_scale_change = false;
void Fl_Window_Driver::resize_after_scale_change(int ns, float old_f, float new_f) {
int oldx = pWindow->x(), oldy = pWindow->y();
fl_uintptr_t current = current_cursor();
pWindow->hide();
screen_num(ns);
pWindow->position(oldx*old_f/new_f, oldy*old_f/new_f);
force_position(1);
if (pWindow->fullscreen_active()) {
pWindow->size(pWindow->w() * old_f/new_f, pWindow->h() * old_f/new_f);
}
Fl_Graphics_Driver::default_driver().scale(new_f);
pWindow->show();
reuse_cursor(current);
reuse_icons();
//extern FILE*LOG;fprintf(LOG,"ns=%d old_f%.2f new_f=%.2f\n",ns,old_f,new_f);fflush(LOG);
int W, H;
if (pWindow->fullscreen_active()) {
W = pWindow->w() * old_f/new_f; H = pWindow->h() * old_f/new_f;
} else {
W = pWindow->w(); H = pWindow->h();
}
in_resize_after_scale_change = true;
pWindow->resize(pWindow->x()*old_f/new_f, pWindow->y()*old_f/new_f, W, H);
size_range();
in_resize_after_scale_change = false;
}
//

View File

@ -1679,10 +1679,10 @@ int Fl_WinAPI_Window_Driver::fake_X_wm(int &X,int &Y, int &bt,int &bx, int &by)
void Fl_WinAPI_Window_Driver::resize(int X,int Y,int W,int H) {
UINT flags = SWP_NOSENDCHANGING | SWP_NOZORDER
| SWP_NOACTIVATE | SWP_NOOWNERZORDER;
int is_a_resize = (W != w() || H != h());
int is_a_resize = (W != w() || H != h() || in_resize_after_scale_change);
int resize_from_program = (pWindow != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0;
if (X != x() || Y != y()) {
if (X != x() || Y != y() || in_resize_after_scale_change) {
force_position(1);
} else {
if (!is_a_resize) return;

View File

@ -2106,8 +2106,8 @@ fprintf(stderr,"\n");*/
////////////////////////////////////////////////////////////////
void Fl_X11_Window_Driver::resize(int X,int Y,int W,int H) {
int is_a_move = (X != x() || Y != y());
int is_a_resize = (W != w() || H != h());
int is_a_move = (X != x() || Y != y() || in_resize_after_scale_change);
int is_a_resize = (W != w() || H != h() || in_resize_after_scale_change);
int resize_from_program = (pWindow != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0;
if (is_a_move && resize_from_program) force_position(1);