diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Menu.cxx | 4 | ||||
| -rw-r--r-- | src/Fl_Screen_Driver.H | 3 | ||||
| -rw-r--r-- | src/Fl_Tooltip.cxx | 38 | ||||
| -rw-r--r-- | src/Fl_Window_Driver.H | 6 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Screen_Driver.H | 3 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.H | 4 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 27 |
7 files changed, 37 insertions, 48 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 4e17ec534..003cb6a17 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -1,7 +1,7 @@ // // Menu code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2023 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 @@ -115,7 +115,7 @@ protected: Fl_Menu_Window(X, Y, W, H, 0) { menu = m; set_menu_window(); - Fl_Window_Driver::driver(this)->popup_window(true); + Fl_Window_Driver::driver(this)->set_popup_window(); end(); set_modal(); clear_border(); diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H index bfff5b03d..f6da764a7 100644 --- a/src/Fl_Screen_Driver.H +++ b/src/Fl_Screen_Driver.H @@ -1,7 +1,7 @@ // // All screen related calls in a driver style class. // -// Copyright 1998-2022 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 @@ -123,6 +123,7 @@ public: H = 600; } void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh); + virtual bool screen_boundaries_known() { return true; } virtual int screen_num(int x, int y); virtual int screen_num(int x, int y, int w, int h); virtual void screen_dpi(float &h, float &v, int n = 0) { // FL_OVERRIDE in driver! 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); } diff --git a/src/Fl_Window_Driver.H b/src/Fl_Window_Driver.H index c85cc84d8..b7c8a6d07 100644 --- a/src/Fl_Window_Driver.H +++ b/src/Fl_Window_Driver.H @@ -2,7 +2,7 @@ // A base class for platform specific window handling code // for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2023 by Bill Spitzak and others. +// Copyright 2010-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 @@ -129,6 +129,8 @@ public: } void resize_after_scale_change(int ns, float old_f, float new_f); + void set_popup_window() { pWindow->set_flag(Fl_Window::POPUP); } + bool popup_window() const {return pWindow->flags() & Fl_Window::POPUP;} // --- window data virtual int decorated_w() { return w(); } // default, should be overidden by driver @@ -213,8 +215,6 @@ public: static void scroll_to_selected_item(Fl_Window *); virtual fl_uintptr_t os_id() { return 0; } - virtual void popup_window(bool v) {} - virtual bool popup_window() { return false; } }; #endif // FL_WINDOW_DRIVER_H diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H index 2b9580863..d5a7ed9ad 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H @@ -2,7 +2,7 @@ // Definition of the Wayland Screen interface // for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2023 by Bill Spitzak and others. +// Copyright 2010-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 @@ -170,6 +170,7 @@ public: int get_key(int k) FL_OVERRIDE; void enable_im() FL_OVERRIDE; void disable_im() FL_OVERRIDE; + bool screen_boundaries_known() FL_OVERRIDE { return false; } // overridden functions from parent class Fl_Unix_Screen_Driver int poll_or_select_with_delay(double time_to_wait) FL_OVERRIDE; diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H index 8d50fe3cf..e0eca821e 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H @@ -1,7 +1,7 @@ // // Definition of Wayland window driver for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2023 by Bill Spitzak and others. +// Copyright 2010-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 @@ -132,8 +132,6 @@ public: int scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, void (*draw_area)(void*, int,int,int,int), void* data) FL_OVERRIDE; void wait_for_expose() FL_OVERRIDE; - void popup_window(bool v) FL_OVERRIDE; - bool popup_window() FL_OVERRIDE; // menu-related stuff void reposition_menu_window(int x, int y) FL_OVERRIDE; void menu_window_area(int &X, int &Y, int &W, int &H, int nscreen = -1) FL_OVERRIDE; diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index dacfdde1d..5979ce0d9 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1,7 +1,7 @@ // // Implementation of the Wayland window driver. // -// Copyright 1998-2023 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 @@ -1377,6 +1377,9 @@ void Fl_Wayland_Window_Driver::makeWindow() if (pWindow->parent() && !pWindow->window()) return; if (pWindow->parent() && !pWindow->window()->shown()) return; + if (!pWindow->parent() && !popup_window()) { + x(0); y(0); // toplevel, non-popup windows must have origin at 0,0 + } new_window = (struct wld_window *)calloc(1, sizeof *new_window); new_window->fl_win = pWindow; wl_list_init(&new_window->outputs); @@ -1398,7 +1401,7 @@ void Fl_Wayland_Window_Driver::makeWindow() // put transient scale win at center of top window by making it a tooltip of top Fl_Screen_Driver::transient_scale_parent = Fl::first_window(); pWindow->set_tooltip_window(); - popup_window(true); + set_popup_window(); pWindow->position( (Fl_Screen_Driver::transient_scale_parent->w() - pWindow->w())/2 , (Fl_Screen_Driver::transient_scale_parent->h() - pWindow->h())/2); @@ -1849,20 +1852,12 @@ void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) { if (W < 1) W = 1; if (H < 1) H = 1; } - // toplevel, non-popup windows must have origin at 0,0 - if (!pWindow->parent() && !popup_window()) X = Y = 0; pWindow->Fl_Group::resize(X,Y,W,H); //fprintf(stderr, "resize: win=%p to %dx%d\n", pWindow, W, H); if (shown()) {pWindow->redraw();} } else { - if (pWindow->parent() || popup_window()) { - x(X); y(Y); + x(X); y(Y); //fprintf(stderr, "move menuwin=%p x()=%d\n", pWindow, X); - } else { - //"a deliberate design trait of Wayland makes application windows ignorant of - // their exact placement on screen" - x(0); y(0); - } } if (shown()) { @@ -2167,13 +2162,3 @@ void Fl_Wayland_Window_Driver::un_maximize() { struct wld_window *xid = (struct wld_window *)Fl_X::flx(pWindow)->xid; if (xid->kind == DECORATED) libdecor_frame_unset_maximized(xid->frame); } - - -void Fl_Wayland_Window_Driver::popup_window(bool v) { - is_popup_window_ = v; -} - - -bool Fl_Wayland_Window_Driver::popup_window() { - return is_popup_window_; -} |
