summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c3
-rw-r--r--desktop/browser.h4
-rw-r--r--desktop/textarea.c24
-rw-r--r--desktop/textinput.c30
4 files changed, 44 insertions, 17 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index e42f6e200..8d115e749 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -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;
diff --git a/desktop/browser.h b/desktop/browser.h
index dcc728b56..44eac992f 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -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);
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 73781f261..26c1e0ba4 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -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);
}
diff --git a/desktop/textinput.c b/desktop/textinput.c
index 6ffa02c86..4d280d536 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -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 */