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.c119
1 files changed, 105 insertions, 14 deletions
diff --git a/frontends/riscos/corewindow.c b/frontends/riscos/corewindow.c
index 84177aa90..88bb5c3ef 100644
--- a/frontends/riscos/corewindow.c
+++ b/frontends/riscos/corewindow.c
@@ -45,12 +45,15 @@
#include "riscos/window.h"
#include "riscos/toolbar.h"
#include "riscos/mouse.h"
+#include "riscos/wimputils.h"
#include "riscos/corewindow.h"
#ifndef wimp_KEY_END
#define wimp_KEY_END wimp_KEY_COPY
#endif
+static struct ro_corewindow *ro_cw_drag_cw;
+
/**
* Update a windows scrollbars.
*
@@ -119,10 +122,15 @@ static void ro_cw_redraw(wimp_draw *redraw)
origin_x = redraw->box.x0 - redraw->xscroll;
origin_y = redraw->box.y1 + ro_cw->origin_y - redraw->yscroll;
- r.x0 = (redraw->clip.x0 - origin_x) / 2;
- r.y0 = (origin_y - redraw->clip.y1) / 2;
- r.x1 = r.x0 + ((redraw->clip.x1 - redraw->clip.x0) / 2);
- r.y1 = r.y0 + ((redraw->clip.y1 - redraw->clip.y0) / 2);
+ ro_plot_clip_rect.x0 = redraw->clip.x0 - origin_x;
+ ro_plot_clip_rect.y0 = origin_y - redraw->clip.y0;
+ ro_plot_clip_rect.x1 = redraw->clip.x1 - origin_x;
+ ro_plot_clip_rect.y1 = origin_y - redraw->clip.y1;
+
+ r.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */
+ r.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */
+ r.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */
+ r.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */
/* call the draw callback */
ro_cw->draw(ro_cw, origin_x, origin_y, &r);
@@ -143,10 +151,24 @@ static void ro_cw_scroll(wimp_scroll *scroll)
int page_y;
struct ro_corewindow *ro_cw;
wimp_open open;
+ wimp_window_state state;
ro_cw = (struct ro_corewindow *)ro_gui_wimp_event_get_user_data(scroll->w);
NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
+ state.w = ro_cw->wh;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ return;
+ }
+
+ /* Don't try to update window if it's closed */
+ if (!(state.flags & wimp_WINDOW_OPEN)) {
+ return;
+ }
+
page_x = scroll->visible.x1 - scroll->visible.x0 - 32;
page_y = scroll->visible.y1 - scroll->visible.y0 - 32;
@@ -235,6 +257,11 @@ static void ro_cw_mouse_at(wimp_pointer *pointer, void *data)
(unsigned int)pointer->w);
return;
}
+ if (ro_cw != ro_cw_drag_cw) {
+ NSLOG(netsurf, DEEPDEBUG, "Called without drag window: %p",
+ ro_cw);
+ return;
+ }
NSLOG(netsurf, INFO, "RO corewindow context %p", ro_cw);
/* Not a Menu click. */
@@ -371,6 +398,7 @@ ro_cw_drag_start(struct ro_corewindow *ro_cw,
ro_warn_user("WimpError", error->errmess);
}
+ ro_cw_drag_cw = ro_cw;
ro_mouse_drag_start(ro_cw_drag_end, ro_cw_mouse_at, NULL, NULL);
}
}
@@ -791,7 +819,7 @@ ro_cw_invalidate(struct core_window *cw, const struct rect *r)
/**
* Callback from the core to update the content area size.
*/
-static void
+static nserror
ro_cw_update_size(struct core_window *cw, int width, int height)
{
struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
@@ -810,7 +838,7 @@ ro_cw_update_size(struct core_window *cw, int width, int height)
if (error) {
NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
error->errnum, error->errmess);
- return;
+ return NSERROR_INVALID;
}
/* only update the window if it is open */
@@ -823,16 +851,63 @@ ro_cw_update_size(struct core_window *cw, int width, int height)
update_scrollbars(ro_cw, &open);
}
+ return NSERROR_OK;
}
/**
* Callback from the core to scroll the visible content.
*/
-static void
-ro_cw_scroll_visible(struct core_window *cw, const struct rect *r)
+static nserror
+ro_cw_get_scroll(const struct core_window *cw, int *x, int *y)
{
- //struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
+ struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
+ wimp_window_state state = {
+ .w = ro_cw->wh,
+ };
+ os_error *error;
+
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, ERROR, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ *x = state.xscroll / 2;
+ *y = -state.yscroll / 2;
+ return NSERROR_OK;
+}
+
+
+/**
+ * Callback from the core to scroll the visible content.
+ */
+static nserror
+ro_cw_set_scroll(struct core_window *cw, int x, int y)
+{
+ struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
+ wimp_window_state state = {
+ .w = ro_cw->wh,
+ };
+ os_error *error;
+
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, ERROR, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ return NSERROR_INVALID;
+ }
+
+ state.xscroll = x * 2;
+ state.yscroll = -y * 2;
+
+ /* only update the window if it is open */
+ if (state.flags & wimp_WINDOW_OPEN) {
+ update_scrollbars(ro_cw, PTR_WIMP_OPEN(&state));
+ }
+
+ return NSERROR_OK;
}
@@ -843,8 +918,9 @@ ro_cw_scroll_visible(struct core_window *cw, const struct rect *r)
* \param[out] width to be set to viewport width in px
* \param[out] height to be set to viewport height in px
*/
-static void
-ro_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
+static nserror
+ro_cw_get_window_dimensions(const struct core_window *cw,
+ int *width, int *height)
{
struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
os_error *error;
@@ -855,29 +931,42 @@ ro_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
if (error) {
NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
error->errnum, error->errmess);
- return;
+ return NSERROR_INVALID;
}
*width = (state.visible.x1 - state.visible.x0) / 2;
*height = (state.visible.y1 - state.visible.y0) / 2;
+
+ /* Account for toolbar height, if present */
+ if (ro_cw->toolbar != NULL) {
+ *height -= ro_toolbar_full_height(ro_cw->toolbar) / 2;
+ }
+ if (*height < 0) {
+ *height = 0;
+ }
+
+ return NSERROR_OK;
}
/**
* Callback from the core to update the drag status.
*/
-static void
+static nserror
ro_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
{
struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw;
ro_cw->drag_status = ds;
+
+ return NSERROR_OK;
}
struct core_window_callback_table ro_cw_cb_table = {
.invalidate = ro_cw_invalidate,
.update_size = ro_cw_update_size,
- .scroll_visible = ro_cw_scroll_visible,
+ .set_scroll = ro_cw_set_scroll,
+ .get_scroll = ro_cw_get_scroll,
.get_window_dimensions = ro_cw_get_window_dimensions,
.drag_status = ro_cw_drag_status
};
@@ -965,6 +1054,8 @@ ro_corewindow_init(struct ro_corewindow *ro_cw,
}
/* setup context for event handlers */
+ NSLOG(netsurf, INFO, "Setting corewindow %p for window handle %p",
+ ro_cw, ro_cw->wh);
ro_gui_wimp_event_set_user_data(ro_cw->wh, ro_cw);
/* register wimp events. */