summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-07-17 23:32:09 +0000
committerJames Bursa <james@netsurf-browser.org>2004-07-17 23:32:09 +0000
commitf23fd2a0945b4d178eff39413b68528a951b8775 (patch)
tree898de8adb998be27471e74e67ca9f9ca6de2adc9 /riscos
parenta9aef8bf603fc68b230543bcfd399cb81e6687be (diff)
downloadnetsurf-f23fd2a0945b4d178eff39413b68528a951b8775.tar.gz
netsurf-f23fd2a0945b4d178eff39413b68528a951b8775.tar.bz2
[project @ 2004-07-17 23:32:08 by bursa]
Rewrite and simplify mouse click handling. svn path=/import/netsurf/; revision=1094
Diffstat (limited to 'riscos')
-rw-r--r--riscos/gui.c50
-rw-r--r--riscos/menus.c117
-rw-r--r--riscos/textselection.c10
-rw-r--r--riscos/window.c40
4 files changed, 117 insertions, 100 deletions
diff --git a/riscos/gui.c b/riscos/gui.c
index c629da12b..f3a05f9ae 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -35,7 +35,6 @@
#include "netsurf/desktop/netsurf.h"
#include "netsurf/desktop/options.h"
#include "netsurf/render/font.h"
-#include "netsurf/render/form.h"
#include "netsurf/render/html.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/help.h"
@@ -62,8 +61,6 @@ const char *__dynamic_da_name = "NetSurf"; /**< For UnixLib. */
int __feature_imagefs_is_file = 1; /**< For UnixLib. */
char *NETSURF_DIR;
-wimp_menu *combo_menu;
-struct form_control *current_gadget;
/** The pointer is over a window which is tracking mouse movement. */
static bool gui_track = false;
@@ -958,53 +955,6 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
}
-void gui_gadget_combo(struct browser_window* bw, struct form_control* g, unsigned long mx, unsigned long my)
-{
- int count;
- struct form_option* o;
- wimp_pointer pointer;
-
- if (combo_menu != NULL)
- xfree(combo_menu);
-
- for (count = 0, o = g->data.select.items; o != NULL; ++count, o = o->next)
- /* no body */;
-
- combo_menu = xcalloc(1, wimp_SIZEOF_MENU(count));
-
- combo_menu->title_data.indirected_text.text =
- messages_get("SelectMenu");
- combo_menu->title_fg = wimp_COLOUR_BLACK;
- combo_menu->title_bg = wimp_COLOUR_LIGHT_GREY;
- combo_menu->work_fg = wimp_COLOUR_BLACK;
- combo_menu->work_bg = wimp_COLOUR_WHITE;
- combo_menu->width = 0;
- combo_menu->height = wimp_MENU_ITEM_HEIGHT;
- combo_menu->gap = wimp_MENU_ITEM_GAP;
-
- for (count = 0, o = g->data.select.items; o != NULL; ++count, o = o->next) {
- combo_menu->entries[count].menu_flags = 0;
- if (count == 0)
- combo_menu->entries[count].menu_flags = wimp_MENU_TITLE_INDIRECTED;
- if (o->selected)
- combo_menu->entries[count].menu_flags |= wimp_MENU_TICKED;
- if (o->next == NULL)
- combo_menu->entries[count].menu_flags |= wimp_MENU_LAST;
-
- combo_menu->entries[count].sub_menu = wimp_NO_SUB_MENU;
- combo_menu->entries[count].icon_flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | wimp_ICON_FILLED | wimp_ICON_VCENTRED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT) | (wimp_BUTTON_MENU_ICON << wimp_ICON_BUTTON_TYPE_SHIFT);
- /* \todo combo_menu->entries[count].data.indirected_text.text needs to be free() when menu gets closed. */
- combo_menu->entries[count].data.indirected_text.text = cnv_str_local_enc(o->text);
- combo_menu->entries[count].data.indirected_text.validation = "\0";
- combo_menu->entries[count].data.indirected_text.size = strlen(combo_menu->entries[count].data.indirected_text.text) + 1;
- }
-
- wimp_get_pointer_info(&pointer);
- current_gadget = g;
- ro_gui_create_menu(combo_menu, pointer.pos.x - 64, pointer.pos.y, bw->window);
-}
-
-
/**
* Handle Message_DataLoad (file dragged in).
*/
diff --git a/riscos/menus.c b/riscos/menus.c
index 4211642c2..5039d973a 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -18,6 +18,7 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "netsurf/desktop/gui.h"
+#include "netsurf/render/form.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/help.h"
#include "netsurf/riscos/options.h"
@@ -57,6 +58,12 @@ struct gui_window *current_gui;
wimp_menu *current_menu;
static int current_menu_x, current_menu_y;
+/** Menu of options for form select controls. */
+static wimp_menu *gui_form_select_menu = 0;
+/** Form control which gui_form_select_menu is for. */
+static struct form_control *gui_form_select_control;
+
+
/* Default menu item flags
*/
#define DEFAULT_FLAGS (wimp_ICON_TEXT | wimp_ICON_FILLED | \
@@ -512,18 +519,16 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i)
void ro_gui_menu_selection(wimp_selection *selection)
{
- struct browser_action msg;
wimp_pointer pointer;
wimp_window_state state;
os_error *error;
wimp_get_pointer_info(&pointer);
- if (current_menu == combo_menu && selection->items[0] >= 0) {
- msg.type = act_GADGET_SELECT;
- msg.data.gadget_select.g = current_gadget;
- msg.data.gadget_select.item = selection->items[0];
- browser_window_action(current_gui->bw, &msg);
+ if (current_menu == gui_form_select_menu && 0 <= selection->items[0]) {
+ browser_window_form_select(current_gui->bw,
+ gui_form_select_control,
+ selection->items[0]);
} else if (current_menu == iconbar_menu) {
switch (selection->items[0]) {
@@ -655,8 +660,6 @@ void ro_gui_menu_selection(wimp_selection *selection)
case 1: /* Select all */
break;
case 2: /* Clear */
- msg.type = act_CLEAR_SELECTION;
- browser_window_action(current_gui->bw, &msg);
break;
}
break;
@@ -807,10 +810,13 @@ void ro_gui_menu_selection(wimp_selection *selection)
}
if (pointer.buttons == wimp_CLICK_ADJUST) {
- if (current_menu == combo_menu)
- gui_gadget_combo(current_gui->bw, current_gadget, (unsigned int)current_menu_x, (unsigned int)current_menu_y);
+ if (current_menu == gui_form_select_menu)
+ gui_create_form_select_menu(current_gui->bw,
+ gui_form_select_control);
else
- ro_gui_create_menu(current_menu, current_menu_x, current_menu_y, current_gui);
+ ro_gui_create_menu(current_menu,
+ current_menu_x, current_menu_y,
+ current_gui);
} else {
if (current_menu == hotlist_menu) {
ro_gui_hotlist_menu_closed();
@@ -1458,3 +1464,92 @@ void ro_gui_menu_object_reload(void)
}
}
+
+/**
+ * Display a menu of options for a form select control.
+ *
+ * \param bw browser window containing form control
+ * \param control form control of type GADGET_SELECT
+ */
+
+void gui_create_form_select_menu(struct browser_window *bw,
+ struct form_control *control)
+{
+ unsigned int i = 0, j;
+ struct form_option *option;
+ wimp_pointer pointer;
+ os_error *error;
+
+ for (option = control->data.select.items; option; option = option->next)
+ i++;
+
+ if (i == 0)
+ return;
+
+ if (gui_form_select_menu) {
+ for (j = 0; ; j++) {
+ free(gui_form_select_menu->entries[j].data.
+ indirected_text.text);
+ if (gui_form_select_menu->entries[j].menu_flags &
+ wimp_MENU_LAST)
+ break;
+ }
+ free(gui_form_select_menu);
+ gui_form_select_menu = 0;
+ }
+
+ gui_form_select_menu = malloc(wimp_SIZEOF_MENU(i));
+ if (!gui_form_select_menu) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+
+ gui_form_select_menu->title_data.indirected_text.text =
+ messages_get("SelectMenu");
+ gui_form_select_menu->title_fg = wimp_COLOUR_BLACK;
+ gui_form_select_menu->title_bg = wimp_COLOUR_LIGHT_GREY;
+ gui_form_select_menu->work_fg = wimp_COLOUR_BLACK;
+ gui_form_select_menu->work_bg = wimp_COLOUR_WHITE;
+ gui_form_select_menu->width = 200;
+ gui_form_select_menu->height = wimp_MENU_ITEM_HEIGHT;
+ gui_form_select_menu->gap = wimp_MENU_ITEM_GAP;
+
+ for (i = 0, option = control->data.select.items; option;
+ i++, option = option->next) {
+ gui_form_select_menu->entries[i].menu_flags = 0;
+ if (option->selected)
+ gui_form_select_menu->entries[i].menu_flags =
+ wimp_MENU_TICKED;
+ gui_form_select_menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
+ gui_form_select_menu->entries[i].icon_flags = wimp_ICON_TEXT |
+ wimp_ICON_INDIRECTED | wimp_ICON_FILLED |
+ (wimp_COLOUR_BLACK <<
+ wimp_ICON_FG_COLOUR_SHIFT) |
+ (wimp_COLOUR_WHITE <<
+ wimp_ICON_BG_COLOUR_SHIFT);
+ /* \todo can cnv_str_local_enc() fail? */
+ gui_form_select_menu->entries[i].data.indirected_text.text =
+ cnv_str_local_enc(option->text);
+ gui_form_select_menu->entries[i].data.indirected_text.
+ validation = "\0";
+ gui_form_select_menu->entries[i].data.indirected_text.size =
+ strlen(gui_form_select_menu->entries[i].
+ data.indirected_text.text) + 1;
+ }
+
+ gui_form_select_menu->entries[0].menu_flags |=
+ wimp_MENU_TITLE_INDIRECTED;
+ gui_form_select_menu->entries[i - 1].menu_flags |= wimp_MENU_LAST;
+
+ error = xwimp_get_pointer_info(&pointer);
+ if (error) {
+ LOG(("xwimp_get_pointer_info: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+
+ 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);
+}
diff --git a/riscos/textselection.c b/riscos/textselection.c
index 34be842d7..7129fd2ac 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -35,7 +35,7 @@ void ro_gui_start_selection(wimp_pointer *pointer, wimp_window_state *state,
void ro_gui_selection_drag_end(wimp_dragged *drag)
{
- struct browser_action msg;
+/* struct browser_action msg; */
int final_x0, final_y0;
wimp_window_state state;
@@ -45,16 +45,16 @@ void ro_gui_selection_drag_end(wimp_dragged *drag)
final_x0 = window_x_units(drag->final.x0, &state) / 2;
final_y0 = window_y_units(drag->final.y0, &state) / 2;
- msg.data.mouse.x = final_x0;
+/* msg.data.mouse.x = final_x0;
msg.data.mouse.y = final_y0;
msg.type = act_ALTER_SELECTION;
- browser_window_action(current_gui->bw, &msg);
+ 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)))
{
- msg.type = act_CLEAR_SELECTION;
- browser_window_action(current_gui->bw, &msg);
+/* msg.type = act_CLEAR_SELECTION;
+ browser_window_action(current_gui->bw, &msg);*/
}
current_gui->bw->current_content->data.html.text_selection.altering = alter_UNKNOWN;
}
diff --git a/riscos/window.c b/riscos/window.c
index 2c86918d1..01de4839d 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -908,14 +908,7 @@ void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
x = window_x_units(pointer->pos.x, &state) / 2 / g->option.scale;
y = -window_y_units(pointer->pos.y, &state) / 2 / g->option.scale;
- if (g->bw->current_content != NULL)
- {
- struct browser_action msg;
- msg.type = act_MOUSE_AT;
- msg.data.mouse.x = x;
- msg.data.mouse.y = y;
- browser_window_action(g->bw, &msg);
- }
+ browser_window_mouse_click(g->bw, BROWSER_MOUSE_HOVER, x, y);
}
@@ -1034,7 +1027,6 @@ void ro_gui_status_click(struct gui_window *g, wimp_pointer *pointer)
void ro_gui_window_click(struct gui_window *g, wimp_pointer *pointer)
{
- struct browser_action msg;
int x, y;
wimp_window_state state;
os_error *error;
@@ -1066,33 +1058,13 @@ void ro_gui_window_click(struct gui_window *g, wimp_pointer *pointer)
}
}
- if (pointer->buttons == wimp_CLICK_MENU) {
+ if (pointer->buttons == wimp_CLICK_MENU)
ro_gui_create_menu(browser_menu, pointer->pos.x - 64,
pointer->pos.y, g);
- return;
- }
-
- if (pointer->buttons == wimp_CLICK_SELECT) {
- msg.type = act_MOUSE_CLICK;
- msg.data.mouse.x = x;
- msg.data.mouse.y = y;
- if (browser_window_action(
- g->bw, &msg) == 1)
- return;
- msg.type = act_UNKNOWN;
- }
-
- if (pointer->buttons == wimp_CLICK_SELECT
- || pointer->buttons == wimp_CLICK_ADJUST) {
-
- if (pointer->buttons == wimp_CLICK_SELECT)
- msg.type = act_FOLLOW_LINK;
- else
- msg.type = act_FOLLOW_LINK_NEW_WINDOW;
- msg.data.mouse.x = x;
- msg.data.mouse.y = y;
- browser_window_action(g->bw, &msg);
- }
+ else if (pointer->buttons == wimp_CLICK_SELECT)
+ browser_window_mouse_click(g->bw, BROWSER_MOUSE_CLICK_1, x, y);
+ else if (pointer->buttons == wimp_CLICK_ADJUST)
+ browser_window_mouse_click(g->bw, BROWSER_MOUSE_CLICK_2, x, y);
}