summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-10-23 11:15:04 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-10-23 11:15:04 +0200
commit39a157a7dd83e1626c9f67e0b09d6deb23aa7c76 (patch)
tree1d293a1dea40a80bbbb80e8dbea011b7ae51769b /src/drivers
parent17baeceb7ab90251f99c7909eb9eeca92aec5a05 (diff)
Wayland: implement transient scale factor windows as popups
as discussed in issue #794. Also, fix for macOS the use of the FL_FOCUS event for these transient windows
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 07bb5230d..bbd372797 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -1161,17 +1161,6 @@ static const struct xdg_popup_listener popup_listener = {
bool Fl_Wayland_Window_Driver::in_flush_ = false;
-// Compute the parent window of the transient scale window
-static Fl_Window *calc_transient_parent(int &center_x, int &center_y) {
- // Find top, the topmost window, but not a transient window itself
- Fl_Window *top = Fl::first_window()->top_window();
- while (top && top->user_data() == &Fl_Screen_Driver::transient_scale_display)
- top = Fl::next_window(top);
- center_x = top->w()/2; center_y = top->h()/2;
- return top;
-}
-
-
static const char *get_prog_name() {
pid_t pid = getpid();
char fname[100];
@@ -1255,6 +1244,8 @@ static const char *get_prog_name() {
item, when there's one, is visible immediately after the tall popup is mapped on display.
*/
+static Fl_Window *transient_parent = NULL; // used for transient scale windows
+
bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_window) {
// a menu window or tooltip
new_window->kind = Fl_Wayland_Window_Driver::POPUP;
@@ -1274,6 +1265,8 @@ bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_wi
Fl_Window_Driver::menu_title(pWindow);
}
Fl_Widget *target = (pWindow->tooltip_window() ? Fl_Tooltip::current() : NULL);
+ if (pWindow->user_data() == &Fl_Screen_Driver::transient_scale_display &&
+ transient_parent) target = transient_parent;
if (!target) target = Fl_Window_Driver::menu_parent();
if (!target) target = Fl::belowmouse();
if (!target) target = Fl::first_window();
@@ -1375,13 +1368,11 @@ void Fl_Wayland_Window_Driver::makeWindow()
if (pWindow->user_data() == &Fl_Screen_Driver::transient_scale_display &&
Fl::first_window()) {
- // put transient scale win at center of top window by making it a child of top
- int center_x, center_y;
- Fl_Window *top = calc_transient_parent(center_x, center_y);
- if (top) {
- top->add(pWindow);
- pWindow->position(center_x - pWindow->w()/2 , center_y - pWindow->h()/2);
- }
+ // put transient scale win at center of top window by making it a tooltip of top
+ transient_parent = Fl::first_window();
+ pWindow->set_tooltip_window();
+ pWindow->position((transient_parent->w() - pWindow->w())/2 ,
+ (transient_parent->h() - pWindow->h())/2);
}
if (pWindow->menu_window() || pWindow->tooltip_window()) { // a menu window or tooltip