summaryrefslogtreecommitdiff
path: root/frontends/riscos/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/riscos/window.c')
-rw-r--r--frontends/riscos/window.c543
1 files changed, 318 insertions, 225 deletions
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index 986e5c55d..4dcdcd734 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -64,6 +64,7 @@
#include "netsurf/keypress.h"
#include "desktop/browser_history.h"
#include "desktop/cookie_manager.h"
+#include "desktop/searchweb.h"
#include "riscos/bitmap.h"
#include "riscos/buffer.h"
@@ -71,6 +72,7 @@
#include "riscos/dialog.h"
#include "riscos/local_history.h"
#include "riscos/global_history.h"
+#include "riscos/pageinfo.h"
#include "riscos/gui.h"
#include "riscos/gui/status_bar.h"
#include "riscos/help.h"
@@ -390,15 +392,18 @@ static void ro_gui_window_open(wimp_open *open)
/* reformat or change extent if necessary */
if (have_content &&
- (g->old_width != width || g->old_height != height)) {
+ (g->old_width != width || g->old_height != height)) {
/* Ctrl-resize of a top-level window scales the content size */
- if ((g->old_width > 0) && (g->old_width != width) &&
- (ro_gui_ctrl_pressed()))
- new_scale = (g->scale * width) / g->old_width;
+ if ((g->old_width > 0) &&
+ (g->old_width != width) &&
+ (ro_gui_ctrl_pressed())) {
+ new_scale = (browser_window_get_scale(g->bw) * width) / g->old_width;
+ }
browser_window_schedule_reformat(g->bw);
}
- if (g->update_extent || g->old_width != width ||
- g->old_height != height) {
+ if (g->update_extent ||
+ g->old_width != width ||
+ g->old_height != height) {
g->old_width = width;
g->old_height = height;
g->update_extent = false;
@@ -583,7 +588,7 @@ static void ro_gui_window_action_add_bookmark(struct gui_window *g)
browser_window_has_content(g->bw) == false)
return;
- url = browser_window_get_url(g->bw);
+ url = browser_window_access_url(g->bw);
ro_gui_hotlist_add_page(url);
ro_toolbar_update_hotlist(g->toolbar);
@@ -603,7 +608,7 @@ static void ro_gui_window_action_remove_bookmark(struct gui_window *g)
browser_window_has_content(g->bw) == false)
return;
- url = browser_window_get_url(g->bw);
+ url = browser_window_access_url(g->bw);
ro_gui_hotlist_remove_page(url);
}
@@ -828,8 +833,11 @@ ro_gui_window_toolbar_click(void *data,
if (action_type == TOOLBAR_ACTION_URL) {
switch (action.url) {
case TOOLBAR_URL_DRAG_URL:
+ case TOOLBAR_URL_DRAG_FAVICON:
{
gui_save_type save_type;
+ nserror err;
+ nsurl *url;
if (!browser_window_has_content(g->bw))
break;
@@ -839,9 +847,17 @@ ro_gui_window_toolbar_click(void *data,
else
save_type = GUI_SAVE_LINK_TEXT;
- ro_gui_drag_save_link(save_type,
- browser_window_get_url(g->bw),
+ err = browser_window_get_url(g->bw, true, &url);
+ if (err != NSERROR_OK) {
+ /* Fall back to access (won't get fragment). */
+ url = nsurl_ref(
+ browser_window_access_url(g->bw));
+ }
+
+ ro_gui_drag_save_link(save_type, url,
browser_window_get_title(g->bw), g);
+
+ nsurl_unref(url);
}
break;
@@ -853,6 +869,10 @@ ro_gui_window_toolbar_click(void *data,
ro_gui_window_action_remove_bookmark(g);
break;
+ case TOOLBAR_URL_SELECT_PGINFO:
+ case TOOLBAR_URL_ADJUST_PGINFO:
+ ro_gui_pageinfo_present(g);
+
default:
break;
}
@@ -972,17 +992,18 @@ ro_gui_window_toolbar_click(void *data,
* \param g gui_window to update
* \param url1 url to be launched
*/
-static void ro_gui_window_launch_url(struct gui_window *g, const char *url1)
+static void ro_gui_window_launch_url(struct gui_window *g, const char *url_s)
{
nserror error;
nsurl *url;
- if (url1 == NULL)
+ if (url_s == NULL) {
return;
+ }
ro_gui_url_complete_close();
- error = nsurl_create(url1, &url);
+ error = search_web_omni(url_s, SEARCH_WEB_OMNI_NONE, &url);
if (error != NSERROR_OK) {
ro_warn_user(messages_get_errorcode(error), 0);
} else {
@@ -1009,7 +1030,7 @@ static void ro_gui_window_action_new_window(struct gui_window *g)
return;
error = browser_window_create(BW_CREATE_CLONE,
- browser_window_get_url(g->bw),
+ browser_window_access_url(g->bw),
NULL, g->bw, NULL);
if (error != NSERROR_OK) {
@@ -1102,7 +1123,7 @@ ro_gui_window_scroll_action(struct gui_window *g,
step_x = SCROLL_TOP;
break;
default:
- step_x = (visible_x * (scroll_x>>2)) >> 2;
+ step_x = (32 * (scroll_x / 4));
break;
}
@@ -1128,7 +1149,7 @@ ro_gui_window_scroll_action(struct gui_window *g,
step_y = SCROLL_TOP;
break;
default:
- step_y = -((visible_y * (scroll_y>>2)) >> 2);
+ step_y = -(32 * (scroll_y / 4));
break;
}
@@ -1142,10 +1163,12 @@ ro_gui_window_scroll_action(struct gui_window *g,
*/
if (pointer.w == g->window &&
- ro_gui_window_to_window_pos(g,
- pointer.pos.x, pointer.pos.y, &pos))
- handled = browser_window_scroll_at_point(g->bw, pos.x, pos.y,
- step_x, step_y);
+ ro_gui_window_to_window_pos(g, pointer.pos.x, pointer.pos.y, &pos))
+ handled = browser_window_scroll_at_point(g->bw,
+ pos.x,
+ pos.y,
+ step_x,
+ step_y);
/* If the core didn't do the scrolling, handle it via the Wimp.
* Windows which contain frames can only be scrolled by the core,
@@ -1197,6 +1220,52 @@ ro_gui_window_scroll_action(struct gui_window *g,
}
}
+/**
+ * handle scale kepresses within RISC OS
+ */
+static bool handle_local_keypress_scale(struct gui_window *gw, uint32_t c)
+{
+ float cscale; /* current scale */
+ float scale; /* new scale */
+
+ cscale = browser_window_get_scale(gw->bw);
+
+ scale = cscale;
+
+ if (ro_gui_shift_pressed() && c == 17) {
+ scale = cscale - 0.1;
+ } else if (ro_gui_shift_pressed() && c == 23) {
+ scale = cscale + 0.1;
+ } else if (c == 17) {
+ for (int i = SCALE_SNAP_TO_SIZE - 1; i >= 0; i--) {
+ if (scale_snap_to[i] < cscale) {
+ scale = scale_snap_to[i];
+ break;
+ }
+ }
+ } else {
+ for (unsigned int i = 0; i < SCALE_SNAP_TO_SIZE; i++) {
+ if (scale_snap_to[i] > cscale) {
+ scale = scale_snap_to[i];
+ break;
+ }
+ }
+ }
+
+ if (scale < scale_snap_to[0]) {
+ scale = scale_snap_to[0];
+ }
+
+ if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1]) {
+ scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
+ }
+
+ if (cscale != scale) {
+ ro_gui_window_set_scale(gw, scale);
+ }
+
+ return true;
+}
/**
* Handle keypresses within the RISC OS GUI
@@ -1219,7 +1288,6 @@ ro_gui_window_handle_local_keypress(struct gui_window *g,
os_error *ro_error;
wimp_pointer pointer;
os_coord pos;
- float scale;
uint32_t c = (uint32_t) key->c;
wimp_scroll_direction xscroll = wimp_SCROLL_NONE;
wimp_scroll_direction yscroll = wimp_SCROLL_NONE;
@@ -1245,7 +1313,7 @@ ro_gui_window_handle_local_keypress(struct gui_window *g,
case IS_WIMP_KEY + wimp_KEY_F1: /* Help. */
{
nserror error = nsurl_create(
- "http://www.netsurf-browser.org/documentation/",
+ "https://www.netsurf-browser.org/documentation/",
&url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
@@ -1359,8 +1427,7 @@ ro_gui_window_handle_local_keypress(struct gui_window *g,
if (is_toolbar) {
const char *toolbar_url;
toolbar_url = ro_toolbar_get_url(g->toolbar);
- if (toolbar_url != NULL)
- ro_gui_window_launch_url(g, toolbar_url);
+ ro_gui_window_launch_url(g, toolbar_url);
}
return true;
@@ -1380,34 +1447,10 @@ ro_gui_window_handle_local_keypress(struct gui_window *g,
case 17: /* CTRL+Q (Zoom out) */
case 23: /* CTRL+W (Zoom in) */
- if (browser_window_has_content(g->bw) == false)
- break;
- scale = g->scale;
- if (ro_gui_shift_pressed() && c == 17)
- scale = g->scale - 0.1;
- else if (ro_gui_shift_pressed() && c == 23)
- scale = g->scale + 0.1;
- else if (c == 17) {
- for (int i = SCALE_SNAP_TO_SIZE - 1; i >= 0; i--)
- if (scale_snap_to[i] < g->scale) {
- scale = scale_snap_to[i];
- break;
- }
- } else {
- for (unsigned int i = 0; i < SCALE_SNAP_TO_SIZE; i++)
- if (scale_snap_to[i] > g->scale) {
- scale = scale_snap_to[i];
- break;
- }
- }
- if (scale < scale_snap_to[0])
- scale = scale_snap_to[0];
- if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1])
- scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
- if (g->scale != scale) {
- ro_gui_window_set_scale(g, scale);
+ if (browser_window_has_content(g->bw) == true) {
+ return handle_local_keypress_scale(g, c);
}
- return true;
+ break;
case IS_WIMP_KEY + wimp_KEY_PRINT:
ro_gui_window_action_print(g);
@@ -1552,7 +1595,7 @@ static void ro_gui_window_close(wimp_w w)
if (pointer.buttons & wimp_CLICK_ADJUST) {
destroy = !ro_gui_shift_pressed();
- url = browser_window_get_url(g->bw);
+ url = browser_window_access_url(g->bw);
if (url != NULL) {
netsurf_nsurl_to_path(url, &filename);
}
@@ -1597,6 +1640,57 @@ static void ro_gui_window_close(wimp_w w)
}
}
+/**
+ * Wrapper for calls to browser_window_redraw for a wimp_draw rectangle.
+ *
+ * \param[in] gui_win Window to render.
+ * \param[in] wimp_rect The area of gui_win to render into.
+ * \param[in] use_buffer Whether to use buffered rendering.
+ */
+static inline void ro_gui_window__redraw_rect(
+ const struct gui_window *gui_win,
+ const wimp_draw *wimp_rect,
+ bool use_buffer)
+{
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &ro_plotters
+ };
+ struct rect clip;
+
+ /* OS's redraw request coordinates are in screen coordinates,
+ * with an origin at the bottom left of the screen.
+ * Find the coordinate of the top left of the document in terms
+ * of OS screen coordinates.
+ * NOTE: OS units are 2 per px. */
+ ro_plot_origin_x = wimp_rect->box.x0 - wimp_rect->xscroll;
+ ro_plot_origin_y = wimp_rect->box.y1 - wimp_rect->yscroll;
+
+ /* Adjust clip rect for origin. */
+ ro_plot_clip_rect.x0 = wimp_rect->clip.x0 - ro_plot_origin_x;
+ ro_plot_clip_rect.y0 = ro_plot_origin_y - wimp_rect->clip.y0;
+ ro_plot_clip_rect.x1 = wimp_rect->clip.x1 - ro_plot_origin_x;
+ ro_plot_clip_rect.y1 = ro_plot_origin_y - wimp_rect->clip.y1;
+
+ /* Convert OS redraw rectangle request coordinates into NetSurf
+ * coordinates. NetSurf coordinates have origin at top left of
+ * document and units are in px. */
+ clip.x0 = (ro_plot_clip_rect.x0 ) / 2; /* left */
+ clip.y0 = (ro_plot_clip_rect.y1 ) / 2; /* top */
+ clip.x1 = (ro_plot_clip_rect.x1 + 1) / 2; /* right */
+ clip.y1 = (ro_plot_clip_rect.y0 + 1) / 2; /* bottom */
+
+ if (use_buffer) {
+ ro_gui_buffer_open(wimp_rect);
+ }
+
+ browser_window_redraw(gui_win->bw, 0, 0, &clip, &ctx);
+
+ if (use_buffer) {
+ ro_gui_buffer_close();
+ }
+}
/**
* Handle a Redraw_Window_Request for a browser window.
@@ -1608,11 +1702,6 @@ static void ro_gui_window_redraw(wimp_draw *redraw)
osbool more;
struct gui_window *g;
os_error *error;
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &ro_plotters
- };
g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
@@ -1633,31 +1722,8 @@ static void ro_gui_window_redraw(wimp_draw *redraw)
return;
}
while (more) {
- struct rect clip;
-
- /* OS's redraw request coordinates are in screen coordinates,
- * with an origin at the bottom left of the screen.
- * Find the coordinate of the top left of the document in terms
- * of OS screen coordinates.
- * NOTE: OS units are 2 per px. */
- ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
- ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
-
- /* Convert OS redraw rectangle request coordinates into NetSurf
- * coordinates. NetSurf coordinates have origin at top left of
- * document and units are in px. */
- clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2; /* left */
- clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2; /* top */
- clip.x1 = (redraw->clip.x1 - ro_plot_origin_x) / 2; /* right */
- clip.y1 = (ro_plot_origin_y - redraw->clip.y0) / 2; /* bottom */
-
- if (ro_gui_current_redraw_gui->option.buffer_everything)
- ro_gui_buffer_open(redraw);
-
- browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
-
- if (ro_gui_current_redraw_gui->option.buffer_everything)
- ro_gui_buffer_close();
+ ro_gui_window__redraw_rect(g, redraw,
+ ro_gui_current_redraw_gui->option.buffer_everything);
/* Check to see if there are more rectangles to draw and
* get next one */
@@ -1688,37 +1754,48 @@ static void ro_gui_window_redraw(wimp_draw *redraw)
*/
static void ro_gui_window_scroll(wimp_scroll *scroll)
{
- struct gui_window *g = ro_gui_window_lookup(scroll->w);
-
- if (g && browser_window_has_content(g->bw) && ro_gui_shift_pressed()) {
- /* extended scroll request with shift held down; change zoom */
- float scale, inc;
-
- if (scroll->ymin & 3)
- inc = 0.02; /* RO5 sends the msg 5 times;
- * don't ask me why
- *
- * @todo this is liable to break if
- * HID is configured optimally for
- * frame scrolling. *5 appears to be
- * an artifact of non-HID mode scrolling.
- */
- else
- inc = (1 << (ABS(scroll->ymin)>>2)) / 20.0F;
-
- if (scroll->ymin > 0) {
- scale = g->scale + inc;
- if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1])
- scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
- } else {
- scale = g->scale - inc;
- if (scale < scale_snap_to[0])
- scale = scale_snap_to[0];
- }
- if (g->scale != scale)
- ro_gui_window_set_scale(g, scale);
- } else if (g != NULL) {
+ float cscale, scale, inc;
+ struct gui_window *g = ro_gui_window_lookup(scroll->w);
+
+ if (g == NULL) {
+ return;
+ }
+
+ if ((browser_window_has_content(g->bw) == false) ||
+ (ro_gui_shift_pressed() == false)) {
ro_gui_window_scroll_action(g, scroll->xmin, scroll->ymin);
+ return;
+ }
+
+ /* extended scroll request with shift held down; change zoom */
+ cscale = browser_window_get_scale(g->bw);
+
+ if (scroll->ymin & 3) {
+ inc = 0.02; /* RO5 sends the msg 5 times;
+ * don't ask me why
+ *
+ * @todo this is liable to break if
+ * HID is configured optimally for
+ * frame scrolling. *5 appears to be
+ * an artifact of non-HID mode scrolling.
+ */
+ } else {
+ inc = (1 << (ABS(scroll->ymin)>>2)) / 20.0F;
+ }
+
+ if (scroll->ymin > 0) {
+ scale = cscale + inc;
+ if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1]) {
+ scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1];
+ }
+ } else {
+ scale = cscale - inc;
+ if (scale < scale_snap_to[0]) {
+ scale = scale_snap_to[0];
+ }
+ }
+ if (scale != cscale) {
+ ro_gui_window_set_scale(g, scale);
}
}
@@ -2498,7 +2575,7 @@ ro_gui_window_menu_select(wimp_w w,
/* help actions */
case HELP_OPEN_CONTENTS:
- error = nsurl_create("http://www.netsurf-browser.org/documentation/", &url);
+ error = nsurl_create("https://www.netsurf-browser.org/documentation/", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
url,
@@ -2510,7 +2587,7 @@ ro_gui_window_menu_select(wimp_w w,
break;
case HELP_OPEN_GUIDE:
- error = nsurl_create("http://www.netsurf-browser.org/documentation/guide", &url);
+ error = nsurl_create("https://www.netsurf-browser.org/documentation/guide", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
url,
@@ -2522,7 +2599,7 @@ ro_gui_window_menu_select(wimp_w w,
break;
case HELP_OPEN_INFORMATION:
- error = nsurl_create("http://www.netsurf-browser.org/documentation/info", &url);
+ error = nsurl_create("https://www.netsurf-browser.org/documentation/info", &url);
if (error == NSERROR_OK) {
error = browser_window_create(BW_CREATE_HISTORY,
url,
@@ -2585,7 +2662,7 @@ ro_gui_window_menu_select(wimp_w w,
/* cookies actions */
case COOKIES_SHOW:
- ro_gui_cookies_present();
+ ro_gui_cookies_present(NULL);
break;
case COOKIES_DELETE:
@@ -2671,7 +2748,7 @@ ro_gui_window_menu_select(wimp_w w,
error = browser_window_navigate(
bw,
current_menu_url,
- browser_window_get_url(bw),
+ browser_window_access_url(bw),
BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
@@ -2684,7 +2761,7 @@ ro_gui_window_menu_select(wimp_w w,
error = browser_window_create(
BW_CREATE_HISTORY | BW_CREATE_CLONE,
current_menu_url,
- browser_window_get_url(bw),
+ browser_window_access_url(bw),
bw,
NULL);
}
@@ -3221,7 +3298,6 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
g->active = false;
strcpy(g->title, "NetSurf");
g->iconise_icon = -1;
- g->scale = browser_window_get_scale(bw);
/* Set the window position */
if (existing != NULL &&
@@ -3502,20 +3578,25 @@ static void gui_window_destroy(struct gui_window *g)
*/
static void gui_window_set_title(struct gui_window *g, const char *title)
{
+ float scale;
assert(g);
assert(title);
- if (g->scale != 1.0) {
- int scale_disp = g->scale * 100;
+ scale = browser_window_get_scale(g->bw);
+
+ if (scale != 1.0) {
+ int scale_disp = scale * 100;
- if (ABS((float)scale_disp - g->scale * 100) >= 0.05)
+ if (ABS((float)scale_disp - scale * 100) >= 0.05) {
snprintf(g->title, sizeof g->title, "%s (%.1f%%)",
- title, g->scale * 100);
- else
+ title, scale * 100);
+ } else {
snprintf(g->title, sizeof g->title, "%s (%i%%)",
title, scale_disp);
+ }
} else {
- strncpy(g->title, title, sizeof g->title);
+ strncpy(g->title, title, sizeof(g->title) - 1);
+ g->title[sizeof(g->title)-1] = 0;
}
ro_gui_set_window_title(g->window, g->title);
@@ -3547,10 +3628,11 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return false;
}
- if (g->toolbar)
+ if (g->toolbar) {
toolbar_height = ro_toolbar_full_height(g->toolbar);
- *sx = state.xscroll / (2 * g->scale);
- *sy = -(state.yscroll - toolbar_height) / (2 * g->scale);
+ }
+ *sx = state.xscroll / 2;
+ *sy = -(state.yscroll - toolbar_height) / 2;
return true;
}
@@ -3589,8 +3671,8 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
if ((rect->x0 == rect->x1) && (rect->y0 == rect->y1)) {
/* scroll to top */
- state.xscroll = rect->x0 * 2 * g->scale;
- state.yscroll = (-rect->y0 * 2 * g->scale) + toolbar_height;
+ state.xscroll = rect->x0 * 2;
+ state.yscroll = (-rect->y0 * 2) + toolbar_height;
} else {
/* scroll area into view with padding */
int x0, y0, x1, y1;
@@ -3598,10 +3680,10 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
int padding_available;
int correction;
- x0 = rect->x0 * 2 * g->scale;
- y0 = rect->y0 * 2 * g->scale;
- x1 = rect->x1 * 2 * g->scale;
- y1 = rect->y1 * 2 * g->scale;
+ x0 = rect->x0 * 2 ;
+ y0 = rect->y0 * 2 ;
+ x1 = rect->x1 * 2 ;
+ y1 = rect->y1 * 2 ;
cx0 = state.xscroll;
cy0 = -state.yscroll + toolbar_height;
@@ -3669,21 +3751,15 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
* \param gw gui window to measure
* \param width receives width of window
* \param height receives height of window
- * \param scaled whether to return scaled values
+ * \return NSERROR_OK and width and height updated
*/
static nserror
-gui_window_get_dimensions(struct gui_window *gw,
- int *width, int *height,
- bool scaled)
+gui_window_get_dimensions(struct gui_window *gw, int *width, int *height)
{
/* use the cached window sizes */
*width = gw->old_width / 2;
*height = gw->old_height / 2;
- if (scaled) {
- *width /= gw->scale;
- *height /= gw->scale;
- }
return NSERROR_OK;
}
@@ -3717,7 +3793,6 @@ static void gui_window_start_throbber(struct gui_window *g)
}
-
/**
* Update the interface to reflect page loading stopped.
*
@@ -3732,6 +3807,20 @@ static void gui_window_stop_throbber(struct gui_window *g)
g->active = false;
}
+
+/**
+ * Update the interface to reflect change in page info status
+ *
+ * \param gw window with start of load
+ */
+static void gui_window_page_info_change(struct gui_window *gw)
+{
+ if (gw->toolbar != NULL) {
+ ro_toolbar_page_info_change(gw->toolbar);
+ }
+}
+
+
/**
* set favicon
*/
@@ -3745,7 +3834,6 @@ gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
}
-
/**
* Remove the caret, if present.
*
@@ -3825,8 +3913,9 @@ static void ro_gui_window_scroll_end(wimp_dragged *drag, void *data)
ro_warn_user("WimpError", error->errmess);
}
- if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0, &pos))
+ if (ro_gui_window_to_window_pos(g, drag->final.x0, drag->final.y0, &pos)) {
browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
+ }
}
@@ -3905,6 +3994,7 @@ gui_window_drag_start(struct gui_window *g,
{
wimp_pointer pointer;
wimp_drag drag;
+ float scale = browser_window_get_scale(g->bw);
if (rect != NULL) {
/* We have a box to constrain the pointer to, for the drag
@@ -3921,13 +4011,13 @@ gui_window_drag_start(struct gui_window *g,
drag.type = wimp_DRAG_USER_POINT;
drag.bbox.x0 = pointer.pos.x +
- (int)(rect->x0 * 2 * g->scale);
+ (int)(rect->x0 * 2 * scale);
drag.bbox.y0 = pointer.pos.y +
- (int)(rect->y0 * 2 * g->scale);
+ (int)(rect->y0 * 2 * scale);
drag.bbox.x1 = pointer.pos.x +
- (int)(rect->x1 * 2 * g->scale);
+ (int)(rect->x1 * 2 * scale);
drag.bbox.y1 = pointer.pos.y +
- (int)(rect->y1 * 2 * g->scale);
+ (int)(rect->y1 * 2 * scale);
error = xwimp_drag_box(&drag);
if (error) {
@@ -3941,8 +4031,9 @@ gui_window_drag_start(struct gui_window *g,
switch (type) {
case GDRAGGING_SCROLLBAR:
/* Dragging a core scrollbar */
- ro_mouse_drag_start(ro_gui_window_scroll_end, ro_gui_window_mouse_at,
- NULL, g);
+ ro_mouse_drag_start(ro_gui_window_scroll_end,
+ ro_gui_window_mouse_at,
+ NULL, g);
break;
default:
@@ -4087,6 +4178,57 @@ ro_gui_window_import_text(struct gui_window *g, const char *filename)
/**
+ * process miscellaneous window events
+ *
+ * \param gw The window receiving the event.
+ * \param event The event code.
+ * \return NSERROR_OK when processed ok
+ */
+static nserror
+ro_gui_window_event(struct gui_window *gw, enum gui_window_event event)
+{
+ switch (event) {
+ case GW_EVENT_UPDATE_EXTENT:
+ gui_window_update_extent(gw);
+ break;
+
+ case GW_EVENT_REMOVE_CARET:
+ gui_window_remove_caret(gw);
+ break;
+
+ case GW_EVENT_SCROLL_START:
+ gui_window_scroll_start(gw);
+ break;
+
+ case GW_EVENT_NEW_CONTENT:
+ gui_window_new_content(gw);
+ break;
+
+ case GW_EVENT_START_THROBBER:
+ gui_window_start_throbber(gw);
+ break;
+
+ case GW_EVENT_STOP_THROBBER:
+ gui_window_stop_throbber(gw);
+ break;
+
+ case GW_EVENT_START_SELECTION:
+ /* from textselection */
+ gui_start_selection(gw);
+ break;
+
+ case GW_EVENT_PAGE_INFO_CHANGE:
+ gui_window_page_info_change(gw);
+ break;
+
+ default:
+ break;
+ }
+ return NSERROR_OK;
+}
+
+
+/**
* RISC OS browser window operation table
*/
static struct gui_window_table window_table = {
@@ -4096,7 +4238,7 @@ static struct gui_window_table window_table = {
.get_scroll = gui_window_get_scroll,
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
- .update_extent = gui_window_update_extent,
+ .event = ro_gui_window_event,
.set_title = gui_window_set_title,
.set_url = ro_gui_window_set_url,
@@ -4104,21 +4246,13 @@ static struct gui_window_table window_table = {
.set_status = riscos_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
- .remove_caret = gui_window_remove_caret,
.save_link = gui_window_save_link,
.drag_start = gui_window_drag_start,
- .scroll_start = gui_window_scroll_start,
- .new_content = gui_window_new_content,
- .start_throbber = gui_window_start_throbber,
- .stop_throbber = gui_window_stop_throbber,
.create_form_select_menu = gui_window_create_form_select_menu,
/* from save */
.drag_save_object = gui_drag_save_object,
.drag_save_selection =gui_drag_save_selection,
-
- /* from textselection */
- .start_selection = gui_start_selection,
};
struct gui_window_table *riscos_window_table = &window_table;
@@ -4268,10 +4402,10 @@ ro_gui_window_invalidate_area(struct gui_window *g, const struct rect *rect)
return NSERROR_OK;
}
- x0 = floorf(rect->x0 * 2 * g->scale);
- y0 = -ceilf(rect->y1 * 2 * g->scale);
- x1 = ceilf(rect->x1 * 2 * g->scale) + 1;
- y1 = -floorf(rect->y0 * 2 * g->scale) + 1;
+ x0 = floorf(rect->x0 * 2 );
+ y0 = -ceilf(rect->y1 * 2 );
+ x1 = ceilf(rect->x1 * 2 ) + 1;
+ y1 = -floorf(rect->y0 * 2 ) + 1;
use_buffer =
(g->option.buffer_everything || g->option.buffer_animations);
@@ -4339,7 +4473,6 @@ nserror ro_gui_window_set_url(struct gui_window *g, nsurl *url)
/* exported interface documented in riscos/window.h */
void ro_gui_window_set_scale(struct gui_window *g, float scale)
{
- g->scale = scale;
browser_window_set_scale(g->bw, scale, true);
}
@@ -4382,11 +4515,14 @@ void ro_gui_window_mouse_at(wimp_pointer *pointer, void *data)
os_coord pos;
struct gui_window *g = (struct gui_window *) data;
- if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
- browser_window_mouse_track(g->bw,
- ro_gui_mouse_drag_state(pointer->buttons,
+ if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos)) {
+ browser_window_mouse_track(
+ g->bw,
+ ro_gui_mouse_drag_state(pointer->buttons,
wimp_BUTTON_DOUBLE_CLICK_DRAG),
- pos.x, pos.y);
+ pos.x,
+ pos.y);
+ }
}
@@ -4434,7 +4570,7 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi)
/* create the thumbnail sprite */
bitmap = riscos_bitmap_create(width, height,
- BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
+ BITMAP_OPAQUE | BITMAP_CLEAR);
if (!bitmap) {
NSLOG(netsurf, INFO, "Thumbnail initialisation failed.");
return;
@@ -4559,22 +4695,15 @@ void ro_gui_window_redraw_all(void)
}
}
-
/* exported interface documented in riscos/window.h */
void ro_gui_window_update_boxes(void)
{
osbool more;
bool use_buffer;
wimp_draw update;
- struct rect clip;
os_error *error;
struct update_box *cur;
struct gui_window *g;
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &ro_plotters
- };
for (cur = pending_updates; cur != NULL; cur = cur->next) {
g = cur->g;
@@ -4600,22 +4729,8 @@ void ro_gui_window_update_boxes(void)
/* Set the current redraw gui_window to get options from */
ro_gui_current_redraw_gui = g;
- ro_plot_origin_x = update.box.x0 - update.xscroll;
- ro_plot_origin_y = update.box.y1 - update.yscroll;
-
while (more) {
- clip.x0 = (update.clip.x0 - ro_plot_origin_x) / 2;
- clip.y0 = (ro_plot_origin_y - update.clip.y1) / 2;
- clip.x1 = (update.clip.x1 - ro_plot_origin_x) / 2;
- clip.y1 = (ro_plot_origin_y - update.clip.y0) / 2;
-
- if (use_buffer)
- ro_gui_buffer_open(&update);
-
- browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
-
- if (use_buffer)
- ro_gui_buffer_close();
+ ro_gui_window__redraw_rect(g, &update, use_buffer);
error = xwimp_get_rectangle(&update, &more);
/* RISC OS 3.7 returns an error here if enough buffer
@@ -4676,17 +4791,19 @@ void ro_gui_throb(void)
/* exported interface documented in riscos/window.h */
void ro_gui_window_default_options(struct gui_window *gui)
{
+ float cscale;
+
if (gui == NULL)
return;
- /* Save the basic options
- */
- nsoption_set_int(scale, gui->scale * 100);
+ cscale = browser_window_get_scale(gui->bw);
+
+ /* Save the basic options */
+ nsoption_set_int(scale, cscale * 100);
nsoption_set_bool(buffer_animations, gui->option.buffer_animations);
nsoption_set_bool(buffer_everything, gui->option.buffer_everything);
- /* Set up the toolbar
- */
+ /* Set up the toolbar */
if (gui->toolbar != NULL) {
nsoption_set_bool(toolbar_show_buttons,
ro_toolbar_get_display_buttons(gui->toolbar));
@@ -4695,9 +4812,10 @@ void ro_gui_window_default_options(struct gui_window *gui)
nsoption_set_bool(toolbar_show_throbber,
ro_toolbar_get_display_throbber(gui->toolbar));
}
- if (gui->status_bar != NULL)
+ if (gui->status_bar != NULL) {
nsoption_set_int(toolbar_status_size,
ro_gui_status_bar_get_width(gui->status_bar));
+ }
}
@@ -4749,33 +4867,8 @@ ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos)
ro_warn_user("WimpError", error->errmess);
return false;
}
- pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->scale;
- pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->scale;
- return true;
-}
-
-
-/* exported interface documented in riscos/window.h */
-bool ro_gui_window_to_screen_pos(struct gui_window *g,
- int x,
- int y,
- os_coord *pos)
-{
- wimp_window_state state;
- os_error *error;
-
- assert(g);
-
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x:%s",
- error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return false;
- }
- pos->x = (x * 2 * g->scale) + (state.visible.x0 - state.xscroll);
- pos->y = (state.visible.y1 - state.yscroll) - (y * 2 * g->scale);
+ pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 ;
+ pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 ;
return true;
}