Merge branch 'wip/baedert/for-master' into 'master'

Wip/baedert/for master

See merge request GNOME/gtk!1828
This commit is contained in:
Matthias Clasen 2020-05-06 03:55:55 +00:00
commit b96509c030
32 changed files with 670 additions and 475 deletions

View File

@ -4470,7 +4470,6 @@ gtk_style_context_save
gtk_style_context_add_class
gtk_style_context_remove_class
gtk_style_context_has_class
gtk_style_context_list_classes
gtk_style_context_set_display
gtk_style_context_set_state
gtk_style_context_set_scale

View File

@ -671,22 +671,24 @@ gdk_motion_event_push_history (GdkEvent *event,
GdkEvent *history_event)
{
GdkMotionEvent *self = (GdkMotionEvent *) event;
GdkTimeCoord *hist;
GdkTimeCoord hist;
GdkDevice *device;
gint i, n_axes;
g_assert (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY));
g_assert (GDK_IS_EVENT_TYPE (history_event, GDK_MOTION_NOTIFY));
hist = g_new0 (GdkTimeCoord, 1);
device = gdk_event_get_device (history_event);
n_axes = gdk_device_get_n_axes (device);
for (i = 0; i <= MIN (n_axes, GDK_MAX_TIMECOORD_AXES); i++)
gdk_event_get_axis (history_event, i, &hist->axes[i]);
gdk_event_get_axis (history_event, i, &hist.axes[i]);
if (G_UNLIKELY (!self->history))
self->history = g_array_new (FALSE, TRUE, sizeof (GdkTimeCoord));
g_array_append_val (self->history, hist);
self->history = g_list_prepend (self->history, hist);
}
void
@ -2727,7 +2729,8 @@ gdk_motion_event_finalize (GdkEvent *event)
g_clear_object (&self->tool);
g_clear_pointer (&self->axes, g_free);
g_list_free_full (self->history, g_free);
if (self->history)
g_array_free (self->history, TRUE);
GDK_EVENT_SUPER (event)->finalize (event);
}
@ -2819,6 +2822,7 @@ gdk_motion_event_new (GdkSurface *surface,
/**
* gdk_motion_event_get_history:
* @event: (type GdkMotionEvent): a motion #GdkEvent
* @out_n_coords: (out): Return location for the length of the returned array
*
* Retrieves the history of the @event motion, as a list of time and
* coordinates.
@ -2826,15 +2830,31 @@ gdk_motion_event_new (GdkSurface *surface,
* Returns: (transfer container) (element-type GdkTimeCoord) (nullable): a list
* of time and coordinates
*/
GList *
gdk_motion_event_get_history (GdkEvent *event)
GdkTimeCoord *
gdk_motion_event_get_history (GdkEvent *event,
guint *out_n_coords)
{
GdkMotionEvent *self = (GdkMotionEvent *) event;
g_return_val_if_fail (GDK_IS_EVENT (event), NULL);
g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY), NULL);
g_return_val_if_fail (out_n_coords != NULL, NULL);
return g_list_reverse (g_list_copy (self->history));
if (self->history &&
self->history->len > 0)
{
GdkTimeCoord *result;
*out_n_coords = self->history->len;
result = g_malloc (sizeof (GdkTimeCoord) * self->history->len);
memcpy (result, self->history->data, sizeof (GdkTimeCoord) * self->history->len);
return result;
}
*out_n_coords = 0;
return NULL;
}
/* }}} */

View File

@ -471,7 +471,8 @@ gboolean gdk_grab_broken_event_get_implicit (GdkEvent *event)
GDK_AVAILABLE_IN_ALL
GType gdk_motion_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GList * gdk_motion_event_get_history (GdkEvent *event);
GdkTimeCoord * gdk_motion_event_get_history (GdkEvent *event,
guint *out_n_coords);
GDK_AVAILABLE_IN_ALL
GType gdk_delete_event_get_type (void) G_GNUC_CONST;

View File

