mirror of
https://github.com/fltk/fltk.git
synced 2026-05-25 17:42:14 +08:00
Updated 'hotspot' positioning of windows in OS X and WIN32 to keep the hotspotted window entirely on the screen that contaings the mouse pointer (STR #1599).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5696 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+32
-21
@@ -40,35 +40,46 @@ void Fl_Window::hotspot(int X, int Y, int offscreen) {
|
||||
// If offscreen is 0 (the default), make sure that the window
|
||||
// stays on the screen, if possible.
|
||||
if (!offscreen) {
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
// These will be used by reference, so we must passed different variables
|
||||
int bt,bx,by;
|
||||
x(X);y(Y);
|
||||
Fl_X::fake_X_wm(this, X, Y, bt, bx, by);
|
||||
//force FL_FORCE_POSITION to be set in Fl_Window::resize()
|
||||
if (X==x()) x(X-1);
|
||||
#else
|
||||
int scr_x, scr_y, scr_w, scr_h;
|
||||
Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h);
|
||||
|
||||
int top = 0;
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
int bottom = 0;
|
||||
|
||||
if (border()) {
|
||||
#ifdef WIN32
|
||||
if (size_range_set && (maxw != minw || maxh != minh)) {
|
||||
left = right = GetSystemMetrics(SM_CXSIZEFRAME);
|
||||
top = bottom = GetSystemMetrics(SM_CYSIZEFRAME);
|
||||
} else {
|
||||
ret = 1;
|
||||
left = right = GetSystemMetrics(SM_CXFIXEDFRAME);
|
||||
top = bottom = GetSystemMetrics(SM_CYFIXEDFRAME);
|
||||
}
|
||||
top += GetSystemMetrics(SM_CYCAPTION);
|
||||
#elif defined(__APPLE__)
|
||||
top = 24;
|
||||
left = 2;
|
||||
right = 2;
|
||||
bottom = 2;
|
||||
#else
|
||||
// Ensure border is on screen; these values are generic enough
|
||||
// to work with many window managers, and are based on KDE defaults.
|
||||
const int top = 20;
|
||||
const int left = 4;
|
||||
const int right = 4;
|
||||
const int bottom = 8;
|
||||
if (X+w()+right > scr_w-scr_x) X = scr_w-scr_x-right-w();
|
||||
if (X-left < scr_x) X = left;
|
||||
if (Y+h()+bottom > scr_h-scr_y) Y = scr_h-scr_y-bottom-h();
|
||||
if (Y-top < scr_y) Y = top;
|
||||
top = 20;
|
||||
left = 4;
|
||||
right = 4;
|
||||
bottom = 8;
|
||||
#endif
|
||||
}
|
||||
// now insure contents are on-screen (more important than border):
|
||||
if (X+w() > scr_w-scr_x) X = scr_w-scr_x-w();
|
||||
if (X < scr_x) X = scr_x;
|
||||
if (Y+h() > scr_h-scr_y) Y = scr_h-scr_y-h();
|
||||
if (Y < scr_y) Y = scr_y;
|
||||
#endif
|
||||
if (X+w()+right > scr_w-scr_x) X = scr_w-scr_x-right-w();
|
||||
if (X-left < scr_x) X = left;
|
||||
if (Y+h()+bottom > scr_h-scr_y) Y = scr_h-scr_y-bottom-h();
|
||||
if (Y-top < scr_y) Y = top;
|
||||
// make sure that we will force this position
|
||||
if (X==x()) x(X-1);
|
||||
}
|
||||
|
||||
position(X,Y);
|
||||
|
||||
Reference in New Issue
Block a user