GTK: Cause the page-info popup to appear in the right place
To position the page-info window we have to tunnel all the way from the current scaffolding, via its top-level gui window, through to the toolbar. In the toolbar we look up the URL bar and then determine the screen coordinates of the scaffolding via the top level widget GTK semantics. Finally we place the page-info window 4 pixels down and right of the bottom-left of the entry box, which should look nice. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
14e506f89f
commit
4b8ed9b777
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue