commit 3d7237be212a67c168c0740d2ef95808cb7ff161
Author: dannye <33dannye@gmail.com>
AuthorDate: Sat May 30 21:11:33 2026 -0500
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri Sep 25 15:19:02 2026 +0200
Ensure tooltip window uses the same scale as its widget's window
and ensure it appears on the same screen as the mouse pointer, clamped
fully onto the screen when possible.
src/Fl_Tooltip.cxx | 23 ++++++++++++++---------
src/Fl_win32.cxx | 2 +-
src/Fl_x.cxx | 6 +++---
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git src/Fl_Tooltip.cxx src/Fl_Tooltip.cxx
index b815753..d2146d7 100644
--- src/Fl_Tooltip.cxx
+++ src/Fl_Tooltip.cxx
@@ -105,17 +105,22 @@ void Fl_TooltipBox::layout() {
oy += p->y();
}
}
+ screen_num(Fl_Tooltip::current()->top_window()->screen_num());
if (Fl::screen_driver()->screen_boundaries_known()) {
- int scr_x, scr_y, scr_w, scr_h;
- Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h);
- if (ox+ww > scr_x+scr_w) ox = scr_x+scr_w - ww;
- if (ox < scr_x) ox = scr_x;
- if (currentTooltipH > 30) {
- if (oy+hh > scr_y+scr_h) oy -= 23+hh;
- } else {
- if (oy+hh > scr_y+scr_h) oy -= (4+hh+currentTooltipH);
+ int mx, my;
+ int nscreen = Fl::screen_driver()->get_mouse(mx, my);
+ if (screen_num() == nscreen) {
+ int scr_x, scr_y, scr_w, scr_h;
+ Fl::screen_driver()->screen_xywh(scr_x, scr_y, scr_w, scr_h, nscreen);
+ if (ox+ww > scr_x+scr_w) ox = scr_x+scr_w - ww;
+ if (ox < scr_x) ox = scr_x;
+ if (currentTooltipH > 30) {
+ if (oy+hh > scr_y+scr_h) oy -= 23+hh;
+ } else {
+ if (oy+hh > scr_y+scr_h) oy -= (4+hh+currentTooltipH);
+ }
+ if (oy < scr_y) oy = scr_y;
}
- if (oy < scr_y) oy = scr_y;
}
resize(ox, oy, ww, hh);
diff --git src/Fl_win32.cxx src/Fl_win32.cxx
index e4381d1..2681f9a 100644
--- src/Fl_win32.cxx
+++ src/Fl_win32.cxx
@@ -2373,7 +2373,7 @@ void Fl_WinAPI_Window_Driver::makeWindow() {
if (!force_position()) {
xp = yp = CW_USEDEFAULT;
} else {
- if (!Fl::grab()) {
+ if (!Fl::grab() && !w->tooltip_window()) {
xp = xwm;
yp = ywm;
x(int(round(xp / s)));
diff --git src/Fl_x.cxx src/Fl_x.cxx
index bdcd444..ffdeb8c 100644
--- src/Fl_x.cxx
+++ src/Fl_x.cxx
@@ -2250,7 +2250,7 @@ int fl_handle(const XEvent& thisevent)
int num = d->screen_num_unscaled(X+ actual.width/2, Y +actual.height/2);
if (num == -1) num = olds;
float s = d->scale(num);
- if (num != olds && !window->menu_window()) {
+ if (num != olds && !window->menu_window() && !window->tooltip_window()) {
if (Fl::modal() && Fl::modal()->menu_window()) { // is a menu window active?
Fl::e_x_root = 1000000;
Fl::modal()->handle(FL_PUSH); // simulate a distant click to close menus
@@ -2278,7 +2278,7 @@ int fl_handle(const XEvent& thisevent)
#if USE_XFT || FLTK_USE_CAIRO
if (!Fl_X11_Window_Driver::data_for_resize_window_between_screens_.busy &&
( ceil(W/s) != window->w() || ceil(H/s) != window->h() ) &&
- !window->menu_window()) {
+ !window->menu_window() && !window->tooltip_window()) {
window->resize(rint(X/s), rint(Y/s), ceil(W/s), ceil(H/s));
} else {
window->position(rint(X/s), rint(Y/s));
@@ -2596,7 +2596,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
if (W <= 0) W = 1; // X don't like zero...
int H = win->h();
if (H <= 0) H = 1; // X don't like zero...
- if (!win->parent() && !Fl::grab()) {
+ if (!win->parent() && !Fl::grab() && !win->tooltip_window()) {
// center windows in case window manager does not do anything:
#ifdef FL_CENTER_WINDOWS
if (!win->force_position()) {
[ Direct Link to Message ]