mirror of https://github.com/fltk/fltk
Fix "Wayland: crash with set_menu_window()" (#892)
Fixes also a similar crash occuring after use of set_tooltip_window(). Two bool member variables are added to class Fl_Window_Driver to indicate true FLTK menu windows (i.e., created by Fl_Menu_Item::pulldown()) and true FLTK tooltip windows (i.e., Fl_Tooltip).
This commit is contained in:
parent
b5b839e4f0
commit
2fbf5bed0d
|
@ -115,6 +115,7 @@ protected:
|
|||
Fl_Menu_Window(X, Y, W, H, 0) {
|
||||
menu = m;
|
||||
set_menu_window();
|
||||
Fl_Window_Driver::driver(this)->fltk_menu_window = true;
|
||||
end();
|
||||
set_modal();
|
||||
clear_border();
|
||||
|
@ -183,13 +184,13 @@ Fl_Window *Fl_Window_Driver::menu_parent(int *display_height) {
|
|||
}
|
||||
|
||||
static menuwindow *to_menuwindow(Fl_Window *win) {
|
||||
if (!win->menu_window()) return NULL;
|
||||
if (!Fl_Window_Driver::driver(win)->fltk_menu_window) return false;
|
||||
return ((window_with_items*)win)->as_menuwindow();
|
||||
}
|
||||
|
||||
/** Returns whether win is a menutitle window */
|
||||
bool Fl_Window_Driver::is_menutitle(Fl_Window *win) {
|
||||
if (!win->menu_window()) return false;
|
||||
if (!Fl_Window_Driver::driver(win)->fltk_menu_window) return false;
|
||||
return (((window_with_items*)win)->as_menuwindow() == NULL);
|
||||
}
|
||||
|
||||
|
@ -233,7 +234,7 @@ int *Fl_Window_Driver::menu_offset_y(Fl_Window *win) {
|
|||
|
||||
/** Returns whether win is a non-menubar menutitle */
|
||||
bool Fl_Window_Driver::is_floating_title(Fl_Window *win) {
|
||||
if (!win->menu_window()) return false;
|
||||
if (!Fl_Window_Driver::driver(win)->fltk_menu_window) return false;
|
||||
Fl_Window *mwin = ((window_with_items*)win)->as_menuwindow();
|
||||
return !mwin && !((menutitle*)win)->in_menubar;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <FL/Fl.H>
|
||||
#include <FL/fl_string_functions.h>
|
||||
#include "Fl_System_Driver.H"
|
||||
#include "Fl_Window_Driver.H"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -50,6 +51,7 @@ public:
|
|||
Fl_TooltipBox() : Fl_Menu_Window(0, 0) {
|
||||
set_override();
|
||||
set_tooltip_window();
|
||||
Fl_Window_Driver::driver(this)->fltk_tooltip_window = true;
|
||||
end();
|
||||
}
|
||||
void draw() FL_OVERRIDE;
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
static fl_uintptr_t xid(const Fl_Window *win);
|
||||
static Fl_Window *find(fl_uintptr_t xid);
|
||||
int wait_for_expose_value;
|
||||
bool fltk_menu_window; // true for FLTK menu window
|
||||
bool fltk_tooltip_window; // true for FLTK tooltip window
|
||||
Fl_Image_Surface *other_xid; // offscreen bitmap (overlay and double-buffered windows)
|
||||
int screen_num();
|
||||
void screen_num(int n) { screen_num_ = n; }
|
||||
|
|
|
@ -43,6 +43,8 @@ Fl_Window_Driver::Fl_Window_Driver(Fl_Window *win)
|
|||
wait_for_expose_value = 0;
|
||||
other_xid = 0;
|
||||
screen_num_ = 0;
|
||||
fltk_menu_window = false;
|
||||
fltk_tooltip_window = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1394,12 +1394,13 @@ 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();
|
||||
fltk_tooltip_window = true;
|
||||
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
|
||||
if (fltk_menu_window || fltk_tooltip_window) { // a menu window or tooltip
|
||||
is_floatingtitle = process_menu_or_tooltip(new_window);
|
||||
|
||||
} else if (pWindow->border() && !pWindow->parent() ) { // a decorated window
|
||||
|
|
Loading…
Reference in New Issue