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
This commit is contained in:
parent
c08ee82076
commit
04ece30fa9
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
if (type == DRAGGING_NONE)
|
||||
top_bw->drag_window = NULL;
|
||||
else
|
||||
top_bw->drag_window = bw;
|
||||
gui_drag_type gtype;
|
||||
|
||||
bw->drag_type = type;
|
||||
|
||||
/* TODO: inform front end that the core is handling drag,
|
||||
* pass rect */
|
||||
if (type == DRAGGING_NONE) {
|
||||
top_bw->drag_window = NULL;
|
||||
} else {
|
||||
top_bw->drag_window = bw;
|
||||
|
||||
switch (type) {
|
||||
case DRAGGING_SCR_X:
|
||||
case DRAGGING_SCR_Y:
|
||||
case DRAGGING_CONTENT_SCROLLBAR:
|
||||
gtype = GDRAGGING_SCROLLBAR;
|
||||
break;
|
||||
default:
|
||||
gtype = GDRAGGING_OTHER;
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ typedef enum {
|
|||
DRAGGING_FRAME,
|
||||
DRAGGING_SCR_X,
|
||||
DRAGGING_SCR_Y,
|
||||
DRAGGING_CONTENT_SCROLLBAR,
|
||||
DRAGGING_OTHER
|
||||
} browser_drag_type;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue