summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
Diffstat (limited to 'riscos')
-rw-r--r--riscos/download.c2
-rw-r--r--riscos/gui.c2
-rw-r--r--riscos/hotlist.c2
-rw-r--r--riscos/htmlredraw.c61
-rw-r--r--riscos/menus.c135
-rw-r--r--riscos/textselection.c6
-rw-r--r--riscos/window.c71
7 files changed, 113 insertions, 166 deletions
diff --git a/riscos/download.c b/riscos/download.c
index 591ddce14..2a6d8d583 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -217,6 +217,8 @@ struct gui_download_window *gui_download_window_create(const char *url,
dw->prev = 0;
dw->next = download_window_list;
+ if (download_window_list)
+ download_window_list->prev = dw;
download_window_list = dw;
ro_gui_download_update_status(dw);
diff --git a/riscos/gui.c b/riscos/gui.c
index f3a05f9ae..8cde110ee 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -783,7 +783,7 @@ void ro_gui_icon_bar_click(wimp_pointer *pointer)
{
int key_down = 0;
if (pointer->buttons == wimp_CLICK_MENU) {
- ro_gui_create_menu(iconbar_menu, pointer->pos.x - 64,
+ ro_gui_create_menu(iconbar_menu, pointer->pos.x,
96 + iconbar_menu_height, NULL);
} else if (pointer->buttons == wimp_CLICK_SELECT) {
char url[80];
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 0024336f0..c902628c3 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -1452,7 +1452,7 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) {
/* Create a menu if we should
*/
if (buttons == wimp_CLICK_MENU) {
- ro_gui_create_menu(hotlist_menu, pointer->pos.x - 64,
+ ro_gui_create_menu(hotlist_menu, pointer->pos.x,
pointer->pos.y, NULL);
menu_open = true;
return;
diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c
index 9a285fb3c..1b2ef4ec7 100644
--- a/riscos/htmlredraw.c
+++ b/riscos/htmlredraw.c
@@ -310,52 +310,6 @@ void html_redraw_box(struct content *content, struct box * box,
} else if (box->text && box->font) {
- if (content->data.html.text_selection.selected == 1) {
- struct box_position *start;
- struct box_position *end;
-
- start = &(content->data.html.text_selection.start);
- end = &(content->data.html.text_selection.end);
-
- if (start->box == box) {
- if (end->box == box) {
- colourtrans_set_gcol(os_COLOUR_VERY_LIGHT_GREY, colourtrans_USE_ECFS, 0, 0);
- os_plot(os_MOVE_TO,
- x + start->pixel_offset * 2,
- y - height);
- os_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
- x + end->pixel_offset * 2 - 2,
- y - 2);
- } else {
- colourtrans_set_gcol(os_COLOUR_VERY_LIGHT_GREY, colourtrans_USE_ECFS, 0, 0);
- os_plot(os_MOVE_TO,
- x + start->pixel_offset * 2,
- y - height);
- os_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
- x + width - 2,
- y - 2);
- *select_on = true;
- }
- } else if (*select_on) {
- if (end->box != box) {
- colourtrans_set_gcol(os_COLOUR_VERY_LIGHT_GREY, colourtrans_USE_ECFS, 0, 0);
- os_plot(os_MOVE_TO, x,
- y - height);
- os_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
- x + width - 2,
- y - 2);
- } else {
- colourtrans_set_gcol(os_COLOUR_VERY_LIGHT_GREY, colourtrans_USE_ECFS, 0, 0);
- os_plot(os_MOVE_TO, x,
- y - height);
- os_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
- x + end->pixel_offset * 2 - 2,
- y - 2);
- *select_on = false;
- }
- }
- }
-
colourtrans_set_font_colours(box->font->handle,
current_background_color << 8,
box->style->color << 8, 14, 0, 0, 0);
@@ -429,21 +383,6 @@ void html_redraw_box(struct content *content, struct box * box,
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
box->type == BOX_TABLE_CELL || box->object)
html_redraw_clip(clip_x0, clip_y0, clip_x1, clip_y1);
-
-/* } else {
- if (content->data.html.text_selection.selected == 1) {
- struct box_position *start;
- struct box_position *end;
-
- start = &(content->data.html.text_selection.start);
- end = &(content->data.html.text_selection.end);
-
- if (start->box == box && end->box != box)
- *select_on = true;
- else if (*select_on && end->box == box)
- *select_on = false;
- }
- }*/
}
diff --git a/riscos/menus.c b/riscos/menus.c
index 5039d973a..9bb3bb5b1 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -48,7 +48,6 @@ static void ro_gui_menu_prepare_window(void);
static void ro_gui_menu_prepare_toolbars(void);
static void ro_gui_menu_prepare_help(int forced);
static void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning);
-static struct box *ro_gui_menu_find_object_box(void);
static void ro_gui_menu_object_reload(void);
static void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning);
static void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning);
@@ -58,6 +57,9 @@ struct gui_window *current_gui;
wimp_menu *current_menu;
static int current_menu_x, current_menu_y;
+/** Box for object under menu, or 0 if no object. */
+static struct box *gui_menu_object_box = 0;
+
/** Menu of options for form select controls. */
static wimp_menu *gui_form_select_menu = 0;
/** Form control which gui_form_select_menu is for. */
@@ -477,21 +479,55 @@ void translate_menu(wimp_menu *menu)
void ro_gui_create_menu(wimp_menu *menu, int x, int y, struct gui_window *g)
{
+ int doc_x, doc_y;
+ wimp_window_state state;
+ os_error *error;
+
current_menu = menu;
current_menu_x = x;
current_menu_y = y;
current_gui = g;
+
if (menu == browser_menu) {
- if (!hotlist_window) browser_utilities_menu->entries[0].icon_flags |= wimp_ICON_SHADED;
- if (ro_gui_menu_find_object_box())
+ assert(g);
+
+ state.w = g->window;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ LOG(("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ doc_x = window_x_units(x, &state) / 2 / g->option.scale;
+ doc_y = -window_y_units(y, &state) / 2 / g->option.scale;
+
+ gui_menu_object_box = 0;
+ if (g->bw->current_content &&
+ g->bw->current_content->type == CONTENT_HTML) {
+ gui_menu_object_box = box_object_at_point(
+ g->bw->current_content, doc_x, doc_y);
+ }
+
+ if (!hotlist_window)
+ browser_utilities_menu->entries[0].icon_flags |=
+ wimp_ICON_SHADED;
+ if (gui_menu_object_box)
menu->entries[1].icon_flags &= ~wimp_ICON_SHADED;
else
menu->entries[1].icon_flags |= wimp_ICON_SHADED;
- }
- if (menu == hotlist_menu) {
+
+ } else if (menu == hotlist_menu) {
ro_gui_menu_prepare_hotlist();
}
- wimp_create_menu(menu, x, y);
+
+ error = xwimp_create_menu(menu, x - 64, y);
+ if (error) {
+ LOG(("xwimp_create_menu: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("MenuError", error->errmess);
+ }
}
@@ -508,7 +544,8 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i)
icon_state.i = i;
wimp_get_window_state(&state);
wimp_get_icon_state(&icon_state);
- ro_gui_create_menu(menu, state.visible.x0 + icon_state.icon.extent.x1,
+ ro_gui_create_menu(menu,
+ state.visible.x0 + icon_state.icon.extent.x1 + 64,
state.visible.y1 + icon_state.icon.extent.y1, 0);
}
@@ -630,6 +667,8 @@ void ro_gui_menu_selection(wimp_selection *selection)
}
break;
case MENU_OBJECT:
+ if (!gui_menu_object_box)
+ break;
switch (selection->items[1]) {
case 0: /* Info */
break;
@@ -914,7 +953,7 @@ void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning)
/** \todo this is really dumb, the object should be the one
* that the user clicked menu over, not the one that happens to
* be under the menu now */
- box = ro_gui_menu_find_object_box();
+ box = gui_menu_object_box;
if (!box)
break;
@@ -1377,34 +1416,25 @@ void ro_gui_menu_prepare_pageinfo(void)
ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_TYPE, mime);
}
+
void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning)
{
- struct content *c = current_gui->bw->current_content;
- struct box *box;
- os_error *error;
char icon_buf[20] = "file_xxx";
- const char *icon = icon_buf;
const char *url = "-";
const char *target = "-";
const char *mime = "-";
+ os_error *error;
- box = ro_gui_menu_find_object_box();
- if (box) {
- sprintf(icon_buf, "file_%x", ro_content_filetype(box->object));
- if (box->object->url) url = box->object->url;
- if (box->href) target = box->href;
- if (box->object->mime_type) mime = box->object->mime_type;
- }
- else if (c->type == CONTENT_JPEG || c->type == CONTENT_PNG ||
- c->type == CONTENT_JNG || c->type == CONTENT_MNG ||
- c->type == CONTENT_GIF || c->type == CONTENT_SPRITE ||
- c->type == CONTENT_DRAW) {
- sprintf(icon_buf, "file_%x", ro_content_filetype(c));
- if (c->url) url = c->url;
- if (c->mime_type) mime = c->mime_type;
- }
+ sprintf(icon_buf, "file_%x",
+ ro_content_filetype(gui_menu_object_box->object));
+ if (gui_menu_object_box->object->url)
+ url = gui_menu_object_box->object->url;
+ if (gui_menu_object_box->href)
+ target = gui_menu_object_box->href;
+ if (gui_menu_object_box->object->mime_type)
+ mime = gui_menu_object_box->object->mime_type;
- ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_ICON, icon);
+ ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_ICON, icon_buf);
ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_URL, url);
ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_TARGET, target);
ro_gui_set_icon_string(dialog_objinfo, ICON_OBJINFO_TYPE, mime);
@@ -1412,56 +1442,17 @@ void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning)
error = xwimp_create_sub_menu((wimp_menu *) dialog_objinfo,
warning->pos.x, warning->pos.y);
if (error) {
- LOG(("0x%x: %s\n", error->errnum, error->errmess));
+ LOG(("xwimp_create_sub_menu: 0x%x: %s",
+ error->errnum, error->errmess));
warn_user("MenuError", error->errmess);
}
}
-struct box *ro_gui_menu_find_object_box(void)
-{
- struct content *c = current_gui->bw->current_content;
- struct box_selection *boxes = NULL;
- struct box *box = NULL;
- int found = 0, plot_index = 0, i, x, y;
- wimp_window_state state;
-
- state.w = current_gui->window;
- wimp_get_window_state(&state);
-
- /* The menu is initially created 64 units to the left
- * of the mouse position. Therefore, we negate the offset here
- */
- x = window_x_units(current_menu_x+64, &state) / 2 / current_gui->option.scale;
- y = -window_y_units(current_menu_y, &state) / 2 / current_gui->option.scale;
-
- if (c->type == CONTENT_HTML) {
-
- box_under_area(c, c->data.html.layout->children,
- x, y, 0, 0, &boxes, &found, &plot_index);
-
- if (found > 0) {
- for (i=found-1;i>=0;i--) {
- if (boxes[i].box->object != 0) {
- box = boxes[i].box;
- break;
- }
- }
- }
-
- free(boxes);
- }
-
- return box;
-}
void ro_gui_menu_object_reload(void)
{
- struct box *box = ro_gui_menu_find_object_box();
-
- if (box) {
- box->object->fresh = false;
- browser_window_reload(current_gui->bw, false);
- }
+ gui_menu_object_box->object->fresh = false;
+ browser_window_reload(current_gui->bw, false);
}
@@ -1551,5 +1542,5 @@ void gui_create_form_select_menu(struct browser_window *bw,
current_gui = bw->window;
gui_form_select_control = control;
ro_gui_create_menu(gui_form_select_menu,
- pointer.pos.x - 64, pointer.pos.y, bw->window);
+ pointer.pos.x, pointer.pos.y, bw->window);
}
diff --git a/riscos/textselection.c b/riscos/textselection.c
index 7129fd2ac..b2b69baff 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -50,13 +50,13 @@ void ro_gui_selection_drag_end(wimp_dragged *drag)
msg.type = act_ALTER_SELECTION;
browser_window_action(current_gui->bw, &msg);*/
- if (box_position_eq(&(current_gui->bw->current_content->data.html.text_selection.start),
- &(current_gui->bw->current_content->data.html.text_selection.end)))
+/* if (box_position_eq(&(current_gui->bw->current_content->data.html.text_selection.start), */
+/* &(current_gui->bw->current_content->data.html.text_selection.end))) */
{
/* msg.type = act_CLEAR_SELECTION;
browser_window_action(current_gui->bw, &msg);*/
}
- current_gui->bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
+/* current_gui->bw->current_content->data.html.text_selection.altering = alter_UNKNOWN; */
}
diff --git a/riscos/window.c b/riscos/window.c
index 01de4839d..45fcb5cf8 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -189,6 +189,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
g->prev = 0;
g->next = window_list;
+ if (window_list)
+ window_list->prev = g;
window_list = g;
window_count++;
@@ -1059,7 +1061,7 @@ void ro_gui_window_click(struct gui_window *g, wimp_pointer *pointer)
}
if (pointer->buttons == wimp_CLICK_MENU)
- ro_gui_create_menu(browser_menu, pointer->pos.x - 64,
+ ro_gui_create_menu(browser_menu, pointer->pos.x,
pointer->pos.y, g);
else if (pointer->buttons == wimp_CLICK_SELECT)
browser_window_mouse_click(g->bw, BROWSER_MOUSE_CLICK_1, x, y);
@@ -1416,13 +1418,14 @@ int window_y_units(int y, wimp_window_state *state) {
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
{
- struct browser_window *bw = g->bw;
- struct box_selection *click_boxes = 0;
+ int box_x = 0, box_y = 0;
int x, y;
- int i;
- int found = 0;
- int plot_index = 0;
+ struct box *box;
+ struct box *file_box = 0;
+ struct browser_window *bw = g->bw;
+ struct content *content;
wimp_window_state state;
+ os_error *error;
/* HTML content only. */
if (!bw->current_content || bw->current_content->type != CONTENT_HTML)
@@ -1434,41 +1437,53 @@ bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
/* Search for a file input at the drop point. */
state.w = message->data.data_xfer.w;
- wimp_get_window_state(&state);
- x = window_x_units(message->data.data_xfer.pos.x, &state) / 2;
- y = -window_y_units(message->data.data_xfer.pos.y, &state) / 2;
-
- box_under_area(bw->current_content,
- bw->current_content->data.html.layout->children,
- x, y, 0, 0, &click_boxes, &found, &plot_index);
- if (found == 0)
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ LOG(("xwimp_get_window_state: 0x%x: %s\n",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
return false;
- for (i = 0; i != found; i++) {
- if (click_boxes[i].box->gadget &&
- click_boxes[i].box->gadget->type ==
- GADGET_FILE)
- break;
}
- if (i == found) {
- free(click_boxes);
- return false;
+
+ x = window_x_units(message->data.data_xfer.pos.x, &state) / 2 /
+ g->option.scale;
+ y = -window_y_units(message->data.data_xfer.pos.y, &state) / 2 /
+ g->option.scale;
+
+ content = bw->current_content;
+ box = content->data.html.layout;
+ while ((box = box_at_point(box, x, y, &box_x, &box_y, &content))) {
+ if (box->style &&
+ box->style->visibility == CSS_VISIBILITY_HIDDEN)
+ continue;
+
+ if (box->gadget && box->gadget->type == GADGET_FILE)
+ file_box = box;
}
+ if (!file_box)
+ return false;
+
/* Found: update form input. */
- free(click_boxes[i].box->gadget->value);
- click_boxes[i].box->gadget->value =
+ free(file_box->gadget->value);
+ file_box->gadget->value =
strdup(message->data.data_xfer.file_name);
/* Redraw box. */
- box_coords(click_boxes[i].box, &x, &y);
+ box_coords(file_box, &x, &y);
gui_window_redraw(bw->window, x, y,
- x + click_boxes[i].box->width,
- y + click_boxes[i].box->height);
+ x + file_box->width,
+ y + file_box->height);
/* send DataLoadAck */
message->action = message_DATA_LOAD_ACK;
message->your_ref = message->my_ref;
- wimp_send_message(wimp_USER_MESSAGE, message, message->sender);
+ error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
+ if (error) {
+ LOG(("xwimp_send_message: 0x%x: %s\n",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
return true;
}