summaryrefslogtreecommitdiff
path: root/src/Fl_Window_Driver.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2017-07-30 16:21:57 +0000
committerManolo Gouy <Manolo>2017-07-30 16:21:57 +0000
commitc4e04e4c7f446464ef65382cf10bc13417563b3b (patch)
treef012307f02f8fba85f406f533908f63f7b15ea1c /src/Fl_Window_Driver.cxx
parent5a7a954ebd1005b30bbe48d84e4291c66ad30252 (diff)
Improve rescaling when window moved across screens: make sure center stays on new screen.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12367 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Window_Driver.cxx')
-rw-r--r--src/Fl_Window_Driver.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Fl_Window_Driver.cxx b/src/Fl_Window_Driver.cxx
index b16435dcf..11ffb69fe 100644
--- a/src/Fl_Window_Driver.cxx
+++ b/src/Fl_Window_Driver.cxx
@@ -262,15 +262,23 @@ bool Fl_Window_Driver::is_a_rescale_ = false;
void Fl_Window_Driver::resize_after_scale_change(int ns, float old_f, float new_f) {
screen_num(ns);
Fl_Graphics_Driver::default_driver().scale(new_f);
+ int X = pWindow->x()*old_f/new_f, Y = pWindow->y()*old_f/new_f;
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();
+ int sX, sY, sW, sH;
+ Fl::screen_xywh(sX, sY, sW, sH, ns); // bounding box of new screen
+ const int d = 5; // make sure new window centre is located in new screen
+ if (X+W/2 < sX) X = sX-W/2+d;
+ else if (X+W/2 > sX+sW-1) X = sX+sW-1-W/2-d;
+ if (Y+H/2 < sY) Y = sY-H/2+d;
+ else if (Y+H/2 > sY+sH-1) Y = sY+sH-1-H/2-d;
}
is_a_rescale_ = true;
size_range();
- pWindow->resize(pWindow->x()*old_f/new_f, pWindow->y()*old_f/new_f, W, H);
+ pWindow->resize(X, Y, W, H);
is_a_rescale_ = false;
}