/* This is a flag to speed up development builds. We set it to TRUE when *anyofthedebugdisplayshasdebugflags>0,butweneversetitback *toFALSE.Thiswaywedon'tneedtocallgtk_widget_get_display()in *hotpaths.
*/
gboolean any_display_debug_flags_set = FALSE;
GtkDebugFlags
gtk_get_display_debug_flags (GdkDisplay *display)
{ int i;
if (display == NULL)
display = gdk_display_get_default ();
for (i = 0; i < N_DEBUG_DISPLAYS; i++)
{ if (debug_flags[i].display == display) return (GtkDebugFlags)debug_flags[i].flags;
}
staticconst GdkDebugKey gtk_debug_keys[] = {
{ "keybindings", GTK_DEBUG_KEYBINDINGS, "Information about keyboard shortcuts" },
{ "modules", GTK_DEBUG_MODULES, "Information about modules and extensions" },
{ "icontheme", GTK_DEBUG_ICONTHEME, "Information about icon themes" },
{ "printing", GTK_DEBUG_PRINTING, "Information about printing" },
{ "geometry", GTK_DEBUG_GEOMETRY, "Information about size allocation" },
{ "size-request", GTK_DEBUG_SIZE_REQUEST, "Information about size requests" },
{ "actions", GTK_DEBUG_ACTIONS, "Information about actions and menu models" },
{ "constraints", GTK_DEBUG_CONSTRAINTS, "Information from the constraints solver" },
{ "text", GTK_DEBUG_TEXT, "Information about GtkTextView" },
{ "tree", GTK_DEBUG_TREE, "Information about GtkTreeView" },
{ "layout", GTK_DEBUG_LAYOUT, "Information from layout managers" },
{ "builder-trace", GTK_DEBUG_BUILDER_TRACE, "Trace GtkBuilder operation" },
{ "builder-objects", GTK_DEBUG_BUILDER_OBJECTS, "Log unused GtkBuilder objects" },
{ "no-css-cache", GTK_DEBUG_NO_CSS_CACHE, "Disable style property cache" },
{ "interactive", GTK_DEBUG_INTERACTIVE, "Enable the GTK inspector" },
{ "touch-ui", GTK_DEBUG_TOUCHSCREEN, "Show touch ui elements for pointer events" },
{ "snapshot", GTK_DEBUG_SNAPSHOT, "Generate debug render nodes" },
{ "accessibility", GTK_DEBUG_A11Y, "Information about accessibility state changes" },
{ "iconfallback", GTK_DEBUG_ICONFALLBACK, "Information about icon fallback" },
{ "invert-text-dir", GTK_DEBUG_INVERT_TEXT_DIR, "Invert the default text direction" },
{ "css", GTK_DEBUG_CSS, "Information about deprecated CSS features" },
{ "builder", GTK_DEBUG_BUILDER, "Information about deprecated GtkBuilder features" },
{ "session-mgmt", GTK_DEBUG_SESSION, "Information about session saving" },
{ "general-info", GTK_DEBUG_GENERAL_INFO, "General information (in markdown)" },
};
/* This checks to see if the process is running suid or sgid *atthecurrenttime.Ifso,wedon’tallowGTKtobeinitialized. *Thisismeanttobeamildcheck-weonlyerroroutifwe *canprovetheprogrammerisdoingsomethingwrong,notif *theycouldbedoingsomethingwrong.Forthisreason,we *don’tuseissetugid()onBSDorprctl(PR_GET_DUMPABLE).
*/ static gboolean
check_setugid (void)
{ /* this isn't at all relevant on MS Windows and doesn't compile ... --hb */ #ifndef G_OS_WIN32
uid_t ruid, euid, suid; /* Real, effective and saved user ID's */
gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */
if (ruid != euid || ruid != suid ||
rgid != egid || rgid != sgid)
{
g_warning ("This process is currently running setuid or setgid.\n" "This is not a supported use of GTK. You must create a helper\n" "program instead. For further details, see:\n\n" " http://www.gtk.org/setuid.html\n\n" "Refusing to initialize GTK."); exit (1);
} #endif returnTRUE;
}
static gboolean do_setlocale = TRUE;
/** *gtk_disable_setlocale: * *Prevents[func@Gtk.init]and[func@Gtk.init_check]fromcalling`setlocale()`. * *Youwouldwanttousethisfunctionifyouwantedtosetthelocalefor *yourprogramtosomethingotherthantheuser’slocale,orifyouwanted *tosetdifferentvaluesfordifferentlocalecategories. * *Mostprogramsshouldnotneedtocallthisfunction.
**/ void
gtk_disable_setlocale (void)
{ if (pre_initialized)
g_warning ("gtk_disable_setlocale() must be called before gtk_init()");
do_setlocale = FALSE;
}
/** *gtk_disable_portals: * *PreventsGTKfromusingportals. * *Thisisequivalenttosetting`GDK_DEBUG=no-portals`intheenvironment. * *Thisshouldonlybeusedinportalimplementations,appsmustnotcallit. * *Since:4.18
*/ void
gtk_disable_portals (void)
{ if (pre_initialized)
g_warning ("gtk_disable_portals() must be called before gtk_init()");
gdk_disable_all_portals ();
}
/** *gtk_disable_portal_interfaces: *@portal_interfaces:(arrayzero-terminated=1)(notnullable): *a%NULL-terminatedarrayofportalinterfacenamestodisable * *PreventsGTKfromusingthespecifiedportals. * *Thisshouldonlybeusedinportalimplementations,appsmustnotcallit. * *Since:4.22
*/ void
gtk_disable_portal_interfaces (constchar **portal_interfaces)
{ if (pre_initialized)
g_warning ("gtk_disable_portal_interfaces() must be called before gtk_init()");
if (script_to_check != NULL)
{ /* If lcid is the "other" script for this language, *returnTRUE,i.e.continuelooking.
*/ if (strcmp (script_to_check, "Latn") == 0)
{ switch (LANGIDFROMLCID (lcid))
{ case MAKELANGID (LANG_AZERI, SUBLANG_AZERI_CYRILLIC): returnTRUE; case MAKELANGID (LANG_UZBEK, SUBLANG_UZBEK_CYRILLIC): returnTRUE; case MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC): returnTRUE; case MAKELANGID (LANG_SERBIAN, 0x07): /* Serbian in Bosnia and Herzegovina, Cyrillic */ returnTRUE; default: break;
}
} elseif (strcmp (script_to_check, "Cyrl") == 0)
{ switch (LANGIDFROMLCID (lcid))
{ case MAKELANGID (LANG_AZERI, SUBLANG_AZERI_LATIN): returnTRUE; case MAKELANGID (LANG_UZBEK, SUBLANG_UZBEK_LATIN): returnTRUE; case MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_LATIN): returnTRUE; case MAKELANGID (LANG_SERBIAN, 0x06): /* Serbian in Bosnia and Herzegovina, Latin */ returnTRUE; default: break;
}
}
}
if (do_setlocale)
{ #ifdef G_OS_WIN32 /* If some of the POSIXish environment variables are set, set *theWin32threadlocalecorrespondingly.
*/ char *p = getenv ("LC_ALL"); if (p == NULL)
p = getenv ("LANG");
if (p != NULL)
{
p = g_strdup (p); if (strcmp (p, "C") == 0)
SetThreadLocale (LOCALE_SYSTEM_DEFAULT); else
{ /* Check if one of the supported locales match the *environmentvariable.Ifso,usethatlocale.
*/
iso639_to_check = p;
iso3166_to_check = strchr (iso639_to_check, '_'); if (iso3166_to_check != NULL)
{
*iso3166_to_check++ = '\0';
if (g_module_symbol (module, "gtk_progress_get_type", &func))
result = TRUE; elseif (g_module_symbol (module, "gtk_misc_get_type", &func))
result = TRUE; else
result = FALSE;
debug_flags[0].flags = gdk_parse_debug_var ("GTK_DEBUG", "GTK_DEBUG can be set to values that make GTK print out different\n" "types of debugging information or change the behavior of GTK for\n" "debugging purposes.\n",
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
any_display_debug_flags_set = debug_flags[0].flags > 0;
/* We always allow inverting the text direction, even in *productionbuilds,asSDK/IDEtoolingmayprovidethe *abilityfordeveloperstotestrtl/ltrinverted.
*/ if (gtk_get_debug_flags () & GTK_DEBUG_INVERT_TEXT_DIR)
text_dir = (text_dir == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
/* This is relevant when building with gcc for Windows (MinGW), *wherewewanttobestructpackingcompatiblewithMSVC, *i.e.usethe-mms-bitfieldsswitch. *ForCygwinthereshouldbenoneedtobecompatiblewithMSVC, *sononeedtouseG_PLATFORM_WIN32.
*/
staticvoid
check_sizeof_GtkWindow (size_t sizeof_GtkWindow)
{ if (sizeof_GtkWindow != sizeof (GtkWindow))
g_error ("Incompatible build!\n" "The code using GTK thinks GtkWindow is of different\n" "size than it actually is in this build of GTK.\n" "On Windows, this probably means that you have compiled\n" "your code with gcc without the -mms-bitfields switch,\n" "or that you are using an unsupported compiler.");
}
/* In GTK 2.0 the GtkWindow struct actually is the same size in *gcc-compiledcodeonWin32whethercompiledwith-fnative-structor *not.Unfortunatelythiswasn’tnoticeduntilafterGTK2.0.1.So, *fromGTK2.0.2on,checksomeotherstruct,too,wheretheuseof *-fnative-structstillmatters.GtkBoxisonesuch.
*/ staticvoid
check_sizeof_GtkBox (size_t sizeof_GtkBox)
{ if (sizeof_GtkBox != sizeof (GtkBox))
g_error ("Incompatible build!\n" "The code using GTK thinks GtkBox is of different\n" "size than it actually is in this build of GTK.\n" "On Windows, this probably means that you have compiled\n" "your code with gcc without the -mms-bitfields switch,\n" "or that you are using an unsupported compiler.");
}
/* These two functions might get more checks added later, thus pass *inthenumberofextraargs.
*/ void
gtk_init_abi_check (int num_checks, size_t sizeof_GtkWindow, size_t sizeof_GtkBox)
{
check_sizeof_GtkWindow (sizeof_GtkWindow); if (num_checks >= 2)
check_sizeof_GtkBox (sizeof_GtkBox);
gtk_init ();
}
switch (hb_script_get_horizontal_direction (script))
{ case HB_DIRECTION_LTR: return GTK_TEXT_DIR_LTR; case HB_DIRECTION_RTL: return GTK_TEXT_DIR_RTL; case HB_DIRECTION_TTB: case HB_DIRECTION_BTT: case HB_DIRECTION_INVALID: default: break;
}
}
}
switch ((guint) type)
{ case GDK_BUTTON_PRESS: case GDK_BUTTON_RELEASE: return gdk_button_event_new (type,
new_surface,
gdk_event_get_device (event),
gdk_event_get_device_tool (event),
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
gdk_button_event_get_button (event),
x, y,
gdk_event_dup_axes (event)); case GDK_MOTION_NOTIFY: return gdk_motion_event_new (new_surface,
gdk_event_get_device (event),
gdk_event_get_device_tool (event),
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
x, y,
gdk_event_dup_axes (event)); case GDK_TOUCH_BEGIN: case GDK_TOUCH_UPDATE: case GDK_TOUCH_END: case GDK_TOUCH_CANCEL: return gdk_touch_event_new (type,
gdk_event_get_event_sequence (event),
new_surface,
gdk_event_get_device (event),
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
x, y,
gdk_event_dup_axes (event),
gdk_touch_event_get_emulating_pointer (event)); case GDK_TOUCHPAD_SWIPE:
gdk_touchpad_event_get_deltas (event, &dx, &dy); return gdk_touchpad_event_new_swipe (new_surface,
gdk_event_get_event_sequence (event),
gdk_event_get_device (event),
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
gdk_touchpad_event_get_gesture_phase (event),
x, y,
gdk_touchpad_event_get_n_fingers (event),
dx, dy); case GDK_TOUCHPAD_PINCH:
gdk_touchpad_event_get_deltas (event, &dx, &dy); return gdk_touchpad_event_new_pinch (new_surface,
gdk_event_get_event_sequence (event),
gdk_event_get_device (event),
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
gdk_touchpad_event_get_gesture_phase (event),
x, y,
gdk_touchpad_event_get_n_fingers (event),
dx, dy,
gdk_touchpad_event_get_pinch_scale (event),
gdk_touchpad_event_get_pinch_angle_delta (event)); case GDK_TOUCHPAD_HOLD: return gdk_touchpad_event_new_hold (new_surface,
gdk_event_get_event_sequence (event),
gdk_event_get_device (event),
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
gdk_touchpad_event_get_gesture_phase (event),
x, y,
gdk_touchpad_event_get_n_fingers (event)); default: break;
}
return NULL;
}
/* If there is a seat grab in effect what GDK does is deliver the event normally *ifitwasgoingtothisclient,otherwise,deliversitintermsofthegrab *surface. * *Thisfunctionrewriteseventstotheeffectthateventsgoingtothesame *windowgrouparedeliverednormally,otherwise,theeventisdeliveredin *termsofthegrabsurface.
*/ static GdkEvent *
rewrite_event_for_grabs (GdkEvent *event)
{
GdkSurface *grab_surface;
GtkWidget *event_widget, *grab_widget;
GdkSeat *seat;
switch ((guint) gdk_event_get_event_type (event))
{ case GDK_SCROLL: case GDK_BUTTON_PRESS: case GDK_BUTTON_RELEASE: case GDK_MOTION_NOTIFY: case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: case GDK_KEY_PRESS: case GDK_KEY_RELEASE: case GDK_TOUCH_BEGIN: case GDK_TOUCH_UPDATE: case GDK_TOUCH_END: case GDK_TOUCH_CANCEL: case GDK_TOUCHPAD_SWIPE: case GDK_TOUCHPAD_PINCH: case GDK_TOUCHPAD_HOLD:
seat = gdk_event_get_seat (event);
grab_surface = gdk_seat_get_topmost_grab_surface (seat);
if (!grab_surface) return NULL; break; default: return NULL;
}
static gboolean
is_pointing_event (GdkEvent *event)
{ switch ((guint) gdk_event_get_event_type (event))
{ case GDK_MOTION_NOTIFY: case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: case GDK_BUTTON_PRESS: case GDK_BUTTON_RELEASE: case GDK_SCROLL: case GDK_TOUCH_BEGIN: case GDK_TOUCH_UPDATE: case GDK_TOUCH_END: case GDK_TOUCH_CANCEL: case GDK_TOUCHPAD_PINCH: case GDK_TOUCHPAD_SWIPE: case GDK_TOUCHPAD_HOLD: case GDK_DRAG_ENTER: case GDK_DRAG_LEAVE: case GDK_DRAG_MOTION: case GDK_DROP_START: returnTRUE;
case GDK_GRAB_BROKEN: return gdk_device_get_source (gdk_event_get_device (event)) != GDK_SOURCE_KEYBOARD;
default: returnFALSE;
}
}
static gboolean
is_key_event (GdkEvent *event)
{ switch ((guint) gdk_event_get_event_type (event))
{ case GDK_KEY_PRESS: case GDK_KEY_RELEASE: returnTRUE; break; case GDK_GRAB_BROKEN: return gdk_device_get_source (gdk_event_get_device (event)) == GDK_SOURCE_KEYBOARD; default: returnFALSE;
}
}
gtk_native_get_surface_transform (GTK_NATIVE (native), &native_x, &native_y);
x -= native_x;
y -= native_y;
type = gdk_event_get_event_type (event);
sequence = gdk_event_get_event_sequence (event);
if (type == GDK_SCROLL && !gdk_event_get_device_tool (event))
{ /* A bit of a kludge, resolve target lookups for scrolling devices *ontheseatpointer.
*/
device = gdk_seat_get_pointer (gdk_event_get_seat (event));
} elseif (type == GDK_TOUCHPAD_PINCH ||
type == GDK_TOUCHPAD_SWIPE ||
type == GDK_TOUCHPAD_HOLD)
{ /* Another bit of a kludge, touchpad gesture sequences do not *reflectonthepointerfocuslookup.
*/
sequence = NULL;
}
switch ((guint) type)
{ case GDK_LEAVE_NOTIFY: if (gdk_crossing_event_get_mode (event) == GDK_CROSSING_GRAB)
{
GtkWidget *grab_widget;
/* Let it take the effective pointer focus anyway, as it may change due *toimplicitgrabs.
*/
target = NULL; break; case GDK_BUTTON_PRESS: case GDK_BUTTON_RELEASE:
target = gtk_window_lookup_effective_pointer_focus_widget (toplevel,
device,
sequence);
has_implicit =
gtk_window_lookup_pointer_focus_implicit_grab (toplevel,
device,
sequence) != NULL;
modifiers = gdk_event_get_modifier_state (event);
if (gtk_inspector_handle_event (event)) returnFALSE;
/* Find the widget which got the event. We store the widget *intheuser_datafieldofGdkSurface's.Ignoretheevent *ifwedon'thaveawidgetforit.
*/
event_widget = gtk_get_event_widget (event); if (!event_widget) returnFALSE;
target_widget = event_widget;
/* We propagate key events from the root, even if they are *deliveredtoapopupsurface. * *Ifpointerorkeyboardgrabsareineffect,mungetheevents *sothateachwindowgrouplookslikeaseparateapp.
*/ if (is_key_event (event))
rewritten_event = rewrite_event_for_toplevel (event); else
rewritten_event = rewrite_event_for_grabs (event); if (rewritten_event)
{
event = rewritten_event;
target_widget = gtk_get_event_widget (event);
}
/* Push the event onto a stack of current events for *gtk_current_event_get().
*/
current_events = g_list_prepend (current_events, event);
case GDK_KEY_PRESS: case GDK_KEY_RELEASE: case GDK_SCROLL: case GDK_BUTTON_PRESS: case GDK_TOUCH_BEGIN: case GDK_MOTION_NOTIFY: case GDK_BUTTON_RELEASE: case GDK_PROXIMITY_IN: case GDK_PROXIMITY_OUT: case GDK_TOUCH_UPDATE: case GDK_TOUCH_END: case GDK_TOUCH_CANCEL: case GDK_TOUCHPAD_SWIPE: case GDK_TOUCHPAD_PINCH: case GDK_TOUCHPAD_HOLD: case GDK_PAD_BUTTON_PRESS: case GDK_PAD_BUTTON_RELEASE: case GDK_PAD_RING: case GDK_PAD_STRIP: case GDK_PAD_DIAL: case GDK_PAD_GROUP_MODE: case GDK_GRAB_BROKEN:
handled_event = gtk_propagate_event (grab_widget, event); break;
case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: case GDK_DRAG_ENTER: case GDK_DRAG_LEAVE: /* Crossing event propagation happens during picking */
handled_event = TRUE; break;
/* If not yet handled, also propagate back up */ if (!handled_event)
{ /* Propagate event up the widget tree so that *parentscanseethebuttonandmotion *eventsofthechildren.
*/ for (i = 0; i < gtk_widget_stack_get_size (&widget_array); i++)
{
widget = gtk_widget_stack_get (&widget_array, i);
/* Scroll events are special cased here because it *feelswrongwhenscrollingaGtkViewport,say, *tohavechildrenoftheviewporteatthescroll *event
*/ if (!_gtk_widget_is_sensitive (widget))
handled_event = gdk_event_get_event_type (event) != GDK_SCROLL; elseif (_gtk_widget_get_realized (widget))
handled_event = gtk_widget_event (widget, event, target);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.