diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2024-02-05 12:39:10 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2024-02-05 12:39:10 +0100 |
| commit | 676e976cb6de59fb12059cdf5a8ef99f8e8ee53f (patch) | |
| tree | b56a71f21ed4c2b3062f54c30dae51878ab30218 /src/Fl_Tooltip.cxx | |
| parent | 0da00995a8052119228e7a84e2a34440142504fb (diff) | |
Fl_Window_Driver::set_popup_window(), Fl_Screen_Driver::screen_boundaries_known()
Fl_Window_Driver::set_popup_window() is to be used to declare a window should be
positioned relatively to a previously mapped other window. This allows a platform
to process such windows differently from other windows if needed.
Menu and tooltip windows are so declared.
A call to Fl_Window_Driver::set_popup_window() also allows to distinguish a real
menu or tooltip window from a window marked by Fl_Window::set_menu_window()
or by Fl_Window::set_tooltip_window() but that's not a real menu or tooltip.
New member function bool Fl_Screen_Driver::screen_boundaries_known() returns
true by default. A platform where the position of windows inside a screen is hidden
(e.g., Wayland) returns false. This allows FLTK to refrain from trying to make sure
a computed position is inside a screen.
Diffstat (limited to 'src/Fl_Tooltip.cxx')
| -rw-r--r-- | src/Fl_Tooltip.cxx | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/Fl_Tooltip.cxx b/src/Fl_Tooltip.cxx index 5ae23f0ad..674c57a49 100644 --- a/src/Fl_Tooltip.cxx +++ b/src/Fl_Tooltip.cxx @@ -1,7 +1,7 @@ // // Tooltip source file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2015 by Bill Spitzak and others. +// Copyright 1998-2024 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -21,6 +21,7 @@ #include <FL/fl_string_functions.h> #include "Fl_System_Driver.H" #include "Fl_Window_Driver.H" +#include "Fl_Screen_Driver.H" #include <stdio.h> @@ -51,7 +52,7 @@ public: Fl_TooltipBox() : Fl_Menu_Window(0, 0) { set_override(); set_tooltip_window(); - Fl_Window_Driver::driver(this)->popup_window(true); + Fl_Window_Driver::driver(this)->set_popup_window(); end(); } void draw() FL_OVERRIDE; @@ -91,25 +92,28 @@ void Fl_TooltipBox::layout() { hh += (Fl_Tooltip::margin_height() * 2); // find position on the screen of the widget: - int ox = Fl::event_x_root(); - int oy = currentTooltipY + currentTooltipH+2; - for (Fl_Widget* p = Fl_Tooltip::current(); p; p = p->window()) { - oy += p->y(); - } - int scr_x = -100000, scr_y = -100000, scr_w = 1000000, scr_h = 1000000; - if (!Fl_Window_Driver::driver(this)->popup_window()) { - 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; + int ox = Fl::event_x_root(), oy; if (currentTooltipH > 30) { oy = Fl::event_y_root()+13; - if (oy+hh > scr_y+scr_h) oy -= 23+hh; } else { - if (oy+hh > scr_y+scr_h) oy -= (4+hh+currentTooltipH); + oy = currentTooltipY + currentTooltipH+2; + for (Fl_Widget* p = Fl_Tooltip::current(); p; p = p->window()) { + oy += p->y(); + } } - if (oy < scr_y) oy = scr_y; - + 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); + } + if (oy < scr_y) oy = scr_y; + } + resize(ox, oy, ww, hh); } |
