summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2008-06-06 13:58:56 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2008-06-06 13:58:56 +0000
commit2319b6032e7f9b58bb5d6510e286052971e42eca (patch)
treed99fb03fd986d16c2e437c289a45deafb18d1c6c
parentf1b1a9737fecf026fa335a84e7345227cb822df3 (diff)
downloadnetsurf-2319b6032e7f9b58bb5d6510e286052971e42eca.tar.gz
netsurf-2319b6032e7f9b58bb5d6510e286052971e42eca.tar.bz2
+ Change core to handle different front end click behaviour
styles. (Act on mouse button press or on button release.) + Click hold on CSS scrollbar arrows now pauses before starting to auto-repeat. + Click hold on scrollbar wells will now auto-repeat. svn path=/trunk/netsurf/; revision=4268
-rw-r--r--desktop/browser.c39
-rw-r--r--desktop/browser.h42
-rw-r--r--riscos/gui.c9
-rw-r--r--riscos/gui.h6
-rw-r--r--riscos/window.c28
5 files changed, 86 insertions, 38 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 55e3f793e..dfa05b367 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1976,10 +1976,12 @@ const char *browser_window_scrollbar_click(struct browser_window *bw,
browser_mouse_state mouse, struct box *box,
int box_x, int box_y, int x, int y)
{
- const browser_mouse_state but1 = (BROWSER_MOUSE_CLICK_1 |
- BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_HOLDING_1);
- const browser_mouse_state but2 = (BROWSER_MOUSE_CLICK_2 |
- BROWSER_MOUSE_DRAG_2 | BROWSER_MOUSE_HOLDING_2);
+ bool but1 = (mouse & (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_DRAG_1)) ||
+ ((mouse & BROWSER_MOUSE_HOLDING_1) &&
+ (mouse & BROWSER_MOUSE_DRAG_ON));
+ bool but2 = (mouse & (BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_DRAG_2)) ||
+ ((mouse & BROWSER_MOUSE_HOLDING_2) &&
+ (mouse & BROWSER_MOUSE_DRAG_ON));;
const int w = SCROLLBAR_WIDTH;
bool vscroll, hscroll;
int well_height, bar_top, bar_height;
@@ -2027,27 +2029,30 @@ const char *browser_window_scrollbar_click(struct browser_window *bw,
/* find icon in scrollbar and calculate scroll */
if (z < w) {
+ /* on scrollbar bump arrow button */
status = messages_get(vert ? "ScrollUp" : "ScrollLeft");
- if (mouse & but2)
- scroll += 16;
- else if (mouse & but1)
+ if (but1)
scroll -= 16;
+ else if (but2)
+ scroll += 16;
} else if (z < w + bar_start + w / 4) {
+ /* in scrollbar well */
status = messages_get(vert ? "ScrollPUp" : "ScrollPLeft");
- if (mouse & BROWSER_MOUSE_CLICK_1)
+ if (but1)
scroll -= page;
- else if (mouse & BROWSER_MOUSE_CLICK_2)
+ else if (but2)
scroll += page;
} else if (z < w + bar_start + bar_size - w / 4) {
+ /* in scrollbar */
status = messages_get(vert ? "ScrollV" : "ScrollH");
/* respond on the click rather than the drag because it gives
the scrollbars a more solid, RISC OS feel */
- if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) {
+ if (mouse & (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_PRESS_2)) {
int x0 = 0, x1 = 0;
int y0 = 0, y1 = 0;
- if (mouse & BROWSER_MOUSE_CLICK_1) {
+ if (mouse & BROWSER_MOUSE_PRESS_1) {
bw->drag_type = vert ? DRAGGING_VSCROLL :
DRAGGING_HSCROLL;
} else
@@ -2067,17 +2072,19 @@ const char *browser_window_scrollbar_click(struct browser_window *bw,
gui_window_hide_pointer(bw->window);
}
} else if (z < w + well_size) {
+ /* in scrollbar well */
status = messages_get(vert ? "ScrollPDown" : "ScrollPRight");
- if (mouse & BROWSER_MOUSE_CLICK_1)
+ if (but1)
scroll += page;
- else if (mouse & BROWSER_MOUSE_CLICK_2)
+ else if (but2)
scroll -= page;
} else {
+ /* on scrollbar bump arrow button */
status = messages_get(vert ? "ScrollDown" : "ScrollRight");
- if (mouse & but2)
- scroll -= 16;
- else if (mouse & but1)
+ if (but1)
scroll += 16;
+ else if (but2)
+ scroll -= 16;
}
/* update box and redraw */
diff --git a/desktop/browser.h b/desktop/browser.h
index bdada0c73..45a930c6a 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -174,18 +174,38 @@ struct browser_window {
};
+/* Mouse state. 1 is primary mouse button (e.g. Select on RISC OS).
+ * 2 is secondary mouse button (e.g. Adjust on RISC OS). */
typedef enum {
- BROWSER_MOUSE_CLICK_1 = 1, /* primary mouse button down (eg. Select) */
- BROWSER_MOUSE_CLICK_2 = 2,
-
- BROWSER_MOUSE_DRAG_1 = 8, /* start of drag operation */
- BROWSER_MOUSE_DRAG_2 = 16,
-
- BROWSER_MOUSE_HOLDING_1 = 64, /* whilst drag is in progress */
- BROWSER_MOUSE_HOLDING_2 = 128,
-
- BROWSER_MOUSE_MOD_1 = 512, /* primary modifier key pressed (eg. Shift) */
- BROWSER_MOUSE_MOD_2 = 1024
+ BROWSER_MOUSE_PRESS_1 = 1, /* button 1 pressed */
+ BROWSER_MOUSE_PRESS_2 = 2, /* button 2 pressed */
+
+ /* note: click meaning is different for
+ * different front ends. On RISC OS, it
+ * is standard to act on press, so a
+ * click is fired at the same time as a
+ * mouse button is pressed. With GTK, it
+ * is standard to act on release, so a
+ * click is fired when the mouse button
+ * is released, if the operation wasn't
+ * a drag. */
+ BROWSER_MOUSE_CLICK_1 = 4, /* button 1 clicked. */
+ BROWSER_MOUSE_CLICK_2 = 8, /* button 2 clicked. */
+
+ BROWSER_MOUSE_DRAG_1 = 16, /* start of button 1 drag operation */
+ BROWSER_MOUSE_DRAG_2 = 32, /* start of button 2 drag operation */
+
+ BROWSER_MOUSE_DRAG_ON = 64, /* a drag operation was started and
+ * a mouse button is still pressed */
+
+ BROWSER_MOUSE_HOLDING_1 = 128, /* while button 1 drag is in progress */
+ BROWSER_MOUSE_HOLDING_2 = 256, /* while button 2 drag is in progress */
+
+
+ BROWSER_MOUSE_MOD_1 = 512, /* primary modifier key pressed
+ * (eg. Shift) */
+ BROWSER_MOUSE_MOD_2 = 1024 /* secondary modifier key pressed
+ * (eg. Ctrl) */
} browser_mouse_state;
diff --git a/riscos/gui.c b/riscos/gui.c
index 018cd0d93..7f78286d3 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -896,7 +896,8 @@ void gui_poll(bool active)
{
wimp_event_no event;
wimp_block block;
- const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP;
+ const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN |
+ wimp_SAVE_FP;
/* Poll wimp. */
xhourglass_off();
@@ -1019,7 +1020,8 @@ void gui_multitask(void)
return;
xhourglass_off();
- event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP, &block, 0);
+ event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP,
+ &block, 0);
xhourglass_on();
gui_last_poll = clock();
@@ -1071,7 +1073,8 @@ void ro_gui_null_reason_code(void)
if (gui_track_wimp_w == dialog_url_complete)
ro_gui_url_complete_mouse_at(&pointer);
else if (gui_track_gui_window)
- ro_gui_window_mouse_at(gui_track_gui_window, &pointer);
+ ro_gui_window_mouse_at(gui_track_gui_window,
+ &pointer);
break;
}
}
diff --git a/riscos/gui.h b/riscos/gui.h
index 1c6bd41cc..21df85bbf 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -153,8 +153,10 @@ void ro_gui_throb(void);
struct gui_window *ro_gui_window_lookup(wimp_w window);
struct gui_window *ro_gui_toolbar_lookup(wimp_w window);
void ro_gui_scroll_request(wimp_scroll *scroll);
-bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *pos);
-bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *pos);
+bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y,
+ os_coord *pos);
+bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y,
+ os_coord *pos);
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message);
void ro_gui_window_process_reformats(void);
diff --git a/riscos/window.c b/riscos/window.c
index 0ae8aa077..86d51edd3 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -84,6 +84,9 @@
static bool iconise_used[64];
static int iconise_next = 0;
+/** Whether a pressed mouse button has become a drag */
+static bool mouse_drag;
+
/** List of all browser windows. */
static struct gui_window *window_list = 0;
/** GUI window which is being redrawn. Valid only during redraw. */
@@ -140,8 +143,8 @@ static void ro_gui_window_launch_url(struct gui_window *g, const char *url);
static void ro_gui_window_clone_options(struct browser_window *new_bw,
struct browser_window *old_bw);
static browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons);
-static bool ro_gui_window_import_text(struct gui_window *g, const char *filename,
- bool toolbar);
+static bool ro_gui_window_import_text(struct gui_window *g,
+ const char *filename, bool toolbar);
struct update_box {
int x0;
@@ -3003,11 +3006,19 @@ browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons)
{
browser_mouse_state state = 0;
- if (buttons & (wimp_CLICK_SELECT)) state |= BROWSER_MOUSE_CLICK_1;
- if (buttons & (wimp_CLICK_ADJUST)) state |= BROWSER_MOUSE_CLICK_2;
+ if (buttons & (wimp_CLICK_SELECT))
+ state |= BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_CLICK_1;
+ if (buttons & (wimp_CLICK_ADJUST))
+ state |= BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_CLICK_2;
- if (buttons & (wimp_DRAG_SELECT)) state |= BROWSER_MOUSE_DRAG_1;
- if (buttons & (wimp_DRAG_ADJUST)) state |= BROWSER_MOUSE_DRAG_2;
+ if (buttons & (wimp_DRAG_SELECT)) {
+ state |= BROWSER_MOUSE_DRAG_1;
+ mouse_drag = true;
+ }
+ if (buttons & (wimp_DRAG_ADJUST)) {
+ state |= BROWSER_MOUSE_DRAG_2;
+ mouse_drag = true;
+ }
if (ro_gui_shift_pressed()) state |= BROWSER_MOUSE_MOD_1;
if (ro_gui_ctrl_pressed()) state |= BROWSER_MOUSE_MOD_2;
@@ -3025,9 +3036,14 @@ browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons)
{
browser_mouse_state state = 0;
+
if (buttons & (wimp_CLICK_SELECT)) state |= BROWSER_MOUSE_HOLDING_1;
if (buttons & (wimp_CLICK_ADJUST)) state |= BROWSER_MOUSE_HOLDING_2;
+ if (!(buttons & (wimp_CLICK_SELECT) || buttons & (wimp_CLICK_ADJUST)))
+ mouse_drag = false;
+ if (mouse_drag) state |= BROWSER_MOUSE_DRAG_ON;
+
if (ro_gui_shift_pressed()) state |= BROWSER_MOUSE_MOD_1;
if (ro_gui_ctrl_pressed()) state |= BROWSER_MOUSE_MOD_2;