summaryrefslogtreecommitdiff
path: root/frontends/riscos/corewindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/riscos/corewindow.c')
-rw-r--r--frontends/riscos/corewindow.c190
1 files changed, 125 insertions, 65 deletions
diff --git a/frontends/riscos/corewindow.c b/frontends/riscos/corewindow.c
index 3219be985..84177aa90 100644
--- a/frontends/riscos/corewindow.c
+++ b/frontends/riscos/corewindow.c
@@ -42,6 +42,7 @@
#include "riscos/wimp_event.h"
#include "riscos/dialog.h"
#include "riscos/gui.h"
+#include "riscos/window.h"
#include "riscos/toolbar.h"
#include "riscos/mouse.h"
#include "riscos/corewindow.h"
@@ -62,22 +63,22 @@ static void update_scrollbars(struct ro_corewindow *ro_cw, wimp_open *open)
int extent_height;
os_box extent;
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
/* extent of content in not smaller than window so start there */
extent_width = open->visible.x1 - open->visible.x0;
extent_height = open->visible.y0 - open->visible.y1;
- LOG("extent w:%d h:%d content w:%d h:%d origin h:%d",
- extent_width, extent_height,
- ro_cw->content_width, ro_cw->content_height, ro_cw->origin_y);
+ NSLOG(netsurf, INFO,
+ "extent w:%d h:%d content w:%d h:%d origin h:%d", extent_width,
+ extent_height, ro_cw->content_width, ro_cw->content_height,
+ ro_cw->origin_y);
if (ro_cw->content_width > extent_width) {
extent_width = ro_cw->content_width;
}
if (extent_height > (ro_cw->origin_y + ro_cw->content_height)) {
extent_height = ro_cw->origin_y + ro_cw->content_height;
}
- LOG("extent w:%d h:%d",
- extent_width, extent_height);
+ NSLOG(netsurf, INFO, "extent w:%d h:%d", extent_width, extent_height);
extent.x0 = 0;
extent.y0 = extent_height;
extent.x1 = extent_width;
@@ -85,15 +86,15 @@ static void update_scrollbars(struct ro_corewindow *ro_cw, wimp_open *open)
error = xwimp_set_extent(ro_cw->wh, &extent);
if (error) {
- LOG("xwimp_set_extent: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
error = xwimp_open_window(open);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
@@ -129,8 +130,8 @@ static void ro_cw_redraw(wimp_draw *redraw)
error = xwimp_get_rectangle(redraw, &more);
}
if (error != NULL) {
- LOG("xwimp_redraw_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
@@ -144,7 +145,7 @@ static void ro_cw_scroll(wimp_scroll *scroll)
wimp_open open;
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(scroll->w);
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
page_x = scroll->visible.x1 - scroll->visible.x0 - 32;
page_y = scroll->visible.y1 - scroll->visible.y0 - 32;
@@ -201,8 +202,8 @@ static void ro_cw_scroll(wimp_scroll *scroll)
error = xwimp_open_window(&open);
if (error) {
- LOG("xwimp_open_window: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
}
}
@@ -230,38 +231,38 @@ static void ro_cw_mouse_at(wimp_pointer *pointer, void *data)
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(pointer->w);
if (ro_cw == NULL) {
- LOG("no corewindow conext for window: 0x%x",
- (unsigned int)pointer->w);
+ NSLOG(netsurf, INFO, "no corewindow conext for window: 0x%x",
+ (unsigned int)pointer->w);
return;
}
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
- /* no futher processing required if no drag in progress */
- if (ro_cw->drag_status == CORE_WINDOW_DRAG_NONE) {
- return;
- }
-
- /* Not a Menu click and a drag is in progress. */
+ /* Not a Menu click. */
state.w = pointer->w;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
- /* Convert the returned mouse coordinates into NetSurf's internal
- * units.
+ /* Convert the returned mouse coordinates into
+ * NetSurf's internal units.
*/
xpos = ((pointer->pos.x - state.visible.x0) + state.xscroll) / 2;
ypos = ((state.visible.y1 - pointer->pos.y) -
state.yscroll + ro_cw->origin_y) / 2;
- /* Start to process the mouse click. */
- mouse = ro_gui_mouse_drag_state(pointer->buttons,
- wimp_BUTTON_DOUBLE_CLICK_DRAG);
+ /* if no drag in progress report hover */
+ if (ro_cw->drag_status == CORE_WINDOW_DRAG_NONE) {
+ mouse = BROWSER_MOUSE_HOVER;
+ } else {
+ /* Start to process the mouse click. */
+ mouse = ro_gui_mouse_drag_state(pointer->buttons,
+ wimp_BUTTON_DOUBLE_CLICK_DRAG);
- ro_cw->mouse(ro_cw, mouse, xpos, ypos);
+ ro_cw->mouse(ro_cw, mouse, xpos, ypos);
+ }
if (!(mouse & BROWSER_MOUSE_DRAG_ON)) {
ro_cw->mouse(ro_cw, BROWSER_MOUSE_HOVER, xpos, ypos);
@@ -284,14 +285,15 @@ static void ro_cw_drag_end(wimp_dragged *drag, void *data)
error = xwimp_drag_box((wimp_drag *) -1);
if (error) {
- LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
error = xwimp_auto_scroll(0, NULL, NULL);
if (error) {
- LOG("xwimp_auto_scroll: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
}
@@ -344,12 +346,13 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw,
break;
}
- LOG("Drag start...");
+ NSLOG(netsurf, INFO, "Drag start...");
error = xwimp_drag_box_with_flags(&drag,
wimp_DRAG_BOX_KEEP_IN_LINE | wimp_DRAG_BOX_CLIP);
if (error) {
- LOG("xwimp_drag_box: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_drag_box: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
} else {
auto_scroll.w = ro_cw->wh;
@@ -363,7 +366,8 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw,
error = xwimp_auto_scroll(wimp_AUTO_SCROLL_ENABLE_VERTICAL,
&auto_scroll, NULL);
if (error) {
- LOG("xwimp_auto_scroll: 0x%x: %s", error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_auto_scroll: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
}
@@ -373,16 +377,40 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw,
/**
+ * Handle Pointer Leaving Window events.
+ *
+ * These events are delivered as the termination callback handler from
+ * ro_mouse's mouse tracking.
+ *
+ * \param leaving The Wimp_PointerLeavingWindow block.
+ * \param data NULL data pointer.
+ */
+static void ro_cw_pointer_leaving(wimp_leaving *leaving, void *data)
+{
+ struct ro_corewindow *ro_cw;
+
+ ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(leaving->w);
+ if (ro_cw == NULL) {
+ NSLOG(netsurf, INFO, "no corewindow conext for window: 0x%x",
+ (unsigned int)leaving->w);
+ return;
+ }
+
+ ro_cw->mouse(ro_cw, BROWSER_MOUSE_LEAVE, 0, 0);
+}
+
+
+/**
* Wimp callback on pointer entering window.
*
* The wimp has issued an event to the window because the pointer has
* entered it.
*
- * \param open The open event to be processed
+ * \param entering The entering event to be processed
*/
static void ro_cw_pointer_entering(wimp_entering *entering)
{
- ro_mouse_track_start(NULL, ro_cw_mouse_at, NULL);
+ ro_mouse_track_start(ro_cw_pointer_leaving, ro_cw_mouse_at, NULL);
}
@@ -414,14 +442,14 @@ static bool ro_cw_mouse_click(wimp_pointer *pointer)
struct ro_corewindow *ro_cw;
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(pointer->w);
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return false;
}
@@ -492,7 +520,7 @@ static bool ro_cw_keypress(wimp_key *key)
nserror res;
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(key->w);
- LOG("RO corewindow context %p", ro_cw);
+ NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
c = (uint32_t) key->c;
@@ -615,8 +643,8 @@ static void cw_tb_size(void *ctx)
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -624,8 +652,8 @@ static void cw_tb_size(void *ctx)
0, state.visible.y0 - state.visible.y1,
state.visible.x1 - state.visible.x0, 0);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
}
@@ -664,6 +692,8 @@ static void cw_tb_update(void *ctx)
* Respond to user actions (click) in a corewindow.
*
* \param ctx Context as passed to toolbar creation.
+ * \param action_type type of action on toolbar
+ * \param action data for action.
*/
static void
cw_tb_click(void *ctx,
@@ -698,7 +728,9 @@ static void cw_tb_save(void *ctx, char *config)
-/** core window toolbar callbacks */
+/**
+ * riscos core window toolbar callbacks
+ */
static const struct toolbar_callbacks corewindow_toolbar_callbacks = {
.theme_update = cw_tb_theme,
.change_size = cw_tb_size,
@@ -707,24 +739,52 @@ static const struct toolbar_callbacks corewindow_toolbar_callbacks = {
.save_buttons = cw_tb_save,
};
+
/**
- * callback from core to request a redraw.
+ * callback from core to request an invalidation of a window area.
+ *
+ * The specified area of the window should now be considered
+ * out of date. If the area is NULL the entire window must be
+ * invalidated.
+ *
+ * \param[in] cw The core window to invalidate.
+ * \param[in] r area to redraw or NULL for the entire window area.
+ * \return NSERROR_OK on success or appropriate error code.
*/
-static void
-ro_cw_redraw_request(struct core_window *cw, const struct rect *r)
+static nserror
+ro_cw_invalidate(struct core_window *cw, const struct rect *r)
{
struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
os_error *error;
+ wimp_window_info info;
+
+ if (r == NULL) {
+ info.w = ro_cw->wh;
+ error = xwimp_get_window_info_header_only(&info);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimp_get_window_info_header_only: 0x%x: %s",
+ error->errnum,
+ error->errmess);
+ return NSERROR_INVALID;
+ }
+ } else {
+ /* convert the passed rectangle into RO window dimensions */
+ info.extent.x0 = 2 * r->x0;
+ info.extent.y0 = (-2 * (r->y0 + (r->y1 - r->y0))) + ro_cw->origin_y;
+ info.extent.x1 = 2 * (r->x0 + (r->x1 - r->x0));
+ info.extent.y1 = (-2 * r->y0) + ro_cw->origin_y;
+ }
error = xwimp_force_redraw(ro_cw->wh,
- (2 * r->x0),
- (-2 * (r->y0 + (r->y1 - r->y0))) + ro_cw->origin_y,
- (2 * (r->x0 + (r->x1 - r->x0))),
- (-2 * r->y0) + ro_cw->origin_y);
+ info.extent.x0, info.extent.y0,
+ info.extent.x1, info.extent.y1);
if (error) {
- LOG("xwimp_force_redraw: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
}
+ return NSERROR_OK;
}
@@ -739,8 +799,8 @@ ro_cw_update_size(struct core_window *cw, int width, int height)
wimp_window_state state;
os_error *error;
- LOG("content resize from w:%d h:%d to w:%d h:%d",
- ro_cw->content_width, ro_cw->content_height, width, height);
+ NSLOG(netsurf, INFO, "content resize from w:%d h:%d to w:%d h:%d",
+ ro_cw->content_width, ro_cw->content_height, width, height);
ro_cw->content_width = width * 2;
ro_cw->content_height = -(2 * height);
@@ -748,8 +808,8 @@ ro_cw_update_size(struct core_window *cw, int width, int height)
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -793,8 +853,8 @@ ro_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
state.w = ro_cw->wh;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess);
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
return;
}
@@ -815,7 +875,7 @@ ro_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
struct core_window_callback_table ro_cw_cb_table = {
- .redraw_request = ro_cw_redraw_request,
+ .invalidate = ro_cw_invalidate,
.update_size = ro_cw_update_size,
.scroll_visible = ro_cw_scroll_visible,
.get_window_dimensions = ro_cw_get_window_dimensions,