Author: mikeL
Date: Fri Jun 6 11:08:17 2008
New Revision: 4273
URL:
http://source.netsurf-browser.org?rev=4273&view=rev
Log:
Merged core patch which adds extra mouse states
Modified:
branches/mikeL/netsurf/desktop/browser.c
branches/mikeL/netsurf/desktop/browser.h
branches/mikeL/netsurf/render/layout.c
branches/mikeL/netsurf/riscos/gui.c
branches/mikeL/netsurf/riscos/gui.h
branches/mikeL/netsurf/riscos/window.c
Modified: branches/mikeL/netsurf/desktop/browser.c
URL:
http://source.netsurf-browser.org/branches/mikeL/netsurf/desktop/browser....
==============================================================================
--- branches/mikeL/netsurf/desktop/browser.c (original)
+++ branches/mikeL/netsurf/desktop/browser.c Fri Jun 6 11:08:17 2008
@@ -1977,10 +1977,12 @@
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;
@@ -2028,27 +2030,30 @@
/* find icon in scrollbar and calculate scroll */
if (z < w) {
+ /* on scrollbar bump arrow button */
status = messages_get(vert ? "ScrollUp" : "ScrollLeft");
- if (mouse & but2)
+ if (but1)
+ scroll -= 16;
+ else if (but2)
scroll += 16;
- else if (mouse & but1)
- 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
@@ -2068,17 +2073,19 @@
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)
+ if (but1)
+ scroll += 16;
+ else if (but2)
scroll -= 16;
- else if (mouse & but1)
- scroll += 16;
}
/* update box and redraw */
Modified: branches/mikeL/netsurf/desktop/browser.h
URL:
http://source.netsurf-browser.org/branches/mikeL/netsurf/desktop/browser....
==============================================================================
--- branches/mikeL/netsurf/desktop/browser.h (original)
+++ branches/mikeL/netsurf/desktop/browser.h Fri Jun 6 11:08:17 2008
@@ -174,18 +174,38 @@
};
+/* 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;
Modified: branches/mikeL/netsurf/render/layout.c
URL:
http://source.netsurf-browser.org/branches/mikeL/netsurf/render/layout.c?...
==============================================================================
--- branches/mikeL/netsurf/render/layout.c (original)
+++ branches/mikeL/netsurf/render/layout.c Fri Jun 6 11:08:17 2008
@@ -291,6 +291,9 @@
(box->style->position == CSS_POSITION_ABSOLUTE||
box->style->position == CSS_POSITION_FIXED)) {
box->x = box->parent->padding[LEFT];
+ /* absolute positioned; this element will establish
+ * its own block context when it gets laid out later,
+ * so no need to look at its children now. */
goto advance_to_next_box;
}
@@ -335,6 +338,36 @@
cy = y;
}
}
+
+ /* Unless the box has an overflow style of visible, the box
+ * establishes a new block context. */
+ if (box->type != BOX_INLINE_CONTAINER && box->style &&
+ box->style->overflow != CSS_OVERFLOW_VISIBLE) {
+ layout_block_context(box, content);
+
+ if (box->type == BOX_BLOCK || box->object)
+ cy += box->padding[TOP];
+
+ if (box->type == BOX_BLOCK && box->height == AUTO) {
+ box->height = 0;
+ layout_block_add_scrollbar(box, BOTTOM);
+ }
+
+ cy += box->height + box->padding[BOTTOM] +
+ box->border[BOTTOM];
+ max_pos_margin = max_neg_margin = 0;
+ if (max_pos_margin < box->margin[BOTTOM])
+ max_pos_margin = box->margin[BOTTOM];
+ else if (max_neg_margin < -box->margin[BOTTOM])
+ max_neg_margin = -box->margin[BOTTOM];
+ cx -= box->x;
+ y = box->y + box->padding[TOP] + box->height +
+ box->padding[BOTTOM] +
+ box->border[BOTTOM];
+ /* Skip children, because they are done in the new
+ * block context */
+ goto advance_to_next_box;
+ }
LOG(("box %p, cx %i, cy %i", box, cx, cy));
Modified: branches/mikeL/netsurf/riscos/gui.c
URL:
http://source.netsurf-browser.org/branches/mikeL/netsurf/riscos/gui.c?rev...
==============================================================================
--- branches/mikeL/netsurf/riscos/gui.c (original)
+++ branches/mikeL/netsurf/riscos/gui.c Fri Jun 6 11:08:17 2008
@@ -877,7 +877,8 @@
{
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();
@@ -1000,7 +1001,8 @@
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();
@@ -1052,7 +1054,8 @@
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;
}
}
Modified: branches/mikeL/netsurf/riscos/gui.h
URL:
http://source.netsurf-browser.org/branches/mikeL/netsurf/riscos/gui.h?rev...
==============================================================================
--- branches/mikeL/netsurf/riscos/gui.h (original)
+++ branches/mikeL/netsurf/riscos/gui.h Fri Jun 6 11:08:17 2008
@@ -153,8 +153,10 @@
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);
Modified: branches/mikeL/netsurf/riscos/window.c
URL:
http://source.netsurf-browser.org/branches/mikeL/netsurf/riscos/window.c?...
==============================================================================
--- branches/mikeL/netsurf/riscos/window.c (original)
+++ branches/mikeL/netsurf/riscos/window.c Fri Jun 6 11:08:17 2008
@@ -83,6 +83,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. */
@@ -139,8 +142,8 @@
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;
@@ -3002,11 +3005,19 @@
{
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_DRAG_SELECT)) state |= BROWSER_MOUSE_DRAG_1;
- if (buttons & (wimp_DRAG_ADJUST)) state |= BROWSER_MOUSE_DRAG_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;
+ 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;
@@ -3024,8 +3035,13 @@
{
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;