void TextInputGTK::PreEditStartCallback( GtkIMContext *context, gpointer userData ) { REALcontrolInstance control = reinterpret_cast<REALcontrolInstance>(userData); REALobject selRange = FireSelectedRange( control ); if (selRange) { REALobject rect = FireRectForRange( control, &selRange ); if (rect) { long left = 0; long top = 0; long width = 0; long height = 0; REALGetPropValue( rect, "Left", &left ); REALGetPropValue( rect, "Top", &top ); REALGetPropValue( rect, "Width", &width ); REALGetPropValue( rect, "Height", &height ); REALUnlockObject( rect ); GdkRectangle area = {0}; area.x = left; area.y = top; area.width = width; area.height = height; gtk_im_context_set_cursor_location( context, &area ); } REALUnlockObject( selRange ); } }
static VALUE rg_set_cursor_location(VALUE self, VALUE area) { gtk_im_context_set_cursor_location( _SELF(self), ((GdkRectangle*)RVAL2BOXED(area, GDK_TYPE_RECTANGLE))); return self; }
static VALUE rg_set_cursor_location(VALUE self, VALUE area) { gtk_im_context_set_cursor_location( _SELF(self), RVAL2GDKRECTANGLE(area)); return self; }
void GtkInputMethodFilter::setCursorRect(const IntRect& cursorRect) { // Don't move the window unless the cursor actually moves more than 10 // pixels. This prevents us from making the window flash during minor // cursor adjustments. static const int windowMovementThreshold = 10 * 10; if (cursorRect.location().distanceSquaredToPoint(m_lastCareLocation) < windowMovementThreshold) return; m_lastCareLocation = cursorRect.location(); IntRect translatedRect = cursorRect; ASSERT(m_widget); GtkAllocation allocation; gtk_widget_get_allocation(m_widget, &allocation); translatedRect.move(allocation.x, allocation.y); GdkRectangle gdkCursorRect = cursorRect; gtk_im_context_set_cursor_location(m_context.get(), &gdkCursorRect); }
void gdk_region_get_clipbox (const GdkRegion *region, GdkRectangle *rectangle) { g_return_if_fail (region != NULL); g_return_if_fail (rectangle != NULL); rectangle->x = region->extents.x1; rectangle->y = region->extents.y1; rectangle->width = region->extents.x2 - region->extents.x1; rectangle->height = region->extents.y2 - region->extents.y1; GdkRectangle rect; rect.x = rectangle->x; rect.y = rectangle->y; rect.width = 0; rect.height = rectangle->height; //The caret width is 2; //Maybe sometimes we will make a mistake, but for most of the time, it should be the caret. if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) { gtk_im_context_set_cursor_location(local_context, rectangle); } }
static void fcitx_im_context_set_cursor_location(GtkIMContext *context, GdkRectangle *area) { FcitxLog(LOG_LEVEL, "fcitx_im_context_set_cursor_location %d %d %d %d", area->x, area->y, area->height, area->width); FcitxIMContext *fcitxcontext = FCITX_IM_CONTEXT(context); if (fcitxcontext->area.x == area->x && fcitxcontext->area.y == area->y && fcitxcontext->area.width == area->width && fcitxcontext->area.height == area->height) { return; } fcitxcontext->area = *area; if (fcitx_client_is_valid(fcitxcontext->client)) { _set_cursor_location_internal(fcitxcontext); } gtk_im_context_set_cursor_location(fcitxcontext->slave, area); return; }
static void update_im_cursor_location (StIMText *self) { StIMTextPrivate *priv = self->priv; ClutterText *clutter_text = CLUTTER_TEXT (self); gint position; gfloat cursor_x, cursor_y, cursor_height; gfloat actor_x, actor_y; GdkRectangle area; position = clutter_text_get_cursor_position (clutter_text); clutter_text_position_to_coords (clutter_text, position, &cursor_x, &cursor_y, &cursor_height); clutter_actor_get_transformed_position (CLUTTER_ACTOR (self), &actor_x, &actor_y); area.x = (int)(0.5 + cursor_x + actor_x); area.y = (int)(0.5 + cursor_y + actor_y); area.width = 0; area.height = (int)(0.5 + cursor_height); gtk_im_context_set_cursor_location (priv->im_context, &area); }
void html_engine_draw_cursor_in_area (HTMLEngine *engine, gint x, gint y, gint width, gint height) { HTMLObject *obj; guint offset; gint x1, y1, x2, y2, sc_x, sc_y; GdkRectangle pos; GtkAdjustment *hadj, *vadj; if ((engine->editable || engine->caret_mode) && (engine->cursor_hide_count <= 0 && !engine->thaw_idle_id)) { html_engine_draw_table_cursor (engine); html_engine_draw_cell_cursor (engine); html_engine_draw_image_cursor (engine); } if (!cursor_enabled || engine->cursor_hide_count > 0 || !(engine->editable || engine->caret_mode) || engine->thaw_idle_id) return; obj = engine->cursor->object; if (obj == NULL || engine->window == NULL) return; offset = engine->cursor->offset; if (width < 0 || height < 0) { width = html_engine_get_doc_width (engine); height = html_engine_get_doc_height (engine); x = 0; y = 0; } html_object_get_cursor (obj, engine->painter, offset, &x1, &y1, &x2, &y2); while (obj) { if (html_object_is_frame (obj)) { x1 -= HTML_EMBEDDED (obj)->abs_x; x2 -= HTML_EMBEDDED (obj)->abs_x; y1 -= HTML_EMBEDDED (obj)->abs_y; y2 -= HTML_EMBEDDED (obj)->abs_y; break; } obj = obj->parent; } /* get scroll offset */ hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (engine->widget)); vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (engine->widget)); sc_x = (gint) gtk_adjustment_get_value (hadj); sc_y = (gint) gtk_adjustment_get_value (vadj); pos.x = x1 - sc_x; pos.y = y1 - sc_y; pos.width = x2 - x1; pos.height = y2 - y1; gtk_im_context_set_cursor_location (GTK_HTML (engine->widget)->priv->im_context, &pos); if (clip_cursor (engine, x, y, width, height, &x1, &y1, &x2, &y2)) { cairo_t *cr; gboolean using_painter_cr; using_painter_cr = engine->painter && HTML_IS_GDK_PAINTER (engine->painter) && HTML_GDK_PAINTER (engine->painter)->cr != NULL; if (using_painter_cr) { HTMLGdkPainter *gdk_painter = HTML_GDK_PAINTER (engine->painter); cr = gdk_painter->cr; cairo_save (cr); x1 -= gdk_painter->x1; y1 -= gdk_painter->y1; x2 -= gdk_painter->x1; y2 -= gdk_painter->y1; } else { cr = gdk_cairo_create (engine->window); } cairo_set_source_rgb (cr, 1, 1, 1); cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE); cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); cairo_move_to (cr, x1 + 0.5, y1 + 0.5); cairo_line_to (cr, x2 + 0.5, y2 - 0.5); cairo_set_line_width (cr, 1); cairo_stroke (cr); if (using_painter_cr) cairo_restore (cr); else cairo_destroy (cr); } }