diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2008-06-06 13:58:56 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2008-06-06 13:58:56 +0000 |
commit | 2319b6032e7f9b58bb5d6510e286052971e42eca (patch) | |
tree | d99fb03fd986d16c2e437c289a45deafb18d1c6c /desktop | |
parent | f1b1a9737fecf026fa335a84e7345227cb822df3 (diff) | |
download | netsurf-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
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/browser.c | 39 | ||||
-rw-r--r-- | desktop/browser.h | 42 |
2 files changed, 54 insertions, 27 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; |