summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-01-11 14:20:26 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2012-01-11 14:20:26 +0000
commit04ece30fa930743d21af95d809acc2d25f82848a (patch)
treedc12f21957546d0fff08687055ccdd4a2e81509e
parentc08ee820764673bb6d8ac367f8637d040adf7fa2 (diff)
downloadnetsurf-04ece30fa930743d21af95d809acc2d25f82848a.tar.gz
netsurf-04ece30fa930743d21af95d809acc2d25f82848a.tar.bz2
Pass pointer constraints for drag out to front ends. Ensure content scrollbar drag termination always informs the browser window layer that the drag is over.
svn path=/trunk/netsurf/; revision=13395
-rwxr-xr-xamiga/gui.c6
-rwxr-xr-xatari/gui.c4
-rw-r--r--beos/beos_window.cpp4
-rw-r--r--cocoa/gui.m4
-rw-r--r--desktop/browser.c26
-rw-r--r--desktop/browser.h1
-rw-r--r--desktop/gui.h12
-rw-r--r--framebuffer/gui.c4
-rw-r--r--gtk/window.c4
-rw-r--r--monkey/browser.c7
-rw-r--r--render/form.c10
-rw-r--r--render/html_interaction.c13
-rw-r--r--riscos/gui.c2
-rw-r--r--riscos/gui.h4
-rw-r--r--riscos/window.c67
-rw-r--r--windows/gui.c4
16 files changed, 103 insertions, 69 deletions
diff --git a/amiga/gui.c b/amiga/gui.c
index 7ff4c4768..46529e83c 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -3843,10 +3843,10 @@ bool gui_window_scroll_start(struct gui_window *g)
return true;
}
-bool gui_window_box_scroll_start(struct gui_window *g,
- int x0, int y0, int x1, int y1)
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
- DebugPrintF("box scroll start\n");
+ DebugPrintF("drag start\n");
return true;
}
diff --git a/atari/gui.c b/atari/gui.c
index 8af3e9af5..f6f0d9d3d 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -593,8 +593,8 @@ bool gui_window_scroll_start(struct gui_window *w)
return true;
}
-bool gui_window_box_scroll_start(struct gui_window *w,
- int x0, int y0, int x1, int y1)
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
TODO();
return true;
diff --git a/beos/beos_window.cpp b/beos/beos_window.cpp
index 9d46254b1..3a87be8f4 100644
--- a/beos/beos_window.cpp
+++ b/beos/beos_window.cpp
@@ -1603,8 +1603,8 @@ bool gui_window_scroll_start(struct gui_window *g)
return true;
}
-bool gui_window_box_scroll_start(struct gui_window *g,
- int x0, int y0, int x1, int y1)
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
return true;
}
diff --git a/cocoa/gui.m b/cocoa/gui.m
index dc2155164..5bb29724a 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -273,8 +273,8 @@ bool gui_window_scroll_start(struct gui_window *g)
return true;
}
-bool gui_window_box_scroll_start(struct gui_window *g,
- int x0, int y0, int x1, int y1)
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
return true;
}
diff --git a/desktop/browser.c b/desktop/browser.c
index fbb91b02c..4d54e8bc4 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -383,16 +383,28 @@ void browser_window_set_drag_type(struct browser_window *bw,
browser_drag_type type, struct rect *rect)
{
struct browser_window *top_bw = browser_window_get_root(bw);
+ gui_drag_type gtype;
- if (type == DRAGGING_NONE)
+ bw->drag_type = type;
+
+ if (type == DRAGGING_NONE) {
top_bw->drag_window = NULL;
- else
+ } else {
top_bw->drag_window = bw;
- bw->drag_type = type;
+ switch (type) {
+ case DRAGGING_SCR_X:
+ case DRAGGING_SCR_Y:
+ case DRAGGING_CONTENT_SCROLLBAR:
+ gtype = GDRAGGING_SCROLLBAR;
+ break;
+ default:
+ gtype = GDRAGGING_OTHER;
+ break;
+ }
- /* TODO: inform front end that the core is handling drag,
- * pass rect */
+ gui_window_drag_start(top_bw->window, gtype, rect);
+ }
}
/* exported interface, documented in browser.h */
@@ -2554,10 +2566,8 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
switch (bw->drag_type) {
case DRAGGING_SELECTION:
- /* Drag handled by content handler */
- break;
-
case DRAGGING_OTHER:
+ case DRAGGING_CONTENT_SCROLLBAR:
/* Drag handled by content handler */
break;
diff --git a/desktop/browser.h b/desktop/browser.h
index e7975d2f7..977396014 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -63,6 +63,7 @@ typedef enum {
DRAGGING_FRAME,
DRAGGING_SCR_X,
DRAGGING_SCR_Y,
+ DRAGGING_CONTENT_SCROLLBAR,
DRAGGING_OTHER
} browser_drag_type;
diff --git a/desktop/gui.h b/desktop/gui.h
index dc2841fb8..dcb9160a5 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -41,6 +41,12 @@ typedef enum {
GUI_SAVE_CLIPBOARD_CONTENTS
} gui_save_type;
+typedef enum {
+ GDRAGGING_NONE,
+ GDRAGGING_SCROLLBAR,
+ GDRAGGING_OTHER
+} gui_drag_type;
+
struct gui_window;
struct gui_download_window;
struct browser_window;
@@ -100,8 +106,10 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height);
void gui_window_remove_caret(struct gui_window *g);
void gui_window_new_content(struct gui_window *g);
bool gui_window_scroll_start(struct gui_window *g);
-bool gui_window_box_scroll_start(struct gui_window *g,
- int x0, int y0, int x1, int y1);
+
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect);
+
void gui_window_save_link(struct gui_window *g, const char *url,
const char *title);
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 7fe9f81a2..65a58a25e 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -1493,8 +1493,8 @@ gui_window_scroll_start(struct gui_window *g)
}
bool
-gui_window_box_scroll_start(struct gui_window *g,
- int x0, int y0, int x1, int y1)
+gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
return true;
}
diff --git a/gtk/window.c b/gtk/window.c
index c2f2c6aa1..b57c849a5 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -988,8 +988,8 @@ bool gui_window_scroll_start(struct gui_window *g)
return true;
}
-bool gui_window_box_scroll_start(struct gui_window *g,
- int x0, int y0, int x1, int y1)
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
return true;
}
diff --git a/monkey/browser.c b/monkey/browser.c
index 527c67424..36dd5d5bc 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -370,11 +370,10 @@ gui_window_remove_caret(struct gui_window *g)
}
bool
-gui_window_box_scroll_start(struct gui_window *g,
- int x0, int y0, int x1, int y1)
+gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
- fprintf(stdout, "WINDOW SCROLL_START WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
- g->win_num, x0, y0, x1, y1);
+ fprintf(stdout, "WINDOW SCROLL_START WIN %u TYPE %i\n);
return false;
}
diff --git a/render/form.c b/render/form.c
index 9724c4c4c..924dbb4f7 100644
--- a/render/form.c
+++ b/render/form.c
@@ -1295,19 +1295,19 @@ void form_select_menu_scroll_callback(void *client_data,
.y1 = scrollbar_data->y1
};
- browser_window_set_drag_type(html->bw, DRAGGING_OTHER,
- &rect);
+ browser_window_set_drag_type(html->bw,
+ DRAGGING_CONTENT_SCROLLBAR, &rect);
menu->scroll_capture = true;
root_bw = browser_window_get_root(html->bw);
- 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;
+
+ browser_window_set_drag_type(html->bw,
+ DRAGGING_NONE, NULL);
break;
default:
break;
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 2bec3d26a..56d9e83b7 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -223,8 +223,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
return;
}
- if (bw->drag_type != DRAGGING_NONE && !mouse &&
- html->scrollbar != NULL) {
+ if (!mouse && html->scrollbar != NULL) {
/* drag end: scrollbar */
html_overflow_scroll_drag_end(html->scrollbar, mouse, x, y);
}
@@ -856,19 +855,19 @@ void html_overflow_scroll_callback(void *client_data,
.x1 = scrollbar_data->x1,
.y1 = scrollbar_data->y1
};
- browser_window_set_drag_type(html->bw, DRAGGING_OTHER,
- &rect);
+ browser_window_set_drag_type(html->bw,
+ DRAGGING_CONTENT_SCROLLBAR, &rect);
html->scrollbar = scrollbar_data->scrollbar;
root_bw = browser_window_get_root(html->bw);
- 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;
+
+ browser_window_set_drag_type(html->bw,
+ DRAGGING_NONE, NULL);
browser_window_set_pointer(html->bw,
GUI_POINTER_DEFAULT);
diff --git a/riscos/gui.c b/riscos/gui.c
index ab107e9b7..5b8a3ec2b 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -176,7 +176,7 @@ static wimp_w gui_track_wimp_w;
/** Browser window which the pointer is over, or 0 if none. */
struct gui_window *gui_track_gui_window;
-gui_drag_type gui_current_drag_type;
+ro_gui_drag_type gui_current_drag_type;
wimp_t task_handle; /**< RISC OS wimp task handle. */
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
osspriteop_area *gui_sprites; /**< Sprite area containing pointer and hotlist sprites */
diff --git a/riscos/gui.h b/riscos/gui.h
index 434e569d5..14835274b 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -68,9 +68,9 @@ extern bool print_active, print_text_black;
typedef enum { GUI_DRAG_NONE, GUI_DRAG_SELECTION, GUI_DRAG_DOWNLOAD_SAVE,
GUI_DRAG_SAVE, GUI_DRAG_SCROLL, GUI_DRAG_STATUS_RESIZE,
GUI_DRAG_TREEVIEW, GUI_DRAG_BUTTONBAR,
- GUI_DRAG_FRAME } gui_drag_type;
+ GUI_DRAG_FRAME } ro_gui_drag_type;
-extern gui_drag_type gui_current_drag_type;
+extern ro_gui_drag_type gui_current_drag_type;
/** desktop font, size and style being used */
extern char ro_gui_desktop_font_family[];
diff --git a/riscos/window.c b/riscos/window.c
index d3aeb612f..a5b4b553c 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1244,45 +1244,62 @@ bool gui_window_scroll_start(struct gui_window *g)
/**
- * Platform-dependent part of starting a box scrolling operation,
- * for frames and textareas.
+ * Platform-dependent part of starting drag operation.
*
- * \param x0 minimum x ordinate of box relative to mouse pointer
- * \param y0 minimum y ordinate
- * \param x1 maximum x ordinate
- * \param y1 maximum y ordinate
+ * \param g gui window containing the drag
+ * \param type type of drag the core is performing
+ * \param rect rectangle to constrain pointer to (relative to drag start coord)
* \return true iff succesful
*/
-bool gui_window_box_scroll_start(struct gui_window *g, int x0, int y0, int x1, int y1)
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
wimp_pointer pointer;
os_error *error;
wimp_drag drag;
- 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);
- return false;
+ if (rect != NULL) {
+ /* We have a box to constrain the pointer to, for the drag
+ * duration */
+ 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);
+ return false;
+ }
+
+ drag.type = wimp_DRAG_USER_POINT;
+ drag.bbox.x0 = pointer.pos.x +
+ (int)(rect->x0 * 2 * g->bw->scale);
+ drag.bbox.y0 = pointer.pos.y +
+ (int)(rect->y0 * 2 * g->bw->scale);
+ drag.bbox.x1 = pointer.pos.x +
+ (int)(rect->x1 * 2 * g->bw->scale);
+ drag.bbox.y1 = pointer.pos.y +
+ (int)(rect->y1 * 2 * g->bw->scale);
+
+ error = xwimp_drag_box(&drag);
+ if (error) {
+ LOG(("xwimp_drag_box: 0x%x : %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return false;
+ }
}
- drag.type = wimp_DRAG_USER_POINT;
- drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->bw->scale);
- drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->bw->scale);
- drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->bw->scale);
- drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->bw->scale);
+ switch (type) {
+ case GDRAGGING_SCROLLBAR:
+ /* Dragging a core scrollbar */
+ gui_current_drag_type = GUI_DRAG_SCROLL;
+ break;
- error = xwimp_drag_box(&drag);
- if (error) {
- LOG(("xwimp_drag_box: 0x%x : %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- return false;
+ default:
+ /* Not handled here yet */
+ break;
}
- gui_current_drag_type = GUI_DRAG_SCROLL;
return true;
}
diff --git a/windows/gui.c b/windows/gui.c
index 469230188..d75fe065e 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -1718,8 +1718,8 @@ bool gui_window_scroll_start(struct gui_window *w)
return true;
}
-bool gui_window_box_scroll_start(struct gui_window *w,
- int x0, int y0, int x1, int y1)
+bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+ struct rect *rect)
{
return true;
}