diff options
Diffstat (limited to 'frontends/riscos/corewindow.c')
-rw-r--r-- | frontends/riscos/corewindow.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/frontends/riscos/corewindow.c b/frontends/riscos/corewindow.c index 8004dcc95..17f0e3638 100644 --- a/frontends/riscos/corewindow.c +++ b/frontends/riscos/corewindow.c @@ -52,6 +52,8 @@ #define wimp_KEY_END wimp_KEY_COPY #endif +static struct ro_corewindow *ro_cw_drag_cw; + /** * Update a windows scrollbars. * @@ -120,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); @@ -144,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; @@ -236,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. */ @@ -372,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); } } @@ -832,7 +859,7 @@ ro_cw_update_size(struct core_window *cw, int width, int height) * Callback from the core to scroll the visible content. */ static nserror -ro_cw_get_scroll(struct core_window *cw, int *x, int *y) +ro_cw_get_scroll(const struct core_window *cw, int *x, int *y) { struct ro_corewindow *ro_cw = (struct ro_corewindow *)cw; wimp_window_state state = { @@ -875,7 +902,11 @@ ro_cw_set_scroll(struct core_window *cw, int x, int y) state.xscroll = x * 2; state.yscroll = -y * 2; - ro_cw_open(PTR_WIMP_OPEN(&state)); + /* 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; } @@ -888,7 +919,8 @@ ro_cw_set_scroll(struct core_window *cw, int x, int y) * \param[out] height to be set to viewport height in px */ static nserror -ro_cw_get_window_dimensions(struct core_window *cw, int *width, int *height) +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; @@ -930,15 +962,17 @@ ro_cw_drag_status(struct core_window *cw, core_window_drag_status ds) } -struct core_window_callback_table ro_cw_cb_table = { +struct core_window_table ro_cw_cb_table = { .invalidate = ro_cw_invalidate, - .update_size = ro_cw_update_size, + .set_extent = ro_cw_update_size, .set_scroll = ro_cw_set_scroll, .get_scroll = ro_cw_get_scroll, - .get_window_dimensions = ro_cw_get_window_dimensions, + .get_dimensions = ro_cw_get_window_dimensions, .drag_status = ro_cw_drag_status }; +struct core_window_table *riscos_core_window_table = &ro_cw_cb_table; + /** * dummy toolbar click callback * @@ -972,9 +1006,6 @@ ro_corewindow_init(struct ro_corewindow *ro_cw, theme_style tb_style, const char *tb_help) { - /* setup the core window callback table */ - ro_cw->cb_table = &ro_cw_cb_table; - /* start with the content area being as small as possible */ ro_cw->content_width = -1; ro_cw->content_height = -1; @@ -1022,6 +1053,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. */ |