gtk/gdk
Sergey Bugaev 964affb1cc Stop using enums in bitfields
The C standard does not specify whether the underlying type of an enum
is signed or unsigned, and until C23 there was no way to control this
explicitly. GCC appears to make enums unsigned unless there is a
negative value among cases of the enum, in which case it becomes signed.
MSCV appears to make enums signed by default.

A bitfield of an enum type (which is not specificied in the C standard
either) behaves as if it was an instance of a numeric type with a
reduced value range. Specifically, a 'signed int val : 2;' bitfield will
have the possible values of -2, -1, 0, and 1, with the usual wraparound
behavior for the values that don't fit (although this too is
implementation-defined).

This causes the following issue, if we have:

typedef enum
{
  GTK_ZERO,
  GTK_ONE,
  GTK_TWO
} GtkFoo;

struct _GtkBar
{
  GtkFoo foo : 2;
};

and then assign bar.foo = GTK_TWO and read it back, it will have the
expected value of 2 (aka GTK_TWO) on GCC, but a value of -2 (not
matching any of the enum variants) on MSVC.

There does not seem to be any way to influence signedness of an enum
prior to C23, nor is there a 'unsigned GtkFoo foo : 2;' syntax. The only
remaining options seems to be never using enums in bitfields, which is
what this change implements.

