From 1e1d2f18c6d797f7e49a71f998a82cb255b8bb58 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 5 Mar 2022 10:20:04 +0000 Subject: [PATCH] Obey decorator-specified width and height of tooltip frames on Haiku * src/haiku_support.cc (BWindow_dimensions): New functions. * src/haiku_support.h: Update prototypes. * src/haikufns.c (Fx_show_tip): Use actual dimensions, because the decorator might specify a minimum width and height for the tooltip frame. * src/haikuterm.c (haiku_update_size_hints): Ignore tooltip frames. --- src/haiku_support.cc | 10 ++++++++++ src/haiku_support.h | 3 +++ src/haikufns.c | 3 +++ src/haikuterm.c | 3 +++ 4 files changed, 19 insertions(+) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 20d04163fc9..057464c9088 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2080,6 +2080,16 @@ BWindow_set_offset (void *window, int x, int y) wn->MoveTo (x, y); } +void +BWindow_dimensions (void *window, int *width, int *height) +{ + BWindow *w = (BWindow *) window; + BRect frame = w->Frame (); + + *width = BE_RECT_WIDTH (frame); + *height = BE_RECT_HEIGHT (frame); +} + /* Iconify WINDOW. */ void BWindow_iconify (void *window) diff --git a/src/haiku_support.h b/src/haiku_support.h index 9d13cae47c2..04079edbbc5 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -939,6 +939,9 @@ extern "C" extern haiku_font_family_or_style * be_list_font_families (size_t *length); + extern void + BWindow_dimensions (void *window, int *width, int *height); + #ifdef __cplusplus extern void * find_appropriate_view_for_draw (void *vw); diff --git a/src/haikufns.c b/src/haikufns.c index ff5082030f1..545edb27ae0 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -2201,6 +2201,9 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, block_input (); void *wnd = FRAME_HAIKU_WINDOW (tip_f); BWindow_resize (wnd, width, height); + /* The window decorator might cause the actual width and height to + be larger than WIDTH and HEIGHT, so use the actual sizes. */ + BWindow_dimensions (wnd, &width, &height); BView_resize_to (FRAME_HAIKU_VIEW (tip_f), width, height); BView_set_view_cursor (FRAME_HAIKU_VIEW (tip_f), FRAME_OUTPUT_DATA (f)->current_cursor); diff --git a/src/haikuterm.c b/src/haikuterm.c index ac087e3bec5..c44b350c583 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -140,6 +140,9 @@ haiku_update_size_hints (struct frame *f) int base_width, base_height; eassert (FRAME_HAIKU_P (f) && FRAME_HAIKU_WINDOW (f)); + if (f->tooltip) + return; + base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0); -- 2.39.2