diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-10-24 09:43:23 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-10-24 09:43:23 +0200 |
| commit | 3868ea90bd2bd5fc194bb08ee4a267b4940bd232 (patch) | |
| tree | 676a715508deb9bab1d606db7f10194935427cd4 /src | |
| parent | 434e6a09ed793223aa3f7b6e9ab50a42d9c10aa4 (diff) | |
Wayland: implement scale factor windows as popups - cont'd
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Screen_Driver.H | 2 | ||||
| -rw-r--r-- | src/Fl_Screen_Driver.cxx | 23 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 18 |
3 files changed, 29 insertions, 14 deletions
diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H index 1b6e057ed..ec3de15c0 100644 --- a/src/Fl_Screen_Driver.H +++ b/src/Fl_Screen_Driver.H @@ -79,6 +79,8 @@ public: static const int fl_YValue; static const int fl_XNegative; static const int fl_YNegative; + // Used when transient scale windows are implemented as popups + static Fl_Window *transient_scale_parent; // key_table and key_table_size are used in fl_shortcut to translate key names struct Keyname { unsigned int key; diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index b3cc70c88..f9a40f132 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -384,9 +384,15 @@ void Fl_Screen_Driver::rescale_all_windows_from_screen(int screen, float f) } -static void del_transient_window(Fl_Window **pwin) { - delete *pwin; - *pwin = NULL; +static Fl_Window *transient_scale_window = NULL; +Fl_Window *Fl_Screen_Driver::transient_scale_parent = NULL; + + +static void del_transient_window(void *) { + Fl_Screen_Driver::transient_scale_parent = NULL; + delete (Fl_Image*)transient_scale_window->shape(); + delete transient_scale_window; + transient_scale_window = NULL; } @@ -430,15 +436,14 @@ void Fl_Screen_Driver::transient_scale_display(float f, int nscreen) win->set_non_modal(); Fl_Window_Driver::driver(win)->screen_num(nscreen); Fl_Window_Driver::driver(win)->force_position(1); - static Fl_Window *transient = NULL; - if (transient) { - Fl::remove_timeout((Fl_Timeout_Handler)del_transient_window); - delete transient; + if (transient_scale_window) { + Fl::remove_timeout(del_transient_window); + del_transient_window(NULL); } - transient = win; + transient_scale_window = win; win->show(); // delete transient win after 1 sec - Fl::add_timeout(1, (Fl_Timeout_Handler)del_transient_window, &transient); + Fl::add_timeout(1, del_transient_window, NULL); } // respond to Ctrl-'+' and Ctrl-'-' and Ctrl-'0' (Ctrl-'=' is same as Ctrl-'+') by rescaling all windows diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index bbd372797..73a8c442d 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -434,6 +434,11 @@ static void destroy_surface_caution_pointer_focus(struct wl_surface *surface, void Fl_Wayland_Window_Driver::hide() { + if (pWindow == Fl_Screen_Driver::transient_scale_parent) { + // Don't hide the parent of a running transient scale window + // because the transient is a popup and MUST be deleted first. + return; + } Fl_X* ip = Fl_X::flx(pWindow); if (hide_common()) return; if (ip->region) { @@ -1244,7 +1249,6 @@ 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 @@ -1266,7 +1270,9 @@ bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_wi } 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; + Fl_Screen_Driver::transient_scale_parent) { + target = Fl_Screen_Driver::transient_scale_parent; + } if (!target) target = Fl_Window_Driver::menu_parent(); if (!target) target = Fl::belowmouse(); if (!target) target = Fl::first_window(); @@ -1343,6 +1349,7 @@ bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_wi void Fl_Wayland_Window_Driver::makeWindow() { + Fl_Group::current(0); // get rid of very common user bug: forgot end() struct wld_window *new_window; bool is_floatingtitle = false; wait_for_expose_value = 1; @@ -1369,10 +1376,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 tooltip of top - transient_parent = Fl::first_window(); + Fl_Screen_Driver::transient_scale_parent = Fl::first_window(); pWindow->set_tooltip_window(); - pWindow->position((transient_parent->w() - pWindow->w())/2 , - (transient_parent->h() - pWindow->h())/2); + pWindow->position( + (Fl_Screen_Driver::transient_scale_parent->w() - pWindow->w())/2 , + (Fl_Screen_Driver::transient_scale_parent->h() - pWindow->h())/2); } if (pWindow->menu_window() || pWindow->tooltip_window()) { // a menu window or tooltip |
