diff --git a/frontends/gtk/page_info.c b/frontends/gtk/page_info.c index a3e2747b7..0d76a2f71 100644 --- a/frontends/gtk/page_info.c +++ b/frontends/gtk/page_info.c @@ -197,6 +197,10 @@ nserror nsgtk_page_info(struct browser_window *bw) gtk_window_set_screen(GTK_WINDOW(ncwin->dlg), gtk_widget_get_screen(GTK_WIDGET(scaffwin))); + /* Attempt to place the window in the right place */ + nsgtk_scaffolding_position_page_info(nsgtk_current_scaffolding(), + ncwin); + ncwin->core.drawing_area = GTK_DRAWING_AREA( gtk_builder_get_object(ncwin->builder, "PGIDrawingArea")); @@ -243,3 +247,12 @@ nserror nsgtk_page_info(struct browser_window *bw) return NSERROR_OK; } + +/* exported interface documented in gtk/page_info.h */ +void +nsgtk_page_info_set_position(struct nsgtk_pi_window *win, int x, int y) +{ + NSLOG(netsurf, INFO, "win=%p x=%d y=%d", win, x, y); + + gtk_window_move(GTK_WINDOW(win->dlg), x, y); +} diff --git a/frontends/gtk/page_info.h b/frontends/gtk/page_info.h index ad443fcfd..23e1e348c 100644 --- a/frontends/gtk/page_info.h +++ b/frontends/gtk/page_info.h @@ -27,4 +27,14 @@ */ nserror nsgtk_page_info(struct browser_window *bw); +/** + * Position the given page information window at the given + * coordinates. + * + * \param pi the page info window to position + * \param x the X coordinate for the top left of the window + * \param y the Y coordinate for the top left of the window + */ +void nsgtk_page_info_set_position(struct nsgtk_pi_window *pi, int x, int y); + #endif diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c index 030c6d488..0c8fd333d 100644 --- a/frontends/gtk/scaffolding.c +++ b/frontends/gtk/scaffolding.c @@ -1574,3 +1574,10 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) return gs; } + +/* exported interface documented in gtk/scaffolding.h */ +nserror nsgtk_scaffolding_position_page_info(struct nsgtk_scaffolding *gs, + struct nsgtk_pi_window *win) +{ + return nsgtk_window_position_page_info(gs->top_level, win); +} diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h index 1fae00394..95cd51a2a 100644 --- a/frontends/gtk/scaffolding.h +++ b/frontends/gtk/scaffolding.h @@ -27,6 +27,7 @@ struct hlcache_handle; struct gui_window; struct gui_search_web_table; struct nsurl; +struct nsgtk_pi_window; /** @@ -55,6 +56,15 @@ nserror nsgtk_scaffolding_throbber(struct gui_window* gw, bool active); */ nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs); +/** + * Position the page-info popup in the right place + * + * \param gs The scaffolding to position relative to + * \param win The page-info window to position + */ +nserror nsgtk_scaffolding_position_page_info(struct nsgtk_scaffolding *gs, + struct nsgtk_pi_window *win); + /** * open the burger menu */ diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c index f2b1d05c8..c6028c94b 100644 --- a/frontends/gtk/toolbar.c +++ b/frontends/gtk/toolbar.c @@ -3799,3 +3799,27 @@ nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb) return res; } + +/* exported interface documented in toolbar.h */ +nserror nsgtk_toolbar_position_page_info(struct nsgtk_toolbar *tb, + struct nsgtk_pi_window *win) +{ + struct nsgtk_toolbar_item *item = &tb->items[URL_BAR_ITEM]; + GtkWidget *widget = GTK_WIDGET(gtk_bin_get_child(GTK_BIN(item->button))); + gint rootx, rooty, x, y; + + if (gtk_widget_translate_coordinates(widget, + gtk_widget_get_toplevel(widget), + 0, + gtk_widget_get_allocated_height(widget) - 1, + &x, &y) != TRUE) { + return NSERROR_UNKNOWN; + } + + gtk_window_get_position(GTK_WINDOW(gtk_widget_get_toplevel(widget)), + &rootx, &rooty); + + nsgtk_page_info_set_position(win, rootx + x + 4, rooty + y + 4); + + return NSERROR_OK; +} diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h index 77c3bcda2..15740b52b 100644 --- a/frontends/gtk/toolbar.h +++ b/frontends/gtk/toolbar.h @@ -117,6 +117,15 @@ nserror nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb, nsgtk_toolbar_butt */ nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show); +/** + * position the page info window appropriately + * + * \param tb The toolbar to position relative to + * \param win The page-info window to position + */ +nserror nsgtk_toolbar_position_page_info(struct nsgtk_toolbar *tb, + struct nsgtk_pi_window *win); + /** * Initialise customization of toolbar entries diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index df1e58de6..601177d6f 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -1677,3 +1677,10 @@ nserror nsgtk_window_toolbar_update(void) } return NSERROR_OK; } + +/* exported interface documented in window.h */ +nserror nsgtk_window_position_page_info(struct gui_window *gw, + struct nsgtk_pi_window *win) +{ + return nsgtk_toolbar_position_page_info(gw->toolbar, win); +} diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h index b126a955f..36166d811 100644 --- a/frontends/gtk/window.h +++ b/frontends/gtk/window.h @@ -19,6 +19,8 @@ #ifndef NETSURF_GTK_WINDOW_H #define NETSURF_GTK_WINDOW_H 1 +struct nsgtk_pi_window; + extern struct gui_window_table *nsgtk_window_table; extern struct gui_search_web_table *nsgtk_search_web_table; @@ -95,5 +97,13 @@ GtkLayout *nsgtk_window_get_layout(struct gui_window *gw); */ nserror nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid); +/** + * position page_info appropriately + * + * \param gw The gui window handle to position relative to + * \param win The page-info window to position + */ +nserror nsgtk_window_position_page_info(struct gui_window *gw, + struct nsgtk_pi_window *win); #endif /* NETSURF_GTK_WINDOW_H */