In practice, this fixes GdkPipeIOStream crashing with an assertion when
trying to copy-paste in-app in MSVC builds on GTK.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-10 11:23:08 +03:00
..
broadway gdk: Replace prefers_high_depth with depth 2023-06-18 14:28:39 +02:00
deprecated gdk: Fix up introspection build 2023-05-21 09:46:49 -04:00
loaders gdk: Add A16_FLOAT and A32_FLOAT formats 2023-07-22 01:33:44 +02:00
macos macOS: Clamp damage region to surface size 2023-09-13 17:13:33 +02:00
version Use #pragma once 2023-05-09 16:43:35 +01:00
wayland gdk/wayland: Use toplevel surface for activation 2023-09-18 22:04:32 +02:00
win32 Merge branch '5724_gdk_win32_ignore_invalid_client_rect' into 'main' 2023-10-04 07:58:55 +00:00
x11 gdk/x11/clipboard: Fix Slist leak 2023-08-21 20:32:42 +03:00
COPYING
default_cursor.png docs: Update cursor images 2023-09-21 19:51:11 +02:00
filetransferportal.c filetransfer: Be more careful around files 2023-01-30 14:03:13 -05:00
filetransferportalprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdk.c Improve FOO_DEBUG=help output 2023-09-24 08:33:22 -04:00
gdk.h gdk: Deprecated some pixbuf apis 2023-05-15 18:22:37 -04:00
gdkapplaunchcontext.c Drop gdkintl.h 2022-09-23 23:33:42 -04:00
gdkapplaunchcontext.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkapplaunchcontextprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkarrayimpl.c Merge branch 'wip/chergert/fix-gdkarrayimpl-from-c++' into 'main' 2023-09-26 18:48:02 +00:00
gdkcairo.c gdk: Drop some unused private api 2023-05-15 20:30:38 -04:00
gdkcairo.h gdk: Deprecated some pixbuf apis 2023-05-15 18:22:37 -04:00
gdkcairocontext.c gdk: Remove gdkinternals.h 2021-09-24 22:50:29 +02:00
gdkcairocontext.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkcairocontextprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkclipboard.c docs: Drop uneeded ` in gi-docgen links 2023-08-12 22:26:25 +02:00
gdkclipboard.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkclipboardprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkconfig.h.meson gdk: Cosmetics 2022-10-05 23:01:28 -04:00
gdkconfig.h.win32 Use a single compilation symbol 2019-11-27 13:33:43 +00:00
gdkconfig.h.win32_vulkan Use a single compilation symbol 2019-11-27 13:33:43 +00:00
gdkconstructorprivate.h Rename gdkconstructor.h to gdkconstructorprivate.h 2022-09-23 23:14:08 -04:00
gdkcontentdeserializer.c gdk: Stop using g_slice 2023-03-14 14:56:42 -04:00
gdkcontentdeserializer.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkcontentformats.c gdk: Fix an oversight in GdkContentFormats 2023-06-09 08:17:34 -04:00
gdkcontentformats.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkcontentformatsprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkcontentprovider.c Drop gdkintl.h 2022-09-23 23:33:42 -04:00
gdkcontentprovider.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkcontentproviderimpl.c Drop gdkintl.h 2022-09-23 23:33:42 -04:00
gdkcontentproviderimpl.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkcontentproviderprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkcontentserializer.c gdk: Deprecated some pixbuf apis 2023-05-15 18:22:37 -04:00
gdkcontentserializer.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkcursor.c Drop gdkintl.h 2022-09-23 23:33:42 -04:00
gdkcursor.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkcursorprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdebugprivate.h gdk: Add GDK_DEBUG=no-vsync 2023-05-09 16:29:41 +02:00
gdkdevice.c Fix spelling errors 2022-11-17 22:49:45 -05:00
gdkdevice.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdevicepad.c gdk: Clean up docs syntax 2021-05-22 17:25:26 -04:00
gdkdevicepad.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdevicepadprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdeviceprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdevicetool.c Various spelling mistakes across a few domains that show up in documentation. 2022-12-08 12:16:22 +00:00
gdkdevicetool.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdevicetoolprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdisplay.c Fix documentation of gdk_display_put_event() 2023-09-13 08:19:11 -05:00
gdkdisplay.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdisplaymanager.c Avoid a bad warning 2023-05-01 10:40:26 -04:00
gdkdisplaymanager.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdisplaymanagerprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdisplayprivate.h vulkan: Store shaders in the display 2023-07-16 12:12:36 +02:00
gdkdrag.c Drop gdkintl.h 2022-09-23 23:33:42 -04:00
gdkdrag.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdragprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdragsurface.c Remove wrong annotation from GdkDragSurface::compute-size 2023-03-26 15:50:22 +01:00
gdkdragsurface.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdragsurfaceprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkdragsurfacesize.c g-i: Add since annotation to GdkSurfaceSize 2023-03-20 08:14:25 +00:00
gdkdragsurfacesize.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdragsurfacesizeprivate.h Add GdkDragSurfaceSize 2023-03-14 19:41:44 -07:00
gdkdrawcontext.c gdk: Replace prefers_high_depth with depth 2023-06-18 14:28:39 +02:00
gdkdrawcontext.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdrawcontextprivate.h gdk: Replace prefers_high_depth with depth 2023-06-18 14:28:39 +02:00
gdkdrop.c gdk: Stop using g_slice 2023-03-14 14:56:42 -04:00
gdkdrop.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkdropprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkenums.h gdk: Add A16_FLOAT and A32_FLOAT formats 2023-07-22 01:33:44 +02:00
gdkevents.c docs: Add another cross reference 2023-03-25 15:06:19 -04:00
gdkevents.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkeventsprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkframeclock.c frameclock: Keep more history 2023-05-09 16:29:41 +02:00
gdkframeclock.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkframeclockidle.c gdk: Add GDK_DEBUG=no-vsync 2023-05-09 16:29:41 +02:00
gdkframeclockidleprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkframeclockprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkframetimings.c gdk: Stop using g_slice 2023-03-14 14:56:42 -04:00
gdkframetimings.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkgl.c gdk: Remove unused gdk_gl_texture_quads() function 2021-10-06 03:44:36 +02:00
gdkglcontext.c glcontext: Add gdk_gl_context_get_glsl_version_string() 2023-09-26 11:08:59 +02:00
gdkglcontext.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkglcontextprivate.h glcontext: Add gdk_gl_context_get_glsl_version_string() 2023-09-26 11:08:59 +02:00
gdkglobals.c gdk: Remove gdkinternals.h 2021-09-24 22:50:29 +02:00
gdkgltexture.c gltexture: Restore previous GL context 2023-08-24 05:00:29 +02:00
gdkgltexture.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkgltexturebuilder.c gltexturebuilder: Update the docs 2023-05-31 14:39:07 -04:00
gdkgltexturebuilder.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkgltextureprivate.h gltexture: Optionally take a sync object 2023-04-27 06:55:37 +02:00
gdkglversionprivate.h gdk: Add workaround for Visual Studio 2023-04-27 02:13:33 +02:00
gdkhsla.c gdk_rgba_parse: Support HSL colors 2021-09-10 16:56:42 -05:00
gdkhslaprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkkeys.c gdk: Tweaks to keyname handling 2022-09-24 10:03:37 -04:00
gdkkeys.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkkeysprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkkeysyms-update.pl Update the link to the development branch 2022-01-13 14:42:34 +00:00
gdkkeysyms.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkkeyuni.c gdk: Update keyboard symbols from libxkbcommon 2022-01-29 14:31:09 +02:00
gdkmarshalers.list surface: add missing va_marshaller for layout signal 2021-12-07 22:21:19 -08:00
gdkmemoryformat.c gl: Pass swizzle array directly 2023-08-12 23:13:23 +02:00
gdkmemoryformatprivate.h gl: Pass swizzle array directly 2023-08-12 23:13:23 +02:00
gdkmemorytexture.c memorytexture: Add a check 2023-07-31 16:51:03 +02:00
gdkmemorytexture.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkmemorytextureprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkmonitor.c Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkmonitor.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkmonitorprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkpaintable.c gdk: Fix compiler warning 2023-09-26 11:08:59 +02:00
gdkpaintable.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkpango.c Drop gdkintl.h 2022-09-23 23:33:42 -04:00
gdkpango.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkpipeiostream.c Stop using enums in bitfields 2023-10-10 11:23:08 +03:00
gdkpipeiostreamprivate.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkpopup.c docs: Fix various broken links 2023-03-27 21:29:08 +02:00
gdkpopup.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkpopuplayout.c Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkpopuplayout.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkpopupprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkprivate.h gdk: Drop unnecessary conditionals 2023-07-20 15:18:13 -04:00
gdkprofiler.c Drop the gdk/gdkversionmacros.h header 2023-05-09 16:43:35 +01:00
gdkprofilerprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkrectangle.c gdk: Clean up docs syntax 2021-05-22 17:25:26 -04:00
gdkrectangle.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkrectangleprivate.h wayland: Use wl_surface_damage_buffer() in Cairo 2023-04-29 05:07:03 +02:00
gdkrgba.c docs: add HSL to Gdk.RGBA.parse 2023-05-25 17:16:55 +02:00
gdkrgba.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkrgbaprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkseat.c Drop gdkintl.h 2022-09-23 23:33:42 -04:00
gdkseat.h gdk: Include pads in GDK_SEAT_CAPABILITY_ALL 2023-06-14 01:42:53 +02:00
gdkseatdefault.c gdk/x11: Implement XI2.4 touchpad gesture support 2021-09-27 23:19:33 +03:00
gdkseatdefaultprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdkseatprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdksnapshot.c docs: Rework the gdk docs 2021-03-11 16:37:31 +00:00
gdksnapshot.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdksnapshotprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdksurface.c Merge branch 'master' into 'main' 2023-09-30 15:03:33 +00:00
gdksurface.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdksurfaceprivate.h display: Remove ::create_surface() vfunc 2023-04-26 21:03:34 +02:00
gdktexture.c docs: Clarify the behaviour of gdk_texture_new_for_surface() 2023-09-26 12:57:52 +01:00
gdktexture.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdktexturedownloader.c Cosmetics 2023-05-15 15:25:11 -04:00
gdktexturedownloader.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdktexturedownloaderprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdktextureprivate.h texture: Add gdk_texture_diff() 2023-05-01 22:24:14 +02:00
gdktoplevel.c gdk: Change the private export handle api 2023-05-14 23:49:44 -04:00
gdktoplevel.h gtk: Add suspended window state 2023-07-30 11:40:09 +03:00
gdktoplevellayout.c gdk: Clean up docs syntax 2021-05-22 17:25:26 -04:00
gdktoplevellayout.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdktoplevelprivate.h gdk: Change the private export handle api 2023-05-14 23:49:44 -04:00
gdktoplevelsize.c toplevel-size: Report zero bounds as infinite 2022-09-30 09:31:40 +02:00
gdktoplevelsize.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdktoplevelsizeprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gdktypes.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkvulkancontext.c vulkan: Require Vulkan 1.2 2023-09-15 16:34:00 +02:00
gdkvulkancontext.h Minimize the amount of inclusions in public headers 2023-05-09 17:36:59 +01:00
gdkvulkancontextprivate.h vulkan: Store shaders in the display 2023-07-16 12:12:36 +02:00
gen-gdk-gresources-xml.py gdk: Remove unused gdk_gl_texture_quads() function 2021-10-06 03:44:36 +02:00
gen-keyname-table.pl gdk: Tweaks to keyname handling 2022-09-24 10:03:37 -04:00
keynames-translate.txt gdk: Translate some more key names 2017-10-09 20:33:14 +02:00
keynames.txt
keynamesprivate.h gdk: Tweaks to keyname handling 2022-09-24 10:03:37 -04:00
meson.build gdk: Deprecated some pixbuf apis 2023-05-15 18:22:37 -04:00