@ -127,7 +127,7 @@ struct _GdkMotionEvent
double y;
double *axes;
GdkDeviceTool *tool;
GList *history;
GArray *history; /* <GdkTimeCoord> */
};
/*
@ -343,7 +343,7 @@ struct _GdkConfigureEvent
/*
* GdkProximityEvent:
* @tool: the #GdkDeviceTool associated to the event
* @tool: the #GdkDeviceTool associated to the event
*
* A proximity event indicates that a tool of a graphic tablet, or similar
* devices that report proximity, has moved in or out of contact with the
@ -456,7 +456,7 @@ GdkEvent * gdk_button_event_new (GdkEventType type,
double x,
double y,
double *axes);
GdkEvent * gdk_motion_event_new (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
@ -477,7 +477,7 @@ GdkEvent * gdk_crossing_event_new (GdkEventType type,
double y,
GdkCrossingMode mode,
GdkNotifyType notify);
GdkEvent * gdk_proximity_event_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
@ -537,7 +537,7 @@ GdkEvent * gdk_touch_event_new (GdkEventType type,
double y,
double *axes,
gboolean emulating);
GdkEvent * gdk_touchpad_event_new_swipe (GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,

View File

@ -3027,7 +3027,6 @@ gdk_surface_get_seat_from_event (GdkSurface *surface,
GdkDevice *device = gdk_event_get_device (event);
GdkSeat *seat = NULL;
device = gdk_event_get_device (event);
if (device)
seat = gdk_device_get_seat (device);

View File

@ -1287,13 +1287,13 @@ create_shm_pool (struct wl_shm *shm,
fd = open_shared_memory ();
if (fd < 0)
return NULL;
goto fail;
if (ftruncate (fd, size) < 0)
{
g_critical (G_STRLOC ": Truncating shared memory file failed: %m");
close (fd);
return NULL;
goto fail;
}
data = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
@ -1302,7 +1302,7 @@ create_shm_pool (struct wl_shm *shm,
{
g_critical (G_STRLOC ": mmap'ping shared memory file failed: %m");
close (fd);
return NULL;
goto fail;
}
pool = wl_shm_create_pool (shm, fd, size);
@ -1313,6 +1313,11 @@ create_shm_pool (struct wl_shm *shm,
*buf_length = size;
return pool;
fail:
*data_out = NULL;
*buf_length = 0;
return NULL;
}
static void

View File

@ -10,20 +10,23 @@
fun:gtk_widget_class_add_action
}
{
GIO modules
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:_g_io_module_get_default
}
{
GTK media extension gio modules
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
fun:g_slice_alloc
fun:g_slice_alloc0
fun:g_type_create_instance
fun:g_object_new_internal
fun:g_object_new_with_properties
fun:g_object_new
fun:g_io_module_new
fun:g_io_modules_scan_all_in_directory_with_scope
...
fun:gio_module_new
...
fun:gtk_media_file_extension_init
}
@ -35,6 +38,13 @@
...
obj:/usr/lib*/dri/radeonsi_dri.so
}
{
radeonsi_dri general
Memcheck:Leak
fun:malloc
...
obj:/usr/lib*/dri/radeonsi_dri.so
}
# mesa driver stuff
{
@ -118,6 +128,14 @@
fun:epoxy_eglInitialize_global_rewrite_ptr
}
{
epoxy strncmp
Memcheck:Addr8
fun:strncmp
...
fun:epoxy_eglInitialize_global_rewrite_ptr
}
{
mesa malloc
Memcheck:Leak
@ -244,10 +262,10 @@
# GLib
{
glib 1
glib GQuark
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
fun:g_quark_init
...
fun:g_quark_*
}

View File

@ -59,30 +59,22 @@ get_color (GskPangoRenderer *crenderer,
PangoRenderPart part,
GdkRGBA *rgba)
{
PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
gdouble red, green, blue, alpha;
red = crenderer->fg_color.red;
green = crenderer->fg_color.green;
blue = crenderer->fg_color.blue;
alpha = crenderer->fg_color.alpha;
const PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
const guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
if (color)
{
red = color->red / 65535.;
green = color->green / 65535.;
blue = color->blue / 65535.;
alpha = 1.;
rgba->red = color->red / 65535.;
rgba->green = color->green / 65535.;
rgba->blue = color->blue / 65535.;
rgba->alpha = a ? a / 65535. : crenderer->fg_color.alpha;
}
else
{
*rgba = crenderer->fg_color;
if (a)
rgba->alpha = a / 65535.;
}
if (a)
alpha = a / 65535.;
rgba->red = red;
rgba->green = green;
rgba->blue = blue;
rgba->alpha = alpha;
}
static void

134
gtk/gtkarrayimplprivate.h Normal file
View File

@ -0,0 +1,134 @@
#ifndef __GTK_ARRAY_IMPL_PRIVATE_H__
#define __GTK_ARRAY_IMPL_PRIVATE_H__
/* This is a dumbed-down GPtrArray, which takes some stack
* space to use. When using this, the general case should always
* be that the number of elements is lower than reversed_size.
* The GPtrArray should only be used in extreme cases.
*/
typedef struct
{
guint reserved_size;
guint len;
void **stack_space;
GPtrArray *ptr_array;
} GtkArray;
static inline void
gtk_array_init (GtkArray *self,
void **stack_space,
guint reserved_size)
{
self->reserved_size = reserved_size;
self->len = 0;
self->stack_space = stack_space;
self->ptr_array = NULL;
}
static inline void *
gtk_array_index (const GtkArray *self,
guint index)
{
g_assert (index < self->len);
if (G_LIKELY (!self->ptr_array))
return self->stack_space[index];
return g_ptr_array_index (self->ptr_array, index);
}
static inline void
gtk_array_add (GtkArray *self,
void *element)
{
if (G_LIKELY (self->len < self->reserved_size))
{
self->stack_space[self->len] = element;
self->len++;
return;
}
/* Need to fall back to the GPtrArray */
if (G_UNLIKELY (!self->ptr_array))
{
guint i;
self->ptr_array = g_ptr_array_new_full (self->reserved_size, NULL);
/* Copy elements from stack space to GPtrArray */
for (i = 0; i < self->len; i++)
g_ptr_array_add (self->ptr_array, self->stack_space[i]);
}
g_ptr_array_add (self->ptr_array, element);
self->len++; /* We still count self->len */
}
static inline void
gtk_array_insert (GtkArray *self,
guint index,
void *element)
{
if (index >= self->len)
{
gtk_array_add (self, element);
return;
}
if (G_LIKELY (self->len < self->reserved_size))
{
memmove (self->stack_space + index + 1, self->stack_space + index,
sizeof (void *) * (self->len - index));
self->stack_space[index] = element;
self->len++;
return;
}
g_assert (self->ptr_array);
g_ptr_array_insert (self->ptr_array, index, element);
self->len++;
}
static inline void
gtk_array_free (GtkArray *self,
GDestroyNotify element_free_func)
{
guint i;
if (G_LIKELY (!self->ptr_array))
{
if (element_free_func)
{
for (i = 0; i < self->len; i++)
element_free_func (self->stack_space[i]);
}
return;
}
g_assert (self->ptr_array);
if (element_free_func)
{
for (i = 0; i < self->ptr_array->len; i++)
element_free_func (g_ptr_array_index (self->ptr_array, i));
}
g_ptr_array_free (self->ptr_array, TRUE);
}
static inline void **
gtk_array_get_data (GtkArray *self)
{
if (G_LIKELY (!self->ptr_array))
return self->stack_space;
return self->ptr_array->pdata;
}
#endif

View File

@ -391,8 +391,8 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
static void
verify_tree_match_results (GtkCssProvider *provider,
GtkCssNode *node,
GPtrArray *tree_rules)
GtkCssNode *node,
GtkArray *tree_rules)
{
#ifdef VERIFY_TREE
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (provider);
@ -408,7 +408,7 @@ verify_tree_match_results (GtkCssProvider *provider,
for (j = 0; j < tree_rules->len; j++)
{
if (ruleset == tree_rules->pdata[j])
if (ruleset == gtk_array_index (tree_rules, j))
{
found = TRUE;
break;
@ -458,19 +458,22 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
GtkCssRuleset *ruleset;
guint j;
int i;
GPtrArray *tree_rules;
GtkArray tree_rules_array;
GtkCssRuleset *rules_stack[32];
if (_gtk_css_selector_tree_is_empty (priv->tree))
return;
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, filter, node);
if (tree_rules)
{
verify_tree_match_results (css_provider, node, tree_rules);
gtk_array_init (&tree_rules_array, (void**)rules_stack, 32);
_gtk_css_selector_tree_match_all (priv->tree, filter, node, &tree_rules_array);
for (i = tree_rules->len - 1; i >= 0; i--)
if (tree_rules_array.len > 0)
{
verify_tree_match_results (css_provider, node, &tree_rules_array);
for (i = tree_rules_array.len - 1; i >= 0; i--)
{
ruleset = tree_rules->pdata[i];
ruleset = gtk_array_index (&tree_rules_array, i);
if (ruleset->styles == NULL)
continue;
@ -490,7 +493,7 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
}
}
g_ptr_array_free (tree_rules, TRUE);
gtk_array_free (&tree_rules_array, NULL);
}
if (change)

View File

@ -24,6 +24,7 @@
#include "gtkcssprovider.h"
#include "gtkstylecontextprivate.h"
#include "gtkarrayimplprivate.h"
#include <errno.h>
#if defined(_MSC_VER) && _MSC_VER >= 1500
@ -151,21 +152,23 @@ gtk_css_selector_tree_get_matches (const GtkCssSelectorTree *tree)
}
static void
g_ptr_array_insert_sorted (GPtrArray *array,
gpointer data)
gtk_array_insert_sorted (GtkArray *array,
gpointer data)
{
gint i;
guint i;
for (i = 0; i < array->len; i++)
{
if (data == array->pdata[i])
gpointer elem = gtk_array_index (array, i);
if (data == elem)
return;
if (data < array->pdata[i])
if (data < elem)
break;
}
g_ptr_array_insert (array, i, data);
gtk_array_insert (array, i, data);
}
static inline gboolean
@ -1874,7 +1877,7 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
static void
gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree,
GPtrArray **results)
GtkArray *results)
{
int i;
gpointer *matches;
@ -1883,11 +1886,8 @@ gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree,
if (!matches)
return;
if (*results == NULL)
*results = g_ptr_array_sized_new (16);
for (i = 0; matches[i] != NULL; i++)
g_ptr_array_insert_sorted (*results, matches[i]);
gtk_array_insert_sorted (results, matches[i]);
}
static gboolean
@ -1895,7 +1895,7 @@ gtk_css_selector_tree_match (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
gboolean match_filter,
GtkCssNode *node,
GPtrArray **results)
GtkArray *results)
{
const GtkCssSelectorTree *prev;
GtkCssNode *child;
@ -1928,22 +1928,20 @@ gtk_css_selector_tree_match (const GtkCssSelectorTree *tree,
return TRUE;
}
GPtrArray *
void
_gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node)
GtkCssNode *node,
GtkArray *out_tree_rules)
{
const GtkCssSelectorTree *iter;
GPtrArray *results = NULL;
for (iter = tree;
iter != NULL;
iter = gtk_css_selector_tree_get_sibling (iter))
{
gtk_css_selector_tree_match (iter, filter, FALSE, node, &results);
gtk_css_selector_tree_match (iter, filter, FALSE, node, out_tree_rules);
}
return results;
}
gboolean
@ -2103,30 +2101,35 @@ alloc_tree (GByteArray *array, gint32 *offset)
}
static gint32
subdivide_infos (GByteArray *array, GList *infos, gint32 parent_offset)
subdivide_infos (GByteArray *array,
GtkCssSelectorRuleSetInfo **infos,
guint n_infos,
gint32 parent_offset)
{
GtkCssSelectorRuleSetInfo **matched_infos;
guint n_matched = 0;
GtkCssSelectorRuleSetInfo **remaining_infos;
guint n_remaining = 0;
GHashTable *ht;
GList *l;
GList *matched;
GList *remaining;
gint32 tree_offset;
GtkCssSelectorTree *tree;
GtkCssSelectorRuleSetInfo *info;
GtkCssSelector max_selector;
GHashTableIter iter;
guint max_count;
gpointer key, value;
GPtrArray *exact_matches;
void *exact_matches_stack[8];
GtkArray exact_matches_array;
gint32 res;
guint i;
if (infos == NULL)
if (n_infos == 0)
return GTK_CSS_SELECTOR_TREE_EMPTY_OFFSET;
ht = gtk_css_selectors_count_initial_init ();
for (l = infos; l != NULL; l = l->next)
for (i = 0; i < n_infos; i++)
{
info = l->data;
const GtkCssSelectorRuleSetInfo *info = infos[i];
gtk_css_selectors_count_initial (info->current_selector, ht);
}
@ -2148,17 +2151,19 @@ subdivide_infos (GByteArray *array, GList *infos, gint32 parent_offset)
}
}
matched = NULL;
remaining = NULL;
tree = alloc_tree (array, &tree_offset);
tree->parent_offset = parent_offset;
tree->selector = max_selector;
exact_matches = NULL;
for (l = infos; l != NULL; l = l->next)
/* Allocate maximum for both of them */
/* TODO: Potentially dangerous? */
matched_infos = g_alloca (sizeof (GtkCssSelectorRuleSetInfo *) * n_infos);
remaining_infos = g_alloca (sizeof (GtkCssSelectorRuleSetInfo *) * n_infos);
gtk_array_init (&exact_matches_array, (void**)exact_matches_stack, 8);
for (i = 0; i < n_infos; i++)
{
info = l->data;
GtkCssSelectorRuleSetInfo *info = infos[i];
if (gtk_css_selectors_has_initial_selector (info->current_selector, &max_selector))
{
@ -2166,60 +2171,65 @@ subdivide_infos (GByteArray *array, GList *infos, gint32 parent_offset)
if (info->current_selector == NULL)
{
/* Matches current node */
if (exact_matches == NULL)
exact_matches = g_ptr_array_new ();
g_ptr_array_add (exact_matches, info->match);
gtk_array_add (&exact_matches_array, info->match);
if (info->selector_match != NULL)
*info->selector_match = GUINT_TO_POINTER (tree_offset);
}
else
matched = g_list_prepend (matched, info);
{
matched_infos[n_matched] = info;
n_matched++;
}
}
else
{
remaining = g_list_prepend (remaining, info);
remaining_infos[n_remaining] = info;
n_remaining++;
}
}
if (exact_matches)
if (exact_matches_array.len > 0)
{
g_ptr_array_add (exact_matches, NULL); /* Null terminate */
gtk_array_add (&exact_matches_array, NULL); /* Null terminate */
res = array->len;
g_byte_array_append (array, (guint8 *)exact_matches->pdata,
exact_matches->len * sizeof (gpointer));
g_ptr_array_free (exact_matches, TRUE);
g_byte_array_append (array, (guint8 *)gtk_array_get_data (&exact_matches_array),
exact_matches_array.len * sizeof (gpointer));
gtk_array_free (&exact_matches_array, NULL);
}
else
res = GTK_CSS_SELECTOR_TREE_EMPTY_OFFSET;
get_tree (array, tree_offset)->matches_offset = res;
res = subdivide_infos (array, matched, tree_offset);
res = subdivide_infos (array, matched_infos, n_matched, tree_offset);
get_tree (array, tree_offset)->previous_offset = res;
res = subdivide_infos (array, remaining, parent_offset);
res = subdivide_infos (array, remaining_infos, n_remaining, parent_offset);
get_tree (array, tree_offset)->sibling_offset = res;
g_list_free (matched);
g_list_free (remaining);
g_hash_table_unref (ht);
return tree_offset;
}
struct _GtkCssSelectorTreeBuilder {
GList *infos;
GArray *infos;
};
GtkCssSelectorTreeBuilder *
_gtk_css_selector_tree_builder_new (void)
{
return g_new0 (GtkCssSelectorTreeBuilder, 1);
GtkCssSelectorTreeBuilder *builder = g_new0 (GtkCssSelectorTreeBuilder, 1);
builder->infos = g_array_new (FALSE, TRUE, sizeof (GtkCssSelectorRuleSetInfo));
return builder;
}
void
_gtk_css_selector_tree_builder_free (GtkCssSelectorTreeBuilder *builder)
{
g_list_free_full (builder->infos, g_free);
g_array_free (builder->infos, TRUE);
g_free (builder);
}
@ -2229,12 +2239,13 @@ _gtk_css_selector_tree_builder_add (GtkCssSelectorTreeBuilder *builder,
GtkCssSelectorTree **selector_match,
gpointer match)
{
GtkCssSelectorRuleSetInfo *info = g_new0 (GtkCssSelectorRuleSetInfo, 1);
GtkCssSelectorRuleSetInfo *info;
g_array_set_size (builder->infos, builder->infos->len + 1);
info = &g_array_index (builder->infos, GtkCssSelectorRuleSetInfo, builder->infos->len - 1);
info->match = match;
info->current_selector = selectors;
info->selector_match = selector_match;
builder->infos = g_list_prepend (builder->infos, info);
}
/* Convert all offsets to node-relative */
@ -2268,11 +2279,16 @@ _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder)
GByteArray *array;
guint8 *data;
guint len;
GList *l;
GtkCssSelectorRuleSetInfo *info;
guint i;
GtkCssSelectorRuleSetInfo **infos_array;
array = g_byte_array_new ();
subdivide_infos (array, builder->infos, GTK_CSS_SELECTOR_TREE_EMPTY_OFFSET);
infos_array = g_alloca (sizeof (GtkCssSelectorRuleSetInfo *) * builder->infos->len);
for (i = 0; i < builder->infos->len; i++)
infos_array[i] = &g_array_index (builder->infos, GtkCssSelectorRuleSetInfo, i);
subdivide_infos (array, infos_array, builder->infos->len, GTK_CSS_SELECTOR_TREE_EMPTY_OFFSET);
len = array->len;
data = g_byte_array_free (array, FALSE);
@ -2285,13 +2301,15 @@ _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder)
fixup_offsets (tree, data);
/* Convert offsets to final pointers */
for (l = builder->infos; l != NULL; l = l->next)
for (i = 0; i < builder->infos->len; i++)
{
info = l->data;
GtkCssSelectorRuleSetInfo *info = &g_array_index (builder->infos, GtkCssSelectorRuleSetInfo, i);
if (info->selector_match)
*info->selector_match = (GtkCssSelectorTree *)(data + GPOINTER_TO_UINT (*info->selector_match));
}
#ifdef PRINT_TREE
{
GString *s = g_string_new ("");

View File

@ -21,6 +21,7 @@
#include "gtk/gtkcountingbloomfilterprivate.h"
#include "gtk/gtkcsstypesprivate.h"
#include "gtk/gtkcssparserprivate.h"
#include "gtk/gtkarrayimplprivate.h"
G_BEGIN_DECLS
@ -42,9 +43,10 @@ int _gtk_css_selector_compare (const GtkCssSelector *a,
const GtkCssSelector *b);
void _gtk_css_selector_tree_free (GtkCssSelectorTree *tree);
GPtrArray * _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
void _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node);
GtkCssNode *node,
GtkArray *out_tree_rules);
GtkCssChange gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node);

