summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/browser.c9
-rw-r--r--desktop/browser.h3
-rw-r--r--desktop/frames.c57
-rw-r--r--render/form.c12
-rw-r--r--render/html_interaction.c15
-rw-r--r--render/textplain.c4
6 files changed, 66 insertions, 34 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index a864a3601..fbb91b02c 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -380,7 +380,7 @@ void browser_window_set_position(struct browser_window *bw, int x, int y)
/* exported interface, documented in browser.h */
void browser_window_set_drag_type(struct browser_window *bw,
- browser_drag_type type)
+ browser_drag_type type, struct rect *rect)
{
struct browser_window *top_bw = browser_window_get_root(bw);
@@ -390,6 +390,9 @@ void browser_window_set_drag_type(struct browser_window *bw,
top_bw->drag_window = bw;
bw->drag_type = type;
+
+ /* TODO: inform front end that the core is handling drag,
+ * pass rect */
}
/* exported interface, documented in browser.h */
@@ -2583,7 +2586,7 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
break;
default:
- browser_window_set_drag_type(bw, DRAGGING_NONE);
+ browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
break;
}
}
@@ -2616,7 +2619,7 @@ void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
{
- browser_window_set_drag_type(bw, DRAGGING_PAGE_SCROLL);
+ browser_window_set_drag_type(bw, DRAGGING_PAGE_SCROLL, NULL);
bw->drag_start_x = x;
bw->drag_start_y = y;
diff --git a/desktop/browser.h b/desktop/browser.h
index 5136cb205..e7975d2f7 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -413,9 +413,10 @@ void browser_window_set_scroll(struct browser_window *bw, int x, int y);
*
* \param bw browser window to set the type of the current drag for
* \param type drag type
+ * \param rect area pointer may be confined to, during drag, or NULL
*/
void browser_window_set_drag_type(struct browser_window *bw,
- browser_drag_type type);
+ browser_drag_type type, struct rect *rect);
/*
* Get the root level browser window
diff --git a/desktop/frames.c b/desktop/frames.c
index e5fcfd504..e89e54df0 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -75,14 +75,22 @@ void browser_window_scroll_callback(void *client_data,
}
break;
case SCROLLBAR_MSG_SCROLL_START:
+ {
+ struct rect rect = {
+ .x0 = scrollbar_data->x0,
+ .y0 = scrollbar_data->y0,
+ .x1 = scrollbar_data->x1,
+ .y1 = scrollbar_data->y1
+ };
+
if (scrollbar_is_horizontal(scrollbar_data->scrollbar))
- browser_window_set_drag_type(bw, DRAGGING_SCR_X);
+ browser_window_set_drag_type(bw, DRAGGING_SCR_X, &rect);
else
- browser_window_set_drag_type(bw, DRAGGING_SCR_Y);
-
+ browser_window_set_drag_type(bw, DRAGGING_SCR_Y, &rect);
+ }
break;
case SCROLLBAR_MSG_SCROLL_FINISHED:
- browser_window_set_drag_type(bw, DRAGGING_NONE);
+ browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
browser_window_set_pointer(bw, GUI_POINTER_DEFAULT);
break;
@@ -653,7 +661,8 @@ void browser_window_resize_frame(struct browser_window *bw, int x, int y) {
else if (bw->drag_resize_right)
sibling = &parent->children[row * parent->cols + (col + 1)];
if (sibling)
- change |= browser_window_resolve_frame_dimension(bw, sibling, x, y, true, false);
+ change |= browser_window_resolve_frame_dimension(bw, sibling,
+ x, y, true, false);
sibling = NULL;
if (bw->drag_resize_up)
@@ -661,14 +670,16 @@ void browser_window_resize_frame(struct browser_window *bw, int x, int y) {
else if (bw->drag_resize_down)
sibling = &parent->children[(row + 1) * parent->cols + col];
if (sibling)
- change |= browser_window_resolve_frame_dimension(bw, sibling, x, y, false, true);
+ change |= browser_window_resolve_frame_dimension(bw, sibling,
+ x, y, false, true);
if (change)
browser_window_recalculate_frameset(parent);
}
-bool browser_window_resolve_frame_dimension(struct browser_window *bw, struct browser_window *sibling,
+bool browser_window_resolve_frame_dimension(struct browser_window *bw,
+ struct browser_window *sibling,
int x, int y, bool width, bool height) {
int bw_dimension, sibling_dimension;
int bw_pixels, sibling_pixels;
@@ -784,8 +795,10 @@ bool browser_window_resolve_frame_dimension(struct browser_window *bw, struct br
}
-bool browser_window_resize_frames(struct browser_window *bw, browser_mouse_state mouse, int x, int y,
- gui_pointer_shape *pointer, const char **status, bool *action) {
+bool browser_window_resize_frames(struct browser_window *bw,
+ browser_mouse_state mouse, int x, int y,
+ gui_pointer_shape *pointer, const char **status,
+ bool *action) {
struct browser_window *parent;
bool left, right, up, down;
int i, resize_margin;
@@ -871,8 +884,13 @@ bool browser_window_resize_frames(struct browser_window *bw, browser_mouse_state
} else {
*pointer = GUI_POINTER_DOWN;
}
- if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2)) {
- browser_window_set_drag_type(bw, DRAGGING_FRAME);
+ if (mouse & (BROWSER_MOUSE_DRAG_1 |
+ BROWSER_MOUSE_DRAG_2)) {
+
+ /* TODO: Pass appropriate rectangle to allow
+ * front end to clamp pointer range */
+ browser_window_set_drag_type(bw,
+ DRAGGING_FRAME, NULL);
bw->drag_start_x = x;
bw->drag_start_y = y;
bw->drag_resize_left = left;
@@ -880,15 +898,6 @@ bool browser_window_resize_frames(struct browser_window *bw, browser_mouse_state
bw->drag_resize_up = up;
bw->drag_resize_down = down;
- /* TODO: Tell the front end the valid pointer
- * movement range for the drag, so that
- * they can clamp pointer.
- *
- * Probably need a general function for
- * this, to be used by all core-managed
- * drag ops.
- */
-
*status = messages_get("FrameDrag");
*action = true;
}
@@ -898,14 +907,14 @@ bool browser_window_resize_frames(struct browser_window *bw, browser_mouse_state
if (bw->children) {
for (i = 0; i < (bw->cols * bw->rows); i++)
- if (browser_window_resize_frames(&bw->children[i], mouse, x, y, pointer, status,
- action))
+ if (browser_window_resize_frames(&bw->children[i],
+ mouse, x, y, pointer, status, action))
return true;
}
if (bw->iframes) {
for (i = 0; i < bw->iframe_count; i++)
- if (browser_window_resize_frames(&bw->iframes[i], mouse, x, y, pointer, status,
- action))
+ if (browser_window_resize_frames(&bw->iframes[i],
+ mouse, x, y, pointer, status, action))
return true;
}
return false;
diff --git a/render/form.c b/render/form.c
index d11630192..9724c4c4c 100644
--- a/render/form.c
+++ b/render/form.c
@@ -1287,7 +1287,16 @@ void form_select_menu_scroll_callback(void *client_data,
menu->height);
break;
case SCROLLBAR_MSG_SCROLL_START:
- browser_window_set_drag_type(html->bw, DRAGGING_OTHER);
+ {
+ struct rect rect = {
+ .x0 = scrollbar_data->x0,
+ .y0 = scrollbar_data->y0,
+ .x1 = scrollbar_data->x1,
+ .y1 = scrollbar_data->y1
+ };
+
+ browser_window_set_drag_type(html->bw, DRAGGING_OTHER,
+ &rect);
menu->scroll_capture = true;
@@ -1295,6 +1304,7 @@ void form_select_menu_scroll_callback(void *client_data,
gui_window_box_scroll_start(root_bw->window,
scrollbar_data->x0, scrollbar_data->y0,
scrollbar_data->x1, scrollbar_data->y1);
+ }
break;
case SCROLLBAR_MSG_SCROLL_FINISHED:
menu->scroll_capture = false;
diff --git a/render/html_interaction.c b/render/html_interaction.c
index b6508570f..2bec3d26a 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -108,7 +108,7 @@ void html_mouse_track(struct content *c, struct browser_window *bw,
if (idx != 0)
selection_track(&html->sel, mouse, idx);
- browser_window_set_drag_type(bw, DRAGGING_NONE);
+ browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
}
switch (bw->drag_type) {
@@ -255,7 +255,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
}
/* Content related drags handled by now */
- browser_window_set_drag_type(bw, DRAGGING_NONE);
+ browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
/* search the box tree for a link, imagemap, form control, or
* box with scrollbars */
@@ -849,7 +849,15 @@ void html_overflow_scroll_callback(void *client_data,
html_redraw_a_box(html->bw->current_content, box);
break;
case SCROLLBAR_MSG_SCROLL_START:
- browser_window_set_drag_type(html->bw, DRAGGING_OTHER);
+ {
+ struct rect rect = {
+ .x0 = scrollbar_data->x0,
+ .y0 = scrollbar_data->y0,
+ .x1 = scrollbar_data->x1,
+ .y1 = scrollbar_data->y1
+ };
+ browser_window_set_drag_type(html->bw, DRAGGING_OTHER,
+ &rect);
html->scrollbar = scrollbar_data->scrollbar;
@@ -857,6 +865,7 @@ void html_overflow_scroll_callback(void *client_data,
gui_window_box_scroll_start(root_bw->window,
scrollbar_data->x0, scrollbar_data->y0,
scrollbar_data->x1, scrollbar_data->y1);
+ }
break;
case SCROLLBAR_MSG_SCROLL_FINISHED:
html->scrollbar = NULL;
diff --git a/render/textplain.c b/render/textplain.c
index 3294d536a..eabc19b20 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -638,7 +638,7 @@ void textplain_mouse_track(struct content *c, struct browser_window *bw,
idx = textplain_offset_from_coords(c, x, y, dir);
selection_track(&text->sel, mouse, idx);
- browser_window_set_drag_type(bw, DRAGGING_NONE);
+ browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
}
switch (bw->drag_type) {
@@ -680,7 +680,7 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw,
size_t idx;
int dir = 0;
- browser_window_set_drag_type(bw, DRAGGING_NONE);
+ browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
idx = textplain_offset_from_coords(c, x, y, dir);
if (selection_click(&text->sel, mouse, idx)) {