Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/4b9aaee6cdfe9d38683db75ca0de52f45045596a
...commit
http://git.netsurf-browser.org/netsurf.git/commit/4b9aaee6cdfe9d38683db75ca0de52f45045596a
...tree
http://git.netsurf-browser.org/netsurf.git/tree/4b9aaee6cdfe9d38683db75ca0de52f45045596a
The branch, master has been updated
via 4b9aaee6cdfe9d38683db75ca0de52f45045596a (commit)
from e25eedab66d218e608d15fda593001b8073f3e67 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=4b9aaee6cdfe9d38683db75ca0de52f45045596a
commit 4b9aaee6cdfe9d38683db75ca0de52f45045596a
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
update framebuffer to have corewindow interface and use it for localhistory
diff --git a/frontends/framebuffer/Makefile b/frontends/framebuffer/Makefile
index 6d2acb0..760e85b 100644
--- a/frontends/framebuffer/Makefile
+++ b/frontends/framebuffer/Makefile
@@ -146,7 +146,7 @@ $(eval $(foreach V,$(filter
FB_FONT_$(NETSURF_FB_FONTLIB)_%,$(.VARIABLES)),$(cal
# S_FRONTEND are sources purely for the framebuffer build
S_FRONTEND := gui.c framebuffer.c schedule.c bitmap.c fetch.c \
- findfile.c localhistory.c clipboard.c
+ findfile.c corewindow.c local_history.c clipboard.c
# toolkit sources
S_FRAMEBUFFER_FBTK := fbtk.c event.c fill.c bitmap.c user.c window.c \
diff --git a/frontends/framebuffer/corewindow.c
b/frontends/framebuffer/corewindow.c
new file mode 100644
index 0000000..bde488a
--- /dev/null
+++ b/frontends/framebuffer/corewindow.c
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2017 Vincent Sanders <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * framebuffer generic core window interface.
+ *
+ * Provides interface for core renderers to the framebufefr toolkit
+ * drawable area.
+ *
+ * This module is an object that must be encapsulated. Client users
+ * should embed a struct fb_corewindow at the beginning of their
+ * context for this display surface, fill in relevant data and then
+ * call fb_corewindow_init()
+ *
+ * The fb core window structure requires the callback for draw, key and
+ * mouse operations.
+ */
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <libnsfb.h>
+#include <libnsfb_plot.h>
+#include <libnsfb_event.h>
+
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "utils/utf8.h"
+#include "utils/nsoption.h"
+#include "netsurf/keypress.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plot_style.h"
+
+#include "framebuffer/gui.h"
+#include "framebuffer/fbtk.h"
+#include "framebuffer/corewindow.h"
+
+
+/* toolkit event handlers that do generic things and call internal callbacks */
+
+
+static int
+fb_cw_mouse_press_event(fbtk_widget_t *widget, fbtk_callback_info *cbi)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)cbi->context;
+ browser_mouse_state state;
+
+ /** \todo frambuffer corewindow mouse event handling needs improving */
+ if (cbi->event->type != NSFB_EVENT_KEY_UP) {
+ state = BROWSER_MOUSE_HOVER;
+ } else {
+ state = BROWSER_MOUSE_PRESS_1;
+ }
+
+ fb_cw->mouse(fb_cw, state, cbi->x, cbi->y);
+
+ return 1;
+}
+
+/*
+static bool
+fb_cw_input_event(toolkit_widget *widget, void *ctx)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)ctx;
+
+ fb_cw->key(fb_cw, keycode);
+
+ return true;
+}
+*/
+
+/**
+ * handler for toolkit window redraw event
+ */
+static int fb_cw_draw_event(fbtk_widget_t *widget, fbtk_callback_info *cbi)
+{
+ struct fb_corewindow *fb_cw;
+ nsfb_bbox_t rbox;
+ struct rect clip;
+
+ fb_cw = (struct fb_corewindow *)cbi->context;
+
+ rbox.x0 = fbtk_get_absx(widget);
+ rbox.y0 = fbtk_get_absy(widget);
+
+ rbox.x1 = rbox.x0 + fbtk_get_width(widget);
+ rbox.y1 = rbox.y0 + fbtk_get_height(widget);
+
+ nsfb_claim(fbtk_get_nsfb(widget), &rbox);
+
+ clip.x0 = fb_cw->scrollx;
+ clip.y0 = fb_cw->scrolly;
+ clip.x1 = fbtk_get_width(widget) + fb_cw->scrollx;
+ clip.y1 = fbtk_get_height(widget) + fb_cw->scrolly;
+
+ fb_cw->draw(fb_cw, &clip);
+
+ nsfb_update(fbtk_get_nsfb(widget), &rbox);
+
+ return 0;
+}
+
+
+/**
+ * callback from core to request a redraw
+ */
+static nserror
+fb_cw_invalidate(struct core_window *cw, const struct rect *r)
+{
+/* struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ toolkit_widget_queue_draw_area(fb_cw->widget,
+ r->x0, r->y0,
+ r->x1 - r->x0, r->y1 - r->y0);
+*/
+ return NSERROR_OK;
+}
+
+
+static void
+fb_cw_update_size(struct core_window *cw, int width, int height)
+{
+/* struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ toolkit_widget_set_size_request(FB_WIDGET(fb_cw->drawing_area),
+ width, height);
+*/
+}
+
+
+static void
+fb_cw_scroll_visible(struct core_window *cw, const struct rect *r)
+{
+/* struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ toolkit_scroll_widget(fb_cw->widget, r);
+*/
+}
+
+
+static void
+fb_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ *width = fbtk_get_width(fb_cw->drawable);
+ *height = fbtk_get_height(fb_cw->drawable);
+}
+
+
+static void
+fb_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+ fb_cw->drag_staus = ds;
+}
+
+
+struct core_window_callback_table fb_cw_cb_table = {
+ .invalidate = fb_cw_invalidate,
+ .update_size = fb_cw_update_size,
+ .scroll_visible = fb_cw_scroll_visible,
+ .get_window_dimensions = fb_cw_get_window_dimensions,
+ .drag_status = fb_cw_drag_status
+};
+
+/* exported function documented fb/corewindow.h */
+nserror fb_corewindow_init(fbtk_widget_t *parent, struct fb_corewindow *fb_cw)
+{
+ int furniture_width;
+
+ furniture_width = nsoption_int(fb_furniture_size);
+
+ /* setup the core window callback table */
+ fb_cw->cb_table = &fb_cw_cb_table;
+
+ /* container window */
+ fb_cw->wnd = fbtk_create_window(parent, 0, 0, 0, 0, 0);
+
+ fb_cw->drawable = fbtk_create_user(fb_cw->wnd,
+ 0, 0,
+ -furniture_width, -furniture_width,
+ fb_cw);
+
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_REDRAW,
+ fb_cw_draw_event,
+ fb_cw);
+
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_CLICK,
+ fb_cw_mouse_press_event,
+ fb_cw);
+/*
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_INPUT,
+ fb_cw_input_event,
+ fb_cw);
+
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_POINTERMOVE,
+ fb_cw_move_event,
+ fb_cw);
+*/
+
+ /* create horizontal scrollbar */
+ fb_cw->hscroll = fbtk_create_hscroll(fb_cw->wnd,
+ 0,
+ fbtk_get_height(fb_cw->wnd) -
furniture_width,
+ fbtk_get_width(fb_cw->wnd) -
furniture_width,
+ furniture_width,
+ FB_SCROLL_COLOUR,
+ FB_FRAME_COLOUR,
+ NULL,
+ NULL);
+
+ fb_cw->vscroll = fbtk_create_vscroll(fb_cw->wnd,
+ fbtk_get_width(fb_cw->wnd) -
furniture_width,
+ 0,
+ furniture_width,
+ fbtk_get_height(fb_cw->wnd) -
furniture_width,
+ FB_SCROLL_COLOUR,
+ FB_FRAME_COLOUR,
+ NULL,
+ NULL);
+
+ fbtk_create_fill(fb_cw->wnd,
+ fbtk_get_width(fb_cw->wnd) - furniture_width,
+ fbtk_get_height(fb_cw->wnd) - furniture_width,
+ furniture_width,
+ furniture_width,
+ FB_FRAME_COLOUR);
+
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in fb/corewindow.h */
+nserror fb_corewindow_fini(struct fb_corewindow *fb_cw)
+{
+ return NSERROR_OK;
+}
diff --git a/frontends/framebuffer/corewindow.h
b/frontends/framebuffer/corewindow.h
new file mode 100644
index 0000000..ce15c74
--- /dev/null
+++ b/frontends/framebuffer/corewindow.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2017 Vincent Sanders <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FB_COREWINDOW_H
+#define FB_COREWINDOW_H
+
+#include "netsurf/core_window.h"
+
+/**
+ * fb core window state
+ */
+struct fb_corewindow {
+
+ /**
+ * framebuffer toolkit window.
+ */
+ struct fbtk_widget_s *wnd;
+ /**
+ * framebuffer toolkit horizontal scrollbar.
+ */
+ struct fbtk_widget_s *hscroll;
+ /**
+ * framebuffer toolkit vertical scrollbar.
+ */
+ struct fbtk_widget_s *vscroll;
+ /**
+ * framebuffer toolkit user drawable widget.
+ */
+ struct fbtk_widget_s *drawable;
+
+ int scrollx, scrolly; /**< scroll offsets. */
+
+
+ /** drag status set by core */
+ core_window_drag_status drag_staus;
+
+ /** table of callbacks for core window operations */
+ struct core_window_callback_table *cb_table;
+
+ /**
+ * callback to draw on drawable area of fb core window
+ *
+ * \param fb_cw The fb core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+ nserror (*draw)(struct fb_corewindow *fb_cw, struct rect *r);
+
+ /**
+ * callback for keypress on fb core window
+ *
+ * \param fb_cw The fb core window structure.
+ * \param nskey The netsurf key code.
+ * \return NSERROR_OK if key processed,
+ * NSERROR_NOT_IMPLEMENTED if key not processed
+ * otherwise apropriate error code
+ */
+ nserror (*key)(struct fb_corewindow *fb_cw, uint32_t nskey);
+
+ /**
+ * callback for mouse event on fb core window
+ *
+ * \param fb_cw The fb core window structure.
+ * \param mouse_state mouse state
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on sucess otherwise apropriate error code.
+ */
+ nserror (*mouse)(struct fb_corewindow *fb_cw, browser_mouse_state
mouse_state, int x, int y);
+};
+
+
+/**
+ * initialise elements of fb core window.
+ *
+ * As a pre-requisite the draw, key and mouse callbacks must be defined
+ *
+ * \param fb_cw A fb core window structure to initialise
+ * \return NSERROR_OK on successful initialisation otherwise error code.
+ */
+nserror fb_corewindow_init(fbtk_widget_t *parent, struct fb_corewindow *fb_cw);
+
+
+/**
+ * finalise elements of fb core window.
+ *
+ * \param fb_cw A fb core window structure to initialise
+ * \return NSERROR_OK on successful finalisation otherwise error code.
+ */
+nserror fb_corewindow_fini(struct fb_corewindow *fb_cw);
+
+#endif
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 062cb56..1460c77 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -54,6 +54,7 @@
#include "framebuffer/clipboard.h"
#include "framebuffer/fetch.h"
#include "framebuffer/bitmap.h"
+#include "framebuffer/local_history.h"
#define NSFB_TOOLBAR_DEFAULT_LAYOUT "blfsrutc"
@@ -1150,7 +1151,7 @@ fb_localhistory_btn_clik(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- fb_localhistory_map(gw->localhistory);
+ fb_local_history_present(fbtk, gw->bw);
return 0;
}
@@ -1782,7 +1783,6 @@ gui_window_create(struct browser_window *bw,
gw->bw = bw;
create_normal_browser_window(gw, nsoption_int(fb_furniture_size));
- gw->localhistory = fb_create_localhistory(bw, fbtk,
nsoption_int(fb_furniture_size));
/* map and request redraw of gui window */
fbtk_set_mapping(gw->window, true);
diff --git a/frontends/framebuffer/gui.h b/frontends/framebuffer/gui.h
index 0de1add..abb27c4 100644
--- a/frontends/framebuffer/gui.h
+++ b/frontends/framebuffer/gui.h
@@ -27,17 +27,6 @@ typedef struct fb_cursor_s fb_cursor_t;
/* bounding box */
typedef struct nsfb_bbox_s bbox_t;
-struct gui_localhistory {
- struct browser_window *bw;
-
- struct fbtk_widget_s *window;
- struct fbtk_widget_s *hscroll;
- struct fbtk_widget_s *vscroll;
- struct fbtk_widget_s *history;
-
- int scrollx, scrolly; /**< scroll offsets. */
-};
-
struct gui_window {
struct browser_window *bw;
@@ -59,8 +48,6 @@ struct gui_window {
int throbber_index;
- struct gui_localhistory *localhistory;
-
struct gui_window *next;
struct gui_window *prev;
};
@@ -68,13 +55,8 @@ struct gui_window {
extern struct gui_window *window_list;
-struct gui_localhistory *fb_create_localhistory(struct browser_window *bw,
- struct fbtk_widget_s *parent, int furniture_width);
-void fb_localhistory_map(struct gui_localhistory * glh);
-
void gui_resize(struct fbtk_widget_s *root, int width, int height);
-
#endif /* NETSURF_FB_GUI_H */
/*
diff --git a/frontends/framebuffer/local_history.c
b/frontends/framebuffer/local_history.c
new file mode 100644
index 0000000..5201298
--- /dev/null
+++ b/frontends/framebuffer/local_history.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2017 Vincent Sanders <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Implementation of framebuffer local history manager.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <libnsfb.h>
+#include <libnsfb_plot.h>
+#include <libnsfb_event.h>
+
+#include "utils/log.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "desktop/local_history.h"
+
+#include "framebuffer/gui.h"
+#include "framebuffer/fbtk.h"
+#include "framebuffer/framebuffer.h"
+#include "framebuffer/corewindow.h"
+#include "framebuffer/local_history.h"
+
+struct fb_local_history_window {
+ struct fb_corewindow core;
+
+ struct local_history_session *session;
+};
+
+static struct fb_local_history_window *local_history_window = NULL;
+
+
+/**
+ * callback for mouse action on local history window
+ *
+ * \param fb_cw The fb core window structure.
+ * \param mouse_state netsurf mouse state on event
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+fb_local_history_mouse(struct fb_corewindow *fb_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ struct fb_local_history_window *lhw;
+ /* technically degenerate container of */
+ lhw = (struct fb_local_history_window *)fb_cw;
+
+ local_history_mouse_action(lhw->session, mouse_state, x, y);
+
+ if (mouse_state != BROWSER_MOUSE_HOVER) {
+ fbtk_set_mapping(lhw->core.wnd, false);
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * callback for keypress on local history window
+ *
+ * \param fb_cw The fb core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+fb_local_history_key(struct fb_corewindow *fb_cw, uint32_t nskey)
+{
+ struct fb_local_history_window *lhw;
+ /* technically degenerate container of */
+ lhw = (struct fb_local_history_window *)fb_cw;
+
+ if (local_history_keypress(lhw->session, nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+
+/**
+ * callback on draw event for local history window
+ *
+ * \param fb_cw The fb core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+fb_local_history_draw(struct fb_corewindow *fb_cw, struct rect *r)
+{
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &fb_plotters
+ };
+ struct fb_local_history_window *lhw;
+
+ /* technically degenerate container of */
+ lhw = (struct fb_local_history_window *)fb_cw;
+
+ local_history_redraw(lhw->session, 0, 0, r, &ctx);
+
+ return NSERROR_OK;
+}
+
+/**
+ * Creates the window for the local history view.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+static nserror
+fb_local_history_init(fbtk_widget_t *parent,
+ struct browser_window *bw,
+ struct fb_local_history_window **win_out)
+{
+ struct fb_local_history_window *ncwin;
+ nserror res;
+
+ /* memoise window so it can be represented when necessary
+ * instead of recreating every time.
+ */
+ if ((*win_out) != NULL) {
+ res = local_history_set((*win_out)->session, bw);
+ return res;
+ }
+
+ ncwin = malloc(sizeof(struct fb_local_history_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ ncwin->core.draw = fb_local_history_draw;
+ ncwin->core.key = fb_local_history_key;
+ ncwin->core.mouse = fb_local_history_mouse;
+
+ res = fb_corewindow_init(parent, &ncwin->core);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ res = local_history_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin,
+ bw,
+ &ncwin->session);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ *win_out = ncwin;
+
+ return NSERROR_OK;
+}
+
+
+/* exported function documented gtk/history.h */
+nserror fb_local_history_present(fbtk_widget_t *parent,
+ struct browser_window *bw)
+{
+ nserror res;
+ int prnt_width, prnt_height;
+ int width, height;
+
+ res = fb_local_history_init(parent, bw, &local_history_window);
+ if (res == NSERROR_OK) {
+
+ prnt_width = fbtk_get_width(parent);
+ prnt_height = fbtk_get_height(parent);
+
+ /* resize history widget ensureing the drawing area is
+ * no larger than parent window
+ */
+ res = local_history_get_size(local_history_window->session,
+ &width,
+ &height);
+ if (width > prnt_width) {
+ width = prnt_width;
+ }
+ if (height > prnt_height) {
+ height = prnt_height;
+ }
+ /* should update scroll area with contents */
+
+ fbtk_set_zorder(local_history_window->core.wnd, INT_MIN);
+ fbtk_set_mapping(local_history_window->core.wnd, true);
+ }
+
+ return res;
+}
+
+
+/* exported function documented gtk/history.h */
+nserror fb_local_history_hide(void)
+{
+ nserror res = NSERROR_OK;
+
+ if (local_history_window != NULL) {
+ fbtk_set_mapping(local_history_window->core.wnd, false);
+
+ res = local_history_set(local_history_window->session, NULL);
+ }
+
+ return res;
+}
+
+
+/* exported function documented gtk/history.h */
+nserror fb_local_history_destroy(void)
+{
+ nserror res;
+
+ if (local_history_window == NULL) {
+ return NSERROR_OK;
+ }
+
+ res = local_history_fini(local_history_window->session);
+ if (res == NSERROR_OK) {
+ res = fb_corewindow_fini(&local_history_window->core);
+ //gtk_widget_destroy(GTK_WIDGET(local_history_window->wnd));
+ free(local_history_window);
+ local_history_window = NULL;
+ }
+
+ return res;
+
+}
diff --git a/frontends/framebuffer/local_history.h
b/frontends/framebuffer/local_history.h
new file mode 100644
index 0000000..929eeac
--- /dev/null
+++ b/frontends/framebuffer/local_history.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017 Vincent Sanders <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Interface to framebuffer local history manager
+ */
+
+#ifndef FB_LOCAL_HISTORY_H
+#define FB_LOCAL_HISTORY_H
+
+struct browser_window;
+
+/**
+ * make the local history window visible.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror fb_local_history_present(fbtk_widget_t *parent, struct browser_window
*bw);
+
+/**
+ * hide the local history window from being visible.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror fb_local_history_hide(void);
+
+/**
+ * Destroys the local history window and performs any other necessary cleanup
+ * actions.
+ */
+nserror fb_local_history_destroy(void);
+
+#endif
diff --git a/frontends/framebuffer/localhistory.c
b/frontends/framebuffer/localhistory.c
deleted file mode 100644
index b91c947..0000000
--- a/frontends/framebuffer/localhistory.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2010 Vincent Sanders <[email protected]>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <limits.h>
-
-#include <libnsfb.h>
-#include <libnsfb_plot.h>
-#include <libnsfb_event.h>
-
-#include "desktop/browser_history.h"
-#include "netsurf/plotters.h"
-
-#include "framebuffer/gui.h"
-#include "framebuffer/fbtk.h"
-#include "framebuffer/framebuffer.h"
-
-static int
-localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
-{
- struct gui_localhistory *glh = cbi->context;
- nsfb_bbox_t rbox;
- struct rect clip;
-
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &fb_plotters
- };
-
- rbox.x0 = fbtk_get_absx(widget);
- rbox.y0 = fbtk_get_absy(widget);
-
- rbox.x1 = rbox.x0 + fbtk_get_width(widget);
- rbox.y1 = rbox.y0 + fbtk_get_height(widget);
-
- nsfb_claim(fbtk_get_nsfb(widget), &rbox);
-
- nsfb_plot_rectangle_fill(fbtk_get_nsfb(widget), &rbox, 0xffffffff);
-
- clip.x0 = glh->scrollx;
- clip.y0 = glh->scrolly;
- clip.x1 = fbtk_get_width(widget) + glh->scrollx;
- clip.y0 = fbtk_get_height(widget) + glh->scrolly;
-
- browser_window_history_redraw_rectangle(glh->bw,
- &clip, 0, 0, &ctx);
-
- nsfb_update(fbtk_get_nsfb(widget), &rbox);
-
- return 0;
-}
-
-static int
-localhistory_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
-{
- struct gui_localhistory *glh = cbi->context;
-
- if (cbi->event->type != NSFB_EVENT_KEY_UP)
- return 0;
-
- browser_window_history_click(glh->bw, cbi->x, cbi->y, false);
-
- fbtk_set_mapping(glh->window, false);
-
- return 1;
-}
-
-struct gui_localhistory *
-fb_create_localhistory(struct browser_window *bw,
- fbtk_widget_t *parent,
- int furniture_width)
-{
- struct gui_localhistory *glh;
- glh = calloc(1, sizeof(struct gui_localhistory));
-
- if (glh == NULL)
- return NULL;
-
- glh->bw = bw;
-
- /* container window */
- glh->window = fbtk_create_window(parent, 0, 0, 0, 0, 0);
-
- glh->history = fbtk_create_user(glh->window, 0, 0, -furniture_width,
-furniture_width, glh);
-
- fbtk_set_handler(glh->history, FBTK_CBT_REDRAW, localhistory_redraw,
glh);
- fbtk_set_handler(glh->history, FBTK_CBT_CLICK, localhistory_click, glh);
- /*
- fbtk_set_handler(gw->localhistory, FBTK_CBT_INPUT,
fb_browser_window_input, gw);
- fbtk_set_handler(gw->localhistory, FBTK_CBT_POINTERMOVE,
fb_browser_window_move, bw);
- */
-
- /* create horizontal scrollbar */
- glh->hscroll = fbtk_create_hscroll(glh->window,
- 0,
- fbtk_get_height(glh->window) -
furniture_width,
- fbtk_get_width(glh->window) -
furniture_width,
- furniture_width,
- FB_SCROLL_COLOUR,
- FB_FRAME_COLOUR,
- NULL,
- NULL);
-
- glh->vscroll = fbtk_create_vscroll(glh->window,
- fbtk_get_width(glh->window) -
furniture_width,
- 0,
- furniture_width,
- fbtk_get_height(glh->window) -
furniture_width,
- FB_SCROLL_COLOUR,
- FB_FRAME_COLOUR,
- NULL,
- NULL);
-
- fbtk_create_fill(glh->window,
- fbtk_get_width(glh->window) - furniture_width,
- fbtk_get_height(glh->window) - furniture_width,
- furniture_width,
- furniture_width,
- FB_FRAME_COLOUR);
-
- return glh;
-}
-
-void
-fb_localhistory_map(struct gui_localhistory * glh)
-{
- fbtk_set_zorder(glh->window, INT_MIN);
- fbtk_set_mapping(glh->window, true);
-}
-----------------------------------------------------------------------
Summary of changes:
frontends/framebuffer/Makefile | 2 +-
frontends/framebuffer/corewindow.c | 261 +++++++++++++++++++++++
frontends/{windows => framebuffer}/corewindow.h | 85 ++++----
frontends/framebuffer/gui.c | 4 +-
frontends/framebuffer/gui.h | 18 --
frontends/{gtk => framebuffer}/local_history.c | 131 +++++-------
frontends/{gtk => framebuffer}/local_history.h | 14 +-
frontends/framebuffer/localhistory.c | 146 -------------
8 files changed, 367 insertions(+), 294 deletions(-)
create mode 100644 frontends/framebuffer/corewindow.c
copy frontends/{windows => framebuffer}/corewindow.h (50%)
copy frontends/{gtk => framebuffer}/local_history.c (56%)
copy frontends/{gtk => framebuffer}/local_history.h (76%)
delete mode 100644 frontends/framebuffer/localhistory.c
diff --git a/frontends/framebuffer/Makefile b/frontends/framebuffer/Makefile
index 6d2acb0..760e85b 100644
--- a/frontends/framebuffer/Makefile
+++ b/frontends/framebuffer/Makefile
@@ -146,7 +146,7 @@ $(eval $(foreach V,$(filter
FB_FONT_$(NETSURF_FB_FONTLIB)_%,$(.VARIABLES)),$(cal
# S_FRONTEND are sources purely for the framebuffer build
S_FRONTEND := gui.c framebuffer.c schedule.c bitmap.c fetch.c \
- findfile.c localhistory.c clipboard.c
+ findfile.c corewindow.c local_history.c clipboard.c
# toolkit sources
S_FRAMEBUFFER_FBTK := fbtk.c event.c fill.c bitmap.c user.c window.c \
diff --git a/frontends/framebuffer/corewindow.c
b/frontends/framebuffer/corewindow.c
new file mode 100644
index 0000000..bde488a
--- /dev/null
+++ b/frontends/framebuffer/corewindow.c
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2017 Vincent Sanders <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * framebuffer generic core window interface.
+ *
+ * Provides interface for core renderers to the framebufefr toolkit
+ * drawable area.
+ *
+ * This module is an object that must be encapsulated. Client users
+ * should embed a struct fb_corewindow at the beginning of their
+ * context for this display surface, fill in relevant data and then
+ * call fb_corewindow_init()
+ *
+ * The fb core window structure requires the callback for draw, key and
+ * mouse operations.
+ */
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <libnsfb.h>
+#include <libnsfb_plot.h>
+#include <libnsfb_event.h>
+
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "utils/utf8.h"
+#include "utils/nsoption.h"
+#include "netsurf/keypress.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plot_style.h"
+
+#include "framebuffer/gui.h"
+#include "framebuffer/fbtk.h"
+#include "framebuffer/corewindow.h"
+
+
+/* toolkit event handlers that do generic things and call internal callbacks */
+
+
+static int
+fb_cw_mouse_press_event(fbtk_widget_t *widget, fbtk_callback_info *cbi)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)cbi->context;
+ browser_mouse_state state;
+
+ /** \todo frambuffer corewindow mouse event handling needs improving */
+ if (cbi->event->type != NSFB_EVENT_KEY_UP) {
+ state = BROWSER_MOUSE_HOVER;
+ } else {
+ state = BROWSER_MOUSE_PRESS_1;
+ }
+
+ fb_cw->mouse(fb_cw, state, cbi->x, cbi->y);
+
+ return 1;
+}
+
+/*
+static bool
+fb_cw_input_event(toolkit_widget *widget, void *ctx)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)ctx;
+
+ fb_cw->key(fb_cw, keycode);
+
+ return true;
+}
+*/
+
+/**
+ * handler for toolkit window redraw event
+ */
+static int fb_cw_draw_event(fbtk_widget_t *widget, fbtk_callback_info *cbi)
+{
+ struct fb_corewindow *fb_cw;
+ nsfb_bbox_t rbox;
+ struct rect clip;
+
+ fb_cw = (struct fb_corewindow *)cbi->context;
+
+ rbox.x0 = fbtk_get_absx(widget);
+ rbox.y0 = fbtk_get_absy(widget);
+
+ rbox.x1 = rbox.x0 + fbtk_get_width(widget);
+ rbox.y1 = rbox.y0 + fbtk_get_height(widget);
+
+ nsfb_claim(fbtk_get_nsfb(widget), &rbox);
+
+ clip.x0 = fb_cw->scrollx;
+ clip.y0 = fb_cw->scrolly;
+ clip.x1 = fbtk_get_width(widget) + fb_cw->scrollx;
+ clip.y1 = fbtk_get_height(widget) + fb_cw->scrolly;
+
+ fb_cw->draw(fb_cw, &clip);
+
+ nsfb_update(fbtk_get_nsfb(widget), &rbox);
+
+ return 0;
+}
+
+
+/**
+ * callback from core to request a redraw
+ */
+static nserror
+fb_cw_invalidate(struct core_window *cw, const struct rect *r)
+{
+/* struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ toolkit_widget_queue_draw_area(fb_cw->widget,
+ r->x0, r->y0,
+ r->x1 - r->x0, r->y1 - r->y0);
+*/
+ return NSERROR_OK;
+}
+
+
+static void
+fb_cw_update_size(struct core_window *cw, int width, int height)
+{
+/* struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ toolkit_widget_set_size_request(FB_WIDGET(fb_cw->drawing_area),
+ width, height);
+*/
+}
+
+
+static void
+fb_cw_scroll_visible(struct core_window *cw, const struct rect *r)
+{
+/* struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ toolkit_scroll_widget(fb_cw->widget, r);
+*/
+}
+
+
+static void
+fb_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+
+ *width = fbtk_get_width(fb_cw->drawable);
+ *height = fbtk_get_height(fb_cw->drawable);
+}
+
+
+static void
+fb_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
+{
+ struct fb_corewindow *fb_cw = (struct fb_corewindow *)cw;
+ fb_cw->drag_staus = ds;
+}
+
+
+struct core_window_callback_table fb_cw_cb_table = {
+ .invalidate = fb_cw_invalidate,
+ .update_size = fb_cw_update_size,
+ .scroll_visible = fb_cw_scroll_visible,
+ .get_window_dimensions = fb_cw_get_window_dimensions,
+ .drag_status = fb_cw_drag_status
+};
+
+/* exported function documented fb/corewindow.h */
+nserror fb_corewindow_init(fbtk_widget_t *parent, struct fb_corewindow *fb_cw)
+{
+ int furniture_width;
+
+ furniture_width = nsoption_int(fb_furniture_size);
+
+ /* setup the core window callback table */
+ fb_cw->cb_table = &fb_cw_cb_table;
+
+ /* container window */
+ fb_cw->wnd = fbtk_create_window(parent, 0, 0, 0, 0, 0);
+
+ fb_cw->drawable = fbtk_create_user(fb_cw->wnd,
+ 0, 0,
+ -furniture_width, -furniture_width,
+ fb_cw);
+
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_REDRAW,
+ fb_cw_draw_event,
+ fb_cw);
+
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_CLICK,
+ fb_cw_mouse_press_event,
+ fb_cw);
+/*
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_INPUT,
+ fb_cw_input_event,
+ fb_cw);
+
+ fbtk_set_handler(fb_cw->drawable,
+ FBTK_CBT_POINTERMOVE,
+ fb_cw_move_event,
+ fb_cw);
+*/
+
+ /* create horizontal scrollbar */
+ fb_cw->hscroll = fbtk_create_hscroll(fb_cw->wnd,
+ 0,
+ fbtk_get_height(fb_cw->wnd) -
furniture_width,
+ fbtk_get_width(fb_cw->wnd) -
furniture_width,
+ furniture_width,
+ FB_SCROLL_COLOUR,
+ FB_FRAME_COLOUR,
+ NULL,
+ NULL);
+
+ fb_cw->vscroll = fbtk_create_vscroll(fb_cw->wnd,
+ fbtk_get_width(fb_cw->wnd) -
furniture_width,
+ 0,
+ furniture_width,
+ fbtk_get_height(fb_cw->wnd) -
furniture_width,
+ FB_SCROLL_COLOUR,
+ FB_FRAME_COLOUR,
+ NULL,
+ NULL);
+
+ fbtk_create_fill(fb_cw->wnd,
+ fbtk_get_width(fb_cw->wnd) - furniture_width,
+ fbtk_get_height(fb_cw->wnd) - furniture_width,
+ furniture_width,
+ furniture_width,
+ FB_FRAME_COLOUR);
+
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in fb/corewindow.h */
+nserror fb_corewindow_fini(struct fb_corewindow *fb_cw)
+{
+ return NSERROR_OK;
+}
diff --git a/frontends/windows/corewindow.h b/frontends/framebuffer/corewindow.h
similarity index 50%
copy from frontends/windows/corewindow.h
copy to frontends/framebuffer/corewindow.h
index b78c72e..ce15c74 100644
--- a/frontends/windows/corewindow.h
+++ b/frontends/framebuffer/corewindow.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Vincent Sanders <[email protected]>
+ * Copyright 2017 Vincent Sanders <[email protected]>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,95 +16,92 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NETSURF_WINDOWS_COREWINDOW_H
-#define NETSURF_WINDOWS_COREWINDOW_H
+#ifndef FB_COREWINDOW_H
+#define FB_COREWINDOW_H
#include "netsurf/core_window.h"
/**
- * nsw32 core window state
+ * fb core window state
*/
-struct nsw32_corewindow {
- /** window handle */
- HWND hWnd;
+struct fb_corewindow {
- /** content width */
- int content_width;
+ /**
+ * framebuffer toolkit window.
+ */
+ struct fbtk_widget_s *wnd;
+ /**
+ * framebuffer toolkit horizontal scrollbar.
+ */
+ struct fbtk_widget_s *hscroll;
+ /**
+ * framebuffer toolkit vertical scrollbar.
+ */
+ struct fbtk_widget_s *vscroll;
+ /**
+ * framebuffer toolkit user drawable widget.
+ */
+ struct fbtk_widget_s *drawable;
+
+ int scrollx, scrolly; /**< scroll offsets. */
- /** content height */
- int content_height;
- /** window title */
- const char *title;
-
/** drag status set by core */
core_window_drag_status drag_staus;
/** table of callbacks for core window operations */
struct core_window_callback_table *cb_table;
-
+
/**
- * callback to draw on drawable area of nsw32 core window
+ * callback to draw on drawable area of fb core window
*
- * \param nsw32_cw The nsw32 core window structure.
+ * \param fb_cw The fb core window structure.
* \param r The rectangle of the window that needs updating.
* \return NSERROR_OK on success otherwise apropriate error code
*/
- nserror (*draw)(struct nsw32_corewindow *nsw32_cw, int scrollx, int
scrolly, struct rect *r);
+ nserror (*draw)(struct fb_corewindow *fb_cw, struct rect *r);
/**
- * callback for keypress on nsw32 core window
+ * callback for keypress on fb core window
*
- * \param nsw32_cw The nsw32 core window structure.
+ * \param fb_cw The fb core window structure.
* \param nskey The netsurf key code.
* \return NSERROR_OK if key processed,
* NSERROR_NOT_IMPLEMENTED if key not processed
* otherwise apropriate error code
*/
- nserror (*key)(struct nsw32_corewindow *nsw32_cw, uint32_t nskey);
+ nserror (*key)(struct fb_corewindow *fb_cw, uint32_t nskey);
/**
- * callback for mouse event on nsw32 core window
+ * callback for mouse event on fb core window
*
- * \param nsw32_cw The nsw32 core window structure.
+ * \param fb_cw The fb core window structure.
* \param mouse_state mouse state
* \param x location of event
* \param y location of event
* \return NSERROR_OK on sucess otherwise apropriate error code.
*/
- nserror (*mouse)(struct nsw32_corewindow *nsw32_cw,
browser_mouse_state mouse_state, int x, int y);
-
- /**
- * callback for window close event
- *
- * \param nsw32_cw The nsw32 core window structure.
- * \return NSERROR_OK on sucess otherwise apropriate error code.
- */
- nserror (*close)(struct nsw32_corewindow *nsw32_cw);
+ nserror (*mouse)(struct fb_corewindow *fb_cw, browser_mouse_state
mouse_state, int x, int y);
};
+
/**
- * initialise elements of nsw32 core window.
+ * initialise elements of fb core window.
*
* As a pre-requisite the draw, key and mouse callbacks must be defined
*
- * \param hInstance The instance to create the core window in
- * \param hWndParent parent window handle may be NULL for top level window.
- * \param nsw32_cw A nsw32 core window structure to initialise
+ * \param fb_cw A fb core window structure to initialise
* \return NSERROR_OK on successful initialisation otherwise error code.
*/
-nserror nsw32_corewindow_init(HINSTANCE hInstance,
- HWND hWndParent,
- struct nsw32_corewindow *nsw32_cw);
+nserror fb_corewindow_init(fbtk_widget_t *parent, struct fb_corewindow *fb_cw);
+
/**
- * finalise elements of nsw32 core window.
+ * finalise elements of fb core window.
*
- * \param nsw32_cw A nsw32 core window structure to initialise
+ * \param fb_cw A fb core window structure to initialise
* \return NSERROR_OK on successful finalisation otherwise error code.
*/
-nserror nsw32_corewindow_fini(struct nsw32_corewindow *nsw32_cw);
-
-nserror nsw32_create_corewindow_class(HINSTANCE hInstance);
+nserror fb_corewindow_fini(struct fb_corewindow *fb_cw);
#endif
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 062cb56..1460c77 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -54,6 +54,7 @@
#include "framebuffer/clipboard.h"
#include "framebuffer/fetch.h"
#include "framebuffer/bitmap.h"
+#include "framebuffer/local_history.h"
#define NSFB_TOOLBAR_DEFAULT_LAYOUT "blfsrutc"
@@ -1150,7 +1151,7 @@ fb_localhistory_btn_clik(fbtk_widget_t *widget,
fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- fb_localhistory_map(gw->localhistory);
+ fb_local_history_present(fbtk, gw->bw);
return 0;
}
@@ -1782,7 +1783,6 @@ gui_window_create(struct browser_window *bw,
gw->bw = bw;
create_normal_browser_window(gw, nsoption_int(fb_furniture_size));
- gw->localhistory = fb_create_localhistory(bw, fbtk,
nsoption_int(fb_furniture_size));
/* map and request redraw of gui window */
fbtk_set_mapping(gw->window, true);
diff --git a/frontends/framebuffer/gui.h b/frontends/framebuffer/gui.h
index 0de1add..abb27c4 100644
--- a/frontends/framebuffer/gui.h
+++ b/frontends/framebuffer/gui.h
@@ -27,17 +27,6 @@ typedef struct fb_cursor_s fb_cursor_t;
/* bounding box */
typedef struct nsfb_bbox_s bbox_t;
-struct gui_localhistory {
- struct browser_window *bw;
-
- struct fbtk_widget_s *window;
- struct fbtk_widget_s *hscroll;
- struct fbtk_widget_s *vscroll;
- struct fbtk_widget_s *history;
-
- int scrollx, scrolly; /**< scroll offsets. */
-};
-
struct gui_window {
struct browser_window *bw;
@@ -59,8 +48,6 @@ struct gui_window {
int throbber_index;
- struct gui_localhistory *localhistory;
-
struct gui_window *next;
struct gui_window *prev;
};
@@ -68,13 +55,8 @@ struct gui_window {
extern struct gui_window *window_list;
-struct gui_localhistory *fb_create_localhistory(struct browser_window *bw,
- struct fbtk_widget_s *parent, int furniture_width);
-void fb_localhistory_map(struct gui_localhistory * glh);
-
void gui_resize(struct fbtk_widget_s *root, int width, int height);
-
#endif /* NETSURF_FB_GUI_H */
/*
diff --git a/frontends/gtk/local_history.c
b/frontends/framebuffer/local_history.c
similarity index 56%
copy from frontends/gtk/local_history.c
copy to frontends/framebuffer/local_history.c
index b36ccd2..5201298 100644
--- a/frontends/gtk/local_history.c
+++ b/frontends/framebuffer/local_history.c
@@ -18,58 +18,62 @@
/**
* \file
- * Implementation of GTK local history manager.
+ * Implementation of framebuffer local history manager.
*/
#include <stdint.h>
+#include <stdbool.h>
#include <stdlib.h>
-#include <gtk/gtk.h>
+#include <limits.h>
+
+#include <libnsfb.h>
+#include <libnsfb_plot.h>
+#include <libnsfb_event.h>
#include "utils/log.h"
#include "netsurf/keypress.h"
#include "netsurf/plotters.h"
#include "desktop/local_history.h"
-#include "gtk/compat.h"
-#include "gtk/plotters.h"
-#include "gtk/resources.h"
-#include "gtk/corewindow.h"
-#include "gtk/local_history.h"
-
-struct nsgtk_local_history_window {
- struct nsgtk_corewindow core;
-
- GtkBuilder *builder;
+#include "framebuffer/gui.h"
+#include "framebuffer/fbtk.h"
+#include "framebuffer/framebuffer.h"
+#include "framebuffer/corewindow.h"
+#include "framebuffer/local_history.h"
- GtkWindow *wnd;
+struct fb_local_history_window {
+ struct fb_corewindow core;
struct local_history_session *session;
};
-static struct nsgtk_local_history_window *local_history_window = NULL;
-
+static struct fb_local_history_window *local_history_window = NULL;
/**
* callback for mouse action on local history window
*
- * \param nsgtk_cw The nsgtk core window structure.
+ * \param fb_cw The fb core window structure.
* \param mouse_state netsurf mouse state on event
* \param x location of event
* \param y location of event
* \return NSERROR_OK on success otherwise apropriate error code
*/
static nserror
-nsgtk_local_history_mouse(struct nsgtk_corewindow *nsgtk_cw,
+fb_local_history_mouse(struct fb_corewindow *fb_cw,
browser_mouse_state mouse_state,
int x, int y)
{
- struct nsgtk_local_history_window *lhw;
+ struct fb_local_history_window *lhw;
/* technically degenerate container of */
- lhw = (struct nsgtk_local_history_window *)nsgtk_cw;
+ lhw = (struct fb_local_history_window *)fb_cw;
local_history_mouse_action(lhw->session, mouse_state, x, y);
+ if (mouse_state != BROWSER_MOUSE_HOVER) {
+ fbtk_set_mapping(lhw->core.wnd, false);
+ }
+
return NSERROR_OK;
}
@@ -77,16 +81,16 @@ nsgtk_local_history_mouse(struct nsgtk_corewindow *nsgtk_cw,
/**
* callback for keypress on local history window
*
- * \param nsgtk_cw The nsgtk core window structure.
+ * \param fb_cw The fb core window structure.
* \param nskey The netsurf key code
* \return NSERROR_OK on success otherwise apropriate error code
*/
static nserror
-nsgtk_local_history_key(struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey)
+fb_local_history_key(struct fb_corewindow *fb_cw, uint32_t nskey)
{
- struct nsgtk_local_history_window *lhw;
+ struct fb_local_history_window *lhw;
/* technically degenerate container of */
- lhw = (struct nsgtk_local_history_window *)nsgtk_cw;
+ lhw = (struct fb_local_history_window *)fb_cw;
if (local_history_keypress(lhw->session, nskey)) {
return NSERROR_OK;
@@ -98,24 +102,23 @@ nsgtk_local_history_key(struct nsgtk_corewindow *nsgtk_cw,
uint32_t nskey)
/**
* callback on draw event for local history window
*
- * \param nsgtk_cw The nsgtk core window structure.
+ * \param fb_cw The fb core window structure.
* \param r The rectangle of the window that needs updating.
* \return NSERROR_OK on success otherwise apropriate error code
*/
static nserror
-nsgtk_local_history_draw(struct nsgtk_corewindow *nsgtk_cw, struct rect *r)
+fb_local_history_draw(struct fb_corewindow *fb_cw, struct rect *r)
{
struct redraw_context ctx = {
.interactive = true,
.background_images = true,
- .plot = &nsgtk_plotters
+ .plot = &fb_plotters
};
- struct nsgtk_local_history_window *lhw;
+ struct fb_local_history_window *lhw;
/* technically degenerate container of */
- lhw = (struct nsgtk_local_history_window *)nsgtk_cw;
+ lhw = (struct fb_local_history_window *)fb_cw;
- ctx.plot->clip(&ctx, r);
local_history_redraw(lhw->session, 0, 0, r, &ctx);
return NSERROR_OK;
@@ -127,10 +130,11 @@ nsgtk_local_history_draw(struct nsgtk_corewindow
*nsgtk_cw, struct rect *r)
* \return NSERROR_OK on success else appropriate error code on faliure.
*/
static nserror
-nsgtk_local_history_init(struct browser_window *bw,
- struct nsgtk_local_history_window **win_out)
+fb_local_history_init(fbtk_widget_t *parent,
+ struct browser_window *bw,
+ struct fb_local_history_window **win_out)
{
- struct nsgtk_local_history_window *ncwin;
+ struct fb_local_history_window *ncwin;
nserror res;
/* memoise window so it can be represented when necessary
@@ -141,42 +145,16 @@ nsgtk_local_history_init(struct browser_window *bw,
return res;
}
- ncwin = malloc(sizeof(struct nsgtk_local_history_window));
+ ncwin = malloc(sizeof(struct fb_local_history_window));
if (ncwin == NULL) {
return NSERROR_NOMEM;
}
- res = nsgtk_builder_new_from_resname("localhistory", &ncwin->builder);
- if (res != NSERROR_OK) {
- LOG("Local history UI builder init failed");
- free(ncwin);
- return res;
- }
-
- gtk_builder_connect_signals(ncwin->builder, NULL);
-
- ncwin->wnd = GTK_WINDOW(gtk_builder_get_object(ncwin->builder,
- "wndHistory"));
-
- ncwin->core.scrolled = GTK_SCROLLED_WINDOW(
- gtk_builder_get_object(ncwin->builder,
- "HistoryScrolled"));
+ ncwin->core.draw = fb_local_history_draw;
+ ncwin->core.key = fb_local_history_key;
+ ncwin->core.mouse = fb_local_history_mouse;
- ncwin->core.drawing_area = GTK_DRAWING_AREA(
- gtk_builder_get_object(ncwin->builder,
- "HistoryDrawingArea"));
-
- /* make the delete event hide the window */
- g_signal_connect(G_OBJECT(ncwin->wnd),
- "delete_event",
- G_CALLBACK(gtk_widget_hide_on_delete),
- NULL);
-
- ncwin->core.draw = nsgtk_local_history_draw;
- ncwin->core.key = nsgtk_local_history_key;
- ncwin->core.mouse = nsgtk_local_history_mouse;
-
- res = nsgtk_corewindow_init(&ncwin->core);
+ res = fb_corewindow_init(parent, &ncwin->core);
if (res != NSERROR_OK) {
free(ncwin);
return res;
@@ -198,17 +176,18 @@ nsgtk_local_history_init(struct browser_window *bw,
/* exported function documented gtk/history.h */
-nserror nsgtk_local_history_present(GtkWindow *parent,
- struct browser_window *bw)
+nserror fb_local_history_present(fbtk_widget_t *parent,
+ struct browser_window *bw)
{
nserror res;
int prnt_width, prnt_height;
int width, height;
- res = nsgtk_local_history_init(bw, &local_history_window);
+
+ res = fb_local_history_init(parent, bw, &local_history_window);
if (res == NSERROR_OK) {
- gtk_window_set_transient_for(local_history_window->wnd, parent);
- gtk_window_get_size(parent, &prnt_width, &prnt_height);
+ prnt_width = fbtk_get_width(parent);
+ prnt_height = fbtk_get_height(parent);
/* resize history widget ensureing the drawing area is
* no larger than parent window
@@ -222,9 +201,10 @@ nserror nsgtk_local_history_present(GtkWindow *parent,
if (height > prnt_height) {
height = prnt_height;
}
- gtk_window_resize(local_history_window->wnd, width, height);
+ /* should update scroll area with contents */
- gtk_window_present(local_history_window->wnd);
+ fbtk_set_zorder(local_history_window->core.wnd, INT_MIN);
+ fbtk_set_mapping(local_history_window->core.wnd, true);
}
return res;
@@ -232,12 +212,12 @@ nserror nsgtk_local_history_present(GtkWindow *parent,
/* exported function documented gtk/history.h */
-nserror nsgtk_local_history_hide(void)
+nserror fb_local_history_hide(void)
{
nserror res = NSERROR_OK;
if (local_history_window != NULL) {
- gtk_widget_hide(GTK_WIDGET(local_history_window->wnd));
+ fbtk_set_mapping(local_history_window->core.wnd, false);
res = local_history_set(local_history_window->session, NULL);
}
@@ -247,7 +227,7 @@ nserror nsgtk_local_history_hide(void)
/* exported function documented gtk/history.h */
-nserror nsgtk_local_history_destroy(void)
+nserror fb_local_history_destroy(void)
{
nserror res;
@@ -257,9 +237,8 @@ nserror nsgtk_local_history_destroy(void)
res = local_history_fini(local_history_window->session);
if (res == NSERROR_OK) {
- res = nsgtk_corewindow_fini(&local_history_window->core);
- gtk_widget_destroy(GTK_WIDGET(local_history_window->wnd));
- g_object_unref(G_OBJECT(local_history_window->builder));
+ res = fb_corewindow_fini(&local_history_window->core);
+ //gtk_widget_destroy(GTK_WIDGET(local_history_window->wnd));
free(local_history_window);
local_history_window = NULL;
}
diff --git a/frontends/gtk/local_history.h
b/frontends/framebuffer/local_history.h
similarity index 76%
copy from frontends/gtk/local_history.h
copy to frontends/framebuffer/local_history.h
index 605405d..929eeac 100644
--- a/frontends/gtk/local_history.h
+++ b/frontends/framebuffer/local_history.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Vincent Sanders <[email protected]>
+ * Copyright 2017 Vincent Sanders <[email protected]>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -18,11 +18,11 @@
/**
* \file
- * Interface to GTK local history manager
+ * Interface to framebuffer local history manager
*/
-#ifndef NSGTK_LOCAL_HISTORY_H
-#define NSGTK_LOCAL_HISTORY_H
+#ifndef FB_LOCAL_HISTORY_H
+#define FB_LOCAL_HISTORY_H
struct browser_window;
@@ -31,19 +31,19 @@ struct browser_window;
*
* \return NSERROR_OK on success else appropriate error code on faliure.
*/
-nserror nsgtk_local_history_present(GtkWindow *parent, struct browser_window
*bw);
+nserror fb_local_history_present(fbtk_widget_t *parent, struct browser_window
*bw);
/**
* hide the local history window from being visible.
*
* \return NSERROR_OK on success else appropriate error code on faliure.
*/
-nserror nsgtk_local_history_hide(void);
+nserror fb_local_history_hide(void);
/**
* Destroys the local history window and performs any other necessary cleanup
* actions.
*/
-nserror nsgtk_local_history_destroy(void);
+nserror fb_local_history_destroy(void);
#endif
diff --git a/frontends/framebuffer/localhistory.c
b/frontends/framebuffer/localhistory.c
deleted file mode 100644
index b91c947..0000000
--- a/frontends/framebuffer/localhistory.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2010 Vincent Sanders <[email protected]>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <limits.h>
-
-#include <libnsfb.h>
-#include <libnsfb_plot.h>
-#include <libnsfb_event.h>
-
-#include "desktop/browser_history.h"
-#include "netsurf/plotters.h"
-
-#include "framebuffer/gui.h"
-#include "framebuffer/fbtk.h"
-#include "framebuffer/framebuffer.h"
-
-static int
-localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
-{
- struct gui_localhistory *glh = cbi->context;
- nsfb_bbox_t rbox;
- struct rect clip;
-
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &fb_plotters
- };
-
- rbox.x0 = fbtk_get_absx(widget);
- rbox.y0 = fbtk_get_absy(widget);
-
- rbox.x1 = rbox.x0 + fbtk_get_width(widget);
- rbox.y1 = rbox.y0 + fbtk_get_height(widget);
-
- nsfb_claim(fbtk_get_nsfb(widget), &rbox);
-
- nsfb_plot_rectangle_fill(fbtk_get_nsfb(widget), &rbox, 0xffffffff);
-
- clip.x0 = glh->scrollx;
- clip.y0 = glh->scrolly;
- clip.x1 = fbtk_get_width(widget) + glh->scrollx;
- clip.y0 = fbtk_get_height(widget) + glh->scrolly;
-
- browser_window_history_redraw_rectangle(glh->bw,
- &clip, 0, 0, &ctx);
-
- nsfb_update(fbtk_get_nsfb(widget), &rbox);
-
- return 0;
-}
-
-static int
-localhistory_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
-{
- struct gui_localhistory *glh = cbi->context;
-
- if (cbi->event->type != NSFB_EVENT_KEY_UP)
- return 0;
-
- browser_window_history_click(glh->bw, cbi->x, cbi->y, false);
-
- fbtk_set_mapping(glh->window, false);
-
- return 1;
-}
-
-struct gui_localhistory *
-fb_create_localhistory(struct browser_window *bw,
- fbtk_widget_t *parent,
- int furniture_width)
-{
- struct gui_localhistory *glh;
- glh = calloc(1, sizeof(struct gui_localhistory));
-
- if (glh == NULL)
- return NULL;
-
- glh->bw = bw;
-
- /* container window */
- glh->window = fbtk_create_window(parent, 0, 0, 0, 0, 0);
-
- glh->history = fbtk_create_user(glh->window, 0, 0, -furniture_width,
-furniture_width, glh);
-
- fbtk_set_handler(glh->history, FBTK_CBT_REDRAW, localhistory_redraw,
glh);
- fbtk_set_handler(glh->history, FBTK_CBT_CLICK, localhistory_click, glh);
- /*
- fbtk_set_handler(gw->localhistory, FBTK_CBT_INPUT,
fb_browser_window_input, gw);
- fbtk_set_handler(gw->localhistory, FBTK_CBT_POINTERMOVE,
fb_browser_window_move, bw);
- */
-
- /* create horizontal scrollbar */
- glh->hscroll = fbtk_create_hscroll(glh->window,
- 0,
- fbtk_get_height(glh->window) -
furniture_width,
- fbtk_get_width(glh->window) -
furniture_width,
- furniture_width,
- FB_SCROLL_COLOUR,
- FB_FRAME_COLOUR,
- NULL,
- NULL);
-
- glh->vscroll = fbtk_create_vscroll(glh->window,
- fbtk_get_width(glh->window) -
furniture_width,
- 0,
- furniture_width,
- fbtk_get_height(glh->window) -
furniture_width,
- FB_SCROLL_COLOUR,
- FB_FRAME_COLOUR,
- NULL,
- NULL);
-
- fbtk_create_fill(glh->window,
- fbtk_get_width(glh->window) - furniture_width,
- fbtk_get_height(glh->window) - furniture_width,
- furniture_width,
- furniture_width,
- FB_FRAME_COLOUR);
-
- return glh;
-}
-
-void
-fb_localhistory_map(struct gui_localhistory * glh)
-{
- fbtk_set_zorder(glh->window, INT_MIN);
- fbtk_set_mapping(glh->window, true);
-}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org