View File

@ -67,21 +67,20 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
GtkCssParser *parser)
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
const guint n_props = shorthand->subproperties->len;
GtkCssValue **data;
GtkCssValue *result;
guint i;
data = g_new0 (GtkCssValue *, shorthand->subproperties->len);
data = g_newa (GtkCssValue *, n_props);
memset (data, 0, sizeof (GtkCssValue *) * n_props);
if (gtk_css_parser_try_ident (parser, "initial"))
{
/* the initial value can be explicitly specified with the
* initial keyword which all properties accept.
*/
for (i = 0; i < shorthand->subproperties->len; i++)
{
data[i] = _gtk_css_initial_value_new ();
}
return _gtk_css_initial_value_new ();
}
else if (gtk_css_parser_try_ident (parser, "inherit"))
{
@ -91,10 +90,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
* strengthen inherited values in the cascade, and it can
* also be used on properties that are not normally inherited.
*/
for (i = 0; i < shorthand->subproperties->len; i++)
{
data[i] = _gtk_css_inherit_value_new ();
}
return _gtk_css_inherit_value_new ();
}
else if (gtk_css_parser_try_ident (parser, "unset"))
{
@ -102,34 +98,29 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
* then if it is an inherited property, this is treated as
* inherit, and if it is not, this is treated as initial.
*/
for (i = 0; i < shorthand->subproperties->len; i++)
{
data[i] = _gtk_css_unset_value_new ();
}
return _gtk_css_unset_value_new ();
}
else if (!shorthand->parse (shorthand, data, parser))
{
for (i = 0; i < shorthand->subproperties->len; i++)
for (i = 0; i < n_props; i++)
{
if (data[i] != NULL)
_gtk_css_value_unref (data[i]);
}
g_free (data);
return NULL;
}
/* All values that aren't set by the parse func are set to their
* default values here.
* XXX: Is the default always initial or can it be inherit? */
for (i = 0; i < shorthand->subproperties->len; i++)
for (i = 0; i < n_props; i++)
{
if (data[i] == NULL)
data[i] = _gtk_css_initial_value_new ();
}
result = _gtk_css_array_value_new_from_array (data, shorthand->subproperties->len);
g_free (data);
result = _gtk_css_array_value_new_from_array (data, n_props);
return result;
}

View File

@ -250,14 +250,14 @@ static gboolean
same_native (GtkWidget *widget,
GtkWidget *target)
{
GtkWidget *native;
GtkWidget *native2;
GtkNative *native;
GtkNative *native2;
if (!widget || !target)
return TRUE;
native = GTK_WIDGET (gtk_widget_get_native (widget));
native2 = GTK_WIDGET (gtk_widget_get_native (target));
native = gtk_widget_get_native (widget);
native2 = gtk_widget_get_native (target);
return native == native2;
}

View File

