diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-05-02 14:50:33 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-05-02 14:50:33 +0200 |
| commit | ef5bf602399c07ff534b28089d9e7baee98d9911 (patch) | |
| tree | 9b1c14da5c89d64794dc0970f81233a023ee9386 /src | |
| parent | cad6e632961c352f108233af039940387feffb9a (diff) | |
Wayland: problem with dropdown menus on secondary monitor (#724)
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index fc3d22801..eb7915e0e 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1069,6 +1069,7 @@ static const char *get_prog_name() { item, when there's one, is visible immediately after the tall popup is mapped on display. */ +static bool flip_gravity = false; bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_window) { // a menu window or tooltip @@ -1117,12 +1118,14 @@ bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_wi } if (parent_xid->kind == Fl_Wayland_Window_Driver::DECORATED) libdecor_frame_translate_coordinate(parent_xid->frame, popup_x, popup_y, &popup_x, &popup_y); + if (flip_gravity) {popup_y += pWindow->h();} xdg_positioner_set_anchor_rect(positioner, popup_x, popup_y, 1, 1); popup_y++; } xdg_positioner_set_size(positioner, pWindow->w() * f , pWindow->h() * f ); xdg_positioner_set_anchor(positioner, XDG_POSITIONER_ANCHOR_BOTTOM_LEFT); - xdg_positioner_set_gravity(positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT); + xdg_positioner_set_gravity(positioner, flip_gravity ? + XDG_POSITIONER_GRAVITY_TOP_RIGHT : XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT); // prevent menuwindow from expanding beyond display limits int constraint = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y; @@ -1274,7 +1277,23 @@ void Fl_Wayland_Window_Driver::makeWindow() Fl::e_number = old_event; // make sure each popup is mapped with its constraints before mapping next popup if (pWindow->menu_window() && !is_floatingtitle) { - pWindow->wait_for_expose(); // to map the popup + int count = 0; // attempt to map the menuwindow (i.e., until it appears on a screen) + while (!new_window->output && count <= 5) { + wl_display_roundtrip(scr_driver->wl_display); + count++; + } + if (!new_window->output) { +//printf("menuwindow doesn't map: count=%d\n",count); + // On a secondary display, the menuwindow may fail to map in what looks like + // a bug in the compositor. Bypass this problem by attempting again to create + // the menuwindow with another constraint: XDG_POSITIONER_GRAVITY_TOP_RIGHT + // instead of XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT. + pWindow->hide(); + flip_gravity = true; + pWindow->show(); + return; + } + flip_gravity = false; if (previous_floatingtitle) { // a menuwindow with a menutitle //puts("previous_floatingtitle"); int HH; |
