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.
This commit is contained in:
parent
0da00995a8
commit
676e976cb6
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Widget header file for the Fast Light Tool Kit (FLTK).
|
// Widget header file 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
|
// 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
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@ -181,6 +181,7 @@ protected:
|
|||||||
DEIMAGE_BOUND = 1<<22, ///< bind the inactive image to the widget, so the widget deletes the image when it is no longer needed
|
DEIMAGE_BOUND = 1<<22, ///< bind the inactive image to the widget, so the widget deletes the image when it is no longer needed
|
||||||
AUTO_DELETE_USER_DATA = 1<<23, ///< automatically call `delete` on the user_data pointer when destroying this widget; if set, user_data must point to a class derived from the class Fl_Callback_User_Data
|
AUTO_DELETE_USER_DATA = 1<<23, ///< automatically call `delete` on the user_data pointer when destroying this widget; if set, user_data must point to a class derived from the class Fl_Callback_User_Data
|
||||||
MAXIMIZED = 1<<24, ///< a maximized Fl_Window
|
MAXIMIZED = 1<<24, ///< a maximized Fl_Window
|
||||||
|
POPUP = 1<<25, ///< popup window (i.e., positioned relatively to another mapped window)
|
||||||
// Note to devs: add new FLTK core flags above this line (up to 1<<28).
|
// Note to devs: add new FLTK core flags above this line (up to 1<<28).
|
||||||
|
|
||||||
// Three more flags, reserved for user code
|
// Three more flags, reserved for user code
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Menu code for the Fast Light Tool Kit (FLTK).
|
// 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
|
// 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
|
// 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) {
|
Fl_Menu_Window(X, Y, W, H, 0) {
|
||||||
menu = m;
|
menu = m;
|
||||||
set_menu_window();
|
set_menu_window();
|
||||||
Fl_Window_Driver::driver(this)->popup_window(true);
|
Fl_Window_Driver::driver(this)->set_popup_window();
|
||||||
end();
|
end();
|
||||||
set_modal();
|
set_modal();
|
||||||
clear_border();
|
clear_border();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// All screen related calls in a driver style class.
|
// 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
|
// 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
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@ -123,6 +123,7 @@ public:
|
|||||||
H = 600;
|
H = 600;
|
||||||
}
|
}
|
||||||
void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
|
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);
|
||||||
virtual int screen_num(int x, int y, int w, int h);
|
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!
|
virtual void screen_dpi(float &h, float &v, int n = 0) { // FL_OVERRIDE in driver!
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Tooltip source file for the Fast Light Tool Kit (FLTK).
|
// 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
|
// 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
|
// 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/fl_string_functions.h>
|
||||||
#include "Fl_System_Driver.H"
|
#include "Fl_System_Driver.H"
|
||||||
#include "Fl_Window_Driver.H"
|
#include "Fl_Window_Driver.H"
|
||||||
|
#include "Fl_Screen_Driver.H"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ public:
|
|||||||
Fl_TooltipBox() : Fl_Menu_Window(0, 0) {
|
Fl_TooltipBox() : Fl_Menu_Window(0, 0) {
|
||||||
set_override();
|
set_override();
|
||||||
set_tooltip_window();
|
set_tooltip_window();
|
||||||
Fl_Window_Driver::driver(this)->popup_window(true);
|
Fl_Window_Driver::driver(this)->set_popup_window();
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
void draw() FL_OVERRIDE;
|
void draw() FL_OVERRIDE;
|
||||||
@ -91,24 +92,27 @@ void Fl_TooltipBox::layout() {
|
|||||||
hh += (Fl_Tooltip::margin_height() * 2);
|
hh += (Fl_Tooltip::margin_height() * 2);
|
||||||
|
|
||||||
// find position on the screen of the widget:
|
// find position on the screen of the widget:
|
||||||
int ox = Fl::event_x_root();
|
int ox = Fl::event_x_root(), oy;
|
||||||
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;
|
|
||||||
if (currentTooltipH > 30) {
|
if (currentTooltipH > 30) {
|
||||||
oy = Fl::event_y_root()+13;
|
oy = Fl::event_y_root()+13;
|
||||||
if (oy+hh > scr_y+scr_h) oy -= 23+hh;
|
|
||||||
} else {
|
} 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 (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;
|
||||||
}
|
}
|
||||||
if (oy < scr_y) oy = scr_y;
|
|
||||||
|
|
||||||
resize(ox, oy, ww, hh);
|
resize(ox, oy, ww, hh);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// A base class for platform specific window handling code
|
// A base class for platform specific window handling code
|
||||||
// for the Fast Light Tool Kit (FLTK).
|
// 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
|
// 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
|
// 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 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
|
// --- window data
|
||||||
virtual int decorated_w() { return w(); } // default, should be overidden by driver
|
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 *);
|
static void scroll_to_selected_item(Fl_Window *);
|
||||||
|
|
||||||
virtual fl_uintptr_t os_id() { return 0; }
|
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
|
#endif // FL_WINDOW_DRIVER_H
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Definition of the Wayland Screen interface
|
// Definition of the Wayland Screen interface
|
||||||
// for the Fast Light Tool Kit (FLTK).
|
// 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
|
// 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
|
// 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;
|
int get_key(int k) FL_OVERRIDE;
|
||||||
void enable_im() FL_OVERRIDE;
|
void enable_im() FL_OVERRIDE;
|
||||||
void disable_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
|
// overridden functions from parent class Fl_Unix_Screen_Driver
|
||||||
int poll_or_select_with_delay(double time_to_wait) FL_OVERRIDE;
|
int poll_or_select_with_delay(double time_to_wait) FL_OVERRIDE;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Definition of Wayland window driver for the Fast Light Tool Kit (FLTK).
|
// 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
|
// 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
|
// 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,
|
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 (*draw_area)(void*, int,int,int,int), void* data) FL_OVERRIDE;
|
||||||
void wait_for_expose() FL_OVERRIDE;
|
void wait_for_expose() FL_OVERRIDE;
|
||||||
void popup_window(bool v) FL_OVERRIDE;
|
|
||||||
bool popup_window() FL_OVERRIDE;
|
|
||||||
// menu-related stuff
|
// menu-related stuff
|
||||||
void reposition_menu_window(int x, int y) FL_OVERRIDE;
|
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;
|
void menu_window_area(int &X, int &Y, int &W, int &H, int nscreen = -1) FL_OVERRIDE;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Implementation of the Wayland window driver.
|
// 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
|
// 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
|
// 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()) return;
|
||||||
if (pWindow->parent() && !pWindow->window()->shown()) 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 = (struct wld_window *)calloc(1, sizeof *new_window);
|
||||||
new_window->fl_win = pWindow;
|
new_window->fl_win = pWindow;
|
||||||
wl_list_init(&new_window->outputs);
|
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
|
// 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();
|
Fl_Screen_Driver::transient_scale_parent = Fl::first_window();
|
||||||
pWindow->set_tooltip_window();
|
pWindow->set_tooltip_window();
|
||||||
popup_window(true);
|
set_popup_window();
|
||||||
pWindow->position(
|
pWindow->position(
|
||||||
(Fl_Screen_Driver::transient_scale_parent->w() - pWindow->w())/2 ,
|
(Fl_Screen_Driver::transient_scale_parent->w() - pWindow->w())/2 ,
|
||||||
(Fl_Screen_Driver::transient_scale_parent->h() - pWindow->h())/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 (W < 1) W = 1;
|
||||||
if (H < 1) H = 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);
|
pWindow->Fl_Group::resize(X,Y,W,H);
|
||||||
//fprintf(stderr, "resize: win=%p to %dx%d\n", pWindow, W, H);
|
//fprintf(stderr, "resize: win=%p to %dx%d\n", pWindow, W, H);
|
||||||
if (shown()) {pWindow->redraw();}
|
if (shown()) {pWindow->redraw();}
|
||||||
} else {
|
} else {
|
||||||
if (pWindow->parent() || popup_window()) {
|
x(X); y(Y);
|
||||||
x(X); y(Y);
|
|
||||||
//fprintf(stderr, "move menuwin=%p x()=%d\n", pWindow, X);
|
//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()) {
|
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;
|
struct wld_window *xid = (struct wld_window *)Fl_X::flx(pWindow)->xid;
|
||||||
if (xid->kind == DECORATED) libdecor_frame_unset_maximized(xid->frame);
|
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_;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user