@ -283,7 +283,8 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
{
GdkEvent *event;
GArray *backlog_array;
GList *history = NULL, *l;
GdkTimeCoord *history = NULL;
guint n_coords = 0, i;
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
g_return_val_if_fail (backlog != NULL && n_elems != NULL, FALSE);
@ -291,14 +292,15 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
event = gesture_get_current_event (gesture);
if (event && GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY))
history = gdk_motion_event_get_history (event);
history = gdk_motion_event_get_history (event, &n_coords);
if (!history)
return FALSE;
backlog_array = g_array_new (FALSE, FALSE, sizeof (GdkTimeCoord));
for (l = history; l; l = l->next)
for (i = 0; i < n_coords; i++)
{
GdkTimeCoord *time_coord = l->data;
GdkTimeCoord *time_coord = &history[i];
graphene_point_t p;
g_array_append_val (backlog_array, *time_coord);
@ -320,7 +322,7 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
*n_elems = backlog_array->len;
*backlog = (GdkTimeCoord *) g_array_free (backlog_array, FALSE);
g_list_free (history);
g_free (history);
return TRUE;
}

View File

@ -330,7 +330,7 @@ struct _GtkIconTheme
/* time when we last stat:ed for theme changes */
glong last_stat_time;
GList *dir_mtimes;
GArray *dir_mtimes;
gulong theme_changed_idle;
@ -1239,6 +1239,16 @@ pixbuf_supports_svg (void)
return found_svg;
}
static void
free_dir_mtime (IconThemeDirMtime *dir_mtime)
{
if (dir_mtime->cache)
gtk_icon_cache_unref (dir_mtime->cache);
g_free (dir_mtime->dir);
g_slice_free (IconThemeDirMtime, dir_mtime);
}
static void
gtk_icon_theme_init (GtkIconTheme *self)
{
@ -1252,6 +1262,8 @@ gtk_icon_theme_init (GtkIconTheme *self)
(GDestroyNotify)icon_uncached_cb);
self->custom_theme = FALSE;
self->dir_mtimes = g_array_new (FALSE, TRUE, sizeof (IconThemeDirMtime));
g_array_set_clear_func (self->dir_mtimes, (GDestroyNotify)free_dir_mtime);
xdg_data_dirs = g_get_system_data_dirs ();
for (i = 0; xdg_data_dirs[i]; i++) ;
@ -1283,16 +1295,6 @@ gtk_icon_theme_init (GtkIconTheme *self)
self->pixbuf_supports_svg = pixbuf_supports_svg ();
}
static void
free_dir_mtime (IconThemeDirMtime *dir_mtime)
{
if (dir_mtime->cache)
gtk_icon_cache_unref (dir_mtime->cache);
g_free (dir_mtime->dir);
g_slice_free (IconThemeDirMtime, dir_mtime);
}
static gboolean
theme_changed_idle__mainthread_unlocked (gpointer user_data)
{
@ -1365,12 +1367,11 @@ blow_themes (GtkIconTheme *self)
if (self->themes_valid)
{
g_list_free_full (self->themes, (GDestroyNotify) theme_destroy);
g_list_free_full (self->dir_mtimes, (GDestroyNotify) free_dir_mtime);
g_array_set_size (self->dir_mtimes, 0);
g_hash_table_destroy (self->unthemed_icons);
}
self->themes = NULL;
self->unthemed_icons = NULL;
self->dir_mtimes = NULL;
self->themes_valid = FALSE;
self->serial++;
}
@ -1424,6 +1425,7 @@ gtk_icon_theme_finalize (GObject *object)
g_strfreev (self->resource_path);
blow_themes (self);
g_array_free (self->dir_mtimes, TRUE);
gtk_icon_theme_ref_unref (self->ref);
@ -1750,7 +1752,6 @@ insert_theme (GtkIconTheme *self,
gchar *path;
GKeyFile *theme_file;
GError *error = NULL;
IconThemeDirMtime *dir_mtime;
GStatBuf stat_buf;
for (l = self->themes; l != NULL; l = l->next)
@ -1762,22 +1763,23 @@ insert_theme (GtkIconTheme *self,
for (i = 0; self->search_path[i]; i++)
{
IconThemeDirMtime dir_mtime;
path = g_build_filename (self->search_path[i], theme_name, NULL);
dir_mtime = g_slice_new (IconThemeDirMtime);
dir_mtime->cache = NULL;
dir_mtime->dir = path;
dir_mtime.cache = NULL;
dir_mtime.dir = path;
if (g_stat (path, &stat_buf) == 0 && S_ISDIR (stat_buf.st_mode))
{
dir_mtime->mtime = stat_buf.st_mtime;
dir_mtime->exists = TRUE;
dir_mtime.mtime = stat_buf.st_mtime;
dir_mtime.exists = TRUE;
}
else
{
dir_mtime->mtime = 0;
dir_mtime->exists = FALSE;
dir_mtime.mtime = 0;
dir_mtime.exists = FALSE;
}
self->dir_mtimes = g_list_prepend (self->dir_mtimes, dir_mtime);
g_array_insert_val (self->dir_mtimes, 0, dir_mtime);
}
theme_file = NULL;
@ -1963,7 +1965,6 @@ load_themes (GtkIconTheme *self)
gchar *dir;
const gchar *file;
GTimeVal tv;
IconThemeDirMtime *dir_mtime;
GStatBuf stat_buf;
int j;
@ -1978,10 +1979,11 @@ load_themes (GtkIconTheme *self)
for (base = 0; self->search_path[base]; base++)
{
IconThemeDirMtime *dir_mtime;
dir = self->search_path[base];
dir_mtime = g_slice_new (IconThemeDirMtime);
self->dir_mtimes = g_list_prepend (self->dir_mtimes, dir_mtime);
g_array_set_size (self->dir_mtimes, self->dir_mtimes->len + 1);
dir_mtime = &g_array_index (self->dir_mtimes, IconThemeDirMtime, self->dir_mtimes->len - 1);
dir_mtime->dir = g_strdup (dir);
dir_mtime->mtime = 0;
@ -2006,7 +2008,6 @@ load_themes (GtkIconTheme *self)
g_dir_close (gdir);
}
self->dir_mtimes = g_list_reverse (self->dir_mtimes);
for (j = 0; self->resource_path[j]; j++)
{
@ -2747,15 +2748,14 @@ gtk_icon_theme_get_icon_names (GtkIconTheme *self)
static gboolean
rescan_themes (GtkIconTheme *self)
{
IconThemeDirMtime *dir_mtime;
GList *d;
gint stat_res;
GStatBuf stat_buf;
GTimeVal tv;
guint i;
for (d = self->dir_mtimes; d != NULL; d = d->next)
for (i = 0; i < self->dir_mtimes->len; i++)
{
dir_mtime = d->data;
const IconThemeDirMtime *dir_mtime = &g_array_index (self->dir_mtimes, IconThemeDirMtime, i);
stat_res = g_stat (dir_mtime->dir, &stat_buf);
@ -3296,7 +3296,6 @@ theme_subdir_load (GtkIconTheme *self,
GKeyFile *theme_file,
gchar *subdir)
{
GList *d;
gchar *type_string;
IconThemeDirType type;
gint size;
@ -3304,10 +3303,10 @@ theme_subdir_load (GtkIconTheme *self,
gint max_size;
gint threshold;
GError *error = NULL;
IconThemeDirMtime *dir_mtime;
guint32 dir_size_index;
IconThemeDirSize *dir_size;
gint scale;
guint i;
size = g_key_file_get_integer (theme_file, subdir, "Size", &error);
if (error)
@ -3355,10 +3354,10 @@ theme_subdir_load (GtkIconTheme *self,
dir_size_index = theme_ensure_dir_size (theme, type, size, min_size, max_size, threshold, scale);
dir_size = &g_array_index (theme->dir_sizes, IconThemeDirSize, dir_size_index);
for (d = self->dir_mtimes; d; d = d->next)
for (i = 0; i < self->dir_mtimes->len; i++)
{
IconThemeDirMtime *dir_mtime = &g_array_index (self->dir_mtimes, IconThemeDirMtime, i);
gchar *full_dir;
dir_mtime = (IconThemeDirMtime *)d->data;
if (!dir_mtime->exists)
continue; /* directory doesn't exist */
@ -3397,14 +3396,14 @@ theme_subdir_load (GtkIconTheme *self,
if (strcmp (theme->name, FALLBACK_ICON_THEME) == 0)
{
int i;
for (i = 0; self->resource_path[i]; i++)
int r;
for (r = 0; self->resource_path[r]; r++)
{
GHashTable *icons;
gchar *full_dir;
/* Force a trailing / here, to avoid extra copies in GResource */
full_dir = g_build_filename (self->resource_path[i], subdir, " ", NULL);
full_dir = g_build_filename (self->resource_path[r], subdir, " ", NULL);
full_dir[strlen (full_dir) - 1] = '\0';
icons = scan_resource_directory (self, full_dir, &theme->icons);

View File

@ -1838,8 +1838,6 @@ gtk_label_set_attributes (GtkLabel *self,
if (!attrs && !self->attrs)
return;
if (attrs == self->attrs) g_error ("Z");
if (attrs)
pango_attr_list_ref (attrs);
@ -2852,7 +2850,10 @@ gtk_label_update_layout_attributes (GtkLabel *self,
PangoAttrList *attrs;
if (self->layout == NULL)
return;
{
pango_attr_list_unref (style_attrs);
return;
}
if (self->select_info && self->select_info->links)
{
@ -2913,8 +2914,7 @@ gtk_label_update_layout_attributes (GtkLabel *self,
pango_layout_set_attributes (self->layout, attrs);
if (attrs)
pango_attr_list_unref (attrs);
pango_attr_list_unref (attrs);
}
static void
@ -3849,8 +3849,14 @@ gtk_label_focus (GtkWidget *widget,
int new_index = -1;
int i;
if (info->n_links == 0)
goto out;
focus_link = gtk_label_get_focus_link (self, &focus_link_index);
if (!focus_link)
goto out;
switch (direction)
{
case GTK_DIR_TAB_FORWARD:

View File

@ -95,6 +95,7 @@
#include "gdk/gdk-private.h"
#include "gsk/gskprivate.h"
#include "gsk/gskrendernodeprivate.h"
#include "gtkarrayimplprivate.h"
#include <locale.h>
@ -1310,7 +1311,8 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
double x, y;
GtkWidget *prev;
gboolean seen_ancestor;
GPtrArray *targets;
GtkArray target_array;
GtkWidget *stack_targets[16];
int i;
if (old_target == new_target)
@ -1346,7 +1348,7 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
GtkWidget *w;
crossing.new_descendent = NULL;
for (w = new_target; w != ancestor; w = gtk_widget_get_parent (w))
for (w = new_target; w != ancestor; w = _gtk_widget_get_parent (w))
crossing.new_descendent = w;
seen_ancestor = TRUE;
@ -1361,22 +1363,22 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
if (crossing_type == GTK_CROSSING_POINTER)
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_PRELIGHT);
prev = widget;
widget = gtk_widget_get_parent (widget);
widget = _gtk_widget_get_parent (widget);
}
targets = g_ptr_array_new_full (16, NULL);
for (widget = new_target; widget; widget = gtk_widget_get_parent (widget))
g_ptr_array_add (targets, widget);
gtk_array_init (&target_array, (void**)stack_targets, 16);
for (widget = new_target; widget; widget = _gtk_widget_get_parent (widget))
gtk_array_add (&target_array, widget);
crossing.direction = GTK_CROSSING_IN;
seen_ancestor = FALSE;
for (i = (int)targets->len - 1; i >= 0; i--)
for (i = (int)target_array.len - 1; i >= 0; i--)
{
widget = g_ptr_array_index (targets, i);
widget = gtk_array_index (&target_array, i);
if (i < (int)targets->len - 1)
crossing.new_descendent = g_ptr_array_index (targets, i + 1);
if (i < (int)target_array.len - 1)
crossing.new_descendent = gtk_array_index (&target_array, i + 1);
else
crossing.new_descendent = NULL;
@ -1389,7 +1391,7 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
GtkWidget *w;
crossing.old_descendent = NULL;
for (w = old_target; w != ancestor; w = gtk_widget_get_parent (w))
for (w = old_target; w != ancestor; w = _gtk_widget_get_parent (w))
crossing.old_descendent = w;
seen_ancestor = TRUE;
@ -1405,7 +1407,7 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
}
g_ptr_array_free (targets, TRUE);
gtk_array_free (&target_array, NULL);
}
static GtkWidget *
@ -1487,7 +1489,7 @@ set_widget_active_state (GtkWidget *target,
else
gtk_widget_set_state_flags (w, GTK_STATE_FLAG_ACTIVE, FALSE);
w = gtk_widget_get_parent (w);
w = _gtk_widget_get_parent (w);
}
}
@ -2101,14 +2103,14 @@ propagate_event_up (GtkWidget *widget,
* to have children of the viewport eat the scroll
* event
*/
if (!gtk_widget_is_sensitive (widget))
if (!_gtk_widget_is_sensitive (widget))
handled_event = gdk_event_get_event_type (event) != GDK_SCROLL;
else if (gtk_widget_get_realized (widget))
else if (_gtk_widget_get_realized (widget))
handled_event = gtk_widget_event (widget, event, target);
handled_event |= !gtk_widget_get_realized (widget);
handled_event |= !_gtk_widget_get_realized (widget);
tmp = gtk_widget_get_parent (widget);
tmp = _gtk_widget_get_parent (widget);
g_object_unref (widget);
if (widget == topmost)
@ -2130,30 +2132,31 @@ propagate_event_down (GtkWidget *widget,
{
gint handled_event = FALSE;
GtkWidget *target = widget;
GPtrArray *widgets;
GtkArray widget_array;
GtkWidget *stack_widgets[16];
int i;
widgets = g_ptr_array_new_full (16, g_object_unref);
g_ptr_array_add (widgets, g_object_ref (widget));
gtk_array_init (&widget_array, (void**)stack_widgets, 16);
gtk_array_add (&widget_array, g_object_ref (widget));
for (;;)
{
widget = gtk_widget_get_parent (widget);
widget = _gtk_widget_get_parent (widget);
if (!widget)
break;
g_ptr_array_add (widgets, g_object_ref (widget));
gtk_array_add (&widget_array, g_object_ref (widget));
if (widget == topmost)
break;
}
i = (int)widgets->len - 1;
i = widget_array.len - 1;
for (;;)
{
widget = g_ptr_array_index (widgets, i);
widget = gtk_array_index (&widget_array, i);
if (!gtk_widget_is_sensitive (widget))
if (!_gtk_widget_is_sensitive (widget))
{
/* stop propagating on SCROLL, but don't handle the event, so it
* can propagate up again and reach its handling widget
@ -2163,10 +2166,10 @@ propagate_event_down (GtkWidget *widget,
else
handled_event = TRUE;
}
else if (gtk_widget_get_realized (widget))
else if (_gtk_widget_get_realized (widget))
handled_event = _gtk_widget_captured_event (widget, event, target);
handled_event |= !gtk_widget_get_realized (widget);
handled_event |= !_gtk_widget_get_realized (widget);
if (handled_event)
break;
@ -2177,7 +2180,7 @@ propagate_event_down (GtkWidget *widget,
i--;
}
g_ptr_array_free (widgets, TRUE);
gtk_array_free (&widget_array, g_object_unref);
return handled_event;
}

View File

@ -1266,12 +1266,9 @@ gtk_popover_fill_border_path (GtkPopover *popover,
cairo_t *cr)
{
GtkWidget *widget = GTK_WIDGET (popover);
GtkAllocation allocation;
int x, y, w, h;
GskRoundedRect box;
gtk_widget_get_allocation (widget, &allocation);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
gtk_popover_apply_tail_path (popover, cr);

View File

@ -119,8 +119,6 @@ typedef struct
GtkScrollType autoscroll_step;
gboolean autoscrolling;
guint click_id;
gchar **icon_list;
GtkAdjustment *adjustment; /* needed because it must be settable in init() */
@ -409,7 +407,6 @@ gtk_scale_button_init (GtkScaleButton *button)
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
GtkEventController *controller;
priv->click_id = 0;
priv->orientation = GTK_ORIENTATION_VERTICAL;
priv->applied_orientation = GTK_ORIENTATION_VERTICAL;
@ -515,20 +512,9 @@ gtk_scale_button_finalize (GObject *object)
GtkScaleButton *button = GTK_SCALE_BUTTON (object);
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
if (priv->icon_list)
{
g_strfreev (priv->icon_list);
priv->icon_list = NULL;
}
if (priv->adjustment)
{
g_object_unref (priv->adjustment);
priv->adjustment = NULL;
}
if (priv->autoscroll_timeout)
g_source_remove (priv->autoscroll_timeout);
g_clear_pointer (&priv->icon_list, g_strfreev);
g_clear_object (&priv->adjustment);
g_clear_handle_id (&priv->autoscroll_timeout, g_source_remove);
G_OBJECT_CLASS (gtk_scale_button_parent_class)->finalize (object);
}
@ -542,12 +528,6 @@ gtk_scale_button_dispose (GObject *object)
g_clear_pointer (&priv->dock, gtk_widget_unparent);
g_clear_pointer (&priv->button, gtk_widget_unparent);
if (priv->click_id != 0)
{
g_source_remove (priv->click_id);
priv->click_id = 0;
}
G_OBJECT_CLASS (gtk_scale_button_parent_class)->dispose (object);
}

View File

@ -283,7 +283,6 @@ shortcut_data_free (gpointer data)
ShortcutData *sdata = data;
g_object_unref (sdata->shortcut);
g_free (sdata);
}
static gboolean
@ -294,13 +293,12 @@ gtk_shortcut_controller_run_controllers (GtkEventController *controller,
gboolean enable_mnemonics)
{
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller);
guint i;
GSList *shortcuts = NULL;
GSList *l;
int i, p;
GArray *shortcuts = NULL;
gboolean has_exact = FALSE;
gboolean retval = FALSE;
for (i = 0; i < g_list_model_get_n_items (self->shortcuts); i++)
for (i = 0, p = g_list_model_get_n_items (self->shortcuts); i < p; i++)
{
GtkShortcut *shortcut;
ShortcutData *data;
@ -325,8 +323,8 @@ gtk_shortcut_controller_run_controllers (GtkEventController *controller,
case GDK_KEY_MATCH_EXACT:
if (!has_exact)
{
g_slist_free_full (shortcuts, shortcut_data_free);
shortcuts = NULL;
if (shortcuts)
g_array_set_size (shortcuts, 0);
}
has_exact = TRUE;
break;
@ -344,29 +342,43 @@ gtk_shortcut_controller_run_controllers (GtkEventController *controller,
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (model));
}
native = gtk_widget_get_native (widget);
if (!gtk_widget_is_sensitive (widget) ||
!gtk_widget_get_mapped (widget) ||
!gdk_surface_is_viewable (gtk_native_get_surface (native)))
if (!_gtk_widget_is_sensitive (widget) ||
!_gtk_widget_get_mapped (widget))
{
g_object_unref (shortcut);
continue;
}
data = g_new0 (ShortcutData, 1);
native = gtk_widget_get_native (widget);
if (!native ||
!gdk_surface_is_viewable(gtk_native_get_surface (native)))
{
g_object_unref (shortcut);
continue;
}
if (G_UNLIKELY (!shortcuts))
{
shortcuts = g_array_sized_new (FALSE, TRUE, sizeof (ShortcutData), 8);
g_array_set_clear_func (shortcuts, shortcut_data_free);
}
g_array_set_size (shortcuts, shortcuts->len + 1);
data = &g_array_index (shortcuts, ShortcutData, shortcuts->len - 1);
data->shortcut = shortcut;
data->index = index;
data->widget = widget;
shortcuts = g_slist_append (shortcuts, data);
}
for (l = shortcuts; l; l = l->next)
if (!shortcuts)
return retval;
for (i = shortcuts->len - 1, p = shortcuts->len; i >= 0; i--)
{
ShortcutData *data = l->data;
const ShortcutData *data = &g_array_index (shortcuts, ShortcutData, i);
if (gtk_shortcut_action_activate (gtk_shortcut_get_action (data->shortcut),
shortcuts->next == NULL ? GTK_SHORTCUT_ACTION_EXCLUSIVE : 0,
i == p - 1 ? GTK_SHORTCUT_ACTION_EXCLUSIVE : 0,
data->widget,
gtk_shortcut_get_arguments (data->shortcut)))
{
@ -376,7 +388,7 @@ gtk_shortcut_controller_run_controllers (GtkEventController *controller,
}
}
g_slist_free_full (shortcuts, shortcut_data_free);
g_array_free (shortcuts, TRUE);
return retval;
}

View File

@ -113,16 +113,16 @@ gtk_shortcut_manager_default_remove_controller (GtkShortcutManager *self,
if (model)
{
GListModel *store;
guint position;
guint position, len;
store = gtk_flatten_list_model_get_model (model);
store = gtk_flatten_list_model_get_model (model);
#if 0 && GLIB_CHECK_VERSION(2,64,0)
if (_g_list_store_find (G_LIST_STORE (store), controller, &position))
g_list_store_remove (G_LIST_STORE (store), position);
#else
for (position = 0; position < g_list_model_get_n_items (G_LIST_MODEL (store)); position++)
for (position = 0, len = g_list_model_get_n_items (store); position < len; position++)
{
GtkShortcutController *item = g_list_model_get_item (G_LIST_MODEL (store), position);
GtkShortcutController *item = g_list_model_get_item (store, position);
g_object_unref (item);
if (item == controller)
{

View File

@ -781,34 +781,6 @@ gtk_style_context_has_class (GtkStyleContext *context,
return gtk_css_node_has_class (priv->cssnode, class_quark);
}
/**
* gtk_style_context_list_classes:
* @context: a #GtkStyleContext
*
* Returns the list of classes currently defined in @context.
*
* Returns: (transfer container) (element-type utf8): a #GList of
* strings with the currently defined classes. The contents
* of the list are owned by GTK+, but you must free the list
* itself with g_list_free() when you are done with it.
**/
GList *
gtk_style_context_list_classes (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
GList *classes_list = NULL;
const GQuark *classes;
guint n_classes, i;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
classes = gtk_css_node_list_classes (priv->cssnode, &n_classes);
for (i = n_classes; i > 0; i--)
classes_list = g_list_prepend (classes_list, (gchar *)g_quark_to_string (classes[i - 1]));
return classes_list;
}
GtkCssValue *
_gtk_style_context_peek_property (GtkStyleContext *context,
guint property_id)

View File

@ -865,9 +865,6 @@ void gtk_style_context_set_scale (GtkStyleContext *context,
GDK_AVAILABLE_IN_ALL
gint gtk_style_context_get_scale (GtkStyleContext *context);
GDK_AVAILABLE_IN_ALL
GList * gtk_style_context_list_classes (GtkStyleContext *context);
GDK_AVAILABLE_IN_ALL
void gtk_style_context_add_class (GtkStyleContext *context,
const gchar *class_name);

View File

@ -437,21 +437,31 @@ gtk_text_child_anchor_finalize (GObject *obj)
*
* Returns: (element-type GtkWidget) (transfer container): list of widgets anchored at @anchor
**/
GList*
gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor)
GtkWidget **
gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor,
guint *out_len)
{
GtkTextLineSegment *seg = anchor->segment;
GList *list = NULL;
GPtrArray *arr;
GSList *iter;
CHECK_IN_BUFFER_RETURN (anchor, NULL);
g_return_val_if_fail (out_len != NULL, NULL);
g_return_val_if_fail (seg->type == &gtk_text_child_type, NULL);
iter = seg->body.child.widgets;
if (!iter)
{
*out_len = 0;
return NULL;
}
arr = g_ptr_array_new ();
while (iter != NULL)
{
list = g_list_prepend (list, iter->data);
g_ptr_array_add (arr, iter->data);
iter = iter->next;
}
@ -459,7 +469,8 @@ gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor)
/* Order is not relevant, so we don't need to reverse the list
* again.
*/
return list;
*out_len = arr->len;
return (GtkWidget **)g_ptr_array_free (arr, FALSE);
}
/**

View File

@ -31,6 +31,7 @@
#include <gdk/gdk.h>
#include <glib-object.h>
#include <gtkwidget.h>
G_BEGIN_DECLS
@ -78,7 +79,8 @@ GDK_AVAILABLE_IN_ALL
GtkTextChildAnchor* gtk_text_child_anchor_new (void);
GDK_AVAILABLE_IN_ALL
GList* gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor);
GtkWidget ** gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor,
guint *out_len);
GDK_AVAILABLE_IN_ALL
gboolean gtk_text_child_anchor_get_deleted (GtkTextChildAnchor *anchor);

View File

@ -2010,8 +2010,9 @@ allocate_child_widgets (GtkTextLayout *text_layout,
gint byte_index;
GtkTextIter text_iter;
GtkTextChildAnchor *anchor = NULL;
GList *widgets = NULL;
GList *l;
GtkWidget **widgets = NULL;
guint n_widgets = 0;
guint i;
/* The pango iterator iterates in visual order.
* We use the byte index to find the child widget.
@ -2019,13 +2020,13 @@ allocate_child_widgets (GtkTextLayout *text_layout,
byte_index = pango_layout_iter_get_index (run_iter);
line_display_index_to_iter (text_layout, display, &text_iter, byte_index, 0);
anchor = gtk_text_iter_get_child_anchor (&text_iter);
if (anchor)
widgets = gtk_text_child_anchor_get_widgets (anchor);
if (anchor)
widgets = gtk_text_child_anchor_get_widgets (anchor, &n_widgets);
for (l = widgets; l; l = l->next)
for (i = 0; i < n_widgets; i++)
{
GtkWidget *child = widgets[i];
PangoRectangle extents;
GtkWidget *child = l->data;
if (_gtk_anchored_child_get_layout (child) == text_layout)
{
@ -2047,7 +2048,7 @@ allocate_child_widgets (GtkTextLayout *text_layout,
}
}
g_list_free (widgets);
g_free (widgets);
}
}
while (pango_layout_iter_next_run (run_iter));

View File

@ -818,11 +818,14 @@ gtk_widget_real_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
int i;
for (l = g_list_last (priv->event_controllers); l; l = l->prev)
if (!priv->controllers)
return;
for (i = (int)priv->controllers->len - 1; i >= 0; i--)
{
GtkEventController *controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
GdkDevice *device = NULL;
if (GTK_IS_GESTURE (controller))
@ -839,14 +842,19 @@ static void
gtk_widget_real_root (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
guint i;
gtk_widget_forall (widget, (GtkCallback) gtk_widget_root, NULL);
for (l = priv->event_controllers; l; l = l->next)
if (!priv->controllers)
return;
for (i = 0; i < priv->controllers->len; i++)
{
if (GTK_IS_SHORTCUT_CONTROLLER (l->data))
gtk_shortcut_controller_root (GTK_SHORTCUT_CONTROLLER (l->data));
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (GTK_IS_SHORTCUT_CONTROLLER (controller))
gtk_shortcut_controller_root (GTK_SHORTCUT_CONTROLLER (controller));
}
}
@ -854,12 +862,17 @@ static void
gtk_widget_real_unroot (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
guint i;
for (l = priv->event_controllers; l; l = l->next)
if (priv->controllers)
{
if (GTK_IS_SHORTCUT_CONTROLLER (l->data))
gtk_shortcut_controller_unroot (GTK_SHORTCUT_CONTROLLER (l->data));
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (GTK_IS_SHORTCUT_CONTROLLER (controller))
gtk_shortcut_controller_unroot (GTK_SHORTCUT_CONTROLLER (controller));
}
}
gtk_widget_forall (widget, (GtkCallback) gtk_widget_unroot, NULL);
@ -2056,13 +2069,15 @@ _gtk_widget_get_last_event (GtkWidget *widget,
GtkWidget **target)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkEventController *controller;
GdkEvent *event;
GList *l;
guint i;
for (l = priv->event_controllers; l; l = l->next)
if (!priv->controllers)
goto out;
for (i = 0; i < priv->controllers->len; i++)
{
controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (!GTK_IS_GESTURE (controller))
continue;
@ -2075,6 +2090,7 @@ _gtk_widget_get_last_event (GtkWidget *widget,
}
}
out:
*target = NULL;
return NULL;
}
@ -2085,7 +2101,6 @@ _gtk_widget_get_emulating_sequence (GtkWidget *widget,
GdkEventSequence **sequence_out)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
*sequence_out = sequence;
@ -2103,12 +2118,13 @@ _gtk_widget_get_emulating_sequence (GtkWidget *widget,
gdk_touch_event_get_emulating_pointer (last_event))
return TRUE;
}
else
else if (priv->controllers)
{
guint i;
/* For a NULL(pointer) sequence, find the pointer emulating one */
for (l = priv->event_controllers; l; l = l->next)
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (!GTK_IS_GESTURE (controller))
continue;
@ -2128,14 +2144,17 @@ gtk_widget_needs_press_emulation (GtkWidget *widget,
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
gboolean sequence_press_handled = FALSE;
GList *l;
guint i;
if (!priv->controllers)
return FALSE;
/* Check whether there is any remaining gesture in
* the capture phase that handled the press event
*/
for (l = priv->event_controllers; l; l = l->next)
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
GtkPropagationPhase phase;
GtkGesture *gesture;
@ -2165,11 +2184,13 @@ _gtk_widget_set_sequence_state_internal (GtkWidget *widget,
gboolean emulates_pointer, sequence_handled = FALSE;
GdkEvent *mimic_event;
GtkWidget *target;
GList *group = NULL, *l;
GList *group = NULL;
GdkEventSequence *seq;
gint n_handled = 0;
guint i;
if (!priv->event_controllers && state != GTK_EVENT_SEQUENCE_CLAIMED)
if (state != GTK_EVENT_SEQUENCE_CLAIMED &&
(!priv->controllers || priv->controllers->len == 0))
return TRUE;
if (emitter)
@ -2178,15 +2199,14 @@ _gtk_widget_set_sequence_state_internal (GtkWidget *widget,
emulates_pointer = _gtk_widget_get_emulating_sequence (widget, sequence, &seq);
mimic_event = _gtk_widget_get_last_event (widget, seq, &target);
for (l = priv->event_controllers; l; l = l->next)
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
GtkEventSequenceState gesture_state;
GtkEventController *controller;
GtkGesture *gesture;
gboolean retval;
seq = sequence;
controller = l->data;
gesture_state = state;
if (!GTK_IS_GESTURE (controller))
@ -2254,17 +2274,19 @@ _gtk_widget_cancel_sequence (GtkWidget *widget,
gboolean emulates_pointer;
gboolean handled = FALSE;
GdkEventSequence *seq;
GList *l;
guint i;
if (!priv->controllers)
return FALSE;
emulates_pointer = _gtk_widget_get_emulating_sequence (widget, sequence, &seq);
for (l = priv->event_controllers; l; l = l->next)
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
GtkGesture *gesture;
seq = sequence;
controller = l->data;
if (!GTK_IS_GESTURE (controller))
continue;
@ -3461,41 +3483,41 @@ gtk_widget_realize (GtkWidget *widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!_gtk_widget_get_realized (widget))
if (priv->realized)
return;
gtk_widget_push_verify_invariants (widget);
/*
if (GTK_IS_CONTAINER (widget) && _gtk_widget_get_has_surface (widget))
g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
*/
if (priv->parent == NULL && !GTK_IS_ROOT (widget))
g_warning ("Calling gtk_widget_realize() on a widget that isn't "
"inside a toplevel window is not going to work very well. "
"Widgets must be inside a toplevel container before realizing them.");
if (priv->parent && !_gtk_widget_get_realized (priv->parent))
gtk_widget_realize (priv->parent);
g_signal_emit (widget, widget_signals[REALIZE], 0);
if (priv->multidevice)
{
gtk_widget_push_verify_invariants (widget);
GdkSurface *surface = gtk_widget_get_surface (widget);
/*
if (GTK_IS_CONTAINER (widget) && _gtk_widget_get_has_surface (widget))
g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
*/
if (priv->parent == NULL && !GTK_IS_ROOT (widget))
g_warning ("Calling gtk_widget_realize() on a widget that isn't "
"inside a toplevel window is not going to work very well. "
"Widgets must be inside a toplevel container before realizing them.");
if (priv->parent && !_gtk_widget_get_realized (priv->parent))
gtk_widget_realize (priv->parent);
g_signal_emit (widget, widget_signals[REALIZE], 0);
if (priv->multidevice)
{
GdkSurface *surface = gtk_widget_get_surface (widget);
gdk_surface_set_support_multidevice (surface, TRUE);
}
gtk_widget_update_alpha (widget);
if (priv->context)
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
else
gtk_widget_get_style_context (widget);
gtk_widget_pop_verify_invariants (widget);
gdk_surface_set_support_multidevice (surface, TRUE);
}
gtk_widget_update_alpha (widget);
if (priv->context)
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
else
gtk_widget_get_style_context (widget);
gtk_widget_pop_verify_invariants (widget);
}
/**
@ -4492,25 +4514,25 @@ gtk_widget_run_controllers (GtkWidget *widget,
GtkPropagationPhase phase)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkEventController *controller;
gboolean handled = FALSE;
GList *l;
guint i;
if (!priv->controllers)
return FALSE;
g_object_ref (widget);
l = priv->event_controllers;
while (l != NULL)
for (i = 0; i < priv->controllers->len; i++)
{
GList *next = l->next;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (!WIDGET_REALIZED_FOR_EVENT (widget, event))
break;
controller = l->data;
if (controller == NULL)
{
priv->event_controllers = g_list_delete_link (priv->event_controllers, l);
g_ptr_array_remove_index (priv->controllers, i);
i--; /* Need to check this index again */
}
else
{
@ -4536,8 +4558,6 @@ gtk_widget_run_controllers (GtkWidget *widget,
break;
}
}
l = next;
}
g_object_unref (widget);
@ -4552,14 +4572,16 @@ gtk_widget_handle_crossing (GtkWidget *widget,
double y)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
guint i;
if (!priv->controllers)
return;
g_object_ref (widget);
for (l = priv->event_controllers; l; l = l->next)
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
gtk_event_controller_handle_crossing (controller, crossing, x, y);
}
@ -5710,7 +5732,7 @@ gtk_widget_set_sensitive (GtkWidget *widget,
gboolean sensitive)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
guint i;
g_return_if_fail (GTK_IS_WIDGET (widget));
@ -5721,11 +5743,14 @@ gtk_widget_set_sensitive (GtkWidget *widget,
priv->sensitive = sensitive;
for (l = priv->event_controllers; l; l = l->next)
if (priv->controllers)
{
GtkEventController *controller = l->data;
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
gtk_event_controller_reset (controller);
gtk_event_controller_reset (controller);
}
}
if (priv->parent == NULL
@ -6026,7 +6051,7 @@ gtk_widget_get_native (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return GTK_NATIVE (gtk_widget_get_ancestor (widget, GTK_TYPE_NATIVE));
return (GtkNative *)gtk_widget_get_ancestor (widget, GTK_TYPE_NATIVE);
}
static void
@ -7358,12 +7383,19 @@ gtk_widget_real_destroy (GtkWidget *object)
destroy_surface_transform_data (widget);
}
static void
gtk_widget_unset_controller (GtkWidget *widget,
GtkEventController *controller)
{
GTK_EVENT_CONTROLLER_GET_CLASS (controller)->unset_widget (controller);
g_object_unref (controller);
}
static void
gtk_widget_finalize (GObject *object)
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
gtk_grab_remove (widget);
@ -7380,18 +7412,17 @@ gtk_widget_finalize (GObject *object)
_gtk_size_request_cache_free (&priv->requests);
l = priv->event_controllers;
while (l)
if (priv->controllers)
{
GList *next = l->next;
GtkEventController *controller = l->data;
guint i;
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (controller)
gtk_widget_remove_controller (widget, controller);
l = next;
gtk_widget_unset_controller (widget, controller);
}
g_ptr_array_free (priv->controllers, TRUE);
}
g_assert (priv->event_controllers == NULL);
if (_gtk_widget_get_first_child (widget) != NULL)
{
@ -7788,7 +7819,6 @@ gtk_widget_propagate_state (GtkWidget *widget,
if (!gtk_widget_is_sensitive (widget))
gtk_widget_reset_controllers (widget);
/* Make sure to only propagate the right states further */
child_data.old_scale_factor = new_scale_factor;
child_data.flags_to_set = data->flags_to_set & GTK_STATE_FLAGS_DO_SET_PROPAGATE;
@ -10439,7 +10469,7 @@ gtk_widget_set_alloc_needed (GtkWidget *widget)
if (!priv->visible)
break;
if (GTK_IS_ROOT (widget))
if (!priv->parent && GTK_IS_ROOT (widget))
{
gtk_root_start_layout (GTK_ROOT (widget));
break;
@ -11384,7 +11414,10 @@ gtk_widget_add_controller (GtkWidget *widget,
GTK_EVENT_CONTROLLER_GET_CLASS (controller)->set_widget (controller, widget);
priv->event_controllers = g_list_prepend (priv->event_controllers, controller);
if (G_UNLIKELY (!priv->controllers))
priv->controllers = g_ptr_array_new ();
g_ptr_array_add (priv->controllers, controller);
if (priv->controller_observer)
gtk_list_list_model_item_added_at (priv->controller_observer, 0);
@ -11406,21 +11439,28 @@ gtk_widget_remove_controller (GtkWidget *widget,
GtkEventController *controller)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *before, *list;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_IS_EVENT_CONTROLLER (controller));
g_return_if_fail (gtk_event_controller_get_widget (controller) == widget);
GTK_EVENT_CONTROLLER_GET_CLASS (controller)->unset_widget (controller);
list = g_list_find (priv->event_controllers, controller);
before = list->prev;
priv->event_controllers = g_list_delete_link (priv->event_controllers, list);
g_object_unref (controller);
if (priv->controller_observer)
gtk_list_list_model_item_removed (priv->controller_observer, before);
{
/* Here we care about the index */
guint index;
g_ptr_array_find (priv->controllers, controller, &index);
gtk_list_list_model_item_removed_at (priv->controller_observer, index);
g_ptr_array_remove_index_fast (priv->controllers, index);
}
else
{
/* XXX _fast really possible? */
g_ptr_array_remove_fast (priv->controllers, controller);
}
gtk_widget_unset_controller (widget, controller);
}
gboolean
@ -11431,11 +11471,14 @@ _gtk_widget_consumes_motion (GtkWidget *widget,
while (widget != NULL && !GTK_IS_WINDOW (widget))
{
GList *l;
guint i;
for (l = priv->event_controllers; l; l = l->next)
if (!priv->controllers)
goto next;
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (controller == NULL ||
!GTK_IS_GESTURE (controller))
@ -11448,6 +11491,7 @@ _gtk_widget_consumes_motion (GtkWidget *widget,
return TRUE;
}
next:
widget = priv->parent;
priv = gtk_widget_get_instance_private (widget);
}
@ -11459,12 +11503,15 @@ void
gtk_widget_reset_controllers (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
guint i;
if (!priv->controllers)
return;
/* Reset all controllers */
for (l = priv->event_controllers; l; l = l->next)
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (controller == NULL)
continue;
@ -11480,13 +11527,13 @@ gtk_widget_list_controllers (GtkWidget *widget,
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GPtrArray *controllers = g_ptr_array_new ();
GList *l;
guint i;
g_assert (out_n_controllers);
for (l = priv->event_controllers; l; l = l->next)
for (i = 0; i < priv->controllers->len; i++)
{
GtkEventController *controller = l->data;
GtkEventController *controller = g_ptr_array_index (priv->controllers, i);
if (gtk_event_controller_get_propagation_phase (controller) == phase)
g_ptr_array_add (controllers, controller);
@ -11723,28 +11770,49 @@ gtk_widget_controller_observer_destroyed (gpointer widget)
static gpointer
gtk_widget_controller_list_get_first (gpointer widget)
{
return GTK_WIDGET (widget)->priv->event_controllers;
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
if (priv->controllers)
return g_ptr_array_index (priv->controllers, 0);
return NULL;
}
static gpointer
gtk_widget_controller_list_get_next (gpointer item,
gpointer widget)
{
return g_list_next (item);
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
guint index;
g_ptr_array_find (priv->controllers, item, &index);
if (index + 1 <= priv->controllers->len - 1)
return g_ptr_array_index (priv->controllers, index + 1);
return NULL;
}
static gpointer
gtk_widget_controller_list_get_prev (gpointer item,
gpointer widget)
{
return g_list_previous (item);
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
guint index;
g_ptr_array_find (priv->controllers, item, &index);
if (index >= 0)
return g_ptr_array_index (priv->controllers, index - 1);
return NULL;
}
static gpointer
gtk_widget_controller_list_get_item (gpointer item,
gpointer widget)
{
return g_object_ref (((GList *) item)->data);
return item;
}
/**

View File

@ -174,7 +174,7 @@ struct _GtkWidgetPrivate
GSList *paintables;
GList *event_controllers;
GPtrArray *controllers;
AtkObject *accessible;

View File

@ -5247,35 +5247,6 @@ surface_event (GdkSurface *surface,
return TRUE;
}
/* the accel_key and accel_mods fields of the key have to be setup
* upon calling this function. itll then return whether that key
* is at all used as accelerator, and if so will OR in the
* accel_flags member of the key.
*/
gboolean
_gtk_window_query_nonaccels (GtkWindow *window,
guint accel_key,
GdkModifierType accel_mods)
{
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
/* movement keys are considered locked accels */
if (!accel_mods)
{
static const guint bindings[] = {
GDK_KEY_space, GDK_KEY_KP_Space, GDK_KEY_Return, GDK_KEY_ISO_Enter, GDK_KEY_KP_Enter, GDK_KEY_Up, GDK_KEY_KP_Up, GDK_KEY_Down, GDK_KEY_KP_Down,
GDK_KEY_Left, GDK_KEY_KP_Left, GDK_KEY_Right, GDK_KEY_KP_Right, GDK_KEY_Tab, GDK_KEY_KP_Tab, GDK_KEY_ISO_Left_Tab,
};
guint i;
for (i = 0; i < G_N_ELEMENTS (bindings); i++)
if (bindings[i] == accel_key)
return TRUE;
}
return FALSE;
}
static GtkWindowRegion
get_active_region_type (GtkWindow *window, gint x, gint y)
{

View File

@ -64,10 +64,6 @@ gboolean gtk_window_configure (GtkWindow *window,
guint height);
/* --- internal (GtkAcceleratable) --- */
gboolean _gtk_window_query_nonaccels (GtkWindow *window,
guint accel_key,
GdkModifierType accel_mods);
void _gtk_window_schedule_mnemonics_visible (GtkWindow *window);
void _gtk_window_notify_keys_changed (GtkWindow *window);

View File

@ -180,19 +180,15 @@
<object class="GtkStackPage">
<property name="name">browse</property>
<property name="child">
<object class="GtkFrame">
<object class="GtkScrolledWindow">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkScrolledWindow">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<object class="GtkViewport">
<child>
<object class="GtkViewport">
<child>
<object class="GtkListBox" id="listbox">
<property name="selection-mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated" object="GtkPlacesView" swapped="yes"/>
</object>
</child>
<object class="GtkListBox" id="listbox">
<property name="selection-mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated" object="GtkPlacesView" swapped="yes"/>
</object>
</child>
</object>