From 7227c29bbacbc796e9f549cf21e8bd978fde5114 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 13 Jan 2014 01:08:15 +0000 Subject: move window scroll getter and setter into operations table --- desktop/browser.c | 4 ++-- desktop/gui.h | 21 +++++++++++++++++++-- desktop/gui_factory.c | 8 +++++++- 3 files changed, 28 insertions(+), 5 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 6d260a538..3a286eecf 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -499,7 +499,7 @@ void browser_window_scroll_visible(struct browser_window *bw, void browser_window_set_scroll(struct browser_window *bw, int x, int y) { if (bw->window != NULL) { - gui_window_set_scroll(bw->window, x, y); + guit->window->set_scroll(bw->window, x, y); } else { if (bw->scroll_x != NULL) scrollbar_set(bw->scroll_x, x, false); @@ -2946,7 +2946,7 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y) if (bw->window != NULL) { /* Front end window */ - gui_window_get_scroll(bw->window, &bw->drag_start_scroll_x, + guit->window->get_scroll(bw->window, &bw->drag_start_scroll_x, &bw->drag_start_scroll_y); guit->window->scroll_start(bw->window); diff --git a/desktop/gui.h b/desktop/gui.h index 0b7bdcca6..bf922737b 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -94,6 +94,25 @@ struct gui_window_table { */ void (*update)(struct gui_window *g, const struct rect *rect); + /** + * Get the scroll position of a browser window. + * + * \param g gui_window + * \param sx receives x ordinate of point at top-left of window + * \param sy receives y ordinate of point at top-left of window + * \return true iff successful + */ + bool (*get_scroll)(struct gui_window *g, int *sx, int *sy); + + /** + * Set the scroll position of a browser window. + * + * \param g gui_window to scroll + * \param sx point to place at top-left of window + * \param sy point to place at top-left of window + */ + void (*set_scroll)(struct gui_window *g, int sx, int sy); + /* Optional entries */ @@ -179,8 +198,6 @@ struct gui_table { extern struct gui_table *guit; /* the gui vtable */ -bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy); -void gui_window_set_scroll(struct gui_window *g, int sx, int sy); void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled); void gui_window_update_extent(struct gui_window *g); diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index 9cf328557..a4cc1c9a9 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -52,7 +52,7 @@ static void gui_default_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1) { - gui_window_set_scroll(g, x0, y0); + guit->window->set_scroll(g, x0, y0); } static void gui_default_window_new_content(struct gui_window *g) @@ -86,6 +86,12 @@ static nserror verify_window_register(struct gui_window_table *gwt) if (gwt->update == NULL) { return NSERROR_BAD_PARAMETER; } + if (gwt->get_scroll == NULL) { + return NSERROR_BAD_PARAMETER; + } + if (gwt->set_scroll == NULL) { + return NSERROR_BAD_PARAMETER; + } /* fill in the optional entries with defaults */ if (gwt->set_title == NULL) { -- cgit v1.2.3