forked from AuroraMiddleware/gtk
inspector: Allow picking insensitive widgets
The default gtk_widget_contains/gtk_widget_pick don't consider insensitive widgets.
This commit is contained in:
parent
2dca8f935c
commit
8224e7ac72
@ -648,10 +648,6 @@ static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor);
|
||||
static gboolean gtk_widget_real_can_activate_accel (GtkWidget *widget,
|
||||
guint signal_id);
|
||||
|
||||
static void gtk_widget_get_origin_relative_to_parent(GtkWidget *widget,
|
||||
int *origin_x,
|
||||
int *origin_y);
|
||||
|
||||
static void gtk_widget_real_set_has_tooltip (GtkWidget *widget,
|
||||
gboolean has_tooltip,
|
||||
gboolean force);
|
||||
@ -4830,7 +4826,7 @@ gtk_widget_common_ancestor (GtkWidget *widget_a,
|
||||
return widget_a;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
gtk_widget_get_origin_relative_to_parent (GtkWidget *widget,
|
||||
int *origin_x,
|
||||
int *origin_y)
|
||||
|
@ -332,6 +332,12 @@ gboolean gtk_widget_emit_event_signals (GtkWidget *widg
|
||||
|
||||
void gtk_widget_init_legacy_controller (GtkWidget *widget);
|
||||
|
||||
void gtk_widget_get_origin_relative_to_parent (GtkWidget *widget,
|
||||
int *origin_x,
|
||||
int *origin_y);
|
||||
|
||||
|
||||
|
||||
|
||||
/* inline getters */
|
||||
|
||||
|
@ -30,6 +30,51 @@
|
||||
#include "gtkstack.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkinvisible.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
static gboolean
|
||||
inspector_contains (GtkWidget *widget,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
|
||||
if (!gtk_widget_is_drawable (widget))
|
||||
return FALSE;
|
||||
|
||||
return GTK_WIDGET_GET_CLASS (widget)->contains (widget, x, y);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
inspector_pick (GtkWidget *widget,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
/* Like gtk_widget_pick and gtk_widget_contains,
|
||||
* but we need to consider insensitive widgets as well. */
|
||||
GtkWidget *child;
|
||||
|
||||
for (child = _gtk_widget_get_last_child (widget);
|
||||
child;
|
||||
child = _gtk_widget_get_prev_sibling (child))
|
||||
{
|
||||
GtkWidget *picked;
|
||||
int dx, dy;
|
||||
|
||||
gtk_widget_get_origin_relative_to_parent (child, &dx, &dy);
|
||||
|
||||
picked = inspector_pick (child, x - dx, y - dy);
|
||||
if (picked)
|
||||
return picked;
|
||||
}
|
||||
|
||||
|
||||
if (!inspector_contains (widget, x, y))
|
||||
return NULL;
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
find_widget_at_pointer (GdkDevice *device)
|
||||
@ -73,7 +118,7 @@ find_widget_at_pointer (GdkDevice *device)
|
||||
gdk_window_get_device_position_double (gtk_widget_get_window (widget),
|
||||
device, &x, &y, NULL);
|
||||
|
||||
widget = gtk_widget_pick (widget, x, y);
|
||||
widget = inspector_pick (widget, x, y);
|
||||
}
|
||||
|
||||
return widget;
|
||||
|
Loading…
Reference in New Issue
Block a user