Don't use GUI_POINTERs in content handlers.

This commit is contained in:
Michael Drake 2012-08-16 22:21:08 +01:00
parent cb9781e057
commit 35fd2ad7f2
6 changed files with 87 additions and 57 deletions

View File

@ -1920,14 +1920,22 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
*/
void browser_window_set_pointer(struct browser_window *bw,
gui_pointer_shape shape)
browser_pointer_shape shape)
{
struct browser_window *root = browser_window_get_root(bw);
gui_pointer_shape gui_shape;
assert(root);
assert(root->window);
gui_window_set_pointer(root->window, shape);
if (shape == BROWSER_POINTER_AUTO) {
gui_shape = GUI_POINTER_DEFAULT;
} else {
gui_shape = (gui_pointer_shape)shape;
}
gui_window_set_pointer(root->window, gui_shape);
}
@ -2400,7 +2408,7 @@ void browser_window_mouse_track(struct browser_window *bw,
{
hlcache_handle *c = bw->current_content;
const char *status = NULL;
gui_pointer_shape pointer = GUI_POINTER_DEFAULT;
browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
if (bw->window != NULL && bw->drag_window && bw != bw->drag_window) {
/* This is the root browser window and there's an active drag
@ -2481,7 +2489,7 @@ void browser_window_mouse_track(struct browser_window *bw,
/* Start a scrollbar drag, or continue existing drag */
status = scrollbar_mouse_action(bw->scroll_x, mouse,
scr_x, scr_y);
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
if (status != NULL)
browser_window_set_status(bw, status);
@ -2506,7 +2514,7 @@ void browser_window_mouse_track(struct browser_window *bw,
/* Start a scrollbar drag, or continue existing drag */
status = scrollbar_mouse_action(bw->scroll_y, mouse,
scr_x, scr_y);
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
if (status != NULL)
browser_window_set_status(bw, status);
@ -2552,7 +2560,7 @@ void browser_window_mouse_click(struct browser_window *bw,
{
hlcache_handle *c = bw->current_content;
const char *status = NULL;
gui_pointer_shape pointer = GUI_POINTER_DEFAULT;
browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
if (bw->children) {
/* Browser window has children (frames) */
@ -2600,7 +2608,7 @@ void browser_window_mouse_click(struct browser_window *bw,
scr_y > 0 && scr_y < SCROLLBAR_WIDTH) {
status = scrollbar_mouse_action(bw->scroll_x, mouse,
scr_x, scr_y);
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
if (status != NULL)
browser_window_set_status(bw, status);
@ -2621,7 +2629,7 @@ void browser_window_mouse_click(struct browser_window *bw,
scr_x > 0 && scr_x < SCROLLBAR_WIDTH) {
status = scrollbar_mouse_action(bw->scroll_y, mouse,
scr_x, scr_y);
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
if (status != NULL)
browser_window_set_status(bw, status);
@ -2648,7 +2656,7 @@ void browser_window_mouse_click(struct browser_window *bw,
else if (mouse & (BROWSER_MOUSE_DRAG_1 |
BROWSER_MOUSE_DRAG_2)) {
browser_window_page_drag_start(bw, x, y);
browser_window_set_pointer(bw, GUI_POINTER_MOVE);
browser_window_set_pointer(bw, BROWSER_POINTER_MOVE);
}
break;
}

View File

@ -68,6 +68,29 @@ typedef enum {
DRAGGING_OTHER
} browser_drag_type;
typedef enum {
BROWSER_POINTER_DEFAULT = GUI_POINTER_DEFAULT,
BROWSER_POINTER_POINT = GUI_POINTER_POINT,
BROWSER_POINTER_CARET = GUI_POINTER_CARET,
BROWSER_POINTER_MENU = GUI_POINTER_MENU,
BROWSER_POINTER_UP = GUI_POINTER_UP,
BROWSER_POINTER_DOWN = GUI_POINTER_DOWN,
BROWSER_POINTER_LEFT = GUI_POINTER_LEFT,
BROWSER_POINTER_RIGHT = GUI_POINTER_RIGHT,
BROWSER_POINTER_RU = GUI_POINTER_RU,
BROWSER_POINTER_LD = GUI_POINTER_LD,
BROWSER_POINTER_LU = GUI_POINTER_LU,
BROWSER_POINTER_RD = GUI_POINTER_RD,
BROWSER_POINTER_CROSS = GUI_POINTER_CROSS,
BROWSER_POINTER_MOVE = GUI_POINTER_MOVE,
BROWSER_POINTER_WAIT = GUI_POINTER_WAIT,
BROWSER_POINTER_HELP = GUI_POINTER_HELP,
BROWSER_POINTER_NO_DROP = GUI_POINTER_NO_DROP,
BROWSER_POINTER_NOT_ALLOWED = GUI_POINTER_NOT_ALLOWED,
BROWSER_POINTER_PROGRESS = GUI_POINTER_PROGRESS,
BROWSER_POINTER_AUTO
} browser_pointer_shape;
/** Browser window data. */
struct browser_window {
/** Page currently displayed, or 0. Must have status READY or DONE. */
@ -301,7 +324,7 @@ void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
void browser_window_set_status(struct browser_window *bw, const char *text);
void browser_window_set_pointer(struct browser_window *bw,
gui_pointer_shape shape);
browser_pointer_shape shape);
void browser_window_page_drag_start(struct browser_window *bw, int x, int y);
bool browser_window_back_available(struct browser_window *bw);

View File

@ -91,7 +91,7 @@ void browser_window_scroll_callback(void *client_data,
case SCROLLBAR_MSG_SCROLL_FINISHED:
browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
browser_window_set_pointer(bw, GUI_POINTER_DEFAULT);
browser_window_set_pointer(bw, BROWSER_POINTER_DEFAULT);
break;
}
}
@ -800,7 +800,7 @@ bool browser_window_resolve_frame_dimension(struct browser_window *bw,
static bool browser_window_resize_frames(struct browser_window *bw,
browser_mouse_state mouse, int x, int y,
gui_pointer_shape *pointer)
browser_pointer_shape *pointer)
{
struct browser_window *parent;
bool left, right, up, down;
@ -878,22 +878,22 @@ static bool browser_window_resize_frames(struct browser_window *bw,
if (left || right || up || down) {
if (left) {
if (down)
*pointer = GUI_POINTER_LD;
*pointer = BROWSER_POINTER_LD;
else if (up)
*pointer = GUI_POINTER_LU;
*pointer = BROWSER_POINTER_LU;
else
*pointer = GUI_POINTER_LEFT;
*pointer = BROWSER_POINTER_LEFT;
} else if (right) {
if (down)
*pointer = GUI_POINTER_RD;
*pointer = BROWSER_POINTER_RD;
else if (up)
*pointer = GUI_POINTER_RU;
*pointer = BROWSER_POINTER_RU;
else
*pointer = GUI_POINTER_RIGHT;
*pointer = BROWSER_POINTER_RIGHT;
} else if (up) {
*pointer = GUI_POINTER_UP;
*pointer = BROWSER_POINTER_UP;
} else {
*pointer = GUI_POINTER_DOWN;
*pointer = BROWSER_POINTER_DOWN;
}
if (mouse & (BROWSER_MOUSE_DRAG_1 |
BROWSER_MOUSE_DRAG_2)) {
@ -931,7 +931,7 @@ static bool browser_window_resize_frames(struct browser_window *bw,
bool browser_window_frame_resize_start(struct browser_window *bw,
browser_mouse_state mouse, int x, int y,
gui_pointer_shape *pointer)
browser_pointer_shape *pointer)
{
struct browser_window *root = browser_window_get_root(bw);
int offx, offy;

View File

@ -24,7 +24,6 @@
#define _NETSURF_DESKTOP_FRAMES_H_
#include "desktop/browser.h"
#include "desktop/gui.h"
void browser_window_create_iframes(struct browser_window *bw,
@ -35,7 +34,7 @@ void browser_window_create_frameset(struct browser_window *bw,
void browser_window_recalculate_frameset(struct browser_window *bw);
bool browser_window_frame_resize_start(struct browser_window *bw,
browser_mouse_state mouse, int x, int y,
gui_pointer_shape *pointer);
browser_pointer_shape *pointer);
void browser_window_resize_frame(struct browser_window *bw, int x, int y);
void browser_window_scroll_callback(void *client_data,

View File

@ -46,7 +46,7 @@
#include "utils/utils.h"
static gui_pointer_shape get_pointer_shape(struct browser_window *bw,
static browser_pointer_shape get_pointer_shape(struct browser_window *bw,
struct box *box, bool imagemap);
static void html_box_drag_start(struct box *box, int x, int y);
@ -175,7 +175,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
const char *target = 0;
char status_buffer[200];
const char *status = 0;
gui_pointer_shape pointer = GUI_POINTER_DEFAULT;
browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
bool imagemap = false;
int box_x = 0, box_y = 0;
int gadget_box_x = 0, gadget_box_y = 0;
@ -370,19 +370,19 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
if (scrollbar) {
status = scrollbar_mouse_action(scrollbar, mouse,
scroll_mouse_x, scroll_mouse_y);
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
} else if (gadget) {
switch (gadget->type) {
case GADGET_SELECT:
status = messages_get("FormSelect");
pointer = GUI_POINTER_MENU;
pointer = BROWSER_POINTER_MENU;
if (mouse & BROWSER_MOUSE_CLICK_1 &&
nsoption_bool(core_select_menu)) {
html->visible_select_menu = gadget;
form_open_select_menu(c, gadget,
form_select_menu_callback,
c);
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
} else if (mouse & BROWSER_MOUSE_CLICK_1)
gui_create_form_select_menu(bw, gadget);
break;
@ -666,7 +666,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
drag_candidate,
x, y);
}
pointer = GUI_POINTER_MOVE;
pointer = BROWSER_POINTER_MOVE;
}
}
else if (mouse & BROWSER_MOUSE_DRAG_2) {
@ -686,7 +686,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
drag_candidate,
x, y);
}
pointer = GUI_POINTER_MOVE;
pointer = BROWSER_POINTER_MOVE;
}
}
}
@ -724,10 +724,10 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
}
gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box,
browser_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box,
bool imagemap)
{
gui_pointer_shape pointer;
browser_pointer_shape pointer;
css_computed_style *style;
enum css_cursor_e cursor;
lwc_string **cursor_uris;
@ -742,7 +742,7 @@ gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box,
if (wallclock() - bw->last_action < 100 && loading)
/* If less than 1 second since last link followed, show
* progress indicating pointer and we're loading something */
return GUI_POINTER_PROGRESS;
return BROWSER_POINTER_PROGRESS;
if (box->type == BOX_FLOAT_LEFT || box->type == BOX_FLOAT_RIGHT)
style = box->children->style;
@ -750,7 +750,7 @@ gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box,
style = box->style;
if (style == NULL)
return GUI_POINTER_DEFAULT;
return BROWSER_POINTER_DEFAULT;
cursor = css_computed_cursor(style, &cursor_uris);
@ -761,70 +761,70 @@ gui_pointer_shape get_pointer_shape(struct browser_window *bw, struct box *box,
box->gadget->type == GADGET_SUBMIT)) ||
imagemap) {
/* link */
pointer = GUI_POINTER_POINT;
pointer = BROWSER_POINTER_POINT;
} else if (box->gadget &&
(box->gadget->type == GADGET_TEXTBOX ||
box->gadget->type == GADGET_PASSWORD ||
box->gadget->type == GADGET_TEXTAREA)) {
/* text input */
pointer = GUI_POINTER_CARET;
pointer = BROWSER_POINTER_CARET;
} else {
/* anything else */
if (loading) {
/* loading new content */
pointer = GUI_POINTER_PROGRESS;
pointer = BROWSER_POINTER_PROGRESS;
} else {
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
}
}
break;
case CSS_CURSOR_CROSSHAIR:
pointer = GUI_POINTER_CROSS;
pointer = BROWSER_POINTER_CROSS;
break;
case CSS_CURSOR_POINTER:
pointer = GUI_POINTER_POINT;
pointer = BROWSER_POINTER_POINT;
break;
case CSS_CURSOR_MOVE:
pointer = GUI_POINTER_MOVE;
pointer = BROWSER_POINTER_MOVE;
break;
case CSS_CURSOR_E_RESIZE:
pointer = GUI_POINTER_RIGHT;
pointer = BROWSER_POINTER_RIGHT;
break;
case CSS_CURSOR_W_RESIZE:
pointer = GUI_POINTER_LEFT;
pointer = BROWSER_POINTER_LEFT;
break;
case CSS_CURSOR_N_RESIZE:
pointer = GUI_POINTER_UP;
pointer = BROWSER_POINTER_UP;
break;
case CSS_CURSOR_S_RESIZE:
pointer = GUI_POINTER_DOWN;
pointer = BROWSER_POINTER_DOWN;
break;
case CSS_CURSOR_NE_RESIZE:
pointer = GUI_POINTER_RU;
pointer = BROWSER_POINTER_RU;
break;
case CSS_CURSOR_SW_RESIZE:
pointer = GUI_POINTER_LD;
pointer = BROWSER_POINTER_LD;
break;
case CSS_CURSOR_SE_RESIZE:
pointer = GUI_POINTER_RD;
pointer = BROWSER_POINTER_RD;
break;
case CSS_CURSOR_NW_RESIZE:
pointer = GUI_POINTER_LU;
pointer = BROWSER_POINTER_LU;
break;
case CSS_CURSOR_TEXT:
pointer = GUI_POINTER_CARET;
pointer = BROWSER_POINTER_CARET;
break;
case CSS_CURSOR_WAIT:
pointer = GUI_POINTER_WAIT;
pointer = BROWSER_POINTER_WAIT;
break;
case CSS_CURSOR_PROGRESS:
pointer = GUI_POINTER_PROGRESS;
pointer = BROWSER_POINTER_PROGRESS;
break;
case CSS_CURSOR_HELP:
pointer = GUI_POINTER_HELP;
pointer = BROWSER_POINTER_HELP;
break;
default:
pointer = GUI_POINTER_DEFAULT;
pointer = BROWSER_POINTER_DEFAULT;
break;
}
@ -867,7 +867,7 @@ void html_overflow_scroll_callback(void *client_data,
DRAGGING_NONE, NULL);
browser_window_set_pointer(html->bw,
GUI_POINTER_DEFAULT);
BROWSER_POINTER_DEFAULT);
break;
}
}

View File

@ -675,7 +675,7 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw,
browser_mouse_state mouse, int x, int y)
{
textplain_content *text = (textplain_content *) c;
gui_pointer_shape pointer = GUI_POINTER_DEFAULT;
browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
const char *status = 0;
size_t idx;
int dir = 0;
@ -701,7 +701,7 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw,
if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2)) {
browser_window_page_drag_start(bw, x, y);
pointer = GUI_POINTER_MOVE;
pointer = BROWSER_POINTER_MOVE;
}
}