Compare commits
1 Commits
main
...
wip/cherge
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3ee661a3e |
@@ -264,7 +264,7 @@ released_cb (GtkGestureClick *gesture,
|
||||
{
|
||||
GtkTextIter start, end, iter;
|
||||
GtkTextBuffer *buffer;
|
||||
int tx, ty;
|
||||
GtkTextUnit tx, ty;
|
||||
|
||||
if (gtk_gesture_single_get_button (GTK_GESTURE_SINGLE (gesture)) > 1)
|
||||
return;
|
||||
@@ -290,7 +290,7 @@ motion_cb (GtkEventControllerMotion *controller,
|
||||
double y,
|
||||
GtkTextView *text_view)
|
||||
{
|
||||
int tx, ty;
|
||||
GtkTextUnit tx, ty;
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (text_view,
|
||||
GTK_TEXT_WINDOW_WIDGET,
|
||||
|
||||
@@ -398,7 +398,7 @@ text_view_query_tooltip_cb (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
int bx, by, trailing;
|
||||
GtkTextUnit bx, by, trailing;
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (self->text_view), GTK_TEXT_WINDOW_TEXT,
|
||||
x, y, &bx, &by);
|
||||
@@ -1587,7 +1587,7 @@ click_gesture_pressed (GtkGestureClick *gesture,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
int bx, by, trailing;
|
||||
GtkTextUnit bx, by, trailing;
|
||||
GdkModifierType state;
|
||||
|
||||
state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
@@ -1815,7 +1815,7 @@ text_view_released (GtkGestureClick *gesture,
|
||||
GtkWidget *text_view;
|
||||
GtkTextIter start, end, iter;
|
||||
GtkTextBuffer *buffer;
|
||||
int tx, ty;
|
||||
GtkTextUnit tx, ty;
|
||||
|
||||
if (gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)) != GDK_BUTTON_PRIMARY)
|
||||
return;
|
||||
@@ -1881,7 +1881,7 @@ text_view_motion (GtkEventControllerMotion *motion,
|
||||
double y,
|
||||
GtkAboutDialog *about)
|
||||
{
|
||||
int tx, ty;
|
||||
GtkTextUnit tx, ty;
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (motion));
|
||||
|
||||
@@ -57,6 +57,8 @@ VOID:BOXED,ENUM
|
||||
VOID:BOXED,OBJECT
|
||||
VOID:BOXED,STRING,INT
|
||||
VOID:DOUBLE,DOUBLE
|
||||
VOID:DOUBLE,DOUBLE,DOUBLE
|
||||
VOID:DOUBLE,DOUBLE,ENUM,ENUM
|
||||
VOID:DOUBLE,DOUBLE,UINT,BOXED
|
||||
VOID:ENUM,DOUBLE
|
||||
VOID:ENUM,INT
|
||||
|
||||
@@ -107,6 +107,8 @@ struct _GtkRangePrivate
|
||||
int slide_initial_slider_position;
|
||||
int slide_initial_coordinate_delta;
|
||||
|
||||
guint changed_tick_id;
|
||||
|
||||
guint flippable : 1;
|
||||
guint inverted : 1;
|
||||
guint slider_size_fixed : 1;
|
||||
@@ -693,6 +695,12 @@ gtk_range_set_adjustment (GtkRange *range,
|
||||
g_signal_handlers_disconnect_by_func (priv->adjustment,
|
||||
gtk_range_adjustment_value_changed,
|
||||
range);
|
||||
if (priv->changed_tick_id)
|
||||
{
|
||||
gtk_widget_remove_tick_callback (GTK_WIDGET (range),
|
||||
priv->changed_tick_id);
|
||||
priv->changed_tick_id = 0;
|
||||
}
|
||||
g_object_unref (priv->adjustment);
|
||||
}
|
||||
|
||||
@@ -1318,6 +1326,13 @@ gtk_range_dispose (GObject *object)
|
||||
|
||||
gtk_range_remove_step_timer (range);
|
||||
|
||||
if (priv->changed_tick_id)
|
||||
{
|
||||
gtk_widget_remove_tick_callback (GTK_WIDGET (range),
|
||||
priv->changed_tick_id);
|
||||
priv->changed_tick_id = 0;
|
||||
}
|
||||
|
||||
if (priv->adjustment)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (priv->adjustment,
|
||||
@@ -2358,16 +2373,22 @@ gtk_range_drag_gesture_end (GtkGestureDrag *gesture,
|
||||
stop_scrolling (range);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_adjustment_changed (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
static gboolean
|
||||
gtk_range_adjustment_changed_cb (GtkWidget *widget,
|
||||
GdkFrameClock *frame_clock,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkRange *range = GTK_RANGE (data);
|
||||
GtkRange *range = GTK_RANGE (widget);
|
||||
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
|
||||
double upper = gtk_adjustment_get_upper (priv->adjustment);
|
||||
double lower = gtk_adjustment_get_lower (priv->adjustment);
|
||||
|
||||
gtk_widget_set_visible (priv->slider_widget, upper != lower || !GTK_IS_SCALE (range));
|
||||
priv->changed_tick_id = 0;
|
||||
|
||||
if (upper == lower && GTK_IS_SCALE (range))
|
||||
gtk_widget_hide (priv->slider_widget);
|
||||
else
|
||||
gtk_widget_show (priv->slider_widget);
|
||||
|
||||
gtk_widget_queue_allocate (priv->trough_widget);
|
||||
|
||||
@@ -2383,6 +2404,32 @@ gtk_range_adjustment_changed (GtkAdjustment *adjustment,
|
||||
* can input into the adjustment, not a filter that the GtkRange
|
||||
* will enforce on the adjustment.
|
||||
*/
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_adjustment_changed (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
{
|
||||
GtkRange *range = GTK_RANGE (data);
|
||||
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
|
||||
|
||||
/* There is a good chance that we will get this notification
|
||||
* from size_allocate() of another widget. That means we are
|
||||
* already in the LAYOUT phase of the frame clock.
|
||||
*
|
||||
* It's not allowed to call gtk_widget_show()/hide() from that
|
||||
* point because it will result in a loss of allocations which
|
||||
* are needed to complete the current frame.
|
||||
*
|
||||
* Instead, defer until the next frame to perform adjustments.
|
||||
*/
|
||||
if (priv->changed_tick_id == 0)
|
||||
priv->changed_tick_id =
|
||||
gtk_widget_add_tick_callback (GTK_WIDGET (range),
|
||||
gtk_range_adjustment_changed_cb,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -293,8 +293,8 @@ static NodeData * gtk_text_btree_node_ensure_data (GtkTextBTr
|
||||
gpointer view_id);
|
||||
static void gtk_text_btree_node_get_size (GtkTextBTreeNode *node,
|
||||
gpointer view_id,
|
||||
int *width,
|
||||
int *height);
|
||||
GtkTextUnit *width,
|
||||
GtkTextUnit *height);
|
||||
static GtkTextBTreeNode * gtk_text_btree_node_common_parent (GtkTextBTreeNode *node1,
|
||||
GtkTextBTreeNode *node2);
|
||||
static void get_tree_bounds (GtkTextBTree *tree,
|
||||
@@ -1340,11 +1340,14 @@ _gtk_text_btree_unregister_child_anchor (GtkTextChildAnchor *anchor)
|
||||
*/
|
||||
|
||||
static GtkTextLine*
|
||||
find_line_by_y (GtkTextBTree *tree, BTreeView *view,
|
||||
GtkTextBTreeNode *node, int y, int *line_top,
|
||||
GtkTextLine *last_line)
|
||||
find_line_by_y (GtkTextBTree *tree,
|
||||
BTreeView *view,
|
||||
GtkTextBTreeNode *node,
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit *line_top,
|
||||
GtkTextLine *last_line)
|
||||
{
|
||||
int current_y = 0;
|
||||
GtkTextUnit current_y = 0;
|
||||
|
||||
if (GTK_DEBUG_CHECK (TEXT))
|
||||
_gtk_text_btree_check (tree);
|
||||
@@ -1382,8 +1385,8 @@ find_line_by_y (GtkTextBTree *tree, BTreeView *view,
|
||||
|
||||
while (child != NULL)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
GtkTextUnit width;
|
||||
GtkTextUnit height;
|
||||
|
||||
gtk_text_btree_node_get_size (child, view->view_id,
|
||||
&width, &height);
|
||||
@@ -1406,13 +1409,13 @@ find_line_by_y (GtkTextBTree *tree, BTreeView *view,
|
||||
GtkTextLine *
|
||||
_gtk_text_btree_find_line_by_y (GtkTextBTree *tree,
|
||||
gpointer view_id,
|
||||
int ypixel,
|
||||
int *line_top_out)
|
||||
GtkTextUnit ypixel,
|
||||
GtkTextUnit *line_top_out)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
BTreeView *view;
|
||||
GtkTextLine *last_line;
|
||||
int line_top = 0;
|
||||
GtkTextUnit line_top = 0;
|
||||
|
||||
view = gtk_text_btree_get_view (tree, view_id);
|
||||
g_return_val_if_fail (view != NULL, NULL);
|
||||
@@ -1460,7 +1463,7 @@ _gtk_text_btree_find_line_top (GtkTextBTree *tree,
|
||||
GtkTextLine *target_line,
|
||||
gpointer view_id)
|
||||
{
|
||||
int y = 0;
|
||||
GtkTextUnit y = 0;
|
||||
BTreeView *view;
|
||||
GtkTextBTreeNode *node;
|
||||
GtkTextBTreeNode *nodes[64];
|
||||
@@ -1500,8 +1503,8 @@ _gtk_text_btree_find_line_top (GtkTextBTree *tree,
|
||||
|
||||
while (child != NULL)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
GtkTextUnit width;
|
||||
GtkTextUnit height;
|
||||
|
||||
if (child == target_node)
|
||||
break;
|
||||
@@ -1635,9 +1638,9 @@ _gtk_text_btree_invalidate_region (GtkTextBTree *tree,
|
||||
|
||||
void
|
||||
_gtk_text_btree_get_view_size (GtkTextBTree *tree,
|
||||
gpointer view_id,
|
||||
int *width,
|
||||
int *height)
|
||||
gpointer view_id,
|
||||
GtkTextUnit *width,
|
||||
GtkTextUnit *height)
|
||||
{
|
||||
g_return_if_fail (tree != NULL);
|
||||
g_return_if_fail (view_id != NULL);
|
||||
@@ -5236,11 +5239,11 @@ gtk_text_btree_node_validate (BTreeView *view,
|
||||
**/
|
||||
gboolean
|
||||
_gtk_text_btree_validate (GtkTextBTree *tree,
|
||||
gpointer view_id,
|
||||
int max_pixels,
|
||||
int *y,
|
||||
int *old_height,
|
||||
int *new_height)
|
||||
gpointer view_id,
|
||||
int max_pixels,
|
||||
GtkTextUnit *y,
|
||||
GtkTextUnit *old_height,
|
||||
GtkTextUnit *new_height)
|
||||
{
|
||||
BTreeView *view;
|
||||
|
||||
@@ -5567,8 +5570,10 @@ gtk_text_btree_node_remove_data (GtkTextBTreeNode *node, gpointer view_id)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_btree_node_get_size (GtkTextBTreeNode *node, gpointer view_id,
|
||||
int *width, int *height)
|
||||
gtk_text_btree_node_get_size (GtkTextBTreeNode *node,
|
||||
gpointer view_id,
|
||||
GtkTextUnit *width,
|
||||
GtkTextUnit *height)
|
||||
{
|
||||
NodeData *nd;
|
||||
|
||||
@@ -5667,8 +5672,8 @@ tag_changed_cb (GtkTextTagTable *table,
|
||||
|
||||
while (view != NULL)
|
||||
{
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
GtkTextUnit width = 0;
|
||||
GtkTextUnit height = 0;
|
||||
|
||||
_gtk_text_btree_get_view_size (tree, view->view_id, &width, &height);
|
||||
gtk_text_layout_changed (view->layout, 0, height, height);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <gtk/gtktextchild.h>
|
||||
#include <gtk/gtktextsegmentprivate.h>
|
||||
#include <gtk/gtktextiter.h>
|
||||
#include <gtk/gtktexttypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -78,8 +79,8 @@ void _gtk_text_btree_unregister_child_anchor (GtkTextChildAnchor *anchor);
|
||||
/* View stuff */
|
||||
GtkTextLine *_gtk_text_btree_find_line_by_y (GtkTextBTree *tree,
|
||||
gpointer view_id,
|
||||
int ypixel,
|
||||
int *line_top_y);
|
||||
GtkTextUnit ypixel,
|
||||
GtkTextUnit *line_top_y);
|
||||
int _gtk_text_btree_find_line_top (GtkTextBTree *tree,
|
||||
GtkTextLine *line,
|
||||
gpointer view_id);
|
||||
@@ -93,16 +94,16 @@ void _gtk_text_btree_invalidate_region (GtkTextBTree *tree,
|
||||
gboolean cursors_only);
|
||||
void _gtk_text_btree_get_view_size (GtkTextBTree *tree,
|
||||
gpointer view_id,
|
||||
int *width,
|
||||
int *height);
|
||||
GtkTextUnit *width,
|
||||
GtkTextUnit *height);
|
||||
gboolean _gtk_text_btree_is_valid (GtkTextBTree *tree,
|
||||
gpointer view_id);
|
||||
gboolean _gtk_text_btree_validate (GtkTextBTree *tree,
|
||||
gpointer view_id,
|
||||
int max_pixels,
|
||||
int *y,
|
||||
int *old_height,
|
||||
int *new_height);
|
||||
GtkTextUnit *y,
|
||||
GtkTextUnit *old_height,
|
||||
GtkTextUnit *new_height);
|
||||
void _gtk_text_btree_validate_line (GtkTextBTree *tree,
|
||||
GtkTextLine *line,
|
||||
gpointer view_id);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <gtk/gtktextiter.h>
|
||||
#include <gtk/gtktextmark.h>
|
||||
#include <gtk/gtktextchild.h>
|
||||
#include <gtk/gtktexttypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
@@ -119,9 +119,9 @@ static void gtk_text_layout_invalidate_cache (GtkTextLayout *layout,
|
||||
static void gtk_text_layout_invalidate_cursor_line (GtkTextLayout *layout,
|
||||
gboolean cursors_only);
|
||||
static void gtk_text_layout_emit_changed (GtkTextLayout *layout,
|
||||
int y,
|
||||
int old_height,
|
||||
int new_height);
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit old_height,
|
||||
GtkTextUnit new_height);
|
||||
|
||||
static void gtk_text_layout_invalidate_all (GtkTextLayout *layout);
|
||||
|
||||
@@ -251,14 +251,14 @@ gtk_text_layout_class_init (GtkTextLayoutClass *klass)
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__INT_INT_INT,
|
||||
_gtk_marshal_VOID__DOUBLE_DOUBLE_DOUBLE,
|
||||
G_TYPE_NONE,
|
||||
3,
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT);
|
||||
GTK_TYPE_TEXT_UNIT,
|
||||
GTK_TYPE_TEXT_UNIT,
|
||||
GTK_TYPE_TEXT_UNIT);
|
||||
g_signal_set_va_marshaller (signals[CHANGED], G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_VOID__INT_INT_INTv);
|
||||
_gtk_marshal_VOID__DOUBLE_DOUBLE_DOUBLEv);
|
||||
|
||||
signals[ALLOCATE_CHILD] =
|
||||
g_signal_new (I_("allocate-child"),
|
||||
@@ -511,7 +511,8 @@ gtk_text_layout_get_buffer (GtkTextLayout *layout)
|
||||
}
|
||||
|
||||
void
|
||||
gtk_text_layout_set_screen_width (GtkTextLayout *layout, int width)
|
||||
gtk_text_layout_set_screen_width (GtkTextLayout *layout,
|
||||
GtkTextUnit width)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
|
||||
g_return_if_fail (width >= 0);
|
||||
@@ -545,7 +546,7 @@ gtk_text_layout_set_cursor_visible (GtkTextLayout *layout,
|
||||
if (layout->cursor_visible != cursor_visible)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
int y, height;
|
||||
GtkTextUnit y, height;
|
||||
|
||||
layout->cursor_visible = cursor_visible;
|
||||
|
||||
@@ -624,8 +625,8 @@ gtk_text_layout_set_preedit_string (GtkTextLayout *layout,
|
||||
|
||||
void
|
||||
gtk_text_layout_get_size (GtkTextLayout *layout,
|
||||
int *width,
|
||||
int *height)
|
||||
GtkTextUnit *width,
|
||||
GtkTextUnit *height)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
|
||||
|
||||
@@ -644,18 +645,18 @@ gtk_text_layout_invalidated (GtkTextLayout *layout)
|
||||
|
||||
static void
|
||||
gtk_text_layout_emit_changed (GtkTextLayout *layout,
|
||||
int y,
|
||||
int old_height,
|
||||
int new_height)
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit old_height,
|
||||
GtkTextUnit new_height)
|
||||
{
|
||||
g_signal_emit (layout, signals[CHANGED], 0, y, old_height, new_height);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_text_layout_changed (GtkTextLayout *layout,
|
||||
int y,
|
||||
int old_height,
|
||||
int new_height)
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit old_height,
|
||||
GtkTextUnit new_height)
|
||||
{
|
||||
GtkTextLayoutPrivate *priv = GTK_TEXT_LAYOUT_GET_PRIVATE (layout);
|
||||
gtk_text_line_display_cache_invalidate_y_range (priv->cache, layout, y, old_height, new_height, FALSE);
|
||||
@@ -664,9 +665,9 @@ gtk_text_layout_changed (GtkTextLayout *layout,
|
||||
|
||||
void
|
||||
gtk_text_layout_cursors_changed (GtkTextLayout *layout,
|
||||
int y,
|
||||
int old_height,
|
||||
int new_height)
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit old_height,
|
||||
GtkTextUnit new_height)
|
||||
{
|
||||
GtkTextLayoutPrivate *priv = GTK_TEXT_LAYOUT_GET_PRIVATE (layout);
|
||||
gtk_text_line_display_cache_invalidate_y_range (priv->cache, layout, y, old_height, new_height, TRUE);
|
||||
@@ -902,16 +903,16 @@ update_layout_size (GtkTextLayout *layout)
|
||||
void
|
||||
gtk_text_layout_validate_yrange (GtkTextLayout *layout,
|
||||
GtkTextIter *anchor,
|
||||
int y0,
|
||||
int y1)
|
||||
GtkTextUnit y0,
|
||||
GtkTextUnit y1)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
GtkTextLine *first_line = NULL;
|
||||
GtkTextLine *last_line = NULL;
|
||||
int seen;
|
||||
int delta_height = 0;
|
||||
int first_line_y = 0; /* Quiet GCC */
|
||||
int last_line_y = 0; /* Quiet GCC */
|
||||
GtkTextUnit seen;
|
||||
GtkTextUnit delta_height = 0;
|
||||
GtkTextUnit first_line_y = 0; /* Quiet GCC */
|
||||
GtkTextUnit last_line_y = 0; /* Quiet GCC */
|
||||
|
||||
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
|
||||
|
||||
@@ -930,8 +931,8 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
|
||||
GtkTextLineData *line_data = _gtk_text_line_get_data (line, layout);
|
||||
if (!line_data || !line_data->valid)
|
||||
{
|
||||
int old_height, new_height;
|
||||
int top_ink, bottom_ink;
|
||||
GtkTextUnit old_height, new_height;
|
||||
GtkTextUnit top_ink, bottom_ink;
|
||||
|
||||
old_height = line_data ? line_data->height : 0;
|
||||
top_ink = line_data ? line_data->top_ink : 0;
|
||||
@@ -971,8 +972,8 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
|
||||
GtkTextLineData *line_data = _gtk_text_line_get_data (line, layout);
|
||||
if (!line_data || !line_data->valid)
|
||||
{
|
||||
int old_height, new_height;
|
||||
int top_ink, bottom_ink;
|
||||
GtkTextUnit old_height, new_height;
|
||||
GtkTextUnit top_ink, bottom_ink;
|
||||
|
||||
old_height = line_data ? line_data->height : 0;
|
||||
top_ink = line_data ? line_data->top_ink : 0;
|
||||
@@ -1008,7 +1009,7 @@ gtk_text_layout_validate_yrange (GtkTextLayout *layout,
|
||||
*/
|
||||
if (first_line)
|
||||
{
|
||||
int line_top;
|
||||
GtkTextUnit line_top;
|
||||
|
||||
update_layout_size (layout);
|
||||
|
||||
@@ -1036,7 +1037,7 @@ gtk_text_layout_validate (GtkTextLayout *layout,
|
||||
int max_pixels)
|
||||
{
|
||||
GtkTextBTree *btree;
|
||||
int y, old_height, new_height;
|
||||
GtkTextUnit y, old_height, new_height;
|
||||
|
||||
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
|
||||
|
||||
@@ -1839,11 +1840,11 @@ add_child_attrs (GtkTextLayout *layout,
|
||||
*/
|
||||
static gboolean
|
||||
get_block_cursor (GtkTextLayout *layout,
|
||||
GtkTextLineDisplay *display,
|
||||
const GtkTextIter *insert_iter,
|
||||
int insert_index,
|
||||
GdkRectangle *pos,
|
||||
gboolean *cursor_at_line_end)
|
||||
GtkTextLineDisplay *display,
|
||||
const GtkTextIter *insert_iter,
|
||||
int insert_index,
|
||||
GtkTextRectangle *pos,
|
||||
gboolean *cursor_at_line_end)
|
||||
{
|
||||
PangoRectangle pango_pos;
|
||||
|
||||
@@ -2737,9 +2738,9 @@ line_display_index_to_iter (GtkTextLayout *layout,
|
||||
|
||||
static void
|
||||
get_line_at_y (GtkTextLayout *layout,
|
||||
int y,
|
||||
GtkTextUnit y,
|
||||
GtkTextLine **line,
|
||||
int *line_top)
|
||||
GtkTextUnit *line_top)
|
||||
{
|
||||
GtkTextBTree *btree = _gtk_text_buffer_get_btree (layout->buffer);
|
||||
|
||||
@@ -2772,8 +2773,8 @@ get_line_at_y (GtkTextLayout *layout,
|
||||
void
|
||||
gtk_text_layout_get_line_at_y (GtkTextLayout *layout,
|
||||
GtkTextIter *target_iter,
|
||||
int y,
|
||||
int *line_top)
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit *line_top)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
|
||||
@@ -2787,10 +2788,10 @@ gtk_text_layout_get_line_at_y (GtkTextLayout *layout,
|
||||
gboolean
|
||||
gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
|
||||
GtkTextIter *target_iter,
|
||||
int x,
|
||||
int y)
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y)
|
||||
{
|
||||
int trailing;
|
||||
GtkTextUnit trailing;
|
||||
gboolean inside;
|
||||
|
||||
inside = gtk_text_layout_get_iter_at_position (layout, target_iter, &trailing, x, y);
|
||||
@@ -2803,13 +2804,13 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
|
||||
gboolean
|
||||
gtk_text_layout_get_iter_at_position (GtkTextLayout *layout,
|
||||
GtkTextIter *target_iter,
|
||||
int *trailing,
|
||||
int x,
|
||||
int y)
|
||||
GtkTextUnit *trailing,
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
int byte_index;
|
||||
int line_top;
|
||||
GtkTextUnit line_top;
|
||||
GtkTextLineDisplay *display;
|
||||
gboolean inside;
|
||||
|
||||
@@ -2836,12 +2837,17 @@ gtk_text_layout_get_iter_at_position (GtkTextLayout *layout,
|
||||
}
|
||||
else
|
||||
{
|
||||
int out_trailing;
|
||||
|
||||
/* Ignore the "outside" return value from pango. Pango is doing
|
||||
* the right thing even if we are outside the layout in the
|
||||
* x-direction.
|
||||
*/
|
||||
inside = pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
|
||||
&byte_index, trailing);
|
||||
&byte_index, &out_trailing);
|
||||
|
||||
if (trailing)
|
||||
*trailing = out_trailing;
|
||||
}
|
||||
|
||||
line_display_index_to_iter (layout, display, target_iter, byte_index, 0);
|
||||
@@ -2869,10 +2875,10 @@ gtk_text_layout_get_iter_at_position (GtkTextLayout *layout,
|
||||
* direction of the paragraph are inserted.
|
||||
**/
|
||||
void
|
||||
gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
GdkRectangle *strong_pos,
|
||||
GdkRectangle *weak_pos)
|
||||
gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
GtkTextRectangle *strong_pos,
|
||||
GtkTextRectangle *weak_pos)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
GtkTextLineDisplay *display;
|
||||
@@ -2925,7 +2931,7 @@ gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
|
||||
/**
|
||||
* _gtk_text_layout_get_block_cursor:
|
||||
* @layout: a `GtkTextLayout`
|
||||
* @pos: a `GdkRectangle` to store block cursor position
|
||||
* @pos: a `GtkTextRectangle` to store block cursor position
|
||||
*
|
||||
* If layout is to display a block cursor, calculates its position
|
||||
* and returns %TRUE. Otherwise it returns %FALSE. In case when
|
||||
@@ -2934,13 +2940,13 @@ gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
|
||||
* (see get_block_cursor()).
|
||||
**/
|
||||
gboolean
|
||||
_gtk_text_layout_get_block_cursor (GtkTextLayout *layout,
|
||||
GdkRectangle *pos)
|
||||
_gtk_text_layout_get_block_cursor (GtkTextLayout *layout,
|
||||
GtkTextRectangle *pos)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
GtkTextLineDisplay *display;
|
||||
GtkTextIter iter;
|
||||
GdkRectangle rect;
|
||||
GtkTextRectangle rect;
|
||||
gboolean block = FALSE;
|
||||
|
||||
g_return_val_if_fail (layout != NULL, FALSE);
|
||||
@@ -2963,7 +2969,7 @@ _gtk_text_layout_get_block_cursor (GtkTextLayout *layout,
|
||||
index = gtk_text_iter_get_line_index (&iter);
|
||||
|
||||
if (get_block_cursor (layout, display, &iter, index, &rect, NULL))
|
||||
block = TRUE;
|
||||
block = TRUE;
|
||||
}
|
||||
|
||||
if (block && pos)
|
||||
@@ -2971,7 +2977,7 @@ _gtk_text_layout_get_block_cursor (GtkTextLayout *layout,
|
||||
int line_top;
|
||||
|
||||
line_top = _gtk_text_btree_find_line_top (_gtk_text_buffer_get_btree (layout->buffer),
|
||||
line, layout);
|
||||
line, layout);
|
||||
|
||||
*pos = rect;
|
||||
pos->x += display->x_offset;
|
||||
@@ -2996,8 +3002,8 @@ _gtk_text_layout_get_block_cursor (GtkTextLayout *layout,
|
||||
void
|
||||
gtk_text_layout_get_line_yrange (GtkTextLayout *layout,
|
||||
const GtkTextIter *iter,
|
||||
int *y,
|
||||
int *height)
|
||||
GtkTextUnit *y,
|
||||
GtkTextUnit *height)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
|
||||
@@ -3022,14 +3028,14 @@ gtk_text_layout_get_line_yrange (GtkTextLayout *layout,
|
||||
void
|
||||
gtk_text_layout_get_iter_location (GtkTextLayout *layout,
|
||||
const GtkTextIter *iter,
|
||||
GdkRectangle *rect)
|
||||
GtkTextRectangle *rect)
|
||||
{
|
||||
PangoRectangle pango_rect;
|
||||
GtkTextLine *line;
|
||||
GtkTextBTree *tree;
|
||||
GtkTextLineDisplay *display;
|
||||
int byte_index;
|
||||
int x_offset;
|
||||
GtkTextUnit x_offset;
|
||||
|
||||
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
|
||||
g_return_if_fail (_gtk_text_iter_get_btree (iter) == _gtk_text_buffer_get_btree (layout->buffer));
|
||||
@@ -3065,12 +3071,12 @@ gtk_text_layout_get_iter_location (GtkTextLayout *layout,
|
||||
static void
|
||||
find_display_line_below (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int y)
|
||||
GtkTextUnit y)
|
||||
{
|
||||
GtkTextBTree *btree;
|
||||
GtkTextLine *line, *next;
|
||||
GtkTextLine *found_line = NULL;
|
||||
int line_top;
|
||||
GtkTextUnit line_top;
|
||||
int found_byte = 0;
|
||||
|
||||
btree = _gtk_text_buffer_get_btree (layout->buffer);
|
||||
@@ -3132,12 +3138,12 @@ find_display_line_below (GtkTextLayout *layout,
|
||||
static void
|
||||
find_display_line_above (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int y)
|
||||
GtkTextUnit y)
|
||||
{
|
||||
GtkTextBTree *btree;
|
||||
GtkTextLine *line;
|
||||
GtkTextLine *found_line = NULL;
|
||||
int line_top;
|
||||
GtkTextUnit line_top;
|
||||
int found_byte = 0;
|
||||
|
||||
btree = _gtk_text_buffer_get_btree (layout->buffer);
|
||||
@@ -3154,7 +3160,7 @@ find_display_line_above (GtkTextLayout *layout,
|
||||
GtkTextLineDisplay *display = gtk_text_layout_get_line_display (layout, line, FALSE);
|
||||
PangoRectangle logical_rect;
|
||||
PangoLayoutIter *layout_iter;
|
||||
int tmp_top;
|
||||
GtkTextUnit tmp_top;
|
||||
|
||||
layout_iter = pango_layout_get_iter (display->layout);
|
||||
|
||||
@@ -3215,10 +3221,10 @@ find_display_line_above (GtkTextLayout *layout,
|
||||
gboolean
|
||||
gtk_text_layout_clamp_iter_to_vrange (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int top,
|
||||
int bottom)
|
||||
GtkTextUnit top,
|
||||
GtkTextUnit bottom)
|
||||
{
|
||||
GdkRectangle iter_rect;
|
||||
GtkTextRectangle iter_rect;
|
||||
|
||||
gtk_text_layout_get_iter_location (layout, iter, &iter_rect);
|
||||
|
||||
@@ -3574,7 +3580,7 @@ gtk_text_layout_get_iter_at_line (GtkTextLayout *layout,
|
||||
void
|
||||
gtk_text_layout_move_iter_to_x (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int x)
|
||||
GtkTextUnit x)
|
||||
{
|
||||
GtkTextLine *line;
|
||||
GtkTextLineDisplay *display;
|
||||
@@ -4099,16 +4105,16 @@ snapshot_shape (PangoAttrShape *attr,
|
||||
}
|
||||
|
||||
void
|
||||
gtk_text_layout_snapshot (GtkTextLayout *layout,
|
||||
GtkWidget *widget,
|
||||
GtkSnapshot *snapshot,
|
||||
const GdkRectangle *clip,
|
||||
gboolean selection_style_changed,
|
||||
float cursor_alpha)
|
||||
gtk_text_layout_snapshot (GtkTextLayout *layout,
|
||||
GtkWidget *widget,
|
||||
GtkSnapshot *snapshot,
|
||||
const GtkTextRectangle *clip,
|
||||
gboolean selection_style_changed,
|
||||
float cursor_alpha)
|
||||
{
|
||||
GtkTextLayoutPrivate *priv;
|
||||
GskPangoRenderer *crenderer;
|
||||
int offset_y;
|
||||
GtkTextUnit offset_y;
|
||||
GtkTextIter selection_start, selection_end;
|
||||
int selection_start_line;
|
||||
int selection_end_line;
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtktextattributesprivate.h>
|
||||
#include <gtk/gtktexttypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -106,11 +107,11 @@ struct _GtkTextLayout
|
||||
|
||||
/* width of the display area on-screen,
|
||||
* i.e. pixels we should wrap to fit inside. */
|
||||
int screen_width;
|
||||
GtkTextUnit screen_width;
|
||||
|
||||
/* width/height of the total logical area being laid out */
|
||||
int width;
|
||||
int height;
|
||||
GtkTextUnit width;
|
||||
GtkTextUnit height;
|
||||
|
||||
int left_padding;
|
||||
int right_padding;
|
||||
@@ -189,13 +190,13 @@ struct _GtkTextLineDisplay
|
||||
|
||||
GtkTextDirection direction;
|
||||
|
||||
int width; /* Width of layout */
|
||||
int total_width; /* width - margins, if no width set on layout, if width set on layout, -1 */
|
||||
int height;
|
||||
GtkTextUnit width; /* Width of layout */
|
||||
GtkTextUnit total_width; /* width - margins, if no width set on layout, if width set on layout, -1 */
|
||||
GtkTextUnit height;
|
||||
/* Amount layout is shifted from left edge - this is the left margin
|
||||
* plus any other factors, such as alignment or indentation.
|
||||
*/
|
||||
int x_offset;
|
||||
GtkTextUnit x_offset;
|
||||
int left_margin;
|
||||
int right_margin;
|
||||
int top_margin;
|
||||
@@ -204,7 +205,7 @@ struct _GtkTextLineDisplay
|
||||
|
||||
GtkTextLine *line;
|
||||
|
||||
GdkRectangle block_cursor;
|
||||
GtkTextRectangle block_cursor;
|
||||
|
||||
guint cursors_invalid : 1;
|
||||
guint has_block_cursor : 1;
|
||||
@@ -240,7 +241,7 @@ void gtk_text_layout_set_keyboard_direction (GtkTextLayout *la
|
||||
void gtk_text_layout_default_style_changed (GtkTextLayout *layout);
|
||||
|
||||
void gtk_text_layout_set_screen_width (GtkTextLayout *layout,
|
||||
int width);
|
||||
GtkTextUnit width);
|
||||
void gtk_text_layout_set_preedit_string (GtkTextLayout *layout,
|
||||
const char *preedit_string,
|
||||
PangoAttrList *preedit_attrs,
|
||||
@@ -251,8 +252,8 @@ void gtk_text_layout_set_cursor_visible (GtkTextLayout *layout,
|
||||
gboolean gtk_text_layout_get_cursor_visible (GtkTextLayout *layout);
|
||||
|
||||
void gtk_text_layout_get_size (GtkTextLayout *layout,
|
||||
int *width,
|
||||
int *height);
|
||||
GtkTextUnit *width,
|
||||
GtkTextUnit *height);
|
||||
|
||||
void gtk_text_layout_wrap_loop_start (GtkTextLayout *layout);
|
||||
void gtk_text_layout_wrap_loop_end (GtkTextLayout *layout);
|
||||
@@ -269,17 +270,17 @@ int gtk_text_line_display_compare (const GtkTextLineDisplay
|
||||
|
||||
void gtk_text_layout_get_line_at_y (GtkTextLayout *layout,
|
||||
GtkTextIter *target_iter,
|
||||
int y,
|
||||
int *line_top);
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit *line_top);
|
||||
gboolean gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int x,
|
||||
int y);
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y);
|
||||
gboolean gtk_text_layout_get_iter_at_position (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int *trailing,
|
||||
int x,
|
||||
int y);
|
||||
GtkTextUnit *trailing,
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y);
|
||||
void gtk_text_layout_invalidate (GtkTextLayout *layout,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end);
|
||||
@@ -294,8 +295,8 @@ void gtk_text_layout_free_line_data (GtkTextLayout *layout,
|
||||
gboolean gtk_text_layout_is_valid (GtkTextLayout *layout);
|
||||
void gtk_text_layout_validate_yrange (GtkTextLayout *layout,
|
||||
GtkTextIter *anchor_line,
|
||||
int y0_,
|
||||
int y1_);
|
||||
GtkTextUnit y0_,
|
||||
GtkTextUnit y1_);
|
||||
void gtk_text_layout_validate (GtkTextLayout *layout,
|
||||
int max_pixels);
|
||||
|
||||
@@ -303,24 +304,24 @@ GtkTextLineData* gtk_text_layout_wrap (GtkTextLayout *layout,
|
||||
GtkTextLine *line,
|
||||
GtkTextLineData *line_data);
|
||||
void gtk_text_layout_changed (GtkTextLayout *layout,
|
||||
int y,
|
||||
int old_height,
|
||||
int new_height);
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit old_height,
|
||||
GtkTextUnit new_height);
|
||||
void gtk_text_layout_cursors_changed (GtkTextLayout *layout,
|
||||
int y,
|
||||
int old_height,
|
||||
int new_height);
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit old_height,
|
||||
GtkTextUnit new_height);
|
||||
void gtk_text_layout_get_iter_location (GtkTextLayout *layout,
|
||||
const GtkTextIter *iter,
|
||||
GdkRectangle *rect);
|
||||
GtkTextRectangle *rect);
|
||||
void gtk_text_layout_get_line_yrange (GtkTextLayout *layout,
|
||||
const GtkTextIter *iter,
|
||||
int *y,
|
||||
int *height);
|
||||
GtkTextUnit *y,
|
||||
GtkTextUnit *height);
|
||||
void gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
GdkRectangle *strong_pos,
|
||||
GdkRectangle *weak_pos);
|
||||
GtkTextRectangle *strong_pos,
|
||||
GtkTextRectangle *weak_pos);
|
||||
GtkTextLineDisplay *gtk_text_layout_create_display (GtkTextLayout *layout,
|
||||
GtkTextLine *line,
|
||||
gboolean size_only);
|
||||
@@ -330,11 +331,11 @@ void gtk_text_layout_update_display_cursors (GtkTextLayout *layout,
|
||||
void gtk_text_layout_update_children (GtkTextLayout *layout,
|
||||
GtkTextLineDisplay *display);
|
||||
gboolean _gtk_text_layout_get_block_cursor (GtkTextLayout *layout,
|
||||
GdkRectangle *pos);
|
||||
GtkTextRectangle *pos);
|
||||
gboolean gtk_text_layout_clamp_iter_to_vrange (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int top,
|
||||
int bottom);
|
||||
GtkTextUnit top,
|
||||
GtkTextUnit bottom);
|
||||
|
||||
gboolean gtk_text_layout_move_iter_to_line_end (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
@@ -345,7 +346,7 @@ gboolean gtk_text_layout_move_iter_to_next_line (GtkTextLayout *layout,
|
||||
GtkTextIter *iter);
|
||||
void gtk_text_layout_move_iter_to_x (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int x);
|
||||
GtkTextUnit x);
|
||||
gboolean gtk_text_layout_move_iter_visually (GtkTextLayout *layout,
|
||||
GtkTextIter *iter,
|
||||
int count);
|
||||
@@ -372,12 +373,12 @@ void gtk_text_anchored_child_set_layout (GtkWidget *child,
|
||||
|
||||
void gtk_text_layout_spew (GtkTextLayout *layout);
|
||||
|
||||
void gtk_text_layout_snapshot (GtkTextLayout *layout,
|
||||
GtkWidget *widget,
|
||||
GtkSnapshot *snapshot,
|
||||
const GdkRectangle *clip,
|
||||
gboolean selection_style_changed,
|
||||
float cursor_alpha);
|
||||
void gtk_text_layout_snapshot (GtkTextLayout *layout,
|
||||
GtkWidget *widget,
|
||||
GtkSnapshot *snapshot,
|
||||
const GtkTextRectangle *clip,
|
||||
gboolean selection_style_changed,
|
||||
float cursor_alpha);
|
||||
|
||||
void gtk_text_layout_set_mru_size (GtkTextLayout *layout,
|
||||
guint mru_size);
|
||||
|
||||
46
gtk/gtktexttypes.h
Normal file
46
gtk/gtktexttypes.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* gtktexttypes.h
|
||||
*
|
||||
* Copyright 2023 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 2.1 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef __GTK_TEXT_TYPES_H__
|
||||
#define __GTK_TEXT_TYPES_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
# error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_TEXT_UNIT G_TYPE_DOUBLE
|
||||
|
||||
typedef double GtkTextUnit;
|
||||
|
||||
typedef struct _GtkTextRectangle
|
||||
{
|
||||
GtkTextUnit x;
|
||||
GtkTextUnit y;
|
||||
GtkTextUnit width;
|
||||
GtkTextUnit height;
|
||||
} GtkTextRectangle;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_TEXT_TYPES_H__ */
|
||||
@@ -209,7 +209,7 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
GtkSnapshot *snapshot;
|
||||
int layout_width, layout_height;
|
||||
GtkTextUnit layout_width, layout_height;
|
||||
GtkTextBuffer *new_buffer;
|
||||
GtkTextLayout *layout;
|
||||
GtkTextAttributes *style;
|
||||
@@ -286,7 +286,7 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
|
||||
gtk_css_style_snapshot_background (&boxes, snapshot);
|
||||
}
|
||||
|
||||
gtk_text_layout_snapshot (layout, widget, snapshot, &(GdkRectangle) { 0, 0, layout_width, layout_height }, FALSE, 1.0);
|
||||
gtk_text_layout_snapshot (layout, widget, snapshot, &(GtkTextRectangle) { 0, 0, layout_width, layout_height }, FALSE, 1.0);
|
||||
|
||||
g_object_unref (layout);
|
||||
g_object_unref (new_buffer);
|
||||
|
||||
@@ -187,6 +187,8 @@
|
||||
#define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->priv->text_window)
|
||||
#define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->priv->text_window)
|
||||
|
||||
#define RECT_TO_GDK(r) (GdkRectangle){(r)->x,(r)->y,(r)->width,(r)->height}
|
||||
|
||||
#define SPACE_FOR_CURSOR 1
|
||||
|
||||
typedef struct _GtkTextWindow GtkTextWindow;
|
||||
@@ -208,8 +210,8 @@ struct _GtkTextViewPrivate
|
||||
guint im_spot_idle;
|
||||
char *im_module;
|
||||
|
||||
int dnd_x;
|
||||
int dnd_y;
|
||||
GtkTextUnit dnd_x;
|
||||
GtkTextUnit dnd_y;
|
||||
|
||||
GtkTextHandle *text_handles[TEXT_HANDLE_N_HANDLES];
|
||||
GtkWidget *selection_bubble;
|
||||
@@ -235,16 +237,16 @@ struct _GtkTextViewPrivate
|
||||
/* X offset between widget coordinates and buffer coordinates
|
||||
* taking left_padding in account
|
||||
*/
|
||||
int xoffset;
|
||||
GtkTextUnit xoffset;
|
||||
|
||||
/* Y offset between widget coordinates and buffer coordinates
|
||||
* taking top_padding and top_margin in account
|
||||
*/
|
||||
int yoffset;
|
||||
GtkTextUnit yoffset;
|
||||
|
||||
/* Width and height of the buffer */
|
||||
int width;
|
||||
int height;
|
||||
GtkTextUnit width;
|
||||
GtkTextUnit height;
|
||||
|
||||
/* The virtual cursor position is normally the same as the
|
||||
* actual (strong) cursor position, except in two circumstances:
|
||||
@@ -259,7 +261,7 @@ struct _GtkTextViewPrivate
|
||||
int virtual_cursor_y; /* -1 means use actual cursor position */
|
||||
|
||||
GtkTextMark *first_para_mark; /* Mark at the beginning of the first onscreen paragraph */
|
||||
int first_para_pixels; /* Offset of top of screen in the first onscreen paragraph */
|
||||
GtkTextUnit first_para_pixels; /* Offset of top of screen in the first onscreen paragraph */
|
||||
|
||||
guint64 blink_start_time;
|
||||
guint blink_tick;
|
||||
@@ -551,8 +553,8 @@ static gboolean gtk_text_view_end_selection_drag (GtkTextView *text_v
|
||||
static void gtk_text_view_start_selection_dnd (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
GdkEvent *event,
|
||||
int x,
|
||||
int y);
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y);
|
||||
static void gtk_text_view_check_cursor_blink (GtkTextView *text_view);
|
||||
static void gtk_text_view_pend_cursor_blink (GtkTextView *text_view);
|
||||
static void gtk_text_view_stop_cursor_blink (GtkTextView *text_view);
|
||||
@@ -602,11 +604,11 @@ static void gtk_text_view_buffer_notify_undo (GtkTextBuffer *buffer,
|
||||
GtkTextView *view);
|
||||
static void gtk_text_view_get_virtual_cursor_pos (GtkTextView *text_view,
|
||||
GtkTextIter *cursor,
|
||||
int *x,
|
||||
int *y);
|
||||
GtkTextUnit *x,
|
||||
GtkTextUnit *y);
|
||||
static void gtk_text_view_set_virtual_cursor_pos (GtkTextView *text_view,
|
||||
int x,
|
||||
int y);
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y);
|
||||
|
||||
static void gtk_text_view_do_popup (GtkTextView *text_view,
|
||||
GdkEvent *event);
|
||||
@@ -764,6 +766,45 @@ check_scroll (double offset, GtkAdjustment *adjustment)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
rectangle_intersect (GtkTextRectangle *src1,
|
||||
GtkTextRectangle *src2,
|
||||
GtkTextRectangle *dest)
|
||||
{
|
||||
GtkTextUnit dest_x, dest_y;
|
||||
GtkTextUnit dest_x2, dest_y2;
|
||||
int return_val;
|
||||
|
||||
g_return_val_if_fail (src1 != NULL, FALSE);
|
||||
g_return_val_if_fail (src2 != NULL, FALSE);
|
||||
|
||||
return_val = FALSE;
|
||||
|
||||
dest_x = MAX (src1->x, src2->x);
|
||||
dest_y = MAX (src1->y, src2->y);
|
||||
dest_x2 = MIN (src1->x + src1->width, src2->x + src2->width);
|
||||
dest_y2 = MIN (src1->y + src1->height, src2->y + src2->height);
|
||||
|
||||
if (dest_x2 > dest_x && dest_y2 > dest_y)
|
||||
{
|
||||
if (dest)
|
||||
{
|
||||
dest->x = dest_x;
|
||||
dest->y = dest_y;
|
||||
dest->width = dest_x2 - dest_x;
|
||||
dest->height = dest_y2 - dest_y;
|
||||
}
|
||||
return_val = TRUE;
|
||||
}
|
||||
else if (dest)
|
||||
{
|
||||
dest->width = 0;
|
||||
dest->height = 0;
|
||||
}
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_text_view_drop_motion_scroll_timeout (gpointer data)
|
||||
{
|
||||
@@ -2472,8 +2513,8 @@ gtk_text_view_get_buffer (GtkTextView *text_view)
|
||||
void
|
||||
gtk_text_view_get_cursor_locations (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
GdkRectangle *strong,
|
||||
GdkRectangle *weak)
|
||||
GtkTextRectangle *strong,
|
||||
GtkTextRectangle *weak)
|
||||
{
|
||||
GtkTextIter insert;
|
||||
|
||||
@@ -2512,8 +2553,8 @@ gtk_text_view_get_cursor_locations (GtkTextView *text_view,
|
||||
gboolean
|
||||
gtk_text_view_get_iter_at_location (GtkTextView *text_view,
|
||||
GtkTextIter *iter,
|
||||
int x,
|
||||
int y)
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), FALSE);
|
||||
g_return_val_if_fail (iter != NULL, FALSE);
|
||||
@@ -2550,9 +2591,9 @@ gtk_text_view_get_iter_at_location (GtkTextView *text_view,
|
||||
gboolean
|
||||
gtk_text_view_get_iter_at_position (GtkTextView *text_view,
|
||||
GtkTextIter *iter,
|
||||
int *trailing,
|
||||
int x,
|
||||
int y)
|
||||
GtkTextUnit *trailing,
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), FALSE);
|
||||
g_return_val_if_fail (iter != NULL, FALSE);
|
||||
@@ -2577,7 +2618,7 @@ gtk_text_view_get_iter_at_position (GtkTextView *text_view,
|
||||
void
|
||||
gtk_text_view_get_iter_location (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
GdkRectangle *location)
|
||||
GtkTextRectangle *location)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
|
||||
g_return_if_fail (gtk_text_iter_get_buffer (iter) == get_buffer (text_view));
|
||||
@@ -2603,8 +2644,8 @@ gtk_text_view_get_iter_location (GtkTextView *text_view,
|
||||
void
|
||||
gtk_text_view_get_line_yrange (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
int *y,
|
||||
int *height)
|
||||
GtkTextUnit *y,
|
||||
GtkTextUnit *height)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
|
||||
g_return_if_fail (gtk_text_iter_get_buffer (iter) == get_buffer (text_view));
|
||||
@@ -2635,8 +2676,8 @@ gtk_text_view_get_line_yrange (GtkTextView *text_view,
|
||||
void
|
||||
gtk_text_view_get_line_at_y (GtkTextView *text_view,
|
||||
GtkTextIter *target_iter,
|
||||
int y,
|
||||
int *line_top)
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit *line_top)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
|
||||
|
||||
@@ -2667,25 +2708,25 @@ _gtk_text_view_scroll_to_iter (GtkTextView *text_view,
|
||||
GtkTextViewPrivate *priv = text_view->priv;
|
||||
GtkWidget *widget;
|
||||
|
||||
GdkRectangle cursor;
|
||||
int cursor_bottom;
|
||||
int cursor_right;
|
||||
GtkTextRectangle cursor;
|
||||
GtkTextUnit cursor_bottom;
|
||||
GtkTextUnit cursor_right;
|
||||
|
||||
GdkRectangle screen;
|
||||
GdkRectangle screen_dest;
|
||||
GtkTextRectangle screen;
|
||||
GtkTextRectangle screen_dest;
|
||||
|
||||
int screen_inner_left;
|
||||
int screen_inner_right;
|
||||
int screen_inner_top;
|
||||
int screen_inner_bottom;
|
||||
GtkTextUnit screen_inner_left;
|
||||
GtkTextUnit screen_inner_right;
|
||||
GtkTextUnit screen_inner_top;
|
||||
GtkTextUnit screen_inner_bottom;
|
||||
|
||||
int border_xoffset = 0;
|
||||
int border_yoffset = 0;
|
||||
int within_margin_xoffset;
|
||||
int within_margin_yoffset;
|
||||
GtkTextUnit border_xoffset = 0;
|
||||
GtkTextUnit border_yoffset = 0;
|
||||
GtkTextUnit within_margin_xoffset;
|
||||
GtkTextUnit within_margin_yoffset;
|
||||
|
||||
int buffer_bottom;
|
||||
int buffer_right;
|
||||
GtkTextUnit buffer_bottom;
|
||||
GtkTextUnit buffer_right;
|
||||
|
||||
gboolean retval = FALSE;
|
||||
|
||||
@@ -2823,7 +2864,7 @@ _gtk_text_view_scroll_to_iter (GtkTextView *text_view,
|
||||
|
||||
if (use_align)
|
||||
{
|
||||
int cursor_x_alignment_offset;
|
||||
GtkTextUnit cursor_x_alignment_offset;
|
||||
|
||||
cursor_x_alignment_offset = (cursor.width * xalign) - (screen_dest.width * xalign);
|
||||
screen_dest.x = cursor.x + cursor_x_alignment_offset - within_margin_xoffset;
|
||||
@@ -2966,7 +3007,7 @@ gtk_text_view_queue_scroll (GtkTextView *text_view,
|
||||
static gboolean
|
||||
gtk_text_view_flush_scroll (GtkTextView *text_view)
|
||||
{
|
||||
int height;
|
||||
GtkTextUnit height;
|
||||
GtkTextIter iter;
|
||||
GtkTextPendingScroll *scroll;
|
||||
gboolean retval;
|
||||
@@ -3026,7 +3067,7 @@ static void
|
||||
gtk_text_view_update_adjustments (GtkTextView *text_view)
|
||||
{
|
||||
GtkTextViewPrivate *priv;
|
||||
int width = 0, height = 0;
|
||||
GtkTextUnit width = 0, height = 0;
|
||||
|
||||
DV(g_print(">Updating adjustments ("G_STRLOC")\n"));
|
||||
|
||||
@@ -3063,7 +3104,7 @@ gtk_text_view_update_layout_width (GtkTextView *text_view)
|
||||
static void
|
||||
gtk_text_view_update_im_spot_location (GtkTextView *text_view)
|
||||
{
|
||||
GdkRectangle area;
|
||||
GtkTextRectangle area;
|
||||
|
||||
if (text_view->priv->layout == NULL)
|
||||
return;
|
||||
@@ -3078,7 +3119,7 @@ gtk_text_view_update_im_spot_location (GtkTextView *text_view)
|
||||
*/
|
||||
area.width = 0;
|
||||
|
||||
gtk_im_context_set_cursor_location (text_view->priv->im_context, &area);
|
||||
gtk_im_context_set_cursor_location (text_view->priv->im_context, &RECT_TO_GDK (&area));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -3205,7 +3246,7 @@ gtk_text_view_scroll_mark_onscreen (GtkTextView *text_view,
|
||||
static gboolean
|
||||
clamp_iter_onscreen (GtkTextView *text_view, GtkTextIter *iter)
|
||||
{
|
||||
GdkRectangle visible_rect;
|
||||
GtkTextRectangle visible_rect;
|
||||
gtk_text_view_get_visible_rect (text_view, &visible_rect);
|
||||
|
||||
return gtk_text_layout_clamp_iter_to_vrange (text_view->priv->layout, iter,
|
||||
@@ -3255,8 +3296,8 @@ gtk_text_view_move_mark_onscreen (GtkTextView *text_view,
|
||||
* [method@Gtk.TextView.buffer_to_window_coords].
|
||||
*/
|
||||
void
|
||||
gtk_text_view_get_visible_rect (GtkTextView *text_view,
|
||||
GdkRectangle *visible_rect)
|
||||
gtk_text_view_get_visible_rect (GtkTextView *text_view,
|
||||
GtkTextRectangle *visible_rect)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
@@ -3271,11 +3312,11 @@ gtk_text_view_get_visible_rect (GtkTextView *text_view,
|
||||
visible_rect->width = SCREEN_WIDTH (widget);
|
||||
visible_rect->height = SCREEN_HEIGHT (widget);
|
||||
|
||||
DV(g_print(" visible rect: %d,%d %d x %d\n",
|
||||
visible_rect->x,
|
||||
visible_rect->y,
|
||||
visible_rect->width,
|
||||
visible_rect->height));
|
||||
g_print(" visible rect: %lf,%lf %lf x %lf\n",
|
||||
visible_rect->x,
|
||||
visible_rect->y,
|
||||
visible_rect->width,
|
||||
visible_rect->height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4489,7 +4530,7 @@ gtk_text_view_compute_child_allocation (GtkTextView *text_view,
|
||||
int gutter_width,
|
||||
int gutter_height)
|
||||
{
|
||||
int buffer_y;
|
||||
GtkTextUnit buffer_y;
|
||||
GtkTextIter iter;
|
||||
GtkRequisition req;
|
||||
|
||||
@@ -5070,15 +5111,18 @@ invalidated_handler (GtkTextLayout *layout,
|
||||
|
||||
static void
|
||||
changed_handler (GtkTextLayout *layout,
|
||||
int start_y,
|
||||
int old_height,
|
||||
int new_height,
|
||||
GtkTextUnit start_y,
|
||||
GtkTextUnit old_height,
|
||||
GtkTextUnit new_height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTextView *text_view;
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkWidget *widget;
|
||||
|
||||
g_assert (GTK_IS_TEXT_LAYOUT (layout));
|
||||
g_assert (GTK_IS_TEXT_VIEW (data));
|
||||
|
||||
text_view = GTK_TEXT_VIEW (data);
|
||||
priv = text_view->priv;
|
||||
widget = GTK_WIDGET (data);
|
||||
@@ -5096,8 +5140,8 @@ changed_handler (GtkTextLayout *layout,
|
||||
{
|
||||
const GList *iter;
|
||||
GtkTextIter first;
|
||||
int new_first_para_top;
|
||||
int old_first_para_top;
|
||||
GtkTextUnit new_first_para_top;
|
||||
GtkTextUnit old_first_para_top;
|
||||
int x_offset = 0;
|
||||
int y_offset = 0;
|
||||
|
||||
@@ -5354,8 +5398,8 @@ gtk_text_view_unobscure_mouse_cursor (GtkTextView *text_view)
|
||||
|
||||
static void
|
||||
_text_window_to_widget_coords (GtkTextView *text_view,
|
||||
int *x,
|
||||
int *y)
|
||||
GtkTextUnit *x,
|
||||
GtkTextUnit *y)
|
||||
{
|
||||
GtkTextViewPrivate *priv = text_view->priv;
|
||||
|
||||
@@ -5365,8 +5409,8 @@ _text_window_to_widget_coords (GtkTextView *text_view,
|
||||
|
||||
static void
|
||||
_widget_to_text_surface_coords (GtkTextView *text_view,
|
||||
int *x,
|
||||
int *y)
|
||||
GtkTextUnit *x,
|
||||
GtkTextUnit *y)
|
||||
{
|
||||
GtkTextViewPrivate *priv = text_view->priv;
|
||||
|
||||
@@ -5380,8 +5424,8 @@ gtk_text_view_set_handle_position (GtkTextView *text_view,
|
||||
GtkTextIter *iter)
|
||||
{
|
||||
GtkTextViewPrivate *priv;
|
||||
GdkRectangle rect;
|
||||
int x, y;
|
||||
GtkTextRectangle rect;
|
||||
GtkTextUnit x, y;
|
||||
|
||||
priv = text_view->priv;
|
||||
gtk_text_view_get_cursor_locations (text_view, iter, &rect, NULL);
|
||||
@@ -5409,7 +5453,7 @@ gtk_text_view_set_handle_position (GtkTextView *text_view,
|
||||
rect.y = CLAMP (y, 0, SCREEN_HEIGHT (text_view));
|
||||
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
|
||||
|
||||
gtk_text_handle_set_position (handle, &rect);
|
||||
gtk_text_handle_set_position (handle, &RECT_TO_GDK (&rect));
|
||||
|
||||
if (gtk_text_iter_get_attributes (iter, &attributes))
|
||||
dir = attributes.direction;
|
||||
@@ -5421,11 +5465,11 @@ gtk_text_view_set_handle_position (GtkTextView *text_view,
|
||||
static void
|
||||
gtk_text_view_show_magnifier (GtkTextView *text_view,
|
||||
GtkTextIter *iter,
|
||||
int x,
|
||||
int y)
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y)
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkTextRectangle rect;
|
||||
GtkRequisition req;
|
||||
|
||||
#define N_LINES 1
|
||||
@@ -5434,8 +5478,7 @@ gtk_text_view_show_magnifier (GtkTextView *text_view,
|
||||
_gtk_text_view_ensure_magnifier (text_view);
|
||||
|
||||
/* Set size/content depending on iter rect */
|
||||
gtk_text_view_get_iter_location (text_view, iter,
|
||||
(GdkRectangle *) &rect);
|
||||
gtk_text_view_get_iter_location (text_view, iter, &rect);
|
||||
rect.x = x + priv->xoffset;
|
||||
gtk_text_view_buffer_to_window_coords (text_view, GTK_TEXT_WINDOW_TEXT,
|
||||
rect.x, rect.y, &rect.x, &rect.y);
|
||||
@@ -5451,7 +5494,14 @@ gtk_text_view_show_magnifier (GtkTextView *text_view,
|
||||
rect.x = CLAMP (rect.x, 0, gtk_widget_get_width (GTK_WIDGET (text_view)));
|
||||
rect.y += rect.height / 4;
|
||||
rect.height -= rect.height / 4;
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->magnifier_popover), &rect);
|
||||
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->magnifier_popover),
|
||||
&(GdkRectangle) {
|
||||
rect.x,
|
||||
rect.y,
|
||||
rect.width,
|
||||
rect.height
|
||||
});
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (priv->magnifier_popover));
|
||||
|
||||
@@ -5460,13 +5510,14 @@ gtk_text_view_show_magnifier (GtkTextView *text_view,
|
||||
|
||||
static void
|
||||
gtk_text_view_handle_dragged (GtkTextHandle *handle,
|
||||
int x,
|
||||
int y,
|
||||
int handle_x,
|
||||
int handle_y,
|
||||
GtkTextView *text_view)
|
||||
{
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkTextIter cursor, bound, iter, *old_iter;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextUnit x = handle_x, y = handle_y;
|
||||
|
||||
priv = text_view->priv;
|
||||
buffer = get_buffer (text_view);
|
||||
@@ -5722,12 +5773,12 @@ static gboolean
|
||||
get_iter_from_gesture (GtkTextView *text_view,
|
||||
GtkGesture *gesture,
|
||||
GtkTextIter *iter,
|
||||
int *x,
|
||||
int *y)
|
||||
GtkTextUnit *x,
|
||||
GtkTextUnit *y)
|
||||
{
|
||||
GdkEventSequence *sequence;
|
||||
GtkTextViewPrivate *priv;
|
||||
int xcoord, ycoord;
|
||||
GtkTextUnit xcoord, ycoord;
|
||||
double px, py;
|
||||
|
||||
priv = text_view->priv;
|
||||
@@ -6057,7 +6108,7 @@ gtk_text_view_paint (GtkWidget *widget,
|
||||
gtk_text_layout_snapshot (priv->layout,
|
||||
widget,
|
||||
snapshot,
|
||||
&(GdkRectangle) {
|
||||
&(GtkTextRectangle) {
|
||||
priv->xoffset,
|
||||
priv->yoffset,
|
||||
gtk_widget_get_width (widget),
|
||||
@@ -6536,7 +6587,7 @@ gtk_text_view_move_cursor (GtkTextView *text_view,
|
||||
GtkTextIter insert;
|
||||
GtkTextIter newplace;
|
||||
gboolean cancel_selection = FALSE;
|
||||
int cursor_x_pos = 0;
|
||||
GtkTextUnit cursor_x_pos = 0;
|
||||
GtkDirectionType leave_direction = -1;
|
||||
|
||||
priv = text_view->priv;
|
||||
@@ -6850,14 +6901,14 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
|
||||
{
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkAdjustment *adjustment;
|
||||
int cursor_x_pos, cursor_y_pos;
|
||||
GtkTextUnit cursor_x_pos, cursor_y_pos;
|
||||
GtkTextMark *insert_mark;
|
||||
GtkTextIter old_insert;
|
||||
GtkTextIter new_insert;
|
||||
GtkTextIter anchor;
|
||||
double newval;
|
||||
double oldval;
|
||||
int y0, y1;
|
||||
GtkTextUnit y0, y1;
|
||||
|
||||
priv = text_view->priv;
|
||||
|
||||
@@ -6943,13 +6994,13 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
|
||||
{
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkAdjustment *adjustment;
|
||||
int cursor_x_pos, cursor_y_pos;
|
||||
GtkTextUnit cursor_x_pos, cursor_y_pos;
|
||||
GtkTextMark *insert_mark;
|
||||
GtkTextIter old_insert;
|
||||
GtkTextIter new_insert;
|
||||
double newval;
|
||||
double oldval;
|
||||
int y, height;
|
||||
GtkTextUnit y, height;
|
||||
|
||||
priv = text_view->priv;
|
||||
|
||||
@@ -7660,10 +7711,10 @@ selection_data_free (SelectionData *data)
|
||||
static gboolean
|
||||
drag_gesture_get_text_surface_coords (GtkGestureDrag *gesture,
|
||||
GtkTextView *text_view,
|
||||
int *start_x,
|
||||
int *start_y,
|
||||
int *x,
|
||||
int *y)
|
||||
GtkTextUnit *start_x,
|
||||
GtkTextUnit *start_y,
|
||||
GtkTextUnit *x,
|
||||
GtkTextUnit *y)
|
||||
{
|
||||
double sx, sy, ox, oy;
|
||||
|
||||
@@ -7688,7 +7739,7 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture,
|
||||
double offset_y,
|
||||
GtkTextView *text_view)
|
||||
{
|
||||
int start_x, start_y, x, y;
|
||||
GtkTextUnit start_x, start_y, x, y;
|
||||
GdkEventSequence *sequence;
|
||||
gboolean is_touchscreen;
|
||||
GdkEvent *event;
|
||||
@@ -7724,7 +7775,7 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture,
|
||||
if (!is_touchscreen)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
int buffer_x, buffer_y;
|
||||
GtkTextUnit buffer_x, buffer_y;
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (text_view,
|
||||
GTK_TEXT_WINDOW_TEXT,
|
||||
@@ -7817,7 +7868,7 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
|
||||
GtkTextView *text_view)
|
||||
{
|
||||
gboolean is_touchscreen, clicked_in_selection;
|
||||
int start_x, start_y, x, y;
|
||||
GtkTextUnit start_x, start_y, x, y;
|
||||
GdkEventSequence *sequence;
|
||||
GtkTextViewPrivate *priv;
|
||||
GdkEvent *event;
|
||||
@@ -8386,8 +8437,8 @@ static void
|
||||
gtk_text_view_start_selection_dnd (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
GdkEvent *event,
|
||||
int x,
|
||||
int y)
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (text_view);
|
||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view);
|
||||
@@ -8449,7 +8500,7 @@ gtk_text_view_drag_motion (GtkDropTarget *dest,
|
||||
GtkTextIter newplace;
|
||||
GtkTextIter start;
|
||||
GtkTextIter end;
|
||||
int bx, by;
|
||||
GtkTextUnit bx, by;
|
||||
gboolean can_accept = FALSE;
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (text_view,
|
||||
@@ -8610,7 +8661,7 @@ gtk_text_view_set_vadjustment_values (GtkTextView *text_view)
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkTextIter first_para;
|
||||
int screen_height;
|
||||
int y;
|
||||
GtkTextUnit y;
|
||||
double old_value;
|
||||
double new_value;
|
||||
double new_upper;
|
||||
@@ -8648,9 +8699,9 @@ gtk_text_view_value_changed (GtkAdjustment *adjustment,
|
||||
{
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkTextIter iter;
|
||||
int line_top;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
GtkTextUnit line_top;
|
||||
GtkTextUnit dx = 0;
|
||||
GtkTextUnit dy = 0;
|
||||
|
||||
priv = text_view->priv;
|
||||
|
||||
@@ -8666,12 +8717,12 @@ gtk_text_view_value_changed (GtkAdjustment *adjustment,
|
||||
|
||||
if (adjustment == priv->hadjustment)
|
||||
{
|
||||
dx = priv->xoffset - (int)gtk_adjustment_get_value (adjustment);
|
||||
priv->xoffset = (int)gtk_adjustment_get_value (adjustment) - priv->left_padding;
|
||||
dx = priv->xoffset - gtk_adjustment_get_value (adjustment);
|
||||
priv->xoffset = gtk_adjustment_get_value (adjustment) - priv->left_padding;
|
||||
}
|
||||
else if (adjustment == priv->vadjustment)
|
||||
{
|
||||
dy = priv->yoffset - (int)gtk_adjustment_get_value (adjustment) + priv->top_margin ;
|
||||
dy = priv->yoffset - gtk_adjustment_get_value (adjustment) + priv->top_margin ;
|
||||
priv->yoffset -= dy;
|
||||
|
||||
if (priv->layout)
|
||||
@@ -9006,12 +9057,12 @@ gtk_text_view_mark_set_handler (GtkTextBuffer *buffer,
|
||||
static void
|
||||
gtk_text_view_get_virtual_cursor_pos (GtkTextView *text_view,
|
||||
GtkTextIter *cursor,
|
||||
int *x,
|
||||
int *y)
|
||||
GtkTextUnit *x,
|
||||
GtkTextUnit *y)
|
||||
{
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkTextIter insert;
|
||||
GdkRectangle pos;
|
||||
GtkTextRectangle pos;
|
||||
|
||||
priv = text_view->priv;
|
||||
|
||||
@@ -9044,10 +9095,10 @@ gtk_text_view_get_virtual_cursor_pos (GtkTextView *text_view,
|
||||
|
||||
static void
|
||||
gtk_text_view_set_virtual_cursor_pos (GtkTextView *text_view,
|
||||
int x,
|
||||
int y)
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y)
|
||||
{
|
||||
GdkRectangle pos;
|
||||
GtkTextRectangle pos;
|
||||
|
||||
if (!text_view->priv->layout)
|
||||
return;
|
||||
@@ -9314,7 +9365,7 @@ gtk_text_view_do_popup (GtkTextView *text_view,
|
||||
{
|
||||
GdkDevice *device;
|
||||
GdkSeat *seat;
|
||||
GdkRectangle rect = { 0, 0, 1, 1 };
|
||||
GtkTextRectangle rect = { 0, 0, 1, 1 };
|
||||
|
||||
device = gdk_event_get_device (trigger_event);
|
||||
seat = gdk_event_get_seat (trigger_event);
|
||||
@@ -9344,14 +9395,14 @@ gtk_text_view_do_popup (GtkTextView *text_view,
|
||||
rect.y = p.y;
|
||||
}
|
||||
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->popup_menu), &rect);
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->popup_menu), &RECT_TO_GDK (&rect));
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter;
|
||||
GdkRectangle iter_location;
|
||||
GdkRectangle visible_rect;
|
||||
GtkTextRectangle iter_location;
|
||||
GtkTextRectangle visible_rect;
|
||||
gboolean is_visible;
|
||||
|
||||
buffer = get_buffer (text_view);
|
||||
@@ -9374,7 +9425,7 @@ gtk_text_view_do_popup (GtkTextView *text_view,
|
||||
&iter_location.x,
|
||||
&iter_location.y);
|
||||
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->popup_menu), &iter_location);
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->popup_menu), &RECT_TO_GDK (&iter_location));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9391,12 +9442,12 @@ gtk_text_view_popup_menu (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
gtk_text_view_get_selection_rect (GtkTextView *text_view,
|
||||
cairo_rectangle_int_t *rect)
|
||||
cairo_rectangle_int_t *rect)
|
||||
{
|
||||
cairo_rectangle_int_t rect_cursor, rect_bound;
|
||||
GtkTextRectangle rect_cursor, rect_bound;
|
||||
GtkTextIter cursor, bound;
|
||||
GtkTextBuffer *buffer;
|
||||
int x1, y1, x2, y2;
|
||||
GtkTextUnit x1, y1, x2, y2;
|
||||
|
||||
buffer = get_buffer (text_view);
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &cursor,
|
||||
@@ -9507,6 +9558,7 @@ gtk_text_view_selection_bubble_popup_show (gpointer user_data)
|
||||
GtkWidget *box;
|
||||
GtkWidget *toolbar;
|
||||
GMenuModel *model;
|
||||
GtkTextUnit inout_x, inout_y;
|
||||
int i;
|
||||
|
||||
gtk_text_view_update_clipboard_actions (text_view);
|
||||
@@ -9544,10 +9596,13 @@ gtk_text_view_selection_bubble_popup_show (gpointer user_data)
|
||||
rect.x -= priv->xoffset;
|
||||
rect.y -= priv->yoffset;
|
||||
|
||||
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
|
||||
inout_x = rect.x;
|
||||
inout_y = rect.y;
|
||||
|
||||
rect.x -= 5;
|
||||
rect.y -= 5;
|
||||
_text_window_to_widget_coords (text_view, &inout_x, &inout_y);
|
||||
|
||||
rect.x = inout_x - 5;
|
||||
rect.y = inout_y - 5;
|
||||
rect.width += 10;
|
||||
rect.height += 10;
|
||||
|
||||
@@ -9712,10 +9767,10 @@ text_window_get_height (GtkTextWindow *win)
|
||||
void
|
||||
gtk_text_view_buffer_to_window_coords (GtkTextView *text_view,
|
||||
GtkTextWindowType win,
|
||||
int buffer_x,
|
||||
int buffer_y,
|
||||
int *window_x,
|
||||
int *window_y)
|
||||
GtkTextUnit buffer_x,
|
||||
GtkTextUnit buffer_y,
|
||||
GtkTextUnit *window_x,
|
||||
GtkTextUnit *window_y)
|
||||
{
|
||||
GtkTextViewPrivate *priv = text_view->priv;
|
||||
|
||||
@@ -9776,10 +9831,10 @@ gtk_text_view_buffer_to_window_coords (GtkTextView *text_view,
|
||||
void
|
||||
gtk_text_view_window_to_buffer_coords (GtkTextView *text_view,
|
||||
GtkTextWindowType win,
|
||||
int window_x,
|
||||
int window_y,
|
||||
int *buffer_x,
|
||||
int *buffer_y)
|
||||
GtkTextUnit window_x,
|
||||
GtkTextUnit window_y,
|
||||
GtkTextUnit *buffer_x,
|
||||
GtkTextUnit *buffer_y)
|
||||
{
|
||||
GtkTextViewPrivate *priv = text_view->priv;
|
||||
|
||||
@@ -10328,8 +10383,8 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
|
||||
{
|
||||
GtkWidget *chooser;
|
||||
GtkTextIter iter;
|
||||
GdkRectangle rect;
|
||||
GdkRectangle rect2;
|
||||
GtkTextRectangle rect;
|
||||
GtkTextRectangle rect2;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
if (gtk_widget_get_ancestor (GTK_WIDGET (text_view), GTK_TYPE_EMOJI_CHOOSER) != NULL)
|
||||
@@ -10351,7 +10406,7 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &iter,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
|
||||
gtk_text_view_get_iter_location (text_view, &iter, (GdkRectangle *) &rect);
|
||||
gtk_text_view_get_iter_location (text_view, &iter, &rect);
|
||||
|
||||
rect.width = MAX (rect.width, 1);
|
||||
rect.height = MAX (rect.height, 1);
|
||||
@@ -10364,7 +10419,7 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
|
||||
rect2.x, rect2.y, &rect2.x, &rect2.y);
|
||||
_text_window_to_widget_coords (text_view, &rect2.x, &rect2.y);
|
||||
|
||||
if (!gdk_rectangle_intersect (&rect2, &rect, &rect))
|
||||
if (!rectangle_intersect (&rect2, &rect, &rect))
|
||||
{
|
||||
rect.x = rect2.width / 2;
|
||||
rect.y = rect2.height / 2;
|
||||
@@ -10372,7 +10427,7 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
|
||||
rect.height = 0;
|
||||
}
|
||||
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (chooser), &rect);
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (chooser), &RECT_TO_GDK (&rect));
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (chooser));
|
||||
}
|
||||
@@ -10827,6 +10882,20 @@ gtk_text_view_accessible_text_get_default_attributes (GtkAccessibleText *self,
|
||||
g_hash_table_unref (attrs);
|
||||
}
|
||||
|
||||
static void
|
||||
union_region_rect (cairo_region_t *region,
|
||||
const GtkTextRectangle *rect)
|
||||
{
|
||||
const cairo_rectangle_int_t r = {
|
||||
rect->x,
|
||||
rect->y,
|
||||
rect->width,
|
||||
rect->height
|
||||
};
|
||||
|
||||
cairo_region_union_rectangle (region, &r);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_text_view_accessible_text_get_extents (GtkAccessibleText *self,
|
||||
unsigned int start,
|
||||
@@ -10836,7 +10905,9 @@ gtk_text_view_accessible_text_get_extents (GtkAccessibleText *self,
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
cairo_region_t *region;
|
||||
GdkRectangle rect;
|
||||
GtkTextRectangle rect;
|
||||
cairo_rectangle_int_t r;
|
||||
GtkTextUnit x, y;
|
||||
|
||||
buffer = get_buffer (GTK_TEXT_VIEW (self));
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start);
|
||||
@@ -10846,31 +10917,31 @@ gtk_text_view_accessible_text_get_extents (GtkAccessibleText *self,
|
||||
do
|
||||
{
|
||||
gtk_text_view_get_iter_location (GTK_TEXT_VIEW (self), &start_iter, &rect);
|
||||
cairo_region_union_rectangle (region, &rect);
|
||||
union_region_rect (region, &rect);
|
||||
|
||||
gtk_text_iter_forward_to_line_end (&start_iter);
|
||||
gtk_text_iter_order (&start_iter, &end_iter);
|
||||
|
||||
gtk_text_view_get_iter_location (GTK_TEXT_VIEW (self), &end_iter, &rect);
|
||||
cairo_region_union_rectangle (region, &rect);
|
||||
union_region_rect (region, &rect);
|
||||
|
||||
gtk_text_iter_forward_line (&start_iter);
|
||||
}
|
||||
while (gtk_text_iter_compare (&start_iter, &end_iter) < 0);
|
||||
|
||||
cairo_region_get_extents (region, &rect);
|
||||
cairo_region_get_extents (region, &r);
|
||||
cairo_region_destroy (region);
|
||||
|
||||
gtk_text_view_buffer_to_window_coords (GTK_TEXT_VIEW (self),
|
||||
GTK_TEXT_WINDOW_TEXT,
|
||||
rect.x, rect.y,
|
||||
&rect.x, &rect.y);
|
||||
_text_window_to_widget_coords (GTK_TEXT_VIEW (self), &rect.x, &rect.y);
|
||||
r.x, r.y,
|
||||
&x, &y);
|
||||
_text_window_to_widget_coords (GTK_TEXT_VIEW (self), &x, &y);
|
||||
|
||||
extents->origin.x = rect.x;
|
||||
extents->origin.y = rect.y;
|
||||
extents->size.width = rect.width;
|
||||
extents->size.height = rect.height;
|
||||
extents->origin.x = x;
|
||||
extents->origin.y = y;
|
||||
extents->size.width = r.width;
|
||||
extents->size.height = r.height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -10881,7 +10952,7 @@ gtk_text_view_accessible_text_get_offset (GtkAccessibleText *self,
|
||||
unsigned int *offset)
|
||||
{
|
||||
GtkTextView *text_view = GTK_TEXT_VIEW (self);
|
||||
int x, y;
|
||||
GtkTextUnit x, y;
|
||||
GtkTextIter iter;
|
||||
|
||||
x = point->x;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <gtk/gtkimcontext.h>
|
||||
#include <gtk/gtktextbuffer.h>
|
||||
#include <gtk/gtktexttypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -218,7 +219,7 @@ gboolean gtk_text_view_place_cursor_onscreen (GtkTextView *text_view);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_get_visible_rect (GtkTextView *text_view,
|
||||
GdkRectangle *visible_rect);
|
||||
GtkTextRectangle *visible_rect);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_set_cursor_visible (GtkTextView *text_view,
|
||||
gboolean setting);
|
||||
@@ -231,49 +232,49 @@ void gtk_text_view_reset_cursor_blink (GtkTextView *text_view);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_get_cursor_locations (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
GdkRectangle *strong,
|
||||
GdkRectangle *weak);
|
||||
GtkTextRectangle *strong,
|
||||
GtkTextRectangle *weak);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_get_iter_location (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
GdkRectangle *location);
|
||||
GtkTextRectangle *location);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_text_view_get_iter_at_location (GtkTextView *text_view,
|
||||
GtkTextIter *iter,
|
||||
int x,
|
||||
int y);
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_text_view_get_iter_at_position (GtkTextView *text_view,
|
||||
GtkTextIter *iter,
|
||||
int *trailing,
|
||||
int x,
|
||||
int y);
|
||||
GtkTextUnit *trailing,
|
||||
GtkTextUnit x,
|
||||
GtkTextUnit y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_get_line_yrange (GtkTextView *text_view,
|
||||
const GtkTextIter *iter,
|
||||
int *y,
|
||||
int *height);
|
||||
GtkTextUnit *y,
|
||||
GtkTextUnit *height);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_get_line_at_y (GtkTextView *text_view,
|
||||
GtkTextIter *target_iter,
|
||||
int y,
|
||||
int *line_top);
|
||||
GtkTextUnit y,
|
||||
GtkTextUnit *line_top);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_buffer_to_window_coords (GtkTextView *text_view,
|
||||
GtkTextWindowType win,
|
||||
int buffer_x,
|
||||
int buffer_y,
|
||||
int *window_x,
|
||||
int *window_y);
|
||||
GtkTextUnit buffer_x,
|
||||
GtkTextUnit buffer_y,
|
||||
GtkTextUnit *window_x,
|
||||
GtkTextUnit *window_y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_view_window_to_buffer_coords (GtkTextView *text_view,
|
||||
GtkTextWindowType win,
|
||||
int window_x,
|
||||
int window_y,
|
||||
int *buffer_x,
|
||||
int *buffer_y);
|
||||
GtkTextUnit window_x,
|
||||
GtkTextUnit window_y,
|
||||
GtkTextUnit *buffer_x,
|
||||
GtkTextUnit *buffer_y);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_text_view_forward_display_line (GtkTextView *text_view,
|
||||
|
||||
@@ -84,7 +84,7 @@ query_tooltip_cb (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
int bx, by, trailing;
|
||||
GtkTextUnit bx, by, trailing;
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (ce->priv->view), GTK_TEXT_WINDOW_TEXT,
|
||||
x, y, &bx, &by);
|
||||
@@ -314,7 +314,7 @@ text_changed (GtkTextBuffer *buffer,
|
||||
if (ce->priv->timeout != 0)
|
||||
g_source_remove (ce->priv->timeout);
|
||||
|
||||
ce->priv->timeout = g_timeout_add (100, update_timeout, ce);
|
||||
ce->priv->timeout = g_timeout_add (100, update_timeout, ce);
|
||||
|
||||
g_list_free_full (ce->priv->errors, css_error_free);
|
||||
ce->priv->errors = NULL;
|
||||
|
||||
@@ -617,6 +617,7 @@ gtk_public_headers = files([
|
||||
'gtktextmark.h',
|
||||
'gtktexttag.h',
|
||||
'gtktexttagtable.h',
|
||||
'gtktexttypes.h',
|
||||
'gtktextview.h',
|
||||
'gtktogglebutton.h',
|
||||
'gtktooltip.h',
|
||||
|
||||
@@ -81,7 +81,7 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_insert (buffer, &iter, "For example, you can have ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"italic translucent blue text", -1,
|
||||
"italic",
|
||||
"italic",
|
||||
"semi_blue_foreground",
|
||||
"x-large",
|
||||
NULL);
|
||||
@@ -91,7 +91,7 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"bold text with translucent red background", -1,
|
||||
"bold",
|
||||
"bold",
|
||||
"semi_red_background",
|
||||
"x-large",
|
||||
NULL);
|
||||
@@ -108,7 +108,7 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_insert (buffer, &iter, "For instance, you can have ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"bold translucent blue text", -1,
|
||||
"bold",
|
||||
"bold",
|
||||
"semi_blue_foreground",
|
||||
"x-large",
|
||||
NULL);
|
||||
@@ -118,7 +118,7 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
"italic text with translucent red background", -1,
|
||||
"italic",
|
||||
"italic",
|
||||
"semi_red_background",
|
||||
"x-large",
|
||||
NULL);
|
||||
@@ -147,7 +147,7 @@ static void
|
||||
snapshot_background (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GdkRectangle visible_rect;
|
||||
GtkTextRectangle visible_rect;
|
||||
|
||||
gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (widget), &visible_rect);
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ query_tooltip_text_view_cb (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
int bx, by, trailing;
|
||||
GtkTextUnit bx, by, trailing;
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (text_view, GTK_TEXT_WINDOW_TEXT,
|
||||
x, y, &bx, &by);
|
||||
|
||||
Reference in New Issue
Block a user