Fix "Wrong tooltip position on Wayland with secondary monitor" (#894)

This commit is contained in:
ManoloFLTK 2024-01-23 10:40:25 +01:00
parent 5cc5a60e09
commit da8d6c8d77

View File

@ -96,17 +96,19 @@ void Fl_TooltipBox::layout() {
for (Fl_Widget* p = Fl_Tooltip::current(); p; p = p->window()) { for (Fl_Widget* p = Fl_Tooltip::current(); p; p = p->window()) {
oy += p->y(); oy += p->y();
} }
int scr_x, scr_y, scr_w, scr_h; if (!Fl_Window_Driver::driver(this)->popup_window()) {
Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h); int scr_x, scr_y, scr_w, scr_h;
if (ox+ww > scr_x+scr_w) ox = scr_x+scr_w - ww; Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h);
if (ox < scr_x) ox = scr_x; if (ox+ww > scr_x+scr_w) ox = scr_x+scr_w - ww;
if (currentTooltipH > 30) { if (ox < scr_x) ox = scr_x;
oy = Fl::event_y_root()+13; if (currentTooltipH > 30) {
if (oy+hh > scr_y+scr_h) oy -= 23+hh; oy = Fl::event_y_root()+13;
} else { if (oy+hh > scr_y+scr_h) oy -= 23+hh;
if (oy+hh > scr_y+scr_h) oy -= (4+hh+currentTooltipH); } 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); resize(ox, oy, ww, hh);
} }