Propagate native caret clip rect through core.
This commit is contained in:
parent
461d4576fb
commit
e8950dee22
|
@ -1546,7 +1546,8 @@ nserror browser_window_callback(hlcache_handle *c,
|
|||
browser_window_place_caret(bw,
|
||||
event->data.caret.pos.x,
|
||||
event->data.caret.pos.y,
|
||||
event->data.caret.pos.height);
|
||||
event->data.caret.pos.height,
|
||||
event->data.caret.pos.clip);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -202,8 +202,8 @@ bool browser_window_stop_available(struct browser_window *bw);
|
|||
|
||||
|
||||
/* In desktop/textinput.c */
|
||||
void browser_window_place_caret(struct browser_window *bw,
|
||||
int x, int y, int height);
|
||||
void browser_window_place_caret(struct browser_window *bw, int x, int y,
|
||||
int height, const struct rect *clip);
|
||||
void browser_window_remove_caret(struct browser_window *bw, bool only_hide);
|
||||
bool browser_window_key_press(struct browser_window *bw, uint32_t key);
|
||||
|
||||
|
|
|
@ -462,13 +462,19 @@ static void textarea_scrollbar_callback(void *client_data,
|
|||
|
||||
if (!(ta->flags & TEXTAREA_INTERNAL_CARET)) {
|
||||
/* Tell client where caret should be placed */
|
||||
struct rect cr = {
|
||||
.x0 = ta->border_width,
|
||||
.y0 = ta->border_width,
|
||||
.x1 = ta->vis_width - ta->border_width,
|
||||
.y1 = ta->vis_height - ta->border_width
|
||||
};
|
||||
msg.ta = ta;
|
||||
msg.type = TEXTAREA_MSG_CARET_UPDATE;
|
||||
msg.data.caret.type = TEXTAREA_CARET_SET_POS;
|
||||
msg.data.caret.pos.x = ta->caret_x - ta->scroll_x;
|
||||
msg.data.caret.pos.y = ta->caret_y - ta->scroll_y;
|
||||
msg.data.caret.pos.height = ta->line_height;
|
||||
msg.data.caret.pos.clip = NULL;
|
||||
msg.data.caret.pos.clip = &cr;
|
||||
|
||||
ta->callback(ta->data, &msg);
|
||||
}
|
||||
|
@ -1443,13 +1449,19 @@ bool textarea_set_caret(struct textarea *ta, int caret)
|
|||
|
||||
if (!(ta->flags & TEXTAREA_INTERNAL_CARET)) {
|
||||
/* Tell client where caret should be placed */
|
||||
struct rect cr = {
|
||||
.x0 = ta->border_width,
|
||||
.y0 = ta->border_width,
|
||||
.x1 = ta->vis_width - ta->border_width,
|
||||
.y1 = ta->vis_height - ta->border_width
|
||||
};
|
||||
msg.ta = ta;
|
||||
msg.type = TEXTAREA_MSG_CARET_UPDATE;
|
||||
msg.data.caret.type = TEXTAREA_CARET_SET_POS;
|
||||
msg.data.caret.pos.x = x - ta->scroll_x;
|
||||
msg.data.caret.pos.y = y - ta->scroll_y;
|
||||
msg.data.caret.pos.height = ta->line_height;
|
||||
msg.data.caret.pos.clip = NULL;
|
||||
msg.data.caret.pos.clip = &cr;
|
||||
|
||||
ta->callback(ta->data, &msg);
|
||||
}
|
||||
|
@ -2375,13 +2387,19 @@ bool textarea_clear_selection(struct textarea *ta)
|
|||
|
||||
if (!(ta->flags & TEXTAREA_INTERNAL_CARET)) {
|
||||
/* Tell client where caret should be placed */
|
||||
struct rect cr = {
|
||||
.x0 = ta->border_width,
|
||||
.y0 = ta->border_width,
|
||||
.x1 = ta->vis_width - ta->border_width,
|
||||
.y1 = ta->vis_height - ta->border_width
|
||||
};
|
||||
msg.ta = ta;
|
||||
msg.type = TEXTAREA_MSG_CARET_UPDATE;
|
||||
msg.data.caret.type = TEXTAREA_CARET_SET_POS;
|
||||
msg.data.caret.pos.x = ta->caret_x - ta->scroll_x;
|
||||
msg.data.caret.pos.y = ta->caret_y - ta->scroll_y;
|
||||
msg.data.caret.pos.height = ta->line_height;
|
||||
msg.data.caret.pos.clip = NULL;
|
||||
msg.data.caret.pos.clip = &cr;
|
||||
|
||||
ta->callback(ta->data, &msg);
|
||||
}
|
||||
|
|
|
@ -52,22 +52,19 @@
|
|||
/**
|
||||
* Position the caret and assign a callback for key presses.
|
||||
*
|
||||
* \param bw The browser window in which to place the caret
|
||||
* \param x X coordinate of the caret
|
||||
* \param y Y coordinate
|
||||
* \param height Height of caret
|
||||
* \param caret_cb Callback function for keypresses
|
||||
* \param paste_cb Callback function for pasting text
|
||||
* \param move_cb Callback function for caret movement
|
||||
* \param p1 Callback private data pointer, passed to callback function
|
||||
* \param p2 Callback private data pointer, passed to callback function
|
||||
* \param bw The browser window in which to place the caret
|
||||
* \param x X coordinate of the caret
|
||||
* \param y Y coordinate
|
||||
* \param height Height of caret
|
||||
* \param clip Clip rectangle for caret
|
||||
*/
|
||||
void browser_window_place_caret(struct browser_window *bw,
|
||||
int x, int y, int height)
|
||||
void browser_window_place_caret(struct browser_window *bw, int x, int y,
|
||||
int height, const struct rect *clip)
|
||||
{
|
||||
struct browser_window *root_bw;
|
||||
int pos_x = 0;
|
||||
int pos_y = 0;
|
||||
struct rect cr;
|
||||
|
||||
/* Find top level browser window */
|
||||
root_bw = browser_window_get_root(bw);
|
||||
|
@ -76,6 +73,17 @@ void browser_window_place_caret(struct browser_window *bw,
|
|||
x = x * bw->scale + pos_x;
|
||||
y = y * bw->scale + pos_y;
|
||||
|
||||
if (clip != NULL) {
|
||||
cr = *clip;
|
||||
cr.x0 += pos_x;
|
||||
cr.y0 += pos_y;
|
||||
cr.x1 += pos_x;
|
||||
cr.y1 += pos_y;
|
||||
}
|
||||
|
||||
/* TODO: intersect with bw viewport */
|
||||
/* TODO: pass clip rect out to GUI */
|
||||
|
||||
gui_window_place_caret(root_bw->window, x, y, height * bw->scale);
|
||||
|
||||
/* Set focus browser window */
|
||||
|
|
|
@ -1144,11 +1144,20 @@ void html_set_focus(html_content *html, html_focus_type focus_type,
|
|||
} else if (focus_type != HTML_FOCUS_SELF && hide_caret) {
|
||||
msg_data.caret.type = CONTENT_CARET_HIDE;
|
||||
} else {
|
||||
struct rect cr;
|
||||
if (clip != NULL) {
|
||||
cr = *clip;
|
||||
cr.x0 += x_off;
|
||||
cr.y0 += y_off;
|
||||
cr.x1 += x_off;
|
||||
cr.y1 += y_off;
|
||||
}
|
||||
|
||||
msg_data.caret.type = CONTENT_CARET_SET_POS;
|
||||
msg_data.caret.pos.x = x + x_off;
|
||||
msg_data.caret.pos.y = y + y_off;
|
||||
msg_data.caret.pos.height = height;
|
||||
msg_data.caret.pos.clip = clip;
|
||||
msg_data.caret.pos.clip = (clip == NULL) ? NULL : &cr;
|
||||
}
|
||||
|
||||
/* Inform of the content's drag status change */
|
||||
|
|
Loading…
Reference in New Issue